mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: Split up virDomainVcpuPinDefParseXML
Extract part that parses iothreads into virDomainIothreadPinDefParseXML
This commit is contained in:
parent
06c03b48bd
commit
0532ec3faa
@ -13173,30 +13173,19 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
return idmap;
|
return idmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the XML definition for a vcpupin or emulatorpin.
|
/* Parse the XML definition for a vcpupin
|
||||||
*
|
*
|
||||||
* vcpupin has the form of
|
* vcpupin has the form of
|
||||||
* <vcpupin vcpu='0' cpuset='0'/>
|
* <vcpupin vcpu='0' cpuset='0'/>
|
||||||
*
|
|
||||||
* and emulatorpin has the form of
|
|
||||||
* <emulatorpin cpuset='0'/>
|
|
||||||
*
|
|
||||||
* and an iothreadspin has the form
|
|
||||||
* <iothreadpin iothread='1' cpuset='2'/>
|
|
||||||
*
|
|
||||||
* A vcpuid of -1 is valid and only valid for emulatorpin. So callers
|
|
||||||
* have to check the returned cpuid for validity.
|
|
||||||
*/
|
*/
|
||||||
static virDomainPinDefPtr
|
static virDomainPinDefPtr
|
||||||
virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
int maxvcpus,
|
int maxvcpus)
|
||||||
bool iothreads)
|
|
||||||
{
|
{
|
||||||
virDomainPinDefPtr def;
|
virDomainPinDefPtr def;
|
||||||
xmlNodePtr oldnode = ctxt->node;
|
xmlNodePtr oldnode = ctxt->node;
|
||||||
int vcpuid = -1;
|
int vcpuid = -1;
|
||||||
unsigned int iothreadid;
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -13205,7 +13194,6 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
|||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
if (!iothreads) {
|
|
||||||
ret = virXPathInt("string(./@vcpu)", ctxt, &vcpuid);
|
ret = virXPathInt("string(./@vcpu)", ctxt, &vcpuid);
|
||||||
if ((ret == -2) || (vcpuid < -1)) {
|
if ((ret == -2) || (vcpuid < -1)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -13224,9 +13212,48 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
def->id = vcpuid;
|
def->id = vcpuid;
|
||||||
|
|
||||||
|
if (!(tmp = virXMLPropString(node, "cpuset"))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("missing cpuset for vcpupin"));
|
||||||
|
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iothreads && (tmp = virXPathString("string(./@iothread)", ctxt))) {
|
if (virBitmapParse(tmp, 0, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(tmp);
|
||||||
|
ctxt->node = oldnode;
|
||||||
|
return def;
|
||||||
|
|
||||||
|
error:
|
||||||
|
VIR_FREE(def);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Parse the XML definition for a iothreadpin
|
||||||
|
* and an iothreadspin has the form
|
||||||
|
* <iothreadpin iothread='1' cpuset='2'/>
|
||||||
|
*/
|
||||||
|
static virDomainPinDefPtr
|
||||||
|
virDomainIOThreadPinDefParseXML(xmlNodePtr node,
|
||||||
|
xmlXPathContextPtr ctxt,
|
||||||
|
int iothreads)
|
||||||
|
{
|
||||||
|
virDomainPinDefPtr def;
|
||||||
|
xmlNodePtr oldnode = ctxt->node;
|
||||||
|
unsigned int iothreadid;
|
||||||
|
char *tmp = NULL;
|
||||||
|
|
||||||
|
if (VIR_ALLOC(def) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ctxt->node = node;
|
||||||
|
|
||||||
|
if ((tmp = virXPathString("string(./@iothread)", ctxt))) {
|
||||||
if (virStrToLong_uip(tmp, NULL, 10, &iothreadid) < 0) {
|
if (virStrToLong_uip(tmp, NULL, 10, &iothreadid) < 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("invalid setting for iothread '%s'"), tmp);
|
_("invalid setting for iothread '%s'"), tmp);
|
||||||
@ -13240,11 +13267,9 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NB: maxvcpus is actually def->iothreads
|
/* IOThreads are numbered "iothread1...iothread<n>", where
|
||||||
* IOThreads are numbered "iothread1...iothread<n>", where
|
* "n" is the iothreads value */
|
||||||
* "n" is the iothreads value
|
if (iothreadid > iothreads) {
|
||||||
*/
|
|
||||||
if (iothreadid > maxvcpus) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("iothread id must not exceed iothreads"));
|
_("iothread id must not exceed iothreads"));
|
||||||
goto error;
|
goto error;
|
||||||
@ -13254,13 +13279,8 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(node, "cpuset"))) {
|
if (!(tmp = virXMLPropString(node, "cpuset"))) {
|
||||||
if (iothreads)
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("missing cpuset for iothreadpin"));
|
_("missing cpuset for iothreadpin"));
|
||||||
else
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("missing cpuset for vcpupin"));
|
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13285,6 +13305,7 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Parse the XML definition for emulatorpin.
|
/* Parse the XML definition for emulatorpin.
|
||||||
* emulatorpin has the form of
|
* emulatorpin has the form of
|
||||||
* <emulatorpin cpuset='0'/>
|
* <emulatorpin cpuset='0'/>
|
||||||
@ -14011,7 +14032,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
virDomainPinDefPtr vcpupin = NULL;
|
virDomainPinDefPtr vcpupin = NULL;
|
||||||
vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
|
vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
|
||||||
def->maxvcpus, false);
|
def->maxvcpus);
|
||||||
|
|
||||||
if (!vcpupin)
|
if (!vcpupin)
|
||||||
goto error;
|
goto error;
|
||||||
@ -14098,9 +14119,8 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
virDomainPinDefPtr iothreadpin = NULL;
|
virDomainPinDefPtr iothreadpin = NULL;
|
||||||
iothreadpin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
|
iothreadpin = virDomainIOThreadPinDefParseXML(nodes[i], ctxt,
|
||||||
def->iothreads,
|
def->iothreads);
|
||||||
true);
|
|
||||||
if (!iothreadpin)
|
if (!iothreadpin)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user