From patchwork Mon Sep 11 04:38:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9946617 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 277F36035D for ; Mon, 11 Sep 2017 04:42:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E1E427D0C for ; Mon, 11 Sep 2017 04:42:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1314E2837E; Mon, 11 Sep 2017 04:42:11 +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 A0AA627D0C for ; Mon, 11 Sep 2017 04:42:10 +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 1drGW1-0003XG-Tv; Mon, 11 Sep 2017 04:40:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drGW0-0003Rs-2t for xen-devel@lists.xen.org; Mon, 11 Sep 2017 04:40:08 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id C7/8B-03093-7A316B95; Mon, 11 Sep 2017 04:40:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXS1tYhortceFu kwXk5iyUfF7M4MHoc3f2bKYAxijUzLym/IoE1o2dRJ1vBUYGKjTOaWBoYp/J2MXJxCAlMZ5S4 eXELUxcjJ4eEAK/EkWUzWLsYOYDsAImVp6shanoZJfasWgBWwyagL7Hi8UFWEFtEQFri2ufLj CA2s8AfRol7n2RBeoUF0iSOv/IACbMIqEocfzyXBcTmFbCTaPjbxwqxSl5iV9tFMJsTKH7w5T tmEFtIwFZiwekFrBMYeRcwMqxi1ChOLSpLLdI1MtdLKspMzyjJTczM0TU0MNPLTS0uTkxPzUl MKtZLzs/dxAgMBQYg2MG4eG3gIUZJDiYlUd53x7dECvEl5adUZiQWZ8QXleakFh9ilOHgUJLg VRHaFikkWJSanlqRlpkDDEqYtAQHj5IIbxRImre4IDG3ODMdInWKUZej4+bdP0xCLHn5ealS4 rxyIEUCIEUZpXlwI2ARcolRVkqYlxHoKCGegtSi3MwSVPlXjOIcjErCvBEgU3gy80rgNr0COo IJ6AieS1tAjihJREhJNTDO/i59oiVMZK7o/Yuumf+unKwT6QtR6tp7ZH23zOTPi38qHCq/rvk 3Mknu4r66swVvf2e47VAW93uj8lLoQdzLlRGVt42D1A39pTcxTVxUIDFLdirvk6O/X/Ttu/87 8f0y1wi1sMeWayO/y9VM7/n1PvadxielOXxRwiqTJ03JWVYja8zgsniJEktxRqKhFnNRcSIAS KJaT4sCAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1505104735!56506342!32 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52320 invoked from network); 11 Sep 2017 04:40:06 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-2.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2017 04:40:06 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2017 21:40:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,376,1500966000"; d="scan'208"; a="1217078643" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by fmsmga002.fm.intel.com with ESMTP; 10 Sep 2017 21:40:04 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 11 Sep 2017 12:38:18 +0800 Message-Id: <20170911043820.14617-38-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170911043820.14617-1-haozhong.zhang@intel.com> References: <20170911043820.14617-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Wei Liu , Ian Jackson , Chao Peng , Dan Williams Subject: [Xen-devel] [RFC XEN PATCH v3 37/39] tools/libxl: allow aborting domain creation on fatal QMP init errors 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-Virus-Scanned: ClamAV using ClamSMTP If some errors happening during QMP initialization can affect the proper work of a domain, it'd be better to treat them as fatal errors and abort the creation of that domain. The existing types of QMP initialization errors are not treated as fatal, and do not abort the domain creation as before. Signed-off-by: Haozhong Zhang --- Cc: Ian Jackson Cc: Wei Liu --- tools/libxl/libxl_create.c | 4 +++- tools/libxl/libxl_qmp.c | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 9123585b52..3e05ea09e9 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1507,7 +1507,9 @@ static void domcreate_devmodel_started(libxl__egc *egc, if (dcs->sdss.dm.guest_domid) { if (d_config->b_info.device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl__qmp_initializations(gc, domid, d_config); + ret = libxl__qmp_initializations(gc, domid, d_config); + if (ret == ERROR_BADFAIL) + goto error_out; } } diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index eab993aca9..e1eb47c1d2 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -1175,11 +1175,12 @@ int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, { const libxl_vnc_info *vnc = libxl__dm_vnc(guest_config); libxl__qmp_handler *qmp = NULL; - int ret = 0; + bool ignore_error = true; + int ret = -1; qmp = libxl__qmp_initialize(gc, domid); if (!qmp) - return -1; + goto out; ret = libxl__qmp_query_serial(qmp); if (!ret && vnc && vnc->passwd) { ret = qmp_change(gc, qmp, "vnc", "password", vnc->passwd); @@ -1189,7 +1190,9 @@ int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, ret = qmp_query_vnc(qmp); } libxl__qmp_close(qmp); - return ret; + + out: + return ret ? (ignore_error ? ERROR_FAIL : ERROR_BADFAIL) : 0; } /*