diff options
| author | John Griffith <john.griffith@solidfire.com> | 2013-02-07 16:45:03 -0700 |
|---|---|---|
| committer | John Griffith <john.griffith@solidfire.com> | 2013-02-08 21:38:10 +0000 |
| commit | e1921703395cdc8807caa92813dcf1936d0ab64f (patch) | |
| tree | 9d37f43d1a4e796b53a473b51e08c20add0766d3 | |
| parent | bce3806efec31fb0fa536b152d763b333d75120d (diff) | |
| download | nova-e1921703395cdc8807caa92813dcf1936d0ab64f.tar.gz nova-e1921703395cdc8807caa92813dcf1936d0ab64f.tar.xz nova-e1921703395cdc8807caa92813dcf1936d0ab64f.zip | |
Fix missing key error in libvirt.driver
The libvirt disk mapping refactor change introduced
a bug in libvirt.driver.get_guest_config where we were
attempting to perform instance_update using a non-existent
key in the disk_mapping.
Given that we already parsed out the root_device_name and stored
it in a variable, and then verify that it's set in an if
statement before this method we should be just using what
we've already parsed.
Fixes bug: 1118829
Change-Id: Ifd80e67740d6f257ee537b68e9afe028273484d2
| -rw-r--r-- | nova/tests/test_libvirt.py | 23 | ||||
| -rw-r--r-- | nova/virt/libvirt/driver.py | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index cef9252c5..e1a4ee294 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -433,6 +433,29 @@ class LibvirtConnTestCase(test.TestCase): self.assertEquals(type(cfg.devices[7]), vconfig.LibvirtConfigGuestGraphics) + def test_get_guest_config_bug_1118829(self): + self.flags(libvirt_type='uml') + conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) + instance_ref = db.instance_create(self.context, self.test_instance) + + disk_info = {'disk_bus': 'virtio', + 'cdrom_bus': 'ide', + 'mapping': {u'vda': {'bus': 'virtio', + 'type': 'disk', + 'dev': u'vda'}, + 'root': {'bus': 'virtio', + 'type': 'disk', + 'dev': 'vda'}}} + + # NOTE(jdg): For this specific test leave this blank + # This will exercise the failed code path still, + # and won't require fakes and stubs of the iscsi discovery + block_device_info = {} + cfg = conn.get_guest_config(instance_ref, [], None, disk_info, + None, block_device_info) + instance_ref = db.instance_get(self.context, instance_ref['id']) + self.assertEquals(instance_ref['root_device_name'], '/dev/vda') + def test_get_guest_config_with_root_device_name(self): self.flags(libvirt_type='uml') conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 666eb66f3..9c6da127c 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1789,7 +1789,7 @@ class LibvirtDriver(driver.ComputeDriver): # for nova.api.ec2.cloud.CloudController.get_metadata() self.virtapi.instance_update( nova_context.get_admin_context(), instance['uuid'], - {'root_device_name': '/dev/' + disk_mapping['disk']['dev']}) + {'root_device_name': root_device_name}) guest.os_type = vm_mode.get_from_instance(instance) |
