From 6d0d1ecce9b107855f93f7813de356f66463b2db Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 30 Apr 2013 15:38:32 +0100 Subject: [PATCH] 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 --- src/xen/xen_driver.c | 22 ++------------- src/xen/xen_driver.h | 2 -- src/xen/xend_internal.c | 7 +---- src/xen/xend_internal.h | 2 +- src/xen/xs_internal.c | 62 ----------------------------------------- src/xen/xs_internal.h | 3 -- 6 files changed, 5 insertions(+), 93 deletions(-) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 6cf61b9b45..1ae27e852d 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -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; - - for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) - if (priv->opened[i] && - drivers[i]->xenDomainReboot && - drivers[i]->xenDomainReboot(dom, flags) == 0) - return 0; + virCheckFlags(0, -1); - return -1; + return xenDaemonDomainReboot(dom); } static int diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index ac38b19659..b77067d6fb 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -94,8 +94,6 @@ extern int xenRegister (void); */ struct xenUnifiedDriver { virDrvConnectGetHostname xenGetHostname; - virDrvDomainShutdown xenDomainShutdown; - virDrvDomainReboot xenDomainReboot; virDrvDomainDestroyFlags xenDomainDestroyFlags; virDrvDomainGetOSType xenDomainGetOSType; virDrvDomainGetMaxMemory xenDomainGetMaxMemory; diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index ba31a4ec5d..8f9e624d9d 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -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, diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index e8713a72cc..27e8fbdc79 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -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, diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c index 7926535f0a..a7a8d15b8a 100644 --- a/src/xen/xs_internal.c +++ b/src/xen/xs_internal.c @@ -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 diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h index fc7798dfca..da98eeae67 100644 --- a/src/xen/xs_internal.h +++ b/src/xen/xs_internal.h @@ -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); -- GitLab