From: Michal Privoznik Date: Mon, 16 Sep 2019 10:28:48 +0000 (+0200) Subject: qemu_blockjob: Remove secdriver metadata for whole backing chain on job completion X-Git-Tag: v5.8.0-rc1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70d353356d25a0ea6b2681ef5996ef71fac11813;p=thirdparty%2Flibvirt.git qemu_blockjob: Remove secdriver metadata for whole backing chain on job completion Turns out, block mirror is not the only job a disk can have. It can also do commits of one layer into the other. Or possibly some other tricks too. Problem is that while we set seclabels on given layers of backing chain when the job is starting (via qemuDomainStorageSourceAccessAllow()) we don't restore them when job finishes. This leaves XATTRs set and corresponding images unusable. Signed-off-by: Michal Privoznik ACKed-by: Peter Krempa --- diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 80d0269128..c118f2c298 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -664,9 +664,9 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPtr driver, virObjectUnref(disk->src); disk->src = disk->mirror; } else { - if (disk->mirror) { - virStorageSourcePtr n; + virStorageSourcePtr n; + if (disk->mirror) { virDomainLockImageDetach(driver->lockManager, vm, disk->mirror); /* Ideally, we would restore seclabels on the backing chain here @@ -684,6 +684,16 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPtr driver, virObjectUnref(disk->mirror); } + + for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) { + if (qemuSecurityMoveImageMetadata(driver, vm, n, NULL) < 0) { + VIR_WARN("Unable to remove disk metadata on " + "vm %s from %s (disk target %s)", + vm->def->name, + NULLSTR(n->path), + disk->dst); + } + } } /* Recompute the cached backing chain to match our