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] [BLKTAP] Little error handling fix to blk

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [BLKTAP] Little error handling fix to blktapctrl.c.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Nov 2006 09:00:53 +0000
Delivery-date: Thu, 16 Nov 2006 01:00:47 -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 Andrew Warfield <andy@xxxxxxxxxxxxx>
# Node ID 66a169df22c504fc6f0b75543bd11e4917ba302a
# Parent  3fa6635d04b99cfeb936ea9a7ff9dde9b7b5ced8
[BLKTAP] Little error handling fix to blktapctrl.c.

Signed-off-by: Andrew Warfield <andy@xxxxxxxxxxxxx>
---
 tools/blktap/drivers/blktapctrl.c |   67 +++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 22 deletions(-)

diff -r 3fa6635d04b9 -r 66a169df22c5 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Wed Nov 15 18:41:06 2006 +0000
+++ b/tools/blktap/drivers/blktapctrl.c Wed Nov 15 12:50:17 2006 -0800
@@ -167,13 +167,22 @@ static int get_tapdisk_pid(blkif_t *blki
        return 1;
 }
 
-static blkif_t *test_path(char *path, char **dev, int *type)
+/* Look up the disk specified by path: 
+ *   if found, dev points to the device string in the path
+ *             type is the tapdisk driver type id
+ *             blkif is the existing interface if this is a shared driver
+ *             and NULL otherwise.
+ *   return 0 on success, -1 on error.
+ */
+
+static int test_path(char *path, char **dev, int *type, blkif_t *blkif)
 {
        char *ptr, handle[10];
-       int i, size;
+       int i, size, found = 0;
 
        size = sizeof(dtypes)/sizeof(disk_info_t *);
        *type = MAX_DISK_TYPES + 1;
+        blkif = NULL;
 
        if ( (ptr = strstr(path, ":"))!=NULL) {
                memcpy(handle, path, (ptr - path));
@@ -182,25 +191,35 @@ static blkif_t *test_path(char *path, ch
                *ptr = '\0';
                DPRINTF("Detected handle: [%s]\n",handle);
 
-               for (i = 0; i < size; i++) {
-                       if (strncmp(handle, dtypes[i]->handle, (ptr - path))
-                           ==0) {
-                               *type = dtypes[i]->idnum;
-
-                               if (dtypes[i]->single_handler == 1) {
-                                       /* Check whether tapdisk process 
-                                          already exists */
-                                       if (active_disks[dtypes[i]->idnum] 
-                                           == NULL) return NULL;
-                                       else 
-                                               return 
active_disks[dtypes[i]->idnum]->blkif;
-                               }
-                       }
-               }
-       } else *dev = NULL;
-
-       return NULL;
-}
+               for (i = 0; i < size; i++) 
+                       if (strncmp(handle, dtypes[i]->handle, 
+                                    (ptr - path)) ==0) {
+                                found = 1;
+                                break;
+                        }
+
+                if (found) {
+                        *type = dtypes[i]->idnum;
+                        
+                        if (dtypes[i]->single_handler == 1) {
+                                /* Check whether tapdisk process 
+                                   already exists */
+                                if (active_disks[dtypes[i]->idnum] == NULL) 
+                                        blkif = NULL;
+                                else 
+                                        blkif = active_disks[dtypes[i]
+                                                             ->idnum]->blkif;
+                        }
+                        return 0;
+                }
+        }
+
+        /* Fall-through case, we didn't find a disk driver. */
+        DPRINTF("Unknown blktap disk type [%s]!\n",handle);
+        *dev = NULL;
+        return -1;
+}
+
 
 static void add_disktype(blkif_t *blkif, int type)
 {
@@ -463,7 +482,11 @@ int blktapctrl_new_blkif(blkif_t *blkif)
                if (get_new_dev(&major, &minor, blkif)<0)
                        return -1;
 
-               exist = test_path(blk->params, &ptr, &type);
+               if (test_path(blk->params, &ptr, &type, exist) != 0) {
+                        DPRINTF("Error in blktap device string(%s).\n",
+                                blk->params);
+                        return -1;
+                }
                blkif->drivertype = type;
                blkif->cookie = lrand48() % MAX_RAND_VAL;
 

_______________________________________________
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] [BLKTAP] Little error handling fix to blktapctrl.c., Xen patchbot-unstable <=