qm monitor and shell scripts

ablock

New Member
Mar 16, 2010
8
0
1
Hi,
I want to save the state of a virtual machine with a shell script. Manually I can do this job by open a qm shell (qm monitor VMID) and then enter:

stop
migrate "exec:dd of=state.img"
cont
quit

I tried to write these commands in a file named Komma and pipe this to the qm command like: cat Komma | qm monitor 101. It didn't work.

Does anybody knows how to do the job? Maybe there are qm commands, that do the same. I found out, that qm stop makes something complete different, than the stop command in the qm shell.

Thanks
Andreas Block
 
Does anybody knows how to do the job? Maybe there are qm commands, that do the same. I found out, that qm stop makes something complete different, than the stop command in the qm shell.

pipe command into the monitor is simply not implemented (someone needs to implement it).
 
Hi,
thanks for the reply. Is there any other possibility to save a running virtual machine together with it's state, so that I can make a backup? Later it should be possible to start the virtual machine from the backup exactly in that state, I made the backup from.

A. Block
 
Hi,
thanks for the reply. Is there any other possibility to save a running virtual machine together with it's state, so that I can make a backup? Later it should be possible to start the virtual machine from the backup exactly in that state, I made the backup from.

That would be an interesting vzdump extension/feature - not implemented currently.
 
Hi,

perhaps you can try with socat command
like this script


Code:
#!/bin/bash

QEMU_MONITOR_SOCKET_PATH=/var/run/qemu-server
QEMU_MONITOR_SOCKET_EXT=mon
SOCAT=$(which socat) || { echo "socat cmd not found => exit"; exit 1; }
VMID=101
command="command you want to run in qemu monitor"

echo "${command}" | ${SOCAT} unix-connect:${QEMU_MONITOR_SOCKET_PATH}/${VMID}.${QEMU_MONITOR_SOCKET_EXT} stdio

exit 0
I hope it will help you ...
Cyril
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!