From patchwork Fri Jul 28 16:42:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 9869131 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 9918960382 for ; Fri, 28 Jul 2017 16:44:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC7ED288C4 for ; Fri, 28 Jul 2017 16:44:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A120B288CF; Fri, 28 Jul 2017 16:44:51 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 ACA95288C4 for ; Fri, 28 Jul 2017 16:44:49 +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 1db8LO-0000Hj-V1; Fri, 28 Jul 2017 16:42:30 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1db8LO-0000HO-5B for xen-devel@lists.xen.org; Fri, 28 Jul 2017 16:42:30 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 60/7D-02177-5796B795; Fri, 28 Jul 2017 16:42:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRWlGSWpSXmKPExsXilM8iqVuSWR1 p8POlucWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnFzxT7Ggm0qFfdb+1gbGC9IdzFycggJrGKU +LI1EcLOlvi++j9rFyMXB4vAJFaJ5c97mUASEgKeEu/aQRIgtrPE9AunWUCKhAQOMUo0TdzPD pJgEwiVaN8+A6xIREBa4trny4wgRcwCcxklZmz4yAaSEBYIkThy5zlYEYuAqsTG/4/AmnkF/C We3+1jg9ggJ7HvVQNQMwcHp0CAxNXdJSCmEFDJ0xvVENWCEidnPmEBCTMLqEusnycEEuYXUJL Yth5kKydQWF6ieets5gmMwrOQdMxC6JiFpGoBI/MqRo3i1KKy1CJdIwu9pKLM9IyS3MTMHF1D A1O93NTi4sT01JzEpGK95PzcTYzAEK9nYGDcwdi3yu8QoyQHk5Io702z6kghvqT8lMqMxOKM+ KLSnNTiQ4waHBwCm9euvsAoxZKXn5eqJMGbmAFUJ1iUmp5akZaZA4xCmFIJDh4lEV5NkDRvcU FibnFmOkTqFKMxx52+DV+YOF5N+P+NSQhskpQ47+N0oFIBkNKM0jy4QbDkcIlRVkqYl5GBgUG IpyC1KDezBFX+FaM4B6OSMK8gyEKezLwSuH2vgE5hAjplYlMlyCkliQgpqQZG4xMvhSYelfp/ UL/gceP3PbGWfemZ4pwnBPi+nv24+H/LUdXIssUe0549Tp/Fk1VqXn+QLaejY1++QuAS3a68F Von9MrZp/xgOT+t/5LYx9TgiorzD1/+id929afSV9W1nc/bVt7Xf9G9uqJfdJu7A3MsV3Rsjb TH+blKN9uzeP7piJbU/LBRYinOSDTUYi4qTgQA7p6AXwkDAAA= X-Env-Sender: marmarek@invisiblethingslab.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1501260148!104876750!1 X-Originating-IP: [66.111.4.25] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTExLjQuMjUgPT4gNDQ5ODE=\n X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19730 invoked from network); 28 Jul 2017 16:42:28 -0000 Received: from out1-smtp.messagingengine.com (HELO out1-smtp.messagingengine.com) (66.111.4.25) by server-4.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Jul 2017 16:42:28 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id EBE7320D8F; Fri, 28 Jul 2017 12:42:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Fri, 28 Jul 2017 12:42:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=B8jNnquVeucel9KxYVsIqzt27u4RYqE3VG4Vy9S6A7U=; b=iJpMxwAx WvDzbDbpUcjghm8wr4HMvwx44iwpXJjvnduTih5jGKknTPiCeByM/aWeZUEkUViF N9QlLp6/bj3Z2A/2p8c1UQgLjyccg814pPIbAFbPlGll27u+N8OR3DkLbQ+JArkr GkQ9EL4dcb9g6UhpwtnObIEdGWEQIhFDOlvpUx3WpGIWLFYN+LFzvgBQplA3YAGe H1JeBgepedczOg4fl0od+9ae4XoSFdsuuINhlLNxrAwopz34DgZtrRoa8Mlg1o6I 7YLiYRebvWAcC/hJOd5JecggI/k5H6Xu8cJFbjzMN0tScRpnESQ3+ZKDmoX8NtxL LNt87QxfeI8jHA== X-ME-Sender: X-Sasl-enc: B0Tfnvey6QEPtu10SMWG3H70dmCUBY4YWI32Jd6zxM/K 1501260147 Received: from devel-3rdparty.localdomain (89-70-103-23.dynamic.chello.pl [89.70.103.23]) by mail.messagingengine.com (Postfix) with ESMTPA id DEAEF7E5EC; Fri, 28 Jul 2017 12:42:26 -0400 (EDT) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xen.org Date: Fri, 28 Jul 2017 18:42:14 +0200 Message-Id: <1501260134-11837-2-git-send-email-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1501260134-11837-1-git-send-email-marmarek@invisiblethingslab.com> References: <1501260134-11837-1-git-send-email-marmarek@invisiblethingslab.com> MIME-Version: 1.0 Organization: Invisible Things Lab Cc: Wei Liu , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [Xen-devel] [PATCH v2 2/2] libxl: do not start dom0 qemu for stubdomain when not needed 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 Do not setup vfb+vkb when no access method was configured. Then check if qemu is really needed. The only not configurable thing forcing qemu running in dom0 after this change are consoles used to save/restore. But even in that case, there is much smaller part of qemu exposed. Signed-off-by: Marek Marczykowski-Górecki Acked-by: Wei Liu --- tools/libxl/libxl_dm.c | 54 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 44ebd70..e0e6a99 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1868,13 +1868,17 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) ret = libxl__domain_build_info_setdefault(gc, &dm_config->b_info); if (ret) goto out; - GCNEW(vfb); - GCNEW(vkb); - libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, vfb, vkb); - dm_config->vfbs = vfb; - dm_config->num_vfbs = 1; - dm_config->vkbs = vkb; - dm_config->num_vkbs = 1; + if (libxl_defbool_val(guest_config->b_info.u.hvm.vnc.enable) + || libxl_defbool_val(guest_config->b_info.u.hvm.spice.enable) + || libxl_defbool_val(guest_config->b_info.u.hvm.sdl.enable)) { + GCNEW(vfb); + GCNEW(vkb); + libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, vfb, vkb); + dm_config->vfbs = vfb; + dm_config->num_vfbs = 1; + dm_config->vkbs = vkb; + dm_config->num_vkbs = 1; + } stubdom_state->pv_kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", libxl__xenfirmwaredir_path()); @@ -1959,6 +1963,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc, libxl__domain_build_state *const d_state = sdss->dm.build_state; libxl__domain_build_state *const stubdom_state = &sdss->dm_state; uint32_t dm_domid = sdss->pvqemu.guest_domid; + int need_qemu; if (ret) { LOGD(ERROR, guest_domid, "error connecting disk devices"); @@ -1975,12 +1980,16 @@ static void spawn_stub_launch_dm(libxl__egc *egc, if (ret) goto out; } - ret = libxl__device_vfb_add(gc, dm_domid, &dm_config->vfbs[0]); - if (ret) - goto out; - ret = libxl__device_vkb_add(gc, dm_domid, &dm_config->vkbs[0]); - if (ret) - goto out; + if (dm_config->num_vfbs) { + ret = libxl__device_vfb_add(gc, dm_domid, &dm_config->vfbs[0]); + if (ret) + goto out; + } + if (dm_config->num_vkbs) { + ret = libxl__device_vkb_add(gc, dm_domid, &dm_config->vkbs[0]); + if (ret) + goto out; + } if (guest_config->b_info.u.hvm.serial) num_console++; @@ -1988,7 +1997,6 @@ static void spawn_stub_launch_dm(libxl__egc *egc, console = libxl__calloc(gc, num_console, sizeof(libxl__device_console)); for (i = 0; i < num_console; i++) { - libxl__device device; console[i].devid = i; console[i].consback = LIBXL__CONSOLE_BACKEND_IOEMU; /* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging @@ -2005,6 +2013,9 @@ static void spawn_stub_launch_dm(libxl__egc *egc, if (ret) goto out; console[i].output = GCSPRINTF("file:%s", filename); free(filename); + /* will be changed back to LIBXL__CONSOLE_BACKEND_IOEMU if qemu + * will be in use */ + console[i].consback = LIBXL__CONSOLE_BACKEND_XENCONSOLED; break; case STUBDOM_CONSOLE_SAVE: console[i].output = GCSPRINTF("file:%s", @@ -2019,6 +2030,14 @@ static void spawn_stub_launch_dm(libxl__egc *egc, console[i].output = "pty"; break; } + } + + need_qemu = libxl__need_xenpv_qemu(gc, dm_config); + + for (i = 0; i < num_console; i++) { + libxl__device device; + if (need_qemu) + console[i].consback = LIBXL__CONSOLE_BACKEND_IOEMU; ret = libxl__device_console_add(gc, dm_domid, &console[i], i == STUBDOM_CONSOLE_LOGGING ? stubdom_state : NULL, &device); @@ -2032,7 +2051,12 @@ static void spawn_stub_launch_dm(libxl__egc *egc, sdss->pvqemu.build_state = &sdss->dm_state; sdss->pvqemu.callback = spawn_stubdom_pvqemu_cb; - libxl__spawn_local_dm(egc, &sdss->pvqemu); + if (!need_qemu) { + /* If dom0 qemu not needed, do not launch it */ + spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, 0); + } else { + libxl__spawn_local_dm(egc, &sdss->pvqemu); + } return;