From nobody Mon Feb 9 09:16:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605512644; cv=none; d=zohomail.com; s=zohoarc; b=jv1waEluZ+OzFdGFxkrFC5s+AxtyjR3ViyuJhEHFXRrTqLWlsuy1pPERblzd2SR6YPhtg5uny+fGmmAKIoitekpZ4SxNd+b9wczRqrvg0nTWADgK78OeVdvMVzkxZ9Egco37a3pU8FiG6+21QbahHTiHUnkdhu2mw1xlXimvzxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512644; 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=GO8BXQhH6l99uryQgXUYQNcfEOlKbFPn8DMHwNMqZL8=; b=W8D+O+ZeY7OE/X2wLGEzh5VXrUyf4GisX4u6Bb9LVHwFi3P+Z3jqJP+WjtKfet48DRKZdriRYXO9SmZTSeajhKNfpfTtVfHa7L86QfWYvOSHf3NzFn9RrScSODxuS844hSIUtXnBCuUetCjtzV+ggY+KNYUynLtz1d58bpU5x2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605512644607414.5056718371552; Sun, 15 Nov 2020 23:44:04 -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-355-wTjWwlVtNqmSQzJTNGAAAQ-1; Mon, 16 Nov 2020 02:44:00 -0500 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 0A8BE8015B1; Mon, 16 Nov 2020 07:43:54 +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 DB86455764; Mon, 16 Nov 2020 07:43:53 +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 476EE181A06C; Mon, 16 Nov 2020 07:43:52 +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 0AG7ho8E032546 for ; Mon, 16 Nov 2020 02:43:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8BA0F5B4A9; Mon, 16 Nov 2020 07:43:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CD2D5B4C1 for ; Mon, 16 Nov 2020 07:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512643; 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=GO8BXQhH6l99uryQgXUYQNcfEOlKbFPn8DMHwNMqZL8=; b=LB319QzxG3KBP6e1uz0YcuBMG0J52ZVQr+6+PJqOhr0Mv/t1Myv24WbKyCIRDOSk6VsRpQ /HAUVeigAruTZ3ZFCg/cTSRERsZbZQ5ryiomyUQlseQtBs6BOh47tizgXZMsPk3EgNFtsY sJ1Mb7RU8Mb9U9G8A+SIDYuoT2ZXuIQ= X-MC-Unique: wTjWwlVtNqmSQzJTNGAAAQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] qemu: Validate RNG model Date: Mon, 16 Nov 2020 08:43:40 +0100 Message-Id: <4fbaefb6df0f5c5ea5e6564b1bb92d4e5947d2ad.1605512572.git.mprivozn@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.15 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" The aim is to eliminate virDomainCapsDeviceDefValidate(). And in order to do so, the domain RNG model has to be validated in qemuValidateDomainRNGDef(). Signed-off-by: Michal Privoznik --- src/conf/domain_capabilities.c | 18 +----------------- src/qemu/qemu_validate.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 6ee8730111..b886ba7090 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -640,20 +640,6 @@ virDomainCapsFormat(const virDomainCaps *caps) } while (0) =20 =20 -static int -virDomainCapsDeviceRNGDefValidate(const virDomainCaps *caps, - const virDomainRNGDef *dev) -{ - if (ENUM_VALUE_MISSING(caps->rng.model, dev->model)) { - ENUM_VALUE_ERROR("rng model", - virDomainRNGModelTypeToString(dev->model)); - return -1; - } - - return 0; -} - - static int virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps, const virDomainVideoDef *dev) @@ -676,9 +662,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *cap= s, int ret =3D 0; =20 switch ((virDomainDeviceType) dev->type) { - case VIR_DOMAIN_DEVICE_RNG: - ret =3D virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng); - break; case VIR_DOMAIN_DEVICE_VIDEO: ret =3D virDomainCapsDeviceVideoDefValidate(caps, dev->data.video); break; @@ -706,6 +689,7 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *cap= s, case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 79e765a212..c18865367e 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1883,6 +1883,31 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def, return -1; } =20 + switch ((virDomainRNGModel) def->model) { + case VIR_DOMAIN_RNG_MODEL_VIRTIO: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain configuration does not support rng mo= del '%s'"), + virDomainRNGModelTypeToString(def->model)); + return -1; + } + break; + + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain configuration does not support rng mo= del '%s'"), + virDomainRNGModelTypeToString(def->model)); + return -1; + } + break; + + case VIR_DOMAIN_RNG_MODEL_LAST: + break; + } + if (qemuValidateDomainVirtioOptions(def->virtio, qemuCaps) < 0) return -1; =20 --=20 2.26.2