From nobody Thu Apr 18 04:58:01 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=linux.ibm.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528454980974345.8799163282779; Fri, 8 Jun 2018 03:49:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 700858553F; Fri, 8 Jun 2018 10:49:38 +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 8C1CF308BDAA; Fri, 8 Jun 2018 10:49:37 +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 3D2194CA80; Fri, 8 Jun 2018 10:49:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w58AnYhF021348 for ; Fri, 8 Jun 2018 06:49:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5219F6887A; Fri, 8 Jun 2018 10:49:34 +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 49EB968879 for ; Fri, 8 Jun 2018 10:49:29 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 7CE78307C942 for ; Fri, 8 Jun 2018 10:49:28 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w58AnQUf129204 for ; Fri, 8 Jun 2018 06:49:28 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jfqpt1mav-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 08 Jun 2018 06:49:27 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Jun 2018 11:49:14 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 8 Jun 2018 11:49:12 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w58AnBHl26738740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 Jun 2018 10:49:11 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B54CB4C046; Fri, 8 Jun 2018 11:40:28 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EEDB4C04E; Fri, 8 Jun 2018 11:40:28 +0100 (BST) Received: from marc-ibm.boeblingen.de.ibm.com (unknown [9.152.97.129]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 8 Jun 2018 11:40:28 +0100 (BST) From: Marc Hartmayer To: Date: Fri, 8 Jun 2018 12:49:07 +0200 X-TM-AS-GCONF: 00 x-cbid: 18060810-0012-0000-0000-0000027D3813 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18060810-0013-0000-0000-000020AE3AEE Message-Id: <20180608104907.16149-1-mhartmay@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-08_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806080125 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 08 Jun 2018 10:49:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 08 Jun 2018 10:49:28 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Marc Hartmayer Subject: [libvirt] [PATCH] qemu: Fix segmentation fault on reconnect 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.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 08 Jun 2018 10:49:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" On start up of libvirtd the worker pool of the QEMU driver must be initialized before trying to reconnect to all the running QEMU instances. Otherwise segmentation faults can occur if there are QEMU monitor events emitted. #0 __GI___pthread_mutex_lock (mutex=3Dmutex@entry=3D0x40) at ../nptl/pthr= ead_mutex_lock.c:67 #1 0x000003fffdba9e62 in virMutexLock (m=3Dm@entry=3D0x40) at ../../src/u= til/virthread.c:89 #2 0x000003fffdbab2dc in virThreadPoolSendJob (pool=3D0x0, priority=3Dpri= ority@entry=3D0, jobData=3D0x1000b7210) at ../../src/util/virthreadpool.c:3= 86 #3 0x000003ffd8343b70 in qemuProcessHandleSerialChanged (mon=3D, vm=3D0x3ff70074340, devAlias=3D, connected=3D, opaque=3D0x3ff70013f70) at ../../src/qemu/qemu_process.c:1480 #4 0x000003ffd836a776 in qemuMonitorEmitSerialChange (mon=3Dmon@entry=3D0= x3ff500013f0, devAlias=3DdevAlias@entry=3D0x1000b6940 "channel0", connected= =3D) at ../../src/qemu/qemu_monitor.c:1558 #5 0x000003ffd8378e52 in qemuMonitorJSONHandleSerialChange (mon=3D0x3ff50= 0013f0, data=3D0x1000b79a0) at ../../src/qemu/qemu_monitor_json.c:1133 #6 0x000003ffd8378930 in qemuMonitorJSONIOProcessEvent (mon=3D, mon@entry=3D0x3ff500013f0, obj=3Dobj@entry=3D0x1000b6780) at ../../sr= c/qemu/qemu_monitor_json.c:182 #7 0x000003ffd837edee in qemuMonitorJSONIOProcessLine (mon=3D0x3ff500013f= 0, mon@entry=3D, line= =3D0x1000b8760 "{\"timestamp\": {\"seconds\": 1528444997, \"microseconds\":= 125231}, \"event\": \"VSERPORT_CHANGE\", \"data\": {\"open\": false, \"id\= ": \"channel0\"}}", msg=3D0x3ff917f9850, msg@entry=3D) at ../../src/qemu/qemu_monitor_json.c:211 #8 0x000003ffd837ef86 in qemuMonitorJSONIOProcess (mon=3D,= mon@entry=3D0x3ff500013f0, data=3D0x10008c4c0 "{\"return\": [{\"arch\": \"= other\", \"current\": true, \"props\": {\"core-id\": 0}, \"CPU\": 0, \"qom_= path\": \"/machine/unattached/device[0]\", \"halted\": false, \"thread_id\"= : 131501}, {\"arch\": \"other\", \"current\": false"..., len=3D477, msg=3D<= optimized out>, msg@entry=3D0x3ff917f9850) at ../../src/qemu/qemu_monitor_j= son.c:253 #9 0x000003ffd836757a in qemuMonitorIOProcess (mon=3Dmon@entry=3D0x3ff500= 013f0) at ../../src/qemu/qemu_monitor.c:447 #10 0x000003ffd836863e in qemuMonitorIO (watch=3D, fd=3D, events=3D0, events@ent= ry=3D, opaque=3D0x3ff= 500013f0, opaque@entry=3D) at ../../src/qemu/qemu_monitor.c:702 #11 0x000003fffdb4033a in virEventPollDispatchHandles (nfds=3D, fds=3D0x1000b7160) at ../../src/util/vireventpoll.c:508 #12 0x000003fffdb4055e in virEventPollRunOnce () at ../../src/util/vireven= tpoll.c:657 #13 0x000003fffdb3e782 in virEventRunDefaultImpl () at ../../src/util/vire= vent.c:327 #14 0x000003fffdc89400 in virNetDaemonRun (dmn=3D0x1000b2510) at ../../src= /rpc/virnetdaemon.c:850 #15 0x000000010002a816 in main (argc=3D, argv=3D) at ../../src/remote/remote_daemon.c:1460 Signed-off-by: Marc Hartmayer Reviewed-by: Bjoern Walk Reviewed-by: Boris Fiuczynski Reviewed-by: Erik Skultety --- src/qemu/qemu_driver.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 971cf3c2750a..28769878cc58 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -932,12 +932,15 @@ qemuStateInitialize(bool privileged, qemuDomainManagedSaveLoad, qemu_driver); =20 - qemuProcessReconnectAll(qemu_driver); - + /* must be initialized before trying to reconnect to all the + * running domains since there might occur some QEMU monitor + * events that will be dispatched to the worker pool */ qemu_driver->workerPool =3D virThreadPoolNew(0, 1, 0, qemuProcessEvent= Handler, qemu_driver); if (!qemu_driver->workerPool) goto error; =20 + qemuProcessReconnectAll(qemu_driver); + virNWFilterRegisterCallbackDriver(&qemuCallbackDriver); return 0; =20 --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list