]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
CA-26523: Allow for alternate tapdisk programs spawned by blktapctrl.
authorDaniel Stodden <daniel.stodden@citrix.com>
Mon, 6 Apr 2009 20:22:21 +0000 (13:22 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Mon, 6 Apr 2009 20:22:21 +0000 (13:22 -0700)
Some experiments, such as profiling blktap, get a whole lot easier if
there's a simple way to wrap tapdisk processes in custom code. A
typical example would be running tapdisk processes through Valgrind.

This patch makes blktapctrl sensitive to an environment variable
TAPDISK, which can be set to point to a replacement program which
blktapctrl is then supposed to spawn instead. PATH search per execvp()
remains unaffected.

daemon/tapdisk-channel.c

index 0fbb9afd14c1dfd0e45547a2a53338c52b2dd939..1510e98b2b9c2bbc2111805620d6d6d31b894e64 100644 (file)
@@ -858,6 +858,7 @@ tapdisk_channel_start_process(tapdisk_channel_t *channel,
 {
        pid_t child;
        char *argv[] = { "tapdisk", write_dev, read_dev, NULL };
+       const char *tapdisk;
        int i;
 
        if ((child = fork()) == -1)
@@ -872,7 +873,11 @@ tapdisk_channel_start_process(tapdisk_channel_t *channel,
                    i != STDERR_FILENO)
                        close(i);
 
-       execvp("tapdisk", argv);
+       tapdisk = getenv("TAPDISK");
+       if (!tapdisk)
+               tapdisk = argv[0];
+
+       execvp(tapdisk, argv);
 
        PERROR("execvp");
        _exit(1);