From patchwork Mon Mar 2 13:54:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Marczewski?= X-Patchwork-Id: 11415669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09E0C1395 for ; Mon, 2 Mar 2020 13:55:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA9F720656 for ; Mon, 2 Mar 2020 13:55:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="igl83SfO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA9F720656 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Inumbo-ID: 526ee4b6-5c8d-11ea-b122-bc764e2007e4 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 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: 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) From: =?utf-8?q?Pawe=C5=82_Marczewski?= 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_Marczew?= =?utf-8?q?ski?= , Ian Jackson , =?utf-8?q?Marek_Marczykowski-G?= =?utf-8?q?=C3=B3recki?= , Wei Liu 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ł Marczewski Reviewed-by: Marek Marczykowski-Górecki --- 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)); } +static void console_xswait_callback(libxl__egc *egc, libxl__xswait_state *xswa, + int rc, const char *p) +{ + EGC_GC; + libxl__domain_create_state *dcs = CONTAINER_OF(xswa, *dcs, console_xswait); + char *dompath = libxl__xs_get_dompath(gc, dcs->guest_domid); + char *tty_path = GCSPRINTF("%s/console/tty", dompath); + char *tty; + + if (rc) { + if (rc == ERROR_TIMEDOUT) + LOG(ERROR, "%s: timed out", xswa->what); + libxl__xswait_stop(gc, xswa); + domcreate_complete(egc, dcs, rc); + return; + } + + tty = libxl__xs_read(gc, XBT_NULL, tty_path); + + if (tty && tty[0] != '\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; } - domcreate_console_available(egc, dcs); - - domcreate_complete(egc, dcs, 0); + dcs->console_xswait.ao = ao; + dcs->console_xswait.what = GCSPRINTF("domain %d console tty", domid); + dcs->console_xswait.path = GCSPRINTF("%s/console/tty", + libxl__xs_get_dompath(gc, domid)); + dcs->console_xswait.timeout_ms = LIBXL_INIT_TIMEOUT * 1000; + dcs->console_xswait.callback = console_xswait_callback; + ret = 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; + } return; @@ -1861,6 +1897,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid; + libxl__xswait_init(&cdcs->dcs.console_xswait); initiate_domain_create(egc, &cdcs->dcs); 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; }; _hidden int libxl__device_nic_set_devids(libxl__gc *gc,