From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785271; cv=none; d=zohomail.com; s=zohoarc; b=OkPkTRe5AunBFjuvbsMWYFcoNYSmY6NrzykUD+8sao/lL2iJZZnMLAiCqSW6QoeSRI3e2MomMhGZ0nr318SFcCPLOvq8/MAx9ZYX6c5M6y2C71hYKnheGTCUrLx5k033WyfNsNBw3sZEl3GxNO+vsp2HopgjaHpk61XbF6VsKHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785271; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ptt25UpSG4SGs9AzU+y2uMaUodSAfWpLkKmV1ixjEv4=; b=kZ3vayHPKbXQyq6exj7q4rKIyYUqskWwnLGkuONsMgX6JEhXNWuYl5s74X3Yj8PqSo0mHw3DzQwPJaFaD4KSiroBKgpmvfFwIWjBEMhEZLluKP2C754b+tyBPo8L3Udne59NP2mtW2RBzma/WVBmJl1ND1T69B1P3DylIrwJz4Q= 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 1697785271409451.4380425013293; Fri, 20 Oct 2023 00:01:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjSd-00026e-3H; Fri, 20 Oct 2023 02:58:19 -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 1qtjSZ-00024Z-1k for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjSW-0003PG-9e for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:14 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-146-n1qWBceSOyyk8xMFkJd1-w-1; Fri, 20 Oct 2023 02:58:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 531E13C108CF; Fri, 20 Oct 2023 06:58:07 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63C3725C0; Fri, 20 Oct 2023 06:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ptt25UpSG4SGs9AzU+y2uMaUodSAfWpLkKmV1ixjEv4=; b=SFSCUXMWVU32Vwokj4xrd9SqkXsWNYeStMqU7s/AQ1jov2/HE6XntRwbCSMymX8Cb5ra3u 72gbvmAPLpriz6t3V6UPQ0ZnVhkWXAknZ0Sajmf/r4cur7OfBcugw5BBP6bDOaSumSq+pO NRrwMqNvWVZqqbtrxmNp4xLAcHLboV4= X-MC-Unique: n1qWBceSOyyk8xMFkJd1-w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 01/17] tests/qtest/migration-test: Disable the analyze-migration.py test on s390x Date: Fri, 20 Oct 2023 08:57:35 +0200 Message-ID: <20231020065751.26047-2-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785271873100006 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The analyze-migration.py script fails on s390x hosts: Traceback (most recent call last): File "scripts/analyze-migration.py", line 662, in dump.read(dump_memory =3D args.memory) File "scripts/analyze-migration.py", line 596, in read classdesc =3D self.section_classes[section_key] KeyError: ('s390-storage_attributes', 0) It obviously never has been adapted to s390x yet, so until this has been done, disable this test on s390x. Signed-off-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231018091239.164452-1-thuth@redhat.com> --- tests/qtest/migration-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index e1c110537b..241b409857 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -3034,7 +3034,9 @@ int main(int argc, char **argv) =20 qtest_add_func("/migration/bad_dest", test_baddest); #ifndef _WIN32 - qtest_add_func("/migration/analyze-script", test_analyze_script); + if (!g_str_equal(arch, "s390x")) { + qtest_add_func("/migration/analyze-script", test_analyze_script); + } #endif qtest_add_func("/migration/precopy/unix/plain", test_precopy_unix_plai= n); qtest_add_func("/migration/precopy/unix/xbzrle", test_precopy_unix_xbz= rle); --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785172; cv=none; d=zohomail.com; s=zohoarc; b=ioGdr2JY3VVvpAci1cU/u1aaGbH7+p1Dk8rvXkEZCNM7u/tFYBh1x8EZd925DADb+AG+Ty/NnQMWGd7vVmFqiIUTOVTYIx3HtAR7BuISiFtUoybHidH/3NE7mdNQguaJSYDZ8a2ybe7m4KARmmf4myvpPX6BwkhRkQpnVWcK9mI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785172; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z/SAByVT7Qgiw/sxJHe4WcPtyn9dHrQ/m6/DajkrD1s=; b=Bp+c/0nsV8VOImwfjptsDYY+w0KdMaRm3wow6ZpuyK9nyZCMM7+nmhYOxLerTw2IwEBnpW1/XGRgwNwvJZ4UAGRlkgRYGg+mdX2GSU4jxbwxfzcgUEUU1AVCg5J2l5Ey48dYgzttIqM3Y1NkVkXKMFGEIDa4/as/xH3dfP1vqtU= 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 1697785172724689.3961499332631; Thu, 19 Oct 2023 23:59:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjSn-0002RP-OK; Fri, 20 Oct 2023 02:58:29 -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 1qtjSm-0002R7-MU for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjSe-0003Sq-GX for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:24 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-Pqjf3sjHNzmXAG5W3v3fwQ-1; Fri, 20 Oct 2023 02:58:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB0F910201E5; Fri, 20 Oct 2023 06:58:14 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 987E325C0; Fri, 20 Oct 2023 06:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z/SAByVT7Qgiw/sxJHe4WcPtyn9dHrQ/m6/DajkrD1s=; b=ZrxyWilMz/YYQvKAVaybYT/9TLgLFOgtMQ1Km7ZiyREx5PPgYxrG2dJgS4Oh3cvZBffFPF +CoFZ7I7EAuz/cY4gJC1tP2m0cGK/U0BRrj2oWCXkTVTqkYYD/R0mm5yaeUYjea6U6q1QF q3ZFWMfqrq2wF98lyKknl7lXq2PHnkc= X-MC-Unique: Pqjf3sjHNzmXAG5W3v3fwQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org, Steve Sistare , Michael Galaxy Subject: [PULL 02/17] migration: simplify blockers Date: Fri, 20 Oct 2023 08:57:36 +0200 Message-ID: <20231020065751.26047-3-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785173889100001 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Modify migrate_add_blocker and migrate_del_blocker to take an Error ** reason. This allows migration to own the Error object, so that if an error occurs in migrate_add_blocker, migration code can free the Error and clear the client handle, simplifying client code. It also simplifies the migrate_del_blocker call site. In addition, this is a pre-requisite for a proposed future patch that would add a mode argument to migration requests to support live update, and maintain a list of blockers for each mode. A blocker may apply to a single mode or to multiple modes, and passing Error** will allow one Error object to be registered for multiple modes. No functional change. Signed-off-by: Steve Sistare Tested-by: Michael Galaxy Reviewed-by: Michael Galaxy Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <1697634216-84215-1-git-send-email-steven.sistare@oracle.com> --- include/migration/blocker.h | 24 +++++++++++++++++------- backends/tpm/tpm_emulator.c | 10 ++-------- block/parallels.c | 9 +++------ block/qcow.c | 6 ++---- block/vdi.c | 6 ++---- block/vhdx.c | 6 ++---- block/vmdk.c | 6 ++---- block/vpc.c | 6 ++---- block/vvfat.c | 6 ++---- dump/dump.c | 4 ++-- hw/9pfs/9p.c | 10 ++-------- hw/display/virtio-gpu-base.c | 8 ++------ hw/intc/arm_gic_kvm.c | 3 +-- hw/intc/arm_gicv3_its_kvm.c | 3 +-- hw/intc/arm_gicv3_kvm.c | 3 +-- hw/misc/ivshmem.c | 8 ++------ hw/ppc/pef.c | 2 +- hw/ppc/spapr.c | 9 +-------- hw/ppc/spapr_events.c | 6 +++++- hw/ppc/spapr_rtas.c | 2 +- hw/remote/proxy.c | 7 ++----- hw/s390x/s390-virtio-ccw.c | 9 +++------ hw/scsi/vhost-scsi.c | 8 +++----- hw/vfio/common.c | 10 ++-------- hw/vfio/migration.c | 16 ++-------------- hw/virtio/vhost.c | 8 ++------ migration/migration.c | 22 ++++++++++++++-------- stubs/migr-blocker.c | 4 ++-- target/i386/kvm/kvm.c | 8 ++++---- target/i386/nvmm/nvmm-all.c | 3 +-- target/i386/sev.c | 2 +- target/i386/whpx/whpx-all.c | 3 +-- ui/vdagent.c | 5 ++--- 33 files changed, 92 insertions(+), 150 deletions(-) diff --git a/include/migration/blocker.h b/include/migration/blocker.h index 9cebe2ba06..b048f301b4 100644 --- a/include/migration/blocker.h +++ b/include/migration/blocker.h @@ -17,19 +17,23 @@ /** * @migrate_add_blocker - prevent migration from proceeding * - * @reason - an error to be returned whenever migration is attempted + * @reasonp - address of an error to be returned whenever migration is att= empted * * @errp - [out] The reason (if any) we cannot block migration right now. * * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set. + * + * *@reasonp is freed and set to NULL if failure is returned. + * On success, the caller must not free @reasonp, except by + * calling migrate_del_blocker. */ -int migrate_add_blocker(Error *reason, Error **errp); +int migrate_add_blocker(Error **reasonp, Error **errp); =20 /** * @migrate_add_blocker_internal - prevent migration from proceeding witho= ut * only-migrate implications * - * @reason - an error to be returned whenever migration is attempted + * @reasonp - address of an error to be returned whenever migration is att= empted * * @errp - [out] The reason (if any) we cannot block migration right now. * @@ -38,14 +42,20 @@ int migrate_add_blocker(Error *reason, Error **errp); * Some of the migration blockers can be temporary (e.g., for a few second= s), * so it shouldn't need to conflict with "-only-migratable". For those ca= ses, * we can call this function rather than @migrate_add_blocker(). + * + * *@reasonp is freed and set to NULL if failure is returned. + * On success, the caller must not free @reasonp, except by + * calling migrate_del_blocker. */ -int migrate_add_blocker_internal(Error *reason, Error **errp); +int migrate_add_blocker_internal(Error **reasonp, Error **errp); =20 /** - * @migrate_del_blocker - remove a blocking error from migration + * @migrate_del_blocker - remove a blocking error from migration and free = it. * - * @reason - the error blocking migration + * @reasonp - address of the error blocking migration + * + * This function frees *@reasonp and sets it to NULL. */ -void migrate_del_blocker(Error *reason); +void migrate_del_blocker(Error **reasonp); =20 #endif diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 402a2d6312..bf1a90f5d7 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -534,11 +534,8 @@ static int tpm_emulator_block_migration(TPMEmulator *t= pm_emu) error_setg(&tpm_emu->migration_blocker, "Migration disabled: TPM emulator does not support " "migration"); - if (migrate_add_blocker(tpm_emu->migration_blocker, &err) < 0) { + if (migrate_add_blocker(&tpm_emu->migration_blocker, &err) < 0) { error_report_err(err); - error_free(tpm_emu->migration_blocker); - tpm_emu->migration_blocker =3D NULL; - return -1; } } @@ -1016,10 +1013,7 @@ static void tpm_emulator_inst_finalize(Object *obj) =20 qapi_free_TPMEmulatorOptions(tpm_emu->options); =20 - if (tpm_emu->migration_blocker) { - migrate_del_blocker(tpm_emu->migration_blocker); - error_free(tpm_emu->migration_blocker); - } + migrate_del_blocker(&tpm_emu->migration_blocker); =20 tpm_sized_buffer_reset(&state_blobs->volatil); tpm_sized_buffer_reset(&state_blobs->permanent); diff --git a/block/parallels.c b/block/parallels.c index 6b46623241..1d695ce7fb 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1369,9 +1369,8 @@ static int parallels_open(BlockDriverState *bs, QDict= *options, int flags, bdrv_get_device_or_node_name(bs)); bdrv_graph_rdunlock_main_loop(); =20 - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_setg(errp, "Migration blocker error"); goto fail; } qemu_co_mutex_init(&s->lock); @@ -1406,7 +1405,7 @@ static int parallels_open(BlockDriverState *bs, QDict= *options, int flags, ret =3D bdrv_check(bs, &res, BDRV_FIX_ERRORS | BDRV_FIX_LEAKS); if (ret < 0) { error_setg_errno(errp, -ret, "Could not repair corrupted image= "); - migrate_del_blocker(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); goto fail; } } @@ -1423,7 +1422,6 @@ fail: */ parallels_free_used_bitmap(bs); =20 - error_free(s->migration_blocker); g_free(s->bat_dirty_bmap); qemu_vfree(s->header); return ret; @@ -1448,8 +1446,7 @@ static void parallels_close(BlockDriverState *bs) g_free(s->bat_dirty_bmap); qemu_vfree(s->header); =20 - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); } =20 static bool parallels_is_support_dirty_bitmaps(BlockDriverState *bs) diff --git a/block/qcow.c b/block/qcow.c index 38a16253b8..fdd4c83948 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -307,9 +307,8 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, bdrv_get_device_or_node_name(bs)); bdrv_graph_rdunlock_main_loop(); =20 - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_free(s->migration_blocker); goto fail; } =20 @@ -802,8 +801,7 @@ static void qcow_close(BlockDriverState *bs) g_free(s->cluster_cache); g_free(s->cluster_data); =20 - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); } =20 static int coroutine_fn GRAPH_UNLOCKED diff --git a/block/vdi.c b/block/vdi.c index 3ed43b6f35..fd7e365383 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -498,9 +498,8 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, bdrv_get_device_or_node_name(bs)); bdrv_graph_rdunlock_main_loop(); =20 - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_free(s->migration_blocker); goto fail_free_bmap; } =20 @@ -988,8 +987,7 @@ static void vdi_close(BlockDriverState *bs) =20 qemu_vfree(s->bmap); =20 - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); } =20 static int vdi_has_zero_init(BlockDriverState *bs) diff --git a/block/vhdx.c b/block/vhdx.c index 73cb214fb4..e37f8c0926 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -985,8 +985,7 @@ static void vhdx_close(BlockDriverState *bs) s->bat =3D NULL; qemu_vfree(s->parent_entries); s->parent_entries =3D NULL; - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); qemu_vfree(s->log.hdr); s->log.hdr =3D NULL; vhdx_region_unregister_all(s); @@ -1097,9 +1096,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *opt= ions, int flags, error_setg(&s->migration_blocker, "The vhdx format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_free(s->migration_blocker); goto fail; } =20 diff --git a/block/vmdk.c b/block/vmdk.c index 8a3b152798..1335d39e16 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1386,9 +1386,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *opt= ions, int flags, error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_free(s->migration_blocker); goto fail; } =20 @@ -2867,8 +2866,7 @@ static void vmdk_close(BlockDriverState *bs) vmdk_free_extents(bs); g_free(s->create_type); =20 - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); } =20 static int64_t coroutine_fn GRAPH_RDLOCK diff --git a/block/vpc.c b/block/vpc.c index 945847fe4a..c30cf8689a 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -452,9 +452,8 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, bdrv_get_device_or_node_name(bs)); bdrv_graph_rdunlock_main_loop(); =20 - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_free(s->migration_blocker); goto fail; } =20 @@ -1190,8 +1189,7 @@ static void vpc_close(BlockDriverState *bs) g_free(s->pageentry_u8); #endif =20 - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); } =20 static QemuOptsList vpc_create_opts =3D { diff --git a/block/vvfat.c b/block/vvfat.c index b0415798c0..266e036dcd 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1268,9 +1268,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, "The vvfat (rw) format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret =3D migrate_add_blocker(s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { - error_free(s->migration_blocker); goto fail; } } @@ -3239,8 +3238,7 @@ static void vvfat_close(BlockDriverState *bs) g_free(s->cluster_buffer); =20 if (s->qcow) { - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); + migrate_del_blocker(&s->migration_blocker); } } =20 diff --git a/dump/dump.c b/dump/dump.c index d3578ddc62..d355ada62e 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -111,7 +111,7 @@ static int dump_cleanup(DumpState *s) qemu_mutex_unlock_iothread(); } } - migrate_del_blocker(dump_migration_blocker); + migrate_del_blocker(&dump_migration_blocker); =20 return 0; } @@ -2158,7 +2158,7 @@ void qmp_dump_guest_memory(bool paging, const char *f= ile, * Allows even for -only-migratable, but forbid migration during the * process of dump guest memory. */ - if (migrate_add_blocker_internal(dump_migration_blocker, errp)) { + if (migrate_add_blocker_internal(&dump_migration_blocker, errp)) { /* Remember to release the fd before passing it over to dump state= */ close(fd); return; diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 323f042e65..af636cfb2d 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -406,11 +406,7 @@ static int coroutine_fn put_fid(V9fsPDU *pdu, V9fsFidS= tate *fidp) * delete the migration blocker. Ideally, this * should be hooked to transport close notification */ - if (pdu->s->migration_blocker) { - migrate_del_blocker(pdu->s->migration_blocker); - error_free(pdu->s->migration_blocker); - pdu->s->migration_blocker =3D NULL; - } + migrate_del_blocker(&pdu->s->migration_blocker); } return free_fid(pdu, fidp); } @@ -1505,10 +1501,8 @@ static void coroutine_fn v9fs_attach(void *opaque) error_setg(&s->migration_blocker, "Migration is disabled when VirtFS export path '%s' is = mounted in the guest using mount_tag '%s'", s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag); - err =3D migrate_add_blocker(s->migration_blocker, NULL); + err =3D migrate_add_blocker(&s->migration_blocker, NULL); if (err < 0) { - error_free(s->migration_blocker); - s->migration_blocker =3D NULL; clunk_fid(s, fid); goto out; } diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 50c5373b65..37af256219 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -184,8 +184,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, =20 if (virtio_gpu_virgl_enabled(g->conf)) { error_setg(&g->migration_blocker, "virgl is not yet migratable"); - if (migrate_add_blocker(g->migration_blocker, errp) < 0) { - error_free(g->migration_blocker); + if (migrate_add_blocker(&g->migration_blocker, errp) < 0) { return false; } } @@ -253,10 +252,7 @@ virtio_gpu_base_device_unrealize(DeviceState *qdev) { VirtIOGPUBase *g =3D VIRTIO_GPU_BASE(qdev); =20 - if (g->migration_blocker) { - migrate_del_blocker(g->migration_blocker); - error_free(g->migration_blocker); - } + migrate_del_blocker(&g->migration_blocker); } =20 static void diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index 1d588946bc..e0d9e512a3 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -516,8 +516,7 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error= **errp) if (!kvm_arm_gic_can_save_restore(s)) { error_setg(&s->migration_blocker, "This operating system kernel do= es " "not support vGICv2 migration"); - if (migrate_add_blocker(s->migration_blocker, errp) < 0) { - error_free(s->migration_blocker); + if (migrate_add_blocker(&s->migration_blocker, errp) < 0) { return; } } diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index 7eda9fb86e..61c1cc7bdb 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -114,8 +114,7 @@ static void kvm_arm_its_realize(DeviceState *dev, Error= **errp) GITS_CTLR)) { error_setg(&s->migration_blocker, "This operating system kernel " "does not support vITS migration"); - if (migrate_add_blocker(s->migration_blocker, errp) < 0) { - error_free(s->migration_blocker); + if (migrate_add_blocker(&s->migration_blocker, errp) < 0) { return; } } else { diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 72ad916d3d..77eb37e131 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -878,8 +878,7 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Err= or **errp) GICD_CTLR)) { error_setg(&s->migration_blocker, "This operating system kernel do= es " "not support vGICv3 migration"); - if (migrate_add_blocker(s->migration_blocker, errp) < 0) { - error_free(s->migration_blocker); + if (migrate_add_blocker(&s->migration_blocker, errp) < 0) { return; } } diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index d66d912172..0447888029 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -903,8 +903,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Erro= r **errp) if (!ivshmem_is_master(s)) { error_setg(&s->migration_blocker, "Migration is disabled when using feature 'peer mode' i= n device 'ivshmem'"); - if (migrate_add_blocker(s->migration_blocker, errp) < 0) { - error_free(s->migration_blocker); + if (migrate_add_blocker(&s->migration_blocker, errp) < 0) { return; } } @@ -922,10 +921,7 @@ static void ivshmem_exit(PCIDevice *dev) IVShmemState *s =3D IVSHMEM_COMMON(dev); int i; =20 - if (s->migration_blocker) { - migrate_del_blocker(s->migration_blocker); - error_free(s->migration_blocker); - } + migrate_del_blocker(&s->migration_blocker); =20 if (memory_region_is_mapped(s->ivshmem_bar2)) { if (!s->hostmem) { diff --git a/hw/ppc/pef.c b/hw/ppc/pef.c index cc44d5e339..d28ed3ba73 100644 --- a/hw/ppc/pef.c +++ b/hw/ppc/pef.c @@ -63,7 +63,7 @@ static int kvmppc_svm_init(ConfidentialGuestSupport *cgs,= Error **errp) /* add migration blocker */ error_setg(&pef_mig_blocker, "PEF: Migration is not implemented"); /* NB: This can fail if --only-migratable is used */ - migrate_add_blocker(pef_mig_blocker, &error_fatal); + migrate_add_blocker(&pef_mig_blocker, &error_fatal); =20 cgs->ready =3D true; =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index cb840676d3..b25093be28 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1761,7 +1761,7 @@ static void spapr_machine_reset(MachineState *machine= , ShutdownCause reason) /* Signal all vCPUs waiting on this condition */ qemu_cond_broadcast(&spapr->fwnmi_machine_check_interlock_cond); =20 - migrate_del_blocker(spapr->fwnmi_migration_blocker); + migrate_del_blocker(&spapr->fwnmi_migration_blocker); } =20 static void spapr_create_nvram(SpaprMachineState *spapr) @@ -2937,13 +2937,6 @@ static void spapr_machine_init(MachineState *machine) spapr_create_lmb_dr_connectors(spapr); } =20 - if (spapr_get_cap(spapr, SPAPR_CAP_FWNMI) =3D=3D SPAPR_CAP_ON) { - /* Create the error string for live migration blocker */ - error_setg(&spapr->fwnmi_migration_blocker, - "A machine check is being handled during migration. The handle= r" - "may run and log hardware error on the destination"); - } - if (mc->nvdimm_supported) { spapr_create_nvdimm_dr_connectors(spapr); } diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 4508e40814..deb4641505 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -920,7 +920,11 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recover= ed) * fails when running with -only-migrate. A proper interface to * delay migration completion for a bit could avoid that. */ - ret =3D migrate_add_blocker(spapr->fwnmi_migration_blocker, NULL); + error_setg(&spapr->fwnmi_migration_blocker, + "A machine check is being handled during migration. The handler" + "may run and log hardware error on the destination"); + + ret =3D migrate_add_blocker(&spapr->fwnmi_migration_blocker, NULL); if (ret =3D=3D -EBUSY) { warn_report("Received a fwnmi while migration was in progress"); } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 7df21581c2..26c384b261 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -496,7 +496,7 @@ static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu, spapr->fwnmi_machine_check_interlock =3D -1; qemu_cond_signal(&spapr->fwnmi_machine_check_interlock_cond); rtas_st(rets, 0, RTAS_OUT_SUCCESS); - migrate_del_blocker(spapr->fwnmi_migration_blocker); + migrate_del_blocker(&spapr->fwnmi_migration_blocker); } =20 static struct rtas_call { diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c index 2052d721e5..fbc85a8d36 100644 --- a/hw/remote/proxy.c +++ b/hw/remote/proxy.c @@ -107,8 +107,7 @@ static void pci_proxy_dev_realize(PCIDevice *device, Er= ror **errp) =20 error_setg(&dev->migration_blocker, "%s does not support migration", TYPE_PCI_PROXY_DEV); - if (migrate_add_blocker(dev->migration_blocker, errp) < 0) { - error_free(dev->migration_blocker); + if (migrate_add_blocker(&dev->migration_blocker, errp) < 0) { object_unref(dev->ioc); return; } @@ -134,9 +133,7 @@ static void pci_proxy_dev_exit(PCIDevice *pdev) qio_channel_close(dev->ioc, NULL); } =20 - migrate_del_blocker(dev->migration_blocker); - - error_free(dev->migration_blocker); + migrate_del_blocker(&dev->migration_blocker); =20 proxy_memory_listener_deconfigure(&dev->proxy_listener); =20 diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 2d75f2131f..07a5157c0f 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -332,8 +332,7 @@ static void s390_machine_unprotect(S390CcwMachineState = *ms) s390_pv_vm_disable(); } ms->pv =3D false; - migrate_del_blocker(pv_mig_blocker); - error_free_or_abort(&pv_mig_blocker); + migrate_del_blocker(&pv_mig_blocker); ram_block_discard_disable(false); } =20 @@ -356,11 +355,10 @@ static int s390_machine_protect(S390CcwMachineState *= ms) =20 error_setg(&pv_mig_blocker, "protected VMs are currently not migratable."); - rc =3D migrate_add_blocker(pv_mig_blocker, &local_err); + rc =3D migrate_add_blocker(&pv_mig_blocker, &local_err); if (rc) { ram_block_discard_disable(false); error_report_err(local_err); - error_free_or_abort(&pv_mig_blocker); return rc; } =20 @@ -368,8 +366,7 @@ static int s390_machine_protect(S390CcwMachineState *ms) rc =3D s390_pv_vm_enable(); if (rc) { ram_block_discard_disable(false); - migrate_del_blocker(pv_mig_blocker); - error_free_or_abort(&pv_mig_blocker); + migrate_del_blocker(&pv_mig_blocker); return rc; } =20 diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 443f67daa4..14e23cc5b4 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -208,7 +208,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error = **errp) "When external environment supports it (Orchestrator migra= tes " "target SCSI device state or use shared storage over netwo= rk), " "set 'migratable' property to true to enable migration."); - if (migrate_add_blocker(vsc->migration_blocker, errp) < 0) { + if (migrate_add_blocker(&vsc->migration_blocker, errp) < 0) { goto free_virtio; } } @@ -241,10 +241,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error= **errp) free_vqs: g_free(vqs); if (!vsc->migratable) { - migrate_del_blocker(vsc->migration_blocker); + migrate_del_blocker(&vsc->migration_blocker); } free_virtio: - error_free(vsc->migration_blocker); virtio_scsi_common_unrealize(dev); close_fd: if (vhostfd >=3D 0) { @@ -260,8 +259,7 @@ static void vhost_scsi_unrealize(DeviceState *dev) struct vhost_virtqueue *vqs =3D vsc->dev.vqs; =20 if (!vsc->migratable) { - migrate_del_blocker(vsc->migration_blocker); - error_free(vsc->migration_blocker); + migrate_del_blocker(&vsc->migration_blocker); } =20 /* This will stop vhost backend. */ diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 5ff5acf1d8..d806057b40 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -129,11 +129,7 @@ int vfio_block_multiple_devices_migration(VFIODevice *= vbasedev, Error **errp) error_setg(&multiple_devices_migration_blocker, "Multiple VFIO devices migration is supported only if all o= f " "them support P2P migration"); - ret =3D migrate_add_blocker(multiple_devices_migration_blocker, errp); - if (ret < 0) { - error_free(multiple_devices_migration_blocker); - multiple_devices_migration_blocker =3D NULL; - } + ret =3D migrate_add_blocker(&multiple_devices_migration_blocker, errp); =20 return ret; } @@ -145,9 +141,7 @@ void vfio_unblock_multiple_devices_migration(void) return; } =20 - migrate_del_blocker(multiple_devices_migration_blocker); - error_free(multiple_devices_migration_blocker); - multiple_devices_migration_blocker =3D NULL; + migrate_del_blocker(&multiple_devices_migration_blocker); } =20 bool vfio_viommu_preset(VFIODevice *vbasedev) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index da43dcd2fe..0aaad65c06 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -891,8 +891,6 @@ static void vfio_migration_deinit(VFIODevice *vbasedev) =20 static int vfio_block_migration(VFIODevice *vbasedev, Error *err, Error **= errp) { - int ret; - if (vbasedev->enable_migration =3D=3D ON_OFF_AUTO_ON) { error_propagate(errp, err); return -EINVAL; @@ -901,13 +899,7 @@ static int vfio_block_migration(VFIODevice *vbasedev, = Error *err, Error **errp) vbasedev->migration_blocker =3D error_copy(err); error_free(err); =20 - ret =3D migrate_add_blocker(vbasedev->migration_blocker, errp); - if (ret < 0) { - error_free(vbasedev->migration_blocker); - vbasedev->migration_blocker =3D NULL; - } - - return ret; + return migrate_add_blocker(&vbasedev->migration_blocker, errp); } =20 /* ---------------------------------------------------------------------- = */ @@ -994,9 +986,5 @@ void vfio_migration_exit(VFIODevice *vbasedev) vfio_migration_deinit(vbasedev); } =20 - if (vbasedev->migration_blocker) { - migrate_del_blocker(vbasedev->migration_blocker); - error_free(vbasedev->migration_blocker); - vbasedev->migration_blocker =3D NULL; - } + migrate_del_blocker(&vbasedev->migration_blocker); } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9f37206ba0..d737671028 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1527,9 +1527,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, } =20 if (hdev->migration_blocker !=3D NULL) { - r =3D migrate_add_blocker(hdev->migration_blocker, errp); + r =3D migrate_add_blocker(&hdev->migration_blocker, errp); if (r < 0) { - error_free(hdev->migration_blocker); goto fail_busyloop; } } @@ -1597,10 +1596,7 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) memory_listener_unregister(&hdev->memory_listener); QLIST_REMOVE(hdev, entry); } - if (hdev->migration_blocker) { - migrate_del_blocker(hdev->migration_blocker); - error_free(hdev->migration_blocker); - } + migrate_del_blocker(&hdev->migration_blocker); g_free(hdev->mem); g_free(hdev->mem_sections); if (hdev->vhost_ops) { diff --git a/migration/migration.c b/migration/migration.c index 05c0b801ba..818b02b707 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1465,35 +1465,41 @@ int migrate_init(MigrationState *s, Error **errp) return 0; } =20 -int migrate_add_blocker_internal(Error *reason, Error **errp) +int migrate_add_blocker_internal(Error **reasonp, Error **errp) { /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too= . */ if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) { - error_propagate_prepend(errp, error_copy(reason), + error_propagate_prepend(errp, *reasonp, "disallowing migration blocker " "(migration/snapshot in progress) for: "); + *reasonp =3D NULL; return -EBUSY; } =20 - migration_blockers =3D g_slist_prepend(migration_blockers, reason); + migration_blockers =3D g_slist_prepend(migration_blockers, *reasonp); return 0; } =20 -int migrate_add_blocker(Error *reason, Error **errp) +int migrate_add_blocker(Error **reasonp, Error **errp) { if (only_migratable) { - error_propagate_prepend(errp, error_copy(reason), + error_propagate_prepend(errp, *reasonp, "disallowing migration blocker " "(--only-migratable) for: "); + *reasonp =3D NULL; return -EACCES; } =20 - return migrate_add_blocker_internal(reason, errp); + return migrate_add_blocker_internal(reasonp, errp); } =20 -void migrate_del_blocker(Error *reason) +void migrate_del_blocker(Error **reasonp) { - migration_blockers =3D g_slist_remove(migration_blockers, reason); + if (*reasonp) { + migration_blockers =3D g_slist_remove(migration_blockers, *reasonp= ); + error_free(*reasonp); + *reasonp =3D NULL; + } } =20 void qmp_migrate_incoming(const char *uri, Error **errp) diff --git a/stubs/migr-blocker.c b/stubs/migr-blocker.c index 5676a2f93c..17a5dbf87b 100644 --- a/stubs/migr-blocker.c +++ b/stubs/migr-blocker.c @@ -1,11 +1,11 @@ #include "qemu/osdep.h" #include "migration/blocker.h" =20 -int migrate_add_blocker(Error *reason, Error **errp) +int migrate_add_blocker(Error **reasonp, Error **errp) { return 0; } =20 -void migrate_del_blocker(Error *reason) +void migrate_del_blocker(Error **reasonp) { } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ab72bcdfad..e7c054cc16 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1603,7 +1603,7 @@ static int hyperv_init_vcpu(X86CPU *cpu) error_setg(&hv_passthrough_mig_blocker, "'hv-passthrough' CPU flag prevents migration, use expl= icit" " set of hv-* flags instead"); - ret =3D migrate_add_blocker(hv_passthrough_mig_blocker, &local_err= ); + ret =3D migrate_add_blocker(&hv_passthrough_mig_blocker, &local_er= r); if (ret < 0) { error_report_err(local_err); return ret; @@ -1617,7 +1617,7 @@ static int hyperv_init_vcpu(X86CPU *cpu) " use explicit 'hv-no-nonarch-coresharing=3Don' instead= (but" " make sure SMT is disabled and/or that vCPUs are prope= rly" " pinned)"); - ret =3D migrate_add_blocker(hv_no_nonarch_cs_mig_blocker, &local_e= rr); + ret =3D migrate_add_blocker(&hv_no_nonarch_cs_mig_blocker, &local_= err); if (ret < 0) { error_report_err(local_err); return ret; @@ -2213,7 +2213,7 @@ int kvm_arch_init_vcpu(CPUState *cs) error_setg(&invtsc_mig_blocker, "State blocked by non-migratable CPU device" " (invtsc flag)"); - r =3D migrate_add_blocker(invtsc_mig_blocker, &local_err); + r =3D migrate_add_blocker(&invtsc_mig_blocker, &local_err); if (r < 0) { error_report_err(local_err); return r; @@ -2271,7 +2271,7 @@ int kvm_arch_init_vcpu(CPUState *cs) return 0; =20 fail: - migrate_del_blocker(invtsc_mig_blocker); + migrate_del_blocker(&invtsc_mig_blocker); =20 return r; } diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index fb769868f2..7d752bc5e0 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -929,9 +929,8 @@ nvmm_init_vcpu(CPUState *cpu) error_setg(&nvmm_migration_blocker, "NVMM: Migration not supported"); =20 - if (migrate_add_blocker(nvmm_migration_blocker, &local_error) < 0)= { + if (migrate_add_blocker(&nvmm_migration_blocker, &local_error) < 0= ) { error_report_err(local_error); - error_free(nvmm_migration_blocker); return -EINVAL; } } diff --git a/target/i386/sev.c b/target/i386/sev.c index fe2144c038..9a71246682 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -891,7 +891,7 @@ sev_launch_finish(SevGuestState *sev) /* add migration blocker */ error_setg(&sev_mig_blocker, "SEV: Migration is not implemented"); - migrate_add_blocker(sev_mig_blocker, &error_fatal); + migrate_add_blocker(&sev_mig_blocker, &error_fatal); } =20 static void diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index df3aba2642..d29ba916a0 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2160,9 +2160,8 @@ int whpx_init_vcpu(CPUState *cpu) "State blocked due to non-migratable CPUID feature support," "dirty memory tracking support, and XSAVE/XRSTOR support"); =20 - if (migrate_add_blocker(whpx_migration_blocker, &local_error) < 0)= { + if (migrate_add_blocker(&whpx_migration_blocker, &local_error) < 0= ) { error_report_err(local_error); - error_free(whpx_migration_blocker); ret =3D -EINVAL; goto error; } diff --git a/ui/vdagent.c b/ui/vdagent.c index 00d36a8677..d8f2f95432 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -671,7 +671,7 @@ static void vdagent_chr_open(Chardev *chr, return; #endif =20 - if (migrate_add_blocker(vd->migration_blocker, errp) !=3D 0) { + if (migrate_add_blocker(&vd->migration_blocker, errp) !=3D 0) { return; } =20 @@ -924,13 +924,12 @@ static void vdagent_chr_fini(Object *obj) { VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); =20 - migrate_del_blocker(vd->migration_blocker); + migrate_del_blocker(&vd->migration_blocker); vdagent_disconnect(vd); if (vd->mouse_hs) { qemu_input_handler_unregister(vd->mouse_hs); } buffer_free(&vd->outbuf); - error_free(vd->migration_blocker); } =20 static const TypeInfo vdagent_chr_type_info =3D { --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785375; cv=none; d=zohomail.com; s=zohoarc; b=QHSPxtQexLbUnE06pD7N1f3C5b4kEX9s/yFCONaY11svy4d041DAiTyytT9gt3/Rss/m7T+DgjIaU+QmePRqa0gw6TPaX9UH2V9gNcZB0nD/ReYywK5gcXiFHWG089Y4r2XB7ZbVgh0Px1T86pXbN7IwibRKMYYheHUZeWUFdcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785375; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b9pXnfvE217MgZiA1KwQf4E/+MFgK3AhJc1q/dcWL9Q=; b=QwSNSa96CrI4iVdGiTaGD+athGhQtNPKkYusBHt79lazwHzEUBRRKmGY/+MaXUABbKbTE7DzaFM8ZY/ByA9LKklBQY1TmCW/EABCd18/Kf6KtN5ZJlmy5RYf5aO9rIE1zeWIfYwCLeXFbzyf2y8kqHhaHmHDsWFpDOJuyNtl7hw= 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 1697785375836809.0560161740541; Fri, 20 Oct 2023 00:02:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjT6-0002eb-5s; Fri, 20 Oct 2023 02:58:48 -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 1qtjT3-0002bT-Hx for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjT2-0003X4-0I for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:45 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-151-Gl8yl_f-MbqeImRuS8JXLA-1; Fri, 20 Oct 2023 02:58:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D3D2B88B770; Fri, 20 Oct 2023 06:58:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 104A325C1; Fri, 20 Oct 2023 06:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b9pXnfvE217MgZiA1KwQf4E/+MFgK3AhJc1q/dcWL9Q=; b=DAyfd1DLSPXfe0jz0GSV8WEyz6N2yYY6WBRlxaDFHqV386ekoee/3E61W1n2cVzDeFRn4F NDc/lvvMNoK5S+SYpt9oZdFtnZ20CSJIO+0Y0Wt9ymNo2/W+DKWkaFknbghli+W7vqWTpP uBReFhQh/hKEPWI6n2l18B2Mc5s/+no= X-MC-Unique: Gl8yl_f-MbqeImRuS8JXLA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 03/17] migration: Fix parse_ramblock() on overwritten retvals Date: Fri, 20 Oct 2023 08:57:37 +0200 Message-ID: <20231020065751.26047-4-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785378513100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu It's possible that some errors can be overwritten with success retval later on, and then ignored. Always capture all errors and report. Reported by Coverity 1522861, but actually I spot one more in the same function. Fixes: CID 1522861 Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231017203855.298260-1-peterx@redhat.com> --- migration/ram.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 16c30a9d7a..92769902bb 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3873,6 +3873,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *bloc= k, ram_addr_t length) ret =3D qemu_ram_resize(block, length, &local_err); if (local_err) { error_report_err(local_err); + return ret; } } /* For postcopy we need to check hugepage sizes match */ @@ -3883,7 +3884,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *bloc= k, ram_addr_t length) error_report("Mismatched RAM page size %s " "(local) %zd !=3D %" PRId64, block->idstr, block->page_size, remote_page_size); - ret =3D -EINVAL; + return -EINVAL; } } if (migrate_ignore_shared()) { @@ -3893,7 +3894,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *bloc= k, ram_addr_t length) error_report("Mismatched GPAs for block %s " "%" PRId64 "!=3D %" PRId64, block->idstr, (uint64_t)addr, (uint64_t)block->mr->addr); - ret =3D -EINVAL; + return -EINVAL; } } ret =3D rdma_block_notification_handle(f, block->idstr); --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785270; cv=none; d=zohomail.com; s=zohoarc; b=Efa4IkyrfBHktCwb/Ri5gI+dmdRQYGUEldNK1VMm2pKS8ZpTT/mvJkDkg/gtWSNQlv/Cj1AskpJ8055IDSUK+eVaLBkvJt7rNnuVzrnbkGcjadzDHIOxE9Z54I7HTAh+As+EfcQ57EU82gPiqKm0YoF6bnzTwGRsajNILlFSrfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785270; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VF6oDLtyOYcF3ptVqd+MyQZn9RP0si74mFPnV/wX+pI=; b=VI0kZPyUw3eW+8fvt60/6GanSS6N+HR4XidLTZpsjKapdHBKBxbz1Us2PUbejrQYvnioYXEzkNXQbmXa+Eldq1baoIyCDc/Wd9OAQF7hY/Xx8ppSud9Ie2IYh+o3fqN1H77yUQ6XjcAz3GMYGCd0kbndVp76XZUzyPwMiDrtckw= 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 1697785270695340.76960974106146; Fri, 20 Oct 2023 00:01:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjT4-0002c9-2e; Fri, 20 Oct 2023 02:58:46 -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 1qtjT2-0002Zo-2d for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjSz-0003Vz-UY for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:43 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-fHzfvg1tNdGU2Vhk7l48XQ-1; Fri, 20 Oct 2023 02:58:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 25A8110201E3; Fri, 20 Oct 2023 06:58:29 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2452E25C0; Fri, 20 Oct 2023 06:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VF6oDLtyOYcF3ptVqd+MyQZn9RP0si74mFPnV/wX+pI=; b=dUHxXxd7hh9l+x7P+heIdD8xePUdfPhpM5n9ae3BH4Vly5Nf7Qc5pT3oKyGVpaKbGS5h7n CF5hzQUdwkDsSR4BSZJIk9e6k7EqUYY5QVWW7MAEvNZu9X9cuFWLTY3qSjEQkRvRcCHlC/ vfl6EJ1mmIVX3zKs4fqUxZ+q83bLI2I= X-MC-Unique: fHzfvg1tNdGU2Vhk7l48XQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org, Steve Sistare , Michael Galaxy Subject: [PULL 04/17] migration: simplify notifiers Date: Fri, 20 Oct 2023 08:57:38 +0200 Message-ID: <20231020065751.26047-5-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785272025100008 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Pass the callback function to add_migration_state_change_notifier so that migration can initialize the notifier on add and clear it on delete, which simplifies the call sites. Shorten the function names so the extra arg can be added more legibly. Hide the global notifier list in a new function migration_call_notifiers, and make it externally visible so future live update code can call it. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Tested-by: Michael Galaxy Reviewed-by: Michael Galaxy Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <1686148954-250144-1-git-send-email-steven.sistare@oracle.com> --- include/migration/misc.h | 6 ++++-- hw/net/virtio-net.c | 6 +++--- hw/vfio/migration.c | 6 +++--- migration/migration.c | 22 ++++++++++++++++------ net/vhost-vdpa.c | 7 ++++--- ui/spice-core.c | 3 +-- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 7dcc0b5c2c..673ac490fb 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,8 +60,10 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); -void add_migration_state_change_notifier(Notifier *notify); -void remove_migration_state_change_notifier(Notifier *notify); +void migration_add_notifier(Notifier *notify, + void (*func)(Notifier *notifier, void *data)); +void migration_remove_notifier(Notifier *notify); +void migration_call_notifiers(MigrationState *s); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 29e33ea5ed..b85c7946a7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3624,8 +3624,8 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) n->primary_listener.hide_device =3D failover_hide_primary_device; qatomic_set(&n->failover_primary_hidden, true); device_listener_register(&n->primary_listener); - n->migration_state.notify =3D virtio_net_migration_state_notifier; - add_migration_state_change_notifier(&n->migration_state); + migration_add_notifier(&n->migration_state, + virtio_net_migration_state_notifier); n->host_features |=3D (1ULL << VIRTIO_NET_F_STANDBY); } =20 @@ -3788,7 +3788,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev) if (n->failover) { qobject_unref(n->primary_opts); device_listener_unregister(&n->primary_listener); - remove_migration_state_change_notifier(&n->migration_state); + migration_remove_notifier(&n->migration_state); } else { assert(n->primary_opts =3D=3D NULL); } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 0aaad65c06..28d422b39f 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -872,8 +872,8 @@ static int vfio_migration_init(VFIODevice *vbasedev) NULL; migration->vm_state =3D qdev_add_vm_change_state_handler_full( vbasedev->dev, vfio_vmstate_change, prepare_cb, vbasedev); - migration->migration_state.notify =3D vfio_migration_state_notifier; - add_migration_state_change_notifier(&migration->migration_state); + migration_add_notifier(&migration->migration_state, + vfio_migration_state_notifier); =20 return 0; } @@ -882,7 +882,7 @@ static void vfio_migration_deinit(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; =20 - remove_migration_state_change_notifier(&migration->migration_state); + migration_remove_notifier(&migration->migration_state); qemu_del_vm_change_state_handler(migration->vm_state); unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev); vfio_migration_free(vbasedev); diff --git a/migration/migration.c b/migration/migration.c index 818b02b707..67547eb6a1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1207,7 +1207,7 @@ static void migrate_fd_cleanup(MigrationState *s) /* It is used on info migrate. We can't free it */ error_report_err(error_copy(s->error)); } - notifier_list_notify(&migration_state_notifiers, s); + migration_call_notifiers(s); block_cleanup_parameters(); yank_unregister_instance(MIGRATION_YANK_INSTANCE); } @@ -1311,14 +1311,24 @@ static void migrate_fd_cancel(MigrationState *s) } } =20 -void add_migration_state_change_notifier(Notifier *notify) +void migration_add_notifier(Notifier *notify, + void (*func)(Notifier *notifier, void *data)) { + notify->notify =3D func; notifier_list_add(&migration_state_notifiers, notify); } =20 -void remove_migration_state_change_notifier(Notifier *notify) +void migration_remove_notifier(Notifier *notify) { - notifier_remove(notify); + if (notify->notify) { + notifier_remove(notify); + notify->notify =3D NULL; + } +} + +void migration_call_notifiers(MigrationState *s) +{ + notifier_list_notify(&migration_state_notifiers, s); } =20 bool migration_in_setup(MigrationState *s) @@ -2233,7 +2243,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * spice needs to trigger a transition now */ ms->postcopy_after_devices =3D true; - notifier_list_notify(&migration_state_notifiers, ms); + migration_call_notifiers(ms); =20 ms->downtime =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_sto= p; =20 @@ -3313,7 +3323,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ - notifier_list_notify(&migration_state_notifiers, s); + migration_call_notifiers(s); } =20 migration_rate_set(rate_limit); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 939c984d5b..0f2e6fc58e 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -339,7 +339,8 @@ static void vhost_vdpa_net_data_start_first(VhostVDPASt= ate *s) { struct vhost_vdpa *v =3D &s->vhost_vdpa; =20 - add_migration_state_change_notifier(&s->migration_state); + migration_add_notifier(&s->migration_state, + vdpa_net_migration_state_notifier); if (v->shadow_vqs_enabled) { v->iova_tree =3D vhost_iova_tree_new(v->iova_range.first, v->iova_range.last); @@ -399,7 +400,7 @@ static void vhost_vdpa_net_client_stop(NetClientState *= nc) assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 if (s->vhost_vdpa.index =3D=3D 0) { - remove_migration_state_change_notifier(&s->migration_state); + migration_remove_notifier(&s->migration_state); } =20 dev =3D s->vhost_vdpa.dev; @@ -1456,7 +1457,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; s->always_svq =3D svq; - s->migration_state.notify =3D vdpa_net_migration_state_notifier; + s->migration_state.notify =3D NULL; s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.iova_range =3D iova_range; s->vhost_vdpa.shadow_data =3D svq; diff --git a/ui/spice-core.c b/ui/spice-core.c index 52a59386d7..db21db2c94 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -821,8 +821,7 @@ static void qemu_spice_init(void) }; using_spice =3D 1; =20 - migration_state.notify =3D migration_state_notifier; - add_migration_state_change_notifier(&migration_state); + migration_add_notifier(&migration_state, migration_state_notifier); spice_migrate.base.sif =3D &migrate_interface.base; qemu_spice.add_interface(&spice_migrate.base); =20 --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785387; cv=none; d=zohomail.com; s=zohoarc; b=YrsK87tafVjVtlU3fp2aaK2mFIZUR+TVJ4G2EGgxYTVLRcKFWnIDibCSO85SDj53gUjr1UuST1hRFYfMO1K9aN1j+hq9NIr4fYRvzlGfyIGcDQWzipGRFVxJlWA8AhjD3HWKw0c1frCfrBWFG71NN6quBfWMIaXG9sJnitAAjwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785387; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+qBebYea9Sc/9cMZRnCZCUgrDnNVvTWKR5tveNx55zQ=; b=mYR5kV6xxN97Jp1R7+ucGCbllv/6eFJq44j4G6E+IgMjPuNpoqxr+7gp7fJex30oLd7EcYMia7HuxQowGauMylB9PW9KmrMUeF+v3PkQ7AulLW5DJaASa8VdYdfGPaAPiHwXWrE0cHV+9PylAMo32/cpdil84uXczxJx6faVFgM= 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 169778538754384.29426742748979; Fri, 20 Oct 2023 00:03:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjT6-0002g4-Eo; Fri, 20 Oct 2023 02:58:48 -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 1qtjT4-0002cR-Ia for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjT2-0003XQ-Kr for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:46 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-35-7H8ooKsVMY2eM27BdPrgIg-1; Fri, 20 Oct 2023 02:58:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D16F1C05154; Fri, 20 Oct 2023 06:58:36 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E9C725C0; Fri, 20 Oct 2023 06:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+qBebYea9Sc/9cMZRnCZCUgrDnNVvTWKR5tveNx55zQ=; b=bhV6GYV/INmeHN/PN5xfLU5vC2dCWGoFG6lvSyHdyp/feck3YKrtPLU2CmpQ7VrtoWdN6o tpvddbEDSl/F9baPKRo8bmpBANQcUMtz3rQe5vbgDwB+niVGDMOUzOGP04DRks78gHOQ+Q Y2Y3a5lUr9JFTEDZis7zJBVRwhbs+8U= X-MC-Unique: 7H8ooKsVMY2eM27BdPrgIg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 05/17] migration/multifd: Stop checking p->quit in multifd_send_thread Date: Fri, 20 Oct 2023 08:57:39 +0200 Message-ID: <20231020065751.26047-6-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785388586100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We don't need to check p->quit in the multifd_send_thread() because it is shadowed by the 'exiting' flag. Ever since that flag was added p->quit became obsolete as a way to stop the thread. Since p->quit is set at multifd_send_terminate_threads() under the p->mutex lock, the thread will only see it once it loops, so 'exiting' will always be seen first. Note that setting p->quit at multifd_send_terminate_threads() still makes sense because we need a way to inform multifd_send_pages() that the channel has stopped. Signed-off-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231012140651.13122-3-farosas@suse.de> --- migration/multifd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 1fe53d3b98..e2a45c667a 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -743,9 +743,6 @@ static void *multifd_send_thread(void *opaque) if (flags & MULTIFD_FLAG_SYNC) { qemu_sem_post(&p->sem_sync); } - } else if (p->quit) { - qemu_mutex_unlock(&p->mutex); - break; } else { qemu_mutex_unlock(&p->mutex); /* sometimes there are spurious wakeups */ --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785225; cv=none; d=zohomail.com; s=zohoarc; b=YBwZyqpy1b1cfQN8oVZMcVphSdriyIb0vjZz6VYS+5zA8FmidfX3YTh3WCEsSJig0/qLb0RQYv5oEicGuBtlX8inewOVZXez9xa0JyTWCTD8oJ5eyObf6XDDjm6NNmjyk9R2jIazZkxq3fFR856zuN8nlFwCyU6tc/ARlTjJYnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785225; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DXWEVBlIcLBd6yDALjVLIhuAbVizKeUEyowRi41q+m0=; b=F0+JDCjFcp0ZqO86oFXO8NQ9LuMiVQB3hhrMW0yjbSjxFN1RBdTyoMnQqdIKMWuhTzenoyrdID8FvmwVwT8VYe6zuxr78WLyVTwCNFw2jVF1rpbuVKbFB7G5X5Gz364EYHB7PXoIDpXgxjaGcITcbmQgNpfl+gPTMooHpDY8L10= 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 1697785225012236.01308384932145; Fri, 20 Oct 2023 00:00:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjTO-00034e-6e; Fri, 20 Oct 2023 02:59:06 -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 1qtjTF-0002uc-JZ for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTC-0003ZN-Vx for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:56 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-zbzUsfckNCi7Kw-aqmSPxQ-1; Fri, 20 Oct 2023 02:58:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FC6C869ECC; Fri, 20 Oct 2023 06:58:43 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EACA25C0; Fri, 20 Oct 2023 06:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DXWEVBlIcLBd6yDALjVLIhuAbVizKeUEyowRi41q+m0=; b=FWpnYVy6wF68a89KRfp29EQHQ346hKpFGdmtx+4O4GFW3QAgDg/9MTacW+ebMGyKL/k+9d peILxnhcjxF1gPkfm/jUbUPH4IEsgDLtiU48w+bHxK4BdeKFrcqrgOBCfoYsGqIjnXOqNc qNLflGwCh18d2JQEgBu5nSr1ls5K2KA= X-MC-Unique: zbzUsfckNCi7Kw-aqmSPxQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 06/17] tests/qtest: Allow qtest_qemu_binary to use a custom environment variable Date: Fri, 20 Oct 2023 08:57:40 +0200 Message-ID: <20231020065751.26047-7-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785225585100009 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We're adding support for testing migration using two different QEMU binaries. We'll provide the second binary in a new environment variable. Allow qtest_qemu_binary() to receive the name of the new variable. If the new environment variable is not set, that's not an error, we use QTEST_QEMU_BINARY as a fallback. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-2-farosas@suse.de> --- tests/qtest/libqtest.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index dc7a55634c..03fa644663 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -336,10 +336,17 @@ void qtest_remove_abrt_handler(void *data) } } =20 -static const char *qtest_qemu_binary(void) +static const char *qtest_qemu_binary(const char *var) { const char *qemu_bin; =20 + if (var) { + qemu_bin =3D getenv(var); + if (qemu_bin) { + return qemu_bin; + } + } + qemu_bin =3D getenv("QTEST_QEMU_BINARY"); if (!qemu_bin) { fprintf(stderr, "Environment variable QTEST_QEMU_BINARY required\n= "); @@ -392,7 +399,7 @@ static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu= (const char *fmt, ...) =20 va_start(ap, fmt); g_string_append_printf(command, CMD_EXEC "%s %s", - qtest_qemu_binary(), tracearg); + qtest_qemu_binary(NULL), tracearg); g_string_append_vprintf(command, fmt, ap); va_end(ap); =20 @@ -905,7 +912,7 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...) =20 const char *qtest_get_arch(void) { - const char *qemu =3D qtest_qemu_binary(); + const char *qemu =3D qtest_qemu_binary(NULL); const char *end =3D strrchr(qemu, '-'); =20 if (!end) { --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785401; cv=none; d=zohomail.com; s=zohoarc; b=cDrFmAIvBG5MM0uC7Su1zdpcAb+NInXPqFngwapsdGe2Yb1AxzgQZUcS8X4IYMFMdZtLM6SDXAwaXEX1Bmz+yruF/hvcRWJClEZ58iPK0L8+NeAJjZGQCWjVcvewxkcB2RkMuBIJN1+4f5lt9ExwtT7Hyx8aJArcI9gcEpft6cI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785401; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aTn9veGAxLAYJslyZIyZzW0sClB0zJRQrXIWfbzdZi4=; b=Ob11IbKHojXsfZ8ao2AAvJn2q0KJek5vjINiAK2++QJifZoAfGTuR/NObimKKRAh9EJ2Dj2l0WfDuLF+skQ0kscSQ5vN1GtsASKudYrs7CE7H2IWMBvcW0Fyk6ajZFOdZ7STfJL9gLFt8hWYg/0QkT4Zyq0V9vTf1MuPEmTLWhE= 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 1697785401591457.41549039667996; Fri, 20 Oct 2023 00:03:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjTP-00039P-DB; Fri, 20 Oct 2023 02:59:07 -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 1qtjTF-0002uo-KT for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTD-0003Zt-Gr for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:58:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-a7AaMWqrOZumdOKVwB96Vw-1; Fri, 20 Oct 2023 02:58:51 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5580010201E3; Fri, 20 Oct 2023 06:58:50 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9A5625C0; Fri, 20 Oct 2023 06:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aTn9veGAxLAYJslyZIyZzW0sClB0zJRQrXIWfbzdZi4=; b=Wur4wpqeSEfsSfKYr1RlE83z29icBXTJku9AdqVYjprrmvwJudD8n57bLp+1ZjJC4yNhEU jRiph8R8suAn2jVB9S5xE7Qfh613GrYf1aFZ8lSyab69KWSl4S6V86rp1rlzBEz26LzhpB NvU1YMFsVAt2zwubZaIEPSWw0l2mxYI= X-MC-Unique: a7AaMWqrOZumdOKVwB96Vw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 07/17] tests/qtest: Introduce qtest_init_with_env Date: Fri, 20 Oct 2023 08:57:41 +0200 Message-ID: <20231020065751.26047-8-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1697785402620100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Add a version of qtest_init() that takes an environment variable containing the path of the QEMU binary. This allows tests to use more than one QEMU binary. If no variable is provided or the environment variable does not exist, that is not an error. Fallback to using QTEST_QEMU_BINARY. Signed-off-by: Fabiano Rosas Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-3-farosas@suse.de> --- tests/qtest/libqtest.h | 13 +++++++++++++ tests/qtest/libqtest.c | 26 +++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 5fe3d13466..76fc195f1c 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -55,6 +55,19 @@ QTestState *qtest_vinitf(const char *fmt, va_list ap) G_= GNUC_PRINTF(1, 0); */ QTestState *qtest_init(const char *extra_args); =20 +/** + * qtest_init_with_env: + * @var: Environment variable from where to take the QEMU binary + * @extra_args: Other arguments to pass to QEMU. CAUTION: these + * arguments are subject to word splitting and shell evaluation. + * + * Like qtest_init(), but use a different environment variable for the + * QEMU binary. + * + * Returns: #QTestState instance. + */ +QTestState *qtest_init_with_env(const char *var, const char *extra_args); + /** * qtest_init_without_qmp_handshake: * @extra_args: other arguments to pass to QEMU. CAUTION: these diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 03fa644663..9eebba8767 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -388,7 +388,8 @@ static pid_t qtest_create_process(char *cmd) } #endif /* _WIN32 */ =20 -static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu(const char *fmt, .= ..) +static QTestState *G_GNUC_PRINTF(2, 3) qtest_spawn_qemu(const char *qemu_b= in, + const char *fmt, .= ..) { va_list ap; QTestState *s =3D g_new0(QTestState, 1); @@ -398,8 +399,7 @@ static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu= (const char *fmt, ...) g_autoptr(GString) command =3D g_string_new(""); =20 va_start(ap, fmt); - g_string_append_printf(command, CMD_EXEC "%s %s", - qtest_qemu_binary(NULL), tracearg); + g_string_append_printf(command, CMD_EXEC "%s %s", qemu_bin, tracearg); g_string_append_vprintf(command, fmt, ap); va_end(ap); =20 @@ -438,7 +438,8 @@ static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu= (const char *fmt, ...) return s; } =20 -QTestState *qtest_init_without_qmp_handshake(const char *extra_args) +static QTestState *qtest_init_internal(const char *qemu_bin, + const char *extra_args) { QTestState *s; int sock, qmpsock, i; @@ -463,7 +464,8 @@ QTestState *qtest_init_without_qmp_handshake(const char= *extra_args) sock =3D init_socket(socket_path); qmpsock =3D init_socket(qmp_socket_path); =20 - s =3D qtest_spawn_qemu("-qtest unix:%s " + s =3D qtest_spawn_qemu(qemu_bin, + "-qtest unix:%s " "-qtest-log %s " "-chardev socket,path=3D%s,id=3Dchar0 " "-mon chardev=3Dchar0,mode=3Dcontrol " @@ -516,9 +518,14 @@ QTestState *qtest_init_without_qmp_handshake(const cha= r *extra_args) return s; } =20 -QTestState *qtest_init(const char *extra_args) +QTestState *qtest_init_without_qmp_handshake(const char *extra_args) { - QTestState *s =3D qtest_init_without_qmp_handshake(extra_args); + return qtest_init_internal(qtest_qemu_binary(NULL), extra_args); +} + +QTestState *qtest_init_with_env(const char *var, const char *extra_args) +{ + QTestState *s =3D qtest_init_internal(qtest_qemu_binary(var), extra_ar= gs); QDict *greeting; =20 /* Read the QMP greeting and then do the handshake */ @@ -529,6 +536,11 @@ QTestState *qtest_init(const char *extra_args) return s; } =20 +QTestState *qtest_init(const char *extra_args) +{ + return qtest_init_with_env(NULL, extra_args); +} + QTestState *qtest_vinitf(const char *fmt, va_list ap) { char *args =3D g_strdup_vprintf(fmt, ap); --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785205; cv=none; d=zohomail.com; s=zohoarc; b=lTB2PEo4dYHya8jxDoSeXld4QNBzaHxNl2Q9RG3sqU2kHMJNDAr3dIF+F+QDpNf5gAZbbyu5JokCLwWDc0P5KjjLcgZyEqJvW5XrMR+2yH5yA4mlQokZZaPbqAKplBcDGG29DBGvvFEI6zBeRRBCV+1XWEdehirCATszkBeqmSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785205; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=62Wx7d+hUDk5LG3UXJEzcN6iBAElK9cZPEKqQ1pd96A=; b=AbwUF9Glgl1e4ngvZOGW+RecqCJlXUJv4AnCHLjzcOBW7rmrO6GYOHeUxFS0+SqgzPCZS28myQNjKoF1utWt0VsxBEjsMMfRPiU9DlsuwhnnCUSs6hUtlth/Azslv50y7uS++V0vOic1Wh2FDGhbFOrcobR0wITSSKbikCESCPU= 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 169778520597568.58941175628377; Fri, 20 Oct 2023 00:00:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjTV-0003FW-SL; Fri, 20 Oct 2023 02:59:13 -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 1qtjTT-0003DF-IN for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTP-0003cY-1R for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:09 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-67LFWRorOMSgATgpK2Uo5A-1; Fri, 20 Oct 2023 02:58:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B20C2810D47; Fri, 20 Oct 2023 06:58:57 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EA9425C0; Fri, 20 Oct 2023 06:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62Wx7d+hUDk5LG3UXJEzcN6iBAElK9cZPEKqQ1pd96A=; b=byGI6GIoO7Gx9l77XFglClEagOps8o8uJBveXj03ZilU4AO7UdGQJBA1dLCtKct8W1UZYr QVNPHZfxbVfpBBoB4cGtO1xdlPUWDBcaG8z1uCcdc5ClKLuYl5U48A0TeS/sl+g8pFaKe8 TgS2dBUG+0p+0wFQnLTTkskgUYlJwuo= X-MC-Unique: 67LFWRorOMSgATgpK2Uo5A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 08/17] tests/qtest: Allow qtest_get_machines to use an alternate QEMU binary Date: Fri, 20 Oct 2023 08:57:42 +0200 Message-ID: <20231020065751.26047-9-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785207884100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We're adding support for using more than one QEMU binary in tests. Modify qtest_get_machines() to take an environment variable that contains the QEMU binary path. Since the function keeps a cache of the machines list in the form of a static variable, refresh it any time the environment variable changes. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-4-farosas@suse.de> --- tests/qtest/libqtest.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 9eebba8767..3cc7bf3076 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1468,13 +1468,26 @@ struct MachInfo { char *alias; }; =20 +static void qtest_free_machine_list(struct MachInfo *machines) +{ + if (machines) { + for (int i =3D 0; machines[i].name !=3D NULL; i++) { + g_free(machines[i].name); + g_free(machines[i].alias); + } + + g_free(machines); + } +} + /* * Returns an array with pointers to the available machine names. * The terminating entry has the name set to NULL. */ -static struct MachInfo *qtest_get_machines(void) +static struct MachInfo *qtest_get_machines(const char *var) { static struct MachInfo *machines; + static char *qemu_var; QDict *response, *minfo; QList *list; const QListEntry *p; @@ -1483,11 +1496,19 @@ static struct MachInfo *qtest_get_machines(void) QTestState *qts; int idx; =20 + if (g_strcmp0(qemu_var, var)) { + qemu_var =3D g_strdup(var); + + /* new qemu, clear the cache */ + qtest_free_machine_list(machines); + machines =3D NULL; + } + if (machines) { return machines; } =20 - qts =3D qtest_init("-machine none"); + qts =3D qtest_init_with_env(qemu_var, "-machine none"); response =3D qtest_qmp(qts, "{ 'execute': 'query-machines' }"); g_assert(response); list =3D qdict_get_qlist(response, "return"); @@ -1528,7 +1549,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char= *machine), struct MachInfo *machines; int i; =20 - machines =3D qtest_get_machines(); + machines =3D qtest_get_machines(NULL); =20 for (i =3D 0; machines[i].name !=3D NULL; i++) { /* Ignore machines that cannot be used for qtests */ @@ -1549,7 +1570,7 @@ bool qtest_has_machine(const char *machine) struct MachInfo *machines; int i; =20 - machines =3D qtest_get_machines(); + machines =3D qtest_get_machines(NULL); =20 for (i =3D 0; machines[i].name !=3D NULL; i++) { if (g_str_equal(machine, machines[i].name) || --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785225; cv=none; d=zohomail.com; s=zohoarc; b=GJlXKv6BtK9oTi2LuLpyTbvl/iGGBeET/wQrRQxdi2XrXQvjVzEdCkD089PnJ9T68W5iySGcpGcx6X0wtbPOSSR4+Mdc6vaFIEnDeUnysypESGIJaBOlyVM3yRtliY5J2SuMH3ITXopi5+Exf3gm7Afs08tThS5PsvD6/qtNklw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785225; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UvqeZdhYhfKzgLjBZRcYvls2Y57BmP1MiE49zKSMaRk=; b=J2Gz0oCSujJ00OzJ0pEKv2mG1WBopo4W5OZ8YfICDtbTGoKKkr6zvDgQ/YPynkNUTdBrj131Doq8CVVdfotqDfMPD2eZdKNE5+HThpo+l/7YRTW0eOERT6qvQ4kiMsIUqQbvZn6QEQCWgTfXMODZxG+W7oi+oD26bJDelpeu70Q= 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 169778522588877.31849392292986; Fri, 20 Oct 2023 00:00:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjTh-0004P5-1T; Fri, 20 Oct 2023 02:59:25 -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 1qtjTf-0004Eg-Ju for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTd-0003mx-S3 for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:23 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-495-MNOE15wlNZmcK9X0buzJ3g-1; Fri, 20 Oct 2023 02:59:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B251E2810D45; Fri, 20 Oct 2023 06:59:04 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84BE825C0; Fri, 20 Oct 2023 06:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UvqeZdhYhfKzgLjBZRcYvls2Y57BmP1MiE49zKSMaRk=; b=GJL5+nHCMMBZzTCICEB4W37wOZK2JW+d4RVFPfbSnv45/DCznH43ImnBkd+Wqy7tgObfMW +Id8uImX+FAZCLXH7ae18kAVj1zG/peglWofs3Z4V159a/hare3hJZfZbuhsy8lIIdB55m VX8JKKrBLBZZhgLa+j+cwzole9agT3E= X-MC-Unique: MNOE15wlNZmcK9X0buzJ3g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 09/17] tests/qtest: Introduce qtest_has_machine_with_env Date: Fri, 20 Oct 2023 08:57:43 +0200 Message-ID: <20231020065751.26047-10-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785227612100015 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Add a variant of qtest_has_machine() that receives an environment variable containing an alternate QEMU binary path. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-5-farosas@suse.de> --- tests/qtest/libqtest.h | 9 +++++++++ tests/qtest/libqtest.c | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 76fc195f1c..d16deb9891 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -930,6 +930,15 @@ void qtest_cb_for_every_machine(void (*cb)(const char = *machine), */ bool qtest_has_machine(const char *machine); =20 +/** + * qtest_has_machine_with_env: + * @var: Environment variable from where to take the QEMU binary + * @machine: The machine to look for + * + * Returns: true if the machine is available in the specified binary. + */ +bool qtest_has_machine_with_env(const char *var, const char *machine); + /** * qtest_has_device: * @device: The device to look for diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 3cc7bf3076..603d900e7d 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1565,12 +1565,12 @@ void qtest_cb_for_every_machine(void (*cb)(const ch= ar *machine), } } =20 -bool qtest_has_machine(const char *machine) +bool qtest_has_machine_with_env(const char *var, const char *machine) { struct MachInfo *machines; int i; =20 - machines =3D qtest_get_machines(NULL); + machines =3D qtest_get_machines(var); =20 for (i =3D 0; machines[i].name !=3D NULL; i++) { if (g_str_equal(machine, machines[i].name) || @@ -1582,6 +1582,11 @@ bool qtest_has_machine(const char *machine) return false; } =20 +bool qtest_has_machine(const char *machine) +{ + return qtest_has_machine_with_env(NULL, machine); +} + bool qtest_has_device(const char *device) { static QList *list; --=20 2.41.0 From nobody Wed Nov 27 14:36:19 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785222; cv=none; d=zohomail.com; s=zohoarc; b=TARfYKH1vPbIaXe9j3qpN5MY97bVbj5KeKGk+eiu2BFteSEX0QsvjIKKglE66QnvwmzqoTMMIM5tWm2THh+mjaXpRChCEQ/1MwekLXVc6d4ew0Tz8uiDadNcXqFmS0YvFNuXWNaE+Nis/M/qMXpVDyoF/EbxLOB+CpPYADXlDCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785222; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NSgHyHEZfPE9cd1uGtechBOjRxN9vNPYJYi2OtzuiQ0=; b=mkges/tSd+c6iD2xAe8iV4W6O9FKgSx8/KqiJgVXftmNdJnxglI3NszGVAGGSWDklf0wSf48vDxqPaJTXPWOKzY3g0++2KA3ilZhdTd9+tFM5HpJVUX3faHXj8SWfTw6u7D6mxEhNcPMifLueAE5qoR8AcRGE7pAIl6ZetL6sCI= 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 1697785222944122.5475210875104; Fri, 20 Oct 2023 00:00:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjTu-0004oO-Jp; Fri, 20 Oct 2023 02:59:38 -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 1qtjTn-0004ei-Na for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTj-0003ox-5N for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:31 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-395-A4rH87AqMS-35XtixiB6ZQ-1; Fri, 20 Oct 2023 02:59:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C07C29AA2C2; Fri, 20 Oct 2023 06:59:11 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06B3725C0; Fri, 20 Oct 2023 06:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NSgHyHEZfPE9cd1uGtechBOjRxN9vNPYJYi2OtzuiQ0=; b=hBV8PZI6cKvXw4KzFQICxzUX++gHgGrGuqoyxuc+g3xFXfzMkwzcFuD745hcYEYX1KDEPw XUffsuWjbPA/UPcdtF+9clqMZRTOn2fviLqHLUMZFcUyb0h6QOkNmOc8H8yckAo+nNeIhz IfgDma39P+cBMorw6fUZH8+SnMEodww= X-MC-Unique: A4rH87AqMS-35XtixiB6ZQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 10/17] tests/qtest: Introduce qtest_resolve_machine_alias Date: Fri, 20 Oct 2023 08:57:44 +0200 Message-ID: <20231020065751.26047-11-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785223605100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas The migration tests are being enhanced to test migration between different QEMU versions. A requirement of migration is that the machine type between source and destination matches, including the version. We cannot hardcode machine types in the tests because those change with each release. QEMU provides a machine type alias that has a fixed name, but points to the latest machine type at each release. Add a helper to resolve the alias into the exact machine type. E.g. "-machine pc" resolves to "pc-i440fx-8.2" Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-6-farosas@suse.de> --- tests/qtest/libqtest.h | 10 ++++++++++ tests/qtest/libqtest.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index d16deb9891..6e3d3525bf 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -922,6 +922,16 @@ void qtest_qmp_fds_assert_success(QTestState *qts, int= *fds, size_t nfds, void qtest_cb_for_every_machine(void (*cb)(const char *machine), bool skip_old_versioned); =20 +/** + * qtest_resolve_machine_alias: + * @var: Environment variable from where to take the QEMU binary + * @alias: The alias to resolve + * + * Returns: the machine type corresponding to the alias if any, + * otherwise NULL. + */ +char *qtest_resolve_machine_alias(const char *var, const char *alias); + /** * qtest_has_machine: * @machine: The machine to look for diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 603d900e7d..c843c41188 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1565,6 +1565,22 @@ void qtest_cb_for_every_machine(void (*cb)(const cha= r *machine), } } =20 +char *qtest_resolve_machine_alias(const char *var, const char *alias) +{ + struct MachInfo *machines; + int i; + + machines =3D qtest_get_machines(var); + + for (i =3D 0; machines[i].name !=3D NULL; i++) { + if (machines[i].alias && g_str_equal(alias, machines[i].alias)) { + return g_strdup(machines[i].name); + } + } + + return NULL; +} + bool qtest_has_machine_with_env(const char *var, const char *machine) { struct MachInfo *machines; --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785337; cv=none; d=zohomail.com; s=zohoarc; b=SEaBRZ4+cnYVCS7XTYQuYKHGafaC+oo7wssxMtWfW20SsiWgMvvtRVBWHIddA6QchHbT2ZvwKaVAI+HidFU7m9vWvePhMj0LjM1fqfpS8CY198Gp5KU0Az9gLkc6W9nVruzUrNms7M2itG4/ORnB+rQRYJfUQEAWzYKaPWruA2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785337; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s8q34WPeVwwWmtWZXJNkr41CpA/2YBdbzKgCn8LRZ9E=; b=KWn324Ni0cR8TEcadMuqtPrXO6axTcGU0X7WGfCEFpEVJ8B0qoekl6EGxNsTJ9trgW8LlCfXfU0logKPpuTpNl+hT6aBjDyxbWVwDMY7Pqj45IWk8SX9eRJ1Qwi+VitSfB+TO9FpV5h1rg7qKzrr4URqtVT2olyaL7jFp1s3mS4= 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 1697785337111734.485356894385; Fri, 20 Oct 2023 00:02:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjTn-0004eL-9p; Fri, 20 Oct 2023 02:59:31 -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 1qtjTi-0004Vm-21 for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTg-0003ny-47 for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:25 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-78-GTfhQzdOOVuShxXLwSW9xA-1; Fri, 20 Oct 2023 02:59:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82BB238116F3; Fri, 20 Oct 2023 06:59:18 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5C8625C0; Fri, 20 Oct 2023 06:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s8q34WPeVwwWmtWZXJNkr41CpA/2YBdbzKgCn8LRZ9E=; b=Pl1mce7XFWi1liPxaufs8reR5/XiAcfsJgyekuQ2Yf4INgS8MwXtbgfJCTfsICU/tITQfI /uCNTI1AGnljXd1m7JaPkDB9AlP06YnJMDIdiJjQXCsMNscjjaLUcLXxxrLdV0x5MYNMRT i9W0U+ZE3aj45EoYq8AQDNV4Ivq9Bu8= X-MC-Unique: GTfhQzdOOVuShxXLwSW9xA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 11/17] tests/qtest/migration: Introduce find_common_machine_version Date: Fri, 20 Oct 2023 08:57:45 +0200 Message-ID: <20231020065751.26047-12-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785338353100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas When using two different QEMU binaries for migration testing, we'll need to find what is the machine version that will work with both binaries. Add a helper for that. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-7-farosas@suse.de> --- tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-helpers.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 4f51d0f8bc..d1c2351d33 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -43,4 +43,6 @@ void wait_for_migration_complete(QTestState *who); =20 void wait_for_migration_fail(QTestState *from, bool allow_active); =20 +char *find_common_machine_version(const char *mtype, const char *var1, + const char *var2); #endif /* MIGRATION_HELPERS_H */ diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 0c185db450..13449c1fe1 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -240,3 +240,29 @@ void wait_for_migration_fail(QTestState *from, bool al= low_active) g_assert(qdict_get_bool(rsp_return, "running")); qobject_unref(rsp_return); } + +char *find_common_machine_version(const char *mtype, const char *var1, + const char *var2) +{ + g_autofree char *type1 =3D qtest_resolve_machine_alias(var1, mtype); + g_autofree char *type2 =3D qtest_resolve_machine_alias(var2, mtype); + + g_assert(type1 && type2); + + if (g_str_equal(type1, type2)) { + /* either can be used */ + return g_strdup(type1); + } + + if (qtest_has_machine_with_env(var2, type1)) { + return g_strdup(type1); + } + + if (qtest_has_machine_with_env(var1, type2)) { + return g_strdup(type2); + } + + g_test_message("No common machine version for machine type '%s' betwee= n " + "binaries %s and %s", mtype, getenv(var1), getenv(var2)= ); + g_assert_not_reached(); +} --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785259; cv=none; d=zohomail.com; s=zohoarc; b=B5l/nVf1/cZurpOgZMG5/bAoJ6XrsKuNN96d65PZgaJ7lz41BKgRnjbfuqRtkDYd+YCRZA6/dFQ9Dl0BZK2sAtCSZksE2wq1jQPhgzeq+EEIeYtyTXFGADB5EUYOLEEJeljNtVrIw/xOmNSVgGEL91bs3or4jiGen326yEXVbTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785259; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rbNbI20heWd00U5Y9TovTUKtsrNmucO4Gcl0M7WtmH8=; b=ZgFUF+C1ibLTTNxDCp9qWxbYDqbKZZWqb+TXkT4RTqQAuuFFe7Hce7egysEAQJxXrE2qUxqe+iGDhM3VNm/RVldI6jg1M71jMANqu4q2R2y8+lPGGbdGkR6VVdZGzv48BXmfaOVM1VAZkiISLfRbAClcg9pxgNnFmeghiH5ZOzo= 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 1697785259244352.41816878032694; Fri, 20 Oct 2023 00:00:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjU2-00057E-Er; Fri, 20 Oct 2023 02:59:46 -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 1qtjTs-0004oq-F2 for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjTo-0003uc-IN for qemu-devel@nongnu.org; Fri, 20 Oct 2023 02:59:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-B_HUPvvDP0CLP862x3tfYw-1; Fri, 20 Oct 2023 02:59:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C20688B7A2; Fri, 20 Oct 2023 06:59:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC06F25C0; Fri, 20 Oct 2023 06:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rbNbI20heWd00U5Y9TovTUKtsrNmucO4Gcl0M7WtmH8=; b=APMyUcvJe+SM2ydO+F3XULMgakK+uHmAvfJId3Ckz7+/t21APOMs1/IWSlMu/w46DGo1Wg /+Qa5ZnSvCbIh15hZ2qhFJ3fNs9sbwsqNG5I4ibcbAglVMMrscnWc7l3DAb25BR3l2z5iB cMmXXK5z3hWEpk+Wj+LKKEWvJ0vHnF8= X-MC-Unique: B_HUPvvDP0CLP862x3tfYw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 12/17] tests/qtest/migration: Define a machine for all architectures Date: Fri, 20 Oct 2023 08:57:46 +0200 Message-ID: <20231020065751.26047-13-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785259804100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Stop relying on defaults and select a machine explicitly for every architecture. This is a prerequisite for being able to select machine types for migration using different QEMU binaries for source and destination. Signed-off-by: Fabiano Rosas Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-8-farosas@suse.de> --- tests/qtest/migration-test.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 241b409857..dfea75b76f 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -743,6 +743,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, const char *kvm_opts =3D NULL; const char *arch =3D qtest_get_arch(); const char *memory_size; + const char *machine_alias, *machine_opts =3D ""; =20 if (args->use_shmem) { if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { @@ -755,11 +756,13 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, got_dst_resume =3D false; if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; + machine_alias =3D "pc"; arch_opts =3D g_strdup_printf("-drive file=3D%s,format=3Draw", boo= tpath); start_address =3D X86_TEST_MEM_START; end_address =3D X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { memory_size =3D "128M"; + machine_alias =3D "s390-ccw-virtio"; arch_opts =3D g_strdup_printf("-bios %s", bootpath); start_address =3D S390_TEST_MEM_START; end_address =3D S390_TEST_MEM_END; @@ -771,11 +774,14 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, "'nvramrc=3Dhex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\"= 0 " "until'", end_address, start_address= ); - arch_opts =3D g_strdup("-nodefaults -machine vsmt=3D8"); + machine_alias =3D "pseries"; + machine_opts =3D "vsmt=3D8"; + arch_opts =3D g_strdup("-nodefaults"); } else if (strcmp(arch, "aarch64") =3D=3D 0) { memory_size =3D "150M"; - arch_opts =3D g_strdup_printf("-machine virt,gic-version=3Dmax -cp= u max " - "-kernel %s", bootpath); + machine_alias =3D "virt"; + machine_opts =3D "gic-version=3Dmax"; + arch_opts =3D g_strdup_printf("-cpu max -kernel %s", bootpath); start_address =3D ARM_TEST_MEM_START; end_address =3D ARM_TEST_MEM_END; } else { @@ -810,11 +816,13 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, } =20 cmd_source =3D g_strdup_printf("-accel kvm%s -accel tcg " + "-machine %s,%s " "-name source,debug-threads=3Don " "-m %s " "-serial file:%s/src_serial " "%s %s %s %s %s", kvm_opts ? kvm_opts : "", + machine_alias, machine_opts, memory_size, tmpfs, arch_opts ? arch_opts : "", arch_source ? arch_source : "", @@ -829,12 +837,14 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, } =20 cmd_target =3D g_strdup_printf("-accel kvm%s -accel tcg " + "-machine %s,%s " "-name target,debug-threads=3Don " "-m %s " "-serial file:%s/dest_serial " "-incoming %s " "%s %s %s %s %s", kvm_opts ? kvm_opts : "", + machine_alias, machine_opts, memory_size, tmpfs, uri, arch_opts ? arch_opts : "", arch_target ? arch_target : "", --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785236; cv=none; d=zohomail.com; s=zohoarc; b=CIJ89arLYuCPSfHNVvdwP49aHM6jWNJIlquhhkoJVEQc2T78JOJXpHXvyxS8BZ7XXmw2Z0zxS+r7h60hnvo41WpboQyHxCY75oTn2vNxrab3yeZT2tOSbeCTGOK4rSrRiOwuiLeyBefFST9dN5AyR5oWbZycosI0zlwIUA0t6xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785236; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/ct7tpaBQF/mAugReIGRzRiq07xyYjlXknJgUpBhWjc=; b=BfBoSgG1qvCBl/OKcn+LRFTA6t6tP4cuQiJ7ZBJg5LkCR2sC6X2VF0GZGZpCVl/OAvTgc8fhEyFlAUGQDCUZHjN36xBSa0Jx8aBci2FDBOw6MVbbHhQnDdDOZBUr/J70hAz+bvyN+HypGa7tf0OAfQ/n5Evb8QUhK9CCdVHG5sc= 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 1697785236490900.9187363242005; Fri, 20 Oct 2023 00:00:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjUN-0006LB-KO; Fri, 20 Oct 2023 03:00:08 -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 1qtjUG-0005yq-E3 for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjUA-0004M3-Mh for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:00 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-9Ml-1w3MMcu4zB3EHdme4w-1; Fri, 20 Oct 2023 02:59:35 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E93B86B8C0; Fri, 20 Oct 2023 06:59:32 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id E540B25C0; Fri, 20 Oct 2023 06:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ct7tpaBQF/mAugReIGRzRiq07xyYjlXknJgUpBhWjc=; b=iY2MqIg1tf+ABuaXT5ScWLuwSs1w78A4g2OgnSvtzYt0/8zyoU62pZXRZSLptV/bp3dVIR OIl4n2Gx4p9w6JAB29CYCVXrgiJsUAwWhXqC1cfbaJ3zATTQUjwDm3UTEfYH6fo/k4ldFo dXPadOMM0pyVHVmuRb3QDvHyBbUg3H8= X-MC-Unique: 9Ml-1w3MMcu4zB3EHdme4w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 13/17] tests/qtest/migration: Specify the geometry of the bootsector Date: Fri, 20 Oct 2023 08:57:47 +0200 Message-ID: <20231020065751.26047-14-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785237673100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We're about to enable the x86_64 tests to run with the q35 machine, but that machine does not work with the program we use to dirty the memory for the tests. The issue is that QEMU needs to guess the geometry of the "disk" we give to it and the guessed geometry doesn't pass the sanity checks done by SeaBIOS. This causes SeaBIOS to interpret the geometry as if needing a translation from LBA to CHS and SeaBIOS ends up miscomputing the number of cylinders and aborting due to that. The reason things work with the "pc" machine is that is uses ATA instead of AHCI like q35 and SeaBIOS has an exception for ATA that ends up skipping the sanity checks and ignoring translation altogether. Workaround this situation by specifying a geometry in the command line. Signed-off-by: Fabiano Rosas Acked-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-9-farosas@suse.de> --- tests/qtest/migration-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index dfea75b76f..9959a0dc12 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -757,7 +757,9 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; machine_alias =3D "pc"; - arch_opts =3D g_strdup_printf("-drive file=3D%s,format=3Draw", boo= tpath); + arch_opts =3D g_strdup_printf( + "-drive if=3Dnone,id=3Dd0,file=3D%s,format=3Draw " + "-device ide-hd,drive=3Dd0,secs=3D1,cyls=3D1,heads=3D1", bootp= ath); start_address =3D X86_TEST_MEM_START; end_address =3D X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785292; cv=none; d=zohomail.com; s=zohoarc; b=jR1ckjaMFRmyeLKgdpL0YYAlKNanRW+I82QOheOlizLeajQmWQNSaPy79nYVDsinNDv3NTyOgMvYu1+pMmB7NE61sJUdGDhjdxzngASahJsBDkDiKnz2beXyFmEMAWkQSd5Fgyg67oOEgCb9L/DpSNGQ7I1hfvV+2hGHdSOCzrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785292; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0AjHopf0WSr2ZtMzzl7kHx/e4uPmz/VqQWHe0zDEnXg=; b=JwA22s+A04tUkDsdpIQsgs28ioNPbjRd71nlLitr/2aoMOoZ6RgLPsVTGLy76H8f7U0MddH2hejqmeWlPHTq4+JXAl909XK+SY8rS/hQnixkcpviGYi7OFZJ1AVM6EaAdfW3VK//WWE46vqCtCKGJaU8Q43GlFKfJDsMxhSEw9A= 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 1697785292175393.35251469614843; Fri, 20 Oct 2023 00:01:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjUS-0006RS-CF; Fri, 20 Oct 2023 03:00:12 -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 1qtjUK-0006Au-0z for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjUG-0004Q6-Uh for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:02 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-G2MNXjNWMiGGAYIq1SYCYQ-1; Fri, 20 Oct 2023 02:59:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 64AEA3C025BA; Fri, 20 Oct 2023 06:59:39 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id C911D25C0; Fri, 20 Oct 2023 06:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0AjHopf0WSr2ZtMzzl7kHx/e4uPmz/VqQWHe0zDEnXg=; b=G7G2ua8CRtzxQEH05k9BrkMmaxkXSoIJ4dJsajP1IuDjy6lCz+uZn1SF+PV7DLSjnmU1qM oo5mo6SXMKUScW/Dxspx3ItredCYpAvlB/b0TXTScRmF8wxmYm3ylEmoKP7FMPybPE1i5C JUUVnNJSvwOLbKHVYYPKskB874zGypw= X-MC-Unique: G2MNXjNWMiGGAYIq1SYCYQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 14/17] tests/qtest/migration: Set q35 as the default machine for x86_86 Date: Fri, 20 Oct 2023 08:57:48 +0200 Message-ID: <20231020065751.26047-15-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785294102100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Change the x86_64 to use the q35 machines in tests from now on. Keep testing the pc macine on 32bit. Signed-off-by: Fabiano Rosas Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-10-farosas@suse.de> --- tests/qtest/migration-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 9959a0dc12..03f3feac7b 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -756,7 +756,12 @@ static int test_migrate_start(QTestState **from, QTest= State **to, got_dst_resume =3D false; if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; - machine_alias =3D "pc"; + + if (g_str_equal(arch, "i386")) { + machine_alias =3D "pc"; + } else { + machine_alias =3D "q35"; + } arch_opts =3D g_strdup_printf( "-drive if=3Dnone,id=3Dd0,file=3D%s,format=3Draw " "-device ide-hd,drive=3Dd0,secs=3D1,cyls=3D1,heads=3D1", bootp= ath); --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785321; cv=none; d=zohomail.com; s=zohoarc; b=fBrDLUixiWJ0koDtn87t1yLpoNWNkPdHPVZ4nRIf7A8wu7a4TJ0EUqrkKqSngpvsfRBVkjISwpqXHOywcbtPJJ16bcJM4SFbmNzP0Ude9a+ZvOq87lYo0lTQ7WREtZOd1mTvrE8d6Jv9wL89PbZTmwsg2zPxNN8itRhCegk/zqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785321; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pAJTnVpdSndHpJHcO4Q9CXE/YX/zGK2bRQ4iuRIKTlg=; b=KBEzsIxIix7vhQdaCTJi00Nu06r2YZ+59YOq0lR+9s+zAFyHbdKcnL2ii3JVxJBxVmENummb+PAGiJHzVFZfnJxJaJVB/zyBsNfkdBYDl5K51T3qNDc4Ti81LPZjKvoOpxZ+xOQqM/2AdkuhbQ3ws7466Z+jVj8Ny9YoMh9OKZU= 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 1697785321329211.69061315896158; Fri, 20 Oct 2023 00:02:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjUW-0006dx-1Q; Fri, 20 Oct 2023 03:00:16 -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 1qtjUM-0006I5-AI for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjUK-0004SL-6F for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:05 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-471-mraWogRDOOm_TQ1VtIgBmQ-1; Fri, 20 Oct 2023 02:59:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94E9A1C05159; Fri, 20 Oct 2023 06:59:46 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE43025C1; Fri, 20 Oct 2023 06:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pAJTnVpdSndHpJHcO4Q9CXE/YX/zGK2bRQ4iuRIKTlg=; b=aFbwQlA/gv2fUIg8ScUMqyRhMdfa1+eZLrfblh+k0K+yrLOTAY5VqTQOZxgaidG1Pb1/XV 8fzG8cRIPVSnG6Owza95tEF0DWhkpCWAY4XzuzaDNpXIw0W6SUg0h/zP/bidNkZ6TGdbMP Jgv5StsC2ELaPESZIQe7syPYeLsdJ08= X-MC-Unique: mraWogRDOOm_TQ1VtIgBmQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 15/17] tests/qtest/migration: Support more than one QEMU binary Date: Fri, 20 Oct 2023 08:57:49 +0200 Message-ID: <20231020065751.26047-16-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785322373100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We have strict rules around migration compatibility between different QEMU versions but no test to validate the migration state between different binaries. Add infrastructure to allow running the migration tests with two different QEMU binaries as migration source and destination. The code now recognizes two new environment variables QTEST_QEMU_BINARY_SRC and QTEST_QEMU_BINARY_DST. In the absence of either of them, the test will use the QTEST_QEMU_BINARY variable. If both are missing then the tests are run with single binary as previously. The machine type is selected automatically as the latest machine type version that works with both binaries. Usage (only one of SRC|DST is allowed): QTEST_QEMU_BINARY_SRC=3D../build-8.2.0/qemu-system-x86_64 \ QTEST_QEMU_BINARY=3D../build-8.1.0/qemu-system-x86_64 \ ./tests/qtest/migration-test Reviewed-by: Juan Quintela Signed-off-by: Fabiano Rosas Reviewed-by: Thomas Huth Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-11-farosas@suse.de> --- tests/qtest/migration-test.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 03f3feac7b..4a5d37317a 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -71,6 +71,8 @@ static bool got_dst_resume; #define QEMU_VM_FILE_MAGIC 0x5145564d #define FILE_TEST_FILENAME "migfile" #define FILE_TEST_OFFSET 0x1000 +#define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC" +#define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST" =20 #if defined(__linux__) #include @@ -744,6 +746,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, const char *arch =3D qtest_get_arch(); const char *memory_size; const char *machine_alias, *machine_opts =3D ""; + g_autofree char *machine =3D NULL; =20 if (args->use_shmem) { if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { @@ -822,6 +825,10 @@ static int test_migrate_start(QTestState **from, QTest= State **to, kvm_opts =3D ",dirty-ring-size=3D4096"; } =20 + machine =3D find_common_machine_version(machine_alias, QEMU_ENV_SRC, + QEMU_ENV_DST); + g_test_message("Using machine type: %s", machine); + cmd_source =3D g_strdup_printf("-accel kvm%s -accel tcg " "-machine %s,%s " "-name source,debug-threads=3Don " @@ -829,7 +836,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, "-serial file:%s/src_serial " "%s %s %s %s %s", kvm_opts ? kvm_opts : "", - machine_alias, machine_opts, + machine, machine_opts, memory_size, tmpfs, arch_opts ? arch_opts : "", arch_source ? arch_source : "", @@ -837,7 +844,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, args->opts_source ? args->opts_source : "= ", ignore_stderr); if (!args->only_target) { - *from =3D qtest_init(cmd_source); + *from =3D qtest_init_with_env(QEMU_ENV_SRC, cmd_source); qtest_qmp_set_event_callback(*from, migrate_watch_for_stop, &got_src_stop); @@ -851,14 +858,14 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, "-incoming %s " "%s %s %s %s %s", kvm_opts ? kvm_opts : "", - machine_alias, machine_opts, + machine, machine_opts, memory_size, tmpfs, uri, arch_opts ? arch_opts : "", arch_target ? arch_target : "", shmem_opts ? shmem_opts : "", args->opts_target ? args->opts_target : "= ", ignore_stderr); - *to =3D qtest_init(cmd_target); + *to =3D qtest_init_with_env(QEMU_ENV_DST, cmd_target); qtest_qmp_set_event_callback(*to, migrate_watch_for_resume, &got_dst_resume); @@ -2989,10 +2996,23 @@ int main(int argc, char **argv) bool has_uffd; const char *arch; g_autoptr(GError) err =3D NULL; + const char *qemu_src =3D getenv(QEMU_ENV_SRC); + const char *qemu_dst =3D getenv(QEMU_ENV_DST); int ret; =20 g_test_init(&argc, &argv, NULL); =20 + /* + * The default QTEST_QEMU_BINARY must always be provided because + * that is what helpers use to query the accel type and + * architecture. + */ + if (qemu_src && qemu_dst) { + g_test_message("Only one of %s, %s is allowed", + QEMU_ENV_SRC, QEMU_ENV_DST); + exit(1); + } + has_kvm =3D qtest_has_accel("kvm"); has_tcg =3D qtest_has_accel("tcg"); =20 --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785269; cv=none; d=zohomail.com; s=zohoarc; b=aE6/HPhgEgJoEj/az2+Fp9skKq5hSeDBP0oNf8tPc1pTEVqqAJkpt3qescRrqPHvxUOWGF2XB1TKLo8IGi5tgsJ4OFCVU6ztIOs7/Go4VEVMVTDppXi+SZ6HaauSW5Ez1FlaldnKb1Nfc6iXEpoadiQdeWwMId2T7iGBVjAT21c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785269; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sM/0UQ5xBCWfmnH5VTYXfvCTYeIJ1ZcbMPhmzQIzyg0=; b=dJCn2K8DopEkmWJWadowQ2W6bvfuVheudVFwGvdmf3+8xSA3SsqHjdR6CFpfasfoEWAebrwWazbYPV9QO6Q1Uxux4wKUKa4MLcMXUkzkmHzhG8nbb3m9OA3S/wQW0Ek2r1phhPLVD7XBLFjmE1l8vJ1eEX/oKgb2LktNbrqrkqM= 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 1697785269722350.91696113322416; Fri, 20 Oct 2023 00:01:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjUR-0006OZ-TM; Fri, 20 Oct 2023 03:00:12 -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 1qtjUK-0006Af-0w for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjUG-0004QA-Sn for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:02 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-bGAuUPiJO-ubat5-GAy0Gw-1; Fri, 20 Oct 2023 02:59:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A35D988B76E; Fri, 20 Oct 2023 06:59:53 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC5825C0; Fri, 20 Oct 2023 06:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sM/0UQ5xBCWfmnH5VTYXfvCTYeIJ1ZcbMPhmzQIzyg0=; b=QkQ0M5342kx9P49osRS+Kj3jwW5U3lT7p2axRtZuHbGFqL98GJ2Hm7dHNkZa1qq4ZZMUnR AvqQv6rohsQX8uWP9Tfp0uvDjChbHKxMrB2G7/ywdtJlpOd0N4y32xgTf7WrOQMx3zPcp1 ss1V/J/qv6xb2gILrxSzv9S61TaeW7E= X-MC-Unique: bGAuUPiJO-ubat5-GAy0Gw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 16/17] tests/qtest/migration: Allow user to specify a machine type Date: Fri, 20 Oct 2023 08:57:50 +0200 Message-ID: <20231020065751.26047-17-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1697785271866100005 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Accept the QTEST_QEMU_MACHINE_TYPE environment variable to take a machine type to use in the tests. The full machine type is recognized (e.g. pc-q35-8.2). Aliases (e.g. pc) are also allowed and resolve to the latest machine version for that alias, or, if using two QEMU binaries, to the latest common machine version between the two. Signed-off-by: Fabiano Rosas Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20231018192741.25885-12-farosas@suse.de> --- tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-helpers.c | 26 ++++++++++++++++++++++++++ tests/qtest/migration-test.c | 5 +++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index d1c2351d33..e31dc85cc7 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -45,4 +45,6 @@ void wait_for_migration_fail(QTestState *from, bool allow= _active); =20 char *find_common_machine_version(const char *mtype, const char *var1, const char *var2); +char *resolve_machine_version(const char *alias, const char *var1, + const char *var2); #endif /* MIGRATION_HELPERS_H */ diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 13449c1fe1..24fb7b3525 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -11,6 +11,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/ctype.h" #include "qapi/qmp/qjson.h" =20 #include "migration-helpers.h" @@ -266,3 +267,28 @@ char *find_common_machine_version(const char *mtype, c= onst char *var1, "binaries %s and %s", mtype, getenv(var1), getenv(var2)= ); g_assert_not_reached(); } + +char *resolve_machine_version(const char *alias, const char *var1, + const char *var2) +{ + const char *mname =3D g_getenv("QTEST_QEMU_MACHINE_TYPE"); + g_autofree char *machine_name =3D NULL; + + if (mname) { + const char *dash =3D strrchr(mname, '-'); + const char *dot =3D strrchr(mname, '.'); + + machine_name =3D g_strdup(mname); + + if (dash && dot) { + assert(qtest_has_machine(machine_name)); + return g_steal_pointer(&machine_name); + } + /* else: probably an alias, let it be resolved below */ + } else { + /* use the hardcoded alias */ + machine_name =3D g_strdup(alias); + } + + return find_common_machine_version(machine_name, var1, var2); +} diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 4a5d37317a..bc70a14642 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -825,8 +825,9 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, kvm_opts =3D ",dirty-ring-size=3D4096"; } =20 - machine =3D find_common_machine_version(machine_alias, QEMU_ENV_SRC, - QEMU_ENV_DST); + machine =3D resolve_machine_version(machine_alias, QEMU_ENV_SRC, + QEMU_ENV_DST); + g_test_message("Using machine type: %s", machine); =20 cmd_source =3D g_strdup_printf("-accel kvm%s -accel tcg " --=20 2.41.0 From nobody Wed Nov 27 14:36:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697785280; cv=none; d=zohomail.com; s=zohoarc; b=WQp5ED4fC5DiSc8CVOIXmBPdsv8+aWAPT8/JdPTt18ZDe3uRoAA+QE6lEpyrwReUpGkj3J5qWoYPSbRIZPJhCZoEzsJNEckkR5Yoc2ecji/QF8xWNgMHBInPq1ui8+jiDFT6LHlJJ8XtEAxNtrFdlVcAJgcQYYpCOEVnBMS1vUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697785280; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TnYw+YU1jFZePtxi6Q8YXgpyNvkRnDyLIi315klT6xM=; b=PL5xOnEBtv+I/tRD/tAGwcjaHOsgJKaa0YPViwNflFY6FVEXYvxFN4QVOoWkA+UFBsT34mzuAF98jXsLAI7mjW89kEezhw3BlVFgqmrzAOybUKGT1cCc6gcwSlYrTchn6Q7NhN5zzzasK9N5/u2JlXkQPosKZLKvve5YugEqULU= 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 1697785280386206.70625827185916; Fri, 20 Oct 2023 00:01:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtjUW-0006eA-Tn; Fri, 20 Oct 2023 03:00:16 -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 1qtjUP-0006PD-QI for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtjUN-0004Xj-JL for qemu-devel@nongnu.org; Fri, 20 Oct 2023 03:00:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-683-3IgkL9QzP5KrLCFHOrqQ6w-1; Fri, 20 Oct 2023 03:00:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88A9488B772; Fri, 20 Oct 2023 07:00:00 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED04125C0; Fri, 20 Oct 2023 06:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697785205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TnYw+YU1jFZePtxi6Q8YXgpyNvkRnDyLIi315klT6xM=; b=Q2Pse0R0sGK4c8DyyFUcKRPO2p0h7nXmbqLuRz0rkqhNvUAyk2EzGGKOpJgs0szM2mdObJ h/T+oCnKlm21ZS1IntcnCB5NJ07uxdtH39hibMPF5Qfvmnd+1qv0wKp2pxV1PDqGfOa8SV 9jba13IqVsN1sRuBex8LhcthW+XDIWg= X-MC-Unique: 3IgkL9QzP5KrLCFHOrqQ6w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Halil Pasic , "Denis V. Lunev" , Juan Quintela , Fam Zheng , kvm@vger.kernel.org, Harsh Prateek Bora , Nicholas Piggin , Christian Borntraeger , Eric Farman , Kevin Wolf , David Hildenbrand , Jason Wang , Sunil Muthuswamy , David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi , Jagannathan Raman , qemu-arm@nongnu.org, Alex Williamson , Reinoud Zandijk , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , "Michael S. Tsirkin" , Elena Ufimtseva , qemu-ppc@nongnu.org, Ilya Leoshkevich , Stefan Berger , Stefan Weil , Peter Xu , Christian Schoenebeck , Peter Maydell , Gerd Hoffmann , Richard Henderson , Jeff Cody , Laurent Vivier , Hanna Reitz , Marcelo Tosatti , Leonardo Bras , Fabiano Rosas , Daniel Henrique Barboza , Greg Kurz , qemu-block@nongnu.org Subject: [PULL 17/17] tests/qtest: Don't print messages from query instances Date: Fri, 20 Oct 2023 08:57:51 +0200 Message-ID: <20231020065751.26047-18-quintela@redhat.com> In-Reply-To: <20231020065751.26047-1-quintela@redhat.com> References: <20231020065751.26047-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1697785281849100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Now that we can query more than one binary, the "starting QEMU..." message can get a little noisy. Mute those messages unless we're running with --verbose. Only affects qtest_init() calls from within libqtest. The tests continue to output as usual. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Fabiano Rosas Message-ID: <20231018192741.25885-13-farosas@suse.de> Signed-off-by: Juan Quintela --- tests/qtest/libqtest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index c843c41188..f33a210861 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -91,6 +91,7 @@ struct QTestState =20 static GHookList abrt_hooks; static void (*sighandler_old)(int); +static bool silence_spawn_log; =20 static int qtest_query_target_endianness(QTestState *s); =20 @@ -405,7 +406,9 @@ static QTestState *G_GNUC_PRINTF(2, 3) qtest_spawn_qemu= (const char *qemu_bin, =20 qtest_add_abrt_handler(kill_qemu_hook_func, s); =20 - g_test_message("starting QEMU: %s", command->str); + if (!silence_spawn_log) { + g_test_message("starting QEMU: %s", command->str); + } =20 #ifndef _WIN32 s->qemu_pid =3D fork(); @@ -1508,6 +1511,8 @@ static struct MachInfo *qtest_get_machines(const char= *var) return machines; } =20 + silence_spawn_log =3D !g_test_verbose(); + qts =3D qtest_init_with_env(qemu_var, "-machine none"); response =3D qtest_qmp(qts, "{ 'execute': 'query-machines' }"); g_assert(response); @@ -1539,6 +1544,8 @@ static struct MachInfo *qtest_get_machines(const char= *var) qtest_quit(qts); qobject_unref(response); =20 + silence_spawn_log =3D false; + memset(&machines[idx], 0, sizeof(struct MachInfo)); /* Terminating ent= ry */ return machines; } --=20 2.41.0