From nobody Fri May 3 03:01:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1584038219; cv=none; d=zohomail.com; s=zohoarc; b=MDNbbRIIhPIGgJrRUKFQi0ubMhAqoTq5trKQ6tXqQ1SYMNx60WgNllfAqIGcgSLbLo86fyjpvg/xDu9LOMarwlI/1WXl2aoziuNEo6R2+LGvfpM+bR+IkGXGDhSaQtvITu8jAHcqMUWbdYb3voAevBkps03z+pJqmW+oW6JO594= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584038219; 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; bh=oirlDv5NTEsHrtV0slvQ2MbGOj8ZnwUmQV3R3eaw9ck=; b=OBXwrXuFT6jgEbPzkwO/hA55khxedl3OercZr03vBlsT8htpEKFZonvXNJKn26/EAjys9AbT9wRynHQQBSxVK7kRbyaIxOrBPy/02TVrhn6YYvie8JOzWe3ytjuXsleao8Hf7iGdjkT7r2fG0i4R9ufJhF7xl6ufdXLTonN8rvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584038219578973.5628592679899; Thu, 12 Mar 2020 11:36:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-83-NB-fCVHcN9CuErjogXQ0ew-1; Thu, 12 Mar 2020 14:36:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E60813F6; Thu, 12 Mar 2020 18:36:48 +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 DCCD25C1B5; Thu, 12 Mar 2020 18:36:47 +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 1967685EC3; Thu, 12 Mar 2020 18:36:46 +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 02CIai7n001655 for ; Thu, 12 Mar 2020 14:36:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id B15E75C1D4; Thu, 12 Mar 2020 18:36:44 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDF525C1C3; Thu, 12 Mar 2020 18:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584038218; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oirlDv5NTEsHrtV0slvQ2MbGOj8ZnwUmQV3R3eaw9ck=; b=fCDD2TgERH8KMqP5+zUSsm6/8ffAw6pLDKNb/SU5yYHLnaIKSro1/2mYKqN8erJiRQBxPk Ry0bSAgrjtG9iTIyzXOlE1ij0G2bT7JDdOhTDk1uHi8sOaZARU+AN7wtNG1bLKUjcTQkCX pstjNGcxrgGypvc5U2RkfZfeEr+xxNQ= X-MC-Unique: NB-fCVHcN9CuErjogXQ0ew-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] tests: fix double-lock of monitor in hotplug test Date: Thu, 12 Mar 2020 18:36:38 +0000 Message-Id: <20200312183638.961024-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The qemuMonitorTestNew() function returns with the monitor object locked, and expects it to still be locked when qemuMonitorTestFree is called. The qemuhotplug test, however, explicitly unlocks the monitor, but then forgets to lock it again. As a result the qemuMonitorTestFree function is unlocking a mutex it doesn't own. This bug has existed forever, but since we use normal POSIX mutexes and don't check the return value of pthread_mutex_lock/unlock we didn't see the error. It was harmless until the switch to the per monitor event loop which requires the thread synchronization to work reliably, whereupon it started crashing. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Krempa --- tests/qemuhotplugtest.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 8b411d63f0..d9244dca44 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -337,6 +337,8 @@ testQemuHotplug(const void *data) ret =3D testQemuHotplugUpdate(vm, dev); } =20 + virObjectLock(priv->mon); + cleanup: VIR_FREE(domain_filename); VIR_FREE(device_filename); @@ -378,6 +380,7 @@ static void testQemuHotplugCpuDataFree(struct testQemuHotplugCpuData *data) { qemuDomainObjPrivatePtr priv; + qemuMonitorPtr mon; =20 if (!data) return; @@ -396,6 +399,8 @@ testQemuHotplugCpuDataFree(struct testQemuHotplugCpuDat= a *data) virObjectUnref(data->vm); } =20 + mon =3D qemuMonitorTestGetMonitor(data->mon); + virObjectLock(mon); qemuMonitorTestFree(data->mon); VIR_FREE(data); } --=20 2.24.1