virtinst: allow adding host network devices to LXC containers
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
This commit is contained in:
parent
139031793c
commit
bba3d04558
|
@ -1222,6 +1222,10 @@ USB by vendor, product (via lsusb).
|
|||
|
||||
PCI device (via lspci).
|
||||
|
||||
=item B<--hostdev wlan0,type=net>
|
||||
|
||||
Network 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>
|
||||
|
|
|
@ -43,5 +43,10 @@
|
|||
<address bus="0" target="0" unit="0"/>
|
||||
</source>
|
||||
</hostdev>
|
||||
<hostdev mode="capabilities" type="net" managed="yes">
|
||||
<source>
|
||||
<interface>wlan0</interface>
|
||||
</source>
|
||||
</hostdev>
|
||||
</devices>
|
||||
</domain>
|
||||
|
|
|
@ -46,5 +46,10 @@
|
|||
<address bus="1" target="2" unit="3"/>
|
||||
</source>
|
||||
</hostdev>
|
||||
<hostdev mode="capabilities" type="net" managed="yes">
|
||||
<source>
|
||||
<interface>eth0</interface>
|
||||
</source>
|
||||
</hostdev>
|
||||
</devices>
|
||||
</domain>
|
||||
|
|
|
@ -695,6 +695,7 @@ class XMLParseTest(unittest.TestCase):
|
|||
dev2 = guest.devices.hostdev[1]
|
||||
dev3 = guest.devices.hostdev[2]
|
||||
dev4 = guest.devices.hostdev[3]
|
||||
dev5 = guest.devices.hostdev[4]
|
||||
|
||||
check = self._make_checker(dev1)
|
||||
check("type", "usb", "foo", "usb")
|
||||
|
@ -729,6 +730,10 @@ class XMLParseTest(unittest.TestCase):
|
|||
check("scsi_bus", 0, 1)
|
||||
check("scsi_target", 0, 2)
|
||||
check("scsi_unit", 0, 3)
|
||||
|
||||
check = self._make_checker(dev5)
|
||||
check("type", "net")
|
||||
check("net_interface", "wlan0", "eth0")
|
||||
self._alter_compare(guest.get_xml_config(), outfile)
|
||||
|
||||
def testAlterWatchdogs(self):
|
||||
|
|
|
@ -2779,8 +2779,12 @@ class ParserHostdev(VirtCLIParser):
|
|||
remove_first = "name"
|
||||
|
||||
def set_name_cb(self, inst, val, virtarg):
|
||||
val = NodeDevice.lookupNodedevFromString(inst.conn, val)
|
||||
inst.set_from_nodedev(val)
|
||||
if inst.type == "net":
|
||||
inst.mode = "capabilities"
|
||||
inst.net_interface = val
|
||||
else:
|
||||
val = NodeDevice.lookupNodedevFromString(inst.conn, val)
|
||||
inst.set_from_nodedev(val)
|
||||
|
||||
def name_lookup_cb(self, inst, val, virtarg):
|
||||
nodedev = NodeDevice.lookupNodedevFromString(inst.conn, val)
|
||||
|
@ -2788,6 +2792,7 @@ class ParserHostdev(VirtCLIParser):
|
|||
|
||||
_register_virt_parser(ParserHostdev)
|
||||
_add_device_address_args(ParserHostdev)
|
||||
ParserHostdev.add_arg("type", "type")
|
||||
ParserHostdev.add_arg(None, "name",
|
||||
cb=ParserHostdev.set_name_cb,
|
||||
lookup_cb=ParserHostdev.name_lookup_cb)
|
||||
|
|
|
@ -132,3 +132,6 @@ class DeviceHostdev(Device):
|
|||
scsi_bus = XMLProperty("./source/address/@bus", is_int=True)
|
||||
scsi_target = XMLProperty("./source/address/@target", is_int=True)
|
||||
scsi_unit = XMLProperty("./source/address/@unit", is_int=True)
|
||||
|
||||
# type=net handling
|
||||
net_interface = XMLProperty("./source/interface")
|
||||
|
|
Loading…
Reference in New Issue