|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: remove stubdom device model save file when destroying stubdom
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1323968181 0
# Node ID 01c8b27e3d7d4ad2b469be9922bb04b5eb0195e8
# Parent 27736c7944b903c4945adbee4530c3af863c2545
libxl: remove stubdom device model save file when destroying stubdom
/var/lib/xen/qemu-save.<domid> is created when the stub domain is started
(connected to a stubdom console) and is used to save the device model state on
suspend/migrate but never cleaned up.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
diff -r 27736c7944b9 -r 01c8b27e3d7d tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Thu Dec 15 16:53:52 2011 +0000
+++ b/tools/libxl/libxl_dm.c Thu Dec 15 16:56:21 2011 +0000
@@ -36,6 +36,11 @@
#endif
}
+const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid)
+{
+ return libxl__sprintf(gc, "/var/lib/xen/qemu-save.%d", domid);
+}
+
const char *libxl__domain_device_model(libxl__gc *gc,
libxl_device_model_info *info)
{
@@ -721,7 +726,8 @@
free(filename);
break;
case STUBDOM_CONSOLE_SAVE:
- console[i].output = libxl__sprintf(gc, "file:"SAVEFILE".%d",
info->domid);
+ console[i].output = libxl__sprintf(gc, "file:%s",
+ libxl__device_model_savefile(gc, info->domid));
break;
case STUBDOM_CONSOLE_RESTORE:
if (info->saved_state)
@@ -924,6 +930,8 @@
pid = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc,
"/local/domain/%d/image/device-model-pid", domid));
if (!pid) {
int stubdomid = libxl_get_stubdom_id(ctx, domid);
+ const char *savefile;
+
if (!stubdomid) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't find device
model's pid");
ret = ERROR_INVAL;
@@ -933,6 +941,20 @@
ret = libxl_domain_destroy(ctx, stubdomid, 0);
if (ret)
goto out;
+
+ savefile = libxl__device_model_savefile(gc, domid);
+ ret = unlink(savefile);
+ /*
+ * On suspend libxl__domain_save_device_model will have already
+ * unlinked the save file.
+ */
+ if (ret && errno == ENOENT) ret = 0;
+ if (ret) {
+ LIBXL__LOG_ERRNO(ctx, XTL_ERROR,
+ "failed to remove device-model savefile %s\n",
+ savefile);
+ goto out;
+ }
} else {
ret = kill(atoi(pid), SIGHUP);
if (ret < 0 && errno == ESRCH) {
diff -r 27736c7944b9 -r 01c8b27e3d7d tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Thu Dec 15 16:53:52 2011 +0000
+++ b/tools/libxl/libxl_dom.c Thu Dec 15 16:56:21 2011 +0000
@@ -608,7 +608,7 @@
libxl_ctx *ctx = libxl__gc_owner(gc);
int fd2, c;
char buf[1024];
- char *filename = libxl__sprintf(gc, "/var/lib/xen/qemu-save.%d", domid);
+ const char *filename = libxl__device_model_savefile(gc, domid);
struct stat st;
uint32_t qemu_state_len;
diff -r 27736c7944b9 -r 01c8b27e3d7d tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Thu Dec 15 16:53:52 2011 +0000
+++ b/tools/libxl/libxl_internal.h Thu Dec 15 16:56:21 2011 +0000
@@ -59,7 +59,6 @@
#define STUBDOM_CONSOLE_RESTORE 2
#define STUBDOM_CONSOLE_SERIAL 3
#define STUBDOM_SPECIAL_CONSOLES 3
-#define SAVEFILE "/var/lib/xen/qemu-save"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
@@ -244,6 +243,7 @@
_hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
libxl_domain_type type,
int live, int debug);
+_hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t
domid);
_hidden int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int
fd);
_hidden void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |