From nobody Sat Feb 7 06:55:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1579795048; cv=none; d=zohomail.com; s=zohoarc; b=jr1Pje6p2LPrWcNDy5QsJncEb4Y2MwkpM9s5OukbRbBp4EUGGAHAzGheioboRH5QdKNfrkrcyiO1umxQcDTj5A7Vx/FDVpxWWqz1bUofOSR8wK3OXVYEGK+1uyIsm7k9lyOayEQLh0aRLvqC9SNgEGrW8Wzmbl0PHs6iiXjXibw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579795048; 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=9YM12yhxZksqdGkxzVqb3Ut8H2hxDstpKGAcCUlmJtM=; b=GuHpzzNbgHxiYko9iwhf9qUOOl1yK8p6W//CgGnjkbEfBZvjf5QHUHYE+X+Puxkvq7vdaUJCqdWD/PvhjifAOUygVHl8XfjkmFwcPMd15HzOtYN29aFBAePrO5duhggusGmuX7b/vS9Q2XYmulDsnwobUzaMCxt6nzHq4Ij3hLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1579795048161823.6479579816821; Thu, 23 Jan 2020 07:57:28 -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-170-WGjsAcivNQ6rl26O_vjjcQ-1; Thu, 23 Jan 2020 10:57:24 -0500 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 2AACD100550E; Thu, 23 Jan 2020 15:57:19 +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 D44FC5C545; Thu, 23 Jan 2020 15:57:18 +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 BBA0F8594B; Thu, 23 Jan 2020 15:57:15 +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 00NFvECw012645 for ; Thu, 23 Jan 2020 10:57:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1431038F; Thu, 23 Jan 2020 15:57:14 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BD4F19C69; Thu, 23 Jan 2020 15:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579795047; 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=9YM12yhxZksqdGkxzVqb3Ut8H2hxDstpKGAcCUlmJtM=; b=d8sH/xQpX9S+PxVJA85OK+m/vPhR4wpxqaOm/3nWIv+k75OPjAqT38/Und7MN+xPsgLiDK ba2fI9fQ8zC2m+cGEEMZntI4hKLl3fEbpSxMbkGne1gnkTv7mrp+W2GOvcJSX/9kEQtcEq Jc96HRyQVE0ZrqQb3uL3qB+ULxMgBzI= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: domain: Extract code to determine topmost nodename to qemuDomainDiskGetTopNodename Date: Thu, 23 Jan 2020 16:57:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-MC-Unique: WGjsAcivNQ6rl26O_vjjcQ-1 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" There are more places which require getting the topmost nodename to be passed to qemu. Separate it out into a new function. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++------------ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 38addc7b61..4604b6c993 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11530,6 +11530,31 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driv= er, } +/** + * qemuDomainDiskGetTopNodename: + * + * @disk: disk definition object + * + * Returns the pointer to the node-name of the topmost layer used by @disk= as + * backend. Currently returns the nodename of the copy-on-read filter if e= nabled + * or the nodename of the top image's format driver. Empty disks return NU= LL. + * This must be used only when VIR_QEMU_CAPS_BLOCKDEV is enabled. + */ +const char * +qemuDomainDiskGetTopNodename(virDomainDiskDefPtr disk) +{ + qemuDomainDiskPrivatePtr priv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); + + if (virStorageSourceIsEmpty(disk->src)) + return NULL; + + if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON) + return priv->nodeCopyOnRead; + + return disk->src->nodeformat; +} + + /** * qemuDomainDiskGetBackendAlias: * @disk: disk definition @@ -11549,8 +11574,6 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr d= isk, virQEMUCapsPtr qemuCaps, char **backendAlias) { - qemuDomainDiskPrivatePtr priv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - const char *nodename =3D NULL; *backendAlias =3D NULL; if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { @@ -11560,16 +11583,7 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr = disk, return 0; } - if (virStorageSourceIsEmpty(disk->src)) - return 0; - - if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON) - nodename =3D priv->nodeCopyOnRead; - else - nodename =3D disk->src->nodeformat; - - *backendAlias =3D g_strdup(nodename); - + *backendAlias =3D g_strdup(qemuDomainDiskGetTopNodename(disk)); return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 21ece23177..c8bf621c61 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -874,6 +874,10 @@ int qemuDomainStorageFileInit(virQEMUDriverPtr driver, virStorageSourcePtr parent); char *qemuDomainStorageAlias(const char *device, int depth); +const char * +qemuDomainDiskGetTopNodename(virDomainDiskDefPtr disk) + ATTRIBUTE_NONNULL(1); + int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, char **backendAlias) --=20 2.24.1