diff --git a/src/host/HostShare.cc b/src/host/HostShare.cc index 83d8b78fe9..e922a00fd3 100644 --- a/src/host/HostShare.cc +++ b/src/host/HostShare.cc @@ -92,7 +92,7 @@ bool HostSharePCI::test(const vector &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; diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 2b61438acf..895f0027c8 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1071,7 +1071,6 @@ int VirtualMachine::parse_pci(string& error_str) vector::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; - } } }