212 lines
5.5 KiB
Diff
212 lines
5.5 KiB
Diff
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
|
|
@@ -65,6 +65,8 @@
|
|
#define MAX_RAND_VAL 0xFFFF
|
|
#define MAX_ATTEMPTS 10
|
|
|
|
+#undef ALWAYS_USE_IOEMU
|
|
+
|
|
int run = 1;
|
|
int max_timeout = MAX_TIMEOUT;
|
|
int ctlfd = 0;
|
|
@@ -148,7 +150,8 @@ static int get_tapdisk_pid(blkif_t *blki
|
|
* return 0 on success, -1 on error.
|
|
*/
|
|
|
|
-static int test_path(char *path, char **dev, int *type, blkif_t **blkif)
|
|
+static int test_path(char *path, char **dev, int *type, blkif_t **blkif,
|
|
+ int* use_ioemu)
|
|
{
|
|
char *ptr, handle[10];
|
|
int i, size, found = 0;
|
|
@@ -174,6 +177,7 @@ static int test_path(char *path, char **
|
|
}
|
|
|
|
if (found) {
|
|
+ *use_ioemu = dtypes[i]->use_ioemu;
|
|
*type = dtypes[i]->idnum;
|
|
|
|
if (dtypes[i]->single_handler == 1) {
|
|
@@ -185,6 +189,7 @@ static int test_path(char *path, char **
|
|
*blkif = active_disks[dtypes[i]
|
|
->idnum]->blkif;
|
|
}
|
|
+
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -474,6 +479,7 @@ static int launch_tapdisk_provider(char
|
|
return child;
|
|
}
|
|
|
|
+#ifndef ALWAYS_USE_IOEMU
|
|
static int launch_tapdisk(char *wrctldev, char *rdctldev)
|
|
{
|
|
char *argv[] = { "tapdisk", wrctldev, rdctldev, NULL };
|
|
@@ -483,6 +489,7 @@ static int launch_tapdisk(char *wrctldev
|
|
|
|
return 0;
|
|
}
|
|
+#endif
|
|
|
|
static int launch_tapdisk_ioemu(void)
|
|
{
|
|
@@ -505,7 +512,8 @@ static int connect_qemu(blkif_t *blkif,
|
|
static int tapdisk_ioemu_pid = 0;
|
|
static int dom0_readfd = 0;
|
|
static int dom0_writefd = 0;
|
|
-
|
|
+ int refresh_pid = 0;
|
|
+
|
|
if (asprintf(&rdctldev, BLKTAP_CTRL_DIR "/qemu-read-%d", domid) < 0)
|
|
return -1;
|
|
|
|
@@ -524,15 +532,23 @@ static int connect_qemu(blkif_t *blkif,
|
|
if (tapdisk_ioemu_pid == 0 || kill(tapdisk_ioemu_pid, 0)) {
|
|
/* No device model and tapdisk-ioemu doesn't run yet */
|
|
DPRINTF("Launching tapdisk-ioemu\n");
|
|
- tapdisk_ioemu_pid = launch_tapdisk_ioemu();
|
|
+ launch_tapdisk_ioemu();
|
|
|
|
dom0_readfd = open_ctrl_socket(wrctldev);
|
|
dom0_writefd = open_ctrl_socket(rdctldev);
|
|
+
|
|
+ refresh_pid = 1;
|
|
}
|
|
|
|
DPRINTF("Using tapdisk-ioemu connection\n");
|
|
blkif->fds[READ] = dom0_readfd;
|
|
blkif->fds[WRITE] = dom0_writefd;
|
|
+
|
|
+ if (refresh_pid) {
|
|
+ get_tapdisk_pid(blkif);
|
|
+ tapdisk_ioemu_pid = blkif->tappid;
|
|
+ }
|
|
+
|
|
} else if (access(rdctldev, R_OK | W_OK) == 0) {
|
|
/* Use existing pipe to the device model */
|
|
DPRINTF("Using qemu-dm connection\n");
|
|
@@ -554,6 +570,7 @@ static int connect_qemu(blkif_t *blkif,
|
|
return 0;
|
|
}
|
|
|
|
+#ifndef ALWAYS_USE_IOEMU
|
|
/* Launch tapdisk instance */
|
|
static int connect_tapdisk(blkif_t *blkif, int minor)
|
|
{
|
|
@@ -597,6 +614,7 @@ fail:
|
|
|
|
return ret;
|
|
}
|
|
+#endif
|
|
|
|
static int blktapctrl_new_blkif(blkif_t *blkif)
|
|
{
|
|
@@ -606,13 +624,14 @@ static int blktapctrl_new_blkif(blkif_t
|
|
image_t *image;
|
|
blkif_t *exist = NULL;
|
|
static uint16_t next_cookie = 0;
|
|
+ int use_ioemu;
|
|
|
|
DPRINTF("Received a poll for a new vbd\n");
|
|
if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) {
|
|
if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0)
|
|
return -1;
|
|
|
|
- if (test_path(blk->params, &ptr, &type, &exist) != 0) {
|
|
+ if (test_path(blk->params, &ptr, &type, &exist, &use_ioemu) != 0) {
|
|
DPRINTF("Error in blktap device string(%s).\n",
|
|
blk->params);
|
|
goto fail;
|
|
@@ -621,13 +640,18 @@ static int blktapctrl_new_blkif(blkif_t
|
|
blkif->cookie = next_cookie++;
|
|
|
|
if (!exist) {
|
|
- if (type == DISK_TYPE_IOEMU) {
|
|
+#ifdef ALWAYS_USE_IOEMU
|
|
+ if (connect_qemu(blkif, blkif->domid))
|
|
+ goto fail;
|
|
+#else
|
|
+ if (use_ioemu) {
|
|
if (connect_qemu(blkif, blkif->domid))
|
|
goto fail;
|
|
} else {
|
|
if (connect_tapdisk(blkif, minor))
|
|
goto fail;
|
|
}
|
|
+#endif
|
|
|
|
} else {
|
|
DPRINTF("Process exists!\n");
|
|
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
|
|
@@ -145,6 +145,8 @@ typedef struct disk_info {
|
|
char handle[10]; /* xend handle, e.g. 'ram' */
|
|
int single_handler; /* is there a single controller for all */
|
|
/* instances of disk type? */
|
|
+ int use_ioemu; /* backend provider: 0 = tapdisk; 1 = ioemu */
|
|
+
|
|
#ifdef TAPDISK
|
|
struct tap_disk *drv;
|
|
#endif
|
|
@@ -166,6 +168,7 @@ static disk_info_t aio_disk = {
|
|
"raw image (aio)",
|
|
"aio",
|
|
0,
|
|
+ 1,
|
|
#ifdef TAPDISK
|
|
&tapdisk_aio,
|
|
#endif
|
|
@@ -176,6 +179,7 @@ static disk_info_t sync_disk = {
|
|
"raw image (sync)",
|
|
"sync",
|
|
0,
|
|
+ 1,
|
|
#ifdef TAPDISK
|
|
&tapdisk_sync,
|
|
#endif
|
|
@@ -186,6 +190,7 @@ static disk_info_t vmdk_disk = {
|
|
"vmware image (vmdk)",
|
|
"vmdk",
|
|
1,
|
|
+ 1,
|
|
#ifdef TAPDISK
|
|
&tapdisk_vmdk,
|
|
#endif
|
|
@@ -196,6 +201,7 @@ static disk_info_t ram_disk = {
|
|
"ramdisk image (ram)",
|
|
"ram",
|
|
1,
|
|
+ 0,
|
|
#ifdef TAPDISK
|
|
&tapdisk_ram,
|
|
#endif
|
|
@@ -206,6 +212,7 @@ static disk_info_t qcow_disk = {
|
|
"qcow disk (qcow)",
|
|
"qcow",
|
|
0,
|
|
+ 1,
|
|
#ifdef TAPDISK
|
|
&tapdisk_qcow,
|
|
#endif
|
|
@@ -216,6 +223,7 @@ static disk_info_t qcow2_disk = {
|
|
"qcow2 disk (qcow2)",
|
|
"qcow2",
|
|
0,
|
|
+ 1,
|
|
#ifdef TAPDISK
|
|
&tapdisk_qcow2,
|
|
#endif
|
|
@@ -226,6 +234,7 @@ static disk_info_t ioemu_disk = {
|
|
"ioemu disk",
|
|
"ioemu",
|
|
1,
|
|
+ 1,
|
|
#ifdef TAPDISK
|
|
NULL
|
|
#endif
|