p = virXMLPropStringLimit(ctxt->node, "relabel",
VIR_SECURITY_LABEL_BUFLEN-1);
if (p) {
- if (STREQ(p, "yes")) {
- seclabel->relabel = true;
- } else if (STREQ(p, "no")) {
- seclabel->relabel = false;
- } else {
+ if (virStringParseYesNo(p, &seclabel->relabel) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid security relabel value %s"), p);
goto error;
relabel = virXMLPropString(list[i], "relabel");
if (relabel != NULL) {
- if (STREQ(relabel, "yes")) {
- seclabels[i]->relabel = true;
- } else if (STREQ(relabel, "no")) {
- seclabels[i]->relabel = false;
- } else {
+ if (virStringParseYesNo(relabel, &seclabels[i]->relabel) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid security relabel value %s"),
relabel);
ctxt->node = node;
if (fullscreen != NULL) {
- if (STREQ(fullscreen, "yes")) {
- def->data.sdl.fullscreen = true;
- } else if (STREQ(fullscreen, "no")) {
- def->data.sdl.fullscreen = false;
- } else {
+ if (virStringParseYesNo(fullscreen, &def->data.sdl.fullscreen) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown fullscreen value '%s'"), fullscreen);
goto cleanup;
VIR_AUTOFREE(char *) fullscreen = virXMLPropString(node, "fullscreen");
if (fullscreen != NULL) {
- if (STREQ(fullscreen, "yes")) {
- def->data.desktop.fullscreen = true;
- } else if (STREQ(fullscreen, "no")) {
- def->data.desktop.fullscreen = false;
- } else {
+ if (virStringParseYesNo(fullscreen, &def->data.desktop.fullscreen) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown fullscreen value '%s'"), fullscreen);
return -1;
allow = virXMLPropString(node, "allow");
if (allow) {
- if (STREQ(allow, "yes")) {
- def->allow = true;
- } else if (STREQ(allow, "no")) {
- def->allow = false;
- } else {
+ if (virStringParseYesNo(allow, &def->allow) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid allow value, either 'yes' or 'no'"));
goto error;
prop = virXPathString("string(./@ephemeral)", ctxt);
if (prop != NULL) {
- if (STREQ(prop, "yes")) {
- def->isephemeral = true;
- } else if (STREQ(prop, "no")) {
- def->isephemeral = false;
- } else {
+ if (virStringParseYesNo(prop, &def->isephemeral) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid value of 'ephemeral'"));
goto cleanup;
prop = virXPathString("string(./@private)", ctxt);
if (prop != NULL) {
- if (STREQ(prop, "yes")) {
- def->isprivate = true;
- } else if (STREQ(prop, "no")) {
- def->isprivate = false;
- } else {
+ if (virStringParseYesNo(prop, &def->isprivate) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid value of 'private'"));
goto cleanup;