|
|
8799e5 |
From 2c83348bc15d030174ab798d84ad1ea3c909a81f Mon Sep 17 00:00:00 2001
|
|
|
8799e5 |
Message-Id: <2c83348bc15d030174ab798d84ad1ea3c909a81f@dist-git>
|
|
|
8799e5 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8799e5 |
Date: Tue, 3 Oct 2017 16:59:13 +0200
|
|
|
8799e5 |
Subject: [PATCH] diskbackend: get a proper size of existing block device while
|
|
|
8799e5 |
cloning
|
|
|
8799e5 |
|
|
|
8799e5 |
We cannot use os.statvfs() if the clone disk is a block device because
|
|
|
8799e5 |
it gets stats about filesystem which in this case is "devtmpfs" mounted
|
|
|
8799e5 |
as "/dev".
|
|
|
8799e5 |
|
|
|
8799e5 |
As a workaround we can seek to the end of the block device to get
|
|
|
8799e5 |
the actual size.
|
|
|
8799e5 |
|
|
|
8799e5 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1450908
|
|
|
8799e5 |
|
|
|
8799e5 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8799e5 |
(cherry picked from commit 6e6f59e7abfd85b2a53554b7d091e553585e85c8)
|
|
|
8799e5 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8799e5 |
---
|
|
|
8799e5 |
virtinst/diskbackend.py | 7 +++++--
|
|
|
8799e5 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
8799e5 |
|
|
|
8799e5 |
diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py
|
|
|
8799e5 |
index de745f4d..a08a23e5 100644
|
|
|
8799e5 |
--- a/virtinst/diskbackend.py
|
|
|
8799e5 |
+++ b/virtinst/diskbackend.py
|
|
|
8799e5 |
@@ -387,8 +387,11 @@ class CloneStorageCreator(_StorageCreator):
|
|
|
8799e5 |
def is_size_conflict(self):
|
|
|
8799e5 |
ret = False
|
|
|
8799e5 |
msg = None
|
|
|
8799e5 |
- vfs = os.statvfs(os.path.dirname(self._path))
|
|
|
8799e5 |
- avail = vfs[statvfs.F_FRSIZE] * vfs[statvfs.F_BAVAIL]
|
|
|
8799e5 |
+ if self.get_dev_type() == "block":
|
|
|
8799e5 |
+ avail = _stat_disk(self._path)[1]
|
|
|
8799e5 |
+ else:
|
|
|
8799e5 |
+ vfs = os.statvfs(os.path.dirname(self._path))
|
|
|
8799e5 |
+ avail = vfs[statvfs.F_FRSIZE] * vfs[statvfs.F_BAVAIL]
|
|
|
8799e5 |
need = long(self._size * 1024 * 1024 * 1024)
|
|
|
8799e5 |
if need > avail:
|
|
|
8799e5 |
if self._sparse:
|
|
|
8799e5 |
--
|
|
|
8799e5 |
2.14.3
|
|
|
8799e5 |
|