From nobody Tue Nov 26 23:37:37 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562387907; cv=none; d=zoho.com; s=zohoarc; b=XhTCi9Zy/Wew9MC/2RtEK1ctTYZ+dP+3dcL+xKQ1aOdoDeojwyyHZRi4mLRHOyrRq4QdPOXPtouuYwLPavd2Ujt+2Z5Zcvon6z6pAmJ5DaZDZ8m/c8hbC7rLaGANJURJPDSFzh+GK0VvRc3BEM50PvDaYOd1ypn3B7tDiaLxmIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562387907; 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:ARC-Authentication-Results; bh=E9wKlyAGzUskji/RmkCEhTWycHwoDZVrYqB+W5Cz1qo=; b=m3tNimLFp7yY8qx8uxq4IP/Q2gt469QlvgFtwM7qWSSqQfgbgNbMapNvCGktzlrXhXQMavR8NdhHwFx0am75GdCg0deFonx77i+FD4Y9D4H9nyJokCCwA9HAIQAkWk2bsvy1v1MdeO9p3/aBcfzA6bEb7TEndbX/wi+RfS9SryI= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562387907288442.1953213968927; Fri, 5 Jul 2019 21:38:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7246307D91E; Sat, 6 Jul 2019 04:38:25 +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 94A6883EBB; Sat, 6 Jul 2019 04:38:25 +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 53BE2C59A; Sat, 6 Jul 2019 04:38:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x664blaK006767 for ; Sat, 6 Jul 2019 00:37:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6E7F1001B19; Sat, 6 Jul 2019 04:37:47 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-152.phx2.redhat.com [10.3.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE2341001B04 for ; Sat, 6 Jul 2019 04:37:47 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 23:37:34 -0500 Message-Id: <20190706043735.26284-8-eblake@redhat.com> In-Reply-To: <20190706043735.26284-1-eblake@redhat.com> References: <20190706043735.26284-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] snapshot: Add ListAll filters for current snapshot 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 06 Jul 2019 04:38:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a new filter group VIR_DOMAIN_SNAPSHOT_LIST_CURRENT/NO_CURRENT, which restricts the output based on whether a snapshot is the domain's current snapshot. This is redundant with existing API (both virDomainHasCurrentSnapshot and virDomainSnapshotCurrent can be emulated by a single call to virDomainListAllSnapshots, and replacing virDomainSnapshotIsCurrent is also possible but a bit more indirect). However, adding the new filters makes snapshots slightly more consistent with the plans for the upcoming checkpoint API additions to ONLY provide access to the notion of being current via list filters or XML inspection. Signed-off-by: Eric Blake --- include/libvirt/libvirt-domain-snapshot.h | 5 +++++ src/conf/virdomainsnapshotobjlist.h | 7 ++++++- src/conf/virdomainsnapshotobjlist.c | 4 ++++ src/libvirt-domain-snapshot.c | 14 ++++++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/libvirt/libvirt-domain-snapshot.h b/include/libvirt/li= bvirt-domain-snapshot.h index 90673ed0fb..02cdabafbc 100644 --- a/include/libvirt/libvirt-domain-snapshot.h +++ b/include/libvirt/libvirt-domain-snapshot.h @@ -141,6 +141,11 @@ typedef enum { VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL =3D (1 << 10), /* Ensure parents = occur before children in the resulting lis= t */ + + VIR_DOMAIN_SNAPSHOT_LIST_CURRENT =3D (1 << 11), /* Filter to just = current + snapshot */ + VIR_DOMAIN_SNAPSHOT_LIST_NO_CURRENT =3D (1 << 12), /* Filter out curr= ent + snapshot */ } virDomainSnapshotListFlags; /* Return the number of snapshots for this domain */ diff --git a/src/conf/virdomainsnapshotobjlist.h b/src/conf/virdomainsnapsh= otobjlist.h index fed8d22bc8..59a176aaef 100644 --- a/src/conf/virdomainsnapshotobjlist.h +++ b/src/conf/virdomainsnapshotobjlist.h @@ -73,11 +73,16 @@ int virDomainSnapshotCheckCycles(virDomainSnapshotObjLi= stPtr snapshots, (VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL | \ VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL) +#define VIR_DOMAIN_SNAPSHOT_FILTERS_CURRENT \ + (VIR_DOMAIN_SNAPSHOT_LIST_CURRENT | \ + VIR_DOMAIN_SNAPSHOT_LIST_NO_CURRENT) + #define VIR_DOMAIN_SNAPSHOT_FILTERS_ALL \ (VIR_DOMAIN_SNAPSHOT_FILTERS_METADATA | \ VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES | \ VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS | \ - VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION) + VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION | \ + VIR_DOMAIN_SNAPSHOT_FILTERS_CURRENT) int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots, virDomainMomentObjPtr from, diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapsh= otobjlist.c index 99bc4bb0c5..cac0834e1f 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -124,6 +124,10 @@ virDomainSnapshotObjListGetNames(virDomainSnapshotObjL= istPtr snapshots, VIR_DOMAIN_MOMENT_LIST_LEAVES, }, { VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES, VIR_DOMAIN_MOMENT_LIST_NO_LEAVES, }, + { VIR_DOMAIN_SNAPSHOT_LIST_CURRENT, + VIR_DOMAIN_MOMENT_LIST_CURRENT, }, + { VIR_DOMAIN_SNAPSHOT_LIST_NO_CURRENT, + VIR_DOMAIN_MOMENT_LIST_NO_CURRENT, }, { VIR_DOMAIN_SNAPSHOT_LIST_METADATA, VIR_DOMAIN_MOMENT_LIST_METADATA, }, { VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, diff --git a/src/libvirt-domain-snapshot.c b/src/libvirt-domain-snapshot.c index 2687a34b96..5dd2c5390b 100644 --- a/src/libvirt-domain-snapshot.c +++ b/src/libvirt-domain-snapshot.c @@ -465,6 +465,12 @@ virDomainSnapshotListNames(virDomainPtr domain, char *= *names, int nameslen, * whether the snapshot is stored inside the disk images or as * additional files. * + * The next group of @flags is VIR_DOMAIN_SNAPSHOT_LIST_CURRENT and + * VIR_DOMAIN_SNAPSHOT_LIST_NO_CURRENT, to filter based on whether a + * snapshot is current. This filter provides the same functionality as + * virDomainHasCurrentSnapshot(), virDomainSnapshotCurrent(), and + * virDomainSnapshotIsCurrent(). + * * Returns the number of domain snapshots found or -1 and sets @snaps to * NULL in case of error. On success, the array stored into @snaps is * guaranteed to have an extra allocated element set to NULL but not inclu= ded @@ -736,7 +742,9 @@ virDomainSnapshotLookupByName(virDomainPtr domain, * @domain: pointer to the domain object * @flags: extra flags; not used yet, so callers should always pass 0 * - * Determine if the domain has a current snapshot. + * Determine if the domain has a current snapshot. This can also be + * determined by using virDomainListAllSnapshots() with the + * VIR_DOMAIN_SNAPSHOT_LIST_CURRENT filter. * * Returns 1 if such snapshot exists, 0 if it doesn't, -1 on error. */ @@ -771,7 +779,9 @@ virDomainHasCurrentSnapshot(virDomainPtr domain, unsign= ed int flags) * @domain: a domain object * @flags: extra flags; not used yet, so callers should always pass 0 * - * Get the current snapshot for a domain, if any. + * Get the current snapshot for a domain, if any. This can also be + * determined by using virDomainListAllSnapshots() with the + * VIR_DOMAIN_SNAPSHOT_LIST_CURRENT filter. * * virDomainSnapshotFree should be used to free the resources after the * snapshot object is no longer needed. --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list