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] Make blktap support optional.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Make blktap support optional.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Aug 2010 07:00:57 -0700
Delivery-date: Wed, 18 Aug 2010 07:05:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 Christoph Egger <Christoph.Egger@xxxxxxx>
# Date 1281974671 -3600
# Node ID 2f1f35359317a116ea9683a206d639633e29699f
# Parent  def814437d4247eced1218e5bcd5c583bf7df0bb
Make blktap support optional.
Enable it by default on Linux, disable it on non-Linux.

Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
committer: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/Rules.mk                |   11 +++++++
 tools/libxl/Makefile          |    6 ++++
 tools/libxl/libxl.c           |   58 ++++++++++++------------------------------
 tools/libxl/libxl_blktap2.c   |   51 ++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h  |   21 ++++++++++++++-
 tools/libxl/libxl_noblktap2.c |   29 +++++++++++++++++++++
 6 files changed, 134 insertions(+), 42 deletions(-)

diff -r def814437d42 -r 2f1f35359317 tools/Rules.mk
--- a/tools/Rules.mk    Mon Aug 16 13:39:19 2010 +0100
+++ b/tools/Rules.mk    Mon Aug 16 17:04:31 2010 +0100
@@ -26,8 +26,19 @@ CFLAGS_libxenstore = -I$(XEN_XENSTORE) $
 CFLAGS_libxenstore = -I$(XEN_XENSTORE) $(CFLAGS_include)
 LDLIBS_libxenstore = -L$(XEN_XENSTORE) -lxenstore
 
+ifeq ($(CONFIG_Linux),y)
+LIBXL_BLKTAP = y
+else
+LIBXL_BLKTAP = n
+endif
+
+ifeq ($(LIBXL_BLKTAP),y)
 CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include 
$(CFLAGS_include)
 LDLIBS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl
+else
+CFLAGS_libblktapctl =
+LDLIBS_libblktapctl =
+endif
 
 X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR)
 
diff -r def814437d42 -r 2f1f35359317 tools/libxl/Makefile
--- a/tools/libxl/Makefile      Mon Aug 16 13:39:19 2010 +0100
+++ b/tools/libxl/Makefile      Mon Aug 16 17:04:31 2010 +0100
@@ -18,6 +18,12 @@ LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_lib
 LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) 
$(LDLIBS_libblktapctl) $(UTIL_LIBS)
 
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o
+ifeq ($(LIBXL_BLKTAP),y)
+LIBXL_OBJS-y += libxl_blktap2.o
+else
+LIBXL_OBJS-y += libxl_noblktap2.o
+endif
+
 LIBXL_OBJS = flexarray.o libxl.o libxl_pci.o libxl_dom.o libxl_exec.o 
libxl_xshelp.o libxl_device.o libxl_internal.o xenguest.o libxl_utils.o 
$(LIBXL_OBJS-y)
 
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
diff -r def814437d42 -r 2f1f35359317 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Aug 16 13:39:19 2010 +0100
+++ b/tools/libxl/libxl.c       Mon Aug 16 17:04:31 2010 +0100
@@ -36,7 +36,6 @@
 #include "libxl_utils.h"
 #include "libxl_internal.h"
 #include "flexarray.h"
-#include "tap-ctl.h"
 
 #define PAGE_TO_MEMKB(pages) ((pages) * 4)
 
@@ -1715,27 +1714,6 @@ int libxl_confirm_device_model_startup(l
 
 
/******************************************************************************/
 
-static char *get_blktap2_device(libxl_gc *gc,
-                               const char *name, const char *type)
-{
-    int minor = tap_ctl_find_minor(type, name);
-    if (minor < 0)
-        return NULL;
-    return libxl_sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor);
-}
-
-static char *make_blktap2_device(libxl_gc *gc,
-                                const char *name, const char *type)
-{
-    char *params, *devname = NULL;
-    int err;
-    params = libxl_sprintf(gc, "%s:%s", type, name);
-    err = tap_ctl_create(params, &devname);
-    if (!err)
-        libxl_ptr_add(gc, devname);
-    return err ? NULL : devname;
-}
-
 int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk 
*disk)
 {
     libxl_gc gc = LIBXL_INIT_GC(ctx);
@@ -1790,14 +1768,13 @@ int libxl_device_disk_add(libxl_ctx *ctx
         case PHYSTYPE_FILE:
             /* let's pretend is tap:aio for the moment */
             disk->phystype = PHYSTYPE_AIO;
-        case PHYSTYPE_AIO: case PHYSTYPE_QCOW: case PHYSTYPE_QCOW2: case 
PHYSTYPE_VHD: {
-            const char *msg;
-            if (!tap_ctl_check(&msg)) {
-                const char *type = 
device_disk_string_of_phystype(disk->phystype);
-                char *dev;
-                dev = get_blktap2_device(&gc, disk->physpath, type);
-                if (!dev)
-                    dev = make_blktap2_device(&gc, disk->physpath, type);
+        case PHYSTYPE_AIO:
+        case PHYSTYPE_QCOW:
+        case PHYSTYPE_QCOW2:
+        case PHYSTYPE_VHD:
+            if (libxl_blktap_enabled(&gc)) {
+                const char *dev = libxl_blktap_devpath(&gc,
+                                               disk->physpath, disk->phystype);
                 if (!dev) {
                     rc = ERROR_FAIL;
                     goto out_free;
@@ -1820,7 +1797,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
 
             device.backend_kind = DEVICE_TAP;
             break;
-        }
+
         default:
             XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", 
disk->phystype);
             rc = ERROR_INVAL;
@@ -1892,7 +1869,8 @@ char * libxl_device_disk_local_attach(li
 char * libxl_device_disk_local_attach(libxl_ctx *ctx, libxl_device_disk *disk)
 {
     libxl_gc gc = LIBXL_INIT_GC(ctx);
-    char *dev = NULL, *ret;
+    const char *dev = NULL;
+    char *ret;
     int phystype = disk->phystype;
     switch (phystype) {
         case PHYSTYPE_PHY: {
@@ -1903,16 +1881,14 @@ char * libxl_device_disk_local_attach(li
         case PHYSTYPE_FILE:
             /* let's pretend is tap:aio for the moment */
             phystype = PHYSTYPE_AIO;
-        case PHYSTYPE_AIO: case PHYSTYPE_QCOW: case PHYSTYPE_QCOW2: case 
PHYSTYPE_VHD: {
-            const char *msg;
-            if (!tap_ctl_check(&msg)) {
-                const char *type = device_disk_string_of_phystype(phystype);
-                dev = get_blktap2_device(&gc, disk->physpath, type);
-                if (!dev)
-                    dev = make_blktap2_device(&gc, disk->physpath, type);
-            }
+        case PHYSTYPE_AIO:
+        case PHYSTYPE_QCOW:
+        case PHYSTYPE_QCOW2:
+        case PHYSTYPE_VHD:
+            if (libxl_blktap_enabled(&gc))
+                dev = libxl_blktap_devpath(&gc, disk->physpath, phystype);
             break;
-        }
+
         default:
             XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", 
phystype);
             break;
diff -r def814437d42 -r 2f1f35359317 tools/libxl/libxl_blktap2.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_blktap2.c       Mon Aug 16 17:04:31 2010 +0100
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010      Advanced Micro Devices
+ * Author Christoph Egger <Christoph.Egger@xxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl.h"
+#include "libxl_osdeps.h"
+#include "libxl_internal.h"
+
+#include "tap-ctl.h"
+
+int libxl_blktap_enabled(libxl_gc *gc)
+{
+    const char *msg;
+    return !tap_ctl_check(&msg);
+}
+
+const char *libxl_blktap_devpath(libxl_gc *gc,
+                                 const char *disk,
+                                 libxl_disk_phystype phystype)
+{
+    const char *type;
+    char *params, *devname;
+    int minor, err;
+
+    type = device_disk_string_of_phystype(phystype);
+    minor = tap_ctl_find_minor(type, disk);
+    if (minor >= 0) {
+        devname = libxl_sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor);
+        if (devname)
+            return devname;
+    }
+
+    params = libxl_sprintf(gc, "%s:%s", type, disk);
+    err = tap_ctl_create(params, &devname);
+    if (!err) {
+        libxl_ptr_add(gc, devname);
+        return devname;
+    }
+
+    return NULL;
+}
diff -r def814437d42 -r 2f1f35359317 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Aug 16 13:39:19 2010 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Aug 16 17:04:31 2010 +0100
@@ -248,4 +248,23 @@ _hidden char *_libxl_domid_to_name(libxl
 _hidden char *_libxl_domid_to_name(libxl_gc *gc, uint32_t domid);
 _hidden char *_libxl_poolid_to_name(libxl_gc *gc, uint32_t poolid);
 
-#endif
+/*
+ * blktap2 support
+ */
+
+/* libxl_blktap_enabled:
+ *    return true if blktap/blktap2 support is available.
+ */
+int libxl_blktap_enabled(libxl_gc *gc);
+
+/* libxl_blktap_devpath:
+ *    Argument: path and disk image as specified in config file.
+ *      The type specifies whether this is aio, qcow, qcow2, etc.
+ *    returns device path xenstore wants to have. returns NULL
+ *      if no device corresponds to the disk.
+ */
+const char *libxl_blktap_devpath(libxl_gc *gc,
+                                 const char *disk,
+                                 libxl_disk_phystype phystype);
+
+#endif
diff -r def814437d42 -r 2f1f35359317 tools/libxl/libxl_noblktap2.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_noblktap2.c     Mon Aug 16 17:04:31 2010 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010      Advanced Micro Devices
+ * Author Christoph Egger <Christoph.Egger@xxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl.h"
+#include "libxl_osdeps.h"
+#include "libxl_internal.h"
+
+int libxl_blktap_enabled(libxl_gc *gc)
+{
+    return 0;
+}
+
+const char *libxl_blktap_devpath(libxl_gc *gc,
+                                 const char *disk,
+                                 libxl_disk_phystype phystype)
+{
+    return NULL;
+}

_______________________________________________
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] Make blktap support optional., Xen patchbot-unstable <=