From nobody Mon Feb 9 00:27:06 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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=1666621009; cv=none; d=zohomail.com; s=zohoarc; b=S0jxsVxDBfo6wqAMnEJrSKKys/gJG64sqTgumeESFE2eT2nBgmzLm6bS4tWsbaowuKbpBnrk/TmVr0JtdpxBjkoOT7T+17kBHj7PNNVRpDPhTL/ko1Sfazar3KOsJox+s2hvKd3cUZ2uXrMA+R5eOymoq+KiUu0ZBFh4Zzy6uXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621009; 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=mcQ5aYgdLg61CSyuFljTaOHcrbjplAVJchF0aRy8Adc=; b=cbE/9v7qp2oSzaiy2gAsrcFMFhPYv7/1xJWtG79HC5QLMCIJtNKSxP6Cao5KzLIL7WGwt9vyK0DNsPEKC7LMroNBWZu0JlDsW6uEtVGqyiWcAMAOfrDG2uG24s5XIIaOeoTsn3r9XUinojh4B7PZCU59OtDPiEPCRg/5xqMyhGQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 166662100983784.17118400561299; Mon, 24 Oct 2022 07:16:49 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-cJbA71ZJO-mw9Q75z5mGpA-1; Mon, 24 Oct 2022 10:16:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22C0A80253E; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CDFD1415117; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E5A7E1946594; Mon, 24 Oct 2022 14:15:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0D035194658D for ; Mon, 24 Oct 2022 14:15:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0081940C2140; Mon, 24 Oct 2022 14:15:48 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24FE840C2064 for ; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621007; 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=mcQ5aYgdLg61CSyuFljTaOHcrbjplAVJchF0aRy8Adc=; b=OuIcgIFE6X5lHmawsSvt0QfBYZzdYhiQYQ9FFbzMijj4yFvDQukcVS/2KQ57Ar1SVnqKRr Q2k5ujzX69/jlODPWR+86U2eNw90yuxz/KPtA8hbsI5/0RYRHezzRzZbepjLzhelvDuPDd Fcqd/HhXNnhDfs0VpjBf92D21R0Dx9g= X-MC-Unique: cJbA71ZJO-mw9Q75z5mGpA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/43] virDomainTimerDef: Convert 'mode' field to proper enum type Date: Mon, 24 Oct 2022 16:14:40 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666621010640100005 Content-Type: text/plain; charset="utf-8" Adjust the parser and switch statements to go with it. Note that the XEN/libxl drivers had a 'default:' case for few of the swtich statements so this patch blindly expands it to what it would be in those cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 +++--------- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 6 +++++- src/libxl/xen_common.c | 6 +++++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d91c058868..6c976b366a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; - g_autofree char *mode =3D NULL; ctxt->node =3D node; @@ -10577,14 +10576,9 @@ virDomainTimerDefParseXML(xmlNodePtr node, return NULL; } - mode =3D virXMLPropString(node, "mode"); - if (mode !=3D NULL) { - if ((def->mode =3D virDomainTimerModeTypeFromString(mode)) <=3D 0)= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown timer mode '%s'"), mode); - return NULL; - } - } + if (virXMLPropEnum(node, "mode", virDomainTimerModeTypeFromString, + VIR_XML_PROP_NONZERO, &def->mode) < 0) + return NULL; catchup =3D virXPathNode("./catchup", ctxt); if (catchup !=3D NULL) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 36b6757c3c..f5825138e7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2483,7 +2483,7 @@ struct _virDomainTimerDef { /* frequency & mode are only valid for name=3D'tsc' */ unsigned long long frequency; /* in Hz, unspecified =3D 0 */ - int mode; /* enum virDomainTimerModeType */ + virDomainTimerModeType mode; }; typedef enum { diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 918303c8d0..d13e48abb2 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -409,8 +409,12 @@ libxlMakeDomBuildInfo(virDomainDef *def, case VIR_DOMAIN_TIMER_MODE_EMULATE: b_info->tsc_mode =3D LIBXL_TSC_MODE_ALWAYS_EMULATE; break; - default: + case VIR_DOMAIN_TIMER_MODE_NONE: + case VIR_DOMAIN_TIMER_MODE_AUTO: + case VIR_DOMAIN_TIMER_MODE_SMPSAFE: b_info->tsc_mode =3D LIBXL_TSC_MODE_DEFAULT; + case VIR_DOMAIN_TIMER_MODE_LAST: + break; } break; diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 6918a4b121..f61719adac 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -2102,9 +2102,13 @@ xenFormatHypervisorFeatures(virConf *conf, virDomain= Def *def) if (xenConfigSetString(conf, "tsc_mode", "always_emulate")= < 0) return -1; break; - default: + case VIR_DOMAIN_TIMER_MODE_NONE: + case VIR_DOMAIN_TIMER_MODE_AUTO: + case VIR_DOMAIN_TIMER_MODE_SMPSAFE: if (xenConfigSetString(conf, "tsc_mode", "default") < 0) return -1; + case VIR_DOMAIN_TIMER_MODE_LAST: + break; } break; --=20 2.37.3