-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qemu monitor for interactive VM management #286
Comments
Great! However, you can do this much easier I think. First, the monitor is already enabled, because the default value for the
So you dont need to add one on port 55555, because one is already running on port 7100. Secondly, you dont need to go inside the machine to connect. You can add this port (7100) to the list of ports that will not be forwarded to the VM, by adding this to the compose file: environment:
HOST_PORTS: "7100,8600" Now you can connect to the IP of the container on port 7100 with your telnet client and control the monitor. |
Thanks kroese. I didn't spot that the telnet/monitor had already been enabled. Maybe another one for documentation. A few things though: 1.Port 7100 appears as "font-service" in "netstat -a" so its not easy to spot in the container with this mapping: -p 55555:7100
Is it just me or does this work for others? |
This monitor is used to send the poweroff signal for graceful shutdown, so it cannot be disabled otherwise there is no way to shutdown Windows cleanly. Also, it is not really insecure since port 7100 is not mapped in the default Dockerfile, so normally this port is not reachable from outside the container.
It worked for me last time I tried. Does it work when you dont map 55555, but just use 7100:7100 and add 7100 to |
Nope, if I map 7100:7100 then I get this: ❯ telnet 192.168.1.6 7100 So no connection refused on 7100, but also no telnet |
This would greatly improve kvm experience for me. I like to snapshot a running vm multiple times, and revert back to a given running state. |
#!/bin/bash 定义Docker容器的名称DOCKER_CONTAINERS=("qbittorrent" "nas-tools" "transmission" "xiaoyaliu" "MoviePilot") 获取当前小时(24小时制)CURRENT_HOUR=$(date +"%H") 获取当前分钟CURRENT_MINUTE=$(date +"%M") 日志文件路径LOG_FILE="/mnt/user/domains/docker_control.log" 函数:记录日志log() { 函数:清理日志cleanup_logs() { log "开始脚本执行." 如果当前时间在0点到7点59分59秒之间if [ "$CURRENT_HOUR" -ge 0 ] && [ "$CURRENT_HOUR" -lt 8 ] && [ "$CURRENT_MINUTE" -lt 60 ]; then log "脚本执行结束." 清理日志cleanup_logs DOCKER_CONTAINERS=("qbittorrent" "nas-tools" "transmission" "xiaoyaliu" "MoviePilot")你可以修改这里的,定时重启容器. 这是一个脚本. |
Seems the qemu docker image doesn't have libvirt or virsh for VM management.
However you can do some interactive management via the qemu monitor interface.
First you have to enable monitor and add an endpoint. Unix sockets is probably more secure but telnet is ok for me. Add this qemu argument to your docker startup:
-e ARGUMENTS="-monitor telnet::55555,server,nowait"
and rebuild your container.
I tried to docker port map 55555 to the host, but there is something very weird with telnet to containers. Anyway no matter we just bash straight into the container with:
We need the telnet client, so do this:
then telnet to the qemu monitor from inside the container:
Now you get the (qemu) prompt and type help for all the commands:
(qemu) help
You can add/remove devices, take snapshots, shutdown the VM etc etc Google is your friend
use ctrl+] to quit out of monitor and then "quit" at the telnet prompt and "exit" from the container bash to your host
My use case was to try and hot swap USB devices. But its super flakey and only really works for USB devices that are plugged in at container boot.
Some useful commands are:
see usb devices in VM:
(qemu) info usb
see host usb devices: (this only seems to work if you have already hooked up a host device already)
(qemu) info usbhost
add a host usb device to VM:
(qemu) device_add usb-host,id=myusb,vendorid=0x1234,productid=0x5678
remove a host usb device from VM:
(qemu) device_del myusb
Remember to eject usb storage devices in the VM OS first
Caveats:
1.Telnet is not secure.
2.You can easily wreck your VM by changing boot devices and removing devices
3.You need to install telnet into the container every time you rebuild it
4.I couldn't get telnet to connect properly by mapping ports to the host
5.I couldn't get USB devices to get recognised after ejecting them from the host after VM starts
The text was updated successfully, but these errors were encountered: