From 4e939fd6eb7ec2ceacd286f90aa5c272e4c600d9 Mon Sep 17 00:00:00 2001 From: lmr Date: Mon, 6 Jun 2011 21:55:25 +0000 Subject: [PATCH] KVM test: ahci cdroms This patch adds support for AHCI cdroms. SCSI cdroms work too as side effect. The patch also adds cd_format, which is the same as disk_format but for cdroms. Signed-off-by: Gerd Hoffmann git-svn-id: svn://test.kernel.org/autotest/trunk@5414 592f7852-d20e-0410-864c-8624ca9c26a4 --- client/virt/kvm_vm.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py index 43408f6a..f6a77fcb 100644 --- a/client/virt/kvm_vm.py +++ b/client/virt/kvm_vm.py @@ -188,11 +188,23 @@ class VM(virt_vm.BaseVM): def add_smp(help, smp): return " -smp %s" % smp - def add_cdrom(help, filename, index=None): + def add_cdrom(help, filename, index=None, format=None): if has_option(help, "drive"): + name = None; + dev = ""; + if format == "ahci": + name = "ahci%s" % index + dev += " -device ide-drive,bus=ahci.%s,drive=%s" % (index, name) + format = "none" + index = None cmd = " -drive file='%s',media=cdrom" % filename - if index is not None: cmd += ",index=%s" % index - return cmd + if index is not None: + cmd += ",index=%s" % index + if format: + cmd += ",if=%s" % format + if name: + cmd += ",id=%s" % name + return cmd + dev else: return " -cdrom '%s'" % filename @@ -469,9 +481,13 @@ class VM(virt_vm.BaseVM): for cdrom in params.objects("cdroms"): cdrom_params = params.object_params(cdrom) iso = cdrom_params.get("cdrom") + if cdrom_params.get("cd_format") == "ahci" and not have_ahci: + qemu_cmd += " -device ahci,id=ahci" + have_ahci = True if iso: qemu_cmd += add_cdrom(help, virt_utils.get_path(root_dir, iso), - cdrom_params.get("drive_index")) + cdrom_params.get("drive_index"), + cdrom_params.get("cd_format")) # We may want to add {floppy_otps} parameter for -fda # {fat:floppy:}/path/. However vvfat is not usually recommended. -- 2.11.4.GIT