[libvirt] [PATCH] qemu: blockjob: Call qemuDomainSupportsBlockJobs only on online VMs

Since the qemu capabilities are not initialized for offline VMs the caller might get suboptimal error message: $ virsh blockjob VM PATH --bandwidth 1 error: unsupported configuration: block jobs not supported with this QEMU binary Move the checks after we make sure that the VM is alive. --- src/qemu/qemu_driver.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3695b26..d6e7570 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16555,34 +16555,34 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, goto cleanup; } - if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain is not running")); + goto endjob; + } + + if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + goto endjob; + if (!modern) { if (base) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("partial block pull not supported with this " "QEMU binary")); - goto cleanup; + goto endjob; } if (bandwidth) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("setting bandwidth at start of block pull not " "supported with this QEMU binary")); - goto cleanup; + goto endjob; } } - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; - - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); - goto endjob; - } - if (!(device = qemuDiskPathToAlias(vm, path, &idx))) goto endjob; disk = vm->def->disks[idx]; @@ -16682,9 +16682,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom, if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) - goto cleanup; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; @@ -16694,6 +16691,9 @@ qemuDomainBlockJobAbort(virDomainPtr dom, goto endjob; } + if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + goto endjob; + if (!(device = qemuDiskPathToAlias(vm, path, &idx))) goto endjob; disk = vm->def->disks[idx]; @@ -16896,9 +16896,6 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, if (virDomainBlockJobSetSpeedEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) - goto cleanup; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; @@ -16908,6 +16905,9 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, goto endjob; } + if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + goto endjob; + if (!(device = qemuDiskPathToAlias(vm, path, NULL))) goto endjob; -- 2.3.5

On 04/30/2015 08:37 AM, Peter Krempa wrote:
Since the qemu capabilities are not initialized for offline VMs the caller might get suboptimal error message:
$ virsh blockjob VM PATH --bandwidth 1 error: unsupported configuration: block jobs not supported with this QEMU binary
Move the checks after we make sure that the VM is alive. --- src/qemu/qemu_driver.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
ACK; safe enough for freeze
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3695b26..d6e7570 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16555,34 +16555,34 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, goto cleanup; }
- if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup;
+ if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain is not running")); + goto endjob; + } + + if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + goto endjob; + if (!modern) { if (base) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("partial block pull not supported with this " "QEMU binary")); - goto cleanup; + goto endjob; }
if (bandwidth) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("setting bandwidth at start of block pull not " "supported with this QEMU binary")); - goto cleanup; + goto endjob; } }
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; - - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); - goto endjob; - } - if (!(device = qemuDiskPathToAlias(vm, path, &idx))) goto endjob; disk = vm->def->disks[idx]; @@ -16682,9 +16682,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom, if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) goto cleanup;
- if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) - goto cleanup; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup;
@@ -16694,6 +16691,9 @@ qemuDomainBlockJobAbort(virDomainPtr dom, goto endjob; }
+ if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + goto endjob; + if (!(device = qemuDiskPathToAlias(vm, path, &idx))) goto endjob; disk = vm->def->disks[idx]; @@ -16896,9 +16896,6 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, if (virDomainBlockJobSetSpeedEnsureACL(dom->conn, vm->def) < 0) goto cleanup;
- if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) - goto cleanup; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup;
@@ -16908,6 +16905,9 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, goto endjob; }
+ if (qemuDomainSupportsBlockJobs(vm, &modern) < 0) + goto endjob; + if (!(device = qemuDiskPathToAlias(vm, path, NULL))) goto endjob;
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Thu, Apr 30, 2015 at 08:40:56 -0600, Eric Blake wrote:
On 04/30/2015 08:37 AM, Peter Krempa wrote:
Since the qemu capabilities are not initialized for offline VMs the caller might get suboptimal error message:
$ virsh blockjob VM PATH --bandwidth 1 error: unsupported configuration: block jobs not supported with this QEMU binary
Move the checks after we make sure that the VM is alive. --- src/qemu/qemu_driver.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
ACK; safe enough for freeze
Now pushed; Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa