提交 bb6cb66f 编写于 作者: E Eric Blake 提交者: Daniel Veillard

sched: provide new API shims for remaining drivers

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.
上级 97f63513
......@@ -3559,8 +3559,9 @@ esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams)
static int
esxDomainGetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams)
esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
unsigned int flags)
{
int result = -1;
esxPrivate *priv = domain->conn->privateData;
......@@ -3571,6 +3572,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"));
......@@ -3681,11 +3684,18 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
return result;
}
static int
esxDomainGetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params, int *nparams)
{
return esxDomainGetSchedulerParametersFlags(domain, params, nparams, 0);
}
static int
esxDomainSetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params, int nparams)
esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
virTypedParameterPtr params, int nparams,
unsigned int flags)
{
int result = -1;
esxPrivate *priv = domain->conn->privateData;
......@@ -3697,6 +3707,8 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
char *taskInfoErrorMessage = NULL;
int i;
virCheckFlags(0, -1);
if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
......@@ -3812,6 +3824,12 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
return result;
}
static int
esxDomainSetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params, int nparams)
{
return esxDomainSetSchedulerParametersFlags(domain, params, nparams, 0);
}
static int
......@@ -4711,7 +4729,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 */
......
......@@ -2950,8 +2950,10 @@ cleanup:
}
static int
libxlDomainGetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int *nparams)
libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
virTypedParameterPtr params,
int *nparams,
unsigned int flags)
{
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDomainObjPrivatePtr priv;
......@@ -2960,6 +2962,8 @@ libxlDomainGetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int sched_id;
int ret = -1;
virCheckFlags(0, -1);
libxlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
libxlDriverUnlock(driver);
......@@ -3027,8 +3031,17 @@ cleanup:
}
static int
libxlDomainSetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int nparams)
libxlDomainGetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int *nparams)
{
return libxlDomainGetSchedulerParametersFlags(dom, params, nparams, 0);
}
static int
libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
virTypedParameterPtr params,
int nparams,
unsigned int flags)
{
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDomainObjPrivatePtr priv;
......@@ -3038,6 +3051,8 @@ libxlDomainSetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int i;
int ret = -1;
virCheckFlags(0, -1);
libxlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
libxlDriverUnlock(driver);
......@@ -3114,6 +3129,13 @@ cleanup:
return ret;
}
static int
libxlDomainSetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int nparams)
{
return libxlDomainSetSchedulerParametersFlags(dom, params, nparams, 0);
}
static int
libxlDomainIsActive(virDomainPtr dom)
{
......@@ -3266,7 +3288,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 */
......
......@@ -2161,9 +2161,11 @@ static char *lxcGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
return schedulerType;
}
static int lxcSetSchedulerParameters(virDomainPtr domain,
static int
lxcSetSchedulerParametersFlags(virDomainPtr domain,
virTypedParameterPtr params,
int nparams)
int nparams,
unsigned int flags)
{
lxc_driver_t *driver = domain->conn->privateData;
int i;
......@@ -2171,6 +2173,8 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
virDomainObjPtr vm = NULL;
int ret = -1;
virCheckFlags(0, -1);
if (driver->cgroup == NULL)
return -1;
......@@ -2222,9 +2226,19 @@ cleanup:
return ret;
}
static int lxcGetSchedulerParameters(virDomainPtr domain,
static int
lxcSetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams)
int nparams)
{
return lxcSetSchedulerParametersFlags(domain, params, nparams, 0);
}
static int
lxcGetSchedulerParametersFlags(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams,
unsigned int flags)
{
lxc_driver_t *driver = domain->conn->privateData;
virCgroupPtr group = NULL;
......@@ -2232,6 +2246,8 @@ static int lxcGetSchedulerParameters(virDomainPtr domain,
unsigned long long val;
int ret = -1;
virCheckFlags(0, -1);
if (driver->cgroup == NULL)
return -1;
......@@ -2276,6 +2292,14 @@ cleanup:
return ret;
}
static int
lxcGetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams)
{
return lxcGetSchedulerParametersFlags(domain, params, nparams, 0);
}
#ifdef __linux__
static int
lxcDomainInterfaceStats(virDomainPtr dom,
......@@ -2752,7 +2776,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 */
......
......@@ -2636,14 +2636,18 @@ static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
return type;
}
static int testDomainGetSchedulerParams(virDomainPtr domain,
static int
testDomainGetSchedulerParamsFlags(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams)
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);
......@@ -2673,15 +2677,26 @@ cleanup:
return ret;
}
static int
testDomainGetSchedulerParams(virDomainPtr domain,
virTypedParameterPtr params,
int *nparams)
{
return testDomainGetSchedulerParamsFlags(domain, params, nparams, 0);
}
static int testDomainSetSchedulerParams(virDomainPtr domain,
static int
testDomainSetSchedulerParamsFlags(virDomainPtr domain,
virTypedParameterPtr params,
int nparams)
int nparams,
unsigned int flags)
{
testConnPtr privconn = domain->conn->privateData;
virDomainObjPtr privdom;
int ret = -1, i;
virCheckFlags(0, -1);
testDriverLock(privconn);
privdom = virDomainFindByName(&privconn->domains,
domain->name);
......@@ -2713,6 +2728,14 @@ cleanup:
return ret;
}
static int
testDomainSetSchedulerParams(virDomainPtr domain,
virTypedParameterPtr params,
int nparams)
{
return testDomainSetSchedulerParamsFlags(domain, params, nparams, 0);
}
static int testDomainBlockStats(virDomainPtr domain,
const char *path,
struct _virDomainBlockStats *stats)
......@@ -5454,7 +5477,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 */
......
......@@ -1676,13 +1676,16 @@ xenUnifiedDomainGetSchedulerType (virDomainPtr dom, int *nparams)
}
static int
xenUnifiedDomainGetSchedulerParameters (virDomainPtr dom,
xenUnifiedDomainGetSchedulerParametersFlags(virDomainPtr dom,
virTypedParameterPtr params,
int *nparams)
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);
......@@ -1694,13 +1697,25 @@ xenUnifiedDomainGetSchedulerParameters (virDomainPtr dom,
}
static int
xenUnifiedDomainSetSchedulerParameters (virDomainPtr dom,
xenUnifiedDomainGetSchedulerParameters(virDomainPtr dom,
virTypedParameterPtr params,
int nparams)
int *nparams)
{
return xenUnifiedDomainGetSchedulerParametersFlags(dom, params,
nparams, 0);
}
static int
xenUnifiedDomainSetSchedulerParametersFlags(virDomainPtr dom,
virTypedParameterPtr 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) {
......@@ -1713,6 +1728,15 @@ xenUnifiedDomainSetSchedulerParameters (virDomainPtr dom,
return(-1);
}
static int
xenUnifiedDomainSetSchedulerParameters(virDomainPtr dom,
virTypedParameterPtr params,
int nparams)
{
return xenUnifiedDomainSetSchedulerParametersFlags(dom, params,
nparams, 0);
}
static int
xenUnifiedDomainBlockStats (virDomainPtr dom, const char *path,
struct _virDomainBlockStats *stats)
......@@ -2197,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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册