From nobody Sat Nov 23 18:08:34 2024 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=1723160553; cv=none; d=zohomail.com; s=zohoarc; b=GfM+1jlGl/bGLI/pSWoB8jlODMUI7+sB46h/Q1A/b7sP2WpmAEky5RvKK/HQI2vM8ctKYa+l8P8y4BJDuCulyHzAO4ZaMHQVrOUfxAanv2A9yLuIKYCC1isGLpxpvfm/5QmIHVyIopV+YN37b4ciILohUbbclTgpbuKrSwSEK0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723160553; 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:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=neWbj29NMhmly6qDeikSiC+QKWrdNyXULx2drkappSE=; b=Fs/kWufsXB1FTWd4nsWgUQk7N8Foq0/tRcokLe1CJ1egpIIs2eBWZwMUpv9TVcvhh+Lb1faFK7KJKuxu30sV7psTtc+WMu/jrKMpuYdXO0453cibrrpswiOpNFV/FHV75VqLDEn5fhXjY6aG/Sq+jYfIp+SbkTSTwp350B1hbok= 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 1723160553735993.7193436916152; Thu, 8 Aug 2024 16:42:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 91A7D1495; Thu, 8 Aug 2024 19:42:32 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 46E041506; Thu, 8 Aug 2024 19:39:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7C72012E2; Thu, 8 Aug 2024 19:38:53 -0400 (EDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4EA811437 for ; Thu, 8 Aug 2024 19:38:34 -0400 (EDT) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2f035ae1083so15621091fa.3 for ; Thu, 08 Aug 2024 16:38:34 -0700 (PDT) Received: from localhost ([69.51.98.127]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20ae3542sm59106785ab.67.2024.08.08.16.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:38:32 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1723160313; x=1723765113; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZUWa+TIurjQqe1o8fjh/h2Pp+r55UOO/gfn+c6bbmzE=; b=Jj2O4ip2q5gyqV4z5kN59tqrKr5Aivl3sZDrpiLfetRN2U/wWbP3ubaDo/NVnDKgcp rSe9tVjYjTEFaeMf8X3WRwNUYs94OlYT3ndbji+DjD5Rhct0LVvt2ewvXZsEAOR2P9p5 Rw0k7Zfh0YGts7xzLSG6BdXnKPoJV0L6okDPDgxcZIzQUI/mhQfmiycQKH57oDs4wRlh lI7erpprayZyGfZBjZeU2L1bNJOj4frEDXrUJjMYnxwZ6xhp+2m7SJ7fUQaRN5eoQR8B oMLy6d7V8wE16YzE+QllIW2IqShC1eTEShMlSh89GSrR/moEXEo8WeNI6tn7Zko3civw erWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160313; x=1723765113; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZUWa+TIurjQqe1o8fjh/h2Pp+r55UOO/gfn+c6bbmzE=; b=qMlgZCl+9DDY+VNmXeJuzrtrZQM1ih6gAVY0sTKogjY9HxHf2xhnZSTXzpK9CWqX5B LOFb12zGX05FfK5ARKzGxau8QbeWi1XmVt86/f1eKOZL0yhUbqAveW9RWAwQq/MKGsUM 5yCwAEAggLARtFtd56TPJu44911kUHFw6rdWZlT/mExB8SasTHnGT2gp/Ls41RUevNhc vhQMeTVgwDkz0sD+IAHbWIOTuwjghqNAssfJXOzlWTgFiZ61TQ7PdMu31KpV+4Lw6W/B 8qN+/RDl/r2kDgRcVUxt59SuiFKbf2MVScqvRLVPjCgkWwo1M3MRCRlFOV2wC1b8wo3O uq9g== X-Gm-Message-State: AOJu0YyvVaHIT1dpvB79H+abOoxE3C0LWoOAMfiG4c3GOh6WBYcVIKb+ YTzla8U4yOXOykChbLFNUeOqjSxTGhD1ZKeACyU6nfDg3JDMloCBxCK2E01ZkXzCl7MJ54I72HY S X-Google-Smtp-Source: AGHT+IEDpFPmwwZa6C1WMsRIcx2n0XqiqDwbwZgnlEXnzFuBsFvY6fiqPcXsP97boMJonulti8viVw== X-Received: by 2002:a2e:9156:0:b0:2ef:24dd:8d86 with SMTP id 38308e7fff4ca-2f19de9148emr20612771fa.49.1723160312736; Thu, 08 Aug 2024 16:38:32 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 08/20] qemu: conf: Add setting for save image version Date: Thu, 8 Aug 2024 17:38:01 -0600 Message-Id: <20240808233813.22905-9-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240808233813.22905-1-jfehlig@suse.com> References: <20240808233813.22905-1-jfehlig@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EVHBIGIWWALJLMXQ76K4BBAQ45YBF6K4 X-Message-ID-Hash: EVHBIGIWWALJLMXQ76K4BBAQ45YBF6K4 X-MailFrom: jfehlig@suse.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: farosas@suse.de X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Jim Fehlig via Devel Reply-To: Jim Fehlig X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723160555164116600 Content-Type: text/plain; charset="utf-8" Add a 'save_image_version' setting to qemu.conf to control the image version when saving a VM with 'virsh save' or 'virsh managedsave'. Default to the new version 3. Signed-off-by: Jim Fehlig --- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf.in | 6 ++++++ src/qemu/qemu_conf.c | 16 ++++++++++++++++ src/qemu/qemu_conf.h | 5 +++++ src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_saveimage.c | 11 ++++++----- src/qemu/qemu_saveimage.h | 8 ++++---- src/qemu/qemu_snapshot.c | 4 ++-- src/qemu/test_libvirtd_qemu.aug.in | 1 + 9 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 2b6526538f..acbfcd9fc3 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -92,6 +92,7 @@ module Libvirtd_qemu =3D | str_array_entry "namespaces" =20 let save_entry =3D str_entry "save_image_format" + | int_entry "save_image_version" | str_entry "dump_image_format" | str_entry "snapshot_image_format" | str_entry "auto_dump_path" diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 6bc2140dcb..b5df8c1cc6 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -590,6 +590,11 @@ # at scheduled saving, and it is an error if the specified save_image_form= at # is not valid, or the requested compression program can't be found. # +# save_image_version is applicable when using 'virsh save' or 'virsh manag= ed-save'. +# Currently only versions 2 and 3 are supported, with version 3 being the = default. +# If saved images must be compatible with an older libvirt without this se= tting, +# then set save_image_format_version to 2. +# # dump_image_format is used when you use 'virsh dump' at emergency # crashdump, and if the specified dump_image_format is not valid, or # the requested compression program can't be found, this falls @@ -601,6 +606,7 @@ # or the requested compression program can't be found. # #save_image_format =3D "raw" +#save_image_version =3D 3 #dump_image_format =3D "raw" #snapshot_image_format =3D "raw" =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index b36bede6c3..ab4122708c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -66,6 +66,10 @@ VIR_LOG_INIT("qemu.qemu_conf"); #define QEMU_MIGRATION_PORT_MIN 49152 #define QEMU_MIGRATION_PORT_MAX 49215 =20 +/* Need to reconsile definition here and in qemu_saveimage.h */ +#define QEMU_SAVE_VERSION 3 + + VIR_ENUM_IMPL(virQEMUSchedCore, QEMU_SCHED_CORE_LAST, "none", @@ -246,6 +250,8 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privil= eged, cfg->migrationPortMin =3D QEMU_MIGRATION_PORT_MIN; cfg->migrationPortMax =3D QEMU_MIGRATION_PORT_MAX; =20 + cfg->saveImageVersion =3D QEMU_SAVE_IMAGE_VERSION; + /* For privileged driver, try and find hugetlbfs mounts automatically. * Non-privileged driver requires admin to create a dir for the * user, chown it, and then let user configure it manually. */ @@ -608,6 +614,16 @@ static int virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg, virConf *conf) { + if (virConfGetValueUInt(conf, "save_image_version", &cfg->saveImageVer= sion) < 0) + return -1; + if (cfg->saveImageVersion < QEMU_SAVE_IMAGE_VERSION_MIN || + cfg->saveImageVersion > QEMU_SAVE_IMAGE_VERSION) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid save image version %1$u"), + cfg->saveImageVersion); + return -1; + } + if (virConfGetValueString(conf, "save_image_format", &cfg->saveImageFo= rmat) < 0) return -1; if (virConfGetValueString(conf, "dump_image_format", &cfg->dumpImageFo= rmat) < 0) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index aa1e1a626c..55abede7e3 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -45,6 +45,10 @@ =20 #define QEMU_DRIVER_NAME "QEMU" =20 +#define QEMU_SAVE_IMAGE_VERSION_MIN 2 +#define QEMU_SAVE_IMAGE_VERSION 3 + + typedef enum { QEMU_SCHED_CORE_NONE =3D 0, QEMU_SCHED_CORE_VCPUS, @@ -193,6 +197,7 @@ struct _virQEMUDriverConfig { bool securityRequireConfined; =20 char *saveImageFormat; + unsigned int saveImageVersion; char *dumpImageFormat; char *snapshotImageFormat; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 736602333e..6c0d3e097c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2683,8 +2683,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, if (!(cookie =3D qemuDomainSaveCookieNew(vm))) goto endjob; =20 - if (!(data =3D virQEMUSaveDataNew(xml, cookie, was_running, compressed, - driver->xmlopt))) + if (!(data =3D virQEMUSaveDataNew(driver, xml, cookie, was_running, co= mpressed))) goto endjob; xml =3D NULL; =20 diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 50fec33f54..bffa0a3397 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -95,25 +95,26 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUSaveData, virQEMUS= aveDataFree); * This function steals @domXML on success. */ virQEMUSaveData * -virQEMUSaveDataNew(char *domXML, +virQEMUSaveDataNew(virQEMUDriver *driver, + char *domXML, qemuDomainSaveCookie *cookieObj, bool running, - int compressed, - virDomainXMLOption *xmlopt) + int compressed) { virQEMUSaveData *data =3D NULL; virQEMUSaveHeader *header; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); =20 data =3D g_new0(virQEMUSaveData, 1); =20 if (cookieObj && !(data->cookie =3D virSaveCookieFormat((virObject *) cookieObj, - virDomainXMLOptionGetSaveCook= ie(xmlopt)))) + virDomainXMLOptionGetSaveCook= ie(driver->xmlopt)))) goto error; =20 header =3D &data->header; memcpy(header->magic, QEMU_SAVE_PARTIAL, sizeof(header->magic)); - header->version =3D QEMU_SAVE_VERSION; + header->version =3D cfg->saveImageVersion; header->was_running =3D running ? 1 : 0; header->compressed =3D compressed; =20 diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h index 9dd7de292d..3cee846f14 100644 --- a/src/qemu/qemu_saveimage.h +++ b/src/qemu/qemu_saveimage.h @@ -28,7 +28,7 @@ */ #define QEMU_SAVE_MAGIC "LibvirtQemudSave" #define QEMU_SAVE_PARTIAL "LibvirtQemudPart" -#define QEMU_SAVE_VERSION 3 +#define QEMU_SAVE_VERSION QEMU_SAVE_IMAGE_VERSION =20 G_STATIC_ASSERT(sizeof(QEMU_SAVE_MAGIC) =3D=3D sizeof(QEMU_SAVE_PARTIAL)); =20 @@ -123,11 +123,11 @@ virQEMUSaveDataWrite(virQEMUSaveData *data, const char *path); =20 virQEMUSaveData * -virQEMUSaveDataNew(char *domXML, +virQEMUSaveDataNew(virQEMUDriver *driver, + char *domXML, qemuDomainSaveCookie *cookieObj, bool running, - int compressed, - virDomainXMLOption *xmlopt); + int compressed); =20 void virQEMUSaveDataFree(virQEMUSaveData *data); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index f5260c4a22..1d75208814 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1390,9 +1390,9 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, !(snapdef->cookie =3D (virObject *) qemuDomainSaveCookieNew(vm= ))) goto cleanup; =20 - if (!(data =3D virQEMUSaveDataNew(xml, + if (!(data =3D virQEMUSaveDataNew(driver, xml, (qemuDomainSaveCookie *) snapdef->= cookie, - resume, compressed, driver->xmlopt= ))) + resume, compressed))) goto cleanup; xml =3D NULL; =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index b97e6de11e..8bcb332020 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -70,6 +70,7 @@ module Test_libvirtd_qemu =3D { "8" =3D "/dev/userfaultfd" } } { "save_image_format" =3D "raw" } +{ "save_image_version" =3D "3" } { "dump_image_format" =3D "raw" } { "snapshot_image_format" =3D "raw" } { "auto_dump_path" =3D "/var/lib/libvirt/qemu/dump" } --=20 2.35.3