From nobody Thu May 16 16:25:01 2024 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=1586177923; cv=none; d=zohomail.com; s=zohoarc; b=CpJ0LNsl+4Oh+foB0Pl5+fVp0z0x+V4ayfN7uVrb2rfbi5bXy126cA23G4ze2ISk+QeUil0EDdNvWlJV1O+1L6dfKUDSV7dDmPB0fkXcVBh+16DYG7G1EC/+KyNfEkk/5aeGDkDUEKFIU5TV6uacXo1VSqr14m126dYoY7eR+LI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586177923; 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=ow3U9sQS+AT0U/8hEZXnGi+Q21uM7HxAqn/aemiz2n0=; b=cg8lAVNc6k+KEOwFOjubjF35N7GM0l/a3SumjI5SbqAt36Rs5vh/Dsx0qmU+YEN0ME2t7yeUVaxW5MC8v03L7QmHCNjD5Ycve8wriNuIT2S25Zl0meUbhCn6gAtDmVBm1trAThSFuhCsI6lQ+kiDU1k/wsuiBJd9udBW6eruq0g= 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 1586177923076341.2265915238744; Mon, 6 Apr 2020 05:58:43 -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-368-Lnm5BkxlPvCreNM4Pml_fA-1; Mon, 06 Apr 2020 08:58:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE826100551A; Mon, 6 Apr 2020 12:58:33 +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 77C855C1BB; Mon, 6 Apr 2020 12:58:32 +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 7F073181AC26; Mon, 6 Apr 2020 12:58:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 036CwSB3014230 for ; Mon, 6 Apr 2020 08:58:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7648E9A266; Mon, 6 Apr 2020 12:58:28 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id EECB89A260 for ; Mon, 6 Apr 2020 12:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586177921; 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=ow3U9sQS+AT0U/8hEZXnGi+Q21uM7HxAqn/aemiz2n0=; b=QK5dgNjG04jXIZATLk7uc5m/Quw0aYZecyt1x7TuS6BnoqCKj4XF7cPqHR926RuPMi+oLR VL0O2/UgHXwlvsr5fLwPjn4cIHVIlNbTV67UPoAS6qzJxyCdjm4oKPp1dzj8tfzT0GbEjW mcgmXzTUNzYLHM/jNYIYc4lbcDuUaw0= X-MC-Unique: Lnm5BkxlPvCreNM4Pml_fA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: backup: Fix handling of backing store for backup target images Date: Mon, 6 Apr 2020 14:58:24 +0200 Message-Id: <1384a52886f7a6f5d8121c77d90a3735f10cf3e8.1586177822.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.16 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" We always tried to install backing store for the image even if it didn't make sesne, e.g. for a full backup into a raw image. Additionally we didn't record the backing file into the qcow2 metadata so the image itself contained the diff of data but reading from it would be incomplete as it depends on the backing image. This patch fixes both issues by carefully installing the correct backing file when appropriate and also recording it into the metadata when creating the image. https://bugzilla.redhat.com/show_bug.cgi?id=3D1813310 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_backup.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 9a056fa407..5d18720f53 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -105,6 +105,8 @@ struct qemuBackupDiskData { virDomainDiskDefPtr domdisk; qemuBlockJobDataPtr blockjob; virStorageSourcePtr store; + virStorageSourcePtr terminator; + virStorageSourcePtr backingStore; char *incrementalBitmap; qemuBlockStorageSourceChainDataPtr crdata; bool labelled; @@ -146,6 +148,7 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm, qemuBlockJobStartupFinalize(vm, dd->blockjob); qemuBlockStorageSourceChainDataFree(dd->crdata); + virObjectUnref(dd->terminator); } @@ -295,6 +298,7 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm, virDomainBackupDiskDefPtr backupdisk, struct qemuBackupDiskData *dd, virJSONValuePtr actions, + bool pull, virDomainMomentDefPtr *incremental, virHashTablePtr blockNamedNodeData, virQEMUDriverConfigPtr cfg) @@ -314,6 +318,19 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm, if (!dd->store->format) dd->store->format =3D VIR_STORAGE_FILE_QCOW2; + /* calculate backing store to use: + * push mode: + * full backups: no backing store + * incremental: original disk if format supports backing store + * pull mode: + * both: original disk + */ + if (pull || (incremental && dd->store->format >=3D VIR_STORAGE_FILE_BA= CKING)) { + dd->backingStore =3D dd->domdisk->src; + } else { + dd->backingStore =3D dd->terminator =3D virStorageSourceNew(); + } + if (qemuDomainStorageFileInit(priv->driver, vm, dd->store, dd->domdisk= ->src) < 0) return -1; @@ -337,7 +354,7 @@ qemuBackupDiskPrepareDataOne(virDomainObjPtr vm, /* use original disk as backing to prevent opening the backing chain */ if (!(dd->crdata =3D qemuBuildStorageSourceChainAttachPrepareBlockdevT= op(dd->store, - = dd->domdisk->src, + = dd->backingStore, = priv->qemuCaps))) return -1; @@ -398,6 +415,7 @@ qemuBackupDiskPrepareData(virDomainObjPtr vm, struct qemuBackupDiskData *disks =3D NULL; ssize_t ndisks =3D 0; size_t i; + bool pull =3D def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL; disks =3D g_new0(struct qemuBackupDiskData, def->ndisks); @@ -410,12 +428,12 @@ qemuBackupDiskPrepareData(virDomainObjPtr vm, ndisks++; - if (qemuBackupDiskPrepareDataOne(vm, backupdisk, dd, actions, + if (qemuBackupDiskPrepareDataOne(vm, backupdisk, dd, actions, pull, incremental, blockNamedNodeData, cfg) < 0) goto error; - if (def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL) { + if (pull) { if (qemuBackupDiskPrepareDataOnePull(actions, dd) < 0) goto error; } else { @@ -480,7 +498,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObjPtr vm, dd->store, dd->domdisk-= >src) < 0) return -1; - if (qemuBlockStorageSourceCreate(vm, dd->store, NULL, NULL, + if (qemuBlockStorageSourceCreate(vm, dd->store, dd->backingStore, = NULL, dd->crdata->srcdata[0], QEMU_ASYNC_JOB_BACKUP) < 0) return -1; --=20 2.25.1