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 <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
John Ferlan 2018-10-03 08:48:30 -04:00
parent d1c1f2c2f5
commit 212dc9286a

View File

@ -5484,12 +5484,36 @@ qemuDomainGetMaxVcpus(virDomainPtr dom)
VIR_DOMAIN_VCPU_MAXIMUM)); 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 static int
qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainIOThreadInfoPtr **info) virDomainIOThreadInfoPtr **info)
{ {
qemuDomainObjPrivatePtr priv;
qemuMonitorIOThreadInfoPtr *iothreads = NULL; qemuMonitorIOThreadInfoPtr *iothreads = NULL;
virDomainIOThreadInfoPtr *info_ret = NULL; virDomainIOThreadInfoPtr *info_ret = NULL;
int niothreads = 0; int niothreads = 0;
@ -5505,18 +5529,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
goto endjob; goto endjob;
} }
priv = vm->privateData; if ((niothreads = qemuDomainGetIOThreadsMon(driver, vm, &iothreads)) < 0)
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)
goto endjob; goto endjob;
/* Nothing to do */ /* Nothing to do */
@ -5546,8 +5559,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
virBitmapFree(map); virBitmapFree(map);
} }
*info = info_ret; VIR_STEAL_PTR(*info, info_ret);
info_ret = NULL;
ret = niothreads; ret = niothreads;
endjob: endjob: