1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-15 05:57:23 +03:00

B #3230 Wrong PCI to VM association removed when migrating VM with PCI pass-through (#3261)

This commit is contained in:
Christian González 2019-04-26 10:13:12 +02:00 committed by Ruben S. Montero
parent 87e928dc26
commit 3e60cc4002
3 changed files with 44 additions and 3 deletions

View File

@ -121,7 +121,8 @@ void HostSharePCI::add(vector<VectorAttribute *> &devs, int vmid)
map<string, PCIDevice *>::const_iterator jt;
unsigned int vendor_id, device_id, class_id;
int vendor_rc, device_rc, class_rc;
string address;
int vendor_rc, device_rc, class_rc, addr_rc;
for ( it=devs.begin(); it!= devs.end(); it++)
{
@ -129,6 +130,8 @@ void HostSharePCI::add(vector<VectorAttribute *> &devs, int vmid)
device_rc = get_pci_value("DEVICE", *it, device_id);
class_rc = get_pci_value("CLASS" , *it, class_id);
addr_rc = (*it)->vector_value("ADDRESS", address);
for (jt=pci_devices.begin(); jt!=pci_devices.end(); jt++)
{
PCIDevice * dev = jt->second;
@ -148,6 +151,11 @@ void HostSharePCI::add(vector<VectorAttribute *> &devs, int vmid)
(*it)->replace("ADDRESS",dev->attrs->vector_value("ADDRESS"));
if (addr_rc != -1 && !address.empty())
{
(*it)->replace("PREV_ADDRESS", address);
}
break;
}
}
@ -164,6 +172,18 @@ void HostSharePCI::del(const vector<VectorAttribute *> &devs)
for ( it=devs.begin(); it!= devs.end(); it++)
{
pci_it = pci_devices.find((*it)->vector_value("PREV_ADDRESS"));
if (pci_it != pci_devices.end())
{
pci_it->second->vmid = -1;
pci_it->second->attrs->replace("VMID",-1);
(*it)->remove("PREV_ADDRESS");
continue;
}
pci_it = pci_devices.find((*it)->vector_value("ADDRESS"));
if (pci_it != pci_devices.end())

View File

@ -52,8 +52,6 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)
vmpool->update_history(vm);
vmpool->update(vm);
vm->get_requirements(cpu, mem, disk, pci);
if ( vm->get_hid() != vm->get_previous_hid() )
@ -62,6 +60,8 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)
disk, pci);
}
vmpool->update(vm);
//----------------------------------------------------
tm->trigger(TMAction::PROLOG_MIGR,vm->get_oid());

View File

@ -1152,6 +1152,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
// - VM States are right and there is at least a history record
// - New host is not the current one
// - Host capacity if required
// - Compatibility with PCI devices
// - New host and current one are in the same cluster
// - New or old host are not public cloud
// ------------------------------------------------------------------------
@ -1237,6 +1238,26 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return;
}
//Check PCI devices are compatible with migration type
int cpu, mem, disk;
vector<VectorAttribute *> pci;
vm->get_requirements(cpu, mem, disk, pci);
if ((pci.size() > 0) && !poffmgr)
{
ostringstream oss;
oss << "Cannot migrate VM [" << id << "], for migrating a VM with PCI devices attached it's necessary either the poweroff or poweroff-hard flag";
att.resp_msg = oss.str();
failure_response(ACTION, att);
vm->unlock();
return;
}
vm->unlock();
// Check we are migrating to a compatible cluster