From: Lukas Doktor <ldoktor@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org,
kvm-autotest@redhat.com, ldoktor@redhat.com, jzupka@redhat.com
Subject: [PATCH] [KVM-autotest] virt.kvm_vm: Add virtio-scsi support
Date: Thu, 9 Feb 2012 08:33:01 +0100 [thread overview]
Message-ID: <1328772781-27339-2-git-send-email-ldoktor@redhat.com> (raw)
In-Reply-To: <1328772781-27339-1-git-send-email-ldoktor@redhat.com>
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
prev parent reply other threads:[~2012-02-09 7:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-09 7:33 [KVM-autotest] virt.kvm_vm: Add virtio-scsi support Lukas Doktor
2012-02-09 7:33 ` Lukas Doktor [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328772781-27339-2-git-send-email-ldoktor@redhat.com \
--to=ldoktor@redhat.com \
--cc=autotest@test.kernel.org \
--cc=jzupka@redhat.com \
--cc=kvm-autotest@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).