Skip to content

Commit

Permalink
libvirt_vm: enablement of SAN based guest with LUN id
Browse files Browse the repository at this point in the history
Boot guest with SAN based storage type using LUN id which can be
retrieved from /dev/disk/by-id, this enablement helps to use the
guest for SAN based migration tests. As LUN id would be same when
LUN is shared across multiple host and it is necessary for
migration to succeed.

Signed-off-by: Balamuruhan S <[email protected]>
  • Loading branch information
Balamuruhan S committed May 29, 2018
1 parent 1906f2e commit 464d857
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
11 changes: 11 additions & 0 deletions shared/cfg/base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ image_unbootable_pattern = "Hard Disk.*not a bootable disk"
# export_ip: optional.
# export_options: optional.

# SAN support related params. Please fill the params based on the environment
# storage_type = "SAN"
# storage_lun_id can be retrieved from /dev/disk/by-id for the lun
# that has to be given to the guest
# storage_lun_id = "scsi-360050768028211d8b0000000000000b9"
# image_device = "lun"
# image_bus = "scsi"
# drive_cache = "none"
# image_format = "raw"
# driver_name = "qemu"

#
# List of hypervisor-monitor object names (one per guest),
# used to communicate with hypervisor to control guests.
Expand Down
21 changes: 19 additions & 2 deletions virttest/libvirt_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def check_controller(virt_install_cmd_line, controller):

def add_drive(help_text, filename, pool=None, vol=None, device=None,
bus=None, perms=None, size=None, sparse=False,
cache=None, fmt=None):
cache=None, fmt=None, driver_name=None):
cmd = " --disk"
if filename:
cmd += " path=%s" % filename
Expand All @@ -707,6 +707,8 @@ def add_drive(help_text, filename, pool=None, vol=None, device=None,
cmd += ",format=%s" % fmt
if cache:
cmd += ",cache=%s" % cache
if driver_name:
cmd += ",driver_name=%s" % driver_name
return cmd

def add_floppy(help_text, filename):
Expand Down Expand Up @@ -1151,6 +1153,21 @@ def add_kernel(help_text, cmdline, kernel_path=None, initrd_path=None,

filename = storage.get_image_filename(image_params,
base_dir)
if image_params.get("storage_type", None) == "SAN":
filename = image_params.get("storage_lun_id")
filename = os.path.join("/dev/disk/by-id", filename)
virt_install_cmd += add_drive(help_text,
filename,
None,
None,
image_params.get("image_device"),
image_params.get("image_bus"),
None,
None,
None,
image_params.get("drive_cache"),
image_params.get("image_format"),
image_params.get("driver_name"))
if image_params.get("use_storage_pool") == "yes":
filename = None
virt_install_cmd += add_drive(help_text,
Expand All @@ -1167,7 +1184,7 @@ def add_kernel(help_text, cmdline, kernel_path=None, initrd_path=None,

if image_params.get("boot_drive") == "no":
continue
if filename:
if filename and image_params.get("storage_type", None) != "SAN":
libvirt_controller = image_params.get(
"libvirt_controller", None)
_drive_format = image_params.get("drive_format")
Expand Down

0 comments on commit 464d857

Please sign in to comment.