summaryrefslogtreecommitdiffstats
path: root/nova/virt/disk/api.py
diff options
context:
space:
mode:
authorPádraig Brady <pbrady@redhat.com>2012-07-16 14:15:36 +0100
committerPádraig Brady <pbrady@redhat.com>2012-07-18 10:42:07 +0100
commit3a3ad54058323b2e012748781fc00bc6d50de23a (patch)
treee99bb2a36194a5792112f24b80c162bd664409b2 /nova/virt/disk/api.py
parentacb158714c562d3142bf2f3f560dc374daa2df7d (diff)
downloadnova-3a3ad54058323b2e012748781fc00bc6d50de23a.tar.gz
nova-3a3ad54058323b2e012748781fc00bc6d50de23a.tar.xz
nova-3a3ad54058323b2e012748781fc00bc6d50de23a.zip
improve efficiency of image transfer during migration
This reduces time to transfer a qcow2 image with a virtual size of 10G, over GigE, from about 7 minutes to about 30 seconds. There are multiple inefficiencies in the existing process. Taking an example of a qcow2 image with 10G virtual size, the process was: qcow2 -> raw -> read -> send -> write -> qcow2 qcow2 to raw takes 20s, transfer of the resultant 10G is another 4m9s, and conversion back to qcow takes 2m33s. I.E. a total of about 7 minutes. So instead we try to avoid the initial qcow2 to raw conversion completely, which results in the whole process completing in about 30s, in the common case where no conversion to raw is done on the destination. We also optimize the case where the source qcow2 image doesn't have a backing file, and then directly copy the source image without merging a backing file. Note this will also improve the situation when resizing/migrating within the same host as needles conversions are avoided in that case too. We also optimize the case where raw images are being used by trying to use `rsync -Sz` rather than `scp`. That compresses runs of zeros and create sparse destination files. Testing a 10G raw image showed a saving of 30s in transfer time. Also the network was greatly reduced (corresponding to holes in the source), as was space usage at the destination. This gain is limited though by rsync inefficiently reading all the holes at the source: https://bugzilla.samba.org/show_bug.cgi?id=8918 Thanks to David Naori <dnaori@redhat.com> for testing and ideas. Change-Id: I9e87f912ef2717221c244241cda2f1027a4ca66a
Diffstat (limited to 'nova/virt/disk/api.py')
-rw-r--r--nova/virt/disk/api.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py
index cf3b2f894..54d974534 100644
--- a/nova/virt/disk/api.py
+++ b/nova/virt/disk/api.py
@@ -124,6 +124,31 @@ def extend(image, size):
resize2fs(image)
+def can_resize_fs(image, size, use_cow=False):
+ """Check whether we can resize contained file system."""
+
+ # Check that we're increasing the size
+ virt_size = get_image_virtual_size(image)
+ if virt_size >= size:
+ return False
+
+ # Check the image is unpartitioned
+ if use_cow:
+ # Try to mount an unpartitioned qcow2 image
+ try:
+ inject_data(image, use_cow=True)
+ except exception.NovaException:
+ return False
+ else:
+ # For raw, we can directly inspect the file system
+ try:
+ utils.execute('e2label', image)
+ except exception.ProcessExecutionError:
+ return False
+
+ return True
+
+
def bind(src, target, instance_name):
"""Bind device to a filesytem"""
if src: