From nobody Mon Feb 9 10:28:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1581085650719644.9731385126204; Fri, 7 Feb 2020 06:27:30 -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-292-o0Cohju1P9-YgS5qHXQR2Q-1; Fri, 07 Feb 2020 09:27:25 -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 1AD48106BBDE; Fri, 7 Feb 2020 14:27:20 +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 3BEBA790E5; Fri, 7 Feb 2020 14:27:19 +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 40AD318089CE; Fri, 7 Feb 2020 14:27:18 +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 017ERG0e004467 for ; Fri, 7 Feb 2020 09:27:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id F16D75C28C; Fri, 7 Feb 2020 14:27:16 +0000 (UTC) Received: from kinshicho.usersys.redhat.com (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77ED55C299 for ; Fri, 7 Feb 2020 14:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581085647; 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=jAySZaAjjurLDvaRKOiWylKgIPOukswSJ3N8/PJavws=; b=NQQ+Umxk9a2tomjzMZ1VV7k9+GM7PK8lTnCwyfPicMEDjPmjzxrZlxFbaaE44fHzvBveLo q3qHfdMSzcwO2Aj3uCskKmN4A1BYPc872oeSslTubkQLfbhd8mwDQRxjgNdpai1F+Up9pE QwCbTCcy4T4+UeDXcI6THTPeZOEndk8= From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/8] qemu: Use switch statement in qemuBuildCpuCommandLine() Date: Fri, 7 Feb 2020 15:27:01 +0100 Message-Id: <20200207142708.6315-2-abologna@redhat.com> In-Reply-To: <20200207142708.6315-1-abologna@redhat.com> References: <20200207142708.6315-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 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 X-MC-Unique: o0Cohju1P9-YgS5qHXQR2Q-1 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 sure we are taking all possible virDomainTimerNameType values into account. This will make upcoming changes easier. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko Reviewed-by: Masayoshi Mizuma --- src/qemu/qemu_command.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0dbd78124b..52a74c7acf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6594,16 +6594,30 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, for (i =3D 0; i < def->clock.ntimers; i++) { virDomainTimerDefPtr timer =3D def->clock.timers[i]; =20 - if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_KVMCLOCK && - timer->present !=3D -1) { - qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock", - !!timer->present); - } else if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK && - timer->present =3D=3D 1) { - virBufferAddLit(&buf, ",hv-time"); - } else if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC && - timer->frequency > 0) { - virBufferAsprintf(&buf, ",tsc-frequency=3D%lu", timer->frequen= cy); + switch ((virDomainTimerNameType)timer->name) { + case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: + if (timer->present !=3D -1) { + qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock", + !!timer->present); + } + break; + case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: + if (timer->present =3D=3D 1) + virBufferAddLit(&buf, ",hv-time"); + break; + case VIR_DOMAIN_TIMER_NAME_TSC: + if (timer->frequency > 0) + virBufferAsprintf(&buf, ",tsc-frequency=3D%lu", timer->fre= quency); + break; + case VIR_DOMAIN_TIMER_NAME_PLATFORM: + case VIR_DOMAIN_TIMER_NAME_PIT: + case VIR_DOMAIN_TIMER_NAME_RTC: + case VIR_DOMAIN_TIMER_NAME_HPET: + break; + case VIR_DOMAIN_TIMER_NAME_LAST: + default: + virReportEnumRangeError(virDomainTimerNameType, timer->name); + return -1; } } =20 --=20 2.24.1