Skip to content

Commit

Permalink
B #6772: Fix for NUMA and CPU Pinning Discrepancies During VM Save an…
Browse files Browse the repository at this point in the history
…d Live Migration

Signed-off-by: Kristian Feldsam <[email protected]>
  • Loading branch information
feldsam committed Dec 20, 2024
1 parent ebc5b95 commit 24b109d
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 61 deletions.
2 changes: 2 additions & 0 deletions include/History.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ class History:public ObjectSQL, public ObjectXML
std::string deployment_file;
std::string context_file;
std::string token_file;
std::string migrate_file;

// Remote paths
std::string checkpoint_file;
std::string rdeployment_file;
std::string system_dir;
std::string rmigrate_file;

/**
* Writes the history record in the DB
Expand Down
24 changes: 24 additions & 0 deletions include/VirtualMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,19 @@ class VirtualMachine : public PoolObjectSQL
return history->token_file;
}

/**
* Returns the migrate filename. The migrate file is in the form:
* $ONE_LOCATION/var/vms/$VM_ID/migrate.$SEQ
* or, in case that OpenNebula is installed in root
* /var/lib/one/vms/$VM_ID/migrate.$SEQ
* The hasHistory() function MUST be called before this one.
* @return the migrate file path
*/
const std::string & get_migrate_file() const
{
return history->migrate_file;
};

/**
* Returns the remote deployment filename. The file is in the form:
* $DS_LOCATION/$SYSTEM_DS/$VM_ID/deployment.$SEQ
Expand All @@ -596,6 +609,17 @@ class VirtualMachine : public PoolObjectSQL
return history->rdeployment_file;
};

/**
* Returns the remote migrate filename. The file is in the form:
* $DS_LOCATION/$SYSTEM_DS/$VM_ID/migrate.$SEQ
* The hasHistory() function MUST be called before this one.
* @return the migrate filename
*/
const std::string & get_rmigrate_file() const
{
return history->rmigrate_file;
};

/**
* Returns the checkpoint filename for the current host. The checkpoint file
* is in the form:
Expand Down
4 changes: 3 additions & 1 deletion include/VirtualMachineManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ class VirtualMachineManager :
const std::string& tmpl,
int ds_id,
int sgid = -1,
int nicid = -1);
int nicid = -1,
const std::string& lmfile = "",
const std::string& rmfile = "");

public:
/**
Expand Down
16 changes: 13 additions & 3 deletions src/lcm/LifeCycleActions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,

if ( vm->get_hid() != vm->get_previous_hid() )
{
hpool->del_capacity(vm->get_previous_hid(), sr);
HostShareCapacity prev_sr;
Template tmpl;
vm->get_previous_capacity(prev_sr, tmpl);

hpool->del_capacity(vm->get_previous_hid(), prev_sr);

vm->release_previous_vnc_port();
}
Expand Down Expand Up @@ -1038,6 +1042,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
int& image_id, int uid, int gid, int req_id, Template& quota_tmpl)
{
HostShareCapacity sr;
HostShareCapacity prev_sr;
Template tmpl;

time_t the_time = time(0);

Expand Down Expand Up @@ -1245,11 +1251,13 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
case VirtualMachine::MIGRATE:
vm->set_running_etime(the_time);

vm->get_previous_capacity(prev_sr, tmpl);

vm->set_previous_etime(the_time);
vm->set_previous_vm_info();
vm->set_previous_running_etime(the_time);

hpool->del_capacity(vm->get_previous_hid(), sr);
hpool->del_capacity(vm->get_previous_hid(), prev_sr);

vmpool->update_previous_history(vm);

Expand All @@ -1268,11 +1276,13 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
case VirtualMachine::SAVE_MIGRATE:
vm->set_running_etime(the_time);

vm->get_previous_capacity(prev_sr, tmpl);

vm->set_previous_etime(the_time);
vm->set_previous_vm_info();
vm->set_previous_running_etime(the_time);

hpool->del_capacity(vm->get_previous_hid(), sr);
hpool->del_capacity(vm->get_previous_hid(), prev_sr);

vmpool->update_previous_history(vm);

Expand Down
25 changes: 13 additions & 12 deletions src/lcm/LifeCycleStates.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)

vm->set_state(VirtualMachine::PROLOG_MIGRATE);

vm->set_previous_etime(the_time);

vm->set_previous_running_etime(the_time);

vmpool->update_previous_history(vm);

vm->set_prolog_stime(the_time);

vmpool->update_history(vm);

if ( vm->get_hid() != vm->get_previous_hid() )
{
Template tmpl;
Expand All @@ -64,6 +54,16 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)
vm->release_previous_vnc_port();
}

vm->set_previous_etime(the_time);

vm->set_previous_running_etime(the_time);

vmpool->update_previous_history(vm);

vm->set_prolog_stime(the_time);

vmpool->update_history(vm);

vmpool->update(vm);

//----------------------------------------------------
Expand Down Expand Up @@ -290,6 +290,9 @@ void LifeCycleManager::trigger_deploy_success(int vid)

vm->set_running_stime(the_time);

Template tmpl;
vm->get_previous_capacity(sr, tmpl);

vmpool->update_history(vm.get());

vm->set_previous_etime(the_time);
Expand All @@ -298,8 +301,6 @@ void LifeCycleManager::trigger_deploy_success(int vid)

vmpool->update_previous_history(vm.get());

vm->get_capacity(sr);

hpool->del_capacity(vm->get_previous_hid(), sr);

vm->set_state(VirtualMachine::RUNNING);
Expand Down
8 changes: 0 additions & 8 deletions src/rm/RequestManagerVirtualMachine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1160,14 +1160,6 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return;
}

if (live && vm->is_pinned())
{
att.resp_msg = "VM with a pinned NUMA topology cannot be live-migrated";
failure_response(ACTION, att);

return;
}

// Get System DS information from current History record
c_ds_id = vm->get_ds_id();
c_tm_mad = vm->get_tm_mad();
Expand Down
10 changes: 10 additions & 0 deletions src/vm/History.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ void History::non_persistent_data()

token_file = os.str();

os.str("");
os << vm_lhome << "/migrate." << seq;

migrate_file = os.str();

// ----------- Remote Locations ------------
os.str("");
os << ds_location << "/" << ds_id << "/" << oid;
Expand All @@ -141,6 +146,11 @@ void History::non_persistent_data()
os << system_dir << "/deployment." << seq;

rdeployment_file = os.str();

os.str("");
os << system_dir << "/migrate." << seq;

rmigrate_file = os.str();
}

/* -------------------------------------------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions src/vmm/LibVirtDriverKVM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2298,5 +2298,7 @@ int LibVirtDriver::deployment_description_kvm(

file << "</domain>" << endl;

file.close();

return 0;
}
79 changes: 74 additions & 5 deletions src/vmm/VirtualMachineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ string VirtualMachineManager::format_message(
const string& tmpl,
int ds_id,
int sgid,
int nicid)
int nicid,
const string& lmfile,
const string& rmfile)
{
ostringstream oss;

Expand Down Expand Up @@ -266,6 +268,17 @@ string VirtualMachineManager::format_message(
oss << "<REMOTE_DEPLOYMENT_FILE/>";
}

if (!lmfile.empty())
{
oss << "<LOCAL_MIGRATE_FILE>" << lmfile << "</LOCAL_MIGRATE_FILE>";
oss << "<REMOTE_MIGRATE_FILE>" << rmfile << "</REMOTE_MIGRATE_FILE>";
}
else
{
oss << "<LOCAL_MIGRATE_FILE/>";
oss << "<REMOTE_MIGRATE_FILE/>";
}

if (!cfile.empty())
{
oss << "<CHECKPOINT_FILE>" << cfile << "</CHECKPOINT_FILE>";
Expand Down Expand Up @@ -495,8 +508,9 @@ void VirtualMachineManager::trigger_save(int vid)
trigger([this, vid]
{
const VirtualMachineManagerDriver * vmd;
int rc;

string hostname, checkpoint_file;
string hostname, checkpoint_file, migrate_file, rmigrate_file;
string vm_tmpl;
string drv_msg;
int ds_id;
Expand Down Expand Up @@ -535,12 +549,31 @@ void VirtualMachineManager::trigger_save(int vid)
hostname = vm->get_previous_hostname();
checkpoint_file = vm->get_previous_checkpoint_file();
ds_id = vm->get_previous_ds_id();

//Generate VM description file
os << "Generating migrate file: " << vm->get_migrate_file();

vm->log("VMM", Log::INFO, os);

os.str("");

rc = vmd->deployment_description(vm.get(), vm->get_migrate_file());

if (rc != 0)
{
goto error_file;
}

migrate_file = vm->get_migrate_file();
rmigrate_file = vm->get_rmigrate_file();
}
else
{
hostname = vm->get_hostname();
checkpoint_file = vm->get_checkpoint_file();
ds_id = vm->get_ds_id();
migrate_file = "";
rmigrate_file = "";
}

// Invoke driver method
Expand All @@ -556,7 +589,10 @@ void VirtualMachineManager::trigger_save(int vid)
"",
vm->to_xml(vm_tmpl),
ds_id,
-1);
-1,
-1,
migrate_file,
rmigrate_file);

vmd->save(vid, drv_msg);

Expand All @@ -570,6 +606,11 @@ void VirtualMachineManager::trigger_save(int vid)
os << "save_action, error getting driver " << vm->get_vmm_mad();
goto error_common;

error_file:
os << "save_action, error generating migrate file: "
<< vm->get_migrate_file();
goto error_common;

error_previous_history:
os << "save_action, VM has no previous history";

Expand Down Expand Up @@ -1154,10 +1195,12 @@ void VirtualMachineManager::trigger_migrate(int vid)
trigger([this, vid]
{
const VirtualMachineManagerDriver * vmd;
int rc;

ostringstream os;
string vm_tmpl;
string drv_msg;
string tm_command = "";

// Get the VM from the pool
auto vm = vmpool->get(vid);
Expand Down Expand Up @@ -1187,6 +1230,24 @@ void VirtualMachineManager::trigger_migrate(int vid)

Nebula::instance().get_tm()->migrate_transfer_command(vm.get(), os);

tm_command = os.str();

os.str("");

//Generate VM description file
os << "Generating migrate file: " << vm->get_migrate_file();

vm->log("VMM", Log::INFO, os);

os.str("");

rc = vmd->deployment_description(vm.get(), vm->get_migrate_file());

if (rc != 0)
{
goto error_file;
}

// Invoke driver method
drv_msg = format_message(
vm->get_previous_hostname(),
Expand All @@ -1195,12 +1256,15 @@ void VirtualMachineManager::trigger_migrate(int vid)
"",
"",
"",
os.str(),
tm_command,
"",
vm->get_system_dir(),
vm->to_xml(vm_tmpl),
vm->get_previous_ds_id(),
-1);
-1,
-1,
vm->get_migrate_file(),
vm->get_rmigrate_file());

vmd->migrate(vid, drv_msg);

Expand All @@ -1214,6 +1278,11 @@ void VirtualMachineManager::trigger_migrate(int vid)
os << "migrate_action, error getting driver " << vm->get_vmm_mad();
goto error_common;

error_file:
os << "migrate_action, error generating migrate file: "
<< vm->get_migrate_file();
goto error_common;

error_previous_history:
os << "migrate_action, error VM has no previous history";

Expand Down
Loading

0 comments on commit 24b109d

Please sign in to comment.