From patchwork Wed Mar 22 13:09:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9638779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 046B460327 for ; Wed, 22 Mar 2017 13:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E97F827D5E for ; Wed, 22 Mar 2017 13:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE12128460; Wed, 22 Mar 2017 13:13:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 5A8AD27D5E for ; Wed, 22 Mar 2017 13:13:02 +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 1cqg1l-0000m6-0l; Wed, 22 Mar 2017 13:10:13 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqg1j-0000m0-DT for xen-devel@lists.xenproject.org; Wed, 22 Mar 2017 13:10:11 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 57/53-25093-2B772D85; Wed, 22 Mar 2017 13:10:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGLMWRWlGSWpSXmKPExsXitHRDpO6m8ks RBj2XuS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyNPf2MBbd1K968FWtg7FLqYuTkkBDwl2i4 vpgdxGYT0JGY+vQSaxcjB4eIgIrE7b0GIGFmgWKJv/+7mUFsYQFPia2zT7GAlLAIqEoc35QPE uYVcJeYfamNDWKinMT54z/ByoWApqyfOosNokZQ4uTMJywQIyUkDr54wTyBkXsWktQsJKkFjE yrGDWKU4vKUot0jQz1kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECw4ABCHYw/lk WcIhRkoNJSZTXXflShBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3qxcoJxgUWp6akVaZg4wIGHS Ehw8SiK8yQVAad7igsTc4sx0iNQpRl2OWw173jAJseTl56VKifOm5QEVCYAUZZTmwY2ARcclR lkpYV5GoKOEeApSi3IzS1DlXzGKczAqCfMeyAGawpOZVwK36RXQEUxAR5TtuQByREkiQkqqgV HI9ejKvIK0ghU57vc3PDzUE2U43XIix5zEy7futpetuy74rVhSPnXGI/PSZSVZinKdKvrL7X8 8+bin21TqldbL0MpZ/VMOy++7nXn58avkF6ecy3Q0uc3U3u/aUtR3aeen+wH1N8VNwj7/YVG8 nHS4I2Z78qMN7AFZC7a6fpEv14ldKdFl1aXEUpyRaKjFXFScCACh4q2uiQIAAA== X-Env-Sender: prvs=2479a8bc7=Paul.Durrant@citrix.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1490188208!40645683!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54281 invoked from network); 22 Mar 2017 13:10:09 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 22 Mar 2017 13:10:09 -0000 X-IronPort-AV: E=Sophos;i="5.36,205,1486425600"; d="scan'208";a="415364166" From: Paul Durrant To: Date: Wed, 22 Mar 2017 13:09:55 +0000 Message-ID: <1490188195-25209-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Wei Liu , Paul Durrant , Ian Jackson Subject: [Xen-devel] [PATCH RESEND] tools/libxl: add support for emulated NVMe drives 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-Virus-Scanned: ClamAV using ClamSMTP 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 --- Cc: Ian Jackson Cc: Wei Liu 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 =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,