Re: [libvirt] [PATCH v3 01/13] Adding structure and defines for virDomainSet/GetMemoryParameters

2010-10-08 Thread Nikunj A. Dadhania
On Thu, 7 Oct 2010 12:45:22 +0100, Daniel P. Berrange berra...@redhat.com 
wrote:
 On Tue, Sep 28, 2010 at 03:26:15PM +0530, Nikunj A. Dadhania wrote:
  +
  +/* 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);
 
 We should add an  'unsigned int flags' parameter to both of these,
 so we can extend their semantics in the future. 
I have added this and mentioned it as unused at present.

 The comment here
 can be moved to the libvirt.c file so it gets picked up in the API
 docs.
 
I have already put a detailed comment in libvirt.c for API docs. I am getting
rid of this for now.

Nikunj

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 01/13] Adding structure and defines for virDomainSet/GetMemoryParameters

2010-10-07 Thread Daniel P. Berrange
On Tue, Sep 28, 2010 at 03:26:15PM +0530, Nikunj A. Dadhania wrote:
 +
 +/* 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);

We should add an  'unsigned int flags' parameter to both of these,
so we can extend their semantics in the future. The comment here
can be moved to the libvirt.c file so it gets picked up in the API
docs.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org-o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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

2010-09-28 Thread Nikunj A. Dadhania
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