From nobody Mon Feb 9 02:51:07 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=1586526997; cv=none; d=zohomail.com; s=zohoarc; b=OtxFt43MIaMVzFfKI408+P4wny4bEfrW2Icu28jYl+sz1D6HgmAeTJteXhBZc14pyLxx+l6Q7kX65dGP53SY1m3TB3zv1cpBYTC5ZsV34P2nFK/RMUInEz+CwxQtEe3FlOJ7VQFVPxSEW9f8pGTqJe8OrbsUXwMSC4M/k42iKEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586526997; 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=Ku6oT5e8UajixcANt4nJYSAxS2hCF5HAv4nSUloxL58=; b=Zb4eM96aqs/AMtjlmpcBLRXnDdBqns5/XOElO7ZQNyv8ZPdHG8moNma9zfcIMeP1MW3CY4iUtFQZhMKYgC6FRdohYoL4jvOh4FMs7sVrKxrL/egUJFXD3V6atcsbpSuEc4sDFj4EKlWEgAX6Jby4/mXLhlhKm1wMoOJLCO6yKf0= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1586526997170338.1540944420325; Fri, 10 Apr 2020 06:56:37 -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-165-RGtQYwFNMFKpWtgnmf3jew-1; Fri, 10 Apr 2020 09:56:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 159098018AF; Fri, 10 Apr 2020 13:56:25 +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 D5EB95DA75; Fri, 10 Apr 2020 13:56:24 +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 8858818034F0; Fri, 10 Apr 2020 13:56:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03ADu0cR023115 for ; Fri, 10 Apr 2020 09:56:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id A75E92028CD6; Fri, 10 Apr 2020 13:56:00 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A310920230A6 for ; Fri, 10 Apr 2020 13:56:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 E1260101A55E for ; Fri, 10 Apr 2020 13:55:59 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-128-1UfjR3KfM_CpO-rDhkGmGw-1; Fri, 10 Apr 2020 09:55:56 -0400 Received: by mail-wr1-f66.google.com with SMTP id f13so2344935wrm.13 for ; Fri, 10 Apr 2020 06:55:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 06:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586526996; 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=Ku6oT5e8UajixcANt4nJYSAxS2hCF5HAv4nSUloxL58=; b=HV4GpM9hA9exhnOvzm2VmBv/j/GrthxPkvaLhY9uziYeKtmLqkVhSDL2zEyIJUhrXkz383 U/EQUVmfyRwMHa1jOVLKN/yxaKIVlCXscbSRjEPExwQJdsgHzwfSiRBgX05xgv6y478lD6 04SBt1sZoOfJXO3jiLdcz8RMD9094us= X-MC-Unique: RGtQYwFNMFKpWtgnmf3jew-1 X-MC-Unique: 1UfjR3KfM_CpO-rDhkGmGw-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=ge0EKJiKJO3NQu39M1t4j2pgVbMRAEvVyWz7jl3grnI=; b=AOhTaFi721fwvz1F279ez0eGifStZj/nWJo+319tOHigv9IF1ppIwgm1HcYNVaMhRi ZYBWCIbx+trQmrvsnm4uU/6FB/l38/0uQyTHz+QBfPj7Lbzo52my7p6KwTToZI8ipvVw K06T+699Y/DheqG4m2H3uLsbdhLpvG892XNL7ut1Oae3GhTo82VvOGuV86kuCIB/AznX x0T3Nh5lrx0qng3KFvEANNMutFb+KMa4M3Amvhej7vCJLj5ZYj9DJuOuRWdLKKR6jtgV 4wkZX+SB6qV7nZeSSxr0Zb6nLbyU2yRBw4wf39ypo7NL14aUDU5fHpDvaLEdJCRfnX8w 136g== X-Gm-Message-State: AGi0Pub65b4ATRzKq4sqKRgysBHMtwAm7iSJBT8bCaUF6W/t1rSPbWs8 Jmdw3oy0P81vzvfJ2RWVVW5xI0ZnodU= X-Google-Smtp-Source: APiQypKXl7wLUdzO++dRiapWhnSY5UE3VuHqa5E9iTxGDXe8rKNu0QfsRVkqMW5X/RnrK0OyqxMjOA== X-Received: by 2002:adf:a350:: with SMTP id d16mr4949861wrb.277.1586526955209; Fri, 10 Apr 2020 06:55:55 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH 21/43] node_device: convert virMutex to GMutex Date: Fri, 10 Apr 2020 15:54:48 +0200 Message-Id: <20200410135510.2148319-22-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.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03ADu0cR023115 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.14 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 --- src/conf/virnodedeviceobj.h | 4 ++-- src/node_device/node_device_driver.c | 11 +++-------- src/node_device/node_device_hal.c | 20 +++++--------------- src/node_device/node_device_udev.c | 21 +++++---------------- 4 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/conf/virnodedeviceobj.h b/src/conf/virnodedeviceobj.h index c9df8dedab..2ffefddd20 100644 --- a/src/conf/virnodedeviceobj.h +++ b/src/conf/virnodedeviceobj.h @@ -35,8 +35,8 @@ typedef virNodeDeviceObjList *virNodeDeviceObjListPtr; typedef struct _virNodeDeviceDriverState virNodeDeviceDriverState; typedef virNodeDeviceDriverState *virNodeDeviceDriverStatePtr; struct _virNodeDeviceDriverState { - virMutex lock; - virCond initCond; + GMutex lock; + GCond initCond; bool initialized; =20 /* pid file FD, ensures two copies of the driver can't use the same ro= ot */ diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ee175e1095..7d626948ec 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -145,14 +145,14 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def G_= GNUC_UNUSED) void nodeDeviceLock(void) { - virMutexLock(&driver->lock); + g_mutex_lock(&driver->lock); } =20 =20 void nodeDeviceUnlock(void) { - virMutexUnlock(&driver->lock); + g_mutex_unlock(&driver->lock); } =20 =20 @@ -161,12 +161,7 @@ nodeDeviceWaitInit(void) { nodeDeviceLock(); while (!driver->initialized) { - if (virCondWait(&driver->initCond, &driver->lock) < 0) { - virReportSystemError(errno, "%s", - _("failed to wait on condition")); - nodeDeviceUnlock(); - return -1; - } + g_cond_wait(&driver->initCond, &driver->lock); } nodeDeviceUnlock(); return 0; diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 53a49ba2aa..fe78c3c4ae 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -607,18 +607,8 @@ nodeStateInitialize(bool privileged G_GNUC_UNUSED, return VIR_DRV_STATE_INIT_ERROR; =20 driver->lockFD =3D -1; - if (virMutexInit(&driver->lock) < 0) { - VIR_FREE(driver); - return VIR_DRV_STATE_INIT_ERROR; - } - - if (virCondInit(&driver->initCond) < 0) { - virReportSystemError(errno, "%s", - _("Unable to initialize condition variable")); - virMutexDestroy(&driver->lock); - VIR_FREE(driver); - return VIR_DRV_STATE_INIT_ERROR; - } + g_mutex_init(&driver->lock); + g_cond_init(&driver->initCond); =20 nodeDeviceLock(); =20 @@ -713,7 +703,7 @@ nodeStateInitialize(bool privileged G_GNUC_UNUSED, nodeDeviceLock(); driver->initialized =3D true; nodeDeviceUnlock(); - virCondBroadcast(&driver->initCond); + g_cond_broadcast(&driver->initCond); =20 return VIR_DRV_STATE_INIT_COMPLETE; =20 @@ -747,8 +737,8 @@ nodeStateCleanup(void) =20 VIR_FREE(driver->stateDir); nodeDeviceUnlock(); - virCondDestroy(&driver->initCond); - virMutexDestroy(&driver->lock); + g_cond_clear(&driver->initCond); + g_mutex_clear(&driver->lock); VIR_FREE(driver); return 0; } diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 8451903e8a..433de0aae0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1477,8 +1477,8 @@ nodeStateCleanup(void) virPidFileRelease(driver->stateDir, "driver", driver->lockFD); =20 VIR_FREE(driver->stateDir); - virCondDestroy(&driver->initCond); - virMutexDestroy(&driver->lock); + g_cond_clear(&driver->initCond); + g_mutex_clear(&driver->lock); VIR_FREE(driver); =20 udevPCITranslateDeinit(); @@ -1748,7 +1748,7 @@ nodeStateInitializeEnumerate(void *opaque) nodeDeviceLock(); driver->initialized =3D true; nodeDeviceUnlock(); - virCondBroadcast(&driver->initCond); + g_cond_broadcast(&driver->initCond); =20 return; =20 @@ -1806,19 +1806,8 @@ nodeStateInitialize(bool privileged, return VIR_DRV_STATE_INIT_ERROR; =20 driver->lockFD =3D -1; - if (virMutexInit(&driver->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to initialize mutex")); - VIR_FREE(driver); - return VIR_DRV_STATE_INIT_ERROR; - } - if (virCondInit(&driver->initCond) < 0) { - virReportSystemError(errno, "%s", - _("Unable to initialize condition variable")); - virMutexDestroy(&driver->lock); - VIR_FREE(driver); - return VIR_DRV_STATE_INIT_ERROR; - } + g_mutex_init(&driver->lock); + g_cond_init(&driver->initCond); =20 driver->privileged =3D privileged; =20 --=20 2.25.2