From 5fc1abfc64f68ed56938f275ad6d7df0ccf228e7 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Thu, 16 Aug 2012 19:01:02 +0000 Subject: xenapi: attach root disk during rescue before boot Fixes bug 1037729 The xenapi driver attaches the root disk after the rescue instance has booted. However, hotplugging block devices is only supported on images that use PV drivers. Attaching the disk before the rescue instance boots will allow rescue to work on instances that don't use PV drivers. Change-Id: I187762e4f1ea921d81afd40fcbde0b93d7d3cbc1 --- nova/virt/xenapi/vmops.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 10cca68f4..3a0c8e4d1 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -303,6 +303,18 @@ class VMOps(object): undo_mgr.undo_with(undo_create_vm) return vm_ref + if rescue: + # NOTE(johannes): Attach root disk to rescue VM now, before + # booting the VM, since we can't hotplug block devices + # on non-PV guests + @step + def attach_root_disk_step(undo_mgr, vm_ref): + orig_vm_ref = vm_utils.lookup(self._session, instance['name']) + vdi_ref = self._find_root_vdi_ref(orig_vm_ref) + + vm_utils.create_vbd(self._session, vm_ref, vdi_ref, + DEVICE_RESCUE, bootable=False) + @step def prepare_security_group_filters_step(undo_mgr): try: @@ -345,6 +357,9 @@ class VMOps(object): vm_ref = create_vm_step(undo_mgr, vdis, kernel_file, ramdisk_file) prepare_security_group_filters_step(undo_mgr) + if rescue: + attach_root_disk_step(undo_mgr, vm_ref) + boot_instance_step(undo_mgr, vm_ref) apply_security_group_filters_step(undo_mgr) @@ -1054,13 +1069,6 @@ class VMOps(object): self._acquire_bootlock(vm_ref) self.spawn(context, instance, image_meta, [], rescue_password, network_info, name_label=rescue_name_label, rescue=True) - rescue_vm_ref = vm_utils.lookup(self._session, rescue_name_label) - vdi_ref = self._find_root_vdi_ref(vm_ref) - - rescue_vbd_ref = vm_utils.create_vbd(self._session, rescue_vm_ref, - vdi_ref, DEVICE_RESCUE, - bootable=False) - self._session.call_xenapi('VBD.plug', rescue_vbd_ref) def unrescue(self, instance): """Unrescue the specified instance. -- cgit