mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
conf: use virStringParseYesNo
Use existing function built for this exact purpose. Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ea903036fa
commit
8c53938e18
@ -9203,7 +9203,7 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn,
|
||||
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];
|
||||
@ -12354,16 +12354,14 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
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 &&
|
||||
@ -13887,15 +13885,13 @@ virDomainTimerDefParseXML(xmlNodePtr node,
|
||||
|
||||
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;
|
||||
@ -18611,10 +18607,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "virxml.h"
|
||||
#include "viruuid.h"
|
||||
#include "virbuffer.h"
|
||||
#include "virstring.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_INTERFACE
|
||||
|
||||
@ -268,21 +269,19 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def,
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user