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-unstable] blktapctrl: Fix too early close of pipes

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] blktapctrl: Fix too early close of pipes
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Mar 2009 11:55:14 -0700
Delivery-date: Thu, 12 Mar 2009 11:55:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 1236883586 0
# Node ID d8741d4dd05a4aec44bbdbf67deb2f26e1c934ad
# Parent  f603aeef08086aa735d58d788000781e4736d6b5
blktapctrl: Fix too early close of pipes

Connections to ioemu have single_handler set, so they are closed as
soon as all images of a certain type are closed. This is wrong with
ioemu: All images that belong to the same domain are handled by the
same backend process (usually qemu-dm, but also tapdisk-ioemu for
domains without device model), regardless of the image type.

This patch checks for the same-domain condition for ioemu connections.

Signed-off-by: Kevin Wolf <kwolf@xxxxxxx>
---
 tools/blktap/drivers/blktapctrl.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+)

diff -r f603aeef0808 -r d8741d4dd05a tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Thu Mar 12 18:42:59 2009 +0000
+++ b/tools/blktap/drivers/blktapctrl.c Thu Mar 12 18:46:26 2009 +0000
@@ -231,6 +231,24 @@ static void add_disktype(blkif_t *blkif,
        entry->pprev = pprev;
 }
 
+static int qemu_instance_has_disks(pid_t pid)
+{
+       int i;
+       int count = 0;
+       driver_list_entry_t *entry;
+
+       for (i = 0; i < MAX_DISK_TYPES; i++) {
+               entry = active_disks[i];
+               while (entry) {
+                       if ((entry->blkif->tappid == pid) && 
dtypes[i]->use_ioemu)
+                               count++;
+                       entry = entry->next;
+               }
+       }
+
+       return (count != 0);
+}
+
 static int del_disktype(blkif_t *blkif)
 {
        driver_list_entry_t *entry, **pprev;
@@ -254,6 +272,14 @@ static int del_disktype(blkif_t *blkif)
 
        DPRINTF("DEL_DISKTYPE: Freeing entry\n");
        free(entry);
+
+       /*
+        * When using ioemu, all disks of one VM are connected to the same
+        * qemu-dm instance. We may close the file handle only if there is
+        * no other disk left for this domain.
+        */
+       if (dtypes[type]->use_ioemu)
+               return !qemu_instance_has_disks(blkif->tappid);
 
        /* Caller should close() if no single controller, or list is empty. */
        return (!dtypes[type]->single_handler || (active_disks[type] == NULL));
@@ -721,6 +747,7 @@ static int unmap_blktapctrl(blkif_t *blk
        }
 
        if (del_disktype(blkif)) {
+               DPRINTF("Closing communication pipe to pid %d\n", 
blkif->tappid);
                close(blkif->fds[WRITE]);
                close(blkif->fds[READ]);
        }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] blktapctrl: Fix too early close of pipes, Xen patchbot-unstable <=