mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Handle storage formats properly
This simple patch fixes three issues: 1) We used only one list of storage formats. However, we are able to use some formats which we cannot create. This patch adds a list called 'no_create_formats' and moves such formats (currently only one) into it and uses new parameter 'create' which describes whether such formats should be removed or not. 2) When creating new storage with the above fixed, we need to set the combobox's text to "" in order not to change it to "raw". This was already done in reset_state(), but we need it also when toggle_storage_select() happens and it doesn't hurt in set_initial_state(), so I abstracted the implementation into populate_disk_format_combo(). 3) It's a bit unrelated, but when bus of a domain disk gets changed (in details.py), the address was not cleaned up properly ('target' attribute was still kept), so I fixed up the VirtualDeviceAddress as well. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=907289
This commit is contained in:
parent
64b1ca15f2
commit
3b9c397d11
@ -252,8 +252,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
uihelpers.build_cache_combo(self.vm, cache_list)
|
||||
|
||||
# Disk format mode
|
||||
format_list = self.widget("config-storage-format")
|
||||
uihelpers.build_storage_format_combo(self.vm, format_list)
|
||||
self.populate_disk_format_combo(True)
|
||||
|
||||
# Sparse tooltip
|
||||
sparse_info = self.widget("config-storage-nosparse-info")
|
||||
@ -429,9 +428,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self.widget("config-storage-size").set_value(8)
|
||||
self.widget("config-storage-entry").set_text("")
|
||||
self.widget("config-storage-nosparse").set_active(True)
|
||||
# Don't specify by default, so we don't overwrite possibly working
|
||||
# libvirt detection
|
||||
self.widget("config-storage-format").get_child().set_text("")
|
||||
self.populate_disk_format_combo(True)
|
||||
target_list = self.widget("config-storage-devtype")
|
||||
self.populate_target_device_model(target_list.get_model())
|
||||
if len(target_list.get_model()) > 0:
|
||||
@ -593,6 +590,12 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
model.append([_("No Devices Available"), None])
|
||||
uihelpers.set_list_selection(devlist, 0)
|
||||
|
||||
def populate_disk_format_combo(self, create):
|
||||
format_list = self.widget("config-storage-format")
|
||||
uihelpers.update_storage_format_combo(self.vm, format_list, create)
|
||||
if not create:
|
||||
format_list.get_child().set_text("")
|
||||
|
||||
########################
|
||||
# get_config_* methods #
|
||||
########################
|
||||
@ -942,6 +945,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
def toggle_storage_select(self, src):
|
||||
act = src.get_active()
|
||||
self.widget("config-storage-browse-box").set_sensitive(act)
|
||||
self.populate_disk_format_combo(not act)
|
||||
|
||||
def set_disk_storage_path(self, ignore, path):
|
||||
self.widget("config-storage-entry").set_text(path)
|
||||
|
@ -960,7 +960,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
# Disk format combo
|
||||
format_list = self.widget("disk-format")
|
||||
uihelpers.build_storage_format_combo(self.vm, format_list)
|
||||
uihelpers.update_storage_format_combo(self.vm, format_list, False)
|
||||
|
||||
# Disk bus combo
|
||||
disk_bus = self.widget("disk-bus-combo")
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2006 Red Hat, Inc.
|
||||
# Copyright (C) 2006, 2013 Red Hat, Inc.
|
||||
# Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -419,20 +419,26 @@ def build_vnc_keymap_combo(vm, combo, no_default=False):
|
||||
# Storage format list/combo helpers #
|
||||
#####################################
|
||||
|
||||
def build_storage_format_combo(vm, combo):
|
||||
def update_storage_format_combo(vm, combo, create):
|
||||
dev_model = Gtk.ListStore(str)
|
||||
combo.set_model(dev_model)
|
||||
combo.set_entry_text_column(0)
|
||||
|
||||
formats = ["raw", "qcow2", "qed"]
|
||||
no_create_formats = []
|
||||
if vm.rhel6_defaults():
|
||||
formats.append("vmdk")
|
||||
formats.append("vdi")
|
||||
no_create_formats.append("vdi")
|
||||
|
||||
for m in formats:
|
||||
dev_model.append([m])
|
||||
if not create:
|
||||
for m in no_create_formats:
|
||||
dev_model.append([m])
|
||||
|
||||
combo.set_active(0)
|
||||
if create:
|
||||
# TODO: make the default storage format configurable
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
#######################################################################
|
||||
|
@ -135,7 +135,8 @@ class VirtualDeviceAddress(XMLBuilder):
|
||||
ADDRESS_TYPE_SPAPR_VIO]
|
||||
|
||||
_XML_ROOT_XPATH = "/domain/devices/device/address"
|
||||
_XML_PROP_ORDER = ["type", "domain", "bus", "slot", "function"]
|
||||
_XML_PROP_ORDER = ["type", "domain", "controller", "bus", "slot",
|
||||
"function", "target", "unit"]
|
||||
|
||||
def set_addrstr(self, addrstr):
|
||||
if addrstr is None:
|
||||
@ -163,3 +164,4 @@ class VirtualDeviceAddress(XMLBuilder):
|
||||
controller = XMLProperty(xpath="./address/@controller", is_int=True)
|
||||
unit = XMLProperty(xpath="./address/@unit", is_int=True)
|
||||
port = XMLProperty(xpath="./address/@port", is_int=True)
|
||||
target = XMLProperty(xpath="./address/@target", is_int=True)
|
||||
|
Loading…
Reference in New Issue
Block a user