xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
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>,
	Ian Campbell <ian.campbell@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 2/7] libxl: introduce an OS-specific function to get the physical-device
Date: Thu, 25 Feb 2016 20:25:13 +0100	[thread overview]
Message-ID: <1456428318-8318-3-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1456428318-8318-1-git-send-email-roger.pau@citrix.com>

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é <roger.pau@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 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);
+}
-- 
2.5.4 (Apple Git-61)


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

  parent reply	other threads:[~2016-02-25 19:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 19:25 [PATCH v2 0/7] libxl: add support for FreeBSD block hotplug scripts Roger Pau Monne
2016-02-25 19:25 ` [PATCH v2 1/7] blkif: document how FreeBSD uses the physical-device backend node Roger Pau Monne
2016-03-01 12:39   ` Wei Liu
2016-03-01 18:17   ` Ian Jackson
2016-02-25 19:25 ` Roger Pau Monne [this message]
2016-03-01 12:39   ` [PATCH v2 2/7] libxl: introduce an OS-specific function to get the physical-device Wei Liu
2016-02-25 19:25 ` [PATCH v2 3/7] hotplug/FreeBSD: add block hotplug script Roger Pau Monne
2016-03-01 12:39   ` Wei Liu
2016-02-25 19:25 ` [PATCH v2 4/7] libxl/FreeBSD: add support for disk hotplug scripts Roger Pau Monne
2016-03-01 12:40   ` Wei Liu
2016-02-25 19:25 ` [PATCH v2 5/7] libxl: properly use vdev vs local device Roger Pau Monne
2016-03-01 12:40   ` Wei Liu
2016-02-25 19:25 ` [PATCH v2 6/7] libxl: add a FreeBSD implementation of libxl__devid_to_localdev Roger Pau Monne
2016-03-01 12:40   ` Wei Liu
2016-02-25 19:25 ` [PATCH v2 7/7] libxl: fix error message in local_device_attach_cb Roger Pau Monne
2016-03-01 12:40   ` Wei Liu
2016-02-29 12:15 ` [PATCH v2 0/7] libxl: add support for FreeBSD block hotplug scripts George Dunlap
2016-02-29 12:18   ` Roger Pau Monné
2016-02-29 14:26     ` George Dunlap
2016-02-29 16:08       ` Roger Pau Monné
2016-02-29 16:45         ` George Dunlap
2016-03-01 13:13           ` Roger Pau Monné

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=1456428318-8318-3-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=ian.campbell@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).