qemu: distinguish pr disk before qemuHotplugRemoveManagedPR

when a disk without PR perform attach or detach operation,
need not call qemuHotplugRemoveManagedPR, otherwise, it will
print err log about PR, let us fix it.

Signed-off-by: Jie Wang <wangjie88@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jie Wang 2019-06-18 21:28:26 +08:00 committed by Michal Privoznik
parent 3338c40b47
commit cf146eb042

View File

@ -694,7 +694,9 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -2;
if (qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
if (virStorageSourceChainHasManagedPR(disk->src) &&
qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
ret = -2;
virDomainAuditDisk(vm, NULL, disk->src, "attach", false);
@ -4266,7 +4268,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
dev.data.disk = disk;
ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
if (qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
if (virStorageSourceChainHasManagedPR(disk->src) &&
qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
goto cleanup;
ret = 0;