From 2b8463047a71e40e86233b7f35698f478350986f Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 23 Jul 2012 13:56:09 +0200 Subject: [PATCH] KVM: only pass boot flag once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This addresses issue 230: passing two methods of booting to KVM can, depending on the KVM version, confuse it. Note that commit 4304964a introduced a partial fix for this (but only for disks, and keyed on KVM versions). However, it didn't fix cdrom booting, which still fails with the same error, so let's fix it more generically; we still leave the per-disk check since that is about -boot c versus -drive β¦,boot=on rather than two boot methods. Patch is based on the one submitted by Vladimir Mencl, many thanks! Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/hypervisor/hv_kvm.py | 13 ++++++++----- man/gnt-instance.rst | 15 +++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 77b46b2e2..2ed07aece 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -551,10 +551,14 @@ class KVMHypervisor(hv_base.BaseHypervisor): kvm_cmd.extend(["-no-reboot"]) hvp = instance.hvparams - boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK - boot_cdrom = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_CDROM - boot_floppy = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_FLOPPY - boot_network = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_NETWORK + kernel_path = hvp[constants.HV_KERNEL_PATH] + if kernel_path: + boot_disk = boot_cdrom = boot_floppy = boot_network = False + else: + boot_disk = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_DISK + boot_cdrom = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_CDROM + boot_floppy = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_FLOPPY + boot_network = hvp[constants.HV_BOOT_ORDER] == constants.HT_BO_NETWORK self.ValidateParameters(hvp) @@ -645,7 +649,6 @@ class KVMHypervisor(hv_base.BaseHypervisor): drive_val = "file=%s%s" % (floppy_image, options) kvm_cmd.extend(["-drive", drive_val]) - kernel_path = hvp[constants.HV_KERNEL_PATH] if kernel_path: kvm_cmd.extend(["-kernel", kernel_path]) initrd_path = hvp[constants.HV_INITRD_PATH] diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 5d906a403..bb2d982f1 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -175,9 +175,11 @@ boot\_order as 'dc'. For KVM the boot order is either "floppy", "cdrom", "disk" or - "network". Please note that older versions of KVM couldn't - netboot from virtio interfaces. This has been fixed in more recent - versions and is confirmed to work at least with qemu-kvm 0.11.1. + "network". Please note that older versions of KVM couldn't netboot + from virtio interfaces. This has been fixed in more recent versions + and is confirmed to work at least with qemu-kvm 0.11.1. Also note + that if you have set the ``kernel_path`` option, that will be used + for booting, and this setting will be silently ignored. blockdev\_prefix Valid for the Xen HVM and PVM hypervisors. @@ -326,9 +328,10 @@ kernel\_path Valid for the Xen PVM and KVM hypervisors. This option specifies the path (on the node) to the kernel to boot - the instance with. Xen PVM instances always require this, while - for KVM if this option is empty, it will cause the machine to load - the kernel from its disks. + the instance with. Xen PVM instances always require this, while for + KVM if this option is empty, it will cause the machine to load the + kernel from its disks (and the boot will be done accordingly to + ``boot_order``). kernel\_args Valid for the Xen PVM and KVM hypervisors. -- GitLab