1. 程式人生 > 實用技巧 >kata virtio-9p-pci

kata virtio-9p-pci

qemu啟動引數需要新增:

-fsdev local,security_model=passthrough,id=fsdev0,path=/tmp/share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare


然後提示:
'virtio-9p-pci' is not a valid device model name


需要重新編譯qemu,編譯時新增額外的configure引數:
--enable-virtfs

編譯安裝qemu後,再執行,可以了。


在guest中掛載host共享的目錄:

mkdir /tmp/host_files
mount -t 9p -o trans=virtio,version=9p2000.L hostshare /tmp/host_files

提示:
mount: unknown filesystem type '9p'

需要在kernel中新增9p的支援:
CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=y
CONFIG_NET_9P_DEBUG=y (Optional)
CONFIG_9P_FS=y
CONFIG_9P_FS_POSIX_ACL=y


然後就可以使用了,如果再加上virtio console的支援,那麼既有shell,又可以傳輸檔案,基本可以代替adb的常用功能了。

參考:

qemu啟動命令:http://www.linux-kvm.org/page/9p_virtio

kernel配置:http://wiki.qemu.org/Documentation/9psetup

qemu新增configure選項:https://groups.google.com/forum/#!topic/coreos-dev/MjhL3tOOAVM

/usr/share/kata-containers/binary/qemu-system-aarch64  -machine virt,usb=off,accel=kvm,gic-version=host,nvdimm -cpu host,pmu=off  -smp 2 -m 4096M  -kernel /usr/share/kata-containers/binary/vmlinuz-5.4.34-88   -nographic   -append "root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0  ignore_loglevel
" -initrd /usr/share/kata-containers/binary/kata-containers.img -fsdev local,security_model=passthrough,id=fsdev0,path=./nfsroot -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare