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've created a KVM virtual machine using the following command:

sudo ubuntu-vm-builder kvm oneiric \
                  --domain xpstage \
                  --dest xpstage \
                  --arch i386 \
                  --hostname xpstage \
                  --mem 1024 \
                  --user myuser --pass mypassword \
                  --bridge virbr0 \
                  --ip 192.168.1.50 --dns 8.8.8.8 \
                  --components main,universe,restricted \
                  --addpkg acpid --addpkg vim --addpkg openssh-server --addpkg avahi-daemon \
                  --libvirt qemu:///system ;

I'm able to start the VM, but I can't connect to it using networking (ssh) nor console.

To enable console access, I added a console section to the VM definition file:

<domain type='kvm' id='10'>
  <name>xpstage</name>
  <uuid>1fbe45ca-655f-9de2-b552-6ed44b2fe4c2</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.14'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/darugar/VMs/xpstage/tmpB1Hu5k.qcow2'/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:d1:6d:b8'/>
      <source bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/3'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-1fbe45ca-655f-9de2-b552-6ed44b2fe4c2</label>
    <imagelabel>libvirt-1fbe45ca-655f-9de2-b552-6ed44b2fe4c2</imagelabel>
  </seclabel>
</domain>

However, when I attempt to connect via the console nothing displays at all:

$ virsh console xpstage
Connected to domain xpstage
Escape character is ^]

$ virsh ttyconsole xpstage
/dev/pts/3

The "virsh console" command appears to connect, but nothing is displayed besides the "Escape character is ^]".

Note that I'm not looking for VNC or graphical access; I want simple console based access.

Ideas on how to make this work would be appreciated.

share|improve this question
add comment

3 Answers

I believe you still need to send something to the console from your host.

So either having kernel parameter like console=ttyS0,38400n8 and

T0:2345:respawn:/sbin/getty -L ttyS0 38400 vt100

in your /etc/inittab.

Or maybe just removing the VGA will make Ubuntu use ttyS0 by default (but i'm wildly guessing here).

share|improve this answer
add comment

You definitely need to enable the serial console in the guest machine before being able to connect. The correct way is described here: https://help.ubuntu.com/community/SerialConsoleHowto

Recent Ubuntu versions use Upstart tasks and services so you should add an Upstart task as /etc/init/ttyS0.conf, containing the following:

# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc or RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -L 115200 ttyS0 vt102

Start it this way:

$ sudo start ttyS0

After that you should be able to connect to the serial console from the host. Don't forget to press Enter once connected.

share|improve this answer
    
Thanks, I'd found the same page and tried it. I've verified the /etc/init/ttyS0.conf file exists, but when I do "sudo start ttyS0" I get start: Unknown job: ttyS0 . I'll see if I can figure out why. –  Parand Dec 7 '11 at 23:50
    
If start ttyS0 doesn't work you could try service ttyS0 start. Or a reboot :) –  daff Dec 8 '11 at 3:50
add comment

Two problems are described, ssh access, and virsh console access. Obviously the console is the starting point so you can debug ssh and networking. Here's how to get virsh console working.

  1. shut down the guest and mount its root drive on a loop device, perhaps

    $ sudo kpartx -a guest.img
    $ sudo kpartx -av guest.img 
    add map loop0p1 (253:1): 0 41940992 linear /dev/loop0 2048
    $ sudo mount -t ext4 /dev/loop0p1 /mnt
    
  2. Create this file -- google "ttyS0 (your guest OS version)" for examples.

    ttyS0.conf:
    # ttyS0 - getty
    #
    # This service maintains a getty on ttyS0 from the point the system is
    # started until it is shut down again.
    
    start on stopped rc RUNLEVEL=[2345]
    stop on runlevel [!2345]
    
    respawn
    exec /sbin/getty -L 115200 ttyS0 xterm
    
  3. Edit /mnt/etc/securetty and add ttyS0 to the list.

  4. Unmount /mnt, kpartx -d guest.img, and start your guest.

  5. Now virsh console guest should work AND login will succeed (without the edit to securetty, Login always fails.)

share|improve this answer
add comment

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.