From: Christoph Egger <Christoph.Egger@amd.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>, xen-devel@lists.xen.org
Subject: Re: [PATCH v2 4/5] libxl: call hotplug scripts from xl for NetBSD
Date: Fri, 27 Jul 2012 14:49:43 +0200 [thread overview]
Message-ID: <50128E67.7000706@amd.com> (raw)
In-Reply-To: <1343332476-33765-5-git-send-email-roger.pau@citrix.com>
On 07/26/12 21:54, Roger Pau Monne wrote:
> Add the missing NetBSD functions to call hotplug scripts, and disable
> xenbackendd if libxl/disable_udev is not set.
>
> Cc: Christoph Egger <Christoph.Egger@amd.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
> Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
> ---
> tools/libxl/libxl_netbsd.c | 57 ++++++++++++++++++++++++++++++++++++++-
> tools/xenbackendd/xenbackendd.c | 8 +++++-
> 2 files changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
> index 28cdf21..9587833 100644
> --- a/tools/libxl/libxl_netbsd.c
> +++ b/tools/libxl/libxl_netbsd.c
> @@ -32,10 +32,65 @@ char *libxl__devid_to_localdev(libxl__gc *gc, int devid)
> }
>
> /* Hotplug scripts caller functions */
> +static int libxl__hotplug(libxl__gc *gc, libxl__device *dev, char ***args,
> + libxl__device_action action)
> +{
> + char *be_path = libxl__device_backend_path(gc, dev);
> + char *script;
> + int nr = 0, rc = 0, arraysize = 4;
> +
> + script = libxl__xs_read(gc, XBT_NULL,
> + GCSPRINTF("%s/%s", be_path, "script"));
> + if (!script) {
> + LOGEV(ERROR, errno, "unable to read script from %s", be_path);
> + rc = ERROR_FAIL;
> + goto out;
> + }
> +
> + GCNEW_ARRAY(*args, arraysize);
> + (*args)[nr++] = script;
> + (*args)[nr++] = be_path;
> + (*args)[nr++] = GCSPRINTF("%d", action == DEVICE_CONNECT ?
> + XenbusStateInitWait : XenbusStateClosed);
> + (*args)[nr++] = NULL;
> + assert(nr == arraysize);
> +
> +out:
> + return rc;
> +}
> +
> int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
> char ***args, char ***env,
> libxl__device_action action,
> int num_exec)
> {
> - return 0;
> + char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH);
> + int rc;
> +
> + /* Check if we have to run hotplug scripts */
> + if (!disable_udev || num_exec > 0) {
> + rc = 0;
> + goto out;
> + }
> +
> + switch (dev->backend_kind) {
> + case LIBXL__DEVICE_KIND_VBD:
> + case LIBXL__DEVICE_KIND_VIF:
> + if (num_exec != 0) {
> + rc = 0;
> + goto out;
> + }
> + rc = libxl__hotplug(gc, dev, args, action);
> + if (!rc) rc = 1;
> + break;
> + default:
> + /* If no need to execute any hotplug scripts,
> + * call the callback manually
> + */
> + rc = 0;
> + break;
> + }
> +
> +out:
> + return rc;
> }
> diff --git a/tools/xenbackendd/xenbackendd.c b/tools/xenbackendd/xenbackendd.c
> index 6b5bb8e..5381a2a 100644
> --- a/tools/xenbackendd/xenbackendd.c
> +++ b/tools/xenbackendd/xenbackendd.c
> @@ -33,6 +33,7 @@
> #define DEVTYPE_UNKNOWN 0
> #define DEVTYPE_VIF 1
> #define DEVTYPE_VBD 2
> +#define DISABLE_EXEC "libxl/disable_udev"
>
> #define DOMAIN_PATH "/local/domain/0"
>
> @@ -149,7 +150,7 @@ main(int argc, char * const argv[])
> unsigned int num;
> char *s;
> int state;
> - char *sstate;
> + char *sstate, *sdisable;
> char *p;
> char buf[80];
> int type;
> @@ -245,6 +246,10 @@ main(int argc, char * const argv[])
> continue;
> }
>
> + sdisable = xs_read(xs, XBT_NULL, DISABLE_EXEC, 0);
> + if (sdisable)
> + goto next1;
> +
> if (strlen(vec[XS_WATCH_PATH]) < sizeof("state"))
> goto next1;
>
> @@ -314,6 +319,7 @@ next2:
> free(sstate);
>
> next1:
> + free(sdisable);
> free(vec);
> }
>
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
next prev parent reply other threads:[~2012-07-27 12:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-26 19:54 [PATCH v2 0/5] NetBSD: minor fixes and hotplug execution Roger Pau Monne
2012-07-26 19:54 ` [PATCH v2 1/5] tools/build: fix pygrub linking Roger Pau Monne
2012-07-27 8:48 ` Ian Campbell
2012-08-01 11:47 ` Ian Campbell
2012-08-02 5:42 ` Olaf Hering
2012-08-02 6:44 ` Ian Campbell
2012-07-26 19:54 ` [PATCH v2 2/5] libxl: react correctly to POLLHUP Roger Pau Monne
2012-07-27 8:53 ` Ian Campbell
2012-07-27 14:26 ` Ian Jackson
2012-07-27 17:01 ` Ian Jackson
2012-07-31 13:18 ` Ian Campbell
2012-07-31 14:42 ` Ian Jackson
2012-07-27 14:27 ` Ian Jackson
2012-07-26 19:54 ` [PATCH v2 3/5] hotplug/NetBSD: check type of file to attach from params Roger Pau Monne
2012-07-27 14:28 ` Ian Jackson
2012-07-26 19:54 ` [PATCH v2 4/5] libxl: call hotplug scripts from xl for NetBSD Roger Pau Monne
2012-07-27 12:49 ` Christoph Egger [this message]
2012-08-01 11:47 ` Ian Campbell
2012-07-26 19:54 ` [PATCH v2 5/5] init/NetBSD: move xenbackendd to xend init script Roger Pau Monne
2012-07-27 12:50 ` Christoph Egger
2012-07-27 14:29 ` Ian Jackson
2012-07-27 14:49 ` Christoph Egger
2012-08-01 11:47 ` 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=50128E67.7000706@amd.com \
--to=christoph.egger@amd.com \
--cc=ian.jackson@eu.citrix.com \
--cc=roger.pau@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.