mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
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,
|
||||
unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
||||
int i;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] &&
|
||||
drivers[i]->xenDomainShutdown &&
|
||||
drivers[i]->xenDomainShutdown(dom) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
return xenDaemonDomainShutdown(dom);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -778,16 +769,9 @@ xenUnifiedDomainShutdown(virDomainPtr dom)
|
||||
static int
|
||||
xenUnifiedDomainReboot(virDomainPtr dom, unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
||||
int i;
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] &&
|
||||
drivers[i]->xenDomainReboot &&
|
||||
drivers[i]->xenDomainReboot(dom, flags) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
return xenDaemonDomainReboot(dom);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -94,8 +94,6 @@ extern int xenRegister (void);
|
||||
*/
|
||||
struct xenUnifiedDriver {
|
||||
virDrvConnectGetHostname xenGetHostname;
|
||||
virDrvDomainShutdown xenDomainShutdown;
|
||||
virDrvDomainReboot xenDomainReboot;
|
||||
virDrvDomainDestroyFlags xenDomainDestroyFlags;
|
||||
virDrvDomainGetOSType xenDomainGetOSType;
|
||||
virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
|
||||
|
@ -1320,7 +1320,6 @@ xenDaemonDomainShutdown(virDomainPtr domain)
|
||||
/**
|
||||
* xenDaemonDomainReboot:
|
||||
* @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 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.
|
||||
*/
|
||||
int
|
||||
xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags)
|
||||
xenDaemonDomainReboot(virDomainPtr domain)
|
||||
{
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (domain->id < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("Domain %s isn't running."), domain->name);
|
||||
@ -3450,8 +3447,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
|
||||
}
|
||||
|
||||
struct xenUnifiedDriver xenDaemonDriver = {
|
||||
.xenDomainShutdown = xenDaemonDomainShutdown,
|
||||
.xenDomainReboot = xenDaemonDomainReboot,
|
||||
.xenDomainDestroyFlags = xenDaemonDomainDestroyFlags,
|
||||
.xenDomainGetOSType = xenDaemonDomainGetOSType,
|
||||
.xenDomainGetMaxMemory = xenDaemonDomainGetMaxMemory,
|
||||
|
@ -90,7 +90,7 @@ int xenDaemonNodeGetTopology(virConnectPtr conn, virCapsPtr caps);
|
||||
int xenDaemonDomainSuspend(virDomainPtr domain);
|
||||
int xenDaemonDomainResume(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 xenDaemonDomainSave(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);
|
||||
|
||||
struct xenUnifiedDriver xenStoreDriver = {
|
||||
.xenDomainShutdown = xenStoreDomainShutdown,
|
||||
.xenDomainReboot = xenStoreDomainReboot,
|
||||
.xenDomainGetOSType = xenStoreDomainGetOSType,
|
||||
.xenDomainGetMaxMemory = xenStoreDomainGetMaxMemory,
|
||||
.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:
|
||||
* @domain: a domain object
|
||||
|
@ -47,9 +47,6 @@ unsigned long xenStoreGetMaxMemory (virDomainPtr domain);
|
||||
int xenStoreDomainSetMemory (virDomainPtr domain,
|
||||
unsigned long memory);
|
||||
unsigned long long xenStoreDomainGetMaxMemory(virDomainPtr domain);
|
||||
int xenStoreDomainShutdown (virDomainPtr domain);
|
||||
int xenStoreDomainReboot (virDomainPtr domain,
|
||||
unsigned int flags);
|
||||
|
||||
int xenStoreDomainGetVNCPort(virConnectPtr conn,
|
||||
int domid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user