conf: Extend device types handled by virDomainDeviceDefParse

Not all device types are currently parsed in virDomainDeviceDefParse,
Since all needed functions do exist, nothing holds us back to make the
implementation complete. Similarly, the virDomainDeviceDefFree needs to
be updated as well.
This commit is contained in:
Michal Privoznik 2013-07-11 11:20:34 +02:00
parent 46a46563ca
commit b63ea46761

View File

@ -1756,13 +1756,23 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_RNG:
virDomainRNGDefFree(def->data.rng); virDomainRNGDefFree(def->data.rng);
break; break;
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_CHR:
virDomainChrDefFree(def->data.chr);
break;
case VIR_DOMAIN_DEVICE_FS:
virDomainFSDefFree(def->data.fs);
break;
case VIR_DOMAIN_DEVICE_SMARTCARD:
virDomainSmartcardDefFree(def->data.smartcard);
break;
case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_MEMBALLOON:
virDomainMemballoonDefFree(def->data.memballoon);
break;
case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_NVRAM:
virDomainNVRAMDefFree(def->data.nvram);
break;
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_NONE:
break; break;
} }
@ -9388,6 +9398,29 @@ virDomainDeviceDefParse(const char *xmlStr,
dev->type = VIR_DOMAIN_DEVICE_RNG; dev->type = VIR_DOMAIN_DEVICE_RNG;
if (!(dev->data.rng = virDomainRNGDefParseXML(node, ctxt, flags))) if (!(dev->data.rng = virDomainRNGDefParseXML(node, ctxt, flags)))
goto error; goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "channel") ||
xmlStrEqual(node->name, BAD_CAST "console") ||
xmlStrEqual(node->name, BAD_CAST "parallel") ||
xmlStrEqual(node->name, BAD_CAST "serial")) {
dev->type = VIR_DOMAIN_DEVICE_CHR;
if (!(dev->data.chr = virDomainChrDefParseXML(ctxt,
node,
def->seclabels,
def->nseclabels,
flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "smartcard")) {
dev->type = VIR_DOMAIN_DEVICE_SMARTCARD;
if (!(dev->data.smartcard = virDomainSmartcardDefParseXML(node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "memballoon")) {
dev->type = VIR_DOMAIN_DEVICE_MEMBALLOON;
if (!(dev->data.memballoon = virDomainMemballoonDefParseXML(node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "nvram")) {
dev->type = VIR_DOMAIN_DEVICE_NVRAM;
if (!(dev->data.nvram = virDomainNVRAMDefParseXML(node, flags)))
goto error;
} else { } else {
virReportError(VIR_ERR_XML_ERROR, "%s", _("unknown device type")); virReportError(VIR_ERR_XML_ERROR, "%s", _("unknown device type"));
goto error; goto error;