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] Use stat to poll on phantom device until

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Use stat to poll on phantom device until it becomes ready
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Feb 2007 18:30:17 -0800
Delivery-date: Wed, 28 Feb 2007 18:30:06 -0800
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 Wim Colgate <wim@xxxxxxxxxxxxx>
# Date 1172694936 28800
# Node ID 3379f667c3a66664d30a72905c51514c0fd936ef
# Parent  d66dff09338a892c016bdb4bfb1fcdd07b1ec8b7
    Use stat to poll on phantom device until it becomes ready

    Signed-off by Wim Colgate <wim@xxxxxxxxxxxxx>
---
 tools/ioemu/xenstore.c |   51 ++++++++++++++++++++-----------------------------
 1 files changed, 21 insertions(+), 30 deletions(-)

diff -r d66dff09338a -r 3379f667c3a6 tools/ioemu/xenstore.c
--- a/tools/ioemu/xenstore.c    Wed Feb 28 18:15:42 2007 +0000
+++ b/tools/ioemu/xenstore.c    Wed Feb 28 12:35:36 2007 -0800
@@ -16,6 +16,9 @@ static char *hd_filename[MAX_DISKS];
 static char *hd_filename[MAX_DISKS];
 static QEMUTimer *insert_timer = NULL;
 
+#define UWAIT_MAX (30*1000000) /* thirty seconds */
+#define UWAIT     (100000)     /* 1/10th second  */
+
 static int pasprintf(char **buf, const char *fmt, ...)
 {
     va_list ap;
@@ -53,32 +56,20 @@ void xenstore_check_new_media_present(in
     qemu_mod_timer(insert_timer, qemu_get_clock(rt_clock) + timeout);
 }
 
-static int waitForDevice(char *path, char *field, char *desired)
+static void waitForDevice(char *fn)
 { 
-    char *buf = NULL, *stat = NULL;
-    unsigned int len;
-    int val = 1;
-
-    /* loop until we find a value in xenstore, return 
-     * if it was what we wanted, or not
-     */
-    while (1) {
-        if (pasprintf(&buf, "%s/%s", path, field) == -1)
-            goto done;
-        free(stat);
-        stat = xs_read(xsh, XBT_NULL, buf, &len);
-        if (stat == NULL) {
-            usleep(100000); /* 1/10th second, no path found */
-        } else {
-            val = strcmp(stat, desired);
-            goto done;
-        }
-    }
-
-done:
-    free(stat);
-    free(buf);
-    return val;
+    struct stat sbuf;
+    int status;
+    int uwait = UWAIT_MAX;
+
+    do {
+        status = stat(fn, &sbuf);
+        if (!status) break;
+        usleep(UWAIT);
+        uwait -= UWAIT;
+    } while (uwait > 0);
+
+    return;
 }
 
 void xenstore_parse_domain_config(int domid)
@@ -161,11 +152,6 @@ void xenstore_parse_domain_config(int do
        free(fpath);
         fpath = xs_read(xsh, XBT_NULL, buf, &len);
        if (fpath != NULL) {
-
-            if (waitForDevice(fpath, "hotplug-status", "connected")) {
-               continue;
-            }
-
            if (pasprintf(&buf, "%s/dev", fpath) == -1)
                continue;
             params = xs_read(xsh, XBT_NULL, buf , &len);
@@ -173,6 +159,11 @@ void xenstore_parse_domain_config(int do
                 free(hd_filename[hd_index]);
                 hd_filename[hd_index] = params;
                 params = NULL;              /* don't free params on re-use */
+                /* 
+                 * wait for device, on timeout silently fail because we will 
+                 * fail to open below
+                 */
+                waitForDevice(hd_filename[hd_index]);
             }
         }
        bs_table[hd_index] = bdrv_new(dev);

_______________________________________________
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] Use stat to poll on phantom device until it becomes ready, Xen patchbot-unstable <=