[libvirt] [PATCH v3 03/13] Adds xml entries for memory tunables
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com The patch adds xml entries to the domain.rng file. v2: + Fix typo min_guarantee Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- docs/schemas/domain.rng | 31 +++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index ccb8cf3..d75254c 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -299,6 +299,37 @@ /optional /element /optional + + !-- All the memory/swap related tunables would go in the memtune -- + optional + element name=memtune + !-- Maximum memory the VM can use -- + optional + element name=hard_limit + ref name=memoryKB/ + /element + /optional + !-- Minimum memory ascertained for the VM during contention -- + optional + element name=soft_limit + ref name=memoryKB/ + /element + /optional + !-- Minimum amount of memory required to start the VM -- + optional + element name=min_guarantee + ref name=memoryKB/ + /element + /optional + !-- Maximum swap area the VM can use -- + optional + element name=swap_hard_limit + ref name=memoryKB/ + /element + /optional + /element + /optional + optional element name=vcpu optional -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 01/13] Adding structure and defines for virDomainSet/GetMemoryParameters
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com This patch adds a structure virMemoryParameter, it contains the name of the parameter and the type of the parameter along with a union. v3: + Protoype for virDomainGetMemoryParameters and dummy python binding. v2: + Includes dummy python bindings for the library to build cleanly. + Define string constants like hard_limit, etc. + re-order this patch. Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- include/libvirt/libvirt.h.in| 68 +++ python/generator.py |2 + python/libvirt-override-api.xml | 12 +++ python/libvirt-override.c | 14 4 files changed, 96 insertions(+), 0 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index b45f7ec..a528f67 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -674,6 +674,74 @@ int virDomainGetInfo (virDomainPtr domain, char * virDomainGetSchedulerType(virDomainPtr domain, int *nparams); +/** + * virDomainMemoryParameterType: + * + * A memory parameter field type + */ +typedef enum { +VIR_DOMAIN_MEMORY_FIELD_INT = 1, /* integer case */ +VIR_DOMAIN_MEMORY_FIELD_UINT= 2, /* unsigned integer case */ +VIR_DOMAIN_MEMORY_FIELD_LLONG = 3, /* long long case */ +VIR_DOMAIN_MEMORY_FIELD_ULLONG = 4, /* unsigned long long case */ +VIR_DOMAIN_MEMORY_FIELD_DOUBLE = 5, /* double case */ +VIR_DOMAIN_MEMORY_FIELD_BOOLEAN = 6 /* boolean(character) case */ +} virMemoryParameterType; + +/** + * VIR_DOMAIN_MEMORY_FIELD_LENGTH: + * + * Macro providing the field length of virMemoryParameter + */ + +#define VIR_DOMAIN_MEMORY_FIELD_LENGTH 80 +#define VIR_DOMAIN_MEMORY_HARD_LIMIT hard_limit +#define VIR_DOMAIN_MEMORY_SOFT_LIMIT soft_limit +#define VIR_DOMAIN_MEMORY_MIN_GUARANTEE min_guarantee +#define VIR_DOMAIN_SWAP_HARD_LIMIT swap_hard_limit + +/** + * virDomainMemoryParameter: + * + * a virDomainMemoryParameter is the set of scheduler parameters + */ + +typedef struct _virMemoryParameter virMemoryParameter; + +struct _virMemoryParameter { +char field[VIR_DOMAIN_MEMORY_FIELD_LENGTH]; /* parameter name */ +int type; /* parameter type */ +union { +int i; /* data for integer case */ +unsigned int ui;/* data for unsigned integer case */ +long long int l;/* data for long long integer case */ +unsigned long long int ul; /* data for unsigned long long integer case */ +double d; /* data for double case */ +char b; /* data for char case */ +} value; /* parameter value */ +}; + +/** + * virMemoryParameterPtr: + * + * a virMemoryParameterPtr is a pointer to a virMemoryParameter structure. + */ + +typedef virMemoryParameter *virMemoryParameterPtr; + +/* Set memory tunables for the domain*/ +int virDomainSetMemoryParameters(virDomainPtr domain, +virMemoryParameterPtr params, +int nparams); +/* Get memory tunables for the domain, caller allocates the params if nparams + * is zero and params is NULL, the domain returns back number of parameters + * supported by the HV. This could be used by the caller to allocate the + * memory and call with params structure allocated. + */ +int virDomainGetMemoryParameters(virDomainPtr domain, +virMemoryParameterPtr params, +int *nparams); + /* * Dynamic control of domains */ diff --git a/python/generator.py b/python/generator.py index d876df6..68009b9 100755 --- a/python/generator.py +++ b/python/generator.py @@ -306,6 +306,8 @@ skip_impl = ( 'virDomainGetSchedulerType', 'virDomainGetSchedulerParameters', 'virDomainSetSchedulerParameters', +'virDomainSetMemoryParameters', +'virDomainGetMemoryParameters', 'virDomainGetVcpus', 'virDomainPinVcpu', 'virSecretGetValue', diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml index ca16993..f209608 100644 --- a/python/libvirt-override-api.xml +++ b/python/libvirt-override-api.xml @@ -162,6 +162,18 @@ arg name='domain' type='virDomainPtr' info='pointer to domain object'/ arg name='params' type='virSchedParameterPtr' info='pointer to scheduler parameter objects'/ /function +function name='virDomainSetMemoryParameters' file='python' + infoChange the memory tunables/info + return type='int' info='-1 in case of error, 0 in case of success.'/ + arg name='domain' type='virDomainPtr' info='pointer to domain object'/ + arg name='params' type='virMemoryParameterPtr' info='pointer to memory tunable objects'/ +/function +function name='virDomainGetMemoryParameters' file='python' + infoGet the memory
[libvirt] [PATCH v3 00/13] Implement memory control api
Changelog from v2: * Implement virDomainGetMemoryParameters api * Add virDomainGetMemoryParameters to memtune command in virsh * Provide domainGetMemoryParameters implementation for remote, QEmu and LXC drivers * Auto-generate code using rpcgen and remote_generate_stubs.pl * Squash all the changes related to remote driver and remote protocol into one single patch. * Patch re-ordering Changelog from v1: * Patch re-ordering for compilation * Folded python bindings changes to patch 01 * Added defines for string constants for memory tunables * Typo fix: min_guarantee * Moved initialization of function pointers in driver.h patch This patch series implement public api for controlling various memory tunables exported by the OS. This is based on the following RFC[1]. * Implement virDomainSetMemoryParameters api * Provide implementation for remote, QEmu and LXC drivers * Enable memory controller support fro QEmu * virsh command for runtime changes to the memory parameters * Domain configuration parsing for memory control parameters * Cgroup memory controller code for memory hard_limit/soft_limit, swap hard_limit To Do * Python bindings is just a place holder, need to implement 1. https://www.redhat.com/archives/libvir-list/2010-August/msg00607.html 2. https://www.redhat.com/archives/libvir-list/2010-August/msg00699.html --- Nikunj A. Dadhania (13): Adding structure and defines for virDomainSet/GetMemoryParameters Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API Adds xml entries for memory tunables XML parsing for memory tunables Implement cgroup memory controller tunables Implement driver interface domainSetMemoryParamters for QEmu Implement driver interface domainGetMemoryParamters for QEmu Adding memtunables to qemuSetupCgroup Adding memtunables to libvirt-lxc command Implement driver interface domainSetMemoryParamters for LXC Implement driver interface domainGetMemoryParamters for LXC Adding memtune command to virsh tool Remote protocol changes and implements virDomainSet/GetMemoryParameters daemon/remote.c | 158 ++ daemon/remote_dispatch_args.h |2 daemon/remote_dispatch_prototypes.h | 16 ++ daemon/remote_dispatch_ret.h|1 daemon/remote_dispatch_table.h | 10 + docs/schemas/domain.rng | 31 include/libvirt/libvirt.h.in| 68 + python/generator.py |2 python/libvirt-override-api.xml | 12 ++ python/libvirt-override.c | 14 ++ src/conf/domain_conf.c | 50 ++- src/conf/domain_conf.h | 12 +- src/driver.h| 12 ++ src/esx/esx_driver.c|2 src/esx/esx_vmx.c | 30 ++-- src/libvirt.c | 103 ++ src/libvirt_private.syms|6 + src/libvirt_public.syms |6 + src/lxc/lxc_controller.c| 24 +++ src/lxc/lxc_driver.c| 213 - src/openvz/openvz_driver.c | 10 + src/phyp/phyp_driver.c |2 src/qemu/qemu.conf |4 - src/qemu/qemu_conf.c| 11 +- src/qemu/qemu_driver.c | 256 ++- src/remote/remote_driver.c | 146 src/remote/remote_protocol.c| 84 +++ src/remote/remote_protocol.h| 56 src/remote/remote_protocol.x| 42 ++ src/test/test_driver.c | 14 +- src/uml/uml_conf.c |2 src/uml/uml_driver.c| 16 +- src/util/cgroup.c | 106 ++ src/util/cgroup.h |7 + src/xen/xen_driver.c|2 tools/virsh.c | 130 ++ 36 files changed, 1592 insertions(+), 68 deletions(-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 09/13] Adding memtunables to libvirt-lxc command
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com libvirt-lxc now configures the hardlimit, softlimit and swaplimit, if specified in the domain xml file or picks up the defaults. Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/lxc/lxc_controller.c | 22 ++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 82ecce0..dee99b7 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -109,6 +109,28 @@ static int lxcSetContainerResources(virDomainDefPtr def) def-name); goto cleanup; } + +rc = virCgroupSetMemoryHardLimit(cgroup, def-mem.hard_limit); +if (rc != 0) { +virReportSystemError(-rc, + _(Unable to set memory hard limit for domain %s), + def-name); +goto cleanup; +} +rc = virCgroupSetMemorySoftLimit(cgroup, def-mem.soft_limit); +if (rc != 0) { +virReportSystemError(-rc, + _(Unable to set memory soft limit for domain %s), + def-name); +goto cleanup; +} +rc = virCgroupSetSwapHardLimit(cgroup, def-mem.swap_hard_limit); +if (rc != 0) { +virReportSystemError(-rc, + _(Unable to set swap hard limit for domain %s), + def-name); +goto cleanup; +} rc = virCgroupDenyAllDevices(cgroup); if (rc != 0) { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 05/13] Implement cgroup memory controller tunables
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com Provides interfaces for setting/getting memory tunables like hard_limit, soft_limit and swap_hard_limit Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/libvirt_private.syms |6 +++ src/util/cgroup.c| 106 ++ src/util/cgroup.h|7 +++ 3 files changed, 119 insertions(+), 0 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c2905ba..038dd77 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -77,6 +77,12 @@ virCgroupControllerTypeFromString; virCgroupGetCpuacctUsage; virCgroupGetFreezerState; virCgroupSetFreezerState; +virCgroupSetMemoryHardLimit; +virCgroupGetMemoryHardLimit; +virCgroupSetMemorySoftLimit; +virCgroupGetMemorySoftLimit; +virCgroupSetSwapHardLimit; +virCgroupGetSwapHardLimit; # cpu.h diff --git a/src/util/cgroup.c b/src/util/cgroup.c index 024036a..f94db12 100644 --- a/src/util/cgroup.c +++ b/src/util/cgroup.c @@ -874,6 +874,112 @@ int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb) } /** + * virCgroupSetMemoryHardLimit: + * + * @group: The cgroup to change memory hard limit for + * @kb: The memory amount in kilobytes + * + * Returns: 0 on success + */ +int virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long kb) +{ +return virCgroupSetMemory(group, kb); +} + +/** + * virCgroupGetMemoryHardLimit: + * + * @group: The cgroup to get the memory hard limit for + * @kb: The memory amount in kilobytes + * + * Returns: 0 on success + */ +int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long *kb) +{ +long long unsigned int limit_in_bytes; +int ret; +ret = virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + memory.limit_in_bytes, limit_in_bytes); +if (ret == 0) +*kb = (unsigned long) limit_in_bytes 10; +return ret; +} + +/** + * virCgroupSetMemorySoftLimit: + * + * @group: The cgroup to change memory soft limit for + * @kb: The memory amount in kilobytes + * + * Returns: 0 on success + */ +int virCgroupSetMemorySoftLimit(virCgroupPtr group, unsigned long kb) +{ +return virCgroupSetValueU64(group, +VIR_CGROUP_CONTROLLER_MEMORY, +memory.soft_limit_in_bytes, +kb 10); +} + + +/** + * virCgroupGetMemorySoftLimit: + * + * @group: The cgroup to get the memory soft limit for + * @kb: The memory amount in kilobytes + * + * Returns: 0 on success + */ +int virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long *kb) +{ +long long unsigned int limit_in_bytes; +int ret; +ret = virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + memory.soft_limit_in_bytes, limit_in_bytes); +if (ret == 0) +*kb = (unsigned long) limit_in_bytes 10; +return ret; +} + +/** + * virCgroupSetSwapHardLimit: + * + * @group: The cgroup to change swap hard limit for + * @kb: The swap amount in kilobytes + * + * Returns: 0 on success + */ +int virCgroupSetSwapHardLimit(virCgroupPtr group, unsigned long kb) +{ +return virCgroupSetValueU64(group, +VIR_CGROUP_CONTROLLER_MEMORY, +memory.memsw.limit_in_bytes, +kb 10); +} + +/** + * virCgroupGetSwapHardLimit: + * + * @group: The cgroup to get swap hard limit for + * @kb: The swap amount in kilobytes + * + * Returns: 0 on success + */ +int virCgroupGetSwapHardLimit(virCgroupPtr group, unsigned long *kb) +{ +long long unsigned int limit_in_bytes; +int ret; +ret = virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + memory.memsw.limit_in_bytes, limit_in_bytes); +if (ret == 0) +*kb = (unsigned long) limit_in_bytes 10; +return ret; +} + +/** * virCgroupDenyAllDevices: * * @group: The cgroup to deny devices for diff --git a/src/util/cgroup.h b/src/util/cgroup.h index 2bea49f..b8f2d08 100644 --- a/src/util/cgroup.h +++ b/src/util/cgroup.h @@ -43,6 +43,13 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid); int virCgroupSetMemory(virCgroupPtr group, unsigned long kb); int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb); +int virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long kb); +int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long *kb); +int virCgroupSetMemorySoftLimit(virCgroupPtr group, unsigned long kb); +int virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long *kb); +int virCgroupSetSwapHardLimit(virCgroupPtr group, unsigned long kb); +int virCgroupGetSwapHardLimit(virCgroupPtr group, unsigned long *kb); + int virCgroupDenyAllDevices(virCgroupPtr group); int virCgroupAllowDevice(virCgroupPtr group,
[libvirt] [PATCH v3 06/13] Implement driver interface domainSetMemoryParamters for QEmu
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com Driver interface for setting memory hard_limit, soft_limit and swap hard_limit. v2: + Use #define string constants for hard_limit, etc. + fix typo: min_guarantee Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/qemu/qemu_driver.c | 94 +++- 1 files changed, 93 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bf4373a..b6be343 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9365,6 +9365,98 @@ cleanup: return ret; } + +static int qemuDomainSetMemoryParameters(virDomainPtr dom, + virMemoryParameterPtr params, + int nparams) +{ +struct qemud_driver *driver = dom-conn-privateData; +int i; +virCgroupPtr group = NULL; +virDomainObjPtr vm = NULL; +int ret = -1; + +qemuDriverLock(driver); +if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_MEMORY)) { +qemuReportError(VIR_ERR_NO_SUPPORT, +__FUNCTION__); +goto cleanup; +} + +vm = virDomainFindByUUID(driver-domains, dom-uuid); + +if (vm == NULL) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, +_(No such domain %s), dom-uuid); +goto cleanup; +} + +if (virCgroupForDomain(driver-cgroup, vm-def-name, group, 0) != 0) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, +_(cannot find cgroup for domain %s), vm-def-name); +goto cleanup; +} + +for (i = 0; i nparams; i++) { +virMemoryParameterPtr param = params[i]; + +if (STREQ(param-field, VIR_DOMAIN_MEMORY_HARD_LIMIT)) { +int rc; +if (param-type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { +qemuReportError(VIR_ERR_INVALID_ARG, %s, +_(invalid type for memory hard_limit tunable, expected a 'ullong')); +continue; +} + +rc = virCgroupSetMemoryHardLimit(group, params[i].value.ul); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set memory hard_limit tunable)); +} +} else if (STREQ(param-field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) { +int rc; +if (param-type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { +qemuReportError(VIR_ERR_INVALID_ARG, %s, +_(invalid type for memory soft_limit tunable, expected a 'ullong')); +continue; +} + +rc = virCgroupSetMemorySoftLimit(group, params[i].value.ul); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set memory soft_limit tunable)); +} +} else if (STREQ(param-field, VIR_DOMAIN_SWAP_HARD_LIMIT)) { +int rc; +if (param-type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { +qemuReportError(VIR_ERR_INVALID_ARG, %s, +_(invalid type for swap_hard_limit tunable, expected a 'ullong')); +continue; +} + +rc = virCgroupSetSwapHardLimit(group, params[i].value.ul); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set swap_hard_limit tunable)); +} +} else if (STREQ(param-field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) { +qemuReportError(VIR_ERR_INVALID_ARG, +_(Memory tunable `%s' not implemented), param-field); +} else { +qemuReportError(VIR_ERR_INVALID_ARG, +_(Parameter `%s' not supported), param-field); +} +} +ret = 0; + +cleanup: +virCgroupFree(group); +if (vm) +virDomainObjUnlock(vm); +qemuDriverUnlock(driver); +return ret; +} + static int qemuSetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params, int nparams) @@ -12710,7 +12802,7 @@ static virDriver qemuDriver = { qemuDomainRevertToSnapshot, /* domainRevertToSnapshot */ qemuDomainSnapshotDelete, /* domainSnapshotDelete */ qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */ -NULL, /* domainSetMemoryParameters */ +qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */ NULL, /* domainGetMemoryParameters */ }; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 12/13] Adding memtune command to virsh tool
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com The command helps to control the memory/swap parameters for the system, for eg. hard_limit (max memory the vm can use), soft_limit (limit during memory contention), swap_hard_limit(max swap the vm can use) v3: + Added call to virDomainGetMemoryParameters and print them. + Added virDomainGetMemoryParameters and virDomainSetMemoryParamters to libvirt_public.syms v2: + Use #define string constants for hard_limit, etc Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/libvirt_public.syms |6 ++ tools/virsh.c | 130 +++ 2 files changed, 136 insertions(+), 0 deletions(-) diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 849c163..fceb516 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -405,4 +405,10 @@ LIBVIRT_0.8.2 { virDomainCreateWithFlags; } LIBVIRT_0.8.1; +LIBVIRT_0.8.5 { +global: +virDomainSetMemoryParameters; +virDomainGetMemoryParameters; +} LIBVIRT_0.8.2; + # define new API here using predicted next version number diff --git a/tools/virsh.c b/tools/virsh.c index 85014f2..0500cb5 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -2614,6 +2614,135 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) } /* + * memtune command + */ +static const vshCmdInfo info_memtune[] = { +{help, N_(Get/Set memory paramters)}, +{desc, N_(Get/Set the current memory paramters for the guest domain.\n \ +To get the memory parameters use following command: \n\n \ +virsh # memtune domain)}, +{NULL, NULL} +}; + +static const vshCmdOptDef opts_memtune[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{VIR_DOMAIN_MEMORY_HARD_LIMIT, VSH_OT_STRING, VSH_OFLAG_NONE, N_(Max memory in kilobytes)}, +{VIR_DOMAIN_MEMORY_SOFT_LIMIT, VSH_OT_STRING, VSH_OFLAG_NONE, N_(Memory during contention in kilobytes)}, +{VIR_DOMAIN_SWAP_HARD_LIMIT, VSH_OT_STRING, VSH_OFLAG_NONE, N_(Max swap in kilobytes)}, +{NULL, 0, 0, NULL} +}; + +static int +cmdMemtune(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom; +int hard_limit, soft_limit, swap_hard_limit; +int nparams = 0; +unsigned int i = 0; +virMemoryParameterPtr params = NULL, temp = NULL; +int ret = FALSE; + +if (!vshConnectionUsability(ctl, ctl-conn)) +return FALSE; + +if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) +return FALSE; + +hard_limit = vshCommandOptInt(cmd, VIR_DOMAIN_MEMORY_HARD_LIMIT, hard_limit); +if (hard_limit) +nparams++; + +soft_limit = vshCommandOptInt(cmd, VIR_DOMAIN_MEMORY_SOFT_LIMIT, soft_limit); +if (soft_limit) +nparams++; + +swap_hard_limit = vshCommandOptInt(cmd, VIR_DOMAIN_SWAP_HARD_LIMIT, swap_hard_limit); +if (swap_hard_limit) +nparams++; + +if(nparams == 0) { +/* get the number of memory parameters */ +if (virDomainGetMemoryParameters(dom, NULL, nparams) != 0 (nparams != 0)) { +vshError(ctl, %s, _(Unable to get number of memory parameters)); +goto cleanup; +} + +/* now go get all the memory parameters */ +params = vshMalloc(ctl, sizeof(virMemoryParameter)* nparams); +memset(params, 0, sizeof(virMemoryParameter)* nparams); +if (virDomainGetMemoryParameters(dom, params, nparams)) { +vshError(ctl, %s, _(Unable to get memory parameters)); +goto cleanup; +} + +for (i = 0; i nparams; i++){ +switch (params[i].type) { +case VIR_DOMAIN_MEMORY_FIELD_INT: +vshPrint(ctl, %-15s: %d\n, params[i].field, params[i].value.i); +break; +case VIR_DOMAIN_MEMORY_FIELD_UINT: +vshPrint(ctl, %-15s: %u\n, params[i].field, params[i].value.ui); +break; +case VIR_DOMAIN_MEMORY_FIELD_LLONG: +vshPrint(ctl, %-15s: %lld\n, params[i].field, params[i].value.l); +break; +case VIR_DOMAIN_MEMORY_FIELD_ULLONG: +vshPrint(ctl, %-15s: %llu\n, params[i].field, params[i].value.ul); +break; +case VIR_DOMAIN_MEMORY_FIELD_DOUBLE: +vshPrint(ctl, %-15s: %f\n, params[i].field, params[i].value.d); +break; +case VIR_DOMAIN_MEMORY_FIELD_BOOLEAN: +vshPrint(ctl, %-15s: %d\n, params[i].field, params[i].value.b); +break; +default: +vshPrint(ctl, not implemented scheduler parameter type\n); +} +} + +ret = TRUE; +} else { +/* set the memory parameters */ +params = vshMalloc(ctl, sizeof(virMemoryParameter)* nparams); + +memset(params, 0, sizeof(virMemoryParameter)* nparams); +for(i = 0; i
[libvirt] [PATCH v3 02/13] Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com Public api to set/get memory tunables supported by the hypervisors. RFC: https://www.redhat.com/archives/libvir-list/2010-August/msg00607.html v3: * Add domainGetMemoryParamters and NULL in all the driver interface v2: * Initialize domainSetMemoryParameters to NULL in all the driver interface structure. Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/driver.h | 12 + src/esx/esx_driver.c |2 + src/libvirt.c | 103 src/lxc/lxc_driver.c |2 + src/openvz/openvz_driver.c |2 + src/phyp/phyp_driver.c |2 + src/qemu/qemu_driver.c |2 + src/remote/remote_driver.c |2 + src/test/test_driver.c |2 + src/uml/uml_driver.c |2 + src/xen/xen_driver.c |2 + 11 files changed, 133 insertions(+), 0 deletions(-) diff --git a/src/driver.h b/src/driver.h index e443c1c..0580bee 100644 --- a/src/driver.h +++ b/src/driver.h @@ -128,6 +128,16 @@ typedef int (*virDrvDomainSetMemory) (virDomainPtr domain, unsigned long memory); typedef int +(*virDrvDomainSetMemoryParameters) +(virDomainPtr domain, + virMemoryParameterPtr params, + int nparams); +typedef int +(*virDrvDomainGetMemoryParameters) +(virDomainPtr domain, + virMemoryParameterPtr params, + int *nparams); +typedef int (*virDrvDomainGetInfo) (virDomainPtr domain, virDomainInfoPtr info); typedef int @@ -575,6 +585,8 @@ struct _virDriver { virDrvDomainRevertToSnapshot domainRevertToSnapshot; virDrvDomainSnapshotDelete domainSnapshotDelete; virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand; +virDrvDomainSetMemoryParameters domainSetMemoryParameters; +virDrvDomainGetMemoryParameters domainGetMemoryParameters; }; typedef int diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index e382950..e959be2 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4217,6 +4217,8 @@ static virDriver esxDriver = { esxDomainRevertToSnapshot, /* domainRevertToSnapshot */ esxDomainSnapshotDelete, /* domainSnapshotDelete */ NULL,/* qemuDomainMonitorCommand */ +NULL,/* domainSetMemoryParameters */ +NULL,/* domainGetMemoryParameters */ }; diff --git a/src/libvirt.c b/src/libvirt.c index ca383ba..0708e36 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3000,6 +3000,109 @@ error: } /** + * virDomainSetMemoryParameters: + * @domain: pointer to domain object + * @params: pointer to memory parameter objects + * @nparams: number of memory parameter (this value should be same or + * less than the number of parameters supported) + * + * Change the memory tunables + * This function requires privileged access to the hypervisor. + * FIXME: Should we make changes to the domain configuration file as well? + * + * Returns -1 in case of error, 0 in case of success. + */ +int +virDomainSetMemoryParameters(virDomainPtr domain, +virMemoryParameterPtr params, +int nparams) +{ +virConnectPtr conn; +DEBUG(domain=%p, params=%p, nparams=%d, domain, params, nparams); + +virResetLastError(); + +if (!VIR_IS_CONNECTED_DOMAIN(domain)) { +virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); +virDispatchError(NULL); +return -1; +} +if (domain-conn-flags VIR_CONNECT_RO) { +virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); +goto error; +} +conn = domain-conn; + +if (conn-driver-domainSetMemoryParameters) { +int ret; +ret = conn-driver-domainSetMemoryParameters (domain, params, nparams); +if (ret 0) +goto error; +return ret; +} + +virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: +virDispatchError(domain-conn); +return -1; +} + +/** + * virDomainGetMemoryParameters: + * @domain: pointer to domain object + * @params: pointer to memory parameter object + * (return value, allocated by the caller) + * @nparams: pointer to number of memory parameters + * + * Get the memory parameters, the @params array will be filled with the values + * equal to the number of parameters suggested by @nparams + * + * As a special case, if @nparams is zero and @params is NULL, the API will + * set the number of parameters supported by the HV in @nparams and return + * SUCCESS. + * + * This function requires privileged access to
[libvirt] [PATCH v3 10/13] Implement driver interface domainSetMemoryParamters for LXC
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com Add support in the lxc driver for various memory controllable parameters v2: + Use #define string constants for hard_limit, etc + fix typo: min_guarantee Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/lxc/lxc_driver.c | 90 +- 1 files changed, 89 insertions(+), 1 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8977835..6912bb8 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -677,6 +677,94 @@ cleanup: return ret; } +static int lxcDomainSetMemoryParameters(virDomainPtr dom, +virMemoryParameterPtr params, +int nparams) +{ +lxc_driver_t *driver = dom-conn-privateData; +int i; +virCgroupPtr cgroup = NULL; +virDomainObjPtr vm = NULL; +int ret = -1; + +lxcDriverLock(driver); +vm = virDomainFindByUUID(driver-domains, dom-uuid); + +if (vm == NULL) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(dom-uuid, uuidstr); +lxcError(VIR_ERR_NO_DOMAIN, + _(No domain with matching uuid '%s'), uuidstr); +goto cleanup; +} + +if (virCgroupForDomain(driver-cgroup, vm-def-name, cgroup, 0) != 0) { +lxcError(VIR_ERR_INTERNAL_ERROR, + _(Unable to get cgroup for %s), vm-def-name); +goto cleanup; +} + +for (i = 0; i nparams; i++) { +virMemoryParameterPtr param = params[i]; + +if (STREQ(param-field, VIR_DOMAIN_MEMORY_HARD_LIMIT)) { +int rc; +if (param-type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { +lxcError(VIR_ERR_INVALID_ARG, %s, + _(invalid type for memory hard_limit tunable, expected a 'ullong')); +continue; +} + +rc = virCgroupSetMemoryHardLimit(cgroup, params[i].value.ul); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set memory hard_limit tunable)); +} +} else if (STREQ(param-field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) { +int rc; +if (param-type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { +lxcError(VIR_ERR_INVALID_ARG, %s, + _(invalid type for memory soft_limit tunable, expected a 'ullong')); +continue; +} + +rc = virCgroupSetMemorySoftLimit(cgroup, params[i].value.ul); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set memory soft_limit tunable)); +} +} else if (STREQ(param-field, VIR_DOMAIN_SWAP_HARD_LIMIT)) { +int rc; +if (param-type != VIR_DOMAIN_MEMORY_FIELD_ULLONG) { +lxcError(VIR_ERR_INVALID_ARG, %s, + _(invalid type for swap_hard_limit tunable, expected a 'ullong')); +continue; +} + +rc = virCgroupSetSwapHardLimit(cgroup, params[i].value.ul); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set swap_hard_limit tunable)); +} +} else if (STREQ(param-field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) { +lxcError(VIR_ERR_INVALID_ARG, + _(Memory tunable `%s' not implemented), param-field); +} else { +lxcError(VIR_ERR_INVALID_ARG, + _(Parameter `%s' not supported), param-field); +} +} +ret = 0; + +cleanup: +if (cgroup) +virCgroupFree(cgroup); +if (vm) +virDomainObjUnlock(vm); +lxcDriverUnlock(driver); +return ret; +} + static char *lxcDomainDumpXML(virDomainPtr dom, int flags) { @@ -2620,7 +2708,7 @@ static virDriver lxcDriver = { NULL, /* domainRevertToSnapshot */ NULL, /* domainSnapshotDelete */ NULL, /* qemuDomainMonitorCommand */ -NULL, /* domainSetMemoryParameters */ +lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */ NULL, /* domainGetMemoryParameters */ }; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 08/13] Adding memtunables to qemuSetupCgroup
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com QEmu startup would pick up the memory tunables specified in the domain configuration file. Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/qemu/qemu.conf |4 ++-- src/qemu/qemu_conf.c |3 ++- src/qemu/qemu_driver.c | 27 +++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index dc8eb83..bfb9f6a 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -111,13 +111,13 @@ # the adminsitrator has mounted cgroups. eg # # mkdir /dev/cgroup -# mount -t cgroup -o devices,cpu none /dev/cgroup +# mount -t cgroup -o devices,cpu,memory none /dev/cgroup # # They can be mounted anywhere, and different controlers # can be mounted in different locations. libvirt will detect # where they are located. # -# cgroup_controllers = [ cpu, devices ] +# cgroup_controllers = [ cpu, devices, memory ] # This is the basic set of devices allowed / required by # all virtual machines. diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 731c554..3f5c1ac 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -275,7 +275,8 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, } else { driver-cgroupControllers = (1 VIR_CGROUP_CONTROLLER_CPU) | -(1 VIR_CGROUP_CONTROLLER_DEVICES); +(1 VIR_CGROUP_CONTROLLER_DEVICES) | +(1 VIR_CGROUP_CONTROLLER_MEMORY); } for (i = 0 ; i VIR_CGROUP_CONTROLLER_LAST ; i++) { if (driver-cgroupControllers (1 i)) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fcb7f9d..6d05bf8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3495,6 +3495,33 @@ static int qemuSetupCgroup(struct qemud_driver *driver, goto cleanup; } +if ((rc = qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_MEMORY))) { +rc = virCgroupSetMemoryHardLimit(cgroup, vm-def-mem.hard_limit); +if (rc != 0) { +virReportSystemError(-rc, + _(Unable to set memory hard limit for domain %s), + vm-def-name); +goto cleanup; +} +rc = virCgroupSetMemorySoftLimit(cgroup, vm-def-mem.soft_limit); +if (rc != 0) { +virReportSystemError(-rc, + _(Unable to set memory soft limit for domain %s), + vm-def-name); +goto cleanup; +} +rc = virCgroupSetSwapHardLimit(cgroup, vm-def-mem.swap_hard_limit); +if (rc != 0) { +virReportSystemError(-rc, + _(Unable to set swap hard limit for domain %s), + vm-def-name); +goto cleanup; +} +} else { +VIR_WARN(Memory cgroup is disabled in qemu configuration file: %s, + vm-def-name); +} + done: virCgroupFree(cgroup); return 0; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 13/13] Remote protocol changes and implements virDomainSet/GetMemoryParameters
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com v3: * Squased all the remote driver changes to one single big patch and auto-generated is around 40% * Implements domainSetMemoryParameters and domainGetMemoryParameters for remote driver daemon/remote.c src/remote/remote_driver.c * Auto generate the files using rpcgen and helper scripts in daemon/ directory src/remote/remote_protocol.x daemon/remote_dispatch_args.h daemon/remote_dispatch_prototypes.h daemon/remote_dispatch_ret.h daemon/remote_dispatch_table.h src/remote/remote_protocol.c src/remote/remote_protocol.h Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- daemon/remote.c | 158 +++ daemon/remote_dispatch_args.h |2 daemon/remote_dispatch_prototypes.h | 16 daemon/remote_dispatch_ret.h|1 daemon/remote_dispatch_table.h | 10 ++ src/remote/remote_driver.c | 148 - src/remote/remote_protocol.c| 84 +++ src/remote/remote_protocol.h| 56 src/remote/remote_protocol.x| 42 + 9 files changed, 514 insertions(+), 3 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 118654c..c8977d8 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -2332,6 +2332,164 @@ remoteDispatchDomainSetMemory (struct qemud_server *server ATTRIBUTE_UNUSED, } static int +remoteDispatchDomainSetMemoryParameters (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_parameters_args *args, + void *ret ATTRIBUTE_UNUSED) +{ +virDomainPtr dom; +int i, r, nparams; +virMemoryParameterPtr params; + +nparams = args-params.params_len; + +if (nparams REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) { +remoteDispatchFormatError (rerr, %s, _(nparams too large)); +return -1; +} +if (VIR_ALLOC_N(params, nparams) 0) { +remoteDispatchOOMError(rerr); +return -1; +} + +/* Deserialise parameters. */ +for (i = 0; i nparams; ++i) { +if (virStrcpyStatic(params[i].field, args-params.params_val[i].field) == NULL) { +remoteDispatchFormatError(rerr, _(Field %s too big for destination), + args-params.params_val[i].field); +return -1; +} +params[i].type = args-params.params_val[i].value.type; +switch (params[i].type) { +case VIR_DOMAIN_MEMORY_FIELD_INT: +params[i].value.i = args-params.params_val[i].value.remote_memory_param_value_u.i; break; +case VIR_DOMAIN_MEMORY_FIELD_UINT: +params[i].value.ui = args-params.params_val[i].value.remote_memory_param_value_u.ui; break; +case VIR_DOMAIN_MEMORY_FIELD_LLONG: +params[i].value.l = args-params.params_val[i].value.remote_memory_param_value_u.l; break; +case VIR_DOMAIN_MEMORY_FIELD_ULLONG: +params[i].value.ul = args-params.params_val[i].value.remote_memory_param_value_u.ul; break; +case VIR_DOMAIN_MEMORY_FIELD_DOUBLE: +params[i].value.d = args-params.params_val[i].value.remote_memory_param_value_u.d; break; +case VIR_DOMAIN_MEMORY_FIELD_BOOLEAN: +params[i].value.b = args-params.params_val[i].value.remote_memory_param_value_u.b; break; +} +} + +dom = get_nonnull_domain (conn, args-dom); +if (dom == NULL) { +VIR_FREE(params); +remoteDispatchConnError(rerr, conn); +return -1; +} + +r = virDomainSetMemoryParameters (dom, params, nparams); +virDomainFree(dom); +VIR_FREE(params); +if (r == -1) { +remoteDispatchConnError(rerr, conn); +return -1; +} + +return 0; +} + +static int remoteDispatchDomainGetMemoryParameters (struct qemud_server *server, +struct qemud_client *client, +virConnectPtr conn, +remote_message_header *hdr, +remote_error *rerr, + remote_domain_get_memory_parameters_args *args, + remote_domain_get_memory_parameters_ret *ret) +{ +virDomainPtr dom; +virMemoryParameterPtr params; +int i, r, nparams; + +nparams = args-nparams; + +if (nparams
[libvirt] [PATCH v3 04/13] XML parsing for memory tunables
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com Adding parsing code for memory tunables in the domain xml file v2: + Fix typo min_guarantee Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/conf/domain_conf.c | 50 +--- src/conf/domain_conf.h | 12 --- src/esx/esx_vmx.c | 30 +- src/lxc/lxc_controller.c |2 +- src/lxc/lxc_driver.c | 12 +-- src/openvz/openvz_driver.c |8 --- src/qemu/qemu_conf.c |8 --- src/qemu/qemu_driver.c | 18 src/test/test_driver.c | 12 +-- src/uml/uml_conf.c |2 +- src/uml/uml_driver.c | 14 ++-- 11 files changed, 104 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e05d5d7..0dd74e4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4231,19 +4231,38 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def-description = virXPathString(string(./description[1]), ctxt); /* Extract domain memory */ -if (virXPathULong(string(./memory[1]), ctxt, def-maxmem) 0) { +if (virXPathULong(string(./memory[1]), ctxt, + def-mem.max_balloon) 0) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, %s, _(missing memory element)); goto error; } -if (virXPathULong(string(./currentMemory[1]), ctxt, def-memory) 0) -def-memory = def-maxmem; +if (virXPathULong(string(./currentMemory[1]), ctxt, + def-mem.cur_balloon) 0) +def-mem.cur_balloon = def-mem.max_balloon; node = virXPathNode(./memoryBacking/hugepages, ctxt); if (node) -def-hugepage_backed = 1; - +def-mem.hugepage_backed = 1; + +/* Extract other memory tunables */ +if (virXPathULong(string(./memtune/hard_limit), ctxt, + def-mem.hard_limit) 0) +def-mem.hard_limit = 0; + +if (virXPathULong(string(./memtune/soft_limit[1]), ctxt, + def-mem.soft_limit) 0) +def-mem.soft_limit = 0; + +if (virXPathULong(string(./memtune/min_guarantee[1]), ctxt, + def-mem.min_guarantee) 0) +def-mem.min_guarantee = 0; + +if (virXPathULong(string(./memtune/swap_hard_limit[1]), ctxt, + def-mem.swap_hard_limit) 0) +def-mem.swap_hard_limit = 0; + if (virXPathULong(string(./vcpu[1]), ctxt, def-vcpus) 0) def-vcpus = 1; @@ -6382,10 +6401,25 @@ char *virDomainDefFormat(virDomainDefPtr def, virBufferEscapeString(buf, description%s/description\n, def-description); -virBufferVSprintf(buf, memory%lu/memory\n, def-maxmem); +virBufferVSprintf(buf, memory%lu/memory\n, def-mem.max_balloon); virBufferVSprintf(buf, currentMemory%lu/currentMemory\n, - def-memory); -if (def-hugepage_backed) { + def-mem.cur_balloon); +virBufferVSprintf(buf, memtune\n); +if (def-mem.hard_limit) { +virBufferVSprintf(buf, hard_limit%lu/hard_limit\n, + def-mem.hard_limit); +} +if (def-mem.soft_limit) { +virBufferVSprintf(buf, soft_limit%lu/soft_limit\n, + def-mem.soft_limit); +} +if (def-mem.swap_hard_limit) { +virBufferVSprintf(buf, swap_hard_limit%lu/swap_hard_limit\n, + def-mem.swap_hard_limit); +} +virBufferVSprintf(buf, /memtune\n); + +if (def-mem.hugepage_backed) { virBufferAddLit(buf, memoryBacking\n); virBufferAddLit(buf, hugepages/\n); virBufferAddLit(buf, /memoryBacking\n); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7195c04..2ecc2af 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -864,9 +864,15 @@ struct _virDomainDef { char *name; char *description; -unsigned long memory; -unsigned long maxmem; -unsigned char hugepage_backed; +struct { +unsigned long max_balloon; +unsigned long cur_balloon; +unsigned long hugepage_backed; +unsigned long hard_limit; +unsigned long soft_limit; +unsigned long min_guarantee; +unsigned long swap_hard_limit; +} mem; unsigned long vcpus; int cpumasklen; char *cpumask; diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c index 59eb3b2..6f1eb17 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -48,8 +48,8 @@ domain-xml= vmx def-id = value = ??? # not representable def-uuid = value = uuid.bios = value def-name = value = displayName = value -def-maxmem = value kilobyte= memsize = value
[libvirt] [PATCH v3 11/13] Implement driver interface domainGetMemoryParamters for LXC
From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com Driver interface for getting memory parameters, eg. hard_limit, soft_limit and swap_hard_limit. Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com --- src/lxc/lxc_driver.c | 113 ++ 1 files changed, 112 insertions(+), 1 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6912bb8..e60a569 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -765,6 +765,117 @@ cleanup: return ret; } +static int lxcDomainGetMemoryParameters(virDomainPtr dom, +virMemoryParameterPtr params, +int *nparams) +{ +lxc_driver_t *driver = dom-conn-privateData; +int i; +virCgroupPtr cgroup = NULL; +virDomainObjPtr vm = NULL; +unsigned long val; +int ret = -1; +int rc; + +lxcDriverLock(driver); +vm = virDomainFindByUUID(driver-domains, dom-uuid); + +if (vm == NULL) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(dom-uuid, uuidstr); +lxcError(VIR_ERR_NO_DOMAIN, + _(No domain with matching uuid '%s'), uuidstr); +goto cleanup; +} + +if ((*nparams) == 0) { +/* Current number of memory parameters supported by cgroups is 3 + * FIXME: Magic number, need to see where should this go + */ +*nparams = 3; +ret = 0; +goto cleanup; +} +if ((*nparams) != 3) { +lxcError(VIR_ERR_INVALID_ARG, + %s, _(Invalid parameter count)); +goto cleanup; +} + +if (virCgroupForDomain(driver-cgroup, vm-def-name, cgroup, 0) != 0) { +lxcError(VIR_ERR_INTERNAL_ERROR, + _(Unable to get cgroup for %s), vm-def-name); +goto cleanup; +} + +for (i = 0; i *nparams; i++) { +virMemoryParameterPtr param = params[i]; +val = 0; +param-value.ul = 0; +param-type = VIR_DOMAIN_MEMORY_FIELD_ULLONG; + +switch(i) { +case 0: /* fill memory hard limit here */ +rc = virCgroupGetMemoryHardLimit(cgroup, val); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to get memory hard limit)); +continue; +} +if (virStrcpyStatic(param-field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) { +lxcError(VIR_ERR_INTERNAL_ERROR, + %s, _(Field memory hard limit too long for destination)); +continue; +} +param-value.ul = val; +break; + +case 1: /* fill memory soft limit here */ +rc = virCgroupGetMemorySoftLimit(cgroup, val); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to get memory soft limit)); +continue; +} +if (virStrcpyStatic(param-field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) { +lxcError(VIR_ERR_INTERNAL_ERROR, + %s, _(Field memory soft limit too long for destination)); +continue; +} +param-value.ul = val; +break; + +case 2: /* fill swap hard limit here */ +rc = virCgroupGetSwapHardLimit(cgroup, val); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to get swap hard limit)); +continue; +} +if (virStrcpyStatic(param-field, VIR_DOMAIN_SWAP_HARD_LIMIT) == NULL) { +lxcError(VIR_ERR_INTERNAL_ERROR, + %s, _(Field swap hard limit too long for destination)); +continue; +} +param-value.ul = val; +break; + +default: +break; +/* should not hit here */ +} +} +ret = 0; + +cleanup: +if (cgroup) +virCgroupFree(cgroup); +if (vm) +virDomainObjUnlock(vm); +lxcDriverUnlock(driver); +return ret; +} + static char *lxcDomainDumpXML(virDomainPtr dom, int flags) { @@ -2709,7 +2820,7 @@ static virDriver lxcDriver = { NULL, /* domainSnapshotDelete */ NULL, /* qemuDomainMonitorCommand */ lxcDomainSetMemoryParameters, /* domainSetMemoryParameters */ -NULL, /* domainGetMemoryParameters */ +lxcDomainGetMemoryParameters, /* domainGetMemoryParameters */ }; static virStateDriver lxcStateDriver = { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/5] Extend nwfilter schema to accept comment attributes
Eric Blake ebl...@redhat.com wrote on 09/27/2010 05:07:47 PM: On 09/27/2010 12:40 PM, Stefan Berger wrote: Extend the nwfilter.rng schema to accept comment attributes for all protocol types. Signed-off-by: Stefan Berger stef...@us.ibm.com + define name=comment-attribute +interleave + optional +attribute name=comment + ref name=comment-type/ +/attribute + /optional +/interleave + /define Maybe I'm not understanding rng, but what is being interleaved here? Do things still validate if comment-attribute does not contain an interleave? It's not necessary from what I can see, so I removed it. + + define name='comment-type' +data type=string + param name=pattern[a-za-z0-9`~...@#$%\-_+=|\\:;,./ \ (\)\[\]\{\}quot;amp;lt;gt;apos;]*/param Since we are enforcing a maximum comment length of 256, would it make sense to use {0,256} rather than * (or is it \{0,256\} for this flavor of regular expression)? This explicitly leaves out tabs; I guess that's Correct. okay. It also leaves out 8-bit bytes - could that be a problem for i18n where people want comments with native-language accented characters? That is, are we being too strict here? Maybe a better pattern would be to reject specific non-printing ASCII bytes we want to avoid, assuing you can use escape sequences like [^\001]? Looking at http://www.asciitable.com/ I should probably include 0x20-0x7E and 128-175, 224-238 - maybe even more? So the regex then becomes [#x20;-#x7E;#128;-#175;#224;-#238;]{0,256} Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] mac os x: don't compile failing example program on 32 bit mac os x
This addresses a compilation failure issue reported last year on OS X: https://www.redhat.com/archives/libvir-list/2009-May/msg00166.html In testing here, the compilation only fails on 32 bit OS X, but works on 64 bit, even when using exact same compile and linking flags. This commit surgically disables compilation of this one example program on 32 bit Mac OS X (only). Compilation still occurs, with a working executable produced, on 64 bit Mac OS X. --- examples/domain-events/events-c/event-test.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c index 74eabba..3dff13b 100644 --- a/examples/domain-events/events-c/event-test.c +++ b/examples/domain-events/events-c/event-test.c @@ -5,7 +5,7 @@ #include string.h #include signal.h -#if HAVE_SYS_POLL_H +#if HAVE_SYS_POLL_H !(defined(__i386__) defined(__APPLE__) defined(__MACH__)) # include sys/types.h # include sys/poll.h # include libvirt/libvirt.h -- 1.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nwfilter: remove recently added workaround define for macos x
On 09/28/2010 08:48 PM, Stefan Berger wrote: On 09/27/2010 09:10 PM, Justin Clift wrote: This reverses commit 04c3704, which added a define to nwfilter to allow libvirtd compilation on Mac OS X. Stefan Bergers commit, 2e7294d, is the proper solution, removing the requirement for nwfilter on non-Linux. snip ACK. Thanks, pushed. :) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] mac os x: use awk selected by build system rather than first in path
Prior to this patch, the ChangeLog generation was hard coded to use awk, when it should have been using the AWK variable set by our build system. This breaks compilation on a newly installed OS X system, where the default path has the Mac (non GNU) awk in the default search PATH before any installed GNU awk (gawk). --- docs/Makefile.am |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index 114ea1f..7fae40d 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -88,7 +88,7 @@ api: libvirt-api.xml libvirt-refs.xml web: $(dot_html) html/index.html devhelp/index.html ChangeLog.xml: ../ChangeLog ChangeLog.awk - awk -f ChangeLog.awk $ $@ + $(AWK) -f ChangeLog.awk $ $@ ChangeLog.html.in: ChangeLog.xml ChangeLog.xsl @if [ -x $(XSLTPROC) ] ; then \ -- 1.7.2.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] mac os x: don't compile failing example program on 32 bit mac os x
[adding bug-gnulib] On 09/28/2010 06:36 AM, Justin Clift wrote: This addresses a compilation failure issue reported last year on OS X: https://www.redhat.com/archives/libvir-list/2009-May/msg00166.html which in turn mentions: gcc -Wall -Wformat -Wmissing-prototypes -Wnested-externs -Wpointer- arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wp,- D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables -g -O2 - o .libs/event-test event_test-event-test.o -L/opt/local/lib ../../../ src/.libs/libvirt.dylib -L/usr/lib /usr/lib/libxml2.dylib -licucore - lm /opt/local/lib/libgnutls.dylib /opt/local/lib/libtasn1.dylib -lz / opt/local/lib/libgcrypt.dylib /opt/local/lib/libgpg-error.dylib - lpthread /opt/local/lib/libintl.dylib /opt/local/lib/libiconv.dylib -lc Undefined symbols: _rpl_poll$UNIX2003, referenced from: _main in event_test-event-test.o ld: symbol(s) not found collect2: ld returned 1 exit status make[2]: *** [event-test] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 The UNIX2003 symbol does not exist in 10.4, only in 10.5. But the failed link mentions rpl_poll, not poll, which means this is most likely a gnulib bug in the poll module. Rather than skipping this test on just 32-bit MacOS in libvirt, I think the better thing to do is address why gnulib is triggering a link failure in the first place. In testing here, the compilation only fails on 32 bit OS X, but works on 64 bit, even when using exact same compile and linking flags. This commit surgically disables compilation of this one example program on 32 bit Mac OS X (only). Compilation still occurs, with a working executable produced, on 64 bit Mac OS X. --- examples/domain-events/events-c/event-test.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] mac os x: use awk selected by build system rather than first in path
On 09/28/2010 07:38 AM, Justin Clift wrote: Prior to this patch, the ChangeLog generation was hard coded to use awk, when it should have been using the AWK variable set by our build system. This breaks compilation on a newly installed OS X system, where the default path has the Mac (non GNU) awk in the default search PATH before any installed GNU awk (gawk). --- docs/Makefile.am |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index 114ea1f..7fae40d 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -88,7 +88,7 @@ api: libvirt-api.xml libvirt-refs.xml web: $(dot_html) html/index.html devhelp/index.html ChangeLog.xml: ../ChangeLog ChangeLog.awk - awk -f ChangeLog.awk $$@ + $(AWK) -f ChangeLog.awk $$@ In general: autoconf's AC_PROG_AWK only guarantees that $(AWK) is nawk or better (but of course, gawk is better than nawk) - so maybe there is a bug in ChangeLog.awk for using non-portable awk constructs. That said, on several platforms, plain 'awk' lacks essential features of nawk, so whether or not we also need to patch ChangeLog.awk, this patch is good. ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] mac os x: don't compile failing example program on 32 bit mac os x
[replies can omit bug-gnulib] On 09/28/2010 08:29 AM, Eric Blake wrote: [adding bug-gnulib] which in turn mentions: gcc -Wall -Wformat -Wmissing-prototypes -Wnested-externs -Wpointer- arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wp,- D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables -g -O2 - o .libs/event-test event_test-event-test.o -L/opt/local/lib ../../../ src/.libs/libvirt.dylib -L/usr/lib /usr/lib/libxml2.dylib -licucore - lm /opt/local/lib/libgnutls.dylib /opt/local/lib/libtasn1.dylib -lz / opt/local/lib/libgcrypt.dylib /opt/local/lib/libgpg-error.dylib - lpthread /opt/local/lib/libintl.dylib /opt/local/lib/libiconv.dylib -lc Aha - I just realized the problem. The Makefile.am fails to link against the gnulib library that provides rpl_poll, even though the headers are pulling in the replacement definition. But the failed link mentions rpl_poll, not poll, which means this is most likely a gnulib bug in the poll module. Rather than skipping this test on just 32-bit MacOS in libvirt, I think the better thing to do is address why gnulib is triggering a link failure in the first place. In testing here, the compilation only fails on 32 bit OS X, but works on 64 bit, even when using exact same compile and linking flags. That's because poll doesn't need gnulib replacement on the 64-bit OS X, just the 32-bit version. The real fix should be in examples/domain-events/events-c/Makefile.am to fix LDADD to mention libgnu.la. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] mac os x: don't compile failing example program on 32 bit mac os x
On 09/29/2010 12:29 AM, Eric Blake wrote: snip But the failed link mentions rpl_poll, not poll, which means this is most likely a gnulib bug in the poll module. Rather than skipping this test on just 32-bit MacOS in libvirt, I think the better thing to do is address why gnulib is triggering a link failure in the first place. Went with the surgical removal approach here for time efficient, rather than going for the perfect world approach. :) Figured that on the balance of things, this is just an example program being disabled for now rather than something essential. Still trying to get other bits behaving place, and this compilation failure was more of a distraction than anything. :) But, if sometime has time in the very near future to give direction for solving this, them I'm happy to do my bit. ? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Rework configure logic for virtualport support
In this patch I am reworking the logic around detecting virtual port support and requiring the libnl dependency. - It requires --with-macvtap and displays an error in case of --without-macvtap --with-virtualport. - It tests for availability of certain data in include files and displays an error in case the include file is not at the correct level and --with-virtualport was chosen - displays 'checking' messages for macvtap and virtualport support and results - libnl support is required when macvtap is found or requested; if libnl is not there, please supply without-macvtap Signed-off-by: Stefan Berger stef...@us.ibm.com diff --git a/configure.ac b/configure.ac index 6100610..d94b510 100644 --- a/configure.ac +++ b/configure.ac @@ -2058,6 +2058,7 @@ AC_ARG_WITH([macvtap], [with_macvtap=${withval}], [with_macvtap=check]) +AC_MSG_CHECKING([whether to compile with macvtap support]) if test $with_macvtap != no ; then AC_TRY_COMPILE([ #include sys/socket.h #include linux/rtnetlink.h ], @@ -2075,19 +2076,31 @@ if test $with_macvtap != no ; then AC_DEFINE_UNQUOTED([WITH_MACVTAP], $val, [whether macvtap support is enabled]) fi AM_CONDITIONAL([WITH_MACVTAP], [test $with_macvtap = yes]) +AC_MSG_RESULT([$with_macvtap]) -AC_TRY_COMPILE([ #include sys/socket.h - #include linux/rtnetlink.h ], - [ int x = IFLA_PORT_MAX; ], - [ with_virtualport=yes ], - [ with_virtualport=no ]) -if test $with_virtualport = yes; then -val=1 -else -val=0 +val=0 +if test $with_virtualport != no; then +if test $with_macvtap = no; then +AC_MSG_ERROR([--with-virtualport requires --with-macvtap]) +fi +AC_MSG_CHECKING([whether to compile with virtual port support]) +AC_TRY_COMPILE([ #include sys/socket.h + #include linux/rtnetlink.h ], + [ int x = IFLA_PORT_MAX; ], + [ with_virtualport=yes ], + [ if test $with_virtualport = yes ; then + AC_MSG_ERROR([Installed linux headers don't show support for virtual port support.]) + fi + with_virtualport=no ]) +if test $with_virtualport = yes; then +val=1 +else +val=0 +fi +AC_DEFINE_UNQUOTED([WITH_VIRTUALPORT], $val, + [whether vsi vepa support is enabled]) +AC_MSG_RESULT([$with_virtualport]) fi -AC_DEFINE_UNQUOTED([WITH_VIRTUALPORT], $val, - [whether vsi vepa support is enabled]) AM_CONDITIONAL([WITH_VIRTUALPORT], [test $with_virtualport = yes]) @@ -2096,7 +2109,7 @@ dnl netlink library LIBNL_CFLAGS= LIBNL_LIBS= -if test $with_macvtap = yes || test $with_virtualport = yes; then +if test $with_macvtap = yes; then PKG_CHECK_MODULES([LIBNL], [libnl-1 = $LIBNL_REQUIRED], [ ], [ AC_MSG_ERROR([libnl = $LIBNL_REQUIRED is required for macvtap support]) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Rework configure logic for virtualport support
On 09/28/2010 11:01 AM, Stefan Berger wrote: In this patch I am reworking the logic around detecting virtual port support and requiring the libnl dependency. - It requires --with-macvtap and displays an error in case of --without-macvtap --with-virtualport. - It tests for availability of certain data in include files and displays an error in case the include file is not at the correct level and --with-virtualport was chosen - displays 'checking' messages for macvtap and virtualport support and results - libnl support is required when macvtap is found or requested; if libnl is not there, please supply without-macvtap Signed-off-by: Stefan Berger stef...@us.ibm.com diff --git a/configure.ac b/configure.ac index 6100610..d94b510 100644 --- a/configure.ac +++ b/configure.ac @@ -2058,6 +2058,7 @@ AC_ARG_WITH([macvtap], [with_macvtap=${withval}], [with_macvtap=check]) +AC_MSG_CHECKING([whether to compile with macvtap support]) if test $with_macvtap != no ; then AC_TRY_COMPILE([ #include sys/socket.h #include linux/rtnetlink.h ], @@ -2075,19 +2076,31 @@ if test $with_macvtap != no ; then AC_DEFINE_UNQUOTED([WITH_MACVTAP], $val, [whether macvtap support is enabled]) fi AM_CONDITIONAL([WITH_MACVTAP], [test $with_macvtap = yes]) +AC_MSG_RESULT([$with_macvtap]) This part's nice. -AC_TRY_COMPILE([ #include sys/socket.h - #include linux/rtnetlink.h ], - [ int x = IFLA_PORT_MAX; ], - [ with_virtualport=yes ], - [ with_virtualport=no ]) -if test $with_virtualport = yes; then - val=1 -else - val=0 +val=0 +if test $with_virtualport != no; then Hmm - here you use $with_virtualport without adding an AC_ARG_WITH([virtualport]), which means the user doesn't have an easy way to set this variable via ./configure --with-virtualport. I think we need a v2 that adds the AC_ARG_WITH. -if test $with_macvtap = yes || test $with_virtualport = yes; then +if test $with_macvtap = yes; then PKG_CHECK_MODULES([LIBNL], [libnl-1 = $LIBNL_REQUIRED], [ So virtualport doesn't require libnl. The rest of your logic looks okay, once we get the AC_ARG_WITH sorted out. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Rework configure logic for virtualport support
On 09/28/2010 01:52 PM, Eric Blake wrote: On 09/28/2010 11:01 AM, Stefan Berger wrote: -AC_TRY_COMPILE([ #include sys/socket.h - #include linux/rtnetlink.h ], - [ int x = IFLA_PORT_MAX; ], - [ with_virtualport=yes ], - [ with_virtualport=no ]) -if test $with_virtualport = yes; then - val=1 -else - val=0 +val=0 +if test $with_virtualport != no; then Hmm - here you use $with_virtualport without adding an AC_ARG_WITH([virtualport]), which means the user doesn't have an easy way to set this variable via ./configure --with-virtualport. I think we need a v2 that adds the AC_ARG_WITH. Ooops. -if test $with_macvtap = yes || test $with_virtualport = yes; then +if test $with_macvtap = yes; then PKG_CHECK_MODULES([LIBNL], [libnl-1 = $LIBNL_REQUIRED], [ So virtualport doesn't require libnl. The rest of your logic looks okay, once we get the AC_ARG_WITH sorted out. virtualport support requires macvtap -- at least at the moment -- which in turn requires libnl. [virtualport support could be used with directly mapped PCI devices (not needing macvtap), but there is no support for this atm. In that case the two will become independent of each other.] Will send a V2 shortly. Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V2] Rework configure logic for virtualport support
On 09/28/2010 12:31 PM, Stefan Berger wrote: V2: - added missing AC_ARG_WITH() for --with-virtualport In this patch I am reworking the logic around detecting virtual port support and requiring the libnl dependency. - It requires --with-macvtap and displays an error in case of --without-macvtap --with-virtualport. - It tests for availability of certain data in include files and displays an error in case the include file is not at the correct level and --with-virtualport was chosen - displays 'checking' messages for macvtap and virtualport support and results - libnl support is required when macvtap is found or requested; if libnl is not there, please supply without-macvtap Signed-off-by: Stefan Berger stef...@us.ibm.com ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/5] Extend XML parser and generator to support comment attribute
On 09/27/2010 02:26 PM, Stefan Berger wrote: The patch below extends the XML parser and generator so that every protocol now can have a comment node. Comments are limited to 256 characters and are tested to only contain printable characters or spaces. Literal spaces, or generic blanks (space and tab for sure, but what about newline, not to mention vertical tab, form feed, ...), all of which are technically printable according to c_isprint()? I have been doing some testing using 'virsh nwfilter-edit'. I edited a comment and put horizontal tabs into it or newlines or a combination of both. Both of these seem to automatically be converted to space, meaning that when the XML is generated after the parsing, the tab or newline now are shown as simple space. I also wrote the XML into a file using 'virsh nwfilter-dumpxml', added a newline in the comment, ran unix2dos on it to get '\r' and used 'virsh nwfilter-define' on it again, and the '\r' disappeared. From that I took that the XML parser does the correct replacement already and I don't need to worry about it -- assuming it would do the same for vertical tab as well. Tab seems like it would be most likely for people to want, but I'm okay with leaving it unsupported for now until someone complains (and even then, it depends on whether XML parsing can even preserve tabs). Patch 1 #defines MAX_COMMENT_LENGTH 256 in nwfilter_conf.c, patch 2 #defines IPTABLES_MAX_COMMENT_SIZE 256 MAX_COMMENT_LENGTH 256 in nwfilter_ebiptables_driver.h. Should these two values be consolidated into a single name in a common .h file in patch 1? -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/5] Extend nwfilter schema to accept comment attributes
On 09/28/2010 04:28 AM, Stefan Berger wrote: okay. It also leaves out 8-bit bytes - could that be a problem for i18n where people want comments with native-language accented characters? That is, are we being too strict here? Maybe a better pattern would be to reject specific non-printing ASCII bytes we want to avoid, assuing you can use escape sequences like [^\001]? Looking at http://www.asciitable.com/ I should probably include 0x20-0x7E and 128-175, 224-238 - maybe even more? So the regex then becomes [#x20;-#x7E;#128;-#175;#224;-#238;]{0,256} True ASCII is strictly 7-bit; any locale where isprint() returns true on 8-bit bytes is a superset single-byte encoding, such as ISO-8859-1, or 'extended ascii' from the URL you posted above. But I'm also thinking about multi-byte encodings, like UTF-8, where we cannot a priori write a regex that will accept all valid Unicode printable characters, in part because you have to look at more than one byte at a time to determine if you have a printable character. Which goes back to my suggestion of an inverse charset - rejecting bytes that are known to be non-printable ASCII, and letting everything else whether or not it is is a printable byte sequence in the current locale. So what about this idea: exclude control characters except for tab, and let space and everything after through (I don't know if it needs to be adjusted to also reject #x00): [^#x01;-#x08#x0A-#x1F]{0,256} -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] RFC: add currentVcpu element
On 09/27/2010 11:20 AM, Eric Blake wrote: No change to existing API semantics, although the implementation can wrap old APIs to call the new ones with appropriate flags where appropriate to minimize code duplication. One more API to think about: virDomainGetInfo returns a virDomainInfoPtr, where that struct includes an unsigned short nrVirtCpu member. I'm assuming that since this is a public struct involved in on-the-wire RPC protocol, we can't change it to add a new member (and it also implicitly means that we are limited to 64k vcpus, even though the unsigned int argument of virDomainSetVcpus could otherwise go larger). Given my testing, it looks like this field tracks live changes from virsh setvcpus, so this now needs to be explicitly documented as the current vcpu rather than the maximum, when the two differ. Which means we have another synonym: - current vcpu on running guests virDomainGetVcpusFlags(,VIR_DOMAIN_VCPU_ACTIVE) virDomainGetVcpus() + parsing pinning info virDomainGetInfo() -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/5] Extend XML parser and generator to support comment attribute
Eric Blake ebl...@redhat.com wrote on 09/28/2010 03:19:42 PM: On 09/27/2010 02:26 PM, Stefan Berger wrote: The patch below extends the XML parser and generator so that every protocol now can have a comment node. Comments are limited to 256 characters and are tested to only contain printable characters or spaces. Literal spaces, or generic blanks (space and tab for sure, but what about newline, not to mention vertical tab, form feed, ...), all of which are technically printable according to c_isprint()? I have been doing some testing using 'virsh nwfilter-edit'. I edited a comment and put horizontal tabs into it or newlines or a combination of both. Both of these seem to automatically be converted to space, meaning that when the XML is generated after the parsing, the tab or newline now are shown as simple space. I also wrote the XML into a file using 'virsh nwfilter-dumpxml', added a newline in the comment, ran unix2dos on it to get '\r' and used 'virsh nwfilter-define' on it again, and the '\r' disappeared. From that I took that the XML parser does the correct replacement already and I don't need to worry about it -- assuming it would do the same for vertical tab as well. Tab seems like it would be most likely for people to want, but I'm okay with leaving it unsupported for now until someone complains (and even then, it depends on whether XML parsing can even preserve tabs). Patch 1 #defines MAX_COMMENT_LENGTH 256 in nwfilter_conf.c, patch 2 #defines IPTABLES_MAX_COMMENT_SIZE 256 MAX_COMMENT_LENGTH 256 in nwfilter_ebiptables_driver.h. Should these two values be consolidated into a single name in a common .h file in patch 1? I chose two independent constants to reflect that the parser and the (iptables) driver should be somewhat loosely coupled. The iptables driver could cut the size of the comment down to what it can handle, though in this case the sizes match. Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/5] Extend nwfilter schema to accept comment attributes
Eric Blake ebl...@redhat.com wrote on 09/28/2010 03:26:48 PM: [image removed] Re: [libvirt] [PATCH v2 3/5] Extend nwfilter schema to accept comment attributes Eric Blake to: Stefan Berger 09/28/2010 03:27 PM Cc: libvir-list On 09/28/2010 04:28 AM, Stefan Berger wrote: okay. It also leaves out 8-bit bytes - could that be a problem for i18n where people want comments with native-language accented characters? That is, are we being too strict here? Maybe a better pattern would be to reject specific non-printing ASCII bytes we want to avoid, assuing you can use escape sequences like [^\001]? Looking at http://www.asciitable.com/ I should probably include 0x20-0x7E and 128-175, 224-238 - maybe even more? So the regex then becomes [#x20;-#x7E;#128;-#175;#224;-#238;]{0,256} True ASCII is strictly 7-bit; any locale where isprint() returns true on 8-bit bytes is a superset single-byte encoding, such as ISO-8859-1, or 'extended ascii' from the URL you posted above. But I'm also thinking about multi-byte encodings, like UTF-8, where we cannot a priori write a regex that will accept all valid Unicode printable characters, in part because you have to look at more than one byte at a time to determine if you have a printable character. Which goes back to my suggestion of an inverse charset - rejecting bytes that are known to be non-printable ASCII, and letting everything else whether or not it is is a printable byte sequence in the current locale. So what about this idea: exclude control characters except for tab, and let space and everything after through (I don't know if it needs to be adjusted to also reject #x00): [^#x01;-#x08#x0A-#x1F]{0,256} Fine by me. We may just give the impression of accepting unicode while the code does not handle it. Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] RFC: add currentVcpu element
On 09/27/2010 11:20 AM, Eric Blake wrote: Another question I had, is there a way in QEmu to specifiy a different cpu count from the -smp indicating the startup count ? I wish I knew off-hand, as it would make it easier for me to implement when I get to that part of the patch series :) But even if there isn't, I think that starting with the maximum via -smp and immediately after hot-unplugging to the current count is better than nothing. Answering my own question: with qemu 0.12.5, 'qemu -help' lists: -smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets] set the number of CPUs to 'n' [default=1] maxcpus= maximum number of total cpus, including offline CPUs for hotplug etc. So it looks like '-smp 1,maxcpus=2' maps nicely to vcpu current='1'2/vcpu. But per tests/qemuhelpdata, qemu 0.11.0 lacks this, so I also have to code up a qemu feature test. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list