[libvirt] [PATCH] setmem: provide dummy impls for remaining drivers

Eric Blake eblake at redhat.com
Thu Mar 10 22:53:58 UTC 2011


* 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




More information about the libvir-list mailing list