From patchwork Thu Mar 31 15:09:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8714211 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5315F9F44D for ; Thu, 31 Mar 2016 15:13:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 74CBB20251 for ; Thu, 31 Mar 2016 15:13:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0705020295 for ; Thu, 31 Mar 2016 15:13:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aleFL-0006c1-Ew; Thu, 31 Mar 2016 15:10:55 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aleFK-0006bd-8R for xen-devel@lists.xenproject.org; Thu, 31 Mar 2016 15:10:54 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 94/01-03645-DFD3DF65; Thu, 31 Mar 2016 15:10:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXitHSDve5f279 hBqfuMVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnrZsxiLLgnUPHg0DPGBsYJPF2MnBwSAv4S h//OZwGx2QR0JC7O3cnWxcjBISKgInF7rwFImFmgWOLrqj5WEFtYwE/i08I/TCA2i4CqxKE1m 9lBynkFnCXOrymDmKgrcXL3JnYQm1PAReJG5yQ2EFsIqOTghx5mEJtXQFDi5MwnLBDjNSVat/ 9mh7DlJZq3zmaGqFeU6J/3AOwaCQFuib/d9hMY+Wch6Z6FpHsWku4FjMyrGNWLU4vKUot0zfS SijLTM0pyEzNzdA0NTfRyU4uLE9NTcxKTivWS83M3MQKDjwEIdjD+neB8iFGSg0lJlPeI9d8w Ib6k/JTKjMTijPii0pzU4kOMMhwcShK8wTZAOcGi1PTUirTMHGAcwKQlOHiURHizQNK8xQWJu cWZ6RCpU4yKUuK8KiAJAZBERmkeXBss9i4xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmHcCyB SezLwSuOmvgBYzAS3eqvELZHFJIkJKqoHR5aet3twPP9qOGIe1Pa9kPJ5tsFBf35RHzXovF+/ 7iQ3fnrvO9FyxYlbVStMZ51cJznsu9Dzi7KFZ+1IOZ/aus3SO/8jy3+jPs4ISq1Ann4KA8JUK rnGNGf+8NZ1+fbPJPHrpjbfejhlTSqoF/bncbS/FO53z0qp73dmZeOzj2pePfme2Wz1VYinOS DTUYi4qTgQA/0b5YbgCAAA= X-Env-Sender: prvs=8914c038b=roger.pau@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1459437050!34537169!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37507 invoked from network); 31 Mar 2016 15:10:52 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 31 Mar 2016 15:10:52 -0000 X-IronPort-AV: E=Sophos;i="5.24,422,1454976000"; d="scan'208";a="350454649" From: Roger Pau Monne To: Date: Thu, 31 Mar 2016 17:09:35 +0200 Message-ID: <1459436979-7475-5-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.6.4 (Apple Git-63) In-Reply-To: <1459436979-7475-1-git-send-email-roger.pau@citrix.com> References: <1459436979-7475-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Ian Jackson , Roger Pau Monne Subject: [Xen-devel] [PATCH v3 4/8] libxl: add support for disk hotplug scripts on FreeBSD X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow FreeBSD to execute hotplug scripts when attaching disk devices. Signed-off-by: Roger Pau Monné --- Cc: Ian Jackson Cc: Wei Liu --- 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;