From 78126baa70f9f05ae9fd9f7423da4ea0ba45c49c Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 21 Feb 2013 19:33:23 +0000 Subject: Fix launching libvirt instances with swap The code in commit 7be531fe9462f2b07d4a1abf6687f649d1dfbb89 Author: Daniel P. Berrange Date: Tue Jan 15 20:43:48 2013 +0000 Refactor code for setting up libvirt disk mappings accidentally broken launching of instances where the flavor had non-zero swap specified. This was not caught due to complete lack of test coverage for the '_create_image' method. This adds two test cases for that method, exercising this bug. It also fixes a bug in netutils which was not handling a NULL network mapping, which is a valid scenario for several callers. Fixes bug #1131306 Change-Id: I214561ba3ec6440d11a5afb0665e6b6f990bd148 Signed-off-by: Daniel P. Berrange --- nova/virt/libvirt/driver.py | 3 ++- nova/virt/netutils.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index bcbd1de87..dfae88c23 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1780,6 +1780,7 @@ class LibvirtDriver(driver.ComputeDriver): ephemeral_size=eph['size']) if 'disk.swap' in disk_mapping: + mapping = disk_mapping['disk.swap'] swap_mb = 0 swap = driver.block_device_info_get_swap(block_device_info) @@ -1787,7 +1788,7 @@ class LibvirtDriver(driver.ComputeDriver): swap_mb = swap['swap_size'] elif (inst_type['swap'] > 0 and not block_device.volume_in_mapping( - swap['dev'], block_device_info)): + mapping['dev'], block_device_info)): swap_mb = inst_type['swap'] if swap_mb > 0: diff --git a/nova/virt/netutils.py b/nova/virt/netutils.py index eec2d6467..1277251b5 100644 --- a/nova/virt/netutils.py +++ b/nova/virt/netutils.py @@ -67,6 +67,9 @@ def get_injected_network_template(network_info, use_ipv6=CONF.use_ipv6, convert the type itself if necessary. """ + if network_info is None: + return None + # the code below depends on the legacy 'network_info' if hasattr(network_info, 'legacy'): network_info = network_info.legacy() -- cgit