[PATCH v3 2/4] conf: add support for panic device

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

 



panic device is a device that enables libvirt to receive notification
of guest panic event.
---
 docs/formatdomain.html.in     | 28 +++++++++++++++++
 docs/schemas/domaincommon.rng | 10 ++++++
 src/conf/domain_conf.c        | 72 +++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h        |  9 ++++++
 4 files changed, 119 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 054ebc6..c8f213e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5085,6 +5085,34 @@ qemu-kvm -net nic,model=? /dev/null
     </dd>
   </dl>
 
+    <h4><a name="elementsPanic">panic device</a></h4>
+    <p>
+      panic device enables libvirt to receive panic notification from a QEMU
+      guest.
+      <span class="since">Since 1.2.1, QEMU and KVM only</span>
+    </p>
+    <p>
+      Example: usage of panic configuration
+    </p>
+<pre>
+  ...
+  &lt;devices&gt;
+    &lt;panic&gt;
+      &lt;address type='isa' iobase='0x505'/&gt;
+    &lt;/panic&gt;
+  &lt;/devices&gt;
+  ...
+</pre>
+  <dl>
+    <dt><code>address</code></dt>
+    <dd>
+      <p>
+        address of panic. The default ioport is 0x505. Most users
+        don't need to specify an address.
+      </p>
+    </dd>
+  </dl>
+
     <h3><a name="seclabel">Security label</a></h3>
 
     <p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3e98af9..8ae96f2 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3556,6 +3556,9 @@
         <optional>
           <ref name="nvram"/>
         </optional>
+        <optional>
+          <ref name="panic"/>
+        </optional>
       </interleave>
     </element>
   </define>
@@ -4409,4 +4412,11 @@
       </data>
     </choice>
   </define>
+  <define name="panic">
+    <element name="panic">
+      <optional>
+        <ref name="address"/>
+      </optional>
+    </element>
+  </define>
 </grammar>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7d5617e..233b848 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1877,6 +1877,15 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource)
     VIR_FREE(resource);
 }
 
+void
+virDomainPanicDefFree(virDomainPanicDefPtr panic)
+{
+    if (!panic)
+        return;
+
+    virDomainDeviceInfoClear(&panic->info);
+    VIR_FREE(panic);
+}
 
 void virDomainDefFree(virDomainDefPtr def)
 {
@@ -1965,6 +1974,8 @@ void virDomainDefFree(virDomainDefPtr def)
 
     virDomainTPMDefFree(def->tpm);
 
+    virDomainPanicDefFree(def->panic);
+
     VIR_FREE(def->idmap.uidmap);
     VIR_FREE(def->idmap.gidmap);
 
@@ -10673,6 +10684,22 @@ cleanup:
     return idmap;
 }
 
+static virDomainPanicDefPtr
+virDomainPanicDefParseXML(xmlNodePtr node)
+{
+    virDomainPanicDefPtr panic;
+
+    if (VIR_ALLOC(panic) < 0)
+        return NULL;
+
+    if (virDomainDeviceInfoParseXML(node, NULL, &panic->info, 0) < 0)
+        goto error;
+
+    return panic;
+error:
+    virDomainPanicDefFree(panic);
+    return NULL;
+}
 
 /* Parse the XML definition for a vcpupin or emulatorpin.
  *
@@ -12500,6 +12527,27 @@ virDomainDefParseXML(xmlDocPtr xml,
     }
     VIR_FREE(nodes);
 
+    /* analysis of the panic devices */
+    def->panic = NULL;
+    if ((n = virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0) {
+        goto error;
+    }
+    if (n > 1) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("only a single panic device is supported"));
+        goto error;
+    }
+    if (n > 0) {
+        virDomainPanicDefPtr panic =
+            virDomainPanicDefParseXML(nodes[0]);
+        if (!panic)
+            goto error;
+
+        def->panic = panic;
+        VIR_FREE(nodes);
+    }
+
+
     /* analysis of the user namespace mapping */
     if ((n = virXPathNodeSet("./idmap/uid", ctxt, &nodes)) < 0)
         goto error;
@@ -13589,6 +13637,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
     return true;
 }
 
+static bool
+virDomainPanicCheckABIStability(virDomainPanicDefPtr src,
+                                virDomainPanicDefPtr dst)
+{
+    return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
+}
+
 
 /* This compares two configurations and looks for any differences
  * which will affect the guest ABI. This is primarily to allow
@@ -13930,6 +13985,9 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
     if (!virDomainRNGDefCheckABIStability(src->rng, dst->rng))
         return false;
 
+    if (!virDomainPanicCheckABIStability(src->panic, dst->panic))
+        return false;
+
     return true;
 }
 
@@ -15776,6 +15834,16 @@ virDomainWatchdogDefFormat(virBufferPtr buf,
     return 0;
 }
 
+static int virDomainPanicDefFormat(virBufferPtr buf,
+                                     virDomainPanicDefPtr def)
+{
+    virBufferAddLit(buf, "    <panic>\n");
+    if (virDomainDeviceInfoFormat(buf, &def->info, 0) < 0)
+        return -1;
+    virBufferAddLit(buf, "    </panic>\n");
+
+    return 0;
+}
 
 static int
 virDomainRNGDefFormat(virBufferPtr buf,
@@ -17199,6 +17267,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->nvram)
         virDomainNVRAMDefFormat(buf, def->nvram, flags);
 
+    if (def->panic &&
+        virDomainPanicDefFormat(buf, def->panic) < 0)
+        goto error;
+
     virBufferAddLit(buf, "  </devices>\n");
 
     virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 25bd362..7e68aa2 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 _virDomainPanicDef virDomainPanicDef;
+typedef virDomainPanicDef *virDomainPanicDefPtr;
+
 /* Flags for the 'type' field in virDomainDeviceDef */
 typedef enum {
     VIR_DOMAIN_DEVICE_NONE = 0,
@@ -1919,6 +1922,10 @@ struct _virDomainIdMapDef {
 };
 
 
+struct _virDomainPanicDef {
+    virDomainDeviceInfo info;
+};
+
 void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
                                     int ndevices);
 
@@ -2070,6 +2077,7 @@ struct _virDomainDef {
     virSysinfoDefPtr sysinfo;
     virDomainRedirFilterDefPtr redirfilter;
     virDomainRNGDefPtr rng;
+    virDomainPanicDefPtr panic;
 
     void *namespaceData;
     virDomainXMLNamespace ns;
@@ -2213,6 +2221,7 @@ virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
 bool virDomainObjTaint(virDomainObjPtr obj,
                        enum virDomainTaintFlags taint);
 
+void virDomainPanicDefFree(virDomainPanicDefPtr panic);
 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]