WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Switch blktapctrl.c over to using standar

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Switch blktapctrl.c over to using standard system daemon(3) call. Current patch was not closing all FDs and redirecting output to /dev/null, preventing tapdisk from launching correctly.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Aug 2006 19:20:31 +0000
Delivery-date: Tue, 01 Aug 2006 12:25:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User jchesterfield@xxxxxxxxxxxxxxxxxxxxxxx
# Node ID 8b635f93018747335522e06eb20a74a7701d9945
# Parent  d323acca28a2784df56dbb499ad65d2e735077a1
Switch blktapctrl.c over to using standard system daemon(3) call. Current patch 
was not closing all FDs and redirecting output to /dev/null, preventing tapdisk 
from launching correctly.
---
 tools/blktap/drivers/blktapctrl.c |   54 +++++++++++---------------------------
 1 files changed, 17 insertions(+), 37 deletions(-)

diff -r d323acca28a2 -r 8b635f930187 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Tue Aug 01 17:47:21 2006 +0100
+++ b/tools/blktap/drivers/blktapctrl.c Tue Aug 01 17:59:27 2006 +0100
@@ -61,6 +61,7 @@
 #define MSG_SIZE 4096
 #define MAX_TIMEOUT 10
 #define MAX_RAND_VAL 0xFFFF
+#define MAX_ATTEMPTS 10
 
 int run = 1;
 int max_timeout = MAX_TIMEOUT;
@@ -622,50 +623,18 @@ static void print_drivers(void)
                DPRINTF("Found driver: [%s]\n",dtypes[i]->name);
 } 
 
-/* Stevens. */
-static void daemonize(void)
-{
-       pid_t pid;
-
-       /* Separate from our parent via fork, so init inherits us. */
-       if ((pid = fork()) < 0)
-               DPRINTF("Failed to fork daemon\n");
-       if (pid != 0)
-               exit(0);
-
-       /* Session leader so ^C doesn't whack us. */
-       setsid();
-
-       /* Let session leader exit so child cannot regain CTTY */
-       if ((pid = fork()) < 0)
-               DPRINTF("Failed to fork daemon\n");
-       if (pid != 0)
-               exit(0);
-
-       /* Move off any mount points we might be in. */
-       if (chdir("/") == -1)
-               DPRINTF("Failed to chdir\n");
-
-       /* Discard our parent's old-fashioned umask prejudices. */
-       umask(0);
-
-       close(STDIN_FILENO);
-       close(STDOUT_FILENO);
-       close(STDERR_FILENO);
-}
-
 int main(int argc, char *argv[])
 {
        char *devname;
        tapdev_info_t *ctlinfo;
-       int tap_pfd, store_pfd, xs_fd, ret, timeout, pfd_count;
+       int tap_pfd, store_pfd, xs_fd, ret, timeout, pfd_count, count=0;
        struct xs_handle *h;
        struct pollfd  pfd[NUM_POLL_FDS];
        pid_t process;
 
        __init_blkif();
        openlog("BLKTAPCTRL", LOG_CONS|LOG_ODELAY, LOG_DAEMON);
-       daemonize();
+       daemon(0,0);
 
        print_drivers();
        init_driver_list();
@@ -684,18 +653,28 @@ int main(int argc, char *argv[])
                goto open_failed;
        }
 
+ retry:
        /* Set up store connection and watch. */
        h = xs_daemon_open();
        if (h == NULL) {
                DPRINTF("xs_daemon_open failed -- "
                        "is xenstore running?\n");
-               goto open_failed;
+                if (count < MAX_ATTEMPTS) {
+                        count++;
+                        sleep(2);
+                        goto retry;
+                } else goto open_failed;
        }
        
        ret = add_blockdevice_probe_watch(h, "Domain-0");
        if (ret != 0) {
-               DPRINTF("adding device probewatch\n");
-               goto open_failed;
+               DPRINTF("Failed adding device probewatch\n");
+                if (count < MAX_ATTEMPTS) {
+                        count++;
+                        sleep(2);
+                        xs_daemon_close(h);
+                        goto retry;
+                } else goto open_failed;
        }
 
        ioctl(ctlfd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_INTERPOSE );
@@ -724,6 +703,7 @@ int main(int argc, char *argv[])
                }
        }
 
+       xs_daemon_close(h);
        ioctl(ctlfd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_PASSTHROUGH );
        close(ctlfd);
        closelog();

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Switch blktapctrl.c over to using standard system daemon(3) call. Current patch was not closing all FDs and redirecting output to /dev/null, preventing tapdisk from launching correctly., Xen patchbot-unstable <=