]> xenbits.xensource.com Git - libvirt.git/commitdiff
Simplify the Xen domain shutdown/reboot driver methods
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 30 Apr 2013 14:38:32 +0000 (15:38 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 9 May 2013 12:16:19 +0000 (13:16 +0100)
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>
src/xen/xen_driver.c
src/xen/xen_driver.h
src/xen/xend_internal.c
src/xen/xend_internal.h
src/xen/xs_internal.c
src/xen/xs_internal.h

index 6cf61b9b45ea264df4e10f69bc7eec6b3e9f4ee4..1ae27e852d6a1d18d5a474384f0d092c96385bf5 100644 (file)
@@ -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
index ac38b19659720065167261c6bbbf086349940c6f..b77067d6fb91297749f2d80e17f6327c531d14a4 100644 (file)
@@ -94,8 +94,6 @@ extern int xenRegister (void);
  */
 struct xenUnifiedDriver {
     virDrvConnectGetHostname xenGetHostname;
-    virDrvDomainShutdown xenDomainShutdown;
-    virDrvDomainReboot xenDomainReboot;
     virDrvDomainDestroyFlags xenDomainDestroyFlags;
     virDrvDomainGetOSType xenDomainGetOSType;
     virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
index ba31a4ec5d00ca59b1a7dfc838d7a42732010c4e..8f9e624d9d12bf0836b90e6b9094dd194307b753 100644 (file)
@@ -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,
index e8713a72cce64908b7076f76a0ab8a80f313c18c..27e8fbdc79aa81cb63bddef7ca1c21f80c6cb12f 100644 (file)
@@ -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,
index 7926535f0ad8cb6193934e35b8cc32c3be38bab4..a7a8d15b8af07b2a69c803b4c523b6f46a3c6c8a 100644 (file)
@@ -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
index fc7798dfca298eb7fe98140b7720616b0aef8a45..da98eeae67d063386a7a9d26b9d13c86eda0bbbf 100644 (file)
@@ -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);