From nobody Fri Dec 19 18:44:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1745502447; cv=none; d=zohomail.com; s=zohoarc; b=M0FS254Q30B06pB1+i8FMmb+kDkD05keH/BS/MIjx5am4e5Vxkrxxe6kN35MpiHPYaGmYE3IacjZnTEi2WAFGafyhiAM5TjVIpRo0w+XvfThGLJdtC1QOJ+V0ELiiKlHxWu3XsWfqtf6bhVb4z4TofOdDJ49cnUn5nV26aRmfTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745502447; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=KQJlAvGE9EV3XchEdABoQylrr9o2+eYJYQ9u/BrwWNw=; b=lsr5VJbHaYjbvz/pV/cGAa1ZkT7b3N1VgGl9Hwz7KXK82cUYatjDKnfqpZHlMfXO/+SCf0PoeTu5RamKIjkVWz/rHEiAgEMLyy39JYj9Mes1vt0Q2N7VFGGcFe4Tu9tHeQDBIYS2pKOn70JeBmVUXnObUFsQQnFtD6ANOqGZJbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1745502447777128.1063400686519; Thu, 24 Apr 2025 06:47:27 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C1226BF6; Thu, 24 Apr 2025 09:47:26 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9F401B25; Thu, 24 Apr 2025 09:47:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AE7FEA66; Thu, 24 Apr 2025 09:47:00 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 94DD1A6F for ; Thu, 24 Apr 2025 09:46:59 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-b_tHaYV7NoqNhOlHlgABjg-1; Thu, 24 Apr 2025 09:46:58 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 44E4E1801A12 for ; Thu, 24 Apr 2025 13:46:57 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.31]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4556D1800873; Thu, 24 Apr 2025 13:46:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745502419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9IQXeHwGx1TiywHA7nz/mEZ7A6RaF9Lec+ge7PnHnfA=; b=KWfOfQ6OXMlg2Jb534zhNqNNmAmw1lFXkSOOHslAYlDqY1MDV66JNI7BslPVfldbzcAB2c +E+AdWuwVA9iGgCpSXpLuGbeyfn/YKvlZ15O2CXIdkcvkUqdNh+Vog3pdgg94q0WJxXJzR 5bDm5SoWJyDSNT750OgYQe2SOSf6ehM= X-MC-Unique: b_tHaYV7NoqNhOlHlgABjg-1 X-Mimecast-MFC-AGG-ID: b_tHaYV7NoqNhOlHlgABjg_1745502417 To: devel@lists.libvirt.org Subject: [PATCH] qemuxmlactivetest: Don't segfault when capability XMLs are invalid Date: Thu, 24 Apr 2025 15:46:53 +0200 Message-ID: <58f0d87b02d28aceeddd309022569473381d335c.1745502413.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Vt47GYhXxCR7FRNQh-aJuybjDRgDZxlwiEoWWiiahh4_1745502417 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OSMPX7WR3VGMCT2M3XNI3GB6ZY5YEPKM X-Message-ID-Hash: OSMPX7WR3VGMCT2M3XNI3GB6ZY5YEPKM X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Peter Krempa X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1745502452245019100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa This is purely a devel-time problem in the test suite. 'qemuxmlactivetest' invokes the whole test worker twice, once for inactive output and second time for active. Now 'testQemuInfoInitArgs' returns a failure if the XML is invalid and the test is skipped. On another invocation though it returns 0 if 'testQemuInfoSetArgs' was not invoked meanwhile and thus makes it seem it succeeded which leads to a crash in the code assuming that some pointers are valid. Use same interlocking as 'qemuxmlconftest' to skip the second invocation on failure of the first one. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuxmlactivetest.c | 67 +++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/tests/qemuxmlactivetest.c b/tests/qemuxmlactivetest.c index b132b91623..de2b1e48eb 100644 --- a/tests/qemuxmlactivetest.c +++ b/tests/qemuxmlactivetest.c @@ -87,6 +87,45 @@ testRunStatus(const char *name, } +static int +testqemuActiveXML2XMLCommonPrepare(testQemuInfo *info) +{ + if (info->prepared) + return 0; + + if (testQemuInfoInitArgs((testQemuInfo *) info) < 0) + goto error; + + virFileCacheClear(driver.qemuCapsCache); + + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0) + goto error; + + if (!(info->def =3D virDomainDefParseFile(info->infile, + driver.xmlopt, NULL, + info->parseFlags))) + goto error; + + if (!virDomainDefCheckABIStability(info->def, info->def, driver.xmlopt= )) { + VIR_TEST_DEBUG("ABI stability check failed on %s", info->infile); + goto error; + } + + /* make sure that the XML definition looks active, by setting an ID + * as otherwise the XML formatter will simply assume that it's inactiv= e */ + if (info->def->id =3D=3D -1) + info->def->id =3D 1337; + + info->prepared =3D true; + return 0; + + error: + info->prep_skip =3D true; + info->prepared =3D true; + return -1; +} + + static int testqemuActiveXML2XMLCommon(testQemuInfo *info, bool live) @@ -95,31 +134,11 @@ testqemuActiveXML2XMLCommon(testQemuInfo *info, const char *outfile =3D info->out_xml_active; unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; - /* Prepare the test data and parse the input just once */ - if (!info->def) { - if (testQemuInfoInitArgs((testQemuInfo *) info) < 0) - return -1; - - virFileCacheClear(driver.qemuCapsCache); + if (info->prep_skip) + return EXIT_AM_SKIP; - if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) = < 0) - return -1; - - if (!(info->def =3D virDomainDefParseFile(info->infile, - driver.xmlopt, NULL, - info->parseFlags))) - return -1; - - if (!virDomainDefCheckABIStability(info->def, info->def, driver.xm= lopt)) { - VIR_TEST_DEBUG("ABI stability check failed on %s", info->infil= e); - return -1; - } - - /* make sure that the XML definition looks active, by setting an ID - * as otherwise the XML formatter will simply assume that it's ina= ctive */ - if (info->def->id =3D=3D -1) - info->def->id =3D 1337; - } + if (testqemuActiveXML2XMLCommonPrepare(info) < 0) + return -1; if (!live) { format_flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE; --=20 2.49.0