mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
virt-install: add --network hostdev=HOSTDEV
This is a special convenience option for filling in `type=hostdev` config using the same format of lookup string that can be passed to `--hostdev` Fixes: https://github.com/virt-manager/virt-manager/issues/500 Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
300f934cae
commit
afa8231525
@ -1332,6 +1332,11 @@ Some example suboptions:
|
||||
|
||||
This option deprecates -m/--mac, -b/--bridge, and --nonetworks
|
||||
|
||||
``hostdev=HOSTDEV``
|
||||
Use the referenced nodedev device as the source for ``type=hostdev``
|
||||
as described here: https://libvirt.org/formatdomain.html#pci-passthrough
|
||||
|
||||
For ``HOSTDEV`` format, see ``--hostdev`` documentation
|
||||
|
||||
|
||||
GRAPHICS OPTIONS
|
||||
|
@ -633,6 +633,20 @@
|
||||
<address type="pci" domain="0" bus="0" slot="7" function="0"/>
|
||||
</source>
|
||||
</interface>
|
||||
<interface type="hostdev" managed="yes">
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="virtio"/>
|
||||
<source>
|
||||
<address type="pci" domain="0" bus="0" slot="9" function="0"/>
|
||||
</source>
|
||||
</interface>
|
||||
<interface type="hostdev" managed="yes">
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="virtio"/>
|
||||
<source>
|
||||
<address type="pci" domain="0" bus="0" slot="4" function="0"/>
|
||||
</source>
|
||||
</interface>
|
||||
<smartcard mode="passthrough" type="spicevmc"/>
|
||||
<smartcard mode="host" type="tcp"/>
|
||||
<smartcard mode="passthrough" type="spicevmc"/>
|
||||
|
@ -3589,6 +3589,23 @@ ba</description>
|
||||
</device>
|
||||
<!-- End duplicate USB devices -->
|
||||
|
||||
<device>
|
||||
<name>pci_0000_00_09_0</name>
|
||||
<path>/sys/devices/pci0000:00/0000:00:09.0</path>
|
||||
<parent>computer</parent>
|
||||
<driver>
|
||||
<name>i915</name>
|
||||
</driver>
|
||||
<capability type='pci'>
|
||||
<domain>0</domain>
|
||||
<bus>0</bus>
|
||||
<slot>9</slot>
|
||||
<function>0</function>
|
||||
<product id='0x191b'>HD Graphics 530</product>
|
||||
<vendor id='0x8086'>Intel Corporation</vendor>
|
||||
</capability>
|
||||
</device>
|
||||
|
||||
<device>
|
||||
<name>pci_0000_00_02_0</name>
|
||||
<path>/sys/devices/pci0000:00/0000:00:02.0</path>
|
||||
|
@ -653,6 +653,8 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
|
||||
--network model=vmxnet3
|
||||
--network backend.type=passt,backend.logFile=/tmp/foo.log,portForward0.proto=tcp,portForward0.address=192.168.10.10,portForward0.dev=eth0,portForward0.range0.start=4000,portForward0.range0.end=5000,portForward0.range0.to=10000,portForward0.range0.exclude=no,portForward0.range1.start=6000,portForward1.proto=tcp,portForward1.range0.start=2022,portForward1.range0.to=22
|
||||
--network type=hostdev,source.address.type=pci,source.address.domain=0x0,source.address.bus=0x00,source.address.slot=0x07,source.address.function=0x0
|
||||
--network hostdev=pci_0000_00_09_0
|
||||
--network hostdev=0:0:4.0
|
||||
|
||||
|
||||
--graphics sdl
|
||||
|
@ -3913,6 +3913,10 @@ class ParserNetwork(VirtCLIParser):
|
||||
cb = self._make_find_inst_cb(cliarg, list_propname)
|
||||
return cb(inst, *args, **kwargs)
|
||||
|
||||
def set_hostdev_cb(self, inst, val, virtarg):
|
||||
val = _lookupNodedevFromString(inst.conn, val)
|
||||
inst.set_from_nodedev(val)
|
||||
|
||||
@classmethod
|
||||
def _virtcli_class_init(cls):
|
||||
VirtCLIParser._virtcli_class_init_common(cls)
|
||||
@ -3942,6 +3946,8 @@ class ParserNetwork(VirtCLIParser):
|
||||
cls.add_arg("source.address.slot", "source_address.slot")
|
||||
cls.add_arg("source.address.function", "source_address.function")
|
||||
|
||||
cls.add_arg("hostdev", None, cb=cls.set_hostdev_cb, lookup_cb=None)
|
||||
|
||||
cls.add_arg("target.dev", "target_dev")
|
||||
cls.add_arg("model.type", "model")
|
||||
cls.add_arg("mac.address", "macaddr", cb=cls.set_mac_cb)
|
||||
|
@ -8,6 +8,7 @@ import os
|
||||
import random
|
||||
|
||||
from .device import Device, DeviceAddress
|
||||
from ..nodedev import NodeDevice
|
||||
from ..logger import log
|
||||
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
|
||||
@ -291,6 +292,7 @@ class DeviceInterface(Device):
|
||||
source_address = XMLChildProperty(_DeviceInterfaceSourceAddress,
|
||||
is_single=True,
|
||||
relative_xpath="./source")
|
||||
managed = XMLProperty("./@managed", is_yesno=True)
|
||||
|
||||
portgroup = XMLProperty("./source/@portgroup")
|
||||
model = XMLProperty("./model/@type")
|
||||
@ -327,6 +329,24 @@ class DeviceInterface(Device):
|
||||
self.type = nettype
|
||||
self.source = source
|
||||
|
||||
def set_from_nodedev(self, nodedev):
|
||||
log.debug("set_from_nodedev xml=\n%s", nodedev.get_xml())
|
||||
|
||||
self.type = "hostdev"
|
||||
if self.managed is None:
|
||||
self.managed = True
|
||||
|
||||
if nodedev.device_type == NodeDevice.CAPABILITY_TYPE_PCI:
|
||||
self.source_address.type = "pci"
|
||||
self.source_address.domain = nodedev.domain
|
||||
self.source_address.bus = nodedev.bus
|
||||
self.source_address.slot = nodedev.slot
|
||||
self.source_address.function = nodedev.function
|
||||
|
||||
else: # pragma: no cover
|
||||
raise ValueError(_("Unsupported node device type '%s'") %
|
||||
nodedev.device_type)
|
||||
|
||||
|
||||
##################
|
||||
# Default config #
|
||||
|
Loading…
Reference in New Issue
Block a user