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
This commit is contained in:
Cole Robinson 2019-05-12 08:54:36 -04:00
parent ea63141fca
commit 8e1cdf2cd7
3 changed files with 19 additions and 29 deletions

View File

@ -1081,6 +1081,8 @@ Controller also supports the special values B<usb2> and B<usb3> to
specify which version of the USB controller should be used (version 2
or 3).
Some example suboptions:
=over 4
=item B<model>
@ -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<master>
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<https://libvirt.org/formatdomain.html#elementsControllers>

View File

@ -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)
###################

View File

@ -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")