mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Simplify the Xen domain scheduler parameter driver methods
Make the Xen domain scheduler parameter methods directly call into XenD or Xen hypervisor drivers Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
758aea3098
commit
a8f3222a40
@ -80,12 +80,6 @@ xenUnifiedDomainGetVcpus(virDomainPtr dom,
|
||||
unsigned char *cpumaps, int maplen);
|
||||
|
||||
|
||||
/* The five Xen drivers below us. */
|
||||
static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = {
|
||||
[XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver,
|
||||
[XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver,
|
||||
};
|
||||
|
||||
static bool is_privileged = false;
|
||||
|
||||
/**
|
||||
@ -1514,17 +1508,17 @@ static char *
|
||||
xenUnifiedDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
||||
int i;
|
||||
char *schedulertype;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; i++) {
|
||||
if (priv->opened[i] && drivers[i]->xenDomainGetSchedulerType) {
|
||||
schedulertype = drivers[i]->xenDomainGetSchedulerType(dom, nparams);
|
||||
if (schedulertype != NULL)
|
||||
return schedulertype;
|
||||
if (dom->id < 0) {
|
||||
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot change scheduler parameters"));
|
||||
return NULL;
|
||||
}
|
||||
return xenDaemonGetSchedulerType(dom, nparams);
|
||||
} else {
|
||||
return xenHypervisorGetSchedulerType(dom, nparams);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1534,18 +1528,19 @@ xenUnifiedDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
||||
int i, ret;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) {
|
||||
if (priv->opened[i] && drivers[i]->xenDomainGetSchedulerParameters) {
|
||||
ret = drivers[i]->xenDomainGetSchedulerParameters(dom, params, nparams);
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
if (dom->id < 0) {
|
||||
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot change scheduler parameters"));
|
||||
return -1;
|
||||
}
|
||||
return xenDaemonGetSchedulerParameters(dom, params, nparams);
|
||||
} else {
|
||||
return xenHypervisorGetSchedulerParameters(dom, params, nparams);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1564,20 +1559,19 @@ xenUnifiedDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
||||
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]->xenDomainSetSchedulerParameters) {
|
||||
ret = drivers[i]->xenDomainSetSchedulerParameters(dom, params, nparams);
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
if (dom->id < 0) {
|
||||
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot change scheduler parameters"));
|
||||
return -1;
|
||||
}
|
||||
return xenDaemonSetSchedulerParameters(dom, params, nparams);
|
||||
} else {
|
||||
return xenHypervisorSetSchedulerParameters(dom, params, nparams);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -82,21 +82,6 @@ extern int xenRegister (void);
|
||||
VIR_MIGRATE_PAUSED | \
|
||||
VIR_MIGRATE_PERSIST_DEST)
|
||||
|
||||
/* _xenUnifiedDriver:
|
||||
*
|
||||
* Entry points into the underlying Xen drivers. This structure
|
||||
* will eventually go away and instead xen unified will make direct
|
||||
* calls to the underlying Xen drivers.
|
||||
*
|
||||
* To reiterate - the goal is to remove elements from this structure
|
||||
* until it is empty, replacing indirect calls through this
|
||||
* structure with direct calls in xen_unified.c.
|
||||
*/
|
||||
struct xenUnifiedDriver {
|
||||
virDrvDomainGetSchedulerType xenDomainGetSchedulerType;
|
||||
virDrvDomainGetSchedulerParameters xenDomainGetSchedulerParameters;
|
||||
virDrvDomainSetSchedulerParameters xenDomainSetSchedulerParameters;
|
||||
};
|
||||
|
||||
typedef struct xenXMConfCache *xenXMConfCachePtr;
|
||||
typedef struct xenXMConfCache {
|
||||
|
@ -849,12 +849,6 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
|
||||
# error "unsupported platform"
|
||||
#endif
|
||||
|
||||
struct xenUnifiedDriver xenHypervisorDriver = {
|
||||
.xenDomainGetSchedulerType = xenHypervisorGetSchedulerType,
|
||||
.xenDomainGetSchedulerParameters = xenHypervisorGetSchedulerParameters,
|
||||
.xenDomainSetSchedulerParameters = xenHypervisorSetSchedulerParameters,
|
||||
};
|
||||
|
||||
/**
|
||||
* xenHypervisorDoV0Op:
|
||||
* @handle: the handle to the Xen hypervisor
|
||||
@ -1124,12 +1118,6 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams)
|
||||
char *schedulertype = NULL;
|
||||
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
||||
|
||||
if (domain->id < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("domain is not running"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Support only hv_versions.dom_interface >=5
|
||||
* (Xen3.1.0 or later)
|
||||
@ -1194,13 +1182,6 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
||||
|
||||
|
||||
if (domain->id < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("domain is not running"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Support only hv_versions.dom_interface >=5
|
||||
* (Xen3.1.0 or later)
|
||||
@ -1303,12 +1284,6 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
|
||||
NULL) < 0)
|
||||
return -1;
|
||||
|
||||
if (domain->id < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("domain is not running"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Support only hv_versions.dom_interface >=5
|
||||
* (Xen3.1.0 or later)
|
||||
|
@ -36,7 +36,6 @@ struct xenHypervisorVersions {
|
||||
int dom_interface; /* -1,3,4,5,6,7 */
|
||||
};
|
||||
|
||||
extern struct xenUnifiedDriver xenHypervisorDriver;
|
||||
int xenHypervisorInit(struct xenHypervisorVersions *override_versions);
|
||||
|
||||
virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn);
|
||||
|
@ -2984,7 +2984,7 @@ error:
|
||||
* Returns a scheduler name (credit or sedf) which must be freed by the
|
||||
* caller or NULL in case of failure
|
||||
*/
|
||||
static char *
|
||||
char *
|
||||
xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
||||
@ -3049,7 +3049,7 @@ error:
|
||||
*
|
||||
* Returns 0 or -1 in case of failure
|
||||
*/
|
||||
static int
|
||||
int
|
||||
xenDaemonGetSchedulerParameters(virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int *nparams)
|
||||
@ -3151,7 +3151,7 @@ error:
|
||||
*
|
||||
* Returns 0 or -1 in case of failure
|
||||
*/
|
||||
static int
|
||||
int
|
||||
xenDaemonSetSchedulerParameters(virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int nparams)
|
||||
@ -3340,12 +3340,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct xenUnifiedDriver xenDaemonDriver = {
|
||||
.xenDomainGetSchedulerType = xenDaemonGetSchedulerType,
|
||||
.xenDomainGetSchedulerParameters = xenDaemonGetSchedulerParameters,
|
||||
.xenDomainSetSchedulerParameters = xenDaemonSetSchedulerParameters,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* virDomainXMLDevID:
|
||||
|
@ -148,10 +148,6 @@ int xenDaemonDomainGetAutostart (virDomainPtr dom,
|
||||
int xenDaemonDomainSetAutostart (virDomainPtr domain,
|
||||
int autostart);
|
||||
|
||||
/* xen_unified calls through here. */
|
||||
extern struct xenUnifiedDriver xenDaemonDriver;
|
||||
int xenDaemonInit (void);
|
||||
|
||||
virDomainPtr xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc);
|
||||
virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid);
|
||||
virDomainPtr xenDaemonLookupByName(virConnectPtr conn, const char *domname);
|
||||
@ -160,4 +156,12 @@ int xenDaemonDomainMigratePerform (virDomainPtr domain, const char *cookie, int
|
||||
|
||||
int xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, unsigned long long offset, size_t size, void *buffer);
|
||||
|
||||
char * xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams);
|
||||
int xenDaemonGetSchedulerParameters(virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int *nparams);
|
||||
int xenDaemonSetSchedulerParameters(virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int nparams);
|
||||
|
||||
#endif /* __XEND_INTERNAL_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user