mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
addhardware: Don't list device 'default' options
This is really only useful for building default XML internally, and for virt-install stuff like --watchdog default. Instead just select the 'default' value in the wizard
This commit is contained in:
parent
f33b6d2750
commit
e8e2c831bf
@ -490,7 +490,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
#####################
|
||||
|
||||
@staticmethod
|
||||
def populate_video_combo(vm, combo, no_default=None):
|
||||
def populate_video_combo(vm, combo):
|
||||
model = combo.get_model()
|
||||
has_spice = bool([g for g in vm.get_graphics_devices()
|
||||
if g.type == g.TYPE_SPICE])
|
||||
@ -505,24 +505,22 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
# Only list QXL video option when VM has SPICE video
|
||||
continue
|
||||
|
||||
if m == tmpdev.MODEL_DEFAULT and no_default:
|
||||
continue
|
||||
model.append([m, tmpdev.pretty_model(m)])
|
||||
|
||||
if len(model) > 0:
|
||||
combo.set_active(0)
|
||||
|
||||
@staticmethod
|
||||
def build_video_combo(vm, combo, no_default=None):
|
||||
def build_video_combo(vm, combo):
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uiutil.init_combo_text_column(combo, 1)
|
||||
combo.get_model().set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
||||
|
||||
vmmAddHardware.populate_video_combo(vm, combo, no_default)
|
||||
vmmAddHardware.populate_video_combo(vm, combo)
|
||||
|
||||
@staticmethod
|
||||
def build_sound_combo(vm, combo, no_default=False):
|
||||
def build_sound_combo(vm, combo):
|
||||
model = Gtk.ListStore(str)
|
||||
combo.set_model(model)
|
||||
uiutil.init_combo_text_column(combo, 0)
|
||||
@ -532,9 +530,6 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
stable_soundmodels = ["ich6", "ich9", "ac97"]
|
||||
|
||||
for m in virtinst.VirtualAudio.MODELS:
|
||||
if m == virtinst.VirtualAudio.MODEL_DEFAULT and no_default:
|
||||
continue
|
||||
|
||||
if (stable_defaults and m not in stable_soundmodels):
|
||||
continue
|
||||
|
||||
@ -543,31 +538,25 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
combo.set_active(0)
|
||||
|
||||
@staticmethod
|
||||
def build_watchdogmodel_combo(vm, combo, no_default=False):
|
||||
def build_watchdogmodel_combo(vm, combo):
|
||||
ignore = vm
|
||||
model = Gtk.ListStore(str)
|
||||
combo.set_model(model)
|
||||
uiutil.init_combo_text_column(combo, 0)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
for m in virtinst.VirtualWatchdog.MODELS:
|
||||
if m == virtinst.VirtualAudio.MODEL_DEFAULT and no_default:
|
||||
continue
|
||||
model.append([m])
|
||||
if len(model) > 0:
|
||||
combo.set_active(0)
|
||||
|
||||
@staticmethod
|
||||
def build_watchdogaction_combo(vm, combo, no_default=False):
|
||||
def build_watchdogaction_combo(vm, combo):
|
||||
ignore = vm
|
||||
model = Gtk.ListStore(str, str)
|
||||
combo.set_model(model)
|
||||
uiutil.init_combo_text_column(combo, 1)
|
||||
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
|
||||
for m in virtinst.VirtualWatchdog.ACTIONS:
|
||||
if m == virtinst.VirtualWatchdog.ACTION_DEFAULT and no_default:
|
||||
continue
|
||||
model.append([m, virtinst.VirtualWatchdog.get_action_desc(m)])
|
||||
if len(model) > 0:
|
||||
combo.set_active(0)
|
||||
|
@ -967,8 +967,6 @@ class vmmDetails(vmmGObjectUI):
|
||||
txtCol.add_attribute(text, 'text', BOOT_LABEL)
|
||||
txtCol.add_attribute(text, 'sensitive', BOOT_ACTIVE)
|
||||
|
||||
no_default = not self.is_customize_dialog
|
||||
|
||||
try:
|
||||
cpu_names = caps.get_cpu_values(self.vm.get_arch())
|
||||
except:
|
||||
@ -1030,23 +1028,19 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
# Sound model
|
||||
sound_dev = self.widget("sound-model")
|
||||
vmmAddHardware.build_sound_combo(self.vm, sound_dev,
|
||||
no_default=no_default)
|
||||
vmmAddHardware.build_sound_combo(self.vm, sound_dev)
|
||||
|
||||
# Video model combo
|
||||
video_dev = self.widget("video-model")
|
||||
vmmAddHardware.build_video_combo(self.vm, video_dev,
|
||||
no_default=no_default)
|
||||
vmmAddHardware.build_video_combo(self.vm, video_dev)
|
||||
|
||||
# Watchdog model combo
|
||||
combo = self.widget("watchdog-model")
|
||||
vmmAddHardware.build_watchdogmodel_combo(self.vm, combo,
|
||||
no_default=no_default)
|
||||
vmmAddHardware.build_watchdogmodel_combo(self.vm, combo)
|
||||
|
||||
# Watchdog action combo
|
||||
combo = self.widget("watchdog-action")
|
||||
vmmAddHardware.build_watchdogaction_combo(self.vm, combo,
|
||||
no_default=no_default)
|
||||
vmmAddHardware.build_watchdogaction_combo(self.vm, combo)
|
||||
|
||||
# Smartcard mode
|
||||
sc_mode = self.widget("smartcard-mode")
|
||||
@ -3071,10 +3065,8 @@ class vmmDetails(vmmGObjectUI):
|
||||
if not vid:
|
||||
return
|
||||
|
||||
no_default = not self.is_customize_dialog
|
||||
vmmAddHardware.populate_video_combo(self.vm,
|
||||
self.widget("video-model"),
|
||||
no_default=no_default)
|
||||
self.widget("video-model"))
|
||||
|
||||
model = vid.model
|
||||
ram = vid.vram
|
||||
|
@ -25,7 +25,7 @@ class VirtualAudio(VirtualDevice):
|
||||
virtual_device_type = VirtualDevice.VIRTUAL_DEV_AUDIO
|
||||
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["es1370", "sb16", "pcspk", "ac97", "ich6", "ich9", MODEL_DEFAULT]
|
||||
MODELS = ["es1370", "sb16", "pcspk", "ac97", "ich6", "ich9"]
|
||||
|
||||
model = XMLProperty("./@model",
|
||||
default_cb=lambda s: "es1370",
|
||||
|
@ -25,10 +25,12 @@ from .xmlbuilder import XMLProperty
|
||||
class VirtualMemballoon(VirtualDevice):
|
||||
virtual_device_type = VirtualDevice.VIRTUAL_DEV_MEMBALLOON
|
||||
|
||||
MODEL_DEFAULT = "virtio"
|
||||
MODELS = ["xen", "none", MODEL_DEFAULT]
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["virtio", "xen", "none"]
|
||||
|
||||
model = XMLProperty("./@model", default_cb=lambda s: s.MODEL_DEFAULT)
|
||||
model = XMLProperty("./@model",
|
||||
default_name=MODEL_DEFAULT,
|
||||
default_cb=lambda s: "virtio")
|
||||
|
||||
|
||||
VirtualMemballoon.register_type()
|
||||
|
@ -30,7 +30,7 @@ class VirtualRedirDevice(VirtualDevice):
|
||||
BUSES = ["usb"]
|
||||
|
||||
TYPE_DEFAULT = "default"
|
||||
TYPES = ["tcp", "spicevmc", TYPE_DEFAULT]
|
||||
TYPES = ["tcp", "spicevmc"]
|
||||
|
||||
@staticmethod
|
||||
def pretty_type(typ):
|
||||
|
@ -27,7 +27,7 @@ class VirtualVideoDevice(VirtualDevice):
|
||||
|
||||
# Default models list
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["cirrus", "vga", "vmvga", "xen", "qxl", MODEL_DEFAULT]
|
||||
MODELS = ["cirrus", "vga", "vmvga", "xen", "qxl"]
|
||||
|
||||
@staticmethod
|
||||
def pretty_model(model):
|
||||
|
@ -28,7 +28,7 @@ class VirtualWatchdog(VirtualDevice):
|
||||
MODEL_I6300 = "i6300esb"
|
||||
MODEL_IB700 = "ib700"
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = [MODEL_I6300, MODEL_IB700, MODEL_DEFAULT]
|
||||
MODELS = [MODEL_I6300, MODEL_IB700]
|
||||
|
||||
ACTION_SHUTDOWN = "shutdown"
|
||||
ACTION_RESET = "reset"
|
||||
@ -39,8 +39,7 @@ class VirtualWatchdog(VirtualDevice):
|
||||
ACTION_DEFAULT = "default"
|
||||
ACTIONS = [ACTION_RESET, ACTION_SHUTDOWN,
|
||||
ACTION_POWEROFF, ACTION_PAUSE,
|
||||
ACTION_NONE, ACTION_DUMP,
|
||||
ACTION_DEFAULT]
|
||||
ACTION_NONE, ACTION_DUMP]
|
||||
|
||||
@staticmethod
|
||||
def get_action_desc(action):
|
||||
@ -54,8 +53,6 @@ class VirtualWatchdog(VirtualDevice):
|
||||
return _("Pause the guest")
|
||||
if action == VirtualWatchdog.ACTION_NONE:
|
||||
return _("No action")
|
||||
if action == VirtualWatchdog.ACTION_DEFAULT:
|
||||
return _("Hypervisor default")
|
||||
return action
|
||||
|
||||
_XML_PROP_ORDER = ["model", "action"]
|
||||
|
Loading…
Reference in New Issue
Block a user