From nobody Mon Feb 9 12:15:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559057384; cv=none; d=zoho.com; s=zohoarc; b=H++zzCOKUZg+65FLkTgCJtf5789NcPOLuhmVerjEKS4JllRsiJdpeIIhMkPKz07MFAKdZwMzG+WZOVwVpxhjuPp6GBS7p/7qjaHIvFa50wWtkQ70hLpmLaiVzgwrZbBGBKxvnKqxPTywvSxCJId6bzz2AVJuLanEL292KYC+ikM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559057384; 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:ARC-Authentication-Results; bh=UgOvFv5Q/ehDY8IFebfzfnkyFBQg8Q7bbr3ZOU5Nclk=; b=Is+miVf590Tnh6/sXqnn5WhLJri1XMxlDBxQWkMfmViOczPOXJRBRpvVsRQeaClbAjo1U/imv+3E0JSdWo43rl93jDJ18PoVaVDqoKr57/7zVUpMOul77iEG3qibOJedP9xS8ECG0qfghweLubDkqL/lYMQLspMA/U4yjUxEEec= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155905738474545.061302060533876; Tue, 28 May 2019 08:29:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD80B3087958; Tue, 28 May 2019 15:29:36 +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 88B14100203C; Tue, 28 May 2019 15:29:26 +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 8CE9C1833001; Tue, 28 May 2019 15:29:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4SFTCJA015562 for ; Tue, 28 May 2019 11:29:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7ACFD5C1B5; Tue, 28 May 2019 15:29:12 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F27FDBF9F8 for ; Tue, 28 May 2019 15:29:11 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 28 May 2019 17:28:54 +0200 Message-Id: <20190528152904.25650-2-abologna@redhat.com> In-Reply-To: <20190528152904.25650-1-abologna@redhat.com> References: <20190528152904.25650-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/11] qemu: Fix switch() statements for virDomainIOMMUModel 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 28 May 2019 15:29:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Ensure unexpected values are dealt with correctly, that is by invoking virReportEnumRangeError() and immediately returning a negative value to the caller. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 10 ++++++++-- src/qemu/qemu_domain.c | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5bf6c704e0..fcc6caf42f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6961,8 +6961,12 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd, virBufferAsprintf(&opts, ",device-iotlb=3D%s", virTristateSwitchTypeToString(iommu->iotlb)); } - case VIR_DOMAIN_IOMMU_MODEL_LAST: break; + + case VIR_DOMAIN_IOMMU_MODEL_LAST: + default: + virReportEnumRangeError(virDomainIOMMUModel, iommu->model); + return -1; } virCommandAddArg(cmd, "-device"); virCommandAddArgBuffer(cmd, &opts); @@ -7609,7 +7613,9 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, virBufferAddLit(&buf, ",iommu=3Don"); break; case VIR_DOMAIN_IOMMU_MODEL_LAST: - break; + default: + virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model= ); + return -1; } } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e50e84a3b2..366ebe1604 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6138,6 +6138,7 @@ qemuDomainDeviceDefValidateIOMMU(const virDomainIOMMU= Def *iommu, case VIR_DOMAIN_IOMMU_MODEL_LAST: default: virReportEnumRangeError(virDomainIOMMUModel, iommu->model); + return -1; } =20 return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list