From 25295deed22c3621f71529b7f30a9aa8967a4814 Mon Sep 17 00:00:00 2001
From: Asias He <asias@cloudius-systems.com>
Date: Fri, 20 Dec 2013 10:42:15 +0800
Subject: [PATCH] run.py: Add --scsi option to boot from virtio-scsi

Use --scsi or -S to boot from virtio-scsi instead of virtio-blk device.

This options is default to false.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
---
 scripts/run.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/scripts/run.py b/scripts/run.py
index aef0a1e5a..274beecba 100755
--- a/scripts/run.py
+++ b/scripts/run.py
@@ -55,8 +55,15 @@ def start_osv_qemu(options):
         "-vnc", ":1",
         "-gdb", "tcp::1234,server,nowait",
         "-m", options.memsize,
-        "-smp", options.vcpus,
-        "-drive", "file=%s,if=virtio,cache=%s" % (options.image_file, cache)]
+        "-smp", options.vcpus]
+
+    if (options.scsi):
+        args += [
+        "-device", "virtio-scsi-pci,id=scsi0",
+        "-drive", "file=%s,if=none,id=hd0,media=disk,aio=native,cache=%s" % (options.image_file, cache),
+        "-device", "scsi-hd,bus=scsi0.0,drive=hd0,lun=0,bootindex=0"]
+    else:
+        args += ["-drive", "file=%s,if=virtio,cache=%s" % (options.image_file, cache)]
     
     if (options.no_shutdown):
         args += ["-no-reboot", "-no-shutdown"]
@@ -217,6 +224,8 @@ if (__name__ == "__main__"):
                         help="don't start OSv till otherwise specified, e.g. through the QEMU monitor or a remote gdb")
     parser.add_argument("-i", "--image", action="store", default=None, metavar="IMAGE",
                         help="path to disk image file. defaults to build/$mode/usr.img")
+    parser.add_argument("-S", "--scsi", action="store_true", default=False,
+                        help="use virtio-scsi instead of virtio-blk")
     parser.add_argument("-n", "--networking", action="store_true",
                         help="needs root. tap networking, specify interface")
     parser.add_argument("-b", "--bridge", action="store", default="virbr0",
-- 
GitLab