From nobody Sat May 4 06:16:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151151373632316.608836528860706; Fri, 24 Nov 2017 00:55:36 -0800 (PST) Received: from localhost ([::1]:48049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI9li-0006FM-M7 for importer@patchew.org; Fri, 24 Nov 2017 03:55:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI9kI-0005bz-2R for qemu-devel@nongnu.org; Fri, 24 Nov 2017 03:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eI9kH-0001bD-09 for qemu-devel@nongnu.org; Fri, 24 Nov 2017 03:54:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eI9kG-0001aZ-OW for qemu-devel@nongnu.org; Fri, 24 Nov 2017 03:54:00 -0500 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 E4FC1A0B52; Fri, 24 Nov 2017 08:53:59 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-45.pek2.redhat.com [10.72.12.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1146A1883A; Fri, 24 Nov 2017 08:53:57 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 24 Nov 2017 16:53:50 +0800 Message-Id: <20171124085351.26386-2-famz@redhat.com> In-Reply-To: <20171124085351.26386-1-famz@redhat.com> References: <20171124085351.26386-1-famz@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.25]); Fri, 24 Nov 2017 08:53:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] docs: Add image locking subsection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, mreitz@redhat.com, famz@redhat.com, Philipp Hahn Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This documents the image locking feature and explains when and how related options can be used. Signed-off-by: Fam Zheng --- docs/qemu-block-drivers.texi | 36 ++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 1 + 2 files changed, 37 insertions(+) diff --git a/docs/qemu-block-drivers.texi b/docs/qemu-block-drivers.texi index 1cb1e55686..503c1847aa 100644 --- a/docs/qemu-block-drivers.texi +++ b/docs/qemu-block-drivers.texi @@ -785,6 +785,42 @@ warning: ssh server @code{ssh.example.com:22} does not= support fsync With sufficiently new versions of libssh2 and OpenSSH, @code{fsync} is supported. =20 +@node disk_image_locking +@subsection Disk image file locking + +By default, QEMU tries to protect image files from unexpected concurrent +access, as long as it's supported by the block protocol driver and host +operating system. If multiple QEMU processes (including QEMU emulators and +utilities) try to open the same image with conflicting accessing modes, al= l but +the first one will get an error. + +This feature is currently supported by the file protocol on Linux with the= Open +File Descriptor (OFD) locking API, and can be configured to fall back to P= OSIX +locking if the POSIX host doesn't support Linux OFD locking. + +To explicitly enable image locking, specify "locking=3Don" in the file pro= tocol +driver options. If OFD locking is not possible, a warning will be printed = and +the POSIX locking API will be used. In this case there is a risk that the = lock +will get silently lost when doing hot plugging and block jobs, due to the +shortcomings of the POSIX locking API. + +QEMU transparently handles lock handover during shared storage migration. = For +shared virtual disk images between multiple VMs, the "share-rw" device opt= ion +should be used. + +Alternatively, locking can be fully disabled by "locking=3Doff" block devi= ce +option. In the command line, the option is usually in the form of +"file.locking=3Doff" as the protocol driver is normally placed as a "file"= child +under a format driver. For example: + +@code{-blockdev driver=3Dqcow2,file.filename=3D/path/to/image,file.locking= =3Doff,file.driver=3Dfile} + +To check if image locking is active, check the output of the "lslocks" com= mand +on host and see if there are locks held by the QEMU process on the image f= ile. +More than one byte could be locked by the QEMU instance, each byte of which +reflects a particular permission that is acquired or protected by the runn= ing +block driver. + @c man end =20 @ignore diff --git a/qemu-doc.texi b/qemu-doc.texi index 617254917d..db2351c746 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -405,6 +405,7 @@ encrypted disk images. * disk_images_iscsi:: iSCSI LUNs * disk_images_gluster:: GlusterFS disk images * disk_images_ssh:: Secure Shell (ssh) disk images +* disk_image_locking:: Disk image file locking @end menu =20 @node disk_images_quickstart --=20 2.14.3 From nobody Sat May 4 06:16:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511513812236807.5233548067447; Fri, 24 Nov 2017 00:56:52 -0800 (PST) Received: from localhost ([::1]:48056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI9mw-00076C-J4 for importer@patchew.org; Fri, 24 Nov 2017 03:56:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI9kM-0005dw-EW for qemu-devel@nongnu.org; Fri, 24 Nov 2017 03:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eI9kL-0001fM-R8 for qemu-devel@nongnu.org; Fri, 24 Nov 2017 03:54:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52470) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eI9kL-0001dg-Ke for qemu-devel@nongnu.org; Fri, 24 Nov 2017 03:54:05 -0500 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 ABEB6C058EDD; Fri, 24 Nov 2017 08:54:04 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-45.pek2.redhat.com [10.72.12.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FC4461984; Fri, 24 Nov 2017 08:54:00 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 24 Nov 2017 16:53:51 +0800 Message-Id: <20171124085351.26386-3-famz@redhat.com> In-Reply-To: <20171124085351.26386-1-famz@redhat.com> References: <20171124085351.26386-1-famz@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.32]); Fri, 24 Nov 2017 08:54:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] qemu-options: Mention locking option of file driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, mreitz@redhat.com, famz@redhat.com, Philipp Hahn Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- qemu-options.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 3728e9b4dd..f10c2a3ddb 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -693,6 +693,10 @@ This is the protocol-level block driver for accessing = regular files. The path to the image file in the local filesystem @item aio Specifies the AIO backend (threads/native, default: threads) +@item locking +Specifies whether the image file is protected with Linux OFD / POSIX locks= . The +default is to use the Linux Open File Descriptor API if avaiable, otherwis= e no +lock is applied. (auto/on/off, default: auto) @end table Example: @example --=20 2.14.3