From nobody Sun Feb 8 21:11:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1563883752; cv=none; d=zoho.com; s=zohoarc; b=YKKVy2BYW3M1daDibtULAo8BEhUVU+ty50zYx4c+TakARRNW6AALFpJA8fEsvHOkcNg+AhGN/LuAq0eRIPrkKd3UY3OUuu6ia53jBu2MI0y2+hcIPAdolLcEOx+LBk9jjByqlyQdICcj6gxf8bPaOInQeyJM62nbAqR56OX6Cvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563883752; 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:ARC-Authentication-Results; bh=8m50N3HMUwxAKlrfnmeguRIPgRNKBQ+7f0NnuQW4+xY=; b=BrfqLmT+vKNwhwixTwvR4qFGCS7st9iNJsvCjsQPJA5rwvh7LwUu/pX4g3zMaCmEHE9SHc3zipRKFxS80lLjwd+VdLseBU0nWz7CwNpwFuyjVmXmBMhikHbPJ2+egfgdsyPruwhPQPd0yBCGEtrewQfMoAzjvcFXzHq5mIAQQUI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563883752698693.5564784032703; Tue, 23 Jul 2019 05:09:12 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 7E35D81F18; Tue, 23 Jul 2019 12:09:11 +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 082185D9D3; Tue, 23 Jul 2019 12:09:11 +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 B081A1972E; Tue, 23 Jul 2019 12:09:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6NC8u3S009414 for ; Tue, 23 Jul 2019 08:08:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id B36B652FC2; Tue, 23 Jul 2019 12:08:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8F4A5B684 for ; Tue, 23 Jul 2019 12:08:55 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 23 Jul 2019 14:08:46 +0200 Message-Id: <5284a2451c01dacfcdb2fcba95239290c0ef12e9.1563883655.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] qemu: Add possibility to prepare top image only for attachment via blockdev 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 23 Jul 2019 12:09:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuBuildStorageSourceChainAttachPrepareBlockdev prepares the full backing chain for attachment via blockdev. For snapshots we'll need to prepare one image only as it needs to be plugged on top of the existing chain. This patch introduces qemuBuildStorageSourceChainAttachPrepareBlockdevTop which prepares only @top similarly to the original function by splitting out the functionality into an internal function so that the API does not change. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 51 +++++++++++++++++++++++++++++++++-------- src/qemu/qemu_command.h | 3 +++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index eefec98022..476e710257 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -11159,16 +11159,10 @@ qemuBuildStorageSourceChainAttachPrepareDrive(vir= DomainDiskDefPtr disk, } -/** - * qemuBuildStorageSourceChainAttachPrepareBlockdev: - * @top: storage source chain - * @qemuCaps: qemu capabilities object - * - * Prepares qemuBlockStorageSourceChainDataPtr for attaching @top via -blo= ckdev. - */ -qemuBlockStorageSourceChainDataPtr -qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, - virQEMUCapsPtr qemuCaps) +static qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(virStorageSourceP= tr top, + virQEMUCapsPtr qe= muCaps, + bool onlyTop) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; @@ -11186,7 +11180,44 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(v= irStorageSourcePtr top, if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) return NULL; + + if (onlyTop) + break; } VIR_RETURN_PTR(data); } + + +/** + * qemuBuildStorageSourceChainAttachPrepareBlockdev: + * @top: storage source chain + * @qemuCaps: qemu capabilities object + * + * Prepares qemuBlockStorageSourceChainDataPtr for attaching the chain of = images + * starting at @top via -blockdev. + */ +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, + virQEMUCapsPtr qemuCaps) +{ + return qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(top, q= emuCaps, + false); +} + + +/** + * qemuBuildStorageSourceChainAttachPrepareBlockdevTop: + * @top: storage source chain + * @qemuCaps: qemu capabilities object + * + * Prepares qemuBlockStorageSourceChainDataPtr for attaching of @top image= only + * via -blockdev. + */ +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr to= p, + virQEMUCapsPtr qemuCap= s) +{ + return qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(top, q= emuCaps, + true); +} diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 8695832c16..7e2dc5a60a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -117,6 +117,9 @@ qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, virQEMUCapsPtr qemuCaps); +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr to= p, + virQEMUCapsPtr qemuCap= s); char *qemuBuildDiskDeviceStr(const virDomainDef *def, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list