block-backend.c (4417ab7adf1613799054be5afedf810fc2524ee8) block-backend.c (cfa1a5723f0fc8eb6563fb1d19c206fd5e40cd41)
1/*
2 * QEMU Block backends
3 *
4 * Copyright (C) 2014-2016 Red Hat, Inc.
5 *
6 * Authors:
7 * Markus Armbruster <armbru@redhat.com>,
8 *

--- 142 unchanged lines hidden (view full) ---

151 blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);
152 if (local_err) {
153 error_propagate(errp, local_err);
154 blk->disable_perm = true;
155 return;
156 }
157}
158
1/*
2 * QEMU Block backends
3 *
4 * Copyright (C) 2014-2016 Red Hat, Inc.
5 *
6 * Authors:
7 * Markus Armbruster <armbru@redhat.com>,
8 *

--- 142 unchanged lines hidden (view full) ---

151 blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);
152 if (local_err) {
153 error_propagate(errp, local_err);
154 blk->disable_perm = true;
155 return;
156 }
157}
158
159static int blk_root_inactivate(BdrvChild *child)
160{
161 BlockBackend *blk = child->opaque;
162
163 if (blk->disable_perm) {
164 return 0;
165 }
166
167 /* Only inactivate BlockBackends for guest devices (which are inactive at
168 * this point because the VM is stopped) and unattached monitor-owned
169 * BlockBackends. If there is still any other user like a block job, then
170 * we simply can't inactivate the image. */
171 if (!blk->dev && !blk->name[0]) {
172 return -EPERM;
173 }
174
175 blk->disable_perm = true;
176 if (blk->root) {
177 bdrv_child_try_set_perm(blk->root, 0, BLK_PERM_ALL, &error_abort);
178 }
179
180 return 0;
181}
182
159static const BdrvChildRole child_root = {
160 .inherit_options = blk_root_inherit_options,
161
162 .change_media = blk_root_change_media,
163 .resize = blk_root_resize,
164 .get_name = blk_root_get_name,
165 .get_parent_desc = blk_root_get_parent_desc,
166
167 .drained_begin = blk_root_drained_begin,
168 .drained_end = blk_root_drained_end,
169
170 .activate = blk_root_activate,
183static const BdrvChildRole child_root = {
184 .inherit_options = blk_root_inherit_options,
185
186 .change_media = blk_root_change_media,
187 .resize = blk_root_resize,
188 .get_name = blk_root_get_name,
189 .get_parent_desc = blk_root_get_parent_desc,
190
191 .drained_begin = blk_root_drained_begin,
192 .drained_end = blk_root_drained_end,
193
194 .activate = blk_root_activate,
195 .inactivate = blk_root_inactivate,
171};
172
173/*
174 * Create a new BlockBackend with a reference count of one.
175 *
176 * @perm is a bitmasks of BLK_PERM_* constants which describes the permissions
177 * to request for a block driver node that is attached to this BlockBackend.
178 * @shared_perm is a bitmask which describes which permissions may be granted

--- 1771 unchanged lines hidden ---
196};
197
198/*
199 * Create a new BlockBackend with a reference count of one.
200 *
201 * @perm is a bitmasks of BLK_PERM_* constants which describes the permissions
202 * to request for a block driver node that is attached to this BlockBackend.
203 * @shared_perm is a bitmask which describes which permissions may be granted

--- 1771 unchanged lines hidden ---