kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [KVM-autotest] virt.kvm_vm: Add virtio-scsi support
@ 2012-02-09  7:33 Lukas Doktor
  2012-02-09  7:33 ` [PATCH] " Lukas Doktor
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Doktor @ 2012-02-09  7:33 UTC (permalink / raw)
  To: autotest, kvm, kvm-autotest, ldoktor, jzupka

This patch adds support for virtio-scsi devices.

Added block variants:
* virtio_scsi (default)
* virtio_scsi_disk (legacy scsi)
* virtio_scsi_block (only raw /dev/sd* files)
* virtio_scsi_generic (only raw /dev/sg* files)

Please keep in mind that virtio-scsi is not yet upstream. To test this patch you have to:
1) have a guest OS with virtio-scsi support ( https://github.com/bonzini/virtio-scsi/commits/master )
2) qemu support for virtio-scsi devices ( git://github.com/bonzini/qemu.git )
3) qemu bios support (http://people.redhat.com/pbonzini/virtio-scsi/ )
NOTE: you can download testing rpm packages for all of the above on Paolo Bonzini's page http://people.redhat.com/pbonzini/virtio-scsi/
NOTE2: without modified qemu bios you won't be able to boot from virtio-scsi device
NOTE3: currently only boot from lun0 is supported
NOTE4: automatic hotplug that doesn't work. You have to initialize the device (echo "scsi add-single-device" 2 0 1 0 > /proc/scsi/scsi )

Also please be aware that virtio_scsi_block and virtio_scsi_generic devices are pass-through targets thus you can specify only /dev/sg (resp. /dev/sd*) devices. Also in my version of qemu it was impossible to set those targets directly from cmd-line, although hot-plug worked fine.

Pull request:
https://github.com/autotest/autotest/pull/170

Regards,
Lukáš Doktor

Signed-off-by: Lukas Doktor ldoktor@redhat.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] [KVM-autotest] virt.kvm_vm: Add virtio-scsi support
  2012-02-09  7:33 [KVM-autotest] virt.kvm_vm: Add virtio-scsi support Lukas Doktor
@ 2012-02-09  7:33 ` Lukas Doktor
  0 siblings, 0 replies; 2+ messages in thread
From: Lukas Doktor @ 2012-02-09  7:33 UTC (permalink / raw)
  To: autotest, kvm, kvm-autotest, ldoktor, jzupka

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@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-09  7:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09  7:33 [KVM-autotest] virt.kvm_vm: Add virtio-scsi support Lukas Doktor
2012-02-09  7:33 ` [PATCH] " Lukas Doktor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).