Re: [PATCH v3 04/18] blockjob: split out block info monitor handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/30/2014 10:02 PM, Eric Blake wrote:
> Another layer of overly-multiplexed code that deserves to be
> split into obviously separate paths for query vs. modify.
> This continues the cleanup started in the previous patch.
> 
> In the process, make some tweaks to simplify the logic when
> parsing the JSON reply.  There should be no user-visible
> semantic changes.
> 

In addition to the ATTRIBUTE_NONNULL addition, I found a bug that needs
fixing:

> +int
> +qemuMonitorJSONBlockJobInfo(qemuMonitorPtr mon,
> +                            const char *device,
> +                            virDomainBlockJobInfoPtr info)
>  {
> +    virJSONValuePtr cmd = NULL;
> +    virJSONValuePtr reply = NULL;
>      virJSONValuePtr data;
>      int nr_results;
>      size_t i;
> +    int ret;
> 
> -    if (!info)
> +    cmd = qemuMonitorJSONMakeCommand("query-block-jobs", NULL);
> +    if (!cmd)
>          return -1;
> +    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
> +    if (ret < 0)
> +        goto cleanup;

If we haven't errored out yet, then ret is now 0...

> 
>      if ((data = virJSONValueObjectGet(reply, "return")) == NULL) {
>          virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                         _("reply was missing return data"));
> -        return -1;
> +        goto cleanup;

...and we have changed the return code from -1 to 0 here.  Oops.  I'm
squashing this in, before pushing:

diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
index 68ba084..2b58c78 100644
--- i/src/qemu/qemu_monitor_json.c
+++ w/src/qemu/qemu_monitor_json.c
@@ -3753,13 +3753,12 @@ qemuMonitorJSONBlockJobInfo(qemuMonitorPtr mon,
     virJSONValuePtr data;
     int nr_results;
     size_t i;
-    int ret;
+    int ret = -1;

     cmd = qemuMonitorJSONMakeCommand("query-block-jobs", NULL);
     if (!cmd)
         return -1;
-    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
-    if (ret < 0)
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
         goto cleanup;

     if ((data = virJSONValueObjectGet(reply, "return")) == NULL) {
@@ -3780,7 +3779,7 @@ qemuMonitorJSONBlockJobInfo(qemuMonitorPtr mon,
         goto cleanup;
     }

-    for (i = 0, ret = 0; i < nr_results && ret == 0; i++) {
+    for (i = ret = 0; i < nr_results && ret == 0; i++) {
         virJSONValuePtr entry = virJSONValueArrayGet(data, i);
         if (!entry) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]