From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH v8 5/6] xl: Add new option dtdev Date: Tue, 12 May 2015 15:33:11 +0100 Message-ID: <1431441192-27897-6-git-send-email-julien.grall@citrix.com> References: <1431441192-27897-1-git-send-email-julien.grall@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsBFw-0002GM-30 for xen-devel@lists.xenproject.org; Tue, 12 May 2015 14:34:00 +0000 In-Reply-To: <1431441192-27897-1-git-send-email-julien.grall@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Wei Liu , ian.campbell@citrix.com, tim@xen.org, Julien Grall , Ian Jackson , stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org From: Julien Grall The option "dtdev" will be used to passthrough a device described in the device tree to a guest. Signed-off-by: Julien Grall Acked-by: Ian Campbell Cc: Ian Jackson Cc: Wei Liu --- Changes in v5: - Drop "non-PCI" in the commit message - Add Ian's ack Changes in v4: - Typoes in the documentation - Wrap the line in xl_cmdimpl.c Changes in v2: - libxl_device_dt has been rename to libxl_device_dtdev - use xrealloc instead of realloc --- docs/man/xl.cfg.pod.5 | 5 +++++ tools/libxl/xl_cmdimpl.c | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index fb8721f..a189091 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -789,6 +789,11 @@ More information about Xen gfx_passthru feature is available on the XenVGAPassthrough L wiki page. +=item B + +Specifies the host device tree nodes to passthrough to this guest. Each +DTDEV_PATH is the absolute path in the device tree. + =item B Allow guest to access specific legacy I/O ports. Each B diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 19bf103..51ab85a 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1169,7 +1169,7 @@ static void parse_config_data(const char *config_source, long l, vcpus = 0; XLU_Config *config; XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms; - XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian; + XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs; int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian; int pci_power_mgmt = 0; int pci_msitranslate = 0; @@ -1941,6 +1941,26 @@ skip_vfb: libxl_defbool_set(&b_info->u.pv.e820_host, true); } + if (!xlu_cfg_get_list (config, "dtdev", &dtdevs, 0, 0)) { + d_config->num_dtdevs = 0; + d_config->dtdevs = NULL; + for (i = 0; (buf = xlu_cfg_get_listitem(dtdevs, i)) != NULL; i++) { + libxl_device_dtdev *dtdev; + + d_config->dtdevs = xrealloc(d_config->dtdevs, + sizeof (libxl_device_dtdev) * (i + 1)); + dtdev = d_config->dtdevs + d_config->num_dtdevs; + libxl_device_dtdev_init(dtdev); + + dtdev->path = strdup(buf); + if (dtdev->path == NULL) { + fprintf(stderr, "unable to duplicate string for dtdevs\n"); + exit(-1); + } + d_config->num_dtdevs++; + } + } + switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) { case 0: { -- 2.1.4