fak*_*ake 13 linux mount filesystems qemu
我的问题是我的设备树中的网络设备不是很稳定,所以我认为在 qemu 和主机系统之间共享文件夹的最佳方法是在双方没有缓存的情况下安装相同的 img 但 qemu 上的 -hda 选项没有/dev/ 中可用的高清。
这是我运行的命令。
./qemu-xilinx/arm-softmmu/qemu-system-arm -M xilinx-zynq-a9 -m 1024 -serial null -serial mon:stdio -dtb resources/devicetree.dtb -kernel resources/zImage -initrd resources.qemu/ramdisk.img -nographic -s
Run Code Online (Sandbox Code Playgroud)
所以问题是:有没有办法避免联网,但在 qemu 和主机之间有一个共享目录?
编辑:我编译
./configure --target-list="arm-softmmu,microblazeel-softmmu" --enable-fdt --disable-kvm --enable-virtfs
Run Code Online (Sandbox Code Playgroud)
这应该启用任何需要的东西。但是当我跑
./qemu-xilinx/arm-softmmu/qemu-system-arm -M xilinx-zynq-a9 -m 1024 -serial null -serial mon:stdio -dtb /homes/cperivol/Sandbox/xilinx-zynq-bootstrap/resources/devicetree.dtb -kernel /homes/cperivol/Sandbox/xilinx-zynq-bootstrap/resources/zImage -initrd /homes/cperivol/Sandbox/xilinx-zynq-bootstrap/resources.qemu/ramdisk.img -nographic -s -fsdev local,path=/homes/cperivol/Sandbox/xilinx-zynq-bootstrap/qemu-sandbox/,security_model=passthrough,id=host0 -device virtio-9p-pci,fsdev=host0,mount_tag=host_tag0
Run Code Online (Sandbox Code Playgroud)
或者
./qemu-xilinx/arm-softmmu/qemu-system-arm -M xilinx-zynq-a9 -m 1024 -serial null -serial mon:stdio -dtb resources/devicetree.dtb -kernel resources/zImage -initrd resources.qemu/ramdisk.img -nographic -s -virtfs local,path=/homes/cperivol/Sandbox/xilinx-zynq-bootstrap/qemu-sandbox/,mount_tag=host0,security_model=passthrough,id=host0
Run Code Online (Sandbox Code Playgroud)
我得到
No 'PCI' bus found for device 'virtio-9p-pci'
Run Code Online (Sandbox Code Playgroud)
也许我还应该提到,在arm-softmmu/config-devices.mak那里CONFIG_PCI=y,果然 pci 的目标文件在hw/pci.
EDIT2:查看 qemu 转储的设备树,模拟系统不包括 PCI 总线。
(qemu) info qtree
bus: main-system-bus
type System
dev: xlnx.ps7-dev-cfg, id ""
irq 1
mmio 00000000f8007000/000000000000011c
dev: pl330, id ""
gpio-in 32
num_chnls = 8
num_periph_req = 4
num_events = 16
mgr_ns_at_rst = 0
i-cache_len = 4
num_i-cache_lines = 8
boot_addr = 0
INS = 0
PNS = 0
data_width = 64
wr_cap = 8
wr_q_dep = 16
rd_cap = 8
rd_q_dep = 16
data_buffer_dep = 256
irq 17
mmio 00000000f8003000/0000000000001000
dev: generic-sdhci, id ""
capareg = 0x5780080
maxcurr = 0x0
irq 1
mmio 00000000e0101000/0000000000000100
dev: generic-sdhci, id ""
capareg = 0x5780080
maxcurr = 0x0
irq 1
mmio 00000000e0100000/0000000000000100
dev: cadence_gem, id ""
mac = 52:54:00:12:34:56
vlan = 0
netdev = hub0port0
bootindex = -1
irq 1
mmio 00000000e000b000/0000000000000640
dev: cadence_ttc, id ""
irq 3
mmio 00000000f8002000/0000000000001000
dev: cadence_ttc, id ""
irq 3
mmio 00000000f8001000/0000000000001000
dev: cadence_uart, id ""
irq 1
mmio 00000000e0001000/0000000000001000
dev: cadence_uart, id ""
irq 1
mmio 00000000e0000000/0000000000001000
dev: xlnx.ps7-qspi, id ""
num-busses = 2
num-ss-bits = 1
num-txrx-bytes = 4
irq 3
mmio 00000000e000d000/0000000000000100
mmio 00000000fc000000/0000000002000000
bus: spi1
type SSI
dev: n25q128, id ""
gpio-in 1
bus: spi0
type SSI
dev: n25q128, id ""
gpio-in 1
dev: xlnx.ps7-spi, id ""
num-busses = 1
num-ss-bits = 4
num-txrx-bytes = 1
irq 5
mmio 00000000e0007000/0000000000000100
bus: spi0
type SSI
dev: n25q128, id ""
gpio-in 1
dev: n25q128, id ""
gpio-in 1
dev: n25q128, id ""
gpio-in 1
dev: n25q128, id ""
gpio-in 1
dev: xlnx.ps7-spi, id ""
num-busses = 1
num-ss-bits = 4
num-txrx-bytes = 1
irq 5
mmio 00000000e0006000/0000000000000100
bus: spi0
type SSI
dev: n25q128, id ""
gpio-in 1
dev: n25q128, id ""
gpio-in 1
dev: n25q128, id ""
gpio-in 1
dev: n25q128, id ""
gpio-in 1
dev: xlnx,ps7-usb, id "zynq-usb-1"
maxframes = 128
irq 1
mmio 00000000e0003000/0000000000001000
bus: zynq-usb-1.0
type usb-bus
dev: xlnx,ps7-usb, id "zynq-usb-0"
maxframes = 128
irq 1
mmio 00000000e0002000/0000000000001000
bus: zynq-usb-0.0
type usb-bus
dev: xlnx.ps7-i2c, id ""
irq 1
mmio 00000000e0005000/000000000000002c
bus: i2c
type i2c-bus
dev: pca9548, id ""
chip-enable = 0
address = 0
address-range = 128
reg = 0
bus: i2c@7
type i2c-bus
bus: i2c@6
type i2c-bus
bus: i2c@5
type i2c-bus
bus: i2c@4
type i2c-bus
bus: i2c@3
type i2c-bus
dev: at.24c08, id ""
size = 1024
address = 84
address-range = 4
reg = 84
dev: at.24c08, id ""
size = 1024
address = 80
address-range = 4
reg = 80
bus: i2c@2
type i2c-bus
dev: at.24c08, id ""
size = 1024
address = 84
address-range = 4
reg = 84
dev: at.24c08, id ""
size = 1024
address = 80
address-range = 4
reg = 80
bus: i2c@1
type i2c-bus
bus: i2c@0
type i2c-bus
dev: xlnx.ps7-i2c, id ""
irq 1
mmio 00000000e0004000/000000000000002c
bus: i2c
type i2c-bus
dev: pca9548, id ""
chip-enable = 0
address = 0
address-range = 128
reg = 0
bus: i2c@7
type i2c-bus
bus: i2c@6
type i2c-bus
bus: i2c@5
type i2c-bus
bus: i2c@4
type i2c-bus
bus: i2c@3
type i2c-bus
dev: at.24c08, id ""
size = 1024
address = 84
address-range = 4
reg = 84
dev: at.24c08, id ""
size = 1024
address = 80
address-range = 4
reg = 80
bus: i2c@2
type i2c-bus
dev: at.24c08, id ""
size = 1024
address = 84
address-range = 4
reg = 84
dev: at.24c08, id ""
size = 1024
address = 80
address-range = 4
reg = 80
bus: i2c@1
type i2c-bus
bus: i2c@0
type i2c-bus
dev: arm_mptimer, id ""
num-cpu = 1
irq 1
mmio ffffffffffffffff/0000000000000020
mmio ffffffffffffffff/0000000000000020
dev: arm_mptimer, id ""
num-cpu = 1
irq 1
mmio ffffffffffffffff/0000000000000020
mmio ffffffffffffffff/0000000000000020
dev: a9-scu, id ""
num-cpu = 1
irq 0
mmio ffffffffffffffff/0000000000000100
dev: arm_gic, id ""
gpio-in 96
num-cpu = 1
num-irq = 96
revision = 1
irq 1
mmio ffffffffffffffff/0000000000001000
mmio ffffffffffffffff/0000000000000100
mmio ffffffffffffffff/0000000000000100
dev: a9mpcore_priv, id ""
gpio-in 64
num-cpu = 1
num-irq = 96
irq 1
mmio 00000000f8f00000/0000000000002000
dev: xilinx,zynq_slcr, id ""
irq 0
mmio 00000000f8000000/0000000000001000
dev: nand, id ""
manufacturer_id = 32
chip_id = 170
drive = <null>
irq 0
dev: cfi.pflash02, id ""
drive = <null>
num-blocks = 512
sector-length = 131072
width = 1
mappings = 1
big-endian = 0
id0 = 102
id1 = 34
id2 = 0
id3 = 0
unlock-addr0 = 2730
unlock-addr1 = 1365
name = "pl353.pflash"
irq 0
mmio ffffffffffffffff/0000000004000000
dev: arm.pl35x, id ""
x = 3
irq 0
mmio 00000000e000e000/0000000000001000
mmio 00000000e2000000/0000000001000000
mmio 00000000e1000000/0000000001000000
Run Code Online (Sandbox Code Playgroud)
pil*_*ona 18
如果来宾支持 9p(例如 Linux,当然还有 Plan 9)和 virtio,请尝试添加以下开关。
-virtfs local,path=/path/to/share,mount_tag=host0,security_model=passthrough,id=host0
Run Code Online (Sandbox Code Playgroud)
您可能想要更改 security_model 参数。请参见手册页 qemu(1)。如果我没记错的话, mount_tag 是客人看到的,将 id 留作假人。
如果您正在 chroot,请确保路径在 chroot 下。它是主机上目录的路径。
来宾上的 fstab 条目应如下所示。
host0 /wherever 9p trans=virtio,version=9p2000.L 0 0
Run Code Online (Sandbox Code Playgroud)
要么将它添加到您的 fstab,要么手动调用适当的命令或使用您的 init 系统,无论它是什么。
适用于 x86_64、arm 和 aarch64 的极简工作 9P Buildroot 设置
我创建了一个高度自动化的 Buildroot 工作设置,它可能会帮助您区分为什么您的方法不起作用。
主要成分是:
内核设置:
CONFIG_9P_FS=y
CONFIG_9P_FS_POSIX_ACL=y
CONFIG_9P_FS_SECURITY=y
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_NET_9P=y
CONFIG_NET_9P_DEBUG=y
CONFIG_NET_9P_VIRTIO=y
Run Code Online (Sandbox Code Playgroud)
对于 aarch64,还要添加:
CONFIG_PCI=y
CONFIG_PCI_HOST_COMMON=y
CONFIG_PCI_HOST_GENERIC=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_BLK=y
CONFIG_VIRTIO_NET=y
Run Code Online (Sandbox Code Playgroud)
如果您忘记添加 aarch64 配置并mount失败:
mount: mounting host0 on /mnt/my9p failed: Invalid argument
Run Code Online (Sandbox Code Playgroud)
和 dmesg 抱怨:
9pnet_virtio: no channels available for device
Run Code Online (Sandbox Code Playgroud)
我的 fstab 条目和 QEMU 命令与在以下位置解释的完全一样:https : //superuser.com/a/628381/128124
手动挂载命令为:
mkdir /mnt/my9p
mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/my9p
Run Code Online (Sandbox Code Playgroud)
host0QEMU CLI 上指定的标签在哪里。
作为参考,我完整的 QEMU 命令行是:x86:
./buildroot/output.x86_64~/host/usr/bin/qemu-system-x86_64 \
-m 128M \
-monitor telnet::45454,server,nowait \
-netdev user,hostfwd=tcp::45455-:45455,id=net0 \
-smp 1 \
-virtfs local,path=/host/path/to/share,mount_tag=host0,security_model=mapped,id=host0 \
-M pc \
-append 'root=/dev/vda nopat nokaslr norandmaps printk.devkmsg=on printk.time=y' \
-device edu \
-device lkmc_pci_min \
-device virtio-net-pci,netdev=net0 \
-kernel ./buildroot/output.x86_64~/images/bzImage \
-drive file='./buildroot/output.x86_64~/images/rootfs.ext2.qcow2,if=virtio,format=qcow2'
Run Code Online (Sandbox Code Playgroud)
手臂:
./buildroot/output.arm~/host/usr/bin/qemu-system-arm -m 128M -monitor telnet::45454,server,nowait -netdev user,hostfwd=tcp::45455-:45455,id=net0 -smp 1 -virtfs local,path=/host/path/to/share,mount_tag=host0,security_model=mapped,id=host0 -M versatilepb -append 'root=/dev/sda nokaslr norandmaps printk.devkmsg=on printk.time=y' -device rtl8139,netdev=net0 -dtb ./buildroot/output.arm~/images/versatile-pb.dtb -kernel ./buildroot/output.arm~/images/zImage -serial stdio -drive file='./buildroot/output.arm~/images/rootfs.ext2.qcow2,if=scsi,format=qcow2'
Run Code Online (Sandbox Code Playgroud)
aarch64:
./buildroot/output.aarch64~/host/usr/bin/qemu-system-aarch64 -m 128M -monitor telnet::45454,server,nowait -netdev user,hostfwd=tcp::45455-:45455,id=net0 -smp 1 -virtfs local,path=/host/path/to/share,mount_tag=host0,security_model=mapped,id=host0 -M virt -append 'root=/dev/sda nokaslr norandmaps printk.devkmsg=on printk.time=y' -cpu cortex-a57 -device virtio-net-device,netdev=net0 -kernel ./buildroot/output.aarch64~/images/Image -nographic -serial stdio
Run Code Online (Sandbox Code Playgroud)
在 QEMU 2.11 和来宾 Linux 内核 4.15 上测试。
然后我还在 Ubuntu 18.04 上进行了测试,它刚刚工作:https : //askubuntu.com/questions/884534/how-to-run-ubuntu-desktop-on-qemu/1046792#1046792
| 归档时间: |
|
| 查看次数: |
39324 次 |
| 最近记录: |