提交 0624ac3f 编写于 作者: A Andrea Bolognani

conf: Rework virDomainDeviceDefPostParseCommon()

Now that we've moved all the actual code into helper
functions, we can turn it into a switch statement.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 48dbd70e
...@@ -4966,33 +4966,72 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev, ...@@ -4966,33 +4966,72 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
unsigned int parseFlags ATTRIBUTE_UNUSED, unsigned int parseFlags ATTRIBUTE_UNUSED,
virDomainXMLOptionPtr xmlopt) virDomainXMLOptionPtr xmlopt)
{ {
if (dev->type == VIR_DOMAIN_DEVICE_CHR) int ret = -1;
return virDomainChrDefPostParse(dev->data.chr, def);
if (dev->type == VIR_DOMAIN_DEVICE_RNG) switch ((virDomainDeviceType)dev->type) {
return virDomainRNGDefPostParse(dev->data.rng); case VIR_DOMAIN_DEVICE_CHR:
ret = virDomainChrDefPostParse(dev->data.chr, def);
break;
if (dev->type == VIR_DOMAIN_DEVICE_DISK) case VIR_DOMAIN_DEVICE_RNG:
return virDomainDiskDefPostParse(dev->data.disk, def, xmlopt); ret = virDomainRNGDefPostParse(dev->data.rng);
break;
if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) case VIR_DOMAIN_DEVICE_DISK:
return virDomainVideoDefPostParse(dev->data.video, def); ret = virDomainDiskDefPostParse(dev->data.disk, def, xmlopt);
break;
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV && case VIR_DOMAIN_DEVICE_VIDEO:
virDomainHostdevDefPostParse(dev->data.hostdev, def, xmlopt) < 0) ret = virDomainVideoDefPostParse(dev->data.video, def);
return -1; break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
ret = virDomainHostdevDefPostParse(dev->data.hostdev, def, xmlopt);
break;
if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) case VIR_DOMAIN_DEVICE_CONTROLLER:
return virDomainControllerDefPostParse(dev->data.controller); ret = virDomainControllerDefPostParse(dev->data.controller);
break;
if (dev->type == VIR_DOMAIN_DEVICE_NET) case VIR_DOMAIN_DEVICE_NET:
return virDomainNetDefPostParse(dev->data.net); ret = virDomainNetDefPostParse(dev->data.net);
break;
if (dev->type == VIR_DOMAIN_DEVICE_VSOCK && case VIR_DOMAIN_DEVICE_VSOCK:
virDomainVsockDefPostParse(dev->data.vsock) < 0) ret = virDomainVsockDefPostParse(dev->data.vsock);
return -1; break;
return 0; case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
case VIR_DOMAIN_DEVICE_WATCHDOG:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_MEMORY:
case VIR_DOMAIN_DEVICE_IOMMU:
ret = 0;
break;
case VIR_DOMAIN_DEVICE_NONE:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected VIR_DOMAIN_DEVICE_NONE"));
break;
case VIR_DOMAIN_DEVICE_LAST:
default:
virReportEnumRangeError(virDomainDeviceType, dev->type);
break;
}
return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册