Long subject line. 'git shortlog -20' should give you a feel for how to shorten this; I went with: setmem: add VIR_DOMAIN_MEM_CURRENT support to qemu On 03/22/2011 11:48 PM, Taku Izumi wrote: > > This patch adds virDomainSetMemroyFlags(,,VIR_DOMAIN_MEM_CURRENT) support s/Memroy/Memory/ > code to qemu driver. > > Signed-off-by: Taku Izumi <izumi.taku@xxxxxxxxxxxxxx> > --- > src/qemu/qemu_driver.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > Index: libvirt/src/qemu/qemu_driver.c > =================================================================== > --- libvirt.orig/src/qemu/qemu_driver.c > +++ libvirt/src/qemu/qemu_driver.c > @@ -1575,16 +1575,11 @@ static int qemudDomainSetMemoryFlags(vir > qemuDomainObjPrivatePtr priv; > virDomainObjPtr vm; > virDomainDefPtr persistentDef = NULL; > - int ret = -1, r; > + int ret = -1, r, isActive; Hmm, based on the name, I would have guessed isActive is better as a bool. > > virCheckFlags(VIR_DOMAIN_MEM_LIVE | > VIR_DOMAIN_MEM_CONFIG, -1); > > - if ((flags & (VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG)) == 0) { > - qemuReportError(VIR_ERR_INVALID_ARG, > - _("invalid flag combination: (0x%x)"), flags); > - } > - > qemuDriverLock(driver); > vm = virDomainFindByUUID(&driver->domains, dom->uuid); > qemuDriverUnlock(driver); > @@ -1605,7 +1600,16 @@ static int qemudDomainSetMemoryFlags(vir > if (qemuDomainObjBeginJob(vm) < 0) > goto cleanup; > > - if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_MEM_LIVE)) { > + isActive = virDomainObjIsActive(vm); Surprisingly, virDomainObjIsActive returns int instead of bool. Well, no longer :) > + > + if (flags == VIR_DOMAIN_MEM_CURRENT) { > + if (isActive) > + flags = VIR_DOMAIN_MEM_LIVE; > + else > + flags = VIR_DOMAIN_MEM_CONFIG; > + } > + > + if (!isActive && (flags & VIR_DOMAIN_MEM_LIVE)) { > qemuReportError(VIR_ERR_OPERATION_INVALID, > "%s", _("domain is not running")); > goto endjob; I squashed this in, then pushed: diff --git i/src/conf/domain_conf.h w/src/conf/domain_conf.h index 10e73cb..95bd11e 100644 --- i/src/conf/domain_conf.h +++ w/src/conf/domain_conf.h @@ -1172,7 +1172,7 @@ struct _virDomainObjList { virHashTable *objs; }; -static inline int +static inline bool virDomainObjIsActive(virDomainObjPtr dom) { return dom->def->id != -1; diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c index c0e706c..6a0bf24 100644 --- i/src/qemu/qemu_driver.c +++ w/src/qemu/qemu_driver.c @@ -1576,7 +1576,8 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, qemuDomainObjPrivatePtr priv; virDomainObjPtr vm; virDomainDefPtr persistentDef = NULL; - int ret = -1, r, isActive; + int ret = -1, r; + bool isActive; virCheckFlags(VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG, -1); -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 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