{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
virSysinfoDef *def;
- g_autofree char *typeStr = NULL;
- int type;
ctxt->node = node;
def = g_new0(virSysinfoDef, 1);
- typeStr = virXMLPropString(node, "type");
- if (typeStr == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("sysinfo must contain a type attribute"));
- goto error;
- }
- if ((type = virSysinfoTypeFromString(typeStr)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown sysinfo type '%s'"), typeStr);
+ if (virXMLPropEnum(node, "type", virSysinfoTypeFromString,
+ VIR_XML_PROP_REQUIRED, &def->type) < 0)
goto error;
- }
- def->type = type;
switch (def->type) {
case VIR_SYSINFO_SMBIOS: