virt-install: Add --input option

For configuring VM <input> devices
This commit is contained in:
Cole Robinson 2015-04-09 13:22:40 -04:00
parent 2bf1a29f40
commit 527c49dec2
6 changed files with 36 additions and 2 deletions

View File

@ -998,6 +998,14 @@ proper device (if needed). This applies to all PCI devices.
Use --controller=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsControllers> Use --controller=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsControllers>
=item B<--input> OPTIONS
Attach an input device to the guest. Example input device types are mouse, tablet, or keyboard.
Use --input=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsInput>
=item B<--hostdev> OPTIONS =item B<--hostdev> OPTIONS
=item B<--host-device> OPTIONS =item B<--host-device> OPTIONS

View File

@ -192,6 +192,8 @@ Before defining or updating the domain, show the generated XML diff and interact
=item B<--controller> =item B<--controller>
=item B<--input>
=item B<--serial> =item B<--serial>
=item B<--parallel> =item B<--parallel>

View File

@ -174,7 +174,8 @@
</virtualport> </virtualport>
<boot order="1"/> <boot order="1"/>
</interface> </interface>
<input type="tablet" bus="usb"/> <input type="keyboard" bus="usb"/>
<input type="tablet" bus="xen"/>
<graphics type="sdl" display=":3.4" xauth="/tmp/.Xauthority"/> <graphics type="sdl" display=":3.4" xauth="/tmp/.Xauthority"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/> <graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<graphics type="vnc" port="5950" keymap="ja" listen="1.2.3.4" passwd="foo"/> <graphics type="vnc" port="5950" keymap="ja" listen="1.2.3.4" passwd="foo"/>

View File

@ -555,6 +555,9 @@ c.add_compare(""" \
--controller usb,model=ich9-uhci2,address=0:0:4.1,index=0,master=2 \ --controller usb,model=ich9-uhci2,address=0:0:4.1,index=0,master=2 \
--controller usb,model=ich9-uhci3,address=0:0:4.2,index=0,master=4 \ --controller usb,model=ich9-uhci3,address=0:0:4.2,index=0,master=4 \
\ \
--input keyboard,bus=usb \
--input type=tablet \
\
--serial tcp,host=:2222,mode=bind,protocol=telnet \ --serial tcp,host=:2222,mode=bind,protocol=telnet \
--parallel udp,host=0.0.0.0:1234,bind_host=127.0.0.1:1234 \ --parallel udp,host=0.0.0.0:1234,bind_host=127.0.0.1:1234 \
--parallel unix,path=/tmp/foo-socket \ --parallel unix,path=/tmp/foo-socket \

View File

@ -42,6 +42,7 @@ from .devicedisk import VirtualDisk
from .devicefilesystem import VirtualFilesystem from .devicefilesystem import VirtualFilesystem
from .devicegraphics import VirtualGraphics from .devicegraphics import VirtualGraphics
from .devicehostdev import VirtualHostDevice from .devicehostdev import VirtualHostDevice
from .deviceinput import VirtualInputDevice
from .deviceinterface import VirtualNetworkInterface from .deviceinterface import VirtualNetworkInterface
from .devicememballoon import VirtualMemballoon from .devicememballoon import VirtualMemballoon
from .devicepanic import VirtualPanicDevice from .devicepanic import VirtualPanicDevice
@ -574,6 +575,10 @@ def add_device_options(devg, sound_back_compat=False):
devg.add_argument("--controller", action="append", devg.add_argument("--controller", action="append",
help=_("Configure a guest controller device. Ex:\n" help=_("Configure a guest controller device. Ex:\n"
"--controller type=usb,model=ich9-ehci1")) "--controller type=usb,model=ich9-ehci1"))
devg.add_argument("--input", action="append",
help=_("Configure a guest input device. Ex:\n"
"--input tablet\n"
"--input keyboard,bus=usb"))
devg.add_argument("--serial", action="append", devg.add_argument("--serial", action="append",
help=_("Configure a guest serial device")) help=_("Configure a guest serial device"))
devg.add_argument("--parallel", action="append", devg.add_argument("--parallel", action="append",
@ -1782,6 +1787,19 @@ class ParserController(VirtCLIParser):
return VirtCLIParser._parse(self, opts, inst) return VirtCLIParser._parse(self, opts, inst)
###################
# --input parsing #
###################
class ParserInput(VirtCLIParser):
def _init_params(self):
self.devclass = VirtualInputDevice
self.remove_first = "type"
self.set_param("type", "type")
self.set_param("bus", "bus")
####################### #######################
# --smartcard parsing # # --smartcard parsing #
####################### #######################
@ -2182,6 +2200,7 @@ def build_parser_map(options, skip=None, only=None):
register_parser("network", ParserNetwork) register_parser("network", ParserNetwork)
register_parser("graphics", ParserGraphics) register_parser("graphics", ParserGraphics)
register_parser("controller", ParserController) register_parser("controller", ParserController)
register_parser("input", ParserInput)
register_parser("smartcard", ParserSmartcard) register_parser("smartcard", ParserSmartcard)
register_parser("redirdev", ParserRedir) register_parser("redirdev", ParserRedir)
register_parser("tpm", ParserTPM) register_parser("tpm", ParserTPM)

View File

@ -26,8 +26,9 @@ class VirtualInputDevice(VirtualDevice):
TYPE_MOUSE = "mouse" TYPE_MOUSE = "mouse"
TYPE_TABLET = "tablet" TYPE_TABLET = "tablet"
TYPE_KEYBOARD = "keyboard"
TYPE_DEFAULT = "default" TYPE_DEFAULT = "default"
TYPES = [TYPE_MOUSE, TYPE_TABLET, TYPE_DEFAULT] TYPES = [TYPE_MOUSE, TYPE_TABLET, TYPE_KEYBOARD, TYPE_DEFAULT]
BUS_PS2 = "ps2" BUS_PS2 = "ps2"
BUS_USB = "usb" BUS_USB = "usb"