From nobody Sat May 4 10:04:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678664528; cv=none; d=zohomail.com; s=zohoarc; b=DcKDbpZOjxNPga740TNFxdup0g58D7Kzpq0POejgoAx5XU+ylAr6KOqiwOapLW6i/EQDbfSim7GqN8acV23J1Pm2021BjVT8Quxoh0m2mupRprNBfSSVse2CRUl6/jjVxLPSAdifMFm5bR8S7K71P43N5hTfTq2g9wcCHZ7S0/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678664528; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=YYf8IKPQjMmdVSpD++IIu0dqNQ4TJFmfxZjNuxNor9o=; b=LCi31OObdkCxqGZnP71dJ69c2dKiDMfNez4v2JdlVIBN+ZPNJJsu6b5jSfIlU8l8YDzaDnRFpqlSxmbe2+osMkon13BNt8wN8/Gm9Qxg7UJOTc4Hupt6Cr8rpx5RUn34KrzWNXf+qjWKg3boy91qB1xZD7YhvgoUipZQx75UUvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678664528450504.56785935349205; Sun, 12 Mar 2023 16:42:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbVK3-0008PF-6Y; Sun, 12 Mar 2023 19:41:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbVJy-0008GL-HT for qemu-devel@nongnu.org; Sun, 12 Mar 2023 19:41:46 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pbVJw-0003Tq-Un for qemu-devel@nongnu.org; Sun, 12 Mar 2023 19:41:46 -0400 Received: by mail-qt1-x833.google.com with SMTP id c19so11541649qtn.13 for ; Sun, 12 Mar 2023 16:41:44 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:6618:4c00:8b45:5f2f]) by smtp.gmail.com with ESMTPSA id i10-20020ac8004a000000b003b2d890752dsm4444257qtg.88.2023.03.12.16.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 16:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678664503; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YYf8IKPQjMmdVSpD++IIu0dqNQ4TJFmfxZjNuxNor9o=; b=KqED0EjmtxcaaOPdpeQUgPHtxZDwGNHwVbqthRe1dFef66ymtYtFtpFJ9NUFbr5Ui/ iyvCl89W/q1qnTXAOtKSwMvBQSOxGividzqXKFUQe6upU4fYf69wzmAjSB5vHz8Qcfzl 3OV0mzdoU3L6RKsGp/H3AUUIAajN9+nz/HEwCMC5W3uaLuU1XxXaBNl6bVwCfF8xCgVx CSQqBhdQOVYUU7rUGAqTRML+fEv0wwriGAKvvEseyXM8gTu8A47GCd9l1x5I5PSoY4Q+ udxv4qzYB9WTTcLQZqgMhdmn0egU/vBPXOyqFWtqfMzGtBC8EAdhIvsink6tcS4DOHBX TBdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678664503; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YYf8IKPQjMmdVSpD++IIu0dqNQ4TJFmfxZjNuxNor9o=; b=Hnapgc2sI4uFyuAbHciL8xWE1pgO4d6CYPJ4iLl8O1go2KIEnl1y1wzATM8ilDDWPV 7c2Ku4i4+cmCwOBsTNcMRP6mapwg6pfNjxxogC+XFef0xCjoOcY0XEMXvlf0FFlq/PKg 0PkWt03Org1hCQzL9C+V7GrMel2Wk2KP8xwrk3bywRN0HzTUip5P0tg6R5Jsu/bJH//H L6DFGbDv6s+E6Ui0z8wv5Y5V99pty/qt/5Qr7AQxeC7wM1hpA2d6JPhSRhhrulFZl39Z eKdP0Ulqw3H51AA49pQVD7vTp8DfJecrA36vHGuBlm4U99dY7GGZJbsD2phOThcDbZyf zbLg== X-Gm-Message-State: AO0yUKXlbTXQbiXy1hLJKalspxdxPK5JTfc3HLwkLXy0QsBu9eGIbRRh izqTNSWHstTbrQ4kHowTbwM= X-Google-Smtp-Source: AK7set/L8BhEK5+uYXiz54fZi5/q7FNowgXgtI0ud4BIk7wMuW23tMNaJB//njDy7JyNrTINFztDkQ== X-Received: by 2002:a05:622a:1304:b0:3bf:a461:e6f0 with SMTP id v4-20020a05622a130400b003bfa461e6f0mr24732469qtk.31.1678664503620; Sun, 12 Mar 2023 16:41:43 -0700 (PDT) From: Jason Andryuk To: Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org, David Woodhouse Cc: qemu-devel@nongnu.org, Jason Andryuk Subject: [PATCH] xen: fix dm_restrict startup Date: Sun, 12 Mar 2023 19:41:31 -0400 Message-Id: <20230312234131.46898-1-jandryuk@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=jandryuk@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678664530110100003 Content-Type: text/plain; charset="utf-8" QEMU is failing to signal it start when launched by libxl with dm_restrict=3D1. When xenstore_record_dm_state() is called, the restrictions prevent xs_open() from succeeding. QEMU can't write running to the xenstore, and libxl fails the VM start up. Pass in a open xenstore connection. Let the call back use it and the close it. Use the completed boolean to only allow it to be called once. This lets the xenstore connection be closed after the startup indication. Fixes: ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirection = to internal emulation") Signed-off-by: Jason Andryuk --- I think xenstore_record_dm_state() only needs to indicate startup once, so the completed bool makes sense. accel/xen/xen-all.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 00221e23c5..3843299843 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -30,17 +30,13 @@ xc_interface *xen_xc; xenforeignmemory_handle *xen_fmem; xendevicemodel_handle *xen_dmod; =20 -static void xenstore_record_dm_state(const char *state) +static void xenstore_record_dm_state(struct xs_handle *xs, const char *sta= te) { - struct xs_handle *xs; + static bool completed; char path[50]; =20 - /* We now have everything we need to set the xenstore entry. */ - xs =3D xs_open(0); - if (xs =3D=3D NULL) { - fprintf(stderr, "Could not contact XenStore\n"); - exit(1); - } + if (completed) + return; =20 snprintf(path, sizeof (path), "device-model/%u/state", xen_domid); /* @@ -53,6 +49,7 @@ static void xenstore_record_dm_state(const char *state) exit(1); } =20 + completed =3D true; xs_close(xs); } =20 @@ -60,9 +57,10 @@ static void xenstore_record_dm_state(const char *state) static void xen_change_state_handler(void *opaque, bool running, RunState state) { + struct xs_handle *xs =3D opaque; if (running) { /* record state running */ - xenstore_record_dm_state("running"); + xenstore_record_dm_state(xs, "running"); } } =20 @@ -92,6 +90,7 @@ static void xen_setup_post(MachineState *ms, AccelState *= accel) static int xen_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); + struct xs_handle *xs; =20 xen_xc =3D xc_interface_open(0, 0, 0); if (xen_xc =3D=3D NULL) { @@ -111,7 +110,14 @@ static int xen_init(MachineState *ms) xc_interface_close(xen_xc); return -1; } - qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); + + xs =3D xs_open(0); + if (xs =3D=3D NULL) { + fprintf(stderr, "Could not contact XenStore\n"); + exit(1); + } + + qemu_add_vm_change_state_handler(xen_change_state_handler, xs); /* * opt out of system RAM being allocated by generic code */ --=20 2.37.2