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-devel

[Xen-devel] [PATCH] qemu-xen: Fix open_disk for blktap disks

To: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] qemu-xen: Fix open_disk for blktap disks
From: Kevin Wolf <kwolf@xxxxxxx>
Date: Mon, 06 Oct 2008 16:38:06 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 06 Oct 2008 07:37:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.12 (X11/20071114)
qemu-xen: Fix open_disk for blktap disks

If blktap drives are registered properly, qemu code is much less likely
to get confused by them. Use bdrv_new(), assign a device name and create
an entry in drives_table for them.

Signed-off-by: Kevin Wolf <kwolf@xxxxxxx>
Index: qemu-xen/hw/xen_blktap.c
===================================================================
--- qemu-xen.orig/hw/xen_blktap.c
+++ qemu-xen/hw/xen_blktap.c
@@ -32,6 +32,11 @@
 #include <errno.h>
 #include <stdlib.h>
 
+#ifndef QEMU_TOOL
+#include "qemu-common.h"
+#include "sysemu.h"
+#endif
+
 #include "xen_blktap.h"
 #include "block_int.h"
 #include "qemu-char.h"
@@ -217,13 +222,15 @@ static int map_new_dev(struct td_state *
 
 static int open_disk(struct td_state *s, char *path, int readonly)
 {
-       struct disk_id id;
        BlockDriverState* bs;
+       char* devname;
+       static int devnumber = 0;
+       int i;
 
-       DPRINTF("Opening %s\n", path);
-       bs = calloc(1, sizeof(*bs));
-
-       memset(&id, 0, sizeof(struct disk_id));
+       DPRINTF("Opening %s as blktap%d\n", path, devnumber);
+       asprintf(&devname, "blktap%d", devnumber++);
+       bs = bdrv_new(devname);
+       free(devname);
 
        if (bdrv_open(bs, path, 0) != 0) {
                fprintf(stderr, "Could not open image file %s\n", path);
@@ -237,6 +244,18 @@ static int open_disk(struct td_state *s,
 
        s->info = ((s->flags & TD_RDONLY) ? VDISK_READONLY : 0);
 
+#ifndef QEMU_TOOL
+       for (i = 0; i < MAX_DRIVES + 1; i++) {
+               if (drives_table[i].bdrv == NULL) {
+                       drives_table[i].bdrv = bs;
+                       drives_table[i].type = IF_BLKTAP;
+                       drives_table[i].bus = 0;
+                       drives_table[i].unit = 0;
+                       break;
+               }
+       }
+#endif
+
        return 0;
 }
 
Index: qemu-xen/hw/xen_blktap.h
===================================================================
--- qemu-xen.orig/hw/xen_blktap.h
+++ qemu-xen/hw/xen_blktap.h
@@ -30,11 +30,6 @@ typedef uint32_t td_flag_t;
 
 #define TD_RDONLY                1
 
-struct disk_id {
-       char *name;
-       int drivertype;
-};
-
 /* This structure represents the state of an active virtual disk.           */
 struct td_state {
        BlockDriverState* bs;
Index: qemu-xen/sysemu.h
===================================================================
--- qemu-xen.orig/sysemu.h
+++ qemu-xen/sysemu.h
@@ -116,6 +116,7 @@ extern unsigned int nb_prom_envs;
 #endif
 
 typedef enum {
+    IF_BLKTAP,
     IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD
 } BlockInterfaceType;
 
Index: qemu-xen/vl.c
===================================================================
--- qemu-xen.orig/vl.c
+++ qemu-xen/vl.c
@@ -5408,6 +5408,9 @@ static int drive_init(struct drive_opt *
     case IF_PFLASH:
     case IF_MTD:
         break;
+    case IF_BLKTAP:
+        /* Cannot happen - silence gcc warning */
+        break;
     }
     if (!file[0])
         return 0;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] qemu-xen: Fix open_disk for blktap disks, Kevin Wolf <=