[libvirt] [PATCH 2/2] qemu: Audit memory size with memory hotplug operations
Martin Kletzander
mkletzan at redhat.com
Tue Jun 30 16:03:29 UTC 2015
On Fri, Jun 26, 2015 at 05:16:48PM +0200, Peter Krempa wrote:
>The memory device hot(un)plug was missing calls to the auditing code.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1226234
>---
> src/qemu/qemu_hotplug.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
>diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
>index 0628964..13e97e8 100644
>--- a/src/qemu/qemu_hotplug.c
>+++ b/src/qemu/qemu_hotplug.c
>@@ -1735,6 +1735,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
> {
> qemuDomainObjPrivatePtr priv = vm->privateData;
> virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
>+ unsigned long long oldmem = virDomainDefGetMemoryActual(vm->def);
> char *devstr = NULL;
> char *objalias = NULL;
> const char *backendType;
>@@ -1801,6 +1802,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
> if (fix_balloon)
> vm->def->mem.cur_balloon += mem->size;
>
>+ virDomainAuditMemory(vm, oldmem, virDomainDefGetMemoryActual(vm->def),
>+ "hotplug", ret == 0);
s/hotplug/update/ to go with the rest of the code.
>+
> /* mem is consumed by vm->def */
> mem = NULL;
>
>@@ -2890,10 +2894,12 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
> virDomainMemoryDefPtr mem)
> {
> qemuDomainObjPrivatePtr priv = vm->privateData;
>+ unsigned long long oldmem = virDomainDefGetMemoryActual(vm->def);
> virObjectEventPtr event;
> char *backendAlias = NULL;
> int rc;
> int idx;
>+ int ret = -1;
>
> VIR_DEBUG("Removing memory device %s from domain %p %s",
> mem->info.alias, vm, vm->def->name);
>@@ -2902,12 +2908,12 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
> qemuDomainEventQueue(driver, event);
>
> if (virAsprintf(&backendAlias, "mem%s", mem->info.alias) < 0)
>- goto error;
>+ goto cleanup;
>
> qemuDomainObjEnterMonitor(driver, vm);
> rc = qemuMonitorDelObject(priv->mon, backendAlias);
> if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
>- goto error;
>+ goto cleanup;
>
> vm->def->mem.cur_balloon -= mem->size;
>
>@@ -2915,12 +2921,14 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
> virDomainMemoryRemove(vm->def, idx);
>
> virDomainMemoryDefFree(mem);
>- VIR_FREE(backendAlias);
>- return 0;
>+ ret = 0;
>+
>+ cleanup:
>+ virDomainAuditMemory(vm, oldmem, virDomainDefGetMemoryActual(vm->def),
>+ "hotunplug", ret == 0);
>
Similarly here.
You're combining two changes together, but it's fine in this case.
ACK both patches, safe for freeze.
>- error:
> VIR_FREE(backendAlias);
>- return -1;
>+ return ret;
> }
>
>
>--
>2.4.1
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150630/61efd4f5/attachment-0001.sig>
More information about the libvir-list
mailing list