[libvirt] [PATCH] qemu: bulk stats: Clean up code to check whether we need a domain job
Martin Kletzander
mkletzan at redhat.com
Thu Dec 11 13:26:38 UTC 2014
On Thu, Dec 11, 2014 at 01:59:20PM +0100, Peter Krempa wrote:
>Storing the information as a flag in a unsigned int seems a bit
>wasteful. Store it in a bool instead.
>---
> src/qemu/qemu_driver.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index df3ba6d..5c60127 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -18691,7 +18691,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
> int nstats = 0;
> size_t i;
> int ret = -1;
>- unsigned int privflags = 0;
>+ bool needjob;
> unsigned int domflags = 0;
>
> if (ndoms)
>@@ -18727,8 +18727,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
> if (VIR_ALLOC_N(tmpstats, ndoms + 1) < 0)
> goto cleanup;
>
>- if (qemuDomainGetStatsNeedMonitor(stats))
>- privflags |= QEMU_DOMAIN_STATS_HAVE_JOB;
>+ bool needjob = qemuDomainGetStatsNeedMonitor(stats);
>
> for (i = 0; i < ndoms; i++) {
> virDomainStatsRecordPtr tmp = NULL;
>@@ -18744,7 +18743,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
> continue;
> }
>
>- if (HAVE_JOB(privflags) &&
>+ if (needjob &&
> qemuDomainObjBeginJob(driver, dom, QEMU_JOB_QUERY) == 0)
> domflags |= QEMU_DOMAIN_STATS_HAVE_JOB;
> /* else: without a job it's still possible to gather some data */
>--
>2.2.0
>
If you're cleaning up this for privflags, do the same for domflags, it
is used the same, ugly, way.
Thanks,
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141211/56413af0/attachment-0001.sig>
More information about the libvir-list
mailing list