From nobody Fri Apr 26 09:09:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1668440150; cv=none; d=zohomail.com; s=zohoarc; b=htHmHsmPi3W7CHKFk8GUTH1y9wDlNdljcZmzA5gdy2VD2qw/xZ2oubzlJcoYBaj6r5Nv1u88ccXkhUxkfcE0dXcAG9q6D0DLRgzdbYx2TH2B/UQXTM6XpUSAY8uOR0HnSy0IaYvlxSBbiGTny1TkieU3A103sB5lQrAEJui8aiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440150; 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=BHQ73ktE80az0FLgZky8rb8qWXUuljz0Y2ZVSHsJ0l8=; b=YxqJoD04zhCUo+x9gx2sAyfAggM6ae78pmmIddnVqB4YuJRLu8nNrWLw5NiKMaRwtvYhtLa8jjsy7jPQ6STiV+jDxqzw17NKPTfp0PqZQKyC9USbZMjqC3t1eddckYlVa7DMnS9UmIwBOM065Lt0fmQWGpMwK/O3984JpDHDIWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1668440150837847.337159446828; Mon, 14 Nov 2022 07:35:50 -0800 (PST) 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-495-U6ONaMg1P6ym2nxJpuJ86w-1; Mon, 14 Nov 2022 10:35:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2D61800B30; Mon, 14 Nov 2022 15:35:38 +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 E014D40E9783; Mon, 14 Nov 2022 15:35:38 +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 53B1D1946A40; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 977921946589 for ; Mon, 14 Nov 2022 15:35:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7A95B475060; Mon, 14 Nov 2022 15:35:37 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC6B947505E for ; Mon, 14 Nov 2022 15:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440149; 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=BHQ73ktE80az0FLgZky8rb8qWXUuljz0Y2ZVSHsJ0l8=; b=YtMnqZ6QfMGK5c6gh98afn/db0cRswxPhpIOLLbOQsqRzbUtWI/VY0NxOru759kzKLoQVa PCNLq93KLC8I5MmJMOyKnXSQ8VujeZ4CqkI4hRm57WXUifu4rC2D49dtlRwJddsE0iT6kT ouZArJuHvOVPJL7fbrFstvFLrFdAihs= X-MC-Unique: U6ONaMg1P6ym2nxJpuJ86w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/7] qemu_capabilities: Introduce QEMU_CAPS_THREAD_CONTEXT Date: Mon, 14 Nov 2022 16:35:29 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.2 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: 1668440152571100003 Content-Type: text/plain; charset="utf-8"; x-default="true" In its commit v7.1.0-1429-g7208429223 QEMU gained new object thread-context, which allows running specialized tasks with affinity set to a given subset of host CPUs/NUMA nodes. Even though only memory allocation task accepts this new object, it's exactly what we aim to implement in libvirt. Therefore, introduce a new capability to track whether QEMU is capable of this object. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml | 1 + 3 files changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d3ba8c85c9..965af45cb2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -678,6 +678,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "query-stats", /* QEMU_CAPS_QUERY_STATS */ "query-stats-schemas", /* QEMU_CAPS_QUERY_STATS_SCHEMAS */ "sgx-epc", /* QEMU_CAPS_SGX_EPC */ + "thread-context", /* QEMU_CAPS_THREAD_CONTEXT */ ); =20 =20 @@ -1384,6 +1385,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "virtio-mem-pci", QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI }, { "virtio-iommu-pci", QEMU_CAPS_DEVICE_VIRTIO_IOMMU_PCI }, { "sgx-epc", QEMU_CAPS_SGX_EPC }, + { "thread-context", QEMU_CAPS_THREAD_CONTEXT }, }; =20 =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index dfa3d8cd9b..b70c02c05b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -657,6 +657,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_QUERY_STATS, /* accepts query-stats */ QEMU_CAPS_QUERY_STATS_SCHEMAS, /* accepts query-stats-schemas */ QEMU_CAPS_SGX_EPC, /* -object sgx-epc,... */ + QEMU_CAPS_THREAD_CONTEXT, /* -object thread-context */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.2.0.x86_64.xml index 6a861eea24..b478c53502 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml @@ -199,6 +199,7 @@ + 7001050 0 43100245 --=20 2.37.4 From nobody Fri Apr 26 09:09:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1668440146; cv=none; d=zohomail.com; s=zohoarc; b=hrFTX4TFO4732w1yFpBDGlKNX1+dvrEplyU2Wcet7hTdogMfjyHx8I3sEIY1wI52TTetTqR8/6YBAzAXutm2JnFVkWkP/s5D6SBIEhvhVkE6MwoGRFZExtP4llz9TDdG/CkbH0o8ZQcYM8Ihhj/tNxheBh1zVLGgKG2tzLdLfLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440146; 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=x+dg6oUggChKViknOG1stlSweJk28Pzg9ZKgZRbjo5k=; b=h+5+89sKyxr33BQs0MkTiqJAk1kRKRtoq9bk0rCKx/CGOj9s69t9xl+BQ5tOdcYjuuT/N8Cr0y3+2mG89fal1rEuplKAweY+MAWe+SMuvwfKO2a5l5YMRTL3I5C2iMwE7RzAVLsizyjWrZpIRM/LrdKxoxaPYGihRUKeKIjnkXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1668440146969322.14375510153525; Mon, 14 Nov 2022 07:35:46 -0800 (PST) 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-201-KuWDXCKnMAy76qdWDknCGg-1; Mon, 14 Nov 2022 10:35:44 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2ECFA38012CE; Mon, 14 Nov 2022 15:35:40 +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 1B05DC15BB3; Mon, 14 Nov 2022 15:35:40 +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 0F158194658C; Mon, 14 Nov 2022 15:35:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 39BDE1946589 for ; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0E50147505E; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7D83475062 for ; Mon, 14 Nov 2022 15:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440146; 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=x+dg6oUggChKViknOG1stlSweJk28Pzg9ZKgZRbjo5k=; b=XrTzX3VgClW4y5TyEn3l9dFT0AGw05V0f9643qNEeftX4iygI3/RQNzZf1X3N8oRzLrSZj 3698cvetfUNEEKYJuZj9dPgWA5u4PYGcu6bVIMDtP8v9DI4VnaBgglCyCFcO92aS17bK3u DM6zY84PKPD88Ck2eYGfYm8fejytsjM= X-MC-Unique: KuWDXCKnMAy76qdWDknCGg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/7] qemu_command: Introduce qemuBuildThreadContextProps() Date: Mon, 14 Nov 2022 16:35:30 +0100 Message-Id: <5738e30b8a08a769fbd9b95498c1620130be6eaf.1668439393.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.8 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: 1668440148594100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The aim of thread-context object is to set affinity on threads that allocate memory for a memory-backend-* object. For instance: -object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[= 3]}' \ -object '{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":true= ,\ "hugetlbsize":2097152,"share":true,"prealloc":true,"prealloc-thre= ads":8,\ "size":15032385536,"host-nodes":[3],"policy":"preferred",\ "prealloc-context":"tc-ram-node0"}' \ allocates 14GiB worth of memory, backed by 2MiB hugepages from host NUMA node 3, using 8 threads. If it weren't for thread-context these threads wouldn't have any affinity and thus theoretically could be scheduled to run on CPUs of different NUMA node (which is what I saw occasionally). Therefore, whenever we are pinning memory (IOW setting host-nodes attribute), we can generate thread-context object with the same affinity. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_command.c | 48 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_command.h | 5 +++++ 2 files changed, 53 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 41b9f7cb52..392b248628 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3603,6 +3603,54 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg, } =20 =20 +int +qemuBuildThreadContextProps(virJSONValue **tcProps, + virJSONValue **memProps, + qemuDomainObjPrivate *priv) +{ + g_autoptr(virJSONValue) props =3D NULL; + virJSONValue *nodemask =3D NULL; + g_autoptr(virJSONValue) nodemaskCopy =3D NULL; + g_autofree char *tcAlias =3D NULL; + const char *memalias =3D NULL; + + if (tcProps) + *tcProps =3D NULL; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_THREAD_CONTEXT)) + return 0; + + nodemask =3D virJSONValueObjectGetArray(*memProps, "host-nodes"); + if (!nodemask) + return 0; + + memalias =3D virJSONValueObjectGetString(*memProps, "id"); + if (!memalias) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("memory device alias is not assigned")); + return -1; + } + + tcAlias =3D g_strdup_printf("tc-%s", memalias); + nodemaskCopy =3D virJSONValueCopy(nodemask); + + if (virJSONValueObjectAdd(&props, + "s:qom-type", "thread-context", + "s:id", tcAlias, + "a:node-affinity", &nodemaskCopy, + NULL) < 0) + return -1; + + if (virJSONValueObjectAdd(memProps, + "s:prealloc-context", tcAlias, + NULL) < 0) + return -1; + + *tcProps =3D g_steal_pointer(&props); + return 0; +} + + static char * qemuBuildLegacyNicStr(virDomainNetDef *net) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 2578367df9..761cc5d865 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -147,6 +147,11 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg, const virDomainDef *def, const virDomainMemoryDef *mem); =20 +int +qemuBuildThreadContextProps(virJSONValue **tcProps, + virJSONValue **memProps, + qemuDomainObjPrivate *priv); + /* Current, best practice */ virJSONValue * qemuBuildPCIHostdevDevProps(const virDomainDef *def, --=20 2.37.4 From nobody Fri Apr 26 09:09:32 2024 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=1668440164; cv=none; d=zohomail.com; s=zohoarc; b=hQa9g8XdYDultDAAjEQAt8Pz6LTjEzhZ0uu1fg3LNjYAYqILPEkMNRCXxUI22WjQ64Wwp7iQ3y48FKkqKXN8NmuBt6EDgTJ6tUhE0eFPMx+gOXVr5MC5W6Wti/ZbGXOztk/Bfk2PMah8JIrBCclFgmO0vKpHSGSg3A0nKNoOYjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440164; 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=sOg1J1v75Fx0WyRZDB5IF4qTbppQd2VfRpF2rX+xC2A=; b=QbaMksgyv2JhVAUpbz/DMYyclDCClmZT3sD0m9gYJ3uEotSzLZEp6q9hpN76oTYXrz4HwOkg6yJJPjq4Arxm8QjPO7olIlsbQKDbb1fnFkN8HTHN0c43Gip8U9VDnAvRTgVwVvOKzoNRtpm1hxkUQiVdOOuIk9vlrp3i6/bDmIE= 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 166844016423481.49298992088109; Mon, 14 Nov 2022 07:36:04 -0800 (PST) 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-2-1Y8OjbYlPE-OqDvKGIw1yQ-1; Mon, 14 Nov 2022 10:35:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B88D38012CC; Mon, 14 Nov 2022 15:35:40 +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 762C54043CCC; Mon, 14 Nov 2022 15:35:40 +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 4FF8E19466DF; Mon, 14 Nov 2022 15:35:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BCC21194658F for ; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A3041475060; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47DF9475061 for ; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440163; 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=sOg1J1v75Fx0WyRZDB5IF4qTbppQd2VfRpF2rX+xC2A=; b=BprGxL5HwtE5e+zFkmjFZbAU8M60HRK0XyquCs4RMIJOSur1PBjZI5U/gJ81C62LxDGSQJ WJoL+FHEcYIx4NRa3Ig8YgojqZ3uZrMq0tfshK8I51InDcyjh+IhSLEwKgI566Ww9HHero JSmNk2o8ZrYTb1HDMk7w3ZN0f4gIEKI= X-MC-Unique: 1Y8OjbYlPE-OqDvKGIw1yQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] qemu: Delete thread-context objects at domain startup Date: Mon, 14 Nov 2022 16:35:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.1 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: 1668440164628100001 Content-Type: text/plain; charset="utf-8"; x-default="true" While technically thread-context objects can be reused, we only use them (well, will use them) to pin memory allocation threads. Therefore, once we connect to QEMU monitor, all memory (with prealloc=3Dyes) was allocated and thus these objects are no longer needed and can be removed. For on demand allocation the TC object is left behind. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_command.c | 7 ++++++ src/qemu/qemu_domain.c | 2 ++ src/qemu/qemu_domain.h | 2 ++ src/qemu/qemu_process.c | 47 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_process.h | 2 ++ 5 files changed, 60 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 392b248628..90bc537b33 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3613,6 +3613,7 @@ qemuBuildThreadContextProps(virJSONValue **tcProps, g_autoptr(virJSONValue) nodemaskCopy =3D NULL; g_autofree char *tcAlias =3D NULL; const char *memalias =3D NULL; + bool prealloc =3D false; =20 if (tcProps) *tcProps =3D NULL; @@ -3646,6 +3647,12 @@ qemuBuildThreadContextProps(virJSONValue **tcProps, NULL) < 0) return -1; =20 + if (virJSONValueObjectGetBoolean(*memProps, "prealloc", &prealloc) >= =3D 0 && + prealloc) { + priv->threadContextAliases =3D g_slist_prepend(priv->threadContext= Aliases, + g_steal_pointer(&tcAl= ias)); + } + *tcProps =3D g_steal_pointer(&props); return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0d579bfc9b..ef1a9c8c74 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1811,6 +1811,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) priv->preMigrationMemlock =3D 0; =20 virHashRemoveAll(priv->statsSchema); + + g_slist_free_full(g_steal_pointer(&priv->threadContextAliases), g_free= ); } =20 =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index d5f4fbad12..a9af8502d2 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -251,6 +251,8 @@ struct _qemuDomainObjPrivate { * briefly when starting a guest. Don't save/parse into XML. */ pid_t schedCoreChildPID; pid_t schedCoreChildFD; + + GSList *threadContextAliases; /* List of IDs of thread-context objects= */ }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4b26c384cf..0769f30d74 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7500,6 +7500,50 @@ qemuProcessSetupLifecycleActions(virDomainObj *vm, } =20 =20 +int +qemuProcessDeleteThreadContext(virDomainObj *vm) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + GSList *next =3D priv->threadContextAliases; + int ret =3D -1; + + if (!next) + return 0; + + for (; next; next =3D next->next) { + if (qemuMonitorDelObject(priv->mon, next->data, true) < 0) + goto cleanup; + } + + ret =3D 0; + cleanup: + g_slist_free_full(g_steal_pointer(&priv->threadContextAliases), g_free= ); + return ret; +} + + +static int +qemuProcessDeleteThreadContextHelper(virDomainObj *vm, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + int ret =3D -1; + + if (!priv->threadContextAliases) + return 0; + + VIR_DEBUG("Deleting thread context objects"); + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; + + ret =3D qemuProcessDeleteThreadContext(vm); + + qemuDomainObjExitMonitor(vm); + + return ret; +} + + /** * qemuProcessLaunch: * @@ -7860,6 +7904,9 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessSetupLifecycleActions(vm, asyncJob) < 0) goto cleanup; =20 + if (qemuProcessDeleteThreadContextHelper(vm, asyncJob) < 0) + goto cleanup; + ret =3D 0; =20 cleanup: diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index d1f58ee258..9a24745f15 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -123,6 +123,8 @@ int qemuProcessPrepareHost(virQEMUDriver *driver, virDomainObj *vm, unsigned int flags); =20 +int qemuProcessDeleteThreadContext(virDomainObj *vm); + int qemuProcessLaunch(virConnectPtr conn, virQEMUDriver *driver, virDomainObj *vm, --=20 2.37.4 From nobody Fri Apr 26 09:09:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1668440151; cv=none; d=zohomail.com; s=zohoarc; b=Oa51MNcC988D6ih2jImpxUwr8WikyRi7Ykgs+BbmlFzD1lWhlPCLB+ArLuqIoGYQ/MEGpsP5TFu6h7Uhss+ZteTvioK/CpDge9ptPvSMGcGHYUW1tW+MTwjP/VyPVbIk0IdidX6/iQ5Kv94vmTADQ9oxv+5yN+TOP+PmN+c6/UM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440151; 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=0LY5t13XPQ9KymDeTHNQBpqiWnT0+xVhcTsUX2APBwA=; b=B13CbF1wATAPStXZloOcYycaNha/ih7C64H+yYs8iB98ZiWnXlTWGgp1kBRk1dS6yrPJAcg2BCFKfnNt+zFS8+d+Wn6r+8QRyZuSRzO4LnVDgSzaREj069wf7N9VUgbvLeagYntmuPhGkVq9hA7Ch9mguR6GgL/g6JtMAxSxqM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1668440151801740.9492063460984; Mon, 14 Nov 2022 07:35:51 -0800 (PST) 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-317-OZ-ow4hQOh-Z9oXx3piBGQ-1; Mon, 14 Nov 2022 10:35:45 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF41286F144; Mon, 14 Nov 2022 15:35:40 +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 D00FA492B30; Mon, 14 Nov 2022 15:35:40 +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 B91E919465B6; Mon, 14 Nov 2022 15:35:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 684871946589 for ; Mon, 14 Nov 2022 15:35:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 46A12475062; Mon, 14 Nov 2022 15:35:39 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCFDD475060 for ; Mon, 14 Nov 2022 15:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440150; 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=0LY5t13XPQ9KymDeTHNQBpqiWnT0+xVhcTsUX2APBwA=; b=WTi/SId20KJlaeQgzJRUcXGJdW5dMs46VprbBnxZXdjZs9xTPSw4XaeaXMVxjvMWCtIZiV 5IjmOlw0JyZz/XWE8vpC70v5aIPytek63LLq23y1/uIVwn3OEQPJxUPul1xVlEqnFcA4Tv LGDUG62k6Kxk6lh4RHyRFzaUhl7GPs4= X-MC-Unique: OZ-ow4hQOh-Z9oXx3piBGQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/7] qemu_command: Generate thread-context object for guest NUMA memory Date: Mon, 14 Nov 2022 16:35:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.10 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: 1668440152647100007 Content-Type: text/plain; charset="utf-8"; x-default="true" When generating memory for guest NUMA memory-backend-* might be used. This means, we may need to generate thread-context objects too. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_command.c | 10 ++++++++++ .../hugepages-memaccess.x86_64-latest.args | 12 ++++++++---- .../hugepages-memaccess2.x86_64-latest.args | 12 ++++++++---- .../hugepages-shared.x86_64-latest.args | 12 ++++++++---- .../memfd-memory-default-hugepage.x86_64-latest.args | 3 ++- .../memfd-memory-numa.x86_64-latest.args | 3 ++- .../numatune-memnode.x86_64-latest.args | 9 ++++++--- 7 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 90bc537b33..a0f2644ba1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7325,6 +7325,16 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, ssize_t initiator =3D virDomainNumaGetNodeInitiator(def->numa, i); =20 if (needBackend) { + g_autoptr(virJSONValue) tcProps =3D NULL; + + if (qemuBuildThreadContextProps(&tcProps, &nodeBackends[i], pr= iv) < 0) + goto cleanup; + + if (tcProps && + qemuBuildObjectCommandlineFromJSON(cmd, tcProps, + priv->qemuCaps) < 0) + goto cleanup; + if (qemuBuildObjectCommandlineFromJSON(cmd, nodeBackends[i], priv->qemuCaps) < 0) goto cleanup; diff --git a/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args = b/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args index 55a8d899b7..9db085fd1d 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args @@ -16,13 +16,17 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config= \ -m size=3D4194304k,slots=3D16,maxmem=3D8388608k \ -overcommit mem-lock=3Doff \ -smp 4,sockets=3D4,cores=3D1,threads=3D1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"= tc-ram-node0"}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ --object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"t= c-ram-node1"}' \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"= tc-ram-node2"}' \ -numa node,nodeid=3D2,cpus=3D2,memdev=3Dram-node2 \ --object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":= [3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram= -node3"}' \ -numa node,nodeid=3D3,cpus=3D3,memdev=3Dram-node3 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args= b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args index 187c0ab214..37f6dfabe9 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args @@ -16,13 +16,17 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config= \ -m size=3D4194304k,slots=3D16,maxmem=3D8388608k \ -overcommit mem-lock=3Doff \ -smp 4,sockets=3D4,cores=3D1,threads=3D1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-nod= e0"}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ --object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"t= c-ram-node1"}' \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2","share":false,"size":10737= 41824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-nod= e2"}' \ -numa node,nodeid=3D2,cpus=3D2,memdev=3Dram-node2 \ --object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3","share":false,"size":10737= 41824,"host-nodes":[3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":= [3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3","share":false,"size":10737= 41824,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram-node3"}' \ -numa node,nodeid=3D3,cpus=3D3,memdev=3Dram-node3 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args b/t= ests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args index f4fea870fc..4e7ffb50a5 100644 --- a/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args @@ -16,13 +16,17 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config= \ -m 4096 \ -overcommit mem-lock=3Doff \ -smp 4,sockets=3D4,cores=3D1,threads=3D1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":107374182= 4,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":107374182= 4,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node0"}= ' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ --object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"si= ze":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"t= c-ram-node1"}' \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":= [0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"s= ize":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"= tc-ram-node2"}' \ -numa node,nodeid=3D2,cpus=3D2,memdev=3Dram-node2 \ --object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":107374182= 4,"host-nodes":[3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":= [3]}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/d= ev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":107374182= 4,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram-node3"}' \ -numa node,nodeid=3D3,cpus=3D3,memdev=3Dram-node3 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-la= test.args b/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-lat= est.args index 383635c8cd..f516c02bea 100644 --- a/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.ar= gs +++ b/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.ar= gs @@ -16,7 +16,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-instance-00000092/.c= onfig \ -m 14336 \ -overcommit mem-lock=3Doff \ -smp 8,sockets=3D1,dies=3D1,cores=3D8,threads=3D1 \ --object '{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":tru= e,"hugetlbsize":2097152,"share":true,"prealloc":true,"size":15032385536,"ho= st-nodes":[3],"policy":"preferred"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [3]}' \ +-object '{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":tru= e,"hugetlbsize":2097152,"share":true,"prealloc":true,"size":15032385536,"ho= st-nodes":[3],"policy":"preferred","prealloc-context":"tc-ram-node0"}' \ -numa node,nodeid=3D0,cpus=3D0-7,memdev=3Dram-node0 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args b/= tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args index 68bbd73551..c51bb6f828 100644 --- a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args @@ -16,7 +16,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-instance-00000092/.c= onfig \ -m size=3D14680064k,slots=3D16,maxmem=3D1099511627776k \ -overcommit mem-lock=3Doff \ -smp 8,sockets=3D1,dies=3D1,cores=3D8,threads=3D1 \ --object '{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":tru= e,"hugetlbsize":2097152,"share":true,"prealloc":true,"prealloc-threads":8,"= size":15032385536,"host-nodes":[3],"policy":"preferred"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [3]}' \ +-object '{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":tru= e,"hugetlbsize":2097152,"share":true,"prealloc":true,"prealloc-threads":8,"= size":15032385536,"host-nodes":[3],"policy":"preferred","prealloc-context":= "tc-ram-node0"}' \ -numa node,nodeid=3D0,cpus=3D0-7,memdev=3Dram-node0 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args b/t= ests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args index 7cb7e659a4..f4ef91006f 100644 --- a/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args +++ b/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args @@ -16,11 +16,14 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest/.config \ -m 24105 \ -overcommit mem-lock=3Doff \ -smp 32,sockets=3D32,cores=3D1,threads=3D1 \ --object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":20971520= ,"host-nodes":[3],"policy":"preferred"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":= [3]}' \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":20971520= ,"host-nodes":[3],"policy":"preferred","prealloc-context":"tc-ram-node0"}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ --object '{"qom-type":"memory-backend-ram","id":"ram-node1","size":67633152= 0,"host-nodes":[0,1,2,3,4,5,6,7],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":= [0,1,2,3,4,5,6,7]}' \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node1","size":67633152= 0,"host-nodes":[0,1,2,3,4,5,6,7],"policy":"bind","prealloc-context":"tc-ram= -node1"}' \ -numa node,nodeid=3D1,cpus=3D1-27,cpus=3D29,memdev=3Dram-node1 \ --object '{"qom-type":"memory-backend-ram","id":"ram-node2","size":24578621= 440,"host-nodes":[1,2,5,7],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":= [1,2,5,7]}' \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node2","size":24578621= 440,"host-nodes":[1,2,5,7],"policy":"bind","prealloc-context":"tc-ram-node2= "}' \ -numa node,nodeid=3D2,cpus=3D28,cpus=3D30-31,memdev=3Dram-node2 \ -uuid 9f4b6512-e73a-4a25-93e8-5307802821ce \ -display none \ --=20 2.37.4 From nobody Fri Apr 26 09:09:32 2024 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=1668440149; cv=none; d=zohomail.com; s=zohoarc; b=EBhfaJLRHVkFv5RWLW+xqFxmrDauxbm8G2w44IrkYbtLBdjqD+Oo4cd+CzWh0jWcG0SxRmUqmzU/tGjIIz1iIc6Tu6jFjyVN2MH0VvkjrqxBKUFDCqHJ71GN/b239+TtS43bYVfftXsWXvQD4f8t1tY2motk+8Xd4KAcSq4gRNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440149; 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=VHJlt2d4d1/J1ujw0piUngLfwMXPMHP4a4ePFKcYjCg=; b=eJNz4HOvJ2USKiticvc8IFLMFP5qijufMAYTi8oMS9P1I8KxzeK86RboqFDl1fwsU8PbXmG/0TvShp4+D0nhNBNDrJFOhU3d8xdz6h9xEbBaTt95bwPxFQidaKeyAvX0hVqPP7P4jvrkcF+A2usYiSBFPnUmB5QvKcoCOLuNlTs= 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 1668440149119755.1191208972964; Mon, 14 Nov 2022 07:35:49 -0800 (PST) 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-662-bWUqqpWRN-SClF-CtGWa7A-1; Mon, 14 Nov 2022 10:35:45 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF58518153EC; Mon, 14 Nov 2022 15:35:41 +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 BD4ADFD48; Mon, 14 Nov 2022 15:35:41 +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 A6375194658C; Mon, 14 Nov 2022 15:35:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E88FB1946589 for ; Mon, 14 Nov 2022 15:35:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D939C475061; Mon, 14 Nov 2022 15:35:39 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DDA2475060 for ; Mon, 14 Nov 2022 15:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440147; 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=VHJlt2d4d1/J1ujw0piUngLfwMXPMHP4a4ePFKcYjCg=; b=SHEgOEulJS0047c4V5cuHlHgr4DslOERYu2MttmyYLlp74CLNCnB/jjX+xHx5zaCIWiBD8 zhe+EOhQK1Q3dGTSt+jloyz5GTMJMAkbhq78+Zx09PMGbTrRORaw5sSCtjf+DkaTlzEC7k MRmcVQuZAGVnG18U7jOgQPF6wIM8VsM= X-MC-Unique: bWUqqpWRN-SClF-CtGWa7A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/7] qemu: Generate thread-context object for memory devices Date: Mon, 14 Nov 2022 16:35:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.5 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: 1668440150643100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When generating memory for memory devices memory-backend-* might be used. This means, we may need to generate thread-context objects too. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_command.c | 9 +++++++++ .../hugepages-memaccess.x86_64-latest.args | 3 ++- .../hugepages-memaccess2.x86_64-latest.args | 3 ++- .../hugepages-numa-default-dimm.x86_64-latest.args | 3 ++- .../memfd-memory-numa.x86_64-latest.args | 3 ++- .../memory-hotplug-dimm-addr.x86_64-latest.args | 3 ++- .../memory-hotplug-virtio-mem.x86_64-latest.args | 3 ++- .../pages-dimm-discard.x86_64-latest.args | 3 ++- 8 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a0f2644ba1..49ecd91300 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3503,6 +3503,7 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd, qemuDomainObjPrivate *priv) { g_autoptr(virJSONValue) props =3D NULL; + g_autoptr(virJSONValue) tcProps =3D NULL; g_autofree char *alias =3D NULL; =20 if (!mem->info.alias) { @@ -3517,6 +3518,14 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd, priv, def, mem, true, false) < 0) return -1; =20 + if (qemuBuildThreadContextProps(&tcProps, &props, priv) < 0) + return -1; + + if (tcProps && + qemuBuildObjectCommandlineFromJSON(cmd, tcProps, + priv->qemuCaps) < 0) + return -1; + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; =20 diff --git a/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args = b/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args index 9db085fd1d..8342a30c86 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args @@ -39,7 +39,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"siz= e":536870912,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[= 0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"siz= e":536870912,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-= memdimm0"}' \ -device '{"driver":"pc-dimm","node":1,"memdev":"memdimm0","id":"dimm0","sl= ot":0,"addr":4294967296}' \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ diff --git a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args= b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args index 37f6dfabe9..f73da5865d 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args @@ -39,7 +39,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"siz= e":536870912,"host-nodes":[0,1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[= 0,1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"siz= e":536870912,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-= memdimm0"}' \ -device '{"driver":"pc-dimm","node":1,"memdev":"memdimm0","id":"dimm0","sl= ot":0,"addr":4294967296}' \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ diff --git a/tests/qemuxml2argvdata/hugepages-numa-default-dimm.x86_64-late= st.args b/tests/qemuxml2argvdata/hugepages-numa-default-dimm.x86_64-latest.= args index 015464bded..3b8dfeea16 100644 --- a/tests/qemuxml2argvdata/hugepages-numa-default-dimm.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hugepages-numa-default-dimm.x86_64-latest.args @@ -29,7 +29,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-fedora/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages1G/libvirt/qemu/-1-fedora","prealloc":true,"size":1073741824,"ho= st-nodes":[1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[= 1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages1G/libvirt/qemu/-1-fedora","prealloc":true,"size":1073741824,"ho= st-nodes":[1,2,3],"policy":"bind","prealloc-context":"tc-memdimm0"}' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","sl= ot":0}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args b/= tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args index c51bb6f828..4748f0fbb2 100644 --- a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args @@ -30,7 +30,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-instance-00000092/.c= onfig \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memnvdimm0","mem-path":"/= tmp/nvdimm","share":true,"prealloc":true,"prealloc-threads":8,"size":536870= 912,"host-nodes":[3],"policy":"preferred"}' \ +-object '{"qom-type":"thread-context","id":"tc-memnvdimm0","node-affinity"= :[3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memnvdimm0","mem-path":"/= tmp/nvdimm","share":true,"prealloc":true,"prealloc-threads":8,"size":536870= 912,"host-nodes":[3],"policy":"preferred","prealloc-context":"tc-memnvdimm0= "}' \ -device '{"driver":"nvdimm","node":0,"memdev":"memnvdimm0","id":"nvdimm0",= "slot":0}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ diff --git a/tests/qemuxml2argvdata/memory-hotplug-dimm-addr.x86_64-latest.= args b/tests/qemuxml2argvdata/memory-hotplug-dimm-addr.x86_64-latest.args index ac24c77a2b..4e9bbde448 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-dimm-addr.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memory-hotplug-dimm-addr.x86_64-latest.args @@ -29,7 +29,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages2M/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":536870912,= "host-nodes":[1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[= 1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages2M/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":536870912,= "host-nodes":[1,2,3],"policy":"bind","prealloc-context":"tc-memdimm0"}' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","sl= ot":0,"addr":4294967296}' \ -object '{"qom-type":"memory-backend-ram","id":"memdimm2","size":536870912= }' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm2","id":"dimm2","sl= ot":2}' \ diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest= .args b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args index 5aa8110aeb..04876fc044 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args @@ -32,7 +32,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -object '{"qom-type":"memory-backend-ram","id":"memvirtiomem0","reserve":f= alse,"size":1073741824}' \ -device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"request= ed-size":536870912,"memdev":"memvirtiomem0","id":"virtiomem0","bus":"pci.0"= ,"addr":"0x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memvirtiomem1","mem-path"= :"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","reserve":false,"size":21474= 83648,"host-nodes":[1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-memvirtiomem1","node-affini= ty":[1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memvirtiomem1","mem-path"= :"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","reserve":false,"size":21474= 83648,"host-nodes":[1,2,3],"policy":"bind","prealloc-context":"tc-memvirtio= mem1"}' \ -device '{"driver":"virtio-mem-pci","node":0,"block-size":2097152,"request= ed-size":1073741824,"memdev":"memvirtiomem1","prealloc":true,"id":"virtiome= m1","bus":"pci.1","addr":"0x1"}' \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ diff --git a/tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args b= /tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args index 19ed3928de..2418133aa0 100644 --- a/tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args +++ b/tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args @@ -29,7 +29,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-fedora/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages1G/libvirt/qemu/-1-fedora","discard-data":false,"prealloc":true,= "size":1073741824,"host-nodes":[1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[= 1,2,3]}' \ +-object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages1G/libvirt/qemu/-1-fedora","discard-data":false,"prealloc":true,= "size":1073741824,"host-nodes":[1,2,3],"policy":"bind","prealloc-context":"= tc-memdimm0"}' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","sl= ot":0}' \ -object '{"qom-type":"memory-backend-file","id":"memdimm1","mem-path":"/va= r/lib/libvirt/qemu/ram/-1-fedora/dimm1","discard-data":true,"share":false,"= size":536870912}' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm1","id":"dimm1","sl= ot":1}' \ --=20 2.37.4 From nobody Fri Apr 26 09:09:32 2024 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=1668440155; cv=none; d=zohomail.com; s=zohoarc; b=EqcNb9O1Vdgq28CMu4EL1D1MDYlCh6NtNCJ9XI5yZK/kUVTL48gzPxwpXoJ8rA473Vt4IoFPAtV/u2Y+oQr1zjc5qOfC8by1XKNBYjiHICePq+ymFsiC+iE7zi4JPszed2TJblsu0xTJLAwWhSGnEka4+qCESl7o//C5nXZzRnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440155; 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=zSFv+/zNJ0PgeKuTfyDqHVxkAUsLzfwFAek91atbSlc=; b=V/SSa7oJuCBBBACAQq+NsnEBUNHxN9jbJOh5AlpH3fM9+goMkfk8tl30VAzjA9WZ0GN++DOQi4iFee3Xx3dq0cIVkCLswgEApsOwmtND//O5vSBvL7miSYHtcqnQJg7hF/RnxZxx8BGJaOqpo3a4gW0MjBD+POd21WJBJ+0X7VQ= 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 1668440155400364.66141705540576; Mon, 14 Nov 2022 07:35:55 -0800 (PST) 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-636-cIVLD9kHODmr1y6ZjcRWHQ-1; Mon, 14 Nov 2022 10:35:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 70BEC803D48; Mon, 14 Nov 2022 15:35:47 +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 5DCD02166B2B; Mon, 14 Nov 2022 15:35:47 +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 461C319465B2; Mon, 14 Nov 2022 15:35:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A45DB19466DF for ; Mon, 14 Nov 2022 15:35:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 79AA14B3FCE; Mon, 14 Nov 2022 15:35:40 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E470475060 for ; Mon, 14 Nov 2022 15:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440154; 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=zSFv+/zNJ0PgeKuTfyDqHVxkAUsLzfwFAek91atbSlc=; b=HfHeKlXnuwqLo/cMJ2GSsqe5C/R2He4PWCW6j+kEiQjjntsxtscV0x218gU1MViacYOyze 9liFqF2W2tOm2tl61eoIuBGTegjrjq5UZOaiwTEAy1SdihoId9Z+L12N1cRRPmOUMgzovL XYwpx8KkmT1EhyG7F6f149qmbKsTRI4= X-MC-Unique: cIVLD9kHODmr1y6ZjcRWHQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/7] qemu_command: Generate thread-context object for main guest memory Date: Mon, 14 Nov 2022 16:35:34 +0100 Message-Id: <196036da55f17ab076781646c47b43018adc959f.1668439393.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.6 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: 1668440156587100002 Content-Type: text/plain; charset="utf-8"; x-default="true" When generating memory for main guest memory memory-backend-* might be used. This means, we may need to generate thread-context objects too. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_command.c | 9 +++++++++ .../numatune-system-memory.x86_64-latest.args | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 49ecd91300..b8aafd39c8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7009,6 +7009,7 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virComman= d *cmd, { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); g_autoptr(virJSONValue) props =3D NULL; + g_autoptr(virJSONValue) tcProps =3D NULL; virDomainMemoryDef mem =3D { 0 }; =20 mem.size =3D virDomainDefGetMemoryInitial(def); @@ -7019,6 +7020,14 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virComma= nd *cmd, priv, def, &mem, false, true) < 0) return -1; =20 + if (qemuBuildThreadContextProps(&tcProps, &props, priv) < 0) + return -1; + + if (tcProps && + qemuBuildObjectCommandlineFromJSON(cmd, tcProps, + priv->qemuCaps) < 0) + return -1; + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; =20 diff --git a/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.ar= gs b/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.args index fd93abe3eb..125dc43153 100644 --- a/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.args +++ b/tests/qemuxml2argvdata/numatune-system-memory.x86_64-latest.args @@ -14,7 +14,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -accel tcg \ -cpu qemu64 \ -m 214 \ --object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264,"= host-nodes":[0],"policy":"bind"}' \ +-object '{"qom-type":"thread-context","id":"tc-pc.ram","node-affinity":[0]= }' \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264,"= host-nodes":[0],"policy":"bind","prealloc-context":"tc-pc.ram"}' \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,cores=3D1,threads=3D1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --=20 2.37.4 From nobody Fri Apr 26 09:09:32 2024 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=1668440151; cv=none; d=zohomail.com; s=zohoarc; b=ESvE61rVR1z+KHbRX9lLz25ToWqWfuCRftny2ESjqTiMw+tRc+NxbyHmO+qoGjD/rKGzMfh7f4Tg6YRX8q87mT8tJMlrh3W5ScPqoc8CAVPjT2X3WII5RsP7amdYXXvsbOcxFrWmDKF1NP8jGFgkXYaxa0mwtZ0zrWBRR03L4A8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668440151; 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=LsuDPKUIiCnGhrcfKhrMbZkOgFKpFseinnaaujFzSUg=; b=ZJHyGvTY6feKvQcA/XqTsyxSikkBFHzCh6GFDMzTQ+BKdztl+xqHP4lHOTgQLekqL9H9DHx4c8R/PUfIZjj5unAWvVfzTVAAVGeMVFll7Eka9RfgyMoULFEZqI7YsoMMYcH8vlgARhWGgt37AnQ3BSrMjdnfZtC/YWeUFYB/Q9A= 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 1668440151305299.0350901205411; Mon, 14 Nov 2022 07:35:51 -0800 (PST) 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-246-_MsBoaSjNfqigW_IuprbbA-1; Mon, 14 Nov 2022 10:35:48 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DFDB5811E81; Mon, 14 Nov 2022 15:35:45 +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 CD2404B3FC6; Mon, 14 Nov 2022 15:35:45 +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 B5B7419466DF; Mon, 14 Nov 2022 15:35:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 39CC319465B8 for ; Mon, 14 Nov 2022 15:35:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1C9164B3FC6; Mon, 14 Nov 2022 15:35:41 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2F4F4B3FC8 for ; Mon, 14 Nov 2022 15:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668440150; 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=LsuDPKUIiCnGhrcfKhrMbZkOgFKpFseinnaaujFzSUg=; b=UJFcLlb0CipdK3DKZK6DG9Pr0qe3pIoY3es2sihfewV+/i0VWC8LMdLIBvg0dMydA08HjX FszXVfb6yzNzXcvmRO2XU8mHjzG1eKiHBtKDmdi+xyixkgug0C4tw303+OzHFaWI7dMscG n0ZjrJH9nnfYFcELENxQHuJoDbeYLgk= X-MC-Unique: _MsBoaSjNfqigW_IuprbbA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/7] qemu_hotplug: Generate thread-context object for memory device Date: Mon, 14 Nov 2022 16:35:35 +0100 Message-Id: <1681e9ff09174d011b77204947351777d8458e1e.1668439393.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.9 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: 1668440152581100004 Content-Type: text/plain; charset="utf-8"; x-default="true" This is similar to one of previous commits which generated thread-context object for memory devices at cmd line generation phase. This one does the same for hotplug case, except it's doing so iff QEMU sandboxing is turned off. The reason is that once sandboxing is turned on, the __NR_sched_setaffinity syscall is filtered by libseccomp and thus QEMU is unable to instantiate the thread-context object. Signed-off-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index da92ced2f4..5c49da87ba 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2240,11 +2240,13 @@ qemuDomainAttachMemory(virQEMUDriver *driver, g_autoptr(virJSONValue) devprops =3D NULL; g_autofree char *objalias =3D NULL; bool objAdded =3D false; + bool tcObjAdded =3D false; bool releaseaddr =3D false; bool teardownlabel =3D false; bool teardowncgroup =3D false; bool teardowndevice =3D false; g_autoptr(virJSONValue) props =3D NULL; + g_autoptr(virJSONValue) tcProps =3D NULL; virObjectEvent *event; int id; int ret =3D -1; @@ -2273,6 +2275,11 @@ qemuDomainAttachMemory(virQEMUDriver *driver, priv, vm->def, mem, true, false) < 0) goto cleanup; =20 + /* In case sandbox was turned on, thread-context won't work. */ + if (cfg->seccompSandbox =3D=3D 0 && + qemuBuildThreadContextProps(&tcProps, &props, priv) < 0) + goto cleanup; + if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0) goto cleanup; =20 @@ -2294,6 +2301,12 @@ qemuDomainAttachMemory(virQEMUDriver *driver, goto removedef; =20 qemuDomainObjEnterMonitor(vm); + if (tcProps) { + if (qemuMonitorAddObject(priv->mon, &tcProps, NULL) < 0) + goto exit_monitor; + tcObjAdded =3D true; + } + if (qemuMonitorAddObject(priv->mon, &props, NULL) < 0) goto exit_monitor; objAdded =3D true; @@ -2301,6 +2314,12 @@ qemuDomainAttachMemory(virQEMUDriver *driver, if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; =20 + if (tcObjAdded) { + if (qemuProcessDeleteThreadContext(vm) < 0) + goto exit_monitor; + tcObjAdded =3D false; + } + qemuDomainObjExitMonitor(vm); =20 event =3D virDomainEventDeviceAddedNewFromObj(vm, objalias); @@ -2339,6 +2358,8 @@ qemuDomainAttachMemory(virQEMUDriver *driver, virErrorPreserveLast(&orig_err); if (objAdded) ignore_value(qemuMonitorDelObject(priv->mon, objalias, false)); + if (tcObjAdded) + ignore_value(qemuProcessDeleteThreadContext(vm)); qemuDomainObjExitMonitor(vm); =20 if (objAdded && mem) @@ -4380,6 +4401,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriver *driver, =20 qemuDomainObjEnterMonitor(vm); rc =3D qemuMonitorDelObject(priv->mon, backendAlias, true); + /* XXX remove TC object */ qemuDomainObjExitMonitor(vm); =20 virDomainAuditMemory(vm, oldmem, newmem, "update", rc =3D=3D 0); --=20 2.37.4