virt-manager: Add USB3 convenience option to the controller UI

and a --controller usb3 option to virt-install
This commit is contained in:
Cole Robinson 2013-10-03 16:34:28 -04:00
parent db6ef91b0b
commit d83b2c02fa
6 changed files with 43 additions and 33 deletions

View File

@ -865,8 +865,7 @@ guest, use '--virt-type qemu'
Attach a controller device to the guest. TYPE is one of:
B<ide>, B<fdc>, B<scsi>, B<sata>, B<virtio-serial>, or B<usb>.
Controller also supports the special value B<usb2>, which will set up
a USB2 controller with fallback USB1 support.
Controller also supports the special values B<usb2> and B<usb3>.
=over 4

View File

@ -563,7 +563,7 @@ c = vinst.add_category("controller", "--noautoconsole --nodisks --pxe")
c.add_valid("--controller usb,model=ich9-ehci1,address=0:0:4.7")
c.add_valid("--controller usb,model=ich9-ehci1,address=0:0:4.7,index=0")
c.add_valid("--controller usb,model=ich9-ehci1,address=0:0:4.7,index=1")
c.add_valid("--controller usb2")
c.add_valid("--controller usb2 --controller usb3")
c = vinst.add_category("lxc", "--connect %(LXCURI)s --noautoconsole --name foolxc --ram 64")

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.0 on Mon Sep 30 20:58:45 2013 -->
<!-- Generated with glade 3.16.0 on Thu Oct 3 16:27:46 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAccelGroup" id="accelgroup1"/>
@ -5904,13 +5904,11 @@
<property name="top_padding">3</property>
<property name="left_padding">12</property>
<child>
<object class="GtkTable" id="table14">
<object class="GtkGrid" id="table14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="label48">
<property name="visible">True</property>
@ -5919,8 +5917,10 @@
<property name="label" translatable="yes">Type:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -5932,22 +5932,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mlabel48">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Model:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -5964,11 +5951,22 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mlabel48">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Model:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>

View File

@ -3221,22 +3221,25 @@ class vmmDetails(vmmGObjectUI):
type_label = virtinst.VirtualController.pretty_type(dev.type)
model_label = dev.model
is_usb = dev.type == virtinst.VirtualController.TYPE_USB
if not model_label:
model_label = _("Default")
self.widget("controller-type").set_text(type_label)
combo = self.widget("controller-model")
uihelpers.set_grid_row_visible(combo, is_usb)
model = combo.get_model()
model.clear()
if dev.type == virtinst.VirtualController.TYPE_USB:
model.append(["Default", "Default"])
model.append(["default", "Default"])
model.append(["ich9-ehci1", "USB 2"])
model.append(["nec-xhci", "USB 3"])
self.widget("config-remove").set_sensitive(False)
else:
self.widget("config-remove").set_sensitive(True)
self.set_combo_entry("controller-model", model_label)
self.set_combo_entry("controller-model", dev.model or "default")
def refresh_filesystem_page(self):
dev = self.get_hw_selection(HW_LIST_COL_DEVICE)

View File

@ -826,6 +826,12 @@ class vmmDomain(vmmLibvirtObject):
for dev in VirtualController.get_usb2_controllers(
guest.conn):
guest.add_device(dev)
else:
dev = VirtualController(guest.conn)
dev.type = "usb"
if newmodel != "default":
dev.model = newmodel
guest.add_device(dev)
return self._redefine_device(change, devobj)

View File

@ -1553,6 +1553,10 @@ get_graphics = _make_handler(virtinst.VirtualGraphics, parse_graphics)
def parse_controller(guest, optstr, dev):
if optstr == "usb2":
return virtinst.VirtualController.get_usb2_controllers(guest.conn)
elif optstr == "usb3":
dev.type = "usb"
dev.model = "nec-xhci"
return dev
opts = parse_optstr(optstr, remove_first="type")
set_param = _build_set_param(dev, opts)