From nobody Fri Dec 12 14:07:30 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=1765274204; cv=none; d=zohomail.com; s=zohoarc; b=flJ9N7kSKqF2vUahCHHrfrsHI+635G76OIPRG51HVKG7A+3qVCMX+TK+kO9xOVhB7tYyhl2tcdBYdXRrUw/sNTz4HuMggdPYM/BaDlwfdRD2CMhUYs4wJuYvR3zGDqtEl7cEBKuXgKf15VWyfrNbFSfR9SjvjE+44cSSamBfqhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765274204; 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=WzCw1Jon9l9DcGN/0G7EYxLxte166jKCUtigDyWMR7s=; b=MvbvJVppr8EanxPXdEWRI7CKYwuXltDF3WEQxqtD+iwtFZMt3SensPCZrHfx2JNziWIZVg2nt2YGBxNlgF00yBFTyJ6QJoIcdnSQr3qvrEe9l4heCeHo27CV1wNWDFWPbne9MdT+xDfiGIG0ylcKw7TTW9cj2Bm4NJbT9uCbSGg= 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 1765274204249904.4690709780508; Tue, 9 Dec 2025 01:56:44 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 5999E41966; Tue, 9 Dec 2025 04:56:42 -0500 (EST) Received: from [172.19.199.80] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A6039441DC; Tue, 9 Dec 2025 04:48:48 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 8EA6943E14; Tue, 9 Dec 2025 04:46:40 -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 E972243DB7 for ; Tue, 9 Dec 2025 04:46:24 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-h7uldzXnOJ2N09Izs6OZwQ-1; Tue, 09 Dec 2025 04:46:18 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F69F195606B for ; Tue, 9 Dec 2025 09:46:17 +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 99C4F1956095 for ; Tue, 9 Dec 2025 09:46:16 +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=1765273584; 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=WzCw1Jon9l9DcGN/0G7EYxLxte166jKCUtigDyWMR7s=; b=NQ9/YXwQYzEQwb2CZL/KKlF0xRA/6OfRaqGplbbXnczBZNORSJH2lD6vAFBFoVoSYchCeT IclhZy2UBavifL742Zrfn0JA7BKvQ5pJZvjvfEo1rI5c09neIMXat4weCQOohD7KwsjLFn T6pWwasun4rKqdQ+iwK7uO91d9QW7iI= X-MC-Unique: h7uldzXnOJ2N09Izs6OZwQ-1 X-Mimecast-MFC-AGG-ID: h7uldzXnOJ2N09Izs6OZwQ_1765273577 To: devel@lists.libvirt.org Subject: [PATCH 5/9] qemu: conf: Use proper type for (save|dump|snapshot)ImageFormat Date: Tue, 9 Dec 2025 10:46:05 +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: MDPqZ0iriuXipt3XYCVKjxiOmBnM1q0sa-AZmfF6RRo_1765273577 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GZI2X5JP4PUXC3BZEU2DGLB4FKAILKGL X-Message-ID-Hash: GZI2X5JP4PUXC3BZEU2DGLB4FKAILKGL 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: 1765274206616158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Extract the definition of the enum into a separate header file and convert the config struct to use the proper types. Signed-off-by: Peter Krempa --- src/qemu/qemu_conf.c | 48 ++++++++++++++++++++++---------- src/qemu/qemu_conf.h | 7 +++-- src/qemu/qemu_saveimage.h | 20 ++----------- src/qemu/qemu_saveimage_format.h | 25 +++++++++++++++++ 4 files changed, 64 insertions(+), 36 deletions(-) create mode 100644 src/qemu/qemu_saveimage_format.h diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 242955200a..de6e51177a 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -686,29 +686,47 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig = *cfg, if (virConfGetValueString(conf, "save_image_format", &savestr) < 0) return -1; - if (savestr && (cfg->saveImageFormat =3D qemuSaveFormatTypeFromString(= savestr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid save_image_format '%1$s'"), - savestr); - return -1; + if (savestr) { + int formatVal; + + if ((formatVal =3D qemuSaveFormatTypeFromString(savestr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid save_image_format '%1$s'"), + savestr); + return -1; + } + + cfg->saveImageFormat =3D formatVal; } if (virConfGetValueString(conf, "dump_image_format", &dumpstr) < 0) return -1; - if (dumpstr && (cfg->dumpImageFormat =3D qemuSaveFormatTypeFromString(= dumpstr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid dump_image_format '%1$s'"), - dumpstr); - return -1; + if (dumpstr) { + int formatVal; + + if ((formatVal =3D qemuSaveFormatTypeFromString(dumpstr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid dump_image_format '%1$s'"), + dumpstr); + return -1; + } + + cfg->dumpImageFormat =3D formatVal; } if (virConfGetValueString(conf, "snapshot_image_format", &snapstr) < 0) return -1; - if (snapstr && (cfg->snapshotImageFormat =3D qemuSaveFormatTypeFromStr= ing(snapstr)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid snapshot_image_format '%1$s'"), - snapstr); - return -1; + if (snapstr) { + int formatVal; + + if ((formatVal =3D qemuSaveFormatTypeFromString(snapstr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid snapshot_image_format '%1$s'"), + snapstr); + return -1; + } + + cfg->snapshotImageFormat =3D formatVal; } if (virConfGetValueString(conf, "auto_dump_path", &cfg->autoDumpPath) = < 0) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index edb65c99f4..c284e108a1 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -37,6 +37,7 @@ #include "locking/lock_manager.h" #include "qemu_capabilities.h" #include "qemu_nbdkit.h" +#include "qemu_saveimage_format.h" #include "virclosecallbacks.h" #include "virhostdev.h" #include "virfile.h" @@ -216,9 +217,9 @@ struct _virQEMUDriverConfig { bool securityDefaultConfined; bool securityRequireConfined; - int saveImageFormat; - int dumpImageFormat; - int snapshotImageFormat; + virQEMUSaveFormat saveImageFormat; + virQEMUSaveFormat dumpImageFormat; + virQEMUSaveFormat snapshotImageFormat; char *autoDumpPath; bool autoDumpBypassCache; diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 0a22ee5f05..1fd96751a2 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -21,6 +21,7 @@ #include "virconftypes.h" #include "qemu_domain.h" +#include "qemu_saveimage_format.h" /* It would be nice to replace 'Qemud' with 'Qemu' but * this magic string is ABI, so it can't be changed @@ -31,24 +32,7 @@ G_STATIC_ASSERT(sizeof(QEMU_SAVE_MAGIC) =3D=3D sizeof(QEMU_SAVE_PARTIAL)); -typedef enum { - QEMU_SAVE_FORMAT_RAW =3D 0, - QEMU_SAVE_FORMAT_GZIP =3D 1, - QEMU_SAVE_FORMAT_BZIP2 =3D 2, - /* - * Deprecated by xz and never used as part of a release - * QEMU_SAVE_FORMAT_LZMA - */ - QEMU_SAVE_FORMAT_XZ =3D 3, - QEMU_SAVE_FORMAT_LZOP =3D 4, - QEMU_SAVE_FORMAT_ZSTD =3D 5, - QEMU_SAVE_FORMAT_SPARSE =3D 6, - /* Note: add new members only at the end. - These values are used in the on-disk format. - Do not change or re-use numbers. */ - - QEMU_SAVE_FORMAT_LAST -} virQEMUSaveFormat; +/* enum virQEMUSaveFormat is declared in qemu_saveimage_format.h */ VIR_ENUM_DECL(qemuSaveFormat); typedef struct _virQEMUSaveHeader virQEMUSaveHeader; diff --git a/src/qemu/qemu_saveimage_format.h b/src/qemu/qemu_saveimage_for= mat.h new file mode 100644 index 0000000000..53756f9fff --- /dev/null +++ b/src/qemu/qemu_saveimage_format.h @@ -0,0 +1,25 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#pragma once + +/* This enum resides in a separate file to allow inclusion into qemu_conf.= h */ +typedef enum { + QEMU_SAVE_FORMAT_RAW =3D 0, + QEMU_SAVE_FORMAT_GZIP =3D 1, + QEMU_SAVE_FORMAT_BZIP2 =3D 2, + /* + * Deprecated by xz and never used as part of a release + * QEMU_SAVE_FORMAT_LZMA + */ + QEMU_SAVE_FORMAT_XZ =3D 3, + QEMU_SAVE_FORMAT_LZOP =3D 4, + QEMU_SAVE_FORMAT_ZSTD =3D 5, + QEMU_SAVE_FORMAT_SPARSE =3D 6, + /* Note: add new members only at the end. + These values are used in the on-disk format. + Do not change or re-use numbers. */ + + QEMU_SAVE_FORMAT_LAST +} virQEMUSaveFormat; --=20 2.52.0