|
From: | Mario Marietto |
Subject: | How to put a qemu vm in background and hidden between the processes. |
Date: | Tue, 14 May 2024 20:14:57 +0200 |
Hello.
I would like to put the qemu / debian vm that I've created in the background early in the FreeBSD bootloader process and forget it,but I'm having some troubles. The Debian 12 vm that I need should only run a little script. It doesn't even need to run xorg and one desktop environment. This is the script that it should run as soon as the user "marietto" reached the prompt and it has automatically authenticated :
function jumpto
{
label=$1
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
eval "$cmd"
exit
}
start=${1:-"start"}
jumpto $start
start:
warp-cli disconnect
OLD_IP="$(curl -s
api.ipify.org)"
sudo iptables -A POSTROUTING -t nat -s
192.168.1.5 -j
MASQUERADE
warp-cli connect
NEW_IP="$(curl -s
api.ipify.org)"
echo Connected to Cloudflare Warp...echo OLD IP is $OLD_IP ,
NEW IP is $NEW_IP
mid :
if [ "$OLD_IP = $NEW_IP ]
then
echo OLD IP is $OLD_IP , NEW IP is $NEW_IP : it does not work
anymore,reconnecting...
sleep 10
jump foo
else
echo OLD IP is $OLD_IP , NEW IP is $NEW_IP : it still works.
sleep 10
fi
jumpto mid
foo:
warp-cli disconnect
OLD_IP="$(curl -s
api.ipify.org)"
warp-cli connect
NEW_IP="$(curl -s
api.ipify.org)"echo OLD IP is $OLD_IP ,
NEW IP is $NEW_IP : it works again.
jumpto mid
I tried in several ways to put the vm in background or better...to hide it between the processes,but every method used failed. So,please,advice
This is what I tried :
1)
nohup /usr/local/bin/qemu-system-x86_64 -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 1G \
-vga std -drive file=Debian-warp.img,format=raw \
-rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 \
-nodefaults \
-netdev tap,id=mynet0,ifname=tap20,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=52:55:00:d1:55:01
-device ich9-ahci,id=sata \
-drive if=pflash,format=raw,readonly=on,file=/usr/local/share/
edk2-qemu/QEMU_UEFI_CODE-x86_64.fd \
-drive if=pflash,format=raw,file=/usr/local/share/edk2-qemu/
QEMU_UEFI_VARS-x86_64.fd</dev/null >/dev/null 2>&1 &
if test -f nohup.out; then rm -r nohup.out
fi
2)
/usr/local/bin/qemu-system-x86_64 -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 1G -nographic \
-drive file=Debian-warp.img,format=raw \
-rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 \
-nodefaults \
-netdev tap,id=mynet0,ifname=tap20,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \
-device ich9-ahci,id=sata \
-drive if=pflash,format=raw,readonly=on,file=/usr/local/share/
edk2-qemu/QEMU_UEFI_CODE-x86_64.fd \
-drive if=pflash,format=raw,file=/usr/local/share/edk2-qemu/
QEMU_UEFI_VARS-x86_64.fd
3)
/usr/local/bin/qemu-system-x86_64 -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 1G
-display curses \
-drive file=Debian-warp.img,format=raw \
-rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 \
-nodefaults \
-netdev tap,id=mynet0,ifname=tap20,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \
-device ich9-ahci,id=sata \
-drive if=pflash,format=raw,readonly=on,file=/usr/local/share/
edk2-qemu/QEMU_UEFI_CODE-x86_64.fd \
-drive if=pflash,format=raw,file=/usr/local/share/edk2-qemu/
QEMU_UEFI_VARS-x86_64.fd
4)
nohup /usr/local/bin/qemu-system-x86_64 -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 1G -nographic \
-drive file=Debian-warp.img,format=raw \
-rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 \
-nodefaults \
-netdev tap,id=mynet0,ifname=tap20,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \
-device ich9-ahci,id=sata \
-drive if=pflash,format=raw,readonly=on,file=/usr/local/share/
edk2-qemu/QEMU_UEFI_CODE-x86_64.fd \
-drive if=pflash,format=raw,file=/usr/local/share/edk2-qemu/
QEMU_UEFI_VARS-x86_64.fd</dev/null >/dev/null 2>&1 &
if test -f nohup.out; then rm -r nohup.out
fi
5)
nohup /usr/local/bin/qemu-system-x86_64 -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 1G
-display curses \
-drive file=Debian-warp.img,format=raw \
-rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 \
-nodefaults \
-netdev tap,id=mynet0,ifname=tap20,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \
-device ich9-ahci,id=sata \
-drive if=pflash,format=raw,readonly=on,file=/usr/local/share/
edk2-qemu/QEMU_UEFI_CODE-x86_64.fd \
-drive if=pflash,format=raw,file=/usr/local/share/edk2-qemu/
QEMU_UEFI_VARS-x86_64.fd</dev/null >/dev/null 2>&1 &
if test -f nohup.out; then rm -r nohup.out
fi
The final result is always the same : when I ping the IP address
assigned to the vm,it doesn't. But it works when I boot the vm in this
way :
/usr/local/bin/qemu-system-x86_64 -machine q35 \
-cpu kvm64,hv_relaxed,hv_time,hv_synic -m 1G -vga std \
-drive file=Debian-warp.img,format=raw -rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 \
-device usb-tablet -device usb-kbd -smbios type=2 \
-nodefaults \
-netdev tap,id=mynet0,ifname=tap20,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \
-device ich9-ahci,id=sata \
-drive if=pflash,format=raw,readonly=on,file=/usr/local/share/
edk2-qemu/QEMU_UEFI_CODE-x86_64.fd \
-drive if=pflash,format=raw,file=/usr/local/share/edk2-qemu/QEMU_UEFI_VARS-x86_64.fd
[Prev in Thread] | Current Thread | [Next in Thread] |