On 5/23/22 3:08 PM, Michal Privoznik wrote:
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 85aae73873..44ab79c1f0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1942,7 +1942,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDef *def)
const char *virDomainInputDefGetPath(virDomainInputDef *input)
{
- switch ((virDomainInputType) input->type) {
+ switch (input->type) {
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
case VIR_DOMAIN_INPUT_TYPE_TABLET:
case VIR_DOMAIN_INPUT_TYPE_KBD:
@@ -11818,70 +11818,54 @@ virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
virDomainInputDef *def;
- g_autofree char *type = NULL;
- g_autofree char *bus = NULL;
- g_autofree char *model = NULL;
+ virDomainInputBus bus = VIR_DOMAIN_INPUT_BUS_PS2;
xmlNodePtr source = NULL;
def = g_new0(virDomainInputDef, 1);
ctxt->node = node;
- type = virXMLPropString(node, "type");
- bus = virXMLPropString(node, "bus");
- model = virXMLPropString(node, "model");
-
- if (!type) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("missing input device type"));
- goto error;
- }
-
- if ((def->type = virDomainInputTypeFromString(type)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown input device type '%s'"), type);
+ if (virXMLPropEnum(node, "type",
+ virDomainInputTypeFromString,
+ VIR_XML_PROP_REQUIRED,
+ &def->type) < 0)
goto error;
- }
- if (model &&
- ((def->model = virDomainInputModelTypeFromString(model)) < 0 ||
- def->model == VIR_DOMAIN_INPUT_MODEL_DEFAULT)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown input model '%s'"), model);
+ if (virXMLPropEnum(node, "model",
+ virDomainInputModelTypeFromString,
+ VIR_XML_PROP_NONZERO,
+ &def->model) < 0)
goto error;
- }
-
- if (bus) {
- if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown input bus type '%s'"), bus);
- goto error;
- }
- } else {
- if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
- def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
- (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
- def->bus = VIR_DOMAIN_INPUT_BUS_PS2;
- } else if (ARCH_IS_S390(dom->os.arch) ||
- def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
- def->bus = VIR_DOMAIN_INPUT_BUS_VIRTIO;
- } else if (def->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
- def->bus = VIR_DOMAIN_INPUT_BUS_NONE;
- } else {
- def->bus = VIR_DOMAIN_INPUT_BUS_USB;
- }
- } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN ||
- dom->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
- def->bus = VIR_DOMAIN_INPUT_BUS_XEN;
+ if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+ if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
+ (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
+ bus = VIR_DOMAIN_INPUT_BUS_PS2;
+ } else if (ARCH_IS_S390(dom->os.arch) ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
+ bus = VIR_DOMAIN_INPUT_BUS_VIRTIO;
+ } else if (def->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
+ bus = VIR_DOMAIN_INPUT_BUS_NONE;
} else {
- if ((dom->virtType == VIR_DOMAIN_VIRT_VZ ||
- dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
- def->bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
+ bus = VIR_DOMAIN_INPUT_BUS_USB;
}
+ } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ dom->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
+ bus = VIR_DOMAIN_INPUT_BUS_XEN;
+ } else {
+ if ((dom->virtType == VIR_DOMAIN_VIRT_VZ ||
+ dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
+ bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
}
+ if (virXMLPropEnumDefault(node, "bus",
+ virDomainInputBusTypeFromString,
+ VIR_XML_PROP_NONE,
+ &def->bus, bus) < 0)
+ goto error;
+
+
One empty line should be sufficient.
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt,
&def->info, flags) < 0)
goto error;
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294