Commit 069cfbf1 authored by Iustin Pop's avatar Iustin Pop
Browse files

Simplify hypervisor block_devices structure

This is a partial forward-port of commit 1136 on the 1.2 branch:

  The hypervisor doesn't need to be passed the whole block device
  structure, so we'll just give it the block device name on the local
  node, and the name as seen by the instance. This will make it easier to
  manipulate it later without messing with the block devices (eg. by
  changing the system name to a symlink to the name itself).

  Since the HVM hypervisor changes the "virtual" name a note is added
  calling for a redesign that doesn't need this change, as different
  hypervisors and emulation types will anyway have different names for
  exported devices.

  Reviewed-by: iustinp

The changes in this patch compared to the original are:
  - we keep passing the original disk object, not for its iv_name, but
    for it's physical_id which is needed by the file driver (this could
    be fixed maybe)
  - we don't use the iv_name anymore, since in 2.0 we already use the
    index of the device

Original-Author: ultrotter
parent 2b17c3c4
......@@ -741,8 +741,8 @@ def _GatherBlockDevs(instance):
@type instance: L{objects.Instance}
@param instance: the instance whose disks we shoul assemble
@rtype: list of L{bdev.BlockDev}
@return: list of the block devices
@rtype: list
@return: list of (disk_object, device_path)
"""
block_devices = []
......@@ -752,7 +752,7 @@ def _GatherBlockDevs(instance):
raise errors.BlockDeviceError("Block device '%s' is not set up." %
str(disk))
device.Open()
block_devices.append((disk, device))
block_devices.append((disk, device.dev_path))
return block_devices
......
......@@ -203,7 +203,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
nic_seq += 1
boot_drive = True
for cfdev, rldev in block_devices:
for cfdev, dev_path in block_devices:
# TODO: handle FD_LOOP and FD_BLKTAP (?)
if boot_drive:
boot_val = ',boot=on'
......@@ -214,7 +214,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
# TODO: handle different if= types
if_val = ',if=virtio'
drive_val = 'file=%s,format=raw%s%s' % (rldev.dev_path, if_val, boot_val)
drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
kvm_cmd.extend(['-drive', drive_val])
kvm_cmd.extend(['-kernel', instance.hvparams[constants.HV_KERNEL_PATH]])
......
......@@ -256,12 +256,12 @@ class XenHypervisor(hv_base.BaseHypervisor):
# FIXME: instead of this hardcoding here, each of PVM/HVM should
# directly export their info (currently HVM will just sed this info)
namespace = ["sd" + chr(i + ord('a')) for i in range(24)]
for sd_name, (cfdev, rldev) in zip(namespace, block_devices):
for sd_name, (cfdev, dev_path) in zip(namespace, block_devices):
if cfdev.dev_type == constants.LD_FILE:
line = "'%s:%s,%s,w'" % (FILE_DRIVER_MAP[cfdev.physical_id[0]],
rldev.dev_path, sd_name)
dev_path, sd_name)
else:
line = "'phy:%s,%s,w'" % (rldev.dev_path, sd_name)
line = "'phy:%s,%s,w'" % (dev_path, sd_name)
disk_data.append(line)
return disk_data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment