Merge "libvirt: virtlogd: use "log" element in char devices"
This commit is contained in:
commit
76e857cade
@ -1239,6 +1239,23 @@ class LibvirtConfigGuestHostdevPCI(LibvirtConfigBaseTest):
|
|||||||
self.assertEqual(obj.type, 'usb')
|
self.assertEqual(obj.type, 'usb')
|
||||||
|
|
||||||
|
|
||||||
|
class LibvirtConfigGuestCharDeviceLog(LibvirtConfigBaseTest):
|
||||||
|
|
||||||
|
def test_config_log(self):
|
||||||
|
obj = config.LibvirtConfigGuestCharDeviceLog()
|
||||||
|
obj.file = "/tmp/guestname-logd.log"
|
||||||
|
obj.append = "on"
|
||||||
|
|
||||||
|
xml = obj.to_xml()
|
||||||
|
self.assertXmlEqual(xml, """
|
||||||
|
<log file="/tmp/guestname-logd.log" append="on"/>""")
|
||||||
|
|
||||||
|
# create a new object from the XML and check it again
|
||||||
|
obj2 = config.LibvirtConfigGuestCharDeviceLog()
|
||||||
|
obj2.parse_str(xml)
|
||||||
|
self.assertXmlEqual(xml, obj2.to_xml())
|
||||||
|
|
||||||
|
|
||||||
class LibvirtConfigGuestSerialTest(LibvirtConfigBaseTest):
|
class LibvirtConfigGuestSerialTest(LibvirtConfigBaseTest):
|
||||||
|
|
||||||
def test_config_file(self):
|
def test_config_file(self):
|
||||||
@ -1264,6 +1281,24 @@ class LibvirtConfigGuestSerialTest(LibvirtConfigBaseTest):
|
|||||||
<source host="0.0.0.0" service="11111" mode="bind"/>
|
<source host="0.0.0.0" service="11111" mode="bind"/>
|
||||||
</serial>""")
|
</serial>""")
|
||||||
|
|
||||||
|
def test_config_log(self):
|
||||||
|
log = config.LibvirtConfigGuestCharDeviceLog()
|
||||||
|
log.file = "/tmp/guestname-logd.log"
|
||||||
|
log.append = "off"
|
||||||
|
|
||||||
|
device = config.LibvirtConfigGuestSerial()
|
||||||
|
device.type = "tcp"
|
||||||
|
device.listen_port = 11111
|
||||||
|
device.listen_host = "0.0.0.0"
|
||||||
|
device.log = log
|
||||||
|
|
||||||
|
xml = device.to_xml()
|
||||||
|
self.assertXmlEqual(xml, """
|
||||||
|
<serial type="tcp">
|
||||||
|
<source host="0.0.0.0" service="11111" mode="bind"/>
|
||||||
|
<log file="/tmp/guestname-logd.log" append="off"/>
|
||||||
|
</serial>""")
|
||||||
|
|
||||||
|
|
||||||
class LibvirtConfigGuestConsoleTest(LibvirtConfigBaseTest):
|
class LibvirtConfigGuestConsoleTest(LibvirtConfigBaseTest):
|
||||||
def test_config_pty(self):
|
def test_config_pty(self):
|
||||||
@ -1311,6 +1346,24 @@ class LibvirtConfigGuestConsoleTest(LibvirtConfigBaseTest):
|
|||||||
</console>
|
</console>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def test_config_log(self):
|
||||||
|
log = config.LibvirtConfigGuestCharDeviceLog()
|
||||||
|
log.file = "/tmp/guestname-logd.log"
|
||||||
|
log.append = "off"
|
||||||
|
|
||||||
|
device = config.LibvirtConfigGuestConsole()
|
||||||
|
device.type = "tcp"
|
||||||
|
device.listen_port = 11111
|
||||||
|
device.listen_host = "0.0.0.0"
|
||||||
|
device.log = log
|
||||||
|
|
||||||
|
xml = device.to_xml()
|
||||||
|
self.assertXmlEqual(xml, """
|
||||||
|
<console type="tcp">
|
||||||
|
<source host="0.0.0.0" service="11111" mode="bind"/>
|
||||||
|
<log file="/tmp/guestname-logd.log" append="off"/>
|
||||||
|
</console>""")
|
||||||
|
|
||||||
|
|
||||||
class LibvirtConfigGuestChannelTest(LibvirtConfigBaseTest):
|
class LibvirtConfigGuestChannelTest(LibvirtConfigBaseTest):
|
||||||
def test_config_spice_minimal(self):
|
def test_config_spice_minimal(self):
|
||||||
|
@ -1608,6 +1608,7 @@ class LibvirtConfigGuestCharBase(LibvirtConfigGuestDevice):
|
|||||||
self.source_path = None
|
self.source_path = None
|
||||||
self.listen_port = None
|
self.listen_port = None
|
||||||
self.listen_host = None
|
self.listen_host = None
|
||||||
|
self.log = None
|
||||||
|
|
||||||
def format_dom(self):
|
def format_dom(self):
|
||||||
dev = super(LibvirtConfigGuestCharBase, self).format_dom()
|
dev = super(LibvirtConfigGuestCharBase, self).format_dom()
|
||||||
@ -1624,6 +1625,9 @@ class LibvirtConfigGuestCharBase(LibvirtConfigGuestDevice):
|
|||||||
host=self.listen_host,
|
host=self.listen_host,
|
||||||
service=str(self.listen_port)))
|
service=str(self.listen_port)))
|
||||||
|
|
||||||
|
if self.log:
|
||||||
|
dev.append(self.log.format_dom())
|
||||||
|
|
||||||
return dev
|
return dev
|
||||||
|
|
||||||
|
|
||||||
@ -1649,6 +1653,27 @@ class LibvirtConfigGuestChar(LibvirtConfigGuestCharBase):
|
|||||||
return dev
|
return dev
|
||||||
|
|
||||||
|
|
||||||
|
class LibvirtConfigGuestCharDeviceLog(LibvirtConfigObject):
|
||||||
|
"""Represents a sub-element to a character device."""
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(LibvirtConfigGuestCharDeviceLog, self).__init__(root_name="log",
|
||||||
|
**kwargs)
|
||||||
|
self.file = None
|
||||||
|
self.append = "off"
|
||||||
|
|
||||||
|
def parse_dom(self, xmldoc):
|
||||||
|
super(LibvirtConfigGuestCharDeviceLog, self).parse_dom(xmldoc)
|
||||||
|
self.file = xmldoc.get("file")
|
||||||
|
self.append = xmldoc.get("append")
|
||||||
|
|
||||||
|
def format_dom(self):
|
||||||
|
log = super(LibvirtConfigGuestCharDeviceLog, self).format_dom()
|
||||||
|
log.set("file", self.file)
|
||||||
|
log.set("append", self.append)
|
||||||
|
return log
|
||||||
|
|
||||||
|
|
||||||
class LibvirtConfigGuestSerial(LibvirtConfigGuestChar):
|
class LibvirtConfigGuestSerial(LibvirtConfigGuestChar):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user