From b4d4f5d897648b1571871f2c5d8201f33f9a93d1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Jul 2008 18:45:10 +0100 Subject: [PATCH] blktap: Automatically start tapdisk-ioemu on demand When a domain wants to use a tap:ioemu disk but has no device model, start a tapdisk-ioemu instance as provider. Also, move the creation and removal of communication pipes to xend so that qemu-dm doesn't need the unwanted SIGHUP handler anymore. Signed-off-by: Kevin Wolf (xen-unstable c/s 17512:2bc699de2297aefb4eb07f1f6b8586e5fe92c6bb accidentally lost during merge, reinstating now) --- hw/xen_blktap.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/hw/xen_blktap.c b/hw/xen_blktap.c index d307d6e2e..3821aa44f 100644 --- a/hw/xen_blktap.c +++ b/hw/xen_blktap.c @@ -580,17 +580,13 @@ static void handle_blktap_ctrlmsg(void* private) */ static int open_ctrl_socket(char *devname) { - int ret; int ipc_fd; if (mkdir(BLKTAP_CTRL_DIR, 0755) == 0) DPRINTF("Created %s directory\n", BLKTAP_CTRL_DIR); - ret = mkfifo(devname,S_IRWXU|S_IRWXG|S_IRWXO); - if ( (ret != 0) && (errno != EEXIST) ) { - DPRINTF("ERROR: pipe failed (%d)\n", errno); + if (access(devname, R_OK | W_OK)) return -1; - } ipc_fd = open(devname,O_RDWR|O_NONBLOCK); @@ -602,42 +598,6 @@ static int open_ctrl_socket(char *devname) return ipc_fd; } -/** - * Unmaps all disks and closes their pipes - */ -void shutdown_blktap(void) -{ - fd_list_entry_t *ptr; - struct td_state *s; - char *devname; - - DPRINTF("Shutdown blktap\n"); - - /* Unmap all disks */ - ptr = fd_start; - while (ptr != NULL) { - s = ptr->s; - unmap_disk(s); - close(ptr->tap_fd); - ptr = ptr->next; - } - - /* Delete control pipes */ - if (asprintf(&devname, BLKTAP_CTRL_DIR "/qemu-read-%d", domid) >= 0) { - DPRINTF("Delete %s\n", devname); - if (unlink(devname)) - DPRINTF("Could not delete: %s\n", strerror(errno)); - free(devname); - } - - if (asprintf(&devname, BLKTAP_CTRL_DIR "/qemu-write-%d", domid) >= 0) { - DPRINTF("Delete %s\n", devname); - if (unlink(devname)) - DPRINTF("Could not delete: %s\n", strerror(errno)); - free(devname); - } -} - /** * Initialize the blktap interface, i.e. open a pair of pipes in /var/run/tap * and register a fd handler. @@ -678,8 +638,5 @@ int init_blktap(void) /* Attach a handler to the read pipe (called from qemu main loop) */ qemu_set_fd_handler2(read_fd, NULL, &handle_blktap_ctrlmsg, NULL, NULL); - /* Register handler to clean up when the domain is destroyed */ - atexit(&shutdown_blktap); - return 0; } -- 2.39.5