Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2016 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5cdbc18974f88d6ea9e0 to your computer and use it in GitHub Desktop.
Save anonymous/5cdbc18974f88d6ea9e0 to your computer and use it in GitHub Desktop.
#!/bin/bash -
i=0
while [ $# -gt 0 ]; do
case "$1" in
-append)
shift;
CMDLINE="$1";
shift;;
*)
args[i]="$1"
(( i++ ))
shift ;;
esac
done
set -x
if [ -z "$CMDLINE" ]; then
exec kvm "${args[@]}"
fi
CMDLINE="root=9proot rootfstype=9p rootflags=trans=virtio,version=9p2000.L,cache=loose $CMDLINE"
sudo mkdir -p /mnt/guestfs
sudo mount -o loop /var/tmp/.guestfs-1000/appliance.d/root /mnt/guestfs
exec kvm \
-fsdev local,id=root,path=/mnt/guestfs/,security_model=none \
-device virtio-9p-pci,fsdev=root,mount_tag=9proot \
--append "$CMDLINE" "${args[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment