From nobody Sun Feb 8 23:26:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; 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.120 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=1593007699; cv=none; d=zohomail.com; s=zohoarc; b=a8BbW2tW7j5ssAfZ/4P4ZK4VzsChOb6oSpcbhxuN0eSAbESrGZEjkrrKO8cX6mNd9OnjryZrTt7oSR+gEtJVzM6XwC1n+8lMk+td8iJdLy5y75DgYbtzROQvLpn5XMq5tymZTWrwAtm19Iw07w3804eVULH/SLXfYVie9uIculQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593007699; 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=E0/I1q5jLn88XDbT598ut2F0yO32gisV+8x8fQdyKDo=; b=JXPl3FqxyklXCgNwLI0Vso+iEU6+xaNpG1VV659/DcnlOxGJIkWT8Y+k/woY75OMtqmrmz8DG6R91KH9YmOEEROrdlOYznNQLVsLjEPjduY04BTxMSIbBWxTGJjIRvZt4dYnflknQMJWfgKKBiR+f1GnpQBizfbiHOcEbhM5fC0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1593007699628959.1183955361166; Wed, 24 Jun 2020 07:08:19 -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-318-TeFxZnbANYSQV8j70fjE9A-1; Wed, 24 Jun 2020 10:08:16 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE3B4EC1AA; Wed, 24 Jun 2020 14:08:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 772B22B47E; Wed, 24 Jun 2020 14:08:07 +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 43E001800433; Wed, 24 Jun 2020 14:08:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05OE82s7017444 for ; Wed, 24 Jun 2020 10:08:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6913A7FE9D; Wed, 24 Jun 2020 14:08:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC0505BAEF for ; Wed, 24 Jun 2020 14:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593007698; 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=E0/I1q5jLn88XDbT598ut2F0yO32gisV+8x8fQdyKDo=; b=hQA2en8ED8QVnOUI2kemroZSOV43FnByYUM+6AAWs9Rqvrjgx8q+1jgZJ06pPGOFItYro9 SVL5FFIDjvR+tdBKb1Ag2uFjPFQuNlCr9uCz1RC5+MtlYF648k6ZYQ/yurrTZ7WDsMZFxe nJS0Nq/BhSSlx817/x47D3TllV8D6LI= X-MC-Unique: TeFxZnbANYSQV8j70fjE9A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] kbase: incrementalbackupinternals: Replace bash with pseudocode Date: Wed, 24 Jun 2020 16:07:52 +0200 Message-Id: <792d0d5a4a56ff8deff61ee146361410f64bde21.1593007594.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.84 on 10.5.11.23 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" Simplify the docs and reduce maintenance burden by just describing the algorithm by a pseudo-language. Users are encouraged to use libvirt anyways and projects such as oVirt which do some management of storage themselves are unlikely to use bash anyways. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- docs/kbase/incrementalbackupinternals.rst | 44 ++++++----------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/docs/kbase/incrementalbackupinternals.rst b/docs/kbase/increme= ntalbackupinternals.rst index c8a0a66baa..9a96ef6df3 100644 --- a/docs/kbase/incrementalbackupinternals.rst +++ b/docs/kbase/incrementalbackupinternals.rst @@ -228,42 +228,20 @@ following rules: Creating external snapshots manually -------------------------------------- -To create the same topology outside of libvirt (e.g when doing snapshots o= ffline) -a new ``qemu-img`` which supports the ``bitmap`` subcommand is recommended= . The -following algorithm then ensures that the new image after snapshot will wo= rk -with backups (note that ``jq`` is a JSON processor): +To create the same topology outside of libvirt (e.g when doing snapshots +offline) the following pseudo-algorithm ensures that the new image after +snapshot will work with backups. ``OVERLAY`` corresponds to the new overlay +image, ``ACTIVE`` corresponds to the topmost image of the active chain pri= or to +the snapshot. :: - #!/bin/bash + create image OVERLAY on top of ACTIVE - # arguments - SNAP_IMG=3D"vda-2.qcow2" - BACKING_IMG=3D"vda-1.qcow2" + for each BITMAP in ACTIVE: + let GRANULARITY =3D granularity of BITMAP in ACTIVE - # constants - snapshots and bitmaps work only with qcow2 - SNAP_FMT=3D"qcow2" - BACKING_IMG_FMT=3D"qcow2" + if BITMAP isn't RECORDING or is INCONSISTENT: + continue - # create snapshot overlay - qemu-img create -f "$SNAP_FMT" -F "$BACKING_IMG_FMT" -b "$BACKING_IMG" "= $SNAP_IMG" - - BACKING_IMG_INFO=3D$(qemu-img info --output=3Djson -f "$BACKING_IMG_FMT"= "$BACKING_IMG") - BACKING_BITMAPS=3D$(jq '."format-specific".data.bitmaps' <<< "$BACKING_I= MG_INFO") - - if [ "x$BACKING_BITMAPS" =3D "xnull" ]; then - exit 0 - fi - - for BACKING_BITMAP_ in $(jq -c '.[]' <<< "$BACKING_BITMAPS"); do - BITMAP_FLAGS=3D$(jq -c -r '.flags[]' <<< "$BACKING_BITMAP_") - BITMAP_NAME=3D$(jq -r '.name' <<< "$BACKING_BITMAP_") - - if grep 'in-use' <<< "$BITMAP_FLAGS" || - grep -v 'auto' <<< "$BITMAP_FLAGS"; then - continue - fi - - qemu-img bitmap -f "$SNAP_FMT" "$SNAP_IMG" --add "$BITMAP_NAME" - - done + create RECORDING bitmap named BITMAP in OVERLAY with GRANULARITY --=20 2.26.2