[sanlock] 02/03: spec: Use one requirement per line
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit af28516d17a5591e3ea7e10b5e77eae2a07241ed
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Wed May 22 22:59:34 2019 +0300
spec: Use one requirement per line
This make it easier to work with.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
sanlock.spec.in | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sanlock.spec.in b/sanlock.spec.in
index e085152..14729cf 100644
--- a/sanlock.spec.in
+++ b/sanlock.spec.in
@@ -14,7 +14,10 @@ Summary: A shared storage lock manager
License: GPLv2 and GPLv2+ and LGPLv2+
URL: https://pagure.io/sanlock/
BuildRequires: gcc
-BuildRequires: libblkid-devel libaio-devel python2 python2-devel
+BuildRequires: libaio-devel
+BuildRequires: libblkid-devel
+BuildRequires: python2
+BuildRequires: python2-devel
BuildRequires: systemd-units
Requires: %{name}-lib = %{version}-%{release}
Requires(pre): /usr/sbin/groupadd
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 11 months
[sanlock] 01/03: build: Replace %{_localstatedir}/run with
%{_rundir}
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit c47fee4ed5a1608f4199c344338744883a3afd6f
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Wed May 22 22:48:50 2019 +0300
build: Replace %{_localstatedir}/run with %{_rundir}
Completing the move from /var/run to /run, update the development spec.
This change should be backported later to Fedora and RHEL specs.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
sanlock.spec.in | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sanlock.spec.in b/sanlock.spec.in
index cf72ad4..e085152 100644
--- a/sanlock.spec.in
+++ b/sanlock.spec.in
@@ -83,8 +83,8 @@ install -D -m 0644 init.d/wdmd.sysconfig \
$RPM_BUILD_ROOT/etc/sysconfig/wdmd
install -Dd -m 0755 $RPM_BUILD_ROOT/etc/wdmd.d
-install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/sanlock
-install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/sanlk-resetd
+install -Dd -m 0775 $RPM_BUILD_ROOT/%{_rundir}/sanlock
+install -Dd -m 0775 $RPM_BUILD_ROOT/%{_rundir}/sanlk-resetd
%pre
getent group sanlock > /dev/null || /usr/sbin/groupadd \
@@ -111,7 +111,7 @@ getent passwd sanlock > /dev/null || /usr/sbin/useradd \
%{_sbindir}/wdmd
%dir %{_sysconfdir}/wdmd.d
%dir %{_sysconfdir}/sanlock
-%dir %attr(-,sanlock,sanlock) %{_localstatedir}/run/sanlock
+%dir %attr(-,sanlock,sanlock) %{_rundir}/sanlock
%{_mandir}/man8/wdmd*
%{_mandir}/man8/sanlock*
%config(noreplace) %{_sysconfdir}/logrotate.d/sanlock
@@ -193,7 +193,7 @@ common sanlock lockspace.
%{_sbindir}/sanlk-reset
%{_sbindir}/sanlk-resetd
%{_unitdir}/sanlk-resetd.service
-%dir %attr(-,root,root) %{_localstatedir}/run/sanlk-resetd
+%dir %attr(-,root,root) %{_rundir}/sanlk-resetd
%{_mandir}/man8/sanlk-reset*
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 11 months
[sanlock] branch master updated: build: Replace /var/run with /run
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 21905a6 build: Replace /var/run with /run
21905a6 is described below
commit 21905a6346fa4dc08db8b2da204299000d4c0c7e
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Wed May 22 22:37:19 2019 +0300
build: Replace /var/run with /run
/var/run is a symlink to /run since RHEL 7, and few year before that on
Fedora. rpmlint is complaining in Fedora that we still use it:
sanlock.x86_64: E: dir-or-file-in-var-run /var/run/sanlock
Replace all instance of /var/run with /run.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
fence_sanlock/fence_sanlock.in | 2 +-
fence_sanlock/fence_sanlockd.c | 6 +++---
init.d/fence_sanlockd | 12 ++++++------
init.d/sanlock | 8 ++++----
init.d/wdmd | 8 ++++----
reset/sanlk_reset.h | 2 +-
sanlock.spec.in | 2 +-
src/sanlock_internal.h | 2 +-
tests/clientn | 4 ++--
wdmd/main.c | 4 ++--
wdmd/wdmd_sock.h | 2 +-
11 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/fence_sanlock/fence_sanlock.in b/fence_sanlock/fence_sanlock.in
index dbc0f24..a46773c 100755
--- a/fence_sanlock/fence_sanlock.in
+++ b/fence_sanlock/fence_sanlock.in
@@ -256,7 +256,7 @@ action_off() {
# fence_sanlock's can run in parallel. fence_sanlockd may read
# this file to see which host_id we are fencing.
- pidfile=/var/run/$prog/$prog.pid.$$
+ pidfile=/run/$prog/$prog.pid.$$
echo "$$ host_id $host_id gen $owner_gen ver $ver timestamp $timestamp" > $pidfile
diff --git a/fence_sanlock/fence_sanlockd.c b/fence_sanlock/fence_sanlockd.c
index be342c1..6ad7be1 100644
--- a/fence_sanlock/fence_sanlockd.c
+++ b/fence_sanlock/fence_sanlockd.c
@@ -37,8 +37,8 @@
#define LIVE_INTERVAL 5
#define EXPIRE_INTERVAL 20
-#define DAEMON_RUN_DIR "/var/run/fence_sanlockd"
-#define AGENT_RUN_DIR "/var/run/fence_sanlock"
+#define DAEMON_RUN_DIR "/run/fence_sanlockd"
+#define AGENT_RUN_DIR "/run/fence_sanlock"
static char *prog_name = (char *)"fence_sanlockd";
@@ -441,7 +441,7 @@ static int check_fence_agent(int *victim_host_id)
log_debug("read %s", de->d_name);
/*
- * read /var/run/fence_sanlock/fence_sanlock.pid.<pid>
+ * read /run/fence_sanlock/fence_sanlock.pid.<pid>
* to get the pid of fence_sanlock and the victim's host_id
*
* read /proc/pid/comm to check that the pid from that file
diff --git a/init.d/fence_sanlockd b/init.d/fence_sanlockd
index fb5fae8..99041b5 100755
--- a/init.d/fence_sanlockd
+++ b/init.d/fence_sanlockd
@@ -23,8 +23,8 @@
prog="fence_sanlockd"
agent="fence_sanlock"
-runfile="/var/run/$prog/$prog.pid"
-fifofile="/var/run/$prog/$prog.fifo"
+runfile="/run/$prog/$prog.pid"
+fifofile="/run/$prog/$prog.fifo"
lockfile="/var/lock/subsys/$prog"
exec="/usr/sbin/$prog"
@@ -41,17 +41,17 @@ start() {
service sanlock status > /dev/null 2>&1 || service sanlock start
- [ ! -d /var/run/$prog ] && install -d -m 775 /var/run/$prog
+ [ ! -d /run/$prog ] && install -d -m 775 /run/$prog
- [ ! -d /var/run/$agent ] && install -d -m 775 /var/run/$agent
+ [ ! -d /run/$agent ] && install -d -m 775 /run/$agent
[ -n "$(which restorecon)" ] && \
[ -x "$(which restorecon)" ] && \
- restorecon /var/run/$prog
+ restorecon /run/$prog
[ -n "$(which restorecon)" ] && \
[ -x "$(which restorecon)" ] && \
- restorecon /var/run/$agent
+ restorecon /run/$agent
echo -n $"Starting $prog: "
daemon $prog $FENCESANLOCKDOPTS
diff --git a/init.d/sanlock b/init.d/sanlock
index 83b35e8..bc1c330 100644
--- a/init.d/sanlock
+++ b/init.d/sanlock
@@ -22,7 +22,7 @@
. /etc/rc.d/init.d/functions
prog="sanlock"
-runfile="/var/run/$prog/$prog.pid"
+runfile="/run/$prog/$prog.pid"
lockfile="/var/lock/subsys/$prog"
exec="/usr/sbin/$prog"
@@ -34,9 +34,9 @@ SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
start() {
[ -x $exec ] || exit 5
- if [ ! -d /var/run/$prog ]; then
- install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /var/run/$prog
- [ -x /sbin/restorecon ] && restorecon /var/run/$prog
+ if [ ! -d /run/$prog ]; then
+ install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /run/$prog
+ [ -x /sbin/restorecon ] && restorecon /run/$prog
fi
echo -n $"Starting $prog: "
diff --git a/init.d/wdmd b/init.d/wdmd
index 565342d..b6a2a79 100644
--- a/init.d/wdmd
+++ b/init.d/wdmd
@@ -22,7 +22,7 @@
. /etc/rc.d/init.d/functions
prog="wdmd"
-runfile="/var/run/$prog/$prog.pid"
+runfile="/run/$prog/$prog.pid"
lockfile="/var/lock/subsys/$prog"
exec="/usr/sbin/$prog"
@@ -60,9 +60,9 @@ start() {
[ -x $exec ] || exit 5
- if [ ! -d /var/run/$prog ]; then
- install -d -g $WDMDGROUP -m 775 /var/run/$prog
- [ -x /sbin/restorecon ] && restorecon /var/run/$prog
+ if [ ! -d /run/$prog ]; then
+ install -d -g $WDMDGROUP -m 775 /run/$prog
+ [ -x /sbin/restorecon ] && restorecon /run/$prog
fi
echo -n $"Starting $prog: "
diff --git a/reset/sanlk_reset.h b/reset/sanlk_reset.h
index 8c92c8e..377f511 100644
--- a/reset/sanlk_reset.h
+++ b/reset/sanlk_reset.h
@@ -14,7 +14,7 @@
#define EVENT_REBOOT 4
#define EVENT_REBOOTING 8
-#define SANLK_RESETD_RUNDIR "/var/run/sanlk-resetd"
+#define SANLK_RESETD_RUNDIR "/run/sanlk-resetd"
#define SANLK_RESETD_SOCKET SANLK_RESETD_RUNDIR "/sanlk-resetd.sock"
#define SANLK_RESETD_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
diff --git a/sanlock.spec.in b/sanlock.spec.in
index 6485c61..cf72ad4 100644
--- a/sanlock.spec.in
+++ b/sanlock.spec.in
@@ -91,7 +91,7 @@ getent group sanlock > /dev/null || /usr/sbin/groupadd \
-g 179 sanlock
getent passwd sanlock > /dev/null || /usr/sbin/useradd \
-u 179 -c "sanlock" -s /sbin/nologin -r \
- -g 179 -d /var/run/sanlock sanlock
+ -g 179 -d /run/sanlock sanlock
/usr/sbin/usermod -a -G disk sanlock
%post
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 3a09b62..a78c81f 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -46,7 +46,7 @@
#define COMMAND_MAX 4096
#define SANLOCK_RUN_DIR "SANLOCK_RUN_DIR"
-#define DEFAULT_RUN_DIR "/var/run/sanlock"
+#define DEFAULT_RUN_DIR "/run/sanlock"
#define SANLOCK_PRIVILEGED "SANLOCK_PRIVILEGED"
#define SANLK_LOG_DIR "/var/log"
diff --git a/tests/clientn b/tests/clientn
index 85b4181..bd6bf5a 100755
--- a/tests/clientn
+++ b/tests/clientn
@@ -33,7 +33,7 @@ elif [ "$cmd" == "delay" ]; then
sec=$3
- pid=`cat /var/run/sanlock/sanlock.pid`
+ pid=`cat /run/sanlock/sanlock.pid`
echo sync with daemon renewals
kill -s SIGSTOP $pid
@@ -54,7 +54,7 @@ elif [ "$cmd" == "iodelay" ]; then
sec=$4
- pid=`cat /var/run/sanlock/sanlock.pid`
+ pid=`cat /run/sanlock/sanlock.pid`
echo sync with daemon renewals
kill -s SIGSTOP $pid
diff --git a/wdmd/main.c b/wdmd/main.c
index 911d833..edd15e8 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -569,7 +569,7 @@ static int active_clients(void)
#ifdef TEST_FILES
-#define FILES_DIR "/var/run/wdmd/test_files"
+#define FILES_DIR "/run/wdmd/test_files"
const char *files_built = " files";
static DIR *files_dir;
@@ -1024,7 +1024,7 @@ static int _setup_watchdog(char *path)
out:
log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
- /* TODO: save watchdog_path in /var/run/wdmd/saved_path,
+ /* TODO: save watchdog_path in /run/wdmd/saved_path,
* and in startup read that file, copying it to saved_path */
return 0;
diff --git a/wdmd/wdmd_sock.h b/wdmd/wdmd_sock.h
index 6818683..f5ed27e 100644
--- a/wdmd/wdmd_sock.h
+++ b/wdmd/wdmd_sock.h
@@ -10,7 +10,7 @@
#ifndef __WDMD_SOCK_H__
#define __WDMD_SOCK_H__
-#define WDMD_RUN_DIR "/var/run/wdmd"
+#define WDMD_RUN_DIR "/run/wdmd"
#define WDMD_SOCKET_NAME "wdmd.sock"
enum {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 11 months
Re: [PATCH] build: Replace /var/run with /run
by Nir Soffer
On Thu, May 23, 2019 at 3:35 PM Pavel Bar <pbar(a)redhat.com> wrote:
> Looks OK.
> Too bad there is no clean way to eliminate the hard-coded appearance of
> the "/run" across multiple files (.c, .h, scripts).
>
It is possible to avoid the duplication. For example, keeping the
configuration
in a text file, and generating config.h, config.py, and config.sh files to
share
the values with the components that need these values.
But this is is a task for another day.
On Wed, May 22, 2019 at 10:37 PM Nir Soffer <nirsof(a)gmail.com> wrote:
>
>> /var/run is a symlink to /run since RHEL 7, and few year before that on
>> Fedora. rpmlint is complaining in Fedora that we still use it:
>>
>> sanlock.x86_64: E: dir-or-file-in-var-run /var/run/sanlock
>>
>> Replace all instance of /var/run with /run.
>>
>> Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
>> ---
>> fence_sanlock/fence_sanlock.in | 2 +-
>> fence_sanlock/fence_sanlockd.c | 6 +++---
>> init.d/fence_sanlockd | 12 ++++++------
>> init.d/sanlock | 8 ++++----
>> init.d/wdmd | 8 ++++----
>> reset/sanlk_reset.h | 2 +-
>> sanlock.spec.in | 2 +-
>> src/sanlock_internal.h | 2 +-
>> tests/clientn | 4 ++--
>> wdmd/main.c | 4 ++--
>> wdmd/wdmd_sock.h | 2 +-
>> 11 files changed, 26 insertions(+), 26 deletions(-)
>>
>> diff --git a/fence_sanlock/fence_sanlock.in b/fence_sanlock/
>> fence_sanlock.in
>> index dbc0f24..a46773c 100755
>> --- a/fence_sanlock/fence_sanlock.in
>> +++ b/fence_sanlock/fence_sanlock.in
>> @@ -254,11 +254,11 @@ action_off() {
>>
>> # pid file should be unique for each instance so multiple
>> # fence_sanlock's can run in parallel. fence_sanlockd may read
>> # this file to see which host_id we are fencing.
>>
>> - pidfile=/var/run/$prog/$prog.pid.$$
>> + pidfile=/run/$prog/$prog.pid.$$
>>
>> echo "$$ host_id $host_id gen $owner_gen ver $ver timestamp
>> $timestamp" > $pidfile
>>
>> logger -t $prog "$$ host_id $host_id gen $owner_gen ver $ver
>> timestamp $timestamp"
>>
>> diff --git a/fence_sanlock/fence_sanlockd.c
>> b/fence_sanlock/fence_sanlockd.c
>> index be342c1..6ad7be1 100644
>> --- a/fence_sanlock/fence_sanlockd.c
>> +++ b/fence_sanlock/fence_sanlockd.c
>> @@ -35,12 +35,12 @@
>> #define MAX_HOSTS 128 /* keep in sync with fence_sanlock definition */
>>
>> #define LIVE_INTERVAL 5
>> #define EXPIRE_INTERVAL 20
>>
>> -#define DAEMON_RUN_DIR "/var/run/fence_sanlockd"
>> -#define AGENT_RUN_DIR "/var/run/fence_sanlock"
>> +#define DAEMON_RUN_DIR "/run/fence_sanlockd"
>> +#define AGENT_RUN_DIR "/run/fence_sanlock"
>>
>> static char *prog_name = (char *)"fence_sanlockd";
>>
>> static int we_are_victim;
>> static int we_are_fencing;
>> @@ -439,11 +439,11 @@ static int check_fence_agent(int *victim_host_id)
>> memset(name, 0, sizeof(name));
>>
>> log_debug("read %s", de->d_name);
>>
>> /*
>> - * read /var/run/fence_sanlock/fence_sanlock.pid.<pid>
>> + * read /run/fence_sanlock/fence_sanlock.pid.<pid>
>> * to get the pid of fence_sanlock and the victim's
>> host_id
>> *
>> * read /proc/pid/comm to check that the pid from that
>> file
>> * is still running and hasn't been killed
>> *
>> diff --git a/init.d/fence_sanlockd b/init.d/fence_sanlockd
>> index fb5fae8..99041b5 100755
>> --- a/init.d/fence_sanlockd
>> +++ b/init.d/fence_sanlockd
>> @@ -21,12 +21,12 @@
>>
>> . /etc/rc.d/init.d/functions
>>
>> prog="fence_sanlockd"
>> agent="fence_sanlock"
>> -runfile="/var/run/$prog/$prog.pid"
>> -fifofile="/var/run/$prog/$prog.fifo"
>> +runfile="/run/$prog/$prog.pid"
>> +fifofile="/run/$prog/$prog.fifo"
>> lockfile="/var/lock/subsys/$prog"
>> exec="/usr/sbin/$prog"
>>
>> FENCESANLOCKDOPTS="-w"
>>
>> @@ -39,21 +39,21 @@ start() {
>>
>> service wdmd status > /dev/null 2>&1 || service wdmd start
>>
>> service sanlock status > /dev/null 2>&1 || service sanlock start
>>
>> - [ ! -d /var/run/$prog ] && install -d -m 775 /var/run/$prog
>> + [ ! -d /run/$prog ] && install -d -m 775 /run/$prog
>>
>> - [ ! -d /var/run/$agent ] && install -d -m 775 /var/run/$agent
>> + [ ! -d /run/$agent ] && install -d -m 775 /run/$agent
>>
>> [ -n "$(which restorecon)" ] && \
>> [ -x "$(which restorecon)" ] && \
>> - restorecon /var/run/$prog
>> + restorecon /run/$prog
>>
>> [ -n "$(which restorecon)" ] && \
>> [ -x "$(which restorecon)" ] && \
>> - restorecon /var/run/$agent
>> + restorecon /run/$agent
>>
>> echo -n $"Starting $prog: "
>> daemon $prog $FENCESANLOCKDOPTS
>> retval=$?
>> echo
>> diff --git a/init.d/sanlock b/init.d/sanlock
>> index 83b35e8..bc1c330 100644
>> --- a/init.d/sanlock
>> +++ b/init.d/sanlock
>> @@ -20,11 +20,11 @@
>> ### END INIT INFO
>>
>> . /etc/rc.d/init.d/functions
>>
>> prog="sanlock"
>> -runfile="/var/run/$prog/$prog.pid"
>> +runfile="/run/$prog/$prog.pid"
>> lockfile="/var/lock/subsys/$prog"
>> exec="/usr/sbin/$prog"
>>
>> SANLOCKUSER="sanlock"
>> SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
>> @@ -32,13 +32,13 @@ SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
>> [ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
>>
>> start() {
>> [ -x $exec ] || exit 5
>>
>> - if [ ! -d /var/run/$prog ]; then
>> - install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775
>> /var/run/$prog
>> - [ -x /sbin/restorecon ] && restorecon /var/run/$prog
>> + if [ ! -d /run/$prog ]; then
>> + install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775
>> /run/$prog
>> + [ -x /sbin/restorecon ] && restorecon /run/$prog
>> fi
>>
>> echo -n $"Starting $prog: "
>> daemon $prog daemon $SANLOCKOPTS
>> retval=$?
>> diff --git a/init.d/wdmd b/init.d/wdmd
>> index 565342d..b6a2a79 100644
>> --- a/init.d/wdmd
>> +++ b/init.d/wdmd
>> @@ -20,11 +20,11 @@
>> ### END INIT INFO
>>
>> . /etc/rc.d/init.d/functions
>>
>> prog="wdmd"
>> -runfile="/var/run/$prog/$prog.pid"
>> +runfile="/run/$prog/$prog.pid"
>> lockfile="/var/lock/subsys/$prog"
>> exec="/usr/sbin/$prog"
>>
>> WDMDGROUP="sanlock"
>> WDMDOPTS="-G $WDMDGROUP"
>> @@ -58,13 +58,13 @@ watchdog_check() {
>> start() {
>> watchdog_check
>>
>> [ -x $exec ] || exit 5
>>
>> - if [ ! -d /var/run/$prog ]; then
>> - install -d -g $WDMDGROUP -m 775 /var/run/$prog
>> - [ -x /sbin/restorecon ] && restorecon /var/run/$prog
>> + if [ ! -d /run/$prog ]; then
>> + install -d -g $WDMDGROUP -m 775 /run/$prog
>> + [ -x /sbin/restorecon ] && restorecon /run/$prog
>> fi
>>
>> echo -n $"Starting $prog: "
>> daemon $prog $WDMDOPTS
>> retval=$?
>> diff --git a/reset/sanlk_reset.h b/reset/sanlk_reset.h
>> index 8c92c8e..377f511 100644
>> --- a/reset/sanlk_reset.h
>> +++ b/reset/sanlk_reset.h
>> @@ -12,11 +12,11 @@
>> #define EVENT_RESET 1
>> #define EVENT_RESETTING 2
>> #define EVENT_REBOOT 4
>> #define EVENT_REBOOTING 8
>>
>> -#define SANLK_RESETD_RUNDIR "/var/run/sanlk-resetd"
>> +#define SANLK_RESETD_RUNDIR "/run/sanlk-resetd"
>> #define SANLK_RESETD_SOCKET SANLK_RESETD_RUNDIR "/sanlk-resetd.sock"
>> #define SANLK_RESETD_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
>>
>> #define UPDATE_SIZE 256 /* sendmsg size on unix socket */
>>
>> diff --git a/sanlock.spec.in b/sanlock.spec.in
>> index 6485c61..cf72ad4 100644
>> --- a/sanlock.spec.in
>> +++ b/sanlock.spec.in
>> @@ -89,11 +89,11 @@ install -Dd -m 0775
>> $RPM_BUILD_ROOT/%{_localstatedir}/run/sanlk-resetd
>> %pre
>> getent group sanlock > /dev/null || /usr/sbin/groupadd \
>> -g 179 sanlock
>> getent passwd sanlock > /dev/null || /usr/sbin/useradd \
>> -u 179 -c "sanlock" -s /sbin/nologin -r \
>> - -g 179 -d /var/run/sanlock sanlock
>> + -g 179 -d /run/sanlock sanlock
>> /usr/sbin/usermod -a -G disk sanlock
>>
>> %post
>> %systemd_post wdmd.service sanlock.service
>>
>> diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
>> index 3a09b62..a78c81f 100644
>> --- a/src/sanlock_internal.h
>> +++ b/src/sanlock_internal.h
>> @@ -44,11 +44,11 @@
>> /* this is just the path to the executable, not full command line */
>>
>> #define COMMAND_MAX 4096
>>
>> #define SANLOCK_RUN_DIR "SANLOCK_RUN_DIR"
>> -#define DEFAULT_RUN_DIR "/var/run/sanlock"
>> +#define DEFAULT_RUN_DIR "/run/sanlock"
>> #define SANLOCK_PRIVILEGED "SANLOCK_PRIVILEGED"
>>
>> #define SANLK_LOG_DIR "/var/log"
>> #define SANLK_LOGFILE_NAME "sanlock.log"
>> #define SANLK_LOCKFILE_NAME "sanlock.pid"
>> diff --git a/tests/clientn b/tests/clientn
>> index 85b4181..bd6bf5a 100755
>> --- a/tests/clientn
>> +++ b/tests/clientn
>> @@ -31,11 +31,11 @@ elif [ "$cmd" == "start" ]; then
>>
>> elif [ "$cmd" == "delay" ]; then
>>
>> sec=$3
>>
>> - pid=`cat /var/run/sanlock/sanlock.pid`
>> + pid=`cat /run/sanlock/sanlock.pid`
>>
>> echo sync with daemon renewals
>> kill -s SIGSTOP $pid
>> sleep 20
>> kill -s SIGCONT $pid
>> @@ -52,11 +52,11 @@ elif [ "$cmd" == "delay" ]; then
>>
>> elif [ "$cmd" == "iodelay" ]; then
>>
>> sec=$4
>>
>> - pid=`cat /var/run/sanlock/sanlock.pid`
>> + pid=`cat /run/sanlock/sanlock.pid`
>>
>> echo sync with daemon renewals
>> kill -s SIGSTOP $pid
>> sleep 20
>> kill -s SIGCONT $pid
>> diff --git a/wdmd/main.c b/wdmd/main.c
>> index 911d833..edd15e8 100644
>> --- a/wdmd/main.c
>> +++ b/wdmd/main.c
>> @@ -567,11 +567,11 @@ static int active_clients(void)
>> return 0;
>> }
>>
>>
>> #ifdef TEST_FILES
>> -#define FILES_DIR "/var/run/wdmd/test_files"
>> +#define FILES_DIR "/run/wdmd/test_files"
>> const char *files_built = " files";
>> static DIR *files_dir;
>>
>> static void close_files(void)
>> {
>> @@ -1022,11 +1022,11 @@ static int _setup_watchdog(char *path)
>> return -1;
>> }
>> out:
>> log_error("%s armed with fire_timeout %d", watchdog_path,
>> fire_timeout);
>>
>> - /* TODO: save watchdog_path in /var/run/wdmd/saved_path,
>> + /* TODO: save watchdog_path in /run/wdmd/saved_path,
>> * and in startup read that file, copying it to saved_path */
>>
>> return 0;
>> }
>>
>> diff --git a/wdmd/wdmd_sock.h b/wdmd/wdmd_sock.h
>> index 6818683..f5ed27e 100644
>> --- a/wdmd/wdmd_sock.h
>> +++ b/wdmd/wdmd_sock.h
>> @@ -8,11 +8,11 @@
>> */
>>
>> #ifndef __WDMD_SOCK_H__
>> #define __WDMD_SOCK_H__
>>
>> -#define WDMD_RUN_DIR "/var/run/wdmd"
>> +#define WDMD_RUN_DIR "/run/wdmd"
>> #define WDMD_SOCKET_NAME "wdmd.sock"
>>
>> enum {
>> CMD_REGISTER = 1,
>> CMD_REFCOUNT_SET,
>> --
>> 2.17.2
>>
>>
4 years, 11 months
[PATCH 0/3] Spec cleanups
by Nir Soffer
Cleanup the development spec. We need to backport some of these changes
to Fedora and RHEL.
Nir Soffer (3):
build: Replace %{_localstatedir}/run with %{_rundir}
spec: Use one requirement per line
spec: Add missing build requirements
sanlock.spec.in | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--
2.17.2
4 years, 11 months
[PATCH] build: Replace /var/run with /run
by Nir Soffer
/var/run is a symlink to /run since RHEL 7, and few year before that on
Fedora. rpmlint is complaining in Fedora that we still use it:
sanlock.x86_64: E: dir-or-file-in-var-run /var/run/sanlock
Replace all instance of /var/run with /run.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
fence_sanlock/fence_sanlock.in | 2 +-
fence_sanlock/fence_sanlockd.c | 6 +++---
init.d/fence_sanlockd | 12 ++++++------
init.d/sanlock | 8 ++++----
init.d/wdmd | 8 ++++----
reset/sanlk_reset.h | 2 +-
sanlock.spec.in | 2 +-
src/sanlock_internal.h | 2 +-
tests/clientn | 4 ++--
wdmd/main.c | 4 ++--
wdmd/wdmd_sock.h | 2 +-
11 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/fence_sanlock/fence_sanlock.in b/fence_sanlock/fence_sanlock.in
index dbc0f24..a46773c 100755
--- a/fence_sanlock/fence_sanlock.in
+++ b/fence_sanlock/fence_sanlock.in
@@ -254,11 +254,11 @@ action_off() {
# pid file should be unique for each instance so multiple
# fence_sanlock's can run in parallel. fence_sanlockd may read
# this file to see which host_id we are fencing.
- pidfile=/var/run/$prog/$prog.pid.$$
+ pidfile=/run/$prog/$prog.pid.$$
echo "$$ host_id $host_id gen $owner_gen ver $ver timestamp $timestamp" > $pidfile
logger -t $prog "$$ host_id $host_id gen $owner_gen ver $ver timestamp $timestamp"
diff --git a/fence_sanlock/fence_sanlockd.c b/fence_sanlock/fence_sanlockd.c
index be342c1..6ad7be1 100644
--- a/fence_sanlock/fence_sanlockd.c
+++ b/fence_sanlock/fence_sanlockd.c
@@ -35,12 +35,12 @@
#define MAX_HOSTS 128 /* keep in sync with fence_sanlock definition */
#define LIVE_INTERVAL 5
#define EXPIRE_INTERVAL 20
-#define DAEMON_RUN_DIR "/var/run/fence_sanlockd"
-#define AGENT_RUN_DIR "/var/run/fence_sanlock"
+#define DAEMON_RUN_DIR "/run/fence_sanlockd"
+#define AGENT_RUN_DIR "/run/fence_sanlock"
static char *prog_name = (char *)"fence_sanlockd";
static int we_are_victim;
static int we_are_fencing;
@@ -439,11 +439,11 @@ static int check_fence_agent(int *victim_host_id)
memset(name, 0, sizeof(name));
log_debug("read %s", de->d_name);
/*
- * read /var/run/fence_sanlock/fence_sanlock.pid.<pid>
+ * read /run/fence_sanlock/fence_sanlock.pid.<pid>
* to get the pid of fence_sanlock and the victim's host_id
*
* read /proc/pid/comm to check that the pid from that file
* is still running and hasn't been killed
*
diff --git a/init.d/fence_sanlockd b/init.d/fence_sanlockd
index fb5fae8..99041b5 100755
--- a/init.d/fence_sanlockd
+++ b/init.d/fence_sanlockd
@@ -21,12 +21,12 @@
. /etc/rc.d/init.d/functions
prog="fence_sanlockd"
agent="fence_sanlock"
-runfile="/var/run/$prog/$prog.pid"
-fifofile="/var/run/$prog/$prog.fifo"
+runfile="/run/$prog/$prog.pid"
+fifofile="/run/$prog/$prog.fifo"
lockfile="/var/lock/subsys/$prog"
exec="/usr/sbin/$prog"
FENCESANLOCKDOPTS="-w"
@@ -39,21 +39,21 @@ start() {
service wdmd status > /dev/null 2>&1 || service wdmd start
service sanlock status > /dev/null 2>&1 || service sanlock start
- [ ! -d /var/run/$prog ] && install -d -m 775 /var/run/$prog
+ [ ! -d /run/$prog ] && install -d -m 775 /run/$prog
- [ ! -d /var/run/$agent ] && install -d -m 775 /var/run/$agent
+ [ ! -d /run/$agent ] && install -d -m 775 /run/$agent
[ -n "$(which restorecon)" ] && \
[ -x "$(which restorecon)" ] && \
- restorecon /var/run/$prog
+ restorecon /run/$prog
[ -n "$(which restorecon)" ] && \
[ -x "$(which restorecon)" ] && \
- restorecon /var/run/$agent
+ restorecon /run/$agent
echo -n $"Starting $prog: "
daemon $prog $FENCESANLOCKDOPTS
retval=$?
echo
diff --git a/init.d/sanlock b/init.d/sanlock
index 83b35e8..bc1c330 100644
--- a/init.d/sanlock
+++ b/init.d/sanlock
@@ -20,11 +20,11 @@
### END INIT INFO
. /etc/rc.d/init.d/functions
prog="sanlock"
-runfile="/var/run/$prog/$prog.pid"
+runfile="/run/$prog/$prog.pid"
lockfile="/var/lock/subsys/$prog"
exec="/usr/sbin/$prog"
SANLOCKUSER="sanlock"
SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
@@ -32,13 +32,13 @@ SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
start() {
[ -x $exec ] || exit 5
- if [ ! -d /var/run/$prog ]; then
- install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /var/run/$prog
- [ -x /sbin/restorecon ] && restorecon /var/run/$prog
+ if [ ! -d /run/$prog ]; then
+ install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /run/$prog
+ [ -x /sbin/restorecon ] && restorecon /run/$prog
fi
echo -n $"Starting $prog: "
daemon $prog daemon $SANLOCKOPTS
retval=$?
diff --git a/init.d/wdmd b/init.d/wdmd
index 565342d..b6a2a79 100644
--- a/init.d/wdmd
+++ b/init.d/wdmd
@@ -20,11 +20,11 @@
### END INIT INFO
. /etc/rc.d/init.d/functions
prog="wdmd"
-runfile="/var/run/$prog/$prog.pid"
+runfile="/run/$prog/$prog.pid"
lockfile="/var/lock/subsys/$prog"
exec="/usr/sbin/$prog"
WDMDGROUP="sanlock"
WDMDOPTS="-G $WDMDGROUP"
@@ -58,13 +58,13 @@ watchdog_check() {
start() {
watchdog_check
[ -x $exec ] || exit 5
- if [ ! -d /var/run/$prog ]; then
- install -d -g $WDMDGROUP -m 775 /var/run/$prog
- [ -x /sbin/restorecon ] && restorecon /var/run/$prog
+ if [ ! -d /run/$prog ]; then
+ install -d -g $WDMDGROUP -m 775 /run/$prog
+ [ -x /sbin/restorecon ] && restorecon /run/$prog
fi
echo -n $"Starting $prog: "
daemon $prog $WDMDOPTS
retval=$?
diff --git a/reset/sanlk_reset.h b/reset/sanlk_reset.h
index 8c92c8e..377f511 100644
--- a/reset/sanlk_reset.h
+++ b/reset/sanlk_reset.h
@@ -12,11 +12,11 @@
#define EVENT_RESET 1
#define EVENT_RESETTING 2
#define EVENT_REBOOT 4
#define EVENT_REBOOTING 8
-#define SANLK_RESETD_RUNDIR "/var/run/sanlk-resetd"
+#define SANLK_RESETD_RUNDIR "/run/sanlk-resetd"
#define SANLK_RESETD_SOCKET SANLK_RESETD_RUNDIR "/sanlk-resetd.sock"
#define SANLK_RESETD_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define UPDATE_SIZE 256 /* sendmsg size on unix socket */
diff --git a/sanlock.spec.in b/sanlock.spec.in
index 6485c61..cf72ad4 100644
--- a/sanlock.spec.in
+++ b/sanlock.spec.in
@@ -89,11 +89,11 @@ install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/sanlk-resetd
%pre
getent group sanlock > /dev/null || /usr/sbin/groupadd \
-g 179 sanlock
getent passwd sanlock > /dev/null || /usr/sbin/useradd \
-u 179 -c "sanlock" -s /sbin/nologin -r \
- -g 179 -d /var/run/sanlock sanlock
+ -g 179 -d /run/sanlock sanlock
/usr/sbin/usermod -a -G disk sanlock
%post
%systemd_post wdmd.service sanlock.service
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 3a09b62..a78c81f 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -44,11 +44,11 @@
/* this is just the path to the executable, not full command line */
#define COMMAND_MAX 4096
#define SANLOCK_RUN_DIR "SANLOCK_RUN_DIR"
-#define DEFAULT_RUN_DIR "/var/run/sanlock"
+#define DEFAULT_RUN_DIR "/run/sanlock"
#define SANLOCK_PRIVILEGED "SANLOCK_PRIVILEGED"
#define SANLK_LOG_DIR "/var/log"
#define SANLK_LOGFILE_NAME "sanlock.log"
#define SANLK_LOCKFILE_NAME "sanlock.pid"
diff --git a/tests/clientn b/tests/clientn
index 85b4181..bd6bf5a 100755
--- a/tests/clientn
+++ b/tests/clientn
@@ -31,11 +31,11 @@ elif [ "$cmd" == "start" ]; then
elif [ "$cmd" == "delay" ]; then
sec=$3
- pid=`cat /var/run/sanlock/sanlock.pid`
+ pid=`cat /run/sanlock/sanlock.pid`
echo sync with daemon renewals
kill -s SIGSTOP $pid
sleep 20
kill -s SIGCONT $pid
@@ -52,11 +52,11 @@ elif [ "$cmd" == "delay" ]; then
elif [ "$cmd" == "iodelay" ]; then
sec=$4
- pid=`cat /var/run/sanlock/sanlock.pid`
+ pid=`cat /run/sanlock/sanlock.pid`
echo sync with daemon renewals
kill -s SIGSTOP $pid
sleep 20
kill -s SIGCONT $pid
diff --git a/wdmd/main.c b/wdmd/main.c
index 911d833..edd15e8 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -567,11 +567,11 @@ static int active_clients(void)
return 0;
}
#ifdef TEST_FILES
-#define FILES_DIR "/var/run/wdmd/test_files"
+#define FILES_DIR "/run/wdmd/test_files"
const char *files_built = " files";
static DIR *files_dir;
static void close_files(void)
{
@@ -1022,11 +1022,11 @@ static int _setup_watchdog(char *path)
return -1;
}
out:
log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
- /* TODO: save watchdog_path in /var/run/wdmd/saved_path,
+ /* TODO: save watchdog_path in /run/wdmd/saved_path,
* and in startup read that file, copying it to saved_path */
return 0;
}
diff --git a/wdmd/wdmd_sock.h b/wdmd/wdmd_sock.h
index 6818683..f5ed27e 100644
--- a/wdmd/wdmd_sock.h
+++ b/wdmd/wdmd_sock.h
@@ -8,11 +8,11 @@
*/
#ifndef __WDMD_SOCK_H__
#define __WDMD_SOCK_H__
-#define WDMD_RUN_DIR "/var/run/wdmd"
+#define WDMD_RUN_DIR "/run/wdmd"
#define WDMD_SOCKET_NAME "wdmd.sock"
enum {
CMD_REGISTER = 1,
CMD_REFCOUNT_SET,
--
2.17.2
4 years, 11 months
Re: [PATCH] python: Fix comparison between signed and unsigned integer
by Nir Soffer
On Wed, May 22, 2019 at 11:33 AM Pavel Bar <pbar(a)redhat.com> wrote:
> Looks ok
>
Thanks, pushed.
>
> On Tue, May 21, 2019 at 7:18 PM Nir Soffer <nirsof(a)gmail.com> wrote:
>
>> Fix these warnings, seen in python 3 builds on Travis:
>>
>> sanlock.c:1002:23: warning: comparison between signed and unsigned
>> integer expressions [-Wsign-compare]
>> if (res->lver == -1) {
>> ^
>> sanlock.c:1118:23: warning: comparison between signed and unsigned
>> integer expressions [-Wsign-compare]
>> if (res->lver == -1) {
>>
>> Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
>> ---
>> python/sanlock.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/python/sanlock.c b/python/sanlock.c
>> index b412b6a..5d228e8 100644
>> --- a/python/sanlock.c
>> +++ b/python/sanlock.c
>> @@ -997,11 +997,11 @@ py_acquire(PyObject *self __unused, PyObject *args,
>> PyObject *keywds)
>>
>> /* prepare the resource version */
>> if (version != Py_None) {
>> res->flags |= SANLK_RES_LVER;
>> res->lver = pyinteger_as_unsigned_long_long_mask(version);
>> - if (res->lver == -1) {
>> + if (res->lver == (uint64_t)-1) {
>> __set_exception(EINVAL, "Unable to convert the version
>> value");
>> goto exit_fail;
>> }
>> }
>>
>> @@ -1113,11 +1113,11 @@ py_request(PyObject *self __unused, PyObject
>> *args, PyObject *keywds)
>> if (version == Py_None) {
>> flags = SANLK_REQUEST_NEXT_LVER;
>> } else {
>> res->flags |= SANLK_RES_LVER;
>> res->lver = pyinteger_as_unsigned_long_long_mask(version);
>> - if (res->lver == -1) {
>> + if (res->lver == (uint64_t)-1) {
>> __set_exception(EINVAL, "Unable to convert the version
>> value");
>> goto exit_fail;
>> }
>> }
>>
>> --
>> 2.17.2
>>
>>
4 years, 11 months
[sanlock] branch master updated: python: Fix comparison between
signed and unsigned integer
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 9b2e7cf python: Fix comparison between signed and unsigned integer
9b2e7cf is described below
commit 9b2e7cfc420b19cff0000538806de85d8f771f79
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Tue May 21 04:26:20 2019 +0300
python: Fix comparison between signed and unsigned integer
Fix these warnings, seen in python 3 builds on Travis:
sanlock.c:1002:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res->lver == -1) {
^
sanlock.c:1118:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res->lver == -1) {
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index b412b6a..5d228e8 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -999,7 +999,7 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
if (version != Py_None) {
res->flags |= SANLK_RES_LVER;
res->lver = pyinteger_as_unsigned_long_long_mask(version);
- if (res->lver == -1) {
+ if (res->lver == (uint64_t)-1) {
__set_exception(EINVAL, "Unable to convert the version value");
goto exit_fail;
}
@@ -1115,7 +1115,7 @@ py_request(PyObject *self __unused, PyObject *args, PyObject *keywds)
} else {
res->flags |= SANLK_RES_LVER;
res->lver = pyinteger_as_unsigned_long_long_mask(version);
- if (res->lver == -1) {
+ if (res->lver == (uint64_t)-1) {
__set_exception(EINVAL, "Unable to convert the version value");
goto exit_fail;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
4 years, 11 months
[PATCH v2] tests: Simplify 4k tests setup and teardown
by Nir Soffer
Previously you had to setup the environment manually to enable the 4k
tests, and pass environment variable to tests. The tests used single
path, so you had to run the tests twice to test both 4k block device and
filesystem backed by a 4k block device.
Add storage helper script to make it easier to setup storage for the
tests.
To setup 4k storage for the tests, run:
$ python tests/storage.py setup
This script creates both a 4k block device and filesystem backed by a 4k
device. The user_4k_path() fixture enables the tests if the device and
mount exist, and runs the test twice, once with the loop device, and
once with the filesystem.
To clean up the environment, run:
$ python tests/storage.py teardown
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
Changes since v1:
- Fix device checks in teardown (Amit)
- Fix typos (Pavel)
- Merge setup and teardown to single script (Pavel)
- Rewrite helper script in python
v1 was here:
https://lists.fedorahosted.org/archives/list/sanlock-devel@lists.fedoraho...
README.dev | 44 ++++----------
tests/conftest.py | 38 ++++---------
tests/storage.py | 142 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 165 insertions(+), 59 deletions(-)
create mode 100644 tests/storage.py
diff --git a/README.dev b/README.dev
index bfb170c..439b7b4 100644
--- a/README.dev
+++ b/README.dev
@@ -27,44 +27,22 @@ To run only tests matching the substring "foo":
Testing 4K support
==================
-This requires manual setup for creating a block device using 4k sector size,
-optionally creating and mounting a file system, and passing the test path to
-tests. The setup must be done as root, but the tests can run later as the
-current user.
+To enable the 4k tests, you need to setup 4k stroage for the tests:
-Common setup
-------------
+ $ python tests/storage.py setup
-1. Create a backing file:
+This creates two loop devices with 4k sector size; one for testing sanlock with
+4k block device, and the other for testing with a filesystem backed by a 4k
+block device.
- $ truncate -s 1G /var/tmp/backing
+To teardown the storage:
-2. Create a loop device with 4k sector size:
+ $ python tests/storage.py teardown
- $ sudo losetup -f /var/tmp/backing --show --sector-size=4096
- /dev/loop2
+The script unmounts the filesystem and detaches the loop devices.
-3. Change the device (or mountpoint) owner to current user
-
- $ sudo chown $USER:$USER /dev/loop2
-
-Testing 4k block device
------------------------
-
-Run the tests with USER_4K_PATH environment variable:
-
- $ USER_4K_PATH=/dev/loop2 tox -e py27
-
-Testing 4k file system
-----------------------
-
-To test file system on top of 4k block device, create a file system on the
-device, mount it, and create a file for testing lockspace or resources:
-
- $ sudo mkfs.xfs /dev/loop2
- $ sudo mount /dev/loop2 /tmp/sanlock-4k
- $ sudo chown $USER:$USER /tmp/sanlock-4k
- $ truncate -s 128m /tmp/sanlock-4k/disk
- $ USER_4K_PATH=/tmp/sanlock-4k/disk tox -e py27
+The storage helper script uses sudo to perform privileged operations. The best
+way to use it is to setup the environment once at the start of the session, and
+teardown when you finish.
diff --git a/tests/conftest.py b/tests/conftest.py
index bb95d45..5212679 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -5,10 +5,11 @@ Fixtures for sanlock testing.
import os
import stat
import pytest
+from . import storage
from . import util
@pytest.fixture
def sanlock_daemon():
@@ -24,36 +25,21 @@ def sanlock_daemon():
# which takes about 3 seconds, slowing down the tests.
p.kill()
p.wait()
-(a)pytest.fixture
-def user_4k_path():
+(a)pytest.fixture(params=[
+ pytest.param(storage.BLOCK, id="block"),
+ pytest.param(storage.FILE, id="file"),
+])
+def user_4k_path(request):
"""
A path to block device or file on file system on top of 4k block device,
provided by the user.
- The user must create the block device or the file system before running the
- tests, and specify the path to the file in the USER_4K_PATH environment
- variable.
-
- If USER_4K_PATH was not specified, tests using this fixture will be skipped.
- If USER_4K_PATH was specified but does not exist, or is not a file or block
- device, RuntimeError is raised.
-
- Return path to the user specified file.
+ If storage is not available, skip the tests.
"""
- path = os.environ.get("USER_4K_PATH")
- if path is None:
- pytest.skip("USER_4K_PATH pointing to a 4k block device or file was "
- "not specified")
-
- if not os.path.exists(path):
- raise RuntimeError("USER_4K_PATH {!r} does not exist".format(path))
-
- mode = os.stat(path).st_mode
- if not (stat.S_ISBLK(mode) or stat.S_ISREG(mode)):
- raise RuntimeError(
- "USER_4K_PATH {!r} is not a block device or regular file"
- .format(path))
-
- return path
+ if not os.path.exists(request.param):
+ pytest.skip(
+ "user storage available - run 'python tests/strorage.py setup' "
+ "to enable 4k storage tests")
+ return request.param
diff --git a/tests/storage.py b/tests/storage.py
new file mode 100644
index 0000000..3258ed4
--- /dev/null
+++ b/tests/storage.py
@@ -0,0 +1,142 @@
+"""
+storage - provide storage for sanlock tests.
+"""
+
+import argparse
+import errno
+import logging
+import os
+import subprocess
+
+BASE_DIR = "/var/tmp/sanlock-storage"
+MOUNTPOINT = os.path.join(BASE_DIR, "mnt")
+
+# For testing sanlock with 4k block device.
+LOOP1 = os.path.join(BASE_DIR, "loop1")
+BACKING1 = os.path.join(BASE_DIR, "backing1")
+
+# For testing sanlock with a filesystem backed by 4k block device.
+LOOP2 = os.path.join(BASE_DIR, "loop2")
+BACKING2 = os.path.join(BASE_DIR, "backing2")
+
+# Test paths.
+BLOCK = LOOP1
+FILE = os.path.join(MOUNTPOINT, "file")
+
+log = logging.getLogger("storage")
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Storage helper for sanlock tests')
+ parser.add_argument("command", choices=["setup", "teardown"])
+ args = parser.parse_args()
+
+ logging.basicConfig(level=logging.INFO, format="storage: %(message)s")
+
+ if args.command == "setup":
+ setup()
+ elif args.command == "teardown":
+ teardown()
+
+
+def setup():
+ create_dir(BASE_DIR)
+
+ if not os.path.exists(LOOP1):
+ create_loop_device(LOOP1, BACKING1)
+
+ if not os.path.exists(LOOP2):
+ create_loop_device(LOOP2, BACKING2)
+ create_dir(MOUNTPOINT)
+ create_filesystem(LOOP2, MOUNTPOINT)
+
+ # Sanlock allocates spaces as needed.
+ with open(FILE, "wb") as f:
+ f.truncate(0)
+
+
+def teardown():
+ if is_mounted(MOUNTPOINT):
+ remove_filesystem(MOUNTPOINT)
+
+ if os.path.exists(LOOP2):
+ remove_loop_device(LOOP2, BACKING2)
+
+ if os.path.exists(LOOP1):
+ remove_loop_device(LOOP1, BACKING1)
+
+
+def create_loop_device(link_path, backing_file, size=1024**3,
+ sector_size=4096):
+ log.info("Creating loop device %s", link_path)
+
+ with open(backing_file, "wb") as f:
+ f.truncate(size)
+
+ out = subprocess.check_output([
+ "sudo",
+ "losetup",
+ "-f", backing_file,
+ "--sector-size", str(sector_size),
+ "--show",
+ ])
+
+ device = out.decode("utf-8").strip()
+
+ os.symlink(device, link_path)
+ chown(link_path)
+
+
+def remove_loop_device(link_path, backing_file):
+ log.info("Removing loop device %s", link_path)
+
+ subprocess.check_call(["sudo", "losetup", "-d", link_path])
+ remove_file(link_path)
+ remove_file(backing_file)
+
+
+def create_filesystem(device, mountpoint):
+ log.info("Creating filesystem %s", mountpoint)
+
+ subprocess.check_call(["sudo", "mkfs.xfs", "-q", device])
+ subprocess.check_call(["sudo", "mount", device, mountpoint])
+ chown(mountpoint)
+
+
+def remove_filesystem(mountpoint):
+ log.info("Removing filesystem %s", mountpoint)
+ subprocess.check_call(["sudo", "umount", mountpoint])
+
+
+def is_mounted(mountpoint):
+ with open("/proc/self/mounts") as f:
+ for line in f:
+ if mountpoint in line:
+ return True
+ return False
+
+
+def chown(path):
+ user_group = "%(USER)s:%(USER)s" % os.environ
+ subprocess.check_call(["sudo", "chown", user_group, path])
+
+
+def create_dir(path):
+ try:
+ os.makedirs(path)
+ except EnvironmentError as e:
+ if e.errno != errno.EEXIST:
+ raise
+
+
+def remove_file(path):
+ try:
+ os.remove(path)
+ except EnvironmentError as e:
+ if e.errno != errno.ENOENT:
+ raise
+
+
+if __name__ == "__main__":
+ main()
--
2.17.2
4 years, 11 months
[PATCH] python: Fix comparison between signed and unsigned integer
by Nir Soffer
Fix these warnings, seen in python 3 builds on Travis:
sanlock.c:1002:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res->lver == -1) {
^
sanlock.c:1118:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (res->lver == -1) {
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index b412b6a..5d228e8 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -997,11 +997,11 @@ py_acquire(PyObject *self __unused, PyObject *args, PyObject *keywds)
/* prepare the resource version */
if (version != Py_None) {
res->flags |= SANLK_RES_LVER;
res->lver = pyinteger_as_unsigned_long_long_mask(version);
- if (res->lver == -1) {
+ if (res->lver == (uint64_t)-1) {
__set_exception(EINVAL, "Unable to convert the version value");
goto exit_fail;
}
}
@@ -1113,11 +1113,11 @@ py_request(PyObject *self __unused, PyObject *args, PyObject *keywds)
if (version == Py_None) {
flags = SANLK_REQUEST_NEXT_LVER;
} else {
res->flags |= SANLK_RES_LVER;
res->lver = pyinteger_as_unsigned_long_long_mask(version);
- if (res->lver == -1) {
+ if (res->lver == (uint64_t)-1) {
__set_exception(EINVAL, "Unable to convert the version value");
goto exit_fail;
}
}
--
2.17.2
4 years, 11 months