On 05/16/2012 08:35 AM, Daniel P. Berrange wrote: > From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> > > If QEMU supports the BALLOON_EVENT QMP event, then we can > avoid invoking 'query-balloon' when returning XML or the > domain info. > > * src/qemu/qemu_capabilities.c, src/qemu/qemu_capabilities.h: > Add QEMU_CAPS_BALLOON_EVENT > * src/qemu/qemu_driver.c: Skip query-balloon in > qemudDomainGetInfo and qemuDomainGetXMLDesc if we have > QEMU_CAPS_BALLOON_EVENT set > * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Check > for BALLOON_EVENT at connect to monitor. Add callback > for balloon change notifications > * src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: > Add handling of BALLOON_EVENT and impl 'query-events' > check > > Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> > --- > src/qemu/qemu_capabilities.c | 2 + > src/qemu/qemu_capabilities.h | 1 + > src/qemu/qemu_driver.c | 7 ++++- > src/qemu/qemu_monitor.c | 18 +++++++++++- > src/qemu/qemu_monitor.h | 5 +++ > src/qemu/qemu_monitor_json.c | 65 ++++++++++++++++++++++++++++++++++++++++++ > src/qemu/qemu_monitor_json.h | 2 + > src/qemu/qemu_process.c | 31 ++++++++++++++++++++ > 8 files changed, 129 insertions(+), 2 deletions(-) > > + QEMU_CAPS_BALLOON_EVENT = 95, /* Async event for balloon changes */ Yet another cap bit that can only be learned when the guest is live. We really need to start caching qemu capabilities per binary... But at least your patch only matters for live guests (unlike my recent patches for block copy, where I was giving a bad error message for offline guests until I added commit 8e532d34 to shuffle things around). > +static void > +qemuMonitorJSONHandleBalloonChange(qemuMonitorPtr mon, > + virJSONValuePtr data) > +{ > + unsigned long long actual = 0; > + if (virJSONValueObjectGetNumberUlong(data, "actual", &actual) < 0) { > + VIR_WARN("missing actual in balloon change event"); > + return; > + } > + actual = (actual/1024); I think you want to use VIR_DIV_UP(actual, 1024) here, just in case qemu ever reports a value with finer granularity than a kilobyte. -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list