addstorage: Return to using qcow2 sparse by default

https://bugzilla.redhat.com/show_bug.cgi?id=1759454

See 15a6a7e210

The idea behind virt-manager's sparse vs nonsparse default, is that if
the user selected 'raw' for as the default image format, assume they
want to maximize performance, so fully allocate the disk.

qcow2 didn't support anything except sparse, so the sparse=True vs
sparse=False made no difference. So we always set sparse=False

Then qcow2 grows non-sparse support, and virt-manager is suddenly
defaulting to it, which is not the intention.

Default to sparse when requested format isn't raw

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-09-19 18:06:45 -04:00
parent 6f8b9c13a7
commit ba08f84b34
3 changed files with 11 additions and 11 deletions

View File

@ -155,11 +155,8 @@ def testAddDisks(app):
tab.combo_select("Cache mode:", "none")
tab.combo_select("Discard mode:", "ignore")
tab.combo_select("Detect zeroes:", "unmap")
# Size too big
tab.find("GiB", "spin button").set_text("2000")
_finish(addhw, check=None)
app.click_alert_button("not enough free space", "Close")
tab.find("GiB", "spin button").set_text("1.5")
# High number but we are non-sparse by default so it won't complain
tab.find("GiB", "spin button").set_text("200000")
_finish(addhw, check=details)
# USB disk with removable setting

View File

@ -190,12 +190,11 @@ def testNewVMStorage(app):
_forward(newvm)
_forward(newvm)
# Trigger size validation failure
# qcow2 default shouldn't trigger size error
sizetext = newvm.find(None, "spin button", "GiB")
sizetext.set_text("10000000")
_forward(newvm, check=False)
app.click_alert_button("Storage parameter error", "OK")
sizetext.set_text("1")
_forward(newvm)
_back(newvm)
# Use the storage browser to select a local file
storagetext = newvm.find("storage-entry")

View File

@ -251,14 +251,18 @@ class vmmAddStorage(vmmGObjectUI):
if disk.wants_storage_creation():
pool = disk.get_parent_pool()
size = uiutil.spin_get_helper(self.widget("storage-size"))
sparse = False
fmt = self.conn.get_default_storage_format()
# If the user changed the default disk format to raw, assume
# they want to maximize performance, so fully allocate the
# disk image. Otherwise use sparse
sparse = fmt != 'raw'
vol_install = virtinst.DeviceDisk.build_vol_install(
disk.conn, os.path.basename(disk.path), pool,
size, sparse)
disk.set_vol_install(vol_install)
fmt = self.conn.get_default_storage_format()
if disk.get_vol_install().supports_format():
log.debug("Using default prefs format=%s for path=%s",
fmt, disk.path)