From nobody Sun May 5 19:58:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585567367; cv=none; d=zohomail.com; s=zohoarc; b=Xb/chcBIiacrl/fHwYfl9IUFIGhuhv3yQxK6CcFT9AhJRqZ5USoR9OUVp6dhzldignEOI9BLRHkUn8Xel1yA2EkL8vNEnI+p6mxvavuHto0KgIviQvKezha37Us9ex53fJU/CaQBXCmN4tCH3zVgKZi8mlaQj6KVfHF96cxIMRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585567367; 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=5SKnv1NMFKMFW4bOzdToyIwPoszsd0j/PJmPzIu5q9A=; b=cFhj34piBqe4hPvzuPxc3k3Htp8dci0smWiYt7Sx/tiEugWUxQqSpibuQywnhmNJXN0ngUBsUJnI+iNuhmzBuRqH7jhjWJWdRFMry5e27GROUaNzq7gv96aOe99rZtwMP//7P8t+79Li8oeIaNR1Yi/ESxAeaghxYbgqSdVB+L0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585567367561221.2589651942866; Mon, 30 Mar 2020 04:22:47 -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-13-GMchG2QMOYKmPZZ7kk8TYg-1; Mon, 30 Mar 2020 07:22:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 056818017CC; Mon, 30 Mar 2020 11:22:38 +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 D1CC85E026; Mon, 30 Mar 2020 11:22:37 +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 8C25A18089D5; Mon, 30 Mar 2020 11:22:37 +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 02UBLXEm011048 for ; Mon, 30 Mar 2020 07:21:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 74259100EBB1; Mon, 30 Mar 2020 11:21:33 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBE85100EBAD for ; Mon, 30 Mar 2020 11:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585567366; 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=5SKnv1NMFKMFW4bOzdToyIwPoszsd0j/PJmPzIu5q9A=; b=M1fgRu+f2KsoC2RZa+v4UoSBMXGxcM50OZPUOXt+uEjSSYqDaOLnUFh8H8lDdJn1ODbC1T 0nlP6RPqsA8h/Ty0k6s1mdLMMVLQmPFjDJIdOhhgylxUuYAR/aUG90l2wRLbHSAzF8Hqjq eh1C4U+8j6KiblOXktHj83B8HXh5Eo8= X-MC-Unique: GMchG2QMOYKmPZZ7kk8TYg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemu: block: Support VIR_DOMAIN_BLOCK_COMMIT/PULL/REBASE_RELATIVE with blockdev Date: Mon, 30 Mar 2020 13:21:27 +0200 Message-Id: <2ca91c392084ab806ae37b4610833f6d01fa5183.1585567181.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.15 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" Preservation of the relative relationship requires us to load the backing store strings from the disk images. With blockdev we stopped detecting the backing chain if it's specified in the XML so the relative links were not loaded at that point. To preserve the functionality from the pre-blockdev without accessing the backing chain unnecessarily during VM startup we must refresh the relative links when relative block commit or block pull is requested. https://bugzilla.redhat.com/show_bug.cgi?id=3D1818655 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 46 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 5 +++++ src/qemu/qemu_driver.c | 8 ++++++++ 3 files changed, 59 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 648c3f1026..fe5a0a6a7d 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3378,3 +3378,49 @@ qemuBlockStorageSourceGetCookieString(virStorageSour= cePtr src) return virBufferContentAndReset(&buf); } + + +/** + * qemuBlockUpdateRelativeBacking: + * @vm: domain object + * @src: starting point of the update + * @topsrc: top level image in the backing chain (used to get security lab= el) + * + * Reload data necessary for keeping backing store links starting from @src + * relative. + */ +int +qemuBlockUpdateRelativeBacking(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr topsrc) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverPtr driver =3D priv->driver; + virStorageSourcePtr n; + + for (n =3D src; virStorageSourceHasBacking(n); n =3D n->backingStore) { + g_autofree char *backingStoreStr =3D NULL; + int rc; + + if (n->backingStore->relPath) + break; + + if (!virStorageFileSupportsBackingChainTraversal(n)) + continue; + + if (qemuDomainStorageFileInit(driver, vm, n, topsrc) < 0) + return -1; + + rc =3D virStorageFileGetBackingStoreStr(n, &backingStoreStr); + + virStorageFileDeinit(n); + + if (rc < 0) + return rc; + + if (backingStoreStr && virStorageIsRelative(backingStoreStr)) + n->backingStore->relPath =3D g_steal_pointer(&backingStoreStr); + } + + return 0; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 8b57ffd8a5..2ad2ce1a1f 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -261,3 +261,8 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const virS= torageSource *src); char * qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src); + +int +qemuBlockUpdateRelativeBacking(virDomainObjPtr vm, + virStorageSourcePtr src, + virStorageSourcePtr topsrc); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 570dc059e9..ae38b9c914 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17466,6 +17466,10 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, goto endjob; } + if (blockdev && + qemuBlockUpdateRelativeBacking(vm, disk->src, disk->src) <= 0) + goto endjob; + if (virStorageFileGetRelativeBackingPath(disk->src->backingSto= re, baseSource, &backingPath) < 0) @@ -18593,6 +18597,10 @@ qemuDomainBlockCommit(virDomainPtr dom, goto endjob; } + if (blockdev && top_parent && + qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) + goto endjob; + if (virStorageFileGetRelativeBackingPath(topSource, baseSource, &backingPath) < 0) goto endjob; --=20 2.24.1 From nobody Sun May 5 19:58:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585567380; cv=none; d=zohomail.com; s=zohoarc; b=T9EGXKWEgkHFfo1vQKPl2Dgf0bYAPo6Qj+Uq27Il4wC2TST+NXAODy8D5DDRl7tkhEAH3tlTV7+xQ3B+oA+2X1LfSN/tG59H+2WUmgVbASXL+qbl8NzPgoOtu1FydS9MidBb/UKk9kgbqm6udw7RdwrcVK8NcUSugxAsYspaTIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585567380; 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=jYxlanxG0Xw7sUd/ahFpUg/HvWBhP+VCgVrWXhLwgFE=; b=QoM1tkp7wgRmkq20POQGttuLSHyt4GKT3fOvtigJhb2fmLfr6XTCGTnO6e47AxiLKl6rbM1DmJARV0A05Vh7Rl0myOcNOZGNwn2MgyjRE/dbMIUqMpkRgeP2zjzrH1OXPRhcsrLbLarQOiwp/xT5h6L3YMXrZiB1/9wLh9f8YX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585567380810372.6511876051411; Mon, 30 Mar 2020 04:23:00 -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-19-TxIoRQnmMdWJoq5ZBtRtPg-1; Mon, 30 Mar 2020 07:22:57 -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 B6CD3100551A; Mon, 30 Mar 2020 11:22:51 +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 8A5B6100EBAD; Mon, 30 Mar 2020 11:22:51 +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 3ACDF944CC; Mon, 30 Mar 2020 11:22:51 +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 02UBLYr7011058 for ; Mon, 30 Mar 2020 07:21:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4EF66100EBB1; Mon, 30 Mar 2020 11:21:34 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7CB3100EBAD for ; Mon, 30 Mar 2020 11:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585567379; 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=jYxlanxG0Xw7sUd/ahFpUg/HvWBhP+VCgVrWXhLwgFE=; b=DdBJZPfoTE4HuHfgEwpxY/nS0ZbCnEvQJqiXIocFZjBKPQUMnsNmZTBOVmJNLOMQ0flNbk 1cae/WxYZaGGXKfdwGuLG4gKcFWRWvdBPSJUpCyCHW5cmhuHi6BaaDdmqi3QHdjVZpDfWw kqMTnds9frm0svUZrsQ4ISDuJkqcBr4= X-MC-Unique: TxIoRQnmMdWJoq5ZBtRtPg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] qemuDomainSnapshotDiskPrepareOne: Don't load the relative path with blockdev Date: Mon, 30 Mar 2020 13:21:28 +0200 Message-Id: <1152a027238c01b9dcd035c062a465d9b5c2828a.1585567181.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.84 on 10.5.11.22 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" Since we are refreshing the relative paths when doing the blockjobs we no longer need to load them upfront when doing the snapshot. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ae38b9c914..78024614cf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15167,8 +15167,9 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr d= river, dd->initialized =3D true; /* relative backing store paths need to be updated so that relative - * block commit still works */ - if (reuse) { + * block commit still works. With blockdev we must update it when = doing + * commit anyways so it's skipped here */ + if (reuse && !blockdev) { if (supportsBacking) { g_autofree char *backingStoreStr =3D NULL; --=20 2.24.1