9119d9
From e2bc63134ab6c302d7a7e605e0da4fd46b4c687a Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <e2bc63134ab6c302d7a7e605e0da4fd46b4c687a@dist-git>
9119d9
From: John Ferlan <jferlan@redhat.com>
9119d9
Date: Thu, 18 Sep 2014 09:29:52 -0400
9119d9
Subject: [PATCH] qemu_domain: Add niothreadpids and iothreadpids
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1101574
9119d9
9119d9
Add new 'niothreadpids' and 'iothreadpids' to mimic the 'ncpupids' and
9119d9
'vcpupids' that already exist.
9119d9
9119d9
(cherry picked from commit 586905512ac2a43698e6d1fa9e719fa564571613)
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_domain.c | 36 ++++++++++++++++++++++++++++++++++++
9119d9
 src/qemu/qemu_domain.h |  3 +++
9119d9
 2 files changed, 39 insertions(+)
9119d9
9119d9
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
9119d9
index c0306d7..863ab09 100644
9119d9
--- a/src/qemu/qemu_domain.c
9119d9
+++ b/src/qemu/qemu_domain.c
9119d9
@@ -425,6 +425,7 @@ qemuDomainObjPrivateFree(void *data)
9119d9
     virDomainChrSourceDefFree(priv->monConfig);
9119d9
     qemuDomainObjFreeJob(priv);
9119d9
     VIR_FREE(priv->vcpupids);
9119d9
+    VIR_FREE(priv->iothreadpids);
9119d9
     VIR_FREE(priv->lockState);
9119d9
     VIR_FREE(priv->origname);
9119d9
 
9119d9
@@ -483,6 +484,18 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
9119d9
         virBufferAddLit(buf, "</vcpus>\n");
9119d9
     }
9119d9
 
9119d9
+    if (priv->niothreadpids) {
9119d9
+        size_t i;
9119d9
+        virBufferAddLit(buf, "<iothreads>\n");
9119d9
+        virBufferAdjustIndent(buf, 2);
9119d9
+        for (i = 0; i < priv->niothreadpids; i++) {
9119d9
+            virBufferAsprintf(buf, "<iothread pid='%d'/>\n",
9119d9
+                              priv->iothreadpids[i]);
9119d9
+        }
9119d9
+        virBufferAdjustIndent(buf, -2);
9119d9
+        virBufferAddLit(buf, "</iothreads>\n");
9119d9
+    }
9119d9
+
9119d9
     if (priv->qemuCaps) {
9119d9
         size_t i;
9119d9
         virBufferAddLit(buf, "<qemuCaps>\n");
9119d9
@@ -606,6 +619,29 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
9119d9
         VIR_FREE(nodes);
9119d9
     }
9119d9
 
9119d9
+    n = virXPathNodeSet("./iothreads/iothread", ctxt, &nodes);
9119d9
+    if (n < 0)
9119d9
+        goto error;
9119d9
+    if (n) {
9119d9
+        priv->niothreadpids = n;
9119d9
+        if (VIR_REALLOC_N(priv->iothreadpids, priv->niothreadpids) < 0)
9119d9
+            goto error;
9119d9
+
9119d9
+        for (i = 0; i < n; i++) {
9119d9
+            char *pidstr = virXMLPropString(nodes[i], "pid");
9119d9
+            if (!pidstr)
9119d9
+                goto error;
9119d9
+
9119d9
+            if (virStrToLong_i(pidstr, NULL, 10,
9119d9
+                               &(priv->iothreadpids[i])) < 0) {
9119d9
+                VIR_FREE(pidstr);
9119d9
+                goto error;
9119d9
+            }
9119d9
+            VIR_FREE(pidstr);
9119d9
+        }
9119d9
+        VIR_FREE(nodes);
9119d9
+    }
9119d9
+
9119d9
     if ((n = virXPathNodeSet("./qemuCaps/flag", ctxt, &nodes)) < 0) {
9119d9
         virReportError(VIR_ERR_INTERNAL_ERROR,
9119d9
                        "%s", _("failed to parse qemu capabilities flags"));
9119d9
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
9119d9
index 479b51f..4ae2c57 100644
9119d9
--- a/src/qemu/qemu_domain.h
9119d9
+++ b/src/qemu/qemu_domain.h
9119d9
@@ -154,6 +154,9 @@ struct _qemuDomainObjPrivate {
9119d9
     int nvcpupids;
9119d9
     int *vcpupids;
9119d9
 
9119d9
+    int niothreadpids;
9119d9
+    int *iothreadpids;
9119d9
+
9119d9
     virDomainPCIAddressSetPtr pciaddrs;
9119d9
     virDomainCCWAddressSetPtr ccwaddrs;
9119d9
     int persistentAddrs;
9119d9
-- 
9119d9
2.1.0
9119d9