yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From 88780a41e05b8079cde07466c252b42c113f9e5c Mon Sep 17 00:00:00 2001
From: Miroslav Rezanina <mrezanin@redhat.com>
Date: Sun, 9 Jun 2019 09:35:09 +0100
Subject: [PATCH 8/8] Disable VXHS support

RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
Message-id: <1560072909-1725-1-git-send-email-mrezanin@redhat.com>
Patchwork-id: 88629
O-Subject: [RHEL-8 qemu-kvm PATCH] Disable VXHS support
Bugzilla: 1714933
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>

From: Miroslav Rezanina <mrezanin@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714933
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=22065429
Branch: rhel-8.1.0
Upstream: n/a

Reverting commit e9aff9d4ab1f9c10a4cb88fc5b92c4835e8b2688 introducing
downstream modularizaiton of VXHS driver as we do not need to support
VXHS driver anymore.

Patch is not pure revert as we changed way we handle configuration
of qemu build after this patch. In addition, reverting downstream only
removing of vxhs.o from block/Makefile.obj.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
 block/Makefile.objs           |   2 +-
 block/vxhs.c                  | 123 ++++--------------------------------
 configure                     |  33 +++++++++-
 include/block/vxhs_shim.h     | 143 ------------------------------------------
 redhat/qemu-kvm.spec.template |   9 ---
 5 files changed, 42 insertions(+), 268 deletions(-)
 delete mode 100644 include/block/vxhs_shim.h

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