virtinst: allow adding host character devices to LXC containers

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
This commit is contained in:
Lubomir Rintel 2018-06-15 11:29:35 +02:00 committed by Cole Robinson
parent bba3d04558
commit a2a022a879
6 changed files with 25 additions and 0 deletions

View File

@ -1226,6 +1226,10 @@ PCI device (via lspci).
Network device (in LXC container).
=item B<--hostdev /dev/net/tun,type=misc>
Character device (in LXC container).
=back
Use --hostdev=? to see a list of all available sub options. Complete details at L<https://libvirt.org/formatdomain.html#elementsHostDev>

View File

@ -48,5 +48,10 @@
<interface>wlan0</interface>
</source>
</hostdev>
<hostdev mode="capabilities" type="misc" managed="yes">
<source>
<char>/dev/net/tun</char>
</source>
</hostdev>
</devices>
</domain>

View File

@ -51,5 +51,10 @@
<interface>eth0</interface>
</source>
</hostdev>
<hostdev mode="capabilities" type="misc" managed="yes">
<source>
<char>/dev/null</char>
</source>
</hostdev>
</devices>
</domain>

View File

@ -696,6 +696,7 @@ class XMLParseTest(unittest.TestCase):
dev3 = guest.devices.hostdev[2]
dev4 = guest.devices.hostdev[3]
dev5 = guest.devices.hostdev[4]
dev6 = guest.devices.hostdev[5]
check = self._make_checker(dev1)
check("type", "usb", "foo", "usb")
@ -734,6 +735,10 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(dev5)
check("type", "net")
check("net_interface", "wlan0", "eth0")
check = self._make_checker(dev6)
check("type", "misc")
check("misc_char", "/dev/net/tun", "/dev/null")
self._alter_compare(guest.get_xml_config(), outfile)
def testAlterWatchdogs(self):

View File

@ -2782,6 +2782,9 @@ class ParserHostdev(VirtCLIParser):
if inst.type == "net":
inst.mode = "capabilities"
inst.net_interface = val
elif inst.type == "misc":
inst.mode = "capabilities"
inst.misc_char = val
else:
val = NodeDevice.lookupNodedevFromString(inst.conn, val)
inst.set_from_nodedev(val)

View File

@ -135,3 +135,6 @@ class DeviceHostdev(Device):
# type=net handling
net_interface = XMLProperty("./source/interface")
# type=misc handling
misc_char = XMLProperty("./source/char")