details: ADD checkbox to plug/unplug network interface

Hardware Details -> NIC of every VM should now contain checkbox for
interface's link state. This checkbox edits domain's XML by changing
<link state='up/down'/>. If XML doesn't contain this tag, virt manager
assumes state "up".

https://bugzilla.redhat.com/show_bug.cgi?id=1614532

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
This commit is contained in:
Simon Kobyda 2018-08-16 17:30:31 +02:00 committed by Pavel Hrdina
parent cab540792f
commit ef4e0dbc4f
3 changed files with 44 additions and 2 deletions

View File

@ -4014,6 +4014,35 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="network-link-state-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Link _state:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">network_link_state_checkbox</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="network-link-state-checkbox">
<property name="label" translatable="yes">active</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_network_link_state_checkbox_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -69,6 +69,7 @@ from .graphwidgets import Sparkline
EDIT_NET_VPORT,
EDIT_NET_SOURCE,
EDIT_NET_MAC,
EDIT_NET_LINKSTATE,
EDIT_GFX_PASSWD,
EDIT_GFX_TYPE,
@ -93,7 +94,7 @@ from .graphwidgets import Sparkline
EDIT_FS,
EDIT_HOSTDEV_ROMBAR) = range(1, 50)
EDIT_HOSTDEV_ROMBAR) = range(1, 51)
# Columns in hw list model
@ -545,6 +546,9 @@ class vmmDetails(vmmGObjectUI):
"on_network_model_combo_changed": lambda *x: self.enable_apply(x, EDIT_NET_MODEL),
"on_network_mac_entry_changed": lambda *x: self.enable_apply(x,
EDIT_NET_MAC),
"on_network_link_state_checkbox_toggled": lambda *x: self.enable_apply(x,
EDIT_NET_LINKSTATE),
"on_sound_model_combo_changed": lambda *x: self.enable_apply(x,
EDIT_SOUND_MODEL),
@ -2178,6 +2182,9 @@ class vmmDetails(vmmGObjectUI):
if self.edited(EDIT_NET_MAC):
kwargs["macaddr"] = self.widget("network-mac-entry").get_text()
if self.edited(EDIT_NET_LINKSTATE):
kwargs["linkstate"] = self.widget("network-link-state-checkbox").get_active()
return vmmAddHardware.change_config_helper(self.vm.define_network,
kwargs, self.vm, self.err,
devobj=devobj)
@ -2717,6 +2724,9 @@ class vmmDetails(vmmGObjectUI):
else:
self.widget("network-mac-entry").set_text(macaddr)
state = net.link_state == "up" or net.link_state is None
self.widget("network-link-state-checkbox").set_active(state)
self.netlist.set_dev(net)
def refresh_input_page(self):

View File

@ -757,7 +757,7 @@ class vmmDomain(vmmLibvirtObject):
mode=_SENTINEL, model=_SENTINEL, addrstr=_SENTINEL,
vtype=_SENTINEL, managerid=_SENTINEL, typeid=_SENTINEL,
typeidversion=_SENTINEL, instanceid=_SENTINEL,
portgroup=_SENTINEL, macaddr=_SENTINEL):
portgroup=_SENTINEL, macaddr=_SENTINEL, linkstate=_SENTINEL):
xmlobj = self._make_xmlobj_to_define()
editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
if not editdev:
@ -787,6 +787,9 @@ class vmmDomain(vmmLibvirtObject):
if macaddr != _SENTINEL:
editdev.macaddr = macaddr
if linkstate != _SENTINEL:
editdev.link_state = "up" if linkstate else "down"
if do_hotplug:
self.hotplug(device=editdev)
else: