From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v3 4/8] libxl: add support for disk hotplug scripts on FreeBSD
Date: Thu, 31 Mar 2016 17:09:35 +0200 [thread overview]
Message-ID: <1459436979-7475-5-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1459436979-7475-1-git-send-email-roger.pau@citrix.com>
Allow FreeBSD to execute hotplug scripts when attaching disk devices.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
Changes since v2:
- Split the refactoring in a separate patch.
---
tools/libxl/libxl_freebsd.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/libxl/libxl_freebsd.c b/tools/libxl/libxl_freebsd.c
index 54db3d5..e86e28c 100644
--- a/tools/libxl/libxl_freebsd.c
+++ b/tools/libxl/libxl_freebsd.c
@@ -111,6 +111,35 @@ out:
return rc;
}
+static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
+ char ***args, char ***env,
+ libxl__device_action action)
+{
+ char *be_path = libxl__device_backend_path(gc, dev);
+ char *script;
+ int nr = 0, rc;
+
+ 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;
+ }
+
+ const int arraysize = 4;
+ GCNEW_ARRAY(*args, arraysize);
+ (*args)[nr++] = script;
+ (*args)[nr++] = be_path;
+ (*args)[nr++] = (char *) libxl__device_action_to_string(action);
+ (*args)[nr++] = NULL;
+ assert(nr == arraysize);
+ rc = 1;
+
+out:
+ return rc;
+}
+
int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
char ***args, char ***env,
libxl__device_action action,
@@ -131,6 +160,13 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
}
rc = libxl__hotplug_nic(gc, dev, args, env, action, num_exec);
break;
+ case LIBXL__DEVICE_KIND_VBD:
+ if (num_exec != 0) {
+ rc = 0;
+ goto out;
+ }
+ rc = libxl__hotplug_disk(gc, dev, args, env, action);
+ break;
default:
/* No need to execute any hotplug scripts */
rc = 0;
--
2.6.4 (Apple Git-63)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-03-31 15:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-31 15:09 [PATCH v3 0/8] libxl: add support for FreeBSD block hotplug scripts Roger Pau Monne
2016-03-31 15:09 ` [PATCH v3 1/8] blkif: document how FreeBSD uses the physical-device backend node Roger Pau Monne
2016-03-31 16:19 ` George Dunlap
2016-04-06 14:44 ` Ian Jackson
2016-03-31 15:09 ` [PATCH v3 2/8] hotplug/FreeBSD: add block hotplug script Roger Pau Monne
2016-03-31 15:09 ` [PATCH v3 3/8] libxl: refactor the FreeBSD hotplug script code Roger Pau Monne
2016-04-06 14:45 ` Ian Jackson
2016-03-31 15:09 ` Roger Pau Monne [this message]
2016-04-01 14:07 ` [PATCH v3 4/8] libxl: add support for disk hotplug scripts on FreeBSD Ian Jackson
2016-03-31 15:09 ` [PATCH v3 5/8] libxl: properly use vdev vs local device Roger Pau Monne
2016-03-31 15:09 ` [PATCH v3 6/8] libxl: add a FreeBSD implementation of libxl__devid_to_localdev Roger Pau Monne
2016-03-31 15:09 ` [PATCH v3 7/8] libxl: fix error message in local_device_attach_cb Roger Pau Monne
2016-03-31 15:09 ` [PATCH v3 8/8] hotplug/FreeBSD: document disk hotplug interface Roger Pau Monne
2016-03-31 16:38 ` George Dunlap
2016-03-31 15:47 ` [PATCH v3 0/8] libxl: add support for FreeBSD block hotplug scripts George Dunlap
2016-03-31 16:22 ` Roger Pau Monné
2016-04-06 14:47 ` Ian Jackson
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=1459436979-7475-5-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).