From nobody Mon May 20 02:17:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1599490161; cv=none; d=zohomail.com; s=zohoarc; b=kdW4FkOhtyCBL99VDvKqSkooAdQHZNDek1sfgTqM0f1KDgNYr90Wb3glJpH2u4Cayrd2IVuQk+M5Q74UgLZBlcen7Tl0ullP2j4ToOyWBE/4Mz6he8SPyZMsmMc3iot3b1um3MVqKcHCnR2ZcXD1qlEuPq0Q0/BQ9SLAH+t5dBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599490161; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ADJ1y7W9f0r21oSAQKgsIcKVe2msgxrhjhOvvoCXKjA=; b=KdhIjqnFoqMN4Rmo0z3Al87V4ToXxEz6lo1+mJJT2FknZuOlcdZRcobxnZZx7WrZIBjTkm8hXE9T9QS+h7ojFaIhj0OVZdfC/VqcHdwlnsPCXTImZIcWfBnScmufw1cNUE2S8yE/DMLmltRlAl9uqePF3W9E/2dAdQRNe5P2iVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599490161083915.158956937437; Mon, 7 Sep 2020 07:49:21 -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-225-bhCExL4GOuKYUKh-enjXkQ-1; Mon, 07 Sep 2020 10:49:09 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 278A610054FF; Mon, 7 Sep 2020 14:49:04 +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 F2D021002388; Mon, 7 Sep 2020 14:49:03 +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 C110F79FEA; Mon, 7 Sep 2020 14:49:03 +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 087Emsp4029473 for ; Mon, 7 Sep 2020 10:48:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id A6B1210023A7; Mon, 7 Sep 2020 14:48:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2823E100239A for ; Mon, 7 Sep 2020 14:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599490152; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ADJ1y7W9f0r21oSAQKgsIcKVe2msgxrhjhOvvoCXKjA=; b=GH4c4ObyYBebZfEFNQZJmgBYHIkmFQI+VmWxSWzJRaNprhAU125gDL1mAS1YVdBsBOwxHL WDGIDO8s2eC3FmRBgf13OXk6WJsUFJjy8P0ll0kd0yRE95hPaXCCDczDIZH73pieOeT8/w PmtvYSE+sXpxkgtNxbS97+wNK2wf1Ks= X-MC-Unique: bhCExL4GOuKYUKh-enjXkQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu_process: Separate VIR_PERF_EVENT_* setting into a function Date: Mon, 7 Sep 2020 16:48:47 +0200 Message-Id: <10e3eb5914707c31c0b7f3c92e6509eae2caf0de.1599490097.git.mprivozn@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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When starting a domain, qemuProcessLaunch() iterates over all VIR_PERF_EVENT_* values and (possibly) enables them. While there is nothing wrong with the code, the for loop where its done makes it harder to jump onto next block of code. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- Is this trivial enough to be pushed as such? src/qemu/qemu_process.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6b1644880a..dd60fb0ddf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6700,6 +6700,25 @@ qemuProcessEnableDomainNamespaces(virQEMUDriverPtr d= river, } =20 =20 +static int +qemuProcessEnablePerf(virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + size_t i; + + if (!(priv->perf =3D virPerfNew())) + return -1; + + for (i =3D 0; i < VIR_PERF_EVENT_LAST; i++) { + if (vm->def->perf.events[i] =3D=3D VIR_TRISTATE_BOOL_YES && + virPerfEventEnable(priv->perf, i, vm->pid) < 0) + return -1; + } + + return 0; +} + + /** * qemuProcessLaunch: * @@ -6733,7 +6752,6 @@ qemuProcessLaunch(virConnectPtr conn, g_autoptr(virQEMUDriverConfig) cfg =3D NULL; size_t nnicindexes =3D 0; g_autofree int *nicindexes =3D NULL; - size_t i; =20 VIR_DEBUG("conn=3D%p driver=3D%p vm=3D%p name=3D%s if=3D%d asyncJob=3D= %d " "incoming.launchURI=3D%s incoming.deferredURI=3D%s " @@ -6885,15 +6903,10 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuSetupCgroup(vm, nnicindexes, nicindexes) < 0) goto cleanup; =20 - if (!(priv->perf =3D virPerfNew())) + VIR_DEBUG("Setting up domain perf (if required)"); + if (qemuProcessEnablePerf(vm) < 0) goto cleanup; =20 - for (i =3D 0; i < VIR_PERF_EVENT_LAST; i++) { - if (vm->def->perf.events[i] =3D=3D VIR_TRISTATE_BOOL_YES && - virPerfEventEnable(priv->perf, i, vm->pid) < 0) - goto cleanup; - } - /* This must be done after cgroup placement to avoid resetting CPU * affinity */ if (qemuProcessInitCpuAffinity(vm) < 0) --=20 2.26.2