On Wed, Oct 18, 2017 at 05:22:08PM -0400, Cole Robinson wrote:
> On 10/03/2017 11:09 AM, Pavel Hrdina wrote:
> > We cannot use os.statvfs() if the clone disk is a block device because
> > it gets stats about filesystem which in this case is "devtmpfs" mounted
> > as "/dev".
> > 
> > As a workaround we can seek to the end of the block device to get
> > the actual size.
> > 
> > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1450908
> > 
> > Signed-off-by: Pavel Hrdina <[email protected]>
> > ---
> >  virtinst/diskbackend.py | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py
> > index de745f4d..c63a621f 100644
> > --- a/virtinst/diskbackend.py
> > +++ b/virtinst/diskbackend.py
> > @@ -387,8 +387,13 @@ class CloneStorageCreator(_StorageCreator):
> >      def is_size_conflict(self):
> >          ret = False
> >          msg = None
> > -        vfs = os.statvfs(os.path.dirname(self._path))
> > -        avail = vfs[statvfs.F_FRSIZE] * vfs[statvfs.F_BAVAIL]
> > +        if self.get_dev_type() == "block":
> > +            fd = os.open(self._path, os.O_RDONLY)
> > +            avail = os.lseek(fd, 0, os.SEEK_END)
> > +            os.close(fd)
> 
> This idiom is already tracked in the _stat_disk helper, can we reuse that?

Definitely, for some reason I missed that.  Thanks for review, I've
pushed it with this fixed.

Pavel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
virt-tools-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-tools-list

Reply via email to