File s390-tools-sles15sp4-09-libap-use-util_lockfile-and-remove-liblockfile-depen.patch of Package s390-tools.30980
Subject: [PATCH] [FEAT VS1822] libap: use util_lockfile and remove liblockfile dependency
From: Matthew Rosato <mjrosato@linux.ibm.com>
Summary: ap_tools: add ap-check and the ap device type to zdev
Description: This feature adds multiple components in support of persistent
configuration of vfio-ap mediated devices.
The ap-check utility is added as a callout function for the
mdevctl utility. This allows for meaningful error messages to be
presented to end-users when vfio-ap configuration errors are
detected while using mdevctl to create/modify vfio-ap mediated
devices.
Additionally, the 'ap' device type is added to zdev, providing a
command-line interface for managing the apmask and aqmask, which
determine what AP resources are available for vfio-ap usage.
'chzdev' is updated to allow for modifying the active masks as
well as to specify persistent mask values via a udev rule.
'lszdev' is updated to allow for querying of the active and
persistent mask values.
Upstream-ID: 25a70ac5a81ec0b3fa74715e30cc3675d2f018d8
Problem-ID: VS1822
Upstream-Description:
libap: use util_lockfile and remove liblockfile dependency
Now that we have a utility library for file locking, remove all
calls to liblockfile functions from libap and remove all links to
the library from the current users of the libap liblockfile
implementation (ap_tools/ap-check and zdev).
Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/142
Suggested-by: Luca BRUNO <luca.bruno@coreos.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
README.md | 10 ++++------
ap_tools/Makefile | 11 ++---------
ap_tools/ap-check.c | 4 ++--
include/lib/ap.h | 1 +
libap/Makefile | 13 +------------
libap/ap.c | 45 ++++++++++++---------------------------------
zdev/src/Makefile | 3 ---
7 files changed, 22 insertions(+), 65 deletions(-)
--- a/README.md
+++ b/README.md
@@ -316,7 +316,6 @@ build options:
| | | pvattest |
| libxml2 | `HAVE_LIBXML2` | libkmipclient |
| systemd | `HAVE_SYSTEMD` | hsavmcore |
-| liblockfile | `HAVE_LOCKFILE` | ap-check |
This table lists additional build or install options:
@@ -501,8 +500,7 @@ the different tools are provided:
further requires pandoc and GNU awk for the build process.
* ap-check:
- For building the ap-check mdevctl callout utility you need liblockfile
- version 1.14 or newer installed (liblockfile-devel.rpm). Also required is
- json-c version 0.13 or newer (json-c-devel.rpm).
- Tip: you may skip ap-check build by adding `HAVE_LOCKFILE=0` or `HAVE_JSONC=0`
- to the make invocation.
+ For building the ap-check mdevctl callout utility you need json-c version
+ 0.13 or newer (json-c-devel.rpm).
+ Tip: you may skip ap-check build by adding `HAVE_JSONC=0` to the make
+ invocation.
--- a/ap_tools/Makefile
+++ b/ap_tools/Makefile
@@ -7,21 +7,14 @@ MDEVCTL_CALLOUTS = /etc/mdevctl.d/script
libs = $(rootdir)/libap/libap.a \
$(rootdir)/libutil/libutil.a
-ifeq (${HAVE_LOCKFILE},0)
-all:
- $(SKIP) HAVE_LOCKFILE=0
-
-install:
- $(SKIP) HAVE_LOCKFILE=0
-
-else ifeq (${HAVE_JSONC},0)
+ifeq (${HAVE_JSONC},0)
all:
$(SKIP) HAVE_JSONC=0
install:
$(SKIP) HAVE_JSONC=0
else
-LDLIBS += -llockfile -ljson-c
+LDLIBS += -ljson-c
all: ap-check
--- a/ap_tools/ap-check.c
+++ b/ap_tools/ap-check.c
@@ -133,7 +133,7 @@ static void ap_check_cleanup(struct ap_c
if (anc->dev)
vfio_ap_device_free(anc->dev);
if (anc->cleanup_lock)
- ap_release_lock();
+ ap_release_lock_callout();
}
/*
@@ -767,7 +767,7 @@ out:
*/
static int ap_check_handle_post(void)
{
- return ap_release_lock();
+ return ap_release_lock_callout();
}
/* For the specified device, print the attributes to stdout in JSON format */
--- a/include/lib/ap.h
+++ b/include/lib/ap.h
@@ -90,5 +90,6 @@ void ap_list_remove_all(struct util_list
int ap_get_lock(void);
int ap_get_lock_callout(void);
int ap_release_lock(void);
+int ap_release_lock_callout(void);
#endif /* LIB_AP_H */
--- a/libap/Makefile
+++ b/libap/Makefile
@@ -2,17 +2,6 @@ include ../common.mak
lib = libap.a
-check-dep-lock:
- touch check-dep-lock
-ifneq (${HAVE_LOCKFILE},0)
- $(call check_dep, \
- "libap", \
- "lockfile.h", \
- "liblockfile-devel", \
- "HAVE_LOCKFILE=0")
-ALL_CPPFLAGS += -DHAVE_LOCKFILE
-endif
-
check-dep-json:
touch check-dep-json
ifneq (${HAVE_JSONC},0)
@@ -29,7 +18,7 @@ objects = ap.o
$(lib): $(objects)
-$(objects): check-dep-lock check-dep-json
+$(objects): check-dep-json
install: all
--- a/libap/ap.c
+++ b/libap/ap.c
@@ -22,13 +22,10 @@
#include <json-c/json.h>
#endif /* HAVE_JSONC */
-#ifdef HAVE_LOCKFILE
-#include <lockfile.h>
-#endif /* HAVE_LOCKFILE */
-
#include "lib/ap.h"
#include "lib/util_file.h"
#include "lib/util_libc.h"
+#include "lib/util_lockfile.h"
#include "lib/util_panic.h"
#include "lib/util_path.h"
#include "lib/util_udev.h"
@@ -701,33 +698,28 @@ void ap_list_remove_all(struct util_list
}
}
-#ifdef HAVE_LOCKFILE
-static int ap_lockfile_create(int flags)
-{
- return lockfile_create(AP_LOCKFILE, AP_LOCK_RETRIES, flags);
-}
-
/**
- * Acquire the ap config lock using this process PID (L_PID)
+ * Acquire the ap config lock using this Process ID
+ *
+ * @retval 0 Lock acquired on behalf of this process
*
- * @retval 0 Lock successfully acquired on behalf of L_PID
* @retval != 0 Error, lock was not obtained
*/
int ap_get_lock(void)
{
- return ap_lockfile_create(L_PID);
+ return util_lockfile_lock(AP_LOCKFILE, AP_LOCK_RETRIES);
}
/**
- * Acquire the ap config lock using the parent process PID (L_PPID) -- intended
- * for use by the mdevctl callout ap-check utility
+ * Acquire the ap config lock using the Parent Process ID -- intended for use
+ * by the mdevctl callout ap-check utility
*
- * @retval 0 Lock successfully acquired on behalf of L_PPID
+ * @retval 0 Lock acquired on behalf of parent process
* @retval != 0 Error, lock was not obtained
*/
int ap_get_lock_callout(void)
{
- return ap_lockfile_create(L_PPID);
+ return util_lockfile_parent_lock(AP_LOCKFILE, AP_LOCK_RETRIES);
}
/**
@@ -738,23 +730,10 @@ int ap_get_lock_callout(void)
*/
int ap_release_lock(void)
{
- return lockfile_remove(AP_LOCKFILE);
-}
-#else
-/* If no liblockfile, actions are performed without acquiring the file lock */
-int ap_get_lock(void)
-{
- return 0;
+ return util_lockfile_release(AP_LOCKFILE);
}
-int ap_get_lock_callout(void)
+int ap_release_lock_callout(void)
{
- return 0;
+ return util_lockfile_parent_release(AP_LOCKFILE);
}
-
-int ap_release_lock(void)
-{
- return 0;
-}
-
-#endif /* HAVE_LOCKFILE */
--- a/zdev/src/Makefile
+++ b/zdev/src/Makefile
@@ -81,9 +81,6 @@ lszdev_objects += generic_ccw.o
all: chzdev lszdev zdev_id
-ifneq (${HAVE_LOCKFILE}, 0)
-LDLIBS += -llockfile
-endif
ifneq (${HAVE_JSONC}, 0)
LDLIBS += -ljson-c
endif