[openstack-nova] Fix block migration (#741690)
Mark McLoughlin
markmc at fedoraproject.org
Mon Oct 24 13:07:29 UTC 2011
commit 81876ee56b87154d387a075c5d121b76ecaa9fdd
Author: Mark McLoughlin <markmc at redhat.com>
Date: Mon Oct 24 14:06:42 2011 +0100
Fix block migration (#741690)
0009-Fixed-bug-lp850602.patch | 119 +++++++++++++++++++++++++++++++++++++++++
openstack-nova.spec | 9 ++-
2 files changed, 125 insertions(+), 3 deletions(-)
---
diff --git a/0009-Fixed-bug-lp850602.patch b/0009-Fixed-bug-lp850602.patch
new file mode 100644
index 0000000..64cc39a
--- /dev/null
+++ b/0009-Fixed-bug-lp850602.patch
@@ -0,0 +1,119 @@
+From 4450fa948467552faf6e6f522666ff999baa1590 Mon Sep 17 00:00:00 2001
+From: Kei Masumoto <masumotok at nttdata.co.jp>
+Date: Wed, 28 Sep 2011 15:05:54 -0400
+Subject: [PATCH] Fixed bug lp850602. Adding backing file copy operation on
+ kvm block migration.
+
+(cherry picked from commit b9aac1181581b9036c98f5aa493731fdc74be7e1)
+
+Change-Id: I73e34447c46ab188e5769b9ea69ec52fdd69f8f9
+---
+ nova/tests/test_libvirt.py | 12 +++++++++---
+ nova/virt/libvirt/connection.py | 33 ++++++++++++++++++++++++++++++---
+ 2 files changed, 39 insertions(+), 6 deletions(-)
+
+diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
+index 60da454..2653636 100644
+--- a/nova/tests/test_libvirt.py
++++ b/nova/tests/test_libvirt.py
+@@ -794,7 +794,8 @@ class LibvirtConnTestCase(test.TestCase):
+
+ # Test data
+ instance_ref = db.instance_create(self.context, self.test_instance)
+- dummyjson = '[{"path": "%s/disk", "local_gb": "10G", "type": "raw"}]'
++ dummyjson = ('[{"path": "%s/disk", "local_gb": "10G",'
++ ' "type": "raw", "backing_file": ""}]')
+
+ # Preparing mocks
+ # qemu-img should be mockd since test environment might not have
+@@ -835,7 +836,10 @@ class LibvirtConnTestCase(test.TestCase):
+ "</devices></domain>")
+
+ ret = ("image: /test/disk\nfile format: raw\n"
+- "virtual size: 20G (21474836480 bytes)\ndisk size: 3.1G\n")
++ "virtual size: 20G (21474836480 bytes)\ndisk size: 3.1G\n"
++ "disk size: 102M\n"
++ "cluster_size: 2097152\n"
++ "backing file: /test/dummy (actual path: /backing/file)\n")
+
+ # Preparing mocks
+ vdmock = self.mox.CreateMock(libvirt.virDomain)
+@@ -865,7 +869,9 @@ class LibvirtConnTestCase(test.TestCase):
+ info[0]['path'] == '/test/disk' and
+ info[1]['path'] == '/test/disk.local' and
+ info[0]['local_gb'] == '10G' and
+- info[1]['local_gb'] == '20G')
++ info[1]['local_gb'] == '20G' and
++ info[0]['backing_file'] == "" and
++ info[1]['backing_file'] == "file")
+
+ db.instance_destroy(self.context, instance_ref['id'])
+
+diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
+index 9290c5e..00be545 100644
+--- a/nova/virt/libvirt/connection.py
++++ b/nova/virt/libvirt/connection.py
+@@ -1722,9 +1722,31 @@ class LibvirtConnection(driver.ComputeDriver):
+
+ for info in disk_info:
+ base = os.path.basename(info['path'])
+- # Get image type and create empty disk image.
++ # Get image type and create empty disk image, and
++ # create backing file in case of qcow2.
+ instance_disk = os.path.join(instance_dir, base)
+- utils.execute('qemu-img', 'create', '-f', info['type'],
++ if not info['backing_file']:
++ utils.execute('qemu-img', 'create', '-f', info['type'],
++ instance_disk, info['local_gb'])
++
++ else:
++ # Creating backing file follows same way as spawning instances.
++ backing_file = os.path.join(FLAGS.instances_path,
++ '_base', info['backing_file'])
++
++ if not os.path.exists(backing_file):
++ self._cache_image(fn=self._fetch_image,
++ context=ctxt,
++ target=info['path'],
++ fname=info['backing_file'],
++ cow=FLAGS.use_cow_images,
++ image_id=instance_ref['image_ref'],
++ user_id=instance_ref['user_id'],
++ project_id=instance_ref['project_id'],
++ size=instance_ref['local_gb'])
++
++ utils.execute('qemu-img', 'create', '-f', info['type'],
++ '-o', 'backing_file=%s' % backing_file,
+ instance_disk, info['local_gb'])
+
+ # if image has kernel and ramdisk, just download
+@@ -1815,12 +1837,17 @@ class LibvirtConnection(driver.ComputeDriver):
+ driver_nodes[cnt].get_properties().get_next().getContent()
+ if disk_type == 'raw':
+ size = int(os.path.getsize(path))
++ backing_file = ""
+ else:
+ out, err = utils.execute('qemu-img', 'info', path)
+ size = [i.split('(')[1].split()[0] for i in out.split('\n')
+ if i.strip().find('virtual size') >= 0]
+ size = int(size[0])
+
++ backing_file = [i.split('actual path:')[1].strip()[:-1]
++ for i in out.split('\n') if 0 <= i.find('backing file')]
++ backing_file = os.path.basename(backing_file[0])
++
+ # block migration needs same/larger size of empty image on the
+ # destination host. since qemu-img creates bit smaller size image
+ # depending on original image size, fixed value is necessary.
+@@ -1836,7 +1863,7 @@ class LibvirtConnection(driver.ComputeDriver):
+ break
+
+ disk_info.append({'type': disk_type, 'path': path,
+- 'local_gb': size})
++ 'local_gb': size, 'backing_file': backing_file})
+
+ return utils.dumps(disk_info)
+
+--
+1.7.6.4
+
diff --git a/openstack-nova.spec b/openstack-nova.spec
index 9be6360..0a64397 100644
--- a/openstack-nova.spec
+++ b/openstack-nova.spec
@@ -1,10 +1,8 @@
%global with_doc %{!?_without_doc:1}%{?_without_doc:0}
-%global milestone d4
-
Name: openstack-nova
Version: 2011.3
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: OpenStack Compute (nova)
Group: Applications/System
@@ -39,6 +37,7 @@ Patch5: 0005-Have-nova-api-add-the-INPUT-rule-for-EC2-metadata-lp.patc
Patch6: 0006-Allow-the-user-to-choose-either-ietadm-or-tgtadm-lp-.patch
Patch7: 0007-Remove-VolumeDriver.sync_exec-method-lp-819997.patch
Patch8: 0008-Refactor-ietadm-tgtadm-calls-out-into-helper-classes.patch
+Patch9: 0009-Fixed-bug-lp850602.patch
BuildArch: noarch
BuildRequires: intltool
@@ -174,6 +173,7 @@ This package contains documentation files for nova.
%patch6 -p1
%patch7 -p1
%patch8 -p1
+%patch9 -p1
find . \( -name .gitignore -o -name .placeholder \) -delete
@@ -361,6 +361,9 @@ fi
%endif
%changelog
+* Mon Oct 24 2011 Mark McLoughlin <markmc at redhat.com> - 2011.3-5
+- Fix block migration (#741690)
+
* Mon Oct 17 2011 Bob Kukura <rkukura at redhat.com> - 2011.3-4
- Add dependency on python-amqplib (#746685)
More information about the scm-commits
mailing list