From nobody Sun Feb 8 19:39:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155175697017495.44594161691339; Mon, 4 Mar 2019 19:36:10 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E347C01DDFD; Tue, 5 Mar 2019 03:36:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5862D261B0; Tue, 5 Mar 2019 03:36:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1414C3D38E; Tue, 5 Mar 2019 03:36:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x253YuLB004179 for ; Mon, 4 Mar 2019 22:34:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 494B260C7F; Tue, 5 Mar 2019 03:34:56 +0000 (UTC) Received: from blue.redhat.com (ovpn-118-35.phx2.redhat.com [10.3.118.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC8FE60DB4; Tue, 5 Mar 2019 03:34:55 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Mon, 4 Mar 2019 21:34:36 -0600 Message-Id: <20190305033445.17140-10-eblake@redhat.com> In-Reply-To: <20190305033445.17140-1-eblake@redhat.com> References: <20190305033445.17140-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: nsoffer@redhat.com Subject: [libvirt] [PATCH v3 09/18] domain: Expand virDomainDefFormatInternal with snapshots X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Mar 2019 03:36:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Make it possible to grab all snapshot XMLs via a single API call, by adding a new internal flag, and expanding the struct used to pass extra data for formatting. Signed-off-by: Eric Blake Reviewed-by: John Ferlan --- src/conf/domain_conf.h | 3 +++ src/conf/domain_conf.c | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5086bc342a..34c0b8cea1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3120,6 +3120,7 @@ typedef enum { VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM =3D 1 << 6, VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT =3D 1 << 7, VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST =3D 1 << 8, + VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS =3D 1 << 9, } virDomainDefFormatFlags; /* Use these flags to skip specific domain ABI consistency checks done @@ -3198,6 +3199,8 @@ unsigned int virDomainDefFormatConvertXMLFlags(unsign= ed int flags); * domains, according to the flags in use. */ typedef struct _virDomainDefFormatData { virCapsPtr caps; + virDomainSnapshotObjListPtr snapshots; + virDomainSnapshotObjPtr current_snapshot; } virDomainDefFormatData; typedef struct _virDomainDefFormatData *virDomainDefFormatDataPtr; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 941d582dc1..f383f00b8b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1,7 +1,7 @@ /* * domain_conf.c: domain XML processing * - * Copyright (C) 2006-2016 Red Hat, Inc. + * Copyright (C) 2006-2019 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. * @@ -27848,7 +27848,8 @@ virDomainDefFormatInternal(virBufferPtr buf, VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES | - VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST, + VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST | + VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS, -1); if (!(type =3D virDomainVirtTypeToString(def->virtType))) { @@ -28643,6 +28644,21 @@ virDomainDefFormatInternal(virBufferPtr buf, virDomainSEVDefFormat(buf, def->sev); + if (flags & VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS) { + unsigned int snapflags =3D flags & VIR_DOMAIN_DEF_FORMAT_SECURE ? + VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE : 0; + + if (!(data && data->snapshots)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("snapshots requested but not provided")); + goto error; + } + if (virDomainSnapshotObjListFormat(buf, uuidstr, data->snapshots, + data->current_snapshot, caps, + xmlopt, snapflags) < 0) + goto error; + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -28698,7 +28714,8 @@ virDomainDefFormatFull(virDomainDefPtr def, { virBuffer buf =3D VIR_BUFFER_INITIALIZER; - virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL); + virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS | + VIR_DOMAIN_DEF_FORMAT_SNAPSHOTS, NULL); if (virDomainDefFormatInternal(&buf, def, data, flags, NULL) < 0) return NULL; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list