From nobody Mon Feb 9 08:55:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1586526995; cv=none; d=zohomail.com; s=zohoarc; b=NFTLvR/uNsx+tmSLtafTcFVVr0MiPEF450Nt/nsTmOztatwTFMDE5pK44K6u93G1y2C5aSv47o2UCCMJ4pZ2uJVNTj2Vqrz+d552N/PdWc0rZm9H9gBTXG8RokmGZ7gZUAF9oodXWvCwfkDhUHxWJUuwod6CfYUlaqaE1tZsGok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586526995; 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=7CjHuyBOllDQjQAcn3i/7vpMZukXH7ZZtAfdqpYWEog=; b=ArUX0FVtKQn0HLtUptr2PTni7zkWKwZXH7Gnx4+O5lcrQNDj4dcPnxnc38ETbtHy4ll0IiZIOWtAMQkYk5hk+LLoGhvtTdOaHcd8SO2+CIcIAiZP3iiFPk4GnnmVoKZHs2kJDFwC6xFMMVYb4C5QrE2967Ic2u5ZE9ay/Hr/VZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1586526995286407.61451350815537; Fri, 10 Apr 2020 06:56:35 -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-329-HwuvuSc4M1SBXAPrE1DRAA-1; Fri, 10 Apr 2020 09:56:30 -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 A5049DB2E; Fri, 10 Apr 2020 13:56:24 +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 77B215C557; 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 2A55493A90; Fri, 10 Apr 2020 13:56:24 +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 03ADu2YO023141 for ; Fri, 10 Apr 2020 09:56:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id F10912166B36; Fri, 10 Apr 2020 13:56:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECE582166B34 for ; Fri, 10 Apr 2020 13:55:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 9DC338007A4 for ; Fri, 10 Apr 2020 13:55:56 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-ss3bfyEGNW2JFXqGg9z_Dg-1; Fri, 10 Apr 2020 09:55:54 -0400 Received: by mail-wm1-f68.google.com with SMTP id x25so2592096wmc.0 for ; Fri, 10 Apr 2020 06:55:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 06:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586526993; 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=7CjHuyBOllDQjQAcn3i/7vpMZukXH7ZZtAfdqpYWEog=; b=fRfaNv9AIHCWRfaOtDubaqpZ3w3eM/C+03urFwHJnH6WSbzBxZXK3H0nbErf+uiHA/DZoS xpQtRc29W9GUax/9040Nn+NvdafCcd/+QTexVLAXqHifvw2xO/Q6m+0NWznfjFKwLj425j qSKWKrQRjktAIrtHlixl+CTq8dTBb50= X-MC-Unique: HwuvuSc4M1SBXAPrE1DRAA-1 X-MC-Unique: ss3bfyEGNW2JFXqGg9z_Dg-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=FA82rId+cf2ARlZu9zgOLc+DKaEssS14av5jv6Lc4gs=; b=jA29i7bJUePkNHxIr6V9DTqpLSTYJ1T8z0LJ1Up2io0x6vHxPe9NTJ4u9r+y7ZYZT8 D5uqI7RYq9dI0odeVxIlBARUo3V4EH7KlWD7GDfyCDOXqEDoIk0AhC0nuK2Y2XjGtT6M 9cFuH+wKZIekRd1e3DA9mFSPRLo1LicvSTosmB8iRlLx26l9H9NlahZrM8gYNQOS+6aY 4/sLjFpNbQ/0AetKo3x1Qy/aGxSpTfc1tgSP/3hCtbVg7Oxo6y5NJCGJMEiBbAkVzB9m bj/gu5iMUzDzkwVLJFytScPqd1n8H4XfCl3DT+luUqNu2QNNFAtJyPPX/G42FOxhrn33 IFHQ== X-Gm-Message-State: AGi0PuZ4fE+rXg1nKA32D19ejImdb35ju/G9sNzCAkGhb6dp81k5tPfL 6CLVhic8SeYnhZTEYugT6RGSLdNSyVY= X-Google-Smtp-Source: APiQypJsHNeYQgIIaUo4IJ6zWvfXzKfll6O3eYhf+WQwdtt2INO/fHs9mUDW7ZC+yTzmIPp3eI7JQg== X-Received: by 2002:a7b:c010:: with SMTP id c16mr5596052wmb.73.1586526952668; Fri, 10 Apr 2020 06:55:52 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH 19/43] lxc: convert virMutex to GMutex Date: Fri, 10 Apr 2020 15:54:46 +0200 Message-Id: <20200410135510.2148319-20-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 03ADu2YO023141 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 --- src/lxc/lxc_conf.h | 6 +++--- src/lxc/lxc_controller.c | 25 ++++++++++--------------- src/lxc/lxc_driver.c | 7 ++----- tests/testutilslxc.c | 9 ++------- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index f2f0e0a570..27cb861c08 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -64,7 +64,7 @@ struct _virLXCDriverConfig { }; =20 struct _virLXCDriver { - virMutex lock; + GMutex lock; =20 /* Require lock to get reference on 'config', * then lockless thereafter */ @@ -116,9 +116,9 @@ virDomainXMLOptionPtr lxcDomainXMLConfInit(virLXCDriver= Ptr driver); =20 static inline void lxcDriverLock(virLXCDriverPtr driver) { - virMutexLock(&driver->lock); + g_mutex_lock(&driver->lock); } static inline void lxcDriverUnlock(virLXCDriverPtr driver) { - virMutexUnlock(&driver->lock); + g_mutex_unlock(&driver->lock); } diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 453b435dd6..f7394c53a6 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -161,12 +161,7 @@ virLXCControllerDriverNew(void) { virLXCDriverPtr driver =3D g_new0(virLXCDriver, 1); =20 - if (virMutexInit(&driver->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); - g_free(driver); - return NULL; - } + g_mutex_init(&driver->lock); =20 driver->caps =3D virLXCDriverCapsInit(NULL); driver->xmlopt =3D lxcDomainXMLConfInit(driver); @@ -182,7 +177,7 @@ virLXCControllerDriverFree(virLXCDriverPtr driver) return; virObjectUnref(driver->xmlopt); virObjectUnref(driver->caps); - virMutexDestroy(&driver->lock); + g_mutex_clear(&driver->lock); g_free(driver); } =20 @@ -1034,7 +1029,7 @@ static int lxcControllerClearCapabilities(void) } =20 static bool wantReboot; -static virMutex lock =3D VIR_MUTEX_INITIALIZER; +G_LOCK_DEFINE_STATIC(lock); =20 =20 static void virLXCControllerSignalChildIO(virNetDaemonPtr dmn, @@ -1049,13 +1044,13 @@ static void virLXCControllerSignalChildIO(virNetDae= monPtr dmn, VIR_DEBUG("Got sig child %d vs %lld", ret, (long long)ctrl->initpid); if (ret =3D=3D ctrl->initpid) { virNetDaemonQuit(dmn); - virMutexLock(&lock); + G_LOCK(lock); if (WIFSIGNALED(status) && WTERMSIG(status) =3D=3D SIGHUP) { VIR_DEBUG("Status indicates reboot"); wantReboot =3D true; } - virMutexUnlock(&lock); + G_UNLOCK(lock); } } =20 @@ -1169,7 +1164,7 @@ static void virLXCControllerConsoleEPoll(int watch, i= nt fd, int events, void *op { virLXCControllerConsolePtr console =3D opaque; =20 - virMutexLock(&lock); + G_LOCK(lock); VIR_DEBUG("IO event watch=3D%d fd=3D%d events=3D%d fromHost=3D%zu from= cont=3D%zu", watch, fd, events, console->fromHostLen, @@ -1209,14 +1204,14 @@ static void virLXCControllerConsoleEPoll(int watch,= int fd, int events, void *op } =20 cleanup: - virMutexUnlock(&lock); + G_UNLOCK(lock); } =20 static void virLXCControllerConsoleIO(int watch, int fd, int events, void = *opaque) { virLXCControllerConsolePtr console =3D opaque; =20 - virMutexLock(&lock); + G_LOCK(lock); VIR_DEBUG("IO event watch=3D%d fd=3D%d events=3D%d fromHost=3D%zu from= cont=3D%zu", watch, fd, events, console->fromHostLen, @@ -1290,7 +1285,7 @@ static void virLXCControllerConsoleIO(int watch, int = fd, int events, void *opaqu } =20 virLXCControllerConsoleUpdateWatch(console); - virMutexUnlock(&lock); + G_UNLOCK(lock); return; =20 error: @@ -1298,7 +1293,7 @@ static void virLXCControllerConsoleIO(int watch, int = fd, int events, void *opaqu virEventRemoveHandle(console->hostWatch); console->contWatch =3D console->hostWatch =3D -1; virNetDaemonQuit(console->daemon); - virMutexUnlock(&lock); + G_UNLOCK(lock); } =20 =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7b232b4bac..3253c08117 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1494,10 +1494,7 @@ static int lxcStateInitialize(bool privileged, if (VIR_ALLOC(lxc_driver) < 0) return VIR_DRV_STATE_INIT_ERROR; lxc_driver->lockFD =3D -1; - if (virMutexInit(&lxc_driver->lock) < 0) { - VIR_FREE(lxc_driver); - return VIR_DRV_STATE_INIT_ERROR; - } + g_mutex_init(&lxc_driver->lock); =20 if (!(lxc_driver->domains =3D virDomainObjListNew())) goto cleanup; @@ -1631,7 +1628,7 @@ static int lxcStateCleanup(void) virPidFileRelease(lxc_driver->config->stateDir, "driver", lxc_driv= er->lockFD); =20 virObjectUnref(lxc_driver->config); - virMutexDestroy(&lxc_driver->lock); + g_mutex_clear(&lxc_driver->lock); VIR_FREE(lxc_driver); =20 return 0; diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index b5e2f542e7..1e04263d1f 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -63,12 +63,7 @@ testLXCDriverInit(void) { virLXCDriverPtr driver =3D g_new0(virLXCDriver, 1); =20 - if (virMutexInit(&driver->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", "cannot initialize mutex"); - g_free(driver); - return NULL; - } + g_mutex_init(&driver->lock); =20 driver->caps =3D testLXCCapsInit(); driver->xmlopt =3D lxcDomainXMLConfInit(driver); @@ -82,7 +77,7 @@ testLXCDriverFree(virLXCDriverPtr driver) { virObjectUnref(driver->xmlopt); virObjectUnref(driver->caps); - virMutexDestroy(&driver->lock); + g_mutex_clear(&driver->lock); g_free(driver); } =20 --=20 2.25.2