I have a VM which I can start with virsh
. According to virsh dumpxml VM1
, this is the allocated pty:
<serial type='pty'>
<source path='/dev/pts/6'/>
<target port='0'/>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/6'>
<source path='/dev/pts/6'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
The VM is running:
# virsh list
Id Name State
----------------------------------
7 VM1 running
Inside the VM, this is the grub configuration:
kernel /boot/vmlinuz-2.6.24-28-virtual root=UUID=7a1685b9-ecc8-4b70-932c-459a6faac07d ro quiet splash console=tty0 console=ttyS0,9600n8
And this is the command line launched by virsh to start the VM:
/usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 256 -smp 1,sockets=1,cores=1,threads=1 -name VM1 -uuid 47ff6ec2-a748-4738-16b9-2ffe5780e456 -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/VM1.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive file=/var/VMs/VM1.qcow2,if=none,id=drive-ide0-0-0,boot=on,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:12:34:50,bus=pci.0,addr=0x3 -net tap,fd=64,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:0 -k de -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
But if I connect with virsh console VM1
, or I do cat /dev/pts/6
, nothing is shown in the VM console.
Is there something else that I must consider?
UPDATE
I have two VMs, one started directly with kvm
, the other via virsh
. The one started directly has a working console. I have verified the open files in both cases:
root@host1:~# lsof | grep 25093 | grep dev
kvm 25093 root DEL REG 0,4 3758780 /dev/zero
kvm 25093 root DEL REG 0,4 3758779 /dev/zero
kvm 25093 root DEL REG 0,4 3758777 /dev/zero
kvm 25093 root 0u CHR 136,3 0t0 6 /dev/pts/3
kvm 25093 root 1u CHR 136,3 0t0 6 /dev/pts/3
kvm 25093 root 2u CHR 136,3 0t0 6 /dev/pts/3
kvm 25093 root 3u CHR 10,232 0t0 8025 /dev/kvm
kvm 25093 root 7u CHR 10,200 0t0 4983 /dev/net/tun
root@host1:~# lsof | grep 8341 | grep dev
kvm 8341 libvirt-qemu DEL REG 0,4 9743486 /dev/zero
kvm 8341 libvirt-qemu DEL REG 0,4 9743485 /dev/zero
kvm 8341 libvirt-qemu DEL REG 0,4 9743483 /dev/zero
kvm 8341 libvirt-qemu 0r CHR 1,3 0t0 4640 /dev/null
kvm 8341 libvirt-qemu 4u CHR 5,2 0t0 4897 /dev/ptmx
kvm 8341 libvirt-qemu 5u CHR 10,232 0t0 8025 /dev/kvm
kvm 8341 libvirt-qemu 64u CHR 10,200 0t0 4983 /dev/net/tun
As you can see, in one of the VMs (the wrong one), there are no file descriptors 1 & 2, and file descriptor 0 is redirected to /dev/null. That is the problem I guess.
The question is, how do I tell virsh not to do that?