From nobody Fri Dec 19 18:48:04 2025 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