mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
osdict: Move default_netmodel logic to Guest
Make the entry point just return a list of libosinfo device names, and have Guest choose the preference. This is more future proof
This commit is contained in:
parent
b902fbd54f
commit
8a87c91888
@ -1078,22 +1078,26 @@ class Guest(XMLBuilder):
|
||||
disk.cli_generated_target = False
|
||||
used_targets.append(disk.generate_target(used_targets))
|
||||
|
||||
def _set_net_defaults(self):
|
||||
net_model = None
|
||||
def _default_netmodel(self):
|
||||
if not self.os.is_hvm():
|
||||
net_model = None
|
||||
elif self._supports_virtio(self._os_object.supports_virtionet()):
|
||||
net_model = "virtio"
|
||||
else:
|
||||
net_model = self._os_object.default_netmodel()
|
||||
return None
|
||||
if self._supports_virtio(self._os_object.supports_virtionet()):
|
||||
return "virtio"
|
||||
if self.os.is_q35():
|
||||
return "e1000e"
|
||||
|
||||
if not net_model and self.os.is_q35():
|
||||
net_model = "e1000e"
|
||||
prefs = ["e1000", "rtl8139", "ne2k_pci", "pcnet"]
|
||||
supported_models = self._os_object.supported_netmodels()
|
||||
for pref in prefs:
|
||||
if pref in supported_models:
|
||||
return pref
|
||||
return None
|
||||
|
||||
if net_model:
|
||||
for net in self.devices.interface:
|
||||
if not net.model:
|
||||
net.model = net_model
|
||||
def _set_net_defaults(self):
|
||||
default_model = self._default_netmodel()
|
||||
for net in self.devices.interface:
|
||||
if not net.model:
|
||||
net.model = default_model
|
||||
|
||||
def _set_sound_defaults(self):
|
||||
if self.os.is_q35():
|
||||
|
@ -340,14 +340,8 @@ class _OsVariant(object):
|
||||
return self._is_related_to(
|
||||
["debian8", "fedora18", "rhel6.0", "sles11sp4"])
|
||||
|
||||
def default_netmodel(self):
|
||||
"""
|
||||
Default non-virtio net-model, since we check for that separately
|
||||
"""
|
||||
for devname in self._device_filter(cls="net"):
|
||||
if devname in ["pcnet", "ne2k_pci", "rtl8139", "e1000"]:
|
||||
return devname
|
||||
return None
|
||||
def supported_netmodels(self):
|
||||
return self._device_filter(cls="net")
|
||||
|
||||
def supports_usbtablet(self):
|
||||
return bool(self._device_filter(cls="input", name="tablet", bus="usb"))
|
||||
|
Loading…
Reference in New Issue
Block a user