From nobody Mon Feb 9 00:31:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1620144996; cv=none; d=zohomail.com; s=zohoarc; b=TP2FDTnFmUubt4Qkvsi/bxqkzFu/corpVe78fsrH6R4WwI2LDzeFoxjDTMP/BC0eD+8YGzHluiIbJmhO/z6nHxj5BKx8e76t3J2LIE2ktUpQXwrZzq27HVe2H4Slr2cbdtpDi819LVQxLyDpZ9dVVwLofEt/CLZuBJQPk3rSwcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620144996; 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=V/IT1GH3NWBhBJtWUjgQjfY21KX8qyhkK/fQtfe/u6A=; b=B3Okl4c/nxodYIDLxkQxDLHwCXPZU+ciZxB2yAN8j1Bn+LxRJgDjcVqQ9njRqX4r0fy/jIw5fzh+BwGY53/3jmcWiOqvIPuln5/+Ywg1k5h4cdEWf82exwkOMY+9+eq4XbkaOZZ+NLg3oVtYFMG/SEL6UFIfQCO8E5Pgdrx2qPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620144996790528.491298009885; Tue, 4 May 2021 09:16:36 -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-603-Sb_jICQ-Pq2WkSQfOGe4Xg-1; Tue, 04 May 2021 12:16:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4542A6D505; Tue, 4 May 2021 16:16:25 +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 C45E5106A02F; Tue, 4 May 2021 16:16:24 +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 E453C18095C2; Tue, 4 May 2021 16:16:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 144GGLsY026819 for ; Tue, 4 May 2021 12:16:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8D34F19C71; Tue, 4 May 2021 16:16:21 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-176.ams2.redhat.com [10.36.113.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83A7B90BD; Tue, 4 May 2021 16:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620144995; 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=V/IT1GH3NWBhBJtWUjgQjfY21KX8qyhkK/fQtfe/u6A=; b=e62Fhvwwr4sy00ipDHSusqHrlHc9p2R/mfWHUjkU2roey797tN8WS/7wG4QEx7fKtCoDXU LYYw5Y31OwlMcntRDv/VMUJfckYLvfiL9BevHkgGHQ2ucqmNjW6y8cwXrCcCd0HVpPwiZ5 QL/ZNHID0JJvk1UfsZ/zlnKFECIxoN4= X-MC-Unique: Sb_jICQ-Pq2WkSQfOGe4Xg-1 From: Kashyap Chamarthy To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] docs: kbase: Add a doc on live full disk backup Date: Tue, 4 May 2021 18:16:12 +0200 Message-Id: <20210504161613.159831-2-kchamart@redhat.com> In-Reply-To: <20210504161613.159831-1-kchamart@redhat.com> References: <20210504161613.159831-1-kchamart@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This is a rewrite of: https://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit Once this commit merges, the above wiki should point to this kbase document. Signed-off-by: Kashyap Chamarthy --- docs/kbase/index.rst | 3 + docs/kbase/live_full_disk_backup.rst | 111 +++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 docs/kbase/live_full_disk_backup.rst diff --git a/docs/kbase/index.rst b/docs/kbase/index.rst index 532804fe05..5ee3b5fce8 100644 --- a/docs/kbase/index.rst +++ b/docs/kbase/index.rst @@ -12,6 +12,9 @@ Usage Explanation of how disk backing chain specification impacts libvirt's behaviour and basic troubleshooting steps of disk problems. =20 +`Live full disk backup `__ + A walkthrough of how to take effective live full disk backups. + `Virtio-FS `__ Share a filesystem between the guest and the host =20 diff --git a/docs/kbase/live_full_disk_backup.rst b/docs/kbase/live_full_di= sk_backup.rst new file mode 100644 index 0000000000..f4ef7f2cc7 --- /dev/null +++ b/docs/kbase/live_full_disk_backup.rst @@ -0,0 +1,111 @@ +Efficient live full disk backup +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + +Overview +-------- + +Live full disk backups are preferred in many scenarios, *despite* their +space requirements. The following outlines an efficient method to do +that using libvirt's APIs. This method involves concepts: the notion of +`backing chains `_, +`QCOW2 overlays +`_, +and a special operation called "active block-commit", which allows +live-merging an overlay disk image into its backing file. + +At a high-level, this is the approach to take a live ful disk backup: +Assuming a guest with a single disk image, create a temporary live QCOW2 +overlay (commonly called as "external snapshot") to track the live guest +writes. Then backup the original disk image while the guest (live QEMU) +keeps writing to the temporary overlay. Finally, perform the "active +block-commit" opertion to live-merge the temporary overlay disk contents +into the original image =E2=80=94 i.e. the backing file =E2=80=94 and "piv= ot" the live +QEMU process to point to it. + +The below assumes you're using *at least* these versions (preferably +much newer): QEMU 2.1 and libvirt-1.2.9. + +Detailed procedure +------------------ + +1. Start with a guest with a single disk image, ``base.raw``, which is + where the live QEMU is pointing at, and recording the guest writes:: + + base.raw (live QEMU) + +2. List the current block device(s) in use:: + + $ virsh domblklist vm1 + Target Source + ------------------------------------------------ + vda /var/lib/libvirt/images/base.raw + +3. Create the live "external disk snapshot" (or more correctly, "an + overlay"):: + + $ virsh snapshot-create-as --domain vm1 overlay1 \ + --diskspec vda,file=3D/var/lib/libvirt/images/overlay1.qcow2 \ + --disk-only + + The disk image chain looks as follows:: + + base.raw <-- overlay1.qcow2 (live QEMU) + +.. note:: + Above, if you have QEMU guest agent installed in your virtual + machine, use the ``--quiesce`` option with ``virsh + snapshot-create-as [...]`` to ensure you have a consistent disk + state. + + Optionally, you can also supply the ``--no-metadata`` option to + ``virsh snapshot-create-as`` to tell libvirt not track the snapshot + metadata. Otherwise, when you decide to merge snapshot overlays, + you have to explicitly clean the libvirt metadata using ``virsh + snapshot-delete vm1 --metadata [name|--current]``. + +4. Now, take a backup the orignal image, ``base.raw``, to a different + location using ``cp`` or ``rsync``:: + + $ cp /var/lib/libvirt/images/base.raw + /export/backups/copy1_base.raw + + # Or: + + $ rsync -avhW --progress /var/lib/libvirt/images/base.raw \ + /export/backups/copy1_base.raw + +5. Enumerate the current block device(s) in use, again. Notice that the + current disk image in use is the above-created overlay, + ``overlay1.qcow2``:: + + $ virsh domblklist vm1 + Target Source + ------------------------------------------------ + vda vda,file=3D/var/lib/libvirt/images/overlay1.qcow2 + +6. Once the backup of the original image completes, now perform the + "active block-commit" to live-merge the contents of + ``overlay1.qcow2`` into ``base.raw`` *and* pivot the live QEMU back + to the original:: + + $ virsh blockcommit vm1 vda --active --verbose --pivot + +7. After the above operation completes, again list the current block + device(s) in use. And notice that the live QEMU is now writing to + the original base image:: + + $ virsh domblklist vm1 + Target Source + ------------------------------------------------ + vda /var/lib/libvirt/images/base.raw + + +The final updated disk image "chain" will be a single consolidated +disk:: + + [base.raw] (live QEMU) + + +Now you can safely **discard the overlay image**, ``overlay1.qcow2`` =E2= =80=94 +it is no longer valid; and its contents are now fully merged into the +base image. --=20 2.30.2