xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Ian Campbell <ian.campbell@citrix.com>,
	ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
	xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Konrad Rzeszutek Wilk <konrad@darnok.org>
Subject: Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain
Date: Mon, 20 Jul 2015 16:16:58 +0200	[thread overview]
Message-ID: <55AD02DA.4050004@citrix.com> (raw)
In-Reply-To: <1437065907-30388-1-git-send-email-ian.campbell@citrix.com>

El 16/07/15 a les 18.58, Ian Campbell ha escrit:
> The removal of the udev rules highlighted that although it has been
> replaced by "xl devd" there isn't an initscript to replace it.
> 
> To enable this add a --pidfile option to xl devd.
> 
> Tested on Linux by running the script in dom0 and checking the daemon
> was started/stopped, but not in an actual driver domain environment
> since I don't have one conveniently available. I also checked that
> running without the --pidfile option still works.
> 
> Scripts mainly cribbed from the xencommons for each platform.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Cc: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Konrad Rzeszutek Wilk <konrad@darnok.org>
> Cc: George Dunlap <george.dunlap@eu.citrix.com>
> ---
> For 4.6: I think having removed the udev rules we ought to include
> this, it's basically zero risk to normal operation.
> 
> Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend
> started. Is that correct?
> 
> v2: Check in Linux script that we don't start on dom0. I don't know
> the equivalent for *BSD.

At least on FreeBSD there's no easy way to know if we are running on
Dom0 from userspace (unless we start using hypercalls with privcmd).

I could add a dummy device (let's say /dev/xen/control) that's only
present if we are running on Dom0, does that sound reasonable?

Another option would be to add a small C program that can use hypercalls
and privcmd to detect if we are running on Dom0 or not, but that seems
over engineering it.

[...]

> diff --git a/tools/hotplug/FreeBSD/rc.d/xendriverdomain.in b/tools/hotplug/FreeBSD/rc.d/xendriverdomain.in
> new file mode 100644
> index 0000000..25e3edd
> --- /dev/null
> +++ b/tools/hotplug/FreeBSD/rc.d/xendriverdomain.in
> @@ -0,0 +1,48 @@
> +#!/bin/sh
> +#
> +# PROVIDE: xendriverdomain
> +# REQUIRE: DAEMON
> +#
> +# Should be run in a driver domain, but not in domain 0.
> +
> +. /etc/rc.subr
> +
> +. /etc/xen/scripts/hotplugpath.sh

This should have been:

. @XEN_SCRIPT_DIR@/hotplugpath.sh

I will send a patch ASAP to fix it.

[...]

> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index df89777..483eb71 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -477,7 +477,7 @@ out:
>      flush_stream(fh);
>  }
>  
> -static int do_daemonize(char *name)
> +static int do_daemonize(char *name, const char *pidfile)
>  {
>      char *fullname;
>      pid_t child1;
> @@ -509,6 +509,31 @@ static int do_daemonize(char *name)
>  
>      CHK_SYSCALL(daemon(0, 1));
>  
> +    if (pidfile) {
> +        int fd = open(pidfile, O_RDWR | O_CREAT, S_IRUSR|S_IWUSR);
> +        char *pid = NULL;
> +
> +        if (fd == -1) {
> +            perror("Unable to open pidfile");
> +            exit(1);
> +        }
> +
> +        if (asprintf(&pid, "%ld\n", (long)getpid()) == -1) {
> +            perror("Formatting pid");
> +            exit(1);
> +        }
> +
> +        if (write(fd, pid, strlen(pid)) < 0) {
> +            perror("Writing pid");
> +            exit(1);
> +        }
> +
> +        if ( close(fd) < 0 ) {

<pedantic>
The line above doesn't follow libxl coding style.
</pedantic>

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2015-07-20 14:16 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 10:51 [PATCH 0/6] Use system blktap George Dunlap
2015-07-06 10:51 ` [PATCH 1/6] libxl: Make local_initiate_attach more rational George Dunlap
2015-07-06 10:51 ` [PATCH 2/6] libxl: Remove linux udev rules George Dunlap
2015-07-07 11:39   ` Wei Liu
2015-07-14 16:13     ` Konrad Rzeszutek Wilk
2015-07-14 16:21       ` Ian Campbell
2015-07-14 16:35         ` George Dunlap
2015-07-14 16:40           ` Wei Liu
2015-07-14 16:48             ` Ian Campbell
2015-07-23 11:55               ` Roger Pau Monné
2015-07-23 12:30                 ` Ian Campbell
2015-07-15 11:07         ` [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain Ian Campbell
2015-07-15 13:26           ` Wei Liu
2015-07-15 13:40             ` Ian Campbell
2015-07-15 15:25           ` George Dunlap
2015-07-15 15:32           ` Ian Jackson
2015-07-15 15:35             ` George Dunlap
2015-07-15 15:37               ` Ian Campbell
2015-07-16 16:58         ` [PATCH for-4.6 v2] " Ian Campbell
2015-07-16 17:09           ` Ian Jackson
2015-07-16 17:48           ` Wei Liu
2015-07-17  9:05           ` Wei Liu
2015-07-17 11:36             ` Ian Campbell
2015-07-20 14:16           ` Roger Pau Monné [this message]
2015-07-20 14:28             ` Ian Campbell
2015-07-06 10:51 ` [PATCH 3/6] tools: Add a block-tap script for setting up tapdisks via tap-ctl George Dunlap
2015-07-07 12:03   ` Wei Liu
2015-07-07 12:35     ` Wei Liu
2015-07-06 10:51 ` [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP George Dunlap
2015-07-06 11:01   ` Andrew Cooper
2015-07-06 12:39     ` George Dunlap
2015-07-07 12:29   ` Wei Liu
2015-07-07 13:41     ` George Dunlap
2015-07-07 14:20       ` Ian Campbell
2015-07-07 14:27         ` George Dunlap
2015-07-06 10:51 ` [PATCH 5/6] tools: Remove in-tree blktap2 George Dunlap
2015-07-07 11:55   ` Wei Liu
2015-07-06 10:51 ` [PATCH 6/6] libxl: Add more logging to hotplug script path George Dunlap
2015-07-07 11:55   ` Wei Liu
2015-07-07 14:21 ` [PATCH 0/6] Use system blktap Ian Campbell
2015-07-07 14:24   ` George Dunlap
2015-07-07 14:52     ` Ian Campbell
2015-07-07 14:59       ` George Dunlap
2015-07-07 15:04         ` Ian Campbell
2015-07-07 15:20 ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55AD02DA.4050004@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=konrad@darnok.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).