diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 83a5a3f7c33907e075267931bbd0dd56aa9a6160..4ada4cd277d420e0f84095e3ce4360336b3ffc6c 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -33,6 +33,7 @@ #include "virstoragefile.h" #include "virthread.h" #include "virtime.h" +#include "locking/domain_lock.h" #define VIR_FROM_THIS VIR_FROM_QEMU @@ -139,17 +140,19 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver, } } - /* XXX We want to revoke security labels and disk - * lease, as well as audit that revocation, before - * dropping the original source. But it gets tricky - * if both source and mirror share common backing - * files (we want to only revoke the non-shared - * portion of the chain); so for now, we leak the - * access to the original. */ + /* XXX We want to revoke security labels as well as audit that + * revocation, before dropping the original source. But it gets + * tricky if both source and mirror share common backing files (we + * want to only revoke the non-shared portion of the chain); so for + * now, we leak the access to the original. */ + virDomainLockImageDetach(driver->lockManager, vm, disk->src); virStorageSourceFree(disk->src); disk->src = disk->mirror; } else { - virStorageSourceFree(disk->mirror); + if (disk->mirror) { + virDomainLockImageDetach(driver->lockManager, vm, disk->mirror); + virStorageSourceFree(disk->mirror); + } } /* Recompute the cached backing chain to match our @@ -172,8 +175,11 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver, case VIR_DOMAIN_BLOCK_JOB_FAILED: case VIR_DOMAIN_BLOCK_JOB_CANCELED: - virStorageSourceFree(disk->mirror); - disk->mirror = NULL; + if (disk->mirror) { + virDomainLockImageDetach(driver->lockManager, vm, disk->mirror); + virStorageSourceFree(disk->mirror); + disk->mirror = NULL; + } disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; save = true; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index da49088bd007a2903a8aeacf2b064e8f76287707..42f9889651096dbe657990622a4989cea2c239eb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16244,9 +16244,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, if (disk->mirror->format && disk->mirror->format != VIR_STORAGE_FILE_RAW && - (virDomainLockDiskAttach(driver->lockManager, cfg->uri, vm, - disk) < 0 || - qemuDomainNamespaceSetupDisk(driver, vm, disk) < 0 || + (qemuDomainNamespaceSetupDisk(driver, vm, disk) < 0 || qemuSetupDiskCgroup(vm, disk) < 0 || qemuSecuritySetDiskLabel(driver, vm, disk) < 0)) goto cleanup;