From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767429405521.4033028249509; Wed, 17 Oct 2018 02:10:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7896EC051676; Wed, 17 Oct 2018 09:10:27 +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 309115F7CB; Wed, 17 Oct 2018 09:10:27 +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 D117A180B61F; Wed, 17 Oct 2018 09:10:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97Ki7017214 for ; Wed, 17 Oct 2018 05:07:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04DA058D3B; Wed, 17 Oct 2018 09:07:20 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B29A43FF8 for ; Wed, 17 Oct 2018 09:07:16 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:43 +0200 Message-Id: <90b0878bd471244a15989c9e8ea65e27ccd04d45.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 01/13] virprocess: Introduce virProcessRunInFork 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 Oct 2018 09:10:28 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This new helper can be used to spawn a child process and run passed callback from it. This will come handy esp. if the callback is not thread safe. Signed-off-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virprocess.c | 81 ++++++++++++++++++++++++++++++++++++++++ src/util/virprocess.h | 16 ++++++++ 3 files changed, 98 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 335210c31d..e2dc85310a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2625,6 +2625,7 @@ virProcessKill; virProcessKillPainfully; virProcessKillPainfullyDelay; virProcessNamespaceAvailable; +virProcessRunInFork; virProcessRunInMountNamespace; virProcessSchedPolicyTypeFromString; virProcessSchedPolicyTypeToString; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 3883c708fc..51b9ccb1bb 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1165,6 +1165,87 @@ virProcessRunInMountNamespace(pid_t pid, } =20 =20 +static int +virProcessForkHelper(int errfd, + pid_t pid, + virProcessForkCallback cb, + void *opaque) +{ + if (cb(pid, opaque) < 0) { + virErrorPtr err =3D virGetLastError(); + if (err) { + size_t len =3D strlen(err->message) + 1; + ignore_value(safewrite(errfd, err->message, len)); + } + + return -1; + } + + return 0; +} + + +/** + * virProcessRunInFork: + * @cb: callback to run + * @opaque: opaque data to @cb + * + * Do the fork and run @cb in the child. This can be used when + * @cb does something thread unsafe, for instance. However, due + * to possible signal propagation @cb should only call async + * signal safe functions. On return, the returned value is either + * -1 with error message reported if something went bad in the + * parent, if child has died from a signal or if the child + * returned EXIT_CANCELED. Otherwise the returned value is the + * exit status of the child. + */ +int +virProcessRunInFork(virProcessForkCallback cb, + void *opaque) +{ + int ret =3D -1; + pid_t child =3D -1; + pid_t parent =3D getpid(); + int errfd[2] =3D { -1, -1 }; + + if (pipe2(errfd, O_CLOEXEC) < 0) { + virReportSystemError(errno, "%s", + _("Cannot create pipe for child")); + return -1; + } + + if ((child =3D virFork()) < 0) + goto cleanup; + + if (child =3D=3D 0) { + VIR_FORCE_CLOSE(errfd[0]); + ret =3D virProcessForkHelper(errfd[1], parent, cb, opaque); + VIR_FORCE_CLOSE(errfd[1]); + _exit(ret < 0 ? EXIT_CANCELED : ret); + } else { + int status; + VIR_AUTOFREE(char *) buf =3D NULL; + + VIR_FORCE_CLOSE(errfd[1]); + ignore_value(virFileReadHeaderFD(errfd[0], 1024, &buf)); + ret =3D virProcessWait(child, &status, false); + if (!ret) { + ret =3D status =3D=3D EXIT_CANCELED ? -1 : status; + if (ret) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("child reported: %s"), + NULLSTR(buf)); + } + } + } + + cleanup: + VIR_FORCE_CLOSE(errfd[0]); + VIR_FORCE_CLOSE(errfd[1]); + return ret; +} + + #if defined(HAVE_SYS_MOUNT_H) && defined(HAVE_UNSHARE) int virProcessSetupPrivateMountNS(void) diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 5faa0892fe..1bae8c9212 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -93,6 +93,22 @@ int virProcessRunInMountNamespace(pid_t pid, virProcessNamespaceCallback cb, void *opaque); =20 +/** + * virProcessForkCallback: + * @pid: parent's pid + * @opaque: opaque data + * + * Callback to run in fork()-ed process. + * + * Returns: 0 on success, + * -1 on error (treated as EXIT_CANCELED) + */ +typedef int (*virProcessForkCallback)(pid_t pid, + void *opaque); + +int virProcessRunInFork(virProcessForkCallback cb, + void *opaque); + int virProcessSetupPrivateMountNS(void); =20 int virProcessSetScheduler(pid_t pid, --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767434869675.1684811957035; Wed, 17 Oct 2018 02:10:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8BB888E58; Wed, 17 Oct 2018 09:10:32 +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 845F818F0D; Wed, 17 Oct 2018 09:10:32 +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 1062F3D380; Wed, 17 Oct 2018 09:10:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97OdW017226 for ; Wed, 17 Oct 2018 05:07:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36AAE58D26; Wed, 17 Oct 2018 09:07:24 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFA6658D48 for ; Wed, 17 Oct 2018 09:07:20 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:44 +0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 02/13] virprocess: Make virProcessRunInMountNamespace use virProcessRunInFork 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Oct 2018 09:10:33 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Both virProcessRunInMountNamespace() and virProcessRunInFork() look very similar. De-duplicate the code and make virProcessRunInMountNamespace() call virProcessRunInFork(). Signed-off-by: Michal Privoznik --- src/util/virprocess.c | 62 +++++++++---------------------------------- 1 file changed, 12 insertions(+), 50 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 51b9ccb1bb..3304879212 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1073,11 +1073,17 @@ int virProcessGetStartTime(pid_t pid, #endif =20 =20 -static int virProcessNamespaceHelper(int errfd, - pid_t pid, - virProcessNamespaceCallback cb, +typedef struct _virProcessNamespaceHelperData virProcessNamespaceHelperDat= a; +struct _virProcessNamespaceHelperData { + pid_t pid; + virProcessNamespaceCallback cb; + void *opaque; +}; + +static int virProcessNamespaceHelper(pid_t pid ATTRIBUTE_UNUSED, void *opaque) { + virProcessNamespaceHelperData *data =3D opaque; int fd =3D -1; int ret =3D -1; VIR_AUTOFREE(char *) path =3D NULL; @@ -1097,16 +1103,9 @@ static int virProcessNamespaceHelper(int errfd, goto cleanup; } =20 - ret =3D cb(pid, opaque); + ret =3D data->cb(data->pid, data->opaque); =20 cleanup: - if (ret < 0) { - virErrorPtr err =3D virGetLastError(); - if (err) { - size_t len =3D strlen(err->message) + 1; - ignore_value(safewrite(errfd, err->message, len)); - } - } VIR_FORCE_CLOSE(fd); return ret; } @@ -1122,46 +1121,9 @@ virProcessRunInMountNamespace(pid_t pid, virProcessNamespaceCallback cb, void *opaque) { - int ret =3D -1; - pid_t child =3D -1; - int errfd[2] =3D { -1, -1 }; + virProcessNamespaceHelperData data =3D {.pid =3D pid, .cb =3D cb, .opa= que =3D opaque}; =20 - if (pipe2(errfd, O_CLOEXEC) < 0) { - virReportSystemError(errno, "%s", - _("Cannot create pipe for child")); - return -1; - } - - if ((child =3D virFork()) < 0) - goto cleanup; - - if (child =3D=3D 0) { - VIR_FORCE_CLOSE(errfd[0]); - ret =3D virProcessNamespaceHelper(errfd[1], pid, - cb, opaque); - VIR_FORCE_CLOSE(errfd[1]); - _exit(ret < 0 ? EXIT_CANCELED : ret); - } else { - int status; - VIR_AUTOFREE(char *) buf =3D NULL; - - VIR_FORCE_CLOSE(errfd[1]); - ignore_value(virFileReadHeaderFD(errfd[0], 1024, &buf)); - ret =3D virProcessWait(child, &status, false); - if (!ret) { - ret =3D status =3D=3D EXIT_CANCELED ? -1 : status; - if (ret) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("child reported: %s"), - NULLSTR(buf)); - } - } - } - - cleanup: - VIR_FORCE_CLOSE(errfd[0]); - VIR_FORCE_CLOSE(errfd[1]); - return ret; + return virProcessRunInFork(virProcessNamespaceHelper, &data); } =20 =20 --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767441764670.9528911171416; Wed, 17 Oct 2018 02:10:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00FA830833B1; Wed, 17 Oct 2018 09:10:40 +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 9D5A670114; Wed, 17 Oct 2018 09:10:39 +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 2803018005B5; Wed, 17 Oct 2018 09:10:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97lTB017250 for ; Wed, 17 Oct 2018 05:07:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id F060A58D35; Wed, 17 Oct 2018 09:07:46 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B23158D4C for ; Wed, 17 Oct 2018 09:07:24 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:45 +0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 03/13] security: Always spawn process for transactions 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 17 Oct 2018 09:10:40 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the next commit the virSecurityManagerMetadataLock() is going to be turned thread unsafe. Therefore, we have to spawn a separate process for it. Always. Signed-off-by: Michal Privoznik --- src/security/security_dac.c | 2 +- src/security/security_selinux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index da4a6c72fe..580d800bb1 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -563,7 +563,7 @@ virSecurityDACTransactionCommit(virSecurityManagerPtr m= gr ATTRIBUTE_UNUSED, } =20 if ((pid =3D=3D -1 && - virSecurityDACTransactionRun(pid, list) < 0) || + virProcessRunInFork(virSecurityDACTransactionRun, list) < 0) || (pid !=3D -1 && virProcessRunInMountNamespace(pid, virSecurityDACTransactionRun, diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 467d1e6bfe..0e24b9b3ca 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1104,7 +1104,7 @@ virSecuritySELinuxTransactionCommit(virSecurityManage= rPtr mgr ATTRIBUTE_UNUSED, } =20 if ((pid =3D=3D -1 && - virSecuritySELinuxTransactionRun(pid, list) < 0) || + virProcessRunInFork(virSecuritySELinuxTransactionRun, list) < 0) = || (pid !=3D -1 && virProcessRunInMountNamespace(pid, virSecuritySELinuxTransactionRun, --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153976742213716.831134735838305; Wed, 17 Oct 2018 02:10:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7189231524D3; Wed, 17 Oct 2018 09:10:19 +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 DC51F7845A; Wed, 17 Oct 2018 09:10:17 +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 4F5DF19746; Wed, 17 Oct 2018 09:10:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97qtl017260 for ; Wed, 17 Oct 2018 05:07:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id ABCA48B939; Wed, 17 Oct 2018 09:07:51 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F33B58904 for ; Wed, 17 Oct 2018 09:07:47 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:46 +0200 Message-Id: <2a77ceaed6b1dcb02099d9bc726509c57b2d093e.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 04/13] security_manager: Rework metadata locking 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 17 Oct 2018 09:10:20 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Trying to use virlockd to lock metadata turns out to be too big gun. Since we will always spawn a separate process for relabeling we are safe to use thread unsafe POSIX locks and take out virtlockd completely out of the picture. Signed-off-by: Michal Privoznik --- src/security/security_dac.c | 10 +- src/security/security_manager.c | 225 +++++++++++++++++--------------- src/security/security_manager.h | 17 ++- src/security/security_selinux.c | 9 +- 4 files changed, 139 insertions(+), 122 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 580d800bb1..ad2561a241 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -204,6 +204,7 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED, void *opaque) { virSecurityDACChownListPtr list =3D opaque; + virSecurityManagerMetadataLockStatePtr state; const char **paths =3D NULL; size_t npaths =3D 0; size_t i; @@ -216,14 +217,10 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUS= ED, for (i =3D 0; i < list->nItems; i++) { const char *p =3D list->items[i]->path; =20 - if (!p || - virFileIsDir(p)) - continue; - VIR_APPEND_ELEMENT_COPY_INPLACE(paths, npaths, p); } =20 - if (virSecurityManagerMetadataLock(list->manager, paths, npaths) < 0) + if (!(state =3D virSecurityManagerMetadataLock(list->manager, paths, n= paths))) goto cleanup; =20 for (i =3D 0; i < list->nItems; i++) { @@ -246,8 +243,7 @@ virSecurityDACTransactionRun(pid_t pid ATTRIBUTE_UNUSED, break; } =20 - if (virSecurityManagerMetadataUnlock(list->manager, paths, npaths) < 0) - goto cleanup; + virSecurityManagerMetadataUnlock(list->manager, &state); =20 if (rv < 0) goto cleanup; diff --git a/src/security/security_manager.c b/src/security/security_manage= r.c index c6c80e6165..b675f8ab46 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -21,6 +21,10 @@ */ #include =20 +#include +#include +#include + #include "security_driver.h" #include "security_stack.h" #include "security_dac.h" @@ -30,14 +34,11 @@ #include "virlog.h" #include "locking/lock_manager.h" #include "virfile.h" -#include "virtime.h" =20 #define VIR_FROM_THIS VIR_FROM_SECURITY =20 VIR_LOG_INIT("security.security_manager"); =20 -virMutex lockManagerMutex =3D VIR_MUTEX_INITIALIZER; - struct _virSecurityManager { virObjectLockable parent; =20 @@ -47,10 +48,6 @@ struct _virSecurityManager { void *privateData; =20 virLockManagerPluginPtr lockPlugin; - /* This is a FD that represents a connection to virtlockd so - * that connection is kept open in between MetdataLock() and - * MetadataUnlock() calls. */ - int clientfd; }; =20 static virClassPtr virSecurityManagerClass; @@ -66,7 +63,6 @@ void virSecurityManagerDispose(void *obj) mgr->drv->close(mgr); =20 virObjectUnref(mgr->lockPlugin); - VIR_FORCE_CLOSE(mgr->clientfd); =20 VIR_FREE(mgr->privateData); } @@ -119,7 +115,6 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv, mgr->flags =3D flags; mgr->virtDriver =3D virtDriver; VIR_STEAL_PTR(mgr->privateData, privateData); - mgr->clientfd =3D -1; =20 if (drv->open(mgr) < 0) goto error; @@ -1276,129 +1271,153 @@ virSecurityManagerRestoreTPMLabels(virSecurityMan= agerPtr mgr, } =20 =20 -static virLockManagerPtr -virSecurityManagerNewLockManager(virSecurityManagerPtr mgr, - const char * const *paths, - size_t npaths) +struct _virSecurityManagerMetadataLockState { + size_t nfds; + int *fds; +}; + + +static int +cmpstringp(const void *p1, const void *p2) { - virLockManagerPtr lock; - virLockManagerParam params[] =3D { - { .type =3D VIR_LOCK_MANAGER_PARAM_TYPE_UUID, - .key =3D "uuid", - }, - { .type =3D VIR_LOCK_MANAGER_PARAM_TYPE_STRING, - .key =3D "name", - .value =3D { .cstr =3D "libvirtd-sec" }, - }, - { .type =3D VIR_LOCK_MANAGER_PARAM_TYPE_UINT, - .key =3D "pid", - .value =3D { .iv =3D getpid() }, - }, - }; - const unsigned int flags =3D 0; - size_t i; + const char *s1 =3D *(char * const *) p1; + const char *s2 =3D *(char * const *) p2; =20 - if (virGetHostUUID(params[0].value.uuid) < 0) - return NULL; + if (!s1 && !s2) + return 0; =20 - if (!(lock =3D virLockManagerNew(virLockManagerPluginGetDriver(mgr->lo= ckPlugin), - VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON, - ARRAY_CARDINALITY(params), - params, - flags))) - return NULL; + if (!s1 || !s2) + return s2 ? -1 : 1; =20 - for (i =3D 0; i < npaths; i++) { - if (virLockManagerAddResource(lock, - VIR_LOCK_MANAGER_RESOURCE_TYPE_METAD= ATA, - paths[i], 0, NULL, 0) < 0) - goto error; - } - - return lock; - error: - virLockManagerFree(lock); - return NULL; + /* from man 3 qsort */ + return strcmp(s1, s2); } =20 +#define METADATA_OFFSET 1 +#define METADATA_LEN 1 =20 -/* How many seconds should we try to acquire the lock before - * giving up. */ -#define LOCK_ACQUIRE_TIMEOUT 60 - -int -virSecurityManagerMetadataLock(virSecurityManagerPtr mgr, - const char * const *paths, +/** + * virSecurityManagerMetadataLock: + * @mgr: security manager object + * @paths: paths to lock + * @npaths: number of items in @paths array + * + * Lock passed @paths for metadata change. The returned state + * should be passed to virSecurityManagerMetadataUnlock. + * + * NOTE: this function is not thread safe (because of usage of + * POSIX locks). + * + * Returns: state on success, + * NULL on failure. + */ +virSecurityManagerMetadataLockStatePtr +virSecurityManagerMetadataLock(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED, + const char **paths, size_t npaths) { - virLockManagerPtr lock; - virTimeBackOffVar timebackoff; - int fd =3D -1; - int rv =3D -1; - int ret =3D -1; + size_t i =3D 0; + size_t nfds =3D 0; + int *fds =3D NULL; + virSecurityManagerMetadataLockStatePtr ret =3D NULL; =20 - virMutexLock(&lockManagerMutex); + if (VIR_ALLOC_N(fds, npaths) < 0) + return NULL; =20 - if (!(lock =3D virSecurityManagerNewLockManager(mgr, paths, npaths))) - goto cleanup; + /* Sort paths to lock in order to avoid deadlocks. */ + qsort(paths, npaths, sizeof(*paths), cmpstringp); =20 - if (virTimeBackOffStart(&timebackoff, 1, LOCK_ACQUIRE_TIMEOUT * 1000) = < 0) - goto cleanup; - while (virTimeBackOffWait(&timebackoff)) { - rv =3D virLockManagerAcquire(lock, NULL, - VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK, - VIR_DOMAIN_LOCK_FAILURE_DEFAULT, &fd); + for (i =3D 0; i < npaths; i++) { + const char *p =3D paths[i]; + struct stat sb; + int retries =3D 10 * 1000; + int fd; + + if (!p || stat(p, &sb) < 0) + continue; + + if (S_ISDIR(sb.st_mode)) { + /* Directories can't be locked */ + continue; + } + + if ((fd =3D open(p, O_RDWR)) < 0) { + if (S_ISSOCK(sb.st_mode)) { + /* Sockets can be opened only if there exists the + * other side that listens. */ + continue; + } + + virReportSystemError(errno, + _("unable to open %s"), + p); + goto cleanup; + } + + do { + if (virFileLock(fd, false, + METADATA_OFFSET, METADATA_LEN, false) < 0) { + if (retries && (errno =3D=3D EACCES || errno =3D=3D EAGAIN= )) { + /* File is locked. Try again. */ + retries--; + usleep(1000); + continue; + } else { + virReportSystemError(errno, + _("unable to lock %s for metadata= change"), + p); + VIR_FORCE_CLOSE(fd); + goto cleanup; + } + } =20 - if (rv >=3D 0) break; + } while (1); =20 - if (virGetLastErrorCode() =3D=3D VIR_ERR_RESOURCE_BUSY) - continue; - - goto cleanup; + VIR_APPEND_ELEMENT_COPY_INPLACE(fds, nfds, fd); } =20 - if (rv < 0) + if (VIR_ALLOC(ret) < 0) goto cleanup; =20 - mgr->clientfd =3D fd; - fd =3D -1; + VIR_STEAL_PTR(ret->fds, fds); + ret->nfds =3D nfds; + nfds =3D 0; =20 - ret =3D 0; cleanup: - virLockManagerFree(lock); - VIR_FORCE_CLOSE(fd); - if (ret < 0) - virMutexUnlock(&lockManagerMutex); + for (i =3D nfds; i > 0; i--) + VIR_FORCE_CLOSE(fds[i - 1]); + VIR_FREE(fds); return ret; } =20 =20 -int -virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr, - const char * const *paths, - size_t npaths) +void +virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr ATTRIBUTE_UNUSE= D, + virSecurityManagerMetadataLockStatePtr *s= tate) { - virLockManagerPtr lock; - int fd; - int ret =3D -1; + size_t i; =20 - /* lockManagerMutex acquired from previous - * virSecurityManagerMetadataLock() call. */ + if (!state) + return; =20 - fd =3D mgr->clientfd; - mgr->clientfd =3D -1; + for (i =3D 0; i < (*state)->nfds; i++) { + char ebuf[1024]; + int fd =3D (*state)->fds[i]; =20 - if (!(lock =3D virSecurityManagerNewLockManager(mgr, paths, npaths))) - goto cleanup; + /* Technically, unlock is not needed because it will + * happen on VIR_CLOSE() anyway. But let's play it nice. */ + if (virFileUnlock(fd, METADATA_OFFSET, METADATA_LEN) < 0) { + VIR_WARN("Unable to unlock fd %d: %s", + fd, virStrerror(errno, ebuf, sizeof(ebuf))); + } =20 - if (virLockManagerRelease(lock, NULL, 0) < 0) - goto cleanup; + if (VIR_CLOSE(fd) < 0) { + VIR_WARN("Unable to close fd %d: %s", + fd, virStrerror(errno, ebuf, sizeof(ebuf))); + } + } =20 - ret =3D 0; - cleanup: - virLockManagerFree(lock); - VIR_FORCE_CLOSE(fd); - virMutexUnlock(&lockManagerMutex); - return ret; + VIR_FREE((*state)->fds); + VIR_FREE(*state); } diff --git a/src/security/security_manager.h b/src/security/security_manage= r.h index 10ebe5cc29..fe8a1b4a24 100644 --- a/src/security/security_manager.h +++ b/src/security/security_manager.h @@ -199,11 +199,16 @@ int virSecurityManagerSetTPMLabels(virSecurityManager= Ptr mgr, int virSecurityManagerRestoreTPMLabels(virSecurityManagerPtr mgr, virDomainDefPtr vm); =20 -int virSecurityManagerMetadataLock(virSecurityManagerPtr mgr, - const char * const *paths, - size_t npaths); -int virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr, - const char * const *paths, - size_t npaths); +typedef struct _virSecurityManagerMetadataLockState virSecurityManagerMeta= dataLockState; +typedef virSecurityManagerMetadataLockState *virSecurityManagerMetadataLoc= kStatePtr; + +virSecurityManagerMetadataLockStatePtr +virSecurityManagerMetadataLock(virSecurityManagerPtr mgr, + const char **paths, + size_t npaths); + +void +virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr, + virSecurityManagerMetadataLockStatePtr *s= tate); =20 #endif /* VIR_SECURITY_MANAGER_H__ */ diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 0e24b9b3ca..17e24c6ac3 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -214,6 +214,7 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UN= USED, void *opaque) { virSecuritySELinuxContextListPtr list =3D opaque; + virSecurityManagerMetadataLockStatePtr state; bool privileged =3D virSecurityManagerGetPrivileged(list->manager); const char **paths =3D NULL; size_t npaths =3D 0; @@ -227,13 +228,10 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_= UNUSED, for (i =3D 0; i < list->nItems; i++) { const char *p =3D list->items[i]->path; =20 - if (virFileIsDir(p)) - continue; - VIR_APPEND_ELEMENT_COPY_INPLACE(paths, npaths, p); } =20 - if (virSecurityManagerMetadataLock(list->manager, paths, npaths) < 0) + if (!(state =3D virSecurityManagerMetadataLock(list->manager, paths, n= paths))) goto cleanup; =20 rv =3D 0; @@ -250,8 +248,7 @@ virSecuritySELinuxTransactionRun(pid_t pid ATTRIBUTE_UN= USED, } } =20 - if (virSecurityManagerMetadataUnlock(list->manager, paths, npaths) < 0) - goto cleanup; + virSecurityManagerMetadataUnlock(list->manager, &state); =20 if (rv < 0) goto cleanup; --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767454057570.641653210574; Wed, 17 Oct 2018 02:10:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03C173082B72; Wed, 17 Oct 2018 09:10:52 +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 A875D1B482; Wed, 17 Oct 2018 09:10:51 +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 441D63D382; Wed, 17 Oct 2018 09:10:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97qBh017265 for ; Wed, 17 Oct 2018 05:07:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2BAEA7FC3B; Wed, 17 Oct 2018 09:07:52 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F29F7FC3F for ; Wed, 17 Oct 2018 09:07:51 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:47 +0200 Message-Id: <2f4eb17651becfc7ceae1d58175e9fcd3120d913.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/13] Revert "security_manager: Load lock plugin on init" 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 17 Oct 2018 09:10:52 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 3e26b476b5f322353bf0dcd8e3f037ca672b8c62. Signed-off-by: Michal Privoznik --- cfg.mk | 4 +--- src/lxc/lxc_controller.c | 3 +-- src/lxc/lxc_driver.c | 2 +- src/qemu/qemu_driver.c | 3 --- src/security/security_manager.c | 25 +------------------------ src/security/security_manager.h | 2 -- tests/seclabeltest.c | 2 +- tests/securityselinuxlabeltest.c | 2 +- tests/securityselinuxtest.c | 2 +- tests/testutilsqemu.c | 2 +- 10 files changed, 8 insertions(+), 39 deletions(-) diff --git a/cfg.mk b/cfg.mk index 4790d0b7e7..eddd110ed6 100644 --- a/cfg.mk +++ b/cfg.mk @@ -787,10 +787,8 @@ sc_prohibit_cross_inclusion: case $$dir in \ util/) safe=3D"util";; \ access/ | conf/) safe=3D"($$dir|conf|util)";; \ - cpu/| network/| node_device/| rpc/| storage/) \ + cpu/| network/| node_device/| rpc/| security/| storage/) \ safe=3D"($$dir|util|conf|storage)";; \ - security/) \ - safe=3D"($$dir|util|conf|storage|locking)";; \ xenapi/ | xenconfig/ ) safe=3D"($$dir|util|conf|xen|cpu)";; \ *) safe=3D"($$dir|$(mid_dirs)|util)";; \ esac; \ diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 62dfd09473..e853d02d65 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -2624,8 +2624,7 @@ int main(int argc, char *argv[]) ctrl->handshakeFd =3D handshakeFd; =20 if (!(ctrl->securityManager =3D virSecurityManagerNew(securityDriver, - LXC_DRIVER_NAME, - NULL, 0))) + LXC_DRIVER_NAME, 0= ))) goto cleanup; =20 if (ctrl->def->seclabels) { diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f732305649..990871d9b3 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1531,7 +1531,7 @@ lxcSecurityInit(virLXCDriverConfigPtr cfg) flags |=3D VIR_SECURITY_MANAGER_REQUIRE_CONFINED; =20 virSecurityManagerPtr mgr =3D virSecurityManagerNew(cfg->securityDrive= rName, - LXC_DRIVER_NAME, NUL= L, flags); + LXC_DRIVER_NAME, fla= gs); if (!mgr) goto error; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a52e2495d5..3a1185f947 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -350,7 +350,6 @@ qemuSecurityInit(virQEMUDriverPtr driver) while (names && *names) { if (!(mgr =3D qemuSecurityNew(*names, QEMU_DRIVER_NAME, - cfg->metadataLockManagerName, flags))) goto error; if (!stack) { @@ -366,7 +365,6 @@ qemuSecurityInit(virQEMUDriverPtr driver) } else { if (!(mgr =3D qemuSecurityNew(NULL, QEMU_DRIVER_NAME, - cfg->metadataLockManagerName, flags))) goto error; if (!(stack =3D qemuSecurityNewStack(mgr))) @@ -383,7 +381,6 @@ qemuSecurityInit(virQEMUDriverPtr driver) cfg->user, cfg->group, flags, - cfg->metadataLockManagerName, qemuSecurityChownCallback))) goto error; if (!stack) { diff --git a/src/security/security_manager.c b/src/security/security_manage= r.c index b675f8ab46..47be47df48 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -32,7 +32,6 @@ #include "viralloc.h" #include "virobject.h" #include "virlog.h" -#include "locking/lock_manager.h" #include "virfile.h" =20 #define VIR_FROM_THIS VIR_FROM_SECURITY @@ -46,8 +45,6 @@ struct _virSecurityManager { unsigned int flags; const char *virtDriver; void *privateData; - - virLockManagerPluginPtr lockPlugin; }; =20 static virClassPtr virSecurityManagerClass; @@ -58,12 +55,8 @@ void virSecurityManagerDispose(void *obj) { virSecurityManagerPtr mgr =3D obj; =20 - if (mgr->drv && - mgr->drv->close) + if (mgr->drv->close) mgr->drv->close(mgr); - - virObjectUnref(mgr->lockPlugin); - VIR_FREE(mgr->privateData); } =20 @@ -83,7 +76,6 @@ VIR_ONCE_GLOBAL_INIT(virSecurityManager); static virSecurityManagerPtr virSecurityManagerNewDriver(virSecurityDriverPtr drv, const char *virtDriver, - const char *lockManagerPluginName, unsigned int flags) { virSecurityManagerPtr mgr =3D NULL; @@ -103,14 +95,6 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv, if (!(mgr =3D virObjectLockableNew(virSecurityManagerClass))) goto error; =20 - if (!lockManagerPluginName) - lockManagerPluginName =3D "nop"; - - if (!(mgr->lockPlugin =3D virLockManagerPluginNew(lockManagerPluginNam= e, - NULL, NULL, 0))) { - goto error; - } - mgr->drv =3D drv; mgr->flags =3D flags; mgr->virtDriver =3D virtDriver; @@ -133,7 +117,6 @@ virSecurityManagerNewStack(virSecurityManagerPtr primar= y) virSecurityManagerPtr mgr =3D virSecurityManagerNewDriver(&virSecurityDriverStack, virSecurityManagerGetDriver(primary), - NULL, primary->flags); =20 if (!mgr) @@ -142,8 +125,6 @@ virSecurityManagerNewStack(virSecurityManagerPtr primar= y) if (virSecurityStackAddNested(mgr, primary) < 0) goto error; =20 - mgr->lockPlugin =3D virObjectRef(mgr->lockPlugin); - return mgr; error: virObjectUnref(mgr); @@ -166,7 +147,6 @@ virSecurityManagerNewDAC(const char *virtDriver, uid_t user, gid_t group, unsigned int flags, - const char *lockManagerPluginName, virSecurityManagerDACChownCallback chownCallback) { virSecurityManagerPtr mgr; @@ -177,7 +157,6 @@ virSecurityManagerNewDAC(const char *virtDriver, =20 mgr =3D virSecurityManagerNewDriver(&virSecurityDriverDAC, virtDriver, - lockManagerPluginName, flags & VIR_SECURITY_MANAGER_NEW_MAS= K); =20 if (!mgr) @@ -199,7 +178,6 @@ virSecurityManagerNewDAC(const char *virtDriver, virSecurityManagerPtr virSecurityManagerNew(const char *name, const char *virtDriver, - const char *lockManagerPluginName, unsigned int flags) { virSecurityDriverPtr drv =3D virSecurityDriverLookup(name, virtDriver); @@ -228,7 +206,6 @@ virSecurityManagerNew(const char *name, =20 return virSecurityManagerNewDriver(drv, virtDriver, - lockManagerPluginName, flags); } =20 diff --git a/src/security/security_manager.h b/src/security/security_manage= r.h index fe8a1b4a24..c4abc34b17 100644 --- a/src/security/security_manager.h +++ b/src/security/security_manager.h @@ -45,7 +45,6 @@ typedef enum { =20 virSecurityManagerPtr virSecurityManagerNew(const char *name, const char *virtDriver, - const char *lockManagerPluginN= ame, unsigned int flags); =20 virSecurityManagerPtr virSecurityManagerNewStack(virSecurityManagerPtr pri= mary); @@ -71,7 +70,6 @@ virSecurityManagerPtr virSecurityManagerNewDAC(const char= *virtDriver, uid_t user, gid_t group, unsigned int flags, - const char *lockManagerPlug= inName, virSecurityManagerDACChownC= allback chownCallback); =20 int virSecurityManagerPreFork(virSecurityManagerPtr mgr); diff --git a/tests/seclabeltest.c b/tests/seclabeltest.c index 7cddf96e82..a0296c787e 100644 --- a/tests/seclabeltest.c +++ b/tests/seclabeltest.c @@ -14,7 +14,7 @@ mymain(void) if (virThreadInitialize() < 0) return EXIT_FAILURE; =20 - mgr =3D virSecurityManagerNew(NULL, "QEMU", NULL, VIR_SECURITY_MANAGER= _DEFAULT_CONFINED); + mgr =3D virSecurityManagerNew(NULL, "QEMU", VIR_SECURITY_MANAGER_DEFAU= LT_CONFINED); if (mgr =3D=3D NULL) { fprintf(stderr, "Failed to start security driver"); return EXIT_FAILURE; diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index aa9fae7d32..39f4eb7b6a 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -346,7 +346,7 @@ mymain(void) if (!rc) return EXIT_AM_SKIP; =20 - if (!(mgr =3D virSecurityManagerNew("selinux", "QEMU", NULL, + if (!(mgr =3D virSecurityManagerNew("selinux", "QEMU", VIR_SECURITY_MANAGER_DEFAULT_CONFINE= D | VIR_SECURITY_MANAGER_PRIVILEGED))) { VIR_TEST_VERBOSE("Unable to initialize security driver: %s\n", diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c index f1ea51b1ac..a2864cf57c 100644 --- a/tests/securityselinuxtest.c +++ b/tests/securityselinuxtest.c @@ -272,7 +272,7 @@ mymain(void) int ret =3D 0; virSecurityManagerPtr mgr; =20 - if (!(mgr =3D virSecurityManagerNew("selinux", "QEMU", NULL, + if (!(mgr =3D virSecurityManagerNew("selinux", "QEMU", VIR_SECURITY_MANAGER_DEFAULT_CONFINE= D | VIR_SECURITY_MANAGER_PRIVILEGED))) { fprintf(stderr, "Unable to initialize security driver: %s\n", diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 332885eb77..0d3e9fc7e6 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -716,7 +716,7 @@ int qemuTestDriverInit(virQEMUDriver *driver) if (qemuTestCapsCacheInsert(driver->qemuCapsCache, NULL) < 0) goto error; =20 - if (!(mgr =3D virSecurityManagerNew("none", "qemu", NULL, + if (!(mgr =3D virSecurityManagerNew("none", "qemu", VIR_SECURITY_MANAGER_PRIVILEGED))) goto error; if (!(driver->securityManager =3D virSecurityManagerNewStack(mgr))) --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767466481926.3895541105288; Wed, 17 Oct 2018 02:11:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B91530BCCC3; Wed, 17 Oct 2018 09:11:04 +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 EFAF019E2C; Wed, 17 Oct 2018 09:11:03 +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 7D52C180BADC; Wed, 17 Oct 2018 09:11:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97rih017270 for ; Wed, 17 Oct 2018 05:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDC057FFE7; Wed, 17 Oct 2018 09:07:52 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6702495A47 for ; Wed, 17 Oct 2018 09:07:52 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:48 +0200 Message-Id: <43e46b59a29700003a8eea9dc4c4a7389251b7df.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/13] Revert "qemu_conf: Introduce metadata_lock_manager" 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 17 Oct 2018 09:11:05 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 8b8aefb3d6ae2139ea3d4ef6d7dd2c06f57f6075. Signed-off-by: Michal Privoznik --- src/qemu/qemu_conf.c | 1 - src/qemu/qemu_conf.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 17b7e11e02..32da9a7351 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -426,7 +426,6 @@ static void virQEMUDriverConfigDispose(void *obj) virStringListFree(cfg->securityDriverNames); =20 VIR_FREE(cfg->lockManagerName); - VIR_FREE(cfg->metadataLockManagerName); =20 virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares); =20 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index f876f9117c..49e5c50f22 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -186,7 +186,6 @@ struct _virQEMUDriverConfig { bool autoStartBypassCache; =20 char *lockManagerName; - char *metadataLockManagerName; =20 int keepAliveInterval; unsigned int keepAliveCount; --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767448563750.8208885862708; Wed, 17 Oct 2018 02:10:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31062C7C88; Wed, 17 Oct 2018 09:10:45 +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 489701057060; Wed, 17 Oct 2018 09:10:44 +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 CBE4218005B7; Wed, 17 Oct 2018 09:10:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97uxD017289 for ; Wed, 17 Oct 2018 05:07:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 197F858D41; Wed, 17 Oct 2018 09:07:55 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50F6295A57 for ; Wed, 17 Oct 2018 09:07:53 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:49 +0200 Message-Id: <7755dbc2d25b54c4396d0afef3d13097e1eae555.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 07/13] Revert "lock_manager: Allow disabling configFile for virLockManagerPluginNew" 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 17 Oct 2018 09:10:47 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 35b5b244da825fb41e35e4dc62e740d716214ec9. Signed-off-by: Michal Privoznik --- src/locking/lock_driver.h | 4 ---- src/locking/lock_driver_lockd.c | 4 +--- src/locking/lock_driver_sanlock.c | 4 +--- src/locking/lock_manager.c | 10 +++------- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h index ae30abda7d..7c8f744be3 100644 --- a/src/locking/lock_driver.h +++ b/src/locking/lock_driver.h @@ -124,7 +124,6 @@ struct _virLockManagerParam { /** * virLockDriverInit: * @version: the libvirt requested plugin ABI version - * @configFile: path to config file * @flags: the libvirt requested plugin optional extras * * Allow the plugin to validate the libvirt requested @@ -132,9 +131,6 @@ struct _virLockManagerParam { * to block its use in versions of libvirtd which are * too old to support key features. * - * The @configFile variable points to config file that the driver - * should load. If NULL, no config file should be loaded. - * * NB: A plugin may be loaded multiple times, for different * libvirt drivers (eg QEMU, LXC, UML) * diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 0c672b05b1..85cdcf97be 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -371,10 +371,8 @@ static int virLockManagerLockDaemonInit(unsigned int v= ersion, driver->requireLeaseForDisks =3D true; driver->autoDiskLease =3D true; =20 - if (configFile && - virLockManagerLockDaemonLoadConfig(configFile) < 0) { + if (virLockManagerLockDaemonLoadConfig(configFile) < 0) goto error; - } =20 if (driver->autoDiskLease) { if (driver->fileLockSpaceDir && diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index 3ad0dc9bed..b10d8197c5 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -446,10 +446,8 @@ static int virLockManagerSanlockInit(unsigned int vers= ion, goto error; } =20 - if (configFile && - virLockManagerSanlockLoadConfig(driver, configFile) < 0) { + if (virLockManagerSanlockLoadConfig(driver, configFile) < 0) goto error; - } =20 if (driver->autoDiskLease && !driver->hostID) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index 9067f5a01a..d421b6acfc 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -104,8 +104,6 @@ static void virLockManagerLogParams(size_t nparams, /** * virLockManagerPluginNew: * @name: the name of the plugin - * @driverName: the hypervisor driver that loads the plugin - * @configDir: path to dir where config files are stored * @flag: optional plugin flags * * Attempt to load the plugin $(libdir)/libvirt/lock-driver/@name.so @@ -131,13 +129,11 @@ virLockManagerPluginPtr virLockManagerPluginNew(const= char *name, char *configFile =3D NULL; =20 VIR_DEBUG("name=3D%s driverName=3D%s configDir=3D%s flags=3D0x%x", - name, NULLSTR(driverName), NULLSTR(configDir), flags); + name, driverName, configDir, flags); =20 - if (driverName && configDir && - virAsprintf(&configFile, "%s/%s-%s.conf", - configDir, driverName, name) < 0) { + if (virAsprintf(&configFile, "%s/%s-%s.conf", + configDir, driverName, name) < 0) return NULL; - } =20 if (STREQ(name, "nop")) { driver =3D &virLockDriverNop; --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767433584847.7366365086731; Wed, 17 Oct 2018 02:10:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC577308ED4E; Wed, 17 Oct 2018 09:10:31 +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 574422C300; Wed, 17 Oct 2018 09:10:31 +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 E72843D383; Wed, 17 Oct 2018 09:10:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97uQA017296 for ; Wed, 17 Oct 2018 05:07:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D74D970C5; Wed, 17 Oct 2018 09:07:56 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35345940AC for ; Wed, 17 Oct 2018 09:07:55 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:50 +0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 08/13] Revert "lock_driver: Introduce VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK" 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 17 Oct 2018 09:10:32 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 385eb8399bdb1610447c2857abfe99cee4a9fb9e. Signed-off-by: Michal Privoznik --- src/locking/lock_driver.h | 4 -- src/locking/lock_driver_lockd.c | 82 ++++++++++----------------------- 2 files changed, 24 insertions(+), 62 deletions(-) diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h index 7c8f744be3..9be0abcfba 100644 --- a/src/locking/lock_driver.h +++ b/src/locking/lock_driver.h @@ -67,10 +67,6 @@ typedef enum { VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY =3D (1 << 0), /* Prevent further lock/unlock calls from this process */ VIR_LOCK_MANAGER_ACQUIRE_RESTRICT =3D (1 << 1), - /* Used when acquiring more resources in which one of them - * can't be acquired, perform a rollback and release all - * resources acquired so far. */ - VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK =3D (1 << 2), } virLockManagerAcquireFlags; =20 typedef enum { diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 85cdcf97be..d6551e125c 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -735,34 +735,6 @@ static int virLockManagerLockDaemonAddResource(virLock= ManagerPtr lock, } =20 =20 -static int virLockManagerLockDaemonReleaseImpl(virNetClientPtr client, - virNetClientProgramPtr prog= ram, - int counter, - virLockManagerLockDaemonRes= ourcePtr res) -{ - virLockSpaceProtocolReleaseResourceArgs args; - - memset(&args, 0, sizeof(args)); - - args.path =3D res->lockspace; - args.name =3D res->name; - args.flags =3D res->flags; - - args.flags &=3D - ~(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED | - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE | - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA); - - return virNetClientProgramCall(program, - client, - counter, - VIR_LOCK_SPACE_PROTOCOL_PROC_RELEASE_RE= SOURCE, - 0, NULL, NULL, NULL, - (xdrproc_t)xdr_virLockSpaceProtocolRele= aseResourceArgs, &args, - (xdrproc_t)xdr_void, NULL); -} - - static int virLockManagerLockDaemonAcquire(virLockManagerPtr lock, const char *state ATTRIBUTE_UNU= SED, unsigned int flags, @@ -773,13 +745,10 @@ static int virLockManagerLockDaemonAcquire(virLockMan= agerPtr lock, virNetClientProgramPtr program =3D NULL; int counter =3D 0; int rv =3D -1; - ssize_t i; - ssize_t lastGood =3D -1; virLockManagerLockDaemonPrivatePtr priv =3D lock->privateData; =20 virCheckFlags(VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY | - VIR_LOCK_MANAGER_ACQUIRE_RESTRICT | - VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK, -1); + VIR_LOCK_MANAGER_ACQUIRE_RESTRICT, -1); =20 if (priv->type =3D=3D VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN && priv->nresources =3D=3D 0 && @@ -798,6 +767,7 @@ static int virLockManagerLockDaemonAcquire(virLockManag= erPtr lock, goto cleanup; =20 if (!(flags & VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY)) { + size_t i; for (i =3D 0; i < priv->nresources; i++) { virLockSpaceProtocolAcquireResourceArgs args; =20 @@ -815,7 +785,6 @@ static int virLockManagerLockDaemonAcquire(virLockManag= erPtr lock, (xdrproc_t)xdr_virLockSpaceProtoco= lAcquireResourceArgs, &args, (xdrproc_t)xdr_void, NULL) < 0) goto cleanup; - lastGood =3D i; } } =20 @@ -826,28 +795,8 @@ static int virLockManagerLockDaemonAcquire(virLockMana= gerPtr lock, rv =3D 0; =20 cleanup: - if (rv < 0) { - int saved_errno =3D errno; - virErrorPtr origerr; - - virErrorPreserveLast(&origerr); - if (fd) - VIR_FORCE_CLOSE(*fd); - - if (flags & VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK) { - for (i =3D lastGood; i >=3D 0; i--) { - virLockManagerLockDaemonResourcePtr res =3D &priv->resourc= es[i]; - - if (virLockManagerLockDaemonReleaseImpl(client, program, - counter++, res) < = 0) - VIR_WARN("Unable to release resource lockspace=3D%s na= me=3D%s", - res->lockspace, res->name); - } - } - - virErrorRestore(&origerr); - errno =3D saved_errno; - } + if (rv !=3D 0 && fd) + VIR_FORCE_CLOSE(*fd); virNetClientClose(client); virObjectUnref(client); virObjectUnref(program); @@ -875,10 +824,27 @@ static int virLockManagerLockDaemonRelease(virLockMan= agerPtr lock, goto cleanup; =20 for (i =3D 0; i < priv->nresources; i++) { - virLockManagerLockDaemonResourcePtr res =3D &priv->resources[i]; + virLockSpaceProtocolReleaseResourceArgs args; =20 - if (virLockManagerLockDaemonReleaseImpl(client, program, - counter++, res) < 0) + memset(&args, 0, sizeof(args)); + + if (priv->resources[i].lockspace) + args.path =3D priv->resources[i].lockspace; + args.name =3D priv->resources[i].name; + args.flags =3D priv->resources[i].flags; + + args.flags &=3D + ~(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED | + VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE | + VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA); + + if (virNetClientProgramCall(program, + client, + counter++, + VIR_LOCK_SPACE_PROTOCOL_PROC_RELEASE_R= ESOURCE, + 0, NULL, NULL, NULL, + (xdrproc_t)xdr_virLockSpaceProtocolRel= easeResourceArgs, &args, + (xdrproc_t)xdr_void, NULL) < 0) goto cleanup; } =20 --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153976744604851.050934410853756; Wed, 17 Oct 2018 02:10:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1810F3002064; Wed, 17 Oct 2018 09:10:44 +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 B3AE7190CB; Wed, 17 Oct 2018 09:10:43 +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 44584180B5B7; Wed, 17 Oct 2018 09:10:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97uGh017301 for ; Wed, 17 Oct 2018 05:07:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EED556D92; Wed, 17 Oct 2018 09:07:56 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B45458D41 for ; Wed, 17 Oct 2018 09:07:55 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:51 +0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 09/13] Revert "lock_driver: Introduce VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA" 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 17 Oct 2018 09:10:44 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 997283b54b0e1f599aed3085ceba027eb8110acb. Signed-off-by: Michal Privoznik --- src/locking/lock_driver.h | 2 -- src/locking/lock_driver_lockd.c | 47 +++++++++---------------------- src/locking/lock_driver_sanlock.c | 3 +- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h index 9be0abcfba..a9d2041c30 100644 --- a/src/locking/lock_driver.h +++ b/src/locking/lock_driver.h @@ -51,8 +51,6 @@ typedef enum { VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK =3D 0, /* A lease against an arbitrary resource */ VIR_LOCK_MANAGER_RESOURCE_TYPE_LEASE =3D 1, - /* The resource to be locked is a metadata */ - VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA =3D 2, } virLockManagerResourceType; =20 typedef enum { diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index d6551e125c..268676c407 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -563,7 +563,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, virLockManagerLockDaemonPrivatePtr priv =3D lock->privateData; char *newName =3D NULL; char *newLockspace =3D NULL; - int newFlags =3D 0; + bool autoCreate =3D false; int ret =3D -1; =20 virCheckFlags(VIR_LOCK_MANAGER_RESOURCE_READONLY | @@ -575,7 +575,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, switch (priv->type) { case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN: =20 - switch ((virLockManagerResourceType) type) { + switch (type) { case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK: if (params || nparams) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -602,7 +602,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, VIR_DEBUG("Got an LVM UUID %s for %s", newName, name); if (VIR_STRDUP(newLockspace, driver->lvmLockSpaceDir) = < 0) goto cleanup; - newFlags |=3D VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE= _AUTOCREATE; + autoCreate =3D true; break; } virResetLastError(); @@ -619,7 +619,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, VIR_DEBUG("Got an SCSI ID %s for %s", newName, name); if (VIR_STRDUP(newLockspace, driver->scsiLockSpaceDir)= < 0) goto cleanup; - newFlags |=3D VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE= _AUTOCREATE; + autoCreate =3D true; break; } virResetLastError(); @@ -631,7 +631,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, goto cleanup; if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &new= Name) < 0) goto cleanup; - newFlags |=3D VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUT= OCREATE; + autoCreate =3D true; VIR_DEBUG("Using indirect lease %s for %s", newName, name); } else { if (VIR_STRDUP(newLockspace, "") < 0) @@ -676,8 +676,6 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, goto cleanup; =20 } break; - - case VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown lock manager object type %d for doma= in lock object"), @@ -687,29 +685,6 @@ static int virLockManagerLockDaemonAddResource(virLock= ManagerPtr lock, break; =20 case VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON: - switch ((virLockManagerResourceType) type) { - case VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA: - if (params || nparams) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unexpected parameters for metadata resou= rce")); - goto cleanup; - } - if (VIR_STRDUP(newLockspace, "") < 0 || - VIR_STRDUP(newName, name) < 0) - goto cleanup; - newFlags |=3D VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADAT= A; - break; - - case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK: - case VIR_LOCK_MANAGER_RESOURCE_TYPE_LEASE: - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown lock manager object type %d for daem= on lock object"), - type); - goto cleanup; - } - break; - default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown lock manager object type %d"), @@ -717,15 +692,19 @@ static int virLockManagerLockDaemonAddResource(virLoc= kManagerPtr lock, goto cleanup; } =20 - if (flags & VIR_LOCK_MANAGER_RESOURCE_SHARED) - newFlags |=3D VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED; - if (VIR_EXPAND_N(priv->resources, priv->nresources, 1) < 0) goto cleanup; =20 VIR_STEAL_PTR(priv->resources[priv->nresources-1].lockspace, newLocksp= ace); VIR_STEAL_PTR(priv->resources[priv->nresources-1].name, newName); - priv->resources[priv->nresources-1].flags =3D newFlags; + + if (flags & VIR_LOCK_MANAGER_RESOURCE_SHARED) + priv->resources[priv->nresources-1].flags |=3D + VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED; + + if (autoCreate) + priv->resources[priv->nresources-1].flags |=3D + VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE; =20 ret =3D 0; cleanup: diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index b10d8197c5..86efc83b5a 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -811,7 +811,7 @@ static int virLockManagerSanlockAddResource(virLockMana= gerPtr lock, if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY) return 0; =20 - switch ((virLockManagerResourceType) type) { + switch (type) { case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK: if (driver->autoDiskLease) { if (virLockManagerSanlockAddDisk(driver, lock, name, nparams, = params, @@ -835,7 +835,6 @@ static int virLockManagerSanlockAddResource(virLockMana= gerPtr lock, return -1; break; =20 - case VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown lock manager object type %d for domain l= ock object"), --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767459247573.1298435415871; Wed, 17 Oct 2018 02:10:59 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4B66F804E2; Wed, 17 Oct 2018 09:10:57 +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 077B480FF3; Wed, 17 Oct 2018 09:10:57 +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 8DCF23D386; Wed, 17 Oct 2018 09:10:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97vsO017307 for ; Wed, 17 Oct 2018 05:07:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7647E43FFE; Wed, 17 Oct 2018 09:07:57 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE37743FF8 for ; Wed, 17 Oct 2018 09:07:56 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:52 +0200 Message-Id: <8d5066aaf6d06e2d701dbd9efda376daf78d1464.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 10/13] Revert "_virLockManagerLockDaemonPrivate: Move @hasRWDisks into dom union" 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 17 Oct 2018 09:10:58 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit aaf34cb9013d6d746f4edf9807408cb9dfbcf01d. Signed-off-by: Michal Privoznik --- src/locking/lock_driver_lockd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 268676c407..22a5a97913 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -63,8 +63,6 @@ struct _virLockManagerLockDaemonPrivate { char *name; int id; pid_t pid; - - bool hasRWDisks; } dom; =20 struct { @@ -76,6 +74,8 @@ struct _virLockManagerLockDaemonPrivate { =20 size_t nresources; virLockManagerLockDaemonResourcePtr resources; + + bool hasRWDisks; }; =20 =20 @@ -585,7 +585,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, if (!driver->autoDiskLease) { if (!(flags & (VIR_LOCK_MANAGER_RESOURCE_SHARED | VIR_LOCK_MANAGER_RESOURCE_READONLY))) - priv->t.dom.hasRWDisks =3D true; + priv->hasRWDisks =3D true; return 0; } =20 @@ -731,7 +731,7 @@ static int virLockManagerLockDaemonAcquire(virLockManag= erPtr lock, =20 if (priv->type =3D=3D VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN && priv->nresources =3D=3D 0 && - priv->t.dom.hasRWDisks && + priv->hasRWDisks && driver->requireLeaseForDisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Read/write, exclusive access, disks were present= , but no leases specified")); --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767479874175.25024840455296; Wed, 17 Oct 2018 02:11:19 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C4500356D5; Wed, 17 Oct 2018 09:11:17 +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 7979F80FE8; Wed, 17 Oct 2018 09:11:17 +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 EC1DA3D386; Wed, 17 Oct 2018 09:11:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97wfv017316 for ; Wed, 17 Oct 2018 05:07:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F91C43FF4; Wed, 17 Oct 2018 09:07:58 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3C0E34203 for ; Wed, 17 Oct 2018 09:07:57 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:53 +0200 Message-Id: <08d0ec66e55ff7c4666f0631e62c996d3139a014.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 11/13] Revert "lock_driver: Introduce new VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON" 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 17 Oct 2018 09:11:18 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 22baf6e08c65d9174b24f66370724ce961ce9576. Signed-off-by: Michal Privoznik --- src/locking/lock_driver.h | 2 - src/locking/lock_driver_lockd.c | 297 +++++++++++------------------- src/locking/lock_driver_sanlock.c | 37 ++-- 3 files changed, 116 insertions(+), 220 deletions(-) diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h index a9d2041c30..8b7cccc521 100644 --- a/src/locking/lock_driver.h +++ b/src/locking/lock_driver.h @@ -42,8 +42,6 @@ typedef enum { typedef enum { /* The managed object is a virtual guest domain */ VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN =3D 0, - /* The managed object is a daemon (e.g. libvirtd) */ - VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON =3D 1, } virLockManagerObjectType; =20 typedef enum { diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 22a5a97913..ca825e6026 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -56,21 +56,10 @@ struct _virLockManagerLockDaemonResource { }; =20 struct _virLockManagerLockDaemonPrivate { - virLockManagerObjectType type; - union { - struct { - unsigned char uuid[VIR_UUID_BUFLEN]; - char *name; - int id; - pid_t pid; - } dom; - - struct { - unsigned char uuid[VIR_UUID_BUFLEN]; - char *name; - pid_t pid; - } daemon; - } t; + unsigned char uuid[VIR_UUID_BUFLEN]; + char *name; + int id; + pid_t pid; =20 size_t nresources; virLockManagerLockDaemonResourcePtr resources; @@ -167,30 +156,10 @@ virLockManagerLockDaemonConnectionRegister(virLockMan= agerPtr lock, memset(&args, 0, sizeof(args)); =20 args.flags =3D 0; - - switch (priv->type) { - case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN: - memcpy(args.owner.uuid, priv->t.dom.uuid, VIR_UUID_BUFLEN); - args.owner.name =3D priv->t.dom.name; - args.owner.id =3D priv->t.dom.id; - args.owner.pid =3D priv->t.dom.pid; - break; - - case VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON: - memcpy(args.owner.uuid, priv->t.daemon.uuid, VIR_UUID_BUFLEN); - args.owner.name =3D priv->t.daemon.name; - args.owner.pid =3D priv->t.daemon.pid; - /* This one should not be needed. However, virtlockd - * checks for ID because not every domain has a PID. */ - args.owner.id =3D priv->t.daemon.pid; - break; - - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown lock manager object type %d"), - priv->type); - return -1; - } + memcpy(args.owner.uuid, priv->uuid, VIR_UUID_BUFLEN); + args.owner.name =3D priv->name; + args.owner.id =3D priv->id; + args.owner.pid =3D priv->pid; =20 if (virNetClientProgramCall(program, client, @@ -422,18 +391,7 @@ virLockManagerLockDaemonPrivateFree(virLockManagerLock= DaemonPrivatePtr priv) } VIR_FREE(priv->resources); =20 - switch (priv->type) { - case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN: - VIR_FREE(priv->t.dom.name); - break; - - case VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON: - VIR_FREE(priv->t.daemon.name); - break; - - default: - break; - } + VIR_FREE(priv->name); VIR_FREE(priv); } =20 @@ -462,82 +420,46 @@ static int virLockManagerLockDaemonNew(virLockManager= Ptr lock, if (VIR_ALLOC(priv) < 0) return -1; =20 - priv->type =3D type; - - switch ((virLockManagerObjectType) type) { + switch (type) { case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN: for (i =3D 0; i < nparams; i++) { if (STREQ(params[i].key, "uuid")) { - memcpy(priv->t.dom.uuid, params[i].value.uuid, VIR_UUID_BU= FLEN); + memcpy(priv->uuid, params[i].value.uuid, VIR_UUID_BUFLEN); } else if (STREQ(params[i].key, "name")) { - if (VIR_STRDUP(priv->t.dom.name, params[i].value.str) < 0) + if (VIR_STRDUP(priv->name, params[i].value.str) < 0) goto cleanup; } else if (STREQ(params[i].key, "id")) { - priv->t.dom.id =3D params[i].value.iv; + priv->id =3D params[i].value.iv; } else if (STREQ(params[i].key, "pid")) { - priv->t.dom.pid =3D params[i].value.iv; + priv->pid =3D params[i].value.iv; } else if (STREQ(params[i].key, "uri")) { /* ignored */ } else { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected parameter %s for domain objec= t"), + _("Unexpected parameter %s for object"), params[i].key); goto cleanup; } } - if (priv->t.dom.id =3D=3D 0) { + if (priv->id =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing ID parameter for domain object")); goto cleanup; } - if (priv->t.dom.pid =3D=3D 0) + if (priv->pid =3D=3D 0) VIR_DEBUG("Missing PID parameter for domain object"); - if (!priv->t.dom.name) { + if (!priv->name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing name parameter for domain object")); goto cleanup; } - if (!virUUIDIsValid(priv->t.dom.uuid)) { + if (!virUUIDIsValid(priv->uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing UUID parameter for domain object")); goto cleanup; } break; =20 - case VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON: - for (i =3D 0; i < nparams; i++) { - if (STREQ(params[i].key, "uuid")) { - memcpy(priv->t.daemon.uuid, params[i].value.uuid, VIR_UUID= _BUFLEN); - } else if (STREQ(params[i].key, "name")) { - if (VIR_STRDUP(priv->t.daemon.name, params[i].value.str) <= 0) - goto cleanup; - } else if (STREQ(params[i].key, "pid")) { - priv->t.daemon.pid =3D params[i].value.iv; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected parameter %s for daemon objec= t"), - params[i].key); - goto cleanup; - } - } - - if (!virUUIDIsValid(priv->t.daemon.uuid)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing UUID parameter for daemon object")); - goto cleanup; - } - if (!priv->t.daemon.name) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing name parameter for daemon object")); - goto cleanup; - } - if (priv->t.daemon.pid =3D=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing PID parameter for daemon object")); - goto cleanup; - } - break; - default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown lock manager object type %d"), @@ -572,119 +494,107 @@ static int virLockManagerLockDaemonAddResource(virL= ockManagerPtr lock, if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY) return 0; =20 - switch (priv->type) { - case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN: + switch (type) { + case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK: + if (params || nparams) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unexpected parameters for disk resource")); + goto cleanup; + } + if (!driver->autoDiskLease) { + if (!(flags & (VIR_LOCK_MANAGER_RESOURCE_SHARED | + VIR_LOCK_MANAGER_RESOURCE_READONLY))) + priv->hasRWDisks =3D true; + return 0; + } =20 - switch (type) { - case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK: - if (params || nparams) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unexpected parameters for disk resource"= )); + /* XXX we should somehow pass in TYPE=3DBLOCK info + * from the domain_lock code, instead of assuming /dev + */ + if (STRPREFIX(name, "/dev") && + driver->lvmLockSpaceDir) { + VIR_DEBUG("Trying to find an LVM UUID for %s", name); + if (virStorageFileGetLVMKey(name, &newName) < 0) goto cleanup; - } - if (!driver->autoDiskLease) { - if (!(flags & (VIR_LOCK_MANAGER_RESOURCE_SHARED | - VIR_LOCK_MANAGER_RESOURCE_READONLY))) - priv->hasRWDisks =3D true; - return 0; - } =20 - /* XXX we should somehow pass in TYPE=3DBLOCK info - * from the domain_lock code, instead of assuming /dev - */ - if (STRPREFIX(name, "/dev") && - driver->lvmLockSpaceDir) { - VIR_DEBUG("Trying to find an LVM UUID for %s", name); - if (virStorageFileGetLVMKey(name, &newName) < 0) + if (newName) { + VIR_DEBUG("Got an LVM UUID %s for %s", newName, name); + if (VIR_STRDUP(newLockspace, driver->lvmLockSpaceDir) < 0) goto cleanup; - - if (newName) { - VIR_DEBUG("Got an LVM UUID %s for %s", newName, name); - if (VIR_STRDUP(newLockspace, driver->lvmLockSpaceDir) = < 0) - goto cleanup; - autoCreate =3D true; - break; - } - virResetLastError(); - /* Fallback to generic non-block code */ + autoCreate =3D true; + break; } + virResetLastError(); + /* Fallback to generic non-block code */ + } =20 - if (STRPREFIX(name, "/dev") && - driver->scsiLockSpaceDir) { - VIR_DEBUG("Trying to find an SCSI ID for %s", name); - if (virStorageFileGetSCSIKey(name, &newName) < 0) - goto cleanup; - - if (newName) { - VIR_DEBUG("Got an SCSI ID %s for %s", newName, name); - if (VIR_STRDUP(newLockspace, driver->scsiLockSpaceDir)= < 0) - goto cleanup; - autoCreate =3D true; - break; - } - virResetLastError(); - /* Fallback to generic non-block code */ - } + if (STRPREFIX(name, "/dev") && + driver->scsiLockSpaceDir) { + VIR_DEBUG("Trying to find an SCSI ID for %s", name); + if (virStorageFileGetSCSIKey(name, &newName) < 0) + goto cleanup; =20 - if (driver->fileLockSpaceDir) { - if (VIR_STRDUP(newLockspace, driver->fileLockSpaceDir) < 0) - goto cleanup; - if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &new= Name) < 0) + if (newName) { + VIR_DEBUG("Got an SCSI ID %s for %s", newName, name); + if (VIR_STRDUP(newLockspace, driver->scsiLockSpaceDir) < 0) goto cleanup; autoCreate =3D true; - VIR_DEBUG("Using indirect lease %s for %s", newName, name); - } else { - if (VIR_STRDUP(newLockspace, "") < 0) - goto cleanup; - if (VIR_STRDUP(newName, name) < 0) - goto cleanup; - VIR_DEBUG("Using direct lease for %s", name); + break; } + virResetLastError(); + /* Fallback to generic non-block code */ + } =20 - break; - case VIR_LOCK_MANAGER_RESOURCE_TYPE_LEASE: { - size_t i; - char *path =3D NULL; - char *lockspace =3D NULL; - for (i =3D 0; i < nparams; i++) { - if (STREQ(params[i].key, "offset")) { - if (params[i].value.ul !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Offset must be zero for this loc= k manager")); - goto cleanup; - } - } else if (STREQ(params[i].key, "lockspace")) { - lockspace =3D params[i].value.str; - } else if (STREQ(params[i].key, "path")) { - path =3D params[i].value.str; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected parameter %s for lease re= source"), - params[i].key); - goto cleanup; - } - } - if (!path || !lockspace) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing path or lockspace for lease reso= urce")); + if (driver->fileLockSpaceDir) { + if (VIR_STRDUP(newLockspace, driver->fileLockSpaceDir) < 0) goto cleanup; - } - if (virAsprintf(&newLockspace, "%s/%s", - path, lockspace) < 0) + if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &newName= ) < 0) + goto cleanup; + autoCreate =3D true; + VIR_DEBUG("Using indirect lease %s for %s", newName, name); + } else { + if (VIR_STRDUP(newLockspace, "") < 0) goto cleanup; if (VIR_STRDUP(newName, name) < 0) goto cleanup; - - } break; - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown lock manager object type %d for doma= in lock object"), - type); - goto cleanup; + VIR_DEBUG("Using direct lease for %s", name); } + break; + case VIR_LOCK_MANAGER_RESOURCE_TYPE_LEASE: { + size_t i; + char *path =3D NULL; + char *lockspace =3D NULL; + for (i =3D 0; i < nparams; i++) { + if (STREQ(params[i].key, "offset")) { + if (params[i].value.ul !=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Offset must be zero for this lock ma= nager")); + goto cleanup; + } + } else if (STREQ(params[i].key, "lockspace")) { + lockspace =3D params[i].value.str; + } else if (STREQ(params[i].key, "path")) { + path =3D params[i].value.str; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected parameter %s for lease resour= ce"), + params[i].key); + goto cleanup; + } + } + if (!path || !lockspace) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing path or lockspace for lease resource= ")); + goto cleanup; + } + if (virAsprintf(&newLockspace, "%s/%s", + path, lockspace) < 0) + goto cleanup; + if (VIR_STRDUP(newName, name) < 0) + goto cleanup; =20 - case VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON: + } break; default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown lock manager object type %d"), @@ -729,8 +639,7 @@ static int virLockManagerLockDaemonAcquire(virLockManag= erPtr lock, virCheckFlags(VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY | VIR_LOCK_MANAGER_ACQUIRE_RESTRICT, -1); =20 - if (priv->type =3D=3D VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN && - priv->nresources =3D=3D 0 && + if (priv->nresources =3D=3D 0 && priv->hasRWDisks && driver->requireLeaseForDisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index 86efc83b5a..ff0c9be8f7 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -509,32 +509,21 @@ static int virLockManagerSanlockNew(virLockManagerPtr= lock, =20 priv->flags =3D flags; =20 - switch ((virLockManagerObjectType) type) { - case VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN: - for (i =3D 0; i < nparams; i++) { - param =3D ¶ms[i]; + for (i =3D 0; i < nparams; i++) { + param =3D ¶ms[i]; =20 - if (STREQ(param->key, "uuid")) { - memcpy(priv->vm_uuid, param->value.uuid, 16); - } else if (STREQ(param->key, "name")) { - if (VIR_STRDUP(priv->vm_name, param->value.str) < 0) - goto error; - } else if (STREQ(param->key, "pid")) { - priv->vm_pid =3D param->value.iv; - } else if (STREQ(param->key, "id")) { - priv->vm_id =3D param->value.ui; - } else if (STREQ(param->key, "uri")) { - priv->vm_uri =3D param->value.cstr; - } + if (STREQ(param->key, "uuid")) { + memcpy(priv->vm_uuid, param->value.uuid, 16); + } else if (STREQ(param->key, "name")) { + if (VIR_STRDUP(priv->vm_name, param->value.str) < 0) + goto error; + } else if (STREQ(param->key, "pid")) { + priv->vm_pid =3D param->value.iv; + } else if (STREQ(param->key, "id")) { + priv->vm_id =3D param->value.ui; + } else if (STREQ(param->key, "uri")) { + priv->vm_uri =3D param->value.cstr; } - break; - - case VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON: - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown lock manager object type %d"), - type); - goto error; } =20 /* Sanlock needs process registration, but the only way how to probe --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767472850433.53707031641306; Wed, 17 Oct 2018 02:11:12 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 69FA93002705; Wed, 17 Oct 2018 09:11:10 +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 EFBCD5DD61; Wed, 17 Oct 2018 09:11:09 +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 3DE76180BAE3; Wed, 17 Oct 2018 09:11:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H97xFK017321 for ; Wed, 17 Oct 2018 05:07:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44D8A34203; Wed, 17 Oct 2018 09:07:59 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDB6843FF4 for ; Wed, 17 Oct 2018 09:07:58 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:54 +0200 Message-Id: <2f73a75d15ed3735a1a819179db67bf5240f8e88.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 12/13] Revert "lock_driver_lockd: Introduce VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA flag" 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 17 Oct 2018 09:11:11 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 21c34b86be5233634eb38f77be64e2263bfc4e48. Signed-off-by: Michal Privoznik --- src/locking/lock_daemon_dispatch.c | 10 ++-------- src/locking/lock_driver_lockd.c | 3 +-- src/locking/lock_driver_lockd.h | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/locking/lock_daemon_dispatch.c b/src/locking/lock_daemon_d= ispatch.c index a683ad3d6b..10248ec0b5 100644 --- a/src/locking/lock_daemon_dispatch.c +++ b/src/locking/lock_daemon_dispatch.c @@ -37,9 +37,6 @@ VIR_LOG_INIT("locking.lock_daemon_dispatch"); =20 #include "lock_daemon_dispatch_stubs.h" =20 -#define DEFAULT_OFFSET 0 -#define METADATA_OFFSET 1 - static int virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server ATTRIBU= TE_UNUSED, virNetServerClientPtr client, @@ -53,14 +50,13 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServe= rPtr server ATTRIBUTE_UNU virNetServerClientGetPrivateData(client); virLockSpacePtr lockspace; unsigned int newFlags; - off_t start =3D DEFAULT_OFFSET; + off_t start =3D 0; off_t len =3D 1; =20 virMutexLock(&priv->lock); =20 virCheckFlagsGoto(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED | - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE | - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA, c= leanup); + VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE,= cleanup); =20 if (priv->restricted) { virReportError(VIR_ERR_OPERATION_DENIED, "%s", @@ -86,8 +82,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerP= tr server ATTRIBUTE_UNU newFlags |=3D VIR_LOCK_SPACE_ACQUIRE_SHARED; if (flags & VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE) newFlags |=3D VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE; - if (flags & VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA) - start =3D METADATA_OFFSET; =20 if (virLockSpaceAcquireResource(lockspace, args->name, diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index ca825e6026..16fce551c3 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -723,8 +723,7 @@ static int virLockManagerLockDaemonRelease(virLockManag= erPtr lock, =20 args.flags &=3D ~(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED | - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE | - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA); + VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE); =20 if (virNetClientProgramCall(program, client, diff --git a/src/locking/lock_driver_lockd.h b/src/locking/lock_driver_lock= d.h index bebd804365..6931fe7425 100644 --- a/src/locking/lock_driver_lockd.h +++ b/src/locking/lock_driver_lockd.h @@ -25,7 +25,6 @@ enum virLockSpaceProtocolAcquireResourceFlags { VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED =3D (1 << 0), VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE =3D (1 << 1), - VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA =3D (1 << 2), }; =20 #endif /* __VIR_LOCK_DRIVER_LOCKD_H__ */ --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 07:17:56 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539767459759551.0586970708802; Wed, 17 Oct 2018 02:10:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BF1031E7DE; Wed, 17 Oct 2018 09:10:57 +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 46E6A34203; Wed, 17 Oct 2018 09:10:57 +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 D7DFA3D387; Wed, 17 Oct 2018 09:10:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9H980EC017327 for ; Wed, 17 Oct 2018 05:08:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CF9034203; Wed, 17 Oct 2018 09:08:00 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 958E243FFE for ; Wed, 17 Oct 2018 09:07:59 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 17 Oct 2018 11:06:55 +0200 Message-Id: <2d90af6688fba675b0c269f9c215d80fd252a028.1539766897.git.mprivozn@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 13/13] Revert "virlockspace: Allow caller to specify start and length offset in virLockSpaceAcquireResource" 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 Oct 2018 09:10:58 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit afd5a27575e8b6a494d2728552fe0e89c71e32b4. Signed-off-by: Michal Privoznik --- src/locking/lock_daemon_dispatch.c | 3 --- src/util/virlockspace.c | 15 +++++---------- src/util/virlockspace.h | 4 ---- tests/virlockspacetest.c | 29 +++++------------------------ 4 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/locking/lock_daemon_dispatch.c b/src/locking/lock_daemon_d= ispatch.c index 10248ec0b5..1b479db55d 100644 --- a/src/locking/lock_daemon_dispatch.c +++ b/src/locking/lock_daemon_dispatch.c @@ -50,8 +50,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerP= tr server ATTRIBUTE_UNU virNetServerClientGetPrivateData(client); virLockSpacePtr lockspace; unsigned int newFlags; - off_t start =3D 0; - off_t len =3D 1; =20 virMutexLock(&priv->lock); =20 @@ -86,7 +84,6 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerP= tr server ATTRIBUTE_UNU if (virLockSpaceAcquireResource(lockspace, args->name, priv->ownerPid, - start, len, newFlags) < 0) goto cleanup; =20 diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 79fa48d365..0736b4b85b 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -115,10 +115,8 @@ static void virLockSpaceResourceFree(virLockSpaceResou= rcePtr res) static virLockSpaceResourcePtr virLockSpaceResourceNew(virLockSpacePtr lockspace, const char *resname, - pid_t owner, - off_t start, - off_t len, - unsigned int flags) + unsigned int flags, + pid_t owner) { virLockSpaceResourcePtr res; bool shared =3D !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED); @@ -159,7 +157,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace, goto error; } =20 - if (virFileLock(res->fd, shared, start, len, false) < 0) { + if (virFileLock(res->fd, shared, 0, 1, false) < 0) { if (errno =3D=3D EACCES || errno =3D=3D EAGAIN) { virReportError(VIR_ERR_RESOURCE_BUSY, _("Lockspace resource '%s' is locked"), @@ -206,7 +204,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace, goto error; } =20 - if (virFileLock(res->fd, shared, start, len, false) < 0) { + if (virFileLock(res->fd, shared, 0, 1, false) < 0) { if (errno =3D=3D EACCES || errno =3D=3D EAGAIN) { virReportError(VIR_ERR_RESOURCE_BUSY, _("Lockspace resource '%s' is locked"), @@ -614,8 +612,6 @@ int virLockSpaceDeleteResource(virLockSpacePtr lockspac= e, int virLockSpaceAcquireResource(virLockSpacePtr lockspace, const char *resname, pid_t owner, - off_t start, - off_t len, unsigned int flags) { int ret =3D -1; @@ -645,8 +641,7 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspa= ce, goto cleanup; } =20 - if (!(res =3D virLockSpaceResourceNew(lockspace, resname, - owner, start, len, flags))) + if (!(res =3D virLockSpaceResourceNew(lockspace, resname, flags, owner= ))) goto cleanup; =20 if (virHashAddEntry(lockspace->resources, resname, res) < 0) { diff --git a/src/util/virlockspace.h b/src/util/virlockspace.h index 24f2c89be6..041cf20396 100644 --- a/src/util/virlockspace.h +++ b/src/util/virlockspace.h @@ -22,8 +22,6 @@ #ifndef __VIR_LOCK_SPACE_H__ # define __VIR_LOCK_SPACE_H__ =20 -# include - # include "internal.h" # include "virjson.h" =20 @@ -52,8 +50,6 @@ typedef enum { int virLockSpaceAcquireResource(virLockSpacePtr lockspace, const char *resname, pid_t owner, - off_t start, - off_t len, unsigned int flags); =20 int virLockSpaceReleaseResource(virLockSpacePtr lockspace, diff --git a/tests/virlockspacetest.c b/tests/virlockspacetest.c index 3c621e7eb0..93353be285 100644 --- a/tests/virlockspacetest.c +++ b/tests/virlockspacetest.c @@ -98,8 +98,6 @@ static int testLockSpaceResourceLockExcl(const void *args= ATTRIBUTE_UNUSED) { virLockSpacePtr lockspace; int ret =3D -1; - const off_t start =3D 0; - const off_t len =3D 1; =20 rmdir(LOCKSPACE_DIR); =20 @@ -112,13 +110,13 @@ static int testLockSpaceResourceLockExcl(const void *= args ATTRIBUTE_UNUSED) if (virLockSpaceCreateResource(lockspace, "foo") < 0) goto cleanup; =20 - if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), start, le= n, 0) < 0) + if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) < 0) goto cleanup; =20 if (!virFileExists(LOCKSPACE_DIR "/foo")) goto cleanup; =20 - if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), start, le= n, 0) =3D=3D 0) + if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) =3D=3D= 0) goto cleanup; =20 if (virLockSpaceDeleteResource(lockspace, "foo") =3D=3D 0) @@ -146,8 +144,6 @@ static int testLockSpaceResourceLockExclAuto(const void= *args ATTRIBUTE_UNUSED) { virLockSpacePtr lockspace; int ret =3D -1; - const off_t start =3D 0; - const off_t len =3D 1; =20 rmdir(LOCKSPACE_DIR); =20 @@ -161,7 +157,6 @@ static int testLockSpaceResourceLockExclAuto(const void= *args ATTRIBUTE_UNUSED) goto cleanup; =20 if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), - start, len, VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0) goto cleanup; =20 @@ -187,8 +182,6 @@ static int testLockSpaceResourceLockShr(const void *arg= s ATTRIBUTE_UNUSED) { virLockSpacePtr lockspace; int ret =3D -1; - const off_t start =3D 0; - const off_t len =3D 1; =20 rmdir(LOCKSPACE_DIR); =20 @@ -202,16 +195,13 @@ static int testLockSpaceResourceLockShr(const void *a= rgs ATTRIBUTE_UNUSED) goto cleanup; =20 if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), - start, len, VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0) goto cleanup; =20 - if (virLockSpaceAcquireResource(lockspace, "foo", - geteuid(), start, len, 0) =3D=3D 0) + if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), 0) =3D=3D= 0) goto cleanup; =20 if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), - start, len, VIR_LOCK_SPACE_ACQUIRE_SHARED) < 0) goto cleanup; =20 @@ -246,8 +236,6 @@ static int testLockSpaceResourceLockShrAuto(const void = *args ATTRIBUTE_UNUSED) { virLockSpacePtr lockspace; int ret =3D -1; - const off_t start =3D 0; - const off_t len =3D 1; =20 rmdir(LOCKSPACE_DIR); =20 @@ -261,7 +249,6 @@ static int testLockSpaceResourceLockShrAuto(const void = *args ATTRIBUTE_UNUSED) goto cleanup; =20 if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), - start, len, VIR_LOCK_SPACE_ACQUIRE_SHARED | VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0) goto cleanup; @@ -270,7 +257,6 @@ static int testLockSpaceResourceLockShrAuto(const void = *args ATTRIBUTE_UNUSED) goto cleanup; =20 if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), - start, len, VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) =3D= =3D 0) goto cleanup; =20 @@ -278,7 +264,6 @@ static int testLockSpaceResourceLockShrAuto(const void = *args ATTRIBUTE_UNUSED) goto cleanup; =20 if (virLockSpaceAcquireResource(lockspace, "foo", geteuid(), - start, len, VIR_LOCK_SPACE_ACQUIRE_SHARED | VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) < 0) goto cleanup; @@ -311,8 +296,6 @@ static int testLockSpaceResourceLockPath(const void *ar= gs ATTRIBUTE_UNUSED) { virLockSpacePtr lockspace; int ret =3D -1; - const off_t start =3D 0; - const off_t len =3D 1; =20 rmdir(LOCKSPACE_DIR); =20 @@ -325,15 +308,13 @@ static int testLockSpaceResourceLockPath(const void *= args ATTRIBUTE_UNUSED) if (virLockSpaceCreateResource(lockspace, LOCKSPACE_DIR "/foo") < 0) goto cleanup; =20 - if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", - geteuid(), start, len, 0) < 0) + if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", geteu= id(), 0) < 0) goto cleanup; =20 if (!virFileExists(LOCKSPACE_DIR "/foo")) goto cleanup; =20 - if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", - geteuid(), start, len, 0) =3D=3D 0) + if (virLockSpaceAcquireResource(lockspace, LOCKSPACE_DIR "/foo", geteu= id(), 0) =3D=3D 0) goto cleanup; =20 if (virLockSpaceDeleteResource(lockspace, LOCKSPACE_DIR "/foo") =3D=3D= 0) --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list