goto error;
}
- if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
- def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
- def->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("ps2 bus does not support %s input device"),
- type);
- goto error;
- }
- if (def->bus == VIR_DOMAIN_INPUT_BUS_XEN) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported input bus %s"),
- bus);
- goto error;
- }
- } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN ||
- dom->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
- if (def->bus != VIR_DOMAIN_INPUT_BUS_XEN) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported input bus %s"),
- bus);
- goto error;
- }
- if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
- def->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("xen bus does not support %s input device"),
- type);
- goto error;
- }
- } else {
- if (dom->virtType == VIR_DOMAIN_VIRT_VZ ||
- dom->virtType == VIR_DOMAIN_VIRT_PARALLELS) {
- if (def->bus != VIR_DOMAIN_INPUT_BUS_PARALLELS) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("parallels containers don't support "
- "input bus %s"),
- bus);
- goto error;
- }
-
- if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
- def->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("parallels bus does not support "
- "%s input device"),
- type);
- goto error;
- }
- } else {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Input devices are not supported by this "
- "virtualization driver."));
- goto error;
- }
- }
} else {
if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
static int
-virDomainInputDefValidate(const virDomainInputDef *input)
+virDomainInputDefValidate(const virDomainInputDef *input,
+ const virDomainDef *def)
{
+ switch (def->os.type) {
+ case VIR_DOMAIN_OSTYPE_HVM:
+ if (input->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
+ input->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
+ input->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("ps2 bus does not support %s input device"),
+ virDomainInputTypeToString(input->type));
+ return -1;
+ }
+ if (input->bus == VIR_DOMAIN_INPUT_BUS_XEN) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unsupported input bus %s"),
+ virDomainInputBusTypeToString(input->bus));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_OSTYPE_XEN:
+ case VIR_DOMAIN_OSTYPE_XENPVH:
+ if (input->bus != VIR_DOMAIN_INPUT_BUS_XEN) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unsupported input bus %s"),
+ virDomainInputBusTypeToString(input->bus));
+ return -1;
+ }
+ if (input->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
+ input->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("xen bus does not support %s input device"),
+ virDomainInputTypeToString(input->type));
+ return -1;
+ }
+ break;
+
+ default:
+ if (def->virtType == VIR_DOMAIN_VIRT_VZ ||
+ def->virtType == VIR_DOMAIN_VIRT_PARALLELS) {
+ if (input->bus != VIR_DOMAIN_INPUT_BUS_PARALLELS) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("parallels containers don't support "
+ "input bus %s"),
+ virDomainInputBusTypeToString(input->bus));
+ return -1;
+ }
+
+ if (input->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
+ input->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("parallels bus does not support "
+ "%s input device"),
+ virDomainInputTypeToString(input->type));
+ return -1;
+ }
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Input devices are not supported by this "
+ "virtualization driver."));
+ return -1;
+ }
+ }
+
switch ((virDomainInputType) input->type) {
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
case VIR_DOMAIN_INPUT_TYPE_TABLET:
return virDomainVsockDefValidate(dev->data.vsock);
case VIR_DOMAIN_DEVICE_INPUT:
- return virDomainInputDefValidate(dev->data.input);
+ return virDomainInputDefValidate(dev->data.input, def);
case VIR_DOMAIN_DEVICE_SHMEM:
return virDomainShmemDefValidate(dev->data.shmem);