feat: Support file sharing (#198)
This commit is contained in:
parent
85acaee0f4
commit
462fcfdf75
3 changed files with 51 additions and 2 deletions
17
readme.md
17
readme.md
|
@ -276,6 +276,23 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu-arm/refs/heads/mas
|
|||
- /dev/bus/usb
|
||||
```
|
||||
|
||||
### How do I share files with the host?
|
||||
|
||||
To share files with the host, first ensure that your guest OS has `9pfs` support compiled in or available as a kernel module. If so, add the following volume to your compose file:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./example:/shared
|
||||
```
|
||||
|
||||
Then start the container and execute the following command in the guest:
|
||||
|
||||
```shell
|
||||
mount -t 9p -o trans=virtio shared /mnt/example
|
||||
```
|
||||
|
||||
Now the `./example` directory on the host will be available as `/mnt/example` in the guest.
|
||||
|
||||
### How can I provide custom arguments to QEMU?
|
||||
|
||||
You can create the `ARGUMENTS` environment variable to provide additional arguments to QEMU at runtime:
|
||||
|
|
|
@ -17,7 +17,14 @@ MAC_OPTS="-machine type=${MACHINE},secure=${SECURE},dump-guest-core=off${KVM_OPT
|
|||
[ -n "$UUID" ] && MAC_OPTS="$MAC_OPTS -uuid $UUID"
|
||||
DEV_OPTS="-object rng-random,id=objrng0,filename=/dev/urandom"
|
||||
DEV_OPTS+=" -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0"
|
||||
[[ "${BOOT_MODE,,}" != "windows"* ]] && DEV_OPTS+=" -device virtio-balloon-pci,id=balloon0,bus=pcie.0"
|
||||
|
||||
if [[ "${BOOT_MODE,,}" != "windows"* ]]; then
|
||||
DEV_OPTS+=" -device virtio-balloon-pci,id=balloon0,bus=pcie.0"
|
||||
if [ -d "/shared" ]; then
|
||||
DEV_OPTS+=" -fsdev local,id=fsdev0,path=/shared,security_model=none"
|
||||
DEV_OPTS+=" -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=shared"
|
||||
fi
|
||||
fi
|
||||
|
||||
ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $DISPLAY_OPTS $MON_OPTS $SERIAL_OPTS ${USB_OPTS:-} $NET_OPTS $DISK_OPTS $BOOT_OPTS $DEV_OPTS $ARGUMENTS"
|
||||
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
|
||||
|
|
27
src/proc.sh
27
src/proc.sh
|
@ -24,7 +24,32 @@ if [[ "$CPU" == "Rockchip RK3588"* ]] && [[ "$CORES" == "8" ]]; then
|
|||
[ -z "$CPU_PIN" ] && CPU_PIN="4,5,6,7"
|
||||
fi
|
||||
|
||||
if [[ "${ARCH,,}" != "arm64" ]]; then
|
||||
MSRS="/sys/module/kvm/parameters/ignore_msrs"
|
||||
if [ -e "$MSRS" ]; then
|
||||
result=$(<"$MSRS")
|
||||
if [[ "$result" == "0" ]] || [[ "${result^^}" == "N" ]]; then
|
||||
echo 1 | tee "$MSRS" > /dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
CLOCKSOURCE="tsc"
|
||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||
|
||||
if [ ! -f "$CLOCK" ]; then
|
||||
warn "file \"$CLOCK\" cannot not found?"
|
||||
else
|
||||
result=$(<"$CLOCK")
|
||||
case "${result,,}" in
|
||||
"${CLOCKSOURCE,,}" ) ;;
|
||||
"kvm-clock" ) info "Nested KVM virtualization detected.." ;;
|
||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected.." ;;
|
||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "${ARCH,,}" != "arm64" ]]; then
|
||||
KVM="N"
|
||||
warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for ARM64 instructions, this will cause a major loss of performance."
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue