[libvirt] [PATCH 0/5] RFC: configure inactive domains' memory size

Hi all, Currently "virsh setmem" is not allowed to use against an inactive domain. This is yet another approach to configure inactive domain's memory size. The approach before was closed in "virsh" command: http://www.redhat.com/archives/libvir-list/2011-February/msg01074.html This time a new libvirt API is introduced to achieve this. *[PATCH 1/5] setmem: introduce a new libvirt API (virDomainSetMemoryFlags) *[PATCH 2/5] setmem: implement the call back member for new API on each driver *[PATCH 3/5] setmem: implement the code to address the new API in the qemu driver *[PATCH 4/5] setmem: implement the remote protocol to address the new API *[PATCH 5/5] setmem: add the new options to "virsh setmem" command Best regards, Taku Izumi

This patch introduces a new libvirt API (virDomainSetMemoryFlags) and a flag (virDomainMemoryModFlags). Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- include/libvirt/libvirt.h.in | 10 ++++++ src/libvirt.c | 62 +++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 3 files changed, 77 insertions(+) Index: libvirt-git/include/libvirt/libvirt.h.in =================================================================== --- libvirt-git.orig/include/libvirt/libvirt.h.in +++ libvirt-git/include/libvirt/libvirt.h.in @@ -780,6 +780,13 @@ int virDomainGetMemoryParameters(vir virMemoryParameterPtr params, int *nparams, unsigned int flags); +/* Memory size modification flags. */ +typedef enum { + VIR_DOMAIN_MEM_LIVE = (1 << 0), /* affect active domain */ + VIR_DOMAIN_MEM_CONFIG = (1 << 1), /* affect next boot */ +} virDomainMemoryModFlags; + + /* * Dynamic control of domains */ @@ -795,6 +802,9 @@ int virDomainSetMaxM unsigned long memory); int virDomainSetMemory (virDomainPtr domain, unsigned long memory); +int virDomainSetMemoryFlags (virDomainPtr domain, + unsigned long memory, + unsigned int flags); int virDomainGetMaxVcpus (virDomainPtr domain); int virDomainGetSecurityLabel (virDomainPtr domain, virSecurityLabelPtr seclabel); Index: libvirt-git/src/libvirt_public.syms =================================================================== --- libvirt-git.orig/src/libvirt_public.syms +++ libvirt-git/src/libvirt_public.syms @@ -424,4 +424,9 @@ LIBVIRT_0.8.8 { virConnectGetSysinfo; } LIBVIRT_0.8.6; +LIBVIRT_0.8.9 { + global: + virDomainSetMemoryFlags; +} LIBVIRT_0.8.8; + # .... define new API here using predicted next version number .... Index: libvirt-git/src/libvirt.c =================================================================== --- libvirt-git.orig/src/libvirt.c +++ libvirt-git/src/libvirt.c @@ -2846,6 +2846,68 @@ error: return -1; } +/* + * virDomainSetMemoryFlags + * @domain: a domain object or NULL + * @memory: the memory size in kilobytes + * @flags: an OR'ed set of virDomainMemoryFlags + * + * Dynamically change the target amount of physical memory allocated to a + * domain. If domain is NULL, then this change the amount of memory reserved + * to Domain0 i.e. the domain where the application runs. + * This funcation may requires privileged access to the hypervisor. + * + * @flags must include VIR_DOMAIN_MEM_LIVE to affect a running + * domain (which may fail if domain is not active), or + * VIR_DOMAIN_MEM_CONFIG to affect the next boot via the XML + * description of the domain. Both flags may be set. + * + * Returns 0 in case of success, -1 in case of failure. + */ + +int +virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "memory=%lu flags=%u", memory, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + + if (domain->conn->flags & VIR_CONNECT_RO) { + virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (memory < 4096 || + (flags & (VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG)) == 0) { + virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); + goto error; + } + + conn = domain->conn; + + if (conn->driver->domainSetMemoryFlags) { + int ret; + ret = conn->driver->domainSetMemoryFlags(domain, memory, flags); + if (ret < 0) + goto error; + return ret; + } + +error: + virDispatchError(domain->conn); + return -1; +} + + /** * virDomainSetMemoryParameters: * @domain: pointer to domain object

On Wed, Mar 02, 2011 at 05:07:48PM +0900, Taku Izumi wrote:
This patch introduces a new libvirt API (virDomainSetMemoryFlags) and a flag (virDomainMemoryModFlags).
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- include/libvirt/libvirt.h.in | 10 ++++++ src/libvirt.c | 62 +++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 3 files changed, 77 insertions(+)
Index: libvirt-git/include/libvirt/libvirt.h.in =================================================================== --- libvirt-git.orig/include/libvirt/libvirt.h.in +++ libvirt-git/include/libvirt/libvirt.h.in @@ -780,6 +780,13 @@ int virDomainGetMemoryParameters(vir virMemoryParameterPtr params, int *nparams, unsigned int flags);
+/* Memory size modification flags. */ +typedef enum { + VIR_DOMAIN_MEM_LIVE = (1 << 0), /* affect active domain */ + VIR_DOMAIN_MEM_CONFIG = (1 << 1), /* affect next boot */ +} virDomainMemoryModFlags; + + /* * Dynamic control of domains */ @@ -795,6 +802,9 @@ int virDomainSetMaxM unsigned long memory); int virDomainSetMemory (virDomainPtr domain, unsigned long memory); +int virDomainSetMemoryFlags (virDomainPtr domain, + unsigned long memory, + unsigned int flags); int virDomainGetMaxVcpus (virDomainPtr domain); int virDomainGetSecurityLabel (virDomainPtr domain, virSecurityLabelPtr seclabel); Index: libvirt-git/src/libvirt_public.syms =================================================================== --- libvirt-git.orig/src/libvirt_public.syms +++ libvirt-git/src/libvirt_public.syms @@ -424,4 +424,9 @@ LIBVIRT_0.8.8 { virConnectGetSysinfo; } LIBVIRT_0.8.6;
+LIBVIRT_0.8.9 { + global: + virDomainSetMemoryFlags; +} LIBVIRT_0.8.8;
This bit will need re-basing since I added the 0.9.0 section to the file in a recent commit.
+ # .... define new API here using predicted next version number .... Index: libvirt-git/src/libvirt.c =================================================================== --- libvirt-git.orig/src/libvirt.c +++ libvirt-git/src/libvirt.c @@ -2846,6 +2846,68 @@ error: return -1; }
+/* + * virDomainSetMemoryFlags + * @domain: a domain object or NULL + * @memory: the memory size in kilobytes + * @flags: an OR'ed set of virDomainMemoryFlags + * + * Dynamically change the target amount of physical memory allocated to a + * domain. If domain is NULL, then this change the amount of memory reserved + * to Domain0 i.e. the domain where the application runs. + * This funcation may requires privileged access to the hypervisor. + * + * @flags must include VIR_DOMAIN_MEM_LIVE to affect a running + * domain (which may fail if domain is not active), or + * VIR_DOMAIN_MEM_CONFIG to affect the next boot via the XML + * description of the domain. Both flags may be set. + * + * Returns 0 in case of success, -1 in case of failure. + */ + +int +virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "memory=%lu flags=%u", memory, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + + if (domain->conn->flags & VIR_CONNECT_RO) { + virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (memory < 4096 || + (flags & (VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG)) == 0) { + virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); + goto error; + } + + conn = domain->conn; + + if (conn->driver->domainSetMemoryFlags) { + int ret; + ret = conn->driver->domainSetMemoryFlags(domain, memory, flags); + if (ret < 0) + goto error; + return ret; + }
This bit is referencing a struct field that is only created in patch 2, so you should merge the contents of patch 2 into this patch. The goal is that everything should compile after each individual patch is applied The API proposal looks fine to me Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 03/02/2011 01:07 AM, Taku Izumi wrote:
This patch introduces a new libvirt API (virDomainSetMemoryFlags) and a flag (virDomainMemoryModFlags).
+/* Memory size modification flags. */ +typedef enum { + VIR_DOMAIN_MEM_LIVE = (1 << 0), /* affect active domain */ + VIR_DOMAIN_MEM_CONFIG = (1 << 1), /* affect next boot */ +} virDomainMemoryModFlags;
Here called virDomainMemoryModFlags, because virDomainMemoryFlags was already taken,
+/* + * virDomainSetMemoryFlags + * @domain: a domain object or NULL + * @memory: the memory size in kilobytes + * @flags: an OR'ed set of virDomainMemoryFlags
But here just virDomainMemoryFlags. I've fixed the typo, adjust libvirt_public.syms, added you to AUTHORS (let me know if you want to adjust how your name appears - for now I just copied your Signed-Off-By spelling), and squashed in patch 2/5 (with more amendments - see my reply there), then pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

This patch implemetns the call back member for new API on each driver. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- src/driver.h | 5 +++++ src/esx/esx_driver.c | 1 + src/lxc/lxc_driver.c | 1 + src/opennebula/one_driver.c | 1 + src/openvz/openvz_driver.c | 1 + src/phyp/phyp_driver.c | 1 + src/qemu/qemu_driver.c | 1 + src/remote/remote_driver.c | 1 + src/test/test_driver.c | 1 + src/uml/uml_driver.c | 1 + src/vbox/vbox_tmpl.c | 1 + src/xen/xen_driver.c | 1 + src/xenapi/xenapi_driver.c | 1 + 13 files changed, 17 insertions(+) Index: libvirt-git/src/driver.h =================================================================== --- libvirt-git.orig/src/driver.h +++ libvirt-git/src/driver.h @@ -135,6 +135,10 @@ typedef int (*virDrvDomainSetMemory) (virDomainPtr domain, unsigned long memory); typedef int + (*virDrvDomainSetMemoryFlags) (virDomainPtr domain, + unsigned long memory, + unsigned int flags); +typedef int (*virDrvDomainSetMemoryParameters) (virDomainPtr domain, virMemoryParameterPtr params, @@ -537,6 +541,7 @@ struct _virDriver { virDrvDomainGetMaxMemory domainGetMaxMemory; virDrvDomainSetMaxMemory domainSetMaxMemory; virDrvDomainSetMemory domainSetMemory; + virDrvDomainSetMemoryFlags domainSetMemoryFlags; virDrvDomainGetInfo domainGetInfo; virDrvDomainSave domainSave; virDrvDomainRestore domainRestore; Index: libvirt-git/src/esx/esx_driver.c =================================================================== --- libvirt-git.orig/src/esx/esx_driver.c +++ libvirt-git/src/esx/esx_driver.c @@ -4577,6 +4577,7 @@ static virDriver esxDriver = { esxDomainGetMaxMemory, /* domainGetMaxMemory */ esxDomainSetMaxMemory, /* domainSetMaxMemory */ esxDomainSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ esxDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/lxc/lxc_driver.c =================================================================== --- libvirt-git.orig/src/lxc/lxc_driver.c +++ libvirt-git/src/lxc/lxc_driver.c @@ -2852,6 +2852,7 @@ static virDriver lxcDriver = { lxcDomainGetMaxMemory, /* domainGetMaxMemory */ lxcDomainSetMaxMemory, /* domainSetMaxMemory */ lxcDomainSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ lxcDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/opennebula/one_driver.c =================================================================== --- libvirt-git.orig/src/opennebula/one_driver.c +++ libvirt-git/src/opennebula/one_driver.c @@ -751,6 +751,7 @@ static virDriver oneDriver = { NULL, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ NULL, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ oneDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/openvz/openvz_driver.c =================================================================== --- libvirt-git.orig/src/openvz/openvz_driver.c +++ libvirt-git/src/openvz/openvz_driver.c @@ -1591,6 +1591,7 @@ static virDriver openvzDriver = { NULL, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ NULL, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ openvzDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/phyp/phyp_driver.c =================================================================== --- libvirt-git.orig/src/phyp/phyp_driver.c +++ libvirt-git/src/phyp/phyp_driver.c @@ -3973,6 +3973,7 @@ static virDriver phypDriver = { NULL, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ NULL, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ phypDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/qemu/qemu_driver.c =================================================================== --- libvirt-git.orig/src/qemu/qemu_driver.c +++ libvirt-git/src/qemu/qemu_driver.c @@ -6789,6 +6789,7 @@ static virDriver qemuDriver = { qemudDomainGetMaxMemory, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ qemudDomainSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ qemudDomainGetInfo, /* domainGetInfo */ qemudDomainSave, /* domainSave */ qemudDomainRestore, /* domainRestore */ Index: libvirt-git/src/remote/remote_driver.c =================================================================== --- libvirt-git.orig/src/remote/remote_driver.c +++ libvirt-git/src/remote/remote_driver.c @@ -10868,6 +10868,7 @@ static virDriver remote_driver = { remoteDomainGetMaxMemory, /* domainGetMaxMemory */ remoteDomainSetMaxMemory, /* domainSetMaxMemory */ remoteDomainSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ remoteDomainGetInfo, /* domainGetInfo */ remoteDomainSave, /* domainSave */ remoteDomainRestore, /* domainRestore */ Index: libvirt-git/src/test/test_driver.c =================================================================== --- libvirt-git.orig/src/test/test_driver.c +++ libvirt-git/src/test/test_driver.c @@ -5365,6 +5365,7 @@ static virDriver testDriver = { testGetMaxMemory, /* domainGetMaxMemory */ testSetMaxMemory, /* domainSetMaxMemory */ testSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ testGetDomainInfo, /* domainGetInfo */ testDomainSave, /* domainSave */ testDomainRestore, /* domainRestore */ Index: libvirt-git/src/uml/uml_driver.c =================================================================== --- libvirt-git.orig/src/uml/uml_driver.c +++ libvirt-git/src/uml/uml_driver.c @@ -2167,6 +2167,7 @@ static virDriver umlDriver = { umlDomainGetMaxMemory, /* domainGetMaxMemory */ umlDomainSetMaxMemory, /* domainSetMaxMemory */ umlDomainSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ umlDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/vbox/vbox_tmpl.c =================================================================== --- libvirt-git.orig/src/vbox/vbox_tmpl.c +++ libvirt-git/src/vbox/vbox_tmpl.c @@ -8556,6 +8556,7 @@ virDriver NAME(Driver) = { NULL, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ vboxDomainSetMemory, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ vboxDomainGetInfo, /* domainGetInfo */ vboxDomainSave, /* domainSave */ NULL, /* domainRestore */ Index: libvirt-git/src/xen/xen_driver.c =================================================================== --- libvirt-git.orig/src/xen/xen_driver.c +++ libvirt-git/src/xen/xen_driver.c @@ -2034,6 +2034,7 @@ static virDriver xenUnifiedDriver = { xenUnifiedDomainGetMaxMemory, /* domainGetMaxMemory */ xenUnifiedDomainSetMaxMemory, /* domainSetMaxMemory */ xenUnifiedDomainSetMemory, /* domainSetMemory */ + NULL, /*domainSetMemoryFlags */ xenUnifiedDomainGetInfo, /* domainGetInfo */ xenUnifiedDomainSave, /* domainSave */ xenUnifiedDomainRestore, /* domainRestore */ Index: libvirt-git/src/xenapi/xenapi_driver.c =================================================================== --- libvirt-git.orig/src/xenapi/xenapi_driver.c +++ libvirt-git/src/xenapi/xenapi_driver.c @@ -1803,6 +1803,7 @@ static virDriver xenapiDriver = { xenapiDomainGetMaxMemory, /* domainGetMaxMemory */ xenapiDomainSetMaxMemory, /* domainSetMaxMemory */ NULL, /* domainSetMemory */ + NULL, /* domainSetMemoryFlags */ xenapiDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */

On Wed, Mar 02, 2011 at 05:08:48PM +0900, Taku Izumi wrote:
This patch implemetns the call back member for new API on each driver.
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- src/driver.h | 5 +++++ src/esx/esx_driver.c | 1 + src/lxc/lxc_driver.c | 1 + src/opennebula/one_driver.c | 1 + src/openvz/openvz_driver.c | 1 + src/phyp/phyp_driver.c | 1 + src/qemu/qemu_driver.c | 1 + src/remote/remote_driver.c | 1 + src/test/test_driver.c | 1 + src/uml/uml_driver.c | 1 + src/vbox/vbox_tmpl.c | 1 + src/xen/xen_driver.c | 1 + src/xenapi/xenapi_driver.c | 1 + 13 files changed, 17 insertions(+)
ACK, assuming it is squashed into patch1 Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 03/02/2011 01:08 AM, Taku Izumi wrote:
This patch implemetns the call back member for new API
s/implemetns/implements/ But that doesn't matter, now that it's squashed into 1/5.
on each driver.
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- src/driver.h | 5 +++++ src/esx/esx_driver.c | 1 + src/lxc/lxc_driver.c | 1 + src/opennebula/one_driver.c | 1 + src/openvz/openvz_driver.c | 1 + src/phyp/phyp_driver.c | 1 + src/qemu/qemu_driver.c | 1 + src/remote/remote_driver.c | 1 + src/test/test_driver.c | 1 + src/uml/uml_driver.c | 1 + src/vbox/vbox_tmpl.c | 1 + src/xen/xen_driver.c | 1 +
Oops, missed the vmware driver. I fixed that. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

This patch implements the code to address the new API in the qemu driver. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- src/qemu/qemu_driver.c | 64 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 13 deletions(-) Index: libvirt-git/src/qemu/qemu_driver.c =================================================================== --- libvirt-git.orig/src/qemu/qemu_driver.c +++ libvirt-git/src/qemu/qemu_driver.c @@ -1569,12 +1569,22 @@ cleanup: return ret; } -static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { +static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, + unsigned int flags) { struct qemud_driver *driver = dom->conn->privateData; qemuDomainObjPrivatePtr priv; virDomainObjPtr vm; + virDomainDefPtr persistentDef; int ret = -1, r; + 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); @@ -1595,27 +1605,51 @@ static int qemudDomainSetMemory(virDomai if (qemuDomainObjBeginJob(vm) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { + if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_MEM_LIVE)) { qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running")); goto endjob; } - priv = vm->privateData; - qemuDomainObjEnterMonitor(vm); - r = qemuMonitorSetBalloon(priv->mon, newmem); - qemuDomainObjExitMonitor(vm); - if (r < 0) + if (!vm->persistent && (flags & VIR_DOMAIN_MEM_CONFIG)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change persistent config of a transient domain")); goto endjob; + } - /* Lack of balloon support is a fatal error */ - if (r == 0) { - qemuReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("cannot set memory of an active domain")); + if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm))) goto endjob; + + switch (flags) { + case VIR_DOMAIN_MEM_CONFIG: + persistentDef->mem.cur_balloon = newmem; + ret = 0; + break; + + case VIR_DOMAIN_MEM_LIVE: + case VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG: + priv = vm->privateData; + qemuDomainObjEnterMonitor(vm); + r = qemuMonitorSetBalloon(priv->mon, newmem); + qemuDomainObjExitMonitor(vm); + if (r < 0) + goto endjob; + /* Lack of balloon support is a fatal error */ + if (r == 0) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot set memory of an active domain")); + goto endjob; + } + if (flags & VIR_DOMAIN_MEM_CONFIG) + persistentDef->mem.cur_balloon = newmem; + ret = 0; + break; } - ret = 0; + /* Save the persistent config to disk */ + if (flags & VIR_DOMAIN_MEM_CONFIG) + ret = virDomainSaveConfig(driver->configDir, persistentDef); + endjob: if (qemuDomainObjEndJob(vm) == 0) vm = NULL; @@ -1626,6 +1660,10 @@ cleanup: return ret; } +static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { + return qemudDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_MEM_LIVE); +} + static int qemudDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { struct qemud_driver *driver = dom->conn->privateData; @@ -6789,7 +6827,7 @@ static virDriver qemuDriver = { qemudDomainGetMaxMemory, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ qemudDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + qemudDomainSetMemoryFlags, /* domainSetMemoryFlags */ qemudDomainGetInfo, /* domainGetInfo */ qemudDomainSave, /* domainSave */ qemudDomainRestore, /* domainRestore */

On Wed, Mar 02, 2011 at 05:13:09PM +0900, Taku Izumi wrote:
This patch implements the code to address the new API in the qemu driver.
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- src/qemu/qemu_driver.c | 64 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 13 deletions(-)
Index: libvirt-git/src/qemu/qemu_driver.c =================================================================== --- libvirt-git.orig/src/qemu/qemu_driver.c +++ libvirt-git/src/qemu/qemu_driver.c @@ -1569,12 +1569,22 @@ cleanup: return ret; }
-static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { +static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, + unsigned int flags) { struct qemud_driver *driver = dom->conn->privateData; qemuDomainObjPrivatePtr priv; virDomainObjPtr vm; + virDomainDefPtr persistentDef; int ret = -1, r;
+ 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); + }
I think you forgot a 'return -1' statement just here.
+ qemuDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); qemuDriverUnlock(driver); @@ -1595,27 +1605,51 @@ static int qemudDomainSetMemory(virDomai if (qemuDomainObjBeginJob(vm) < 0) goto cleanup;
- if (!virDomainObjIsActive(vm)) { + if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_MEM_LIVE)) { qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running")); goto endjob; }
- priv = vm->privateData; - qemuDomainObjEnterMonitor(vm); - r = qemuMonitorSetBalloon(priv->mon, newmem); - qemuDomainObjExitMonitor(vm); - if (r < 0) + if (!vm->persistent && (flags & VIR_DOMAIN_MEM_CONFIG)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change persistent config of a transient domain")); goto endjob; + }
- /* Lack of balloon support is a fatal error */ - if (r == 0) { - qemuReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("cannot set memory of an active domain")); + if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm))) goto endjob; + + switch (flags) { + case VIR_DOMAIN_MEM_CONFIG: + persistentDef->mem.cur_balloon = newmem; + ret = 0; + break; + + case VIR_DOMAIN_MEM_LIVE: + case VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG: + priv = vm->privateData; + qemuDomainObjEnterMonitor(vm); + r = qemuMonitorSetBalloon(priv->mon, newmem); + qemuDomainObjExitMonitor(vm); + if (r < 0) + goto endjob; + /* Lack of balloon support is a fatal error */ + if (r == 0) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot set memory of an active domain")); + goto endjob; + } + if (flags & VIR_DOMAIN_MEM_CONFIG) + persistentDef->mem.cur_balloon = newmem; + ret = 0; + break; }
I think it is a little wierd to use a 'switch' statement for processing this. I'd just have a pair of 'if' statements eg if (flags & VIR_DOMAIN_MEM_LIVE) { .....do monitor stuff.... } if (flags & VIR_DOMAIN_MEM_CONFIG) { persistentDef->mem.cur_balloon = newmem; ret = virDomainSaveConfig(driver->configDir, persistentDef); } Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 03/09/2011 08:57 AM, Daniel P. Berrange wrote:
+ switch (flags) { + case VIR_DOMAIN_MEM_CONFIG: + persistentDef->mem.cur_balloon = newmem; + ret = 0; + break; + + case VIR_DOMAIN_MEM_LIVE: + case VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG:
I think it is a little wierd to use a 'switch' statement for processing this. I'd just have a pair of 'if' statements eg
if (flags & VIR_DOMAIN_MEM_LIVE) { .....do monitor stuff.... }
if (flags & VIR_DOMAIN_MEM_CONFIG) { persistentDef->mem.cur_balloon = newmem; ret = virDomainSaveConfig(driver->configDir, persistentDef); }
That's probably due to copy-and-paste from the persistent vcpu stuff; which admittedly is pretty convoluted stuff. I'm all for a simpler design, if it works. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 03/02/2011 01:13 AM, Taku Izumi wrote:
This patch implements the code to address the new API in the qemu driver.
+ if (!vm->persistent && (flags & VIR_DOMAIN_MEM_CONFIG)) { + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change persistent config of a transient domain")); goto endjob; + }
+ if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm))) goto endjob;
Doesn't that fail for a transient domain? That is, shouldn't the persistentDef only be set when flags & VIR_DOMAIN_MEM_CONFIG is requested and validated?
+ + switch (flags) { + case VIR_DOMAIN_MEM_CONFIG: + persistentDef->mem.cur_balloon = newmem; + ret = 0; + break; + + case VIR_DOMAIN_MEM_LIVE: + case VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_CONFIG: + priv = vm->privateData; + qemuDomainObjEnterMonitor(vm); + r = qemuMonitorSetBalloon(priv->mon, newmem);
Merge conflict with my audit patches. Plus Daniel's request to rearrange the switch statement into if statements.
+ qemuDomainObjExitMonitor(vm);
@@ -6789,7 +6827,7 @@ static virDriver qemuDriver = { qemudDomainGetMaxMemory, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ qemudDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + qemudDomainSetMemoryFlags, /* domainSetMemoryFlags */
Hmm, for other API additions, I have provided dummy wrappers for the new function anywhere the old function existed, that merely require the same flags as the old function would use. I'll probably propose that as a followup patch. Here's what I ended up with before pushing: diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c index 2f15144..7921d98 100644 --- i/src/qemu/qemu_driver.c +++ w/src/qemu/qemu_driver.c @@ -1568,12 +1568,22 @@ cleanup: return ret; } -static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { +static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, + unsigned int flags) { struct qemud_driver *driver = dom->conn->privateData; qemuDomainObjPrivatePtr priv; virDomainObjPtr vm; + virDomainDefPtr persistentDef = NULL; int ret = -1, r; + 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); @@ -1594,24 +1604,42 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { if (qemuDomainObjBeginJob(vm) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { + if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_MEM_LIVE)) { qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running")); goto endjob; } - priv = vm->privateData; - qemuDomainObjEnterMonitor(vm); - r = qemuMonitorSetBalloon(priv->mon, newmem); - qemuDomainObjExitMonitor(vm); - qemuAuditMemory(vm, vm->def->mem.cur_balloon, newmem, "update", r == 1); - if (r < 0) - goto endjob; + if (flags & VIR_DOMAIN_MEM_CONFIG) { + if (!vm->persistent) { + qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change persistent config of a transient domain")); + goto endjob; + } + if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm))) + goto endjob; + } - /* Lack of balloon support is a fatal error */ - if (r == 0) { - qemuReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("cannot set memory of an active domain")); + if (flags & VIR_DOMAIN_MEM_LIVE) { + priv = vm->privateData; + qemuDomainObjEnterMonitor(vm); + r = qemuMonitorSetBalloon(priv->mon, newmem); + qemuDomainObjExitMonitor(vm); + qemuAuditMemory(vm, vm->def->mem.cur_balloon, newmem, "update", r == 1); + if (r < 0) + goto endjob; + + /* Lack of balloon support is a fatal error */ + if (r == 0) { + qemuReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot set memory of an active domain")); + goto endjob; + } + } + + if (flags& VIR_DOMAIN_MEM_CONFIG) { + persistentDef->mem.cur_balloon = newmem; + ret = virDomainSaveConfig(driver->configDir, persistentDef); goto endjob; } @@ -1626,6 +1654,10 @@ cleanup: return ret; } +static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) { + return qemudDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_MEM_LIVE); +} + static int qemudDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { struct qemud_driver *driver = dom->conn->privateData; @@ -6854,7 +6886,7 @@ static virDriver qemuDriver = { qemudDomainGetMaxMemory, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ qemudDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + qemudDomainSetMemoryFlags, /* domainSetMemoryFlags */ qemudDomainGetInfo, /* domainGetInfo */ qemudDomainSave, /* domainSave */ qemudDomainRestore, /* domainRestore */ -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

* src/esx/esx_driver.c (esxDomainSetMemory): Move guts... (esxDomainSetMemoryFlags): ...here. * src/lxc/lxc_driver.c (lxcDomainSetMemory) (lxcDomainSetMemoryFlags): Likewise. * src/test/test_driver.c (testSetMemory, testSetMemoryFlags): Likewise. * src/uml/uml_driver.c (umlDomainSetMemory) (umlDomainSetMemoryFlags): Likewise. * src/vbox/vbox_tmpl.c (vboxDomainSetMemory) (vboxDomainSetMemoryFlags): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainSetMemory) (xenUnifiedDomainSetMemoryFlags): Likewise. ---
Hmm, for other API additions, I have provided dummy wrappers for the new function anywhere the old function existed, that merely require the same flags as the old function would use. I'll probably propose that as a followup patch.
Like so. src/esx/esx_driver.c | 17 ++++++++++++++--- src/lxc/lxc_driver.c | 15 +++++++++++++-- src/test/test_driver.c | 19 ++++++++++++++++--- src/uml/uml_driver.c | 15 +++++++++++++-- src/vbox/vbox_tmpl.c | 15 +++++++++++++-- src/xen/xen_driver.c | 15 ++++++++++++++- 6 files changed, 83 insertions(+), 13 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 37e104e..a2d8433 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2111,7 +2111,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) static int -esxDomainSetMemory(virDomainPtr domain, unsigned long memory) +esxDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, + unsigned int flags) { int result = -1; esxPrivate *priv = domain->conn->privateData; @@ -2121,6 +2122,12 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory) esxVI_TaskInfoState taskInfoState; char *taskInfoErrorMessage = NULL; + if (flags != VIR_DOMAIN_MEM_LIVE) { + ESX_ERROR(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } + if (esxVI_EnsureSession(priv->primary) < 0) { return -1; } @@ -2164,7 +2171,11 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory) return result; } - +static int +esxDomainSetMemory(virDomainPtr domain, unsigned long memory) +{ + return esxDomainSetMemoryFlags(domain, memory, VIR_DOMAIN_MEM_LIVE); +} static int esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) @@ -4593,7 +4604,7 @@ static virDriver esxDriver = { esxDomainGetMaxMemory, /* domainGetMaxMemory */ esxDomainSetMaxMemory, /* domainSetMaxMemory */ esxDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + esxDomainSetMemoryFlags, /* domainSetMemoryFlags */ esxDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4ddeffd..f65d0a2 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -651,12 +651,19 @@ cleanup: return ret; } -static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { +static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, + unsigned int flags) { lxc_driver_t *driver = dom->conn->privateData; virDomainObjPtr vm; virCgroupPtr cgroup = NULL; int ret = -1; + if (flags != VIR_DOMAIN_MEM_LIVE) { + lxcError(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } + lxcDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); lxcDriverUnlock(driver); @@ -708,6 +715,10 @@ cleanup: return ret; } +static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { + return lxcDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_MEM_LIVE); +} + static int lxcDomainSetMemoryParameters(virDomainPtr dom, virMemoryParameterPtr params, int nparams, @@ -2851,7 +2862,7 @@ static virDriver lxcDriver = { lxcDomainGetMaxMemory, /* domainGetMaxMemory */ lxcDomainSetMaxMemory, /* domainSetMaxMemory */ lxcDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + lxcDomainSetMemoryFlags, /* domainSetMemoryFlags */ lxcDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 438f5a3..3973b08 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2006,13 +2006,20 @@ cleanup: return ret; } -static int testSetMemory(virDomainPtr domain, - unsigned long memory) +static int testSetMemoryFlags(virDomainPtr domain, + unsigned long memory, + unsigned int flags) { testConnPtr privconn = domain->conn->privateData; virDomainObjPtr privdom; int ret = -1; + if (flags != VIR_DOMAIN_MEM_LIVE) { + testError(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } + testDriverLock(privconn); privdom = virDomainFindByName(&privconn->domains, domain->name); @@ -2037,6 +2044,12 @@ cleanup: return ret; } +static int testSetMemory(virDomainPtr domain, + unsigned long memory) +{ + return testSetMemoryFlags(domain, memory, VIR_DOMAIN_MEM_LIVE); +} + static int testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) { @@ -5365,7 +5378,7 @@ static virDriver testDriver = { testGetMaxMemory, /* domainGetMaxMemory */ testSetMaxMemory, /* domainSetMaxMemory */ testSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + testSetMemoryFlags, /* domainSetMemoryFlags */ testGetDomainInfo, /* domainGetInfo */ testDomainSave, /* domainSave */ testDomainRestore, /* domainRestore */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 671fcc5..306ef7f 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1439,11 +1439,18 @@ cleanup: return ret; } -static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) { +static int umlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, + unsigned int flags) { struct uml_driver *driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; + if (flags != VIR_DOMAIN_MEM_LIVE) { + umlReportError(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } + umlDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); umlDriverUnlock(driver); @@ -1478,6 +1485,10 @@ cleanup: return ret; } +static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) { + return umlDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_MEM_LIVE); +} + static int umlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { struct uml_driver *driver = dom->conn->privateData; @@ -2167,7 +2178,7 @@ static virDriver umlDriver = { umlDomainGetMaxMemory, /* domainGetMaxMemory */ umlDomainSetMaxMemory, /* domainSetMaxMemory */ umlDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + umlDomainSetMemoryFlags, /* domainSetMemoryFlags */ umlDomainGetInfo, /* domainGetInfo */ NULL, /* domainSave */ NULL, /* domainRestore */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 342ab5e..a5e6211 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -1749,7 +1749,8 @@ static char *vboxDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) { return osType; } -static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) { +static int vboxDomainSetMemoryFlags(virDomainPtr dom, unsigned long memory, + unsigned int flags) { VBOX_OBJECT_CHECK(dom->conn, int, -1); IMachine *machine = NULL; vboxIID iid = VBOX_IID_INITIALIZER; @@ -1757,6 +1758,12 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) { PRBool isAccessible = PR_FALSE; nsresult rc; + if (flags != VIR_DOMAIN_MEM_LIVE) { + vboxError(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } + vboxIIDFromUUID(&iid, dom->uuid); rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine); if (NS_FAILED(rc)) { @@ -1805,6 +1812,10 @@ cleanup: return ret; } +static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) { + return vboxDomainSetMemoryFlags(dom, memory, VIR_DOMAIN_MEM_LIVE); +} + static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { VBOX_OBJECT_CHECK(dom->conn, int, -1); vboxArray machines = VBOX_ARRAY_INITIALIZER; @@ -8555,7 +8566,7 @@ virDriver NAME(Driver) = { NULL, /* domainGetMaxMemory */ NULL, /* domainSetMaxMemory */ vboxDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + vboxDomainSetMemoryFlags, /* domainSetMemoryFlags */ vboxDomainGetInfo, /* domainGetInfo */ vboxDomainSave, /* domainSave */ NULL, /* domainRestore */ diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index a777225..a2b6559 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -955,11 +955,18 @@ xenUnifiedDomainSetMaxMemory (virDomainPtr dom, unsigned long memory) } static int -xenUnifiedDomainSetMemory (virDomainPtr dom, unsigned long memory) +xenUnifiedDomainSetMemoryFlags(virDomainPtr dom, unsigned long memory, + unsigned int flags) { GET_PRIVATE(dom->conn); int i; + if (flags != VIR_DOMAIN_MEM_LIVE) { + xenUnifiedError(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } + for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) if (priv->opened[i] && drivers[i]->domainSetMemory && @@ -970,6 +977,12 @@ xenUnifiedDomainSetMemory (virDomainPtr dom, unsigned long memory) } static int +xenUnifiedDomainSetMemory (virDomainPtr dom, unsigned long memory) +{ + return xenUnifiedDomainSetMemoryFlags(dom, memory, VIR_DOMAIN_MEM_LIVE); +} + +static int xenUnifiedDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info) { GET_PRIVATE(dom->conn); -- 1.7.4

On 03/10/2011 03:53 PM, Eric Blake wrote:
Hmm, for other API additions, I have provided dummy wrappers for the new function anywhere the old function existed, that merely require the same flags as the old function would use. I'll probably propose that as a followup patch.
Like so.
src/esx/esx_driver.c | 17 ++++++++++++++--- src/lxc/lxc_driver.c | 15 +++++++++++++-- src/test/test_driver.c | 19 ++++++++++++++++--- src/uml/uml_driver.c | 15 +++++++++++++-- src/vbox/vbox_tmpl.c | 15 +++++++++++++-- src/xen/xen_driver.c | 15 ++++++++++++++-
Hmm, re-reading this patch exposes a problem (existing before this patch, and this patch doesn't change the situation): In 0.8.8, 'virsh setmem' on xen:/// meant: if guest is live, then affect live (only); otherwise affect config But with this patch, 'virsh setmem --live' will _still_ affect a config. What we need is three flags instead of two: VIR_DOMAIN_MEM_LIVE VIR_DOMAIN_MEM_CONFIG VIR_DOMAIN_MEM_CURRENT - use LIVE or CONFIG according to domain state where we document that virDomainSetMemory is hypervisor-defined whether it implies CURRENT (xen) or LIVE (qemu), and where virDomainSetMemoryFlags properly honors all three flags for both hypervisors. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Fri, Mar 11, 2011 at 08:26:43AM -0700, Eric Blake wrote:
On 03/10/2011 03:53 PM, Eric Blake wrote:
Hmm, for other API additions, I have provided dummy wrappers for the new function anywhere the old function existed, that merely require the same flags as the old function would use. I'll probably propose that as a followup patch.
Like so.
src/esx/esx_driver.c | 17 ++++++++++++++--- src/lxc/lxc_driver.c | 15 +++++++++++++-- src/test/test_driver.c | 19 ++++++++++++++++--- src/uml/uml_driver.c | 15 +++++++++++++-- src/vbox/vbox_tmpl.c | 15 +++++++++++++-- src/xen/xen_driver.c | 15 ++++++++++++++-
Hmm, re-reading this patch exposes a problem (existing before this patch, and this patch doesn't change the situation):
In 0.8.8, 'virsh setmem' on xen:/// meant: if guest is live, then affect live (only); otherwise affect config
But with this patch, 'virsh setmem --live' will _still_ affect a config.
What we need is three flags instead of two:
VIR_DOMAIN_MEM_LIVE VIR_DOMAIN_MEM_CONFIG VIR_DOMAIN_MEM_CURRENT - use LIVE or CONFIG according to domain state
where we document that virDomainSetMemory is hypervisor-defined whether it implies CURRENT (xen) or LIVE (qemu), and where virDomainSetMemoryFlags properly honors all three flags for both hypervisors.
Ideally VIR_DOMAIN_MEM_CURRENT would have value 0 and thus be the default. So the new API default matches the old API Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Hi Eric,
Hmm, re-reading this patch exposes a problem (existing before this patch, and this patch doesn't change the situation):
In 0.8.8, 'virsh setmem' on xen:/// meant: if guest is live, then affect live (only); otherwise affect config
But with this patch, 'virsh setmem --live' will _still_ affect a config.
What we need is three flags instead of two:
VIR_DOMAIN_MEM_LIVE VIR_DOMAIN_MEM_CONFIG VIR_DOMAIN_MEM_CURRENT - use LIVE or CONFIG according to domain state
where we document that virDomainSetMemory is hypervisor-defined whether it implies CURRENT (xen) or LIVE (qemu), and where virDomainSetMemoryFlags properly honors all three flags for both hypervisors.
Does this indicate that the new option "--current" is added to "virsh setmem" command? Or does this indicate "virsh setmem" command with --live option invokes xenUnifiedDomainSetMemoryFlags with VIR_DOMAIN_MEM_CURRENT in case of Xen? Taku Izumi <izumi.taku@jp.fujitsu.com>

On 03/14/2011 11:11 PM, Taku Izumi wrote:
What we need is three flags instead of two:
VIR_DOMAIN_MEM_LIVE VIR_DOMAIN_MEM_CONFIG VIR_DOMAIN_MEM_CURRENT - use LIVE or CONFIG according to domain state
Daniel's suggestion of letting virDomainSetMemoryFlags(,0) operate as _CURRENT mode sounds best to me (right now, the qemu implementation rejects flags==0, and none of the other hypervisors have flags support yet).
where we document that virDomainSetMemory is hypervisor-defined whether it implies CURRENT (xen) or LIVE (qemu), and where virDomainSetMemoryFlags properly honors all three flags for both hypervisors.
Insofar as possible (for example, Matthias pointed out that esx cannot honor _LIVE in isolation - it only supports _LIVE|_CONFIG on running, and _CONFIG on inactive).
Does this indicate that the new option "--current" is added to "virsh setmem" command? Or does this indicate "virsh setmem" command with --live option invokes xenUnifiedDomainSetMemoryFlags with VIR_DOMAIN_MEM_CURRENT in case of Xen?
I think what this means is that we do need three boolean flags in the virsh command: virsh setmem => virDomainSetMemory (which in turn might be virDomainSetMemoryFlags(,0) or virDomainSetMemoryFlags(,_LIVE) depending on hypervisor) virsh setmem --live => virDomainSetMemoryFlags(,_LIVE) virsh setmem --config => virDomainSetMemoryFlags(,_CONFIG) virsh setmem --live --config => virDomainSetMemoryFlags(,_LIVE|_CONFIG) virsh setmem --current => virDomainSetMemoryFlags(,0) virsh setmem --current --live => virsh error virsh setmem --current --config => virsh error and since virDomainSetMemory no longer implies _LIVE for all hypervisors, we also have to delete the current code base fallback of: virsh setmem --live => virDomainSetMemory That is, no flags gets the old API with its hypervisor-specific quirks, and any flag at all requires the new API and has exact control over what gets modified. Is this something you are willing to tackle? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Hi Eric,
I think what this means is that we do need three boolean flags in the virsh command:
virsh setmem => virDomainSetMemory (which in turn might be virDomainSetMemoryFlags(,0) or virDomainSetMemoryFlags(,_LIVE) depending on hypervisor) virsh setmem --live => virDomainSetMemoryFlags(,_LIVE) virsh setmem --config => virDomainSetMemoryFlags(,_CONFIG) virsh setmem --live --config => virDomainSetMemoryFlags(,_LIVE|_CONFIG) virsh setmem --current => virDomainSetMemoryFlags(,0) virsh setmem --current --live => virsh error virsh setmem --current --config => virsh error
and since virDomainSetMemory no longer implies _LIVE for all hypervisors, we also have to delete the current code base fallback of: virsh setmem --live => virDomainSetMemory
That is, no flags gets the old API with its hypervisor-specific quirks, and any flag at all requires the new API and has exact control over what gets modified.
Is this something you are willing to tackle?
Thank you for providing further information. I'm not sure if I can understand this completely, but I'm willing to do. Taku Izumi

2011/3/10 Eric Blake <eblake@redhat.com>:
* src/esx/esx_driver.c (esxDomainSetMemory): Move guts... (esxDomainSetMemoryFlags): ...here. * src/lxc/lxc_driver.c (lxcDomainSetMemory) (lxcDomainSetMemoryFlags): Likewise. * src/test/test_driver.c (testSetMemory, testSetMemoryFlags): Likewise. * src/uml/uml_driver.c (umlDomainSetMemory) (umlDomainSetMemoryFlags): Likewise. * src/vbox/vbox_tmpl.c (vboxDomainSetMemory) (vboxDomainSetMemoryFlags): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainSetMemory) (xenUnifiedDomainSetMemoryFlags): Likewise. ---
Hmm, for other API additions, I have provided dummy wrappers for the new function anywhere the old function existed, that merely require the same flags as the old function would use. I'll probably propose that as a followup patch.
Like so.
src/esx/esx_driver.c | 17 ++++++++++++++--- src/lxc/lxc_driver.c | 15 +++++++++++++-- src/test/test_driver.c | 19 ++++++++++++++++--- src/uml/uml_driver.c | 15 +++++++++++++-- src/vbox/vbox_tmpl.c | 15 +++++++++++++-- src/xen/xen_driver.c | 15 ++++++++++++++- 6 files changed, 83 insertions(+), 13 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 37e104e..a2d8433 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2111,7 +2111,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
static int -esxDomainSetMemory(virDomainPtr domain, unsigned long memory) +esxDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, + unsigned int flags) { int result = -1; esxPrivate *priv = domain->conn->privateData; @@ -2121,6 +2122,12 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory) esxVI_TaskInfoState taskInfoState; char *taskInfoErrorMessage = NULL;
+ if (flags != VIR_DOMAIN_MEM_LIVE) { + ESX_ERROR(VIR_ERR_INVALID_ARG, + _("invalid flag combination: (0x%x)"), flags); + return -1; + } +
Actually this doesn't match with what ESX really does. There is no such thing like distinct values for _LIVE and _CONFIG. Changing the memory value always affects a running domain and is persistent at the same time. Matthias

On 03/10/2011 03:53 PM, Eric Blake wrote:
* src/esx/esx_driver.c (esxDomainSetMemory): Move guts... (esxDomainSetMemoryFlags): ...here.
Hmm, for other API additions, I have provided dummy wrappers for the new function anywhere the old function existed, that merely require the same flags as the old function would use. I'll probably propose that as a followup patch.
Like so.
src/esx/esx_driver.c | 17 ++++++++++++++--- src/lxc/lxc_driver.c | 15 +++++++++++++-- src/test/test_driver.c | 19 ++++++++++++++++--- src/uml/uml_driver.c | 15 +++++++++++++-- src/vbox/vbox_tmpl.c | 15 +++++++++++++-- src/xen/xen_driver.c | 15 ++++++++++++++- 6 files changed, 83 insertions(+), 13 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 37e104e..a2d8433 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2111,7 +2111,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
static int -esxDomainSetMemory(virDomainPtr domain, unsigned long memory) +esxDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, + unsigned int flags)
I haven't revisited this patch since the rest of the setmem/setmaxmem changes went in, but we really should look at getting the rest of the hypervisors to support the new SetMemoryFlags API (even if only for the single flag combination that they previously supported). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

This patch implements the remote protocol to address the new API. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- daemon/remote.c | 26 ++++++++++++++++++++++++++ daemon/remote_dispatch_args.h | 1 + daemon/remote_dispatch_prototypes.h | 8 ++++++++ daemon/remote_dispatch_table.h | 5 +++++ src/remote/remote_driver.c | 29 ++++++++++++++++++++++++++++- src/remote/remote_protocol.c | 14 ++++++++++++++ src/remote/remote_protocol.h | 10 ++++++++++ src/remote/remote_protocol.x | 9 ++++++++- src/remote_protocol-structs | 5 +++++ 9 files changed, 105 insertions(+), 2 deletions(-) Index: libvirt-git/daemon/remote.c =================================================================== --- libvirt-git.orig/daemon/remote.c +++ libvirt-git/daemon/remote.c @@ -2384,6 +2384,32 @@ remoteDispatchDomainSetMemory (struct qe } static int +remoteDispatchDomainSetMemoryFlags (struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + remote_domain_set_memory_flags_args *args, + void *ret ATTRIBUTE_UNUSED) +{ + virDomainPtr dom; + + dom = get_nonnull_domain (conn, args->dom); + if (dom == NULL) { + remoteDispatchConnError(rerr, conn); + return -1; + } + + if (virDomainSetMemoryFlags (dom, args->memory, args->flags) == -1) { + virDomainFree(dom); + remoteDispatchConnError(rerr, conn); + return -1; + } + virDomainFree(dom); + return 0; +} + +static int remoteDispatchDomainSetMemoryParameters(struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client Index: libvirt-git/daemon/remote_dispatch_args.h =================================================================== --- libvirt-git.orig/daemon/remote_dispatch_args.h +++ libvirt-git/daemon/remote_dispatch_args.h @@ -27,6 +27,7 @@ remote_domain_set_autostart_args val_remote_domain_set_autostart_args; remote_domain_set_max_memory_args val_remote_domain_set_max_memory_args; remote_domain_set_memory_args val_remote_domain_set_memory_args; + remote_domain_set_memory_flags_args val_remote_domain_set_memory_flags_args; remote_domain_set_vcpus_args val_remote_domain_set_vcpus_args; remote_domain_shutdown_args val_remote_domain_shutdown_args; remote_domain_suspend_args val_remote_domain_suspend_args; Index: libvirt-git/daemon/remote_dispatch_prototypes.h =================================================================== --- libvirt-git.orig/daemon/remote_dispatch_prototypes.h +++ libvirt-git/daemon/remote_dispatch_prototypes.h @@ -554,6 +554,14 @@ static int remoteDispatchDomainSetMemory remote_error *err, remote_domain_set_memory_args *args, void *ret); +static int remoteDispatchDomainSetMemoryFlags( + struct qemud_server *server, + struct qemud_client *client, + virConnectPtr conn, + remote_message_header *hdr, + remote_error *err, + remote_domain_set_memory_flags_args *args, + void *ret); static int remoteDispatchDomainSetMemoryParameters( struct qemud_server *server, struct qemud_client *client, Index: libvirt-git/daemon/remote_dispatch_table.h =================================================================== --- libvirt-git.orig/daemon/remote_dispatch_table.h +++ libvirt-git/daemon/remote_dispatch_table.h @@ -1022,3 +1022,8 @@ .args_filter = (xdrproc_t) xdr_remote_get_sysinfo_args, .ret_filter = (xdrproc_t) xdr_remote_get_sysinfo_ret, }, +{ /* DomainSetMemoryFlags => 204 */ + .fn = (dispatch_fn) remoteDispatchDomainSetMemoryFlags, + .args_filter = (xdrproc_t) xdr_remote_domain_set_memory_flags_args, + .ret_filter = (xdrproc_t) xdr_void, +}, Index: libvirt-git/src/remote/remote_driver.c =================================================================== --- libvirt-git.orig/src/remote/remote_driver.c +++ libvirt-git/src/remote/remote_driver.c @@ -2445,6 +2445,33 @@ done: } static int +remoteDomainSetMemoryFlags (virDomainPtr domain, unsigned long memory, unsigned int flags) +{ + int rv = -1; + remote_domain_set_memory_flags_args args; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + make_nonnull_domain (&args.dom, domain); + args.memory = memory; + args.flags = flags; + + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_MEMORY_FLAGS, + (xdrproc_t) xdr_remote_domain_set_memory_flags_args, + (char *) &args, + (xdrproc_t) xdr_void, + (char *) NULL) == -1) + goto done; + + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int remoteDomainSetMemoryParameters (virDomainPtr domain, virMemoryParameterPtr params, int nparams, @@ -10868,7 +10895,7 @@ static virDriver remote_driver = { remoteDomainGetMaxMemory, /* domainGetMaxMemory */ remoteDomainSetMaxMemory, /* domainSetMaxMemory */ remoteDomainSetMemory, /* domainSetMemory */ - NULL, /* domainSetMemoryFlags */ + remoteDomainSetMemoryFlags, /* domainSetMemoryFlags */ remoteDomainGetInfo, /* domainGetInfo */ remoteDomainSave, /* domainSave */ remoteDomainRestore, /* domainRestore */ Index: libvirt-git/src/remote/remote_protocol.c =================================================================== --- libvirt-git.orig/src/remote/remote_protocol.c +++ libvirt-git/src/remote/remote_protocol.c @@ -1070,6 +1070,20 @@ xdr_remote_domain_set_memory_args (XDR * } bool_t +xdr_remote_domain_set_memory_flags_args (XDR *xdrs, + remote_domain_set_memory_flags_args *objp) +{ + + if (!xdr_remote_nonnull_domain (xdrs, &objp->dom)) + return FALSE; + if (!xdr_uint64_t (xdrs, &objp->memory)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->flags)) + return FALSE; + return TRUE; +} + +bool_t xdr_remote_domain_get_info_args (XDR *xdrs, remote_domain_get_info_args *objp) { Index: libvirt-git/src/remote/remote_protocol.h =================================================================== --- libvirt-git.orig/src/remote/remote_protocol.h +++ libvirt-git/src/remote/remote_protocol.h @@ -581,6 +581,13 @@ struct remote_domain_set_memory_args { }; typedef struct remote_domain_set_memory_args remote_domain_set_memory_args; +struct remote_domain_set_memory_flags_args { + remote_nonnull_domain dom; + uint64_t memory; + u_int flags; +}; +typedef struct remote_domain_set_memory_flags_args remote_domain_set_memory_flags_args; + struct remote_domain_get_info_args { remote_nonnull_domain dom; }; @@ -2331,6 +2338,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_OPEN_CONSOLE = 201, REMOTE_PROC_DOMAIN_IS_UPDATED = 202, REMOTE_PROC_GET_SYSINFO = 203, + REMOTE_PROC_DOMAIN_SET_MEMORY_FLAGS = 204, }; typedef enum remote_procedure remote_procedure; @@ -2448,6 +2456,7 @@ extern bool_t xdr_remote_domain_get_max extern bool_t xdr_remote_domain_get_max_memory_ret (XDR *, remote_domain_get_max_memory_ret*); extern bool_t xdr_remote_domain_set_max_memory_args (XDR *, remote_domain_set_max_memory_args*); extern bool_t xdr_remote_domain_set_memory_args (XDR *, remote_domain_set_memory_args*); +extern bool_t xdr_remote_domain_set_memory_flags_args (XDR *, remote_domain_set_memory_flags_args*); extern bool_t xdr_remote_domain_get_info_args (XDR *, remote_domain_get_info_args*); extern bool_t xdr_remote_domain_get_info_ret (XDR *, remote_domain_get_info_ret*); extern bool_t xdr_remote_domain_save_args (XDR *, remote_domain_save_args*); @@ -2796,6 +2805,7 @@ extern bool_t xdr_remote_domain_get_max_ extern bool_t xdr_remote_domain_get_max_memory_ret (); extern bool_t xdr_remote_domain_set_max_memory_args (); extern bool_t xdr_remote_domain_set_memory_args (); +extern bool_t xdr_remote_domain_set_memory_flags_args (); extern bool_t xdr_remote_domain_get_info_args (); extern bool_t xdr_remote_domain_get_info_ret (); extern bool_t xdr_remote_domain_save_args (); Index: libvirt-git/src/remote/remote_protocol.x =================================================================== --- libvirt-git.orig/src/remote/remote_protocol.x +++ libvirt-git/src/remote/remote_protocol.x @@ -641,6 +641,12 @@ struct remote_domain_set_memory_args { unsigned hyper memory; }; +struct remote_domain_set_memory_flags_args { + remote_nonnull_domain dom; + unsigned hyper memory; + unsigned int flags; +}; + struct remote_domain_get_info_args { remote_nonnull_domain dom; }; @@ -2103,7 +2109,8 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_OPEN_CONSOLE = 201, REMOTE_PROC_DOMAIN_IS_UPDATED = 202, - REMOTE_PROC_GET_SYSINFO = 203 + REMOTE_PROC_GET_SYSINFO = 203, + REMOTE_PROC_DOMAIN_SET_MEMORY_FLAGS = 204 /* * Notice how the entries are grouped in sets of 10 ? Index: libvirt-git/src/remote_protocol-structs =================================================================== --- libvirt-git.orig/src/remote_protocol-structs +++ libvirt-git/src/remote_protocol-structs @@ -340,6 +340,11 @@ struct remote_domain_set_memory_args { remote_nonnull_domain dom; uint64_t memory; }; +struct remote_domain_set_memory_flags_args { + remote_nonnull_domain dom; + uint64_t memory; + u_int flags; +}; struct remote_domain_get_info_args { remote_nonnull_domain dom; };

On Wed, Mar 02, 2011 at 05:13:24PM +0900, Taku Izumi wrote:
This patch implements the remote protocol to address the new API.
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- daemon/remote.c | 26 ++++++++++++++++++++++++++ daemon/remote_dispatch_args.h | 1 + daemon/remote_dispatch_prototypes.h | 8 ++++++++ daemon/remote_dispatch_table.h | 5 +++++ src/remote/remote_driver.c | 29 ++++++++++++++++++++++++++++- src/remote/remote_protocol.c | 14 ++++++++++++++ src/remote/remote_protocol.h | 10 ++++++++++ src/remote/remote_protocol.x | 9 ++++++++- src/remote_protocol-structs | 5 +++++ 9 files changed, 105 insertions(+), 2 deletions(-)
ACK, looks fine Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 03/02/2011 01:13 AM, Taku Izumi wrote:
This patch implements the remote protocol to address the new API.
Index: libvirt-git/src/remote/remote_driver.c =================================================================== --- libvirt-git.orig/src/remote/remote_driver.c +++ libvirt-git/src/remote/remote_driver.c @@ -2445,6 +2445,33 @@ done: }
static int +remoteDomainSetMemoryFlags (virDomainPtr domain, unsigned long memory, unsigned int flags)
The extra newline here caused git to complain that your patch was corrupt. You had several other cases where the patch was botched. After fixing those, the patch still failed indentation in remote_protocol-structs. (Hmm - why do we create that file with TABs in the first place? I should fix that in a followup)
Index: libvirt-git/src/remote_protocol-structs =================================================================== --- libvirt-git.orig/src/remote_protocol-structs +++ libvirt-git/src/remote_protocol-structs @@ -340,6 +340,11 @@ struct remote_domain_set_memory_args { remote_nonnull_domain dom; uint64_t memory; }; +struct remote_domain_set_memory_flags_args { + remote_nonnull_domain dom; + uint64_t memory; + u_int flags; +};
Plus, when I reran rpcgen, it changed the spacing in remote_protocol.c. I pushed after fixing those issues. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

* src/Makefile.am (remote_protocol-structs): Flatten tabs. * src/remote_protocol-structs: Likewise. Also add a hint to emacs to make it easier to keep spaces in the file. ---
After fixing those, the patch still failed indentation in remote_protocol-structs. (Hmm - why do we create that file with TABs in the first place? I should fix that in a followup)
Here's the 'git diff -b' output, followed by the real patch. diff --git c/src/Makefile.am w/src/Makefile.am index 645119e..81f1a27 100644 --- c/src/Makefile.am +++ w/src/Makefile.am @@ -195,10 +195,14 @@ remote_protocol-structs: -e ' $$p =~ s!\t*/\*.*?\*/!!sg;' \ -e ' $$p =~ s!\s+\n!\n!sg;' \ -e ' $$p =~ s!\s+$$!!;' \ + -e ' $$p =~ s!\t! !g;' \ -e ' print "$$p\n";' \ -e ' $$n++;' \ -e ' }' \ -e '}' \ + -e 'BEGIN {' \ + -e ' print "/* -*- c -*- */\n";' \ + -e '}' \ -e 'END {' \ -e ' if ($$n < 300) {' \ -e ' warn "WARNING: your pdwtags program is too old\n";' \ diff --git c/src/remote_protocol-structs w/src/remote_protocol-structs index 6e131c8..726d0b0 100644 --- c/src/remote_protocol-structs +++ w/src/remote_protocol-structs @@ -1,3 +1,4 @@ +/* -*- c -*- */ struct remote_nonnull_domain { remote_nonnull_string name; remote_uuid uuid; src/Makefile.am | 4 + src/remote_protocol-structs | 1433 ++++++++++++++++++++++--------------------- 2 files changed, 721 insertions(+), 716 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 645119e..81f1a27 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -195,10 +195,14 @@ remote_protocol-structs: -e ' $$p =~ s!\t*/\*.*?\*/!!sg;' \ -e ' $$p =~ s!\s+\n!\n!sg;' \ -e ' $$p =~ s!\s+$$!!;' \ + -e ' $$p =~ s!\t! !g;' \ -e ' print "$$p\n";' \ -e ' $$n++;' \ -e ' }' \ -e '}' \ + -e 'BEGIN {' \ + -e ' print "/* -*- c -*- */\n";' \ + -e '}' \ -e 'END {' \ -e ' if ($$n < 300) {' \ -e ' warn "WARNING: your pdwtags program is too old\n";' \ diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 6e131c8..726d0b0 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1,1384 +1,1385 @@ +/* -*- c -*- */ struct remote_nonnull_domain { - remote_nonnull_string name; - remote_uuid uuid; - int id; + remote_nonnull_string name; + remote_uuid uuid; + int id; }; struct remote_nonnull_network { - remote_nonnull_string name; - remote_uuid uuid; + remote_nonnull_string name; + remote_uuid uuid; }; struct remote_nonnull_nwfilter { - remote_nonnull_string name; - remote_uuid uuid; + remote_nonnull_string name; + remote_uuid uuid; }; struct remote_nonnull_interface { - remote_nonnull_string name; - remote_nonnull_string mac; + remote_nonnull_string name; + remote_nonnull_string mac; }; struct remote_nonnull_storage_pool { - remote_nonnull_string name; - remote_uuid uuid; + remote_nonnull_string name; + remote_uuid uuid; }; struct remote_nonnull_storage_vol { - remote_nonnull_string pool; - remote_nonnull_string name; - remote_nonnull_string key; + remote_nonnull_string pool; + remote_nonnull_string name; + remote_nonnull_string key; }; struct remote_nonnull_node_device { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_nonnull_secret { - remote_uuid uuid; - int usageType; - remote_nonnull_string usageID; + remote_uuid uuid; + int usageType; + remote_nonnull_string usageID; }; struct remote_nonnull_domain_snapshot { - remote_nonnull_string name; - remote_nonnull_domain domain; + remote_nonnull_string name; + remote_nonnull_domain domain; }; struct remote_error { - int code; - int domain; - remote_string message; - int level; - remote_domain dom; - remote_string str1; - remote_string str2; - remote_string str3; - int int1; - int int2; - remote_network net; + int code; + int domain; + remote_string message; + int level; + remote_domain dom; + remote_string str1; + remote_string str2; + remote_string str3; + int int1; + int int2; + remote_network net; }; struct remote_vcpu_info { - u_int number; - int state; - uint64_t cpu_time; - int cpu; + u_int number; + int state; + uint64_t cpu_time; + int cpu; }; struct remote_sched_param_value { - int type; - union { - int i; - u_int ui; - int64_t l; - uint64_t ul; - double d; - int b; - } remote_sched_param_value_u; + int type; + union { + int i; + u_int ui; + int64_t l; + uint64_t ul; + double d; + int b; + } remote_sched_param_value_u; }; struct remote_sched_param { - remote_nonnull_string field; - remote_sched_param_value value; + remote_nonnull_string field; + remote_sched_param_value value; }; struct remote_memory_param_value { - int type; - union { - int i; - u_int ui; - int64_t l; - uint64_t ul; - double d; - int b; - } remote_memory_param_value_u; + int type; + union { + int i; + u_int ui; + int64_t l; + uint64_t ul; + double d; + int b; + } remote_memory_param_value_u; }; struct remote_memory_param { - remote_nonnull_string field; - remote_memory_param_value value; + remote_nonnull_string field; + remote_memory_param_value value; }; struct remote_open_args { - remote_string name; - int flags; + remote_string name; + int flags; }; struct remote_supports_feature_args { - int feature; + int feature; }; struct remote_supports_feature_ret { - int supported; + int supported; }; struct remote_get_type_ret { - remote_nonnull_string type; + remote_nonnull_string type; }; struct remote_get_version_ret { - int64_t hv_ver; + int64_t hv_ver; }; struct remote_get_lib_version_ret { - int64_t lib_ver; + int64_t lib_ver; }; struct remote_get_hostname_ret { - remote_nonnull_string hostname; + remote_nonnull_string hostname; }; struct remote_get_sysinfo_args { - u_int flags; + u_int flags; }; struct remote_get_sysinfo_ret { - remote_nonnull_string sysinfo; + remote_nonnull_string sysinfo; }; struct remote_get_uri_ret { - remote_nonnull_string uri; + remote_nonnull_string uri; }; struct remote_get_max_vcpus_args { - remote_string type; + remote_string type; }; struct remote_get_max_vcpus_ret { - int max_vcpus; + int max_vcpus; }; struct remote_node_get_info_ret { - char model[32]; - int64_t memory; - int cpus; - int mhz; - int nodes; - int sockets; - int cores; - int threads; + char model[32]; + int64_t memory; + int cpus; + int mhz; + int nodes; + int sockets; + int cores; + int threads; }; struct remote_get_capabilities_ret { - remote_nonnull_string capabilities; + remote_nonnull_string capabilities; }; struct remote_node_get_cells_free_memory_args { - int startCell; - int maxCells; + int startCell; + int maxCells; }; struct remote_node_get_cells_free_memory_ret { - struct { - u_int freeMems_len; - int64_t * freeMems_val; - } freeMems; + struct { + u_int freeMems_len; + int64_t * freeMems_val; + } freeMems; }; struct remote_node_get_free_memory_ret { - int64_t freeMem; + int64_t freeMem; }; struct remote_domain_get_scheduler_type_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_scheduler_type_ret { - remote_nonnull_string type; - int nparams; + remote_nonnull_string type; + int nparams; }; struct remote_domain_get_scheduler_parameters_args { - remote_nonnull_domain dom; - int nparams; + remote_nonnull_domain dom; + int nparams; }; struct remote_domain_get_scheduler_parameters_ret { - struct { - u_int params_len; - remote_sched_param * params_val; - } params; + struct { + u_int params_len; + remote_sched_param * params_val; + } params; }; struct remote_domain_set_scheduler_parameters_args { - remote_nonnull_domain dom; - struct { - u_int params_len; - remote_sched_param * params_val; - } params; + remote_nonnull_domain dom; + struct { + u_int params_len; + remote_sched_param * params_val; + } params; }; struct remote_domain_set_memory_parameters_args { - remote_nonnull_domain dom; - struct { - u_int params_len; - remote_memory_param * params_val; - } params; - u_int flags; + remote_nonnull_domain dom; + struct { + u_int params_len; + remote_memory_param * params_val; + } params; + u_int flags; }; struct remote_domain_get_memory_parameters_args { - remote_nonnull_domain dom; - int nparams; - u_int flags; + remote_nonnull_domain dom; + int nparams; + u_int flags; }; struct remote_domain_get_memory_parameters_ret { - struct { - u_int params_len; - remote_memory_param * params_val; - } params; - int nparams; + struct { + u_int params_len; + remote_memory_param * params_val; + } params; + int nparams; }; struct remote_domain_block_stats_args { - remote_nonnull_domain dom; - remote_nonnull_string path; + remote_nonnull_domain dom; + remote_nonnull_string path; }; struct remote_domain_block_stats_ret { - int64_t rd_req; - int64_t rd_bytes; - int64_t wr_req; - int64_t wr_bytes; - int64_t errs; + int64_t rd_req; + int64_t rd_bytes; + int64_t wr_req; + int64_t wr_bytes; + int64_t errs; }; struct remote_domain_interface_stats_args { - remote_nonnull_domain dom; - remote_nonnull_string path; + remote_nonnull_domain dom; + remote_nonnull_string path; }; struct remote_domain_interface_stats_ret { - int64_t rx_bytes; - int64_t rx_packets; - int64_t rx_errs; - int64_t rx_drop; - int64_t tx_bytes; - int64_t tx_packets; - int64_t tx_errs; - int64_t tx_drop; + int64_t rx_bytes; + int64_t rx_packets; + int64_t rx_errs; + int64_t rx_drop; + int64_t tx_bytes; + int64_t tx_packets; + int64_t tx_errs; + int64_t tx_drop; }; struct remote_domain_memory_stats_args { - remote_nonnull_domain dom; - u_int maxStats; - u_int flags; + remote_nonnull_domain dom; + u_int maxStats; + u_int flags; }; struct remote_domain_memory_stat { - int tag; - uint64_t val; + int tag; + uint64_t val; }; struct remote_domain_memory_stats_ret { - struct { - u_int stats_len; - remote_domain_memory_stat * stats_val; - } stats; + struct { + u_int stats_len; + remote_domain_memory_stat * stats_val; + } stats; }; struct remote_domain_block_peek_args { - remote_nonnull_domain dom; - remote_nonnull_string path; - uint64_t offset; - u_int size; - u_int flags; + remote_nonnull_domain dom; + remote_nonnull_string path; + uint64_t offset; + u_int size; + u_int flags; }; struct remote_domain_block_peek_ret { - struct { - u_int buffer_len; - char * buffer_val; - } buffer; + struct { + u_int buffer_len; + char * buffer_val; + } buffer; }; struct remote_domain_memory_peek_args { - remote_nonnull_domain dom; - uint64_t offset; - u_int size; - u_int flags; + remote_nonnull_domain dom; + uint64_t offset; + u_int size; + u_int flags; }; struct remote_domain_memory_peek_ret { - struct { - u_int buffer_len; - char * buffer_val; - } buffer; + struct { + u_int buffer_len; + char * buffer_val; + } buffer; }; struct remote_domain_get_block_info_args { - remote_nonnull_domain dom; - remote_nonnull_string path; - u_int flags; + remote_nonnull_domain dom; + remote_nonnull_string path; + u_int flags; }; struct remote_domain_get_block_info_ret { - uint64_t allocation; - uint64_t capacity; - uint64_t physical; + uint64_t allocation; + uint64_t capacity; + uint64_t physical; }; struct remote_list_domains_args { - int maxids; + int maxids; }; struct remote_list_domains_ret { - struct { - u_int ids_len; - int * ids_val; - } ids; + struct { + u_int ids_len; + int * ids_val; + } ids; }; struct remote_num_of_domains_ret { - int num; + int num; }; struct remote_domain_create_xml_args { - remote_nonnull_string xml_desc; - int flags; + remote_nonnull_string xml_desc; + int flags; }; struct remote_domain_create_xml_ret { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_lookup_by_id_args { - int id; + int id; }; struct remote_domain_lookup_by_id_ret { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_lookup_by_uuid_args { - remote_uuid uuid; + remote_uuid uuid; }; struct remote_domain_lookup_by_uuid_ret { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_lookup_by_name_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_domain_lookup_by_name_ret { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_suspend_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_resume_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_shutdown_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_reboot_args { - remote_nonnull_domain dom; - int flags; + remote_nonnull_domain dom; + int flags; }; struct remote_domain_destroy_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_os_type_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_os_type_ret { - remote_nonnull_string type; + remote_nonnull_string type; }; struct remote_domain_get_max_memory_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_max_memory_ret { - uint64_t memory; + uint64_t memory; }; struct remote_domain_set_max_memory_args { - remote_nonnull_domain dom; - uint64_t memory; + remote_nonnull_domain dom; + uint64_t memory; }; struct remote_domain_set_memory_args { - remote_nonnull_domain dom; - uint64_t memory; + remote_nonnull_domain dom; + uint64_t memory; }; struct remote_domain_set_memory_flags_args { - remote_nonnull_domain dom; - uint64_t memory; - u_int flags; + remote_nonnull_domain dom; + uint64_t memory; + u_int flags; }; struct remote_domain_get_info_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_info_ret { - u_char state; - uint64_t max_mem; - uint64_t memory; - u_short nr_virt_cpu; - uint64_t cpu_time; + u_char state; + uint64_t max_mem; + uint64_t memory; + u_short nr_virt_cpu; + uint64_t cpu_time; }; struct remote_domain_save_args { - remote_nonnull_domain dom; - remote_nonnull_string to; + remote_nonnull_domain dom; + remote_nonnull_string to; }; struct remote_domain_restore_args { - remote_nonnull_string from; + remote_nonnull_string from; }; struct remote_domain_core_dump_args { - remote_nonnull_domain dom; - remote_nonnull_string to; - int flags; + remote_nonnull_domain dom; + remote_nonnull_string to; + int flags; }; struct remote_domain_dump_xml_args { - remote_nonnull_domain dom; - int flags; + remote_nonnull_domain dom; + int flags; }; struct remote_domain_dump_xml_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_domain_migrate_prepare_args { - remote_string uri_in; - uint64_t flags; - remote_string dname; - uint64_t resource; + remote_string uri_in; + uint64_t flags; + remote_string dname; + uint64_t resource; }; struct remote_domain_migrate_prepare_ret { - struct { - u_int cookie_len; - char * cookie_val; - } cookie; - remote_string uri_out; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_string uri_out; }; struct remote_domain_migrate_perform_args { - remote_nonnull_domain dom; - struct { - u_int cookie_len; - char * cookie_val; - } cookie; - remote_nonnull_string uri; - uint64_t flags; - remote_string dname; - uint64_t resource; + remote_nonnull_domain dom; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; + remote_string dname; + uint64_t resource; }; struct remote_domain_migrate_finish_args { - remote_nonnull_string dname; - struct { - u_int cookie_len; - char * cookie_val; - } cookie; - remote_nonnull_string uri; - uint64_t flags; + remote_nonnull_string dname; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; }; struct remote_domain_migrate_finish_ret { - remote_nonnull_domain ddom; + remote_nonnull_domain ddom; }; struct remote_domain_migrate_prepare2_args { - remote_string uri_in; - uint64_t flags; - remote_string dname; - uint64_t resource; - remote_nonnull_string dom_xml; + remote_string uri_in; + uint64_t flags; + remote_string dname; + uint64_t resource; + remote_nonnull_string dom_xml; }; struct remote_domain_migrate_prepare2_ret { - struct { - u_int cookie_len; - char * cookie_val; - } cookie; - remote_string uri_out; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_string uri_out; }; struct remote_domain_migrate_finish2_args { - remote_nonnull_string dname; - struct { - u_int cookie_len; - char * cookie_val; - } cookie; - remote_nonnull_string uri; - uint64_t flags; - int retcode; + remote_nonnull_string dname; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; + int retcode; }; struct remote_domain_migrate_finish2_ret { - remote_nonnull_domain ddom; + remote_nonnull_domain ddom; }; struct remote_list_defined_domains_args { - int maxnames; + int maxnames; }; struct remote_list_defined_domains_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_num_of_defined_domains_ret { - int num; + int num; }; struct remote_domain_create_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_create_with_flags_args { - remote_nonnull_domain dom; - u_int flags; + remote_nonnull_domain dom; + u_int flags; }; struct remote_domain_create_with_flags_ret { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_define_xml_args { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_domain_define_xml_ret { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_undefine_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_set_vcpus_args { - remote_nonnull_domain dom; - int nvcpus; + remote_nonnull_domain dom; + int nvcpus; }; struct remote_domain_set_vcpus_flags_args { - remote_nonnull_domain dom; - u_int nvcpus; - u_int flags; + remote_nonnull_domain dom; + u_int nvcpus; + u_int flags; }; struct remote_domain_get_vcpus_flags_args { - remote_nonnull_domain dom; - u_int flags; + remote_nonnull_domain dom; + u_int flags; }; struct remote_domain_get_vcpus_flags_ret { - int num; + int num; }; struct remote_domain_pin_vcpu_args { - remote_nonnull_domain dom; - int vcpu; - struct { - u_int cpumap_len; - char * cpumap_val; - } cpumap; + remote_nonnull_domain dom; + int vcpu; + struct { + u_int cpumap_len; + char * cpumap_val; + } cpumap; }; struct remote_domain_get_vcpus_args { - remote_nonnull_domain dom; - int maxinfo; - int maplen; + remote_nonnull_domain dom; + int maxinfo; + int maplen; }; struct remote_domain_get_vcpus_ret { - struct { - u_int info_len; - remote_vcpu_info * info_val; - } info; - struct { - u_int cpumaps_len; - char * cpumaps_val; - } cpumaps; + struct { + u_int info_len; + remote_vcpu_info * info_val; + } info; + struct { + u_int cpumaps_len; + char * cpumaps_val; + } cpumaps; }; struct remote_domain_get_max_vcpus_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_max_vcpus_ret { - int num; + int num; }; struct remote_domain_get_security_label_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_security_label_ret { - struct { - u_int label_len; - char * label_val; - } label; - int enforcing; + struct { + u_int label_len; + char * label_val; + } label; + int enforcing; }; struct remote_node_get_security_model_ret { - struct { - u_int model_len; - char * model_val; - } model; - struct { - u_int doi_len; - char * doi_val; - } doi; + struct { + u_int model_len; + char * model_val; + } model; + struct { + u_int doi_len; + char * doi_val; + } doi; }; struct remote_domain_attach_device_args { - remote_nonnull_domain dom; - remote_nonnull_string xml; + remote_nonnull_domain dom; + remote_nonnull_string xml; }; struct remote_domain_attach_device_flags_args { - remote_nonnull_domain dom; - remote_nonnull_string xml; - u_int flags; + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; }; struct remote_domain_detach_device_args { - remote_nonnull_domain dom; - remote_nonnull_string xml; + remote_nonnull_domain dom; + remote_nonnull_string xml; }; struct remote_domain_detach_device_flags_args { - remote_nonnull_domain dom; - remote_nonnull_string xml; - u_int flags; + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; }; struct remote_domain_update_device_flags_args { - remote_nonnull_domain dom; - remote_nonnull_string xml; - u_int flags; + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; }; struct remote_domain_get_autostart_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_autostart_ret { - int autostart; + int autostart; }; struct remote_domain_set_autostart_args { - remote_nonnull_domain dom; - int autostart; + remote_nonnull_domain dom; + int autostart; }; struct remote_num_of_networks_ret { - int num; + int num; }; struct remote_list_networks_args { - int maxnames; + int maxnames; }; struct remote_list_networks_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_num_of_defined_networks_ret { - int num; + int num; }; struct remote_list_defined_networks_args { - int maxnames; + int maxnames; }; struct remote_list_defined_networks_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_network_lookup_by_uuid_args { - remote_uuid uuid; + remote_uuid uuid; }; struct remote_network_lookup_by_uuid_ret { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_lookup_by_name_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_network_lookup_by_name_ret { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_create_xml_args { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_network_create_xml_ret { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_define_xml_args { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_network_define_xml_ret { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_undefine_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_create_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_destroy_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_dump_xml_args { - remote_nonnull_network net; - int flags; + remote_nonnull_network net; + int flags; }; struct remote_network_dump_xml_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_network_get_bridge_name_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_get_bridge_name_ret { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_network_get_autostart_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_get_autostart_ret { - int autostart; + int autostart; }; struct remote_network_set_autostart_args { - remote_nonnull_network net; - int autostart; + remote_nonnull_network net; + int autostart; }; struct remote_num_of_nwfilters_ret { - int num; + int num; }; struct remote_list_nwfilters_args { - int maxnames; + int maxnames; }; struct remote_list_nwfilters_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_nwfilter_lookup_by_uuid_args { - remote_uuid uuid; + remote_uuid uuid; }; struct remote_nwfilter_lookup_by_uuid_ret { - remote_nonnull_nwfilter nwfilter; + remote_nonnull_nwfilter nwfilter; }; struct remote_nwfilter_lookup_by_name_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_nwfilter_lookup_by_name_ret { - remote_nonnull_nwfilter nwfilter; + remote_nonnull_nwfilter nwfilter; }; struct remote_nwfilter_define_xml_args { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_nwfilter_define_xml_ret { - remote_nonnull_nwfilter nwfilter; + remote_nonnull_nwfilter nwfilter; }; struct remote_nwfilter_undefine_args { - remote_nonnull_nwfilter nwfilter; + remote_nonnull_nwfilter nwfilter; }; struct remote_nwfilter_get_xml_desc_args { - remote_nonnull_nwfilter nwfilter; - int flags; + remote_nonnull_nwfilter nwfilter; + int flags; }; struct remote_nwfilter_get_xml_desc_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_num_of_interfaces_ret { - int num; + int num; }; struct remote_list_interfaces_args { - int maxnames; + int maxnames; }; struct remote_list_interfaces_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_num_of_defined_interfaces_ret { - int num; + int num; }; struct remote_list_defined_interfaces_args { - int maxnames; + int maxnames; }; struct remote_list_defined_interfaces_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_interface_lookup_by_name_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_interface_lookup_by_name_ret { - remote_nonnull_interface iface; + remote_nonnull_interface iface; }; struct remote_interface_lookup_by_mac_string_args { - remote_nonnull_string mac; + remote_nonnull_string mac; }; struct remote_interface_lookup_by_mac_string_ret { - remote_nonnull_interface iface; + remote_nonnull_interface iface; }; struct remote_interface_get_xml_desc_args { - remote_nonnull_interface iface; - u_int flags; + remote_nonnull_interface iface; + u_int flags; }; struct remote_interface_get_xml_desc_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_interface_define_xml_args { - remote_nonnull_string xml; - u_int flags; + remote_nonnull_string xml; + u_int flags; }; struct remote_interface_define_xml_ret { - remote_nonnull_interface iface; + remote_nonnull_interface iface; }; struct remote_interface_undefine_args { - remote_nonnull_interface iface; + remote_nonnull_interface iface; }; struct remote_interface_create_args { - remote_nonnull_interface iface; - u_int flags; + remote_nonnull_interface iface; + u_int flags; }; struct remote_interface_destroy_args { - remote_nonnull_interface iface; - u_int flags; + remote_nonnull_interface iface; + u_int flags; }; struct remote_auth_list_ret { - struct { - u_int types_len; - remote_auth_type * types_val; - } types; + struct { + u_int types_len; + remote_auth_type * types_val; + } types; }; struct remote_auth_sasl_init_ret { - remote_nonnull_string mechlist; + remote_nonnull_string mechlist; }; struct remote_auth_sasl_start_args { - remote_nonnull_string mech; - int nil; - struct { - u_int data_len; - char * data_val; - } data; + remote_nonnull_string mech; + int nil; + struct { + u_int data_len; + char * data_val; + } data; }; struct remote_auth_sasl_start_ret { - int complete; - int nil; - struct { - u_int data_len; - char * data_val; - } data; + int complete; + int nil; + struct { + u_int data_len; + char * data_val; + } data; }; struct remote_auth_sasl_step_args { - int nil; - struct { - u_int data_len; - char * data_val; - } data; + int nil; + struct { + u_int data_len; + char * data_val; + } data; }; struct remote_auth_sasl_step_ret { - int complete; - int nil; - struct { - u_int data_len; - char * data_val; - } data; + int complete; + int nil; + struct { + u_int data_len; + char * data_val; + } data; }; struct remote_auth_polkit_ret { - int complete; + int complete; }; struct remote_num_of_storage_pools_ret { - int num; + int num; }; struct remote_list_storage_pools_args { - int maxnames; + int maxnames; }; struct remote_list_storage_pools_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_num_of_defined_storage_pools_ret { - int num; + int num; }; struct remote_list_defined_storage_pools_args { - int maxnames; + int maxnames; }; struct remote_list_defined_storage_pools_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_find_storage_pool_sources_args { - remote_nonnull_string type; - remote_string srcSpec; - u_int flags; + remote_nonnull_string type; + remote_string srcSpec; + u_int flags; }; struct remote_find_storage_pool_sources_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_storage_pool_lookup_by_uuid_args { - remote_uuid uuid; + remote_uuid uuid; }; struct remote_storage_pool_lookup_by_uuid_ret { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_lookup_by_name_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_storage_pool_lookup_by_name_ret { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_lookup_by_volume_args { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_pool_lookup_by_volume_ret { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_create_xml_args { - remote_nonnull_string xml; - u_int flags; + remote_nonnull_string xml; + u_int flags; }; struct remote_storage_pool_create_xml_ret { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_define_xml_args { - remote_nonnull_string xml; - u_int flags; + remote_nonnull_string xml; + u_int flags; }; struct remote_storage_pool_define_xml_ret { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_build_args { - remote_nonnull_storage_pool pool; - u_int flags; + remote_nonnull_storage_pool pool; + u_int flags; }; struct remote_storage_pool_undefine_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_create_args { - remote_nonnull_storage_pool pool; - u_int flags; + remote_nonnull_storage_pool pool; + u_int flags; }; struct remote_storage_pool_destroy_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_delete_args { - remote_nonnull_storage_pool pool; - u_int flags; + remote_nonnull_storage_pool pool; + u_int flags; }; struct remote_storage_pool_refresh_args { - remote_nonnull_storage_pool pool; - u_int flags; + remote_nonnull_storage_pool pool; + u_int flags; }; struct remote_storage_pool_dump_xml_args { - remote_nonnull_storage_pool pool; - u_int flags; + remote_nonnull_storage_pool pool; + u_int flags; }; struct remote_storage_pool_dump_xml_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_storage_pool_get_info_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_get_info_ret { - u_char state; - uint64_t capacity; - uint64_t allocation; - uint64_t available; + u_char state; + uint64_t capacity; + uint64_t allocation; + uint64_t available; }; struct remote_storage_pool_get_autostart_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_get_autostart_ret { - int autostart; + int autostart; }; struct remote_storage_pool_set_autostart_args { - remote_nonnull_storage_pool pool; - int autostart; + remote_nonnull_storage_pool pool; + int autostart; }; struct remote_storage_pool_num_of_volumes_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_num_of_volumes_ret { - int num; + int num; }; struct remote_storage_pool_list_volumes_args { - remote_nonnull_storage_pool pool; - int maxnames; + remote_nonnull_storage_pool pool; + int maxnames; }; struct remote_storage_pool_list_volumes_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_storage_vol_lookup_by_name_args { - remote_nonnull_storage_pool pool; - remote_nonnull_string name; + remote_nonnull_storage_pool pool; + remote_nonnull_string name; }; struct remote_storage_vol_lookup_by_name_ret { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_lookup_by_key_args { - remote_nonnull_string key; + remote_nonnull_string key; }; struct remote_storage_vol_lookup_by_key_ret { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_lookup_by_path_args { - remote_nonnull_string path; + remote_nonnull_string path; }; struct remote_storage_vol_lookup_by_path_ret { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_create_xml_args { - remote_nonnull_storage_pool pool; - remote_nonnull_string xml; - u_int flags; + remote_nonnull_storage_pool pool; + remote_nonnull_string xml; + u_int flags; }; struct remote_storage_vol_create_xml_ret { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_create_xml_from_args { - remote_nonnull_storage_pool pool; - remote_nonnull_string xml; - remote_nonnull_storage_vol clonevol; - u_int flags; + remote_nonnull_storage_pool pool; + remote_nonnull_string xml; + remote_nonnull_storage_vol clonevol; + u_int flags; }; struct remote_storage_vol_create_xml_from_ret { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_delete_args { - remote_nonnull_storage_vol vol; - u_int flags; + remote_nonnull_storage_vol vol; + u_int flags; }; struct remote_storage_vol_wipe_args { - remote_nonnull_storage_vol vol; - u_int flags; + remote_nonnull_storage_vol vol; + u_int flags; }; struct remote_storage_vol_dump_xml_args { - remote_nonnull_storage_vol vol; - u_int flags; + remote_nonnull_storage_vol vol; + u_int flags; }; struct remote_storage_vol_dump_xml_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_storage_vol_get_info_args { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_get_info_ret { - char type; - uint64_t capacity; - uint64_t allocation; + char type; + uint64_t capacity; + uint64_t allocation; }; struct remote_storage_vol_get_path_args { - remote_nonnull_storage_vol vol; + remote_nonnull_storage_vol vol; }; struct remote_storage_vol_get_path_ret { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_num_of_devices_args { - remote_string cap; - u_int flags; + remote_string cap; + u_int flags; }; struct remote_node_num_of_devices_ret { - int num; + int num; }; struct remote_node_list_devices_args { - remote_string cap; - int maxnames; - u_int flags; + remote_string cap; + int maxnames; + u_int flags; }; struct remote_node_list_devices_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_node_device_lookup_by_name_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_device_lookup_by_name_ret { - remote_nonnull_node_device dev; + remote_nonnull_node_device dev; }; struct remote_node_device_dump_xml_args { - remote_nonnull_string name; - u_int flags; + remote_nonnull_string name; + u_int flags; }; struct remote_node_device_dump_xml_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_node_device_get_parent_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_device_get_parent_ret { - remote_string parent; + remote_string parent; }; struct remote_node_device_num_of_caps_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_device_num_of_caps_ret { - int num; + int num; }; struct remote_node_device_list_caps_args { - remote_nonnull_string name; - int maxnames; + remote_nonnull_string name; + int maxnames; }; struct remote_node_device_list_caps_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_node_device_dettach_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_device_re_attach_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_device_reset_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_node_device_create_xml_args { - remote_nonnull_string xml_desc; - int flags; + remote_nonnull_string xml_desc; + int flags; }; struct remote_node_device_create_xml_ret { - remote_nonnull_node_device dev; + remote_nonnull_node_device dev; }; struct remote_node_device_destroy_args { - remote_nonnull_string name; + remote_nonnull_string name; }; struct remote_domain_events_register_ret { - int cb_registered; + int cb_registered; }; struct remote_domain_events_deregister_ret { - int cb_registered; + int cb_registered; }; struct remote_domain_event_lifecycle_msg { - remote_nonnull_domain dom; - int event; - int detail; + remote_nonnull_domain dom; + int event; + int detail; }; struct remote_domain_xml_from_native_args { - remote_nonnull_string nativeFormat; - remote_nonnull_string nativeConfig; - u_int flags; + remote_nonnull_string nativeFormat; + remote_nonnull_string nativeConfig; + u_int flags; }; struct remote_domain_xml_from_native_ret { - remote_nonnull_string domainXml; + remote_nonnull_string domainXml; }; struct remote_domain_xml_to_native_args { - remote_nonnull_string nativeFormat; - remote_nonnull_string domainXml; - u_int flags; + remote_nonnull_string nativeFormat; + remote_nonnull_string domainXml; + u_int flags; }; struct remote_domain_xml_to_native_ret { - remote_nonnull_string nativeConfig; + remote_nonnull_string nativeConfig; }; struct remote_num_of_secrets_ret { - int num; + int num; }; struct remote_list_secrets_args { - int maxuuids; + int maxuuids; }; struct remote_list_secrets_ret { - struct { - u_int uuids_len; - remote_nonnull_string * uuids_val; - } uuids; + struct { + u_int uuids_len; + remote_nonnull_string * uuids_val; + } uuids; }; struct remote_secret_lookup_by_uuid_args { - remote_uuid uuid; + remote_uuid uuid; }; struct remote_secret_lookup_by_uuid_ret { - remote_nonnull_secret secret; + remote_nonnull_secret secret; }; struct remote_secret_define_xml_args { - remote_nonnull_string xml; - u_int flags; + remote_nonnull_string xml; + u_int flags; }; struct remote_secret_define_xml_ret { - remote_nonnull_secret secret; + remote_nonnull_secret secret; }; struct remote_secret_get_xml_desc_args { - remote_nonnull_secret secret; - u_int flags; + remote_nonnull_secret secret; + u_int flags; }; struct remote_secret_get_xml_desc_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_secret_set_value_args { - remote_nonnull_secret secret; - struct { - u_int value_len; - char * value_val; - } value; - u_int flags; + remote_nonnull_secret secret; + struct { + u_int value_len; + char * value_val; + } value; + u_int flags; }; struct remote_secret_get_value_args { - remote_nonnull_secret secret; - u_int flags; + remote_nonnull_secret secret; + u_int flags; }; struct remote_secret_get_value_ret { - struct { - u_int value_len; - char * value_val; - } value; + struct { + u_int value_len; + char * value_val; + } value; }; struct remote_secret_undefine_args { - remote_nonnull_secret secret; + remote_nonnull_secret secret; }; struct remote_secret_lookup_by_usage_args { - int usageType; - remote_nonnull_string usageID; + int usageType; + remote_nonnull_string usageID; }; struct remote_secret_lookup_by_usage_ret { - remote_nonnull_secret secret; + remote_nonnull_secret secret; }; struct remote_domain_migrate_prepare_tunnel_args { - uint64_t flags; - remote_string dname; - uint64_t resource; - remote_nonnull_string dom_xml; + uint64_t flags; + remote_string dname; + uint64_t resource; + remote_nonnull_string dom_xml; }; struct remote_is_secure_ret { - int secure; + int secure; }; struct remote_domain_is_active_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_is_active_ret { - int active; + int active; }; struct remote_domain_is_persistent_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_is_persistent_ret { - int persistent; + int persistent; }; struct remote_domain_is_updated_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_is_updated_ret { - int updated; + int updated; }; struct remote_network_is_active_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_is_active_ret { - int active; + int active; }; struct remote_network_is_persistent_args { - remote_nonnull_network net; + remote_nonnull_network net; }; struct remote_network_is_persistent_ret { - int persistent; + int persistent; }; struct remote_storage_pool_is_active_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_is_active_ret { - int active; + int active; }; struct remote_storage_pool_is_persistent_args { - remote_nonnull_storage_pool pool; + remote_nonnull_storage_pool pool; }; struct remote_storage_pool_is_persistent_ret { - int persistent; + int persistent; }; struct remote_interface_is_active_args { - remote_nonnull_interface iface; + remote_nonnull_interface iface; }; struct remote_interface_is_active_ret { - int active; + int active; }; struct remote_cpu_compare_args { - remote_nonnull_string xml; - u_int flags; + remote_nonnull_string xml; + u_int flags; }; struct remote_cpu_compare_ret { - int result; + int result; }; struct remote_cpu_baseline_args { - struct { - u_int xmlCPUs_len; - remote_nonnull_string * xmlCPUs_val; - } xmlCPUs; - u_int flags; + struct { + u_int xmlCPUs_len; + remote_nonnull_string * xmlCPUs_val; + } xmlCPUs; + u_int flags; }; struct remote_cpu_baseline_ret { - remote_nonnull_string cpu; + remote_nonnull_string cpu; }; struct remote_domain_get_job_info_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_get_job_info_ret { - int type; - uint64_t timeElapsed; - uint64_t timeRemaining; - uint64_t dataTotal; - uint64_t dataProcessed; - uint64_t dataRemaining; - uint64_t memTotal; - uint64_t memProcessed; - uint64_t memRemaining; - uint64_t fileTotal; - uint64_t fileProcessed; - uint64_t fileRemaining; + int type; + uint64_t timeElapsed; + uint64_t timeRemaining; + uint64_t dataTotal; + uint64_t dataProcessed; + uint64_t dataRemaining; + uint64_t memTotal; + uint64_t memProcessed; + uint64_t memRemaining; + uint64_t fileTotal; + uint64_t fileProcessed; + uint64_t fileRemaining; }; struct remote_domain_abort_job_args { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_migrate_set_max_downtime_args { - remote_nonnull_domain dom; - uint64_t downtime; - u_int flags; + remote_nonnull_domain dom; + uint64_t downtime; + u_int flags; }; struct remote_domain_events_register_any_args { - int eventID; + int eventID; }; struct remote_domain_events_deregister_any_args { - int eventID; + int eventID; }; struct remote_domain_event_reboot_msg { - remote_nonnull_domain dom; + remote_nonnull_domain dom; }; struct remote_domain_event_rtc_change_msg { - remote_nonnull_domain dom; - int64_t offset; + remote_nonnull_domain dom; + int64_t offset; }; struct remote_domain_event_watchdog_msg { - remote_nonnull_domain dom; - int action; + remote_nonnull_domain dom; + int action; }; struct remote_domain_event_io_error_msg { - remote_nonnull_domain dom; - remote_nonnull_string srcPath; - remote_nonnull_string devAlias; - int action; + remote_nonnull_domain dom; + remote_nonnull_string srcPath; + remote_nonnull_string devAlias; + int action; }; struct remote_domain_event_io_error_reason_msg { - remote_nonnull_domain dom; - remote_nonnull_string srcPath; - remote_nonnull_string devAlias; - int action; - remote_nonnull_string reason; + remote_nonnull_domain dom; + remote_nonnull_string srcPath; + remote_nonnull_string devAlias; + int action; + remote_nonnull_string reason; }; struct remote_domain_event_graphics_address { - int family; - remote_nonnull_string node; - remote_nonnull_string service; + int family; + remote_nonnull_string node; + remote_nonnull_string service; }; struct remote_domain_event_graphics_identity { - remote_nonnull_string type; - remote_nonnull_string name; + remote_nonnull_string type; + remote_nonnull_string name; }; struct remote_domain_event_graphics_msg { - remote_nonnull_domain dom; - int phase; - remote_domain_event_graphics_address local; - remote_domain_event_graphics_address remote; - remote_nonnull_string authScheme; - struct { - u_int subject_len; - remote_domain_event_graphics_identity * subject_val; - } subject; + remote_nonnull_domain dom; + int phase; + remote_domain_event_graphics_address local; + remote_domain_event_graphics_address remote; + remote_nonnull_string authScheme; + struct { + u_int subject_len; + remote_domain_event_graphics_identity * subject_val; + } subject; }; struct remote_domain_managed_save_args { - remote_nonnull_domain dom; - u_int flags; + remote_nonnull_domain dom; + u_int flags; }; struct remote_domain_has_managed_save_image_args { - remote_nonnull_domain dom; - u_int flags; + remote_nonnull_domain dom; + u_int flags; }; struct remote_domain_has_managed_save_image_ret { - int ret; + int ret; }; struct remote_domain_managed_save_remove_args { - remote_nonnull_domain dom; - u_int flags; + remote_nonnull_domain dom; + u_int flags; }; struct remote_domain_snapshot_create_xml_args { - remote_nonnull_domain domain; - remote_nonnull_string xml_desc; - int flags; + remote_nonnull_domain domain; + remote_nonnull_string xml_desc; + int flags; }; struct remote_domain_snapshot_create_xml_ret { - remote_nonnull_domain_snapshot snap; + remote_nonnull_domain_snapshot snap; }; struct remote_domain_snapshot_dump_xml_args { - remote_nonnull_domain_snapshot snap; - int flags; + remote_nonnull_domain_snapshot snap; + int flags; }; struct remote_domain_snapshot_dump_xml_ret { - remote_nonnull_string xml; + remote_nonnull_string xml; }; struct remote_domain_snapshot_num_args { - remote_nonnull_domain domain; - int flags; + remote_nonnull_domain domain; + int flags; }; struct remote_domain_snapshot_num_ret { - int num; + int num; }; struct remote_domain_snapshot_list_names_args { - remote_nonnull_domain domain; - int nameslen; - int flags; + remote_nonnull_domain domain; + int nameslen; + int flags; }; struct remote_domain_snapshot_list_names_ret { - struct { - u_int names_len; - remote_nonnull_string * names_val; - } names; + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; }; struct remote_domain_snapshot_lookup_by_name_args { - remote_nonnull_domain domain; - remote_nonnull_string name; - int flags; + remote_nonnull_domain domain; + remote_nonnull_string name; + int flags; }; struct remote_domain_snapshot_lookup_by_name_ret { - remote_nonnull_domain_snapshot snap; + remote_nonnull_domain_snapshot snap; }; struct remote_domain_has_current_snapshot_args { - remote_nonnull_domain domain; - int flags; + remote_nonnull_domain domain; + int flags; }; struct remote_domain_has_current_snapshot_ret { - int result; + int result; }; struct remote_domain_snapshot_current_args { - remote_nonnull_domain domain; - int flags; + remote_nonnull_domain domain; + int flags; }; struct remote_domain_snapshot_current_ret { - remote_nonnull_domain_snapshot snap; + remote_nonnull_domain_snapshot snap; }; struct remote_domain_revert_to_snapshot_args { - remote_nonnull_domain_snapshot snap; - int flags; + remote_nonnull_domain_snapshot snap; + int flags; }; struct remote_domain_snapshot_delete_args { - remote_nonnull_domain_snapshot snap; - int flags; + remote_nonnull_domain_snapshot snap; + int flags; }; struct remote_domain_open_console_args { - remote_nonnull_domain domain; - remote_string devname; - u_int flags; + remote_nonnull_domain domain; + remote_string devname; + u_int flags; }; struct remote_message_header { - u_int prog; - u_int vers; - int proc; - remote_message_type type; - u_int serial; - remote_message_status status; + u_int prog; + u_int vers; + int proc; + remote_message_type type; + u_int serial; + remote_message_status status; }; -- 1.7.4

This patch adds the new options (--live and --config) to "virsh setmem" command. The behavior of above options is the same as that of "virsh setvcpus" and so on. That is, when the --config option is specified, a modification is effective for the persistent domain. Moreover we can modify the memory size of inactive domains as well as that of active domains. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- tools/virsh.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) Index: libvirt-git/tools/virsh.c =================================================================== --- libvirt-git.orig/tools/virsh.c +++ libvirt-git/tools/virsh.c @@ -2910,6 +2910,8 @@ static const vshCmdInfo info_setmem[] = static const vshCmdOptDef opts_setmem[] = { {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, {"kilobytes", VSH_OT_INT, VSH_OFLAG_REQ, N_("number of kilobytes of memory")}, + {"config", VSH_OT_BOOL, 0, N_("affect next boot")}, + {"live", VSH_OT_BOOL, 0, N_("affect running domain")}, {NULL, 0, 0, NULL} }; @@ -2920,6 +2922,10 @@ cmdSetmem(vshControl *ctl, const vshCmd virDomainInfo info; unsigned long kilobytes; int ret = TRUE; + int config = vshCommandOptBool(cmd, "config"); + int live = vshCommandOptBool(cmd, "live"); + int flags = ((config ? VIR_DOMAIN_MEM_CONFIG : 0) | + (live ? VIR_DOMAIN_MEM_LIVE : 0)); if (!vshConnectionUsability(ctl, ctl->conn)) return FALSE; @@ -2947,8 +2953,14 @@ cmdSetmem(vshControl *ctl, const vshCmd return FALSE; } - if (virDomainSetMemory(dom, kilobytes) != 0) { - ret = FALSE; + if (!flags) { + if (virDomainSetMemory(dom, kilobytes) != 0) { + ret = FALSE; + } + } else { + if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) { + ret = FALSE; + } } virDomainFree(dom);

On Wed, Mar 02, 2011 at 05:13:39PM +0900, Taku Izumi wrote:
This patch adds the new options (--live and --config) to "virsh setmem" command. The behavior of above options is the same as that of "virsh setvcpus" and so on. That is, when the --config option is specified, a modification is effective for the persistent domain. Moreover we can modify the memory size of inactive domains as well as that of active domains.
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> --- tools/virsh.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
Index: libvirt-git/tools/virsh.c =================================================================== --- libvirt-git.orig/tools/virsh.c +++ libvirt-git/tools/virsh.c @@ -2910,6 +2910,8 @@ static const vshCmdInfo info_setmem[] = static const vshCmdOptDef opts_setmem[] = { {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, {"kilobytes", VSH_OT_INT, VSH_OFLAG_REQ, N_("number of kilobytes of memory")}, + {"config", VSH_OT_BOOL, 0, N_("affect next boot")}, + {"live", VSH_OT_BOOL, 0, N_("affect running domain")}, {NULL, 0, 0, NULL} };
@@ -2920,6 +2922,10 @@ cmdSetmem(vshControl *ctl, const vshCmd virDomainInfo info; unsigned long kilobytes; int ret = TRUE; + int config = vshCommandOptBool(cmd, "config"); + int live = vshCommandOptBool(cmd, "live"); + int flags = ((config ? VIR_DOMAIN_MEM_CONFIG : 0) | + (live ? VIR_DOMAIN_MEM_LIVE : 0));
if (!vshConnectionUsability(ctl, ctl->conn)) return FALSE; @@ -2947,8 +2953,14 @@ cmdSetmem(vshControl *ctl, const vshCmd return FALSE; }
- if (virDomainSetMemory(dom, kilobytes) != 0) { - ret = FALSE; + if (!flags) { + if (virDomainSetMemory(dom, kilobytes) != 0) { + ret = FALSE; + }
Indentation went a little bit wrong here. Also '!flags' could in fact be '!flags || (flags == VIR_DOMAIN_MEM_LIVE)' since if only the --live flag was set, we can still use the original API call for greater backcompatibility.
+ } else { + if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) { + ret = FALSE; + } }
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 03/09/2011 04:59 PM, Daniel P. Berrange wrote:
+ if (!flags) { + if (virDomainSetMemory(dom, kilobytes) != 0) { + ret = FALSE; + }
Indentation went a little bit wrong here. Also '!flags' could in fact be '!flags || (flags == VIR_DOMAIN_MEM_LIVE)' since if only the --live flag was set, we can still use the original API call for greater backcompatibility.
Perhaps this choice of APIs should be done in libvirt rather than virsh (with virsh always calling the new API). This way all clients can talk to an older remote libvirt without having to care about virDomainSetMemory vs. virDomainSetMemoryFlags. Paolo

On 03/10/2011 12:44 AM, Paolo Bonzini wrote:
On 03/09/2011 04:59 PM, Daniel P. Berrange wrote:
+ if (!flags) { + if (virDomainSetMemory(dom, kilobytes) != 0) { + ret = FALSE; + }
Indentation went a little bit wrong here. Also '!flags' could in fact be '!flags || (flags == VIR_DOMAIN_MEM_LIVE)' since if only the --live flag was set, we can still use the original API call for greater backcompatibility.
Perhaps this choice of APIs should be done in libvirt rather than virsh (with virsh always calling the new API). This way all clients can talk to an older remote libvirt without having to care about virDomainSetMemory vs. virDomainSetMemoryFlags.
Perhaps so, but that's a bigger task better left for a separate patch (if we do that in libvirt.c for one API, we should do it for all of them that fit the same pattern of a new function that subsumes functionality of an older one - I can think of several). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 03/02/2011 01:13 AM, Taku Izumi wrote:
This patch adds the new options (--live and --config) to "virsh setmem" command. The behavior of above options is the same as that of "virsh setvcpus" and so on. That is, when the --config option is specified, a modification is effective for the persistent domain. Moreover we can modify the memory size of inactive domains as well as that of active domains.
@@ -2920,6 +2922,10 @@ cmdSetmem(vshControl *ctl, const vshCmd virDomainInfo info; unsigned long kilobytes; int ret = TRUE; + int config = vshCommandOptBool(cmd, "config"); + int live = vshCommandOptBool(cmd, "live"); + int flags = ((config ? VIR_DOMAIN_MEM_CONFIG : 0) | + (live ? VIR_DOMAIN_MEM_LIVE : 0));
I folded in Daniel's suggestion to call the older API when only --live was requested (actually, I did it differently - flags only has to be set if config is specified). You forgot documentation in tools/virsh.pod. I'm adding: diff --git i/tools/virsh.pod w/tools/virsh.pod index a2ca384..7c12399 100644 --- i/tools/virsh.pod +++ w/tools/virsh.pod @@ -578,9 +578,12 @@ Therefore, -1 is a useful shorthand for 262144. B<Note>: The weight and cap parameters are defined only for the XEN_CREDIT scheduler and are now I<DEPRECATED>. -=item B<setmem> I<domain-id> B<kilobytes> +=item B<setmem> I<domain-id> B<kilobytes> optional I<--config> I<--live> -Immediately change the current memory allocation for an active guest domain. +Change the memory allocation for a guest domain. +If I<--live> is specified, perform a memory balloon of a running guest. +If I<--config> is specified, affect the next boot of a persistent guest. +Both flags may be given. If neither flag is given, I<--live> is assumed. Some hypervisors require a larger granularity than kilobytes, and requests that are not an even multiple will be rounded up. For example, vSphere/ESX @@ -590,10 +593,6 @@ rounds the parameter up unless the kB argument is evenly divisible by 1024 For Xen, you can only adjust the memory of a running domain if the domain is paravirtualized or running the PV balloon driver. -Note, this command only works on active guest domains. To change the memory -allocation for an inactive guest domain, use the virsh B<edit> command to -update the XML <currentMemory> element. - =item B<setmaxmem> I<domain-id> B<kilobytes> Change the maximum memory allocation limit for an inactive guest domain. At any rate, ACK as modified, and I pushed the amended series. Thanks again for your first contribution! -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

At any rate, ACK as modified, and I pushed the amended series. Thanks again for your first contribution!
Thank you for reviewing and correcting it. I also express my appreciation to persons who responded this thread. Thank you for Danie, Paolo, and Eric! -- Taku Izumi <izumi.taku@jp.fujitsu.com>
participants (5)
-
Daniel P. Berrange
-
Eric Blake
-
Matthias Bolte
-
Paolo Bonzini
-
Taku Izumi