[et-mgmt-tools] virt-manager: reuse "storage-file-size" upon "Back"

Jim Meyering jim at meyering.net
Wed Mar 12 09:54:11 UTC 2008


I was surprised when "Back" clobbered a value I'd selected.
I've confirmed that this patch fixes it.

FYI, the "size == None" test appears to be unnecessary, since
the default is set in addhardware.py.  However, this might benefit
from an added sanity check, in case the selected size is too small
(currently, 0 is accepted).  But that is a separate issue.

exporting patch:
# HG changeset patch
# User Jim Meyering <meyering at redhat.com>
# Date 1205314669 -3600
# Node ID 016eb23f596cdc60bc41560ef40f41d2f8bda84e
# Parent  cdc70a3398eaf9f001ae9eb61b54b4ced50e4b50
Reuse user-specified "storage-file-size" upon "Back" button.

In the VM creation dialog, the "Assigning storage space" panel requires
a "File Size:" (when "Simple file:" is selected).  It defaults to 4000MB.
If I specify a different number, click "Forward", and then "Back", rather
than seeing the size *I* chose, I get the default of 4000 again.

This change makes it use the value I selected, instead.

diff --git a/src/virtManager/create.py b/src/virtManager/create.py
--- a/src/virtManager/create.py
+++ b/src/virtManager/create.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006 Red Hat, Inc.
+# Copyright (C) 2006, 2008 Red Hat, Inc.
 # Copyright (C) 2006 Hugh O. Brock <hbrock at redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -726,7 +726,10 @@ class vmmCreate(gobject.GObject):
         if file != None and len(file) > 0 and not(os.path.exists(file)):
             self.window.get_widget("storage-file-size").set_sensitive(True)
             self.window.get_widget("non-sparse").set_sensitive(True)
-            self.window.get_widget("storage-file-size").set_value(4000)
+            size = self.get_config_disk_size()
+            if size == None:
+                size = 4000
+            self.window.get_widget("storage-file-size").set_value(size)
         else:
             self.window.get_widget("storage-file-size").set_sensitive(False)
             self.window.get_widget("non-sparse").set_sensitive(False)




More information about the et-mgmt-tools mailing list