diff options
| author | Yoshiaki Tamura <yoshi@midokura.jp> | 2011-07-04 13:53:17 +0900 |
|---|---|---|
| committer | Yoshiaki Tamura <yoshi@midokura.jp> | 2011-07-04 13:53:17 +0900 |
| commit | b8b96769bfc49e75d2eee3ae561e4e9ee7615473 (patch) | |
| tree | e4fd3443a5ae358dbafa539bdec0638c86be6334 | |
| parent | 6843421be9cdef1fc12d3480889bdcfd96821e1b (diff) | |
Fix boot from volume failure for network block devices.
This patch looks up the device_path and swithes between 'block' and
'network' when creating libvirt.xml.
| -rw-r--r-- | nova/virt/libvirt.xml.template | 6 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/nova/virt/libvirt.xml.template b/nova/virt/libvirt.xml.template index e1a683da8..36d8c5aaa 100644 --- a/nova/virt/libvirt.xml.template +++ b/nova/virt/libvirt.xml.template @@ -82,9 +82,13 @@ </disk> #end if #for $vol in $volumes - <disk type='block'> + <disk type='${vol.type}'> <driver type='raw'/> + #if $vol.type == 'network' + <source protocol='${vol.protocol}' name='${vol.device_path}'/> + #else <source dev='${vol.device_path}'/> + #end if <target dev='${vol.mount_device}' bus='${disk_bus}'/> </disk> #end for diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 0c6eaab84..3168bb9df 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -971,6 +971,7 @@ class LibvirtConnection(driver.ComputeDriver): return True return False + @exception.wrap_exception def _prepare_xml_info(self, instance, rescue=False, network_info=None, block_device_mapping=None): block_device_mapping = block_device_mapping or [] @@ -993,6 +994,16 @@ class LibvirtConnection(driver.ComputeDriver): for vol in block_device_mapping: vol['mount_device'] = _strip_dev(vol['mount_device']) + if vol['device_path'].startswith('/dev/'): + vol['type'] = 'block' + elif ':' in vol['device_path']: + (protocol, name) = vol['device_path'].split(':') + vol['type'] = 'network' + vol['protocol'] = protocol + vol['device_path'] = name + else: + raise exception.InvalidDevicePath(path=vol['device_path']) + ebs_root = self._volume_in_mapping(self.root_mount_device, block_device_mapping) if self._volume_in_mapping(self.local_mount_device, |
