Accepting request 710440 from home:jfehlig:branches:Virtualization

- Update to sanlock 3.8.0
  - Add support for python 3
  - Add support for 4k sector size
  - More API test coverage
  - Misc bug fixes and improvements
  - Dropped patches:
    revert-5d535c0d-py2.patch, sanlock-python3.patch

OBS-URL: https://build.opensuse.org/request/show/710440
OBS-URL: https://build.opensuse.org/package/show/Virtualization/sanlock?expand=0&rev=53
This commit is contained in:
James Fehlig 2019-06-17 22:41:08 +00:00 committed by Git OBS Bridge
parent 82b744757f
commit c7a785ce92
9 changed files with 41 additions and 461 deletions

View File

@ -1,30 +0,0 @@
commit d4fc2914b1847202d9dc26df89954766b27921d6
Author: Jim Fehlig <jfehlig@suse.com>
Date: Thu Mar 21 11:20:29 2019 -0600
Revert "python: Fix build on Fedora 29"
This reverts commit 5d535c0d800a84665879f6dc50c87915cf6657da. We
don't want it on SUSE where there is no python2.
Index: sanlock-3.7.1/python/Makefile
===================================================================
--- sanlock-3.7.1.orig/python/Makefile
+++ sanlock-3.7.1/python/Makefile
@@ -5,13 +5,13 @@
# of the GNU General Public License v.2.
all:
- python2 setup.py build
+ python setup.py build
inplace:
- python2 setup.py build_ext --inplace
+ python setup.py build_ext --inplace
install:
- python2 setup.py install --root=$(DESTDIR)
+ python setup.py install --root=$(DESTDIR)
clean:
rm -rf build

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b04cd8547dc8fa681ca32d7aa3cad3eb54959b5ecad9029d3240ae97398a92af
size 268303

3
sanlock-3.8.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7710b4cbf1faeacbfa7363d2e64284b3e190f5fe648db70b58db999f1a706064
size 262077

View File

@ -2,12 +2,12 @@ Index: python/Makefile
===================================================================
--- python/Makefile.orig
+++ python/Makefile
@@ -11,7 +11,7 @@ inplace:
python setup.py build_ext --inplace
@@ -10,7 +10,7 @@ all:
$(PYTHON) setup.py build $(BUILDARGS)
install:
- python setup.py install --root=$(DESTDIR)
+ python setup.py install --root=$(DESTDIR) --prefix=$(PREFIX)
- $(PYTHON) setup.py install --root=$(DESTDIR)
+ $(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(PREFIX)
clean:
rm -rf build

View File

@ -1,397 +0,0 @@
Index: sanlock-3.7.1/python/sanlock.c
===================================================================
--- sanlock-3.7.1.orig/python/sanlock.c
+++ sanlock-3.7.1/python/sanlock.c
@@ -12,6 +12,10 @@
#include <sanlock_admin.h>
#include <sanlock_direct.h>
+#if PY_MAJOR_VERSION >= 3
+#define IS_PY3K
+#endif
+
#ifndef __unused
#define __unused __attribute__ ((unused))
#endif
@@ -30,6 +34,17 @@
#define __neg_sets_exception
#endif
+struct module_state {
+ PyObject *error;
+};
+
+#ifdef IS_PY3K
+#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
+#else
+#define GETSTATE(m) (&_state)
+static struct module_state _state;
+#endif
+
/* Functions prototypes */
static void __set_exception(int en, char *msg) __sets_exception;
static int __parse_resource(PyObject *obj, struct sanlk_resource **res_ret) __neg_sets_exception;
@@ -103,14 +118,27 @@ __parse_resource(PyObject *obj, struct s
path = PyTuple_GetItem(tuple, 0);
offset = PyTuple_GetItem(tuple, 1);
+#ifdef IS_PY3K
+ p = PyBytes_AsString(path);
+#else
p = PyString_AsString(path);
+#endif
+#ifdef IS_PY3K
+ if (!PyLong_Check(offset)) {
+#else
if (!PyInt_Check(offset)) {
+#endif
__set_exception(EINVAL, "Invalid resource offset");
goto exit_fail;
}
+#ifdef IS_PY3K
+ } else if (PyBytes_Check(tuple)) {
+ p = PyBytes_AsString(tuple);
+#else
} else if (PyString_Check(tuple)) {
p = PyString_AsString(tuple);
+#endif
}
if (p == NULL) {
@@ -123,7 +151,11 @@ __parse_resource(PyObject *obj, struct s
if (offset == NULL) {
res->disks[i].offset = 0;
} else {
+#ifdef IS_PY3K
+ res->disks[i].offset = PyLong_AsLong(offset);
+#else
res->disks[i].offset = PyInt_AsLong(offset);
+#endif
}
}
@@ -150,7 +182,11 @@ __hosts_to_list(struct sanlk_host *hss,
goto exit_fail;
/* fill the dictionary information: host_id */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(hss[i].host_id)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(hss[i].host_id)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "host_id", ls_value);
Py_DECREF(ls_value);
@@ -158,7 +194,11 @@ __hosts_to_list(struct sanlk_host *hss,
goto exit_fail;
/* fill the dictionary information: generation */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(hss[i].generation)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(hss[i].generation)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "generation", ls_value);
Py_DECREF(ls_value);
@@ -166,7 +206,11 @@ __hosts_to_list(struct sanlk_host *hss,
goto exit_fail;
/* fill the dictionary information: timestamp */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(hss[i].timestamp)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(hss[i].timestamp)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "timestamp", ls_value);
Py_DECREF(ls_value);
@@ -174,7 +218,11 @@ __hosts_to_list(struct sanlk_host *hss,
goto exit_fail;
/* fill the dictionary information: io_timeout */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(hss[i].io_timeout)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(hss[i].io_timeout)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "io_timeout", ls_value);
Py_DECREF(ls_value);
@@ -182,7 +230,11 @@ __hosts_to_list(struct sanlk_host *hss,
goto exit_fail;
/* fill the dictionary information: flags */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(hss[i].flags)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(hss[i].flags)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "flags", ls_value);
Py_DECREF(ls_value);
@@ -225,7 +277,11 @@ py_register(PyObject *self __unused, PyO
return NULL;
}
+#ifdef IS_PY3K
+ return PyLong_FromLong(sanlockfd);
+#else
return PyInt_FromLong(sanlockfd);
+#endif
}
/* get_alignment */
@@ -258,7 +314,11 @@ py_get_alignment(PyObject *self __unused
return NULL;
}
+#ifdef IS_PY3K
+ return PyLong_FromLong(rv);
+#else
return PyInt_FromLong(rv);
+#endif
}
/* init_lockspace */
@@ -456,7 +516,11 @@ py_read_lockspace(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: lockspace */
+#ifdef IS_PY3K
+ if ((ls_entry = PyBytes_FromString(ls.name)) == NULL)
+#else
if ((ls_entry = PyString_FromString(ls.name)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_info, "lockspace", ls_entry);
Py_DECREF(ls_entry);
@@ -464,7 +528,11 @@ py_read_lockspace(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: iotimeout */
+#ifdef IS_PY3K
+ if ((ls_entry = PyLong_FromLong(io_timeout)) == NULL)
+#else
if ((ls_entry = PyInt_FromLong(io_timeout)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_info, "iotimeout", ls_entry);
Py_DECREF(ls_entry);
@@ -538,7 +606,11 @@ py_read_resource(PyObject *self __unused
goto exit_fail;
/* fill the dictionary information: lockspace */
+#ifdef IS_PY3K
+ if ((rs_entry = PyBytes_FromString(rs->lockspace_name)) == NULL)
+#else
if ((rs_entry = PyString_FromString(rs->lockspace_name)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(rs_info, "lockspace", rs_entry);
Py_DECREF(rs_entry);
@@ -546,7 +618,11 @@ py_read_resource(PyObject *self __unused
goto exit_fail;
/* fill the dictionary information: resource */
+#ifdef IS_PY3K
+ if ((rs_entry = PyBytes_FromString(rs->name)) == NULL)
+#else
if ((rs_entry = PyString_FromString(rs->name)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(rs_info, "resource", rs_entry);
Py_DECREF(rs_entry);
@@ -832,7 +908,11 @@ py_get_lockspaces(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: lockspace */
+#ifdef IS_PY3K
+ if ((ls_value = PyBytes_FromString(lss[i].name)) == NULL)
+#else
if ((ls_value = PyString_FromString(lss[i].name)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "lockspace", ls_value);
Py_DECREF(ls_value);
@@ -840,7 +920,11 @@ py_get_lockspaces(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: host_id */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(lss[i].host_id)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(lss[i].host_id)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "host_id", ls_value);
Py_DECREF(ls_value);
@@ -848,7 +932,11 @@ py_get_lockspaces(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: path */
+#ifdef IS_PY3K
+ if ((ls_value = PyBytes_FromString(lss[i].host_id_disk.path)) == NULL)
+#else
if ((ls_value = PyString_FromString(lss[i].host_id_disk.path)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "path", ls_value);
Py_DECREF(ls_value);
@@ -856,7 +944,11 @@ py_get_lockspaces(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: offset */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(lss[i].host_id_disk.offset)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(lss[i].host_id_disk.offset)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "offset", ls_value);
Py_DECREF(ls_value);
@@ -864,7 +956,11 @@ py_get_lockspaces(PyObject *self __unuse
goto exit_fail;
/* fill the dictionary information: flags */
+#ifdef IS_PY3K
+ if ((ls_value = PyLong_FromLong(lss[i].flags)) == NULL)
+#else
if ((ls_value = PyInt_FromLong(lss[i].flags)) == NULL)
+#endif
goto exit_fail;
rv = PyDict_SetItemString(ls_entry, "flags", ls_value);
Py_DECREF(ls_value);
@@ -986,7 +1082,11 @@ py_acquire(PyObject *self __unused, PyOb
/* prepare the resource version */
if (version != Py_None) {
res->flags |= SANLK_RES_LVER;
+#ifdef IS_PY3K
+ res->lver = PyLong_AsUnsignedLongMask(version);
+#else
res->lver = PyInt_AsUnsignedLongMask(version);
+#endif
if (res->lver == -1) {
__set_exception(EINVAL, "Unable to convert the version value");
goto exit_fail;
@@ -1102,7 +1202,11 @@ py_request(PyObject *self __unused, PyOb
flags = SANLK_REQUEST_NEXT_LVER;
} else {
res->flags |= SANLK_RES_LVER;
+#ifdef IS_PY3K
+ res->lver = PyLong_AsUnsignedLongMask(version);
+#else
res->lver = PyInt_AsUnsignedLongMask(version);
+#endif
if (res->lver == -1) {
__set_exception(EINVAL, "Unable to convert the version value");
goto exit_fail;
@@ -1217,7 +1321,11 @@ py_killpath(PyObject *self __unused, PyO
size_t arg_len;
item = PyList_GetItem(argslist, i);
+#ifdef IS_PY3K
+ p = PyBytes_AsString(item);
+#else
p = PyString_AsString(item);
+#endif
if (p == NULL) {
__set_exception(EINVAL, "Killpath argument not a string");
@@ -1606,32 +1714,83 @@ exit_fail:
return excp;
}
+#ifdef IS_PY3K
+static int sanlock_traverse(PyObject *m, visitproc visit, void *arg) {
+ Py_VISIT(GETSTATE(m)->error);
+ return 0;
+}
+
+static int sanlock_clear(PyObject *m) {
+ Py_CLEAR(GETSTATE(m)->error);
+ return 0;
+}
+
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "sanlock",
+ pydoc_sanlock,
+ sizeof(struct module_state),
+ sanlock_methods,
+ NULL,
+ sanlock_traverse,
+ sanlock_clear,
+ NULL
+};
+
+#define INITERROR return NULL
+
+PyMODINIT_FUNC
+PyInit_sanlock(void)
+
+#else
+#define INITERROR return
+
PyMODINIT_FUNC
initsanlock(void)
+#endif
{
PyObject *py_module, *sk_constant;
+ struct module_state *st;
+#ifdef IS_PY3K
+ py_module = PyModule_Create(&moduledef);
+#else
py_module = Py_InitModule4("sanlock",
sanlock_methods, pydoc_sanlock, NULL, PYTHON_API_VERSION);
+#endif
if (py_module == NULL)
- return;
+ INITERROR;
py_exception = initexception();
- if (py_exception == NULL)
- return;
+ if (py_exception == NULL) {
+ Py_DECREF(py_module);
+ INITERROR;
+ }
+
+ st = GETSTATE(py_module);
+ st->error = py_exception;
if (PyModule_AddObject(py_module, "SanlockException", py_exception) == 0) {
Py_INCREF(py_exception);
}
+#ifdef IS_PY3K
+#define PYSNLK_INIT_ADD_CONSTANT(x, y) \
+ if ((sk_constant = PyLong_FromLong(x)) != NULL) { \
+ if (PyModule_AddObject(py_module, y, sk_constant)) { \
+ Py_DECREF(sk_constant); \
+ } \
+ }
+#else
#define PYSNLK_INIT_ADD_CONSTANT(x, y) \
if ((sk_constant = PyInt_FromLong(x)) != NULL) { \
if (PyModule_AddObject(py_module, y, sk_constant)) { \
Py_DECREF(sk_constant); \
} \
}
+#endif
/* lockspaces list flags */
PYSNLK_INIT_ADD_CONSTANT(SANLK_LSF_ADD, "LSFLAG_ADD");
@@ -1664,4 +1823,8 @@ initsanlock(void)
PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "SANLK_RES_ALIGN8M");
#undef PYSNLK_INIT_ADD_CONSTANT
+
+#ifdef IS_PY3K
+ return py_module;
+#endif
}

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Mon Jun 17 21:45:36 UTC 2019 - Jim Fehlig <jfehlig@suse.com>
- Update to sanlock 3.8.0
- Add support for python 3
- Add support for 4k sector size
- More API test coverage
- Misc bug fixes and improvements
- Dropped patches:
revert-5d535c0d-py2.patch, sanlock-python3.patch
-------------------------------------------------------------------
Tue Apr 9 22:17:12 UTC 2019 - Jim Fehlig <jfehlig@suse.com>

View File

@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@ -28,7 +28,7 @@
%endif
%bcond_without python2
Name: sanlock
Version: 3.7.1
Version: 3.8.0
Release: 0
Summary: A shared disk lock manager
License: GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
@ -40,12 +40,10 @@ Source2: sysconfig.wdmd
Source3: fence_sanlockd.init
# Upstream patches
# SUSE patches
Patch100: revert-5d535c0d-py2.patch
Patch101: sanlock-SCHED_RESET_ON_FORK-undefined.patch
Patch102: sanlock-python-prefix.patch
Patch103: suse-systemd.patch
Patch104: suse-no-date-time.patch
Patch105: sanlock-python3.patch
Patch100: sanlock-SCHED_RESET_ON_FORK-undefined.patch
Patch101: sanlock-python-prefix.patch
Patch102: suse-systemd.patch
Patch103: suse-no-date-time.patch
BuildRequires: %{python_module devel}
BuildRequires: libaio-devel
BuildRequires: pkgconfig
@ -127,12 +125,10 @@ common sanlock lockspace.
%prep
%setup -q
%patch100 -p1
%patch100
%patch101
%patch102
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%build
# upstream does not require configure

View File

@ -1,7 +1,7 @@
Index: sanlock-3.7.1/src/main.c
Index: sanlock-3.8.0/src/main.c
===================================================================
--- sanlock-3.7.1.orig/src/main.c
+++ sanlock-3.7.1/src/main.c
--- sanlock-3.8.0.orig/src/main.c
+++ sanlock-3.8.0/src/main.c
@@ -2126,8 +2126,8 @@ static int read_command_line(int argc, c
}
@ -13,10 +13,10 @@ Index: sanlock-3.7.1/src/main.c
exit(EXIT_SUCCESS);
}
Index: sanlock-3.7.1/fence_sanlock/fence_sanlockd.c
Index: sanlock-3.8.0/fence_sanlock/fence_sanlockd.c
===================================================================
--- sanlock-3.7.1.orig/fence_sanlock/fence_sanlockd.c
+++ sanlock-3.7.1/fence_sanlock/fence_sanlockd.c
--- sanlock-3.8.0.orig/fence_sanlock/fence_sanlockd.c
+++ sanlock-3.8.0/fence_sanlock/fence_sanlockd.c
@@ -565,8 +565,7 @@ int main(int argc, char *argv[])
print_usage();
exit(0);

View File

@ -1,7 +1,7 @@
Index: sanlock-3.7.1/init.d/sanlock.service
Index: sanlock-3.8.0/init.d/sanlock.service
===================================================================
--- sanlock-3.7.1.orig/init.d/sanlock.service
+++ sanlock-3.7.1/init.d/sanlock.service
--- sanlock-3.8.0.orig/init.d/sanlock.service
+++ sanlock-3.8.0/init.d/sanlock.service
@@ -5,8 +5,10 @@ Wants=wdmd.service
[Service]
@ -15,10 +15,10 @@ Index: sanlock-3.7.1/init.d/sanlock.service
[Install]
WantedBy=multi-user.target
Index: sanlock-3.7.1/init.d/wdmd.service
Index: sanlock-3.8.0/init.d/wdmd.service
===================================================================
--- sanlock-3.7.1.orig/init.d/wdmd.service
+++ sanlock-3.7.1/init.d/wdmd.service
--- sanlock-3.8.0.orig/init.d/wdmd.service
+++ sanlock-3.8.0/init.d/wdmd.service
@@ -4,8 +4,10 @@ After=syslog.target
[Service]
@ -32,10 +32,10 @@ Index: sanlock-3.7.1/init.d/wdmd.service
[Install]
WantedBy=multi-user.target
Index: sanlock-3.7.1/init.d/fence_sanlockd.service
Index: sanlock-3.8.0/init.d/fence_sanlockd.service
===================================================================
--- sanlock-3.7.1.orig/init.d/fence_sanlockd.service
+++ sanlock-3.7.1/init.d/fence_sanlockd.service
--- sanlock-3.8.0.orig/init.d/fence_sanlockd.service
+++ sanlock-3.8.0/init.d/fence_sanlockd.service
@@ -5,8 +5,8 @@ Before=corosync.service
[Service]