From nobody Mon Feb 9 14:15:05 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 1552358629605415.0851184055807; Mon, 11 Mar 2019 19:43:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B50DE3082E4B; Tue, 12 Mar 2019 02:43:47 +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 8871F5C553; Tue, 12 Mar 2019 02:43:47 +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 3F9803FB11; Tue, 12 Mar 2019 02:43:47 +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 x2C2chsa014239 for ; Mon, 11 Mar 2019 22:38:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 571F1648AD; Tue, 12 Mar 2019 02:38:43 +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 C215B648AB; Tue, 12 Mar 2019 02:38:42 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 21:38:33 -0500 Message-Id: <20190312023839.11069-3-eblake@redhat.com> In-Reply-To: <20190312023839.11069-1-eblake@redhat.com> References: <20190312023839.11069-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, jtomko@redhat.com Subject: [libvirt] [PATCH v4 2/8] snapshot: Support topological virDomainSnapshotForEach() 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 12 Mar 2019 02:43:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Previous patches added topological sorting only for existing public API functions, but it turns out that it will also useful for an upcoming API addition that wants to visit all snapshots. Add a parameter, and update all existing callers (none of which care about ordering). Signed-off-by: Eric Blake --- src/conf/snapshot_conf.h | 1 + src/conf/snapshot_conf.c | 6 +++++- src/qemu/qemu_domain.c | 2 +- src/vz/vz_driver.c | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 6d79dbb0da..ba9362c744 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -170,6 +170,7 @@ virDomainSnapshotObjPtr virDomainSnapshotFindByName(vir= DomainSnapshotObjListPtr void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots, virDomainSnapshotObjPtr snapshot); int virDomainSnapshotForEach(virDomainSnapshotObjListPtr snapshots, + bool topological, virHashIterator iter, void *data); int virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index e2c91a5072..8235d7c526 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -1050,7 +1050,7 @@ virDomainSnapshotObjListFormat(virBufferPtr buf, current_snapshot->def->name); virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - if (virDomainSnapshotForEach(snapshots, virDomainSnapshotFormatOne, + if (virDomainSnapshotForEach(snapshots, false, virDomainSnapshotFormat= One, &data) < 0) { virBufferFreeAndReset(buf); return -1; @@ -1293,9 +1293,13 @@ void virDomainSnapshotObjListRemove(virDomainSnapsho= tObjListPtr snapshots, int virDomainSnapshotForEach(virDomainSnapshotObjListPtr snapshots, + bool topological, virHashIterator iter, void *data) { + if (topological) + return virDomainSnapshotForEachDescendant(&snapshots->metaroot, + iter, data); return virHashForEach(snapshots->objs, iter, data); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1659e88478..34f3669967 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8675,7 +8675,7 @@ qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr= driver, rem.vm =3D vm; rem.metadata_only =3D true; rem.err =3D 0; - virDomainSnapshotForEach(vm->snapshots, qemuDomainSnapshotDiscardAll, + virDomainSnapshotForEach(vm->snapshots, false, qemuDomainSnapshotDisca= rdAll, &rem); if (rem.current) vm->current_snapshot =3D NULL; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 066d617524..2a0fc98f72 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2170,7 +2170,8 @@ vzFindCurrentSnapshot(virDomainSnapshotObjListPtr sna= pshots) { virDomainSnapshotObjPtr current =3D NULL; - virDomainSnapshotForEach(snapshots, vzCurrentSnapshotIterator, ¤= t); + virDomainSnapshotForEach(snapshots, false, vzCurrentSnapshotIterator, + ¤t); return current; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list