]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix detection of JSON when restarting libvirtd
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 9 Dec 2009 18:28:30 +0000 (18:28 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 21 Dec 2009 23:37:37 +0000 (23:37 +0000)
The XML XPath for detecting JSON in the running VM statefile was
wrong causing all VMs to get JSON mode enabled at libvirtd restart.

In addition if a VM was running a JSON enabled QEMU once, and then
altered to point to a non-JSON enabled QEMU later the 'monJSON'
flag would not get reset to 0.

* src/qemu/qemu_driver.c: Fix setting/detection of JSON mode

src/qemu/qemu_driver.c

index 60dea9ce868e74d9663bc8b6534ef517f79b32ff..a6a1a5ab7cecfcbc02fd2f93f6e761b6072785ef 100644 (file)
@@ -221,8 +221,11 @@ static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
         priv->monConfig->type = VIR_DOMAIN_CHR_TYPE_PTY;
     VIR_FREE(tmp);
 
-    if (virXPathBoolean(NULL, "int(./monitor[1]/@json)", ctxt))
+    if (virXPathBoolean(NULL, "count(./monitor[@json = '1']) > 0", ctxt)) {
         priv->monJSON = 1;
+    } else {
+        priv->monJSON = 0;
+    }
 
     switch (priv->monConfig->type) {
     case VIR_DOMAIN_CHR_TYPE_PTY:
@@ -2440,7 +2443,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 #if HAVE_YAJL
     if (qemuCmdFlags & QEMUD_CMD_FLAG_MONITOR_JSON)
         priv->monJSON = 1;
+    else
 #endif
+        priv->monJSON = 0;
 
     if ((ret = virFileDeletePid(driver->stateDir, vm->def->name)) != 0) {
         virReportSystemError(conn, ret,