mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
f1a039ef57
commit
4313feade4
|
@ -5088,6 +5088,34 @@ qemu-kvm -net nic,model=? /dev/null
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</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>
|
<h3><a name="seclabel">Security label</a></h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -3556,6 +3556,9 @@
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="nvram"/>
|
<ref name="nvram"/>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name="panic"/>
|
||||||
|
</optional>
|
||||||
</interleave>
|
</interleave>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
@ -4415,4 +4418,11 @@
|
||||||
</data>
|
</data>
|
||||||
</choice>
|
</choice>
|
||||||
</define>
|
</define>
|
||||||
|
<define name="panic">
|
||||||
|
<element name="panic">
|
||||||
|
<optional>
|
||||||
|
<ref name="address"/>
|
||||||
|
</optional>
|
||||||
|
</element>
|
||||||
|
</define>
|
||||||
</grammar>
|
</grammar>
|
||||||
|
|
|
@ -1937,6 +1937,15 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource)
|
||||||
VIR_FREE(resource);
|
VIR_FREE(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
virDomainPanicDefFree(virDomainPanicDefPtr panic)
|
||||||
|
{
|
||||||
|
if (!panic)
|
||||||
|
return;
|
||||||
|
|
||||||
|
virDomainDeviceInfoClear(&panic->info);
|
||||||
|
VIR_FREE(panic);
|
||||||
|
}
|
||||||
|
|
||||||
void virDomainDefFree(virDomainDefPtr def)
|
void virDomainDefFree(virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
|
@ -2025,6 +2034,8 @@ void virDomainDefFree(virDomainDefPtr def)
|
||||||
|
|
||||||
virDomainTPMDefFree(def->tpm);
|
virDomainTPMDefFree(def->tpm);
|
||||||
|
|
||||||
|
virDomainPanicDefFree(def->panic);
|
||||||
|
|
||||||
VIR_FREE(def->idmap.uidmap);
|
VIR_FREE(def->idmap.uidmap);
|
||||||
VIR_FREE(def->idmap.gidmap);
|
VIR_FREE(def->idmap.gidmap);
|
||||||
|
|
||||||
|
@ -10733,6 +10744,22 @@ cleanup:
|
||||||
return idmap;
|
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.
|
/* Parse the XML definition for a vcpupin or emulatorpin.
|
||||||
*
|
*
|
||||||
|
@ -12561,6 +12588,27 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
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 */
|
/* analysis of the user namespace mapping */
|
||||||
if ((n = virXPathNodeSet("./idmap/uid", ctxt, &nodes)) < 0)
|
if ((n = virXPathNodeSet("./idmap/uid", ctxt, &nodes)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -13657,6 +13705,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
virDomainPanicCheckABIStability(virDomainPanicDefPtr src,
|
||||||
|
virDomainPanicDefPtr dst)
|
||||||
|
{
|
||||||
|
return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This compares two configurations and looks for any differences
|
/* This compares two configurations and looks for any differences
|
||||||
* which will affect the guest ABI. This is primarily to allow
|
* which will affect the guest ABI. This is primarily to allow
|
||||||
|
@ -13998,6 +14053,9 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
|
||||||
if (!virDomainRNGDefCheckABIStability(src->rng, dst->rng))
|
if (!virDomainRNGDefCheckABIStability(src->rng, dst->rng))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!virDomainPanicCheckABIStability(src->panic, dst->panic))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15861,6 +15919,16 @@ virDomainWatchdogDefFormat(virBufferPtr buf,
|
||||||
return 0;
|
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
|
static int
|
||||||
virDomainRNGDefFormat(virBufferPtr buf,
|
virDomainRNGDefFormat(virBufferPtr buf,
|
||||||
|
@ -17293,6 +17361,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
||||||
if (def->nvram)
|
if (def->nvram)
|
||||||
virDomainNVRAMDefFormat(buf, def->nvram, flags);
|
virDomainNVRAMDefFormat(buf, def->nvram, flags);
|
||||||
|
|
||||||
|
if (def->panic &&
|
||||||
|
virDomainPanicDefFormat(buf, def->panic) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
virBufferAddLit(buf, " </devices>\n");
|
virBufferAddLit(buf, " </devices>\n");
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
|
@ -126,6 +126,9 @@ typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;
|
||||||
typedef struct _virDomainIdMapDef virDomainIdMapDef;
|
typedef struct _virDomainIdMapDef virDomainIdMapDef;
|
||||||
typedef virDomainIdMapDef *virDomainIdMapDefPtr;
|
typedef virDomainIdMapDef *virDomainIdMapDefPtr;
|
||||||
|
|
||||||
|
typedef struct _virDomainPanicDef virDomainPanicDef;
|
||||||
|
typedef virDomainPanicDef *virDomainPanicDefPtr;
|
||||||
|
|
||||||
/* Flags for the 'type' field in virDomainDeviceDef */
|
/* Flags for the 'type' field in virDomainDeviceDef */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_DOMAIN_DEVICE_NONE = 0,
|
VIR_DOMAIN_DEVICE_NONE = 0,
|
||||||
|
@ -1920,6 +1923,11 @@ struct _virDomainIdMapDef {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct _virDomainPanicDef {
|
||||||
|
virDomainDeviceInfo info;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
|
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
|
||||||
int ndevices);
|
int ndevices);
|
||||||
|
|
||||||
|
@ -2071,6 +2079,7 @@ struct _virDomainDef {
|
||||||
virSysinfoDefPtr sysinfo;
|
virSysinfoDefPtr sysinfo;
|
||||||
virDomainRedirFilterDefPtr redirfilter;
|
virDomainRedirFilterDefPtr redirfilter;
|
||||||
virDomainRNGDefPtr rng;
|
virDomainRNGDefPtr rng;
|
||||||
|
virDomainPanicDefPtr panic;
|
||||||
|
|
||||||
void *namespaceData;
|
void *namespaceData;
|
||||||
virDomainXMLNamespace ns;
|
virDomainXMLNamespace ns;
|
||||||
|
@ -2214,6 +2223,7 @@ virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
|
||||||
bool virDomainObjTaint(virDomainObjPtr obj,
|
bool virDomainObjTaint(virDomainObjPtr obj,
|
||||||
enum virDomainTaintFlags taint);
|
enum virDomainTaintFlags taint);
|
||||||
|
|
||||||
|
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
|
||||||
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
|
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
|
||||||
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
|
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
|
||||||
void virDomainInputDefFree(virDomainInputDefPtr def);
|
void virDomainInputDefFree(virDomainInputDefPtr def);
|
||||||
|
|
Loading…
Reference in New Issue