xen/ioemu-blktap-image-format.patch

117 lines
3.6 KiB
Diff
Raw Normal View History

Index: xen-3.3.1-testing/tools/blktap/drivers/tapdisk.h
===================================================================
--- xen-3.3.1-testing.orig/tools/blktap/drivers/tapdisk.h
+++ xen-3.3.1-testing/tools/blktap/drivers/tapdisk.h
@@ -159,16 +159,6 @@ extern struct tap_disk tapdisk_ram;
extern struct tap_disk tapdisk_qcow;
extern struct tap_disk tapdisk_qcow2;
-#define MAX_DISK_TYPES 20
-
-#define DISK_TYPE_AIO 0
-#define DISK_TYPE_SYNC 1
-#define DISK_TYPE_VMDK 2
-#define DISK_TYPE_RAM 3
-#define DISK_TYPE_QCOW 4
-#define DISK_TYPE_QCOW2 5
-#define DISK_TYPE_IOEMU 6
-
/*Define Individual Disk Parameters here */
static disk_info_t aio_disk = {
Index: xen-3.3.1-testing/tools/blktap/lib/blktaplib.h
===================================================================
--- xen-3.3.1-testing.orig/tools/blktap/lib/blktaplib.h
+++ xen-3.3.1-testing/tools/blktap/lib/blktaplib.h
@@ -211,6 +211,17 @@ typedef struct msg_pid {
#define CTLMSG_PID 9
#define CTLMSG_PID_RSP 10
+/* disk driver types */
+#define MAX_DISK_TYPES 20
+
+#define DISK_TYPE_AIO 0
+#define DISK_TYPE_SYNC 1
+#define DISK_TYPE_VMDK 2
+#define DISK_TYPE_RAM 3
+#define DISK_TYPE_QCOW 4
+#define DISK_TYPE_QCOW2 5
+#define DISK_TYPE_IOEMU 6
+
/* xenstore/xenbus: */
#define DOMNAME "Domain-0"
int setup_probe_watch(struct xs_handle *h);
Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c
===================================================================
--- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.c
+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.c
@@ -222,9 +222,10 @@ static int map_new_dev(struct td_state *
return -1;
}
-static int open_disk(struct td_state *s, char *path, int readonly)
+static int open_disk(struct td_state *s, char *path, int driver, int readonly)
{
BlockDriverState* bs;
+ BlockDriver* drv;
char* devname;
static int devnumber = 0;
int i;
@@ -234,7 +235,22 @@ static int open_disk(struct td_state *s,
bs = bdrv_new(devname);
free(devname);
- if (bdrv_open(bs, path, 0) != 0) {
+ /* Search for disk driver */
+ for (i = 0; blktap_drivers[i].idnum >= 0; i++) {
+ if (blktap_drivers[i].idnum == driver)
+ break;
+ }
+
+ if (blktap_drivers[i].idnum < 0) {
+ fprintf(stderr, "Could not find image format id %d\n", driver);
+ return -ENOMEM;
+ }
+
+ drv = blktap_drivers[i].drv;
+ DPRINTF("%s driver specified\n", drv ? drv->format_name : "No");
+
+ /* Open the image */
+ if (bdrv_open2(bs, path, 0, drv) != 0) {
fprintf(stderr, "Could not open image file %s\n", path);
return -ENOMEM;
}
@@ -529,7 +545,7 @@ static void handle_blktap_ctrlmsg(void*
s = state_init();
/*Open file*/
- if (s == NULL || open_disk(s, path, msg->readonly)) {
+ if (s == NULL || open_disk(s, path, msg->drivertype, msg->readonly)) {
msglen = sizeof(msg_hdr_t);
msg->type = CTLMSG_IMG_FAIL;
msg->len = msglen;
Index: xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h
===================================================================
--- xen-3.3.1-testing.orig/tools/ioemu-remote/hw/xen_blktap.h
+++ xen-3.3.1-testing/tools/ioemu-remote/hw/xen_blktap.h
@@ -50,4 +50,19 @@ typedef struct fd_list_entry {
struct fd_list_entry **pprev, *next;
} fd_list_entry_t;
+typedef struct disk_info {
+ int idnum;
+ struct BlockDriver *drv;
+} disk_info_t;
+
+static disk_info_t blktap_drivers[] = {
+ { DISK_TYPE_AIO, &bdrv_raw },
+ { DISK_TYPE_SYNC, &bdrv_raw },
+ { DISK_TYPE_VMDK, &bdrv_vmdk },
+ { DISK_TYPE_QCOW, &bdrv_qcow },
+ { DISK_TYPE_QCOW2, &bdrv_qcow2 },
+ { DISK_TYPE_IOEMU, NULL },
+ { -1, NULL }
+};
+
#endif /*XEN_BLKTAP_H_*/