I've requested this upstream some time ago but they want to keep the
wizard simple. I wouldn't object to a Debian specific patch though, the
virtinst api has all that's needed.

Attached is a first try - an additional drop down box is
displayed in the "Advanced options" trough which the Device
Model can be modified. If the setting is kept at "Hypervisor
default", the behavior is like it always was before.

It's not that perfect as I needed to double some code (from addhardware.py) as I do not know how to access a function
from another class right now...

Cheers,
Andreas
diff -ur virt-manager.orig/virtManager/create.py virt-manager/virtManager/create.py
--- virt-manager.orig/virtManager/create.py	2009-03-24 21:29:39.000000000 +0100
+++ virt-manager/virtManager/create.py	2009-04-11 18:57:07.803530114 +0200
@@ -241,6 +241,13 @@
         net_list.add_attribute(text, 'text', 2)
         net_list.add_attribute(text, 'sensitive', 3)
 
+        netmodel_list  = self.window.get_widget("net-model")
+        netmodel_model = gtk.ListStore(str, str)
+        netmodel_list.set_model(netmodel_model)
+        text = gtk.CellRendererText()
+        netmodel_list.pack_start(text, True)
+        netmodel_list.add_attribute(text, 'text', 1)
+
         # Archtecture
         archModel = gtk.ListStore(str)
         archList = self.window.get_widget("config-arch")
@@ -466,6 +473,10 @@
             logging.exception("Generating macaddr failed: %s" % str(e))
         self.window.get_widget("config-macaddr").set_text(newmac)
 
+        netmodel = self.window.get_widget("net-model")
+        self.populate_network_model_model(netmodel.get_model())
+        netmodel.set_active(0)
+
     def populate_hv(self):
         hv_list = self.window.get_widget("config-hv")
         model = hv_list.get_model()
@@ -689,6 +700,20 @@
 
         net_list.set_active(default)
 
+    def populate_network_model_model(self, model):
+        model.clear()
+
+        # [xml value, label]
+        model.append([None, _("Hypervisor default")])
+        mod_list = [ "rtl8139", "ne2k_pci", "pcnet" ]
+        if self.capsdomain.hypervisor_type.lower() == "kvm":
+            mod_list.append("e1000")
+            mod_list.append("virtio")
+        mod_list.sort()
+
+        for m in mod_list:
+           model.append([m, m])
+
     def change_caps(self, gtype=None, dtype=None):
         (newg,
          newdom) = virtinst.CapabilitiesParser.guest_lookup(conn=self.conn.vmm,
@@ -879,6 +904,12 @@
 
         return netinfo[0], netinfo[1], macaddr.strip()
 
+    def get_config_net_model(self):
+        model = self.window.get_widget("net-model")
+        modelxml = model.get_model().get_value(model.get_active_iter(), 0)
+        modelstr = model.get_model().get_value(model.get_active_iter(), 1)
+        return modelxml, modelstr
+
     def get_config_sound(self):
         if self.conn.is_remote():
             return self.config.get_remote_sound()
@@ -1337,7 +1368,14 @@
                                           network = netname,
                                           macaddr = macaddr)
 
+            modelxml = self.get_config_net_model()[0]
+            modelstr = self.get_config_net_model()[1]
+            if modelxml != None:
+                logging.debug(_("NIC model %s (%s) selected") % (modelstr, modelxml) )
+                net.model = modelxml
+
             self.guest.nics.append(net)
+
         except Exception, e:
             return self.verr(_("Error with network parameters."), str(e))
 
Binary files virt-manager.orig/virtManager/create.pyc and virt-manager/virtManager/create.pyc differ
diff -ur virt-manager.orig/vmm-create.glade virt-manager/vmm-create.glade
--- virt-manager.orig/vmm-create.glade	2009-03-24 21:29:39.000000000 +0100
+++ virt-manager/vmm-create.glade	2009-04-11 11:36:18.247864741 +0200
@@ -1443,6 +1443,32 @@
                                             <property name="position">2</property>
                                           </packing>
                                         </child>
+                                        <!-- Device Model -->
+                                        <child>
+                                          <widget class="GtkLabel" id="label6">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="label" translatable="yes">Device Model:</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="top_attach">8</property>
+                                            <property name="bottom_attach">9</property>
+                                            <property name="x_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkComboBox" id="net-model">
+                                            <property name="visible">True</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">8</property>
+                                            <property name="bottom_attach">9</property>
+                                          </packing>
+                                        </child>
+                                      <!-- //Device Model -->
                                       </widget>
                                       <packing>
                                         <property name="expand">False</property>

Reply via email to