[Kimchi-devel] [PATCH] Add support for serial console
Ramon Medeiros
ramonn at linux.vnet.ibm.com
Tue Nov 17 12:13:54 UTC 2015
Automatically create serial console device.
Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/vmtemplate.py | 7 +++++-
src/wok/plugins/kimchi/xmlutils/serial.py | 40 +++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 src/wok/plugins/kimchi/xmlutils/serial.py
diff --git a/src/wok/plugins/kimchi/vmtemplate.py b/src/wok/plugins/kimchi/vmtemplate.py
index 283d94d..d8f2f7f 100644
--- a/src/wok/plugins/kimchi/vmtemplate.py
+++ b/src/wok/plugins/kimchi/vmtemplate.py
@@ -37,7 +37,7 @@ from wok.plugins.kimchi.xmlutils.disk import get_disk_xml
from wok.plugins.kimchi.xmlutils.graphics import get_graphics_xml
from wok.plugins.kimchi.xmlutils.interface import get_iface_xml
from wok.plugins.kimchi.xmlutils.qemucmdline import get_qemucmdline_xml
-
+from wok.plugins.kimchi.xmlutils.serial import get_serial_xml
class VMTemplate(object):
def __init__(self, args, scan=False):
@@ -312,6 +312,10 @@ class VMTemplate(object):
params['cpu_info'] = self._get_cpu_xml()
params['disks'] = self._get_disks_xml(vm_uuid)
+ params['serial'] = ''
+ if params['arch'] not in ['ppc', 'ppc64']:
+ params['serial'] = get_serial_xml()
+
graphics = dict(self.info['graphics'])
graphics.update(kwargs.get('graphics', {}))
params['graphics'] = get_graphics_xml(graphics)
@@ -365,6 +369,7 @@ class VMTemplate(object):
%(networks)s
%(graphics)s
%(input_output)s
+ %(serial)s
<memballoon model='virtio' />
</devices>
</domain>
diff --git a/src/wok/plugins/kimchi/xmlutils/serial.py b/src/wok/plugins/kimchi/xmlutils/serial.py
new file mode 100644
index 0000000..2892c45
--- /dev/null
+++ b/src/wok/plugins/kimchi/xmlutils/serial.py
@@ -0,0 +1,40 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2014
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import lxml.etree as ET
+from lxml.builder import E
+
+def get_serial_xml():
+ """
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ """
+ serial = E.serial(type="pty")
+ serial.append(E.target(port='0'))
+ console = E.console(type="pty")
+ console.append(E.target(type="serial", port='0'))
+ return ET.tostring(serial, encoding='utf-8', pretty_print=True) + \
+ ET.tostring(console, encoding='utf-8', pretty_print=True)
+
+
+
--
2.1.0
More information about the Kimchi-devel
mailing list