Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Eucalyptus on Ubuntu 10.04 to set up a private cloud. Sometimes I'm not able to ssh into the VM instances, and I'd like to be able to connect directly to the console of the VM instance. However, by default, that doesn't seem to work through virsh:

$ sudo virsh -c qemu:///system console i-486B085E
No console available for domain

Is there some way to enable this, for example, by changing the way Eucalyptus generates the XML file that gets passed to libvirt?

Here's the libvirt.xml file that Eucalyptus generates:

$ cat /var/lib/eucalyptus/instances/admin/i-486B085E/libvirt.xml
<domain type='kvm'>
    <name>i-486B085E</name>
    <os>
    <type>hvm</type>
        <kernel>/var/lib/eucalyptus/instances//admin/i-486B085E/kernel</kernel>
        <initrd>/var/lib/eucalyptus/instances//admin/i-486B085E/ramdisk</initrd>
        <cmdline>root=/dev/sda1 console=ttyS0</cmdline>
    </os>
    <features>
        <acpi/>
    </features>
    <memory>262144</memory>
    <vcpu>1</vcpu>
    <devices>
        <disk type='file'>
            <source file='/var/lib/eucalyptus/instances//admin/i-486B085E/disk'/>
            <target dev='sda'/>
        </disk>
        <interface type='bridge'>
            <source bridge='eucabr10'/>
            <mac address='d0:0d:48:6B:08:5E'/>
            <model type='e1000'/>
        </interface>
        <serial type="file">
            <source path='/var/lib/eucalyptus/instances//admin/i-486B085E/console.log'/>
            <target port='1'/>
        </serial>
    </devices>
</domain>

Here's the output of virsh dumpxml:

$ sudo virsh dumpxml i-486B085E
<domain type='kvm' id='3'>
  <name>i-486B085E</name>
  <uuid>3b762376-4de1-f6ac-7327-9df520fa4862</uuid>
  <memory>262144</memory>
  <currentMemory>262144</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <kernel>/var/lib/eucalyptus/instances//admin/i-486B085E/kernel</kernel>
    <initrd>/var/lib/eucalyptus/instances//admin/i-486B085E/ramdisk</initrd>
    <cmdline>root=/dev/sda1 console=ttyS0</cmdline>
    <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'>
      <source file='/var/lib/eucalyptus/instances//admin/i-486B085E/disk'/>
      <target dev='sda' bus='scsi'/>
    </disk>
    <interface type='bridge'>
      <mac address='d0:0d:48:6b:08:5e'/>
      <source bridge='eucabr10'/>
      <target dev='vnet0'/>
      <model type='e1000'/>
    </interface>
    <serial type='file'>
      <source path='/var/lib/eucalyptus/instances//admin/i-486B085E/console.log'/>
      <target port='0'/>
    </serial>
    <console type='file'>
      <source path='/var/lib/eucalyptus/instances//admin/i-486B085E/console.log'/>
      <target port='0'/>
    </console>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-3b762376-4de1-f6ac-7327-9df520fa4862</label>
    <imagelabel>libvirt-3b762376-4de1-f6ac-7327-9df520fa4862</imagelabel>
  </seclabel>
</domain>

Here's the full KVM command-line that ends up being invoked:

/usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 256 -smp 1 -name i-486B085E -uuid 3b762376-4de1-f6ac-7327-9df520fa4862 -nographic -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/i-486B085E.monitor,server,nowait -monitor chardev:monitor -boot c -kernel /var/lib/eucalyptus/instances//admin/i-486B085E/kernel -initrd /var/lib/eucalyptus/instances//admin/i-486B085E/ramdisk -append root=/dev/sda1 console=ttyS0 -drive file=/var/lib/eucalyptus/instances//admin/i-486B085E/disk,if=scsi,index=0,boot=on -net nic,macaddr=d0:0d:48:6b:08:5e,vlan=0,model=e1000,name=e1000.0 -net tap,fd=55,vlan=0,name=tap.0 -chardev file,id=serial0,path=/var/lib/eucalyptus/instances//admin/i-486B085E/console.log -serial chardev:serial0 -parallel none -usb
share|improve this question
up vote 2 down vote accepted

Looks like this changed with the advent of Eucalyptus 3 and above - here's an updated solution, to save anyone the aggravation that I went through this morning.

Using a combination of information found at these two links: http://gobertelli.blogspot.co.uk/2012/08/customize-instance-libvirt-environment.html https://www.redhat.com/archives/libvirt-users/2012-May/msg00048.html

On your node controller, edit /etc/eucalyptus/libvirt.xsl so that it looks like this:

    <xsl:choose>
            <xsl:when test="(/instance/hypervisor/@type = 'kvm' or /instance/hypervisor/@type = 'qemu')">
                <serial type="pty">
                    <target port="0"/>
                </serial>
            </xsl:when>
            <xsl:when test="/instance/hypervisor/@type = 'xen' and /instance/os/@platform = 'windows'">
                <serial type="pty">
                    <source path="/dev/pts/3"/>
                    <target port="0"/>
                </serial>
                <input type="tablet" bus="usb"/>
                <input type="mouse" bus="ps2"/>
            </xsl:when>
            <xsl:when test="/instance/hypervisor/@type = 'xen' and /instance/backing/root/@type = 'ebs'">
                <console type="pty"/>
                    <target port="0"/>
            </xsl:when>
    </xsl:choose>
            <!-- <graphics type='vnc' port='-1' autoport='yes' keymap='en-us' -->
        </devices>
    </domain>
</xsl:template>

Changing both the serial and console definitions to type "pty" and target "0".

Stop and start any running virtual machines, and then you should be able to 'virsh console' into them as usual.

share|improve this answer

I figured it out... You need to edit the /usr/share/eucalyptus/gen_kvm_libvirt_xml file. Here's the diff:

--- /usr/share/eucalyptus/gen_kvm_libvirt_xml.bak   2010-09-28 14:54:20.259266161 -0400
+++ /usr/share/eucalyptus/gen_kvm_libvirt_xml   2010-09-28 15:01:25.269265897 -0400
@@ -109,9 +109,9 @@
             <mac address='PRIVMACADDR'/>
             <model type='e1000'/>
         </interface>
-        <serial type="file">
-            <source path='BASEPATH/console.log'/>
-            <target port='1'/>
+        <serial type='pty'>
+          <source path='/dev/pts/2'/>
+          <target port='0'/>
         </serial>
     </devices>
 </domain>
share|improve this answer

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.