[PATCH 01/12] Adding virDomainSetMemoryParameters API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nikunj A. Dadhania <nikunj@xxxxxxxxxxxxxxxxxx>

Public api to set memory tunables supported by the hypervisors.
RFC: https://www.redhat.com/archives/libvir-list/2010-August/msg00607.html

Signed-off-by: Nikunj A. Dadhania <nikunj@xxxxxxxxxxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |    5 ++++
 src/driver.h                 |    6 +++++
 src/libvirt.c                |   49 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index b45f7ec..f546ba6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -674,6 +674,11 @@ int                     virDomainGetInfo        (virDomainPtr domain,
 char *                  virDomainGetSchedulerType(virDomainPtr domain,
                                                  int *nparams);
 
+/* Set memory tunables for the domain*/
+int     virDomainSetMemoryParameters(virDomainPtr domain,
+				     virMemoryParameterPtr params,
+				     int nparams);
+
 /*
  * Dynamic control of domains
  */
diff --git a/src/driver.h b/src/driver.h
index e443c1c..01004e3 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -128,6 +128,11 @@ typedef int
         (*virDrvDomainSetMemory)	(virDomainPtr domain,
                                          unsigned long memory);
 typedef int
+        (*virDrvDomainSetMemoryParameters)
+                                        (virDomainPtr domain,
+                                         virMemoryParameterPtr params,
+                                         int nparams);
+typedef int
         (*virDrvDomainGetInfo)		(virDomainPtr domain,
                                          virDomainInfoPtr info);
 typedef int
@@ -575,6 +580,7 @@ struct _virDriver {
     virDrvDomainRevertToSnapshot domainRevertToSnapshot;
     virDrvDomainSnapshotDelete domainSnapshotDelete;
     virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand;
+    virDrvDomainSetMemoryParameters domainSetMemoryParameters;
 };
 
 typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index ca383ba..64daaa3 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3000,6 +3000,55 @@ 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;
+}
+
+/**
  * virDomainGetInfo:
  * @domain: a domain object
  * @info: pointer to a virDomainInfo structure allocated by the user

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]