mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
bhyve: implement virtio-9p support
Recently virtio-9p support was added to bhyve.
On the host side it looks this way:
bhyve .... -s 25:0,virtio-9p,sharename=/path/to/shared/dir
It could also have ",ro" suffix to make share read-only.
In the Linux guest, this share is mounted with:
mount -t 9p sharename /mnt/sharename
In the guest user will see the same permissions and ownership
information for this directory as on the host. No uid/gid remapping is
supported, so those could resolve to wrong user or group names.
The same applies to the other side: chowning/chmodding in the guest will
set specified ownership and permissions on the host.
In libvirt domain XML it's modeled using the 'filesystem' element:
<filesystem type='mount'>
<source dir='/path/to/shared/dir'/>
<target dir='sharename'/>
</filesystem>
Optional 'readonly' sub-element enables read-only mode.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
10
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args
Normal file
10
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args
Normal file
@@ -0,0 +1,10 @@
|
||||
/usr/sbin/bhyve \
|
||||
-c 1 \
|
||||
-m 214 \
|
||||
-u \
|
||||
-H \
|
||||
-P \
|
||||
-s 0:0,hostbridge \
|
||||
-s 2:0,ahci,hd:/tmp/freebsd.img \
|
||||
-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
|
||||
-s 4:0,virtio-9p,/shared/dir=shared_dir,ro bhyve
|
||||
@@ -0,0 +1,3 @@
|
||||
/usr/sbin/bhyveload \
|
||||
-m 214 \
|
||||
-d /tmp/freebsd.img bhyve
|
||||
28
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.xml
Normal file
28
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<domain type='bhyve'>
|
||||
<name>bhyve</name>
|
||||
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||
<memory>219136</memory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<driver name='file' type='raw'/>
|
||||
<source file='/tmp/freebsd.img'/>
|
||||
<target dev='hda' bus='sata'/>
|
||||
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:b9:94:02'/>
|
||||
<model type='virtio'/>
|
||||
<source bridge="virbr0"/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<filesystem>
|
||||
<source dir='/shared/dir'/>
|
||||
<target dir='shared_dir'/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -0,0 +1,27 @@
|
||||
<domain type='bhyve'>
|
||||
<name>bhyve</name>
|
||||
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||
<memory>219136</memory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<driver name='file' type='raw'/>
|
||||
<source file='/tmp/freebsd.img'/>
|
||||
<target dev='hda' bus='sata'/>
|
||||
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:b9:94:02'/>
|
||||
<model type='virtio'/>
|
||||
<source bridge="virbr0"/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<filesystem accessmode='mapped'>
|
||||
<source dir='/shared/dir'/>
|
||||
<target dir='shared_dir'/>
|
||||
</filesystem>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -0,0 +1,28 @@
|
||||
<domain type='bhyve'>
|
||||
<name>bhyve</name>
|
||||
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||
<memory>219136</memory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<driver name='file' type='raw'/>
|
||||
<source file='/tmp/freebsd.img'/>
|
||||
<target dev='hda' bus='sata'/>
|
||||
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:b9:94:02'/>
|
||||
<model type='virtio'/>
|
||||
<source bridge="virbr0"/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<filesystem>
|
||||
<driver type='loop'/>
|
||||
<source dir='/shared/dir'/>
|
||||
<target dir='shared_dir'/>
|
||||
</filesystem>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -0,0 +1,27 @@
|
||||
<domain type='bhyve'>
|
||||
<name>bhyve</name>
|
||||
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||
<memory>219136</memory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<driver name='file' type='raw'/>
|
||||
<source file='/tmp/freebsd.img'/>
|
||||
<target dev='hda' bus='sata'/>
|
||||
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:b9:94:02'/>
|
||||
<model type='virtio'/>
|
||||
<source bridge="virbr0"/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<filesystem type='bind'>
|
||||
<source dir='/shared/dir'/>
|
||||
<target dir='shared_dir'/>
|
||||
</filesystem>
|
||||
</devices>
|
||||
</domain>
|
||||
10
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args
Normal file
10
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args
Normal file
@@ -0,0 +1,10 @@
|
||||
/usr/sbin/bhyve \
|
||||
-c 1 \
|
||||
-m 214 \
|
||||
-u \
|
||||
-H \
|
||||
-P \
|
||||
-s 0:0,hostbridge \
|
||||
-s 2:0,ahci,hd:/tmp/freebsd.img \
|
||||
-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
|
||||
-s 4:0,virtio-9p,/shared/dir=shared_dir bhyve
|
||||
3
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.ldargs
Normal file
3
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.ldargs
Normal file
@@ -0,0 +1,3 @@
|
||||
/usr/sbin/bhyveload \
|
||||
-m 214 \
|
||||
-d /tmp/freebsd.img bhyve
|
||||
27
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.xml
Normal file
27
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<domain type='bhyve'>
|
||||
<name>bhyve</name>
|
||||
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||
<memory>219136</memory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file'>
|
||||
<driver name='file' type='raw'/>
|
||||
<source file='/tmp/freebsd.img'/>
|
||||
<target dev='hda' bus='sata'/>
|
||||
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:b9:94:02'/>
|
||||
<model type='virtio'/>
|
||||
<source bridge="virbr0"/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<filesystem>
|
||||
<source dir='/shared/dir'/>
|
||||
<target dir='shared_dir'/>
|
||||
</filesystem>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -167,7 +167,7 @@ mymain(void)
|
||||
BHYVE_CAP_NET_E1000 | BHYVE_CAP_LPC_BOOTROM | \
|
||||
BHYVE_CAP_FBUF | BHYVE_CAP_XHCI | \
|
||||
BHYVE_CAP_CPUTOPOLOGY | BHYVE_CAP_SOUND_HDA | \
|
||||
BHYVE_CAP_VNC_PASSWORD;
|
||||
BHYVE_CAP_VNC_PASSWORD | BHYVE_CAP_VIRTIO_9P;
|
||||
|
||||
DO_TEST("base");
|
||||
DO_TEST("wired");
|
||||
@@ -208,6 +208,13 @@ mymain(void)
|
||||
DO_TEST("sound");
|
||||
DO_TEST("isa-controller");
|
||||
DO_TEST_FAILURE("isa-multiple-controllers");
|
||||
DO_TEST("fs-9p");
|
||||
DO_TEST("fs-9p-readonly");
|
||||
DO_TEST_FAILURE("fs-9p-unsupported-type");
|
||||
DO_TEST_FAILURE("fs-9p-unsupported-driver");
|
||||
DO_TEST_FAILURE("fs-9p-unsupported-accessmode");
|
||||
driver.bhyvecaps &= ~BHYVE_CAP_VIRTIO_9P;
|
||||
DO_TEST_FAILURE("fs-9p");
|
||||
|
||||
/* Address allocation tests */
|
||||
DO_TEST("addr-single-sata-disk");
|
||||
|
||||
38
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-fs-9p.xml
Normal file
38
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-fs-9p.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<domain type='bhyve'>
|
||||
<name>bhyve</name>
|
||||
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='file' type='raw'/>
|
||||
<source file='/tmp/freebsd.img'/>
|
||||
<target dev='hda' bus='sata'/>
|
||||
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
|
||||
</disk>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<controller type='sata' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</controller>
|
||||
<filesystem type='mount' accessmode='passthrough'>
|
||||
<source dir='/shared/dir'/>
|
||||
<target dir='shared_dir'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||
</filesystem>
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:b9:94:02'/>
|
||||
<source bridge='virbr0'/>
|
||||
<model type='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -112,6 +112,7 @@ mymain(void)
|
||||
DO_TEST_DIFFERENT("msrs");
|
||||
DO_TEST_DIFFERENT("sound");
|
||||
DO_TEST_DIFFERENT("isa-controller");
|
||||
DO_TEST_DIFFERENT("fs-9p");
|
||||
|
||||
/* Address allocation tests */
|
||||
DO_TEST_DIFFERENT("addr-single-sata-disk");
|
||||
|
||||
Reference in New Issue
Block a user