Bryan D. Payne
2011-Feb-10 23:54 UTC
[libvirt-users] Start domain with usable QMP connection?
Is there any way to get virsh / libvirt to create a domain such that I can later connect to it via QMP (without hacking the code)? The command line that libvirt creates for my current setup looks like this: /usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait -mon chardev=monitor,mode=control -rtc base=localtime -boot c -drive file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=16,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std -device ES1370,id=sound0,bus=pci.0,addr=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 The important pieces of this command line (I believe) are: -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait -mon chardev=monitor,mode=control However, I'm unable to connect using this path because -- I'm guessing -- libvirt has already connected. As a test, I added some code to src/qemu/qemu_command.c to open a second chardev. My new command line looks like this: /usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait -mon chardev=monitor,mode=control -chardev socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait -mon chardev=qmpmonitor,mode=control -rtc base=localtime -boot c -drive file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=15,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std -device ES1370,id=sound0,bus=pci.0,addr=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 Notice that there are now two chardevs: -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait -mon chardev=monitor,mode=control -chardev socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait -mon chardev=qmpmonitor,mode=control As expected, I am able to connect to this second chardev via QMP. Is there anyway that I can enable such functionality in libvirt without hacking the code? Thanks, bryan
? 2011?02?11? 07:54, Bryan D. Payne ??:> Is there any way to get virsh / libvirt to create a domain such that I > can later connect to it via QMP (without hacking the code)? > > The command line that libvirt creates for my current setup looks like this: > > /usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512 > -smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid > ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev > socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control -rtc base=localtime -boot c -drive > file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw > -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 > -drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw > -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 > -netdev tap,fd=16,id=hostnet0 -device > rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3 > -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb > -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std > -device ES1370,id=sound0,bus=pci.0,addr=0x4 -device > virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 > > The important pieces of this command line (I believe) are: > > -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control > > However, I'm unable to connect using this path because -- I'm guessing > -- libvirt has already connected. As a test, I added some code to > src/qemu/qemu_command.c to open a second chardev. My new command line > looks like this: > > /usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512 > -smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid > ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev > socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control -chardev > socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait > -mon chardev=qmpmonitor,mode=control -rtc base=localtime -boot c > -drive file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw > -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 > -drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw > -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 > -netdev tap,fd=15,id=hostnet0 -device > rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3 > -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb > -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std > -device ES1370,id=sound0,bus=pci.0,addr=0x4 -device > virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 > > Notice that there are now two chardevs: > > -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control > > -chardev socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait > -mon chardev=qmpmonitor,mode=control > > As expected, I am able to connect to this second chardev via QMP. Is > there anyway that I can enable such functionality in libvirt without > hacking the code? >Though it's not that convenient as you have a independant monitor to talk directly, you could use "qemu-monitor-command" of communicate with the qemu monitor. And with the latest qemu, which supports monitor command "human-monitor-command", it's more compact, e.g. # virsh qemu-monitor-command --hmp test "info kvm" Regards Osier
By the way, the patch of shortcut for HMP passthrough is very recent. commit 2169472ab6cac3bdb1f32578de2b608a61a1d703 Author: Jiri Denemark <jdenemar at redhat.com> Date: Wed Feb 2 16:37:10 2011 +0100 Make sure you have it supported.. ;-) Regards Osier ? 2011?02?11? 07:54, Bryan D. Payne ??:> Is there any way to get virsh / libvirt to create a domain such that I > can later connect to it via QMP (without hacking the code)? > > The command line that libvirt creates for my current setup looks like this: > > /usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512 > -smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid > ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev > socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control -rtc base=localtime -boot c -drive > file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw > -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 > -drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw > -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 > -netdev tap,fd=16,id=hostnet0 -device > rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3 > -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb > -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std > -device ES1370,id=sound0,bus=pci.0,addr=0x4 -device > virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 > > The important pieces of this command line (I believe) are: > > -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control > > However, I'm unable to connect using this path because -- I'm guessing > -- libvirt has already connected. As a test, I added some code to > src/qemu/qemu_command.c to open a second chardev. My new command line > looks like this: > > /usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512 > -smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid > ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev > socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control -chardev > socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait > -mon chardev=qmpmonitor,mode=control -rtc base=localtime -boot c > -drive file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw > -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 > -drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw > -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 > -netdev tap,fd=15,id=hostnet0 -device > rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3 > -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb > -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std > -device ES1370,id=sound0,bus=pci.0,addr=0x4 -device > virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 > > Notice that there are now two chardevs: > > -chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait > -mon chardev=monitor,mode=control > > -chardev socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait > -mon chardev=qmpmonitor,mode=control > > As expected, I am able to connect to this second chardev via QMP. Is > there anyway that I can enable such functionality in libvirt without > hacking the code? > > Thanks, > bryan > > _______________________________________________ > libvirt-users mailing list > libvirt-users at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-users