From 1efacd76a430275796d45e26cac47af59c0e571a Mon Sep 17 00:00:00 2001
Message-Id: <1efacd76a430275796d45e26cac47af59c0e571a.1387385061.git.jdenemar@redhat.com>
From: Hu Tao <hutao@cn.fujitsu.com>
Date: Mon, 16 Dec 2013 11:58:21 -0700
Subject: [PATCH] conf: add support for panic device
RHEL 7.0: https://bugzilla.redhat.com/show_bug.cgi?id=996520
panic device is a device that enables libvirt to receive notification
of guest panic event.
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 4313feade44e24ca215416e75299c7d29a70db11)
Conflicts:
src/conf/domain_conf.h - context (commit b471066, blkio array clear)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
docs/formatdomain.html.in | 28 +++++++++++++++++
docs/schemas/domaincommon.rng | 10 ++++++
src/conf/domain_conf.c | 72 +++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++
4 files changed, 120 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index fb557f6..fc8a397 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5033,6 +5033,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>
+ ...
+ <devices>
+ <panic>
+ <address type='isa' iobase='0x505'/>
+ </panic>
+ </devices>
+ ...
+</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 871ae30..91b36e2 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3505,6 +3505,9 @@
<optional>
<ref name="nvram"/>
</optional>
+ <optional>
+ <ref name="panic"/>
+ </optional>
</interleave>
</element>
</define>
@@ -4364,4 +4367,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 f35ec44..9cf5432 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1870,6 +1870,15 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource)
VIR_FREE(resource);
}
+void
+virDomainPanicDefFree(virDomainPanicDefPtr panic)
+{
+ if (!panic)
+ return;
+
+ virDomainDeviceInfoClear(&panic->info);
+ VIR_FREE(panic);
+}
void virDomainDefFree(virDomainDefPtr def)
{
@@ -1958,6 +1967,8 @@ void virDomainDefFree(virDomainDefPtr def)
virDomainTPMDefFree(def->tpm);
+ virDomainPanicDefFree(def->panic);
+
VIR_FREE(def->idmap.uidmap);
VIR_FREE(def->idmap.gidmap);
@@ -10553,6 +10564,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.
*
@@ -12390,6 +12417,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;
@@ -13486,6 +13534,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
@@ -13827,6 +13882,9 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
if (!virDomainRNGDefCheckABIStability(src->rng, dst->rng))
return false;
+ if (!virDomainPanicCheckABIStability(src->panic, dst->panic))
+ return false;
+
return true;
}
@@ -15657,6 +15715,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,
@@ -17089,6 +17157,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 7f6096f..ed40def 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,
@@ -1903,6 +1906,11 @@ struct _virDomainIdMapDef {
};
+struct _virDomainPanicDef {
+ virDomainDeviceInfo info;
+};
+
+
void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
int ndevices);
@@ -2054,6 +2062,7 @@ struct _virDomainDef {
virSysinfoDefPtr sysinfo;
virDomainRedirFilterDefPtr redirfilter;
virDomainRNGDefPtr rng;
+ virDomainPanicDefPtr panic;
void *namespaceData;
virDomainXMLNamespace ns;
@@ -2193,6 +2202,7 @@ virDomainObjPtr virDomainObjListFindByName(const 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.8.5.1