[libvirt] [PATCH 9/9] qemu: Always reset @info in qemuDomainGetJobInfo

Peter Krempa posted 9 patches 6 years, 2 months ago
[libvirt] [PATCH 9/9] qemu: Always reset @info in qemuDomainGetJobInfo
Posted by Peter Krempa 6 years, 2 months ago
qemuDomainGetJobInfo didn't always reset the return data in @info.
Thankfully this wouldn't be a problem as the RPC layer does it but we
should do it anyways.

Since we reset the struct we don't have to set the type to
VIR_DOMAIN_JOB_NONE is as the value is 0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5d6a82bc13..112d7a6861 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13920,6 +13920,8 @@ qemuDomainGetJobInfo(virDomainPtr dom,
     virDomainObjPtr vm;
     int ret = -1;

+    memset(info, 0, sizeof(*info));
+
     if (!(vm = qemuDomainObjFromDomain(dom)))
         goto cleanup;

@@ -13930,8 +13932,6 @@ qemuDomainGetJobInfo(virDomainPtr dom,
         goto cleanup;

     if (jobInfo.status == QEMU_DOMAIN_JOB_STATUS_NONE) {
-        memset(info, 0, sizeof(*info));
-        info->type = VIR_DOMAIN_JOB_NONE;
         ret = 0;
         goto cleanup;
     }
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 9/9] qemu: Always reset @info in qemuDomainGetJobInfo
Posted by Eric Blake 6 years, 2 months ago
On 11/25/19 9:01 AM, Peter Krempa wrote:
> qemuDomainGetJobInfo didn't always reset the return data in @info.
> Thankfully this wouldn't be a problem as the RPC layer does it but we
> should do it anyways.
> 
> Since we reset the struct we don't have to set the type to
> VIR_DOMAIN_JOB_NONE is as the value is 0.

s/is as/as/

> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/qemu/qemu_driver.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list