From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
Paul Durrant <paul.durrant@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH RESEND] tools/libxl: add support for emulated NVMe drives
Date: Wed, 22 Mar 2017 13:09:55 +0000 [thread overview]
Message-ID: <1490188195-25209-1-git-send-email-paul.durrant@citrix.com> (raw)
Upstream QEMU supports emulation of NVM Express a.k.a. NVMe drives.
This patch adds a new vdev type into libxl to allow such drives to be
presented to HVM guests. Because the purpose of the new vdev is purely
to configure emulation, the syntax only supports specification of
whole disks. Also there is no need to introduce a new concrete VBD
encoding for NVMe drives.
NOTE: QEMU's emulation only supports a single NVMe namespace, so the
vdev syntax does not include specification of a namespace.
Also, current versions of SeaBIOS do not support booting from
NVMe devices, so the vdev should only be used for secondary
drives.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
NOTE FOR COMMITTERS:
Support for unplug of NVMe drives was added into QEMU by the following
commit:
http://git.qemu-project.org/?p=qemu.git;a=commit;h=090fa1c8
---
docs/man/xen-vbd-interface.markdown.7 | 15 ++++++++-------
docs/man/xl-disk-configuration.pod.5 | 4 ++--
tools/libxl/libxl_device.c | 8 ++++++++
tools/libxl/libxl_dm.c | 6 ++++++
4 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/docs/man/xen-vbd-interface.markdown.7 b/docs/man/xen-vbd-interface.markdown.7
index 1c996bf..8fd378c 100644
--- a/docs/man/xen-vbd-interface.markdown.7
+++ b/docs/man/xen-vbd-interface.markdown.7
@@ -8,12 +8,12 @@ emulated IDE, AHCI or SCSI disks.
The abstract interface involves specifying, for each block device:
* Nominal disk type: Xen virtual disk (aka xvd*, the default); SCSI
- (sd*); IDE or AHCI (hd*).
+ (sd*); IDE or AHCI (hd*); NVMe.
- For HVM guests, each whole-disk hd* and and sd* device is made
- available _both_ via emulated IDE resp. SCSI controller, _and_ as a
- Xen VBD. The HVM guest is entitled to assume that the IDE or SCSI
- disks available via the emulated IDE controller target the same
+ For HVM guests, each whole-disk hd*, sd* or nvme* device is made
+ available _both_ via emulated IDE, SCSI controller or NVMe drive
+ respectively _and_ as a Xen VBD. The HVM guest is entitled to
+ assume that the disks available via the emulation target the same
underlying devices as the corresponding Xen VBD (ie, multipath).
In hd* case with hdtype=ahci, disk will be AHCI via emulated
ich9 disk controller.
@@ -42,8 +42,7 @@ The abstract interface involves specifying, for each block device:
treat each vbd as it would a partition or slice or LVM volume (for
example by putting or expecting a filesystem on it).
- Non-whole disk devices cannot be passed through to HVM guests via
- the emulated IDE or SCSI controllers.
+ Only whole disk devices can be emulated for HVM guests.
Configuration file syntax
@@ -56,6 +55,7 @@ The config file syntaxes are, for example
d536p37 xvdtq37 Xen virtual disk 536 partition 37
sdb3 SCSI disk 1 partition 3
hdc2 IDE disk 2 partition 2
+ nvme0 NVMe disk 0 (whole disk only)
The d*p* syntax is not supported by xm/xend.
@@ -78,6 +78,7 @@ encodes the information above as follows:
8 << 8 | disk << 4 | partition sd, disks and partitions up to 15
3 << 8 | disk << 6 | partition hd, disks 0..1, partitions 0..63
22 << 8 | (disk-2) << 6 | partition hd, disks 2..3, partitions 0..63
+ 1 << 28 | disk << 8 nvme, all disks, whole disk only
2 << 28 onwards reserved for future use
other values less than 1 << 28 deprecated / reserved
diff --git a/docs/man/xl-disk-configuration.pod.5 b/docs/man/xl-disk-configuration.pod.5
index d3eedc1..c40418e 100644
--- a/docs/man/xl-disk-configuration.pod.5
+++ b/docs/man/xl-disk-configuration.pod.5
@@ -127,8 +127,8 @@ designation in some specifications). L<xen-vbd-interface(7)>
=item Supported values
-hd[x], xvd[x], sd[x] etc. Please refer to the above specification for
-further details.
+hd[x], xvd[x], sd[x], nvme[x] etc. Please refer to the above specification
+for further details.
=item Deprecated values
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 5e96676..bd06904 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -532,6 +532,14 @@ int libxl__device_disk_dev_number(const char *virtpath, int *pdisk,
if (ppartition) *ppartition = partition;
return (8 << 8) | (disk << 4) | partition;
}
+ if (!memcmp(virtpath, "nvme", 4)) {
+ disk = strtoul(virtpath + 4, &ep, 10);
+ if (*ep)
+ return -1;
+ if (pdisk) *pdisk = disk;
+ if (ppartition) *ppartition = 0;
+ return (1 << 28) | (disk << 8);
+ }
return -1;
}
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 4344c53..9efb4b7 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1568,6 +1568,12 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
format,
&disks[i],
colo_mode);
+ } else if (strncmp(disks[i].vdev, "nvme", 4) == 0) {
+ flexarray_vappend(dm_args,
+ "-drive", GCSPRINTF("file=%s,if=none,id=nvmedisk-%d,format=%s,cache=writeback", target_path, disk, format),
+ "-device", GCSPRINTF("nvme,drive=nvmedisk-%d,serial=%d", disk, disk),
+ NULL);
+ continue;
} else if (disk < 6 && b_info->u.hvm.hdtype == LIBXL_HDTYPE_AHCI) {
if (!disks[i].readwrite) {
LOGD(ERROR, guest_domid,
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2017-03-22 13:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 13:09 Paul Durrant [this message]
2017-03-22 14:16 ` [PATCH RESEND] tools/libxl: add support for emulated NVMe drives Ian Jackson
2017-03-22 14:22 ` Paul Durrant
2017-03-22 15:01 ` Ian Jackson
2017-03-22 15:21 ` Paul Durrant
2017-03-22 16:03 ` Ian Jackson
2017-03-22 16:31 ` Paul Durrant
2017-03-22 16:45 ` Paul Durrant
2017-03-22 17:02 ` Ian Jackson
2017-03-22 17:16 ` Paul Durrant
2017-03-22 17:31 ` Ian Jackson
2017-03-22 17:41 ` Paul Durrant
2017-03-22 17:48 ` Ian Jackson
2017-03-23 8:55 ` Paul Durrant
-- strict thread matches above, loose matches on Subject: below --
2017-01-13 14:00 Paul Durrant
2017-01-18 10:28 ` Wei Liu
2017-01-18 10:51 ` Paul Durrant
2017-01-18 12:02 ` Wei Liu
2017-01-18 12:15 ` Paul Durrant
2017-01-18 12:20 ` Wei Liu
2017-01-18 15:07 ` Wei Liu
2017-01-19 8:58 ` Paul Durrant
2017-01-19 11:18 ` Wei Liu
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=1490188195-25209-1-git-send-email-paul.durrant@citrix.com \
--to=paul.durrant@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).