From patchwork Wed Feb 19 16:19:00 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: 11391815 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 C833D139A for ; Wed, 19 Feb 2020 16:20:29 +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 A2BAB2464E for ; Wed, 19 Feb 2020 16:20:29 +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="APj6aq9w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2BAB2464E 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 1j4S43-0000SG-5w; Wed, 19 Feb 2020 16:19:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4S42-0000Rg-5n for xen-devel@lists.xenproject.org; Wed, 19 Feb 2020 16:19:06 +0000 X-Inumbo-ID: 8c8cfe48-5333-11ea-ade5-bc764e2007e4 Received: from out5-smtp.messagingengine.com (unknown [66.111.4.29]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8c8cfe48-5333-11ea-ade5-bc764e2007e4; Wed, 19 Feb 2020 16:19:05 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5C10822128; Wed, 19 Feb 2020 11:19:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 19 Feb 2020 11:19:05 -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=17BvhT MFYZGqzieiHllO64rBxU1HSLAcIGalUWK0M9w=; b=APj6aq9wzljs8Nk1Stxh9O QFt7WUwDiN5R2icK8hB51MlXoyx6oJV9bgu2w7ev0onx1fB4shtGLytn0z+oxuGU x8O0B9qrD3CUe1alEh4hp/P/1BSMVpFJ99aYHmsOrIsWTAWpxttybIF8FFSXsMjQ F/anBpMjanM0YSFlycBVxWKCNncv68cOFavYTBLeJCVX12TWy4t8NxHaIeZwhAHS SEjbXDwEZsBdIIP/azeiMYVGNyzVVratfmEQl3zYB+InSxhdwMqfEt4HV7FvFlzT 9T+sjaj2AiCT40almj2iEmVRTjHXDiuVaasQ2/edAYZqoREVxjcsD8S9Ahn1ZkeA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkedtgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpefrrgifvghlucfo rghrtgiivgifshhkihcuoehprgifvghlsehinhhvihhsihgslhgvthhhihhnghhslhgrsg drtghomheqnecukfhppeekfedrleejrddvfedrvdelnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepphgrfigvlhesihhnvhhishhisghlvghthh hinhhgshhlrggsrdgtohhm X-ME-Proxy: Received: from localhost.localdomain (unknown [83.97.23.29]) by mail.messagingengine.com (Postfix) with ESMTPA id 1DF7C328005A; Wed, 19 Feb 2020 11:19:04 -0500 (EST) From: =?utf-8?q?Pawe=C5=82_Marczewski?= To: xen-devel@lists.xenproject.org Date: Wed, 19 Feb 2020 17:19:00 +0100 Message-Id: <7586792df0070ceeba874ba8f430dd7addb53305.1582128348.git.pawel@invisiblethingslab.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH] 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 --- tools/libxl/libxl_create.c | 33 ++++++++++++++++++++++++++++++--- tools/libxl/libxl_internal.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 3a7364e2ac..53f2886544 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1190,6 +1190,21 @@ static void domcreate_console_available(libxl__egc *egc, dcs->aop_console_how.for_event)); } +static void console_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch, + const char *watch_path, + const char *event_path) { + EGC_GC; + libxl__domain_create_state *dcs = CONTAINER_OF(watch, *dcs, console_watch); + char *dompath = libxl__xs_get_dompath(gc, dcs->guest_domid); + char *tty_path = GCSPRINTF("%s/console/tty", dompath); + char *tty = libxl__xs_read(gc, XBT_NULL, tty_path); + + if (tty && tty[0] != '\0') { + domcreate_console_available(egc, dcs); + domcreate_complete(egc, dcs, 0); + } +} + static void domcreate_bootloader_done(libxl__egc *egc, libxl__bootloader_state *bl, int rc) @@ -1705,6 +1720,8 @@ static void domcreate_attach_devices(libxl__egc *egc, int domid = dcs->guest_domid; libxl_domain_config *const d_config = dcs->guest_config; const libxl__device_type *dt; + char *tty_path; + int rc; if (ret) { LOGD(ERROR, domid, "unable to add %s devices", @@ -1728,9 +1745,15 @@ static void domcreate_attach_devices(libxl__egc *egc, return; } - domcreate_console_available(egc, dcs); - - domcreate_complete(egc, dcs, 0); + tty_path = GCSPRINTF("%s/console/tty", libxl__xs_get_dompath(gc, domid)); + rc = libxl__ev_xswatch_register(gc, &dcs->console_watch, + console_watch_callback, + tty_path); + if (rc) { + LOG(ERROR, "unable to set up watch for console path: %s", + tty_path); + goto error_out; + } return; @@ -1747,6 +1770,9 @@ static void domcreate_complete(libxl__egc *egc, libxl_domain_config *const d_config = dcs->guest_config; libxl_domain_config *d_config_saved = &dcs->guest_config_saved; + if (libxl__ev_xswatch_isregistered(&dcs->console_watch)) + libxl__ev_xswatch_deregister(gc, &dcs->console_watch); + libxl__domain_build_state_dispose(&dcs->build_state); if (!rc && d_config->b_info.exec_ssidref) @@ -1861,6 +1887,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__ev_xswatch_init(&cdcs->dcs.console_watch); initiate_domain_create(egc, &cdcs->dcs); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index dd3c08bc14..fa666cbe0c 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4177,6 +4177,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__ev_xswatch console_watch; }; _hidden int libxl__device_nic_set_devids(libxl__gc *gc,