From nobody Wed May 1 12:44:07 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=1582129185; cv=none; d=zohomail.com; s=zohoarc; b=b3e+yr+pB0ImMuFTA4Tr9JHgqxo/dW5YDzxGnKjcJgB7tSBohbtz3cTBz1hgxqndsF6dpBLK1QG5aPlNx42LJNTyo8k1iW56ungfhlvUPSktGXTkIbCuTl3619yeUcaAgoU5Zq3BUjmFdHUCshUVBCq+rdbwIIHHYGwA58OvxA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582129185; 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=a9SPn7qCUIJUA78qxcwyNAc/oFtsW6rfaesS+2aps7E=; b=n4+JdRCIUtSMgvEUiR02Ww61Qxdd8lQ7SoxlnICWVz9gkeV4NK+0h53Lqkn/0atoqXDtXbj5bfNotV88rdKjjpyDGUIVrnqOKq9DFr8BwLQ9hRvLFyzDAhbx3DWpTDlt8sr4J0zQVGsEEA/S1czVkvkgn8rQsNcXLRZf0BHjH+E= 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 158212918551083.10969568864311; Wed, 19 Feb 2020 08:19:45 -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 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 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 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) X-Inumbo-ID: 8c8cfe48-5333-11ea-ade5-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=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: From: =?UTF-8?q?Pawe=C5=82=20Marczewski?= 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=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 --- 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)); } =20 +static void console_watch_callback(libxl__egc *egc, libxl__ev_xswatch *wat= ch, + const char *watch_path, + const char *event_path) { + EGC_GC; + libxl__domain_create_state *dcs =3D CONTAINER_OF(watch, *dcs, console_= watch); + char *dompath =3D libxl__xs_get_dompath(gc, dcs->guest_domid); + char *tty_path =3D GCSPRINTF("%s/console/tty", dompath); + char *tty =3D libxl__xs_read(gc, XBT_NULL, tty_path); + + if (tty && tty[0] !=3D '\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 =3D dcs->guest_domid; libxl_domain_config *const d_config =3D dcs->guest_config; const libxl__device_type *dt; + char *tty_path; + int rc; =20 if (ret) { LOGD(ERROR, domid, "unable to add %s devices", @@ -1728,9 +1745,15 @@ static void domcreate_attach_devices(libxl__egc *egc, return; } =20 - domcreate_console_available(egc, dcs); - - domcreate_complete(egc, dcs, 0); + tty_path =3D GCSPRINTF("%s/console/tty", libxl__xs_get_dompath(gc, dom= id)); + rc =3D 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; + } =20 return; =20 @@ -1747,6 +1770,9 @@ 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 + if (libxl__ev_xswatch_isregistered(&dcs->console_watch)) + libxl__ev_xswatch_deregister(gc, &dcs->console_watch); + libxl__domain_build_state_dispose(&dcs->build_state); =20 if (!rc && d_config->b_info.exec_ssidref) @@ -1861,6 +1887,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__ev_xswatch_init(&cdcs->dcs.console_watch); =20 initiate_domain_create(egc, &cdcs->dcs); =20 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; }; =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