From nobody Sun May 5 13:29:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162390324801546.90746711645693; Wed, 16 Jun 2021 21:14:08 -0700 (PDT) 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-48-ZIQEdZwPO-e6CAG25iAtXg-1; Thu, 17 Jun 2021 00:14:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31295801B13; Thu, 17 Jun 2021 04:13:59 +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 4D47D60613; Thu, 17 Jun 2021 04:13:55 +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 1CF2846F81; Thu, 17 Jun 2021 04:13:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15H4AJP4018158 for ; Thu, 17 Jun 2021 00:10:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 841F12102C42; Thu, 17 Jun 2021 04:10:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F9F52102C2A for ; Thu, 17 Jun 2021 04:10:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5684B1857F1E for ; Thu, 17 Jun 2021 04:10:16 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-kT6-clrdO_uSTNsuIpGhFA-1; Thu, 17 Jun 2021 00:10:13 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 21:09:09 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 21:09:09 -0700 X-MC-Unique: ZIQEdZwPO-e6CAG25iAtXg-1 X-MC-Unique: kT6-clrdO_uSTNsuIpGhFA-1 IronPort-SDR: ExN03AxkwlwJNfLxGH1vtejhlW8nGSpWRtAsCJqKnWTNlzT+tUq5xSSHnSgm3QHyonfUiVPDuc 56m/O0fsWW7w== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="204469544" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="204469544" IronPort-SDR: 8C2QZf2b4ALYXHZF+MD7KFcInVyJOB/ELQ/GewmACIl7aOCTNzo7CqtSzlng5nxc76wDcLIl5o lSv2prlH4YGg== X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485141398" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH] ch_domain: Add handler for virDomainDeviceDefPostParseCallback Date: Wed, 16 Jun 2021 21:16:01 -0700 Message-Id: <20210617041600.635662-1-william.douglas@intel.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: William Douglas 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.13 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 Content-Type: text/plain; charset="utf-8" Instead of trying to match devices passed in based on the monitor detecting the number of devices that were used in the domain definition, use the devicesPostParseCallback to evaluate if unsupported devices are used. This allows the compiler to detect when new device types are added that need to be checked. Signed-off-by: William Douglas --- src/ch/ch_domain.c | 121 +++++++++++++++++++++++++++++++++++++++++++ src/ch/ch_monitor.c | 122 -------------------------------------------- 2 files changed, 121 insertions(+), 122 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index f9a6f3f31d..02ca5ea06c 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -197,7 +197,128 @@ virCHDomainDefPostParse(virDomainDef *def, return 0; } =20 +static int +virCHDomainDeviceDefPostParse(virDomainDeviceDef *dev, + const virDomainDef *def G_GNUC_UNUSED, + unsigned int parseFlags G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED, + void *parseOpaque G_GNUC_UNUSED) +{ + int ret =3D -1; + + switch ((virDomainDeviceType)dev->type) { + case VIR_DOMAIN_DEVICE_DISK: + ret =3D 0; + break; + case VIR_DOMAIN_DEVICE_LEASE: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support lease")); + break; + case VIR_DOMAIN_DEVICE_FS: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support fs")); + break; + case VIR_DOMAIN_DEVICE_NET: + ret =3D 0; + break; + case VIR_DOMAIN_DEVICE_INPUT: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support input")); + break; + case VIR_DOMAIN_DEVICE_SOUND: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support sound")); + break; + case VIR_DOMAIN_DEVICE_VIDEO: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support video")); + break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support hostdev")); + break; + case VIR_DOMAIN_DEVICE_WATCHDOG: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support watchdog")); + break; + case VIR_DOMAIN_DEVICE_CONTROLLER: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support controller")); + break; + case VIR_DOMAIN_DEVICE_GRAPHICS: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support graphics")); + break; + case VIR_DOMAIN_DEVICE_HUB: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support hub")); + break; + case VIR_DOMAIN_DEVICE_REDIRDEV: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support redirdev")); + break; + case VIR_DOMAIN_DEVICE_SMARTCARD: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support smartcard")); + break; + case VIR_DOMAIN_DEVICE_CHR: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support chr")); + break; + case VIR_DOMAIN_DEVICE_MEMBALLOON: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support memballoon")); + break; + case VIR_DOMAIN_DEVICE_NVRAM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support nvram")); + break; + case VIR_DOMAIN_DEVICE_RNG: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support rng")); + break; + case VIR_DOMAIN_DEVICE_SHMEM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support shmem")); + break; + case VIR_DOMAIN_DEVICE_TPM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support tpm")); + break; + case VIR_DOMAIN_DEVICE_PANIC: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support panic")); + break; + case VIR_DOMAIN_DEVICE_MEMORY: + ret =3D 0; + break; + case VIR_DOMAIN_DEVICE_IOMMU: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support iommu")); + break; + case VIR_DOMAIN_DEVICE_VSOCK: + ret =3D 0; + break; + case VIR_DOMAIN_DEVICE_AUDIO: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Cloud-Hypervisor doesn't support audio")); + break; + case VIR_DOMAIN_DEVICE_NONE: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unexpected VIR_DOMAIN_DEVICE_NONE")); + break; + + case VIR_DOMAIN_DEVICE_LAST: + default: + virReportEnumRangeError(virDomainDeviceType, dev->type); + break; + } + + return ret; +} + virDomainDefParserConfig virCHDriverDomainDefParserConfig =3D { .domainPostParseBasicCallback =3D virCHDomainDefPostParseBasic, .domainPostParseCallback =3D virCHDomainDefPostParse, + .devicesPostParseCallback =3D virCHDomainDeviceDefPostParse, }; diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 87520a2639..1648d05017 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -359,125 +359,6 @@ virCHMonitorBuildNetsJson(virJSONValue *content, virD= omainDef *vmdef) return -1; } =20 -static int -virCHMonitorDetectUnsupportedDevices(virDomainDef *vmdef) -{ - int ret =3D 0; - - if (vmdef->ngraphics > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support graphics")); - ret =3D 1; - } - if (vmdef->ncontrollers > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support controllers")); - ret =3D 1; - } - if (vmdef->nfss > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support fss")); - ret =3D 1; - } - if (vmdef->ninputs > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support inputs")); - ret =3D 1; - } - if (vmdef->nsounds > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support sounds")); - ret =3D 1; - } - if (vmdef->naudios > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support audios")); - ret =3D 1; - } - if (vmdef->nvideos > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support videos")); - ret =3D 1; - } - if (vmdef->nhostdevs > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support hostdevs")); - ret =3D 1; - } - if (vmdef->nredirdevs > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support redirdevs")); - ret =3D 1; - } - if (vmdef->nsmartcards > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support smartcards")); - ret =3D 1; - } - if (vmdef->nserials > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support serials")); - ret =3D 1; - } - if (vmdef->nparallels > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support parallels")); - ret =3D 1; - } - if (vmdef->nchannels > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support channels")); - ret =3D 1; - } - if (vmdef->nconsoles > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support consoles")); - ret =3D 1; - } - if (vmdef->nleases > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support leases")); - ret =3D 1; - } - if (vmdef->nhubs > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support hubs")); - ret =3D 1; - } - if (vmdef->nseclabels > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support seclabels")); - ret =3D 1; - } - if (vmdef->nrngs > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support rngs")); - ret =3D 1; - } - if (vmdef->nshmems > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support shmems")); - ret =3D 1; - } - if (vmdef->nmems > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support mems")); - ret =3D 1; - } - if (vmdef->npanics > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support panics")); - ret =3D 1; - } - if (vmdef->nsysinfo > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Cloud-Hypervisor doesn't support sysinfo")); - ret =3D 1; - } - - return ret; -} - static int virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jsonstr) { @@ -490,9 +371,6 @@ virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jso= nstr) goto cleanup; } =20 - if (virCHMonitorDetectUnsupportedDevices(vmdef)) - goto cleanup; - if (virCHMonitorBuildCPUJson(content, vmdef) < 0) goto cleanup; =20 --=20 2.31.1