From patchwork Fri Jan 13 13:56: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: 9515709 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 C8F2B60762 for ; Fri, 13 Jan 2017 13:59:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC093286B2 for ; Fri, 13 Jan 2017 13:59:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0C28286B9; Fri, 13 Jan 2017 13:59:50 +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 17E7D286B2 for ; Fri, 13 Jan 2017 13:59:50 +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 1cS2Mg-0008F2-5P; Fri, 13 Jan 2017 13:57:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cS2Me-0008Eh-He for xen-devel@lists.xenproject.org; Fri, 13 Jan 2017 13:57:56 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id CB/46-06501-3ECD8785; Fri, 13 Jan 2017 13:57:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXitHRDpO7jOxU RBrP2iVh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBk3LsxiLXimXfF59RXWBsbNCl2MnBwSAv4S kx5/YgGx2QR0JKY+vcTaxcjBISKgInF7rwFImFlAS6Jh4hImEFtYwEli5tZlbCA2i4CqxMIbp 9hBbF4Bd4kZmxtYIEbKSZw//pMZxBYCGrN+6iw2iBpBiZMzn7BAzJSQOPjiBfMERu5ZSFKzkK QWMDKtYtQoTi0qSy3SNTTSSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCrWS87P3cQIDAUGINj B2DfL+RCjJAeTkijvd9WKCCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvH9uA+UEi1LTUyvSMnOA QQmTluDgURLhrQFJ8xYXJOYWZ6ZDpE4x6nJ82XnmJZMQS15+XqqUOO8skCIBkKKM0jy4EbAIu cQoKyXMywh0lBBPQWpRbmYJqvwrRnEORiVh3iaQKTyZeSVwm14BHcEEdMRFm3KQI0oSEVJSDY wmE4X49l59aFTcpyux8aWoEuOflgbjV8feRJxZbVTbzT89rWFucL1E55XT4nL2Dj9NBIwrj6g fj1y0Mef3hNn1/HXrLRx2W3bl/A+aOLebaX7z67+Guft1tujPY5jRYhd3SlD4qqlVx51dr2Js th/Z5m9tMXfCD505HJcyFfS3fO0Tfp+/978SS3FGoqEWc1FxIgBOr1jAiwIAAA== X-Env-Sender: prvs=179d013b4=Paul.Durrant@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1484315873!79594436!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.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50972 invoked from network); 13 Jan 2017 13:57:55 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jan 2017 13:57:55 -0000 X-IronPort-AV: E=Sophos;i="5.33,221,1477958400"; d="scan'208";a="399672353" From: Paul Durrant To: Date: Fri, 13 Jan 2017 13:56:55 +0000 Message-ID: <1484315815-10118-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Paul Durrant Subject: [Xen-devel] [PATCH] 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 --- 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 b2aeefc..63a738c 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 281058d..980dad1 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1430,6 +1430,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,