fsdetails: Point users to Memory screen if shared memory not enabled

If the user selects virtiofs when editting or adding a new VM, and
we don't detect that they have shared memory enabled, show
a warning label in the UI pointing them to the Memory screen.

It would be nicer if we did this for them, but to get that totally
correct would require both duplicating libvirt's shared memory
detection logic, and some surgery to the addhw wizard. This is good
enough for now

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2022-02-19 10:25:47 -05:00
parent a7682fc9eb
commit 9c0a132f2a
3 changed files with 66 additions and 11 deletions

View File

@ -588,6 +588,7 @@ def testDetailsEditDevices1(app):
def testDetailsEditDevices2(app): def testDetailsEditDevices2(app):
app.uri = tests.utils.URIs.kvm_x86
win = app.manager_open_details("test-many-devices", win = app.manager_open_details("test-many-devices",
shutdown=True) shutdown=True)
appl = win.find("config-apply", "push button") appl = win.find("config-apply", "push button")
@ -617,6 +618,9 @@ def testDetailsEditDevices2(app):
# Filesystem tweaks # Filesystem tweaks
tab = _select_hw(app, win, "Filesystem /target/", "filesystem-tab") tab = _select_hw(app, win, "Filesystem /target/", "filesystem-tab")
tab.combo_select("Driver:", "virtiofs")
w = tab.find_fuzzy("Enable shared memory", "label")
lib.utils.check(lambda: w.visible)
tab.find("Source path:", "text").set_text("/frib1") tab.find("Source path:", "text").set_text("/frib1")
tab.find("Target path:", "text").set_text("newtarget") tab.find("Target path:", "text").set_text("newtarget")
tab.find_fuzzy("Export filesystem", "check box").click() tab.find_fuzzy("Export filesystem", "check box").click()

View File

@ -7,7 +7,7 @@
<property name="step-increment">100</property> <property name="step-increment">100</property>
<property name="page-increment">1000</property> <property name="page-increment">1000</property>
</object> </object>
<!-- n-columns=2 n-rows=7 --> <!-- n-columns=2 n-rows=8 -->
<object class="GtkGrid" id="vmm-fs-details"> <object class="GtkGrid" id="vmm-fs-details">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
@ -22,7 +22,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">5</property> <property name="top-attach">6</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -37,7 +37,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">6</property> <property name="top-attach">7</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -76,7 +76,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">3</property> <property name="top-attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -118,7 +118,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">3</property> <property name="top-attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -132,7 +132,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">5</property> <property name="top-attach">6</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -145,7 +145,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">6</property> <property name="top-attach">7</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -159,7 +159,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">4</property> <property name="top-attach">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -198,7 +198,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">4</property> <property name="top-attach">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -212,7 +212,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">2</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -230,7 +230,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">2</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -269,5 +269,45 @@
<property name="top-attach">1</property> <property name="top-attach">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox" id="fs-driver-warn-box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-dialog-warning</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="fs-driver-warn">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">blah foo warning message</property>
<property name="wrap">True</property>
<property name="max-width-chars">40</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object> </object>
</interface> </interface>

View File

@ -8,6 +8,7 @@
from gi.repository import Gtk from gi.repository import Gtk
from virtinst import DeviceFilesystem from virtinst import DeviceFilesystem
from virtinst import xmlutil
from ..lib import uiutil from ..lib import uiutil
from ..baseclass import vmmGObjectUI from ..baseclass import vmmGObjectUI
@ -152,6 +153,16 @@ class vmmFSDetails(vmmGObjectUI):
uiutil.set_grid_row_visible( uiutil.set_grid_row_visible(
self.widget("fs-driver-combo"), show_driver_combo) self.widget("fs-driver-combo"), show_driver_combo)
need_shared_mem = fsdriver == "virtiofs"
have_shared_mem, _shared_mem_err = self.vm.has_shared_mem()
show_shared_mem_warn = need_shared_mem and not have_shared_mem
uiutil.set_grid_row_visible(
self.widget("fs-driver-warn-box"), show_shared_mem_warn)
if show_shared_mem_warn:
label = _(
"You may need to 'Enable shared memory' on the 'Memory' screen.")
self.widget("fs-driver-warn").set_markup(
"<small>%s</small>" % xmlutil.xml_escape(label))
############## ##############