From nobody Fri Apr 26 02:38:49 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=1633683724; cv=none; d=zohomail.com; s=zohoarc; b=Eh1YKrc/aGJ7nWhYUnOa6bXxelJ21ffvpGBWjZXKqOp07GGfbh+0AO7l0OLCsckFdHds3qsWs3YAlwmZqeOuqherNGdI4bm7L6v9XuFrJqT8Rkkkf15mSZAKpIDbqMmSyjKXhxm5h259ydxs4HPrVrwyWzXr3tfoXSVCFM2PRQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633683724; 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=20eZoAs9gL4BNHFOgkX3BMMBx/fC6mGPBqRq34YyhnQ=; b=kUkASDreutdD9Xs8b1yUuLhv17nPwiCqOGlPkixOKWMg3hG/jc6djdysdYLmiLbocTfgwwFSQcNT9JR9Te0ypTzZZ5BF9UNEuRsxvPSLQJS919FfBEu/FhAZt+PzmJi7G5Mfth3Zb8kDMtU9teVpTshV597FZT2PHuPe9Y2Paqk= 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) 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 163368372433486.73780288877299; Fri, 8 Oct 2021 02:02:04 -0700 (PDT) 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-333-XMpq5h8nNdyo1uER9dfgig-1; Fri, 08 Oct 2021 05:02:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C80451023F51; Fri, 8 Oct 2021 09:01:56 +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 6E1C560C2B; Fri, 8 Oct 2021 09:01:56 +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 88DCE4EA29; Fri, 8 Oct 2021 09:01:55 +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 19891rb2001611 for ; Fri, 8 Oct 2021 05:01:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id D677E10013C1; Fri, 8 Oct 2021 09:01:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.195.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40A7310016FF; Fri, 8 Oct 2021 09:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633683723; 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=20eZoAs9gL4BNHFOgkX3BMMBx/fC6mGPBqRq34YyhnQ=; b=VNDz7R0xZsKpi3P08mw5O3V+ZdjfA1S8h5Mi+siDMYuZThn8YHXuX/xMxpXP33aTd2aevp l+/2kA2aJ34U1wqU4PyNPAysWp506/KLn9fpJtWRoywHNa0ereGfHDD1ackmgEwqfdvkPD J3E77hN14Um5Hn/bZFxwpn9DjQ2z04M= X-MC-Unique: XMpq5h8nNdyo1uER9dfgig-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v3 4/6] qemu: inline the qemuBuildCpuFeature code Date: Fri, 8 Oct 2021 10:01:43 +0100 Message-Id: <20211008090145.4169737-5-berrange@redhat.com> In-Reply-To: <20211008090145.4169737-1-berrange@redhat.com> References: <20211008090145.4169737-1-berrange@redhat.com> 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.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633683726587100001 With the previous refactorings, there's no real benefit from the qemuBuildCpuFeature helper method. Only one of the callers really needs the CPU feature name re-writing logic, the others can just use the right name directly. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Jiri Denemark --- src/qemu/qemu_command.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 92125dbc85..f24c8842aa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6292,18 +6292,6 @@ qemuBuildGlobalControllerCommandLine(virCommand *cmd, } =20 =20 -static void -qemuBuildCpuFeature(virQEMUCaps *qemuCaps, - virBuffer *buf, - const char *name, - bool state) -{ - name =3D virQEMUCapsCPUFeatureToQEMU(qemuCaps, name); - - virBufferAsprintf(buf, ",%s=3D%s", name, state ? "on" : "off"); -} - - static int qemuBuildCpuModelArgStr(virQEMUDriver *driver, const virDomainDef *def, @@ -6376,15 +6364,17 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver, virBufferAsprintf(buf, ",vendor=3D%s", cpu->vendor_id); =20 for (i =3D 0; i < cpu->nfeatures; i++) { + const char *featname =3D virQEMUCapsCPUFeatureToQEMU( + qemuCaps, cpu->features[i].name); switch ((virCPUFeaturePolicy) cpu->features[i].policy) { case VIR_CPU_FEATURE_FORCE: case VIR_CPU_FEATURE_REQUIRE: - qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, true= ); + virBufferAsprintf(buf, ",%s=3Don", featname); break; =20 case VIR_CPU_FEATURE_DISABLE: case VIR_CPU_FEATURE_FORBID: - qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, fals= e); + virBufferAsprintf(buf, ",%s=3Doff", featname); break; =20 case VIR_CPU_FEATURE_OPTIONAL: @@ -6441,8 +6431,8 @@ qemuBuildCpuCommandLine(virCommand *cmd, switch ((virDomainTimerNameType)timer->name) { case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: if (timer->present !=3D -1) { - qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock", - !!timer->present); + virBufferAsprintf(&buf, ",kvmclock=3D%s", + timer->present ? "on" : "off"); } break; case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: @@ -6480,13 +6470,14 @@ qemuBuildCpuCommandLine(virCommand *cmd, } =20 if (def->apic_eoi) { - qemuBuildCpuFeature(qemuCaps, &buf, "kvm_pv_eoi", - def->apic_eoi =3D=3D VIR_TRISTATE_SWITCH_ON); + virBufferAsprintf(&buf, ",kvm-pv-eoi=3D%s", def->apic_eoi =3D=3D + VIR_TRISTATE_SWITCH_ON ? "on" : "off"); } =20 if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) { - qemuBuildCpuFeature(qemuCaps, &buf, VIR_CPU_x86_KVM_PV_UNHALT, - def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] = =3D=3D VIR_TRISTATE_SWITCH_ON); + virBufferAsprintf(&buf, ",kvm-pv-unhalt=3D%s", + def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] =3D= =3D + VIR_TRISTATE_SWITCH_ON ? "on" : "off"); } =20 if (def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D=3D VIR_TRISTATE_SWITC= H_ON) { --=20 2.31.1