yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
b38b0f
From 88780a41e05b8079cde07466c252b42c113f9e5c Mon Sep 17 00:00:00 2001
b38b0f
From: Miroslav Rezanina <mrezanin@redhat.com>
b38b0f
Date: Sun, 9 Jun 2019 09:35:09 +0100
b38b0f
Subject: [PATCH 8/8] Disable VXHS support
b38b0f
b38b0f
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
b38b0f
Message-id: <1560072909-1725-1-git-send-email-mrezanin@redhat.com>
b38b0f
Patchwork-id: 88629
b38b0f
O-Subject: [RHEL-8 qemu-kvm PATCH] Disable VXHS support
b38b0f
Bugzilla: 1714933
b38b0f
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
b38b0f
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
b38b0f
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
b38b0f
b38b0f
From: Miroslav Rezanina <mrezanin@redhat.com>
b38b0f
b38b0f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714933
b38b0f
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=22065429
b38b0f
Branch: rhel-8.1.0
b38b0f
Upstream: n/a
b38b0f
b38b0f
Reverting commit e9aff9d4ab1f9c10a4cb88fc5b92c4835e8b2688 introducing
b38b0f
downstream modularizaiton of VXHS driver as we do not need to support
b38b0f
VXHS driver anymore.
b38b0f
b38b0f
Patch is not pure revert as we changed way we handle configuration
b38b0f
of qemu build after this patch. In addition, reverting downstream only
b38b0f
removing of vxhs.o from block/Makefile.obj.
b38b0f
b38b0f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 block/Makefile.objs           |   2 +-
b38b0f
 block/vxhs.c                  | 123 ++++--------------------------------
b38b0f
 configure                     |  33 +++++++++-
b38b0f
 include/block/vxhs_shim.h     | 143 ------------------------------------------
b38b0f
 redhat/qemu-kvm.spec.template |   9 ---
b38b0f
 5 files changed, 42 insertions(+), 268 deletions(-)
b38b0f
 delete mode 100644 include/block/vxhs_shim.h
b38b0f
b38b0f
diff --git a/block/Makefile.objs b/block/Makefile.objs
b38b0f
index 037c76b..ac7a1f8 100644
b38b0f
--- a/block/Makefile.objs
b38b0f
+++ b/block/Makefile.objs
b38b0f
@@ -29,7 +29,7 @@ block-obj-$(CONFIG_LIBNFS) += nfs.o
b38b0f
 block-obj-$(CONFIG_CURL) += curl.o
b38b0f
 block-obj-$(CONFIG_RBD) += rbd.o
b38b0f
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
b38b0f
-#block-obj-$(CONFIG_VXHS) += vxhs.o
b38b0f
+block-obj-$(CONFIG_VXHS) += vxhs.o
b38b0f
 block-obj-$(CONFIG_LIBSSH2) += ssh.o
b38b0f
 block-obj-y += accounting.o dirty-bitmap.o
b38b0f
 block-obj-y += write-threshold.o
b38b0f
diff --git a/block/vxhs.c b/block/vxhs.c
b38b0f
index 25fea7f..d2a1f4e 100644
b38b0f
--- a/block/vxhs.c
b38b0f
+++ b/block/vxhs.c
b38b0f
@@ -9,8 +9,7 @@
b38b0f
  */
b38b0f
 
b38b0f
 #include "qemu/osdep.h"
b38b0f
-#include "block/vxhs_shim.h"
b38b0f
-#include <gmodule.h>
b38b0f
+#include <qnio/qnio_api.h>
b38b0f
 #include <sys/param.h>
b38b0f
 #include "block/block_int.h"
b38b0f
 #include "block/qdict.h"
b38b0f
@@ -60,97 +59,6 @@ typedef struct BDRVVXHSState {
b38b0f
     char *tlscredsid; /* tlscredsid */
b38b0f
 } BDRVVXHSState;
b38b0f
 
b38b0f
-#define LIBVXHS_FULL_PATHNAME "/usr/lib64/qemu/libvxhs.so.1"
b38b0f
-static bool libvxhs_loaded;
b38b0f
-static GModule *libvxhs_handle;
b38b0f
-
b38b0f
-static LibVXHSFuncs libvxhs;
b38b0f
-
b38b0f
-typedef struct LibVXHSSymbols {
b38b0f
-    const char *name;
b38b0f
-    gpointer *addr;
b38b0f
-} LibVXHSSymbols;
b38b0f
-
b38b0f
-static LibVXHSSymbols libvxhs_symbols[] = {
b38b0f
-    {"iio_init",        (gpointer *) &libvxhs.iio_init},
b38b0f
-    {"iio_fini",        (gpointer *) &libvxhs.iio_fini},
b38b0f
-    {"iio_min_version", (gpointer *) &libvxhs.iio_min_version},
b38b0f
-    {"iio_max_version", (gpointer *) &libvxhs.iio_max_version},
b38b0f
-    {"iio_open",        (gpointer *) &libvxhs.iio_open},
b38b0f
-    {"iio_close",       (gpointer *) &libvxhs.iio_close},
b38b0f
-    {"iio_writev",      (gpointer *) &libvxhs.iio_writev},
b38b0f
-    {"iio_readv",       (gpointer *) &libvxhs.iio_readv},
b38b0f
-    {"iio_ioctl",       (gpointer *) &libvxhs.iio_ioctl},
b38b0f
-    {NULL}
b38b0f
-};
b38b0f
-
b38b0f
-static void bdrv_vxhs_set_funcs(GModule *handle, Error **errp)
b38b0f
-{
b38b0f
-    int i = 0;
b38b0f
-    while (libvxhs_symbols[i].name) {
b38b0f
-        const char *name = libvxhs_symbols[i].name;
b38b0f
-        if (!g_module_symbol(handle, name, libvxhs_symbols[i].addr)) {
b38b0f
-            error_setg(errp, "%s could not be loaded from libvxhs: %s",
b38b0f
-                       name, g_module_error());
b38b0f
-            return;
b38b0f
-        }
b38b0f
-        ++i;
b38b0f
-    }
b38b0f
-}
b38b0f
-
b38b0f
-static void bdrv_vxhs_load_libs(Error **errp)
b38b0f
-{
b38b0f
-    Error *local_err = NULL;
b38b0f
-    int32_t ver;
b38b0f
-
b38b0f
-    if (libvxhs_loaded) {
b38b0f
-        return;
b38b0f
-    }
b38b0f
-
b38b0f
-    if (!g_module_supported()) {
b38b0f
-        error_setg(errp, "modules are not supported on this platform: %s",
b38b0f
-                     g_module_error());
b38b0f
-        return;
b38b0f
-    }
b38b0f
-
b38b0f
-    libvxhs_handle = g_module_open(LIBVXHS_FULL_PATHNAME,
b38b0f
-                                   G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
b38b0f
-    if (!libvxhs_handle) {
b38b0f
-        error_setg(errp, "The VXHS library from Veritas might not be installed "
b38b0f
-                   "correctly (%s)", g_module_error());
b38b0f
-        return;
b38b0f
-    }
b38b0f
-
b38b0f
-    g_module_make_resident(libvxhs_handle);
b38b0f
-
b38b0f
-    bdrv_vxhs_set_funcs(libvxhs_handle, &local_err);
b38b0f
-    if (local_err) {
b38b0f
-        error_propagate(errp, local_err);
b38b0f
-        return;
b38b0f
-    }
b38b0f
-
b38b0f
-    /* Now check to see if the libvxhs we are using here is supported
b38b0f
-     * by the loaded version */
b38b0f
-
b38b0f
-    ver = (*libvxhs.iio_min_version)();
b38b0f
-    if (ver > QNIO_VERSION) {
b38b0f
-        error_setg(errp, "Trying to use libvxhs version %"PRId32" API, but "
b38b0f
-                         "only %"PRId32" or newer is supported by %s",
b38b0f
-                          QNIO_VERSION, ver, LIBVXHS_FULL_PATHNAME);
b38b0f
-        return;
b38b0f
-    }
b38b0f
-
b38b0f
-    ver = (*libvxhs.iio_max_version)();
b38b0f
-    if (ver < QNIO_VERSION) {
b38b0f
-        error_setg(errp, "Trying to use libvxhs version %"PRId32" API, but "
b38b0f
-                         "only %"PRId32" or earlier is supported by %s",
b38b0f
-                          QNIO_VERSION, ver, LIBVXHS_FULL_PATHNAME);
b38b0f
-        return;
b38b0f
-    }
b38b0f
-
b38b0f
-    libvxhs_loaded = true;
b38b0f
-}
b38b0f
-
b38b0f
 static void vxhs_complete_aio_bh(void *opaque)
b38b0f
 {
b38b0f
     VXHSAIOCB *acb = opaque;
b38b0f
@@ -312,7 +220,7 @@ static void vxhs_parse_filename(const char *filename, QDict *options,
b38b0f
 static int vxhs_init_and_ref(void)
b38b0f
 {
b38b0f
     if (vxhs_ref++ == 0) {
b38b0f
-        if ((*libvxhs.iio_init)(QNIO_VERSION, vxhs_iio_callback)) {
b38b0f
+        if (iio_init(QNIO_VERSION, vxhs_iio_callback)) {
b38b0f
             return -ENODEV;
b38b0f
         }
b38b0f
     }
b38b0f
@@ -322,7 +230,7 @@ static int vxhs_init_and_ref(void)
b38b0f
 static void vxhs_unref(void)
b38b0f
 {
b38b0f
     if (--vxhs_ref == 0) {
b38b0f
-        (*libvxhs.iio_fini)();
b38b0f
+        iio_fini();
b38b0f
     }
b38b0f
 }
b38b0f
 
b38b0f
@@ -392,17 +300,8 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
b38b0f
     char *client_key = NULL;
b38b0f
     char *client_cert = NULL;
b38b0f
 
b38b0f
-    bdrv_vxhs_load_libs(&local_err);
b38b0f
-    if (local_err) {
b38b0f
-        error_propagate(errp, local_err);
b38b0f
-        /* on error, cannot cleanup because the iio_fini() function
b38b0f
-         * is not loaded */
b38b0f
-        return -EINVAL;
b38b0f
-    }
b38b0f
-
b38b0f
     ret = vxhs_init_and_ref();
b38b0f
     if (ret < 0) {
b38b0f
-        error_setg(&local_err, "libvxhs iio_init() failed");
b38b0f
         ret = -EINVAL;
b38b0f
         goto out;
b38b0f
     }
b38b0f
@@ -487,8 +386,8 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
b38b0f
     /*
b38b0f
      * Open qnio channel to storage agent if not opened before
b38b0f
      */
b38b0f
-    dev_handlep = (*libvxhs.iio_open)(of_vsa_addr, s->vdisk_guid, 0,
b38b0f
-                                      cacert, client_key, client_cert);
b38b0f
+    dev_handlep = iio_open(of_vsa_addr, s->vdisk_guid, 0,
b38b0f
+                           cacert, client_key, client_cert);
b38b0f
     if (dev_handlep == NULL) {
b38b0f
         trace_vxhs_open_iio_open(of_vsa_addr);
b38b0f
         ret = -ENODEV;
b38b0f
@@ -552,12 +451,12 @@ static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num,
b38b0f
 
b38b0f
     switch (iodir) {
b38b0f
     case VDISK_AIO_WRITE:
b38b0f
-            ret = (*libvxhs.iio_writev)(dev_handle, acb, qiov->iov, qiov->niov,
b38b0f
-                                        offset, (uint64_t)size, iio_flags);
b38b0f
+            ret = iio_writev(dev_handle, acb, qiov->iov, qiov->niov,
b38b0f
+                             offset, (uint64_t)size, iio_flags);
b38b0f
             break;
b38b0f
     case VDISK_AIO_READ:
b38b0f
-            ret = (*libvxhs.iio_readv)(dev_handle, acb, qiov->iov, qiov->niov,
b38b0f
-                                       offset, (uint64_t)size, iio_flags);
b38b0f
+            ret = iio_readv(dev_handle, acb, qiov->iov, qiov->niov,
b38b0f
+                            offset, (uint64_t)size, iio_flags);
b38b0f
             break;
b38b0f
     default:
b38b0f
             trace_vxhs_aio_rw_invalid(iodir);
b38b0f
@@ -607,7 +506,7 @@ static void vxhs_close(BlockDriverState *bs)
b38b0f
      * Close vDisk device
b38b0f
      */
b38b0f
     if (s->vdisk_hostinfo.dev_handle) {
b38b0f
-        (*libvxhs.iio_close)(s->vdisk_hostinfo.dev_handle);
b38b0f
+        iio_close(s->vdisk_hostinfo.dev_handle);
b38b0f
         s->vdisk_hostinfo.dev_handle = NULL;
b38b0f
     }
b38b0f
 
b38b0f
@@ -629,7 +528,7 @@ static int64_t vxhs_get_vdisk_stat(BDRVVXHSState *s)
b38b0f
     int ret = 0;
b38b0f
     void *dev_handle = s->vdisk_hostinfo.dev_handle;
b38b0f
 
b38b0f
-    ret = (*libvxhs.iio_ioctl)(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0);
b38b0f
+    ret = iio_ioctl(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0);
b38b0f
     if (ret < 0) {
b38b0f
         trace_vxhs_get_vdisk_stat_err(s->vdisk_guid, ret, errno);
b38b0f
         return -EIO;
b38b0f
diff --git a/configure b/configure
b38b0f
index 858b456..6d61b14 100755
b38b0f
--- a/configure
b38b0f
+++ b/configure
b38b0f
@@ -3428,7 +3428,7 @@ else
b38b0f
     glib_req_ver=2.22
b38b0f
 fi
b38b0f
 glib_modules=gthread-2.0
b38b0f
-if test "$modules" = yes -o "$vxhs" = yes; then
b38b0f
+if test "$modules" = yes; then
b38b0f
     glib_modules="$glib_modules gmodule-export-2.0"
b38b0f
 fi
b38b0f
 
b38b0f
@@ -5391,6 +5391,33 @@ if compile_prog "" "" ; then
b38b0f
 fi
b38b0f
 
b38b0f
 ##########################################
b38b0f
+# Veritas HyperScale block driver VxHS
b38b0f
+# Check if libvxhs is installed
b38b0f
+
b38b0f
+if test "$vxhs" != "no" ; then
b38b0f
+  cat > $TMPC <
b38b0f
+#include <stdint.h>
b38b0f
+#include <qnio/qnio_api.h>
b38b0f
+
b38b0f
+void *vxhs_callback;
b38b0f
+
b38b0f
+int main(void) {
b38b0f
+    iio_init(QNIO_VERSION, vxhs_callback);
b38b0f
+    return 0;
b38b0f
+}
b38b0f
+EOF
b38b0f
+  vxhs_libs="-lvxhs -lssl"
b38b0f
+  if compile_prog "" "$vxhs_libs" ; then
b38b0f
+    vxhs=yes
b38b0f
+  else
b38b0f
+    if test "$vxhs" = "yes" ; then
b38b0f
+      feature_not_found "vxhs block device" "Install libvxhs See github"
b38b0f
+    fi
b38b0f
+    vxhs=no
b38b0f
+  fi
b38b0f
+fi
b38b0f
+
b38b0f
+##########################################
b38b0f
 # check for _Static_assert()
b38b0f
 
b38b0f
 have_static_assert=no
b38b0f
@@ -6707,8 +6734,8 @@ if test "$pthread_setname_np" = "yes" ; then
b38b0f
 fi
b38b0f
 
b38b0f
 if test "$vxhs" = "yes" ; then
b38b0f
-  echo "CONFIG_VXHS=m" >> $config_host_mak
b38b0f
-  echo "VXHS_LIBS= -lssl" >> $config_host_mak
b38b0f
+  echo "CONFIG_VXHS=y" >> $config_host_mak
b38b0f
+  echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
b38b0f
 fi
b38b0f
 
b38b0f
 if test "$bochs" = "yes" ; then
b38b0f
diff --git a/include/block/vxhs_shim.h b/include/block/vxhs_shim.h
b38b0f
deleted file mode 100644
b38b0f
index 42519ae..0000000
b38b0f
--- a/include/block/vxhs_shim.h
b38b0f
+++ /dev/null
b38b0f
@@ -1,143 +0,0 @@
b38b0f
-/*
b38b0f
- * Network IO library for VxHS QEMU block driver (Veritas Technologies)
b38b0f
- *
b38b0f
- * This work is licensed under the terms of the GNU GPL, version 2.  See
b38b0f
- * the COPYING file in the top-level directory.
b38b0f
- *
b38b0f
- * Contributions after 2014-08-15 are licensed under the terms of the
b38b0f
- * GNU GPL, version 2 or (at your option) any later version.
b38b0f
- */
b38b0f
-
b38b0f
-#ifndef QNIO_API_H
b38b0f
-#define QNIO_API_H
b38b0f
-
b38b0f
-#include <sys/uio.h>
b38b0f
-
b38b0f
-/*
b38b0f
- * Bump up the version everytime this file is modified
b38b0f
- */
b38b0f
-#define QNIO_VERSION    34
b38b0f
-
b38b0f
-/*
b38b0f
- * These are the opcodes referenced by callback routine.
b38b0f
- */
b38b0f
-#define IRP_READ_REQUEST                    0x1FFF
b38b0f
-#define IRP_WRITE_REQUEST                   0x2FFF
b38b0f
-#define IRP_VDISK_CHECK_IO_FAILOVER_READY   2020
b38b0f
-
b38b0f
-/*
b38b0f
- * opcodes for iio_ioctl.
b38b0f
- */
b38b0f
-#define IOR_VDISK_STAT                      1005
b38b0f
-
b38b0f
-/*
b38b0f
- * Error values for iio_cb_t callback function.
b38b0f
- */
b38b0f
-#define QNIOERROR_HUP                       901 /* Retriable error */
b38b0f
-#define QNIOERROR_NOCONN                    902 /* Non-retriable error */
b38b0f
-
b38b0f
-
b38b0f
-/* Operation Flags */
b38b0f
-#define IIO_FLAG_ASYNC        0x0001   /* Do an async send */
b38b0f
-
b38b0f
-/*
b38b0f
- * INPUT:
b38b0f
- *     ctx - opaque context
b38b0f
- *     opcode - Operation
b38b0f
- *     error - 0 for sucess, non-zero for failure.
b38b0f
- * RETURNS:
b38b0f
- *     void
b38b0f
- * DESCRIPTION:
b38b0f
- *     This callback is called, after Async request completes.
b38b0f
- *
b38b0f
- * CONTEXT:
b38b0f
- *     The callback should be wait-free.
b38b0f
- */
b38b0f
-typedef void (*iio_cb_t) (void *ctx, uint32_t opcode, uint32_t error);
b38b0f
-
b38b0f
-typedef struct LibVXHSFuncs {
b38b0f
-/*
b38b0f
- * RETURNS:
b38b0f
- *     0 for sucess, non-zero for failure.
b38b0f
- * DESCRIPTION:
b38b0f
- *     Intilize the library state. This should be called at the
b38b0f
- *     begining before issuing any library call.
b38b0f
- */
b38b0f
-    int     (*iio_init)(int32_t version, iio_cb_t cb);
b38b0f
-/*
b38b0f
- * RETURNS:
b38b0f
- *     void
b38b0f
- * DESCRIPTION:
b38b0f
- *     Relinquish library resources. This should be called on the
b38b0f
- *     close of last open device.
b38b0f
- */
b38b0f
-    void    (*iio_fini)(void);
b38b0f
-/*
b38b0f
- * DESCRIPTION:
b38b0f
- *     Returns minimum QNIO API version supported by library.
b38b0f
- */
b38b0f
-    int32_t (*iio_min_version)(void);
b38b0f
-/*
b38b0f
- * DESCRIPTION:
b38b0f
- *     Returns maximum QNIO API version supported by library.
b38b0f
- */
b38b0f
-    int32_t (*iio_max_version)(void);
b38b0f
-/*
b38b0f
- * INPUT:
b38b0f
- *    uri - const string of the format of://<hostname|ip>:port
b38b0f
- *    devid - Device ID.
b38b0f
- *    flags - currently unused, this must be set to 0
b38b0f
- *    cacert - CA certificates file in PEM format
b38b0f
- *    client_key - Client private key file in PEM format
b38b0f
- *    client_cert - Client certificate file in PEM format
b38b0f
- * RETURNS:
b38b0f
- *    opeque device handle on success, NULL on failure.
b38b0f
- * DESCRIPTION:
b38b0f
- *    This call returns device handle on success. Returns NULL on
b38b0f
- *    failure with errno set
b38b0f
- *    errno can be one of:
b38b0f
- *        ENODEV - remote device not found
b38b0f
- *        EBADF  - Unable to open communication channel.
b38b0f
- *        EBUSY  - The call cannot be completed right now
b38b0f
- */
b38b0f
-    void   *(*iio_open)(const char *uri, const char *devid, uint32_t flags,
b38b0f
-                        const char *cacert, const char *client_key,
b38b0f
-                        const char *client_cert);
b38b0f
-/*
b38b0f
- * Close the device.
b38b0f
- *    For every matching iio_open() there should be a matching iio_close()
b38b0f
- *    The last close free all data structures associated with the device.
b38b0f
- */
b38b0f
-    int32_t (*iio_close)(void *dev_handle);
b38b0f
-/*
b38b0f
- * INPUT:
b38b0f
- *    dev_handle - device descriptor on which read/write needs to be performed
b38b0f
- *    ctx - an opaque context that is not interpreted This is set for
b38b0f
- *          async calls only. It can be NULL.
b38b0f
- *    iov    - an array of iovecs (This is a scatter gather operation)
b38b0f
- *    iovcnt  - the number of iovecs
b38b0f
- *    offset - an offset to perform the write
b38b0f
- *    size   - I/O size
b38b0f
- *    flags  - can be one of
b38b0f
- *        IIO_FLAG_ASYNC - indicating this is a aio call.
b38b0f
- * RETURNS:
b38b0f
- *        -1 on error, sets errno
b38b0f
- *        EBADF  - the remote fd is bad
b38b0f
- *        EBUSY  - The call cannot be completed right now
b38b0f
- *        EPIPE  - the channel got disconnected, call back would be called in
b38b0f
- *                 addition to this.
b38b0f
- */
b38b0f
-    int32_t (*iio_writev)(void *dev_handle, void *ctx, struct iovec *iov,
b38b0f
-                          int iovcnt, uint64_t offset, uint64_t size,
b38b0f
-                          uint32_t flags);
b38b0f
-
b38b0f
-    int32_t (*iio_readv)(void *dev_handle, void *ctx, struct iovec *iov,
b38b0f
-                         int iovcnt, uint64_t offset, uint64_t size,
b38b0f
-                         uint32_t flags);
b38b0f
-
b38b0f
-    int32_t (*iio_ioctl)(void *dev_handle, uint32_t opcode, void *opaque,
b38b0f
-                         uint32_t flags);
b38b0f
-
b38b0f
-} LibVXHSFuncs;
b38b0f
-
b38b0f
-#endif
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f