From nobody Mon May 6 12:53:41 2024 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=1611842317; cv=none; d=zohomail.com; s=zohoarc; b=JipaRj4KYctlZpFfkdNhVCRe5keqFZsjemguncJnonHP+WYH/PJIVNlRry11pDuQq87i2/C/WMi7pzrJp/zs1/dEOVdi2VCexEN4JjyX3rnKgkhyNN8TKEtLeQ1+V/+n6iAQ5Gtj6nfL92zLioK1rey/cP62Oev1199vdJQHHuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611842317; 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=7swQ2AZvS8NUAy650tRobi4tnS2kN2Qtj1y9JSmXveg=; b=mGED5W1I1NG6PULIT7tt+a9/NpBCvVewJ9ZtCcNUJgbzkL0ykEFVxRW4YGAcZXalThuluxEbAhMgr9sQ09EWWfj+Fv/160QYg75JyObym0YLMH2uuNfXFUQJxu1gmBKaNknkIJ+8oC/wfV3KkWgxPFpam30G9buaKf/D5BMH7iw= 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 1611842317416691.2251373871323; Thu, 28 Jan 2021 05:58:37 -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-278-hBG2kPqHO8qjixRPQ337qQ-1; Thu, 28 Jan 2021 08:58:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3014802B46; Thu, 28 Jan 2021 13:58:28 +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 426035D9EF; Thu, 28 Jan 2021 13:58:28 +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 096EC4BB40; Thu, 28 Jan 2021 13:58:25 +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 10SDwMEL020453 for ; Thu, 28 Jan 2021 08:58:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7F26D5D769; Thu, 28 Jan 2021 13:58:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0DEB5D743 for ; Thu, 28 Jan 2021 13:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611842316; 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=7swQ2AZvS8NUAy650tRobi4tnS2kN2Qtj1y9JSmXveg=; b=DIa5wY96cajiMaWRzT2iK70ZiHJT3PK7acvfax0edxkDTxx99bGu1jQXFdnm4Y1yiVMIdr gpMKrq7fikvr+4HZm7EWHSPd8AdNIZg0n1u5sLPy6rWCsoOtFzmeEtVZWtW5z68lBhZXir NMKMxRPZuZZ1cFxqZFu6uXavAgYhvlQ= X-MC-Unique: hBG2kPqHO8qjixRPQ337qQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] conf: Move virDomainCheckVirtioOptions() into domain_validate.c Date: Thu, 28 Jan 2021 14:58:13 +0100 Message-Id: <8d44cadad8032a88c11137859d813ba5ad8e5ec5.1611842225.git.mprivozn@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 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.14 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 of virDomainCheckVirtioOptions() function is to check whether no virtio options are set, i.e. no @iommu no @ats and no @packed attributes were present in given device's XML (yeah, the function has very misleading name). Nevertheless, this kind of check belongs to validation phase, but now is done in post parse phase. Move the function and its calls to domain_validate.c so that future code is not tempted to repeat this mistake. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 40 +-------------------------- src/conf/domain_validate.c | 55 +++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dab4f10326..69ebd5d66d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5132,34 +5132,6 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr = dev, } =20 =20 -static int -virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio) -{ - if (!virtio) - return 0; - - if (virtio->iommu !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("iommu driver option is only supported " - "for virtio devices")); - return -1; - } - if (virtio->ats !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("ats driver option is only supported " - "for virtio devices")); - return -1; - } - if (virtio->packed !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("packed driver option is only supported " - "for virtio devices")); - return -1; - } - return 0; -} - - static void virDomainChrDefPostParse(virDomainChrDefPtr chr, const virDomainDef *def) @@ -5256,11 +5228,6 @@ virDomainDiskDefPostParse(virDomainDiskDefPtr disk, virDomainPostParseCheckISCSIPath(&disk->src->path); } =20 - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && - virDomainCheckVirtioOptions(disk->virtio) < 0) { - return -1; - } - if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { if (disk->src->nvme->managed =3D=3D VIR_TRISTATE_BOOL_ABSENT) disk->src->nvme->managed =3D VIR_TRISTATE_BOOL_YES; @@ -5310,13 +5277,8 @@ virDomainControllerDefPostParse(virDomainControllerD= efPtr cdev) =20 =20 static int -virDomainNetDefPostParse(virDomainNetDefPtr net) +virDomainNetDefPostParse(virDomainNetDefPtr net G_GNUC_UNUSED) { - if (!virDomainNetIsVirtioModel(net) && - virDomainCheckVirtioOptions(net->virtio) < 0) { - return -1; - } - return 0; } =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 649fc335ac..37c09ff648 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -226,6 +226,34 @@ virSecurityDeviceLabelDefValidate(virSecurityDeviceLab= elDefPtr *seclabels, } =20 =20 +static int +virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio) +{ + if (!virtio) + return 0; + + if (virtio->iommu !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("iommu driver option is only supported " + "for virtio devices")); + return -1; + } + if (virtio->ats !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ats driver option is only supported " + "for virtio devices")); + return -1; + } + if (virtio->packed !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("packed driver option is only supported " + "for virtio devices")); + return -1; + } + return 0; +} + + #define VENDOR_LEN 8 #define PRODUCT_LEN 16 =20 @@ -277,15 +305,19 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } =20 - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && - (disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO || - disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || - disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL)= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk model '%s' not supported for bus '%s'"), - virDomainDiskModelTypeToString(disk->model), - virDomainDiskBusTypeToString(disk->bus)); - return -1; + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { + if (disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO || + disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || + disk->model =3D=3D VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITION= AL) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk model '%s' not supported for bus '%s'"), + virDomainDiskModelTypeToString(disk->model), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + + if (virDomainCheckVirtioOptions(disk->virtio) < 0) + return -1; } =20 if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { @@ -1330,6 +1362,11 @@ virDomainNetDefValidate(const virDomainNetDef *net) return -1; } =20 + if (!virDomainNetIsVirtioModel(net) && + virDomainCheckVirtioOptions(net->virtio) < 0) { + return -1; + } + return 0; } =20 --=20 2.26.2 From nobody Mon May 6 12:53:41 2024 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=1611842322; cv=none; d=zohomail.com; s=zohoarc; b=ANoCXN6t3zgWCCK1n3qPy+i+V1E55LIVDu4PqWHU1qetSnGWJFymf1w+FZeoInla6W/vpjG5aiqxe7fG2IDnzPlzZ1ywrKIhcQZqV0+tzl/oOsdIVGaAACQOkPQRJE6Grv201H1zHExwaHo8WESDBYRX6SQ9dTDtDPEF6CtScVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611842322; 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=UfJ8Qfd5P0ql/3nF3B7svTlRs9Ge6bON7TQzIaA6SJ8=; b=FmUPsu9iQMDo55JvlsaaWaSdi1MRnCg8jap3LaZdnJkwB1ZRGqOf4Upw1dL/SB/PCMo1jVrqAOD2I8rL/OTli5JOtqa97rUQcJpjnBFTWW6yyzDy7bvI/AGStyYnfoYufJpYlzFv7PvQ2dj/lakrmKexVkfSLvFfGwWzW4mYbBE= 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 1611842322775661.0127286151774; Thu, 28 Jan 2021 05:58:42 -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-487-FtWozPvSPKGlBs1vYhxiqw-1; Thu, 28 Jan 2021 08:58:35 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0BD3107ACE4; Thu, 28 Jan 2021 13:58:28 +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 A2F0A1971B; Thu, 28 Jan 2021 13:58:28 +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 690781809CA0; Thu, 28 Jan 2021 13:58:26 +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 10SDwNaM020460 for ; Thu, 28 Jan 2021 08:58:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5BB515D743; Thu, 28 Jan 2021 13:58:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id D15A25D769 for ; Thu, 28 Jan 2021 13:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611842317; 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=UfJ8Qfd5P0ql/3nF3B7svTlRs9Ge6bON7TQzIaA6SJ8=; b=bxCZVOzRBUUTMhM6m2rkUDFaVoNRavqJU6JORgOW5SPaQF5Z7Nj5q+1mA7poDCI1pt6XNC TKYKbWSS00FuUDWXbUUTC8t+2TRBGD5yNmPJhO6lZZWDr9ZtFGz6GIXdMBY5NaMftQNSiR 7AuISAILwWP+Saga2l/ZG5I/PrbHmFo= X-MC-Unique: FtWozPvSPKGlBs1vYhxiqw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] conf: Drop empty virDomainNetDefPostParse() Date: Thu, 28 Jan 2021 14:58:14 +0100 Message-Id: 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 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.84 on 10.5.11.23 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 previous commit rendered this function empty and needless. Remove it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69ebd5d66d..6e90b8e180 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5276,13 +5276,6 @@ virDomainControllerDefPostParse(virDomainControllerD= efPtr cdev) } =20 =20 -static int -virDomainNetDefPostParse(virDomainNetDefPtr net G_GNUC_UNUSED) -{ - return 0; -} - - static void virDomainVsockDefPostParse(virDomainVsockDefPtr vsock) { @@ -5367,10 +5360,6 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef= Ptr dev, ret =3D virDomainControllerDefPostParse(dev->data.controller); break; =20 - case VIR_DOMAIN_DEVICE_NET: - ret =3D virDomainNetDefPostParse(dev->data.net); - break; - case VIR_DOMAIN_DEVICE_VSOCK: virDomainVsockDefPostParse(dev->data.vsock); ret =3D 0; @@ -5382,6 +5371,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefP= tr dev, =20 case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_WATCHDOG: --=20 2.26.2 From nobody Mon May 6 12:53:41 2024 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=1611842331; cv=none; d=zohomail.com; s=zohoarc; b=mdOUVqbkMKrCXDm/iY5VQoFYf4DvfgbMzn9HWg5NdJas9DXgYI7kenORFxktlgqxfzXXdk7u/rlreiEsOu4cA+sF1+ZVdj2TsfNGfKfypQJRbR8J0WXL9M/GLnSWYE2704gop8XzEQUGz3KYgGZ5jLc4Vu/epQC3qu8oajGqRWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611842331; 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=4eWMB8aZDQlu4/oeOUA0YoZDmZwsaFsnMM+to7bPE/4=; b=U4Mw+lhjZTR+CgldONKK6IHSP6FA1QbaXlT4/yVIAX2COOV4p6s3AUfz+/YhPTV13cI/sGBrV0bnYnlVPxppUJDpPqorXoXOly++e1EfLXaRKxBOVw4NHik886ZnMKzUJYA9XfScByXzJTadXKS7nmFCpTgc73bHfseQatfN/tU= 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 1611842331976247.77070654130193; Thu, 28 Jan 2021 05:58:51 -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-537-YQt7YZLaM7C-XnjvyArvxg-1; Thu, 28 Jan 2021 08:58:49 -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 07B4C180A0A0; Thu, 28 Jan 2021 13:58:43 +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 D97A2179B3; Thu, 28 Jan 2021 13:58:42 +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 A23FF1809CA5; Thu, 28 Jan 2021 13:58:42 +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 10SDwOuj020471 for ; Thu, 28 Jan 2021 08:58:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3761E5D769; Thu, 28 Jan 2021 13:58:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD0615D743 for ; Thu, 28 Jan 2021 13:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611842331; 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=4eWMB8aZDQlu4/oeOUA0YoZDmZwsaFsnMM+to7bPE/4=; b=ftI1C3dmdHNXwZVESA51LG1qGP0Urm6sinTzi07tkkzye0bm+f4gP5MxFAtG7qx6MFOkta /MyPg3KDZ6l99JY+yNMNdI8SGw4KMHFrSlAC/JBj4hWLJQONrpdLN2c3uhm0KnmWWCooeX 2LoqO9xH170RagnyVdIgGXI++NJX1uA= X-MC-Unique: YQt7YZLaM7C-XnjvyArvxg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] conf: Improve virDomainVirtioOptionsCheckABIStability() Date: Thu, 28 Jan 2021 14:58:15 +0100 Message-Id: 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 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" The virDomainVirtioOptionsCheckABIStability() function is called from various ABI stability check functions. Every caller checks if both old and new definitions have virtio options set and only after that they call the function. This is suboptimal because: a) this check can be done in the function itself (making all callers shorter), b) is inherently wrong, because it doesn't catch case where one definition has virtio options set and the other doesn't. Do proper checks at the beginning of the function and simplify its calls. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6e90b8e180..905f8f0691 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21533,6 +21533,15 @@ static bool virDomainVirtioOptionsCheckABIStability(virDomainVirtioOptionsPtr src, virDomainVirtioOptionsPtr dst) { + if (!src && !dst) + return true; + + if (!src || !dst) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target device virtio options don't match the sou= rce")); + return false; + } + if (src->iommu !=3D dst->iommu) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target device iommu option '%s' does not " @@ -21617,8 +21626,7 @@ virDomainDiskDefCheckABIStability(virDomainDiskDefP= tr src, return false; } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21677,8 +21685,7 @@ virDomainControllerDefCheckABIStability(virDomainCo= ntrollerDefPtr src, } } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21711,8 +21718,7 @@ virDomainFsDefCheckABIStability(virDomainFSDefPtr s= rc, return false; } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21760,8 +21766,7 @@ virDomainNetDefCheckABIStability(virDomainNetDefPtr= src, return false; } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21799,8 +21804,7 @@ virDomainInputDefCheckABIStability(virDomainInputDe= fPtr src, return false; } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21899,8 +21903,7 @@ virDomainVideoDefCheckABIStability(virDomainVideoDe= fPtr src, } } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -22113,8 +22116,7 @@ virDomainMemballoonDefCheckABIStability(virDomainMe= mballoonDefPtr src, return false; } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -22136,8 +22138,7 @@ virDomainRNGDefCheckABIStability(virDomainRNGDefPtr= src, return false; } =20 - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; =20 if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) --=20 2.26.2