xen: add systemd support
v6 cover xen: add systemd support
From: "Luis R. Rodriguez" <[email protected]>
Here's my v6 series. It should address all the feedback I've gotten fron the v5 series. I've compile tested and run time tested this on both systemd (OpenSUSE 13.1) and non-systemd systems (Debian testing) with cxenstored and oxenstored preferences.
The launcher thing is resolved now by using shell to do the explicit launching for us. This all also goes rebased an testd against today's git tree master branch.
Luis R. Rodriguez (13):
xenstored: enable usage of config.h on both xenstored and oxenstored
cxenstored: add support for systemd active sockets
oxenstored: add support for systemd active sockets
oxenstored: force FD_CLOEXEC with Unix.set_close_on_exec on LSB init tools/xendomains: make xl the default and remove xm usage tools/xendomains: do space cleanups
tools/xendomains: move to libexec and use a smaller init helper
autoconf: xen: force a refresh with autoconf
autoconf: update m4/pkg.m4
autoconf: xen: move standard path variables to config/Paths.mk.in
xencommons: move module list into a generic place
autoconf: xen: enable explicit preference option for xenstored
preference
systemd: add xen systemd service and module files
.gitignore | 6 +
Makefile | 6 +-
README | 77 +++
autogen.sh | 8 +-
config/Paths.mk.in | 37 ++
config/Stubdom.mk.in | 1 +
config/Tools.mk.in | 6 +
config/modules | 16 +
configure.ac | 8 +-
m4/README.source | 38 ++
m4/paths.m4 | 61 +++
m4/pkg.m4 | 88 +++-
m4/systemd.m4 | 123 +++++
m4/xenstored.m4 | 60 +++
stubdom/Makefile | 1 +
tools/Rules.mk | 1 +
tools/configure.ac | 30 +-
tools/hotplug/Linux/Makefile | 45 +-
...ysconfig.xencommons => sysconfig.xencommons.in} | 13 +-
.../Linux/init.d/{xencommons => xencommons.in.in} | 24 +-
tools/hotplug/Linux/init.d/xendomains | 567 +-------------------
tools/hotplug/Linux/systemd/Makefile | 67 +++
tools/hotplug/Linux/systemd/proc-xen.mount.in | 9 +
.../Linux/systemd/var-lib-xenstored.mount.in | 13 +
.../systemd/xen-qemu-dom0-disk-backend.service.in | 22 +
.../hotplug/Linux/systemd/xen-watchdog.service.in | 13 +
tools/hotplug/Linux/systemd/xenconsoled.service.in | 20 +
tools/hotplug/Linux/systemd/xendomains.service.in | 16 +
tools/hotplug/Linux/systemd/xenstored.service.in | 27 +
tools/hotplug/Linux/systemd/xenstored.socket.in | 11 +
tools/hotplug/Linux/systemd/xenstored_ro.socket.in | 11 +
tools/hotplug/Linux/xendomains | 584 +++++++++++++++++++++
tools/ocaml/xenstored/Makefile | 15 +-
tools/ocaml/xenstored/systemd.ml | 17 +
tools/ocaml/xenstored/systemd.mli | 24 +
tools/ocaml/xenstored/systemd_stubs.c | 158 ++++++
tools/ocaml/xenstored/utils.ml | 21 +-
tools/ocaml/xenstored/xenstored.ml | 2 +
tools/xenstore/Makefile | 7 +
tools/xenstore/xenstored_core.c | 110 +++-
40 files changed, 1759 insertions(+), 604 deletions(-)
create mode 100644 config/Paths.mk.in
create mode 100644 config/modules
create mode 100644 m4/README.source
create mode 100644 m4/paths.m4
create mode 100644 m4/systemd.m4
create mode 100644 m4/xenstored.m4
rename tools/hotplug/Linux/init.d/{sysconfig.xencommons => sysconfig.xencommons.in} (64%)
rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in.in} (82%)
create mode 100644 tools/hotplug/Linux/systemd/Makefile
create mode 100644 tools/hotplug/Linux/systemd/proc-xen.mount.in
create mode 100644 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in
create mode 100644 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in
create mode 100644 tools/hotplug/Linux/systemd/xen-watchdog.service.in
create mode 100644 tools/hotplug/Linux/systemd/xenconsoled.service.in
create mode 100644 tools/hotplug/Linux/systemd/xendomains.service.in
create mode 100644 tools/hotplug/Linux/systemd/xenstored.service.in
create mode 100644 tools/hotplug/Linux/systemd/xenstored.socket.in
create mode 100644 tools/hotplug/Linux/systemd/xenstored_ro.socket.in
create mode 100644 tools/hotplug/Linux/xendomains
create mode 100644 tools/ocaml/xenstored/systemd.ml
create mode 100644 tools/ocaml/xenstored/systemd.mli
create mode 100644 tools/ocaml/xenstored/systemd_stubs.cSignature · 1 line
2.0.0.rc3.18.g00a5b79
PATCH v6 1/13 xenstored: enable usage of config.h on both xenstored and oxenstored
From: "Luis R. Rodriguez" <[email protected]>
This will be used later for dynamic configuration paths on C code.
--- tools/ocaml/xenstored/Makefile | 2 ++ tools/xenstore/Makefile | 1 + 2 files changed, 3 insertions(+)
tools/ocaml/xenstored/Makefile +2 -0
@@ -2,6 +2,8 @@ XEN_ROOT = $(CURDIR)/../../.. OCAML_TOPLEVEL = $(CURDIR)/.. include $(OCAML_TOPLEVEL)/common.make +CFLAGS += -I$(XEN_ROOT)/tools/ + OCAMLINCLUDE += \ -I $(OCAML_TOPLEVEL)/libs/xb \ -I $(OCAML_TOPLEVEL)/libs/mmap \
tools/xenstore/Makefile +1 -0
@@ -6,6 +6,7 @@ MINOR = 3 CFLAGS += -Werror CFLAGS += -I. +CFLAGS += -I$(XEN_ROOT)/tools/ CFLAGS += $(CFLAGS_libxenctrl) CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod
Signature · 1 line
2.0.0.rc3.18.g00a5b79
PATCH v6 2/13 cxenstored: add support for systemd active sockets
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This adds systemd socket activation support for the C xenstored. Active sockets enable xenstored to be loaded only if required by a system onto which Xen is installed on. Socket activation is handled by systemd, once a port for a service which claims a socket is used systemd will start the required services for it, on demand. For more details on socket activation refer to Lennart's socket-activation post regarding this [0].
Right now this code adds a no-op for this functionality, leaving the enablement to be done later once systemd is properly hooked into the build system. The socket activation is ordered in aligment with the socket activation order passed on to systemd.
[0] http://0pointer.de/blog/projects/socket-activation2.html
--- tools/xenstore/xenstored_core.c | 110 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-)
tools/xenstore/xenstored_core.c +109 -1
@@ -40,6 +40,7 @@#include <signal.h> #include <assert.h> #include <setjmp.h> +#include <config.h> #include "utils.h" #include "list.h"
@@ -54,6 +55,16 @@#include "hashtable.h" +#ifndef NO_SOCKETS +#if defined(HAVE_SYSTEMD ) +#define XEN_SYSTEMD_ENABLED 1 +#endif +#endif + +#if defined(XEN_SYSTEMD_ENABLED ) +#include <systemd/sd-daemon.h> +#endif +extern xc_evtchn *xce_handle;/* in xenstored_domain.c */ static int xce_pollfd_idx =-1 ;static struct pollfd *fds;
@@ -1714,6 +1725,81 @@ static int destroy_fd(void *_fd)return 0 ; } +#if defined(XEN_SYSTEMD_ENABLED ) +/* Will work regardless of the order systemd gives them to us */ +int xs_get_sd_fd (const char *connect_to) +{ +int fd =SD_LISTEN_FDS_START ; +int r; + +while (fd <=SD_LISTEN_FDS_START +1 ) { + r =sd_is_socket_unix (fd,SOCK_STREAM ,1 , connect_to,0 ); +if (r >0 ) +return fd; + fd++; + } + +return -EBADR ; +} + +int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to)); + +if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) { +sd_notifyf (0 ,"STATUS=unexpected socket: %s\n" +"ERRNO=%i" , + connect_to, +EBADR ); +return -EBADR ; + } + +return xs_get_sd_fd (sock); +} + +static void xen_claim_active_sockets (int **psock,int **pro_sock) +{ +int *sock, *ro_sock; +const char *soc_str =xs_daemon_socket (); +const char *soc_str_ro =xs_daemon_socket_ro (); +int n; + + n =sd_listen_fds (0 ); +if (n <=0 ) { +sd_notifyf (0 ,"STATUS=Failed to get any active sockets: %s\n" +"ERRNO=%i" , +strerror (errno), + errno); +barf_perror ("sd_listen_fds() failed\n" ); + }else if (n >2 ) { +fprintf (stderr,SD_ERR "Expected 2 fds but given %d\n" , n); +sd_notifyf (0 ,"STATUS=Mismatch on number (2): %s\n" +"ERRNO=%d" , +strerror (EBADR ), +EBADR ); +barf_perror ("sd_listen_fds() gave too many fds\n" ); + } + + *psock = sock =talloc (talloc_autofree_context (), int); + *sock =xs_validate_active_socket (soc_str); +if (*sock <=0 ) +barf_perror ("%s" , soc_str); + + *pro_sock = ro_sock =talloc (talloc_autofree_context (), int); + *ro_sock =xs_validate_active_socket (soc_str_ro); +if (*ro_sock <=0 ) +barf_perror ("%s" , soc_str_ro); + +talloc_set_destructor (sock, destroy_fd); +talloc_set_destructor (ro_sock, destroy_fd); +} +#endif +static void init_sockets (int **psock,int **pro_sock) {struct sockaddr_un addr;
@@ -1884,6 +1970,15 @@ int main(int argc, char *argv[])if (optind != argc)barf ("%s: No arguments desired" , argv[0 ]); +#if defined(XEN_SYSTEMD_ENABLED ) +if (sd_booted ()) { + dofork = false; +if (pidfile) +barf ("%s: PID file not needed on systemd" , argv[0 ]); + pidfile =NULL ; + } +#endif +reopen_log ();/* make sure xenstored directories exist */
@@ -1905,7 +2000,13 @@ int main(int argc, char *argv[])/* Don't kill us with SIGPIPE. */ signal (SIGPIPE ,SIG_IGN ); -init_sockets (&sock, &ro_sock); +#if defined(XEN_SYSTEMD_ENABLED ) +if (sd_booted ()) +xen_claim_active_sockets (&sock, &ro_sock); + else +#endif +init_sockets (&sock, &ro_sock); +init_pipe (reopen_log_pipe);/* Setup the database */
@@ -1936,6 +2037,13 @@ int main(int argc, char *argv[])/* Tell the kernel we're up and running. */ xenbus_notify_running (); +#if defined(XEN_SYSTEMD_ENABLED ) +if (sd_booted ()) { +sd_notify (1 ,"READY=1" ); +fprintf (stderr,SD_NOTICE "xenstored is ready\n" ); + } +#endif +/* Main loop. */ for (;;) {struct connection *conn, *next;
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1751
Quoted 7 lines · Luis R. Rodriguez
tools/xenstore/xenstored_core.c +7
-0+int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to));
This risks overrunning sock if connect_to is longer than 30 characters.
But your use of strlen suggests that connect_to is already NULL terminated, so what is this for?
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1754
Quoted 2 lines
tools/xenstore/xenstored_core.c +2
-0+if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) {
Given that sock (or connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?
As it is I think your code would accept
e.g. /var/run/xenstored/socketwibble, no?
Is it common in systemd support to validate the input socket's path in this way? As opposed to trusting that the systemd unit file is correct.
Quoted 11 lines
tools/xenstore/xenstored_core.c +11
-0+static void xen_claim_active_sockets (int **psock,int **pro_sock) +{ +int *sock, *ro_sock; +const char *soc_str =xs_daemon_socket (); +const char *soc_str_ro =xs_daemon_socket_ro (); +int n; + + n =sd_listen_fds (0 ); +if (n <=0 ) { + sd_notifyf(0, "STATUS=Failed to get any active sockets: %s\n" + "ERRNO=%i",
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1785
Quoted 10 lines
tools/xenstore/xenstored_core.c +10
-0+strerror (errno), + errno); +barf_perror ("sd_listen_fds() failed\n" ); + }else if (n >2 ) { +fprintf (stderr,SD_ERR "Expected 2 fds but given %d\n" , n); +sd_notifyf (0 ,"STATUS=Mismatch on number (2): %s\n" +"ERRNO=%d" , +strerror (EBADR ), +EBADR ); +barf_perror ("sd_listen_fds() gave too many fds\n" );
Need this be fatal?
Ian.
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 10 lines · Ian Campbell
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1751
Quoted 7 lines · Luis R. Rodriguez
tools/xenstore/xenstored_core.c +7
-0+int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to));This risks overrunning sock if
connect_tois longer than 30 characters.
Yuk, yes. A size check is required.
Quoted 2 lines
But your use of strlen suggests that
connect_tois already NULL terminated, so what is this for?
strlen() seems to want the string to also be null terminated in order to work, and I also see that snprintf() is ultimately used on the C version of the library, that should ensure its null terminated. This however is not true for the ocaml version and I suppose that is the root of the issue I saw that got me to force null terimination as I did run into issues with this path IIRC when not null terminated.
Quoted 5 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1754
Quoted 2 lines
tools/xenstore/xenstored_core.c +2
-0+if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) {Given that sock (or
connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?
See above.
Quoted 2 lines
As it is I think your code would accept
e.g./var/run/xenstored/socketwibble, no?
It indeed would, its best if we resolve the null termination issue internally then.
Quoted 2 lines
Is it common in systemd support to validate the input socket's path in this way? As opposed to trusting that the systemd unit file is correct.
sd_is_socket_unix() is certainly advised and highly encourged. As for the other check -- yes we want that given that we are using two socket files specifically in order to avoid having to chmod() the socket ourelves. Systemd currently doesn't support having two separate sockets in one file with different permissions. From what I have seen the order in which systemd sets the sockets and maps them to fds will very on the unit socket files you use, this approach lets us allow systemd to give them to us in any order while my hope is that systemd upstream gets support for just one stocket file with multiple permissions.
Quoted 15 lines
Quoted 15 lines
tools/xenstore/xenstored_core.c +15
-0+static void xen_claim_active_sockets (int **psock,int **pro_sock) +{ +int *sock, *ro_sock; +const char *soc_str =xs_daemon_socket (); +const char *soc_str_ro =xs_daemon_socket_ro (); +int n; + + n =sd_listen_fds (0 ); +if (n <=0 ) { +sd_notifyf (0 ,"STATUS=Failed to get any active sockets: %s\n" +"ERRNO=%i" , +strerror (errno), + errno); +barf_perror ("sd_listen_fds() failed\n" ); + }else if (n >2 ) {
Quoted 8 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1785
Quoted 6 lines
tools/xenstore/xenstored_core.c +6
-0+fprintf (stderr,SD_ERR "Expected 2 fds but given %d\n" , n); +sd_notifyf (0 ,"STATUS=Mismatch on number (2): %s\n" +"ERRNO=%d" , +strerror (EBADR ), +EBADR ); +barf_perror ("sd_listen_fds() gave too many fds\n" );Need this be fatal?
You can do anything you want but IMO yes, otherwise we'd be misconfigured and there is a mismatch.
Luis
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 31 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1751
Quoted 7 lines · Luis R. Rodriguez
tools/xenstore/xenstored_core.c +7
-0+int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to));This risks overrunning sock if
connect_tois longer than 30 characters.Yuk, yes. A size check is required.
Quoted 2 lines
But your use of strlen suggests that
connect_tois already NULL terminated, so what is this for?
strlen()seems to want the string to also be null terminated in order to work, and I also see thatsnprintf()is ultimately used on the C version of the library, that should ensure its null terminated. This however is not true for the ocaml version and I suppose that is the root of the issue I saw that got me to force null terimination as I did run into issues with this path IIRC when not null terminated.Quoted 5 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1754
Quoted 2 lines
tools/xenstore/xenstored_core.c +2
-0+if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) {Given that sock (or
connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?
Quoted 7 lines
See above.
Quoted 2 lines
As it is I think your code would accept
e.g./var/run/xenstored/socketwibble, no?It indeed would, its best if we resolve the null termination issue internally then.
Yeah, I think we should write the C version according to normal C string conventions. If the ocaml idea of a string differs then perhaps that version needs to be different.
Quoted 13 lines
Quoted 2 lines
Is it common in systemd support to validate the input socket's path in this way? As opposed to trusting that the systemd unit file is correct.
sd_is_socket_unix()is certainly advised and highly encourged. As for the other check -- yes we want that given that we are using two socket files specifically in order to avoid having tochmod()the socket ourelves. Systemd currently doesn't support having two separate sockets in one file with different permissions. From what I have seen the order in which systemd sets the sockets and maps them to fds will very on the unit socket files you use, this approach lets us allow systemd to give them to us in any order while my hope is that systemd upstream gets support for just one stocket file with multiple permissions.
OK.
BTW, the permissions on these two sockets should be the same (read/write), it's the owner/group which might differ.
(You need to be able to write to the ro socket to send operations, the distinction is that the ro socket will reject XS_WRITE messages)
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
tools/xenstore/xenstored_core.c +15
-0+static void xen_claim_active_sockets (int **psock,int **pro_sock) +{ +int *sock, *ro_sock; +const char *soc_str =xs_daemon_socket (); +const char *soc_str_ro =xs_daemon_socket_ro (); +int n; + + n =sd_listen_fds (0 ); +if (n <=0 ) { +sd_notifyf (0 ,"STATUS=Failed to get any active sockets: %s\n" +"ERRNO=%i" , +strerror (errno), + errno); +barf_perror ("sd_listen_fds() failed\n" ); + }else if (n >2 ) {Quoted 8 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1785
Quoted 6 lines
tools/xenstore/xenstored_core.c +6
-0+fprintf (stderr,SD_ERR "Expected 2 fds but given %d\n" , n); +sd_notifyf (0 ,"STATUS=Mismatch on number (2): %s\n" +"ERRNO=%d" , +strerror (EBADR ), +EBADR ); +barf_perror ("sd_listen_fds() gave too many fds\n" );Need this be fatal?
Quoted 2 lines
You can do anything you want but IMO yes, otherwise we'd be misconfigured and there is a mismatch.
OK.
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 37 lines · Ian Campbell
Quoted 36 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1751
Quoted 7 lines · Luis R. Rodriguez
tools/xenstore/xenstored_core.c +7
-0+int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to));This risks overrunning sock if
connect_tois longer than 30 characters.Yuk, yes. A size check is required.
Quoted 2 lines
But your use of strlen suggests that
connect_tois already NULL terminated, so what is this for?
strlen()seems to want the string to also be null terminated in order to work, and I also see thatsnprintf()is ultimately used on the C version of the library, that should ensure its null terminated. This however is not true for the ocaml version and I suppose that is the root of the issue I saw that got me to force null terimination as I did run into issues with this path IIRC when not null terminated.Quoted 5 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1754
Quoted 2 lines
tools/xenstore/xenstored_core.c +2
-0+if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) {Given that sock (or
connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?See above.
Quoted 2 lines
As it is I think your code would accept
e.g./var/run/xenstored/socketwibble, no?
Quoted 6 lines
Quoted 2 lines
It indeed would, its best if we resolve the null termination issue internally then.
Yeah, I think we should write the C version according to normal C string conventions. If the ocaml idea of a string differs then perhaps that version needs to be different.
OK, or we ensure Ocaml's implementation provides a null terminated string to try to keep the systemd interface similar, poking Dave for feedback:
String_val() is used for the static string connect_to passed to the C wrapper, the String_val() documentation [0] says that "there is a null character after the last character in the string" however its unclear if this is guaranteed if the string was originally a static Ocaml string which was not null terminated.
Now, its unclear which xenstored (cxenstored or oxenstored) gave me issues that pushed me to ensure I give systemd null terminated strings but I do know that it was one for sure and it took me quite a bit to figure out this was needed and that this was the issue. Based on my review just now since the cxenstored uses snprintf() for both xs_daemon_socket_ro() and xs_daemon_socket() and since snprintf() man page says that it will write at most size bytes (including the terminating null byte ('\0') I am left to only grow suspcicious of the oxenstored as the probable cause of the issues I saw. I should also highlight that the socket path can also come from environment variables on cxenstored, XENSTORED_PATH, and getenv() documentation doesn't say whether or not strings will be null terminated for us, that might cause unexpected issues if used and if it doesn't on systemd.
In v5 systemd integration implementation in which I used static structs for the strings in C I had no issues but note that in that case I simply used the Ocaml string (after String_val()) to and compare it to the one on the static C array with:
(!strcmp(connect_to, xenstore_active_sockets[i].path))
I then used the C static string for sd_is_socket_unix(), not the one passed from cxenstored or oxenstored.
[0] http://caml.inria.fr/pub/docs/manual-ocaml-400/manual033.html
Quoted 14 lines
Quoted 13 lines
Quoted 2 lines
Is it common in systemd support to validate the input socket's path in this way? As opposed to trusting that the systemd unit file is correct.
sd_is_socket_unix()is certainly advised and highly encourged. As for the other check -- yes we want that given that we are using two socket files specifically in order to avoid having tochmod()the socket ourelves. Systemd currently doesn't support having two separate sockets in one file with different permissions. From what I have seen the order in which systemd sets the sockets and maps them to fds will very on the unit socket files you use, this approach lets us allow systemd to give them to us in any order while my hope is that systemd upstream gets support for just one stocket file with multiple permissions.
Quoted 4 lines
OK.
BTW, the permissions on these two sockets should be the same (read/write),
tools/xenstore/xenstored_core.c uses chmod to change the permissions:
if (chmod(soc_str, 0600) != 0
|| chmod(soc_str_ro, 0660) != 0)
barf_perror("Could not chmod sockets");Quoted 1 line
it's the owner/group which might differ.
On my latest Debian install of the master branch for legacy init my sockets end up being owned by root, who should be owning the sockets?
Quoted 1 line
(You need to be able to write to the ro socket to send operations,
BTW what is the _ro socket used for exactly? I couldn't find usage for it in existing code.
Quoted 1 line
the distinction is that the ro socket will reject
XS_WRITEmessages)
OK, got it.
Luis
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 26 lines · Luis R. Rodriguez
Quoted 14 lines
Quoted 13 lines
Quoted 2 lines
Is it common in systemd support to validate the input socket's path in this way? As opposed to trusting that the systemd unit file is correct.
sd_is_socket_unix()is certainly advised and highly encourged. As for the other check -- yes we want that given that we are using two socket files specifically in order to avoid having tochmod()the socket ourelves. Systemd currently doesn't support having two separate sockets in one file with different permissions. From what I have seen the order in which systemd sets the sockets and maps them to fds will very on the unit socket files you use, this approach lets us allow systemd to give them to us in any order while my hope is that systemd upstream gets support for just one stocket file with multiple permissions.Quoted 4 lines
OK.
BTW, the permissions on these two sockets should be the same (read/write),
tools/xenstore/xenstored_core.cuses chmod to change the permissions:if (chmod(soc_str, 0600) != 0 || chmod(soc_str_ro, 0660) != 0) barf_perror("Could not chmod sockets");
Quoted 5 lines
Quoted 1 line
it's the owner/group which might differ.
On my latest Debian install of the master branch for legacy init my sockets end up being owned by root, who should be owning the sockets?
My mistake, I thought they were 0660 and root:root and 0660 root:
$something. But 0600 for the rw makes sense too.
Default owner should be root:root for both IMHO. The ro socket is there for the admin if he wants to chgrp it and put things in that group.
Quoted 10 lines
Quoted 1 line
(You need to be able to write to the ro socket to send operations,
BTW what is the
_rosocket used for exactly? I couldn't find usage for it in existing code.Quoted 1 line
the distinction is that the ro socket will reject
XS_WRITEmessages)OK, got it.
Luis
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 33 lines · Ian Campbell
Quoted 26 lines · Luis R. Rodriguez
Quoted 14 lines
Quoted 13 lines
Quoted 2 lines
Is it common in systemd support to validate the input socket's path in this way? As opposed to trusting that the systemd unit file is correct.
sd_is_socket_unix()is certainly advised and highly encourged. As for the other check -- yes we want that given that we are using two socket files specifically in order to avoid having tochmod()the socket ourelves. Systemd currently doesn't support having two separate sockets in one file with different permissions. From what I have seen the order in which systemd sets the sockets and maps them to fds will very on the unit socket files you use, this approach lets us allow systemd to give them to us in any order while my hope is that systemd upstream gets support for just one stocket file with multiple permissions.Quoted 4 lines
OK.
BTW, the permissions on these two sockets should be the same (read/write),
tools/xenstore/xenstored_core.cuses chmod to change the permissions:if (chmod(soc_str, 0600) != 0 || chmod(soc_str_ro, 0660) != 0) barf_perror("Could not chmod sockets");Quoted 5 lines
Quoted 1 line
it's the owner/group which might differ.
On my latest Debian install of the master branch for legacy init my sockets end up being owned by root, who should be owning the sockets?
Quoted 5 lines
My mistake, I thought they were 0660 and root:root and 0660 root:
$something. But 0600 for the rw makes sense too.Default owner should be root:root for both IMHO. The ro socket is there for the admin if he wants to chgrp it and put things in that group.
OK my patches upkeep the existing implementation design then.
Luis
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
In reply to Luis R. RodriguezDavid, Anil, please see below.
Quoted 41 lines · Luis R. Rodriguez
Quoted 40 lines · Ian Campbell
Quoted 38 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1751
Quoted 7 lines · Luis R. Rodriguez
tools/xenstore/xenstored_core.c +7
-0+int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to));This risks overrunning sock if
connect_tois longer than 30 characters.Yuk, yes. A size check is required.
Quoted 2 lines
But your use of strlen suggests that
connect_tois already NULL terminated, so what is this for?
strlen()seems to want the string to also be null terminated in order to work, and I also see thatsnprintf()is ultimately used on the C version of the library, that should ensure its null terminated. This however is not true for the ocaml version and I suppose that is the root of the issue I saw that got me to force null terimination as I did run into issues with this path IIRC when not null terminated.Quoted 5 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1754
Quoted 2 lines
tools/xenstore/xenstored_core.c +2
-0+if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) {Given that sock (or
connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?See above.
Quoted 2 lines
As it is I think your code would accept
e.g./var/run/xenstored/socketwibble, no?It indeed would, its best if we resolve the null termination issue internally then.
Quoted 7 lines
Quoted 3 lines
Yeah, I think we should write the C version according to normal C string conventions. If the ocaml idea of a string differs then perhaps that version needs to be different.
OK, or we ensure Ocaml's implementation provides a null terminated string to try to keep the systemd interface similar, poking Dave for feedback:
Dave, Anil, or other ocaml folks -- feedback is is appreciated on the questions below.
Quoted 25 lines
String_val()is used for the static stringconnect_topassed to the C wrapper, theString_val()documentation [0] says that "there is a null character after the last character in the string" however its unclear if this is guaranteed if the string was originally a static Ocaml string which was not null terminated.Now, its unclear which xenstored (cxenstored or oxenstored) gave me issues that pushed me to ensure I give systemd null terminated strings but I do know that it was one for sure and it took me quite a bit to figure out this was needed and that this was the issue. Based on my review just now since the cxenstored uses
snprintf()for bothxs_daemon_socket_ro()andxs_daemon_socket()and sincesnprintf()man page says that it will write at most size bytes (including the terminating null byte ('\0') I am left to only grow suspcicious of the oxenstored as the probable cause of the issues I saw. I should also highlight that the socket path can also come from environment variables on cxenstored,XENSTORED_PATH, andgetenv()documentation doesn't say whether or not strings will be null terminated for us, that might cause unexpected issues if used and if it doesn't on systemd.In v5 systemd integration implementation in which I used static structs for the strings in C I had no issues but note that in that case I simply used the Ocaml string (after
String_val()) to and compare it to the one on the static C array with:
Quoted 6 lines
(!strcmp(connect_to, xenstore_active_sockets[i].path))
I then used the C static string for
sd_is_socket_unix(), not the one passed from cxenstored or oxenstored.[0] http://caml.inria.fr/pub/docs/manual-ocaml-400/manual033.html
Luis
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Hi Luis,
Sorry I missed this question earlier.
Quoted 48 lines · Luis R. Rodriguez
David, Anil, please see below.
Quoted 45 lines · Luis R. Rodriguez
Quoted 43 lines · Ian Campbell
Quoted 31 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1751
Quoted 7 lines · Luis R. Rodriguez
tools/xenstore/xenstored_core.c +7
-0+int xs_validate_active_socket (const char *connect_to) +{ +char sock[30 ]; + +/* We have to null terminate the socket path */ +memset (sock,'\0' ,sizeof (sock)); +memcpy (sock, connect_to,strlen (connect_to));This risks overrunning sock if
connect_tois longer than 30 characters.Yuk, yes. A size check is required.
Quoted 2 lines
But your use of strlen suggests that
connect_tois already NULL terminated, so what is this for?
strlen()seems to want the string to also be null terminated in order to work, and I also see thatsnprintf()is ultimately used on the C version of the library, that should ensure its null terminated. This however is not true for the ocaml version and I suppose that is the root of the issue I saw that got me to force null terimination as I did run into issues with this path IIRC when not null terminated.Quoted 5 lines
tools/xenstore/xenstored_core.c static int destroy_fd(void *_fd) · line 1754
Quoted 2 lines
tools/xenstore/xenstored_core.c +2
-0+if ((strncmp ("/var/run/xenstored/socket_ro" , sock,28 ) !=0 ) && + (strncmp ("/var/run/xenstored/socket" , sock,25 ) !=0 )) {Given that sock (or
connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?Quoted 7 lines
See above.
Quoted 2 lines
As it is I think your code would accept
e.g./var/run/xenstored/socketwibble, no?It indeed would, its best if we resolve the null termination issue internally then.
Yeah, I think we should write the C version according to normal C string conventions. If the ocaml idea of a string differs then perhaps that version needs to be different.
Quoted 12 lines
Quoted 3 lines
OK, or we ensure Ocaml's implementation provides a null terminated string to try to keep the systemd interface similar, poking Dave for feedback:
Dave, Anil, or other ocaml folks -- feedback is is appreciated on the questions below.
Quoted 5 lines
String_val()is used for the static stringconnect_topassed to the C wrapper, theString_val()documentation [0] says that "there is a null character after the last character in the string" however its unclear if this is guaranteed if the string was originally a static Ocaml string which was not null terminated.
OCaml strings are best thought of as a pair of a byte array and a length. From the point of view of the OCaml program they don’t contain NULLs unless you put some in there yourself. OCaml code which actually writes NULLs into strings is fairly rare.
The manual, although terse, is trustworthy. If you use String_val on an OCaml string you’ll get a char* which is guaranteed to be NULL terminated.
Quoted 7 lines
Quoted 7 lines
Now, its unclear which xenstored (cxenstored or oxenstored) gave me issues that pushed me to ensure I give systemd null terminated strings but I do know that it was one for sure and it took me quite a bit to figure out this was needed and that this was the issue. Based on my review just now since the cxenstored uses
snprintf()for bothxs_daemon_socket_ro()andxs_daemon_socket()and sincesnprintf()man page says that it will write at most size bytes (including the terminating null byte ('\0’)
I believe that’s true.
Quoted 13 lines
Quoted 13 lines
I
am left to only grow suspcicious of the oxenstored as the probable cause of the issues I saw. I should also highlight that the socket path can also come from environment variables on cxenstored,XENSTORED_PATH, andgetenv()documentation doesn't say whether or not strings will be null terminated for us, that might cause unexpected issues if used and if it doesn't on systemd.In v5 systemd integration implementation in which I used static structs for the strings in C I had no issues but note that in that case I simply used the Ocaml string (after
String_val()) to and compare it to the one on the static C array with:
Quoted 4 lines
Quoted 4 lines
(!strcmp(connect_to, xenstore_active_sockets[i].path))
I then used the C static string for
sd_is_socket_unix(), not the one passed from cxenstored or oxenstored.
If the strings compare equal with ‘strcmp’ then I would have thought either would work, unless the consumer is holding onto the string pointer for longer than the call duration. As soon as your function returns (or allocates) the OCaml strings can be moved around which invalidates the result of String_val— perhaps this is the cause of the difference between the String_val result and your static strings?
Dave
Quoted 4 lines
Quoted 2 lines
[0] http://caml.inria.fr/pub/docs/manual-ocaml-400/manual033.html
Luis
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 103 lines · Dave Scott
Hi Luis,
Sorry I missed this question earlier.
Quoted 48 lines · Luis R. Rodriguez
David, Anil, please see below.
Quoted 45 lines · Luis R. Rodriguez
Quoted 43 lines · Ian Campbell
Quoted 31 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
Review
Quoted 7 lines · Luis R. Rodriguez
(quoted diff) +7
-0+int xs_validate_active_socket(const char *connect_to) +{ + char sock[30]; + + /* We have to null terminate the socket path */ + memset(sock, '\0', sizeof(sock)); + memcpy(sock, connect_to, strlen(connect_to));This risks overrunning sock if
connect_tois longer than 30 characters.Yuk, yes. A size check is required.
Quoted 2 lines
But your use of strlen suggests that
connect_tois already NULL terminated, so what is this for?
strlen()seems to want the string to also be null terminated in order to work, and I also see thatsnprintf()is ultimately used on the C version of the library, that should ensure its null terminated. This however is not true for the ocaml version and I suppose that is the root of the issue I saw that got me to force null terimination as I did run into issues with this path IIRC when not null terminated.Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if ((strncmp("/var/run/xenstored/socket_ro", sock, 28) != 0) && + (strncmp("/var/run/xenstored/socket", sock, 25) != 0)) {Given that sock (or
connect_to) is NULL terminated, why strncmp and not the straightforward strcmp?Quoted 7 lines
See above.
Quoted 2 lines
As it is I think your code would accept
e.g./var/run/xenstored/socketwibble, no?It indeed would, its best if we resolve the null termination issue internally then.
Yeah, I think we should write the C version according to normal C string conventions. If the ocaml idea of a string differs then perhaps that version needs to be different.
Quoted 12 lines
Quoted 3 lines
OK, or we ensure Ocaml's implementation provides a null terminated string to try to keep the systemd interface similar, poking Dave for feedback:
Dave, Anil, or other ocaml folks -- feedback is is appreciated on the questions below.
Quoted 5 lines
String_val()is used for the static stringconnect_topassed to the C wrapper, theString_val()documentation [0] says that "there is a null character after the last character in the string" however its unclear if this is guaranteed if the string was originally a static Ocaml string which was not null terminated.OCaml strings are best thought of as a pair of a byte array and a length. From the point of view of the OCaml program they don’t contain NULLs unless you put some in there yourself. OCaml code which actually writes NULLs into strings is fairly rare.
The manual, although terse, is trustworthy. If you use
String_valon an OCaml string you’ll get a char* which is guaranteed to be NULL terminated.Quoted 7 lines
Quoted 7 lines
Now, its unclear which xenstored (cxenstored or oxenstored) gave me issues that pushed me to ensure I give systemd null terminated strings but I do know that it was one for sure and it took me quite a bit to figure out this was needed and that this was the issue. Based on my review just now since the cxenstored uses
snprintf()for bothxs_daemon_socket_ro()andxs_daemon_socket()and sincesnprintf()man page says that it will write at most size bytes (including the terminating null byte ('\0’)I believe that’s true.
Quoted 13 lines
Quoted 13 lines
I
am left to only grow suspcicious of the oxenstored as the probable cause of the issues I saw. I should also highlight that the socket path can also come from environment variables on cxenstored,XENSTORED_PATH, andgetenv()documentation doesn't say whether or not strings will be null terminated for us, that might cause unexpected issues if used and if it doesn't on systemd.In v5 systemd integration implementation in which I used static structs for the strings in C I had no issues but note that in that case I simply used the Ocaml string (after
String_val()) to and compare it to the one on the static C array with:Quoted 4 lines
Quoted 4 lines
(!strcmp(connect_to, xenstore_active_sockets[i].path))
I then used the C static string for
sd_is_socket_unix(), not the one passed from cxenstored or oxenstored.
Quoted 6 lines
If the strings compare equal with ‘strcmp’ then I would have thought either would work, unless the consumer is holding onto the string pointer for longer than the call duration. As soon as your function returns (or allocates) the OCaml strings can be moved around which invalidates the result of String_val— perhaps this is the cause of the difference between the
String_valresult and your static strings?
Your description gave me enough confidence to go ahead and test this without the added null characters and for some reason now it all works. I'll respin and send a v7.
Luis
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v6 02/13] cxenstored: add support for systemd active sockets
Quoted 9 lines · Luis R. Rodriguez
Quoted 7 lines · Dave Scott
If the strings compare equal with ‘strcmp’ then I would have thought either would work, unless the consumer is holding onto the string pointer for longer than the call duration. As soon as your function returns (or allocates) the OCaml strings can be moved around which invalidates the result of String_val— perhaps this is the cause of the difference between the
String_valresult and your static strings?
Quoted 3 lines
Your description gave me enough confidence to go ahead and test this without the added null characters and for some reason now it all works. I'll respin and send a v7.
The heap layout of OCaml strings is described precisely in Real World OCaml here:
https://realworldocaml.org/v1/en/html/memory-representation-of-values.html#string-values
Nul-termination is guaranteed by the representation (via the padding byte) to make it easier to pass to-and-from C functions. OCaml itself tracks the length of the string explicitly, so it doesn't care if there are NUL values within it (although this will of course make it difficult to pass to-and-from C string functions, and care should be taken only to pass NUL-containing OCaml strings to mem* functions instead of str*).
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
String_val()is used for the static stringconnect_topassed to the C wrapper, theString_val()documentation [0] says that "there is a null character after the last character in the string" however its unclear if this is guaranteed if the string was originally a static Ocaml string which was not null terminated.
In other words, trust the OCaml manual just as you trusted the snprintf man page :-)
-anil
PATCH v6 3/13 oxenstored: add support for systemd active sockets
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This adds systemd socket activation support for the Ocaml xenstored. Ocaml lacks systemd library support so we provide our own C helpers as is done with other functionality lacking on Ocaml.
Active sockets enables oxenstored to be loaded only if required by a system onto which Xen is installed on. Socket activation is handled by systemd, once a port for a service which claims a socket is used systemd will start the required services for it, on demand. For more details on socket activation refer to Lennart's socket-activation post regarding this [0].
An important difference with socket activation is that systemd will set FD_CLOEXEC for us on the socket before giving it to us, we'll sprinkly the Unix.set_close_on_exec for LSB init next as a separate commit.
Right now this code adds a no-op for this functionality, leaving the enablement to be done later once systemd is properly hooked into the build system. The socket activation is ordered in aligment with the socket activation order passed on to systemd.
[0] http://0pointer.de/blog/projects/socket-activation2.html
--- tools/ocaml/xenstored/Makefile | 8 +- tools/ocaml/xenstored/systemd.ml | 17 ++++ tools/ocaml/xenstored/systemd.mli | 24 ++++++ tools/ocaml/xenstored/systemd_stubs.c | 158 ++++++++++++++++++++++++++++++++++ tools/ocaml/xenstored/utils.ml | 20 +++-- tools/ocaml/xenstored/xenstored.ml | 2 + 6 files changed, 221 insertions(+), 8 deletions(-) create mode 100644 tools/ocaml/xenstored/systemd.ml create mode 100644 tools/ocaml/xenstored/systemd.mli create mode 100644 tools/ocaml/xenstored/systemd_stubs.c
tools/ocaml/xenstored/Makefile +7 -1
@@ -15,6 +15,11 @@ syslog_OBJS = syslog syslog_C_OBJS = syslog_stubs OCAML_LIBRARY = syslog +LIBS += systemd.cma systemd.cmxa +systemd_OBJS = systemd +systemd_C_OBJS = systemd_stubs +OCAML_LIBRARY += systemd + OBJS = define \ stdext \ trie \
@@ -36,11 +41,12 @@ OBJS = define \ process \ xenstored -INTF = symbol.cmi trie.cmi syslog.cmi +INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi XENSTOREDLIBS = \ unix.cmxa \ -ccopt -L -ccopt . syslog.cmxa \ + -ccopt -L -ccopt . systemd.cmxa \ -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \ -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \ -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
tools/ocaml/xenstored/systemd.ml new file +17 -0
@@ -0,0 +1,17 @@ +(* + * Copyright (C) 2014 Luis R. Rodriguez <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + *) + +external sd_listen_fds: string -> Unix.file_descr = "ocaml_sd_listen_fds" +external sd_booted: unit -> bool = "ocaml_sd_booted" +external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd.mli new file +24 -0
@@ -0,0 +1,24 @@ +(* + * Copyright (C) 2014 Luis R. Rodriguez <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + *) + +(** Calls the C library sd_listen_fds() function for us. Although + * the library doesn't accept argument we send one over to help + * us do sanity checks on the expected sockets *) +val sd_listen_fds: string -> Unix.file_descr + +(** Tells us whether or not systemd support was compiled in *) +val sd_booted: unit -> bool + +(** Tells systemd we're ready *) +external sd_notify_ready: unit -> unit = "ocaml_sd_notify_ready"
tools/ocaml/xenstored/systemd_stubs.c new file +158 -0
158 lines not on this page · raw message
tools/ocaml/xenstored/utils.ml +13 -7
@@ -73,14 +73,20 @@ let trim_path path = let join_by_null ls = String.concat "\000" ls (* unix utils *) +let create_regular_unix_socket name = + Unixext.unlink_safe name; + Unixext.mkdir_rec (Filename.dirname name) 0o700; + let sockaddr = Unix.ADDR_UNIX(name) in + let sock = Unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in + Unix.bind sock sockaddr; + Unix.listen sock 1; + sock + let create_unix_socket name = - Unixext.unlink_safe name; - Unixext.mkdir_rec (Filename.dirname name) 0o700; - let sockaddr = Unix.ADDR_UNIX(name) in - let sock = Unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in - Unix.bind sock sockaddr; - Unix.listen sock 1; - sock + if Systemd.sd_booted() then + Systemd.sd_listen_fds name + else + create_regular_unix_socket name let read_file_single_integer filename = let fd = Unix.openfile filename [ Unix.O_RDONLY ] 0o640 in
tools/ocaml/xenstored/xenstored.ml +2 -0
@@ -383,6 +383,8 @@ let _ = while not !quit do try + if Systemd.sd_booted() then + Systemd.sd_notify_ready (); main_loop () with exc -> error "caught exception %s" (Printexc.to_string exc);
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 03/13] oxenstored: add support for systemd active sockets
Quoted 17 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This adds systemd socket activation support for the Ocaml xenstored. Ocaml lacks systemd library support so we provide our own C helpers as is done with other functionality lacking on Ocaml.
Active sockets enables oxenstored to be loaded only if required by a system onto which Xen is installed on. Socket activation is handled by systemd, once a port for a service which claims a socket is used systemd will start the required services for it, on demand. For more details on socket activation refer to Lennart's socket-activation post regarding this [0].
An important difference with socket activation is that systemd will set
FD_CLOEXECfor us on the socket before giving it to us, we'll sprinkly the Unix.set_close_on_exec for LSB init next as a separate commit.
Quoted 6 lines
Right now this code adds a no-op for this functionality, leaving the enablement to be done later once systemd is properly hooked into the build system. The socket activation is ordered in aligment with the socket activation order passed on to systemd.
[0] http://0pointer.de/blog/projects/socket-activation2.html
I suspect some of my comments against C xenstored will apply to the C code here too...
tools/ocaml/xenstored/systemd.ml
Quoted 5 lines
tools/ocaml/xenstored/systemd.ml new file +0
-0
Ideally the systemd ocaml bindings would come from a suitable ocaml library (opam or whatever). I suppose such a thing doesn't exist already?
Perhaps Dave or Anil etc could advise on the feasibility of publishing these bindings as a separate project. In general I'd much rather we added build dependencies for things like that than incorporate things which are nothing to do with Xen etc into the tree (we've done too much of that in the past...)
Quoted 13 lines
tools/ocaml/xenstored/systemd.ml new file +13
-0+CAMLprim value ocaml_sd_listen_fds(value connect_to) +{ + CAMLparam1(connect_to); + CAMLlocal1(sock_ret); + int sock = -EBADR, n; + + n = sd_listen_fds(0); + if (n <= 0) { + sd_notifyf(0, "STATUS=Failed to get any active sockets: %s\n" + "ERRNO=%i", + strerror(errno), + errno); + caml_failwith("ocaml_sd_listen_fds() failed to get any sockets");
tools/ocaml/xenstored/systemd.ml
Quoted 10 lines
tools/ocaml/xenstored/systemd.ml new file +10
-0+ } else if (n > 2) { + fprintf(stderr, SD_ERR "Expected 2 fds but given %d\n", n); + sd_notifyf(0, "STATUS=Mismatch on number (2): %s\n" + "ERRNO=%d", + strerror(EBADR), + EBADR); + caml_failwith("ocaml_sd_listen_fds() mismatch"); + } + + sock = oxen_verify_socket_socket((const char *) String_val(connect_to));
String_val() gives you a char *, which ought to be automatically promoted to const as necessary. So I think the case is unnecessary and only serves to potentially hide actual errors.
tools/ocaml/xenstored/systemd.ml
Quoted 3 lines
tools/ocaml/xenstored/systemd.ml new file +3
-0+ if (sock <= 0) { + fprintf(stderr, "failed to verify sock %s\n", + (const char *) String_val(connect_to));
Same, if less critical, here.
Is stderr the best place to shove this message? sd_notify is also used elsewhere it seems.
tools/ocaml/xenstored/systemd.ml
Quoted 8 lines
tools/ocaml/xenstored/systemd.ml new file +8
-0+ caml_failwith("ocaml_sd_listen_fds_init() invalid socket"); + } + + sock_ret = Val_int(sock); + + CAMLreturn(sock_ret); +} +
Ian.
Re: [PATCH v6 03/13] oxenstored: add support for systemd active sockets
Quoted 10 lines · Ian Campbell
tools/ocaml/xenstored/systemd.ml
Quoted 5 lines · Luis R. Rodriguez
tools/ocaml/xenstored/systemd.ml new file +0
-0Ideally the systemd ocaml bindings would come from a suitable ocaml library (opam or whatever). I suppose such a thing doesn't exist already?
Not that I was able to find but Ocaml folks can chime in.
Quoted 5 lines
Perhaps Dave or Anil etc could advise on the feasibility of publishing these bindings as a separate project. In general I'd much rather we added build dependencies for things like that than incorporate things which are nothing to do with Xen etc into the tree (we've done too much of that in the past...)
Can't this be done as a separate step? Otherwise Ocaml is holding Xen behind, has that compromise has already been made and accepted?
Quoted 19 lines
Quoted 19 lines
tools/ocaml/xenstored/systemd.ml new file +19
-0+CAMLprim value ocaml_sd_listen_fds(value connect_to) +{ + CAMLparam1(connect_to); + CAMLlocal1(sock_ret); + int sock = -EBADR, n; + + n = sd_listen_fds(0); + if (n <= 0) { + sd_notifyf(0, "STATUS=Failed to get any active sockets: %s\n" + "ERRNO=%i", + strerror(errno), + errno); + caml_failwith("ocaml_sd_listen_fds() failed to get any sockets"); + } else if (n > 2) { + fprintf(stderr, SD_ERR "Expected 2 fds but given %d\n", n); + sd_notifyf(0, "STATUS=Mismatch on number (2): %s\n" + "ERRNO=%d", + strerror(EBADR), + EBADR);
Quoted 8 lines
tools/ocaml/xenstored/systemd.ml
Quoted 4 lines
tools/ocaml/xenstored/systemd.ml new file +4
-0+ caml_failwith("ocaml_sd_listen_fds() mismatch"); + } + + sock = oxen_verify_socket_socket((const char *) String_val(connect_to));
String_val()gives you a char *, which ought to be automatically promoted to const as necessary. So I think the case is unnecessary and only serves to potentially hide actual errors.
OK.
Quoted 8 lines
tools/ocaml/xenstored/systemd.ml
Quoted 3 lines
tools/ocaml/xenstored/systemd.ml new file +3
-0+ if (sock <= 0) { + fprintf(stderr, "failed to verify sock %s\n", + (const char *) String_val(connect_to));Same, if less critical, here.
Is stderr the best place to shove this message?
sd_notifyis also used elsewhere it seems.
stderr will make it out to the journal, the other errors are to also notify systemd, additional messages can be pegged with fprintf(stderr, ...). We want to be very explicit about the root cause of the issue if one triggered.
Luis
Re: [PATCH v6 03/13] oxenstored: add support for systemd active sockets
Quoted 12 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
tools/ocaml/xenstored/systemd.ml
Quoted 5 lines · Luis R. Rodriguez
tools/ocaml/xenstored/systemd.ml new file +0
-0Ideally the systemd ocaml bindings would come from a suitable ocaml library (opam or whatever). I suppose such a thing doesn't exist already?
Quoted 7 lines
Not that I was able to find but Ocaml folks can chime in.
Quoted 5 lines
Perhaps Dave or Anil etc could advise on the feasibility of publishing these bindings as a separate project. In general I'd much rather we added build dependencies for things like that than incorporate things which are nothing to do with Xen etc into the tree (we've done too much of that in the past…)
The bindings could easily be published separately and then shared amongst several projects. They’ll be needed eventually for xapi anyway, so they could live somewhere in the xapi-project on github.
I like the principle that we should prefer build dependencies to incorporating non-core things in-tree. I’d like to do some trimming— for example Mirage has a nice xenstore client library that works in both userspace and kernelspace that we could use instead of the one currently in the tree which is userspace-only. Some of the other mirage libraries (such as the branching key-value store, ‘irmin’) ought to make the oxenstored implementation a lot smaller too.
Quoted 1 line
Can't this be done as a separate step?
Adding these non-core bindings would violate this nice principle. However, if it’s only a couple of functions within oxenstored and not a whole new library (that would doubtless get packaged and probably end up conflicting with our stand-alone version and confusing people)... I could live with it, if this feature is considered important.
Cheers,
Dave
Re: [PATCH v6 03/13] oxenstored: add support for systemd active sockets
Quoted 27 lines · Dave Scott
Quoted 12 lines · Luis R. Rodriguez
Quoted 10 lines · Ian Campbell
tools/ocaml/xenstored/systemd.ml
Quoted 5 lines · Luis R. Rodriguez
tools/ocaml/xenstored/systemd.ml new file +0
-0Ideally the systemd ocaml bindings would come from a suitable ocaml library (opam or whatever). I suppose such a thing doesn't exist already?
Quoted 7 lines
Not that I was able to find but Ocaml folks can chime in.
Quoted 5 lines
Perhaps Dave or Anil etc could advise on the feasibility of publishing these bindings as a separate project. In general I'd much rather we added build dependencies for things like that than incorporate things which are nothing to do with Xen etc into the tree (we've done too much of that in the past…)
The bindings could easily be published separately and then shared amongst several projects. They’ll be needed eventually for xapi anyway, so they could live somewhere in the xapi-project on github.
Quoted 7 lines
I like the principle that we should prefer build dependencies to incorporating non-core things in-tree. I’d like to do some trimming— for example Mirage has a nice xenstore client library that works in both userspace and kernelspace that we could use instead of the one currently in the tree which is userspace-only. Some of the other mirage libraries (such as the branching key-value store, ‘irmin’) ought to make the oxenstored implementation a lot smaller too.
I followed the license practice in-use for oxenstored for the systemd interface, however I'm put to relicense the code to whatever might be helpful for the purposes you mentioned, let me know.
Quoted 7 lines
Quoted 1 line
Can't this be done as a separate step?
Adding these non-core bindings would violate this nice principle. However, if it’s only a couple of functions within oxenstored and not a whole new library (that would doubtless get packaged and probably end up conflicting with our stand-alone version and confusing people)... I could live with it, if this feature is considered important.
You folks make the call.
Luis
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v6 4/13 oxenstored: force FD_CLOEXEC with Unix.set_close_on_exec on LSB init
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Lets match the systemd active socket activation implementation and ensure that FD_CLOEXEC is set by usin Unix.set_close_on_exec. David notes oxenstored likely does not exec but there is no harm in being careful just in case things change in the future.
--- tools/ocaml/xenstored/utils.ml | 1 + 1 file changed, 1 insertion(+)
tools/ocaml/xenstored/utils.ml +1 -0
@@ -78,6 +78,7 @@ let create_regular_unix_socket name = Unixext.mkdir_rec (Filename.dirname name) 0o700; let sockaddr = Unix.ADDR_UNIX(name) in let sock = Unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in + Unix.set_close_on_exec sock; Unix.bind sock sockaddr; Unix.listen sock 1; sock
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 04/13] oxenstored: force FD_CLOEXEC with Unix.set_close_on_exec on LSB init
Quoted 11 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Lets match the systemd active socket activation implementation and ensure that
FD_CLOEXECis set by usin Unix.set_close_on_exec. David notes oxenstored likely does not exec but there is no harm in being careful just in case things change in the future.Cc David Scott <[email protected]>Cc Anil Madhavapeddy <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>
Quoted 18 lines
Cc Vincent Hanquez <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>--- tools/ocaml/xenstored/utils.ml | 1 + 1 file changed, 1 insertion(+)tools/ocaml/xenstored/utils.ml +1
-0@@ -78,6 +78,7 @@ let create_regular_unix_socket name = Unixext.mkdir_rec (Filename.dirname name) 0o700; let sockaddr = Unix.ADDR_UNIX(name) in let sock = Unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in + Unix.set_close_on_exec sock; Unix.bind sock sockaddr; Unix.listen sock 1; sock
PATCH v6 5/13 tools/xendomains: make xl the default and remove xm usage
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
xm is gone so make xl the default and remove xm stuff.
--- tools/hotplug/Linux/init.d/xendomains | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/hotplug/Linux/init.d/xendomains +3 -4
@@ -29,13 +29,12 @@ . /etc/xen/scripts/hotplugpath.sh -CMD=${SBINDIR}/xm -HEADCOMP="LinuxGuestRecord" +CMD=${SBINDIR}/xl +HEADCOMP="Xen saved domain" $CMD list &> /dev/null if test $? -ne 0 then - CMD=${SBINDIR}/xl - HEADCOMP="Xen saved domain" + exit $? fi $CMD list &> /dev/null
Signature · 7 lines
2.0.0.rc3.18.g00a5b79 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v6 6/13 tools/xendomains: do space cleanups
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This has no functional changes. This is just to prepare the file to be moved, so you won't blind your eyes or get git am to complain.
--- tools/hotplug/Linux/init.d/xendomains | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-)
tools/hotplug/Linux/init.d/xendomains +31 -31
@@ -23,7 +23,7 @@ # Default-Start: 2 3 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop secondary xen domains -# Description: Start / stop domains automatically when domain 0 +# Description: Start / stop domains automatically when domain 0 # boots / shuts down. ### END INIT INFO
@@ -43,7 +43,7 @@ then exit 0; fi -# Correct exit code would probably be 5, but it's enough +# Correct exit code would probably be 5, but it's enough # if xend complains if we're not running as privileged domain if ! [ -e /proc/xen/privcmd ]; then exit 0
@@ -73,7 +73,7 @@ test -r $XENDOM_CONFIG || { echo "$XENDOM_CONFIG not existing"; if test -e /etc/rc.status; then # SUSE rc script library . /etc/rc.status -else +else _cmd=$1 declare -a _SMSG if test "${_cmd}" = "status"; then
@@ -96,7 +96,7 @@ else fi } elif test -e /lib/lsb/init-functions; then - # LSB + # LSB . /lib/lsb/init-functions if alias log_success_msg >/dev/null 2>/dev/null; then echo_rc()
@@ -113,7 +113,7 @@ else fi } fi - else + else # emulate it echo_rc() {
@@ -123,17 +123,17 @@ else rc_reset() { _RC_RV=0; } rc_failed() { - if test -z "$1"; then + if test -z "$1"; then _RC_RV=1; - elif test "$1" != "0"; then - _RC_RV=$1; - fi + elif test "$1" != "0"; then + _RC_RV=$1; + fi return ${_RC_RV} } rc_check() { return rc_failed $? - } + } rc_status() { rc_failed $?
@@ -145,7 +145,7 @@ else return ${_RC_RV} } rc_exit() { exit ${_RC_RV}; } - rc_active() + rc_active() { if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi
@@ -192,13 +192,13 @@ rdnames() { NAMES= if ! contains_something "$XENDOMAINS_AUTO" - then + then return fi for dom in $XENDOMAINS_AUTO/*; do rdname $dom - if test -z $NAMES; then - NAMES=$NM; + if test -z $NAMES; then + NAMES=$NM; else NAMES="$NAMES|$NM" fi
@@ -231,7 +231,7 @@ is_running() while read LN; do parseln "$LN" || continue if test $id = 0; then continue; fi - case $name in + case $name in ($NM) RC=0 ;;
@@ -240,11 +240,11 @@ is_running() return $RC } -start() +start() { - if [ -f $LOCKFILE ]; then + if [ -f $LOCKFILE ]; then echo -e "xendomains already running (lockfile exists)" - return; + return; fi saved_domains=" "
@@ -284,10 +284,10 @@ start() # XENDOMAINS_AUTO - they could just be symlinks to files elsewhere # Create all domains with config files in XENDOMAINS_AUTO. - # TODO: We should record which domain name belongs + # TODO: We should record which domain name belongs # so we have the option to selectively shut down / migrate later # If a domain statefile from $XENDOMAINS_SAVE matches a domain name - # in $XENDOMAINS_AUTO, do not try to start that domain; if it didn't + # in $XENDOMAINS_AUTO, do not try to start that domain; if it didn't # restore correctly it requires administrative attention. for dom in $XENDOMAINS_AUTO/*; do echo -n " ${dom##*/}"
@@ -348,14 +348,14 @@ watchdog_xencmd() read PSF PSUID PSPID PSPPID < <(echo "$PSAX") # kill $CMD $1 kill $PSPID >/dev/null 2>&1 - + echo -e . } stop() { exec 3>&2 2> /dev/null - + # Collect list of domains to shut down if test "$XENDOMAINS_AUTO_ONLY" = "true"; then rdnames
@@ -379,7 +379,7 @@ stop() esac " fi - # XENDOMAINS_SYSRQ chould be something like just "s" + # XENDOMAINS_SYSRQ chould be something like just "s" # or "s e i u" or even "s e s i u o" # for the latter, you should set XENDOMAINS_USLEEP to 1200000 or so if test -n "$XENDOMAINS_SYSRQ"; then
@@ -412,7 +412,7 @@ stop() kill $WDOG_PID >/dev/null 2>&1 else kill $WDOG_PID >/dev/null 2>&1 - + echo -e . usleep 1000 continue
@@ -471,7 +471,7 @@ stop() # Unconditionally delete lock file rm -f $LOCKFILE - + exec 2>&3 }
@@ -481,7 +481,7 @@ check_domain_up() while read LN; do parseln "$LN" || continue if test $id = 0; then continue; fi - case $name in + case $name in ($1) return 0 ;;
@@ -500,9 +500,9 @@ check_all_auto_domains_up() for nm in $XENDOMAINS_AUTO/*; do rdname $nm found=0 - if check_domain_up "$NM"; then + if check_domain_up "$NM"; then echo -n " $name" - else + else missing="$missing $NM" fi done
@@ -515,7 +515,7 @@ check_all_auto_domains_up() check_all_saved_domains_up() { - if ! contains_something "$XENDOMAINS_SAVE" + if ! contains_something "$XENDOMAINS_SAVE" then return 0 fi
@@ -562,8 +562,8 @@ case "$1" in ;; status) - echo -n "Checking for xendomains:" - if test ! -f $LOCKFILE; then + echo -n "Checking for xendomains:" + if test ! -f $LOCKFILE; then rc_failed 3 else check_all_auto_domains_up
Signature · 7 lines
2.0.0.rc3.18.g00a5b79 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v6 7/13 tools/xendomains: move to libexec and use a smaller init helper
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
The xendomains script can be reused with systemd systems as it does not control services or sockets per se, but does a one shot scrape of domUs it needs start bring up, stop, reload so we're going to reuse it. This moves the core of the script to libexec and leaves only a helper on init.
--- tools/hotplug/Linux/Makefile | 3 + tools/hotplug/Linux/init.d/xendomains | 566 +------------------------------- tools/hotplug/Linux/xendomains | 584 ++++++++++++++++++++++++++++++++++ 3 files changed, 603 insertions(+), 550 deletions(-) create mode 100644 tools/hotplug/Linux/xendomains
tools/hotplug/Linux/Makefile +3 -0
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk # Init scripts. XENDOMAINS_INITD = init.d/xendomains +XENDOMAINS_LIBEXEC = xendomains XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains XENCOMMONS_INITD = init.d/xencommons
@@ -45,6 +46,8 @@ install: all install-initd install-scripts install-udev install-initd: [ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR) [ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(SYSCONFIG_DIR) + [ -d $(DESTDIR)$(LIBEXEC) ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC) + $(INSTALL_PROG) $(XENDOMAINS_LIBEXEC) $(DESTDIR)$(LIBEXEC) $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(INITD_DIR) $(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
tools/hotplug/Linux/init.d/xendomains +16 -550
597 lines not on this page · raw message
tools/hotplug/Linux/xendomains new file +584 -0
584 lines not on this page · raw message
Signature · 7 lines
2.0.0.rc3.18.g00a5b79 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v6 07/13] tools/xendomains: move to libexec and use a smaller init helper
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
The xendomains script can be reused with systemd systems as it does not control services or sockets per se
It is not quite true. 'xl create' starts a background 'xl' process.
Ideally each of those would be handled by a separate systemd unit (I have such setup on my xen based system), but I am not sure it can be easily integrated into the standard xen distribution. So, maybe, reusing xendomain this way is good enough.
Greets,
Jacek
Re: [PATCH v6 07/13] tools/xendomains: move to libexec and use a smaller init helper
Quoted 11 lines · Jacek Konieczny
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
The xendomains script can be reused with systemd systems as it does not control services or sockets per se
It is not quite true. 'xl create' starts a background 'xl' process.
Ideally each of those would be handled by a separate systemd unit (I have such setup on my xen based system), but I am not sure it can be easily integrated into the standard xen distribution.
We won't know until its tried upstream. Patches welcomed.
Quoted 1 line
So, maybe, reusing xendomain this way is good enough.
Yeah well we have to start somewhere, we should look a this as an evolutionairy process.
Luis
Re: [PATCH v6 07/13] tools/xendomains: move to libexec and use a smaller init helper
In reply to Luis R. RodriguezQuoted 10 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
The xendomains script can be reused with systemd systems as it does not control services or sockets per se, but does a one shot scrape of domUs it needs start bring up, stop, reload so we're going to reuse it. This moves the core of the script to libexec and leaves only a helper on init.
Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>
Assuming it just the code motion (I've not verified) plus the new wrapper:
PATCH v6 8/13 autoconf: xen: force a refresh with autoconf
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
With some new functionality introduced we can't keep around the old cache, but more specifically at times autogen.sh can produce inconsistent results without considering all files obsolete. The cost of considering all files obsolete is small so just force it.
---
Please run autogen.sh, just in case after applying this.
autogen.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
autogen.sh +4 -4
@@ -1,12 +1,12 @@ #!/bin/sh -e -autoconf +autoconf -f ( cd tools - autoconf + autoconf -f autoheader ) ( cd stubdom - autoconf + autoconf -f ) ( cd docs - autoconf + autoconf -f )
Signature · 7 lines
2.0.0.rc3.18.g00a5b79 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v6 9/13 autoconf: update m4/pkg.m4
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
The provenance of the m4 pkg.m4 macro library was not documented and it was not clear how and if we can update this without breaking things. Document where this comes from, update us to the latest release from git and put a warning about avoiding private evolutions so that instead things go upstream.
The pkg-config m4 macro library comes from the upstream pkg-config git repository [0]. If you update the m4 library update this file with provenance and last commit ID information. For documentation on how to use this read the pkg-config(1) man page.
Tree: git://anongit.freedesktop.org/pkg-config
The last synch was from commit:
commit 4f0084d9d3b8726a797a373c7ec5e406000995d0
Author: Dan Nicholson <[email protected]> Date: Mon Feb 3 15:59:18 2014 -0800
glib: Fix Makefiles to suppress warnings from automake
With the newly added glib.mk, some of the noinst_* variables need to use += in the evaluation to avoid multiple definition warnings from automake.
---
please run autogen.sh after applying
m4/README.source | 28 ++++++++++++++++++ m4/pkg.m4 | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 m4/README.source
m4/README.source new file +28 -0
@@ -0,0 +1,28 @@ +About +===== +This documents the upstream sources for the different slew of different +m4 sources we have picked up or developed. + +pkg.m4 +====== +The pkg-config m4 macro library comes from the upstream pkg-config +git repository [0]. If you update the m4 library update this file +with provenance and last commit ID information. For documentation +on how to use this read the pkg-config(1) man page. + +Do not modify this file yourself, if you want to evolve it send +patches upstream and then synch back here. + +Tree: git://anongit.freedesktop.org/pkg-config + +The last synch was from commit: + +commit 4f0084d9d3b8726a797a373c7ec5e406000995d0 +Author: Dan Nicholson <[email protected]> +Date: Mon Feb 3 15:59:18 2014 -0800 + + glib: Fix Makefiles to suppress warnings from automake + + With the newly added glib.mk, some of the noinst_* variables need to use + += in the evaluation to avoid multiple definition warnings from + automake.
m4/pkg.m4 +82 -6
122 lines not on this page · raw message
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 09/13] autoconf: update m4/pkg.m4
Quoted 7 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
The provenance of the m4 pkg.m4 macro library was not documented and it was not clear how and if we can update this without breaking things. Document where this comes from, update us to the latest release from git and put a warning about avoiding private evolutions so that instead things go upstream.
Did we have any such private evolutions? Are you retaining them or throwing them away?
Re: [PATCH v6 09/13] autoconf: update m4/pkg.m4
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
The provenance of the m4 pkg.m4 macro library was not documented and it was not clear how and if we can update this without breaking things. Document where this comes from, update us to the latest release from git and put a warning about avoiding private evolutions so that instead things go upstream.
Did we have any such private evolutions? Are you retaining them or throwing them away?
No.
Luis
PATCH v6 10/13 autoconf: xen: move standard path variables to config/Paths.mk.in
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This moves all generic path variables to a new the config/Paths.mk.in input source file to be processed at configure time, tons of files use these so this just share them. This also paves the way to let us easily dynamically configure these with autoconf, for now we leave the same presets as was present before.
This work was prompted by looking for an autoconf way to do replacements for the hotplug global file, while at it I realized that a few other files use the same variables and have in places around the tree the same constructs for generating their own files. This makes use of the old buildmakevars2file() but generalizes the definition of the paths at configure time and spreads the new definitions out throughout the build system.
This has no impact on building the hypervisor and extras/mini-os, you do not need to, and are not expected to, run configure to build those targets.
While at it lets add some documentation on the for the two files on the source file, we can expand further details on the wiki [0].
[0] http://wiki.xen.org/wiki/Category:Host_Configuration#System_wide_xen_configuration
---
Please run autogen.sh after applying.
.gitignore | 1 + config/Paths.mk.in | 37 +++++++++++++++++++++++++++++++ config/Stubdom.mk.in | 1 + configure.ac | 8 ++++++- m4/paths.m4 | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ stubdom/Makefile | 1 + tools/Rules.mk | 1 + 7 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 config/Paths.mk.in create mode 100644 m4/paths.m4
.gitignore +1 -0
@@ -36,6 +36,7 @@ config.log config.status config.cache config/Toplevel.mk +config/Paths.mk build-* dist/*
config/Paths.mk.in new file +37 -0
@@ -0,0 +1,37 @@ +# Xen system configuration +# ======================== +# +# Xen uses a set of variables for system configuration and at build time, +# because of this these variables are defined on one master input source file +# and is generated after running ./configure. The master source is located +# on the xen source tree at under config/Paths.mk.in and it is used to +# generate shell or header files by the build system upon demand through the +# use of the helper makefile helper buildmakevars2file(). +# +# For more documentation you can refer to the wiki: +# +# http://wiki.xen.org/wiki/Category:Host_Configuration#System_wide_xen_configuration + +SBINDIR := @SBINDIR@ +BINDIR := @BINDIR@ +LIBEXEC := @LIBEXEC@ + +SHAREDIR := @SHAREDIR@ +LIBDIR := @LIBDIR@ + +XEN_RUN_DIR := @XEN_RUN_DIR@ +XEN_LOG_DIR := @XEN_LOG_DIR@ +XEN_LIB_STORED := @XEN_LIB_STORED@ + +CONFIG_DIR := @CONFIG_DIR@ +XEN_LOCK_DIR := @XEN_LOCK_DIR@ +XEN_PAGING_DIR := @XEN_PAGING_DIR@ + +PRIVATE_PREFIX := @PRIVATE_PREFIX@ +PRIVATE_PREFIX := @PKG_XEN_PREFIX@ +PRIVATE_BINDIR := @PRIVATE_BINDIR@ + +XENFIRMWAREDIR := @XENFIRMWAREDIR@ + +XEN_CONFIG_DIR := @XEN_CONFIG_DIR@ +XEN_SCRIPT_DIR := @XEN_SCRIPT_DIR@
config/Stubdom.mk.in +1 -0
@@ -1,4 +1,5 @@ # Prefix and install folder +include $(XEN_ROOT)/config/Paths.mk prefix := @prefix@ PREFIX := $(prefix) exec_prefix := @exec_prefix@
configure.ac +7 -1
@@ -5,12 +5,18 @@ AC_PREREQ([2.67]) AC_INIT([Xen Hypervisor], m4_esyscmd([./version.sh ./xen/Makefile]), [[email protected]], [xen], [http://www.xen.org/]) AC_CONFIG_SRCDIR([./xen/common/kernel.c]) -AC_CONFIG_FILES([./config/Toplevel.mk]) +AC_CONFIG_FILES([ + config/Toplevel.mk + config/Paths.mk +]) AC_CANONICAL_HOST m4_include([m4/features.m4]) m4_include([m4/subsystem.m4]) +m4_include([m4/paths.m4]) + +AX_XEN_EXPAND_CONFIG() dnl mini-os is only ported to certain platforms case "$host_cpu" in
m4/paths.m4 new file +61 -0
61 lines not on this page · raw message
stubdom/Makefile +1 -0
@@ -7,6 +7,7 @@ export stubdom=y export debug=y include $(XEN_ROOT)/Config.mk -include $(XEN_ROOT)/config/Stubdom.mk +include $(XEN_ROOT)/config/Paths.mk GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH) ifeq ($(XEN_TARGET_ARCH),x86_32)
tools/Rules.mk +1 -0
@@ -5,6 +5,7 @@ all: -include $(XEN_ROOT)/config/Tools.mk include $(XEN_ROOT)/Config.mk +include $(XEN_ROOT)/config/Paths.mk export _INSTALL := $(INSTALL) INSTALL = $(XEN_ROOT)/tools/cross-install
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 142 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This moves all generic path variables to a new the config/Paths.mk.in input source file to be processed at configure time, tons of files use these so this just share them. This also paves the way to let us easily dynamically configure these with autoconf, for now we leave the same presets as was present before.
This work was prompted by looking for an autoconf way to do replacements for the hotplug global file, while at it I realized that a few other files use the same variables and have in places around the tree the same constructs for generating their own files. This makes use of the old
buildmakevars2file()but generalizes the definition of the paths at configure time and spreads the new definitions out throughout the build system.This has no impact on building the hypervisor and extras/mini-os, you do not need to, and are not expected to, run configure to build those targets.
While at it lets add some documentation on the for the two files on the source file, we can expand further details on the wiki [0].
[0] http://wiki.xen.org/wiki/Category:Host_Configuration#System_wide_xen_configuration
Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Samuel Thibault <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>---
Please run
autogen.shafter applying..gitignore | 1 + config/Paths.mk.in | 37 +++++++++++++++++++++++++++++++ config/Stubdom.mk.in | 1 + configure.ac | 8 ++++++- m4/paths.m4 | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ stubdom/Makefile | 1 + tools/Rules.mk | 1 + 7 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 config/Paths.mk.in create mode 100644 m4/paths.m4.gitignore +1
-0@@ -36,6 +36,7 @@ config.log config.status config.cache config/Toplevel.mk +config/Paths.mk build-* dist/*config/Paths.mk.in new file +37
-0@@ -0,0 +1,37 @@ +# Xen system configuration +# ======================== +# +# Xen uses a set of variables for system configuration and at build time, +# because of this these variables are defined on one master input source file +# and is generated after running ./configure. The master source is located +# on the xen source tree at under config/Paths.mk.in and it is used to +# generate shell or header files by the build system upon demand through the +# use of the helper makefile helper buildmakevars2file(). +# +# For more documentation you can refer to the wiki: +# +# http://wiki.xen.org/wiki/Category:Host_Configuration#System_wide_xen_configuration + +SBINDIR := @SBINDIR@ +BINDIR := @BINDIR@ +LIBEXEC := @LIBEXEC@ + +SHAREDIR := @SHAREDIR@ +LIBDIR := @LIBDIR@ + +XEN_RUN_DIR := @XEN_RUN_DIR@ +XEN_LOG_DIR := @XEN_LOG_DIR@ +XEN_LIB_STORED := @XEN_LIB_STORED@ + +CONFIG_DIR := @CONFIG_DIR@ +XEN_LOCK_DIR := @XEN_LOCK_DIR@ +XEN_PAGING_DIR := @XEN_PAGING_DIR@ + +PRIVATE_PREFIX := @PRIVATE_PREFIX@ +PRIVATE_PREFIX := @PKG_XEN_PREFIX@ +PRIVATE_BINDIR := @PRIVATE_BINDIR@ + +XENFIRMWAREDIR := @XENFIRMWAREDIR@ + +XEN_CONFIG_DIR := @XEN_CONFIG_DIR@ +XEN_SCRIPT_DIR := @XEN_SCRIPT_DIR@config/Stubdom.mk.in +1
-0@@ -1,4 +1,5 @@ # Prefix and install folder +include $(XEN_ROOT)/config/Paths.mk prefix := @prefix@ PREFIX := $(prefix) exec_prefix := @exec_prefix@configure.ac +7
-1@@ -5,12 +5,18 @@ AC_PREREQ([2.67]) AC_INIT([Xen Hypervisor], m4_esyscmd([./version.sh ./xen/Makefile]), [[email protected]], [xen], [http://www.xen.org/]) AC_CONFIG_SRCDIR([./xen/common/kernel.c]) -AC_CONFIG_FILES([./config/Toplevel.mk]) +AC_CONFIG_FILES([ + config/Toplevel.mk + config/Paths.mk +]) AC_CANONICAL_HOST m4_include([m4/features.m4]) m4_include([m4/subsystem.m4]) +m4_include([m4/paths.m4]) + +AX_XEN_EXPAND_CONFIG() dnl mini-os is only ported to certain platforms case "$host_cpu" inm4/paths.m4 new file +0
-0
m4/paths.m4 line 4
Quoted 4 lines
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefix
This is a bit of shame. I suppose this needs to happen in the middle of AC_OUTPUT which isn't possible?
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Or perhaps we should just PREFIX=$prefix AC_SUBST(PREFIX) and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?
m4/paths.m4 line 17
Quoted 12 lines
m4/paths.m4 new file +12
-0+BINDIR=$prefix/bin +AC_SUBST(BINDIR) + +SBINDIR=$prefix/sbin +AC_SUBST(SBINDIR) + +dnl XXX: this should be changed to use the passed $libexec +dnl but can be done as a second step +LIBEXEC=$prefix/lib/xen/bin +AC_SUBST(LIBEXEC) + +LIBDIR=`eval echo $libdir`
Why is this one an eval?
stubdom/Makefile export stubdom=y · line 10
Quoted 9 lines
stubdom/Makefile +1
-0@@ -7,6 +7,7 @@ export stubdom=y export debug=y include $(XEN_ROOT)/Config.mk -include $(XEN_ROOT)/config/Stubdom.mk +include $(XEN_ROOT)/config/Paths.mk
The reason for the -include of Stubdom.mk is so that if it doesn't exist enogh of the Makefile is still run to get:
ifeq (,$(findstring clean,$(MAKECMDGOALS))) $(XEN_ROOT)/config/Stubdom.mk:
$(error You have to run ./configure before building or installing stubdom)
endif
You included Paths.mk from Stubdom.mk (and Tools.mk etc) so I think these ones are redundant.
Ian.
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?
Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Its unclear what exactly the recommendation is here.
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?
Why though?
Quoted 6 lines
Quoted 6 lines
m4/paths.m4 new file +6
-0+BINDIR=$prefix/bin +AC_SUBST(BINDIR) + +SBINDIR=$prefix/sbin +AC_SUBST(SBINDIR) +
Quoted 8 lines
m4/paths.m4 line 17
Quoted 6 lines
m4/paths.m4 new file +6
-0+dnl XXX: this should be changed to use the passed $libexec +dnl but can be done as a second step +LIBEXEC=$prefix/lib/xen/bin +AC_SUBST(LIBEXEC) + +LIBDIR=`eval echo $libdir`Why is this one an eval?
Yeah you're right, its not needed this should work just as well:
LIBDIR=$libdir
I've amended this change.
Quoted 14 lines
stubdom/Makefile export stubdom=y · line 10
Quoted 9 lines
stubdom/Makefile +1
-0@@ -7,6 +7,7 @@ export stubdom=y export debug=y include $(XEN_ROOT)/Config.mk -include $(XEN_ROOT)/config/Stubdom.mk +include $(XEN_ROOT)/config/Paths.mkThe reason for the -include of Stubdom.mk is so that if it doesn't exist enogh of the
Makefileis still run to get:
ifeq (,$(findstring clean,$(MAKECMDGOALS))) $(XEN_ROOT)/config/Stubdom.mk:
Quoted 5 lines
$(error You have to run ./configure before building or installing stubdom)endif
You included Paths.mk from Stubdom.mk (and Tools.mk etc) so I think these ones are redundant.
OK ammended.
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 19 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Quoted 6 lines
Its unclear what exactly the recommendation is here.
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
into our m4 code.
Ian.
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 22 lines · Ian Campbell
Quoted 21 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Its unclear what exactly the recommendation is here.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefixinto our m4 code.
Ah but that would mean not being able to use --prefix then no?
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 26 lines · Luis R. Rodriguez
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Its unclear what exactly the recommendation is here.
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefixinto our m4 code.
Ah but that would mean not being able to use --prefix then no?
I hope not.
autoconf generates this snippet in configure itself, by deferring the evaluation of things I'm hoping that the content of Paths.mk.in can be evaluated after that snippet has run.
Ian.
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 33 lines · Ian Campbell
Quoted 32 lines · Luis R. Rodriguez
Quoted 30 lines · Ian Campbell
Quoted 19 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Quoted 6 lines
Its unclear what exactly the recommendation is here.
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefixinto our m4 code.
Quoted 7 lines
Quoted 1 line
Ah but that would mean not being able to use --prefix then no?
I hope not.
autoconf generates this snippet in configure itself, by deferring the evaluation of things I'm hoping that the content of Paths.mk.in can be evaluated after that snippet has run.
You're right, this works. OK Great.
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 36 lines · Luis R. Rodriguez
Quoted 35 lines · Ian Campbell
Quoted 33 lines · Luis R. Rodriguez
Quoted 22 lines · Ian Campbell
Quoted 21 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Its unclear what exactly the recommendation is here.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefixinto our m4 code.
Ah but that would mean not being able to use --prefix then no?
Quoted 7 lines
Quoted 5 lines
I hope not.
autoconf generates this snippet in configure itself, by deferring the evaluation of things I'm hoping that the content of Paths.mk.in can be evaluated after that snippet has run.
You're right, this works. OK Great.
Spoke to soon, it only works if and only if --prefix is passed otherwise it gets assigned a NONE value. Can I revert back to the old solution?
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 39 lines · Luis R. Rodriguez
Quoted 38 lines · Luis R. Rodriguez
Quoted 37 lines · Ian Campbell
Quoted 26 lines · Luis R. Rodriguez
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Its unclear what exactly the recommendation is here.
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefixinto our m4 code.
Ah but that would mean not being able to use --prefix then no?
I hope not.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
autoconf generates this snippet in configure itself, by deferring the evaluation of things I'm hoping that the content of Paths.mk.in can be evaluated after that snippet has run.
You're right, this works. OK Great.
Spoke to soon, it only works if and only if --prefix is passed otherwise it gets assigned a NONE value. Can I revert back to the old solution?
I guess so. Stupid autoconf :-)
Ian.
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 44 lines · Ian Campbell
Quoted 43 lines · Luis R. Rodriguez
Quoted 42 lines · Luis R. Rodriguez
Quoted 40 lines · Ian Campbell
Quoted 26 lines · Luis R. Rodriguez
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
m4/paths.m4 line 4
Quoted 10 lines · Luis R. Rodriguez
m4/paths.m4 new file +4
-0@@ -0,0 +1,61 @@ +AC_DEFUN([AX_XEN_EXPAND_CONFIG], [ +dnl expand these early so we can use this for substitutions +test "x$prefix" = "xNONE" && prefix=$ac_default_prefix +test "x$exec_prefix" = "xNONE" && exec_prefix=$ac_default_prefixThis is a bit of shame. I suppose this needs to happen in the middle of
AC_OUTPUTwhich isn't possible?Quoted 2 lines
autoconf itself seems to quote the prefix so it is not expanded until later, i.e. when config.status is run. Would that work here?
Its unclear what exactly the recommendation is here.
Quoted 2 lines
Or perhaps we should just PREFIX=$prefix
AC_SUBST(PREFIX)and put all the BINDIR=$PREFIX/bin into Paths.mk.in after PREFIX=@PREFIX@?Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Why though?
To avoid cutting and pasting the snippet of autoconf internal code:
test "x$prefix" = "xNONE" && prefix=$ac_default_prefixinto our m4 code.
Ah but that would mean not being able to use --prefix then no?
I hope not.
autoconf generates this snippet in configure itself, by deferring the evaluation of things I'm hoping that the content of Paths.mk.in can be evaluated after that snippet has run.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
You're right, this works. OK Great.
Spoke to soon, it only works if and only if --prefix is passed otherwise it gets assigned a NONE value. Can I revert back to the old solution?
I guess so. Stupid autoconf :-)
OK reverted back to the old way.
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
In reply to Ian CampbellQuoted 5 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
+LIBDIR=eval echo $libdirWhy is this one an eval?
BTW I now see why I had used the eval on LIBDIR, its because otherwise Paths.mk ends up with:
LIBDIR := ${exec_prefix}/lib64
...
PRIVATE_PREFIX := ${exec_prefix}/lib64/xen
PRIVATE_PREFIX := ${exec_prefix}/lib64/xen
PRIVATE_BINDIR := ${exec_prefix}/lib64/xen/bin...
Can I upkeep the eval?
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 10 lines · Luis R. Rodriguez
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
+LIBDIR=eval echo $libdirWhy is this one an eval?
BTW I now see why I had used the eval on LIBDIR, its because otherwise Paths.mk ends up with:
Quoted 8 lines
LIBDIR := ${exec_prefix}/lib64
...PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_BINDIR := ${exec_prefix}/lib64/xen/bin...
Can I upkeep the eval?
Seems a bit odd that this would only affect LIBDIR and not PREFIX.
I'd like to understand why this happens before reaching for the eval (or to see some autoconf documentation that claims this is the right thing to do).
Ian.
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Luis R. Rodriguez
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
+LIBDIR=eval echo $libdirWhy is this one an eval?
BTW I now see why I had used the eval on LIBDIR, its because otherwise Paths.mk ends up with:
LIBDIR := ${exec_prefix}/lib64
...PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_BINDIR := ${exec_prefix}/lib64/xen/bin...
Quoted 3 lines
Quoted 1 line
Can I upkeep the eval?
Seems a bit odd that this would only affect LIBDIR and not PREFIX.
Yeah I tested this, the substitution does not happen even if I use AC_SUBST(exec_prefix).
Quoted 3 lines
I'd like to understand why this happens before reaching for the eval (or to see some autoconf documentation that claims this is the right thing to do).
Um, OK. So this patch series will have to wait then until that's done. I'm not sure I can help much here.
Luis
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 19 lines · Luis R. Rodriguez
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Luis R. Rodriguez
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
+LIBDIR=eval echo $libdirWhy is this one an eval?
BTW I now see why I had used the eval on LIBDIR, its because otherwise Paths.mk ends up with:
LIBDIR := ${exec_prefix}/lib64
...PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_BINDIR := ${exec_prefix}/lib64/xen/bin...
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Can I upkeep the eval?
Seems a bit odd that this would only affect LIBDIR and not PREFIX.
Yeah I tested this, the substitution does not happen even if I use
AC_SUBST(exec_prefix).
@exec_prefix@ isn't substituted if you use AC_SUBST(exec_prefix)? Ouch.
Ian.
Re: [PATCH v6 10/13] autoconf: xen: move standard path variables to config/Paths.mk.in
Quoted 20 lines · Ian Campbell
Quoted 19 lines · Luis R. Rodriguez
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Luis R. Rodriguez
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
+LIBDIR=eval echo $libdirWhy is this one an eval?
BTW I now see why I had used the eval on LIBDIR, its because otherwise Paths.mk ends up with:
LIBDIR := ${exec_prefix}/lib64
...PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_PREFIX := ${exec_prefix}/lib64/xen PRIVATE_BINDIR := ${exec_prefix}/lib64/xen/bin...
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Can I upkeep the eval?
Seems a bit odd that this would only affect LIBDIR and not PREFIX.
Yeah I tested this, the substitution does not happen even if I use
AC_SUBST(exec_prefix).@exec_prefix@ isn't substituted if you use
AC_SUBST(exec_prefix)? Ouch.
Nope.
Luis
PATCH v6 11/13 xencommons: move module list into a generic place
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This will allows us to share the same module list with sysemd, and lets us upkeep it in one place. Document this while at it on the top level README and expand on the wiki:
http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules
In order to upkeep parallelism builds be explicit about the requirement to complete all actions before any installation targets.
---
README | 18 +++++++++++
config/modules | 16 ++++++++++
tools/hotplug/Linux/Makefile | 36 +++++++++++++++++++---
.../Linux/init.d/{xencommons => xencommons.in} | 16 +---------
4 files changed, 67 insertions(+), 19 deletions(-)
create mode 100644 config/modules
rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (89%)README +18 -0
@@ -129,6 +129,24 @@ performed with root privileges.] versions of those scripts, so that you can copy the dist directory to another machine and install from that distribution. +Required Linux modules +====================== + +Xen has a set of Linux modules which the init scripts ensure to load before +enablement of xen guests. The list of modules are upkept in one place: + + * config/modules + +The file supports a simple language, comments are ignored, and if you there +are module replacements this can be listed by using a pipe to show preference +for the first module, followed by the older module. + +We should strive to not require statically loading modules but it seems some +systems have had issues with automatically loading some Linux kernel modules. +For more details refer to: + +http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules + Python Runtime Libraries ========================
config/modules new file +16 -0
@@ -0,0 +1,16 @@ +xen-evtchn +xen-gntdev +xen-gntalloc +xen-blkback +xen-netback +xen-pciback +evtchn +gntdev +netbk +blkbk +xen-scsibk +usbbk +pciback +xen-acpi-processor +# Prefer to load blktap2 if found, otherwise load blktap +blktap2|blktap
tools/hotplug/Linux/Makefile +32 -4
@@ -33,17 +33,45 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev UDEV_RULES = xen-backend.rules $(UDEV_RULES-y) .PHONY: all -all: +all: $(XENCOMMONS_INITD) + +$(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in + @set -e ; \ + IFS='' ;\ + cat $(XEN_ROOT)/config/modules | ( \ + while read l ; do \ + if echo $${l} | egrep -q "^#" ; then \ + continue ;\ + fi ;\ + if echo "$${l}" | egrep -q "\|" ; then \ + m1=$${l%%|*} ;\ + m2=$${l#*|} ;\ + echo " modprobe $$m1 2>/dev/null || modprobe $$m2 2>/dev/null" ;\ + else \ + echo " modprobe $$l 2>/dev/null" ;\ + fi ;\ + done \ + ) > $(XENCOMMONS_INITD).modules ;\ + cat $(XENCOMMONS_INITD).in | ( \ + while read l ; do \ + if echo "$${l}" | egrep -q "@LOAD_MODULES@" ; then \ + cat $(XENCOMMONS_INITD).modules ;\ + else \ + echo $$l ;\ + fi ;\ + done \ + ) > $@ + @rm -f $(XENCOMMONS_INITD).modules .PHONY: build -build: +build: all .PHONY: install install: all install-initd install-scripts install-udev # See docs/misc/distro_mapping.txt for INITD_DIR location .PHONY: install-initd -install-initd: +install-initd: all [ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR) [ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(SYSCONFIG_DIR) [ -d $(DESTDIR)$(LIBEXEC) ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)
@@ -55,7 +83,7 @@ install-initd: $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR) .PHONY: install-scripts -install-scripts: +install-scripts: all [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \ $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR) set -e; for i in $(XEN_SCRIPTS); \
tools/hotplug/Linux/init.d/xencommons.in renamed from tools/hotplug/Linux/init.d/xencommons +1 -15
@@ -57,21 +57,7 @@ do_start () { local time=0 local timeout=30 - modprobe xen-evtchn 2>/dev/null - modprobe xen-gntdev 2>/dev/null - modprobe xen-gntalloc 2>/dev/null - modprobe xen-blkback 2>/dev/null - modprobe xen-netback 2>/dev/null - modprobe xen-pciback 2>/dev/null - modprobe evtchn 2>/dev/null - modprobe gntdev 2>/dev/null - modprobe netbk 2>/dev/null - modprobe blkbk 2>/dev/null - modprobe xen-scsibk 2>/dev/null - modprobe usbbk 2>/dev/null - modprobe pciback 2>/dev/null - modprobe xen-acpi-processor 2>/dev/null - modprobe blktap2 2>/dev/null || modprobe blktap 2>/dev/null + @LOAD_MODULES@ mkdir -p /var/run/xen if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1`
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 11/13] xencommons: move module list into a generic place
Quoted 8 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This will allows us to share the same module list with sysemd, and lets us upkeep it in one place. Document this while at it on the top level README and expand on the wiki:
http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules
Quoted 8 lines
In order to upkeep parallelism builds be explicit about the requirement to complete all actions before any installation targets.
Signed-off-by Luis R. Rodriguez <[email protected]>--- README | 18 +++++++++++ config/modules | 16 ++++++++++
This list is Linux specific. If tools/hotplug/Linux/config or something doesn't work for the upcoming system patches then perhaps config/Linux.modules, where Linux is chosen to match $(XEN_OS) aka "uname -s".
Quoted 11 lines
tools/hotplug/Linux/Makefile | 36 +++++++++++++++++++--- .../Linux/init.d/{xencommons => xencommons.in} | 16 +--------- 4 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 config/modules rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (89%)README +0
-0
README performed with root privileges.] · line 136
Quoted 8 lines
README +5
-0@@ -129,6 +129,24 @@ performed with root privileges.] versions of those scripts, so that you can copy the dist directory to another machine and install from that distribution. +Required Linux modules +====================== + +Xen has a set of Linux modules which the init scripts ensure to load before +enablement of xen guests. The list of modules are upkept in one place:
enablement isn't a word. I think "before starting Xen guests" is OK.
upkept also isn't, "maintained" perhaps.
Also, end users don't care a jot about any of this. Move it right to the end of the README? At the moment it comes before the Python stuff which is end user focused.
TBH if it were me I'd just put the "The file supports a simple.." as a comment in config/modules (wherever it ends up) and leave it at that.
README performed with root privileges.] · line 146
Quoted 9 lines
README +9
-0+ * config/modules + +The file supports a simple language, comments are ignored, and if you there +are module replacements this can be listed by using a pipe to show preference +for the first module, followed by the older module. + +We should strive to not require statically loading modules but it seems some +systems have had issues with automatically loading some Linux kernel modules. +For more details refer to:
This last paragraph is just meta commentary, IMHO it is commit log material (at best) rather than README material.
Quoted 31 lines
README +3
-0+ +http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules + Python Runtime Libraries ========================tools/hotplug/Linux/Makefile +16
-1@@ -33,17 +33,45 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev UDEV_RULES = xen-backend.rules $(UDEV_RULES-y) .PHONY: all -all: +all: $(XENCOMMONS_INITD) + +$(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in + @set -e ; \ + IFS='' ;\ + cat $(XEN_ROOT)/config/modules | ( \ + while read l ; do \ + if echo $${l} | egrep -q "^#" ; then \ + continue ;\ + fi ;\ + if echo "$${l}" | egrep -q "\|" ; then \ + m1=$${l%%|*} ;\ + m2=$${l#*|} ;\ + echo " modprobe $$m1 2>/dev/null || modprobe $$m2 2>/dev/null" ;\ + else \ + echo " modprobe $$l 2>/dev/null" ;\
tools/hotplug/Linux/Makefile UDEV_RULES_DIR = $(CONFIG_DIR)/udev · line 61
Quoted 10 lines
tools/hotplug/Linux/Makefile +10
-0+ fi ;\ + done \ + ) > $(XENCOMMONS_INITD).modules ;\ + cat $(XENCOMMONS_INITD).in | ( \ + while read l ; do \ + if echo "$${l}" | egrep -q "@LOAD_MODULES@" ; then \ + cat $(XENCOMMONS_INITD).modules ;\ + else \ + echo $$l ;\ + fi ;\
Sed with something like "/@LOAD_MODULES@/r$(...).modules" can replace this second loop.
Ian.
Re: [PATCH v6 11/13] xencommons: move module list into a generic place
Quoted 18 lines · Ian Campbell
Quoted 8 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This will allows us to share the same module list with sysemd, and lets us upkeep it in one place. Document this while at it on the top level README and expand on the wiki:
http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules
Quoted 8 lines
In order to upkeep parallelism builds be explicit about the requirement to complete all actions before any installation targets.
Signed-off-by Luis R. Rodriguez <[email protected]>--- README | 18 +++++++++++ config/modules | 16 ++++++++++
Quoted 4 lines
This list is Linux specific. If
tools/hotplug/Linux/configor something doesn't work for the upcoming system patches then perhaps config/Linux.modules, where Linux is chosen to match $(XEN_OS) aka "uname -s".
Moved to config/Linux.modules, and made the Makefile use $(XEN_OS).
Quoted 22 lines
Quoted 11 lines
tools/hotplug/Linux/Makefile | 36 +++++++++++++++++++--- .../Linux/init.d/{xencommons => xencommons.in} | 16 +--------- 4 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 config/modules rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (89%)README +0
-0README performed with root privileges.] · line 136
Quoted 8 lines
README +5
-0@@ -129,6 +129,24 @@ performed with root privileges.] versions of those scripts, so that you can copy the dist directory to another machine and install from that distribution. +Required Linux modules +====================== + +Xen has a set of Linux modules which the init scripts ensure to load before +enablement of xen guests. The list of modules are upkept in one place:enablement isn't a word. I think "before starting Xen guests" is OK.
Quoted 1 line
upkept also isn't, "maintained" perhaps.
Amended.
Quoted 4 lines
Also, end users don't care a jot about any of this. Move it right to the end of the README? At the moment it comes before the Python stuff which is end user focused.
Moved to the bottom.
Quoted 2 lines
TBH if it were me I'd just put the "The file supports a simple.." as a comment in config/modules (wherever it ends up) and leave it at that.
Put as a comment on the config OS Linux file.
Quoted 4 lines
Quoted 4 lines
README +4
-0+ * config/modules + +The file supports a simple language, comments are ignored, and if you there +are module replacements this can be listed by using a pipe to show preference
Quoted 8 lines
README performed with root privileges.] · line 145
Quoted 5 lines
README +5
-0+for the first module, followed by the older module. + +We should strive to not require statically loading modules but it seems some +systems have had issues with automatically loading some Linux kernel modules. +For more details refer to:This last paragraph is just meta commentary, IMHO it is commit log material (at best) rather than README material.
Nuked.
Quoted 35 lines
Quoted 35 lines
README +2
-0+http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules + Python Runtime Libraries ========================tools/hotplug/Linux/Makefile +21
-1@@ -33,17 +33,45 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev UDEV_RULES = xen-backend.rules $(UDEV_RULES-y) .PHONY: all -all: +all: $(XENCOMMONS_INITD) + +$(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in + @set -e ; \ + IFS='' ;\ + cat $(XEN_ROOT)/config/modules | ( \ + while read l ; do \ + if echo $${l} | egrep -q "^#" ; then \ + continue ;\ + fi ;\ + if echo "$${l}" | egrep -q "\|" ; then \ + m1=$${l%%|*} ;\ + m2=$${l#*|} ;\ + echo " modprobe $$m1 2>/dev/null || modprobe $$m2 2>/dev/null" ;\ + else \ + echo " modprobe $$l 2>/dev/null" ;\ + fi ;\ + done \ + ) > $(XENCOMMONS_INITD).modules ;\ + cat $(XENCOMMONS_INITD).in | ( \ + while read l ; do \
Quoted 8 lines
tools/hotplug/Linux/Makefile UDEV_RULES_DIR = $(CONFIG_DIR)/udev · line 61
Quoted 5 lines
tools/hotplug/Linux/Makefile +5
-0+ if echo "$${l}" | egrep -q "@LOAD_MODULES@" ; then \ + cat $(XENCOMMONS_INITD).modules ;\ + else \ + echo $$l ;\ + fi ;\Sed with something like "/@LOAD_MODULES@/r$(...).modules" can replace this second loop.
I gave this a few minues minutes but couldn't figure it out, surely this can be an evolution after ? Below is what I tried.
Luis
tools/hotplug/Linux/Makefile +8 -11
@@ -35,10 +35,10 @@ UDEV_RULES = xen-backend.rules $(UDEV_RULES-y) .PHONY: all all: $(XENCOMMONS_INITD) -$(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in +$(XENCOMMONS_INITD): $(XEN_ROOT)/config/$(XEN_OS).modules $(XENCOMMONS_INITD).in @set -e ; \ IFS='' ;\ - cat $(XEN_ROOT)/config/modules | ( \ + cat $(XEN_ROOT)/config/$(XEN_OS).modules | ( \ while read l ; do \ if echo $${l} | egrep -q "^#" ; then \ continue ;\
@@ -52,15 +52,12 @@ $(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in fi ;\ done \ ) > $(XENCOMMONS_INITD).modules ;\ - cat $(XENCOMMONS_INITD).in | ( \ - while read l ; do \ - if echo "$${l}" | egrep -q "@LOAD_MODULES@" ; then \ - cat $(XENCOMMONS_INITD).modules ;\ - else \ - echo $$l ;\ - fi ;\ - done \ - ) > $@ + cat $(XENCOMMONS_INITD).in | ( \ + sed -e '/@LOAD_MODULES@/ { \ + r $(XENCOMMONS_INITD).modules \ + d \ + }' \ + ) > $@ ;\ @rm -f $(XENCOMMONS_INITD).modules .PHONY: build
Re: [PATCH v6 11/13] xencommons: move module list into a generic place
Quoted 5 lines · Luis R. Rodriguez
Quoted 2 lines
Sed with something like "/@LOAD_MODULES@/r$(...).modules" can replace this second loop.
I gave this a few minues minutes but couldn't figure it out, surely this can be an evolution after ?
OK.
PATCH v6 12/13 autoconf: xen: enable explicit preference option for xenstored preference
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
As it stands oxenstored will be used by default if ocaml tools are found, the init system will also try to use oxenstored first if its found otherwise the cxenstored will be used. Lets simplify the init script and let users be explicit about the preference through configure.
This adds support to let you be explicit about the xenstored preference, you can only use one of these two options:
./configure --with-xenstored=xenstored
./configure --with-xenstored=oxenstored
We continue with the old behaviour and default oxenstored will be used but only if you have ocaml dependencies. Since the xenstored preference is explicit now and since we require configure substitutions for it we make use of the AX_XEN_EXPAND_CONFIG() helpers as otherwise substitution for SBINDIR is not propagated from the top level configuration.
All this allows us to simplify the init script to use the configured xenstore from the start. We update the sysconfig/default xencommons file with the paths for the different options though, this can be used by users to override the default xenstored, this follows the old behaviour but we now just explicitly provide the full configured paths for users.
As before, changing the xenstore requires a reboot.
In order to help with documentation we update the README with some details on configure usage refer to the wiki [0] [1] [2] for more elaborate details.
Since we are now parsing an entry within Paths.mk.in on tools we let the move the parsing of the file to be the tool's configure.
[0] http://wiki.xen.org/wiki/Xenstored
[1] http://wiki.xen.org/wiki/XenStore
[2] http://wiki.xen.org/wiki/XenStoreReference
---
Please run autogen.sh after merging please.
README | 37 +++++++++++++
m4/xenstored.m4 | 60 ++++++++++++++++++++++
tools/configure.ac | 19 +++++--
...ysconfig.xencommons => sysconfig.xencommons.in} | 13 ++++-
.../init.d/{xencommons.in => xencommons.in.in} | 8 +--
5 files changed, 126 insertions(+), 11 deletions(-)
create mode 100644 m4/xenstored.m4
rename tools/hotplug/Linux/init.d/{sysconfig.xencommons => sysconfig.xencommons.in} (64%)
rename tools/hotplug/Linux/init.d/{xencommons.in => xencommons.in.in} (92%)README +37 -0
@@ -147,6 +147,43 @@ For more details refer to: http://wiki.xen.org/wiki/Category:Host_Configuration#Linux_kernel_modules +xenstore: xenstored and oxenstored +==================================== + +Xen uses a configuration database called xenstore [0] to maintain configuration +and status information shared between domains. A daemon is implemented as part +of xenstore to act as an interface for access to the database for dom0 and +guests. Two xenstored daemons are supported, one written in C which we refer +to as the xenstored (sometimes referred to as cxenstored), and another written +in Ocaml called oxenstored. Details for xenstore and the different +implementations can be found on the wiki's xenstore reference guide [1] and +the xenstored [2] page. You can choose which xenstore you want to enable as +default on a system through configure: + + ./configure --with-xenstored=xenstored + ./configure --with-xenstored=oxenstored + +By default oxenstored will be used if the ocaml development tools are found. +If you enable oxenstored the xenstored will still be built and installed, +the xenstored used can be changed through the configuration file: + +/etc/sysconfig/xencommons +or +/etc/default/xencommons + +This file has one relevant variables which is specific to the version of +xenstored used: + + * XENSTORED - specifies the full path of the xenstored binary + +You can change the preferred xenstored you want to use in the configuration +but since we cannot stop the daemon a reboot will be required to make the +change take effect. + +[0] http://wiki.xen.org/wiki/XenStore +[1] http://wiki.xen.org/wiki/XenStoreReference +[2] http://wiki.xen.org/wiki/Xenstored + Python Runtime Libraries ========================
m4/xenstored.m4 new file +60 -0
60 lines not on this page · raw message
tools/configure.ac +16 -3
@@ -5,7 +5,11 @@ AC_PREREQ([2.67]) AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]), [[email protected]], [xen], [http://www.xen.org/]) AC_CONFIG_SRCDIR([libxl/libxl.c]) -AC_CONFIG_FILES([../config/Tools.mk]) +AC_CONFIG_FILES([ +../config/Tools.mk +hotplug/Linux/init.d/xencommons.in +hotplug/Linux/init.d/sysconfig.xencommons +]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([../])
@@ -47,6 +51,10 @@ m4_include([../m4/ptyfuncs.m4]) m4_include([../m4/extfs.m4]) m4_include([../m4/fetcher.m4]) m4_include([../m4/ax_compare_version.m4]) +m4_include([../m4/paths.m4]) +m4_include([../m4/xenstored.m4]) + +AX_XEN_EXPAND_CONFIG() # Enable/disable options AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
@@ -159,9 +167,14 @@ AC_PROG_INSTALL AC_PATH_PROG([BISON], [bison]) AC_PATH_PROG([FLEX], [flex]) AX_PATH_PROG_OR_FAIL([PERL], [perl]) + +AC_PROG_OCAML +AC_PROG_FINDLIB + +AX_XENSTORE_OPTIONS +AX_XENSTORE_SET + AS_IF([test "x$ocamltools" = "xy"], [ - AC_PROG_OCAML - AC_PROG_FINDLIB AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"], [ AS_IF([test "x$enable_ocamltools" = "xyes"], [ AC_MSG_ERROR([Ocaml tools enabled, but unable to find Ocaml])])
tools/hotplug/Linux/init.d/sysconfig.xencommons.in renamed from tools/hotplug/Linux/init.d/sysconfig.xencommons +11 -2
@@ -8,8 +8,17 @@ ## Type: string ## Default: xenstored # -# Select xenstored implementation -#XENSTORED=[oxenstored|xenstored] +# Select xenstore implementation, this can be either +# of these below. If using systemd its preferred you +# just edit the xenstored.service unit file and change +# the XENSTORED variable there. +# +# This can be either of: +# * @SBINDIR@/oxenstored +# * @SBINDIR@/xenstored +# +# Changing this requires a reboot to take effect. +#XENSTORED=@XENSTORED@ ## Type: string ## Default: Not defined, tracing off
tools/hotplug/Linux/init.d/xencommons.in.in renamed from tools/hotplug/Linux/init.d/xencommons.in +2 -6
@@ -18,6 +18,8 @@ # Description: Starts and stops the daemons neeeded for xl/xend ### END INIT INFO +XENSTORED=@XENSTORED@ + . /etc/xen/scripts/hotplugpath.sh if [ -d /etc/sysconfig ]; then
@@ -69,12 +71,6 @@ do_start () { if [ -n "$XENSTORED" ] ; then echo -n Starting $XENSTORED... $XENSTORED --pid-file /var/run/xenstored.pid $XENSTORED_ARGS - elif [ -x ${SBINDIR}/oxenstored ] ; then - echo -n Starting oxenstored... - ${SBINDIR}/oxenstored --pid-file /var/run/xenstored.pid $XENSTORED_ARGS - elif [ -x ${SBINDIR}/xenstored ] ; then - echo -n Starting C xenstored... - ${SBINDIR}/xenstored --pid-file /var/run/xenstored.pid $XENSTORED_ARGS else echo "No xenstored found" exit 1
Signature · 1 line
2.0.0.rc3.18.g00a5b79
Re: [PATCH v6 12/13] autoconf: xen: enable explicit preference option for xenstored preference
Quoted 4 lines · Luis R. Rodriguez
Since the xenstored preference
is explicit now and since we require configure substitutions for it we make use of theAX_XEN_EXPAND_CONFIG()helpers as otherwise substitution for SBINDIR is not propagated from the top level configuration.
I'm afraid I don't understand what is going on here. Why is SBINDIR not propagated?
Quoted 2 lines
Since we are now parsing an entry within Paths.mk.in on tools we let the move the parsing of the file to be the tool's configure.
I can't parse this.
Quoted 61 lines
[0] http://wiki.xen.org/wiki/Xenstored
[1] http://wiki.xen.org/wiki/XenStore
[2] http://wiki.xen.org/wiki/XenStoreReferenceCc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>Signed-off-by Luis R. Rodriguez <[email protected]>---
Please run
autogen.shafter merging please.m4/xenstored.m4 new file +41
-0@@ -0,0 +1,60 @@ +AC_DEFUN([AX_XEN_OCAML_XENSTORE_CHECK], [ + AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"], [ + AC_MSG_ERROR([Missing ocaml dependencies for oxenstored, try installing ocaml ocaml-compiler-libs ocaml-runtime ocaml-findlib]) + ]) +]) + +AC_DEFUN([AX_XEN_OCAML_XENSTORE_DEFAULTS], [ + xenstore="oxenstored" + xenstored=$SBINDIR/oxenstored + AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"], [ + xenstore="xenstored" + xenstored=$SBINDIR/xenstored + ]) +]) + +AC_DEFUN([AX_XENSTORE_OPTIONS], [ +AS_IF([test "x$XENSTORE" = "x"], [ +AC_ARG_WITH([xenstored], + AS_HELP_STRING([--with-xenstored@<:@=oxenstored|xenstored@:>@], + [This lets you choose which xenstore daemon you want, you have + two options: the original xenstored written in C (xenstored) + or the newer and robust one written in Ocaml (oxenstored). + The oxenstored daemon is the default but will but can only + be used if you have ocaml library / build dependencies solved, + if you have not specified a preference and do not have ocaml + dependencies resolved we'll enable the C xenstored for you. If + you ask for oxenstored we'll complain until you resolve those + dependencies]), + [ + AS_IF([test "x$withval" = "xxenstored"], [ + xenstore=$withval + xenstored=$SBINDIR/xenstored + ]) + AS_IF([test "x$withval" = "xoxenstored"], [ + xenstore=$withval + xenstored=$SBINDIR/oxenstored + AX_XEN_OCAML_XENSTORE_CHECK() + ]) + AS_IF([test "x$withval" != "xoxenstored" && test "x$withval" != "xxenstored"], [ + AC_MSG_ERROR([Unsupported xenstored specified, supported types: oxenstored xenstored]) + ])
m4/xenstored.m4 line 51
Quoted 10 lines
m4/xenstored.m4 new file +10
-0+ ], + [ + AX_XEN_OCAML_XENSTORE_DEFAULTS() + ]) +]) +]) + +AC_DEFUN([AX_XENSTORE_SET], [ + XENSTORE=$xenstore + AC_SUBST(XENSTORE)
This isn't used any more.
m4/xenstored.m4 line 59
Quoted 8 lines
m4/xenstored.m4 new file +8
-0+ + AS_IF([test "x$XENSTORED" = "x"], [ + XENSTORED=$xenstored + ]) + AC_SUBST(XENSTORED) + + AS_IF([test "x$XENSTORE" != "xxenstored" && test "x$XENSTORE" != "xoxenstored"], + [AC_MSG_ERROR([Invalid xenstore: $XENSTORE])])
You'll have already bailed from the previous incantation before you ever hit this, no?
Quoted 8 lines
tools/hotplug/Linux/init.d/sysconfig.xencommons.in renamed from tools/hotplug/Linux/init.d/sysconfig.xencommons +0
-0
tools/hotplug/Linux/init.d/sysconfig.xencommons.in line 12
Quoted 7 lines
tools/hotplug/Linux/init.d/sysconfig.xencommons.in renamed from tools/hotplug/Linux/init.d/sysconfig.xencommons +2
-2@@ -8,8 +8,17 @@ ## Type: string ## Default: xenstored # -# Select xenstored implementation -#XENSTORED=[oxenstored|xenstored] +# Select xenstore implementation, this can be either +# of these below. If using systemd its preferred you
"it's", and I think you are missing a "that" before you.
Ian.
Re: [PATCH v6 12/13] autoconf: xen: enable explicit preference option for xenstored preference
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Luis R. Rodriguez
Since the xenstored preference
is explicit now and since we require configure substitutions for it we make use of theAX_XEN_EXPAND_CONFIG()helpers as otherwise substitution for SBINDIR is not propagated from the top level configuration.I'm afraid I don't understand what is going on here. Why is SBINDIR not propagated?
Its saying that we need AX_XEN_EXPAND_CONFIG() in order to do substitutions for variables that include SBINDIR in this case for the xenstore full path.
Quoted 4 lines
Quoted 2 lines
Since we are now parsing an entry within Paths.mk.in on tools we let the move the parsing of the file to be the tool's configure.
I can't parse this.
I meant to clarify that since we now have to do a substitution on tools we move the calls to AX_XEN_EXPAND_CONFIG() there. This patch should have also removed the AX_XEN_EXPAND_CONFIG() from the top level configure.ac.
After testing this though and removing AX_XEN_EXPAND_CONFIG() from configure.ac I do see though that substitution doesn't work, it only works if we leave AX_XEN_EXPAND_CONFIG() on both places. This is the issue I mentioned that I ran into and you had proposed we could try to figure out a fix if this was happening. Well it is. Any ideas ? Or are you OK to live with calling AX_XEN_EXPAND_CONFIG() twice, once on configure.ac and another on tools/configure.ac ?
Quoted 3 lines
m4/xenstored.m4
Quoted 3 lines
m4/xenstored.m4 new file +0
-0
<-- snip -->
Quoted 5 lines
m4/xenstored.m4 line 51
Quoted 3 lines
m4/xenstored.m4 new file +3
-0+AC_DEFUN([AX_XENSTORE_SET], [ + XENSTORE=$xenstore + AC_SUBST(XENSTORE)This isn't used any more.
Removed this last AC_SUBST() line.
Quoted 11 lines
m4/xenstored.m4 line 59
Quoted 8 lines
m4/xenstored.m4 new file +8
-0+ + AS_IF([test "x$XENSTORED" = "x"], [ + XENSTORED=$xenstored + ]) + AC_SUBST(XENSTORED) + + AS_IF([test "x$XENSTORE" != "xxenstored" && test "x$XENSTORE" != "xoxenstored"], + [AC_MSG_ERROR([Invalid xenstore: $XENSTORE])])You'll have already bailed from the previous incantation before you ever hit this, no?
Yes true, nuked this superfluous check.
Quoted 9 lines
Quoted 9 lines
tools/hotplug/Linux/init.d/sysconfig.xencommons.in renamed from tools/hotplug/Linux/init.d/sysconfig.xencommons +0
-0@@ -8,8 +8,17 @@ ## Type: string
Quoted 8 lines
tools/hotplug/Linux/init.d/sysconfig.xencommons.in line 12
Quoted 6 lines
tools/hotplug/Linux/init.d/sysconfig.xencommons.in renamed from tools/hotplug/Linux/init.d/sysconfig.xencommons +2
-2## Default: xenstored # -# Select xenstored implementation -#XENSTORED=[oxenstored|xenstored] +# Select xenstore implementation, this can be either +# of these below. If using systemd its preferred you"it's", and I think you are missing a "that" before you.
Amended, thanks.
Luis
Re: [PATCH v6 12/13] autoconf: xen: enable explicit preference option for xenstored preference
Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Luis R. Rodriguez
Since the xenstored preference
is explicit now and since we require configure substitutions for it we make use of theAX_XEN_EXPAND_CONFIG()helpers as otherwise substitution for SBINDIR is not propagated from the top level configuration.
Quoted 5 lines
Quoted 2 lines
I'm afraid I don't understand what is going on here. Why is SBINDIR not propagated?
Its saying that we need
AX_XEN_EXPAND_CONFIG()in order to do substitutions for variables that include SBINDIR in this case for the xenstore full path.
Specifically you mean that the autoconf/m4 code now uses these variables in addition to them appearing in Paths.mk? Strictly speaking you don't need the associated AC_SUBST's but they are harmless.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Since we are now parsing an entry within Paths.mk.in on tools we let the move the parsing of the file to be the tool's configure.
I can't parse this.
I meant to clarify that since we now have to do a substitution on tools we move the calls to
AX_XEN_EXPAND_CONFIG()there. This patch should have also removed theAX_XEN_EXPAND_CONFIG()from the top level configure.ac.
I think moving it would break stubdoms under ./configure --disable-tools?
I think I would suggest keeping AX_XEN_EXPAND_CONFIG and the generation of config/Paths.mk in the top level configure but call AX_XEN_EXPAND_CONFIG again in tools/configure.ac without the generation of config/Paths.mk (I think the AC_SUBST's are benign for this second call)
Quoted 3 lines
After testing this though and removing
AX_XEN_EXPAND_CONFIG()from configure.ac I do see though that substitution doesn't work, it only works if we leaveAX_XEN_EXPAND_CONFIG()on both places.
I should have read this next para before commenting above!
Quoted 5 lines
This is the issue I mentioned that
I ran into and you had proposed we could try to figure out a fix if this was happening. Well it is. Any ideas ? Or are you OK to live with callingAX_XEN_EXPAND_CONFIG()twice, once on configure.ac and another ontools/configure.ac?
Yes, so long as the generation of config/Paths.mk remains in the toplevel configure only.
Ian.
Re: [PATCH v6 12/13] autoconf: xen: enable explicit preference option for xenstored preference
Quoted 8 lines · Ian Campbell
Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Luis R. Rodriguez
Since the xenstored preference
is explicit now and since we require configure substitutions for it we make use of theAX_XEN_EXPAND_CONFIG()helpers as otherwise substitution for SBINDIR is not propagated from the top level configuration.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I'm afraid I don't understand what is going on here. Why is SBINDIR not propagated?
Its saying that we need
AX_XEN_EXPAND_CONFIG()in order to do substitutions for variables that include SBINDIR in this case for the xenstore full path.Specifically you mean that the autoconf/m4 code now uses these variables in addition to them appearing in Paths.mk?
Right.
Quoted 2 lines
Strictly speaking you don't
need the associated AC_SUBST's but they are harmless.
Without the AC_SUBST() I do not believe substitiution is done by autoconf on Paths.mk.
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Since we are now parsing an entry within Paths.mk.in on tools we let the move the parsing of the file to be the tool's configure.
I can't parse this.
I meant to clarify that since we now have to do a substitution on tools we move the calls to
AX_XEN_EXPAND_CONFIG()there. This patch should have also removed theAX_XEN_EXPAND_CONFIG()from the top level configure.ac.
Quoted 8 lines
I think moving it would break stubdoms under ./configure --disable-tools?
I think I would suggest keeping
AX_XEN_EXPAND_CONFIGand the generation ofconfig/Paths.mkin the top level configure but callAX_XEN_EXPAND_CONFIGagain intools/configure.acwithout the generation ofconfig/Paths.mk(I think the AC_SUBST's are benign for this second call)
AX_XEN_EXPAND_CONFIG() is needed in both as we rely on some variable substitutions like SBINDIR on the tools path as well.
Quoted 5 lines
Quoted 3 lines
After testing this though and removing
AX_XEN_EXPAND_CONFIG()from configure.ac I do see though that substitution doesn't work, it only works if we leaveAX_XEN_EXPAND_CONFIG()on both places.I should have read this next para before commenting above!
OK I take it this means I can keep it on both?
Quoted 8 lines
Quoted 5 lines
This is the issue I mentioned that
I ran into and you had proposed we could try to figure out a fix if this was happening. Well it is. Any ideas ? Or are you OK to live with callingAX_XEN_EXPAND_CONFIG()twice, once on configure.ac and another ontools/configure.ac?Yes, so long as the generation of
config/Paths.mkremains in the toplevel configure only.
OK so use AX_XEN_EXPAND_CONFIG() on both top level configure.ac and tools/configure.ac but only have config/Paths.mk be a AC_CONFIG_FILES() for the top level configure.ac ?
I think that's how the v6 patch was then.
Luis
Re: [PATCH v6 12/13] autoconf: xen: enable explicit preference option for xenstored preference
Quoted 5 lines · Luis R. Rodriguez
Quoted 2 lines
Strictly speaking you don't
need the associated AC_SUBST's but they are harmless.Without the
AC_SUBST()I do not believe substitiution is done by autoconf on Paths.mk.
For tools/configure you won't be creating Paths.mk, so it doesn't matter.
Quoted 3 lines
OK so use
AX_XEN_EXPAND_CONFIG()on both top level configure.ac andtools/configure.acbut only haveconfig/Paths.mkbe aAC_CONFIG_FILES()for the top level configure.ac ?
yes.
Re: [PATCH v6 12/13] autoconf: xen: enable explicit preference option for xenstored preference
Quoted 15 lines · Ian Campbell
Quoted 5 lines · Luis R. Rodriguez
Quoted 2 lines
Strictly speaking you don't
need the associated AC_SUBST's but they are harmless.Without the
AC_SUBST()I do not believe substitiution is done by autoconf on Paths.mk.For
tools/configureyou won't be creating Paths.mk, so it doesn't matter.Quoted 3 lines
OK so use
AX_XEN_EXPAND_CONFIG()on both top level configure.ac andtools/configure.acbut only haveconfig/Paths.mkbe aAC_CONFIG_FILES()for the top level configure.ac ?
OK that's exactly how the patch was so I'll leave it alone.
Luis
PATCH v6 13/13 systemd: add xen systemd service and module files
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This adds the systemd xen service / module files. All of this is disabled for now, and won't install / build until we hook up proper support for systemd into the build system.
This goes in with AX_AVAILABLE_SYSTEMD() which will enable systemd if development libraries have been found on your build system. If you don't have systemd on target systems for binaries built with systemd then the binary will not work, you must explicitly disable systemd support if you do not want to build systemd support.
When systemd libraries are present only systems that have booted into systemd go through the systemd initialization, otherwise the legacy init is used.
These are originally based on the Fedora systemd files.
Changes made from Fedora's systemd files:
* split sockets into two files to claim different permissions
* Use /bin/sh -c exec to for a simple launcher implementation
* enables systemd socket activation for C xenstored and Ocaml oxenstored
* use sd_notify(), so change the service to Type=notify, because of this we remove the PIDFile specification as we don't care for it, and let systemd do its magic for us, this also means we don't have to fork so we use --no-fork with systemd
* defines a modules-load.d, its original source file will be shared between systemd and old init systems
* simplify service files with ConditionVirtualization=xen which uses the built in systemd virtualization backend detection, these service files will not be available to start on systems that do not boot with xen as a hypervisor
* use autoconf to replace @variable@ paths for us which piggy backs on top of the latest autoconf changes to xen
* removes oxenstored service file in favor of a system variable which controls which which xentored to use at run time, we avoid multiple service files this way.
* simplifies startup to not require polling on the sockets
as initial socket management is handled by systemd, we just take on the socket later once anything pokes at it, a simple nc -U (as root) on any of the sockets files can activate the service for example. Anything queued up will be sent to us once we start. Socket activation should in theory also let us dynamically switch between xenstores but more importantly we could upgrade xenstored while keeping all active socket communication queued up, but in order to take advantage of this we eventually would need to remove the requirement of not being able to bring down the xenstored. Even though active sockets are supported since most libxl communication doesn't triggger a check on the unix socket first administrators are encouraged to enable the xenstored.service to triggger an initialization of the xenstored upon bring up. Some systems also never use unix sockets for communication with the xenstored and as such active sockets will not be used there.
* allow for xenstored configuration through *either* of these configuration files:
- /etc/sysconfig/xenstored
- /etc/default/xenstored
The /etc/default/xenstored will let debian based systems do the same, while SUSE/OpenSUSE/Fedora/RedHat can keep on chugging with sysconfig. We leave these files all commented out by default though given that for systemd we want to encourage not using them.
* ensures we create the run directory as most systems will likely be using a tmpfs for run dirs for the pid files
* Some systems define the selinux context in the systemd Option for the /var/lib/xenstored tmpfs:
Options=mode=755,context="system_u:object_r:xenstored_var_lib_t:s0"
For the upstream version we remove that and let systems specify the context on their system /etc/default/xenstored or /etc/sysconfig/xenstored $XENSTORED_MOUNT_CTX variable, with a default to none.
* takes advantage of the shared xendomains helper for the xendomains service
* Add the new dom0 that gets kicked off for disk backend access into its own systemd service associated to xen
We end up with these systemd files:
General requirements:
* proc-xen.mount
* var-lib-xenstored.mount
xenstored:
* xenstored.service
* xenstored.socket
* xenstored_ro.socket
* xenconsoled.service
* xen-qemu-dom0-disk-backend.service.in
Optional:
* xendomains.service
* xen-watchdog.service
As for integration with xen, we house keep all the systemd files under a new directory tools/hotplug/Linux/systemd/ and will be targetted by default when building on Linux systems if systemd enabled at build time, which is only required on the build box, not the user system.
The systemd files will be sanitized for meta @VARIABLES@ upon configuration and installed upon the install target. Systems that do not use systemd can still get systemd service unit files installed if the build system enabled systemd support, this however does not mandate a requirement of having systemd libraries present. Old init scripts are always installed.
If you don't specify a prefix you will end up with the services files under /usr/local/lib/systemd/system/ by default, and systemd modules-load.d conf files under /usr/local/lib/modules-load.d/ which systemd does look for (although it seems this is not documented).
Distributions are expected to provide their /usr/ prefix to end up in the more generic location upon distribution install at /usr/lib/systemd/system/ and /usr/lib/modules-load.d/ respectively.
---
Please run autogen.sh after merging please.
.gitignore | 5 + Makefile | 6 +- README | 22 ++++ config/Tools.mk.in | 6 + m4/README.source | 10 ++ m4/systemd.m4 | 123 +++++++++++++++++++++ tools/configure.ac | 11 ++ tools/hotplug/Linux/Makefile | 8 +- tools/hotplug/Linux/systemd/Makefile | 67 +++++++++++ tools/hotplug/Linux/systemd/proc-xen.mount.in | 9 ++ .../Linux/systemd/var-lib-xenstored.mount.in | 13 +++ .../systemd/xen-qemu-dom0-disk-backend.service.in | 22 ++++ .../hotplug/Linux/systemd/xen-watchdog.service.in | 13 +++ tools/hotplug/Linux/systemd/xenconsoled.service.in | 20 ++++ tools/hotplug/Linux/systemd/xendomains.service.in | 16 +++ tools/hotplug/Linux/systemd/xenstored.service.in | 27 +++++ tools/hotplug/Linux/systemd/xenstored.socket.in | 11 ++ tools/hotplug/Linux/systemd/xenstored_ro.socket.in | 11 ++ tools/ocaml/xenstored/Makefile | 5 + tools/xenstore/Makefile | 6 + 20 files changed, 407 insertions(+), 4 deletions(-) create mode 100644 m4/systemd.m4 create mode 100644 tools/hotplug/Linux/systemd/Makefile create mode 100644 tools/hotplug/Linux/systemd/proc-xen.mount.in create mode 100644 tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in create mode 100644 tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in create mode 100644 tools/hotplug/Linux/systemd/xen-watchdog.service.in create mode 100644 tools/hotplug/Linux/systemd/xenconsoled.service.in create mode 100644 tools/hotplug/Linux/systemd/xendomains.service.in create mode 100644 tools/hotplug/Linux/systemd/xenstored.service.in create mode 100644 tools/hotplug/Linux/systemd/xenstored.socket.in create mode 100644 tools/hotplug/Linux/systemd/xenstored_ro.socket.in
.gitignore +5 -0
@@ -389,3 +389,8 @@ tools/xenstore/xenstore-watch docs/txt/misc/*.txt docs/txt/man/*.txt docs/figs/*.png + +tools/hotplug/Linux/systemd/*.conf +tools/hotplug/Linux/systemd/*.mount +tools/hotplug/Linux/systemd/*.socket +tools/hotplug/Linux/systemd/*.service
Makefile +5 -1
@@ -216,8 +216,12 @@ uninstall: rm -f $(D)$(CONFIG_DIR)/udev/rules.d/xen-backend.rules rm -f $(D)$(CONFIG_DIR)/udev/rules.d/xend.rules rm -f $(D)$(SYSCONFIG_DIR)/xendomains + rm -f $(D)$(SBINDIR)/xendomains rm -f $(D)$(SYSCONFIG_DIR)/xencommons - rm -rf $(D)/var/run/xen* $(D)/var/lib/xen* + rm -f $(D)$(XEN_SYSTEMD_DIR)/*.service + rm -f $(D)$(XEN_SYSTEMD_DIR)/*.mount + rm -f $(D)$(XEN_SYSTEMD_MODULES_LOAD)/*.conf + rm -rf $(D)${XEN_RUN_DIR}* $(D)/var/lib/xen* make -C tools uninstall rm -rf $(D)/boot/tboot*
README +22 -0
@@ -72,6 +72,7 @@ disabled at compile time: * cmake (if building vtpm stub domains) * markdown * figlet (for generating the traditional Xen start of day banner) + * systemd daemon development files Second, you need to acquire a suitable kernel for use in domain 0. If possible you should use a kernel provided by your OS distributor. If
@@ -184,6 +185,27 @@ change take effect. [1] http://wiki.xen.org/wiki/XenStoreReference [2] http://wiki.xen.org/wiki/Xenstored +Systemd and legacy init support +=============================== + +If you have systemd development packages installed you can build binaries +with systemd support. Systemd support is enabled by default if you have +systemd development libraries present. Binaries built with systemd supprot +will require systemd libraries to be present on the host system, however +systemd initialization will only occur if the system booted with systemd as its +init. If systemd was not the init the legacy initialization will be used. +Systemd is enabled by default if you have systemd development libraries +present however if you want to force enable systemd to ensure you build +binaries with systemd support you can use --enable-systemd flag. Likewise +if you want to force disable systemd you can use either of these two options: + + ./configure --disable-systemd + ./configure --enable-systemd=no + +For more details refer to the xen xenstored systemd wiki page [3]. + +[3] http://wiki.xen.org/wiki/Xenstored#xenstored_systemd_support + Python Runtime Libraries ========================
config/Tools.mk.in +6 -0
@@ -57,6 +57,12 @@ CONFIG_BLKTAP1 := @blktap1@ CONFIG_VTPM := @vtpm@ CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@ +CONFIG_SYSTEMD := @systemd@ +SYSTEMD_CFLAGS := @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS := @SYSTEMD_LIBS@ +XEN_SYSTEMD_DIR := @SYSTEMD_DIR@ +XEN_SYSTEMD_MODULES_LOAD := @SYSTEMD_MODULES_LOAD@ + #System options ZLIB := @zlib@ CONFIG_LIBICONV := @libiconv@
m4/README.source +10 -0
@@ -26,3 +26,13 @@ Date: Mon Feb 3 15:59:18 2014 -0800 With the newly added glib.mk, some of the noinst_* variables need to use += in the evaluation to avoid multiple definition warnings from automake. + +systemd.m4 +========== + +systemd.m4 was contributed to by Luis R. Rodriguez <[email protected]>, +its current home project can be found at: + +https://github.com/mcgrof/funk-systemd + +There is a plan to upstream this library somehow to systemd.
m4/systemd.m4 new file +123 -0
123 lines not on this page · raw message
tools/configure.ac +11 -0
@@ -9,6 +9,15 @@ AC_CONFIG_FILES([ ../config/Tools.mk hotplug/Linux/init.d/xencommons.in hotplug/Linux/init.d/sysconfig.xencommons +hotplug/Linux/systemd/proc-xen.mount +hotplug/Linux/systemd/var-lib-xenstored.mount +hotplug/Linux/systemd/xenstored.socket +hotplug/Linux/systemd/xenstored_ro.socket +hotplug/Linux/systemd/xenstored.service +hotplug/Linux/systemd/xenconsoled.service +hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service +hotplug/Linux/systemd/xendomains.service +hotplug/Linux/systemd/xen-watchdog.service ]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([../])
@@ -53,6 +62,7 @@ m4_include([../m4/fetcher.m4]) m4_include([../m4/ax_compare_version.m4]) m4_include([../m4/paths.m4]) m4_include([../m4/xenstored.m4]) +m4_include([../m4/systemd.m4]) AX_XEN_EXPAND_CONFIG()
@@ -260,5 +270,6 @@ esac # Checks for header files. AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h]) +AX_AVAILABLE_SYSTEMD() AC_OUTPUT()
tools/hotplug/Linux/Makefile +5 -3
@@ -25,6 +25,8 @@ XEN_SCRIPTS += vscsi XEN_SCRIPTS += block-iscsi XEN_SCRIPTS += $(XEN_SCRIPTS-y) +SUBDIRS-$(CONFIG_SYSTEMD) += systemd + XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh XEN_SCRIPT_DATA += block-common.sh
@@ -33,7 +35,7 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev UDEV_RULES = xen-backend.rules $(UDEV_RULES-y) .PHONY: all -all: $(XENCOMMONS_INITD) +all: $(XENCOMMONS_INITD) subdirs-all $(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in @set -e ; \
@@ -67,7 +69,7 @@ $(XENCOMMONS_INITD): $(XEN_ROOT)/config/modules $(XENCOMMONS_INITD).in build: all .PHONY: install -install: all install-initd install-scripts install-udev +install: all install-initd install-scripts install-udev subdirs-install # See docs/misc/distro_mapping.txt for INITD_DIR location .PHONY: install-initd
@@ -105,4 +107,4 @@ install-udev: done .PHONY: clean -clean: +clean: subdirs-clean
tools/hotplug/Linux/systemd/Makefile new file +67 -0
67 lines not on this page · raw message
tools/hotplug/Linux/systemd/proc-xen.mount.in new file +9 -0
@@ -0,0 +1,9 @@ +[Unit] +Description=Mount /proc/xen files +ConditionVirtualization=xen +RefuseManualStop=true + +[Mount] +What=xenfs +Where=/proc/xen +Type=xenfs
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in new file +13 -0
@@ -0,0 +1,13 @@ +[Unit] +Description=mount xenstore file system +ConditionVirtualization=xen +RefuseManualStop=true + +[Mount] +Environment=XENSTORED_MOUNT_CTX=none +EnvironmentFile=-/etc/sysconfig/xenstored +EnvironmentFile=-/etc/default/xenstored +What=xenstore +Where=@XEN_LIB_STORED@ +Type=tmpfs +Options=mode=755,context="$XENSTORED_MOUNT_CTX"
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +22 -0
@@ -0,0 +1,22 @@ +[Unit] +Description=qemu for xen dom0 disk backend +Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket +After=xenstored.service xenconsoled.service +Before=xendomains.service libvirtd.service libvirt-guests.service +RefuseManualStop=true +ConditionVirtualization=xen + +[Service] +Type=simple +EnvironmentFile=-/etc/default/xenstored +EnvironmentFile=-/etc/sysconfig/xenstored +PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid +ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities +ExecStartPre=/bin/mkdir -p /var/run/xen +ExecStart=@LIBEXEC@/qemu-system-i386 -xen-domid 0 \ + -xen-attach -name dom0 -nographic -M xenpv -daemonize \ + -monitor /dev/null -serial /dev/null -parallel /dev/null \ + -pidfile @XEN_RUN_DIR@/qemu-dom0.pid + +[Install] +WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xen-watchdog.service.in new file +13 -0
@@ -0,0 +1,13 @@ +[Unit] +Description=Xen-watchdog - run xen watchdog daemon +Requires=proc-xen.mount +After=proc-xen.mount xendomains.service +ConditionVirtualization=xen + +[Service] +Type=forking +ExecStart=@SBINDIR@/xenwatchdogd 30 15 +KillSignal=USR1 + +[Install] +WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xenconsoled.service.in new file +20 -0
@@ -0,0 +1,20 @@ +[Unit] +Description=Xenconsoled - handles logging from guest consoles and hypervisor +Requires=xenstored.socket +After=xenstored.service +ConditionVirtualization=xen + +[Service] +Type=simple +Environment=XENCONSOLED_ARGS= +Environment=XENCONSOLED_LOG=none +Environment=XENCONSOLED_LOG_DIR=@XEN_LOG_DIR@/console +EnvironmentFile=-/etc/default/xenconsoled +EnvironmentFile=-/etc/sysconfig/xenconsoled +PIDFile=@XEN_RUN_DIR@/xenconsoled.pid +ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities +ExecStartPre=/bin/mkdir -p ${XENCONSOLED_LOG_DIR} +ExecStart=@SBINDIR@/xenconsoled --pid-file @XEN_RUN_DIR@/xenconsoled.pid --log=${XENCONSOLED_LOG} --log-dir=${XENCONSOLED_LOG_DIR} $XENCONSOLED_ARGS + +[Install] +WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xendomains.service.in new file +16 -0
@@ -0,0 +1,16 @@ +[Unit] +Description=Xendomains - start and stop guests on boot and shutdown +Requires=xenstored.socket +After=xenstored.service xenconsoled.service +ConditionVirtualization=xen + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities +ExecStart=-@LIBEXEC@/xendomains start +ExecStop=@LIBEXEC@/xendomains stop +ExecReload=@LIBEXEC@/xendomains restart + +[Install] +WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xenstored.service.in new file +27 -0
@@ -0,0 +1,27 @@ +[Unit] +Description=The Xen xenstore +Requires=xenstored_ro.socket xenstored.socket proc-xen.mount var-lib-xenstored.mount +After=proc-xen.mount var-lib-xenstored.mount +Before=libvirtd.service libvirt-guests.service +RefuseManualStop=true +ConditionVirtualization=xen + +[Service] +Type=notify +Environment=XENSTORED_ARGS= +Environment=XENSTORED_ROOTDIR=@XEN_LIB_STORED@ +Environment=XENSTORED=@XENSTORED@ +EnvironmentFile=-/etc/default/xencommons +EnvironmentFile=-/etc/sysconfig/xencommons +ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities +ExecStartPre=-/bin/rm -f @XEN_LIB_STORED@/tdb* +ExecStartPre=/bin/mkdir -p @XEN_RUN_DIR@ +ExecStart=/bin/sh -c "exec $XENSTORED --no-fork $XENSTORED_ARGS" +ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0" +ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/domid" 0 + +[Install] +WantedBy=multi-user.target +Also=xenstored_ro.socket xenstored.socket +Also=proc-xen.mount +Also=var-lib-xenstored.mount
tools/hotplug/Linux/systemd/xenstored.socket.in new file +11 -0
@@ -0,0 +1,11 @@ +[Unit] +Description=xenstore socket +ConditionVirtualization=xen + +[Socket] +ListenStream=/var/run/xenstored/socket +SocketMode=0600 +Service=xenstored.service + +[Install] +WantedBy=sockets.target
tools/hotplug/Linux/systemd/xenstored_ro.socket.in new file +11 -0
@@ -0,0 +1,11 @@ +[Unit] +Description=xenstore ro socket +ConditionVirtualization=xen + +[Socket] +ListenStream=/var/run/xenstored/socket_ro +SocketMode=0660 +Service=xenstored.service + +[Install] +WantedBy=sockets.target
tools/ocaml/xenstored/Makefile +5 -0
@@ -3,6 +3,11 @@ OCAML_TOPLEVEL = $(CURDIR)/.. include $(OCAML_TOPLEVEL)/common.make CFLAGS += -I$(XEN_ROOT)/tools/ +CFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_CFLAGS) +LDFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_LIBS) + +CFLAGS += $(CFLAGS-y) +LDFLAGS += $(LDFLAGS-y) OCAMLINCLUDE += \ -I $(OCAML_TOPLEVEL)/libs/xb \
tools/xenstore/Makefile +6 -0
@@ -9,6 +9,12 @@ CFLAGS += -I. CFLAGS += -I$(XEN_ROOT)/tools/ CFLAGS += $(CFLAGS_libxenctrl) +CFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_CFLAGS) +LDFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_LIBS) + +CFLAGS += $(CFLAGS-y) +LDFLAGS += $(LDFLAGS-y) + CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod CLIENTS += xenstore-write xenstore-ls xenstore-watch
Signature · 7 lines
2.0.0.rc3.18.g00a5b79 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
Quoted 3 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This adds the systemd xen service / module files.
this is correct
Quoted 3 lines
All of this
is disabled for now, and won't install / build until we hook up proper support for systemd into the build system.
Actually this description is wrong and I forgot to remove, let me know if you can amed yourself if all else goes smooth. This patch also contains the autoconf integration, I think I had folded them due to review but I forget now why. If we do want to split up the autoconf stuff as the last step I can break this patch in two and resend.
Luis
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
In reply to Luis R. RodriguezQuoted 3 lines · Luis R. Rodriguez
This adds the systemd xen service / module files. All of this is disabled for now, and won't install / build until we hook up proper support for systemd into the build system.
Why?
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in line 3
Quoted 6 lines
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in new file +3
-0@@ -0,0 +1,13 @@ +[Unit] +Description=mount xenstore file system +ConditionVirtualization=xen
Move the whole shit to /run, as anyone else does.
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in line 6
Quoted 9 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +6
-0@@ -0,0 +1,22 @@ +[Service] +Type=simple +EnvironmentFile=-/etc/default/xenstored +EnvironmentFile=-/etc/sysconfig/xenstored +PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid +ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
This can fail and will move the unit into failed state. Please show that this stuff does not make failed units on non-control domains.
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in line 15
Quoted 1 line
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +1
-0+ExecStartPre=/bin/mkdir -p /var/run/xen
This is referenced nowhere.
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in line 10
Quoted 3 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +3
-0+ExecStart=/bin/sh -c "exec $XENSTORED --no-fork $XENSTORED_ARGS" +ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0" +ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/domid" 0
Are you sure this is not racey?
Bastian
Signature · 2 lines
There is an order of things in this universe. -- Apollo, "Who Mourns for Adonais?" stardate 3468.1
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
Quoted 6 lines · Bastian Blank
Quoted 3 lines · Luis R. Rodriguez
This adds the systemd xen service / module files. All of this is disabled for now, and won't install / build until we hook up proper support for systemd into the build system.
Why?
As I noted in my follow up the statement that says that this goes disabled is not accurate, I folded in the autoconf support here so ignore that part. I think I was asked to fold them together in previous reviews and just forgot to update that paragraph.
Quoted 8 lines
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in line 3
Quoted 6 lines
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in new file +3
-0@@ -0,0 +1,13 @@ +[Unit] +Description=mount xenstore file system +ConditionVirtualization=xenMove the whole shit to /run, as anyone else does.
That's a separate atomic change from existing behavior and I'd prefer that change be done separately.
Quoted 4 lines
Quoted 4 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +1
-0@@ -0,0 +1,22 @@ +[Service]
Quoted 8 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in line 14
Quoted 5 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +5
-0+Type=simple +EnvironmentFile=-/etc/default/xenstored +EnvironmentFile=-/etc/sysconfig/xenstored +PIDFile=@XEN_RUN_DIR@/qemu-dom0.pid +ExecStartPre=/bin/grep -q control_d /proc/xen/capabilitiesThis can fail and will move the unit into failed state. Please show that this stuff does not make failed units on non-control domains.
This was in the legacy init scripts, as such its valid and should not fail if this is dom0, for non xen dom0 builds the ConditionVirtualization will prevent this unit from even being considered and as such will not produced a failed unit.
Quoted 9 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in line 15
Quoted 1 line
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +1
-0+ExecStartPre=/bin/mkdir -p /var/run/xenThis is referenced nowhere.
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in line 10
Quoted 3 lines
tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in new file +3
-0+ExecStart=/bin/sh -c "exec $XENSTORED --no-fork $XENSTORED_ARGS" +ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0" +ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/domid" 0Are you sure this is not racey?
As per the documentation ExecStartPost are executed one after the other, serially [0]
[0] http://www.freedesktop.org/software/systemd/man/systemd.service.html
Luis
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
Quoted 3 lines · Luis R. Rodriguez
Quoted 3 lines
Quoted 1 line
+ExecStartPre=/bin/mkdir -p
/var/run/xenThis is referenced nowhere.
This is currently statically defined on code on both xenstored and oxenstored.
Luis
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
Quoted 11 lines · Luis R. Rodriguez <mcgrof <at> do-not-panic.com> writes:
Quoted 3 lines · On Thu, Jun 19, 2014 at 1:21 PM, Luis R. Rodriguez <mcgrof <at>…
Quoted 3 lines
Quoted 1 line
+ExecStartPre=/bin/mkdir -p
/var/run/xenThis is referenced nowhere.
This is currently statically defined on code on both xenstored and oxenstored.
Luis
Out of interest, would it be better to make use of tmpfiles.d to auto-create this, rather than the explicit mkdir?
Regards,
David
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
In reply to Luis R. RodriguezQuoted 2 lines · Luis R. Rodriguez
As for integration with xen, we house keep all the systemd files under a new directory
tools/hotplug/Linux/systemd/and will be targetted
"targeted".
Quoted 2 lines
by default when building on Linux systems if systemd enabled at build time,
This should be predicated on the presence of the systemd libraries, not on actually running systemd. Think e.g. build chroots. Maybe that's what you were trying to say anyway?
Quoted 20 lines
which is only required on the build box, not the user
system.The systemd files will be sanitized for meta @VARIABLES@ upon configuration and installed upon the install target. Systems that do not use systemd can still get systemd service unit files installed if the build system enabled systemd support, this however does not mandate a requirement of having systemd libraries present. Old init scripts are always installed.
If you don't specify a prefix you will end up with the services files under
/usr/local/lib/systemd/system/by default, and systemd modules-load.d conf files under/usr/local/lib/modules-load.d/which systemd does look for (although it seems this is not documented).Distributions are expected to provide their
/usr/prefix to end up in the more generic location upon distribution install at/usr/lib/systemd/system/and/usr/lib/modules-load.d/respectively.
README change take effect. · line 193
Quoted 9 lines
README +6
-0@@ -184,6 +185,27 @@ change take effect. [1] http://wiki.xen.org/wiki/XenStoreReference [2] http://wiki.xen.org/wiki/Xenstored +Systemd and legacy init support +=============================== + +If you have systemd development packages installed you can build binaries +with systemd support. Systemd support is enabled by default if you have +systemd development libraries present. Binaries built with systemd supprot
"support" (please run a spell checker)
README change take effect. · line 197
Quoted 4 lines
README +4
-0+will require systemd libraries to be present on the host system, however +systemd initialization will only occur if the system booted with systemd as its +init. If systemd was not the init the legacy initialization will be used. +Systemd is enabled by default if you have systemd development libraries
This is starting to repeat itself I think (this is the second time this paragraph talks about the default).
Quoted 8 lines
m4/README.source +0
-0@@ -26,3 +26,13 @@ Date: Mon Feb 3 15:59:18 2014 -0800 With the newly added glib.mk, some of the noinst_* variables need to use += in the evaluation to avoid multiple definition warnings from automake.
m4/README.source Date: Mon Feb 3 15:59:18 2014 -0800 · line 38
Quoted 10 lines
m4/README.source +10
-0+ +systemd.m4 +========== + +systemd.m4 was contributed to by Luis R. Rodriguez <[email protected]>, +its current home project can be found at: + +https://github.com/mcgrof/funk-systemd + +There is a plan to upstream this library somehow to systemd.
This last sentence doesn't belong here, we don't much care what upstream plans to do (whether or not that is you).
m4/README.source
Quoted 11 lines
m4/README.source +11
-0+AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ + AC_CHECK_HEADER([systemd/sd-daemon.h], [ + AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [libsystemddaemon="y"]) + ]) + AS_IF([test "x$libsystemddaemon" = x], [ + AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library]) + ]) + + PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon]) + dnl pkg-config older than 0.24 does not set these for + dnl PKG_CHECK_MODULES()
What is the implication of this? THat we have a workaround for it here or that we don't support system on systems with pkg-config older than that?
m4/README.source
Quoted 2 lines
worth also noting is that as of version 208
m4/README.source +1
-0+ dnl of systemd pkg-config --cflags currently yields no extra flags yet.
Why is it worth noting that?
m4/README.source
Quoted 11 lines
m4/README.source +11
-0+ AC_SUBST([SYSTEMD_CFLAGS]) + AC_SUBST([SYSTEMD_LIBS]) + + AS_IF([test "x$SYSTEMD_DIR" = x], [ + dnl In order to use the line below we need to fix upstream systemd + dnl to properly ${prefix} for child variables in + dnl src/core/systemd.pc.in but this is a bit complex at the + dnl moment as they depend on another rootprefix, which can vary + dnl from prefix in practice. We provide our own definition as we + dnl *know* where systemd will dump this to, but this does limit + dnl us to stick to a non custom systemdsystemunitdir, dnl to work
dnl in the middle of the line suggests a rewrapping snafu.
Quoted 4 lines
m4/README.source +4
-0+ dnl around this we provide the additional configure option + dnl --with-systemd where you can specify the directory for the unit + dnl files. It would also be best to just extend the upstream + dnl pkg-config pkg.m4 with an AC_DEFUN() to do this neatly.
Re: [PATCH v6 13/13] systemd: add xen systemd service and module files
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez
As for integration with xen, we house keep all the systemd files under a new directory
tools/hotplug/Linux/systemd/and will be targetted"targeted".
Amended.
Quoted 6 lines
Quoted 2 lines
by default when building on Linux systems if systemd enabled at build time,
This should be predicated on the presence of the systemd libraries, not on actually running systemd. Think e.g. build chroots. Maybe that's what you were trying to say anyway?
Indeed. Fix this up a bit to clarify.
Quoted 23 lines
Quoted 23 lines
which is only required on the build box, not the user
system.The systemd files will be sanitized for meta @VARIABLES@ upon configuration and installed upon the install target. Systems that do not use systemd can still get systemd service unit files installed if the build system enabled systemd support, this however does not mandate a requirement of having systemd libraries present. Old init scripts are always installed.
If you don't specify a prefix you will end up with the services files under
/usr/local/lib/systemd/system/by default, and systemd modules-load.d conf files under/usr/local/lib/modules-load.d/which systemd does look for (although it seems this is not documented).Distributions are expected to provide their
/usr/prefix to end up in the more generic location upon distribution install at/usr/lib/systemd/system/and/usr/lib/modules-load.d/respectively.README +0
-0@@ -184,6 +185,27 @@ change take effect. [1] http://wiki.xen.org/wiki/XenStoreReference [2] http://wiki.xen.org/wiki/Xenstored
Quoted 8 lines
README change take effect. · line 193
Quoted 6 lines
README +6
-0+Systemd and legacy init support +=============================== + +If you have systemd development packages installed you can build binaries +with systemd support. Systemd support is enabled by default if you have +systemd development libraries present. Binaries built with systemd supprot"support" (please run a spell checker)
Amended.
Quoted 7 lines
README change take effect. · line 197
Quoted 4 lines
README +4
-0+will require systemd libraries to be present on the host system, however +systemd initialization will only occur if the system booted with systemd as its +init. If systemd was not the init the legacy initialization will be used. +Systemd is enabled by default if you have systemd development librariesThis is starting to repeat itself I think (this is the second time this paragraph talks about the default).
Nuked.
Quoted 13 lines
Quoted 13 lines
m4/README.source +5
-0@@ -26,3 +26,13 @@ Date: Mon Feb 3 15:59:18 2014 -0800 With the newly added glib.mk, some of the noinst_* variables need to use += in the evaluation to avoid multiple definition warnings from automake. + +systemd.m4 +========== + +systemd.m4 was contributed to by Luis R. Rodriguez <[email protected]>,
Quoted 8 lines
m4/README.source Date: Mon Feb 3 15:59:18 2014 -0800 · line 38
Quoted 5 lines
m4/README.source +5
-0+its current home project can be found at: + +https://github.com/mcgrof/funk-systemd + +There is a plan to upstream this library somehow to systemd.This last sentence doesn't belong here, we don't much care what upstream plans to do (whether or not that is you).
OK, nuked verbosity.
Quoted 7 lines
Quoted 7 lines
m4/README.source +7
-0+AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ + AC_CHECK_HEADER([systemd/sd-daemon.h], [ + AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [libsystemddaemon="y"]) + ]) + AS_IF([test "x$libsystemddaemon" = x], [ + AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library]) + ])
Quoted 8 lines
m4/README.source
Quoted 4 lines
m4/README.source +4
-0+ + PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon]) + dnl pkg-config older than 0.24 does not set these for + dnl PKG_CHECK_MODULES()What is the implication of this? THat we have a workaround for it here or that we don't support system on systems with pkg-config older than that?
Nothing, the purpose of the additions of the two AC_SUBST() is to ensure the variables are always present, even if users are on older version of pkg-config.
Quoted 4 lines
m4/README.source
Quoted 2 lines
worth also noting is that as of version 208
m4/README.source +1
-0+ dnl of systemd pkg-config --cflags currently yields no extra flags yet.Why is it worth noting that?
I think its worth noting it as although support exists its not yet relevant, if issues should come up with it at a later point in time it may become more imporant.
Quoted 5 lines
Quoted 5 lines
m4/README.source +5
-0+ AC_SUBST([SYSTEMD_CFLAGS]) + AC_SUBST([SYSTEMD_LIBS]) + + AS_IF([test "x$SYSTEMD_DIR" = x], [ + dnl In order to use the line below we need to fix upstream systemd
Quoted 8 lines
m4/README.source
Quoted 6 lines
m4/README.source +6
-0+ dnl to properly ${prefix} for child variables in + dnl src/core/systemd.pc.in but this is a bit complex at the + dnl moment as they depend on another rootprefix, which can vary + dnl from prefix in practice. We provide our own definition as we + dnl *know* where systemd will dump this to, but this does limit + dnl us to stick to a non custom systemdsystemunitdir, dnl to workdnl in the middle of the line suggests a rewrapping snafu.
Fixed.
Luis`
Quoted 11 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Here's my v6 series. It should address all the feedback I've gotten fron the v5 series. I've compile tested and run time tested this on both systemd (OpenSUSE 13.1) and non-systemd systems (Debian testing) with cxenstored and oxenstored preferences.
The launcher thing is resolved now by using shell to do the explicit launching for us. This all also goes rebased an testd against today's git tree master branch.
*poke*
Luis
Ian Campbell
AppliedQuoted 1 line · Luis R. Rodriguez
oxenstored: force
FD_CLOEXECwith Unix.set_close_on_exec on LSB init
This is acked by me but I thought I'd give the ocaml folks a chance, and I wasn't sure if it depended textually on something before.
Quoted 5 lines
tools/xendomains: make xl the default and remove xm usagetools/xendomains: do space cleanups
tools/xendomains: move to libexec and use a smaller init helper
autoconf: xen: force a refresh with autoconf
autoconf: update m4/pkg.m4
I've applied these 5 since they seemed to standalone.
Ian.