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-devel

[Xen-devel] [PATCH] libxl: added libxl compatibility with physical backe

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxl: added libxl compatibility with physical backend file for NetBSD
From: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
Date: Fri, 22 Jul 2011 19:36:54 +0200
Delivery-date: Fri, 22 Jul 2011 08:34:27 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:content-type:mime-version:content-transfer-encoding:subject :x-mercurial-node:message-id:user-agent:date:from:to; bh=Qopgl1+/3uRT2zX6HEG4D1T1YDVOOCrXWTVHxaWvdXg=; b=j01nIbwNHCM6bYdT8fXpR5ZhmeV6YfnTfAv7qhBEzarlEqHUD+ElrAaLOVtlnqjtRG VfICUFQc7ZlmIYAAy/UPCK/fc/3EmdMx8tWZEEUrEq7bQCBjzQZGhczkEv0cMM3XsMG1 cuPk3xO02ZQzZkhAyPbwO88hKMBmxMADetdb0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.8.4
# HG changeset patch
# User royger
# Date 1311355770 -7200
# Node ID c3d4cad0fc2d34c8346c8a1c4d493a429939249d
# Parent  bb2568713604f2eef45326c271132b06a0bff1cc
libxl: added libxl compatibility with physical backend file for NetBSD

This patch allows running PV machines on NetBSD using the libxenlight toolstack.
Added option for PHY backend to handle regular files and disable auto-remove of 
vbd xenstore entries.
Updated xenbackend to detect if vbd is a regular file or a block partition and 
pass the correct parameter to 'block' script.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>

diff -r bb2568713604 -r c3d4cad0fc2d tools/hotplug/NetBSD/block
--- a/tools/hotplug/NetBSD/block        Fri Jul 22 19:24:34 2011 +0200
+++ b/tools/hotplug/NetBSD/block        Fri Jul 22 19:29:30 2011 +0200
@@ -19,7 +19,7 @@ error() {
 
 xpath=$1
 xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
+xtype=$3
 xparams=$(xenstore-read "$xpath/params")
 
 case $xstatus in
diff -r bb2568713604 -r c3d4cad0fc2d tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Fri Jul 22 19:24:34 2011 +0200
+++ b/tools/libxl/libxl_device.c        Fri Jul 22 19:29:30 2011 +0200
@@ -136,15 +136,20 @@ static int disk_try_backend(disk_try_bac
               a->disk->format == LIBXL_DISK_FORMAT_EMPTY)) {
             goto bad_format;
         }
-        if (a->disk->format != LIBXL_DISK_FORMAT_EMPTY &&
-            !S_ISBLK(a->stab.st_mode)) {
-            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
-                       " unsuitable as phys path not a block device",
-                       a->disk->vdev);
-            return 0;
-        }
-
-        return backend;
+        if (S_ISBLK(a->stab.st_mode))
+                return backend;
+#ifdef HAVE_PHY_BACKEND_FILE_SUPPORT
+        if (S_ISREG(a->stab.st_mode))
+            return backend;
+        LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
+                   " unsuitable as phys path not a block device or"
+                   " raw image", a->disk->vdev);
+#else
+        LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
+                   " unsuitable as phys path not a block device",
+                   a->disk->vdev);
+#endif
+        return 0;
 
     case LIBXL_DISK_BACKEND_TAP:
         if (!libxl__blktap_enabled(a->gc)) {
@@ -455,6 +460,10 @@ int libxl__devices_destroy(libxl__gc *gc
             fe_path = libxl__sprintf(gc, "/local/domain/%d/device/%s/%s", 
domid, l1[i], l2[j]);
             be_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, 
"%s/backend", fe_path));
             if (be_path != NULL) {
+#ifdef DONT_REMOVE_VBD_FROM_STORE
+                if (!strcmp(l1[i], "vbd"))
+                    continue;
+#endif
                 if (libxl__device_destroy(gc, be_path, force) > 0)
                     n_watches++;
             } else {
diff -r bb2568713604 -r c3d4cad0fc2d tools/libxl/libxl_osdeps.h
--- a/tools/libxl/libxl_osdeps.h        Fri Jul 22 19:24:34 2011 +0200
+++ b/tools/libxl/libxl_osdeps.h        Fri Jul 22 19:29:30 2011 +0200
@@ -25,6 +25,8 @@
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
 #include <util.h>
+#define HAVE_PHY_BACKEND_FILE_SUPPORT
+#define DONT_REMOVE_VBD_FROM_STORE
 #elif defined(__linux__)
 #include <pty.h>
 #elif defined(__sun__)
diff -r bb2568713604 -r c3d4cad0fc2d tools/xenbackendd/xenbackendd.c
--- a/tools/xenbackendd/xenbackendd.c   Fri Jul 22 19:24:34 2011 +0200
+++ b/tools/xenbackendd/xenbackendd.c   Fri Jul 22 19:29:30 2011 +0200
@@ -89,15 +89,15 @@ dodebug(const char *fmt, ...)
 }
 
 static void
-doexec(const char *cmd, const char *arg1, const char *arg2)
+doexec(const char *cmd, const char *arg1, const char *arg2, const char *arg3)
 {
-       dodebug("exec %s %s %s", cmd, arg1, arg2);
+       dodebug("exec %s %s %s %s", cmd, arg1, arg2, arg3);
        switch(vfork()) {
        case -1:
                dolog(LOG_ERR, "can't vfork: %s", strerror(errno));
                break;
        case 0:
-               execl(cmd, cmd, arg1, arg2, NULL);
+               execl(cmd, cmd, arg1, arg2, arg3, NULL);
                dolog(LOG_ERR, "can't exec %s: %s", cmd, strerror(errno));
                exit(EXIT_FAILURE);
                /* NOTREACHED */
@@ -145,11 +145,14 @@ xen_setup(void)
 int
 main(int argc, char * const argv[])
 {
+       struct stat stab;
        char **vec;
        unsigned int num;
        char *s;
        int state;
        char *sstate;
+       char *stype;
+       char *params;
        char *p;
        char buf[80];
        int type;
@@ -169,7 +172,7 @@ main(int argc, char * const argv[])
                        log_file = optarg;
                        break;
                case 'p':
-                       pidfile = pidfile;
+                       pidfile = optarg;
                case 's':
                        vbd_script = optarg;
                        break;
@@ -297,11 +300,38 @@ main(int argc, char * const argv[])
                                    strerror(errno));
                                goto next2;
                        }
-                       doexec(s, vec[XS_WATCH_PATH], sstate);
+                       doexec(s, vec[XS_WATCH_PATH], sstate, NULL);
                        break;
 
                case DEVTYPE_VBD:
-                       doexec(vbd_script, vec[XS_WATCH_PATH], sstate);
+                       /* check if given file is a block device or a raw image 
*/
+                       snprintf(buf, sizeof(buf), "%s/params", 
vec[XS_WATCH_PATH]);
+                       params = xs_read(xs, XBT_NULL, buf, 0);
+                       if(params == NULL) {
+                               dolog(LOG_ERR,
+                                   "Failed to read %s (%s)", buf, 
strerror(errno));
+                               goto next2;
+                       }
+                       if (stat(params, &stab) < 0) {
+                               dolog(LOG_ERR,
+                                   "Failed to get info about %s (%s)", params,
+                                   strerror(errno));
+                               goto next3;
+                       }
+                       stype = NULL;
+                       if (S_ISBLK(stab.st_mode))
+                               stype = "phy";
+                       if (S_ISREG(stab.st_mode))
+                               stype = "file";
+                       if (stype == NULL) {
+                               dolog(LOG_ERR,
+                                   "Failed to attach %s (not a block device or 
raw image)",
+                                   params, strerror(errno));
+                               goto next3;
+                       }
+                       doexec(vbd_script, vec[XS_WATCH_PATH], sstate, stype);
+next3:
+                       free(params);
                        break;
 
                default:

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