]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commitdiff
blktap: Automatically start tapdisk-ioemu on demand
authorIan Jackson <iwj@mariner.uk.xensource.com>
Tue, 1 Jul 2008 17:45:10 +0000 (18:45 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 1 Jul 2008 17:45:10 +0000 (18:45 +0100)
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 <kwolf@suse.de>
(xen-unstable c/s 17512:2bc699de2297aefb4eb07f1f6b8586e5fe92c6bb
 accidentally lost during merge, reinstating now)

hw/xen_blktap.c

index d307d6e2e4dd5c56d848ed04548d4fca78dcc0a5..3821aa44ff55ffbcd581e27785e61e6856f534ba 100644 (file)
@@ -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;
 }