From nobody Fri May 3 17:00:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1559043319; cv=none; d=zoho.com; s=zohoarc; b=NPtQbpXg/rK0y7/5TC05claEv42ESibuViFyc7rtl+pZkY3ItClEBZj8e/+391PktnfDTWjYjUy7W3wxeEnTiPH789/QmyM0ZkSKOJKcHaShLkaf63S027DvcwqFUdCmdsDkMcK122I+8WcM6u5NuHoWdKhSyGukz8yHvxDNM6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559043319; 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:ARC-Authentication-Results; bh=Y4yROd/8E7cPkPJ0793MN8gGFcjWFRMjafcPx3C5xeo=; b=GjjUSgCqS1FLtIZfWDZTBn8ObO+DyjCGAqf7sSGpQaloU41+ZrKijN3mm0U2Qv0JNbvpZMgRJ2TBJDoqjyRto86rZI8BKyHRRuuFYuksKfNB6ydAUeY2H3IhnxjPzTL8mo0oAjyw8QYLRhH6fiG/YRbDFDci7hmV2GxT1F10lO8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559043319135321.79041606658006; Tue, 28 May 2019 04:35:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBB10307D92F; Tue, 28 May 2019 11:34:59 +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 95AE6614C8; Tue, 28 May 2019 11:34:50 +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 4990E206D1; Tue, 28 May 2019 11:34:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4SBYX1B001344 for ; Tue, 28 May 2019 07:34:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9A17F6A24E; Tue, 28 May 2019 11:34:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 955C060565 for ; Tue, 28 May 2019 11:34:31 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECB073004153 for ; Tue, 28 May 2019 11:34:23 +0000 (UTC) Received: from [10.94.3.220] (helo=dim-vz7.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hVaN4-0002hs-8e for libvir-list@redhat.com; Tue, 28 May 2019 14:34:22 +0300 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Tue, 28 May 2019 14:34:18 +0300 Message-Id: <1559043258-44226-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Sender passed SPF test, ACL 242 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 28 May 2019 11:34:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 28 May 2019 11:34:24 +0000 (UTC) for IP:'185.231.240.75' DOMAIN:'relay.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: 0 (SPF_HELO_NONE, SPF_PASS) 185.231.240.75 relay.sw.ru 185.231.240.75 relay.sw.ru X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: aquire job in qemuDomainDefineXMLFlags 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 28 May 2019 11:35:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function updates vm->newDef and frees previous pesistent definition which can be used by in different thread by some API that unlocks domain to communicate to qemu. So we have an access to freed memory in that thread. Let's acquire job condition when changing persistent xml. Signed-off-by: Nikolay Shirokovskiy --- A bug example (some downstream version of libvirt, nevertheless): (gdb) bt #0 0x00007f3bb77a0533 in virDomainDefHasVcpusOffline (def=3Ddef@entry= =3D0x7f3b7802a830) at conf/domain_conf.c:1637 #1 0x00007f3bb77cb32f in virDomainCpuDefFormat (def=3D0x7f3b7802a830, = buf=3D0x7f3ba7308940) at conf/domain_conf.c:27503 #2 virDomainDefFormatInternal (def=3Ddef@entry=3D0x7f3b7802a830, caps= =3D0x7f3b70000ae0, flags=3D3, flags@entry=3D1,=20 buf=3Dbuf@entry=3D0x7f3ba7308940, xmlopt=3Dxmlopt@entry=3D0x0) at c= onf/domain_conf.c:27850 #3 0x00007f3bb77ced46 in virDomainDefFormat (def=3Ddef@entry=3D0x7f3b7= 802a830, caps=3D,=20 flags=3Dflags@entry=3D1) at conf/domain_conf.c:28564 #4 0x00007f3bb77d23f9 in virDomainSaveConfig (configDir=3D0x7f3b981227= e0 "/etc/libvirt/qemu", caps=3D,=20 def=3D0x7f3b7802a830) at conf/domain_conf.c:28776 #5 0x00007f3ba086b617 in qemuDomainSetMemoryStatsPeriod (dom=3D, period=3D30, flags=3D) at qemu/qemu_driver.c:4839 #6 0x00007f3bb7905613 in virDomainSetMemoryStatsPeriod (domain=3Ddomai= n@entry=3D0x7f3b74006200, period=3D30, flags=3D3) at libvirt-domain.c:2087 (gdb) f 5 #5 0x00007f3ba086b617 in qemuDomainSetMemoryStatsPeriod (dom=3D, period=3D30, flags=3D) at qemu/qemu_driver.c:4839 4839 ret =3D virDomainSaveConfig(cfg->configDir, driver->cap= s, persistentDef); (gdb) p vm->def $8 =3D (virDomainDefPtr) 0x7f3b8400c6f0 (gdb) p vm->newDef $9 =3D (virDomainDefPtr) 0x7f3b7001de20 (gdb) p persistentDef $10 =3D (virDomainDefPtr) 0x7f3b7802a830 src/qemu/qemu_driver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 42b1ce2..683dcaa 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7626,6 +7626,7 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, virCapsPtr caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; + bool job =3D false; =20 virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL); =20 @@ -7647,6 +7648,10 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0) goto cleanup; =20 + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + job =3D true; + if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, 0, &oldDef))) @@ -7685,6 +7690,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 cleanup: + if (job) + qemuDomainObjEndJob(driver, vm); + virDomainDefFree(oldDef); virDomainDefFree(def); virDomainObjEndAPI(&vm); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list