Skip to contentSkip to conversation

xen: add systemd files

PATCH Superseded Luis R. Rodriguez 6 participants 37 messages Mar 19, 2014 – Apr 28, 2014 Kbuild

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v2 cover xen: add systemd files

From: "Luis R. Rodriguez" <[email protected]>

This adds systemd files to xen based on the last discussions from the initial attempt. Its best we all work on these upstream rather than chugging on our own. It addresses the meta variable changes for paths and also adds a lot more service files / mount / modules socket files missing. In order to match the existing init script behaviour I also added a small retry socket helper to xenstore-read. We may be able to just rely on systemd's socket monitor instead of the xenstore-read -l but we keep it as-is for now.

As discussed I ended up moving the old LSB init script for xendomains to sbin to share it with systemd and created a simple wrapper for init. The new wrapper gets a new -init postfix to distinguish it but also to help enable us to keep the history of the original file after the move within git.

Luis R. Rodriguez (7):
xenstore-read: add support for a retry open limit on xenstored
xencommons: use the retry limit instead of implementing our own
timeout
tools/xendomains: make xl the default tools/xendomains: remove old redhat check tools/xendomains: do space cleanups
tools/xendomains: move to sbin and use init helper
systemd: add support initial xen systemd service files

 .gitignore                                         |  5 ++
 Config.mk                                          |  9 ++-
 Makefile                                           | 11 ++-
 config/StdGNU.mk                                   |  4 +
 tools/hotplug/Linux/Makefile                       | 13 +++-
 tools/hotplug/Linux/init.d/xencommons              | 19 ++---
 tools/hotplug/Linux/init.d/xendomains-init         | 33 +++++++++
 tools/hotplug/Linux/systemd/Makefile               | 72 ++++++++++++++++++
 tools/hotplug/Linux/systemd/oxenstored.service.in  | 23 ++++++
 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 ++++
 .../Linux/systemd/xen.conf.modules-load.d.in       | 16 ++++
 tools/hotplug/Linux/systemd/xenconsoled.service.in | 20 +++++
 tools/hotplug/Linux/systemd/xendomains.service.in  | 16 ++++
 tools/hotplug/Linux/systemd/xenstored.service.in   | 24 ++++++
 tools/hotplug/Linux/systemd/xenstored.socket.in    |  9 +++
 tools/hotplug/Linux/{init.d => }/xendomains        | 86 ++++++++++------------
 tools/xenstore/xenstore_client.c                   | 31 ++++++--
 20 files changed, 373 insertions(+), 75 deletions(-)
 create mode 100644 tools/hotplug/Linux/init.d/xendomains-init
 create mode 100644 tools/hotplug/Linux/systemd/Makefile
 create mode 100644 tools/hotplug/Linux/systemd/oxenstored.service.in
 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/xen.conf.modules-load.d.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
 rename tools/hotplug/Linux/{init.d => }/xendomains (92%)
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

PATCH v2 1/7 xenstore-read: add support for a retry open limit on xenstored

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/xenstore/xenstore_client.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
tools/xenstore/xenstore_client.c +25 -6
index 0ec103f..87972b7 100644
@@ -77,7 +77,8 @@ usage(enum mode mode, int incl_mode, const char *progname)
 	errx(1, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s] [ -l <num_open_tries> ] key [...]",
+	     progname, mstr);
     case MODE_write:
 	mstr = incl_mode ? "write " : "";
 	errx(1, "Usage: %s %s[-h] [-s] key value [...]", progname, mstr);
@@ -493,9 +494,9 @@ static enum mode lookup_mode(const char *m)
 int
 main(int argc, char **argv)
 {
-    struct xs_handle *xsh;
+    struct xs_handle *xsh = NULL;
     xs_transaction_t xth = XBT_NULL;
-    int ret = 0, socket = 0;
+    int ret = 0, socket = 0, limit = 1, open_tries;
     int prefix = 0;
     int tidy = 0;
     int upto = 0;
@@ -535,10 +536,11 @@ main(int argc, char **argv)
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
 	    {"recurse", 0, 0, 'r'}, /* MODE_chmod */
 	    {"number",  1, 0, 'n'}, /* MODE_watch */
+	    {"limit",   1, 0, 'l'}, /* MODE_read */
 	    {0, 0, 0, 0}
 	};
 
-	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:",
+	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:l:",
 			long_options, &index);
 	if (c == -1)
 	    break;
@@ -589,6 +591,16 @@ main(int argc, char **argv)
 	    else
 		usage(mode, switch_argv, argv[0]);
 	    break;
+	case 'l':
+	    if (mode == MODE_read)
+		limit = atoi(optarg);
+	    else
+		usage(mode, switch_argv, argv[0]);
+	    if (limit < 0) {
+		limit = 1;
+		usage(mode, switch_argv, argv[0]);
+	    }
+	    break;
 	}
     }
 
@@ -632,8 +644,15 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
-    if (xsh == NULL) err(1, "xs_open");
+    for (open_tries = 0; open_tries < limit; open_tries++) {
+	    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+	    if (xsh)
+		    break;
+	    if (limit > 1)
+		    sleep(1);
+    }
+    if (!xsh)
+	    err(1, "xs_open");
 
 again:
     if (transaction) {
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Quoted 15 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
Quoted 2 lines
---
 tools/xenstore/xenstore_client.c | 31 +++++++++++++++++++++++++------

Please update docs/man/xenstore* too.

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 539

Quoted 5 lines
tools/xenstore/xenstore_client.c +1 -0
@@ -535,10 +536,11 @@ main(int argc, char **argv)
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
 	    {"recurse", 0, 0, 'r'}, /* MODE_chmod */
 	    {"number",  1, 0, 'n'}, /* MODE_watch */
+	    {"limit",   1, 0, 'l'}, /* MODE_read */

Limit is an odd name for this options, --retries seems more plausible.

Since this only impacts the xc_open, is there any reason to limit it to read? I might want to retry on any of the operations.

Quoted 9 lines
tools/xenstore/xenstore_client.c +1 -1
 	    {0, 0, 0, 0}
 	};
 
-	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:",
+	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:l:",
 			long_options, &index);
 	if (c == -1)
 	    break;

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 600

Quoted 10 lines
tools/xenstore/xenstore_client.c +7 -0
@@ -589,6 +591,16 @@ main(int argc, char **argv)
 	    else
 		usage(mode, switch_argv, argv[0]);
 	    break;
+	case 'l':
+	    if (mode == MODE_read)
+		limit = atoi(optarg);
+	    else
+		usage(mode, switch_argv, argv[0]);
+	    if (limit < 0) {
+		limit = 1;

Pointless?

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 635

Quoted 11 lines
tools/xenstore/xenstore_client.c +3 -1
+		usage(mode, switch_argv, argv[0]);
+	    }
+	    break;
 	}
     }
 
@@ -632,8 +644,15 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);

It occurs to me that retrying might be incompatible with the ring base (i.e. non-socket) method of talking to xenstored. Harmless to retry though I suppose.

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 647

Quoted 2 lines
tools/xenstore/xenstore_client.c +1 -1
-    if (xsh == NULL) err(1, "xs_open");
+    for (open_tries = 0; open_tries < limit; open_tries++) {

"while(limit--)" (well, retries--) and the adjustments inside the loop which this implies would be more natural I think.

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 658

Quoted 11 lines
tools/xenstore/xenstore_client.c +8 -0
+	    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+	    if (xsh)
+		    break;
+	    if (limit > 1)
+		    sleep(1);
+    }
+    if (!xsh)
+	    err(1, "xs_open");
 
 again:
     if (transaction) {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Ian Campbell writes ("Re: [Xen-devel] [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored"):

Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Surely the advantage of fancy new init systems is that we don't have to have sleeps and polling in our startup scripts ?

Ian.

#4 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Quoted 11 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored"):

Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Surely the advantage of fancy new init systems is that we don't have to have sleeps and polling in our startup scripts ?

It was unclear to me from the systemd documentation *exactly* what the socket service file would do with regards to letting systemd claim it has completed so although I was hoping for what you wrote I was unable to confirm it and as such I think we can leave it in the systemd respective scripts for now. The retry open limit thing could still be used to simplify the old LSB scripts.

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

In reply to Ian Campbell
Quoted 19 lines · Ian Campbell
Quoted 15 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
Quoted 2 lines
---
 tools/xenstore/xenstore_client.c | 31 +++++++++++++++++++++++++------
Quoted 1 line

Please update docs/man/xenstore* too.

docs/man/xenstore.pod.1 has no documentation yet on any arguments passed. I can't see why this would be a requirement for -l if none of the others are documented yet. Documenting only one argument would likely be pretty confusing.

Quoted 7 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 539

Quoted 5 lines
tools/xenstore/xenstore_client.c +1 -0
@@ -535,10 +536,11 @@ main(int argc, char **argv)
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
 	    {"recurse", 0, 0, 'r'}, /* MODE_chmod */
 	    {"number",  1, 0, 'n'}, /* MODE_watch */
+	    {"limit",   1, 0, 'l'}, /* MODE_read */

Limit is an odd name for this options, --retries seems more plausible.

--retries is perfect but the --recurse option takes on the -r smaller version flag so I went with that. Let me know how you'd like to proceed. I'd prefer to call it --socket-retries as that would remove ambiguation from ioctl() open retries or transaaction retries, etc, but again, s is taken for socket only mode.

Quoted 2 lines

Since this only impacts the xc_open, is there any reason to limit it to read? I might want to retry on any of the operations.

Technically no, we need to open the socket for any other mode of operation.

Quoted 13 lines
Quoted 13 lines
tools/xenstore/xenstore_client.c +2 -1
 	    {0, 0, 0, 0}
 	};
 
-	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:",
+	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:l:",
 			long_options, &index);
 	if (c == -1)
 	    break;
@@ -589,6 +591,16 @@ main(int argc, char **argv)
 	    else
 		usage(mode, switch_argv, argv[0]);
 	    break;
+	case 'l':
Quoted 8 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 600

Quoted 6 lines
tools/xenstore/xenstore_client.c +6 -0
+	    if (mode == MODE_read)
+		limit = atoi(optarg);
+	    else
+		usage(mode, switch_argv, argv[0]);
+	    if (limit < 0) {
+		limit = 1;

Pointless?

No, limit is an int, so it can be negative. That implies nr_watches could be negative as it didn't have this check, I can add that if you like as part of my series. Fortunately I see no issues with a negative nr_watches though as in the loop that its used it will always be less than 0, so a fix technically wouldn't do anything, but it would be correct to add it.

Quoted 10 lines
Quoted 10 lines
tools/xenstore/xenstore_client.c +3 -0
+		usage(mode, switch_argv, argv[0]);
+	    }
+	    break;
 	}
     }
 
@@ -632,8 +644,15 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
Quoted 5 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 635

Quoted 1 line
tools/xenstore/xenstore_client.c +0 -1
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);

It occurs to me that retrying might be incompatible with the ring base (i.e. non-socket) method of talking to xenstored. Harmless to retry though I suppose.

How so, I mean, if it can only succeed or not, and if it didn't I don't see how retrying to open the same path would be incompatible?

Quoted 4 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 647

Quoted 2 lines
tools/xenstore/xenstore_client.c +1 -1
-    if (xsh == NULL) err(1, "xs_open");
+    for (open_tries = 0; open_tries < limit; open_tries++) {

"while(limit--)" (well, retries--)

Yeah that saves us an int.

Quoted 2 lines

and the adjustments inside the loop
which this implies would be more natural I think.

Which adjustment? If you mean the branch check on if (limit > 1) -- that is still needed otherwise we sleep(1) even if it worked.

Quoted 9 lines
Quoted 9 lines
tools/xenstore/xenstore_client.c +8 -0
+	    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+	    if (xsh)
+		    break;
+	    if (limit > 1)
+		    sleep(1);
+    }
+    if (!xsh)
+	    err(1, "xs_open");
 
Quoted 5 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 658

Quoted 2 lines
tools/xenstore/xenstore_client.c +0 -0
 again:
     if (transaction) {

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Quoted 20 lines · Luis R. Rodriguez
Quoted 19 lines · Ian Campbell
Quoted 17 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/xenstore/xenstore_client.c | 31 +++++++++++++++++++++++++------
Quoted 6 lines
Quoted 1 line

Please update docs/man/xenstore* too.

docs/man/xenstore.pod.1 has no documentation yet on any arguments passed. I can't see why this would be a requirement for -l if none of the others are documented yet. Documenting only one argument would likely be pretty confusing.

We have to start somewhere and the policy is to try not to make things worse.

(obviously if you want to document some of the other options then feel free, it would be most appreciated, but I'll only insist on the new one)

Quoted 8 lines
Quoted 7 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 539

Quoted 5 lines
tools/xenstore/xenstore_client.c +1 -0
@@ -535,10 +536,11 @@ main(int argc, char **argv)
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
 	    {"recurse", 0, 0, 'r'}, /* MODE_chmod */
 	    {"number",  1, 0, 'n'}, /* MODE_watch */
+	    {"limit",   1, 0, 'l'}, /* MODE_read */

Limit is an odd name for this options, --retries seems more plausible.

Quoted 5 lines

--retries is perfect but the --recurse option takes on the -r smaller version flag so I went with that. Let me know how you'd like to proceed. I'd prefer to call it --socket-retries as that would remove ambiguation from ioctl() open retries or transaaction retries, etc, but again, s is taken for socket only mode.

I think it would be fine to have this option be a long-option only one, its mainly for a pretty specific use case.

Quoted 27 lines
Quoted 2 lines

Since this only impacts the xc_open, is there any reason to limit it to read? I might want to retry on any of the operations.

Technically no, we need to open the socket for any other mode of operation.

Quoted 13 lines
Quoted 13 lines
tools/xenstore/xenstore_client.c +2 -1
 	    {0, 0, 0, 0}
 	};
 
-	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:",
+	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:l:",
 			long_options, &index);
 	if (c == -1)
 	    break;
@@ -589,6 +591,16 @@ main(int argc, char **argv)
 	    else
 		usage(mode, switch_argv, argv[0]);
 	    break;
+	case 'l':
Quoted 8 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 600

Quoted 6 lines
tools/xenstore/xenstore_client.c +6 -0
+	    if (mode == MODE_read)
+		limit = atoi(optarg);
+	    else
+		usage(mode, switch_argv, argv[0]);
+	    if (limit < 0) {
+		limit = 1;

Pointless?

Quoted 1 line

No, limit is an int, so it can be negative.

I meant the assignment, not the if. Since the next thing you do is call usage() which always exits.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
tools/xenstore/xenstore_client.c +3 -0
+		usage(mode, switch_argv, argv[0]);
+	    }
+	    break;
 	}
     }
 
@@ -632,8 +644,15 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
Quoted 8 lines
Quoted 5 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 635

Quoted 1 line
tools/xenstore/xenstore_client.c +0 -1
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);

It occurs to me that retrying might be incompatible with the ring base (i.e. non-socket) method of talking to xenstored. Harmless to retry though I suppose.

How so, I mean, if it can only succeed or not, and if it didn't I don't see how retrying to open the same path would be incompatible?

IIRC opening (or maybe using) the ring based interface while the daemon isn't running will hang not fail. But retrying is rather moot in that case.

Quoted 5 lines
Quoted 4 lines

tools/xenstore/xenstore_client.c main(int argc, char **argv) · line 647

Quoted 2 lines
tools/xenstore/xenstore_client.c +1 -1
-    if (xsh == NULL) err(1, "xs_open");
+    for (open_tries = 0; open_tries < limit; open_tries++) {

"while(limit--)" (well, retries--)

Quoted 7 lines

Yeah that saves us an int.

Quoted 2 lines

and the adjustments inside the loop
which this implies would be more natural I think.

Which adjustment? If you mean the branch check on if (limit > 1) -- that is still needed otherwise we sleep(1) even if it worked.

I meant any necessary adjustments implied by changing from a for over open_tries to a while over limit, maybe there aren't any, or maybe that if (limit) sleep needs adjusting I wasn't sure.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

In reply to Luis R. Rodriguez
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

This seems odd. Surely the point of systemd is that you only start services once their dependencies are up? It doesn't seem right to have a service poll for another.

Quoted 18 lines
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/xenstore/xenstore_client.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
tools/xenstore/xenstore_client.c +0 -0
index 0ec103f..87972b7 100644

tools/xenstore/xenstore_client.c usage(enum mode mode, int incl_mode, const char *progname) · line 81

Quoted 6 lines
tools/xenstore/xenstore_client.c +2 -1
@@ -77,7 +77,8 @@ usage(enum mode mode, int incl_mode, const char *progname)
 	errx(1, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s] [ -l <num_open_tries> ] key [...]",
+	     progname, mstr);

The command line option would be better as a time out value (in seconds).

David

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Quoted 9 lines · David Vrabel
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Quoted 3 lines

This seems odd. Surely the point of systemd is that you only start services once their dependencies are up? It doesn't seem right to have a service poll for another.

Isn't this trying to decide when xenstored is up, for use in the xenstored.service itself?

But now I think of it -- isn't this exactly what the socket activation stuff is for?

Ian.

#9 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Quoted 14 lines · Ian Campbell
Quoted 9 lines · David Vrabel
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Quoted 3 lines

This seems odd. Surely the point of systemd is that you only start services once their dependencies are up? It doesn't seem right to have a service poll for another.

Quoted 5 lines

Isn't this trying to decide when xenstored is up, for use in the xenstored.service itself?

But now I think of it -- isn't this exactly what the socket activation stuff is for?

Strangely enough the socket file gets systemd to kick off the socket prior to xenstored activation, I was baffled by this and since the documentation is shy about the details I could not trust what I assumed and everyone else is assuming systemd *should* be doing. We'll have to dive into the code and verify before knowing for sure we won't let through an attempt to access xenstored without the old legacy retry.

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

Quoted 15 lines · Luis R. Rodriguez
Quoted 14 lines · Ian Campbell
Quoted 12 lines · David Vrabel
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

This seems odd. Surely the point of systemd is that you only start services once their dependencies are up? It doesn't seem right to have a service poll for another.

Quoted 8 lines
Quoted 5 lines

Isn't this trying to decide when xenstored is up, for use in the xenstored.service itself?

But now I think of it -- isn't this exactly what the socket activation stuff is for?

Strangely enough the socket file gets systemd to kick off the socket prior to xenstored activation, I was baffled by this

My understanding was that this was the whole point.

Quoted 5 lines

and since the
documentation is shy about the details I could not trust what I assumed and everyone else is assuming systemd *should* be doing. We'll have to dive into the code and verify before knowing for sure we won't let through an attempt to access xenstored without the old legacy retry.

Right, please can you confirm with someone who understands systemd socket activation what we should be doing here instead of guessing.

Ian.

#11 lore raw

Re: [PATCH v2 1/7] xenstore-read: add support for a retry open limit on xenstored

In reply to David Vrabel
Quoted 9 lines · David Vrabel
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This adds support for a customizable retry limit on trying to open the xenstored, each retry is separated by 1 second. This should allow us to simplify both our LSB init scripts and eventually our systemd service files for starting the xenstored.

Quoted 3 lines

This seems odd. Surely the point of systemd is that you only start services once their dependencies are up? It doesn't seem right to have a service poll for another.

I was unable to verify the dogs will be let loose only once a service which claims a socket is available, so I left the check for now but I think once we do confirm this we should remove it. This retry is also useful for the old LSB scripts though too, it just shaves off of the existing shell script.

Quoted 5 lines
Quoted 5 lines
tools/xenstore/xenstore_client.c +0 -0
index 0ec103f..87972b7 100644
@@ -77,7 +77,8 @@ usage(enum mode mode, int incl_mode, const char *progname)
Quoted 8 lines

tools/xenstore/xenstore_client.c usage(enum mode mode, int incl_mode, const char *progname) · line 81

Quoted 6 lines
tools/xenstore/xenstore_client.c +2 -1
 	errx(1, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s] [ -l <num_open_tries> ] key [...]",
+	     progname, mstr);

The command line option would be better as a time out value (in seconds).

-t for "tidy" is taken, let me know what you guys decide for preference.

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#12 lore raw

PATCH v2 2/7 xencommons: use the retry limit instead of implementing our own timeout

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

xenstore-read now has support to retry opening the xenstored a certain amount of times, once each second, use that instead of implementing our own timeout.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/hotplug/Linux/init.d/xencommons | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
tools/hotplug/Linux/init.d/xencommons +5 -14
index 4ebd636..68d874e 100644
@@ -54,9 +54,6 @@ if test -f /proc/xen/capabilities && \
 fi
 
 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
@@ -93,17 +90,11 @@ do_start () {
 		    echo "No xenstored found"
 		    exit 1
 		fi
-
-		# Wait for xenstored to actually come up, timing out after 30 seconds
-                while [ $time -lt $timeout ] && ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1` ; do
-                    echo -n .
-		    time=$(($time+1))
-                    sleep 1
-                done
-		echo
-
-		# Exit if we timed out
-		if ! [ $time -lt $timeout ] ; then
+		# We try opening the xenstored socket every second up to the
+		# limit specified, if it hasn't opened by then assume
+		# failure.
+                ${BINDIR}/xenstore-read -l 30 -s / >/dev/null 2>&1
+		if [ $? -ne 0 ] ; then
 		    echo Could not start xenstored
 		    exit 1
 		fi
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v2 2/7
#13 lore raw

Re: [PATCH v2 2/7] xencommons: use the retry limit instead of implementing our own timeout

tools/hotplug/Linux/init.d/xencommons do_start () { · line 97

Quoted 5 lines · Luis R. Rodriguez
tools/hotplug/Linux/init.d/xencommons +5 -0
+		# We try opening the xenstored socket every second up to the
+		# limit specified, if it hasn't opened by then assume
+		# failure.
+                ${BINDIR}/xenstore-read -l 30 -s / >/dev/null 2>&1
+		if [ $? -ne 0 ] ; then

Mixture of hard and soft tabs? Other than that,

#14 lore raw

PATCH v2 3/7 tools/xendomains: make xl the default

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

If that fails backoff to using xm.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/hotplug/Linux/init.d/xendomains | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/hotplug/Linux/init.d/xendomains +4 -4
index 59f1e3d..6cb1032 100644
@@ -29,13 +29,13 @@
 
 . /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"
+	CMD=${SBINDIR}/xm
+	HEADCOMP="LinuxGuestRecord"
 fi
 
 $CMD list &> /dev/null
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v2 3/7
#15 lore raw

Re: [PATCH v2 3/7] tools/xendomains: make xl the default

Quoted 3 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

If that fails backoff to using xm.

Good idea.

Quoted 9 lines
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#16 lore raw

PATCH v2 4/7 tools/xendomains: remove old redhat check

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Fedora already changes their script to skip this check, so just fold these upstream already to the more LSB compliant set.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/hotplug/Linux/init.d/xendomains | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
tools/hotplug/Linux/init.d/xendomains +1 -13
index 6cb1032..fac85ba 100644
@@ -84,19 +84,7 @@ else
 	_SMSG=(done failed failed missed failed skipped unused failed failed)
 	_RC_UNUSED=6
     fi
-    if test -e /etc/init.d/functions; then
-	# REDHAT
-	. /etc/init.d/functions
-	echo_rc()
-	{
-	    #echo -n "  [${_SMSG[${_RC_RV}]}] "
-	    if test ${_RC_RV} = 0; then
-		success "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		failure "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	}
-    elif test -e /lib/lsb/init-functions; then
+    if test -e /lib/lsb/init-functions; then
 	# LSB    
     	. /lib/lsb/init-functions
         if alias log_success_msg >/dev/null 2>/dev/null; then
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#17 lore raw

Re: [PATCH v2 4/7] tools/xendomains: remove old redhat check

Quoted 4 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Fedora already changes their script to skip this check, so just fold these upstream already to the more LSB compliant set.

We still care (at least a little) about RHEL5 hosts I think, and we certainly care about RHEL6, so this needs confirming for more than Fedora.

#18 lore raw

Re: [PATCH v2 4/7] tools/xendomains: remove old redhat check

Quoted 9 lines · Ian Campbell
Quoted 4 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Fedora already changes their script to skip this check, so just fold these upstream already to the more LSB compliant set.

We still care (at least a little) about RHEL5 hosts I think, and we certainly care about RHEL6, so this needs confirming for more than Fedora.

OK -- I'll drop this from my series.

Luis

#19 lore raw

PATCH v2 5/7 tools/xendomains: do space cleanups

In reply to Luis R. Rodriguez

From: "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.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/hotplug/Linux/init.d/xendomains | 64 +++++++++++++++++------------------
 1 file changed, 32 insertions(+), 32 deletions(-)
tools/hotplug/Linux/init.d/xendomains +32 -32
index fac85ba..3d68e07 100644
@@ -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
 
@@ -44,7 +44,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
@@ -74,7 +74,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
@@ -85,8 +85,8 @@ else
 	_RC_UNUSED=6
     fi
     if test -e /lib/lsb/init-functions; then
-	# LSB    
-    	. /lib/lsb/init-functions
+	# LSB
+	. /lib/lsb/init-functions
         if alias log_success_msg >/dev/null 2>/dev/null; then
 	  echo_rc()
 	  {
@@ -102,7 +102,7 @@ else
 	    fi
 	  }
         fi
-    else    
+    else
 	# emulate it
 	echo_rc()
 	{
@@ -112,17 +112,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 $?
@@ -134,7 +134,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
@@ -181,13 +181,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
@@ -220,7 +220,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
 		;;
@@ -229,11 +229,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=" "
@@ -273,10 +273,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##*/}"
@@ -337,14 +337,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
@@ -368,7 +368,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
@@ -401,7 +401,7 @@ stop()
 		kill $WDOG_PID >/dev/null 2>&1
 	    else
 		kill $WDOG_PID >/dev/null 2>&1
-		
+
 		echo -e .
 		usleep 1000
 		continue
@@ -460,7 +460,7 @@ stop()
 
     # Unconditionally delete lock file
     rm -f $LOCKFILE
-    
+
     exec 2>&3
 }
 
@@ -470,7 +470,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
 		;;
@@ -489,9 +489,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
@@ -504,7 +504,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
@@ -551,8 +551,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
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v2 5/7
#20 lore raw

Re: [PATCH v2 5/7] tools/xendomains: do space cleanups

Quoted 5 lines · Luis R. Rodriguez

From: "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.

Quoted 7 lines
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>

Taking it on trust that "git diff -b" would be silent:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#21 lore raw

PATCH v2 6/7 tools/xendomains: move to sbin and use init helper

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

The xendomains script can be resued 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 resue it.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/hotplug/Linux/Makefile                |  4 +++-
 tools/hotplug/Linux/init.d/xendomains-init  | 33 +++++++++++++++++++++++++++++
 tools/hotplug/Linux/{init.d => }/xendomains |  0
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 tools/hotplug/Linux/init.d/xendomains-init
 rename tools/hotplug/Linux/{init.d => }/xendomains (100%)
tools/hotplug/Linux/Makefile +3 -1
index 47655f6..0be2e8a 100644
@@ -3,7 +3,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 # Init scripts.
 XEND_INITD = init.d/xend
-XENDOMAINS_INITD = init.d/xendomains
+XENDOMAINS_INITD = init.d/xendomains-init
+XENDOMAINS_SBIN = xendomains
 XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
 
 XENCOMMONS_INITD = init.d/xencommons
@@ -50,6 +51,7 @@ install-initd:
 ifeq ($(CONFIG_XEND),y)
 	$(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(INITD_DIR)
 endif
+	$(INSTALL_PROG) $(XENDOMAINS_SBIN) $(DESTDIR)$(SBINDIR)
 	$(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-init new file +33 -0
new file mode 100644
index 0000000..da55932
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# /etc/init.d/xendomains-init
+#
+# wrapper for starting / stopping domains automatically when domain
+# 0 boots / shuts down on systems using init. The $SBINDIR/xendomains
+# helper is shared between init and systemd systems.
+#
+
+. /etc/xen/scripts/hotplugpath.sh
+
+case "$1" in
+    start)
+	$SBINDIR/xendomains start
+	;;
+    stop)
+	$SBINDIR/xendomains stop
+	;;
+    restart)
+	$SBINDIR/xendomains restart
+	;;
+    reload)
+	$SBINDIR/xendomains reload
+	;;
+    status)
+	$SBINDIR/xendomains status
+	;;
+    *)
+	echo "Usage: $0 {start|stop|restart|reload|status}"
+	exit 3
+	;;
+esac
+exit $?
tools/hotplug/Linux/xendomains renamed from tools/hotplug/Linux/init.d/xendomains +0 -0
similarity index 100%
rename from tools/hotplug/Linux/init.d/xendomains
rename to tools/hotplug/Linux/xendomains
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#22 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 1 line · Luis R. Rodriguez

+XENDOMAINS_SBIN = xendomains

I think this is not a user/admin callable binary, like many many other installed binaries. It should be in some libexec dir, outside of PATH.

Olaf

#23 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 6 lines · Olaf Hering
Quoted 1 line · Luis R. Rodriguez

+XENDOMAINS_SBIN = xendomains

I think this is not a user/admin callable binary, like many many other installed binaries. It should be in some libexec dir, outside of PATH.

Thanks for the review, will ammend as part of a new series.

Luis

#24 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

In reply to Luis R. Rodriguez
Quoted 3 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

The xendomains script can be resued with systemd systems as it

"reused"

Quoted 3 lines

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 resue it.

"reuse"

This strikes me as more of a $libexec thing, what to people think (or does anyone want to quote LSB at me)

Quoted 8 lines
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
Quoted 4 lines
---
 tools/hotplug/Linux/Makefile                |  4 +++-
 tools/hotplug/Linux/init.d/xendomains-init  | 33 +++++++++++++++++++++++++++++
 tools/hotplug/Linux/{init.d => }/xendomains |  0

For some reason we also have tools/hotplug/NetBSD/rc.d/xendomains. I presume there is a non-zero chance that it could call this new tool as well.

Quoted 9 lines
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 tools/hotplug/Linux/init.d/xendomains-init
 rename tools/hotplug/Linux/{init.d => }/xendomains (100%)
tools/hotplug/Linux/Makefile +0 -0
index 47655f6..0be2e8a 100644

tools/hotplug/Linux/Makefile include $(XEN_ROOT)/tools/Rules.mk · line 6

Quoted 5 lines
tools/hotplug/Linux/Makefile +1 -1
@@ -3,7 +3,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 # Init scripts.
 XEND_INITD = init.d/xend
-XENDOMAINS_INITD = init.d/xendomains
+XENDOMAINS_INITD = init.d/xendomains-init

The suffix is unnecessary given the directory, isn't it? Plus it avoids upgrade hassle by not changing the name of the initscript.

Quoted 18 lines
tools/hotplug/Linux/Makefile +2 -0
+XENDOMAINS_SBIN = xendomains
 XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
 
 XENCOMMONS_INITD = init.d/xencommons
@@ -50,6 +51,7 @@ install-initd:
 ifeq ($(CONFIG_XEND),y)
 	$(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(INITD_DIR)
 endif
+	$(INSTALL_PROG) $(XENDOMAINS_SBIN) $(DESTDIR)$(SBINDIR)
 	$(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-init new file +0 -0
new file mode 100644
index 0000000..da55932

tools/hotplug/Linux/init.d/xendomains-init line 7

Quoted 7 lines
tools/hotplug/Linux/init.d/xendomains-init new file +7 -0
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# /etc/init.d/xendomains-init
+#
+# wrapper for starting / stopping domains automatically when domain
+# 0 boots / shuts down on systems using init. The $SBINDIR/xendomains
+# helper is shared between init and systemd systems.

Shouldn't all the LSB headers from the original sit around here somewhere?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#25 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 4 lines · Ian Campbell
Quoted 1 line · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This strikes me as more of a $libexec thing, what to people think (or does anyone want to quote LSB at me)

I see two votes in a week, enough for me to use it, will ammend.

Quoted 13 lines
Quoted 8 lines
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
Quoted 4 lines
---
 tools/hotplug/Linux/Makefile                |  4 +++-
 tools/hotplug/Linux/init.d/xendomains-init  | 33 +++++++++++++++++++++++++++++
 tools/hotplug/Linux/{init.d => }/xendomains |  0
Quoted 3 lines

For some reason we also have tools/hotplug/NetBSD/rc.d/xendomains. I presume there is a non-zero chance that it could call this new tool as well.

I rather have someone with NetBSD verify and then make that change.

Quoted 10 lines
Quoted 10 lines
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 tools/hotplug/Linux/init.d/xendomains-init
 rename tools/hotplug/Linux/{init.d => }/xendomains (100%)
tools/hotplug/Linux/Makefile +0 -0
index 47655f6..0be2e8a 100644
@@ -3,7 +3,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 
Quoted 7 lines

tools/hotplug/Linux/Makefile include $(XEN_ROOT)/tools/Rules.mk · line 6

Quoted 4 lines
tools/hotplug/Linux/Makefile +1 -1
 # Init scripts.
 XEND_INITD = init.d/xend
-XENDOMAINS_INITD = init.d/xendomains
+XENDOMAINS_INITD = init.d/xendomains-init

The suffix is unnecessary given the directory, isn't it? Plus it avoids upgrade hassle by not changing the name of the initscript.

It does and I tried to use the same name but if one does a git mv of a file git adds that old file name and path to a temporary .gitignore requiring you to use git add -f on that file. It does this because if you insist you loose the history of the file after the move. Its also why I changed the name of this modified init.

If you don't want to keep the history I can move forward with a mv but the history will be lost. I did explain this in the commit log so hope is that anyone with the same WTF reaction would understand why this as done, I know I said WTF as well, I tried to avoid this at all costs, let me know if anyone thinks of a better way.

What I mean by keeping the history is you can do git log --follow on the script after the move.

Quoted 8 lines
Quoted 8 lines
tools/hotplug/Linux/init.d/xendomains-init new file +2 -0
new file mode 100644
index 0000000..da55932
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
Quoted 8 lines

tools/hotplug/Linux/init.d/xendomains-init line 7

Quoted 5 lines
tools/hotplug/Linux/init.d/xendomains-init new file +5 -0
+# /etc/init.d/xendomains-init
+#
+# wrapper for starting / stopping domains automatically when domain
+# 0 boots / shuts down on systems using init. The $SBINDIR/xendomains
+# helper is shared between init and systemd systems.

Shouldn't all the LSB headers from the original sit around here somewhere?

OK, will ammend.

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#26 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 16 lines · Luis R. Rodriguez
Quoted 15 lines · Ian Campbell
Quoted 12 lines · Luis R. Rodriguez
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 tools/hotplug/Linux/Makefile                |  4 +++-
 tools/hotplug/Linux/init.d/xendomains-init  | 33 +++++++++++++++++++++++++++++
 tools/hotplug/Linux/{init.d => }/xendomains |  0
Quoted 5 lines
Quoted 3 lines

For some reason we also have tools/hotplug/NetBSD/rc.d/xendomains. I presume there is a non-zero chance that it could call this new tool as well.

I rather have someone with NetBSD verify and then make that change.

OK

Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 tools/hotplug/Linux/init.d/xendomains-init
 rename tools/hotplug/Linux/{init.d => }/xendomains (100%)
tools/hotplug/Linux/Makefile +0 -0
index 47655f6..0be2e8a 100644
@@ -3,7 +3,8 @@ include $(XEN_ROOT)/tools/Rules.mk
 
Quoted 7 lines

tools/hotplug/Linux/Makefile include $(XEN_ROOT)/tools/Rules.mk · line 6

Quoted 4 lines
tools/hotplug/Linux/Makefile +1 -1
 # Init scripts.
 XEND_INITD = init.d/xend
-XENDOMAINS_INITD = init.d/xendomains
+XENDOMAINS_INITD = init.d/xendomains-init

The suffix is unnecessary given the directory, isn't it? Plus it avoids upgrade hassle by not changing the name of the initscript.

It does and I tried to use the same name but if one does a git mv of a file git adds that old file name and path to a temporary .gitignore requiring you to use git add -f on that file. It does this because if you insist you loose the history of the file after the move. Its also why I changed the name of this modified init.

Quoted 8 lines

If you don't want to keep the history I can move forward with a mv but the history will be lost. I did explain this in the commit log so hope is that anyone with the same WTF reaction would understand why this as done, I know I said WTF as well, I tried to avoid this at all costs, let me know if anyone thinks of a better way.

What I mean by keeping the history is you can do git log --follow on the script after the move.

The history is never lost. If git was actually losing history there would be uproar, and the structure of the repo prevents it anyway.

I skanked up an example commit (see below) and git comes up with:

 2 files changed, 54 insertions(+), 610 deletions(-)
 rewrite tools/hotplug/Linux/init.d/xendomains (91%)
 rename tools/hotplug/Linux/{init.d => }/xendomains (93%)

and "git log --follow tools/hotplug/Linux/xendomains" works exactly as I expected, so I think things are fine.

Even if this weren't the case (perhaps the copy/rename detection doesn't notice it in some versions of git) you could still get at the history manually, you just don't get it automatically, which I think is fine in this case.

Ian.

commit e9861de906d91fd2a3c3aad0aa5485d0f90cad67

Author: Ian Campbell <[email protected]>
Date:   Mon Mar 24 10:06:45 2014 +0000

testing

tools/hotplug/Linux/init.d/xendomains +5 -537
index 59f1e3d..c91e1a5 100644
@@ -27,559 +27,27 @@
 #                    boots / shuts down.
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
-
-CMD=${SBINDIR}/xm
-HEADCOMP="LinuxGuestRecord"
-$CMD list &> /dev/null
-if test $? -ne 0
-then
-	CMD=${SBINDIR}/xl
-	HEADCOMP="Xen saved domain"
-fi
-
-$CMD list &> /dev/null
-if test $? -ne 0
-then
-	exit 0;
-fi
-
-# 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
-fi
-
-# See docs/misc/distro_mapping.txt
-if [ -d /var/lock/subsys ]; then
-	LOCKFILE=/var/lock/subsys/xendomains
-else
-	LOCKFILE=/var/lock/xendomains
-fi
-
-if [ -d /etc/sysconfig ]; then
-	XENDOM_CONFIG=/etc/sysconfig/xendomains
-else
-	XENDOM_CONFIG=/etc/default/xendomains
-fi
-
-test -r $XENDOM_CONFIG || { echo "$XENDOM_CONFIG not existing";
-	if [ "$1" = "stop" ]; then exit 0;
-	else exit 6; fi; }
-
-. $XENDOM_CONFIG
-
-# Use the SUSE rc_ init script functions;
-# emulate them on LSB, RH and other systems
-if test -e /etc/rc.status; then
-    # SUSE rc script library
-    . /etc/rc.status
-else    
-    _cmd=$1
-    declare -a _SMSG
-    if test "${_cmd}" = "status"; then
-	_SMSG=(running dead dead unused unknown)
-	_RC_UNUSED=3
-    else
-	_SMSG=(done failed failed missed failed skipped unused failed failed)
-	_RC_UNUSED=6
-    fi
-    if test -e /etc/init.d/functions; then
-	# REDHAT
-	. /etc/init.d/functions
-	echo_rc()
-	{
-	    #echo -n "  [${_SMSG[${_RC_RV}]}] "
-	    if test ${_RC_RV} = 0; then
-		success "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		failure "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	}
-    elif test -e /lib/lsb/init-functions; then
-	# LSB    
-    	. /lib/lsb/init-functions
-        if alias log_success_msg >/dev/null 2>/dev/null; then
-	  echo_rc()
-	  {
-	       echo "  [${_SMSG[${_RC_RV}]}] "
-	  }
-        else
-	  echo_rc()
-	  {
-	    if test ${_RC_RV} = 0; then
-		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	  }
-        fi
-    else    
-	# emulate it
-	echo_rc()
-	{
-	    echo "  [${_SMSG[${_RC_RV}]}] "
-	}
-    fi
-    rc_reset() { _RC_RV=0; }
-    rc_failed()
-    {
-	if test -z "$1"; then 
-	    _RC_RV=1;
-	elif test "$1" != "0"; then 
-	    _RC_RV=$1; 
-    	fi
-	return ${_RC_RV}
-    }
-    rc_check()
-    {
-	return rc_failed $?
-    }	
-    rc_status()
-    {
-	rc_failed $?
-	if test "$1" = "-r"; then _RC_RV=0; shift; fi
-	if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi
-	if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi
-	if test "$1" = "-v"; then echo_rc; shift; fi
-	if test "$1" = "-r"; then _RC_RV=0; shift; fi
-	return ${_RC_RV}
-    }
-    rc_exit() { exit ${_RC_RV}; }
-    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
-	return 1
-    }
-fi
-
-if ! which usleep >&/dev/null
-then
-  usleep()
-  {
-    if [ -n "$1" ]
-    then
-      sleep $(( $1 / 1000000 ))
-    fi
-  }
-fi
-
-# Reset status of this service
-rc_reset
-
-##
-# Returns 0 (success) if the given parameter names a directory, and that
-# directory is not empty.
-#
-contains_something()
-{
-  if [ -d "$1" ] && [ `/bin/ls $1 | wc -l` -gt 0 ]
-  then
-    return 0
-  else
-    return 1
-  fi
-}
-
-# read name from xen config file
-rdname()
-{
-    NM=$($CMD create --quiet --dryrun --defconfig "$1" |
-         sed -n 's/^.*(name \(.*\))$/\1/p;s/^.*"name": "\(.*\)",$/\1/p')
-}
-
-rdnames()
-{
-    NAMES=
-    if ! contains_something "$XENDOMAINS_AUTO"
-    then 
-	return
-    fi
-    for dom in $XENDOMAINS_AUTO/*; do
-	rdname $dom
-	if test -z $NAMES; then 
-	    NAMES=$NM; 
-	else
-	    NAMES="$NAMES|$NM"
-	fi
-    done
-}
-
-LIST_GREP='(domain\|(domid\|(name\|^    {$\|"name":\|"domid":'
-parseln()
-{
-    if [[ "$1" =~ '(domain' ]] || [[ "$1" = "{" ]]; then
-        name=;id=
-    elif [[ "$1" =~ '(name' ]]; then
-        name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
-    elif [[ "$1" =~ '(domid' ]]; then
-        id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
-    elif [[ "$1" =~ '"name":' ]]; then
-        name=$(echo $1 | sed -e 's/^.*"name": "\(.*\)",$/\1/')
-    elif [[ "$1" =~ '"domid":' ]]; then
-        id=$(echo $1 | sed -e 's/^.*"domid": \(.*\),$/\1/')
-    fi
-
-    [ -n "$name" -a -n "$id" ] && return 0 || return 1
-}
-
-is_running()
-{
-    rdname $1
-    RC=1
-    name=;id=
-    while read LN; do
-	parseln "$LN" || continue
-	if test $id = 0; then continue; fi
-	case $name in 
-	    ($NM)
-		RC=0
-		;;
-	esac
-    done < <($CMD list -l | grep "$LIST_GREP")
-    return $RC
-}
-
-start() 
-{
-    if [ -f $LOCKFILE ]; then 
-	echo -e "xendomains already running (lockfile exists)"
-	return; 
-    fi
-
-    saved_domains=" "
-    if [ "$XENDOMAINS_RESTORE" = "true" ] &&
-       contains_something "$XENDOMAINS_SAVE"
-    then
-	mkdir -p $(dirname "$LOCKFILE")
-	touch $LOCKFILE
-	echo -n "Restoring Xen domains:"
-	saved_domains=`ls $XENDOMAINS_SAVE`
-        for dom in $XENDOMAINS_SAVE/*; do
-            if [ -f $dom ] ; then
-                HEADER=`head -c 16 $dom | head -n 1 2> /dev/null`
-                if [ "$HEADER" = "$HEADCOMP" ]; then
-                    echo -n " ${dom##*/}"
-                    XMR=`$CMD restore $dom 2>&1 1>/dev/null`
-                    #$CMD restore $dom
-                    if [ $? -ne 0 ]; then
-                        echo -e "\nAn error occurred while restoring domain ${dom##*/}:\n$XMR"
-                        rc_failed $?
-                        echo -e '!'
-                    else
-                        # mv $dom ${dom%/*}/.${dom##*/}
-                        rm $dom
-                    fi
-                fi
-            fi
-        done
-	echo -e
-    fi
-
-    if contains_something "$XENDOMAINS_AUTO"
-    then
-	touch $LOCKFILE
-	echo -n "Starting auto Xen domains:"
-	# We expect config scripts for auto starting domains to be in
-	# 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 
-	# 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 
-	# restore correctly it requires administrative attention.
-	for dom in $XENDOMAINS_AUTO/*; do
-	    echo -n " ${dom##*/}"
-	    shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)$/\1/p')
-	    echo $saved_domains | grep -w $shortdom > /dev/null
-	    if [ $? -eq 0 ] || is_running $dom; then
-		echo -n "(skip)"
-	    else
-		XMC=`$CMD create --quiet --defconfig $dom`
-		if [ $? -ne 0 ]; then
-		    echo -e "\nAn error occurred while creating domain ${dom##*/}: $XMC\n"
-		    rc_failed $?
-		    echo -e '!'
-		else
-		    usleep $XENDOMAINS_CREATE_USLEEP
-		fi
-	    fi
-	done
-    fi
-}
-
-all_zombies()
-{
-    name=;id=
-    while read LN; do
-	parseln "$LN" || continue
-	if test $id = 0; then continue; fi
-	if test "$state" != "-b---d" -a "$state" != "-----d"; then
-	    return 1;
-	fi
-    done < <($CMD list -l | grep "$LIST_GREP")
-    return 0
-}
-
-# Wait for max $XENDOMAINS_STOP_MAXWAIT for $CMD $1 to finish;
-# if it has not exited by that time kill it, so the init script will
-# succeed within a finite amount of time; if $2 is nonnull, it will
-# kill the command as well as soon as no domain (except for zombies)
-# are left (used for shutdown --all). Third parameter, if any, suppresses
-# output of dots per working state (formatting issues)
-watchdog_xencmd()
-{
-    if test -z "$XENDOMAINS_STOP_MAXWAIT" -o "$XENDOMAINS_STOP_MAXWAIT" = "0"; then
-	exit
-    fi
-
-    usleep 20000
-    for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do
-	# exit if $CMD save/migrate/shutdown is finished
-	PSAX=`ps axlw | grep "$CMD $1" | grep -v grep`
-	if test -z "$PSAX"; then exit; fi
-	if ! test -n "$3"; then echo -n '.'; fi
-	sleep 1
-	# go to kill immediately if there's only zombies left
-	if all_zombies && test -n "$2"; then break; fi
-    done
-    sleep 1
-    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
-    fi
-    echo -n "Shutting down Xen domains:"
-    name=;id=
-    while read LN; do
-	parseln "$LN" || continue
-	if test $id = 0; then continue; fi
-	echo -n " $name"
-	if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
-	    eval "
-	    case \"\$name\" in
-		($NAMES)
-		    # nothing
-		    ;;
-		(*)
-		    echo -e '(skip)'
-		    continue
-		    ;;
-	    esac
-	    "
-	fi
-	# 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
-	    for sysrq in $XENDOMAINS_SYSRQ; do
-		echo -n "(SR-$sysrq)"
-		XMR=`$CMD sysrq $id $sysrq 2>&1 1>/dev/null`
-		if test $? -ne 0; then
-		    echo -e "\nAn error occurred while doing sysrq on domain:\n$XMR\n"
-		    rc_failed $?
-		    echo -n '!'
-		fi
-		# usleep just ignores empty arg
-		usleep $XENDOMAINS_USLEEP
-	    done
-	fi
-	if test "$state" = "-b---d" -o "$state" = "-----d"; then
-	    echo -n "(zomb)"
-	    continue
-	fi
-	if test -n "$XENDOMAINS_MIGRATE"; then
-	    echo -n "(migr)"
-	    watchdog_xencmd migrate &
-	    WDOG_PID=$!
-	    XMR=`$CMD migrate $id $XENDOMAINS_MIGRATE 2>&1 1>/dev/null`
-	    if test $? -ne 0; then
-		echo -e "\nAn error occurred while migrating domain:\n$XMR\n"
-		rc_failed $?
-		echo -e '!'
-
-		kill $WDOG_PID >/dev/null 2>&1
-	    else
-		kill $WDOG_PID >/dev/null 2>&1
-		
-		echo -e .
-		usleep 1000
-		continue
-	    fi
-	fi
-	if test -n "$XENDOMAINS_SAVE"; then
-	    echo -n "(save)"
-	    watchdog_xencmd save &
-	    WDOG_PID=$!
-	    mkdir -p "$XENDOMAINS_SAVE"
-	    XMR=`$CMD save $id $XENDOMAINS_SAVE/$name 2>&1 1>/dev/null`
-	    if test $? -ne 0; then
-		echo -e "\nAn error occurred while saving domain:\n$XMR\n"
-		rc_failed $?
-		echo -e '!'
-		kill $WDOG_PID >/dev/null 2>&1
-	    else
-		kill $WDOG_PID >/dev/null 2>&1
-		echo -e .
-		usleep 1000
-		continue
-	    fi
-	fi
-	if test -n "$XENDOMAINS_SHUTDOWN"; then
-	    # XENDOMAINS_SHUTDOWN should be "--wait"
-	    echo -n "(shut)"
-	    watchdog_xencmd shutdown &
-	    WDOG_PID=$!
-	    XMR=`$CMD shutdown $XENDOMAINS_SHUTDOWN $id 2>&1 1>/dev/null`
-	    if test $? -ne 0; then
-		echo -e "\nAn error occurred while shutting down domain:\n$XMR\n"
-		rc_failed $?
-		echo -e '!'
-	    fi
-	    kill $WDOG_PID >/dev/null 2>&1
-	fi
-    done < <($CMD list -l | grep "$LIST_GREP")
-
-    # NB. this shuts down ALL Xen domains (politely), not just the ones in
-    # AUTODIR/*
-    # This is because it's easier to do ;-) but arguably if this script is run
-    # on system shutdown then it's also the right thing to do.
-    if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then
-	# XENDOMAINS_SHUTDOWN_ALL should be "--all --wait"
-	echo -n " SHUTDOWN_ALL "
-	watchdog_xencmd shutdown 1 false &
-	WDOG_PID=$!
-	XMR=`$CMD shutdown $XENDOMAINS_SHUTDOWN_ALL 2>&1 1>/dev/null`
-	if test $? -ne 0; then
-	    echo -e "\nAn error occurred while shutting down all domains: $XMR\n"
-	    rc_failed $?
-	    echo -e '!'
-	fi
-	kill $WDOG_PID >/dev/null 2>&1
-    fi
-
-    # Unconditionally delete lock file
-    rm -f $LOCKFILE
-    
-    exec 2>&3
-}
-
-check_domain_up()
-{
-    name=;id=
-    while read LN; do
-	parseln "$LN" || continue
-	if test $id = 0; then continue; fi
-	case $name in 
-	    ($1)
-		return 0
-		;;
-	esac
-    done < <($CMD list -l | grep "$LIST_GREP")
-    return 1
-}
-
-check_all_auto_domains_up()
-{
-    if ! contains_something "$XENDOMAINS_AUTO"
-    then
-      return 0
-    fi
-    missing=
-    for nm in $XENDOMAINS_AUTO/*; do
-	rdname $nm
-	found=0
-	if check_domain_up "$NM"; then 
-	    echo -n " $name"
-	else 
-	    missing="$missing $NM"
-	fi
-    done
-    if test -n "$missing"; then
-	echo -n " MISS AUTO:$missing"
-	return 1
-    fi
-    return 0
-}
-
-check_all_saved_domains_up()
-{
-    if ! contains_something "$XENDOMAINS_SAVE" 
-    then
-      return 0
-    fi
-    missing=`/bin/ls $XENDOMAINS_SAVE`
-    echo -n " MISS SAVED: " $missing
-    return 1
-}
-
-# This does NOT necessarily restart all running domains: instead it
-# stops all running domains and then boots all the domains specified in
-# AUTODIR.  If other domains have been started manually then they will
-# not get restarted.
-# Commented out to avoid confusion!
-
-restart()
-{
-    stop
-    start
-}
-
-reload()
-{
-    restart
-}
-
-
 case "$1" in
     start)
-	start
-	rc_status
-	if test -f $LOCKFILE; then rc_status -v; fi
+	foo start
 	;;
 
     stop)
-	stop
-	rc_status -v
+	foo stop
 	;;
 
     restart)
-	restart
+	foo restart
 	;;
     reload)
-	reload
+	foo reload
 	;;
 
     status)
-	echo -n "Checking for xendomains:" 
-	if test ! -f $LOCKFILE; then 
-	    rc_failed 3
-	else
-	    check_all_auto_domains_up
-	    rc_status
-	    check_all_saved_domains_up
-	    rc_status
-	fi
-	rc_status -v
+	foo status -v
 	;;
 
     *)
 	echo "Usage: $0 {start|stop|restart|reload|status}"
-	rc_failed 3
-	rc_status -v
 	;;
 esac
-
-rc_exit
tools/hotplug/Linux/xendomains new file +561 -0

561 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#27 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 7 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez

What I mean by keeping the history is you can do git log --follow on the script after the move.

The history is never lost. If git was actually losing history there would be uproar, and the structure of the repo prevents it anyway.

Quoted 6 lines

I skanked up an example commit (see below) and git comes up with:

 2 files changed, 54 insertions(+), 610 deletions(-)
 rewrite tools/hotplug/Linux/init.d/xendomains (91%)
 rename tools/hotplug/Linux/{init.d => }/xendomains (93%)

and "git log --follow tools/hotplug/Linux/xendomains" works exactly as I expected, so I think things are fine.

Did you try git format-patch -M on that? I now see what you see but I don't see git format-patch respecting the rename detection, either way we'll know it will be so I'll just submit it, just to be clear on the submission that I just move the code, its not a magical rewrite.

Luis

#28 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 15 lines · Luis R. Rodriguez
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez

What I mean by keeping the history is you can do git log --follow on the script after the move.

The history is never lost. If git was actually losing history there would be uproar, and the structure of the repo prevents it anyway.

Quoted 6 lines

I skanked up an example commit (see below) and git comes up with:

 2 files changed, 54 insertions(+), 610 deletions(-)
 rewrite tools/hotplug/Linux/init.d/xendomains (91%)
 rename tools/hotplug/Linux/{init.d => }/xendomains (93%)

and "git log --follow tools/hotplug/Linux/xendomains" works exactly as I expected, so I think things are fine.

Quoted 4 lines

Did you try git format-patch -M on that? I now see what you see but I don't see git format-patch respecting the rename detection, either way we'll know it will be so I'll just submit it, just to be clear on the submission that I just move the code, its not a magical rewrite.

I can't remember what I did above, probably git show -M. I thought git send-email/format-patch obeyed the same option just fine though.

Ian.

#29 lore raw

Re: [PATCH v2 6/7] tools/xendomains: move to sbin and use init helper

Quoted 16 lines · Ian Campbell
Quoted 15 lines · Luis R. Rodriguez
Quoted 13 lines · Ian Campbell
Quoted 2 lines · Luis R. Rodriguez

What I mean by keeping the history is you can do git log --follow on the script after the move.

The history is never lost. If git was actually losing history there would be uproar, and the structure of the repo prevents it anyway.

I skanked up an example commit (see below) and git comes up with:

 2 files changed, 54 insertions(+), 610 deletions(-)
 rewrite tools/hotplug/Linux/init.d/xendomains (91%)
 rename tools/hotplug/Linux/{init.d => }/xendomains (93%)

and "git log --follow tools/hotplug/Linux/xendomains" works exactly as I expected, so I think things are fine.

Quoted 7 lines
Quoted 4 lines

Did you try git format-patch -M on that? I now see what you see but I don't see git format-patch respecting the rename detection, either way we'll know it will be so I'll just submit it, just to be clear on the submission that I just move the code, its not a magical rewrite.

I can't remember what I did above, probably git show -M. I thought git send-email/format-patch obeyed the same option just fine though.

Ditto, I think you may have pasted the output of the commit. Either way I take it you see now what I see. Either way, at least internally it seems git knows what's up. For review this can be an inconvenience though. We'll have to try to fix this upstream on git if its a bug.

Luis

#30 lore raw

PATCH v2 7/7 systemd: add support initial xen systemd service files

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

These are originally based on the Fedora systemd files.

Changes made:

* 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
* generalized path meta @VARIABLES@ which are configuration specific
* uses new xenstore-read -l 30 -s prior to doing letting things rip
* defines systemd socket for xenstored
* 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
* defines a modules-load.d for us
* 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.socket
* oxenstored.service
* 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 (CONFIG_Linux) given the low overhead of only having to only sed the meta @VARIABLES@. The systemd files will be sanitized for meta @VARIABLES@ upon the all make target by default, and installed upon the install target. Systems that do not use systemd will still have these files installed but can still just use the old LSB init scripts; if they happen to get systemd they can easily switch to it. The changes above only apply to systems that use systemd.

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.

Since we have a systemd socket defined for xenstored we may be able to eventually remove our sanity check of tesing access to xenstored with 'xenstore-read -l 30 -s' but we keep it for now.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Jan Rękorajski <[email protected]>
Cc M A Young <[email protected]>
Cc Jacek Konieczny <[email protected]>
---
 .gitignore                                         |  5 ++
 Config.mk                                          |  9 ++-
 Makefile                                           | 11 +++-
 config/StdGNU.mk                                   |  4 ++
 tools/hotplug/Linux/Makefile                       |  9 ++-
 tools/hotplug/Linux/systemd/Makefile               | 72 ++++++++++++++++++++++
 tools/hotplug/Linux/systemd/oxenstored.service.in  | 23 +++++++
 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 ++++
 .../Linux/systemd/xen.conf.modules-load.d.in       | 16 +++++
 tools/hotplug/Linux/systemd/xenconsoled.service.in | 20 ++++++
 tools/hotplug/Linux/systemd/xendomains.service.in  | 16 +++++
 tools/hotplug/Linux/systemd/xenstored.service.in   | 24 ++++++++
 tools/hotplug/Linux/systemd/xenstored.socket.in    |  9 +++
 16 files changed, 270 insertions(+), 5 deletions(-)
 create mode 100644 tools/hotplug/Linux/systemd/Makefile
 create mode 100644 tools/hotplug/Linux/systemd/oxenstored.service.in
 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/xen.conf.modules-load.d.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
.gitignore +5 -0
index db3b083..4d77d16 100644
@@ -400,3 +400,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
Config.mk +8 -1
index 84c558b..24f9463 100644
@@ -153,7 +153,12 @@ endef
 define buildmakevars2shellvars
     export PREFIX="$(PREFIX)";                                            \
     export XEN_SCRIPT_DIR="$(XEN_SCRIPT_DIR)";                            \
-    export XEN_ROOT="$(XEN_ROOT)"
+    export XEN_SYSTEMD_DIR="$(XEN_SYSTEMD_DIR)";                          \
+    export XEN_SYSTEMD_MODULES_LOAD="$(XEN_SYSTEMD_MODULES_LOAD=)";       \
+    export XEN_ROOT="$(XEN_ROOT)";                                        \
+    export XEN_RUN_DIR="$(XEN_RUN_DIR)";                                  \
+    export XEN_LOG_DIR="$(XEN_LOG_DIR)";                                  \
+    export XEN_LIB_STORED="$(XEN_LIB_STORED)"
 endef
 
 #
@@ -174,6 +179,8 @@ define buildmakevars2file-closure
 	$(foreach var,                                                      \
 	          SBINDIR BINDIR LIBEXEC LIBDIR SHAREDIR PRIVATE_BINDIR     \
 	          XENFIRMWAREDIR XEN_CONFIG_DIR XEN_SCRIPT_DIR XEN_LOCK_DIR \
+		  XEN_SYSTEMD_MODULES_LOAD				    \
+		  XEN_SYSTEMD_DIR XEN_LOG_DIR XEN_LIB_STORED                \
 	          XEN_RUN_DIR XEN_PAGING_DIR,                               \
 	          echo "$(var)=\"$($(var))\"" >>$(1).tmp;)        \
 	$(call move-if-changed,$(1).tmp,$(1))
Makefile +10 -1
index 4e48457..8f6d479 100644
@@ -243,8 +243,17 @@ 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)/xenconsoled.service
+	rm -f  $(D)$(XEN_SYSTEMD_DIR)/xendomains.service
+	rm -f  $(D)$(XEN_SYSTEMD_DIR)/xenstored.service
+	rm -f  $(D)$(XEN_SYSTEMD_DIR)/oxenstored.service
+	rm -f  $(D)$(XEN_SYSTEMD_DIR)/xen-watchdog.service
+	rm -f  $(D)$(XEN_SYSTEMD_DIR)/proc-xen.mount
+	rm -f  $(D)$(XEN_SYSTEMD_DIR)/var-lib-xenstored.mount
+	rm -f  $(D)$(XEN_SYSTEMD_MODULES_LOAD)/xen.conf
+	rm -rf $(D)${XEN_RUN_DIR}* $(D)/var/lib/xen*
 	make -C tools uninstall
 	rm -rf $(D)/boot/tboot*
 
config/StdGNU.mk +4 -0
index 25fc594..70e1a40 100644
@@ -44,12 +44,16 @@ PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
 CONFIG_DIR = /etc
 XEN_LOCK_DIR = /var/lock
 XEN_RUN_DIR = /var/run/xen
+XEN_LOG_DIR = /var/log/xen
+XEN_LIB_STORED = /var/lib/xenstored
 XEN_PAGING_DIR = /var/lib/xen/xenpaging
 
 SYSCONFIG_DIR = $(CONFIG_DIR)/$(CONFIG_LEAF_DIR)
 
 XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
 XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
+XEN_SYSTEMD_DIR = $(PREFIX)/lib/systemd/system/
+XEN_SYSTEMD_MODULES_LOAD = $(PREFIX)/lib/modules-load.d/
 
 SOCKET_LIBS =
 UTIL_LIBS = -lutil
tools/hotplug/Linux/Makefile +6 -3
index 0be2e8a..99eb33f 100644
@@ -26,6 +26,8 @@ XEN_SCRIPTS += vscsi
 XEN_SCRIPTS += block-iscsi
 XEN_SCRIPTS += $(XEN_SCRIPTS-y)
 
+SUBDIRS-y += 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
@@ -35,13 +37,13 @@ UDEV_RULES-$(CONFIG_XEND) = xend.rules
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
 .PHONY: all
-all:
+all: subdirs-all
 
 .PHONY: build
 build:
 
 .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
@@ -54,6 +56,7 @@ endif
 	$(INSTALL_PROG) $(XENDOMAINS_SBIN) $(DESTDIR)$(SBINDIR)
 	$(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains
+	ln -sf $(XENDOMAINS_SYSCONFIG) $(SBINDIR)/xendomains
 	$(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_DATA) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons
 	$(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
@@ -81,4 +84,4 @@ install-udev:
 	done
 
 .PHONY: clean
-clean:
+clean: subdirs-clean
tools/hotplug/Linux/systemd/Makefile new file +72 -0

72 lines not on this page · raw message

tools/hotplug/Linux/systemd/oxenstored.service.in new file +23 -0
new file mode 100644
index 0000000..f9bd272
@@ -0,0 +1,23 @@
+[Unit]
+Description=Oxenstored - ocaml version of daemon managing xenstore file system
+Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket
+After=proc-xen.mount var-lib-xenstored.mount
+Before=libvirtd.service libvirt-guests.service
+Conflicts=xenstored.service
+RefuseManualStop=true
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=forking
+Environment=XENSTORED_ARGS=
+EnvironmentFile=-/etc/default/xenstored
+EnvironmentFile=-/etc/sysconfig/xenstored
+PIDFile=@XEN_RUN_DIR@/xenstored.pid
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStartPre=/bin/mkdir -p @XEN_RUN_DIR@
+ExecStart=@SBINDIR@/oxenstored --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
+ExecStartPost=@BINDIR@/xenstore-read -l 30 -s /
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
+
+[Install]
+WantedBy=multi-user.target
tools/hotplug/Linux/systemd/proc-xen.mount.in new file +9 -0
new file mode 100644
index 0000000..6eb61b2
@@ -0,0 +1,9 @@
+[Unit]
+Description=Mount /proc/xen files
+ConditionPathIsDirectory=/proc/xen
+RefuseManualStop=true
+
+[Mount]
+What=xenfs
+Where=/proc/xen
+Type=xenfs
tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in new file +13 -0
new file mode 100644
index 0000000..a393b06
@@ -0,0 +1,13 @@
+[Unit]
+Description=mount xenstore file system
+ConditionPathIsDirectory=/proc/xen
+RefuseManualStop=true
+
+[Mount]
+Environment=XENSTORED_MOUNT_CTX=
+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
new file mode 100644
index 0000000..39a82bc
@@ -0,0 +1,22 @@
+[Unit]
+Description=qemu for xen dom0 disk backend
+Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket
+After=proc-xen.mount xenstored.service oxenstored.service xenconsoled.service
+Before=xendomains.service libvirtd.service libvirt-guests.service
+RefuseManualStop=true
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=forking
+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
new file mode 100644
index 0000000..063fefb
@@ -0,0 +1,13 @@
+[Unit]
+Description=Xen-watchdog - run xen watchdog daemon
+Requires=proc-xen.mount
+After=proc-xen.mount xend.service
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=forking
+ExecStart=@SBINDIR@/xenwatchdogd 30 15
+KillSignal=USR1
+
+[Install]
+WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xen.conf.modules-load.d.in new file +16 -0
new file mode 100644
index 0000000..3fbd59b
@@ -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
+blktap2
+blktap
tools/hotplug/Linux/systemd/xenconsoled.service.in new file +20 -0
new file mode 100644
index 0000000..77c3965
@@ -0,0 +1,20 @@
+[Unit]
+Description=Xenconsoled - handles logging from guest consoles and hypervisor
+Requires=proc-xen.mount
+After=proc-xen.mount xenstored.service oxenstored.service
+ConditionPathIsDirectory=/proc/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 @XEN_RUN_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
new file mode 100644
index 0000000..35beeaf
@@ -0,0 +1,16 @@
+[Unit]
+Description=Xendomains - start and stop guests on boot and shutdown
+Requires=proc-xen.mount
+After=proc-xen.mount xenstored.service xenconsoled.service oxenstored.service
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
+ExecStart=-@SBINDIR@/xendomains start
+ExecStop=@SBINDIR@/xendomains stop
+ExecReload=@SBINDIR@/xendomains restart
+
+[Install]
+WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xenstored.service.in new file +24 -0
new file mode 100644
index 0000000..6a45020
@@ -0,0 +1,24 @@
+[Unit]
+Description=Xenstored - daemon managing xenstore file system
+Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket
+After=proc-xen.mount var-lib-xenstored.mount
+Before=libvirtd.service libvirt-guests.service
+RefuseManualStop=true
+ConditionPathIsDirectory=/proc/xen
+
+[Service]
+Type=forking
+Environment=XENSTORED_ARGS=
+Environment=XENSTORED_ROOTDIR=@XEN_LIB_STORED@
+EnvironmentFile=-/etc/default/xenstored
+EnvironmentFile=-/etc/sysconfig/xenstored
+PIDFile=@XEN_RUN_DIR@/xenstored.pid
+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=@SBINDIR@/xenstored --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
+ExecStartPost=@BINDIR@/xenstore-read -l 30 -s /
+ExecStartPost=@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
+
+[Install]
+WantedBy=multi-user.target
tools/hotplug/Linux/systemd/xenstored.socket.in new file +9 -0
new file mode 100644
index 0000000..2091b82
@@ -0,0 +1,9 @@
+[Unit]
+Description=Xen xenstored / oxenstored Activation Socket
+
+[Socket]
+ListenStream=@XEN_LIB_STORED@/socket
+ListenStream=@XEN_LIB_STORED@/socket_ro
+
+[Install]
+WantedBy=sockets.target
Signature · 7 lines
1.9.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#31 lore raw

Re: [PATCH v2 7/7] systemd: add support initial xen systemd service files

tools/hotplug/Linux/Makefile endif · line 62

Quoted 8 lines · Luis R. Rodriguez
tools/hotplug/Linux/Makefile +1 -0
@@ -54,6 +56,7 @@ endif
        $(INSTALL_PROG) $(XENDOMAINS_SBIN) $(DESTDIR)$(SBINDIR)
        $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(INITD_DIR)
        $(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains
+       ln -sf $(XENDOMAINS_SYSCONFIG) $(SBINDIR)/xendomains
        $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
        $(INSTALL_DATA) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons
        $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)

Sorry I forgot to remove this hunk, will send a v3 for this one alone.

Luis

#32 lore raw

Re: [PATCH v2 7/7] systemd: add support initial xen systemd service files

In reply to Luis R. Rodriguez
Quoted 5 lines · Luis R. Rodriguez

[...]

tools/hotplug/Linux/systemd/oxenstored.service.in +1 -0
[...]
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
tools/hotplug/Linux/systemd/xenstored.service.in +0 -0

[...]

Quoted 1 line

+ExecStartPost=@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"

I accidentally deleted the subthread about writing domid here too, but I was wondering if it might be better to have a common xenstore service which depends on oxenstore.service || cxenstore.service and then does this kind of common implementation agnostic setup in one place where it can't get out of sync easily?

(not sure if that is the "systemd way" but thought I'd throw it out there)

Ian.

#33 lore raw

Re: [PATCH v2 7/7] systemd: add support initial xen systemd service files

Quoted 7 lines · Ian Campbell
Quoted 5 lines · Luis R. Rodriguez

[...]

tools/hotplug/Linux/systemd/oxenstored.service.in +1 -0
[...]
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
tools/hotplug/Linux/systemd/xenstored.service.in +0 -0

[...]

Quoted 7 lines
Quoted 1 line

+ExecStartPost=@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"

I accidentally deleted the subthread about writing domid here too, but I was wondering if it might be better to have a common xenstore service which depends on oxenstore.service || cxenstore.service and then does this kind of common implementation agnostic setup in one place where it can't get out of sync easily?

That's what I was hoping for to achieve with the socket file but that seems to not work as expected, even if you claim the socket explicitly as part of both oxenstored and xenstored. To me this could likely be an enhancement to systemd but not sure.

systemd does not allow one to use || as part of the language for requirements, it also does not let you use || to exec stuff for services which are of type "Forking".

This means we either do some sort of meta @VARIABLE@ substitution or a common init routine which will do the or checking for us. The only problem with this is systemd will treat the Forking type service ExecStart as the process to care for, and if we add a wrapper that'd be dead. I haven't tried to implement one but I think this could confuse systemd or administrators.

Quoted 2 lines

(not sure if that is the "systemd way" but thought I'd throw it out there)

Its what I wanted to do as well. I tried.

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#34 lore raw

Re: [PATCH v2 7/7] systemd: add support initial xen systemd service files

Quoted 16 lines · Luis R. Rodriguez
Quoted 7 lines · Ian Campbell
Quoted 5 lines · Luis R. Rodriguez

[...]

tools/hotplug/Linux/systemd/oxenstored.service.in +1 -0
[...]
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
tools/hotplug/Linux/systemd/xenstored.service.in +0 -0

[...]

Quoted 7 lines
Quoted 1 line

+ExecStartPost=@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"

I accidentally deleted the subthread about writing domid here too, but I was wondering if it might be better to have a common xenstore service which depends on oxenstore.service || cxenstore.service and then does this kind of common implementation agnostic setup in one place where it can't get out of sync easily?

Quoted 6 lines

That's what I was hoping for to achieve with the socket file but that seems to not work as expected, even if you claim the socket explicitly as part of both oxenstored and xenstored. To me this could likely be an enhancement to systemd but not sure.

systemd does not allow one to use || as part of the language for requirements,

Does it not have some sort of "Provides: some-virtual-facility" which two things can provide and other things can depend on?

Quoted 5 lines

This means we either do some sort of meta @VARIABLE@ substitution or a common init routine which will do the or checking for us. The only problem with this is systemd will treat the Forking type service ExecStart as the process to care for, and if we add a wrapper that'd be dead. I haven't tried to implement one but I think this could confuse systemd or administrators.

Yes, lets not go that route.

Ian.

#35 lore raw

Re: [PATCH v2 7/7] systemd: add support initial xen systemd service files

Quoted 22 lines · Ian Campbell
Quoted 21 lines · Luis R. Rodriguez
Quoted 7 lines · Ian Campbell
Quoted 5 lines · Luis R. Rodriguez

[...]

tools/hotplug/Linux/systemd/oxenstored.service.in +1 -0
[...]
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
tools/hotplug/Linux/systemd/xenstored.service.in +0 -0

[...]

Quoted 7 lines
Quoted 1 line

+ExecStartPost=@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"

I accidentally deleted the subthread about writing domid here too, but I was wondering if it might be better to have a common xenstore service which depends on oxenstore.service || cxenstore.service and then does this kind of common implementation agnostic setup in one place where it can't get out of sync easily?

That's what I was hoping for to achieve with the socket file but that seems to not work as expected, even if you claim the socket explicitly as part of both oxenstored and xenstored. To me this could likely be an enhancement to systemd but not sure.

Quoted 4 lines
Quoted 1 line

systemd does not allow one to use || as part of the language for requirements,

Does it not have some sort of "Provides: some-virtual-facility" which two things can provide and other things can depend on?

Not that I have seen.

Quoted 7 lines
Quoted 5 lines

This means we either do some sort of meta @VARIABLE@ substitution or a common init routine which will do the or checking for us. The only problem with this is systemd will treat the Forking type service ExecStart as the process to care for, and if we add a wrapper that'd be dead. I haven't tried to implement one but I think this could confuse systemd or administrators.

Yes, lets not go that route.

I studied this approach a bit more and it turns out that execve() does just what we want, it will carry the same PID for the spawned process, it won't return, it'll just go onto the other process, if it fails it returns back, in which case we can try the other cxenstored. We'd just have to rename the C xentstored to censtored. This would simplify things for both init systems and systemd. In the init system the check for oxenstored can be removed, in systemd we'd just have one systemd service file.

In light of this I'd like for us to consider this approach now.

Thoughts?

Luis

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#36 lore raw

Re: [PATCH v2 7/7] systemd: add support initial xen systemd service files

In reply to Ian Campbell
Quoted 27 lines · Ian Campbell
Quoted 16 lines · Luis R. Rodriguez
Quoted 7 lines · Ian Campbell
Quoted 5 lines · Luis R. Rodriguez

[...]

tools/hotplug/Linux/systemd/oxenstored.service.in +1 -0
[...]
+ExecStartPost=-@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"
tools/hotplug/Linux/systemd/xenstored.service.in +0 -0

[...]

Quoted 7 lines
Quoted 1 line

+ExecStartPost=@BINDIR@/xenstore-write "/local/domain/0/name" "Domain-0"

I accidentally deleted the subthread about writing domid here too, but I was wondering if it might be better to have a common xenstore service which depends on oxenstore.service || cxenstore.service and then does this kind of common implementation agnostic setup in one place where it can't get out of sync easily?

Quoted 6 lines

That's what I was hoping for to achieve with the socket file but that seems to not work as expected, even if you claim the socket explicitly as part of both oxenstored and xenstored. To me this could likely be an enhancement to systemd but not sure.

systemd does not allow one to use || as part of the language for requirements,

Does it not have some sort of "Provides: some-virtual-facility" which two things can provide and other things can depend on?

Quoted 7 lines
Quoted 5 lines

This means we either do some sort of meta @VARIABLE@ substitution or a common init routine which will do the or checking for us. The only problem with this is systemd will treat the Forking type service ExecStart as the process to care for, and if we add a wrapper that'd be dead. I haven't tried to implement one but I think this could confuse systemd or administrators.

Yes, lets not go that route.

I found one, the trick is to use a target file. I'll do a new submission with quite a bit of changes.

Luis