virtinst: allow adding host block devices to LXC containers

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

View File

@ -1230,6 +1230,10 @@ Network device (in LXC container).
Character device (in LXC container).
=item B<--hostdev /dev/sdf,type=storage>
Block 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

@ -53,5 +53,10 @@
<char>/dev/net/tun</char>
</source>
</hostdev>
<hostdev mode="capabilities" type="storage" managed="yes">
<source>
<block>/dev/sdf</block>
</source>
</hostdev>
</devices>
</domain>

View File

@ -56,5 +56,10 @@
<char>/dev/null</char>
</source>
</hostdev>
<hostdev mode="capabilities" type="storage" managed="yes">
<source>
<block>/dev/fd0</block>
</source>
</hostdev>
</devices>
</domain>

View File

@ -697,6 +697,7 @@ class XMLParseTest(unittest.TestCase):
dev4 = guest.devices.hostdev[3]
dev5 = guest.devices.hostdev[4]
dev6 = guest.devices.hostdev[5]
dev7 = guest.devices.hostdev[6]
check = self._make_checker(dev1)
check("type", "usb", "foo", "usb")
@ -739,6 +740,10 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(dev6)
check("type", "misc")
check("misc_char", "/dev/net/tun", "/dev/null")
check = self._make_checker(dev7)
check("type", "storage")
check("storage_block", "/dev/sdf", "/dev/fd0")
self._alter_compare(guest.get_xml_config(), outfile)
def testAlterWatchdogs(self):

View File

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

View File

@ -138,3 +138,6 @@ class DeviceHostdev(Device):
# type=misc handling
misc_char = XMLProperty("./source/char")
# type=misc handling
storage_block = XMLProperty("./source/block")