From 212dc9286a293467cd23a88f269fc1b72c5edca1 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 3 Oct 2018 08:48:30 -0400 Subject: [PATCH] qemu: Split qemuDomainGetIOThreadsLive Separate out the fetch of the IOThread monitor call into a separate helper so that a subsequent domain statistics change can fetch the raw IOThread data and parse it as it sees fit. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 81185be67c..feaa421d43 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5484,12 +5484,36 @@ qemuDomainGetMaxVcpus(virDomainPtr dom) VIR_DOMAIN_VCPU_MAXIMUM)); } + +static int +qemuDomainGetIOThreadsMon(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuMonitorIOThreadInfoPtr **iothreads) +{ + qemuDomainObjPrivatePtr priv; + int niothreads = 0; + + priv = vm->privateData; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads not supported with this binary")); + return -1; + } + + qemuDomainObjEnterMonitor(driver, vm); + niothreads = qemuMonitorGetIOThreads(priv->mon, iothreads); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || niothreads < 0) + return -1; + + return niothreads; +} + + static int qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainIOThreadInfoPtr **info) { - qemuDomainObjPrivatePtr priv; qemuMonitorIOThreadInfoPtr *iothreads = NULL; virDomainIOThreadInfoPtr *info_ret = NULL; int niothreads = 0; @@ -5505,18 +5529,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, goto endjob; } - priv = vm->privateData; - if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IOThreads not supported with this binary")); - goto endjob; - } - - qemuDomainObjEnterMonitor(driver, vm); - niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; - if (niothreads < 0) + if ((niothreads = qemuDomainGetIOThreadsMon(driver, vm, &iothreads)) < 0) goto endjob; /* Nothing to do */ @@ -5546,8 +5559,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, virBitmapFree(map); } - *info = info_ret; - info_ret = NULL; + VIR_STEAL_PTR(*info, info_ret); ret = niothreads; endjob: -- 2.39.5