Mailing List Archive

[PATCH] libxl: do not leak qemu saved state on restore (Was: Re: [xen-unstable test] 10481: regressions - FAIL)
On Tue, 2011-12-13 at 09:44 +0000, Ian Campbell wrote:
>
> > test-amd64-i386-xend-winxpsp3 16 leak-check/check fail never pass
> > test-i386-i386-win 16 leak-check/check fail never pass
> > test-amd64-i386-win-vcpus1 16 leak-check/check fail never pass
> > test-amd64-i386-win 16 leak-check/check fail never pass
>
> These all leaked a load of /var/lib/xen/qemu-resume.N. This should be
> quick & easy to fix, I'll have a look.

These happen to all be xend failures but the only reason xl doesn't have
this is that those tests all fail at the guest-stop stage and never get
as far as the migration test. Here is the fix for the xl version, fixing
the xend side seems less trivial and I don't propose to dig into it.

Ian.

8<--------------------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1323772303 0
# Node ID 9ea12474c6dcd75bbbc7a5c62a2b96de902ccb83
# Parent 88df802b4905d7e34032eacf1942b70c76d150a4
libxl: do not leak qemu saved state on restore

In particular do not leak /var/lib/xen/qemu-resume.<domid>.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 88df802b4905 -r 9ea12474c6dc tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Mon Dec 12 17:43:55 2011 +0000
+++ b/tools/libxl/libxl_create.c Tue Dec 13 10:31:43 2011 +0000
@@ -622,7 +622,7 @@ static int do_domain_create(libxl__gc *g
== LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
libxl__qmp_initializations(ctx, domid);
}
- ret = libxl__confirm_device_model_startup(gc, dm_starting);
+ ret = libxl__confirm_device_model_startup(gc, dm_info, dm_starting);
if (ret < 0) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"device model did not start: %d", ret);
diff -r 88df802b4905 -r 9ea12474c6dc tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Mon Dec 12 17:43:55 2011 +0000
+++ b/tools/libxl/libxl_dm.c Tue Dec 13 10:31:43 2011 +0000
@@ -753,7 +753,8 @@ retry_transaction:
ret = ERROR_FAIL;
goto out_free;
}
- if (libxl__confirm_device_model_startup(gc, dm_starting) < 0) {
+ if (libxl__confirm_device_model_startup(gc, &xenpv_dm_info,
+ dm_starting) < 0) {
ret = ERROR_FAIL;
goto out_free;
}
@@ -894,14 +895,26 @@ out:


int libxl__confirm_device_model_startup(libxl__gc *gc,
- libxl__spawner_starting *starting)
+ libxl_device_model_info *dm_info,
+ libxl__spawner_starting *starting)
{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
char *path;
int domid = starting->domid;
+ int ret, ret2;
path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid);
- return libxl__spawn_confirm_offspring_startup(gc,
+ ret = libxl__spawn_confirm_offspring_startup(gc,
LIBXL_DEVICE_MODEL_START_TIMEOUT,
"Device Model", path, "running", starting);
+ if (dm_info->saved_state) {
+ ret2 = unlink(dm_info->saved_state);
+ if (ret2) LIBXL__LOG_ERRNO(ctx, XTL_ERROR,
+ "failed to remove device-model state %s\n",
+ dm_info->saved_state);
+ /* Do not clobber spawn_confirm error code with unlink error code. */
+ if (!ret) ret = ret2;
+ }
+ return ret;
}

int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
diff -r 88df802b4905 -r 9ea12474c6dc tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Mon Dec 12 17:43:55 2011 +0000
+++ b/tools/libxl/libxl_internal.h Tue Dec 13 10:31:43 2011 +0000
@@ -419,6 +419,7 @@ _hidden int libxl__need_xenpv_qemu(libxl
* return pass *starting_r (which will be non-0) to
* libxl__confirm_device_model_startup or libxl__detach_device_model. */
_hidden int libxl__confirm_device_model_startup(libxl__gc *gc,
+ libxl_device_model_info *dm_info,
libxl__spawner_starting *starting);
_hidden int libxl__detach_device_model(libxl__gc *gc, libxl__spawner_starting *starting);
_hidden int libxl__wait_for_device_model(libxl__gc *gc,



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
[PATCH] libxl: do not leak qemu saved state on restore (Was: Re: [xen-unstable test] 10481: regressions - FAIL) [ In reply to ]
Ian Campbell writes ("[Xen-devel] [PATCH] libxl: do not leak qemu saved state on restore (Was: Re: [xen-unstable test] 10481: regressions - FAIL)"):
> These happen to all be xend failures but the only reason xl doesn't have
> this is that those tests all fail at the guest-stop stage and never get
> as far as the migration test. Here is the fix for the xl version, fixing
> the xend side seems less trivial and I don't propose to dig into it.

Thanks.

> # HG changeset patch
> # User Ian Campbell <ian.campbell@citrix.com>
> # Date 1323772303 0
> # Node ID 9ea12474c6dcd75bbbc7a5c62a2b96de902ccb83
> # Parent 88df802b4905d7e34032eacf1942b70c76d150a4
> libxl: do not leak qemu saved state on restore
>
> In particular do not leak /var/lib/xen/qemu-resume.<domid>.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel