[virt-tools-list] [PATCH 3/3] virt-manager: Add support for vsock devices to add hardware UI
Slavomir Kaslev
kaslevs at vmware.com
Thu Dec 6 19:53:12 UTC 2018
Signed-off-by: Slavomir Kaslev <kaslevs at vmware.com>
---
ui/addhardware.ui | 94 ++++++++++++++++++++++++++++++++++++++
virtManager/addhardware.py | 33 ++++++++++++-
2 files changed, 125 insertions(+), 2 deletions(-)
diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index b6ac8912..33506b76 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -17,6 +17,12 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment6">
+ <property name="lower">3</property>
+ <property name="upper">2147483647</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1569,6 +1575,94 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkGrid" id="grid4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label70">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Guest CID:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="vsock-auto">
+ <property name="label" translatable="yes">Auto</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_vsock_auto_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="vsock-cid">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">3</property>
+ <property name="input_purpose">number</property>
+ <property name="adjustment">adjustment6</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ <property name="value">3</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">12</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="grid4-atkobject">
+ <property name="AtkObject::accessible-name">panic-tab</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">17</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="vsock">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">vsock</property>
+ </object>
+ <packing>
+ <property name="position">17</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 6bb3473c..f08352e8 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -14,7 +14,7 @@ from virtinst import (DeviceChannel, DeviceConsole,
DeviceController, DeviceDisk, DeviceGraphics, DeviceHostdev,
DeviceInput, DeviceInterface, DevicePanic, DeviceParallel,
DeviceRedirdev, DeviceRng, DeviceSerial, DeviceSmartcard,
- DeviceSound, DeviceTpm, DeviceVideo, DeviceWatchdog)
+ DeviceSound, DeviceTpm, DeviceVideo, DeviceVsock, DeviceWatchdog)
from . import uiutil
from .fsdetails import vmmFSDetails
@@ -41,7 +41,8 @@ from .addstorage import vmmAddStorage
PAGE_USBREDIR,
PAGE_TPM,
PAGE_RNG,
- PAGE_PANIC) = range(0, 17)
+ PAGE_PANIC,
+ PAGE_VSOCK) = range(18)
def _build_combo(combo, values, default_value=None, sort=True):
@@ -108,6 +109,8 @@ class vmmAddHardware(vmmGObjectUI):
"on_tpm_device_type_changed": self._change_tpm_device_type,
+ "on_vsock_auto_toggled": self._vsock_auto_toggled,
+
"on_usbredir_type_changed": self._change_usbredir_type,
"on_controller_type_changed": self._change_controller_type,
@@ -287,6 +290,9 @@ class vmmAddHardware(vmmGObjectUI):
add_hw_option(_("Panic Notifier"), "system-run", PAGE_PANIC,
bool(DevicePanic.get_models(self.vm.get_xmlobj().os)),
_("Not supported for this hypervisor/libvirt/arch combination."))
+ add_hw_option(_("VM Sockets"), "network-idle", PAGE_VSOCK,
+ self.vm.is_hvm(),
+ _("Not supported for this hypervisor/libvirt/arch combination."))
def _reset_state(self):
@@ -332,6 +338,10 @@ class vmmAddHardware(vmmGObjectUI):
default_rng = "/dev/urandom"
self.widget("rng-device").set_text(default_rng)
+ # vsock params
+ self.widget("vsock-auto").set_active(True)
+ self.widget("vsock-cid").set_value(3)
+ self.widget("vsock-cid").set_visible(False)
# Remaining devices
self._fsdetails.reset_state()
@@ -803,6 +813,8 @@ class vmmAddHardware(vmmGObjectUI):
return _("Random Number Generator")
if page == PAGE_PANIC:
return _("Panic Notifier")
+ if page == PAGE_VSOCK:
+ return _("VM Sockets")
if page == PAGE_CHAR:
devclass = self._get_char_class()(self.conn.get_backend())
@@ -882,6 +894,13 @@ class vmmAddHardware(vmmGObjectUI):
uiutil.set_grid_row_visible(self.widget(widget_name + "-label"),
make_visible)
+ def _vsock_auto_toggled(self, src):
+ if not src.get_visible():
+ return
+
+ is_auto = self.widget("vsock-auto").get_active()
+ self.widget("vsock-cid").set_visible(not is_auto)
+
def _change_char_auto_socket(self, src):
if not src.get_visible():
return
@@ -1140,6 +1159,8 @@ class vmmAddHardware(vmmGObjectUI):
ret = self._validate_page_rng()
elif page_num == PAGE_PANIC:
ret = self._validate_page_panic()
+ elif page_num == PAGE_VSOCK:
+ ret = self._validate_page_vsock()
if ret is not False and self._dev:
self._dev.set_defaults(self.vm.get_xmlobj())
@@ -1411,6 +1432,14 @@ class vmmAddHardware(vmmGObjectUI):
self._dev = DevicePanic(self.conn.get_backend())
self._dev.model = model
+ def _validate_page_vsock(self):
+ auto_cid = self.widget("vsock-auto").get_active()
+ cid = self.widget("vsock-cid").get_value_as_int()
+ self._dev = DeviceVsock(self.conn.get_backend())
+ self._dev.auto_cid = auto_cid
+ if not auto_cid:
+ self._dev.cid = cid
+
def _validate_page_controller(self):
controller_type = uiutil.get_list_selection(
self.widget("controller-type"))
--
2.19.1
More information about the virt-tools-list
mailing list