]> xenbits.xensource.com Git - libvirt.git/commitdiff
save domstate as string in status file
authorGuido Günther <agx@sigxcpu.org>
Mon, 19 Jan 2009 21:06:26 +0000 (21:06 +0000)
committerGuido Günther <agx@sigxcpu.org>
Mon, 19 Jan 2009 21:06:26 +0000 (21:06 +0000)
ChangeLog
src/domain_conf.c
src/domain_conf.h
src/libvirt_private.syms
src/qemu_conf.c

index a035267bd195bec7cc08816ce2b4572a461e1f1f..0930a4f138a4095ce05bc0d405ae55ffd0f6281d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Jan 19 21:54:25 CET 2009 Guido Günther <agx@sigxcpu.org>
+
+       save domstate as string in status file
+       * src/domain_conf.c (virDomainState): add VIR_ENUM_IMPL
+       * src/domain_conf.h (virDomainState): add VIR_ENUM_DECL
+       * src/qemu_conf.c (qemudDomainStatusParseFile): parse state as string
+         (qemudDomainStatusFormat): write as string
+       * src/libvirt_private.syms (virDomainStateTypeToString,
+         virDomainStateTypeFromString): add sympbols
+
 Mon Jan 19 20:58:34 CET 2009 Daniel Veillard <veillard@redhat.com>
 
        * src/xen_internal.c src/xend_internal.c: Relax NUMA checking
index 94196e83f78d198e72e7f993a2bc0a7bdd0da21c..8deb9923fde0a3622578022ea47366c2bd97a46d 100644 (file)
@@ -142,6 +142,15 @@ VIR_ENUM_IMPL(virDomainHostdevSubsys, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST,
               "usb",
               "pci")
 
+VIR_ENUM_IMPL(virDomainState, VIR_DOMAIN_CRASHED+1,
+              "nostate",
+              "running",
+              "blocked",
+              "paused",
+              "shutdown",
+              "shutoff",
+              "crashed")
+
 #define virDomainReportError(conn, code, fmt...)                           \
         virReportErrorHelper(conn, VIR_FROM_DOMAIN, code, __FILE__,        \
                                __FUNCTION__, __LINE__, fmt)
index 1e5c10369aa86aad33f556ef5f93b27dd9fb4df6..45b3e10cf416fabc4f2ee491dbdb2d910848d051 100644 (file)
@@ -625,5 +625,7 @@ VIR_ENUM_DECL(virDomainHostdevSubsys)
 VIR_ENUM_DECL(virDomainInput)
 VIR_ENUM_DECL(virDomainInputBus)
 VIR_ENUM_DECL(virDomainGraphics)
+/* from libvirt.h */
+VIR_ENUM_DECL(virDomainState)
 
 #endif /* __DOMAIN_CONF_H */
index c76b6c2376afe8c62d69e0f16040959623b8daee..3f83a07807ecee47e950c35ec894c5a7450aca4d 100644 (file)
@@ -94,6 +94,8 @@ virDomainVirtTypeToString;
 virDomainFSDefFree;
 virDomainObjLock;
 virDomainObjUnlock;
+virDomainStateTypeToString;
+virDomainStateTypeFromString;
 
 
 # domain_event.h
index faf1e12ade92aed10cc30f2cef9050f47cbd4b50..45108f32f34b10742ebcb83d020132c67c40e2df 100644 (file)
@@ -1375,12 +1375,14 @@ qemudDomainStatusParseFile(virConnectPtr conn,
     }
 
     ctxt->node = root;
-    if((virXPathLong(conn, "string(./@state)", ctxt, &val)) < 0) {
+    if(!(tmp = virXPathString(conn, "string(./@state)", ctxt))) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
                              "%s", _("invalid domain state"));
         goto error;
-    } else
-        status->state = (int)val;
+    } else {
+        status->state = virDomainStateTypeFromString(tmp);
+        VIR_FREE(tmp);
+    }
 
     if((virXPathLong(conn, "string(./@pid)", ctxt, &val)) < 0) {
         qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1433,7 +1435,9 @@ qemudDomainStatusFormat(virConnectPtr conn,
     char *config_xml = NULL, *xml = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-    virBufferVSprintf(&buf, "<domstatus state='%d' pid='%d'>\n", vm->state, vm->pid);
+    virBufferVSprintf(&buf, "<domstatus state='%s' pid='%d'>\n",
+                      virDomainStateTypeToString(vm->state),
+                      vm->pid);
     virBufferEscapeString(&buf, "  <monitor path='%s'/>\n", vm->monitorpath);
 
     if (!(config_xml = virDomainDefFormat(conn,