mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 18:03:32 +00:00
Move default Input bus logic to PostParse handling
A new enum type "Default" has been added for Input bus. The logic that handled default input bus types in virDomainInputParseXML() has been moved to a new function virDomainInputDefPostParse() in domain_postparse.c Link to Issue: https://gitlab.com/libvirt/libvirt/-/issues/8 Signed-off-by: K Shiva <shiva_kr@riseup.net> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
fb1bfad7ad
commit
c4bc4d3b82
@ -905,6 +905,7 @@ VIR_ENUM_IMPL(virDomainInput,
|
|||||||
|
|
||||||
VIR_ENUM_IMPL(virDomainInputBus,
|
VIR_ENUM_IMPL(virDomainInputBus,
|
||||||
VIR_DOMAIN_INPUT_BUS_LAST,
|
VIR_DOMAIN_INPUT_BUS_LAST,
|
||||||
|
"default",
|
||||||
"ps2",
|
"ps2",
|
||||||
"usb",
|
"usb",
|
||||||
"xen",
|
"xen",
|
||||||
@ -10693,7 +10694,6 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
/* Parse the XML definition for an input device */
|
/* Parse the XML definition for an input device */
|
||||||
static virDomainInputDef *
|
static virDomainInputDef *
|
||||||
virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
|
virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
|
||||||
const virDomainDef *dom,
|
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -10733,37 +10733,14 @@ virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bus) {
|
if (bus &&
|
||||||
if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) {
|
((def->bus = virDomainInputBusTypeFromString(bus)) < 0 ||
|
||||||
|
def->bus == VIR_DOMAIN_INPUT_BUS_DEFAULT)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown input bus type '%1$s'"), bus);
|
_("unknown input bus type '%1$s'"), bus);
|
||||||
goto error;
|
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;
|
|
||||||
} else {
|
|
||||||
if ((dom->virtType == VIR_DOMAIN_VIRT_VZ ||
|
|
||||||
dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
|
|
||||||
def->bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0)
|
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -13768,7 +13745,7 @@ virDomainDeviceDefParse(const char *xmlStr,
|
|||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DEVICE_INPUT:
|
case VIR_DOMAIN_DEVICE_INPUT:
|
||||||
if (!(dev->data.input = virDomainInputDefParseXML(xmlopt, def, node,
|
if (!(dev->data.input = virDomainInputDefParseXML(xmlopt, node,
|
||||||
ctxt, flags)))
|
ctxt, flags)))
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
@ -18874,7 +18851,6 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
virDomainInputDef *input = virDomainInputDefParseXML(xmlopt,
|
virDomainInputDef *input = virDomainInputDefParseXML(xmlopt,
|
||||||
def,
|
|
||||||
nodes[i],
|
nodes[i],
|
||||||
ctxt,
|
ctxt,
|
||||||
flags);
|
flags);
|
||||||
|
@ -1510,6 +1510,7 @@ typedef enum {
|
|||||||
} virDomainInputType;
|
} virDomainInputType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
VIR_DOMAIN_INPUT_BUS_DEFAULT,
|
||||||
VIR_DOMAIN_INPUT_BUS_PS2,
|
VIR_DOMAIN_INPUT_BUS_PS2,
|
||||||
VIR_DOMAIN_INPUT_BUS_USB,
|
VIR_DOMAIN_INPUT_BUS_USB,
|
||||||
VIR_DOMAIN_INPUT_BUS_XEN,
|
VIR_DOMAIN_INPUT_BUS_XEN,
|
||||||
|
@ -649,6 +649,33 @@ virDomainFSDefPostParse(virDomainFSDef *fs)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
virDomainInputDefPostParse(virDomainInputDef *input,
|
||||||
|
const virDomainDef *def)
|
||||||
|
{
|
||||||
|
if (input->bus == VIR_DOMAIN_INPUT_BUS_DEFAULT) {
|
||||||
|
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
||||||
|
if ((input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
|
||||||
|
input->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
|
||||||
|
(ARCH_IS_X86(def->os.arch) || def->os.arch == VIR_ARCH_NONE)) {
|
||||||
|
} else if (ARCH_IS_S390(def->os.arch) ||
|
||||||
|
input->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
|
||||||
|
input->bus = VIR_DOMAIN_INPUT_BUS_VIRTIO;
|
||||||
|
} else if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
|
||||||
|
input->bus = VIR_DOMAIN_INPUT_BUS_NONE;
|
||||||
|
} else {
|
||||||
|
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
||||||
|
}
|
||||||
|
} else if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
|
||||||
|
def->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
|
||||||
|
input->bus = VIR_DOMAIN_INPUT_BUS_XEN;
|
||||||
|
} else {
|
||||||
|
if ((def->virtType == VIR_DOMAIN_VIRT_VZ ||
|
||||||
|
def->virtType == VIR_DOMAIN_VIRT_PARALLELS))
|
||||||
|
input->bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainDeviceDefPostParseCommon(virDomainDeviceDef *dev,
|
virDomainDeviceDefPostParseCommon(virDomainDeviceDef *dev,
|
||||||
@ -701,6 +728,9 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef *dev,
|
|||||||
case VIR_DOMAIN_DEVICE_LEASE:
|
case VIR_DOMAIN_DEVICE_LEASE:
|
||||||
case VIR_DOMAIN_DEVICE_NET:
|
case VIR_DOMAIN_DEVICE_NET:
|
||||||
case VIR_DOMAIN_DEVICE_INPUT:
|
case VIR_DOMAIN_DEVICE_INPUT:
|
||||||
|
virDomainInputDefPostParse(dev->data.input, def);
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
case VIR_DOMAIN_DEVICE_SOUND:
|
case VIR_DOMAIN_DEVICE_SOUND:
|
||||||
case VIR_DOMAIN_DEVICE_WATCHDOG:
|
case VIR_DOMAIN_DEVICE_WATCHDOG:
|
||||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||||
|
@ -4345,6 +4345,7 @@ qemuBuildInputCommandLine(virCommand *cmd,
|
|||||||
if (!(props = qemuBuildInputVirtioDevProps(def, input, qemuCaps)))
|
if (!(props = qemuBuildInputVirtioDevProps(def, input, qemuCaps)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_DEFAULT:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PS2:
|
case VIR_DOMAIN_INPUT_BUS_PS2:
|
||||||
case VIR_DOMAIN_INPUT_BUS_XEN:
|
case VIR_DOMAIN_INPUT_BUS_XEN:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
||||||
|
@ -984,6 +984,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_DEFAULT:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PS2:
|
case VIR_DOMAIN_INPUT_BUS_PS2:
|
||||||
case VIR_DOMAIN_INPUT_BUS_USB:
|
case VIR_DOMAIN_INPUT_BUS_USB:
|
||||||
case VIR_DOMAIN_INPUT_BUS_XEN:
|
case VIR_DOMAIN_INPUT_BUS_XEN:
|
||||||
|
@ -3064,6 +3064,7 @@ qemuDomainAttachInputDevice(virDomainObj *vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_DEFAULT:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PS2:
|
case VIR_DOMAIN_INPUT_BUS_PS2:
|
||||||
case VIR_DOMAIN_INPUT_BUS_XEN:
|
case VIR_DOMAIN_INPUT_BUS_XEN:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
||||||
@ -5810,6 +5811,7 @@ qemuDomainDetachPrepInput(virDomainObj *vm,
|
|||||||
*detach = input = vm->def->inputs[idx];
|
*detach = input = vm->def->inputs[idx];
|
||||||
|
|
||||||
switch ((virDomainInputBus) input->bus) {
|
switch ((virDomainInputBus) input->bus) {
|
||||||
|
case VIR_DOMAIN_INPUT_BUS_DEFAULT:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PS2:
|
case VIR_DOMAIN_INPUT_BUS_PS2:
|
||||||
case VIR_DOMAIN_INPUT_BUS_XEN:
|
case VIR_DOMAIN_INPUT_BUS_XEN:
|
||||||
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
|
||||||
|
Loading…
Reference in New Issue
Block a user