From nobody Mon May 13 14:17:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1674836298; cv=none; d=zohomail.com; s=zohoarc; b=KLgreIo1DInj3RZK2I7ML/nFKcZHCLP+1c7BsheuuO5YuO+a61tKRQf7Vov4Uu32Wx3640vIlnZX92oMH9XoCh40dh6qsJ+iwe2hzP3pswsAM2z021T1C2K7SPUYkKVXWehJqlbuqpmn4FFJA23Y9l1pZSGYUrqLimmfd4El2/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674836298; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fTn5+Q+SWqEwE2uyxIo/eODqZLSuycg85wgwNabMcXk=; b=Qb0yz7HrAg6E+yJRew/2OSVUskZToC0FoNXr/8PWG9l7k4KlN5vV1RhPUJw8Iqn5PDiuT8QJys/AqgKlkUpVdItCe5vQ5NjGi+W+zJnki0NHKH7HMURQqgkBkiC0HDpxAHsBJ6TCZAcyLx8dvtWXM0a1KprizCMb4zLZc/1ifno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1674836298866840.6165496393457; Fri, 27 Jan 2023 08:18:18 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.485791.753191 (Exim 4.92) (envelope-from ) id 1pLRQ9-0007SV-Kt; Fri, 27 Jan 2023 16:17:45 +0000 Received: by outflank-mailman (output) from mailman id 485791.753191; Fri, 27 Jan 2023 16:17:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pLRQ9-0007SO-Hy; Fri, 27 Jan 2023 16:17:45 +0000 Received: by outflank-mailman (input) for mailman id 485791; Fri, 27 Jan 2023 16:17:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pLRQ7-0007SE-Nc for xen-devel@lists.xenproject.org; Fri, 27 Jan 2023 16:17:43 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2001:67c:2178:6::1c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1f93b420-9e5e-11ed-b8d1-410ff93cb8f0; Fri, 27 Jan 2023 17:17:41 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 112DB220D7; Fri, 27 Jan 2023 16:17:41 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DE32E138E3; Fri, 27 Jan 2023 16:17:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id tGTFNCT502O5AgAAMHmgww (envelope-from ); Fri, 27 Jan 2023 16:17:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1f93b420-9e5e-11ed-b8d1-410ff93cb8f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674836261; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=fTn5+Q+SWqEwE2uyxIo/eODqZLSuycg85wgwNabMcXk=; b=HqKwHTjkanDLKW6KGWWyfh7x6eRJuWNf2BcSByRK6ZmBIkNQYoNbfZiw23hXCk6px++bKg zjYEUW3nBRencLpV2if1pW7NyChxKc3ExYCV8Yr8Mvg9iANf6NNwFzM/1YN/fjis1ETzrP r+XPpUYwCMpBe8OTwXwYRc59vPzOwIY= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v3] tools/helpers: don't log errors when trying to load PVH xenstore-stubdom Date: Fri, 27 Jan 2023 17:17:39 +0100 Message-Id: <20230127161739.5596-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1674836300963100001 Content-Type: text/plain; charset="utf-8" When loading a Xenstore stubdom the loader doesn't know whether the lo be loaded kernel is a PVH or a PV one. So it tries to load it as a PVH one first, and if this fails it is loading it as a PV kernel. This results in errors being logged in case the stubdom is a PV kernel. Suppress those errors by setting the minimum logging level to "critical" while trying to load the kernel as PVH. In case PVH mode and PV mode loading fails, retry PVH mode loading without changing the log level in order to get the error messages logged. Fixes: f89955449c5a ("tools/init-xenstore-domain: support xenstore pvh stub= dom") Signed-off-by: Juergen Gross Acked-by: Andrew Cooper --- V2: - retry PVH loading with logging if PV fails, too (Jan Beulich) V3: - expand commit message (Jan Beulich) - expand comment (Andrew Cooper) --- tools/helpers/init-xenstore-domain.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xens= tore-domain.c index 04e351ca29..85cc9e8381 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -31,6 +31,8 @@ static int memory; static int maxmem; static xen_pfn_t console_gfn; static xc_evtchn_port_or_error_t console_evtchn; +static xentoollog_level minmsglevel =3D XTL_PROGRESS; +static void *logger; =20 static struct option options[] =3D { { "kernel", 1, NULL, 'k' }, @@ -141,19 +143,33 @@ static int build(xc_interface *xch) goto err; } =20 + /* + * This is a bodge. We can't currently inspect the kernel's ELF notes + * ahead of attempting to construct a domain, so try PVH first, suppre= ssing + * errors by setting min level to high, and fall back to PV. + */ dom->container_type =3D XC_DOM_HVM_CONTAINER; + xtl_stdiostream_set_minlevel(logger, XTL_CRITICAL); rv =3D xc_dom_parse_image(dom); + xtl_stdiostream_set_minlevel(logger, minmsglevel); if ( rv ) { dom->container_type =3D XC_DOM_PV_CONTAINER; rv =3D xc_dom_parse_image(dom); if ( rv ) { - fprintf(stderr, "xc_dom_parse_image failed\n"); - goto err; + /* Retry PVH, now with normal logging level. */ + dom->container_type =3D XC_DOM_HVM_CONTAINER; + rv =3D xc_dom_parse_image(dom); + if ( rv ) + { + fprintf(stderr, "xc_dom_parse_image failed\n"); + goto err; + } } } - else + + if ( dom->container_type =3D=3D XC_DOM_HVM_CONTAINER ) { config.flags |=3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap; config.arch.emulation_flags =3D XEN_X86_EMU_LAPIC; @@ -412,8 +428,6 @@ int main(int argc, char** argv) char buf[16], be_path[64], fe_path[64]; int rv, fd; char *maxmem_str =3D NULL; - xentoollog_level minmsglevel =3D XTL_PROGRESS; - xentoollog_logger *logger =3D NULL; =20 while ( (opt =3D getopt_long(argc, argv, "v", options, NULL)) !=3D -1 ) { @@ -456,9 +470,7 @@ int main(int argc, char** argv) return 2; } =20 - logger =3D (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, - minmsglevel= , 0); - + logger =3D xtl_createlogger_stdiostream(stderr, minmsglevel, 0); xch =3D xc_interface_open(logger, logger, 0); if ( !xch ) { --=20 2.35.3