Skip to content

Commit

Permalink
virtinst: allow adding host block devices to LXC containers
Browse files Browse the repository at this point in the history
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
  • Loading branch information
lkundrak authored and crobinso committed Jun 19, 2018
1 parent a2a022a commit 3a4cf07
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions man/virt-install.pod
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 5 additions & 0 deletions tests/xmlparse-xml/change-hostdevs-in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
5 changes: 5 additions & 0 deletions tests/xmlparse-xml/change-hostdevs-out.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
5 changes: 5 additions & 0 deletions tests/xmlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ def testAlterHostdevs(self):
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")
Expand Down Expand Up @@ -739,6 +740,10 @@ def testAlterHostdevs(self):
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):
Expand Down
3 changes: 3 additions & 0 deletions virtinst/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,9 @@ def set_name_cb(self, inst, val, virtarg):
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)
Expand Down
3 changes: 3 additions & 0 deletions virtinst/devices/hostdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@ def _get_default_domain(self):

# type=misc handling
misc_char = XMLProperty("./source/char")

# type=misc handling
storage_block = XMLProperty("./source/block")

0 comments on commit 3a4cf07

Please sign in to comment.