On 03/03/2017 05:39 AM, Chen Hanxiao wrote: > From: Chen Hanxiao <chenhanxiao@xxxxxxxxx> > > When adding host device, we could specify driver names, > such as vfio, xen, etc. We can, but is it important enough to expose in the UI? VFIO is preferred and we want to encourage it, which is why it's the default in libvirt for new enough qemu. Originally I decided against adding it to the UI so users weren't encouraged to just set type=kvm if vfio didn't work, so we could flush bugs out of the vfio impl. Nowadays type=kvm is even disabled in some places So unless there's a compelling reason I don't know about, I'd rather just tell users to use virt-xml if they need a non-default driver_type Thanks, Cole > > Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxx> > --- > ui/addhardware.ui | 38 ++++++++++++++++++++++++++++++++++++-- > virtManager/addhardware.py | 17 +++++++++++++++++ > virtinst/devicehostdev.py | 1 + > 3 files changed, 54 insertions(+), 2 deletions(-) > > diff --git a/ui/addhardware.ui b/ui/addhardware.ui > index 92e72c7..12c5aff 100644 > --- a/ui/addhardware.ui > +++ b/ui/addhardware.ui > @@ -1,5 +1,5 @@ > <?xml version="1.0" encoding="UTF-8"?> > -<!-- Generated with glade 3.19.0 --> > +<!-- Generated with glade 3.20.0 --> > <interface> > <requires lib="gtk+" version="3.14"/> > <object class="GtkAdjustment" id="adjustment1"> > @@ -674,7 +674,7 @@ > <object class="GtkTable" id="table3"> > <property name="visible">True</property> > <property name="can_focus">False</property> > - <property name="n_rows">2</property> > + <property name="n_rows">3</property> > <property name="column_spacing">6</property> > <property name="row_spacing">6</property> > <child> > @@ -714,6 +714,40 @@ > <property name="bottom_attach">2</property> > </packing> > </child> > + <child> > + <object class="GtkBox"> > + <property name="visible">True</property> > + <property name="can_focus">False</property> > + <child> > + <object class="GtkLabel" id="host-device-drvtname-label"> > + <property name="visible">True</property> > + <property name="can_focus">False</property> > + <property name="label" translatable="yes">Driver Name:</property> > + </object> > + <packing> > + <property name="expand">False</property> > + <property name="fill">True</property> > + <property name="position">0</property> > + </packing> > + </child> > + <child> > + <object class="GtkComboBox" id="host-device-drvname"> > + <property name="visible">True</property> > + <property name="can_focus">False</property> > + </object> > + <packing> > + <property name="expand">False</property> > + <property name="fill">True</property> > + <property name="position">1</property> > + </packing> > + </child> > + </object> > + <packing> > + <property name="top_attach">2</property> > + <property name="bottom_attach">3</property> > + <property name="y_options"/> > + </packing> > + </child> > </object> > <packing> > <property name="position">7</property> > diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py > index 7645cf9..0115361 100644 > --- a/virtManager/addhardware.py > +++ b/virtManager/addhardware.py > @@ -250,6 +250,8 @@ class vmmAddHardware(vmmGObjectUI): > host_col.add_attribute(text, 'text', 0) > host_dev_model.set_sort_column_id(0, Gtk.SortType.ASCENDING) > host_dev.append_column(host_col) > + host_dev_drvname = self.widget("host-device-drvname") > + self.build_host_device_drvname_combo(self.vm, host_dev_drvname) > > # Video device > video_dev = self.widget("video-model") > @@ -689,6 +691,17 @@ class vmmAddHardware(vmmGObjectUI): > combo.set_active(-1) > > @staticmethod > + def build_host_device_drvname_combo(vm, combo): > + ignore = vm > + model = Gtk.ListStore(str) > + combo.set_model(model) > + uiutil.init_combo_text_column(combo, 0) > + model.set_sort_column_id(0, Gtk.SortType.ASCENDING) > + > + for m in virtinst.VirtualHostDevice.DRIVER_TYPE: > + model.append([m]) > + > + @staticmethod > def populate_disk_bus_combo(vm, devtype, model): > # try to get supported disk bus types from domain capabilities > domcaps = vm.get_domain_capabilities() > @@ -1587,6 +1600,8 @@ class vmmAddHardware(vmmGObjectUI): > > def _validate_page_hostdev(self): > nodedev = uiutil.get_list_selection(self.widget("host-device"), 1) > + driver_type = uiutil.get_list_selection( > + self.widget("host-device-drvname")) > if nodedev is None: > return self.err.val_err(_("Physical Device Required"), > _("A device must be selected.")) > @@ -1607,6 +1622,8 @@ class vmmAddHardware(vmmGObjectUI): > if not res: > return False > dev.set_from_nodedev(nodedev) > + if driver_type is not None: > + dev.driver_name = driver_type > self._dev = dev > except Exception, e: > return self.err.val_err(_("Host device parameter error"), e) > diff --git a/virtinst/devicehostdev.py b/virtinst/devicehostdev.py > index 34c00b0..3955fd4 100644 > --- a/virtinst/devicehostdev.py > +++ b/virtinst/devicehostdev.py > @@ -24,6 +24,7 @@ from .xmlbuilder import XMLProperty > > class VirtualHostDevice(VirtualDevice): > virtual_device_type = VirtualDevice.VIRTUAL_DEV_HOSTDEV > + DRIVER_TYPE = [None, "kvm", "vfio", "xen"] > > def set_from_nodedev(self, nodedev): > """ > _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list