tools/libxl: Revert broken NetBSD portability patches
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 23 Jul 2010 18:13:29 +0000 (19:13 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 23 Jul 2010 18:13:29 +0000 (19:13 +0100)
Revert
 df9d8319bd37 Fix blktap2 NetBSD build and also revert broken change
 e76befc7fe2d portability fixes from tools/console
 24277e3237ca Fix linking error when creating the xl binary.

Now it builds again.

tools/Rules.mk
tools/libxl/Makefile
tools/libxl/libxl.c
tools/libxl/libxl_bootloader.c
tools/libxl/libxl_device.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_linux.c [deleted file]
tools/libxl/libxl_netbsd.c [deleted file]
tools/libxl/libxl_osdeps.h

index eec26d4f5666e40c6afadb4c770d7529f78218cb..7982358f6be4f9ae4e8aefd9d7a538205ed97e4c 100644 (file)
@@ -26,13 +26,8 @@ LDFLAGS_libxenguest = -L$(XEN_LIBXC) -lxenguest
 CFLAGS_libxenstore = -I$(XEN_XENSTORE) $(CFLAGS_include)
 LDFLAGS_libxenstore = -L$(XEN_XENSTORE) -lxenstore
 
-ifeq ($(CONFIG_Linux),y)
 CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include $(CFLAGS_include)
 LDFLAGS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl
-else
-CFLAGS_libblktapctl =
-LDFLAGS_libblktapctl =
-endif
 
 X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR)
 
index 4d57764223ca67a068111161ff74d0140dbc43d3..16abd816a8025fd7d147e678528a82a262c1047c 100644 (file)
@@ -15,11 +15,9 @@ CFLAGS += -Werror -Wno-format-zero-length
 CFLAGS += -I. -fPIC
 CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
 
-LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) $(LDFLAGS_libblktapctl) $(UTIL_LIBS)
+LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore) $(LDFLAGS_libblktapctl) -lutil
 
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o
-LIBXL_OBJS-$(CONFIG_Linux) += libxl_linux.o
-LIBXL_OBJS-$(CONFIG_NetBSD) += libxl_netbsd.o
 LIBXL_OBJS = flexarray.o libxl.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
index 9070cf94faf8e20826ae6d47c8f00cf4f735bb06..12d8ef65e573a3341cfd5c5b09decffdf4e924f6 100644 (file)
@@ -34,6 +34,7 @@
 #include "libxl_utils.h"
 #include "libxl_internal.h"
 #include "flexarray.h"
+#include "tap-ctl.h"
 
 #define PAGE_TO_MEMKB(pages) ((pages) * 4)
 
@@ -1390,6 +1391,27 @@ int libxl_confirm_device_model_startup(struct libxl_ctx *ctx,
 
 /******************************************************************************/
 
+static char *get_blktap2_device(struct libxl_ctx *ctx,
+                               const char *name, const char *type)
+{
+    int minor = tap_ctl_find_minor(type, name);
+    if (minor < 0)
+        return NULL;
+    return libxl_sprintf(ctx, "/dev/xen/blktap-2/tapdev%d", minor);
+}
+
+static char *make_blktap2_device(struct libxl_ctx *ctx,
+                                const char *name, const char *type)
+{
+    char *params, *devname = NULL;
+    int err;
+    params = libxl_sprintf(ctx, "%s:%s", type, name);
+    err = tap_ctl_create(params, &devname);
+    if (!err)
+        libxl_ptr_add(ctx, devname);
+    return err ? NULL : devname;
+}
+
 int libxl_device_disk_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk)
 {
     flexarray_t *front;
@@ -1438,13 +1460,14 @@ int libxl_device_disk_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_di
         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:
-            if (libxl_blktap_enabled(ctx)) {
-                const char *dev = libxl_blktap_devpath(ctx,
-                                               disk->physpath, disk->phystype);
+        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(ctx, disk->physpath, type);
+                if (!dev)
+                    dev = make_blktap2_device(ctx, disk->physpath, type);
                 if (!dev)
                     return ERROR_FAIL;
                 flexarray_set(back, boffset++, "tapdisk-params");
@@ -1465,7 +1488,7 @@ int libxl_device_disk_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_di
 
             device.backend_kind = DEVICE_TAP;
             break;
-
+        }
         default:
             XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", disk->phystype);
             return ERROR_INVAL;
@@ -1529,7 +1552,7 @@ int libxl_device_disk_del(struct libxl_ctx *ctx,
 
 const char * libxl_device_disk_local_attach(struct libxl_ctx *ctx, libxl_device_disk *disk)
 {
-    const char *dev = NULL;
+    char *dev = NULL;
     int phystype = disk->phystype;
     switch (phystype) {
         case PHYSTYPE_PHY: {
@@ -1540,14 +1563,16 @@ const char * libxl_device_disk_local_attach(struct libxl_ctx *ctx, libxl_device_
         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:
-            if (libxl_blktap_enabled(ctx))
-                dev = libxl_blktap_devpath(ctx, disk->physpath, phystype);
+        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(ctx, disk->physpath, type);
+                if (!dev)
+                    dev = make_blktap2_device(ctx, disk->physpath, type);
+            }
             break;
-
+        }
         default:
             XL_LOG(ctx, XL_LOG_ERROR, "unrecognized disk physical type: %d\n", phystype);
             break;
index d2da421f9a9e109101d031da0c3794a18eddff98..e7cf62424432dc7c93ffe86f0d366021e760e843 100644 (file)
 #include "libxl_osdeps.h"
 
 #include <string.h>
+#include <pty.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <termios.h>
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-#include <util.h>
-#elif defined(__linux__)
-#include <pty.h>
-#elif defined(__sun__)
-#include <stropts.h>
-#endif
 
 #include <sys/stat.h>
 #include <sys/types.h>
index 194134e29997fadd44e6d8e07f9db82d142aa7b7..a051d53e53eb2771a6d32cba2b96fae20e3bd435 100644 (file)
@@ -123,7 +123,7 @@ char *device_disk_backend_type_of_phystype(libxl_disk_phystype phystype)
     }
 }
 
-int device_physdisk_major_minor(const char *physpath, int *major, int *minor)
+int device_physdisk_major_minor(char *physpath, int *major, int *minor)
 {
     struct stat buf;
     if (stat(physpath, &buf) < 0)
index 205d37306d9a4f494391221b13ce0765ff409584..129e22cd5090a62fd6c2cf6026e20c6d33044f0e 100644 (file)
@@ -149,7 +149,7 @@ void libxl__userdata_destroyall(struct libxl_ctx *ctx, uint32_t domid);
 char *device_disk_backend_type_of_phystype(libxl_disk_phystype phystype);
 char *device_disk_string_of_phystype(libxl_disk_phystype phystype);
 
-int device_physdisk_major_minor(const char *physpath, int *major, int *minor);
+int device_physdisk_major_minor(char *physpath, int *major, int *minor);
 int device_disk_dev_number(char *virtpath);
 
 int libxl_device_generic_add(struct libxl_ctx *ctx, libxl_device *device,
diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
deleted file mode 100644 (file)
index 369cabd..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2010      Advanced Micro Devices
- * Author Christoph Egger <Christoph.Egger@amd.com>
- *
- * 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 "tap-ctl.h"
-
-int libxl_blktap_enabled(struct libxl_ctx *ctx)
-{
-    const char *msg;
-    return !tap_ctl_check(&msg);
-}
-
-const char *libxl_blktap_devpath(struct libxl_ctx *ctx,
-                                 const char *disk,
-                                 libxl_disk_phystype phystype)
-{
-    const char *type, *devname;
-    char *params;
-    int minor, err;
-
-    type = device_disk_string_of_type(phystype);
-    minor = tap_ctl_find_minor(type, disk);
-    if (minor >= 0) {
-        devname = libxl_sprintf(ctx, "/dev/xen/blktap-2/tapdev%d", minor);
-        if (devname)
-            return devname;
-    }
-
-    params = libxl_sprintf(ctx, "%s:%s", type, disk);
-    err = tap_ctl_create(params, &devname);
-    if (!err) {
-        libxl_ptr_add(ctx, devname);
-        return devname;
-    }
-
-    return NULL;
-}
diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
deleted file mode 100644 (file)
index 6cbfd40..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2010      Advanced Micro Devices
- * Author Christoph Egger <Christoph.Egger@amd.com>
- *
- * 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"
-
-int libxl_blktap_enabled(struct libxl_ctx *ctx)
-{
-    return 0;
-}
-
-const char *libxl_blktap_devpath(struct libxl_ctx *ctx,
-                                 const char *disk,
-                                 libxl_disk_phystype phystype)
-{
-    return NULL;
-}
index 0dd22d89d47bd424cb8bc6d89e1c9499c840f4ed..fc453c3553c4f81a09ea6e018fc639f5fe5d7352 100644 (file)
@@ -23,8 +23,6 @@
 
 #define _GNU_SOURCE
 
-#include <libxl_internal.h>
-
 #ifdef NEED_OWN_ASPRINTF
 #include <stdarg.h>
 
@@ -32,23 +30,4 @@ int asprintf(char **buffer, char *fmt, ...);
 int vasprintf(char **buffer, const char *fmt, va_list ap);
 #endif /*NEED_OWN_ASPRINTF*/
 
-/*
- * blktap2 support
- */
-
-/* libxl_blktap_enabled:
- *    return true if blktap/blktap2 support is available.
- */
-int libxl_blktap_enabled(struct libxl_ctx *ctx);
-
-/* 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(struct libxl_ctx *ctx,
-                                 const char *disk,
-                                 libxl_disk_phystype phystype);
-
 #endif