[PATCH v2 1/2] conf: add xml element devices/pvpanic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a new xml element devices/pvpanic to support qemu device
pvpanic. It can be used to receive guest panic notification.

Signed-off-by: Hu Tao <hutao@xxxxxxxxxxxxxx>
---
 docs/formatdomain.html.in | 25 +++++++++++++++++
 src/conf/domain_conf.c    | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h    |  9 +++++++
 3 files changed, 102 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 1850a2b..0a72baa 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5080,6 +5080,31 @@ qemu-kvm -net nic,model=? /dev/null
     </dd>
   </dl>
 
+    <h4><a name="elementsPvpanic">pvpanic device</a></h4>
+    <p>
+      pvpanic device enables libvirt to receive panic notification from a QEMU
+      guest.
+      <span class="since">Since 1.3.0, QEMU and KVM only</span>
+    </p>
+    <p>
+      Example: usage of pvpanic configuration
+    </p>
+<pre>
+  ...
+  &lt;devices&gt;
+    &lt;pvpanic ioport='0x505'/&gt;
+  &lt;/devices&gt;
+  ...
+</pre>
+  <dl>
+    <dt><code>ioport</code></dt>
+    <dd>
+      <p>
+        ioport used by pvpanic.
+      </p>
+    </dd>
+  </dl>
+
     <h3><a name="seclabel">Security label</a></h3>
 
     <p>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 140eb80..1b8f66f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1876,6 +1876,11 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource)
     VIR_FREE(resource);
 }
 
+void
+virDomainPvpanicDefFree(virDomainPvpanicDefPtr pvpanic)
+{
+    VIR_FREE(pvpanic);
+}
 
 void virDomainDefFree(virDomainDefPtr def)
 {
@@ -1964,6 +1969,8 @@ void virDomainDefFree(virDomainDefPtr def)
 
     virDomainTPMDefFree(def->tpm);
 
+    virDomainPvpanicDefFree(def->pvpanic);
+
     VIR_FREE(def->idmap.uidmap);
     VIR_FREE(def->idmap.gidmap);
 
@@ -10626,6 +10633,31 @@ cleanup:
     return idmap;
 }
 
+static virDomainPvpanicDefPtr
+virDomainPvpanicDefParseXML(xmlNodePtr node)
+{
+    char *ioport = NULL;
+    virDomainPvpanicDefPtr pvpanic;
+
+    if (VIR_ALLOC(pvpanic) < 0)
+        return NULL;
+
+    ioport = virXMLPropString(node, "ioport");
+    if (!ioport) {
+        pvpanic->ioport = -1;
+    } else {
+        if (virStrToLong_i(ioport, NULL, 0, &pvpanic->ioport) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Cannot parse <pvpanic> 'ioport' attribute"));
+            goto error;
+        }
+    }
+
+    return pvpanic;
+error:
+    virDomainPvpanicDefFree(pvpanic);
+    return NULL;
+}
 
 /* Parse the XML definition for a vcpupin or emulatorpin.
  *
@@ -12453,6 +12485,27 @@ virDomainDefParseXML(xmlDocPtr xml,
     }
     VIR_FREE(nodes);
 
+    /* analysis of the pvpanic devices */
+    def->pvpanic = NULL;
+    if ((n = virXPathNodeSet("./devices/pvpanic", ctxt, &nodes)) < 0) {
+        goto error;
+    }
+    if (n > 1) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("only a single pvpanic device is supported"));
+        goto error;
+    }
+    if (n > 0) {
+        virDomainPvpanicDefPtr pvpanic =
+            virDomainPvpanicDefParseXML(nodes[0]);
+        if (!pvpanic)
+            goto error;
+
+        def->pvpanic = pvpanic;
+        VIR_FREE(nodes);
+    }
+
+
     /* analysis of the user namespace mapping */
     if ((n = virXPathNodeSet("./idmap/uid", ctxt, &nodes)) < 0)
         goto error;
@@ -15715,6 +15768,18 @@ virDomainWatchdogDefFormat(virBufferPtr buf,
     return 0;
 }
 
+static int virDomainPvpanicDefFormat(virBufferPtr buf,
+                                     virDomainPvpanicDefPtr def)
+{
+    if (def->ioport > 0) {
+        virBufferAsprintf(buf, "    <pvpanic ioport='%#x'/>\n",
+                          def->ioport);
+    } else {
+        virBufferAsprintf(buf, "    <pvpanic/>\n");
+    }
+
+    return 0;
+}
 
 static int
 virDomainRNGDefFormat(virBufferPtr buf,
@@ -17138,6 +17203,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->nvram)
         virDomainNVRAMDefFormat(buf, def->nvram, flags);
 
+    if (def->pvpanic)
+        virDomainPvpanicDefFormat(buf, def->pvpanic);
+
     virBufferAddLit(buf, "  </devices>\n");
 
     virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4561ccc..9395852 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -126,6 +126,9 @@ typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;
 typedef struct _virDomainIdMapDef virDomainIdMapDef;
 typedef virDomainIdMapDef *virDomainIdMapDefPtr;
 
+typedef struct _virDomainPvpanicDef virDomainPvpanicDef;
+typedef virDomainPvpanicDef *virDomainPvpanicDefPtr;
+
 /* Flags for the 'type' field in virDomainDeviceDef */
 typedef enum {
     VIR_DOMAIN_DEVICE_NONE = 0,
@@ -1910,6 +1913,10 @@ struct _virDomainIdMapDef {
 };
 
 
+struct _virDomainPvpanicDef {
+    int ioport;
+};
+
 void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
                                     int ndevices);
 
@@ -2061,6 +2068,7 @@ struct _virDomainDef {
     virSysinfoDefPtr sysinfo;
     virDomainRedirFilterDefPtr redirfilter;
     virDomainRNGDefPtr rng;
+    virDomainPvpanicDefPtr pvpanic;
 
     void *namespaceData;
     virDomainXMLNamespace ns;
@@ -2204,6 +2212,7 @@ virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
 bool virDomainObjTaint(virDomainObjPtr obj,
                        enum virDomainTaintFlags taint);
 
+void virDomainPvpanicDefFree(virDomainPvpanicDefPtr pvpanic);
 void virDomainResourceDefFree(virDomainResourceDefPtr resource);
 void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
 void virDomainInputDefFree(virDomainInputDefPtr def);
-- 
1.7.11.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]