[libvirt] [PATCH] qemu: Don't fail virDomainGetInfo if we can't update balloon info

Qemu driver tries to update balloon data in virDomainGetInfo and if it can't do so because there is another monitor job running, it just reports what's known in domain def. However, if there was no job running but getting the data from qemu fails, we would fail the whole API. This doesn't make sense. Let's make the failure nonfatal. --- src/qemu/qemu_driver.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dc34e1d..276dc06 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2071,37 +2071,42 @@ static int qemudDomainGetInfo(virDomainPtr dom, } else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) { if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) err = 0; else { qemuDomainObjEnterMonitor(driver, vm); err = qemuMonitorGetBalloonInfo(priv->mon, &balloon); qemuDomainObjExitMonitor(driver, vm); } if (qemuDomainObjEndJob(driver, vm) == 0) { vm = NULL; goto cleanup; } - if (err < 0) - goto cleanup; - if (err == 0) + if (err < 0) { + /* We couldn't get current memory allocation but that's not + * a show stopper; we wouldn't get it if there was a job + * active either + */ + info->memory = vm->def->mem.cur_balloon; + } else if (err == 0) { /* Balloon not supported, so maxmem is always the allocation */ info->memory = vm->def->mem.max_balloon; - else + } else { info->memory = balloon; + } } else { info->memory = vm->def->mem.cur_balloon; } } else { info->memory = vm->def->mem.cur_balloon; } info->nrVirtCpu = vm->def->vcpus; ret = 0; cleanup: if (vm) virDomainObjUnlock(vm); return ret; } -- 1.7.7

On 10/05/2011 08:17 AM, Jiri Denemark wrote:
Qemu driver tries to update balloon data in virDomainGetInfo and if it can't do so because there is another monitor job running, it just reports what's known in domain def. However, if there was no job running but getting the data from qemu fails, we would fail the whole API. This doesn't make sense. Let's make the failure nonfatal. --- src/qemu/qemu_driver.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
ACK. And thanks for the extra context; it made reviewing easier. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Oct 05, 2011 at 08:22:51 -0600, Eric Blake wrote:
On 10/05/2011 08:17 AM, Jiri Denemark wrote:
Qemu driver tries to update balloon data in virDomainGetInfo and if it can't do so because there is another monitor job running, it just reports what's known in domain def. However, if there was no job running but getting the data from qemu fails, we would fail the whole API. This doesn't make sense. Let's make the failure nonfatal. --- src/qemu/qemu_driver.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
ACK. And thanks for the extra context; it made reviewing easier.
Thanks, pushed. Jirka
participants (2)
-
Eric Blake
-
Jiri Denemark