cli: Advertise the --host-device option as --hostdev

It annoys me that all the other CLI options map to the libvirt XML name,
except this one. Of course, keep the old option around for back compat,
just give precendence to the new option.
This commit is contained in:
Cole Robinson 2014-09-20 14:29:34 -04:00
parent 5bbd46a070
commit 5130d959e5
4 changed files with 20 additions and 17 deletions

View File

@ -993,31 +993,31 @@ 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>
=item --host-device=HOSTDEV
=item --hostdev=HOSTDEV, --host-device=HOSTDEV
Attach a physical host device to the guest. Some example values for HOSTDEV:
=over 2
=item B<--host-device pci_0000_00_1b_0>
=item B<--hostdev pci_0000_00_1b_0>
A node device name via libvirt, as shown by 'virsh nodedev-list'
=item B<--host-device 001.003>
=item B<--hostdev 001.003>
USB by bus, device (via lsusb).
=item B<--host-device 0x1234:0x5678>
=item B<--hostdev 0x1234:0x5678>
USB by vendor, product (via lsusb).
=item B<--host-device 1f.01.02>
=item B<--hostdev 1f.01.02>
PCI device (via lspci).
=back
Use --host-device=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsHostDev>
Use --hostdev=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsHostDev>
=item --sound MODEL

View File

@ -204,7 +204,7 @@ Before defining or updating the domain, show the generated XML diff and interact
=item --console
=item --host-device
=item --hostdev
=item --sound
@ -299,11 +299,11 @@ Change disk 'hda' IO to native and use startup policy as 'optional'.
Change all host devices to use driver_name=vfio for VM 'fedora20' on the remote connection
# virt-xml --connect qemu+ssh://remotehost/system \
fedora20 --edit all --host-device driver_name=vfio
fedora20 --edit all --hostdev driver_name=vfio
Hotplug host USB device 001.003 to running domain 'fedora19':
# virt-xml f19 --add-device --host-device 001.003 --update
# virt-xml f19 --add-device --hostdev 001.003 --update
Add a spicevmc channel to the domain 'winxp', that will be available after the next VM shutdown.

View File

@ -559,7 +559,7 @@ c.add_compare("""--hvm --pxe \
--blkiotune weight=200,device_path=/dev/sdc,device_weight=300 \
--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10 \
--boot loader=/foo/bar \
--host-device net_00_1c_25_10_b1_e4,boot_order=4,rom_bar=off \
--hostdev net_00_1c_25_10_b1_e4,boot_order=4,rom_bar=off \
--features acpi=off,eoi=on,privnet=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234 \
--clock offset=localtime,hpet_present=no,rtc_tickpolicy=merge \
--pm suspend_to_mem=yes,suspend_to_disk=no \
@ -729,7 +729,7 @@ c.add_valid("--redirdev usb,type=tcp,server=127.0.0.1:4002") # Different host s
c = vinst.add_category("hostdev", "--noautoconsole --nographics --nodisks --pxe")
c.add_valid("--host-device usb_device_781_5151_2004453082054CA1BEEE") # Host dev by libvirt name
c.add_valid("--host-device 001.003 --host-device 15:0.1 --host-device 2:15:0.2 --host-device 0:15:0.3 --host-device 0x0781:0x5151,driver_name=vfio --host-device 04b3:4485") # Many hostdev parsing types
c.add_valid("--host-device 001.003 --hostdev 15:0.1 --host-device 2:15:0.2 --hostdev 0:15:0.3 --host-device 0x0781:0x5151,driver_name=vfio --host-device 04b3:4485") # Many hostdev parsing types
c.add_invalid("--host-device 1d6b:2") # multiple USB devices with identical vendorId and productId
c.add_invalid("--host-device pci_8086_2850_scsi_host_scsi_host") # Unsupported hostdev type
c.add_invalid("--host-device foobarhostdev") # Unknown hostdev

View File

@ -562,9 +562,12 @@ def add_device_options(devg, sound_back_compat=False):
devg.add_argument("--console", action="append",
help=_("Configure a text console connection between "
"the guest and host"))
devg.add_argument("--host-device", action="append",
help=_("Configure physical host devices attached to the "
"guest"))
devg.add_argument("--hostdev", action="append",
help=_("Configure physical USB/PCI/etc host devices "
"to be shared with the guest"))
# Back compat name
devg.add_argument("--host-device", action="append", dest="hostdev",
help=argparse.SUPPRESS)
# --sound used to be a boolean option, hence the nargs handling
sound_kwargs = {
@ -904,7 +907,7 @@ class VirtCLIParser(object):
These values should be set by subclasses in _init_params
@cli_arg_name: The command line argument this maps to, so
"host-device" for --host-device
"hostdev" for --hostdev
@guest: Will be set parse(), the toplevel Guest object
@remove_first: Passed to VirtOptionString
@check_none: If the parsed option string is just 'none', return None
@ -2060,7 +2063,7 @@ class ParserSound(VirtCLIParser):
#########################
# --host-device parsing #
# --hostdev parsing #
#########################
class ParserHostdev(VirtCLIParser):
@ -2152,7 +2155,7 @@ def build_parser_map(options, skip=None, only=None):
register_parser("filesystem", ParserFilesystem)
register_parser("video", ParserVideo)
register_parser("sound", ParserSound)
register_parser("host-device", ParserHostdev)
register_parser("hostdev", ParserHostdev)
register_parser("panic", ParserPanic)
return parsermap