devices: filesystem: Fix default virtiofs accessmode

We shouldn't use accessmode=mapped here, libvirt rejects it.
Let libvirt fill in a working default

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2022-02-19 09:23:47 -05:00
parent 72b7dcaceb
commit d65d31cea2
3 changed files with 23 additions and 9 deletions

View File

@ -522,6 +522,11 @@
<source dir="/foo/source"/>
<target dir="/bar/target"/>
</filesystem>
<filesystem type="mount">
<source dir="/foo1"/>
<target dir="/bar1"/>
<driver type="virtiofs"/>
</filesystem>
<interface type="user">
<source portgroup="foo"/>
<mac address="12:34:56:78:11:22"/>

View File

@ -695,6 +695,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--filesystem type=block,source.dev=/dev/foo,target.dir=/
--filesystem type=ram,source.usage=1024,source.units=MiB,target=/
--filesystem /foo/source,/bar/target,fmode=0123,dmode=0345
--filesystem /foo1,/bar1,driver.type=virtiofs
--soundhw default

View File

@ -135,14 +135,22 @@ class DeviceFilesystem(Device):
def set_defaults(self, guest):
ignore = guest
if self.conn.is_qemu() or self.conn.is_lxc() or self.conn.is_test():
# type=mount is the libvirt default. But hardcode it
# here since we need it for the accessmode check
if self.type is None:
self.type = self.TYPE_MOUNT
if not (self.conn.is_qemu() or
self.conn.is_lxc() or
self.conn.is_test()):
return
# libvirt qemu defaults to accessmode=passthrough, but that
# really only works well for qemu running as root, which is
# not the common case. so use mode=mapped
if self.accessmode is None:
# type=mount is the libvirt default. But hardcode it since other
# bits like validation depend on it
if self.type is None:
self.type = self.TYPE_MOUNT
if self.accessmode is None:
if self.driver_type == "virtiofs":
# let libvirt fill in default accessmode=passthrough
pass
else:
# libvirt qemu defaults to accessmode=passthrough, but that
# really only works well for qemu running as root, which is
# not the common case. so use mode=mapped
self.accessmode = self.MODE_MAPPED