mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virDomainObjParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f98759170e
commit
107f687128
@ -20354,7 +20354,7 @@ virDomainObjParseXML(xmlDocPtr xml,
|
|||||||
virDomainObj *obj;
|
virDomainObj *obj;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
int state;
|
virDomainState state;
|
||||||
int reason = 0;
|
int reason = 0;
|
||||||
void *parseOpaque = NULL;
|
void *parseOpaque = NULL;
|
||||||
g_autofree char *tmp = NULL;
|
g_autofree char *tmp = NULL;
|
||||||
@ -20377,17 +20377,9 @@ virDomainObjParseXML(xmlDocPtr xml,
|
|||||||
if (!obj->def)
|
if (!obj->def)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(tmp = virXMLPropString(ctxt->node, "state"))) {
|
if (virXMLPropEnum(ctxt->node, "state", virDomainStateTypeFromString,
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
VIR_XML_PROP_REQUIRED, &state) < 0)
|
||||||
"%s", _("missing domain state"));
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
if ((state = virDomainStateTypeFromString(tmp)) < 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("invalid domain state '%s'"), tmp);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
|
|
||||||
if ((tmp = virXMLPropString(ctxt->node, "reason"))) {
|
if ((tmp = virXMLPropString(ctxt->node, "reason"))) {
|
||||||
if ((reason = virDomainStateReasonFromString(state, tmp)) < 0) {
|
if ((reason = virDomainStateReasonFromString(state, tmp)) < 0) {
|
||||||
@ -20409,18 +20401,16 @@ virDomainObjParseXML(xmlDocPtr xml,
|
|||||||
if ((n = virXPathNodeSet("./taint", ctxt, &taintNodes)) < 0)
|
if ((n = virXPathNodeSet("./taint", ctxt, &taintNodes)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
char *str = virXMLPropString(taintNodes[i], "flag");
|
int rc;
|
||||||
if (str) {
|
virDomainTaintFlags taint;
|
||||||
int flag = virDomainTaintTypeFromString(str);
|
|
||||||
if (flag < 0) {
|
if ((rc = virXMLPropEnum(taintNodes[i], "flag",
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virDomainTaintTypeFromString,
|
||||||
_("Unknown taint flag %s"), str);
|
VIR_XML_PROP_NONE, &taint)) < 0)
|
||||||
VIR_FREE(str);
|
goto error;
|
||||||
goto error;
|
|
||||||
}
|
if (rc == 1)
|
||||||
VIR_FREE(str);
|
virDomainObjTaint(obj, taint);
|
||||||
virDomainObjTaint(obj, flag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virXPathNodeSet("./deprecation", ctxt, &depNodes)) < 0)
|
if ((n = virXPathNodeSet("./deprecation", ctxt, &depNodes)) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user