[Ovirt-devel] Serial Console Support

Ian Main imain at redhat.com
Wed Aug 6 04:47:48 UTC 2008


So, I've come up with a patch to add serial console support, however there's a catch :).

The best way to do it would be to make livecd-creator support the --append option to the bootloader kickstart config.  I spent a fair bit of time digging around it today so it wouldn't be hard for me to do this and get it into livecd-tools.  

As an immediate fix, the patch below will make consoles work for pxe and static-flash images which will would catch 99.9% of users at this point I think.

So I'm just wondering how to proceed.. I'm guessing we can push this now and then I'll get a patch into livecd-creator for proper support.  This patch also makes guests created with a serial console.

---

Subject: [PATCH] Add serial console support

This patch adds serial console support to the node and to guest VMs.
With this patch, nodes in developer mode now support a serial console
and can be connected to with the virsh console command.

This only supports console for pxe boot as livecd-creator does not
support appending arbitrary strings to the kernel command line.
---
 ovirt-host-creator/common-install.ks  |    4 ++++
 ovirt-host-creator/ovirt-flash-static |    2 +-
 ovirt-host-creator/ovirt-pxe          |    4 +++-
 wui/src/task-omatic/task_vm.rb        |    5 +++++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ovirt-host-creator/common-install.ks b/ovirt-host-creator/common-install.ks
index badc847..8a7aefa 100644
--- a/ovirt-host-creator/common-install.ks
+++ b/ovirt-host-creator/common-install.ks
@@ -6,6 +6,10 @@ selinux --disabled
 firewall --disabled
 part / --size 550 --fstype ext2
 services --enabled=ntpd,ntpdate,collectd,iptables,network
+# FIXME: I think the right way to do this is to modify
+# livecd-creator to honor the --append settings.  For now
+# this is done for pxe and flash in different ways.
+#bootloader --timeout=1 --append="console=tty0 console=ttyS0,19200n8"
 bootloader --timeout=1
 rootpw --iscrypted Xa8QeYfWrtscM
 
diff --git a/ovirt-host-creator/ovirt-flash-static b/ovirt-host-creator/ovirt-flash-static
index be9c7c9..4a37433 100755
--- a/ovirt-host-creator/ovirt-flash-static
+++ b/ovirt-host-creator/ovirt-flash-static
@@ -54,7 +54,7 @@ rm -f $USBTMP/isolinux.bin
 mv $USBTMP/isolinux.cfg $USBTMP/extlinux.conf
 
 LABEL=`echo $ISO | cut -d'.' -f1 | cut -c-16`
-sed -i -e "s/ *append.*/  append initrd=initrd.img root=LABEL=$LABEL ro/" $USBTMP/extlinux.conf
+sed -i -e "s/ *append.*/  append initrd=initrd.img root=LABEL=$LABEL console=tty0 console=ttyS0,19200n8 ro/" $USBTMP/extlinux.conf
 
 extlinux -i $USBTMP
 
diff --git a/ovirt-host-creator/ovirt-pxe b/ovirt-host-creator/ovirt-pxe
index facca5b..89acaee 100755
--- a/ovirt-host-creator/ovirt-pxe
+++ b/ovirt-host-creator/ovirt-pxe
@@ -29,6 +29,8 @@ test $( id -u ) -ne 0 && die "$ME must run as root"
 
 livecd-iso-to-pxeboot $ISO
 
-# append BOOTIF with PXE MAC info
 f=tftpboot/pxelinux.cfg/default
+# Setup dual consoles.
+sed -i 's/APPEND.*/& console=tty0 console=ttyS0,19200n8/' $f
+# append BOOTIF with PXE MAC info
 grep -q 'IPAPPEND 2' $f || sed -i '/KERNEL/a \\tIPAPPEND 2' $f
diff --git a/wui/src/task-omatic/task_vm.rb b/wui/src/task-omatic/task_vm.rb
index 34749e0..d7f0869 100644
--- a/wui/src/task-omatic/task_vm.rb
+++ b/wui/src/task-omatic/task_vm.rb
@@ -80,6 +80,11 @@ def create_vm_xml(name, uuid, memAllocated, memUsed, vcpus, bootDevice,
   doc.root.elements["devices"].add_element("input", {"type" => "mouse", "bus" => "ps2"})
   doc.root.elements["devices"].add_element("graphics", {"type" => "vnc", "port" => "-1", "listen" => "0.0.0.0"})
 
+  serial = Element.new("serial")
+  serial.add_attribute("type", "pty")
+  serial.add_element("target", {"port" => "0"})
+  doc.root.elements["devices"] << serial
+
   return doc
 end
 
-- 
1.5.5.1




More information about the ovirt-devel mailing list