From nobody Sun Feb 8 22:01:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1612278274; cv=none; d=zohomail.com; s=zohoarc; b=eMI+yaFs893RJvzVJLEaSMliwM7GNNuIKtweNFOkdYn4z2PMRiLpVkQgW0If1sXUbv8AY+uWq+DvURrFubskGSpvafgYYUbOMDVAo2KFWD8FY2wXhYOEED1ydJuzUBirFP82tYoc4QJEgZa7SGZZ7mo3IWc8LjlyZ6b/H8WlVkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612278274; 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=wVvP/3ooiUlYghckbLCoU/vpoaAQjax0yhY/tS/Mt4I=; b=B3jb3R1RYftkPkfz/nMJULgXq12zEg8X166Yy4fTwVD3aFya5FG2Y6/Te/dTW7/g/W9r3VeEeIbeZrARZelD4Y4P17As84KVVfrTrIn6d8wAftGZhGmGhTt9cdA9q/Sy2a8iSCjnP44UGma+DvYP4MoL8sQWKvyCLb0/e+v3PrY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 16122782746031019.1363576261642; Tue, 2 Feb 2021 07:04:34 -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-286-OxIj3dVQPX6xdkYcg3dbuQ-1; Tue, 02 Feb 2021 10:04:29 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E5AF100B715; Tue, 2 Feb 2021 15:04:22 +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 66DC61F0; Tue, 2 Feb 2021 15:04:21 +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 6BE7B4BB7B; Tue, 2 Feb 2021 15:04:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 112F4FUr003116 for ; Tue, 2 Feb 2021 10:04:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6083B19813; Tue, 2 Feb 2021 15:04:15 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEEAF1F0 for ; Tue, 2 Feb 2021 15:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612278271; 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=wVvP/3ooiUlYghckbLCoU/vpoaAQjax0yhY/tS/Mt4I=; b=b1GVHsBVtiV5UmVdboozzwZFJ7CscFym8+Dk7mSk2CJ1BKHpm4p3uLHD3Esubyp+BQefwo 1GaRinVCUABs5VK1VlfUmEHHFxHEcoaJK9yeLsV6+lMCEkyblW9yAYmnVjVXyRPzPqKIbs PwCPIy2RIEQFDFiN1ovwwcbwt9Gvk60= X-MC-Unique: OxIj3dVQPX6xdkYcg3dbuQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/6] qemu_validate: move and refactor qemuValidateDomainDefVirtioFSSharedMemory Date: Tue, 2 Feb 2021 16:04:08 +0100 Message-Id: <37f39b20568c7a0edb0048666c24922746b1483a.1612277922.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Make the function reusable by other vhost-user based devices. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_validate.c | 99 +++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 88f4344df0..96fc7d4118 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1380,6 +1380,54 @@ qemuValidateDomainVirtioOptions(const virDomainVirti= oOptions *virtio, } =20 =20 +static int +qemuValidateDomainDefVhostUserRequireSharedMemory(const virDomainDef *def, + const char *name, + virQEMUCapsPtr qemuCaps) +{ + const char *defaultRAMId =3D virQEMUCapsGetMachineDefaultRAMid(qemuCap= s, + def->virt= Type, + def->os.m= achine); + size_t numa_nodes =3D virDomainNumaGetNodeCount(def->numa); + size_t i; + + if (numa_nodes =3D=3D 0 && + !(defaultRAMId && def->mem.access =3D=3D VIR_DOMAIN_MEMORY_ACCESS_= SHARED)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' requires shared memory"), name); + return -1; + } + + for (i =3D 0; i < numa_nodes; i++) { + virDomainMemoryAccess node_access =3D + virDomainNumaGetNodeMemoryAccessMode(def->numa, i); + + switch (node_access) { + case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT: + if (def->mem.access !=3D VIR_DOMAIN_MEMORY_ACCESS_SHARED) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' requires shared memory"), name); + return -1; + } + break; + case VIR_DOMAIN_MEMORY_ACCESS_SHARED: + break; + case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' requires shared memory"), name); + return -1; + + case VIR_DOMAIN_MEMORY_ACCESS_LAST: + default: + virReportEnumRangeError(virDomainMemoryAccess, node_access); + return -1; + + } + } + return 0; +} + + static int qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net, virQEMUCapsPtr qemuCaps) @@ -3947,53 +3995,6 @@ qemuValidateDomainDeviceDefGraphics(const virDomainG= raphicsDef *graphics, } =20 =20 -static int -qemuValidateDomainDefVirtioFSSharedMemory(const virDomainDef *def, - virQEMUCapsPtr qemuCaps) -{ - const char *defaultRAMId =3D virQEMUCapsGetMachineDefaultRAMid(qemuCap= s, - def->virt= Type, - def->os.m= achine); - size_t numa_nodes =3D virDomainNumaGetNodeCount(def->numa); - size_t i; - - if (numa_nodes =3D=3D 0 && - !(defaultRAMId && def->mem.access =3D=3D VIR_DOMAIN_MEMORY_ACCESS_= SHARED)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtiofs requires shared memory")); - return -1; - } - - for (i =3D 0; i < numa_nodes; i++) { - virDomainMemoryAccess node_access =3D - virDomainNumaGetNodeMemoryAccessMode(def->numa, i); - - switch (node_access) { - case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT: - if (def->mem.access !=3D VIR_DOMAIN_MEMORY_ACCESS_SHARED) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtiofs requires shared memory")); - return -1; - } - break; - case VIR_DOMAIN_MEMORY_ACCESS_SHARED: - break; - case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtiofs requires shared memory")); - return -1; - - case VIR_DOMAIN_MEMORY_ACCESS_LAST: - default: - virReportEnumRangeError(virDomainMemoryAccess, node_access); - return -1; - - } - } - return 0; -} - - static int qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs, const virDomainDef *def, @@ -4091,8 +4092,10 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs, _("virtiofs does not support fmode and dmode")); return -1; } - if (qemuValidateDomainDefVirtioFSSharedMemory(def, qemuCaps) < 0) + if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, "virtio= fs", + qemuCaps) < = 0) { return -1; + } if (fs->info.bootIndex && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOST_USER_FS_BOOTINDEX)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", --=20 2.29.2