From nobody Mon May 6 20:35:05 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1583242171; cv=none; d=zohomail.com; s=zohoarc; b=PuKn2+6bffL9JX4JxwIT95Q213NeFHuHdFqyqcUrPGjthdFpcJ9eyTYkxbWMaW/SumD10ph6fHyIFJP2BsRFQx3CEyBYNwPupo9+2RyWWt9QG2m0fZqnPEHa2AYC0W59mz3HJMEJJkvctDZRDvHgZUGH9Y6+BR/IYQo1yokC5hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583242171; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=WkZ0xAl5Dau00ZYr9ftZejELeyNp+Z8+Zxm0UtLz3EM=; b=U9VIDYSPIz4+f+hUo0uQKW+DFzJ373skd6ujeS80k8mVRJrFP4nFKAiBrclBwZSUsn1lilx3tC+XRTB8CAgLNLZbV5SoDUtcera4aUdvPUrP5YL+SPFqaBo1Td3pDse5eSEhVs/mRtNValwinf6EsD2W5X9mgVLsd+hwnsl2+M4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 158324217156199.83061753190498; Tue, 3 Mar 2020 05:29:31 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j97bU-00019D-P5; Tue, 03 Mar 2020 13:28:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j97bT-000196-8d for xen-devel@lists.xenproject.org; Tue, 03 Mar 2020 13:28:55 +0000 Received: from wout1-smtp.messagingengine.com (unknown [64.147.123.24]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ed5e40dc-5d52-11ea-94a0-bc764e2007e4; Tue, 03 Mar 2020 13:28:54 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 0FB9D9E8; Tue, 3 Mar 2020 08:28:52 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 03 Mar 2020 08:28:53 -0500 Received: from localhost.localdomain (x4e36fe47.dyn.telefonica.de [78.54.254.71]) by mail.messagingengine.com (Postfix) with ESMTPA id 952883280064; Tue, 3 Mar 2020 08:28:51 -0500 (EST) X-Inumbo-ID: ed5e40dc-5d52-11ea-94a0-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=aS9F76 Oi7vp/c9LnNBN1DALsqeSMFwjmhcbBXNME9pU=; b=2Qk2Xdgk+iOxdnPJolbPRq 6mr8gsQ08pOuSu1nf+xAMtKp/gekfoUmxu8wiGlukcfKY2oMCZ9fzLFz14v3cDnO PKxU97EG4QMxF3k41hiGsrzH1V4CApk1v/ukngnh/uvCz2QeIrnjoHvCuoqqGOuY KRIxP300HHoeE+dkJWwsNIEGx3OmGbZRT1GgSG5ryQrNjHI6cDwkQL4qcYjIiAp3 HrbQjHJR6QbxqXxUzi2qT8c9lmfFwonfJqPEqjKQdw1DwEbuUd35rZU8IcrHfgHV 5tIaixl8bCOW+7SRUM0CvnIkgkkURVDhp7UsTjf3yHRimCGKO5bkbOb82ZXO/Ztg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtiedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffogggtgfesthekredtredtjeenucfhrhhomheprfgrfigvlhcu ofgrrhgtiigvfihskhhiuceophgrfigvlhesihhnvhhishhisghlvghthhhinhhgshhlrg gsrdgtohhmqeenucfkphepjeekrdehgedrvdehgedrjedunecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphgrfigvlhesihhnvhhishhisghlvg hthhhinhhgshhlrggsrdgtohhm X-ME-Proxy: From: =?UTF-8?q?Pawe=C5=82=20Marczewski?= To: xen-devel@lists.xenproject.org Date: Tue, 3 Mar 2020 14:28:20 +0100 Message-Id: X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH v4] libxl: wait for console path before firing console_available X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , =?UTF-8?q?Pawe=C5=82=20Marczewski?= , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" If the path doesn't become available after LIBXL_INIT_TIMEOUT seconds, fail the domain creation. If we skip the bootloader, the TTY path will be set by xenconsoled. However, there is no guarantee that this will happen by the time we want to call the console_available callback, so we have to wait. Signed-off-by: Pawe=C5=82 Marczewski Reviewed-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Anthony PERARD --- Changed since v3 (after review by Anthony Perard): * use libxl__console_tty_path * move console_xswait_callback to proper place in file * refactor console_xswait_callback so that it has a single "out" section * move xswait_init to proper function (initiate_domain_create) * add xswait_stop to cleanup (domcreate_complete) * mention in commit message that we fail after a timeout Changed since v2 (after review by Marek Marczykowski-G=C3=B3recki): * replace hardcoded value with LIBXL_INIT_TIMEOUT Changed since v1: * use xswait mechanism to add a timeout tools/libxl/libxl_console.c | 4 +-- tools/libxl/libxl_create.c | 50 ++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_internal.h | 3 +++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 088a455b52..047d23d7ae 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -16,8 +16,8 @@ =20 #include "libxl_internal.h" =20 -static int libxl__console_tty_path(libxl__gc *gc, uint32_t domid, int cons= _num, - libxl_console_type type, char **tty_pat= h) +int libxl__console_tty_path(libxl__gc *gc, uint32_t domid, int cons_num, + libxl_console_type type, char **tty_path) { int rc; char *dom_path; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 3a7364e2ac..ada942bc8d 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -846,6 +846,8 @@ static void domcreate_devmodel_started(libxl__egc *egc, static void domcreate_attach_devices(libxl__egc *egc, libxl__multidev *multidev, int ret); +static void console_xswait_callback(libxl__egc *egc, libxl__xswait_state *= xswa, + int rc, const char *p); =20 /* Our own function to clean up and call the user's callback. * The final call in the sequence. */ @@ -1151,6 +1153,8 @@ static void initiate_domain_create(libxl__egc *egc, if (ret) goto error_out; =20 + libxl__xswait_init(&dcs->console_xswait); + if (restore_fd >=3D 0 || dcs->soft_reset) { LOGD(DEBUG, domid, "restoring, not running bootloader"); domcreate_bootloader_done(egc, &dcs->bl, 0); @@ -1705,6 +1709,7 @@ static void domcreate_attach_devices(libxl__egc *egc, int domid =3D dcs->guest_domid; libxl_domain_config *const d_config =3D dcs->guest_config; const libxl__device_type *dt; + char *tty_path; =20 if (ret) { LOGD(ERROR, domid, "unable to add %s devices", @@ -1728,9 +1733,24 @@ static void domcreate_attach_devices(libxl__egc *egc, return; } =20 - domcreate_console_available(egc, dcs); + ret =3D libxl__console_tty_path(gc, domid, 0, LIBXL_CONSOLE_TYPE_PV, &= tty_path); + if (ret) { + LOG(ERROR, "failed to get domain %d console tty path", + domid); + goto error_out; + } =20 - domcreate_complete(egc, dcs, 0); + dcs->console_xswait.ao =3D ao; + dcs->console_xswait.what =3D GCSPRINTF("domain %d console tty", domid); + dcs->console_xswait.path =3D tty_path; + dcs->console_xswait.timeout_ms =3D LIBXL_INIT_TIMEOUT * 1000; + dcs->console_xswait.callback =3D console_xswait_callback; + ret =3D libxl__xswait_start(gc, &dcs->console_xswait); + if (ret) { + LOG(ERROR, "unable to set up watch for domain %d console tty path", + domid); + goto error_out; + } =20 return; =20 @@ -1739,6 +1759,30 @@ error_out: domcreate_complete(egc, dcs, ret); } =20 +static void console_xswait_callback(libxl__egc *egc, libxl__xswait_state *= xswa, + int rc, const char *p) +{ + EGC_GC; + libxl__domain_create_state *dcs =3D CONTAINER_OF(xswa, *dcs, console_x= swait); + + if (rc) { + if (rc =3D=3D ERROR_TIMEDOUT) + LOG(ERROR, "%s: timed out", xswa->what); + goto out; + } + + if (p && p[0] !=3D '\0') { + domcreate_console_available(egc, dcs); + goto out; + } + + return; + +out: + libxl__xswait_stop(gc, xswa); + domcreate_complete(egc, dcs, rc); +} + static void domcreate_complete(libxl__egc *egc, libxl__domain_create_state *dcs, int rc) @@ -1747,6 +1791,8 @@ static void domcreate_complete(libxl__egc *egc, libxl_domain_config *const d_config =3D dcs->guest_config; libxl_domain_config *d_config_saved =3D &dcs->guest_config_saved; =20 + libxl__xswait_stop(gc, &dcs->console_xswait); + libxl__domain_build_state_dispose(&dcs->build_state); =20 if (!rc && d_config->b_info.exec_ssidref) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4936446069..19d11cc6d6 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1517,6 +1517,8 @@ _hidden char *libxl__domain_device_libxl_path(libxl__= gc *gc, uint32_t domid, uin libxl__device_kind device_ki= nd); _hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path, libxl__device *dev); +_hidden int libxl__console_tty_path(libxl__gc *gc, uint32_t domid, int con= s_num, + libxl_console_type type, char **tty_pa= th); _hidden int libxl__device_destroy(libxl__gc *gc, libxl__device *dev); _hidden int libxl__wait_for_backend(libxl__gc *gc, const char *be_path, const char *state); @@ -4180,6 +4182,7 @@ struct libxl__domain_create_state { /* necessary if the domain creation failed and we have to destroy it */ libxl__domain_destroy_state dds; libxl__multidev multidev; + libxl__xswait_state console_xswait; }; =20 _hidden int libxl__device_nic_set_devids(libxl__gc *gc, --=20 2.21.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel