From nobody Tue Nov 26 23:29:20 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=1562387901; cv=none; d=zoho.com; s=zohoarc; b=EhpZ/6j25dQtFD+q4sPwlhTWpJU+uzpWKln0GNEcNpuGW8m5aOl+4knSQnsNlNi6F10tSTJW4MShBIoobjR21Qs6DktSS1XkfiNLFcsLVVtzIDk6dvCBZWvGVdAG02M/Q+ZKQb+7cOz8g9vxiEcLKkuxBRajuSliEYCM1RQeCnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562387901; 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=nhOSwy4ijE1FXzK24rkK0PNFsY6r9YFNvfDE6qf6oBc=; b=XMCAWnAECm3TJsZzg7ECPkAUEU/ej0PHSi38biuuX94Rng2GLV7ZluybXH1iL+TaT/xtEjQlYQR5HcoxOMWQBmcXb4hxjsKBfd2oOHVdptIboGHbLkdFPhSjVGOjoE8M1bYbk6Z8JhaWnWaETh7+rBm3tKq6974qTZL396H79BE= 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 1562387901155742.6085729071399; Fri, 5 Jul 2019 21:38:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92A3F30832EF; Sat, 6 Jul 2019 04:38:19 +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 6B156BA114; Sat, 6 Jul 2019 04:38:19 +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 32E5441F63; Sat, 6 Jul 2019 04:38:19 +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 x664blLw006762 for ; Sat, 6 Jul 2019 00:37:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A1261001B19; 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 51F2B1001947 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:33 -0500 Message-Id: <20190706043735.26284-7-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 6/8] backup: Add support for filtering based on current moment 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sat, 06 Jul 2019 04:38:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Right now, the snapshot API permits at most one current snapshot, and includes specific API for getting at that snapshot (virDomainHasCurrentSnapshot, virDomainSnapshotCurrent, virDomainSnapshotIsCurrent). However, with upcoming checkpoints, it is conceivable that a hypervisor could mark multiple checkpoints as current (the qemu implementation has only one current checkpoint for an incremental backup, and computes the set of changes for a differential backup by merging a chain of checkpoints - but other hypervisors may treat all differential checkpoints as current). As such, it is more desirable to avoid explicit API for getting at the one current checkpoint, and instead have the List API include a filter for that purpose. Still, it is easier to implement that filter directly in the common virDomainMomentObjList code, since that is the only code that tracks the one moment that is current (both for existing snapshots, and for how qemu will be using current checkpoints). Signed-off-by: Eric Blake --- src/conf/virdomainmomentobjlist.h | 11 +++++++++-- src/conf/virdomainmomentobjlist.c | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentob= jlist.h index 4067e928f4..7628df5e29 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -78,8 +78,10 @@ typedef enum { VIR_DOMAIN_MOMENT_LIST_TOPOLOGICAL =3D (1 << 1), VIR_DOMAIN_MOMENT_LIST_LEAVES =3D (1 << 2), VIR_DOMAIN_MOMENT_LIST_NO_LEAVES =3D (1 << 3), - VIR_DOMAIN_MOMENT_LIST_METADATA =3D (1 << 4), - VIR_DOMAIN_MOMENT_LIST_NO_METADATA =3D (1 << 5), + VIR_DOMAIN_MOMENT_LIST_CURRENT =3D (1 << 4), + VIR_DOMAIN_MOMENT_LIST_NO_CURRENT =3D (1 << 5), + VIR_DOMAIN_MOMENT_LIST_METADATA =3D (1 << 6), + VIR_DOMAIN_MOMENT_LIST_NO_METADATA =3D (1 << 7), } virDomainMomentFilters; #define VIR_DOMAIN_MOMENT_FILTERS_METADATA \ @@ -90,10 +92,15 @@ typedef enum { (VIR_DOMAIN_MOMENT_LIST_LEAVES | \ VIR_DOMAIN_MOMENT_LIST_NO_LEAVES) +#define VIR_DOMAIN_MOMENT_FILTERS_CURRENT \ + (VIR_DOMAIN_MOMENT_LIST_CURRENT | \ + VIR_DOMAIN_MOMENT_LIST_NO_CURRENT) + #define VIR_DOMAIN_MOMENT_FILTERS_ALL \ (VIR_DOMAIN_MOMENT_LIST_ROOTS | \ VIR_DOMAIN_MOMENT_LIST_TOPOLOGICAL | \ VIR_DOMAIN_MOMENT_FILTERS_METADATA | \ + VIR_DOMAIN_MOMENT_FILTERS_CURRENT | \ VIR_DOMAIN_MOMENT_FILTERS_LEAVES) int virDomainMomentObjListGetNames(virDomainMomentObjListPtr moments, diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 0ea5e9af80..55d1db9fb0 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -283,6 +283,7 @@ struct virDomainMomentNameData { unsigned int flags; int count; bool error; + virDomainMomentObjPtr current; /* The current moment, if any */ virDomainMomentObjListFilter filter; unsigned int filter_flags; }; @@ -303,6 +304,11 @@ static int virDomainMomentObjListCopyNames(void *paylo= ad, return 0; if ((data->flags & VIR_DOMAIN_MOMENT_LIST_NO_LEAVES) && !obj->nchildre= n) return 0; + if ((data->flags & VIR_DOMAIN_MOMENT_LIST_CURRENT) && obj !=3D data->c= urrent) + return 0; + if ((data->flags & VIR_DOMAIN_MOMENT_LIST_NO_CURRENT) && + obj =3D=3D data->current) + return 0; if (!data->filter(obj, data->filter_flags)) return 0; @@ -327,7 +333,8 @@ virDomainMomentObjListGetNames(virDomainMomentObjListPt= r moments, unsigned int filter_flags) { struct virDomainMomentNameData data =3D { names, maxnames, flags, 0, - false, filter, filter_flags }; + false, moments->current, + filter, filter_flags }; size_t i; virCheckFlags(VIR_DOMAIN_MOMENT_FILTERS_ALL, -1); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list