From nobody Wed Apr 2 13:38:20 2025 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1743086437; cv=none; d=zohomail.com; s=zohoarc; b=T73T/sOZZAFz2BSa4cHdvhidJl6iHvW/7MZsPBPdzjSUQplYfLYX0aCHGglEuImVi0poWmINz1+fwD8rRh7KhnlMabB2/KX/m5GeKVevIg6VTjWs5GSPdHUnEVYOnZ1vHSTJaPkL/4Lfl6hmuMoPXKKc65KDWUUNPtb3NJemxgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743086437; 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=9JoqtdTugN+FwCPJW4PNptDGkquwWXj5Pm61EHfGRf4=; b=iGgcGh+q6A55K4A7PbFGpZmSQZnrfGpa0dxNeEAKSMuIjjfBJRBKTgYaZ4GQB/PdV3bWQMOoCKtzjQSRrR0GE1kkXoM6xrKWMHvFja+cccDlsX0OePOdF7ShzeUSzuK7zjlrrTena9feAhr1llQIIVd4Hk453qwKspq8RbIbE2I= 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 1743086437026339.1346836301059; Thu, 27 Mar 2025 07:40:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txoOl-0006Vr-An; Thu, 27 Mar 2025 10:39:59 -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 1txoOa-0006UR-FC for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:49 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1txoOY-0005ZI-M3 for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:48 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 962331F79D; Thu, 27 Mar 2025 14:39:41 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8BC6D139D4; Thu, 27 Mar 2025 14:39:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iJseEytj5WcVZgAAD6G6ig (envelope-from ); Thu, 27 Mar 2025 14:39:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086381; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9JoqtdTugN+FwCPJW4PNptDGkquwWXj5Pm61EHfGRf4=; b=y92ZJafVtCMkACwY+SY7DVXPm+KcUyPlcD+aG1ftZZPVtHShKcxUPu1Lus8vizWWEG8uHb uYGC5MHB/QM2bkNLp1cOmffxJLhZrwk9Gch5fCK8yGeyNsygrSNMiSRnFFQbLE7vSXHKGk LDPReZme76weGNzCmnK71DqrXsKCtYM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086381; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9JoqtdTugN+FwCPJW4PNptDGkquwWXj5Pm61EHfGRf4=; b=GTzm0oQafmhBu6heaOXi6vSdU8aglkWCp5Zm1MpRixe/fBmenaugQPDlcgmjtk/DZIPHgo OWcQFi45fqAbQHDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086381; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9JoqtdTugN+FwCPJW4PNptDGkquwWXj5Pm61EHfGRf4=; b=y92ZJafVtCMkACwY+SY7DVXPm+KcUyPlcD+aG1ftZZPVtHShKcxUPu1Lus8vizWWEG8uHb uYGC5MHB/QM2bkNLp1cOmffxJLhZrwk9Gch5fCK8yGeyNsygrSNMiSRnFFQbLE7vSXHKGk LDPReZme76weGNzCmnK71DqrXsKCtYM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086381; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9JoqtdTugN+FwCPJW4PNptDGkquwWXj5Pm61EHfGRf4=; b=GTzm0oQafmhBu6heaOXi6vSdU8aglkWCp5Zm1MpRixe/fBmenaugQPDlcgmjtk/DZIPHgo OWcQFi45fqAbQHDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Prasad Pandit , Juraj Marcin , berrange@redhat.com, Marco Cavenati Subject: [PATCH 1/4] migration/savevm: Add a compatibility check for capabilities Date: Thu, 27 Mar 2025 11:39:31 -0300 Message-Id: <20250327143934.7935-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20250327143934.7935-1-farosas@suse.de> References: <20250327143934.7935-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_TLS_ALL(0.00)[] 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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 @suse.de) X-ZM-MESSAGEID: 1743086439047019100 Content-Type: text/plain; charset="utf-8" It has always been possible to enable arbitrary migration capabilities and attempt to take a snapshot of the VM with the savevm/loadvm commands as well as their QMP counterparts snapshot-save/snapshot-load. Most migration capabilities are not meant to be used with snapshots and there's a risk of crashing QEMU or producing incorrect behavior. Ideally, every migration capability would either be implemented for savevm or explicitly rejected. Add a compatibility check routine and reject the snapshot command if an incompatible capability is enabled. For now only act on the the two that actually cause a crash: multifd and mapped-ram. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2881 Signed-off-by: Fabiano Rosas --- migration/options.c | 26 ++++++++++++++++++++++++++ migration/options.h | 1 + migration/savevm.c | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/migration/options.c b/migration/options.c index b0ac2ea408..8772b98dca 100644 --- a/migration/options.c +++ b/migration/options.c @@ -443,11 +443,37 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_sna= pshot, MIGRATION_CAPABILITY_VALIDATE_UUID, MIGRATION_CAPABILITY_ZERO_COPY_SEND); =20 +/* Snapshot compatibility check list */ +static const +INITIALIZE_MIGRATE_CAPS_SET(check_caps_savevm, + MIGRATION_CAPABILITY_MULTIFD, + MIGRATION_CAPABILITY_MAPPED_RAM, +); + static bool migrate_incoming_started(void) { return !!migration_incoming_get_current()->transport_data; } =20 +bool migrate_can_snapshot(Error **errp) +{ + MigrationState *s =3D migrate_get_current(); + int i; + + for (i =3D 0; i < check_caps_savevm.size; i++) { + int incomp_cap =3D check_caps_savevm.caps[i]; + + if (s->capabilities[incomp_cap]) { + error_setg(errp, + "Snapshots are not compatible with %s", + MigrationCapability_str(incomp_cap)); + return false; + } + } + + return true; +} + /** * @migration_caps_check - check capability compatibility * diff --git a/migration/options.h b/migration/options.h index 762be4e641..20b71b6f2a 100644 --- a/migration/options.h +++ b/migration/options.h @@ -58,6 +58,7 @@ bool migrate_tls(void); /* capabilities helpers */ =20 bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp); +bool migrate_can_snapshot(Error **errp); =20 /* parameters */ =20 diff --git a/migration/savevm.c b/migration/savevm.c index ce158c3512..3be13bcfe8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3229,6 +3229,10 @@ bool save_snapshot(const char *name, bool overwrite,= const char *vmstate, =20 GLOBAL_STATE_CODE(); =20 + if (!migrate_can_snapshot(errp)) { + return false; + } + if (migration_is_blocked(errp)) { return false; } @@ -3413,6 +3417,10 @@ bool load_snapshot(const char *name, const char *vms= tate, int ret; MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 + if (!migrate_can_snapshot(errp)) { + return false; + } + if (!bdrv_all_can_snapshot(has_devices, devices, errp)) { return false; } --=20 2.35.3 From nobody Wed Apr 2 13:38:20 2025 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1743086455; cv=none; d=zohomail.com; s=zohoarc; b=AnTTtGXhIpA9NGPSsJo8dZkEq/m4JNeqprr5lkDboJz3VFBRlcM5pFOjCtF2ocNakolzVE5e+AU2SbDHKZFUIBAVknmXkKEsoPOsr0yXDfeC9HBkE8oUfbEFqfMg4WvDUnXWFMolgB2K6i388RaeyI9B0sqiYRGa20md85O4Y5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743086455; 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=QJh18vi4S8VW/S7WC4c3Cmkh0hz+w8GARbqarPZ7238=; b=Q0MNYj5/dk702d/wf2WZsSy8trLhrWo5JJftxTKX19Jz2okjMGNo+uUQmp/G4DG0tCB8B7f4GpuvesQNvuPW3Hgic0P9PQGNiixBeD6SVZ8CxFnpH/+yNF4WW7FpA4Ypp5yi0ETehkuL5KEz+fVP1cXGqkZq8ELwLK8fdKNGJJs= 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 1743086455441811.1075674320233; Thu, 27 Mar 2025 07:40:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txoOi-0006V8-1b; Thu, 27 Mar 2025 10:39:56 -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 1txoOZ-0006UF-TH for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:48 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1txoOX-0005Z8-Rk for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:47 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 22D792117A; Thu, 27 Mar 2025 14:39:44 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 188D1139D4; Thu, 27 Mar 2025 14:39:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sM9wMi1j5WcVZgAAD6G6ig (envelope-from ); Thu, 27 Mar 2025 14:39:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QJh18vi4S8VW/S7WC4c3Cmkh0hz+w8GARbqarPZ7238=; b=E/GwY7Tuipqoisjwi2ZzJyv6zNoa87FY3ForjvI5QTgfvy+5En6qetEUKpr6NrzFxO13N1 F/NU4+OlYUoSAwOlkDbDXZwYsG+MAglRWCdAeq0+dpA1QoQ7ab1fMZIA8hIXxRaNXAioAi NgbL7iED8/PADEvFihsbDdpvrzQoppM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QJh18vi4S8VW/S7WC4c3Cmkh0hz+w8GARbqarPZ7238=; b=K/+T6SUBU7VafipPW+v9qJskKxIfeRJ9BKkRHFnv2NbTpDUoEVZmYLg7ADsnf6c0fZ/4qs yJSaxmpmfpWTwABA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QJh18vi4S8VW/S7WC4c3Cmkh0hz+w8GARbqarPZ7238=; b=E/GwY7Tuipqoisjwi2ZzJyv6zNoa87FY3ForjvI5QTgfvy+5En6qetEUKpr6NrzFxO13N1 F/NU4+OlYUoSAwOlkDbDXZwYsG+MAglRWCdAeq0+dpA1QoQ7ab1fMZIA8hIXxRaNXAioAi NgbL7iED8/PADEvFihsbDdpvrzQoppM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086384; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QJh18vi4S8VW/S7WC4c3Cmkh0hz+w8GARbqarPZ7238=; b=K/+T6SUBU7VafipPW+v9qJskKxIfeRJ9BKkRHFnv2NbTpDUoEVZmYLg7ADsnf6c0fZ/4qs yJSaxmpmfpWTwABA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Prasad Pandit , Juraj Marcin , berrange@redhat.com, Marco Cavenati Subject: [PATCH 2/4] tests/qtest/migration: Extract machine type resolution Date: Thu, 27 Mar 2025 11:39:32 -0300 Message-Id: <20250327143934.7935-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20250327143934.7935-1-farosas@suse.de> References: <20250327143934.7935-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.de:mid, suse.de:email] 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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 @suse.de) X-ZM-MESSAGEID: 1743086469894019000 Content-Type: text/plain; charset="utf-8" Move the machine type resolution code to a separate function, along with the machine alias, which is only used for this purpose. Signed-off-by: Fabiano Rosas --- tests/qtest/migration/framework.c | 52 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/fram= ework.c index 10e1d04b58..2311100dd6 100644 --- a/tests/qtest/migration/framework.c +++ b/tests/qtest/migration/framework.c @@ -207,6 +207,38 @@ static QList *migrate_start_get_qmp_capabilities(const= MigrateStart *args) return capabilities; } =20 +static char *migrate_resolve_alias(const char *arch) +{ + const char *machine_alias; + + if (g_str_equal(arch, "i386")) { + machine_alias =3D "pc"; + + } else if (g_str_equal(arch, "x86_64")) { + machine_alias =3D "q35"; + + } else if (g_str_equal(arch, "s390x")) { + machine_alias =3D "s390-ccw-virtio"; + + } else if (g_str_equal(arch, "ppc64")) { + machine_alias =3D "pseries"; + + } else if (g_str_equal(arch, "aarch64")) { + machine_alias =3D "virt"; + + } else { + g_assert_not_reached(); + } + + if (!qtest_has_machine(machine_alias)) { + g_autofree char *msg =3D g_strdup_printf("machine %s not supported= ", machine_alias); + g_test_skip(msg); + return NULL; + } + + return resolve_machine_version(machine_alias, QEMU_ENV_SRC, QEMU_ENV_D= ST); +} + int migrate_start(QTestState **from, QTestState **to, const char *uri, MigrateStart *args) { @@ -220,7 +252,7 @@ int migrate_start(QTestState **from, QTestState **to, c= onst char *uri, const char *kvm_opts =3D NULL; const char *arch =3D qtest_get_arch(); const char *memory_size; - const char *machine_alias, *machine_opts =3D ""; + const char *machine_opts =3D ""; g_autofree char *machine =3D NULL; const char *bootpath; g_autoptr(QList) capabilities =3D migrate_start_get_qmp_capabilities(a= rgs); @@ -241,12 +273,6 @@ int migrate_start(QTestState **from, QTestState **to, = const char *uri, =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; - - 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); @@ -254,7 +280,6 @@ int migrate_start(QTestState **from, QTestState **to, c= onst char *uri, 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; @@ -262,14 +287,12 @@ int migrate_start(QTestState **from, QTestState **to,= const char *uri, memory_size =3D "256M"; start_address =3D PPC_TEST_MEM_START; end_address =3D PPC_TEST_MEM_END; - machine_alias =3D "pseries"; machine_opts =3D "vsmt=3D8"; arch_opts =3D g_strdup_printf( "-nodefaults -machine " PSERIES_DEFAULT_CAPABILITIES " " "-bios %s", bootpath); } else if (strcmp(arch, "aarch64") =3D=3D 0) { memory_size =3D "150M"; - machine_alias =3D "virt"; machine_opts =3D "gic-version=3D3"; arch_opts =3D g_strdup_printf("-cpu max -kernel %s", bootpath); start_address =3D ARM_TEST_MEM_START; @@ -311,15 +334,10 @@ int migrate_start(QTestState **from, QTestState **to,= const char *uri, kvm_opts =3D ",dirty-ring-size=3D4096"; } =20 - if (!qtest_has_machine(machine_alias)) { - g_autofree char *msg =3D g_strdup_printf("machine %s not supported= ", machine_alias); - g_test_skip(msg); + machine =3D migrate_resolve_alias(arch); + if (!machine) { return -1; } - - 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.35.3 From nobody Wed Apr 2 13:38:20 2025 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1743086451; cv=none; d=zohomail.com; s=zohoarc; b=WUQmPvtS1ZEbD+iJdPoeDJyD9Sb2EZVGx5k9m4SQu4ee4+0TkC5bPGUter2sp5G5hlZ/S1CbEFI24nvq3HdZqQVfOljJamZ+0eC2T1tfEDX+4Clxs7g7GgtrwPPOA2hvWqSlGb0xSzigGifDs95Ry74hKPnvTLMPGxo4gLFWrgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743086451; 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=u8Aa/7lfvtNeiQpq20QkviAb2ltlW4xgHZk21dTHB6U=; b=WOHc2XmGxQy2qfKZTSRWSq1RoyKQTyU5RbyfNpje7gpIkK4VKUBjrrudvu2tY88wpvlzCyv9LaiX8bznXEOoOqmI+7ZpdY0QYe0Yvb+FEy/hiTwRwYSnFhEQNtn2uLG9XyMwPUExAOY/KHUBmUD1QFFAPJZUCPKYI8a9uybpZDY= 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 1743086451352611.599842066663; Thu, 27 Mar 2025 07:40:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txoOq-0006XR-Na; Thu, 27 Mar 2025 10:40:04 -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 1txoOg-0006VL-5Q for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:55 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1txoOd-0005aB-LJ for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:53 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9EB902119B; Thu, 27 Mar 2025 14:39:46 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9A1F3139D4; Thu, 27 Mar 2025 14:39:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GKiDFjBj5WcVZgAAD6G6ig (envelope-from ); Thu, 27 Mar 2025 14:39:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8Aa/7lfvtNeiQpq20QkviAb2ltlW4xgHZk21dTHB6U=; b=UjEExAtoQR38GnzeYdjkjJjCBmrqJRRoyKHwYeTJMuWDHi8cxcVV4YY9mkhlGj3MYsMO8V bwHf5g8SbSAzgmZeaWr12vh1CfEOlTja2rew2/t1nT0wBxTgE2lBA9N93rcUam4yzTIaOC 3d54T+DBZonF/mKthyr7lYuV24LxM9k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8Aa/7lfvtNeiQpq20QkviAb2ltlW4xgHZk21dTHB6U=; b=GQZPXPy3y8uicf6nYOFqXIVYGYjmwP5S9HVdVHkWMKk598Ag5HSz/qVlaXDIA5jcWtPF5j DaJEJjbjb58QM4Cg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=UjEExAto; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=GQZPXPy3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8Aa/7lfvtNeiQpq20QkviAb2ltlW4xgHZk21dTHB6U=; b=UjEExAtoQR38GnzeYdjkjJjCBmrqJRRoyKHwYeTJMuWDHi8cxcVV4YY9mkhlGj3MYsMO8V bwHf5g8SbSAzgmZeaWr12vh1CfEOlTja2rew2/t1nT0wBxTgE2lBA9N93rcUam4yzTIaOC 3d54T+DBZonF/mKthyr7lYuV24LxM9k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8Aa/7lfvtNeiQpq20QkviAb2ltlW4xgHZk21dTHB6U=; b=GQZPXPy3y8uicf6nYOFqXIVYGYjmwP5S9HVdVHkWMKk598Ag5HSz/qVlaXDIA5jcWtPF5j DaJEJjbjb58QM4Cg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Prasad Pandit , Juraj Marcin , berrange@redhat.com, Marco Cavenati Subject: [PATCH 3/4] tests/qtest/migration: Add QMP helpers for snapshot Date: Thu, 27 Mar 2025 11:39:33 -0300 Message-Id: <20250327143934.7935-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20250327143934.7935-1-farosas@suse.de> References: <20250327143934.7935-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 9EB902119B X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email, suse.de:dkim, suse.de:mid, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 @suse.de) X-ZM-MESSAGEID: 1743086453677019000 Content-Type: text/plain; charset="utf-8" Add helpers to call QMP snapshot commands and monitor the snapshot job. Signed-off-by: Fabiano Rosas --- tests/qtest/migration/migration-qmp.c | 120 ++++++++++++++++++++++++++ tests/qtest/migration/migration-qmp.h | 4 + 2 files changed, 124 insertions(+) diff --git a/tests/qtest/migration/migration-qmp.c b/tests/qtest/migration/= migration-qmp.c index fb59741b2c..f5941e9473 100644 --- a/tests/qtest/migration/migration-qmp.c +++ b/tests/qtest/migration/migration-qmp.c @@ -518,3 +518,123 @@ void migrate_postcopy_start(QTestState *from, QTestSt= ate *to, wait_for_stop(from, src_state); qtest_qmp_eventwait(to, "RESUME"); } + +static void job_status_wait(QTestState *s, const char *id, const char *tar= get) +{ + QDict *response, *data; + const char *status, *name; + bool found; + + do { + response =3D qtest_qmp_eventwait_ref(s, "JOB_STATUS_CHANGE"); + data =3D qdict_get_qdict(response, "data"); + g_assert(data); + + name =3D qdict_get_str(data, "id"); + if (g_str_equal(name, id)) { + status =3D qdict_get_str(data, "status"); + found =3D (strcmp(status, target) =3D=3D 0); + } + + qobject_unref(response); + } while (!found); +} + +static bool job_check_status(QTestState *qts, const char *id, char **msg) +{ + QDict *rsp, *info; + QList *list; + const QListEntry *p; + gchar *status; + const char *job_msg, *job_id; + + rsp =3D qtest_qmp(qts, "{ 'execute': 'query-jobs' }"); + g_assert(rsp); + g_assert(qdict_haskey(rsp, "return")); + + list =3D qdict_get_qlist(rsp, "return"); + g_assert(list); + + for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { + info =3D qobject_to(QDict, qlist_entry_obj(p)); + + g_assert(qdict_haskey(info, "id")); + job_id =3D qdict_get_str(info, "id"); + + if (g_str_equal(job_id, id)) { + break; + } + } + + /* otherwise job not found */ + g_assert(p); + + g_assert(qdict_haskey(info, "status")); + status =3D g_strdup(qdict_get_str(info, "status")); + g_assert(g_str_equal(status, "concluded")); + + if (qdict_haskey(info, "error")) { + job_msg =3D qdict_get_str(info, "error"); + + g_assert(msg); + *msg =3D g_strdup(job_msg); + + return false; + } + + qobject_unref(rsp); + + return true; +} + +static void snapshot_cmd_qmp(QTestState *qts, const char *cmd, const char = *id) +{ + if (g_str_equal(cmd, "snapshot-delete")) { + qtest_qmp_assert_success(qts, "{ 'execute': %s," + "'arguments': { " + "'job-id': %s," + "'tag': 'my-snap'," + "'devices': [ 'disk0' ] } }", + cmd, id); + } else { + qtest_qmp_assert_success(qts, "{ 'execute': %s," + "'arguments': { " + "'job-id': %s," + "'tag': 'my-snap'," + "'devices': [ 'disk0' ]," + "'vmstate': 'disk0' } }", + cmd, id); + } +} + +static bool snapshot_cmd_qmp_sync(QTestState *qts, const char *cmd, const = char* id, + char **error_str) +{ + bool ret; + + snapshot_cmd_qmp(qts, cmd, id); + job_status_wait(qts, id, "concluded"); + ret =3D job_check_status(qts, id, error_str); + + qtest_qmp_assert_success(qts, + "{ 'execute': 'job-dismiss'," + "'arguments': { " + "'id': %s } }", id); + return ret; +} + +bool snapshot_delete_qmp_sync(QTestState *qts, char **error_str) +{ + return snapshot_cmd_qmp_sync(qts, "snapshot-delete", "snapdelete0", + error_str); +} + +bool snapshot_load_qmp_sync(QTestState *qts, char **error_str) +{ + return snapshot_cmd_qmp_sync(qts, "snapshot-load", "snapload0", error_= str); +} + +bool snapshot_save_qmp_sync(QTestState *qts, char **error_str) +{ + return snapshot_cmd_qmp_sync(qts, "snapshot-save", "snapsave0", error_= str); +} diff --git a/tests/qtest/migration/migration-qmp.h b/tests/qtest/migration/= migration-qmp.h index faa8181d91..9033828f7d 100644 --- a/tests/qtest/migration/migration-qmp.h +++ b/tests/qtest/migration/migration-qmp.h @@ -44,5 +44,9 @@ void migrate_recover(QTestState *who, const char *uri); void migrate_cancel(QTestState *who); void migrate_postcopy_start(QTestState *from, QTestState *to, QTestMigrationState *src_state); +bool snapshot_delete_qmp_sync(QTestState *qts, char **error_str); +bool snapshot_load_qmp_sync(QTestState *qts, char **error_str); +bool snapshot_save_qmp_sync(QTestState *qts, char **error_str); + =20 #endif /* MIGRATION_QMP_H */ --=20 2.35.3 From nobody Wed Apr 2 13:38:20 2025 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1743086455; cv=none; d=zohomail.com; s=zohoarc; b=Ko8tDoYFkqFefTbjwwMDwnX6oonj/+bMkbovCC91Wyi00E/Of4HxbzEUk55ysFtnVBq1dB3ZsOkYjE0cr6ijE34jJ3k2VyzV40ks+5TuHl5qr16x5QJioDPVPbQPdW0lEMQvnbfwzcr1tvYL+MFutF90BIN52W+KlMTRrHwpNds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743086455; 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=xNsDhETiAJds2+ePucPEzklBK2SNjt8lSIOpJ0xkdX0=; b=fkT9/cf6DC1sbAtVgQn523Y3SOFm31oMB6GQGofQp2LaxJYFmPKQGjEsp3OwiV02AtVMyH1zgdjMQhYslAA7kzXp6m+aP5W2dcgll8LKpqIfZtEYVuyDpw5OYMn5Sr3bebNzyv2g48cw+bkhJZjpi2sxPvMBrzCsNfJI29XCJLo= 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 1743086455310525.4005184359258; Thu, 27 Mar 2025 07:40:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txoOt-0006YG-1N; Thu, 27 Mar 2025 10:40: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 1txoOm-0006WW-64 for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:40:01 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1txoOj-0005aW-JC for qemu-devel@nongnu.org; Thu, 27 Mar 2025 10:39:59 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1FF2C2117A; Thu, 27 Mar 2025 14:39:49 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1ED1913A41; Thu, 27 Mar 2025 14:39:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aNVlNDJj5WcVZgAAD6G6ig (envelope-from ); Thu, 27 Mar 2025 14:39:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086389; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNsDhETiAJds2+ePucPEzklBK2SNjt8lSIOpJ0xkdX0=; b=Llve80IIwQ+fjsYaLaPEKjhx2CMvbc69eMxxK9nToAgw2QshjcNIS0sQvV7cjObeRSmy4h v7UmbCBFk+cbBQ9HbKKGlXvdjhjxTFPeQGO9tcXKNpilvs0FHP6/PKcJN+tzhN+FIvqyjh 5fkI0qjZOiiDVZ48dHOqkbznqdDG2aQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086389; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNsDhETiAJds2+ePucPEzklBK2SNjt8lSIOpJ0xkdX0=; b=J5CjFkw+VwCen6TgetW4ZKdhz9EBOCbAMrvpp+rFKjEgA+9718iaZ3TdWyaPZwoRIzfTc9 9P9VlSPmbxryLRAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Llve80II; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=J5CjFkw+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1743086389; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNsDhETiAJds2+ePucPEzklBK2SNjt8lSIOpJ0xkdX0=; b=Llve80IIwQ+fjsYaLaPEKjhx2CMvbc69eMxxK9nToAgw2QshjcNIS0sQvV7cjObeRSmy4h v7UmbCBFk+cbBQ9HbKKGlXvdjhjxTFPeQGO9tcXKNpilvs0FHP6/PKcJN+tzhN+FIvqyjh 5fkI0qjZOiiDVZ48dHOqkbznqdDG2aQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1743086389; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNsDhETiAJds2+ePucPEzklBK2SNjt8lSIOpJ0xkdX0=; b=J5CjFkw+VwCen6TgetW4ZKdhz9EBOCbAMrvpp+rFKjEgA+9718iaZ3TdWyaPZwoRIzfTc9 9P9VlSPmbxryLRAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Prasad Pandit , Juraj Marcin , berrange@redhat.com, Marco Cavenati Subject: [PATCH 4/4] tests/qtest/migration: Add savevm tests Date: Thu, 27 Mar 2025 11:39:34 -0300 Message-Id: <20250327143934.7935-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20250327143934.7935-1-farosas@suse.de> References: <20250327143934.7935-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 1FF2C2117A X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 @suse.de) X-ZM-MESSAGEID: 1743086457379019100 Content-Type: text/plain; charset="utf-8" Add a test file for savevm tests so the snapshot functionality can be better tested in the context of migration. There's currently issues with migration capabilities causing crashes in QEMU when running savevm. Start with a couple of tests, one that simply saves and loads a snapshot and another to check that migration capabilities don't cause disruption of savevm. The simple savevm/loadvm test will be redundant with some block layer tests that are already present. The objective here is more to have an infrastructure that can save and load snapshots from different QEMU versions, which is convenient for tracking compatibility bugs. I chose to not add a guest workload for this because we could in the future run the test for all architectures without having to write guest code (but also because the QEMU cmdline construction is way more complex). Both tests only run during the full set of tests. Signed-off-by: Fabiano Rosas --- tests/qtest/meson.build | 1 + tests/qtest/migration-test.c | 1 + tests/qtest/migration/framework.c | 4 +- tests/qtest/migration/framework.h | 5 + tests/qtest/migration/savevm-tests.c | 144 +++++++++++++++++++++++++++ 5 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 tests/qtest/migration/savevm-tests.c diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 3136d15e0f..305b662620 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -347,6 +347,7 @@ migration_files =3D [files( 'migration/misc-tests.c', 'migration/precopy-tests.c', 'migration/postcopy-tests.c', + 'migration/savevm-tests.c', )] =20 migration_tls_files =3D [] diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0893687174..b15f6d091b 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -55,6 +55,7 @@ int main(int argc, char **argv) migration_test_add_precopy(env); migration_test_add_cpr(env); migration_test_add_misc(env); + migration_test_add_savevm(env); =20 ret =3D g_test_run(); =20 diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/fram= ework.c index 2311100dd6..42bda03693 100644 --- a/tests/qtest/migration/framework.c +++ b/tests/qtest/migration/framework.c @@ -28,8 +28,6 @@ =20 =20 #define QEMU_VM_FILE_MAGIC 0x5145564d -#define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC" -#define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST" =20 unsigned start_address; unsigned end_address; @@ -207,7 +205,7 @@ static QList *migrate_start_get_qmp_capabilities(const = MigrateStart *args) return capabilities; } =20 -static char *migrate_resolve_alias(const char *arch) +char *migrate_resolve_alias(const char *arch) { const char *machine_alias; =20 diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/fram= ework.h index e4a11870f6..66823267af 100644 --- a/tests/qtest/migration/framework.h +++ b/tests/qtest/migration/framework.h @@ -17,6 +17,9 @@ #define FILE_TEST_OFFSET 0x1000 #define FILE_TEST_MARKER 'X' =20 +#define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC" +#define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST" + typedef struct MigrationTestEnv { bool has_kvm; bool has_tcg; @@ -225,6 +228,7 @@ void test_file_common(MigrateCommon *args, bool stop_sr= c); void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from, QTestState *to, const char *method); +char *migrate_resolve_alias(const char *arch); =20 typedef struct QTestMigrationState QTestMigrationState; QTestMigrationState *get_src(void); @@ -240,5 +244,6 @@ void migration_test_add_file(MigrationTestEnv *env); void migration_test_add_precopy(MigrationTestEnv *env); void migration_test_add_cpr(MigrationTestEnv *env); void migration_test_add_misc(MigrationTestEnv *env); +void migration_test_add_savevm(MigrationTestEnv *env); =20 #endif /* TEST_FRAMEWORK_H */ diff --git a/tests/qtest/migration/savevm-tests.c b/tests/qtest/migration/s= avevm-tests.c new file mode 100644 index 0000000000..5904c4b07e --- /dev/null +++ b/tests/qtest/migration/savevm-tests.c @@ -0,0 +1,144 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "migration/framework.h" +#include "migration/migration-qmp.h" +#include "migration/migration-util.h" +#include "qapi/qapi-types-migration.h" + +char *disk_path; + +static char *savevm_make_cmdline(void) +{ + MigrationTestEnv *env =3D migration_get_env(); + g_autofree char *drive_opts =3D NULL; + g_autofree char *arch_opts =3D NULL; + g_autofree char *machine_opts =3D NULL; + g_autofree char *machine =3D NULL; + + disk_path =3D g_strdup_printf("%s/qtest-savevm-%d.qcow2", g_get_tmp_di= r(), + getpid()); + drive_opts =3D g_strdup_printf("-drive if=3Dnone,file=3D%s,format=3Dqc= ow2,node-name=3Ddisk0 ", + disk_path); + + g_assert(mkimg(disk_path, "qcow2", 100)); + + machine =3D migrate_resolve_alias(env->arch); + + if (machine) { + machine_opts =3D g_strdup_printf("-machine %s", machine); + } + + return g_strdup_printf("%s %s %s", + drive_opts, + arch_opts ?: "", + machine_opts ?: ""); +} + +static void teardown_savevm_test(void) +{ + unlink(disk_path); + g_free(disk_path); +} + +/* + * Enabling capabilities before savevm/loadvm should either apply the + * appropriate feature or reject the command. Crashing or ignoring the + * capability is not acceptable. Most (all?) migration capabilities + * are incompatible with snapshots, but they've historically not been + * rejected. Since there are compatibility concerns with simply + * rejecting all caps, for now this test only validates that nothing + * crashes. + */ +static void test_savevm_caps(void) +{ + MigrationTestEnv *env =3D migration_get_env(); + g_autofree char *cmdline =3D savevm_make_cmdline(); + QTestState *vm; + + /* + * Only one VM to avoid having to shutdown the machine several + * times to release the disks lock. + */ + if (env->qemu_src || env->qemu_dst) { + g_test_skip("Only one QEMU binary is supported"); + return; + } + + vm =3D qtest_init(cmdline); + + for (int i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { + const char *cap =3D MigrationCapability_str(i); + g_autofree char *error_str =3D NULL; + bool ret; + + switch (i) { + case MIGRATION_CAPABILITY_ZERO_BLOCKS: /* deprecated */ + case MIGRATION_CAPABILITY_ZERO_COPY_SEND: /* requires multif= d */ + case MIGRATION_CAPABILITY_POSTCOPY_PREEMPT: /* requires postco= py-ram */ + case MIGRATION_CAPABILITY_SWITCHOVER_ACK: /* requires return= -path */ + case MIGRATION_CAPABILITY_DIRTY_LIMIT: /* requires dirty = ring setup */ + case MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT: /* requires uffd s= etup */ + continue; + default: + break; + } + + if (getenv("QTEST_LOG")) { + g_test_message("%s", MigrationCapability_str(i)); + } + migrate_set_capability(vm, MigrationCapability_str(i), true); + + ret =3D snapshot_save_qmp_sync(vm, &error_str); + + if (ret) { + g_assert(snapshot_load_qmp_sync(vm, NULL)); + g_assert(snapshot_delete_qmp_sync(vm, NULL)); + } else { + g_autofree char *msg =3D g_strdup_printf( + "Snapshots are not compatible with %s", cap); + + g_assert(error_str); + g_assert(g_str_equal(msg, error_str)); + } + + migrate_set_capability(vm, MigrationCapability_str(i), false); + } + + qtest_quit(vm); + teardown_savevm_test(); +} + +static void test_savevm_loadvm(void) +{ + g_autofree char *cmdline =3D savevm_make_cmdline(); + QTestState *src, *dst; + bool ret; + + src =3D qtest_init_with_env(QEMU_ENV_SRC, cmdline, true); + + ret =3D snapshot_save_qmp_sync(src, NULL); + qtest_quit(src); + + if (ret) { + dst =3D qtest_init_with_env(QEMU_ENV_DST, cmdline, true); + + g_assert(snapshot_load_qmp_sync(dst, NULL)); + g_assert(snapshot_delete_qmp_sync(dst, NULL)); + qtest_quit(dst); + } + + teardown_savevm_test(); +} + +void migration_test_add_savevm(MigrationTestEnv *env) +{ + if (!getenv("QTEST_QEMU_IMG")) { + g_test_message("savevm tests require QTEST_QEMU_IMG"); + return; + } + + migration_test_add("/migration/savevm/save-load", test_savevm_loadvm); + migration_test_add("/migration/savevm/capabilities", test_savevm_caps); +} --=20 2.35.3