Re: [PATCH] blockcopy: check dst = identical device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




>>> On 7/29/2014 at 11:47 PM, in message <53D7C1F6.4030705@xxxxxxxxxx>, Eric Blake
<eblake@xxxxxxxxxx> wrote: 
> On 07/29/2014 07:37 AM, Eric Blake wrote: 
> > On 07/29/2014 03:59 AM, Chunyan Liu wrote: 
> >> Check whether dst is the same device as source, if yes, report 
> >> error and exit. 
> >> 
> >> Currently if dst is the same device as source, blockcopy is still 
> >> going and qemu 'drive-mirror' is executed. Considering that: 
> >> a). blockcopy to the same device is meaningless. b.) result is 
> >> unexpected. (tested with block device whose source path is /dev/sdaX, 
> >> after blockcopy, shutdown VM and then create VM from xml again, the 
> >> VM cannot be started.) This case should not be allowed. 
> >> 
> >> Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx> 
> >> --- 
> >>  src/qemu/qemu_driver.c | 7 +++++++ 
> >>  1 file changed, 7 insertions(+) 
> >> 
> >> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c 
> >> index 704ba39..87a3790 100644 
> >> --- a/src/qemu/qemu_driver.c 
> >> +++ b/src/qemu/qemu_driver.c 
> >> @@ -15309,6 +15309,13 @@ qemuDomainBlockCopy(virDomainObjPtr vm, 
> >>      } 
> >>   
> >>      /* Prepare the destination file.  */ 
> >> +    if (STREQ(disk->src->path, dest)) { 
> >  
> > STREQ is too weak (consider symlinks, or even "a/b" vs. "a//b").  It 
> > will catch some cases, but not all. 
> >  
> > I don't know that we can reliably detect all possible ways the user can 
> > shoot themselves in the foot, so I'm not sure this patch is a good idea. 
>  
> A better idea would be to rely on the volume lease manager - obtaining a 
> lease should be impossible for an image already in use (and should even 
> cover the case of copying 'base <- active' onto 'base', which your 
> equality test wouldn't catch). I'm not sure why the lease manager is not 
> already flagging this issue - are we still using the nop lease manager 
> by default, and would the fcntl or sanlock lease manager do a better job?

Besides the default lock is 'nop', currently lock manager is only used in:
VM start/stop and attach/detach disk, blockcopy not using it.
To use it in blockcopy, maybe can refer to attach/detach disk: before doing
blockcopy, try AcquireResource; after blockcopy finish, try releaseResource.
Anyway, using lock manager is a better idea in such cases.

>  
> --  
> Eric Blake   eblake redhat com    +1-919-301-3266 
> Libvirt virtualization library http://libvirt.org 
>  
>  



--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]