diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml index 23ee0fcd..eee26cc9 100644 --- a/tests/cli-test-xml/compare/virt-install-many-devices.xml +++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml @@ -149,7 +149,7 @@
- + @@ -157,6 +157,10 @@ + + + + diff --git a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml index 9d35eafe..0694ece3 100644 --- a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml +++ b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml @@ -81,7 +81,7 @@ /usr/bin/qemu-kvm - + @@ -201,7 +201,7 @@ /usr/bin/qemu-kvm - + diff --git a/tests/clitest.py b/tests/clitest.py index 544a1b11..b9bb9491 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -498,8 +498,9 @@ c.add_compare(""" \ --hostdev usb_5_20 --hostdev usb_5_21 \ \ ---filesystem /source,/target,accessmode=squash \ +--filesystem /source,/target \ --filesystem template_name,/,type=template,mode=passthrough \ +--filesystem type=file,source=/tmp/somefile.img,target=/mount/point,accessmode=squash \ \ --soundhw default \ --sound ac97 \ diff --git a/virtinst/devicefilesystem.py b/virtinst/devicefilesystem.py index 33be9c2c..951b7165 100644 --- a/virtinst/devicefilesystem.py +++ b/virtinst/devicefilesystem.py @@ -76,7 +76,7 @@ class VirtualFilesystem(VirtualDevice): # In case of qemu for default fs type (mount) target is not # actually a directory, it is merely a arbitrary string tag # that is exported to the guest as a hint for where to mount - if (self.conn.is_qemu() and + if ((self.conn.is_qemu() or self.conn.is_test()) and (self.type is None or self.type == self.TYPE_DEFAULT or self.type == self.TYPE_MOUNT)): @@ -111,5 +111,20 @@ class VirtualFilesystem(VirtualDevice): return setattr(self, self._type_to_source_prop(), val) source = property(_get_source, _set_source) + def set_defaults(self, guest): + ignore = guest + + if self.conn.is_qemu() or self.conn.is_test(): + # type=mount is the libvirt qemu default. But hardcode it + # here since we need it for the accessmode check + if self.type is None or self.type == self.TYPE_DEFAULT: + self.type = self.TYPE_MOUNT + + # 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 or self.accessmode == self.MODE_DEFAULT: + self.accessmode = self.MODE_MAPPED + VirtualFilesystem.register_type()