From nobody Mon Apr 29 21:03:04 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=1583157305; cv=none; d=zohomail.com; s=zohoarc; b=VXJBwoGE1WtBSgP09hzbfAJKymxUwcQ1RBskmt+5/mdufDrZYPUQP7GMwcc39dmh0aKA++GFeF3rSPLLoWzprjwd+YJmpnChH8Z804rKjGkbE8e01Si3GKX1JNnW08mJDtBC8Hc4auHOES/xtq+WW2VqIqfzHPPtPo7LG95PgM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583157305; 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=+nlhOU1iYpTU4hDDu4UddIOkpLTTtJzvk7JSySgJ6NM=; b=MMbx3eEj74Fj79Pfy9VeOx+LvHR8OJJlNrR8H4HaPHfVYDT10/FZB/TGV8/Q50YLmh2HhjqODoe9Q6aLtP1VLewHNwjbybNrcwEDrEuQPNClXgMFopSlkk/8iC2UOjE4zUH07vLTFLrKQUT89L++LoWCQ448tRmLdfMu3EDi93A= 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 1583157305583937.0628600353466; Mon, 2 Mar 2020 05:55:05 -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 1j8lWb-0001sn-Io; Mon, 02 Mar 2020 13:54:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j8lWZ-0001sh-Su for xen-devel@lists.xenproject.org; Mon, 02 Mar 2020 13:54:24 +0000 Received: from out4-smtp.messagingengine.com (unknown [66.111.4.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 526ee4b6-5c8d-11ea-b122-bc764e2007e4; Mon, 02 Mar 2020 13:54:23 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id EDA6220E72; Mon, 2 Mar 2020 08:54:22 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 02 Mar 2020 08:54:22 -0500 Received: from localhost.localdomain (unknown [83.97.23.29]) by mail.messagingengine.com (Postfix) with ESMTPA id 7DB743280069; Mon, 2 Mar 2020 08:54:21 -0500 (EST) X-Inumbo-ID: 526ee4b6-5c8d-11ea-b122-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=vKIf9M GQwq3dQU0QnLxXOiTMXYw1VtMEamO9sCLGYOg=; b=igl83SfO4YCz+E5qsQKui1 yeu0XpnKctNxQz78DiIAOK91HrCtZRavm627aHq6qDEg/gVS7U0i837uKf/4AlVQ ou8q5OXgvmPL1fZz+VrGEuJLAIozUk7W3BMQhVt2Fv7hpTSmK0fiVwKr5yc7Dn/K q5muCn0L5sAo6jMAND1i2z6WU0DdP6rHKihH6QR3I9Vu92gMnAYQ41n/vprot8wn 98Ru6Xq8vBoHBs1WY/2cLfG6Nc/wJx/7ZninHyK/kE1/NWTYI78zWczOFiJSrXPw 6XnrLzJP4bwSvDE9yZOmTfH2dCSmvA4uNZGO7TaEJzDlMTz9ehpS9dR1t5I8oWDQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtgedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffogggtgfesthekredtredtjeenucfhrhhomheprfgrfigvlhcu ofgrrhgtiigvfihskhhiuceophgrfigvlhesihhnvhhishhisghlvghthhhinhhgshhlrg gsrdgtohhmqeenucfkphepkeefrdeljedrvdefrddvleenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehprgifvghlsehinhhvihhsihgslhgvth hhihhnghhslhgrsgdrtghomh X-ME-Proxy: From: =?UTF-8?q?Pawe=C5=82=20Marczewski?= To: xen-devel@lists.xenproject.org Date: Mon, 2 Mar 2020 14:54:08 +0100 Message-Id: X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH v3] 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 we skip the bootloader, the TTY path will be set for 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 --- Changed since v2: * replace hardcoded value with LIBXL_INIT_TIMEOUT Changed since v1: * use xswait mechanism to add a timeout tools/libxl/libxl_create.c | 43 +++++++++++++++++++++++++++++++++--- tools/libxl/libxl_internal.h | 1 + 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 3a7364e2ac..25ab6f6ff4 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1190,6 +1190,33 @@ static void domcreate_console_available(libxl__egc *= egc, dcs->aop_console_how.for_event)); } =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); + char *dompath =3D libxl__xs_get_dompath(gc, dcs->guest_domid); + char *tty_path =3D GCSPRINTF("%s/console/tty", dompath); + char *tty; + + if (rc) { + if (rc =3D=3D ERROR_TIMEDOUT) + LOG(ERROR, "%s: timed out", xswa->what); + libxl__xswait_stop(gc, xswa); + domcreate_complete(egc, dcs, rc); + return; + } + + tty =3D libxl__xs_read(gc, XBT_NULL, tty_path); + + if (tty && tty[0] !=3D '\0') { + libxl__xswait_stop(gc, xswa); + + domcreate_console_available(egc, dcs); + domcreate_complete(egc, dcs, 0); + } +} + static void domcreate_bootloader_done(libxl__egc *egc, libxl__bootloader_state *bl, int rc) @@ -1728,9 +1755,18 @@ static void domcreate_attach_devices(libxl__egc *egc, return; } =20 - domcreate_console_available(egc, dcs); - - 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 GCSPRINTF("%s/console/tty", + libxl__xs_get_dompath(gc, domid)); + 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 path", + domid); + goto error_out; + } =20 return; =20 @@ -1861,6 +1897,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_dom= ain_config *d_config, =20 libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out =3D domid; + libxl__xswait_init(&cdcs->dcs.console_xswait); =20 initiate_domain_create(egc, &cdcs->dcs); =20 diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4936446069..d8129417dc 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4180,6 +4180,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