[libvirt] [PATCH 1/4] save domstate as string in status file

This one is as posted before. Not really necessary, but makes things look nicer. -- Guido --- src/domain_conf.c | 9 +++++++++ src/domain_conf.h | 2 ++ src/libvirt_private.syms | 2 ++ src/qemu_conf.c | 12 ++++++++---- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/domain_conf.c b/src/domain_conf.c index 94196e8..8deb992 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -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) diff --git a/src/domain_conf.h b/src/domain_conf.h index 1e5c103..45b3e10 100644 --- a/src/domain_conf.h +++ b/src/domain_conf.h @@ -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 */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c76b6c2..3f83a07 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -94,6 +94,8 @@ virDomainVirtTypeToString; virDomainFSDefFree; virDomainObjLock; virDomainObjUnlock; +virDomainStateTypeToString; +virDomainStateTypeFromString; # domain_event.h diff --git a/src/qemu_conf.c b/src/qemu_conf.c index faf1e12..45108f3 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -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, -- 1.6.0.6

On Sun, Jan 18, 2009 at 08:28:05PM +0100, Guido G?nther wrote:
This one is as posted before. Not really necessary, but makes things look nicer.
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Sun, Jan 18, 2009 at 08:28:05PM +0100, Guido Günther wrote:
This one is as posted before. Not really necessary, but makes things look nicer. -- Guido
Looks fine, please commit, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Guido Günther