labelskip = virXMLPropString(list[i], "labelskip");
seclabels[i]->labelskip = false;
if (labelskip && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
- seclabels[i]->labelskip = STREQ(labelskip, "yes");
+ ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->labelskip));
VIR_FREE(labelskip);
ctxt->node = list[i];
goto error;
if (managed_tap) {
- if (STREQ(managed_tap, "no")) {
- def->managed_tap = VIR_TRISTATE_BOOL_NO;
- } else if (STREQ(managed_tap, "yes")) {
- def->managed_tap = VIR_TRISTATE_BOOL_YES;
- } else {
+ bool state = false;
+ if (virStringParseYesNo(managed_tap, &state) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid 'managed' value '%s'"),
managed_tap);
goto error;
}
+ def->managed_tap = virTristateBoolFromBool(state);
}
if (def->managed_tap != VIR_TRISTATE_BOOL_NO && ifname &&
def->present = -1; /* unspecified */
if ((present = virXMLPropString(node, "present")) != NULL) {
- if (STREQ(present, "yes")) {
- def->present = 1;
- } else if (STREQ(present, "no")) {
- def->present = 0;
- } else {
+ bool state = false;
+ if (virStringParseYesNo(present, &state) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown timer present value '%s'"), present);
goto error;
}
+ def->present = state ? 1 : 0;
}
def->tickpolicy = -1;
if ((node = virXPathNode("./os/bios[1]", ctxt))) {
tmp = virXMLPropString(node, "useserial");
if (tmp) {
- if (STREQ(tmp, "yes"))
- def->os.bios.useserial = VIR_TRISTATE_BOOL_YES;
- else
- def->os.bios.useserial = VIR_TRISTATE_BOOL_NO;
+ bool state = false;
+ ignore_value(virStringParseYesNo(tmp, &state));
+ def->os.bios.useserial = virTristateBoolFromBool(state);
VIR_FREE(tmp);
}
#include "virxml.h"
#include "viruuid.h"
#include "virbuffer.h"
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_INTERFACE
def->dhcp = 1;
save = ctxt->node;
ctxt->node = dhcp;
+ def->peerdns = -1;
/* Not much to do in the current version */
tmp = virXPathString("string(./@peerdns)", ctxt);
if (tmp) {
- if (STREQ(tmp, "yes")) {
- def->peerdns = 1;
- } else if (STREQ(tmp, "no")) {
- def->peerdns = 0;
- } else {
+ bool state = false;
+ if (virStringParseYesNo(tmp, &state) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown dhcp peerdns value %s"), tmp);
ret = -1;
+ } else {
+ def->peerdns = state ? 1 : 0;
}
VIR_FREE(tmp);
- } else {
- def->peerdns = -1;
}
ctxt->node = save;