mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
devices: sound: Add set_defaults
This commit is contained in:
parent
40de2c4762
commit
698c72e60d
@ -570,7 +570,8 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
continue
|
||||
values.append([m, DeviceSound.pretty_model(m)])
|
||||
|
||||
_build_combo(combo, values)
|
||||
default = DeviceSound.default_model(vm.xmlobj)
|
||||
_build_combo(combo, values, default_value=default)
|
||||
|
||||
|
||||
def _build_hostdev_treeview(self):
|
||||
|
@ -21,9 +21,11 @@ class _Codec(XMLBuilder):
|
||||
class DeviceSound(Device):
|
||||
XML_NAME = "sound"
|
||||
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["es1370", "sb16", "pcspk", "ac97", "ich6", "ich9"]
|
||||
|
||||
model = XMLProperty("./@model")
|
||||
codecs = XMLChildProperty(_Codec)
|
||||
|
||||
@staticmethod
|
||||
def pretty_model(model):
|
||||
ret = model.upper()
|
||||
@ -31,8 +33,17 @@ class DeviceSound(Device):
|
||||
ret = "HDA (%s)" % model.upper()
|
||||
return ret
|
||||
|
||||
model = XMLProperty("./@model",
|
||||
default_cb=lambda s: "es1370",
|
||||
default_name=MODEL_DEFAULT)
|
||||
|
||||
codecs = XMLChildProperty(_Codec)
|
||||
##################
|
||||
# Default config #
|
||||
##################
|
||||
|
||||
@staticmethod
|
||||
def default_model(guest):
|
||||
if guest.os.is_q35():
|
||||
return "ich9"
|
||||
return "ich6"
|
||||
|
||||
def set_defaults(self, guest):
|
||||
if not self.model:
|
||||
self.model = self.default_model(guest)
|
||||
|
@ -744,7 +744,6 @@ class Guest(XMLBuilder):
|
||||
self._set_graphics_defaults()
|
||||
self._add_spice_devices()
|
||||
self._set_net_defaults()
|
||||
self._set_sound_defaults()
|
||||
|
||||
def _is_full_os_container(self):
|
||||
if not self.os.is_container():
|
||||
@ -1067,16 +1066,6 @@ class Guest(XMLBuilder):
|
||||
if not net.model:
|
||||
net.model = default_model
|
||||
|
||||
def _set_sound_defaults(self):
|
||||
if self.os.is_q35():
|
||||
default = "ich9"
|
||||
else:
|
||||
default = "ich6"
|
||||
|
||||
for sound in self.devices.sound:
|
||||
if sound.model == sound.MODEL_DEFAULT:
|
||||
sound.model = default
|
||||
|
||||
def _spice_supported(self):
|
||||
if not self.conn.is_qemu() and not self.conn.is_test():
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user