From 8e1cdf2cd7160722c896c6ab26f3b1982a4522ae Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 12 May 2019 08:54:36 -0400 Subject: [PATCH] cli: --controller: use predictable cli subarg names To match the XML schema, rename these subarguments and add aliases to preserve compatibility: * driver_queues -> driver.queues * master -> master.startport --- man/virt-install.pod | 24 ++---------------------- virtinst/cli.py | 21 +++++++++++++++------ virtinst/devices/controller.py | 3 ++- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/man/virt-install.pod b/man/virt-install.pod index ba11aa82..a81a412f 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -1081,6 +1081,8 @@ Controller also supports the special values B and B to specify which version of the USB controller should be used (version 2 or 3). +Some example suboptions: + =over 4 =item B @@ -1101,28 +1103,6 @@ The preferred method for setting this is using the address.* parameters. A decimal integer describing in which order the bus controller is encountered, and to reference the controller bus. -=item B - -Applicable to USB companion controllers, to define the master bus startport. - -=back - -Examples: - -=over 4 - -=item B<--controller usb,model=ich9-ehci1,address=0:0:4.0,index=0> - -Adds a ICH9 EHCI1 USB controller on PCI address 0:0:4.0 - -=item B<--controller usb,model=ich9-uhci2,address=0:0:4.7,index=0,master=2> - -Adds a ICH9 UHCI2 USB companion controller for the previous master -controller, ports start from port number 2. - -The parameter multifunction='on' will be added automatically to the -proper device (if needed). This applies to all PCI devices. - =back Use --controller=? to see a list of all available sub options. Complete details at L diff --git a/virtinst/cli.py b/virtinst/cli.py index 0c076072..12925a20 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -2781,9 +2781,10 @@ class ParserController(VirtCLIParser): cli_arg_name = "controller" guest_propname = "devices.controller" remove_first = "type" - - def set_server_cb(self, inst, val, virtarg): - inst.address.set_addrstr(val) + aliases = { + "master.startport": "master", + "driver.queues": "driver_queues", + } def _parse(self, inst): if self.optstr == "usb2": @@ -2792,6 +2793,14 @@ class ParserController(VirtCLIParser): return DeviceController.get_usb3_controller(inst.conn, self.guest) return super()._parse(inst) + + ################### + # Option handling # + ################### + + def set_address_cb(self, inst, val, virtarg): + inst.address.set_addrstr(val) + @classmethod def _init_class(cls, **kwargs): VirtCLIParser._init_class(**kwargs) @@ -2799,11 +2808,11 @@ class ParserController(VirtCLIParser): cls.add_arg("type", "type") cls.add_arg("model", "model") cls.add_arg("index", "index") - cls.add_arg("master", "master_startport") - cls.add_arg("driver_queues", "driver_queues") cls.add_arg("maxGrantFrames", "maxGrantFrames") + cls.add_arg("master.startport", "master_startport") + cls.add_arg("driver.queues", "driver_queues") - cls.add_arg("address", None, lookup_cb=None, cb=cls.set_server_cb) + cls.add_arg("address", None, lookup_cb=None, cb=cls.set_address_cb) ################### diff --git a/virtinst/devices/controller.py b/virtinst/devices/controller.py index 9d95f42b..39107be1 100644 --- a/virtinst/devices/controller.py +++ b/virtinst/devices/controller.py @@ -88,7 +88,8 @@ class DeviceController(Device): return ctrl - _XML_PROP_ORDER = ["type", "index", "model", "master_startport", "driver_queues", "maxGrantFrames"] + _XML_PROP_ORDER = ["type", "index", "model", "master_startport", + "driver_queues", "maxGrantFrames"] type = XMLProperty("./@type") model = XMLProperty("./@model")