mirror of https://gitee.com/openkylin/libvirt.git
Introduce virDomainInputDefGetPath
Use it to denadify qemuDomainSetupInput.
This commit is contained in:
parent
74fc32a955
commit
cbf4242db7
|
@ -1404,6 +1404,22 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
|
|||
VIR_FREE(def);
|
||||
}
|
||||
|
||||
const char *virDomainInputDefGetPath(virDomainInputDefPtr input)
|
||||
{
|
||||
switch ((virDomainInputType) input->type) {
|
||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||
case VIR_DOMAIN_INPUT_TYPE_LAST:
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
|
||||
return input->source.evdev;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void virDomainInputDefFree(virDomainInputDefPtr def)
|
||||
{
|
||||
if (!def)
|
||||
|
|
|
@ -2706,6 +2706,7 @@ int virDomainObjWaitUntil(virDomainObjPtr vm,
|
|||
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
|
||||
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
|
||||
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
|
||||
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
|
||||
void virDomainInputDefFree(virDomainInputDefPtr def);
|
||||
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
|
||||
void virDomainDiskDefFree(virDomainDiskDefPtr def);
|
||||
|
|
|
@ -395,6 +395,7 @@ virDomainHypervTypeToString;
|
|||
virDomainInputBusTypeToString;
|
||||
virDomainInputDefFind;
|
||||
virDomainInputDefFree;
|
||||
virDomainInputDefGetPath;
|
||||
virDomainIOMMUModelTypeFromString;
|
||||
virDomainIOMMUModelTypeToString;
|
||||
virDomainIOThreadIDAdd;
|
||||
|
|
|
@ -9041,25 +9041,12 @@ qemuDomainSetupInput(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
|
|||
virDomainInputDefPtr input,
|
||||
const struct qemuDomainCreateDeviceData *data)
|
||||
{
|
||||
int ret = -1;
|
||||
const char *path = virDomainInputDefGetPath(input);
|
||||
|
||||
switch ((virDomainInputType) input->type) {
|
||||
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
|
||||
if (qemuDomainCreateDevice(input->source.evdev, data, false) < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
if (path && qemuDomainCreateDevice(path, data, false) < 0)
|
||||
return -1;
|
||||
|
||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||
case VIR_DOMAIN_INPUT_TYPE_LAST:
|
||||
/* nada */
|
||||
break;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue