From nobody Mon Feb 9 10:27:29 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=1583316803; cv=none; d=zohomail.com; s=zohoarc; b=CUFT5nrOi4Af0KZDEzDx2HzyuYJQIFDQjndvVTTUxuQqXPQ8U4KT/0eI1nmypdyreBz1PHJGH4mTfGL/u6AQqzxx2lh/U3H5/x5pYrzHqLKo6fNw++MaxRT+fROznj91LBhv9b134zKzWtNAhrl4VxYnYONes55Fl3VJwylTk70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583316803; h=Content-Type:Content-Transfer-Encoding:Cc: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=xXpUm+yHk2j3Mgfb0RW2cHE9VQHdkpYBoNb6FECFkz0=; b=fdQC3ug+CdnAll2smgS2wsSyYJwhLHTzlu2WyXiipMRfaI2P4eSay1J4CsTXSjtxjyHtxmj5ErX0V8rItcoNBeu1YgDkGOCTBNDh7OlTUnd1NjDvnWY9ZTXhBW2DJ5muiITdCDU0L1qW1/RA18X/31tFsQzEkGWoE3s/HI+ITy8= 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 1583316803255141.9790821267925; Wed, 4 Mar 2020 02:13:23 -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-308-M6ImzLtwPOikKrDX17YrBg-1; Wed, 04 Mar 2020 05:13:19 -0500 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 4A5D118C8C0C; Wed, 4 Mar 2020 10:13:14 +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 1AC321001B3F; Wed, 4 Mar 2020 10:13:14 +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 BAE2718089D8; Wed, 4 Mar 2020 10:13:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 024ACpCH030707 for ; Wed, 4 Mar 2020 05:12:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4CBF45DA87; Wed, 4 Mar 2020 10:12:51 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9ECF15DA2C; Wed, 4 Mar 2020 10:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583316801; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=xXpUm+yHk2j3Mgfb0RW2cHE9VQHdkpYBoNb6FECFkz0=; b=Hn0MXwK7Vicxg9acGZSHRpBN4Qtz8tOjMsyn/eIiM10mRrn7BHgQDtzdt+xLY1A40GxEdU ncRwYaVYjLJZLd2TVbibiME6MYFYyg4Dr3UrMxQZV4hyKEPcX1FEYzMBB/TOfvM9XXj7z8 x0iVb4BCXzBO7dgo9j2//eIuhAtY3Mc= X-MC-Unique: M6ImzLtwPOikKrDX17YrBg-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH 6/6] qemu: block: extend pull job completion with 'top' handling Date: Wed, 4 Mar 2020 11:12:40 +0100 Message-Id: <20200304101240.1139700-7-pmores@redhat.com> In-Reply-To: <20200304101240.1139700-1-pmores@redhat.com> References: <20200304101240.1139700-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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" 'top' handling basically requires two changes: besides the obvious adjustments to the code that fixes our backing chains (for both active and inactive configuration) after a pull, we need to make the top image read-only again if it's not identical with the active layer (it had to be made writable before submitting QMP block-stream to allow QEMU to fix the backing chain in top's qcow2). Signed-off-by: Pavel Mores --- src/qemu/qemu_blockjob.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index e19a2ad76b..2e53821d43 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -962,6 +962,7 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr = driver, virDomainDiskDefPtr cfgdisk =3D NULL; virStorageSourcePtr cfgbase =3D NULL; virStorageSourcePtr cfgbaseparent =3D NULL; + virStorageSourcePtr cfgtop =3D NULL; virStorageSourcePtr n; virStorageSourcePtr tmp; =20 @@ -994,16 +995,40 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPt= r driver, } } =20 - tmp =3D job->disk->src->backingStore; - job->disk->src->backingStore =3D job->data.pull.base; + if (job->data.pull.top) { + cfgtop =3D cfgdisk->src->backingStore; + for (n =3D job->disk->src->backingStore; n && n !=3D job->data.pul= l.top; n =3D n->backingStore) { + if (cfgtop) + cfgtop =3D cfgtop->backingStore; + } + } + + if (job->data.pull.top && job->data.pull.top !=3D job->disk->src) { + if (qemuDomainStorageSourceAccessAllow(driver, vm, job->data.pull.= top, true, false) < 0) { + virReportError(VIR_ERR_ACCESS_DENIED, "can't reset 'top' to re= ad-only"); + } + } + + if (job->data.pull.top) { + tmp =3D job->data.pull.top->backingStore; + job->data.pull.top->backingStore =3D job->data.pull.base; + } else { + tmp =3D job->disk->src->backingStore; + job->disk->src->backingStore =3D job->data.pull.base; + } if (baseparent) baseparent->backingStore =3D NULL; qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, tmp= ); virObjectUnref(tmp); =20 if (cfgdisk) { - tmp =3D cfgdisk->src->backingStore; - cfgdisk->src->backingStore =3D cfgbase; + if (job->data.pull.top) { + tmp =3D cfgtop->backingStore; + cfgtop->backingStore =3D cfgbase; + } else { + tmp =3D cfgdisk->src->backingStore; + cfgdisk->src->backingStore =3D cfgbase; + } if (cfgbaseparent) cfgbaseparent->backingStore =3D NULL; virObjectUnref(tmp); --=20 2.24.1