mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
feature #3028: Update HostShare::get_pci_value check for empty and wrong
values
This commit is contained in:
parent
5ecbfee4e2
commit
4125ef4c25
@ -92,7 +92,7 @@ bool HostSharePCI::test(const vector<Attribute *> &devs) const
|
||||
device_id = get_pci_value("DEVICE", pci);
|
||||
class_id = get_pci_value("CLASS", pci);
|
||||
|
||||
if (vendor_id == 0 && device_id == 0 && class_id == 0)
|
||||
if (vendor_id <= 0 && device_id <= 0 && class_id <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -293,7 +293,7 @@ unsigned int HostSharePCI::get_pci_value(const char * name,
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
{
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return pci_value;
|
||||
|
@ -1071,7 +1071,6 @@ int VirtualMachine::parse_pci(string& error_str)
|
||||
vector<Attribute *>::iterator it;
|
||||
|
||||
unsigned int pci_val;
|
||||
string st;
|
||||
|
||||
user_obj_template->remove("PCI", array_pci);
|
||||
|
||||
@ -1096,22 +1095,21 @@ int VirtualMachine::parse_pci(string& error_str)
|
||||
|
||||
for (int i=0; i<3; i++)
|
||||
{
|
||||
if (pci->vector_value(attrs[i].c_str(), st) != -1)
|
||||
pci_val = HostSharePCI::get_pci_value(attrs[i].c_str(), pci);
|
||||
|
||||
if (pci_val == -1)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Wrong value for PCI/" << attrs[i] << ": "
|
||||
<< pci->vector_value(attrs[i].c_str())
|
||||
<<". It must be a hex value";
|
||||
|
||||
error_str = oss.str();
|
||||
return -1;
|
||||
}
|
||||
else if ( pci_val != 0 )
|
||||
{
|
||||
found = true;
|
||||
|
||||
pci_val = HostSharePCI::get_pci_value(attrs[i].c_str(), pci);
|
||||
|
||||
if (pci_val == 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Wrong value for PCI/" << attrs[i] << ": "
|
||||
<< pci->vector_value(attrs[i].c_str())
|
||||
<<". It must be a hex value";
|
||||
|
||||
error_str = oss.str();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user