From: Stefan Hajnoczi <stefanha@gmail.com>
To: lijun <junmuzi@gmail.com>
Cc: lcapitulino@redhat.com, qemu-devel@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] HMP: snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same file
Date: Thu, 2 Jan 2014 16:55:01 +0800 [thread overview]
Message-ID: <20140102085501.GA4922@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <52A71E14.6060907@gmail.com>
On Tue, Dec 10, 2013 at 09:58:44PM +0800, lijun wrote:
> On 12/09/2013 08:17 PM, Stefan Hajnoczi wrote:
> >On Mon, Dec 09, 2013 at 02:06:21PM +0800, jun muzi wrote:
> >My question was about the bug. What is the problem you are seeing and
> >how do you reproduce it (including the HMP commands)?
> Now I am seeing is how to "distinguish network storage file mounted
> on different dir is the same file or not".
> Reproduce this bug using nfs mounted in different directories:
> Create a nfs server, and mount it as followings:
> # mount $IP:/home/ /mnt/dir1
> # mount $IP:/home/ /mnt/dir2
> (qemu) snapshot_blkdev drive-scsi0-0-0 /mnt/dir1/sn1
> Formatting '/mnt/dir1/sn1', fmt=qcow2 size=32212254720
> backing_file='/home/juli/RHEL-7.0-20131127.1.qcow2_v3'
> backing_fmt='qcow2' encryption=off cluster_size=65536
> lazy_refcounts=off
> (qemu) snapshot_blkdev drive-scsi0-0-0 /mnt/dir2/sn1
> Formatting '/mnt/dir2/sn1', fmt=qcow2 size=32212254720
> backing_file='/mnt/dir1/sn1' backing_fmt='qcow2' encryption=off
> cluster_size=65536 lazy_refcounts=off
> (qemu) info block
> drive-scsi0-0-0: removable=0 io-status=ok file=/mnt/dir2/sn1
> backing_file=/mnt/dir1/sn1 backing_file_depth=2 ro=0 drv=qcow2
> encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0
> drive-virtio-disk1: removable=0 io-status=ok
> file=/home/juli/data_disk.qcow2_v3 ro=0 drv=qcow2 encrypted=0 bps=0
> bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0
> ide1-cd0: removable=1 locked=0 tray-open=0 io-status=ok [not inserted]
> floppy0: removable=1 locked=0 tray-open=0 [not inserted]
> sd0: removable=1 locked=0 tray-open=0 [not inserted]
> (qemu) snapshot_blkdev drive-scsi0-0-0 /mnt/dir2/sn2
> Could not open '/mnt/dir2/sn1': Could not set AIO state: Too many
> open files: Too many open files
Okay, I think we got side-tracked worrying about identifying identical
files. The problem in your example is more fundamental.
Here is what should have happened:
(qemu) snapshot_blkdev drive-scsi0-0-0 /mnt/dir2/sn1
Could not create '/mnt/dir2/sn1': File exists
The file was previously created with the name /mnt/dir1/sn1. Running
snapshot_blkdev with /mnt/dir2/sn1 clobbers the file in your example.
This is bad because it corrupts the backing chain.
If QEMU uses O_CREAT | O_EXCL open(2) flags then creating the snapshot
file fails and the user will not mistakingly overwrite sn1.
However, QEMU does not use O_EXCL to create image files anywhere today
(qemu-img or QEMU monitor commands). Returning an error is not
backwards-compatible since existing users might rely on clobbering files
(there are safe cases where it can be useful).
We could add an option to commands that create files but I'm not sure if
it's worth the effort since human users who are most at risk probably
won't provide this new option...
That said, if you want to add an O_EXCL option to bdrv_img_create(),
qemu-img commands, and monitor commands, I'm happy to review patches.
Stefan
next prev parent reply other threads:[~2014-01-02 8:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 16:31 [Qemu-devel] [PATCH] HMP: snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same file lijun
2013-11-15 16:42 ` Max Reitz
2013-11-15 17:21 ` Eric Blake
2013-11-18 13:31 ` Stefan Hajnoczi
2013-12-09 6:06 ` jun muzi
2013-12-09 12:17 ` Stefan Hajnoczi
2013-12-10 13:58 ` lijun
2014-01-02 8:55 ` Stefan Hajnoczi [this message]
2014-01-02 13:06 ` Eric Blake
-- strict thread matches above, loose matches on Subject: below --
2013-11-15 16:22 lijun
2013-11-15 16:55 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140102085501.GA4922@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=junmuzi@gmail.com \
--cc=lcapitulino@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).