Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Have you tried to hit "enter" a couple of times, to get the login prompt? –  dyasny Feb 29 '12 at 18:03
    
yes, i have, but there is no reaction. Even during the startup phase (I connect to the pty immediately after starting up the VM) I see no grub startup, and no linux boot messages. I think the VM is running fine, but I can not access it from the outside. I need to debug it (the network is not yet working), that is why I need console access. –  jeckyll2hide Feb 29 '12 at 18:46

1 Answer 1

<serial type='pty'>
  <target port='0'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
</console>

This is what I normally add to the VMs definition, using virsh edit Then console=ttyS0 appended in the VM's kernel line in grub.conf

Never failed me so far

share|improve this answer
    
What is the command that you use to create the vm? I use the following: virt-install --connect qemu:///system -n VM1 -r 256 --vcpus=1 --vnc --noautoconsole --os-type linux --accelerate --network=bridge:eth0,model=virtio -m 52:54:00:12:34:50 -k de --import --nographics --disk /var/VMs/VM1.qcow2 –  jeckyll2hide Feb 29 '12 at 21:22
    
to tell you the truth, I don't use virt-install at all. virt-manager is my usual tool –  dyasny Feb 29 '12 at 21:34
    
The problem was somewhere else, but thanks to your hints, I found it. Using virt-manager allowed me to open a VNC connection and I saw that it is not booting at all, because I did not specify in the --disk parameter that this is a qcow2 disk image. Aparently this can not be automatically inferred - even though the extension should be a good hint?. The command must be extended with --disk path=$vm_drive,format=qcow2 –  jeckyll2hide Feb 29 '12 at 23:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.