1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

conf: add support for panic device

panic device is a device that enables libvirt to receive notification
of guest panic event.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Hu Tao 2013-12-09 17:11:14 +08:00 committed by Eric Blake
parent f1a039ef57
commit 4313feade4
4 changed files with 120 additions and 0 deletions

View File

@ -5088,6 +5088,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>

View File

@ -3556,6 +3556,9 @@
<optional>
<ref name="nvram"/>
</optional>
<optional>
<ref name="panic"/>
</optional>
</interleave>
</element>
</define>
@ -4415,4 +4418,11 @@
</data>
</choice>
</define>
<define name="panic">
<element name="panic">
<optional>
<ref name="address"/>
</optional>
</element>
</define>
</grammar>

View File

@ -1937,6 +1937,15 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource)
VIR_FREE(resource);
}
void
virDomainPanicDefFree(virDomainPanicDefPtr panic)
{
if (!panic)
return;
virDomainDeviceInfoClear(&panic->info);
VIR_FREE(panic);
}
void virDomainDefFree(virDomainDefPtr def)
{
@ -2025,6 +2034,8 @@ void virDomainDefFree(virDomainDefPtr def)
virDomainTPMDefFree(def->tpm);
virDomainPanicDefFree(def->panic);
VIR_FREE(def->idmap.uidmap);
VIR_FREE(def->idmap.gidmap);
@ -10733,6 +10744,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.
*
@ -12561,6 +12588,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;
@ -13657,6 +13705,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
@ -13998,6 +14053,9 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
if (!virDomainRNGDefCheckABIStability(src->rng, dst->rng))
return false;
if (!virDomainPanicCheckABIStability(src->panic, dst->panic))
return false;
return true;
}
@ -15861,6 +15919,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,
@ -17293,6 +17361,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);

View File

@ -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,
@ -1920,6 +1923,11 @@ struct _virDomainIdMapDef {
};
struct _virDomainPanicDef {
virDomainDeviceInfo info;
};
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
int ndevices);
@ -2071,6 +2079,7 @@ struct _virDomainDef {
virSysinfoDefPtr sysinfo;
virDomainRedirFilterDefPtr redirfilter;
virDomainRNGDefPtr rng;
virDomainPanicDefPtr panic;
void *namespaceData;
virDomainXMLNamespace ns;
@ -2214,6 +2223,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);