From patchwork Thu Feb 25 19:25:13 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: 8426091 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 7E2339FC33 for ; Thu, 25 Feb 2016 19:28:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B63952039D for ; Thu, 25 Feb 2016 19:28:22 +0000 (UTC) Received: from lists.xen.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 93C6C20394 for ; Thu, 25 Feb 2016 19:28:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aZ1Xa-00051p-MH; Thu, 25 Feb 2016 19:25:34 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aZ1XZ-00051U-DQ for xen-devel@lists.xenproject.org; Thu, 25 Feb 2016 19:25:33 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id 8E/3A-02989-C255FC65; Thu, 25 Feb 2016 19:25:32 +0000 X-Env-Sender: prvs=856d7c560=roger.pau@citrix.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1456428330!18181714!1 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: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40627 invoked from network); 25 Feb 2016 19:25:31 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2016 19:25:31 -0000 X-IronPort-AV: E=Sophos;i="5.22,498,1449532800"; d="scan'208";a="341174574" From: Roger Pau Monne To: Date: Thu, 25 Feb 2016 20:25:13 +0100 Message-ID: <1456428318-8318-3-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <1456428318-8318-1-git-send-email-roger.pau@citrix.com> References: <1456428318-8318-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Wei Liu , Ian Jackson , Ian Campbell , Roger Pau Monne Subject: [Xen-devel] [PATCH v2 2/7] libxl: introduce an OS-specific function to get the physical-device 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=-1.9 required=5.0 tests=BAYES_00, 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 Linux and NetBSD will return the device major and minor numbers encoded in hex and separated by a ":". FreeBSD on the other hand returns the path to the block device or image file. Signed-off-by: Roger Pau Monné Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Ian Campbell Cc: Wei Liu --- tools/libxl/libxl.c | 9 +++++---- tools/libxl/libxl_freebsd.c | 6 ++++++ tools/libxl/libxl_internal.h | 6 ++++++ tools/libxl/libxl_linux.c | 10 ++++++++++ tools/libxl/libxl_netbsd.c | 10 ++++++++++ 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 2d18b8d..6d719d7 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2515,10 +2515,11 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid, */ if (!disk->script && disk->backend_domid == LIBXL_TOOLSTACK_DOMID) { - int major, minor; - if (!libxl__device_physdisk_major_minor(dev, &major, &minor)) - flexarray_append_pair(back, "physical-device", - GCSPRINTF("%x:%x", major, minor)); + char *physdev; + + physdev = libxl__get_physical_device(dev); + if (physdev != NULL) + flexarray_append_pair(back, "physical-device", physdev); } assert(device->backend_kind == LIBXL__DEVICE_KIND_VBD); diff --git a/tools/libxl/libxl_freebsd.c b/tools/libxl/libxl_freebsd.c index 47c3391..483f36e 100644 --- a/tools/libxl/libxl_freebsd.c +++ b/tools/libxl/libxl_freebsd.c @@ -143,3 +143,9 @@ int libxl__pci_topology_init(libxl__gc *gc, { return ERROR_NI; } + +char *libxl__get_physical_device(char *dev) +{ + + return dev; +} diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 650a958..1a3fa35 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1346,6 +1346,12 @@ void libxl__domaindeathcheck_stop(libxl__gc *gc, libxl__domaindeathcheck *dc); */ _hidden int libxl__try_phy_backend(mode_t st_mode); +/* + * Fetch the "physical-device" backend xenstore field for a local disk + * device. The implementation of this function is OS-specific. + */ +_hidden char *libxl__get_physical_device(char *dev); + _hidden char *libxl__devid_to_localdev(libxl__gc *gc, int devid); diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c index be4afc6..7e6d7b9 100644 --- a/tools/libxl/libxl_linux.c +++ b/tools/libxl/libxl_linux.c @@ -347,3 +347,13 @@ int libxl__pci_topology_init(libxl__gc *gc, return err; } + +char *libxl__get_physical_device(char *dev) +{ + int major, minor; + + if (libxl__device_physdisk_major_minor(dev, &major, &minor)) + return NULL; + + return GCSPRINTF("%x:%x", major, minor); +} diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c index 096c057..e12561f 100644 --- a/tools/libxl/libxl_netbsd.c +++ b/tools/libxl/libxl_netbsd.c @@ -100,3 +100,13 @@ int libxl__pci_topology_init(libxl__gc *gc, { return ERROR_NI; } + +char *libxl__get_physical_device(char *dev) +{ + int major, minor; + + if (libxl__device_physdisk_major_minor(dev, &major, &minor)) + return NULL; + + return GCSPRINTF("%x:%x", major, minor); +}