From patchwork Thu Mar 31 05:49:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 8707561 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1FA919F44D for ; Thu, 31 Mar 2016 05:52:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CCE420374 for ; Thu, 31 Mar 2016 05:52:10 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 121DC2034B for ; Thu, 31 Mar 2016 05:52:09 +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 1alVTl-00082D-BU; Thu, 31 Mar 2016 05:49:13 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1alVTj-00080F-L6 for xen-devel@lists.xen.org; Thu, 31 Mar 2016 05:49:11 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 5B/7A-06546-75ABCF65; Thu, 31 Mar 2016 05:49:11 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1459403350!14928674!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1962 invoked from network); 31 Mar 2016 05:49:10 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-10.tower-206.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 31 Mar 2016 05:49:10 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A0A2DAB5D; Thu, 31 Mar 2016 05:49:08 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org Date: Thu, 31 Mar 2016 07:49:02 +0200 Message-Id: <1459403346-28677-3-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1459403346-28677-1-git-send-email-jgross@suse.com> References: <1459403346-28677-1-git-send-email-jgross@suse.com> Cc: Juergen Gross , wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com, George.Dunlap@eu.citrix.com, ian.jackson@eu.citrix.com, cyliu@suse.com Subject: [Xen-devel] [PATCH v6 2/6] libxl: make libxl__need_xenpv_qemu() operate on domain config 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 libxl__need_xenpv_qemu() is called with configuration data for console, vfbs, disks and channels today in order to evaluate the need for starting a device model for a pv domain. The console data is local to the caller and setup in a way to never require a device model. All other data is taken from the domain config structure. In order to support other device backends via qemu change the interface of libxl__need_xenpv_qemu() to take the domain config structure as input instead of the single device arrays. Signed-off-by: Juergen Gross Acked-by: Wei Liu --- V6: Split patch into 2 as requested by Wei Liu V4: Return (negative) error value in case of failure, 0 or 1 else V2: Return false if libxl__get_domid() fails as requested by George Dunlap --- tools/libxl/libxl_create.c | 13 +++------- tools/libxl/libxl_dm.c | 60 +++++++++++++------------------------------- tools/libxl/libxl_internal.h | 5 +--- 3 files changed, 23 insertions(+), 55 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 763996c..0681103 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1313,18 +1313,13 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } init_console_info(gc, &console, 0); + console.backend_domid = state->console_domid; + libxl__device_console_add(gc, domid, &console, state, &device); + libxl__device_console_dispose(&console); - ret = libxl__need_xenpv_qemu(gc, 1, &console, - d_config->num_vfbs, d_config->vfbs, - d_config->num_disks, &d_config->disks[0], - d_config->num_channels, &d_config->channels[0]); + ret = libxl__need_xenpv_qemu(gc, d_config); if (ret < 0) goto error_out; - - console.backend_domid = state->console_domid; - libxl__device_console_add(gc, domid, &console, state, &device); - libxl__device_console_dispose(&console); - if (ret) { dcs->dmss.dm.guest_domid = domid; libxl__spawn_local_dm(egc, &dcs->dmss.dm); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index eb8961d..027d32b 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2114,61 +2114,37 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid) } /* Return 0 if no dm needed, 1 if needed and <0 if error. */ -int libxl__need_xenpv_qemu(libxl__gc *gc, - int nr_consoles, libxl__device_console *consoles, - int nr_vfbs, libxl_device_vfb *vfbs, - int nr_disks, libxl_device_disk *disks, - int nr_channels, libxl_device_channel *channels) +int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config) { - int i, ret = 0; + int i, ret; uint32_t domid; - /* - * qemu is required in order to support 2 or more consoles. So switch all - * backends to qemu if this is the case - */ - if (nr_consoles > 1) { - for (i = 0; i < nr_consoles; i++) - consoles[i].consback = LIBXL__CONSOLE_BACKEND_IOEMU; - ret = 1; + ret = libxl__get_domid(gc, &domid); + if (ret) { + LOG(ERROR, "unable to get domain id"); goto out; } - for (i = 0; i < nr_consoles; i++) { - if (consoles[i].consback == LIBXL__CONSOLE_BACKEND_IOEMU) { - ret = 1; - goto out; - } - } - - if (nr_vfbs > 0) { + if (d_config->num_vfbs > 0) { ret = 1; goto out; } - if (nr_disks > 0) { - ret = libxl__get_domid(gc, &domid); - if (ret) goto out; - for (i = 0; i < nr_disks; i++) { - if (disks[i].backend == LIBXL_DISK_BACKEND_QDISK && - disks[i].backend_domid == domid) { - ret = 1; - goto out; - } + for (i = 0; i < d_config->num_disks; i++) { + if (d_config->disks[i].backend == LIBXL_DISK_BACKEND_QDISK && + d_config->disks[i].backend_domid == domid) { + ret = 1; + goto out; } } - if (nr_channels > 0) { - ret = libxl__get_domid(gc, &domid); - if (ret) goto out; - for (i = 0; i < nr_channels; i++) { - if (channels[i].backend_domid == domid) { - /* xenconsoled is limited to the first console only. - Until this restriction is removed we must use qemu for - secondary consoles which includes all channels. */ - ret = 1; - goto out; - } + for (i = 0; i < d_config->num_channels; i++) { + if (d_config->channels[i].backend_domid == domid) { + /* xenconsoled is limited to the first console only. + Until this restriction is removed we must use qemu for + secondary consoles which includes all channels. */ + ret = 1; + goto out; } } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 345a764..fc7bdab 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1616,10 +1616,7 @@ _hidden int libxl__domain_build(libxl__gc *gc, _hidden const char *libxl__domain_device_model(libxl__gc *gc, const libxl_domain_build_info *info); _hidden int libxl__need_xenpv_qemu(libxl__gc *gc, - int nr_consoles, libxl__device_console *consoles, - int nr_vfbs, libxl_device_vfb *vfbs, - int nr_disks, libxl_device_disk *disks, - int nr_channels, libxl_device_channel *channels); + libxl_domain_config *d_config); /* * This function will fix reserved device memory conflict