From nobody Sun May 5 13:20:55 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519947964518518.1934633612547; Thu, 1 Mar 2018 15:46:04 -0800 (PST) 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 17A9B4A71B; Thu, 1 Mar 2018 23:46:02 +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 84FC45D6A3; Thu, 1 Mar 2018 23:46:00 +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 11DFE4A46E; Thu, 1 Mar 2018 23:45:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w21NhHYu015428 for ; Thu, 1 Mar 2018 18:43:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id A2DD960BEB; Thu, 1 Mar 2018 23:43:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D94860BE3 for ; Thu, 1 Mar 2018 23:43:15 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B594821C7 for ; Thu, 1 Mar 2018 23:43:14 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Thu, 01 Mar 2018 16:43:08 -0700 From: Jim Fehlig To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 16:42:36 -0700 Message-Id: <20180301234236.7042-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Mar 2018 23:43:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Mar 2018 23:43:14 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virtlockd: acquire locks on re-exec 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.38]); Thu, 01 Mar 2018 23:46:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Locks held by virtlockd are dropped on re-exec. virtlockd 94306 POSIX 5.4G WRITE 0 0 0 /tmp/test.qcow2 virtlockd 94306 POSIX 5B WRITE 0 0 0 /run/virtlockd.pid virtlockd 94306 POSIX 5B WRITE 0 0 0 /run/virtlockd.pid Acquire locks in PostExecRestart code path. Signed-off-by: Jim Fehlig --- The CLOEXEC flag is set in virLockSpaceNewPostExecRestart(), so I assume it is fine to call virFileLock() here as well. src/util/virlockspace.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 41af0cdb6..420878b0a 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -337,6 +337,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) virJSONValuePtr owners; size_t j; ssize_t m; + bool shared =3D false; =20 if (VIR_ALLOC(res) < 0) goto error; @@ -389,6 +390,21 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSON= ValuePtr object) goto error; } =20 + shared =3D !!(res->flags & VIR_LOCK_SPACE_ACQUIRE_SHARED); + 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"), + res->name); + } else { + virReportSystemError(errno, + _("Unable to acquire lock on '%s'"), + res->path); + } + virLockSpaceResourceFree(res); + goto error; + } + if (!(owners =3D virJSONValueObjectGet(child, "owners"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing resource owners in JSON document")); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list