From nobody Sun Feb 8 14:22:26 2026 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=1605901167; cv=none; d=zohomail.com; s=zohoarc; b=dhQH/D2tVpu3Nudzn+njKsAFmIUmZOnOrSE/ixq+jiEwLf1nvKLleVd+GRs7HP2vsvGeS1QJvAderD4DKpMs8qFvdciP3h/zcvwAWdSa4k/A10esTjNKD1Md3I1APP2AAtVasyxn3hsh3VCZJLj3HHKY3WRsQ5K489TLfl8ZkdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605901167; 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=8Y1g/8k+3tdTPfmsSbxbxjPysFQlnJV3lHwYwd/H/FQ=; b=TYsI10DuxP39T8TeP98kBonZXdeZkCG+JbOx2nheyD5oWs0j3qWDqi4sQzX4GyIySPa1CJNWEPMx/fxQeai/aQ081KjTpmC10bYEFWrjeAaV8EbQzmyXPxdhHCI0I/ONpXd3GuIl2oEYeL4MKvHth/EtbjPN2SEAb88caq0f8r4= 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 1605901167008573.4551566601683; Fri, 20 Nov 2020 11:39:27 -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-19-FcQfLXjTOl-_yXcWZsYiZg-1; Fri, 20 Nov 2020 14:39:23 -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 C1F641868412; Fri, 20 Nov 2020 19:39:17 +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 9F4345D6AD; Fri, 20 Nov 2020 19:39:17 +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 09E031809CA0; Fri, 20 Nov 2020 19:39:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AKJdCu1023243 for ; Fri, 20 Nov 2020 14:39:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7413710023AD; Fri, 20 Nov 2020 19:39:12 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46C8C10023AC for ; Fri, 20 Nov 2020 19:39:09 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id DF8F92437EF; Fri, 20 Nov 2020 20:39:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605901166; 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=8Y1g/8k+3tdTPfmsSbxbxjPysFQlnJV3lHwYwd/H/FQ=; b=dIEpk0ByGTmtV7dePku1XaI7hnZivKeGXPilO+EzPO/6AGn3xMxNXV3nWVZjoIf9TZsmXV PqVQgNg52jo1HaGvxzI79mH/DTeQAO9il1ujeGfLn08/3BHhCiSM0a8nbvJO2QDaAXjaMv is1RvigDHrfFsfMJhAo4shheIdBlbWM= X-MC-Unique: FcQfLXjTOl-_yXcWZsYiZg-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/8] conf: Use enum in virCPUDefAddFeatureInternal Date: Fri, 20 Nov 2020 20:39:01 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 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" Replace the 'update' bool parameter with an enum so that we can have more than two possible values. Signed-off-by: Jiri Denemark --- src/conf/cpu_conf.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 55a7925d8a..2367d36c32 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -857,11 +857,17 @@ virCPUDefFormatBuf(virBufferPtr buf, return 0; } =20 + +typedef enum { + VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE, /* Fail if feature exists */ + VIR_CPU_ADD_FEATURE_MODE_UPDATE, /* Add feature or update policy */ +} virCPUDefAddFeatureMode; + static int virCPUDefAddFeatureInternal(virCPUDefPtr def, const char *name, int policy, - bool update) + virCPUDefAddFeatureMode mode) { virCPUFeatureDefPtr feat; =20 @@ -869,16 +875,18 @@ virCPUDefAddFeatureInternal(virCPUDefPtr def, policy =3D -1; =20 if ((feat =3D virCPUDefFindFeature(def, name))) { - if (update) { + switch (mode) { + case VIR_CPU_ADD_FEATURE_MODE_UPDATE: feat->policy =3D policy; return 0; - } - - virReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU feature '%s' specified more than once"), - name); =20 - return -1; + case VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE: + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU feature '%s' specified more than once"), + name); + return -1; + } } =20 if (VIR_RESIZE_N(def->features, def->nfeatures_max, @@ -898,7 +906,8 @@ virCPUDefUpdateFeature(virCPUDefPtr def, const char *name, int policy) { - return virCPUDefAddFeatureInternal(def, name, policy, true); + return virCPUDefAddFeatureInternal(def, name, policy, + VIR_CPU_ADD_FEATURE_MODE_UPDATE); } =20 int @@ -906,7 +915,8 @@ virCPUDefAddFeature(virCPUDefPtr def, const char *name, int policy) { - return virCPUDefAddFeatureInternal(def, name, policy, false); + return virCPUDefAddFeatureInternal(def, name, policy, + VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE); } =20 =20 --=20 2.29.2