[libvirt] [PATCH 0/3] qemu: fix setting of block job speed (blockdev-add sequels)

See patch 3. Peter Krempa (3): qemu: domain: Mention searched disk in error of qemuDomainDiskByName qemu: driver: Use qemuDomainDiskByName instead of virDomainDiskByName qemu: driver: Use appropriate job name when setting blockjob speed src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 20 ++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) -- 2.23.0

Mention the argument used if the disk can't be located. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 470d342afc..7e9b2db9eb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12491,8 +12491,8 @@ qemuDomainDiskByName(virDomainDefPtr def, virDomainDiskDefPtr ret; if (!(ret = virDomainDiskByName(def, name, true))) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("No device found for specified path")); + virReportError(VIR_ERR_INVALID_ARG, + _("disk '%s' not found in domain"), name); return NULL; } -- 2.23.0

Where appropriate replace the open coded call with the qemu wrapper which already reports the error. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bad2fb52f3..82f70465bc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11880,12 +11880,8 @@ qemuDomainBlockPeek(virDomainPtr dom, if (virDomainBlockPeekEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - /* Check the path belongs to this domain. */ - if (!(disk = virDomainDiskByName(vm->def, path, true))) { - virReportError(VIR_ERR_INVALID_ARG, - _("invalid disk or path '%s'"), path); + if (!(disk = qemuDomainDiskByName(vm->def, path))) goto cleanup; - } if (disk->src->format != VIR_STORAGE_FILE_RAW) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, @@ -17818,11 +17814,8 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto endjob; - if (!(disk = virDomainDiskByName(vm->def, path, true))) { - virReportError(VIR_ERR_INVALID_ARG, - _("disk %s not found in the domain"), path); + if (!(disk = qemuDomainDiskByName(vm->def, path))) goto endjob; - } if (!(job = qemuBlockJobDiskGetJob(disk))) { ret = 0; -- 2.23.0

qemuDomainBlockJobSetSpeed was not converted to get the job name from the block job data. This means that after enabling blockdev the API call would fail as we wouldn't use the appropriate name. https://bugzilla.redhat.com/show_bug.cgi?id=1780497 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_driver.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 82f70465bc..84c633aebf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17854,8 +17854,8 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, virDomainDiskDefPtr disk; int ret = -1; virDomainObjPtr vm; - g_autofree char *device = NULL; unsigned long long speed = bandwidth; + g_autoptr(qemuBlockJobData) job = NULL; virCheckFlags(VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES, -1); @@ -17885,12 +17885,15 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, if (!(disk = qemuDomainDiskByName(vm->def, path))) goto endjob; - if (!(device = qemuAliasDiskDriveFromDisk(disk))) + if (!(job = qemuBlockJobDiskGetJob(disk))) { + virReportError(VIR_ERR_INVALID_ARG, + _("disk %s does not have an active block job"), disk->dst); goto endjob; + } qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorBlockJobSetSpeed(qemuDomainGetMonitor(vm), - device, + job->name, speed); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret = -1; -- 2.23.0

On 12/6/19 9:07 AM, Peter Krempa wrote:
See patch 3.
Peter Krempa (3): qemu: domain: Mention searched disk in error of qemuDomainDiskByName qemu: driver: Use qemuDomainDiskByName instead of virDomainDiskByName qemu: driver: Use appropriate job name when setting blockjob speed
Series: Reviewed-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 20 ++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-)
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
participants (2)
-
Eric Blake
-
Peter Krempa