Re: [PATCH 06/12] qemu: monitor: Convert common code to a macro

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

 



On Tue, Mar 10, 2015 at 05:26:35PM +0100, Peter Krempa wrote:
> The function that is extracting block stats data from the QMP monitor
> reply contains a lot of repeated code. Since I'd be changing each of the
> copies in the next patch, lets convert it to a macro right away.
> ---
>  src/qemu/qemu_monitor_json.c | 77 ++++++++++----------------------------------
>  1 file changed, 17 insertions(+), 60 deletions(-)
> 

> +#define QEMU_MONITOR_JSON_BLOCK_STAT(NAME, VAR, MANDATORY)                     \
> +    if (MANDATORY || virJSONValueObjectHasKey(stats, NAME)) {                  \
> +        if (virJSONValueObjectGetNumberLong(stats, NAME, &VAR) < 0) {          \
> +            virReportError(VIR_ERR_INTERNAL_ERROR,                             \
> +                           _("cannot read %s statistic"), NAME);               \
> +            goto cleanup;                                                      \
> +        }                                                                      \
> +    }
> +     QEMU_MONITOR_JSON_BLOCK_STAT("rd_bytes", bstats->rd_bytes, true);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("wr_bytes", bstats->wr_bytes, true);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("rd_operations", bstats->rd_req, true);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("wr_operations", bstats->wr_req, true);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("rd_total_time_ns", bstats->rd_total_times, false);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("wr_total_time_ns", bstats->wr_total_times, false);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("flush_operations", bstats->flush_req, false);
> +     QEMU_MONITOR_JSON_BLOCK_STAT("flush_total_time_ns", bstats->flush_total_times, false);
> +#undef QEMU_MONITOR_JSON_BLOCK_STAT
> 

This macro could also use a verb.

Jan

Attachment: signature.asc
Description: 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]