From nobody Mon May 6 08:33:05 2024 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=1605279337; cv=none; d=zohomail.com; s=zohoarc; b=LvQP106pdDeJb8BbvBwxv41tGi9oyr6282SmTz+PnKsjCEEab49pThCsWbGyg+suxjGed5oQAYl5Sd/A18FoYeA2DsiSy2EaXYB74M+/pM7XGRy8OvSRMXvz+2pDKCuKzpt0/cBtRv4CzNeooA3CwjLzf/AEm7Mo/3w0BhMoHV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605279337; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mX2KPBTewN6m1iXpTHbfhKu+2a7ZiZwgGm0qrrzWt/U=; b=JBAeDR3N1YVcGXonaQ/jBnJAEjE+VTEHIcy3RdR+fnamO9oLhhymezl9vkYaTSZ9TtnqnmcQMp9hiu73s4GFiDdFXfuL+XzDEYYhQkRlw4Kea+QJPcdFBFgsXMYjYw8NmNfqk6CDqwtPgjY/BT/xVPVi7M6aloxfRsevzTHZWf4= 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 1605279337449527.7898804800706; Fri, 13 Nov 2020 06:55:37 -0800 (PST) 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-237-QDHQ8o6xPhCMXaRtAqLYkw-1; Fri, 13 Nov 2020 09:55:33 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9418E803629; Fri, 13 Nov 2020 14:55:27 +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 3DE7C5D9E8; Fri, 13 Nov 2020 14:55:27 +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 4A4879997; Fri, 13 Nov 2020 14:55:26 +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 0ADEtPDu016400 for ; Fri, 13 Nov 2020 09:55:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id A7F5419930; Fri, 13 Nov 2020 14:55:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4E3319D61 for ; Fri, 13 Nov 2020 14:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605279336; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mX2KPBTewN6m1iXpTHbfhKu+2a7ZiZwgGm0qrrzWt/U=; b=ed/GaHKg76xDx2IQ7aP1ami6LQSW374ZG4DONOCUox9G/rjhXNjBWrzMLs0DYsj4TZfLOl Z2oXn6jdABZ70qtSXKh2INgnFA0264kttVmvytLFS0ZoWtUcL7CCDUJfbf7DUFvV0/VHrs Kwhf9Z3d1xA56zATGPs3ceuyd6JjaCw= X-MC-Unique: QDHQ8o6xPhCMXaRtAqLYkw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: backup: Install bitmap for incremental backup to appropriate node only Date: Fri, 13 Nov 2020 15:55:20 +0100 Message-Id: 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Libvirt's backup code has two modes: 1) push - where qemu actively writes the difference since the checkpoint into the output file 2) pull - where we instruct qemu to expose a frozen disk state along with a bitmap of blocks which changed since the checkpoint For push mode qemu needs the temporary bitmap we use where we calculate the actual changes to be present on the block node backing the disk. For pull mode where we expose the bitmap via NBD qemu actually wants the bitmap to be present for the exported block node which is the scratch file. Until now we've calculated the bitmap twice and installed it both to the scratch file and to the disk node, but we don't need to since we know when it's needed. Pass in the 'pull' flag and decide where to install the bitmap according to it and also when to register the bitmap name with the blockjob. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_backup.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 99dee46c4f..09f7921ea7 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -109,6 +109,7 @@ struct qemuBackupDiskData { virStorageSourcePtr terminator; virStorageSourcePtr backingStore; char *incrementalBitmap; + const char *domdiskIncrementalBitmap; /* name of temporary bitmap inst= alled on disk source */ qemuBlockStorageSourceChainDataPtr crdata; bool labelled; bool initialized; @@ -201,6 +202,7 @@ qemuBackupDiskPrepareOneBitmapsChain(virStorageSourcePt= r backingChain, static int qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDiskData *dd, virJSONValuePtr actions, + bool pull, GHashTable *blockNamedNodeData) { if (!qemuBlockBitmapChainIsValid(dd->domdisk->src, @@ -212,21 +214,29 @@ qemuBackupDiskPrepareOneBitmaps(struct qemuBackupDisk= Data *dd, return -1; } - if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src, - dd->domdisk->src, - dd->incrementalBitmap, - dd->backupdisk->incremental, - actions, - blockNamedNodeData) < 0) - return -1; + /* For pull-mode backup, we need the bitmap to be present in the scrat= ch + * file as that will be exported. For push-mode backup the bitmap is + * actually required on top of the image backing the disk */ - if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src, - dd->store, - dd->incrementalBitmap, - dd->backupdisk->incremental, - actions, - blockNamedNodeData) < 0) - return -1; + if (pull) { + if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src, + dd->store, + dd->incrementalBitmap, + dd->backupdisk->increment= al, + actions, + blockNamedNodeData) < 0) + return -1; + } else { + if (qemuBackupDiskPrepareOneBitmapsChain(dd->domdisk->src, + dd->domdisk->src, + dd->incrementalBitmap, + dd->backupdisk->increment= al, + actions, + blockNamedNodeData) < 0) + return -1; + + dd->domdiskIncrementalBitmap =3D dd->backupdisk->incremental; + } return 0; } @@ -293,12 +303,12 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm, else dd->incrementalBitmap =3D g_strdup_printf("backup-%s", dd->dom= disk->dst); - if (qemuBackupDiskPrepareOneBitmaps(dd, actions, blockNamedNodeDat= a) < 0) + if (qemuBackupDiskPrepareOneBitmaps(dd, actions, pull, blockNamedN= odeData) < 0) return -1; } if (!(dd->blockjob =3D qemuBlockJobDiskNewBackup(vm, dd->domdisk, dd->= store, - dd->incrementalBitmap))) + dd->domdiskIncrementalB= itmap))) return -1; /* use original disk as backing to prevent opening the backing chain */ --=20 2.28.0