[libvirt] [PATCH] storage: fix device detach regression with cgroup ACLs

Eric Blake eblake at redhat.com
Tue Nov 27 14:04:50 UTC 2012


Commit 38c4a9cc introduced a regression in hot unplugging of disks
from qemu, where cgroup device ACLs were no longer being revoked
(thankfully not a security hole: cgroup ACLs only prevent open()
of the disk; so reverting the ACL prevents future abuse but doesn't
stop abuse from an fd that was already opened before the ACL change).

The actual regression is due to a latent bug.  The hot unplug code
was computing the set of files to do cgroup ACL revocation based
on the XML passed in by the user, rather than based on the domain's
details on which disk was being deleted.  As long as the revoke
path was always recomputing the backing chain, this didn't really
matter; but now that we want to compute the chain exactly once and
remember that computation, we need to hang on to the backing chain
until after the revoke has happened.

* src/qemu/qemu_hotplug.c (qemuDomainDetachPciDiskDevice):
Transfer backing chain before deletion.

The patch is deceptively small for how long it took me to figure out
why we had a regression :)

 src/qemu/qemu_hotplug.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ae8381e..0bc2259 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1999,6 +1999,8 @@ int qemuDomainDetachPciDiskDevice(struct qemud_driver *driver,

     virDomainDiskRemove(vm->def, i);

+    dev->data.disk->backingChain = detach->backingChain;
+    detach->backingChain = NULL;

     if (virSecurityManagerRestoreImageLabel(driver->securityManager,

More information about the libvir-list mailing list