mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
conf: cpu: Fix parsing of vendor_id
This patch fixes a problem that vendor_id attribute can not be defined when fallback attribute is not defined. If I define domain xml like below: <domain> <cpu> <model vendor_id='aaaabbbbcccc'>core2duo</model> </cpu> </domain> In dumpxml, vendor_id is not reflected: <domain> <cpu mode='custom' match='exact'> <model fallback='allow'>core2duo</model> </cpu> </domain> The expected output is: <domain> <cpu mode='custom' match='exact'> <model fallback='allow' vendor_id='aaaabbbbcccc'>core2duo</model> </cpu> </domain> If the fallback attribute and vendor_id attribute is defined at the same time, it's reflected as expected. Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
This commit is contained in:
parent
77d3a80974
commit
1190a82469
@ -300,32 +300,32 @@ virCPUDefParseXML(const xmlNodePtr node,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (virXPathBoolean("boolean(./model[1]/@vendor_id)", ctxt)) {
|
if (virXPathBoolean("boolean(./model[1]/@vendor_id)", ctxt)) {
|
||||||
char *vendor_id;
|
char *vendor_id;
|
||||||
|
|
||||||
vendor_id = virXPathString("string(./model[1]/@vendor_id)",
|
vendor_id = virXPathString("string(./model[1]/@vendor_id)",
|
||||||
ctxt);
|
ctxt);
|
||||||
if (!vendor_id ||
|
if (!vendor_id ||
|
||||||
strlen(vendor_id) != VIR_CPU_VENDOR_ID_LENGTH) {
|
strlen(vendor_id) != VIR_CPU_VENDOR_ID_LENGTH) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("vendor_id must be exactly"
|
_("vendor_id must be exactly"
|
||||||
" %d characters long"),
|
" %d characters long"),
|
||||||
VIR_CPU_VENDOR_ID_LENGTH);
|
VIR_CPU_VENDOR_ID_LENGTH);
|
||||||
|
VIR_FREE(vendor_id);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
/* ensure that the string can be passed to qemu*/
|
||||||
|
for (i = 0; i < strlen(vendor_id); i++) {
|
||||||
|
if (vendor_id[i]==',') {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("vendor id is invalid"));
|
||||||
VIR_FREE(vendor_id);
|
VIR_FREE(vendor_id);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* ensure that the string can be passed to qemu*/
|
|
||||||
for (i = 0; i < strlen(vendor_id); i++) {
|
|
||||||
if (vendor_id[i]==',') {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("vendor id is invalid"));
|
|
||||||
VIR_FREE(vendor_id);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def->vendor_id = vendor_id;
|
|
||||||
}
|
}
|
||||||
|
def->vendor_id = vendor_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user