From 8318d7d63dc904282f3418a3d2c2dc11061b5301 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 23 Apr 2008 13:30:24 +0100 Subject: Revert 17499:451ae3b8e5c8 Breaks HVM guest creation (bugzilla #1221). Signed-off-by: Keir Fraser --- tools/blktap/drivers/blktapctrl.c | 75 +++++++-------------------------------- tools/blktap/drivers/tapdisk.h | 2 +- 2 files changed, 13 insertions(+), 64 deletions(-) (limited to 'tools/blktap') diff --git a/tools/blktap/drivers/blktapctrl.c b/tools/blktap/drivers/blktapctrl.c index f15c7b997d..8825e919c4 100644 --- a/tools/blktap/drivers/blktapctrl.c +++ b/tools/blktap/drivers/blktapctrl.c @@ -474,8 +474,9 @@ static int read_msg(int fd, int msgtype, void *ptr) } -static int launch_tapdisk_provider(char **argv) +int launch_tapdisk(char *wrctldev, char *rdctldev) { + char *argv[] = { "tapdisk", wrctldev, rdctldev, NULL }; pid_t child; if ((child = fork()) < 0) @@ -489,9 +490,7 @@ static int launch_tapdisk_provider(char **argv) i != STDERR_FILENO) close(i); - execvp(argv[0], argv); - DPRINTF("execvp failed: %d (%s)\n", errno, strerror(errno)); - DPRINTF("PATH = %s\n", getenv("PATH")); + execvp("tapdisk", argv); _exit(1); } else { pid_t got; @@ -499,78 +498,28 @@ static int launch_tapdisk_provider(char **argv) got = waitpid(child, NULL, 0); } while (got != child); } - return child; -} - -static int launch_tapdisk(char *wrctldev, char *rdctldev) -{ - char *argv[] = { "tapdisk", wrctldev, rdctldev, NULL }; - - if (launch_tapdisk_provider(argv) < 0) - return -1; - return 0; } -static int launch_tapdisk_ioemu(void) -{ - char *argv[] = { "tapdisk-ioemu", NULL }; - return launch_tapdisk_provider(argv); -} - -/* - * Connect to an ioemu based disk provider (qemu-dm or tapdisk-ioemu) - * - * If the domain has a device model, connect to qemu-dm through the - * domain specific pipe. Otherwise use a single tapdisk-ioemu instance - * which is represented by domid 0 and provides access for Dom0 and - * all DomUs without device model. - */ -static int connect_qemu(blkif_t *blkif, int domid) +/* Connect to qemu-dm */ +static int connect_qemu(blkif_t *blkif) { char *rdctldev, *wrctldev; - - static int tapdisk_ioemu_pid = 0; - static int dom0_readfd = 0; - static int dom0_writefd = 0; - if (asprintf(&rdctldev, BLKTAP_CTRL_DIR "/qemu-read-%d", domid) < 0) + if (asprintf(&rdctldev, BLKTAP_CTRL_DIR "/qemu-read-%d", + blkif->domid) < 0) return -1; - if (asprintf(&wrctldev, BLKTAP_CTRL_DIR "/qemu-write-%d", domid) < 0) { + if (asprintf(&wrctldev, BLKTAP_CTRL_DIR "/qemu-write-%d", + blkif->domid) < 0) { free(rdctldev); return -1; } DPRINTF("Using qemu blktap pipe: %s\n", rdctldev); - if (domid == 0) { - /* - * tapdisk-ioemu exits as soon as the last image is - * disconnected. Check if it is still running. - */ - 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(); - - dom0_readfd = open_ctrl_socket(wrctldev); - dom0_writefd = open_ctrl_socket(rdctldev); - } - - DPRINTF("Using tapdisk-ioemu connection\n"); - blkif->fds[READ] = dom0_readfd; - blkif->fds[WRITE] = dom0_writefd; - } else if (access(rdctldev, R_OK | W_OK) == 0) { - /* Use existing pipe to the device model */ - DPRINTF("Using qemu-dm connection\n"); - blkif->fds[READ] = open_ctrl_socket(wrctldev); - blkif->fds[WRITE] = open_ctrl_socket(rdctldev); - } else { - /* No device model => try with tapdisk-ioemu */ - DPRINTF("No device model\n"); - connect_qemu(blkif, 0); - } + blkif->fds[READ] = open_ctrl_socket(wrctldev); + blkif->fds[WRITE] = open_ctrl_socket(rdctldev); free(rdctldev); free(wrctldev); @@ -650,7 +599,7 @@ int blktapctrl_new_blkif(blkif_t *blkif) if (!exist) { if (type == DISK_TYPE_IOEMU) { - if (connect_qemu(blkif, blkif->domid)) + if (connect_qemu(blkif)) goto fail; } else { if (connect_tapdisk(blkif, minor)) diff --git a/tools/blktap/drivers/tapdisk.h b/tools/blktap/drivers/tapdisk.h index c8a21827ff..77b7fd8c83 100644 --- a/tools/blktap/drivers/tapdisk.h +++ b/tools/blktap/drivers/tapdisk.h @@ -235,7 +235,7 @@ static disk_info_t ioemu_disk = { DISK_TYPE_IOEMU, "ioemu disk", "ioemu", - 1, + 0, #ifdef TAPDISK NULL #endif -- cgit v1.2.3