]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xend_internal: Use domain/status for shutdown check
authorStefan Bader <stefan.bader@canonical.com>
Thu, 12 Apr 2012 13:42:37 +0000 (15:42 +0200)
committerCole Robinson <crobinso@redhat.com>
Fri, 15 Jun 2012 14:58:05 +0000 (10:58 -0400)
On newer xend (v3.x and after) there is no state and domid reported
for inactive domains. When initially creating connections this is
handled in various places by assigning domain->id = -1.
But once an instance has been running, the id is set to the current
domain id. And it does not change when the instance is shut down.
So when querying the domain info, the hypervisor driver, which gets
asked first will indicate it cannot find information, then the
xend driver is asked and will set the status to NOSTATE because it
checks for the -1 domain id.
Checking domain/status for 0 seems to be more reliable for that.

One note: I am not sure whether the domain->id also should get set
back to -1 whenever any sub-driver thinks the instance is no longer
running.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=746007
BugLink: http://bugs.launchpad.net/bugs/929626
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
(cherry picked from commit 26e9ef476239e8cb79f819092c5aac4afdd47d0d)

(crobinso: Add Stefan to AUTHORS. maint only)

AUTHORS
src/xen/xend_internal.c

diff --git a/AUTHORS b/AUTHORS
index d924583ac1f333db78f24787a86819a459636d3a..cea6ebd45ed862b50b3402a1cb69a5d15b274fb8 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -196,6 +196,7 @@ Patches have also been contributed by:
   Lei Li               <lilei@linux.vnet.ibm.com>
   Matthias Witte       <witte@netzquadrat.de>
   Radu Caragea         <dmns_serp@yahoo.com>
+  Stefan Bader         <stefan.bader@canonical.com>
 
   [....send patches to get your name here....]
 
index fa39e8b26d851a2cc1f81ddb6ba008d05ff12e7a..e5c9b27011f6fecf24ad4f7c0ef9fa97120d6428 100644 (file)
@@ -989,9 +989,14 @@ sexpr_to_xend_domain_state(virDomainPtr domain, const struct sexpr *root)
             state = VIR_DOMAIN_BLOCKED;
         else if (strchr(flags, 'r'))
             state = VIR_DOMAIN_RUNNING;
-    } else if (domain->id < 0) {
-        /* Inactive domains don't have a state reported, so
-           mark them SHUTOFF, rather than NOSTATE */
+    } else if (domain->id < 0 || sexpr_int(root, "domain/status") == 0) {
+        /* As far as I can see the domain->id is a bad sign for checking
+         * inactive domains as this is inaccurate after the domain has
+         * been running once. However domain/status from xend seems to
+         * be always present and 0 for inactive domains.
+         * (keeping the check for id < 0 to be extra safe about backward
+         * compatibility)
+         */
         state = VIR_DOMAIN_SHUTOFF;
     }