From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ1M1-0008Sl-8w for qemu-devel@nongnu.org; Tue, 12 Jan 2016 10:59:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJ1Lx-000429-8Y for qemu-devel@nongnu.org; Tue, 12 Jan 2016 10:59:29 -0500 Received: from relay.parallels.com ([195.214.232.42]:40586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ1Lx-00041q-07 for qemu-devel@nongnu.org; Tue, 12 Jan 2016 10:59:25 -0500 References: <567A4EB0.1040807@parallels.com> <1450856816-9816-1-git-send-email-den@openvz.org> <1450856816-9816-2-git-send-email-den@openvz.org> <20160111173106.GL9454@noname.redhat.com> <56949140.1010800@openvz.org> <20160112101031.GB4841@noname.redhat.com> <20160112113331.GA16191@ad.usersys.redhat.com> From: "Denis V. Lunev" Message-ID: <569522CF.40504@openvz.org> Date: Tue, 12 Jan 2016 18:59:11 +0300 MIME-Version: 1.0 In-Reply-To: <20160112113331.GA16191@ad.usersys.redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/5] block: added lock image option and callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , Kevin Wolf Cc: Olga Krishtal , qemu-devel@nongnu.org, Max Reitz On 01/12/2016 02:33 PM, Fam Zheng wrote: > On Tue, 01/12 11:10, Kevin Wolf wrote: >> The problem is that libvirt already takes a lock, as Dan mentioned in >> another reply in this thread, so we can't enable locking in qemu by >> default. It would always fail when run under libvirt. >> >> Unless I'm seriously mistaken, this means that flock() inside qemu is >> dead. > Yes, I see the problem with libvirt, but can we instead do these? > > 1) Do a soft flock() in QEMU invocation. If it fails, sliently ignore. > 2) Do a hard flock() in qemu-img invocation. If it fails, report and exit. > > This way, if libvirt is holding flock, we can assume libvirt is actually > "using" the image: 1) just works as before, but 2) will not break the qcow2. > That is still a slight improvement, and does solve the reckless "qemu-img > snapshot create" user's problem. > > Fam There is a better way though. If we will switch default in my patch from 'nolock' to 'lock' then pour guys which are calling qemu-img etc stuff will see the lock as necessary while 'proper management software' aka libvirt will be able to call qemu/qemu-img etc with proper 'nolock' flag as they do care about the locking. Though from my POW all locks should be taken in the responsible entity, i.e. qemu or qemu-img as if locks are held by libvirt then they should be re-taken on f.e. daemon restart, which could happen. This is not that convenient. Den