From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axx98-00016R-B0 for qemu-devel@nongnu.org; Wed, 04 May 2016 09:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axx8v-0007Vr-Vd for qemu-devel@nongnu.org; Wed, 04 May 2016 09:47:16 -0400 Date: Wed, 4 May 2016 14:46:32 +0100 From: "Richard W.M. Jones" Message-ID: <20160504134632.GA28935@redhat.com> References: <1461848266-32119-1-git-send-email-famz@redhat.com> <1461848266-32119-9-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461848266-32119-9-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , Markus Armbruster , Max Reitz , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, John Snow On Thu, Apr 28, 2016 at 08:57:27PM +0800, Fam Zheng wrote: > They are wrappers of POSIX fcntl file locking, with the additional > interception of open/close (through qemu_open and qemu_close) to offer a > better semantics that preserves the locks across multiple life cycles of > different fds on the same file. The reason to make this semantics > change over the fcntl locks is to make the API cleaner for QEMU > subsystems. > > More precisely, we remove this "feature" of fcntl lock: > > If a process closes any file descriptor referring to a file, then > all of the process's locks on that file are released, regardless of > the file descriptor(s) on which the locks were obtained. > > as long as the fd is always open/closed through qemu_open and > qemu_close. > + ret = qemu_lock_do(fd, start, len, readonly ? F_RDLCK : F_WRLCK); > + if (ret == -1) { > + return -errno; > + } It still appears this patch would break libguestfs's valid use case. How about addressing what Dan wrote here: https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg02927.html ? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v