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