<input type='mouse' bus='virtio'/>
<input type='keyboard' bus='virtio'/>
<input type='tablet' bus='virtio'/>
+ <input type='passthrough' bus='virtio'>
+ <source evdev='/dev/input/event1/>
+ </input>
</devices>
...</pre>
<dl>
<dt><code>input</code></dt>
<dd>The <code>input</code> element has one mandatory attribute,
- the <code>type</code> whose value can be 'mouse', 'tablet' or
- (<span class="since">since 1.2.2</span>) 'keyboard'.
+ the <code>type</code> whose value can be 'mouse', 'tablet',
+ (<span class="since">since 1.2.2</span>) 'keyboard' or
+ (<span class="since">since 1.3.0</span>) 'passthrough'.
The tablet provides absolute cursor movement,
while the mouse uses relative movement. The optional
<code>bus</code> attribute can be used to refine the exact device type.
sub-element <code><address></code> which can tie the
device to a particular PCI
slot, <a href="#elementsAddress">documented above</a>.
+
+ For type <code>passthrough</code>, the mandatory sub-element <code>source</code>
+ must have an <code>evdev</code> attribute containing the absolute path to the
+ event device passed through to guests. (KVM only)
</p>
<h4><a name="elementsHub">Hub devices</a></h4>
<define name="input">
<element name="input">
- <attribute name="type">
- <choice>
- <value>tablet</value>
- <value>mouse</value>
- <value>keyboard</value>
- </choice>
- </attribute>
- <optional>
- <attribute name="bus">
- <choice>
- <value>ps2</value>
- <value>usb</value>
- <value>xen</value>
+ <choice>
+ <group>
+ <attribute name="type">
+ <choice>
+ <value>tablet</value>
+ <value>mouse</value>
+ <value>keyboard</value>
+ </choice>
+ </attribute>
+ <optional>
+ <attribute name="bus">
+ <choice>
+ <value>ps2</value>
+ <value>usb</value>
+ <value>xen</value>
+ <value>virtio</value>
+ </choice>
+ </attribute>
+ </optional>
+ </group>
+ <group>
+ <attribute name="type">
+ <value>passthrough</value>
+ </attribute>
+ <attribute name="bus">
<value>virtio</value>
- </choice>
- </attribute>
- </optional>
+ </attribute>
+ <element name="source">
+ <attribute name="evdev">
+ <ref name="absFilePath"/>
+ </attribute>
+ </element>
+ </group>
+ </choice>
<optional>
<ref name="alias"/>
</optional>
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
"mouse",
"tablet",
- "keyboard")
+ "keyboard",
+ "passthrough")
VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST,
"ps2",
return;
virDomainDeviceInfoClear(&def->info);
+ VIR_FREE(def->source.evdev);
VIR_FREE(def);
}
static virDomainInputDefPtr
virDomainInputDefParseXML(const virDomainDef *dom,
xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
unsigned int flags)
{
+ xmlNodePtr save = ctxt->node;
virDomainInputDefPtr def;
+ char *evdev = NULL;
char *type = NULL;
char *bus = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
+ ctxt->node = node;
+
type = virXMLPropString(node, "type");
bus = virXMLPropString(node, "bus");
goto error;
}
+ if ((evdev = virXPathString("string(./source/@evdev)", ctxt)))
+ def->source.evdev = virFileSanitizePath(evdev);
+ if (def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH && !def->source.evdev) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Missing evdev path for input device passthrough"));
+ goto error;
+ }
+
cleanup:
+ VIR_FREE(evdev);
VIR_FREE(type);
VIR_FREE(bus);
+ ctxt->node = save;
return def;
error:
goto error;
break;
case VIR_DOMAIN_DEVICE_INPUT:
- if (!(dev->data.input = virDomainInputDefParseXML(def,
- node, flags)))
+ if (!(dev->data.input = virDomainInputDefParseXML(def, node,
+ ctxt, flags)))
goto error;
break;
case VIR_DOMAIN_DEVICE_SOUND:
for (i = 0; i < n; i++) {
virDomainInputDefPtr input = virDomainInputDefParseXML(def,
nodes[i],
+ ctxt,
flags);
if (!input)
goto error;
virBufferAsprintf(buf, "<input type='%s' bus='%s'",
type, bus);
- if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
+ if (virDomainDeviceInfoNeedsFormat(&def->info, flags) ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
+ virBufferEscapeString(buf, "<source evdev='%s'/>\n", def->source.evdev);
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1;
virBufferAdjustIndent(buf, -2);
VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_TYPE_TABLET,
VIR_DOMAIN_INPUT_TYPE_KBD,
+ VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
VIR_DOMAIN_INPUT_TYPE_LAST
} virDomainInputType;
struct _virDomainInputDef {
int type;
int bus;
+ struct {
+ char *evdev;
+ } source;
virDomainDeviceInfo info;
};
}
virBufferAsprintf(&buf, "virtio-keyboard%s,id=%s", suffix, dev->info.alias);
break;
+ case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
+ /* TBD */
case VIR_DOMAIN_INPUT_TYPE_LAST:
break;
}
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='passthrough' bus='virtio'>
+ <source evdev='/dev/input/event1234'/>
+ </input>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
DO_TEST("video-virtio-gpu-device");
DO_TEST("video-virtio-gpu-virgl");
DO_TEST("virtio-input");
+ DO_TEST("virtio-input-passthrough");
qemuTestDriverFree(&driver);