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 6/8] libxl: add a FreeBSD implementation of libxl__devid_to_localdev
Date: Thu, 31 Mar 2016 17:09:37 +0200 [thread overview]
Message-ID: <1459436979-7475-7-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1459436979-7475-1-git-send-email-roger.pau@citrix.com>
This code is extracted from the FreeBSD blkfront implementation.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/libxl_freebsd.c | 54 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/tools/libxl/libxl_freebsd.c b/tools/libxl/libxl_freebsd.c
index e86e28c..c527455 100644
--- a/tools/libxl/libxl_freebsd.c
+++ b/tools/libxl/libxl_freebsd.c
@@ -27,8 +27,58 @@ int libxl__try_phy_backend(mode_t st_mode)
char *libxl__devid_to_localdev(libxl__gc *gc, int devid)
{
- /* TODO */
- return NULL;
+ /* This translation table has been copied from the FreeBSD blkfront code. */
+ const static struct vdev_info {
+ int major;
+ int shift;
+ int base;
+ const char *name;
+ } info[] = {
+ {3, 6, 0, "ada"}, /* ide0 */
+ {22, 6, 2, "ada"}, /* ide1 */
+ {33, 6, 4, "ada"}, /* ide2 */
+ {34, 6, 6, "ada"}, /* ide3 */
+ {56, 6, 8, "ada"}, /* ide4 */
+ {57, 6, 10, "ada"}, /* ide5 */
+ {88, 6, 12, "ada"}, /* ide6 */
+ {89, 6, 14, "ada"}, /* ide7 */
+ {90, 6, 16, "ada"}, /* ide8 */
+ {91, 6, 18, "ada"}, /* ide9 */
+
+ {8, 4, 0, "da"}, /* scsi disk0 */
+ {65, 4, 16, "da"}, /* scsi disk1 */
+ {66, 4, 32, "da"}, /* scsi disk2 */
+ {67, 4, 48, "da"}, /* scsi disk3 */
+ {68, 4, 64, "da"}, /* scsi disk4 */
+ {69, 4, 80, "da"}, /* scsi disk5 */
+ {70, 4, 96, "da"}, /* scsi disk6 */
+ {71, 4, 112, "da"}, /* scsi disk7 */
+ {128, 4, 128, "da"}, /* scsi disk8 */
+ {129, 4, 144, "da"}, /* scsi disk9 */
+ {130, 4, 160, "da"}, /* scsi disk10 */
+ {131, 4, 176, "da"}, /* scsi disk11 */
+ {132, 4, 192, "da"}, /* scsi disk12 */
+ {133, 4, 208, "da"}, /* scsi disk13 */
+ {134, 4, 224, "da"}, /* scsi disk14 */
+ {135, 4, 240, "da"}, /* scsi disk15 */
+
+ {202, 4, 0, "xbd"}, /* xbd */
+
+ {0, 0, 0, NULL},
+ };
+ int major = devid >> 8;
+ int minor = devid & 0xff;
+ int i;
+
+ if (devid & (1 << 28))
+ return GCSPRINTF("%s%d", "xbd", (devid & ((1 << 28) - 1)) >> 8);
+
+ for (i = 0; info[i].major; i++)
+ if (info[i].major == major)
+ return GCSPRINTF("%s%d", info[i].name,
+ info[i].base + (minor >> info[i].shift));
+
+ return GCSPRINTF("%s%d", "xbd", minor >> 4);
}
/* Hotplug scripts caller functions */
--
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:11 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 ` [PATCH v3 4/8] libxl: add support for disk hotplug scripts on FreeBSD Roger Pau Monne
2016-04-01 14:07 ` 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 ` Roger Pau Monne [this message]
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-7-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).