aboutsummaryrefslogtreecommitdiffstats
path: root/tools/blktap/drivers/blktapctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/blktap/drivers/blktapctrl.c')
-rw-r--r--tools/blktap/drivers/blktapctrl.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/tools/blktap/drivers/blktapctrl.c b/tools/blktap/drivers/blktapctrl.c
index b8a872bbbb..b7ee572837 100644
--- a/tools/blktap/drivers/blktapctrl.c
+++ b/tools/blktap/drivers/blktapctrl.c
@@ -148,7 +148,8 @@ static int get_tapdisk_pid(blkif_t *blkif)
* 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;
@@ -158,6 +159,17 @@ static int test_path(char *path, char **dev, int *type, blkif_t **blkif)
*type = MAX_DISK_TYPES + 1;
*blkif = NULL;
+ if (!strncmp(path, "tapdisk:", strlen("tapdisk:"))) {
+ *use_ioemu = 0;
+ path += strlen("tapdisk:");
+ } else if (!strncmp(path, "ioemu:", strlen("ioemu:"))) {
+ *use_ioemu = 1;
+ path += strlen("ioemu:");
+ } else {
+ // Use the default for the image type
+ *use_ioemu = -1;
+ }
+
if ( (ptr = strstr(path, ":"))!=NULL) {
handle_len = (ptr - path);
memcpy(handle, path, handle_len);
@@ -174,6 +186,8 @@ static int test_path(char *path, char **dev, int *type, blkif_t **blkif)
}
if (found) {
+ if (*use_ioemu == -1)
+ *use_ioemu = dtypes[i]->use_ioemu;
*type = dtypes[i]->idnum;
if (dtypes[i]->single_handler == 1) {
@@ -185,6 +199,7 @@ static int test_path(char *path, char **dev, int *type, blkif_t **blkif)
*blkif = active_disks[dtypes[i]
->idnum]->blkif;
}
+
return 0;
}
}
@@ -504,7 +519,8 @@ static int connect_qemu(blkif_t *blkif, int domid)
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;
@@ -523,15 +539,23 @@ static int connect_qemu(blkif_t *blkif, int domid)
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");
@@ -605,13 +629,14 @@ static int blktapctrl_new_blkif(blkif_t *blkif)
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;
@@ -620,7 +645,7 @@ static int blktapctrl_new_blkif(blkif_t *blkif)
blkif->cookie = next_cookie++;
if (!exist) {
- if (type == DISK_TYPE_IOEMU) {
+ if (use_ioemu) {
if (connect_qemu(blkif, blkif->domid))
goto fail;
} else {