From nobody Mon Feb 9 12:09:00 2026 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1586526998; cv=none; d=zohomail.com; s=zohoarc; b=TKjB39KAM5hsJcLnFYnT3w1rF6iyBEd/uybk1xfjIYdZjtCZtS9tY4amhr0Dhr/iHFMHBxVCz2WurLxXz/ppFwc0CJbO5A1mm2QIpOrXH9EKSQUXq8hEs4B5FAPlHjpNtiqzTzycnnkDr+ebtPWMI6qNYIdbdoTFIvpLbeo9S2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586526998; h=Content-Type:Content-Transfer-Encoding:Cc: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=WF5OMQ9XyGWO3co8AGSnd9SOCoJ3xZ16uQsRjfuCX1E=; b=SmyOvwv4aCH9/7UxCWu8bWyxTwhc2+IapNDn9NztHJfdlCmBEkxLSOxIVgq8mtmiQFQP38rh07ovO6fvcKJD3VjPWXaGPInlgBB5XJrbLn9HKAF1GX6vq0AijTkx9OiOYdvsqLbJNUXYbMDPRu7Wv+uGqfDsN6f4++BW/oXNuVU= 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1586526998375765.6014917866246; Fri, 10 Apr 2020 06:56:38 -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-211-waQIsdCkNKO1QvJ1vcsguQ-1; Fri, 10 Apr 2020 09:56:34 -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 4485010509C3; Fri, 10 Apr 2020 13:56:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C6295C557; Fri, 10 Apr 2020 13:56:28 +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 CFF3E18034FA; Fri, 10 Apr 2020 13:56:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03ADu3b1023164 for ; Fri, 10 Apr 2020 09:56:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C28B2166B35; Fri, 10 Apr 2020 13:56:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 381932166B34 for ; Fri, 10 Apr 2020 13:56:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1EEAB185A78E for ; Fri, 10 Apr 2020 13:56:03 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-ZVZonxRvND-DquroU4QAJQ-1; Fri, 10 Apr 2020 09:56:00 -0400 Received: by mail-wm1-f65.google.com with SMTP id z6so2820126wml.2 for ; Fri, 10 Apr 2020 06:56:00 -0700 (PDT) Received: from localhost.localdomain (public-gprs377075.centertel.pl. [37.47.104.52]) by smtp.gmail.com with ESMTPSA id c11sm3066319wrt.24.2020.04.10.06.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 06:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586526997; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=WF5OMQ9XyGWO3co8AGSnd9SOCoJ3xZ16uQsRjfuCX1E=; b=gC+5ei/GUC1OVub/zOQEEn/2GNDAzz2AJ0BvvhEuUESXLjwOWwq1a8W7WVmfClT6PeFiyR MjC+PEo6sQu2UIclibc9nmmSxAHVvzb2mqxVpnjZ6AdkPnF9CvRrSPznIUndVP8FDsf6hD UnOK6RDwNwxNZ33Gz3Eftv3EgmtI6vI= X-MC-Unique: waQIsdCkNKO1QvJ1vcsguQ-1 X-MC-Unique: ZVZonxRvND-DquroU4QAJQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2taPmXOIwF8fGqqXksvcm3KVXyIxxVYMOaemBVtDXgs=; b=VdJ3BQtrQduP/LmJEyJ139SB1plZL5VsV4bxPwpgshRE4Z0/bvMlOaxu3tfKmrdkQ4 ahptId/oSAAZXNwIPdYJWI9kGiQqsNEOzyabvQksNnhpjKT9YpqWvhmi4MtMNn26sQIm wHfvD9FoVo0CuU8FjPgEEfcy/RMjU6LLwldmW8imMG2yokExgqrTFtHROHB/FQPjqnSD QPpbCQHoHkv6m0hZEJFP1XWNPAdLOQL9BUiMHgw22lUjSccXJuAjNChQZGjm8opX1v5c yD6t0Nc/So3LgHp4/HhfALbGo9myc98sFQljVTI9ABh3Jmfgb2ToMj+XYjFc7SnzfPCY gNtQ== X-Gm-Message-State: AGi0Pua/hOuFvvpxtPB9699PrUfJuQnyxKyNNXwT0k52q2dnpMVUrCcU v5H21lIZWuMb1hsLkQ5RP64/j/G2pCM= X-Google-Smtp-Source: APiQypIbnH0uXSmfFoP3wZWzu1YqR6XC4eSxCIKFegCAba6WKyNLROgsbvalNBcXRoRpny5CHsLkcQ== X-Received: by 2002:a05:600c:20c:: with SMTP id 12mr5183729wmi.158.1586526958729; Fri, 10 Apr 2020 06:55:58 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH 24/43] tests: qemumonitortestutils: convert virMutex to GMutex Date: Fri, 10 Apr 2020 15:54:51 +0200 Message-Id: <20200410135510.2148319-25-r4f4rfs@gmail.com> In-Reply-To: <20200410135510.2148319-1-r4f4rfs@gmail.com> References: <20200410135510.2148319-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03ADu3b1023164 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca 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" Signed-off-by: Rafael Fonseca --- tests/qemumonitortestutils.c | 37 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 992d2a4e71..78fc94e710 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -49,7 +49,7 @@ struct _qemuMonitorTestItem { }; =20 struct _qemuMonitorTest { - virMutex lock; + GMutex lock; virThread thread; =20 bool quit; @@ -233,10 +233,9 @@ qemuMonitorTestIO(virNetSocketPtr sock, { qemuMonitorTestPtr test =3D opaque; bool err =3D false; + g_autoptr(GMutexLocker) locker =3D g_mutex_locker_new(&test->lock); =20 - virMutexLock(&test->lock); if (test->quit) { - virMutexUnlock(&test->lock); return; } if (events & VIR_EVENT_HANDLE_WRITABLE) { @@ -320,7 +319,6 @@ qemuMonitorTestIO(virNetSocketPtr sock, =20 virNetSocketUpdateIOCallback(sock, events); } - virMutexUnlock(&test->lock); } =20 =20 @@ -329,23 +327,23 @@ qemuMonitorTestWorker(void *opaque) { qemuMonitorTestPtr test =3D opaque; =20 - virMutexLock(&test->lock); + g_mutex_lock(&test->lock); =20 while (!test->quit) { - virMutexUnlock(&test->lock); + g_mutex_unlock(&test->lock); =20 if (virEventRunDefaultImpl() < 0) { - virMutexLock(&test->lock); + g_mutex_lock(&test->lock); test->quit =3D true; break; } =20 - virMutexLock(&test->lock); + g_mutex_lock(&test->lock); } =20 test->running =3D false; =20 - virMutexUnlock(&test->lock); + g_mutex_unlock(&test->lock); return; } =20 @@ -367,13 +365,13 @@ qemuMonitorTestFree(qemuMonitorTestPtr test) if (!test) return; =20 - virMutexLock(&test->lock); + g_mutex_lock(&test->lock); if (test->running) { test->quit =3D true; /* HACK: Add a dummy timeout to break event loop */ timer =3D virEventAddTimeout(0, qemuMonitorTestFreeTimer, NULL, NU= LL); } - virMutexUnlock(&test->lock); + g_mutex_unlock(&test->lock); =20 if (test->client) { virNetSocketRemoveIOCallback(test->client); @@ -414,7 +412,7 @@ qemuMonitorTestFree(qemuMonitorTestPtr test) =20 VIR_FREE(test->tmpdir); =20 - virMutexDestroy(&test->lock); + g_mutex_clear(&test->lock); VIR_FREE(test); } =20 @@ -426,6 +424,7 @@ qemuMonitorTestAddHandler(qemuMonitorTestPtr test, virFreeCallback freecb) { qemuMonitorTestItemPtr item; + g_autoptr(GMutexLocker) locker =3D g_mutex_locker_new(&test->lock); =20 if (VIR_ALLOC(item) < 0) goto error; @@ -434,12 +433,9 @@ qemuMonitorTestAddHandler(qemuMonitorTestPtr test, item->freecb =3D freecb; item->opaque =3D opaque; =20 - virMutexLock(&test->lock); if (VIR_APPEND_ELEMENT(test->items, test->nitems, item) < 0) { - virMutexUnlock(&test->lock); goto error; } - virMutexUnlock(&test->lock); =20 return 0; =20 @@ -1046,12 +1042,7 @@ qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlop= t, if (VIR_ALLOC(test) < 0) goto error; =20 - if (virMutexInit(&test->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - "Cannot initialize mutex"); - VIR_FREE(test); - return NULL; - } + g_mutex_init(&test->lock); =20 tmpdir_template =3D g_strdup("/tmp/libvirt_XXXXXX"); =20 @@ -1103,6 +1094,7 @@ static int qemuMonitorCommonTestInit(qemuMonitorTestPtr test) { int events =3D VIR_EVENT_HANDLE_READABLE; + g_autoptr(GMutexLocker) locker =3D g_mutex_locker_new(&test->lock); =20 if (!test) return -1; @@ -1123,16 +1115,13 @@ qemuMonitorCommonTestInit(qemuMonitorTestPtr test) NULL) < 0) return -1; =20 - virMutexLock(&test->lock); if (virThreadCreate(&test->thread, true, qemuMonitorTestWorker, test) < 0) { - virMutexUnlock(&test->lock); return -1; } test->started =3D test->running =3D true; - virMutexUnlock(&test->lock); =20 return 0; } --=20 2.25.2