mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu_monitor: search memballoon QOM device path using alias
Commit 4a585a88
introduced searching QOM device path by alias, let's use it for
memballoon too. This may speedup the search because in most cases we will find
the correct QOM device path directly by using alias without the need for the
recursion code.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
4a585a884f
commit
e7093b391d
@ -2455,7 +2455,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
|
|||||||
}
|
}
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
r = qemuMonitorSetMemoryStatsPeriod(priv->mon, period);
|
r = qemuMonitorSetMemoryStatsPeriod(priv->mon, def->memballoon, period);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@ -11003,7 +11003,8 @@ qemuDomainMemoryStats(virDomainPtr dom,
|
|||||||
if (vm->def->memballoon &&
|
if (vm->def->memballoon &&
|
||||||
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
|
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
ret = qemuMonitorGetMemoryStats(qemuDomainGetMonitor(vm), stats, nr_stats);
|
ret = qemuMonitorGetMemoryStats(qemuDomainGetMonitor(vm),
|
||||||
|
vm->def->memballoon, stats, nr_stats);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
|
@ -1068,11 +1068,12 @@ qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
|
|||||||
* This feature was added to QEMU 1.5.
|
* This feature was added to QEMU 1.5.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
qemuMonitorInitBalloonObjectPath(qemuMonitorPtr mon)
|
qemuMonitorInitBalloonObjectPath(qemuMonitorPtr mon,
|
||||||
|
virDomainMemballoonDefPtr balloon)
|
||||||
{
|
{
|
||||||
ssize_t i, nprops = 0;
|
ssize_t i, nprops = 0;
|
||||||
int flp_ret = 0;
|
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
|
const char *name;
|
||||||
qemuMonitorJSONListPathPtr *bprops = NULL;
|
qemuMonitorJSONListPathPtr *bprops = NULL;
|
||||||
|
|
||||||
if (mon->balloonpath) {
|
if (mon->balloonpath) {
|
||||||
@ -1084,16 +1085,20 @@ qemuMonitorInitBalloonObjectPath(qemuMonitorPtr mon)
|
|||||||
}
|
}
|
||||||
mon->ballooninit = true;
|
mon->ballooninit = true;
|
||||||
|
|
||||||
flp_ret = qemuMonitorJSONFindLinkPath(mon, "virtio-balloon-pci", NULL, &path);
|
switch (balloon->info.type) {
|
||||||
if (flp_ret == -2) {
|
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
|
||||||
/* pci object was not found retry search for ccw object */
|
name = "virtio-balloon-pci";
|
||||||
if (qemuMonitorJSONFindLinkPath(mon, "virtio-balloon-ccw",
|
break;
|
||||||
NULL, &path) < 0)
|
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
|
||||||
return;
|
name = "virtio-balloon-ccw";
|
||||||
} else if (flp_ret < 0) {
|
break;
|
||||||
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuMonitorJSONFindLinkPath(mon, name, balloon->info.alias, &path) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
nprops = qemuMonitorJSONGetObjectListPaths(mon, path, &bprops);
|
nprops = qemuMonitorJSONGetObjectListPaths(mon, path, &bprops);
|
||||||
if (nprops < 0)
|
if (nprops < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1718,6 +1723,7 @@ qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
|
qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
|
||||||
|
virDomainMemballoonDefPtr balloon,
|
||||||
virDomainMemoryStatPtr stats,
|
virDomainMemoryStatPtr stats,
|
||||||
unsigned int nr_stats)
|
unsigned int nr_stats)
|
||||||
{
|
{
|
||||||
@ -1726,7 +1732,7 @@ qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
|
|||||||
QEMU_CHECK_MONITOR(mon);
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
if (mon->json) {
|
if (mon->json) {
|
||||||
qemuMonitorInitBalloonObjectPath(mon);
|
qemuMonitorInitBalloonObjectPath(mon, balloon);
|
||||||
return qemuMonitorJSONGetMemoryStats(mon, mon->balloonpath,
|
return qemuMonitorJSONGetMemoryStats(mon, mon->balloonpath,
|
||||||
stats, nr_stats);
|
stats, nr_stats);
|
||||||
} else {
|
} else {
|
||||||
@ -1744,6 +1750,7 @@ qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
||||||
|
virDomainMemballoonDefPtr balloon,
|
||||||
int period)
|
int period)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -1758,7 +1765,7 @@ qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
|||||||
if (period < 0)
|
if (period < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuMonitorInitBalloonObjectPath(mon);
|
qemuMonitorInitBalloonObjectPath(mon, balloon);
|
||||||
if (mon->balloonpath) {
|
if (mon->balloonpath) {
|
||||||
ret = qemuMonitorJSONSetMemoryStatsPeriod(mon, mon->balloonpath,
|
ret = qemuMonitorJSONSetMemoryStatsPeriod(mon, mon->balloonpath,
|
||||||
period);
|
period);
|
||||||
|
@ -397,9 +397,11 @@ int qemuMonitorGetVirtType(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
|
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
|
||||||
unsigned long long *currmem);
|
unsigned long long *currmem);
|
||||||
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
|
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
|
||||||
|
virDomainMemballoonDefPtr balloon,
|
||||||
virDomainMemoryStatPtr stats,
|
virDomainMemoryStatPtr stats,
|
||||||
unsigned int nr_stats);
|
unsigned int nr_stats);
|
||||||
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
||||||
|
virDomainMemballoonDefPtr balloon,
|
||||||
int period);
|
int period);
|
||||||
|
|
||||||
int qemuMonitorBlockIOStatusToError(const char *status);
|
int qemuMonitorBlockIOStatusToError(const char *status);
|
||||||
|
@ -4268,19 +4268,17 @@ qemuProcessSetupBalloon(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
unsigned long long balloon = vm->def->mem.cur_balloon;
|
unsigned long long balloon = vm->def->mem.cur_balloon;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int period;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!virDomainDefHasMemballoon(vm->def))
|
if (!virDomainDefHasMemballoon(vm->def))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
period = vm->def->memballoon->period;
|
|
||||||
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (period)
|
if (vm->def->memballoon->period)
|
||||||
qemuMonitorSetMemoryStatsPeriod(priv->mon, period);
|
qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon,
|
||||||
|
vm->def->memballoon->period);
|
||||||
if (qemuMonitorSetBalloon(priv->mon, balloon) < 0)
|
if (qemuMonitorSetBalloon(priv->mon, balloon) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -6022,7 +6020,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
||||||
vm->def->memballoon->period) {
|
vm->def->memballoon->period) {
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
qemuMonitorSetMemoryStatsPeriod(priv->mon,
|
qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon,
|
||||||
vm->def->memballoon->period);
|
vm->def->memballoon->period);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user