The function can be replaced by much simpler logic. Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/qemu/qemu_hotplug.c | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9481123c19..96042bc06c 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3826,42 +3826,6 @@ static bool qemuIsMultiFunctionDevice(virDomainDefPtr def, } -static int -qemuDomainDiskNeedRemovePR(virDomainObjPtr vm, - virDomainDiskDefPtr disk, - bool *stopDaemon) -{ - qemuDomainObjPrivatePtr priv = vm->privateData; - size_t i; - - *stopDaemon = false; - - if (!disk->src->pr) - return 0; - - if (!virStoragePRDefIsManaged(disk->src->pr)) - return 0; - - for (i = 0; i < vm->def->ndisks; i++) { - const virDomainDiskDef *domainDisk = vm->def->disks[i]; - - if (domainDisk == disk) - continue; - - if (virStoragePRDefIsManaged(domainDisk->src->pr)) - break; - } - - if (i != vm->def->ndisks) - return 0; - - if (priv->prDaemonRunning) - *stopDaemon = true; - - return 0; -} - - static int qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3875,7 +3839,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, char *drivestr; char *objAlias = NULL; char *encAlias = NULL; - bool stopPRDaemon = false; VIR_DEBUG("Removing disk %s from domain %p %s", disk->info.alias, vm, vm->def->name); @@ -3913,9 +3876,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } - if (qemuDomainDiskNeedRemovePR(vm, disk, &stopPRDaemon) < 0) - return -1; - qemuDomainObjEnterMonitor(driver, vm); qemuMonitorDriveDel(priv->mon, drivestr); @@ -3953,7 +3913,9 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } - if (stopPRDaemon) + /* check if the last disk with managed PR was just removed */ + if (priv->prDaemonRunning && + !virDomainDefHasManagedPR(vm->def)) qemuProcessKillManagedPRDaemon(vm); qemuDomainReleaseDeviceAddress(vm, &disk->info, src); -- 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list