From nobody Mon Feb 9 20:09:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646916135; cv=none; d=zohomail.com; s=zohoarc; b=I+gnrShJiqL63YQ+p0wde62CYi0+LfkMmCmIOFzm5SmTb2w56KLa8YvsKiY12//89vvBZ/OIZr4Tsb1PHrS58ukKiyvAy6Tqlv14Xw1jp4NjH0NoXSeFaetqYdzGmDDxgtjsklKHEQt5VzNJkTgwp/f9bKKwc2AlKVNXjON+jHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916135; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gcrk9sXtXSTKEgmThIBjgILddceYN75pB44Azz8AWx8=; b=CfuybUcwL4N+molawOmphU7j9jsJ3ThsS5GRwvkeIQUtK5gvKHd7oax8hnO56c2VzBZCyjdTPtV1xK0QdTpMg8hv9XmHYxpelToJL8Wqcj8OkYPZP+3LyT4/adrATLdc4hg66pCnM6hCjz85PwwDk4dontwfYNLUCKgs7sYZh2g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916135050995.6277813701945; Thu, 10 Mar 2022 04:42:15 -0800 (PST) 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-507-0nfzD7SYOI6ItzSwPbPAQw-1; Thu, 10 Mar 2022 07:41:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F357899EC1; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14DD3C080A2; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB681195FD6E; Thu, 10 Mar 2022 12:40:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EFCFB195356D for ; Thu, 10 Mar 2022 12:40:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BFE587C0F6; Thu, 10 Mar 2022 12:40:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 245177B6D8 for ; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916133; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Gcrk9sXtXSTKEgmThIBjgILddceYN75pB44Azz8AWx8=; b=BuSMzRKQTRoYVfgGi8v1BTDYiI9Mxy1Kx2ZxyBHEWAU9RxpBo+JeCYeonvd4Jqi/iqCYEH Vq+Qq7/lNRXQr6LQH1h0xMSkJc+ModyO/cad5AxqFj2hx+Gk6Jo2CxNSfpJe+Pweizg55c /ADMHnW9qbdxuWFJTDr2K30k5euc57c= X-MC-Unique: 0nfzD7SYOI6ItzSwPbPAQw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/14] virDomainSnapshotDefParse: Decouple parsing of memory snapshot config Date: Thu, 10 Mar 2022 13:40:40 +0100 Message-Id: <2a956575f480d4f14299e753284bc9dbfa93568e.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646916137253100001 Content-Type: text/plain; charset="utf-8" Separate the steps of parsing the memory snapshot config from the post-processing and validation code. The upcoming patch refactoring the parsing will be simpler. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 50 ++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 7f98ae6aec..594492ccd2 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -317,27 +317,37 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, memorySnapshot); return NULL; } - if (def->memorysnapshotfile && - def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { - virReportError(VIR_ERR_XML_ERROR, - _("memory filename '%s' requires external snaps= hot"), - def->memorysnapshotfile); - return NULL; - } - if (!def->memorysnapshotfile && - def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("external memory snapshots require a filename= ")); - return NULL; + } + + if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) { + if (def->memorysnapshotfile) { + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; + } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { + if (offline) { + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; + } else { + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; + } } - } else if (def->memorysnapshotfile) { - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { - def->memory =3D (offline ? - VIR_DOMAIN_SNAPSHOT_LOCATION_NO : - VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); - } - if (offline && def->memory && + } + + if (def->memorysnapshotfile && + def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { + virReportError(VIR_ERR_XML_ERROR, + _("memory filename '%s' requires external snapshot"= ), + def->memorysnapshotfile); + return NULL; + } + + if (!def->memorysnapshotfile && + def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("external memory snapshots require a filename")); + return NULL; + } + + if (offline && + def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) { virReportError(VIR_ERR_XML_ERROR, "%s", _("memory state cannot be saved with offline or " --=20 2.35.1