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 682901 - libvirt-machine: Don't leak volume on failed stop or delete
libvirt-machine: Don't leak volume on failed stop or delete
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-08-28 21:10 UTC by Zeeshan Ali
Modified: 2016-03-31 13:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libvirt-machine: Only stop running or paused machines (1.61 KB, patch)
2012-08-28 21:10 UTC, Zeeshan Ali
reviewed Details | Review
libvirt-machine: Don't leak volume on failed stop or delete (1.97 KB, patch)
2012-08-29 14:49 UTC, Zeeshan Ali
none Details | Review
libvirt-machine: Don't leak volume on failed stop or delete (2.08 KB, patch)
2012-08-29 15:56 UTC, Zeeshan Ali
committed Details | Review

Description Zeeshan Ali 2012-08-28 21:10:00 UTC
The patch in bug#682792 introduced a leak of storage volume. The attached patch fixes it.
Comment 1 Zeeshan Ali 2012-08-28 21:10:01 UTC
Created attachment 222683 [details] [review]
libvirt-machine: Only stop running or paused machines

If domain is already stopped, don't try to stop it. Doing so will only
trigger an error and the following code to delete the volume won't be
executed, resulting in a leak of storage volume.

You can reproduce the issue easily by hitting 'Cancel' at the review
page of wizard.
Comment 2 Christophe Fergeau 2012-08-29 07:34:43 UTC
Review of attachment 222683 [details] [review]:

::: src/libvirt-machine.vala
@@ +394,3 @@
                     // Ensure that the domain is stopped before we touch any data
+                    if (state == MachineState.RUNNING || state == MachineState.PAUSED)
+                        domain.stop (0);

I'd rather we do the stop unconditionally and just catch the potential exceptions. If stop() raise an exception in another case we haven't thought about, this new code will get the same leak.
Comment 3 Alexander Larsson 2012-08-29 07:36:32 UTC
I agree, lets just put each operation in its own try/catch.
Comment 4 Zeeshan Ali 2012-08-29 14:49:53 UTC
Created attachment 222794 [details] [review]
libvirt-machine: Don't leak volume on failed stop or delete

If domain is already stopped, attempting to stop it will fail. Put all
clean-up operations related to deletion in their own try/catch block so
failure of one doesn't mean the others wont be executed.
Comment 5 Christophe Fergeau 2012-08-29 15:01:20 UTC
Review of attachment 222794 [details] [review]:

::: src/libvirt-machine.vala
@@ +401,2 @@
                 } catch (GLib.Error err) {
                     warning (err.message);

Dunno if we want to always warn as this will happen in legit cases
Comment 6 Zeeshan Ali 2012-08-29 15:05:08 UTC
(In reply to comment #5)
> Review of attachment 222794 [details] [review]:
> 
> ::: src/libvirt-machine.vala
> @@ +401,2 @@
>                  } catch (GLib.Error err) {
>                      warning (err.message);
> 
> Dunno if we want to always warn as this will happen in legit cases

How do we filter? Ignore if domain was in running or paused state?
Comment 7 Christophe Fergeau 2012-08-29 15:08:54 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Review of attachment 222794 [details] [review] [details]:
> > 
> > ::: src/libvirt-machine.vala
> > @@ +401,2 @@
> >                  } catch (GLib.Error err) {
> >                      warning (err.message);
> > 
> > Dunno if we want to always warn as this will happen in legit cases
> 
> How do we filter? Ignore if domain was in running or paused state?

Or just always log to debug and remove the warning ?
Comment 8 Zeeshan Ali 2012-08-29 15:56:00 UTC
Created attachment 222801 [details] [review]
libvirt-machine: Don't leak volume on failed stop or delete

V2: Change a warning to debug
Comment 9 Alexander Larsson 2012-08-30 08:33:35 UTC
Review of attachment 222801 [details] [review]:

Looks good to me
Comment 10 Zeeshan Ali 2012-08-30 12:15:18 UTC
Attachment 222801 [details] pushed as d78d431 - libvirt-machine: Don't leak volume on failed stop or delete