From cf9577525e94ff7972edf2b03979b41abdedb95b Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 30 Dec 2017 15:11:30 -0200 Subject: Adds monitor action --- README.md | 2 +- kvmx | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d4158d..6d0eb54 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ sources, you'll feel welcome here :) KVMX currently needs a Debian-based system and the following dependencies: - sudo apt install git qemu qemu-kvm virt-viewer spice-client spice-client-gtk + sudo apt install git qemu qemu-kvm virt-viewer spice-client spice-client-gtk socat If you plan to create guest images, you may also want the following packages: diff --git a/kvmx b/kvmx index ee32862..f896815 100755 --- a/kvmx +++ b/kvmx @@ -166,6 +166,7 @@ function __kvmx_initialize { SPICELOG="$LOG_DIR/spice" XPRALOG="$LOG_DIR/xpra" XDMCPLOG="$LOG_DIR/xdmcp" + MONITORFILE="$STATE_DIR/monitor" if [ -e "$STORAGE/ssh/$VM.key" ]; then mkdir -p "$STORAGE/ssh" @@ -376,6 +377,7 @@ function kvmx_up { -device virtio-serial-pci \ -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \ -chardev spicevmc,id=spicechannel0,name=vdagent \ + -chardev "socket,id=monitor,path=$MONITORFILE,server,nowait" -mon chardev=monitor,mode=readline \ -smp $smp -soundhw ac97 -cpu host -balloon virtio \ -net nic,model=$nic_model \ -net user,hostfwd=tcp:127.0.0.1:$SSH-:22,hostfwd=udp:127.0.0.1:$XDMCP_PORT-:177$hostfwd $qemu_opts &> $LOGFILE < /dev/null & @@ -1370,6 +1372,21 @@ function kvmx_mv { kvmx_rename $* } +# Interface to QEMU monitor +function kvmx_monitor { + if ! kvmx_running; then + echo "$BASENAME: guest $VM is not running" + exit 1 + fi + + if ! which socat &> /dev/null; then + echo "$BASENAME: please install socat" + exit 1 + fi + + socat $MONITORFILE STDIO +} + # Install system function kvmx_install { if kvmx_running; then -- cgit v1.2.3