From nobody Mon Feb 9 09:08:42 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=1660298709; cv=none; d=zohomail.com; s=zohoarc; b=X6vUhh9PvpvIktT7U+pNiFNRac9Em1rthVET07+phc+2Yyw2qnCVjxqQ0oq1ZFdHDXM6OyL49kf3uCNrnO1UFbicSOFcysdjW9u7347KL42JuF7hLFDo0yUvYxsHcKsAnCTNSfBiEXkJeOOl2IlENwsLzXsdJNECKTNV7G750zk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660298709; 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=ZGtRJhVoBXWMjpWjZls3FZe3ABtYj5FC9iqxXrjwEf0=; b=XTwyNlDbFHGWfGNWRLRvrwdzzK+cepw4edUkrbIRcL8HqZpERAzmkKh4a7kSDzYjhLGHGsEl8j7gKN6TTBSx0F2zTKdWVCmPmOPcksPfXq3AlEDUY1Zqr5o10HyIUrE/7wg3dkgUNPgkRadkfF8KOivWw0aBQRiNeGmH8UmQgSc= 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 1660298709401601.5188242212887; Fri, 12 Aug 2022 03:05:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-tGEvY3S6MISMR_Yotruqzw-1; Fri, 12 Aug 2022 06:04:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE1AC3800C4C; Fri, 12 Aug 2022 10:04:36 +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 994351121325; Fri, 12 Aug 2022 10:04:36 +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 2AFE51946A64; Fri, 12 Aug 2022 10:04:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9B4941946A5E for ; Fri, 12 Aug 2022 10:04:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8923FC15BA8; Fri, 12 Aug 2022 10:04:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ECDDC15BA6 for ; Fri, 12 Aug 2022 10:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660298708; 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=ZGtRJhVoBXWMjpWjZls3FZe3ABtYj5FC9iqxXrjwEf0=; b=MrtbY46crUjWpA4ruxTLL14NjsHv6/A5BRo32mVENkHHWHYCbFJIB2VVXSnokAfrJFShzj PWsRnIVEUTslZXzfPGzoDR+zowpEbb7xTkF/9WL/9sSaTR183kA6fiipM7QokXxwsxO3zs X70bVeOIPA9lNabSd6H/w/cgHwDccu8= X-MC-Unique: tGEvY3S6MISMR_Yotruqzw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 6/8] qemu: Enable SCHED_CORE for helper processes Date: Fri, 12 Aug 2022 12:04:21 +0200 Message-Id: <454092f564e4657c38b9c9b91bcc0fa9bec57c1c.1660298204.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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 2.78 on 10.11.54.3 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: 1660298710413100001 Content-Type: text/plain; charset="utf-8"; x-default="true" For QEMU_SCHED_CORE_FULL case, all helper processes should be placed into the same scheduling group as the QEMU process they serve. It may happen though, that a helper process is started before QEMU (cold start of a domain). But we have the dummy process running from which the QEMU process will inherit the scheduling group, so we can use the dummy process PID as an argument to virCommandSetRunAmong(). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 9 +++++++++ src/qemu/qemu_security.c | 11 +++++++++++ src/qemu/qemu_virtiofs.c | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f112209ae6..a8f8a7cb47 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2852,6 +2852,15 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm) * qemu (so that it shares the same view of the system). */ virCommandSetPreExecHook(cmd, qemuProcessStartPRDaemonHook, vm); =20 + if (cfg->schedCore =3D=3D QEMU_SCHED_CORE_FULL) { + pid_t cookie_pid =3D vm->pid; + + if (cookie_pid <=3D 0) + cookie_pid =3D priv->schedCoreChildPID; + + virCommandSetRunAmong(cmd, cookie_pid); + } + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 3be1766764..5b7d5f30c2 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -683,6 +683,9 @@ qemuSecurityCommandRun(virQEMUDriver *driver, int *exitstatus, int *cmdret) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivate *priv =3D vm->privateData; + if (virSecurityManagerSetChildProcessLabel(driver->securityManager, vm->def, cmd) < 0) return -1; @@ -691,6 +694,14 @@ qemuSecurityCommandRun(virQEMUDriver *driver, virCommandSetUID(cmd, uid); if (gid !=3D (gid_t) -1) virCommandSetGID(cmd, gid); + if (cfg->schedCore =3D=3D QEMU_SCHED_CORE_FULL) { + pid_t pid =3D vm->pid; + + if (pid <=3D 0) + pid =3D priv->schedCoreChildPID; + + virCommandSetRunAmong(cmd, pid); + } =20 if (virSecurityManagerPreFork(driver->securityManager) < 0) return -1; diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index ce55286ab5..348908eb43 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -179,6 +179,7 @@ qemuVirtioFSStart(virQEMUDriver *driver, virDomainFSDef *fs) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCommand) cmd =3D NULL; g_autofree char *socket_path =3D NULL; g_autofree char *pidfile =3D NULL; @@ -252,6 +253,16 @@ qemuVirtioFSStart(virQEMUDriver *driver, virCommandNonblockingFDs(cmd); virCommandDaemonize(cmd); =20 + if (cfg->schedCore =3D=3D QEMU_SCHED_CORE_FULL) { + pid_t cookie_pid =3D vm->pid; + + if (cookie_pid <=3D 0) + cookie_pid =3D priv->schedCoreChildPID; + + virCommandSetRunAmong(cmd, cookie_pid); + } + + if (qemuExtDeviceLogCommand(driver, vm, cmd, "virtiofsd") < 0) goto error; =20 --=20 2.35.1