Change in vdsm[master]: vm: sercon: serial config must match console's

fromani at redhat.com fromani at redhat.com
Tue Sep 15 15:21:36 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: vm: sercon: serial config must match console's
......................................................................

vm: sercon: serial config must match console's

When we add a serial console device, we also
inject a matching serial device. This isn't strictly
needed, because

"""
If the targetType attribute is serial, then if no <serial> element
exists, the console element will be copied to the serial element. If a
<serial> element does already exist, the console element will be
ignored.
""""
(http://libvirt.org/formatdomain.html#elementCharConsole)

Until now, the code assumed that the serial console has to be
bind to a PTY, while we can also bind it to an UNIX domain socket
(required by oVirt 3.6 "guest serial console" feature).

This patch makes sure that the injected serial device is bound
to the appropriate host endpoint, either pty or unix domain socket.
Please note that if the mismatch the serial device and the console
device configuration, the VM fails to start.

Change-Id: I49489a76517975fc40a226d2529bdd9f8d8c969c
Bug-Url: https://bugzilla.redhat.com/1223671
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/vmTests.py
M vdsm/virt/vmdevices/core.py
2 files changed, 33 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/87/46187/1

diff --git a/tests/vmTests.py b/tests/vmTests.py
index 4761e79..0a51c3a 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -322,6 +322,26 @@
         console = vmdevices.core.Console(self.conf, self.log, **dev)
         self.assertXMLEqual(console.getSerialDeviceXML().toxml(), serialXML)
 
+    def testPtySerialDeviceXML(self):
+        serialXML = """
+            <serial type="pty">
+                <target port="0"/>
+            </serial>"""
+        dev = {'device': 'console', 'specParams': {'enableSocket': False}}
+        console = vmdevices.core.Console(self.conf, self.log, **dev)
+        self.assertXMLEqual(console.getSerialDeviceXML().toxml(), serialXML)
+
+    def testUnixSocketSerialDeviceXML(self):
+        path = "/var/run/ovirt-vmconsole-console/%s.sock" % self.conf['vmId']
+        serialXML = """
+            <serial type="unix">
+                <source mode="bind" path="%s" />
+                <target port="0" />
+            </serial>""" % path
+        dev = {'device': 'console', 'specParams': {'enableSocket': True}}
+        console = vmdevices.core.Console(self.conf, self.log, **dev)
+        self.assertXMLEqual(console.getSerialDeviceXML().toxml(), serialXML)
+
     def testClockXML(self):
         clockXML = """
             <clock adjustment="-3600" offset="variable">
diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py
index f9f4ea1..d3cee4b 100644
--- a/vdsm/virt/vmdevices/core.py
+++ b/vdsm/virt/vmdevices/core.py
@@ -123,8 +123,20 @@
         <serial type='pty'>
             <target port='0'>
         </serial>
+
+        or
+
+        <serial type='unix'>
+            <source mode='bind'
+              path='/var/run/ovirt-vmconsole-console/${VMID}.sock'/>
+            <target type='isa-serial' port='0'/>
+        </serial>
         """
-        s = self.createXmlElem('serial', 'pty')
+        if self._path:
+            s = self.createXmlElem('serial', 'unix')
+            s.appendChildWithArgs('source', mode='bind', path=self._path)
+        else:
+            s = self.createXmlElem('serial', 'pty')
         s.appendChildWithArgs('target', port='0')
         return s
 


-- 
To view, visit https://gerrit.ovirt.org/46187
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I49489a76517975fc40a226d2529bdd9f8d8c969c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list