After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 756140 - Resizing hard disk is broken if VM has snapshots
Resizing hard disk is broken if VM has snapshots
Status: RESOLVED OBSOLETE
Product: gnome-boxes
Classification: Applications
Component: general
3.16.x
Other Linux
: Normal normal
: 3.22
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
: 766690 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-10-06 20:09 UTC by Michael Catanzaro
Modified: 2018-01-11 10:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libvirt-machine-props: Allow resize of disk w/ snapshots (3.25 KB, patch)
2016-04-01 23:06 UTC, Zeeshan Ali
committed Details | Review

Description Michael Catanzaro 2015-10-06 20:09:10 UTC
After resizing my VM's hard disk, when I reopen the Properties dialog the setting has not been saved: it's back to the original size.

The problem is this:

Boxes-WARNING **: libvirt-machine-properties.vala:594: Failed to change storage capacity of volume 'boxes-unknown' to 40149525456: Unable to resize volume storage: internal error: Child process (/usr/bin/qemu-img resize /home/mcatanzaro/.local/share/gnome-boxes/images/boxes-unknown 40149525504) unexpected exit status 1: qemu-img: Can't resize an image which has snapshots
qemu-img: This image does not support resize

Deleting my snapshot makes resizing work.
Comment 1 Zeeshan Ali 2015-10-12 16:50:45 UTC
I guess the solution would be to:

1. Delete the snapshots before resizing.

2. Inform the user with an infobar, that resizing will result in snapshots being deleted.

However, we can't do that for 3.18 as it breaks UI/string freeze. Any ideas on how to handle this in 3.18? And no, we can't just not show resize slider, cause users will get really confused if a UI disappears without any clue of why.
Comment 2 Michael Catanzaro 2015-10-12 17:47:53 UTC
I think you can either get a freeze exception or else just leave in broken in 3.18. Fixing it in 3.18 would be nice, but most important is to make sure it's fixed going forward....
Comment 3 Matthias Clasen 2016-03-14 14:23:35 UTC
And now we'll already need a 3.20 freeze exception...
Comment 4 Jakub Steiner 2016-03-30 15:31:16 UTC
Of course being able to resize without throwing away snapshots would be the right way™ forward. But if technically not feasible, we should notify the action will throw away the snapshots.

Having a modal "are you sure" dialog might be the most straight forward approach, but people habituate to click through and then realize they didn't actually mean to throw away the snapshots.

A better approach would be to do the size change and throw away the snapshots, showing a "Box has been resized, pruning all snapshots. [undo]" in-app notification.
Comment 5 Zeeshan Ali 2016-03-30 15:38:11 UTC
File a bug on Qemu about this issue, let's see if its technically possible to fix the actual issue: https://bugs.launchpad.net/qemu/+bug/1563931
Comment 6 Zeeshan Ali 2016-04-01 23:06:05 UTC
Created attachment 325193 [details] [review]
libvirt-machine-props: Allow resize of disk w/ snapshots

Since it is currently not possible to resize a disk image if it has
snapshots on it, resize operation ends up not working with a warning on
the console. Let's fix that by deleting all associated snapshots before
attempting to resize the disk image but not before notifying user about
what we are about to do.
Comment 7 Zeeshan Ali 2016-04-01 23:10:57 UTC
I'm not sure of the wording in the notification I used:

1 snapshot:         "Storage resize requires deleting associated snapshot."
multiple snapshots: "Storage resize requires deleting %llu associated snapshots."

Better alternatives?

Also it's a be weird that we give the impression that disk has been resized already even though it's not yet been resized cause snapshots has to be deleted first and we can't just delete them and then bring them back if user clicks "Undo". So that's another reason I didn't push this yet.
Comment 8 Michael Catanzaro 2016-04-02 02:07:54 UTC
Yeah, that's one issue....

I don't think an undo notification is a good solution for this. It's not like a delete button where the user knows the option is destructive. Here, the user has no expectation that the resize will delete snapshots; the first clue will be the notification that snapshots have been deleted (even if they haven't been yet).

I almost think a pop-up confirmation dialog would make sense in this case.

Maybe we could make the undo notification work by adding an explanatory label under the resize slider, warning that resizing will delete your snapshots; then I think the undo notification would be sufficien. We probably should also add a label to make clear that the action is irreversible; i.e. you can only resize up, never down. That's currently confusing.
Comment 9 Jakub Steiner 2016-04-04 18:11:11 UTC
In retrospect I agree learning about the behavior only after the destructive behavior has occurred is bad. Zeenix suggested a less intrusive infobar for this, but as the resizing is instant apply, it would have to have the equivalent of "delete snapshots and resize" action button. It would essentially act like a modal dialog you can choose to ignore. It's odd [1]. Maybe a modal is still the best option we have.

[1] Odd - https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/boxes/wires/odd-resizing-inline-modal.png - don't do this ;)
Comment 10 Michael Catanzaro 2016-04-04 19:20:59 UTC
Keep in mind: not only the act of deleting snapshots is destructive, but also the act of resizing, as it is impossible to size down the VM once the size has been increased. If that slider is really instant-apply, then I am confused as to how the slider could possibly work properly if it's slid to the right and then back left.
Comment 11 Zeeshan Ali 2016-04-05 10:48:38 UTC
No guys, the slider is NOT instantly applied. :) It only applies after properties window is closed.
Comment 12 Michael Catanzaro 2016-05-25 14:30:41 UTC
*** Bug 766690 has been marked as a duplicate of this bug. ***
Comment 13 Maciej (Matthew) Piechotka 2017-06-09 16:55:16 UTC
(In reply to Michael Catanzaro from comment #10)
> Keep in mind: not only the act of deleting snapshots is destructive, but
> also the act of resizing, as it is impossible to size down the VM once the
> size has been increased. If that slider is really instant-apply, then I am
> confused as to how the slider could possibly work properly if it's slid to
> the right and then back left.

Would it be possible to see where is the last partition in MBR or GPT? Any space afterwards should be free and resizable.
Comment 14 Michael Catanzaro 2017-09-21 04:55:44 UTC
OK, I've discovered this bug is exacerbated quite badly by the fact that Boxes now takes an initial "Just installed" snapshot when creating a VM. So... yeah.

(In reply to Zeeshan Ali (Khattak) from comment #6)
> Created attachment 325193 [details] [review] [review]
> libvirt-machine-props: Allow resize of disk w/ snapshots

I think I would push this patch. Even though it's a weird restriction, warning the user is a lot better than silently failing to perform the resize operation.
Comment 15 Michael Catanzaro 2017-09-21 04:58:47 UTC
Also I noticed today that after deleting a snapshot, Boxes tries to delete it again and again forever, once every five seconds or so. Each time, it prints this error message:

(gnome-boxes:17794): Boxes-WARNING **: snapshot-list-row.vala:188: Error while deleting snapshot 2016-09-22-23-42-04: Unable to delete snapshot `2016-09-22-23-42-04'

I think the first attempt to delete the snapshot succeeded (since I was able to resize ;) and the subsequent attempts are all failing because it's already deleted.
Comment 16 Felipe Borges 2017-10-02 11:43:10 UTC
Review of attachment 325193 [details] [review]:

(In reply to Michael Catanzaro from comment #14)
> OK, I've discovered this bug is exacerbated quite badly by the fact that
> Boxes now takes an initial "Just installed" snapshot when creating a VM.
> So... yeah.
> 
> (In reply to Zeeshan Ali (Khattak) from comment #6)
> > Created attachment 325193 [details] [review] [review] [review]
> > libvirt-machine-props: Allow resize of disk w/ snapshots
> 
> I think I would push this patch. Even though it's a weird restriction,
> warning the user is a lot better than silently failing to perform the resize
> operation.

+1

::: src/libvirt-machine-properties.vala
@@ +629,3 @@
+            };
+
+            var msg = ngettext ("Storage resize requires deleting associated snapshot.",

What if instead of "Undo" we would go for something like "Restore Snapshots"?
Comment 17 Felipe Borges 2017-10-02 11:46:23 UTC
Anyway, I would land this for now and we can revisit the feature later.

(In reply to Michael Catanzaro from comment #15)
> Also I noticed today that after deleting a snapshot, Boxes tries to delete
> it again and again forever, once every five seconds or so. Each time, it
> prints this error message:
> 
> (gnome-boxes:17794): Boxes-WARNING **: snapshot-list-row.vala:188: Error
> while deleting snapshot 2016-09-22-23-42-04: Unable to delete snapshot
> `2016-09-22-23-42-04'
> 
> I think the first attempt to delete the snapshot succeeded (since I was able
> to resize ;) and the subsequent attempts are all failing because it's
> already deleted.

Which gnome-boxes --version do you have? Could you please file another bug for this one?
Comment 18 Felipe Borges 2017-10-02 11:51:41 UTC
Comment on attachment 325193 [details] [review]
libvirt-machine-props: Allow resize of disk w/ snapshots

Attachment 325193 [details] pushed as 1c61d1b - libvirt-machine-props: Allow resize of disk w/ snapshots
Attachment 325193 [details] pushed as 458fc08f - libvirt-machine-props: Allow resize of disk w/ snapshots
Comment 19 Rafal Luzynski 2017-10-02 21:23:00 UTC
Review of attachment 325193 [details] [review]:

::: src/libvirt-machine-properties.vala
@@ +618,3 @@
+            var msg = ngettext ("Storage resize requires deleting associated snapshot.",
+                                "Storage resize requires deleting %llu associated snapshots.",
+                                num_snapshots).printf (num_snapshots);

Please be aware that this will not work as you think it will. First, there are languages (Chinese, Japanese, Korean, and probably more) which don't have a plural number. Translators have a choice of only one form. This means that "Storage resize requires deleting %llu associated snapshots" will be always displayed, even if the number is 1. Second, even worse, some languages (Russian, Serbian, and probably more) reuse the singular form if the number is 21, 31, 41…. So if there are 21 snapshots to delete it will say there is a single snapshot to delete. If you want to achieve the correct result you must make it explicit:

if (num_snapshots == 1)
    msg = "Storage resize requires deleting associated snapshot."
else
    msg = ngettext ("Storage resize requires deleting %llu associated snapshot.",
                    "Storage resize requires deleting %llu associated snapshots."
                    num_snapshots).printf (num_snapshots);

While at this, I can see the same problem with "_Open in new window"/"_Open in %u new windows".

One more nitpick: shouldn't it be "Storage resize requires deleting *an* associated snapshot"? (Native English speakers, please help.)
Comment 20 Michael Catanzaro 2017-10-03 09:54:18 UTC
(In reply to Rafal Luzynski from comment #19)
> Review of attachment 325193 [details] [review] [review]:
> 
> ::: src/libvirt-machine-properties.vala
> @@ +618,3 @@
> +            var msg = ngettext ("Storage resize requires deleting
> associated snapshot.",
> +                                "Storage resize requires deleting %llu
> associated snapshots.",
> +                                num_snapshots).printf (num_snapshots);
> 
> Please be aware that this will not work as you think it will.

Also, because Vala is wonderful, that's going to compile to a g_strdup_printf() followed by ngettext(), not vice versa as we desire, so it won't be translated at all. The workaround is to call ngettext() first, store it into a local variable, and then call printf() on the next line. See bug #788387.
 
> One more nitpick: shouldn't it be "Storage resize requires deleting *an*
> associated snapshot"? (Native English speakers, please help.)

Yes, either "an associated snapshot" or "one associated snapshot"
Comment 21 Felipe Borges 2017-10-31 11:19:18 UTC
My understanding is that it really does not matter how many snapshots are there as long as there is One which would prevent the resizing.

So I would suggest a single sentence such as "Storage resizing requires deleting the associated snapshots."

Thoughts?
Comment 22 Felipe Borges 2017-10-31 11:36:55 UTC
(In reply to Rafal Luzynski from comment #19)
> While at this, I can see the same problem with "_Open in new window"/"_Open
> in %u new windows".

In Czech there are three different inflections:
- for the single case = okno
- for [2, 3, 4] = okna
- quantities greater than 5 = oken

So for the plural, if any, we could say "Open in multiple windows". What do you think?
Comment 23 Felipe Borges 2017-10-31 11:38:45 UTC
Is there a wiki page or something of this sort where we could list these particularities and promote awareness about it for the whole gnome community?
Comment 24 André Klapper 2017-10-31 13:51:39 UTC
Felipe: https://wiki.gnome.org/TranslationProject/DevGuidelines
Comment 25 Rafal Luzynski 2017-11-02 22:11:26 UTC
(In reply to Felipe Borges from comment #22)
> [...]
> In Czech there are three different inflections:
> - for the single case = okno
> - for [2, 3, 4] = okna
> - quantities greater than 5 = oken

This is handled fine by gettext, you should not deal with this manually. My only point is that you should not assume that:

- all languages have singular and plural numbers,
- a value equal to 1 uses a singular number and no other value uses a singular number.

> So for the plural, if any, we could say "Open in multiple windows". What do
> you think?

No, I don't think we should change the design in order to workaround bugs. Instead we should fix bugs. But, taking into account what Michael said in comment 20 this time it may be difficult.

(In reply to André Klapper from comment #24)

Good link, André. Also, more:

http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
https://en.wikipedia.org/wiki/Grammatical_number
https://github.com/abrt/gnome-abrt/issues/112#issuecomment-152846843
Comment 26 GNOME Infrastructure Team 2018-01-11 10:27:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-boxes/issues/72.