2008-10-13 23:48:54 +02:00
|
|
|
Index: xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c
|
|
|
|
===================================================================
|
|
|
|
--- xen-3.3.1-testing.orig/tools/blktap/drivers/blktapctrl.c
|
|
|
|
+++ xen-3.3.1-testing/tools/blktap/drivers/blktapctrl.c
|
2008-11-08 20:32:12 +01:00
|
|
|
@@ -221,6 +221,28 @@ static void add_disktype(blkif_t *blkif,
|
|
|
|
entry->pprev = pprev;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int qemu_instance_has_disks(int domid)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+ int count = 0;
|
|
|
|
+ driver_list_entry_t *entry;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < MAX_DISK_TYPES; i++) {
|
|
|
|
+ entry = active_disks[i];
|
|
|
|
+ while (entry) {
|
|
|
|
+#ifdef ALWAYS_USE_IOEMU
|
|
|
|
+ if (entry->blkif->domid == domid)
|
|
|
|
+#else
|
|
|
|
+ if ((entry->blkif->domid == domid) && dtypes[i]->use_ioemu)
|
|
|
|
+#endif
|
|
|
|
+ count++;
|
|
|
|
+ entry = entry->next;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return (count != 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int del_disktype(blkif_t *blkif)
|
|
|
|
{
|
|
|
|
driver_list_entry_t *entry, **pprev;
|
|
|
|
@@ -245,8 +267,20 @@ static int del_disktype(blkif_t *blkif)
|
2008-10-13 23:48:54 +02:00
|
|
|
DPRINTF("DEL_DISKTYPE: Freeing entry\n");
|
|
|
|
free(entry);
|
|
|
|
|
|
|
|
+#ifdef ALWAYS_USE_IOEMU
|
2008-11-08 20:32:12 +01:00
|
|
|
+ return !qemu_instance_has_disks(blkif->domid);
|
2008-10-13 23:48:54 +02:00
|
|
|
+#else
|
2008-11-08 20:32:12 +01:00
|
|
|
+ /*
|
|
|
|
+ * 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->domid);
|
|
|
|
+
|
2008-10-13 23:48:54 +02:00
|
|
|
/* Caller should close() if no single controller, or list is empty. */
|
2008-11-08 20:32:12 +01:00
|
|
|
return (!dtypes[type]->single_handler || (active_disks[type] == NULL));
|
2008-10-13 23:48:54 +02:00
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int write_msg(int fd, int msgtype, void *ptr, void *ptr2)
|