提交 0f62113d 编写于 作者: D Daniel P. Berrange

Simplify the Xen domain suspend/resume driver methods

Update xenUnifiedDomainSuspend and xenUnifiedDomainResume to
unconditionally invoke the XenD APIs for suspend/resume. Delete
the impls in the hypervisor driver which was unreachable.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 aead5166
......@@ -742,47 +742,13 @@ xenUnifiedDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED)
static int
xenUnifiedDomainSuspend(virDomainPtr dom)
{
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int i;
/* Try non-hypervisor methods first, then hypervisor direct method
* as a last resort.
*/
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] &&
drivers[i]->xenDomainSuspend &&
drivers[i]->xenDomainSuspend(dom) == 0)
return 0;
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
xenHypervisorPauseDomain(dom) == 0)
return 0;
return -1;
return xenDaemonDomainSuspend(dom);
}
static int
xenUnifiedDomainResume(virDomainPtr dom)
{
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int i;
/* Try non-hypervisor methods first, then hypervisor direct method
* as a last resort.
*/
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] &&
drivers[i]->xenDomainResume &&
drivers[i]->xenDomainResume(dom) == 0)
return 0;
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
xenHypervisorResumeDomain(dom) == 0)
return 0;
return -1;
return xenDaemonDomainResume(dom);
}
static int
......
......@@ -94,8 +94,6 @@ extern int xenRegister (void);
*/
struct xenUnifiedDriver {
virDrvConnectGetHostname xenGetHostname;
virDrvDomainSuspend xenDomainSuspend;
virDrvDomainResume xenDomainResume;
virDrvDomainShutdown xenDomainShutdown;
virDrvDomainReboot xenDomainReboot;
virDrvDomainDestroyFlags xenDomainDestroyFlags;
......
......@@ -880,8 +880,6 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
static unsigned long long xenHypervisorGetMaxMemory(virDomainPtr domain);
struct xenUnifiedDriver xenHypervisorDriver = {
.xenDomainSuspend = xenHypervisorPauseDomain,
.xenDomainResume = xenHypervisorResumeDomain,
.xenDomainDestroyFlags = xenHypervisorDestroyDomainFlags,
.xenDomainGetOSType = xenHypervisorDomainGetOSType,
.xenDomainGetMaxMemory = xenHypervisorGetMaxMemory,
......@@ -1486,83 +1484,6 @@ xenHypervisorDomainInterfaceStats(virDomainPtr dom,
#endif
}
/**
* virXen_pausedomain:
* @handle: the hypervisor handle
* @id: the domain id
*
* Do a low level hypercall to pause the domain
*
* Returns 0 or -1 in case of failure
*/
static int
virXen_pausedomain(int handle, int id)
{
int ret = -1;
if (hv_versions.hypervisor > 1) {
xen_op_v2_dom op;
memset(&op, 0, sizeof(op));
op.cmd = XEN_V2_OP_PAUSEDOMAIN;
op.domain = (domid_t) id;
ret = xenHypervisorDoV2Dom(handle, &op);
} else if (hv_versions.hypervisor == 1) {
xen_op_v1 op;
memset(&op, 0, sizeof(op));
op.cmd = XEN_V1_OP_PAUSEDOMAIN;
op.u.domain.domain = (domid_t) id;
ret = xenHypervisorDoV1Op(handle, &op);
} else if (hv_versions.hypervisor == 0) {
xen_op_v0 op;
memset(&op, 0, sizeof(op));
op.cmd = XEN_V0_OP_PAUSEDOMAIN;
op.u.domain.domain = (domid_t) id;
ret = xenHypervisorDoV0Op(handle, &op);
}
return ret;
}
/**
* virXen_unpausedomain:
* @handle: the hypervisor handle
* @id: the domain id
*
* Do a low level hypercall to unpause the domain
*
* Returns 0 or -1 in case of failure
*/
static int
virXen_unpausedomain(int handle, int id)
{
int ret = -1;
if (hv_versions.hypervisor > 1) {
xen_op_v2_dom op;
memset(&op, 0, sizeof(op));
op.cmd = XEN_V2_OP_UNPAUSEDOMAIN;
op.domain = (domid_t) id;
ret = xenHypervisorDoV2Dom(handle, &op);
} else if (hv_versions.hypervisor == 1) {
xen_op_v1 op;
memset(&op, 0, sizeof(op));
op.cmd = XEN_V1_OP_UNPAUSEDOMAIN;
op.u.domain.domain = (domid_t) id;
ret = xenHypervisorDoV1Op(handle, &op);
} else if (hv_versions.hypervisor == 0) {
xen_op_v0 op;
memset(&op, 0, sizeof(op));
op.cmd = XEN_V0_OP_UNPAUSEDOMAIN;
op.u.domain.domain = (domid_t) id;
ret = xenHypervisorDoV0Op(handle, &op);
}
return ret;
}
/**
* virXen_destroydomain:
......@@ -3142,52 +3063,6 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
}
/**
* xenHypervisorPauseDomain:
* @domain: pointer to the domain block
*
* Do a hypervisor call to pause the given domain
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorPauseDomain(virDomainPtr domain)
{
int ret;
xenUnifiedPrivatePtr priv = domain->conn->privateData;
if (domain->id < 0)
return -1;
ret = virXen_pausedomain(priv->handle, domain->id);
if (ret < 0)
return -1;
return 0;
}
/**
* xenHypervisorResumeDomain:
* @domain: pointer to the domain block
*
* Do a hypervisor call to resume the given domain
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorResumeDomain(virDomainPtr domain)
{
int ret;
xenUnifiedPrivatePtr priv = domain->conn->privateData;
if (domain->id < 0)
return -1;
ret = virXen_unpausedomain(priv->handle, domain->id);
if (ret < 0)
return -1;
return 0;
}
/**
* xenHypervisorDestroyDomainFlags:
* @domain: pointer to the domain block
......
......@@ -77,10 +77,6 @@ int xenHypervisorDestroyDomain (virDomainPtr domain)
int xenHypervisorDestroyDomainFlags (virDomainPtr domain,
unsigned int flags)
ATTRIBUTE_NONNULL (1);
int xenHypervisorResumeDomain (virDomainPtr domain)
ATTRIBUTE_NONNULL (1);
int xenHypervisorPauseDomain (virDomainPtr domain)
ATTRIBUTE_NONNULL (1);
int xenHypervisorGetDomainInfo (virDomainPtr domain,
virDomainInfoPtr info)
ATTRIBUTE_NONNULL (1);
......
......@@ -3450,8 +3450,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
}
struct xenUnifiedDriver xenDaemonDriver = {
.xenDomainSuspend = xenDaemonDomainSuspend,
.xenDomainResume = xenDaemonDomainResume,
.xenDomainShutdown = xenDaemonDomainShutdown,
.xenDomainReboot = xenDaemonDomainReboot,
.xenDomainDestroyFlags = xenDaemonDomainDestroyFlags,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册