diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 08b04067002c9625898cbbb2088d9e744a4ba092..5682695ae036dce60e04fd8396f761f5f1f958d1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -377,7 +377,7 @@ qemuDomainMaybeStartPRDaemon(virDomainObjPtr vm, /* @disk requires qemu-pr-helper but none is running. * Start it now. */ - if (qemuProcessStartPRDaemon(vm, disk) < 0) + if (qemuProcessStartManagedPRDaemon(vm) < 0) return -1; return 1; @@ -567,7 +567,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, qemuDomainDelDiskSrcTLSObject(driver, vm, disk->src); ignore_value(qemuHotplugPrepareDiskAccess(driver, vm, disk, NULL, true)); if (prdStarted) - qemuProcessKillPRDaemon(vm); + qemuProcessKillManagedPRDaemon(vm); goto cleanup; } @@ -3963,7 +3963,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } if (stopPRDaemon) - qemuProcessKillPRDaemon(vm); + qemuProcessKillManagedPRDaemon(vm); qemuDomainReleaseDeviceAddress(vm, &disk->info, src); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 42b91b39acc3693eef9b377a27cfa958d3d37743..af29bcc59ee819199c55b71e9a0ebfae30927658 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2566,7 +2566,7 @@ qemuProcessBuildPRHelperPidfilePath(virDomainObjPtr vm) void -qemuProcessKillPRDaemon(virDomainObjPtr vm) +qemuProcessKillManagedPRDaemon(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virErrorPtr orig_err; @@ -2624,8 +2624,7 @@ qemuProcessStartPRDaemonHook(void *opaque) int -qemuProcessStartPRDaemon(virDomainObjPtr vm, - const virDomainDiskDef *disk) +qemuProcessStartManagedPRDaemon(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virQEMUDriverPtr driver = priv->driver; @@ -2640,10 +2639,6 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, const unsigned long long timeout = 500000; /* ms */ int ret = -1; - if (!virStoragePRDefIsManaged(disk->src->pr) || - priv->prDaemonRunning) - return 0; - cfg = virQEMUDriverGetConfig(driver); if (!virFileIsExecutable(cfg->prHelperName)) { @@ -2734,7 +2729,7 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, goto cleanup; priv->prDaemonRunning = true; - ret = 1; + ret = 0; cleanup: if (ret < 0) { virCommandAbort(cmd); @@ -2754,22 +2749,22 @@ qemuProcessStartPRDaemon(virDomainObjPtr vm, static int -qemuProcessMaybeStartPRDaemon(virDomainObjPtr vm) +qemuProcessMaybeStartManagedPRDaemon(virDomainObjPtr vm) { + bool hasManaged = false; size_t i; - int rv; for (i = 0; i < vm->def->ndisks; i++) { - const virDomainDiskDef *disk = vm->def->disks[i]; - - if ((rv = qemuProcessStartPRDaemon(vm, disk)) < 0) - return -1; - - if (rv > 0) - return 1; + if (virStoragePRDefIsManaged(vm->def->disks[i]->src->pr)) { + hasManaged = true; + break; + } } - return 0; + if (!hasManaged) + return 0; + + return qemuProcessStartManagedPRDaemon(vm); } @@ -6289,8 +6284,8 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessResctrlCreate(driver, vm) < 0) goto cleanup; - VIR_DEBUG("Setting up PR daemon"); - if (qemuProcessMaybeStartPRDaemon(vm) < 0) + VIR_DEBUG("Setting up managed PR daemon"); + if (qemuProcessMaybeStartManagedPRDaemon(vm) < 0) goto cleanup; VIR_DEBUG("Setting domain security labels"); @@ -6821,7 +6816,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, qemuDomainMasterKeyRemove(priv); /* Do this before we delete the tree and remove pidfile. */ - qemuProcessKillPRDaemon(vm); + qemuProcessKillManagedPRDaemon(vm); virFileDeleteTree(priv->libDir); virFileDeleteTree(priv->channelTargetDir); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index eda66954152e83de24e5560ad305b8dba83904ea..a0e34b1c85da3635b4d4065c5106c1e70c47f4df 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -205,9 +205,8 @@ int qemuProcessRefreshDisks(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob); -int qemuProcessStartPRDaemon(virDomainObjPtr vm, - const virDomainDiskDef *disk); +int qemuProcessStartManagedPRDaemon(virDomainObjPtr vm); -void qemuProcessKillPRDaemon(virDomainObjPtr vm); +void qemuProcessKillManagedPRDaemon(virDomainObjPtr vm); #endif /* __QEMU_PROCESS_H__ */