[PATCH 7/7] sched: provide new API shims for remaining drivers

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

 



Well, the remaining drivers that already had the get/set
scheduler parameter functionality to begin with.

For now, this blindly treats VIR_DOMAIN_SCHEDINFO_CURRENT as
the only supported operation for these 5 domains; it will
take domain-specific patches if more specific behavior is
preferred.

* src/esx/esx_driver.c (esxDomainGetSchedulerParameters)
(esxDomainSetSchedulerParameters): Move guts...
(esxDomainGetSchedulerParametersFlags)
(esxDomainSetSchedulerParametersFlags): ...to new functions.
* src/libxl/libxl_driver.c (libxlDomainGetSchedulerParameters)
(libxlDomainSetSchedulerParameters)
(libxlDomainGetSchedulerParametersFlags)
(libxlDomainSetSchedulerParametersFlags): Likewise.
* src/lxc/lxc_driver.c (lxcGetSchedulerParameters)
(lxcSetSchedulerParameters, lxcGetSchedulerParametersFlags)
(lxcSetSchedulerParametersFlags): Likewise.
* src/test/test_driver.c (testDomainGetSchedulerParams)
(testDomainSetSchedulerParams, testDomainGetSchedulerParamsFlags)
(testDomainSetSchedulerParamsFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainGetSchedulerParameters)
(xenUnifiedDomainSetSchedulerParameters)
(xenUnifiedDomainGetSchedulerParametersFlags)
(xenUnifiedDomainSetSchedulerParametersFlags): Likewise.
---
 src/esx/esx_driver.c     |   28 ++++++++++++++++++++++++----
 src/libxl/libxl_driver.c |   32 ++++++++++++++++++++++++++++----
 src/lxc/lxc_driver.c     |   34 +++++++++++++++++++++++++++++-----
 src/test/test_driver.c   |   37 +++++++++++++++++++++++++++++++------
 src/xen/xen_driver.c     |   36 ++++++++++++++++++++++++++++++++----
 5 files changed, 144 insertions(+), 23 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index bb9d60a..d2e96ec 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3521,8 +3521,9 @@ esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams)


 static int
-esxDomainGetSchedulerParameters(virDomainPtr domain,
-                                virSchedParameterPtr params, int *nparams)
+esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
+                                     virSchedParameterPtr params, int *nparams,
+                                     unsigned int flags)
 {
     int result = -1;
     esxPrivate *priv = domain->conn->privateData;
@@ -3533,6 +3534,8 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
     unsigned int mask = 0;
     int i = 0;

+    virCheckFlags(0, -1);
+
     if (*nparams < 3) {
         ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
                   _("Parameter array must have space for 3 items"));
@@ -3643,11 +3646,18 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
     return result;
 }

+static int
+esxDomainGetSchedulerParameters(virDomainPtr domain,
+                                virSchedParameterPtr params, int *nparams)
+{
+    return esxDomainGetSchedulerParametersFlags(domain, params, nparams, 0);
+}


 static int
-esxDomainSetSchedulerParameters(virDomainPtr domain,
-                                virSchedParameterPtr params, int nparams)
+esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
+                                     virSchedParameterPtr params, int nparams,
+                                     unsigned int flags)
 {
     int result = -1;
     esxPrivate *priv = domain->conn->privateData;
@@ -3659,6 +3669,8 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
     char *taskInfoErrorMessage = NULL;
     int i;

+    virCheckFlags(0, -1);
+
     if (esxVI_EnsureSession(priv->primary) < 0) {
         return -1;
     }
@@ -3774,6 +3786,12 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
     return result;
 }

+static int
+esxDomainSetSchedulerParameters(virDomainPtr domain,
+                                virSchedParameterPtr params, int nparams)
+{
+    return esxDomainSetSchedulerParametersFlags(domain, params, nparams, 0);
+}


 static int
@@ -4673,7 +4691,9 @@ static virDriver esxDriver = {
     .domainSetAutostart = esxDomainSetAutostart, /* 0.9.0 */
     .domainGetSchedulerType = esxDomainGetSchedulerType, /* 0.7.0 */
     .domainGetSchedulerParameters = esxDomainGetSchedulerParameters, /* 0.7.0 */
+    .domainGetSchedulerParametersFlags = esxDomainGetSchedulerParametersFlags, /* 0.9.2 */
     .domainSetSchedulerParameters = esxDomainSetSchedulerParameters, /* 0.7.0 */
+    .domainSetSchedulerParametersFlags = esxDomainSetSchedulerParametersFlags, /* 0.9.2 */
     .domainMigratePrepare = esxDomainMigratePrepare, /* 0.7.0 */
     .domainMigratePerform = esxDomainMigratePerform, /* 0.7.0 */
     .domainMigrateFinish = esxDomainMigrateFinish, /* 0.7.0 */
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5cc9362..a433021 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2425,8 +2425,10 @@ cleanup:
 }

 static int
-libxlDomainGetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params,
-                                  int *nparams)
+libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
+                                       virSchedParameterPtr params,
+                                       int *nparams,
+                                       unsigned int flags)
 {
     libxlDriverPrivatePtr driver = dom->conn->privateData;
     libxlDomainObjPrivatePtr priv;
@@ -2435,6 +2437,8 @@ libxlDomainGetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params,
     int sched_id;
     int ret = -1;

+    virCheckFlags(0, -1);
+
     libxlDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
     libxlDriverUnlock(driver);
@@ -2501,8 +2505,17 @@ cleanup:
 }

 static int
-libxlDomainSetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params,
-                                  int nparams)
+libxlDomainGetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params,
+                                  int *nparams)
+{
+    return libxlDomainGetSchedulerParametersFlags(dom, params, nparams, 0);
+}
+
+static int
+libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
+                                       virSchedParameterPtr params,
+                                       int nparams,
+                                       unsigned int flags)
 {
     libxlDriverPrivatePtr driver = dom->conn->privateData;
     libxlDomainObjPrivatePtr priv;
@@ -2512,6 +2525,8 @@ libxlDomainSetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params,
     int i;
     int ret = -1;

+    virCheckFlags(0, -1);
+
     libxlDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
     libxlDriverUnlock(driver);
@@ -2587,6 +2602,13 @@ cleanup:
 }

 static int
+libxlDomainSetSchedulerParameters(virDomainPtr dom, virSchedParameterPtr params,
+                                  int nparams)
+{
+    return libxlDomainSetSchedulerParametersFlags(dom, params, nparams, 0);
+}
+
+static int
 libxlDomainIsActive(virDomainPtr dom)
 {
     libxlDriverPrivatePtr driver = dom->conn->privateData;
@@ -2733,7 +2755,9 @@ static virDriver libxlDriver = {
     .domainSetAutostart = libxlDomainSetAutostart, /* 0.9.0 */
     .domainGetSchedulerType = libxlDomainGetSchedulerType, /* 0.9.0 */
     .domainGetSchedulerParameters = libxlDomainGetSchedulerParameters, /* 0.9.0 */
+    .domainGetSchedulerParametersFlags = libxlDomainGetSchedulerParametersFlags, /* 0.9.2 */
     .domainSetSchedulerParameters = libxlDomainSetSchedulerParameters, /* 0.9.0 */
+    .domainSetSchedulerParametersFlags = libxlDomainSetSchedulerParametersFlags, /* 0.9.2 */
     .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
     .domainEventRegister = libxlDomainEventRegister, /* 0.9.0 */
     .domainEventDeregister = libxlDomainEventDeregister, /* 0.9.0 */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 2bb592d..687248a 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2160,9 +2160,11 @@ static char *lxcGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
     return schedulerType;
 }

-static int lxcSetSchedulerParameters(virDomainPtr domain,
-                                     virSchedParameterPtr params,
-                                     int nparams)
+static int
+lxcSetSchedulerParametersFlags(virDomainPtr domain,
+                               virSchedParameterPtr params,
+                               int nparams,
+                               unsigned int flags)
 {
     lxc_driver_t *driver = domain->conn->privateData;
     int i;
@@ -2170,6 +2172,8 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
     virDomainObjPtr vm = NULL;
     int ret = -1;

+    virCheckFlags(0, -1);
+
     if (driver->cgroup == NULL)
         return -1;

@@ -2221,9 +2225,18 @@ cleanup:
     return ret;
 }

-static int lxcGetSchedulerParameters(virDomainPtr domain,
+static int lxcSetSchedulerParameters(virDomainPtr domain,
                                      virSchedParameterPtr params,
-                                     int *nparams)
+                                     int nparams)
+{
+    return lxcSetSchedulerParametersFlags(domain, params, nparams, 0);
+}
+
+static int
+lxcGetSchedulerParametersFlags(virDomainPtr domain,
+                               virSchedParameterPtr params,
+                               int *nparams,
+                               unsigned int flags)
 {
     lxc_driver_t *driver = domain->conn->privateData;
     virCgroupPtr group = NULL;
@@ -2231,6 +2244,8 @@ static int lxcGetSchedulerParameters(virDomainPtr domain,
     unsigned long long val;
     int ret = -1;

+    virCheckFlags(0, -1);
+
     if (driver->cgroup == NULL)
         return -1;

@@ -2274,6 +2289,13 @@ cleanup:
     return ret;
 }

+static int lxcGetSchedulerParameters(virDomainPtr domain,
+                                     virSchedParameterPtr params,
+                                     int *nparams)
+{
+    return lxcGetSchedulerParametersFlags(domain, params, nparams, 0);
+}
+
 #ifdef __linux__
 static int
 lxcDomainInterfaceStats(virDomainPtr dom,
@@ -2750,7 +2772,9 @@ static virDriver lxcDriver = {
     .domainSetAutostart = lxcDomainSetAutostart, /* 0.7.0 */
     .domainGetSchedulerType = lxcGetSchedulerType, /* 0.5.0 */
     .domainGetSchedulerParameters = lxcGetSchedulerParameters, /* 0.5.0 */
+    .domainGetSchedulerParametersFlags = lxcGetSchedulerParametersFlags, /* 0.9.2 */
     .domainSetSchedulerParameters = lxcSetSchedulerParameters, /* 0.5.0 */
+    .domainSetSchedulerParametersFlags = lxcSetSchedulerParametersFlags, /* 0.9.2 */
     .domainInterfaceStats = lxcDomainInterfaceStats, /* 0.7.3 */
     .nodeGetCellsFreeMemory = nodeGetCellsFreeMemory, /* 0.6.5 */
     .nodeGetFreeMemory = nodeGetFreeMemory, /* 0.6.5 */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 658bcee..2daec83 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2625,14 +2625,18 @@ static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
     return type;
 }

-static int testDomainGetSchedulerParams(virDomainPtr domain,
-                                        virSchedParameterPtr params,
-                                        int *nparams)
+static int
+testDomainGetSchedulerParamsFlags(virDomainPtr domain,
+                                  virSchedParameterPtr params,
+                                  int *nparams,
+                                  unsigned int flags)
 {
     testConnPtr privconn = domain->conn->privateData;
     virDomainObjPtr privdom;
     int ret = -1;

+    virCheckFlags(0, -1);
+
     testDriverLock(privconn);
     privdom = virDomainFindByName(&privconn->domains,
                                   domain->name);
@@ -2660,15 +2664,26 @@ cleanup:
     return ret;
 }

+static int
+testDomainGetSchedulerParams(virDomainPtr domain,
+                             virSchedParameterPtr params,
+                             int *nparams)
+{
+    return testDomainGetSchedulerParamsFlags(domain, params, nparams, 0);
+}

-static int testDomainSetSchedulerParams(virDomainPtr domain,
-                                        virSchedParameterPtr params,
-                                        int nparams)
+static int
+testDomainSetSchedulerParamsFlags(virDomainPtr domain,
+                                  virSchedParameterPtr params,
+                                  int nparams,
+                                  unsigned int flags)
 {
     testConnPtr privconn = domain->conn->privateData;
     virDomainObjPtr privdom;
     int ret = -1;

+    virCheckFlags(0, -1);
+
     testDriverLock(privconn);
     privdom = virDomainFindByName(&privconn->domains,
                                   domain->name);
@@ -2701,6 +2716,14 @@ cleanup:
     return ret;
 }

+static int
+testDomainSetSchedulerParams(virDomainPtr domain,
+                             virSchedParameterPtr params,
+                             int nparams)
+{
+    return testDomainSetSchedulerParamsFlags(domain, params, nparams, 0);
+}
+
 static int testDomainBlockStats(virDomainPtr domain,
                                 const char *path,
                                 struct _virDomainBlockStats *stats)
@@ -5364,7 +5387,9 @@ static virDriver testDriver = {
     .domainSetAutostart = testDomainSetAutostart, /* 0.3.2 */
     .domainGetSchedulerType = testDomainGetSchedulerType, /* 0.3.2 */
     .domainGetSchedulerParameters = testDomainGetSchedulerParams, /* 0.3.2 */
+    .domainGetSchedulerParametersFlags = testDomainGetSchedulerParamsFlags, /* 0.9.2 */
     .domainSetSchedulerParameters = testDomainSetSchedulerParams, /* 0.3.2 */
+    .domainSetSchedulerParametersFlags = testDomainSetSchedulerParamsFlags, /* 0.9.2 */
     .domainBlockStats = testDomainBlockStats, /* 0.7.0 */
     .domainInterfaceStats = testDomainInterfaceStats, /* 0.7.0 */
     .nodeGetCellsFreeMemory = testNodeGetCellsFreeMemory, /* 0.4.2 */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index fea8548..25479c4 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1676,12 +1676,16 @@ xenUnifiedDomainGetSchedulerType (virDomainPtr dom, int *nparams)
 }

 static int
-xenUnifiedDomainGetSchedulerParameters (virDomainPtr dom,
-                    virSchedParameterPtr params, int *nparams)
+xenUnifiedDomainGetSchedulerParametersFlags(virDomainPtr dom,
+                                            virSchedParameterPtr params,
+                                            int *nparams,
+                                            unsigned int flags)
 {
     GET_PRIVATE(dom->conn);
     int i, ret;

+    virCheckFlags(0, -1);
+
     for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) {
         if (priv->opened[i] && drivers[i]->domainGetSchedulerParameters) {
            ret = drivers[i]->domainGetSchedulerParameters(dom, params, nparams);
@@ -1693,12 +1697,25 @@ xenUnifiedDomainGetSchedulerParameters (virDomainPtr dom,
 }

 static int
-xenUnifiedDomainSetSchedulerParameters (virDomainPtr dom,
-                    virSchedParameterPtr params, int nparams)
+xenUnifiedDomainGetSchedulerParameters(virDomainPtr dom,
+                                       virSchedParameterPtr params,
+                                       int *nparams)
+{
+    return xenUnifiedDomainGetSchedulerParametersFlags(dom, params,
+                                                       nparams, 0);
+}
+
+static int
+xenUnifiedDomainSetSchedulerParametersFlags(virDomainPtr dom,
+                                            virSchedParameterPtr params,
+                                            int nparams,
+                                            unsigned int flags)
 {
     GET_PRIVATE(dom->conn);
     int i, ret;

+    virCheckFlags(0, -1);
+
     /* do the hypervisor call last to get better error */
     for (i = XEN_UNIFIED_NR_DRIVERS - 1; i >= 0; i--) {
         if (priv->opened[i] && drivers[i]->domainSetSchedulerParameters) {
@@ -1712,6 +1729,15 @@ xenUnifiedDomainSetSchedulerParameters (virDomainPtr dom,
 }

 static int
+xenUnifiedDomainSetSchedulerParameters(virDomainPtr dom,
+                                       virSchedParameterPtr params,
+                                       int nparams)
+{
+    return xenUnifiedDomainSetSchedulerParametersFlags(dom, params,
+                                                       nparams, 0);
+}
+
+static int
 xenUnifiedDomainBlockStats (virDomainPtr dom, const char *path,
                             struct _virDomainBlockStats *stats)
 {
@@ -2195,7 +2221,9 @@ static virDriver xenUnifiedDriver = {
     .domainSetAutostart = xenUnifiedDomainSetAutostart, /* 0.4.4 */
     .domainGetSchedulerType = xenUnifiedDomainGetSchedulerType, /* 0.2.3 */
     .domainGetSchedulerParameters = xenUnifiedDomainGetSchedulerParameters, /* 0.2.3 */
+    .domainGetSchedulerParametersFlags = xenUnifiedDomainGetSchedulerParametersFlags, /* 0.9.2 */
     .domainSetSchedulerParameters = xenUnifiedDomainSetSchedulerParameters, /* 0.2.3 */
+    .domainSetSchedulerParametersFlags = xenUnifiedDomainSetSchedulerParametersFlags, /* 0.9.2 */
     .domainMigratePrepare = xenUnifiedDomainMigratePrepare, /* 0.3.2 */
     .domainMigratePerform = xenUnifiedDomainMigratePerform, /* 0.3.2 */
     .domainMigrateFinish = xenUnifiedDomainMigrateFinish, /* 0.3.2 */
-- 
1.7.4.4

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