From nobody Fri Dec 19 21:57:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1592241124; cv=none; d=zohomail.com; s=zohoarc; b=Bl5+1mxpKtxhG20wrQK2w+uNFCyVCAKjTBgjiLIV/wmz+icwgFSInvnobRQ2mH9G5oYcXIRYz2Ff01bi80aTZaIwVU6g5aa7p0Et2XS4AmpcVuMa3xuLJT1Sv5cz5nefqaFvIjqG2VAUVKoSnPS/TaJHbIfwN5AvBbONhRolLHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592241124; 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=3UbcxLCIktu3nP7B6ZXwiBxeJNU62eQvt3MJKnh5uYc=; b=S5/zHdcPUX1DAZMj134anvI+o/Jtf/uBv6wEDyzLJEul+SReQ9yMWuRPQdnXuaL+ETHO/XUzuvgHCWDQLd42uNCdoZH6+FojpHLMk9qIYtXpSVOXRBNJ75c5TfxAunvssoLvZ1wlnInNuuHYsguaiC4jPYyI0fTqN8KrJCFcLbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1592241124670873.5611785419532; Mon, 15 Jun 2020 10:12:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-vYNsLbNZOAaqVWOGrfYTgA-1; Mon, 15 Jun 2020 13:11:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2478363FA; Mon, 15 Jun 2020 17:11:13 +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 A0E9560C47; Mon, 15 Jun 2020 17:11:13 +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 7311195AA3; Mon, 15 Jun 2020 17:11:13 +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 05FHAOvv004610 for ; Mon, 15 Jun 2020 13:10:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id A3BC21001901; Mon, 15 Jun 2020 17:10:24 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D7B2100164D for ; Mon, 15 Jun 2020 17:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592241123; 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=3UbcxLCIktu3nP7B6ZXwiBxeJNU62eQvt3MJKnh5uYc=; b=UxlLqxgvyMXgorrHMC+4UfWaPWNteWGp9Nk/dpHaWRb6Q+CcqDzDm7JStfZKHBZ/7cZhCb zxAbhlyJmR7viA8Zl4rtgV5GuXfc7A0yrNgaME3FCz1S8fG/mgeyb4FCAIXOfP9toKudth 2SZKawzYZ9kdowDTmtqsnC1vJtLcqWo= X-MC-Unique: vYNsLbNZOAaqVWOGrfYTgA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/32] qemu: backup: Split up code traversing checkpoint list looking for bitmaps Date: Mon, 15 Jun 2020 19:09:48 +0200 Message-Id: <585af78e983d6d78b567c5801c54c288952464c0.1592240635.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The algorithm is getting quite complex. Split out the lookup of range of backing chain storage sources and bitmaps contained in them which correspond to one checkpoint. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_backup.c | 111 ++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index b317b841cd..69df6c14c6 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -173,72 +173,83 @@ qemuBackupDiskDataCleanup(virDomainObjPtr vm, } +static int +qemuBackupGetBitmapMergeRange(virStorageSourcePtr from, + const char *bitmapname, + virJSONValuePtr *actions, + virStorageSourcePtr *to, + const char *diskdst, + virHashTablePtr blockNamedNodeData) +{ + g_autoptr(virJSONValue) ret =3D virJSONValueNewArray(); + virStorageSourcePtr tmpsrc =3D NULL; + virStorageSourcePtr n; + bool foundbitmap =3D false; + + for (n =3D from; virStorageSourceIsBacking(n); n =3D n->backingStore) { + qemuBlockNamedNodeDataBitmapPtr bitmap =3D NULL; + + if (!(bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamedN= odeData, + n, + bitmapname))) + break; + + foundbitmap =3D true; + + if (bitmap->inconsistent) { + virReportError(VIR_ERR_INVALID_ARG, + _("bitmap '%s' for image '%s%u' is inconsistent= "), + bitmap->name, diskdst, n->id); + return -1; + } + + if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(ret, + n->nodeformat, + bitmapname) <= 0) + return -1; + + tmpsrc =3D n; + } + + if (!foundbitmap) { + virReportError(VIR_ERR_INVALID_ARG, + _("failed to find bitmap '%s' in image '%s%u'"), + bitmapname, diskdst, from->id); + return -1; + } + + *actions =3D g_steal_pointer(&ret); + *to =3D tmpsrc; + + return 0; +} + + virJSONValuePtr qemuBackupDiskPrepareOneBitmapsChain(virDomainMomentDefPtr *incremental, virStorageSourcePtr backingChain, virHashTablePtr blockNamedNodeData, const char *diskdst) { - qemuBlockNamedNodeDataBitmapPtr bitmap; g_autoptr(virJSONValue) ret =3D NULL; size_t incridx =3D 0; + virStorageSourcePtr n =3D backingChain; ret =3D virJSONValueNewArray(); - if (!(bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeD= ata, - backingChain, - incremental[0]->n= ame))) { - virReportError(VIR_ERR_INVALID_ARG, - _("failed to find bitmap '%s' in image '%s%u'"), - incremental[0]->name, diskdst, backingChain->id); - return NULL; - } + for (incridx =3D 0; incremental[incridx]; incridx++) { + g_autoptr(virJSONValue) tmp =3D virJSONValueNewArray(); + virStorageSourcePtr tmpsrc =3D NULL; - while (bitmap) { - if (bitmap->inconsistent) { - virReportError(VIR_ERR_INVALID_ARG, - _("bitmap '%s' for image '%s%u' is inconsistent= "), - bitmap->name, diskdst, backingChain->id); + if (qemuBackupGetBitmapMergeRange(n, incremental[incridx]->name, + &tmp, &tmpsrc, diskdst, + blockNamedNodeData) < 0) return NULL; - } - if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(ret, - backingChain-= >nodeformat, - bitmap->name)= < 0) + if (virJSONValueArrayConcat(ret, tmp) < 0) return NULL; - if (backingChain->backingStore && - (bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNamedNo= deData, - backingChain->= backingStore, - incremental[in= cridx]->name))) { - backingChain =3D backingChain->backingStore; - continue; - } - - if (incremental[incridx + 1]) { - if ((bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNam= edNodeData, - backingCha= in, - incrementa= l[incridx + 1]->name))) { - incridx++; - continue; - } - - if (backingChain->backingStore && - (bitmap =3D qemuBlockNamedNodeDataGetBitmapByName(blockNam= edNodeData, - backingCha= in->backingStore, - incrementa= l[incridx + 1]->name))) { - incridx++; - backingChain =3D backingChain->backingStore; - continue; - } - - virReportError(VIR_ERR_INVALID_ARG, - _("failed to find bitmap '%s' in image '%s%u'"), - incremental[incridx]->name, diskdst, backingCha= in->id); - return NULL; - } else { - break; - } + n =3D tmpsrc; } return g_steal_pointer(&ret); --=20 2.26.2