mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-13 13:17:57 +03:00
Allow user to manually specify a shared device name
This allows using remote bridge devices where netcf isn't supported.
This commit is contained in:
parent
e3a08b3264
commit
290c99110a
@ -217,7 +217,8 @@ class vmmAddHardware(gobject.GObject):
|
|||||||
|
|
||||||
# Virtual network list
|
# Virtual network list
|
||||||
net_list = self.window.get_widget("net-list")
|
net_list = self.window.get_widget("net-list")
|
||||||
uihelpers.init_network_list(net_list)
|
bridge_box = self.window.get_widget("net-bridge-box")
|
||||||
|
uihelpers.init_network_list(net_list, bridge_box)
|
||||||
|
|
||||||
# Network model list
|
# Network model list
|
||||||
netmodel_list = self.window.get_widget("net-model")
|
netmodel_list = self.window.get_widget("net-model")
|
||||||
@ -618,17 +619,12 @@ class vmmAddHardware(gobject.GObject):
|
|||||||
# Network getters
|
# Network getters
|
||||||
def get_config_network(self):
|
def get_config_network(self):
|
||||||
net_list = self.window.get_widget("net-list")
|
net_list = self.window.get_widget("net-list")
|
||||||
selection = net_list.get_active()
|
bridge_ent = self.window.get_widget("net-bridge")
|
||||||
model = net_list.get_model()
|
|
||||||
|
|
||||||
nettype = None
|
net_type, net_src = uihelpers.get_network_selection(net_list,
|
||||||
devname = None
|
bridge_ent)
|
||||||
if selection >= 0:
|
|
||||||
row = model[selection]
|
|
||||||
nettype = row[0]
|
|
||||||
devname = row[1]
|
|
||||||
|
|
||||||
return (nettype, devname)
|
return net_type, net_src
|
||||||
|
|
||||||
def get_config_net_model(self):
|
def get_config_net_model(self):
|
||||||
model = self.window.get_widget("net-model")
|
model = self.window.get_widget("net-model")
|
||||||
|
@ -269,7 +269,8 @@ class vmmCreate(gobject.GObject):
|
|||||||
# Networking
|
# Networking
|
||||||
# [ interface type, device name, label, sensitive ]
|
# [ interface type, device name, label, sensitive ]
|
||||||
net_list = self.window.get_widget("config-netdev")
|
net_list = self.window.get_widget("config-netdev")
|
||||||
uihelpers.init_network_list(net_list)
|
bridge_box = self.window.get_widget("config-netdev-bridge-box")
|
||||||
|
uihelpers.init_network_list(net_list, bridge_box)
|
||||||
|
|
||||||
# Archtecture
|
# Archtecture
|
||||||
archModel = gtk.ListStore(str)
|
archModel = gtk.ListStore(str)
|
||||||
@ -834,11 +835,14 @@ class vmmCreate(gobject.GObject):
|
|||||||
return (path, size, sparse)
|
return (path, size, sparse)
|
||||||
|
|
||||||
def get_config_network_info(self):
|
def get_config_network_info(self):
|
||||||
netidx = self.window.get_widget("config-netdev").get_active()
|
net_list = self.window.get_widget("config-netdev")
|
||||||
netinfo = self.window.get_widget("config-netdev").get_model()[netidx]
|
bridge_ent = self.window.get_widget("config-netdev-bridge")
|
||||||
macaddr = self.window.get_widget("config-macaddr").get_text()
|
macaddr = self.window.get_widget("config-macaddr").get_text()
|
||||||
|
|
||||||
return netinfo[0], netinfo[1], macaddr.strip()
|
net_type, net_src = uihelpers.get_network_selection(net_list,
|
||||||
|
bridge_ent)
|
||||||
|
|
||||||
|
return net_type, net_src, macaddr.strip()
|
||||||
|
|
||||||
def get_config_sound(self):
|
def get_config_sound(self):
|
||||||
if self.conn.is_remote():
|
if self.conn.is_remote():
|
||||||
|
@ -129,21 +129,40 @@ def pretty_network_desc(nettype, source=None, netobj=None):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def init_network_list(net_list):
|
def init_network_list(net_list, bridge_box):
|
||||||
# [ network type, source name, label, sensitive?, net is active ]
|
# [ network type, source name, label, sensitive?, net is active,
|
||||||
net_model = gtk.ListStore(str, str, str, bool, bool)
|
# manual bridge]
|
||||||
|
net_model = gtk.ListStore(str, str, str, bool, bool, bool)
|
||||||
net_list.set_model(net_model)
|
net_list.set_model(net_model)
|
||||||
|
|
||||||
if isinstance(net_list, gtk.ComboBox):
|
net_list.connect("changed", net_list_changed, bridge_box)
|
||||||
net_col = net_list
|
|
||||||
else:
|
|
||||||
net_col = gtk.TreeViewColumn()
|
|
||||||
net_list.append_column(net_col)
|
|
||||||
|
|
||||||
text = gtk.CellRendererText()
|
text = gtk.CellRendererText()
|
||||||
net_col.pack_start(text, True)
|
net_list.pack_start(text, True)
|
||||||
net_col.add_attribute(text, 'text', 2)
|
net_list.add_attribute(text, 'text', 2)
|
||||||
net_col.add_attribute(text, 'sensitive', 3)
|
net_list.add_attribute(text, 'sensitive', 3)
|
||||||
|
|
||||||
|
def net_list_changed(net_list, bridge_box):
|
||||||
|
active = net_list.get_active()
|
||||||
|
if active < 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
row = net_list.get_model()[active]
|
||||||
|
show_bridge = row[5]
|
||||||
|
|
||||||
|
bridge_box.set_property("visible", show_bridge)
|
||||||
|
|
||||||
|
def get_network_selection(net_list, bridge_entry):
|
||||||
|
row = net_list.get_model()[net_list.get_active()]
|
||||||
|
net_type = row[0]
|
||||||
|
net_src = row[1]
|
||||||
|
net_check_bridge = row[5]
|
||||||
|
|
||||||
|
if net_check_bridge:
|
||||||
|
net_type = VirtualNetworkInterface.TYPE_BRIDGE
|
||||||
|
net_src = bridge_entry.get_text()
|
||||||
|
|
||||||
|
return net_type, net_src
|
||||||
|
|
||||||
def populate_network_list(net_list, conn):
|
def populate_network_list(net_list, conn):
|
||||||
model = net_list.get_model()
|
model = net_list.get_model()
|
||||||
@ -157,12 +176,12 @@ def populate_network_list(net_list, conn):
|
|||||||
def add_row(*args):
|
def add_row(*args):
|
||||||
model.append(build_row(*args))
|
model.append(build_row(*args))
|
||||||
|
|
||||||
def build_row(nettype, name, label, is_sensitive, is_running):
|
def build_row(nettype, name, label, is_sensitive, is_running,
|
||||||
return [nettype, name, label, is_sensitive, is_running]
|
manual_bridge=False):
|
||||||
|
return [nettype, name, label, is_sensitive, is_running, manual_bridge]
|
||||||
|
|
||||||
def set_active(idx):
|
def set_active(idx):
|
||||||
if isinstance(net_list, gtk.ComboBox):
|
net_list.set_active(idx)
|
||||||
net_list.set_active(idx)
|
|
||||||
|
|
||||||
def add_dict(indict, model):
|
def add_dict(indict, model):
|
||||||
keylist = indict.keys()
|
keylist = indict.keys()
|
||||||
@ -269,9 +288,15 @@ def populate_network_list(net_list, conn):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return_warn = True
|
return_warn = True
|
||||||
model.insert(0, [None, None, _("No networking."), True, False])
|
row = build_row(None, None, _("No networking."), True, False)
|
||||||
|
model.insert(0, row)
|
||||||
default = 0
|
default = 0
|
||||||
|
|
||||||
|
# After all is said and done, add a manual bridge option
|
||||||
|
manual_row = build_row(None, None, _("Specify shared device name"),
|
||||||
|
True, False, manual_bridge=True)
|
||||||
|
model.append(manual_row)
|
||||||
|
|
||||||
set_active(default)
|
set_active(default)
|
||||||
return return_warn
|
return return_warn
|
||||||
|
|
||||||
|
@ -675,32 +675,82 @@
|
|||||||
<widget class="GtkLabel" id="label22">
|
<widget class="GtkLabel" id="label22">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="label" translatable="yes">Host device:</property>
|
<property name="yalign">0.23999999463558197</property>
|
||||||
|
<property name="label" translatable="yes">_Host device:</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="mnemonic_widget">net-list</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHBox" id="hbox6">
|
<widget class="GtkVBox" id="vbox11">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="net-list">
|
<widget class="GtkHBox" id="hbox6">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkComboBox" id="net-list">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="net-list-warn">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-dialog-warning</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkImage" id="net-list-warn">
|
<widget class="GtkAlignment" id="alignment17">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-dialog-warning</property>
|
<property name="top_padding">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="net-bridge-box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">_Bridge name:</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="mnemonic_widget">net-bridge</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="net-bridge">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="invisible_char">●</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -1538,7 +1538,17 @@ User shouldn't see this.</property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<widget class="GtkAlignment" id="alignment13">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">5</property>
|
||||||
|
<property name="bottom_attach">6</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
@ -1574,12 +1584,33 @@ User shouldn't see this.</property>
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHBox" id="hbox8">
|
<widget class="GtkVBox" id="vbox6">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="config-netdev">
|
<widget class="GtkHBox" id="hbox8">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkComboBox" id="config-netdev">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="config-netdev-warn">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-dialog-warning</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -1588,12 +1619,41 @@ User shouldn't see this.</property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkImage" id="config-netdev-warn">
|
<widget class="GtkAlignment" id="alignment21">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-dialog-warning</property>
|
<property name="top_padding">6</property>
|
||||||
|
<property name="left_padding">12</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHBox" id="config-netdev-bridge-box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label39">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">_Bridge name:</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="mnemonic_widget">config-netdev-bridge</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="config-netdev-bridge">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="invisible_char">●</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
Loading…
Reference in New Issue
Block a user