[virt-tools-list] Sparse in Virt-clone
Pankaj Rawat
pankaj.rawat at nechclst.in
Mon Sep 17 09:44:40 UTC 2012
To Simplify the things I am adding the code snippet of the unchanged code.
File:- VirtualDisk.py
Function:- def _clone_local(self, meter, size_bytes)
zeros = '\0' * 4096
src_fd, dst_fd = None, None
try:
try:
src_fd = os.open(self.clone_path, os.O_RDONLY)
dst_fd = os.open(self.path, os.O_WRONLY | os.O_CREAT)
i = 0
while 1:
l = os.read(src_fd, clone_block_size)
s = len(l)
if s == 0:
meter.end(size_bytes)
break
# check sequence of zeros
if sparse and zeros == l: # here sparse is false , I tried many option
os.lseek(dst_fd, s, 1)
else:
b = os.write(dst_fd, l)
if s != b:
meter.end(i)
break
Now in above code the sparse is always false , I don't know why ? I tried many options. Because of this the code never go in if statement and always else part gets executed as a result os.write() function call always get executed, hence the guest VM expand to full size. Can anyone tell me why this sparse option always false? How can we make it true?
-----Original Message-----
From: Pankaj Rawat
Sent: 12 September 2012 15:43
To: 'Richard W.M. Jones'
Cc: 'virt-tools-list at redhat.com'
Subject: RE: [virt-tools-list] Sparse in Virt-clone
Hi Richard,
Thanks for the input,
I have mentioned In my previous mail the code snippet which is affecting the size of the cloned image, But I am not sure if this is the correct way to do this.
I managed to get a fully working cloned VM (from virt-clone) with size even less than the original one . That is the reason I am confused about this Code change.
And I also want to know why sparse in VolumeDisk.py code snippet mentioned in my previous mail is initially FALSE
Regards,
Pankaj Rawat
NECHCL ST
-----Original Message-----
From: Richard W.M. Jones [mailto:rjones at redhat.com]
Sent: 12 September 2012 15:16
To: Pankaj Rawat
Cc: 'virt-tools-list at redhat.com'
Subject: Re: [virt-tools-list] Sparse in Virt-clone
On Wed, Sep 12, 2012 at 07:28:46AM +0000, Pankaj Rawat wrote:
>
> Hi all,
>
> I am trying to clone a lvm2 image following thing haapens when I clone
> a image with virt-clone command
>
> virt-clone --prompt --force --original lvm_thin_1 --name lvm_thin_2
> --file /dev/volgrp/lvm_thin2
>
> Now when I clone this, It clone successfully but the cloned image is
> fully expanded , I mean it takes all 100% space
virt-clone doesn't give you much value here. It basically makes a few changes to the libvirt XML configuration (like assigning a new name and UUID) which you could easily do yourself.
So the real question is how to copy a thin-provisioned LV and keep it sparse. I don't see a way to do this, but you could create a snapshot of the original using the regular tools (lvcreate).
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20120917/0224e007/attachment.htm>
More information about the virt-tools-list
mailing list