From cd00217bade7b72f562f6d834e40baeb3fedc578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 3 Jul 2012 18:58:14 +0200 Subject: [PATCH] Bug #1306: VMs cannot be migrated to hosts using a different system DS (cherry picked from commit 2867263e5734007747322cbcf9f94fb5ee6b0ac8) --- src/rm/RequestManagerVirtualMachine.cc | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index eea341cfc6..77ba7b5fdf 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -440,6 +440,11 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList string tm_mad; int ds_id; + PoolObjectAuth aux_perms; + int current_ds_id; + string aux_st; + int current_hid; + int id = xmlrpc_c::value_int(paramList.getInt(1)); int hid = xmlrpc_c::value_int(paramList.getInt(2)); bool live = xmlrpc_c::value_boolean(paramList.getBoolean(3)); @@ -476,6 +481,39 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList return; } + current_hid = vm->get_hid(); + + vm->unlock(); + + if (get_host_information( + current_hid,aux_st,aux_st,aux_st, + aux_st,current_ds_id, att, aux_perms) != 0) + { + return; + } + + if ( current_ds_id != ds_id ) + { + ostringstream oss; + + oss << "Cannot migrate to a different cluster with different system " + << "datastore. Current " << object_name(PoolObjectSQL::HOST) + << " [" << current_hid << "] uses system datastore [" << current_ds_id + << "], new " << object_name(PoolObjectSQL::HOST) << " [" << hid + << "] uses system datastore [" << ds_id << "]"; + + failure_response(ACTION, + request_error(oss.str(),""), + att); + + return; + } + + if ( (vm = get_vm(id, att)) == 0 ) + { + return; + } + if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id,att) != 0) { vm->unlock();