Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-4.5
xen
xen.976ce01e103fc03bb3336cdbc6c951a709e285fe.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xen.976ce01e103fc03bb3336cdbc6c951a709e285fe.patch of Package xen
From: Juergen Gross <jgross@suse.com> Date: Tue, 2 Aug 2016 18:10:44 +0200 Subject: 976ce01e103fc03bb3336cdbc6c951a709e285fe tools: remove systemd xenstore socket definitions On a system with systemd the xenstore sockets are created via systemd. Remove the related configuration files in order to be able to decide at runtime whether the sockets should be created or not. This will enable Xen to start xenstore either via a daemon or via a stub domain. As the xenstore domain start program will exit after it has done its job prepare the same behaviour to be tolerated by systemd for the xenstore daemon by specifying the appropriate flags in the service file. A rerun of autogen.sh is required. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Acked-by: David Scott <dave@recoil.org> --- tools/configure.ac | 2 -- tools/hotplug/Linux/systemd/Makefile | 5 ---- tools/hotplug/Linux/systemd/xenstored.service.in | 5 ++-- tools/hotplug/Linux/systemd/xenstored.socket.in | 13 ----------- tools/hotplug/Linux/systemd/xenstored_ro.socket.in | 13 ----------- tools/ocaml/xenstored/systemd.ml | 2 -- tools/ocaml/xenstored/systemd.mli | 8 ------- tools/ocaml/xenstored/systemd_stubs.c | 98 ------------------------------------------------------------------------------- tools/ocaml/xenstored/utils.ml | 9 +------- tools/xenstore/xenstored_core.c | 91 +++---------------------------------------------------------------------- 10 files changed, 7 insertions(+), 239 deletions(-) delete mode 100644 tools/hotplug/Linux/systemd/xenstored.socket.in delete mode 100644 tools/hotplug/Linux/systemd/xenstored_ro.socket.in --- a/tools/configure.ac +++ b/tools/configure.ac @@ -11,26 +11,24 @@ hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/systemd/proc-xen.mount hotplug/Linux/systemd/var-lib-xenstored.mount hotplug/Linux/systemd/xen-init-dom0.service hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service hotplug/Linux/systemd/xen-watchdog.service hotplug/Linux/systemd/xenconsoled.service hotplug/Linux/systemd/xendomains.service hotplug/Linux/systemd/xenstored.service -hotplug/Linux/systemd/xenstored.socket -hotplug/Linux/systemd/xenstored_ro.socket hotplug/Linux/vif-setup hotplug/Linux/xen-backend.rules hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons ]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([../]) # Check if CFLAGS, LDFLAGS, LIBS, CPPFLAGS or CPP is set and print a warning AS_IF([test -n "$CC$CFLAGS$LDFLAGS$LIBS$CPPFLAGS$CPP"], [ --- a/tools/hotplug/Linux/systemd/Makefile +++ b/tools/hotplug/Linux/systemd/Makefile @@ -1,47 +1,42 @@ XEN_ROOT = $(CURDIR)/../../../.. include $(XEN_ROOT)/tools/Rules.mk XEN_SYSTEMD_MODULES = xen.conf XEN_SYSTEMD_MOUNT = proc-xen.mount XEN_SYSTEMD_MOUNT += var-lib-xenstored.mount -XEN_SYSTEMD_SOCKET = xenstored.socket -XEN_SYSTEMD_SOCKET += xenstored_ro.socket - XEN_SYSTEMD_SERVICE = xenstored.service XEN_SYSTEMD_SERVICE += xenconsoled.service XEN_SYSTEMD_SERVICE += xen-qemu-dom0-disk-backend.service XEN_SYSTEMD_SERVICE += xendomains.service XEN_SYSTEMD_SERVICE += xen-watchdog.service XEN_SYSTEMD_SERVICE += xen-init-dom0.service ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_MOUNT) \ - $(XEN_SYSTEMD_SOCKET) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all all: $(ALL_XEN_SYSTEMD) .PHONY: clean clean: rm -f $(XEN_SYSTEMD_MODULES) .PHONY: install install: $(ALL_XEN_SYSTEMD) [ -d $(DESTDIR)$(XEN_SYSTEMD_DIR) ] || \ $(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_DIR) [ -d $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD) ] || \ $(INSTALL_DIR) $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD) - $(INSTALL_DATA) *.socket $(DESTDIR)$(XEN_SYSTEMD_DIR) $(INSTALL_DATA) *.service $(DESTDIR)$(XEN_SYSTEMD_DIR) $(INSTALL_DATA) *.mount $(DESTDIR)$(XEN_SYSTEMD_DIR) $(INSTALL_DATA) *.conf $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD) $(XEN_SYSTEMD_MODULES): rm -f $@.tmp for mod in $(LINUX_BACKEND_MODULES) ; do \ echo $$mod ; \ done > $@.tmp $(call move-if-changed,$@.tmp,$@) --- a/tools/hotplug/Linux/systemd/xenstored.service.in +++ b/tools/hotplug/Linux/systemd/xenstored.service.in @@ -1,24 +1,25 @@ [Unit] Description=The Xen xenstore -Requires=xenstored_ro.socket xenstored.socket proc-xen.mount var-lib-xenstored.mount +Requires=proc-xen.mount var-lib-xenstored.mount After=proc-xen.mount var-lib-xenstored.mount Before=libvirtd.service libvirt-guests.service RefuseManualStop=true ConditionPathExists=/proc/xen/capabilities [Service] Type=notify +NotifyAccess=all +RemainAfterExit=true KillMode=none Environment=XENSTORED_ARGS= Environment=XENSTORED=@XENSTORED@ EnvironmentFile=-@CONFIG_DIR@/@CONFIG_LEAF_DIR@/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" [Install] WantedBy=multi-user.target -Also=xenstored_ro.socket xenstored.socket Also=proc-xen.mount Also=var-lib-xenstored.mount deleted file mode 100644 --- a/tools/hotplug/Linux/systemd/xenstored.socket.in +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=xenstore socket -Requires=proc-xen.mount var-lib-xenstored.mount -After=proc-xen.mount var-lib-xenstored.mount -ConditionPathExists=/proc/xen/capabilities - -[Socket] -ListenStream=/var/run/xenstored/socket -SocketMode=0600 -Service=xenstored.service - -[Install] -WantedBy=sockets.target deleted file mode 100644 --- a/tools/hotplug/Linux/systemd/xenstored_ro.socket.in +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=xenstore ro socket -Requires=proc-xen.mount var-lib-xenstored.mount -After=proc-xen.mount var-lib-xenstored.mount -ConditionPathExists=/proc/xen/capabilities - -[Socket] -ListenStream=/var/run/xenstored/socket_ro -SocketMode=0660 -Service=xenstored.service - -[Install] -WantedBy=sockets.target --- a/tools/ocaml/xenstored/systemd.ml +++ b/tools/ocaml/xenstored/systemd.ml @@ -3,15 +3,13 @@ * * 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" --- a/tools/ocaml/xenstored/systemd.mli +++ b/tools/ocaml/xenstored/systemd.mli @@ -3,22 +3,14 @@ * * 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" --- a/tools/ocaml/xenstored/systemd_stubs.c +++ b/tools/ocaml/xenstored/systemd_stubs.c @@ -17,136 +17,38 @@ #include <stdbool.h> #include <errno.h> #include <caml/mlvalues.h> #include <caml/memory.h> #include <caml/alloc.h> #include <caml/custom.h> #include <caml/signals.h> #include <caml/fail.h> #include <config.h> #if defined(HAVE_SYSTEMD) -#include <sys/socket.h> #include <systemd/sd-daemon.h> -/* Will work regardless of the order systemd gives them to us */ -static int oxen_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; -} - -static int oxen_verify_socket_socket(const char *connect_to) -{ - if ((strcmp("/var/run/xenstored/socket_ro", connect_to) != 0) && - (strcmp("/var/run/xenstored/socket", connect_to) != 0)) { - sd_notifyf(0, "STATUS=unexpected socket: %s\n" - "ERRNO=%i", - connect_to, - EBADR); - return -EBADR; - } - - return oxen_get_sd_fd(connect_to); -} - -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); - caml_failwith("ocaml_sd_listen_fds() mismatch"); - } - - sock = oxen_verify_socket_socket(String_val(connect_to)); - if (sock <= 0) { - fprintf(stderr, "failed to verify sock %s\n", - String_val(connect_to)); - caml_failwith("ocaml_sd_listen_fds_init() invalid socket"); - } - - sock_ret = Val_int(sock); - - CAMLreturn(sock_ret); -} - -CAMLprim value ocaml_sd_booted(value ignore) -{ - CAMLparam1(ignore); - CAMLlocal1(ret); - - ret = Val_false; - - if (sd_booted()) - ret = Val_true; - - CAMLreturn(ret); -} - CAMLprim value ocaml_sd_notify_ready(value ignore) { CAMLparam1(ignore); CAMLlocal1(ret); ret = Val_int(0); sd_notify(1, "READY=1"); CAMLreturn(ret); } #else -CAMLprim value ocaml_sd_listen_fds(value connect_to) -{ - CAMLparam1(connect_to); - CAMLlocal1(sock_ret); - - sock_ret = Val_int(-1); - - CAMLreturn(sock_ret); -} - -CAMLprim value ocaml_sd_booted(value ignore) -{ - CAMLparam1(ignore); - CAMLlocal1(ret); - - ret = Val_false; - - CAMLreturn(ret); -} - CAMLprim value ocaml_sd_notify_ready(value ignore) { CAMLparam1(ignore); CAMLlocal1(ret); ret = Val_int(-1); CAMLreturn(ret); } #endif --- a/tools/ocaml/xenstored/utils.ml +++ b/tools/ocaml/xenstored/utils.ml @@ -64,40 +64,33 @@ let unhexify hs = s let trim_path path = try let rindex = String.rindex path '/' in String.sub path 0 rindex with Not_found -> "" let join_by_null ls = String.concat "\000" ls (* unix utils *) -let create_regular_unix_socket name = +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.set_close_on_exec sock; Unix.bind sock sockaddr; Unix.listen sock 1; sock -let create_unix_socket name = - 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 let buf = String.make 20 (char_of_int 0) in let sz = Unix.read fd buf 0 20 in Unix.close fd; int_of_string (String.sub buf 0 sz) let path_complete path connection_path = if String.get path 0 <> '/' then connection_path ^ path else path --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1726,93 +1726,24 @@ static void init_sockets(int **psock, int **pro_sock) { static int minus_one = -1; *psock = *pro_sock = &minus_one; } #else static int destroy_fd(void *_fd) { int *fd = _fd; close(*fd); return 0; } -#if defined(XEN_SYSTEMD_ENABLED) -/* Will work regardless of the order systemd gives them to us */ -static 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; -} - -static int xs_validate_active_socket(const char *connect_to) -{ - if ((strcmp("/var/run/xenstored/socket_ro", connect_to) != 0) && - (strcmp("/var/run/xenstored/socket", connect_to) != 0)) { - sd_notifyf(0, "STATUS=unexpected socket: %s\n" - "ERRNO=%i", - connect_to, - EBADR); - return -EBADR; - } - - return xs_get_sd_fd(connect_to); -} - -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; int *sock, *ro_sock; const char *soc_str = xs_daemon_socket(); const char *soc_str_ro = xs_daemon_socket_ro(); /* Create sockets for them to listen to. */ *psock = sock = talloc(talloc_autofree_context(), int); *sock = socket(PF_UNIX, SOCK_STREAM, 0); if (*sock < 0) barf_perror("Could not create socket"); @@ -1965,60 +1896,46 @@ int main(int argc, char *argv[]) break; case 'm': dom0_domid = strtol(optarg, NULL, 10); break; case 'p': priv_domid = strtol(optarg, NULL, 10); break; } } 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 */ /* Errors ignored here, will be reported when we open files */ mkdir(xs_daemon_rundir(), 0755); mkdir(xs_daemon_rootdir(), 0755); if (dofork) { openlog("xenstored", 0, LOG_DAEMON); daemonize(); } if (pidfile) write_pidfile(pidfile); /* Talloc leak reports go to stderr, which is closed if we fork. */ if (!dofork) talloc_enable_leak_report_full(); /* Don't kill us with SIGPIPE. */ signal(SIGPIPE, SIG_IGN); -#if defined(XEN_SYSTEMD_ENABLED) - if (sd_booted()) - xen_claim_active_sockets(&sock, &ro_sock); - else -#endif - init_sockets(&sock, &ro_sock); + init_sockets(&sock, &ro_sock); init_pipe(reopen_log_pipe); /* Setup the database */ setup_structure(); /* Listen to hypervisor. */ if (!no_domain_init) domain_init(); /* Restore existing connections. */ restore_existing_connections(); @@ -2033,28 +1950,26 @@ int main(int argc, char *argv[]) finish_daemonize(); signal(SIGHUP, trigger_reopen_log); /* Get ready to listen to the tools. */ initialize_fds(*sock, &sock_pollfd_idx, *ro_sock, &ro_sock_pollfd_idx, &timeout); /* 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"); - } + sd_notify(1, "READY=1"); + fprintf(stderr, SD_NOTICE "xenstored is ready\n"); #endif /* Main loop. */ for (;;) { struct connection *conn, *next; if (poll(fds, nr_fds, timeout) < 0) { if (errno == EINTR) continue; barf_perror("Poll failed"); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor