Simplify the Xen domain shutdown/reboot driver methods
Make the xenUnifiedDomainShutdownFlags and xenUnifiedDomainReboot driver methods unconditionally call the XenD APIs for shutdown and reboot. Delete the unreachable impls in the XenStore driver. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
0f62113d8a
commit
6d0d1ecce9
@ -755,18 +755,9 @@ static int
|
|||||||
xenUnifiedDomainShutdownFlags(virDomainPtr dom,
|
xenUnifiedDomainShutdownFlags(virDomainPtr dom,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
return xenDaemonDomainShutdown(dom);
|
||||||
if (priv->opened[i] &&
|
|
||||||
drivers[i]->xenDomainShutdown &&
|
|
||||||
drivers[i]->xenDomainShutdown(dom) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -778,16 +769,9 @@ xenUnifiedDomainShutdown(virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainReboot(virDomainPtr dom, unsigned int flags)
|
xenUnifiedDomainReboot(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
virCheckFlags(0, -1);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
return xenDaemonDomainReboot(dom);
|
||||||
if (priv->opened[i] &&
|
|
||||||
drivers[i]->xenDomainReboot &&
|
|
||||||
drivers[i]->xenDomainReboot(dom, flags) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -94,8 +94,6 @@ extern int xenRegister (void);
|
|||||||
*/
|
*/
|
||||||
struct xenUnifiedDriver {
|
struct xenUnifiedDriver {
|
||||||
virDrvConnectGetHostname xenGetHostname;
|
virDrvConnectGetHostname xenGetHostname;
|
||||||
virDrvDomainShutdown xenDomainShutdown;
|
|
||||||
virDrvDomainReboot xenDomainReboot;
|
|
||||||
virDrvDomainDestroyFlags xenDomainDestroyFlags;
|
virDrvDomainDestroyFlags xenDomainDestroyFlags;
|
||||||
virDrvDomainGetOSType xenDomainGetOSType;
|
virDrvDomainGetOSType xenDomainGetOSType;
|
||||||
virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
|
virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
|
||||||
|
@ -1320,7 +1320,6 @@ xenDaemonDomainShutdown(virDomainPtr domain)
|
|||||||
/**
|
/**
|
||||||
* xenDaemonDomainReboot:
|
* xenDaemonDomainReboot:
|
||||||
* @domain: pointer to the Domain block
|
* @domain: pointer to the Domain block
|
||||||
* @flags: extra flags for the reboot operation, not used yet
|
|
||||||
*
|
*
|
||||||
* Reboot the domain, the OS is requested to properly shutdown
|
* Reboot the domain, the OS is requested to properly shutdown
|
||||||
* and restart but the domain may ignore it. It will return immediately
|
* and restart but the domain may ignore it. It will return immediately
|
||||||
@ -1329,10 +1328,8 @@ xenDaemonDomainShutdown(virDomainPtr domain)
|
|||||||
* Returns 0 in case of success, -1 (with errno) in case of error.
|
* Returns 0 in case of success, -1 (with errno) in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags)
|
xenDaemonDomainReboot(virDomainPtr domain)
|
||||||
{
|
{
|
||||||
virCheckFlags(0, -1);
|
|
||||||
|
|
||||||
if (domain->id < 0) {
|
if (domain->id < 0) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("Domain %s isn't running."), domain->name);
|
_("Domain %s isn't running."), domain->name);
|
||||||
@ -3450,8 +3447,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct xenUnifiedDriver xenDaemonDriver = {
|
struct xenUnifiedDriver xenDaemonDriver = {
|
||||||
.xenDomainShutdown = xenDaemonDomainShutdown,
|
|
||||||
.xenDomainReboot = xenDaemonDomainReboot,
|
|
||||||
.xenDomainDestroyFlags = xenDaemonDomainDestroyFlags,
|
.xenDomainDestroyFlags = xenDaemonDomainDestroyFlags,
|
||||||
.xenDomainGetOSType = xenDaemonDomainGetOSType,
|
.xenDomainGetOSType = xenDaemonDomainGetOSType,
|
||||||
.xenDomainGetMaxMemory = xenDaemonDomainGetMaxMemory,
|
.xenDomainGetMaxMemory = xenDaemonDomainGetMaxMemory,
|
||||||
|
@ -90,7 +90,7 @@ int xenDaemonNodeGetTopology(virConnectPtr conn, virCapsPtr caps);
|
|||||||
int xenDaemonDomainSuspend(virDomainPtr domain);
|
int xenDaemonDomainSuspend(virDomainPtr domain);
|
||||||
int xenDaemonDomainResume(virDomainPtr domain);
|
int xenDaemonDomainResume(virDomainPtr domain);
|
||||||
int xenDaemonDomainShutdown(virDomainPtr domain);
|
int xenDaemonDomainShutdown(virDomainPtr domain);
|
||||||
int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags);
|
int xenDaemonDomainReboot(virDomainPtr domain);
|
||||||
int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
|
int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
|
||||||
int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
|
int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
|
||||||
int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
||||||
|
@ -58,8 +58,6 @@ static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
|
|||||||
static void xenStoreWatchListFree(xenStoreWatchListPtr list);
|
static void xenStoreWatchListFree(xenStoreWatchListPtr list);
|
||||||
|
|
||||||
struct xenUnifiedDriver xenStoreDriver = {
|
struct xenUnifiedDriver xenStoreDriver = {
|
||||||
.xenDomainShutdown = xenStoreDomainShutdown,
|
|
||||||
.xenDomainReboot = xenStoreDomainReboot,
|
|
||||||
.xenDomainGetOSType = xenStoreDomainGetOSType,
|
.xenDomainGetOSType = xenStoreDomainGetOSType,
|
||||||
.xenDomainGetMaxMemory = xenStoreDomainGetMaxMemory,
|
.xenDomainGetMaxMemory = xenStoreDomainGetMaxMemory,
|
||||||
.xenDomainSetMemory = xenStoreDomainSetMemory,
|
.xenDomainSetMemory = xenStoreDomainSetMemory,
|
||||||
@ -581,66 +579,6 @@ xenStoreListDomains(virConnectPtr conn, int *ids, int maxids)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xenStoreDomainShutdown:
|
|
||||||
* @domain: pointer to the Domain block
|
|
||||||
*
|
|
||||||
* Shutdown the domain, the OS is requested to properly shutdown
|
|
||||||
* and the domain may ignore it. It will return immediately
|
|
||||||
* after queuing the request.
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xenStoreDomainShutdown(virDomainPtr domain)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
|
||||||
|
|
||||||
if (domain->id == -1 || domain->id == 0)
|
|
||||||
return -1;
|
|
||||||
/*
|
|
||||||
* this is very hackish, the domU kernel probes for a special
|
|
||||||
* node in the xenstore and launch the shutdown command if found.
|
|
||||||
*/
|
|
||||||
xenUnifiedLock(priv);
|
|
||||||
ret = virDomainDoStoreWrite(domain, "control/shutdown", "poweroff");
|
|
||||||
xenUnifiedUnlock(priv);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xenStoreDomainReboot:
|
|
||||||
* @domain: pointer to the Domain block
|
|
||||||
* @flags: extra flags for the reboot operation, not used yet
|
|
||||||
*
|
|
||||||
* Reboot the domain, the OS is requested to properly shutdown
|
|
||||||
* and reboot but the domain may ignore it. It will return immediately
|
|
||||||
* after queuing the request.
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xenStoreDomainReboot(virDomainPtr domain, unsigned int flags)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
|
||||||
|
|
||||||
if (domain->id == -1 || domain->id == 0)
|
|
||||||
return -1;
|
|
||||||
/*
|
|
||||||
* this is very hackish, the domU kernel probes for a special
|
|
||||||
* node in the xenstore and launch the shutdown command if found.
|
|
||||||
*/
|
|
||||||
|
|
||||||
xenUnifiedLock(priv);
|
|
||||||
ret = virDomainDoStoreWrite(domain, "control/shutdown", "reboot");
|
|
||||||
xenUnifiedUnlock(priv);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xenStoreDomainGetOSType:
|
* xenStoreDomainGetOSType:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
|
@ -47,9 +47,6 @@ unsigned long xenStoreGetMaxMemory (virDomainPtr domain);
|
|||||||
int xenStoreDomainSetMemory (virDomainPtr domain,
|
int xenStoreDomainSetMemory (virDomainPtr domain,
|
||||||
unsigned long memory);
|
unsigned long memory);
|
||||||
unsigned long long xenStoreDomainGetMaxMemory(virDomainPtr domain);
|
unsigned long long xenStoreDomainGetMaxMemory(virDomainPtr domain);
|
||||||
int xenStoreDomainShutdown (virDomainPtr domain);
|
|
||||||
int xenStoreDomainReboot (virDomainPtr domain,
|
|
||||||
unsigned int flags);
|
|
||||||
|
|
||||||
int xenStoreDomainGetVNCPort(virConnectPtr conn,
|
int xenStoreDomainGetVNCPort(virConnectPtr conn,
|
||||||
int domid);
|
int domid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user