WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-3.1-testing] [HVM] Save/restore: don't leak shared-

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.1-testing] [HVM] Save/restore: don't leak shared-memory segments after HVM
From: "Xen patchbot-3.1-testing" <patchbot-3.1-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Feb 2008 07:11:44 -0800
Delivery-date: Fri, 22 Feb 2008 07:34:57 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1203529827 0
# Node ID c374d4d0945c5b335d380e707936ccc0958d3950
# Parent  4fb1c626023ea35e83da0e74786516d8a9b2894d
[HVM] Save/restore: don't leak shared-memory segments after HVM
live-migrate.
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
xen-unstable changeset:   15645:07655ed2fe58ebf883b8a4b5c2dccf15576f4778
xen-unstable date:        Thu Jul 26 12:00:32 2007 +0100
---
 tools/xcutils/xc_save.c |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff -r 4fb1c626023e -r c374d4d0945c tools/xcutils/xc_save.c
--- a/tools/xcutils/xc_save.c   Mon Feb 18 17:19:08 2008 +0000
+++ b/tools/xcutils/xc_save.c   Wed Feb 20 17:50:27 2008 +0000
@@ -54,7 +54,17 @@ static int suspend(int domid)
 
 static char *qemu_active_path;
 static char *qemu_next_active_path;
+static int qemu_shmid = -1;
 static struct xs_handle *xs;
+
+
+/* Mark the shared-memory segment for destruction */
+static void qemu_destroy_buffer(void)
+{
+    if (qemu_shmid != -1)
+        shmctl(qemu_shmid, IPC_RMID, NULL);
+    qemu_shmid = -1;
+}
 
 /* Get qemu to change buffers. */
 static void qemu_flip_buffer(int domid, int next_active)
@@ -97,22 +107,23 @@ static void * init_qemu_maps(int domid, 
 {
     key_t key;
     char key_ascii[17] = {0,};
-    int shmid = -1;
     void *seg; 
     char *path, *p;
 
     /* Make a shared-memory segment */
-    while (shmid == -1)
-    {
+    do {
         key = rand(); /* No security, just a sequence of numbers */
-        shmid = shmget(key, 2 * bitmap_size, 
+        qemu_shmid = shmget(key, 2 * bitmap_size, 
                        IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR);
-        if (shmid == -1 && errno != EEXIST)
+        if (qemu_shmid == -1 && errno != EEXIST)
             errx(1, "can't get shmem to talk to qemu-dm");
-    }
+    } while (qemu_shmid == -1);
+
+    /* Remember to tidy up after ourselves */
+    atexit(qemu_destroy_buffer);
 
     /* Map it into our address space */
-    seg = shmat(shmid, NULL, 0);
+    seg = shmat(qemu_shmid, NULL, 0);
     if (seg == (void *) -1) 
         errx(1, "can't map shmem to talk to qemu-dm");
     memset(seg, 0, 2 * bitmap_size);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.1-testing] [HVM] Save/restore: don't leak shared-memory segments after HVM, Xen patchbot-3.1-testing <=