[PATCH] [KVM-autotest] virt.kvm_vm: Add virtio-scsi support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds support for virtio-scsi devices.

Tested targets are scsi-hd, scsi-cd, scsi-disk, scsi-block and
scsi-generic where scsi-hd and scsi-cd are default virtio-scsi variant.

It's possible to use other targets in specific tests by forcing
drive_format_$DISKNAME = "scsi-generic".

NOTE: scsi-block and scsi-generic are passthrough devices and can
      be used only with physical HW (/dev/sd*, resp. /dev/sg*)

Signed-off-by: Lukas Doktor <ldoktor@xxxxxxxxxx>
---
 client/virt/guest-hw.cfg.sample |    8 ++++++++
 client/virt/kvm_vm.py           |   29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/client/virt/guest-hw.cfg.sample b/client/virt/guest-hw.cfg.sample
index f63bb20..0729117 100644
--- a/client/virt/guest-hw.cfg.sample
+++ b/client/virt/guest-hw.cfg.sample
@@ -58,6 +58,14 @@ variants:
         # Some older qemu might need image_boot=yes for virtio images to work.
         # Please uncomment the below if that is the case.
         #image_boot=yes
+    - virtio_scsi:
+        # supported formats are: scsi-hd, scsi-cd, scsi-disk, scsi-block,
+        # scsi-generic
+        # Use drive_format_$DISKNAME = "scsi-generic" to force disk driver
+        # for single disk.
+        # NOTE:  scsi-block and scsi-generic are pass-through physical dev only
+        drive_format=scsi-hd
+        cd_format=scsi-cd
     - ahci:
         drive_format=ahci
         cd_format=ahci
diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index e544f05..3a2e755 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -281,6 +281,13 @@ class VM(virt_vm.BaseVM):
                     dev += ",port=%d" % (int(index) + 1)
                     format = "none"
                     index = None
+                if format.startswith("scsi-"):
+                    # handles scsi-{hd, cd, disk, block, generic} targets
+                    name = "virtio-scsi-cd%s" % index
+                    dev += (" -device %s,drive=%s,bus=virtio_scsi_pci.0" %
+                            (format, name))
+                    format = "none"
+                    index = None
                 cmd = " -drive file='%s',media=cdrom" % filename
                 if index is not None:
                     cmd += ",index=%s" % index
@@ -320,6 +327,20 @@ class VM(virt_vm.BaseVM):
                 dev += _add_option("drive", name)
                 format = "none"
                 index = None
+            if format.startswith("scsi-"):
+                # handles scsi-{hd, cd, disk, block, generic} targets
+                name = "virtio-scsi%s" % index
+                dev += " -device %s,bus=virtio_scsi_pci.0" % format
+                dev += _add_option("drive", name)
+                dev += _add_option("logical_block_size", logical_block_size)
+                dev += _add_option("physical_block_size", physical_block_size)
+                dev += _add_option("min_io_size", min_io_size)
+                dev += _add_option("opt_io_size", opt_io_size)
+                dev += _add_option("bootindex", bootindex)
+                dev += _add_option("serial", serial)
+                dev += _add_option("removable", removable)
+                format = "none"
+                index = None
 
             if blkdebug is not None:
                 cmd = " -drive file=blkdebug:%s:%s" % (blkdebug, filename)
@@ -538,6 +559,7 @@ class VM(virt_vm.BaseVM):
             root_dir = self.root_dir
 
         have_ahci = False
+        have_virtio_scsi = False
 
         # Clone this VM using the new params
         vm = self.clone(name, params, root_dir, copy_state=True)
@@ -607,6 +629,10 @@ class VM(virt_vm.BaseVM):
             if image_params.get("drive_format") == "ahci" and not have_ahci:
                 qemu_cmd += " -device ahci,id=ahci"
                 have_ahci = True
+            if (image_params.get("drive_format").startswith("scsi-")
+                        and not have_virtio_scsi):
+                qemu_cmd += " -device virtio-scsi,id=virtio_scsi_pci"
+                have_virtio_scsi = True
 
             bus = None
             port = None
@@ -697,6 +723,9 @@ class VM(virt_vm.BaseVM):
             if cdrom_params.get("cd_format") == "ahci" and not have_ahci:
                 qemu_cmd += " -device ahci,id=ahci"
                 have_ahci = True
+            if (cdrom_params.get("cd_format").startswith("scsi-")
+                        and not have_virtio_scsi):
+                qemu_cmd += " -device virtio-scsi,id=virtio_scsi_pci"
             if iso:
                 qemu_cmd += add_cdrom(help, virt_utils.get_path(root_dir, iso),
                                       cdrom_params.get("drive_index"),
-- 
1.7.7.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux