From nobody Fri Dec 12 14:06:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1765274046; cv=none; d=zohomail.com; s=zohoarc; b=HyZ9rtHkdI2inNSy4f7whdczc4C5yLlLtRkWlFdyc/DxLsMxS/AWjbFZjgAfDQ0TBPVnLfTiyC4gydS8u4PNGcj+TNnycPBxkMlpJcJbEvRBZ4eyqPHpdNtBdk/BeCRzW4gZQYyv1Z4eKVeWBST2I1HdXNTi42B1GWKcVBGs+Sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765274046; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=ezCvxq8oKqcIBa5JJE7vHjYf6hMcQqWfLju7TpYBemU=; b=aY2HYfk3vX0vuL5nxe/fju9ODzYGx2xUH1BQX/aKa+y7mLpVpYEUdA1bJEDe2b4gVK3HZwnFxZ/46CJBBkGRHA3nQnH/V2AfMc4tBgD2+PM5l/W5mdH42QLWOVAkzAeCGteDez2IPsWk8bG2KZjGZF02WgYV7t/BVK+zjtoPyzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1765274046360422.94112864174986; Tue, 9 Dec 2025 01:54:06 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 5D8A43F953; Tue, 9 Dec 2025 04:54:05 -0500 (EST) Received: from [172.19.199.80] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id BE10B43EAC; Tue, 9 Dec 2025 04:48:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id CFF35419A2; Tue, 9 Dec 2025 04:46:37 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1CC0441A49 for ; Tue, 9 Dec 2025 04:46:24 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-3EXaoQEbNu6sIppFtTfotg-1; Tue, 09 Dec 2025 04:46:22 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D711E18002F5 for ; Tue, 9 Dec 2025 09:46:21 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.44.22.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2D8001956095 for ; Tue, 9 Dec 2025 09:46:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765273583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ezCvxq8oKqcIBa5JJE7vHjYf6hMcQqWfLju7TpYBemU=; b=FjY/+Pwlg2X4jZMWVph2izmzcn5zENEgO3i4/t50sB4hsb6GJqECuc5QZMhwHp8gRUuog1 811RzX61wSC0pjpf5xvQ97IHCaqp29upkiUMaTDAzjikc0r8Q+qhwfp3ZOhk0NuW6O3twm LtUD7YEXkYdEJqdYirysb/WJ0QJe5W0= X-MC-Unique: 3EXaoQEbNu6sIppFtTfotg-1 X-Mimecast-MFC-AGG-ID: 3EXaoQEbNu6sIppFtTfotg_1765273581 To: devel@lists.libvirt.org Subject: [PATCH 9/9] qemuMigrationParamsForSave: Don't take opaque 'flags' Date: Tue, 9 Dec 2025 10:46:09 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gBKGs33EMoPEszyX8ONwz47FMihPHq11bpmgKeenBks_1765273581 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JS2F47EYN5N4XAERMYQCYHXY4GWO4NIY X-Message-ID-Hash: JS2F47EYN5N4XAERMYQCYHXY4GWO4NIY X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1765274048037158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Similarly to previous commit, 'flags' is really opaque. The function lives in migration code and similar functions there expect migration flags. Here we get virDomainSaveRestoreFlags. Here at least the dump code handles it properly and passes VIR_DOMAIN_SAVE_BYPASS_CACHE rather than VIR_DUMP_BYPASS_CACHE. Note: We, in many cases, encourage use of 'flags' instead of a bunch of boolean parameters. Since C doesn't do proper type checks on enums and in fact with 'flags' we pass a binary or of some flags rather than pure options from the enum there isn't really an elegant solution that would be enforced by the compiler and easy on eyes. With a bunch of booleans at least anyone reading the code will need to look up the function definition to see the header rather than assume that passing in 'flags' is fine without properly checking *which* flags are accepted by the function. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 7 ++++--- src/qemu/qemu_migration_params.c | 4 ++-- src/qemu/qemu_migration_params.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cca9d06786..3c6dd97c04 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2679,7 +2679,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, if (!(saveParams =3D qemuMigrationParamsForSave(params, nparams, format =3D=3D QEMU_SAVE_= FORMAT_SPARSE, - flags))) + (flags & VIR_DOMAIN_SAVE= _BYPASS_CACHE)))) goto endjob; ret =3D qemuSaveImageCreate(driver, vm, path, data, compressor, @@ -5798,7 +5798,8 @@ qemuDomainRestoreInternal(virConnectPtr conn, goto cleanup; sparse =3D data->header.format =3D=3D QEMU_SAVE_FORMAT_SPARSE; - if (!(restoreParams =3D qemuMigrationParamsForSave(params, nparams, sp= arse, flags))) + if (!(restoreParams =3D qemuMigrationParamsForSave(params, nparams, sp= arse, + (flags & VIR_DOMAIN_S= AVE_BYPASS_CACHE)))) goto cleanup; fd =3D qemuSaveImageOpen(driver, path, @@ -6130,7 +6131,7 @@ qemuDomainObjRestore(virConnectPtr conn, sparse =3D data->header.format =3D=3D QEMU_SAVE_FORMAT_SPARSE; if (!(restoreParams =3D qemuMigrationParamsForSave(NULL, 0, sparse, - bypass_cache ? VIR_DO= MAIN_SAVE_BYPASS_CACHE : 0))) + bypass_cache))) return -1; fd =3D qemuSaveImageOpen(driver, path, bypass_cache, sparse, &wrapperF= d, false); diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index b79bbad5c2..dd47516742 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -800,7 +800,7 @@ qemuMigrationParams * qemuMigrationParamsForSave(virTypedParameterPtr params, int nparams, bool sparse, - unsigned int flags) + bool bypassCache) { g_autoptr(qemuMigrationParams) saveParams =3D NULL; int nchannels =3D 0; @@ -837,7 +837,7 @@ qemuMigrationParamsForSave(virTypedParameterPtr params, saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].value.i = =3D nchannels; saveParams->params[QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS].set =3D = true; - if (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) { + if (bypassCache) { saveParams->params[QEMU_MIGRATION_PARAM_DIRECT_IO].value.b =3D= true; saveParams->params[QEMU_MIGRATION_PARAM_DIRECT_IO].set =3D tru= e; } diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 9d771d519d..b7a829b85a 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -92,7 +92,7 @@ qemuMigrationParams * qemuMigrationParamsForSave(virTypedParameterPtr params, int nparams, bool sparse, - unsigned int flags); + bool bypassCache); int qemuMigrationParamsDump(qemuMigrationParams *migParams, --=20 2.52.0