[virt-tools-list] [virt-manager 7/8] addhardware: Automatically set mem access to shared for virtiofs

Lin Ma lma at suse.com
Wed Jun 30 12:11:05 UTC 2021


Signed-off-by: Lin Ma <lma at suse.com>
---
 virtManager/addhardware.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 13b899c3..463410ab 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -9,7 +9,7 @@ import traceback
 from gi.repository import Gtk
 
 from virtinst import (DeviceChannel, DeviceConsole,
-        DeviceController, DeviceDisk, DeviceHostdev,
+        DeviceController, DeviceDisk, DeviceHostdev, DeviceFilesystem,
         DeviceInput, DeviceInterface, DevicePanic, DeviceParallel,
         DeviceRedirdev, DeviceRng, DeviceSerial, DeviceSmartcard,
         DeviceSound, DeviceTpm, DeviceVideo, DeviceVsock, DeviceWatchdog)
@@ -1554,6 +1554,21 @@ class vmmAddHardware(vmmGObjectUI):
         return dev
 
     def _build_filesystem(self):
+        fsdriver = uiutil.get_list_selection(
+            self._fsdetails.widget("fs-driver-combo"))
+        if fsdriver == DeviceFilesystem.DRIVER_VIRTIOFS:
+            guest = self.vm.xmlobj
+            if guest.cpu.has_private_memAccess_cells():
+                kwargs = {}
+                kwargs["memAccess"] = "shared"
+                self.change_config_helper(self.vm.define_cpu,
+                        kwargs, self.vm, self.err)
+            elif (not guest.cpu.all_shared_memAccess_cells() and
+                  not guest.memoryBacking.is_access_shared()):
+                kwargs = {}
+                kwargs["access_mode"] = "shared"
+                self.change_config_helper(self.vm.define_memorybacking,
+                        kwargs, self.vm, self.err)
         return self._fsdetails.build_device()
 
     def _build_smartcard(self):
-- 
2.26.2





More information about the virt-tools-list mailing list