Checking if qemu-kvm has the '-device' command line option seems to
safe and accurate enough to generate correct syntaxes on both RHEL 5
and latest upstream.

This is better documented on github issue #504.

Signed-off-by: Cleber Rosa <[email protected]>
---
 client/virt/kvm_vm.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index a5e596b..03a2b14 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -479,11 +479,12 @@ class VM(virt_vm.BaseVM):
                 format = "none"
                 index = None
             if format == "virtio":
-                name = "virtio%s" % index
-                dev += " -device virtio-blk-pci"
+                if has_option(help, "device"):
+                    name = "virtio%s" % index
+                    dev += " -device virtio-blk-pci"
+                    dev += _add_option("drive", name)
+                    format = "none"
                 dev += _add_option("bootindex", bootindex)
-                dev += _add_option("drive", name)
-                format = "none"
                 index = None
             if format in ['usb1', 'usb2', 'usb3']:
                 name = "%s.%s" % (format, index)
-- 
1.7.11.4

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to