From patchwork Tue Dec 29 11:31:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 7929791 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5DA75BEEE5 for ; Tue, 29 Dec 2015 11:36:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58AB020221 for ; Tue, 29 Dec 2015 11:36:25 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CE36201EC for ; Tue, 29 Dec 2015 11:36:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aDsVw-0001NA-7o; Tue, 29 Dec 2015 11:32:28 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aDsVu-0001MM-Is for xen-devel@lists.xen.org; Tue, 29 Dec 2015 11:32:26 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id 09/4B-25438-94F62865; Tue, 29 Dec 2015 11:32:25 +0000 X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1451388744!13681990!1 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55571 invoked from network); 29 Dec 2015 11:32:24 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-12.tower-27.messagelabs.com with SMTP; 29 Dec 2015 11:32:24 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 29 Dec 2015 03:32:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,495,1444719600"; d="scan'208";a="716774050" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.40]) by orsmga003.jf.intel.com with ESMTP; 29 Dec 2015 03:32:21 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Tue, 29 Dec 2015 19:31:50 +0800 Message-Id: <1451388711-18646-4-git-send-email-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.4.8 In-Reply-To: <1451388711-18646-1-git-send-email-haozhong.zhang@intel.com> References: <1451388711-18646-1-git-send-email-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Kevin Tian , Keir Fraser , Ian Campbell , Stefano Stabellini , Jun Nakajima , Andrew Cooper , Ian Jackson , Jan Beulich , Wei Liu Subject: [Xen-devel] [PATCH 3/4] tools/xl: add a new xl configuration 'nvdimm' X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This configure is used to specify vNVDIMM devices which are provided to the guest. xl parses this configuration and passes the result to qemu that is responsible to create vNVDIMM devices. Signed-off-by: Haozhong Zhang --- docs/man/xl.cfg.pod.5 | 19 +++++++++++++++++++ tools/libxl/libxl_dm.c | 15 +++++++++++++-- tools/libxl/libxl_types.idl | 9 +++++++++ tools/libxl/xl_cmdimpl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index 8899f75..a10d28e 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -962,6 +962,25 @@ FIFO-based event channel ABI support up to 131,071 event channels. Other guests are limited to 4095 (64-bit x86 and ARM) or 1023 (32-bit x86). +=item B + +Specifies the NVDIMM devices which are provided to the guest. + +Each B is a comma-separated list of C +settings, from the following list: + +=over 4 + +=item C + +Specifies the path to the file of the NVDIMM device, e.g. file=/dev/pmem0. + +=item C + +Specifies the size in Mbytes of the NVDIMM device. + +=back + =back =head2 Paravirtualised (PV) Guest Specific Options diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 0aaefd9..6fb4bbb 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -763,6 +763,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, const libxl_device_nic *nics = guest_config->nics; const int num_disks = guest_config->num_disks; const int num_nics = guest_config->num_nics; + const int num_nvdimms = guest_config->num_nvdimms; const libxl_vnc_info *vnc = libxl__dm_vnc(guest_config); const libxl_sdl_info *sdl = dm_sdl(guest_config); const char *keymap = dm_keymap(guest_config); @@ -1124,7 +1125,6 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, machinearg, max_ram_below_4g); } } - if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) { enum libxl_gfx_passthru_kind gfx_passthru_kind = libxl__detect_gfx_passthru_kind(gc, guest_config); @@ -1140,7 +1140,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, return ERROR_INVAL; } } - + if (num_nvdimms) + machinearg = libxl__sprintf(gc, "%s,nvdimm", machinearg); flexarray_append(dm_args, machinearg); for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) flexarray_append(dm_args, b_info->extra_hvm[i]); @@ -1154,6 +1155,16 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, flexarray_append(dm_args, GCSPRINTF("%"PRId64, ram_size)); if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { + for (i = 0; i < num_nvdimms; i++) { + flexarray_append(dm_args, "-device"); + flexarray_append(dm_args, + libxl__sprintf(gc, "pc-nvdimm,file=%s,size=%"PRIu64, + guest_config->nvdimms[i].file, + guest_config->nvdimms[i].size_mb)); + } + } + + if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) { if (b_info->u.hvm.hdtype == LIBXL_HDTYPE_AHCI) flexarray_append_pair(dm_args, "-device", "ahci,id=ahci0"); for (i = 0; i < num_disks; i++) { diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 9658356..0a955a1 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -617,6 +617,14 @@ libxl_device_vtpm = Struct("device_vtpm", [ ("uuid", libxl_uuid), ]) +libxl_device_nvdimm = Struct("device_nvdimm", [ + ("backend_domid", libxl_domid), + ("backend_domname", string), + ("devid", libxl_devid), + ("file", string), + ("size_mb", uint64), +]) + libxl_device_channel = Struct("device_channel", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -641,6 +649,7 @@ libxl_domain_config = Struct("domain_config", [ ("vfbs", Array(libxl_device_vfb, "num_vfbs")), ("vkbs", Array(libxl_device_vkb, "num_vkbs")), ("vtpms", Array(libxl_device_vtpm, "num_vtpms")), + ("nvdimms", Array(libxl_device_nvdimm, "num_nvdimms")), # a channel manifests as a console with a name, # see docs/misc/channels.txt ("channels", Array(libxl_device_channel, "num_channels")), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index f9933cb..2db7d45 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1255,6 +1255,49 @@ static void parse_vnuma_config(const XLU_Config *config, free(vcpu_parsed); } +/* + * NVDIMM config is in the format: + * nvdimm = [ 'file=path-to-pmem-dev,size=size-of-file-in-MByte', + * 'file=path-to-pmem-dev,size=size-of-file-in-MByte', + * ... ] + */ +static void parse_nvdimm_config(XLU_Config *config, + libxl_domain_config *d_config) +{ + XLU_ConfigList *nvdimms; + const char *buf; + + if (!xlu_cfg_get_list (config, "nvdimm", &nvdimms, 0, 0)) { + while ((buf = xlu_cfg_get_listitem(nvdimms, + d_config->num_nvdimms)) != NULL) { + libxl_device_nvdimm *nvdimm = + ARRAY_EXTEND_INIT(d_config->nvdimms, d_config->num_nvdimms, + libxl_device_nvdimm_init); + char *nvdimm_cfg_str = strdup(buf); + char *p, *p2; + + p = strtok(nvdimm_cfg_str, ","); + if (!p) + goto next_nvdimm; + do { + while (*p == ' ') + p++; + if ((p2 = strchr(p, '=')) == NULL) + break; + *p2 = '\0'; + if (!strcmp(p, "file")) { + nvdimm->file = strdup(p2 + 1); + } else if (!strcmp(p, "size")) { + nvdimm->size_mb = parse_ulong(p2 + 1); + } + } while ((p = strtok(NULL, ",")) != NULL); + + next_nvdimm: + free(nvdimm_cfg_str); + } + } +} + static void parse_config_data(const char *config_source, const char *config_data, int config_len, @@ -2392,6 +2435,8 @@ skip_vfb: } } + parse_nvdimm_config(config, d_config); + xlu_cfg_destroy(config); }