amluto / virtme

An easy way to virtualize the running system
GNU General Public License v2.0
330 stars 66 forks source link

`--script-exec` and `--script-sh` don't seem to work #6

Closed zevweiss closed 7 years ago

zevweiss commented 8 years ago

I can't seem to get any output with virtme-run's --script-exec or --script-sh flags. Without them I get kernel console message in my terminal as expected, but whenever I use either of these flags I get no output from either the guest kernel or my script -- or even any evidence that my script runs at all, actually. I put an infinite loop in a bash script (while :; do :; done) and passed it to --script-exec, hoping to see qemu continue to peg the CPU beyond a normal guest-boot duration, but its CPU consumption quieted down after about the same amount of time it does when booting into an interactive shell, so it seems like the script isn't getting executed.

I've tried both the cat | prefix mentioned in the --help output and < /dev/null to redirect stdin, but haven't seen any difference in behavior either way. (Using the --force-initramfs flag also hasn't made any difference, if it's relevant.)

Running with --show-command prints:

/usr/local/qemu-2.7.0/bin/qemu-system-x86_64 -fsdev local,id=virtfs1,path=/,security_model=none,readonly -device virtio-9p-pci,fsdev=virtfs1,mount_tag=/dev/root -fsdev local,id=virtfs5,path=/home/zev/src/virtme/virtme/guest,security_model=none,readonly -device virtio-9p-pci,fsdev=virtfs5,mount_tag=virtme.guesttools -fsdev local,id=virtfs9,path=/lib/modules/4.7.0-bcfs-nopreempt+,security_model=none,readonly -device virtio-9p-pci,fsdev=virtfs9,mount_tag=virtme.moddir -machine accel=kvm:tcg -watchdog i6300esb -cpu host -parallel none -net none -vga none -display none -serial none -chardev file,id=console,path=/proc/self/fd/2 -serial chardev:console -chardev stdio,id=stdio,signal=on,mux=off -device virtio-serial-pci -device virtserialport,name=virtme.scriptio,chardev=stdio -no-reboot -kernel /boot/vmlinuz-4.7.0-bcfs-nopreempt+ -append 'virtme_chdir=home/zev init=/bin/sh -- -c "mount -t tmpfs run /run;mkdir -p /run/virtme/guesttools;/bin/mount -n -t 9p -o ro,version=9p2000.L,trans=virtio,access=any virtme.guesttools /run/virtme/guesttools;exec /run/virtme/guesttools/virtme-init"' -initrd /proc/self/fd/4

and the contents of /home/zev/test-script.sh are:

#!/bin/bash
while :; do :; done

This is with python 3.5.0 and qemu 2.7.0, on a 4.7.0 kernel.

zevweiss commented 7 years ago

Fixed by pull request #7.