[libvirt] [PATCH v2 2/4] qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks

Peter Krempa pkrempa at redhat.com
Tue Dec 2 13:09:53 UTC 2014


On 12/01/14 15:57, Michal Privoznik wrote:
> The function queries the block devices visible to qemu
> ('query-block') and parses the qemu's output. The info is
> returned in a hash table which is expected to be pre-filled by
> qemuMonitorJSONGetAllBlockStatsInfo(). However, in the next patch
> we are not going to call the latter function at all, so we should
> make the former function add devices into the hash table if not
> found there.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_monitor_json.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 6e251b3..da80505 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -1889,9 +1889,15 @@ int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
>          if (STRPREFIX(dev_name, QEMU_DRIVE_HOST_PREFIX))
>              dev_name += strlen(QEMU_DRIVE_HOST_PREFIX);
>  
> -        /* ignore missing info */
> -        if (!(bstats = virHashLookup(stats, dev_name)))
> -            continue;
> +        if (!(bstats = virHashLookup(stats, dev_name))) {
> +            if (VIR_ALLOC(bstats) < 0)
> +                goto cleanup;
> +
> +            if (virHashAddEntry(stats, dev_name, bstats) < 0) {
> +                VIR_FREE(bstats);
> +                goto cleanup;
> +            }
> +        }

Move this section ...

>  
>          /* drive may be empty */
>          if (!(inserted = virJSONValueObjectGet(dev, "inserted")) ||
> 

after this piece. If the media isn't inserted, there's no need to alloc
the field.

ACK with that change.

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141202/f27e6ebb/attachment-0001.sig>


More information about the libvir-list mailing list