@@ -9766,7 +9766,7 @@ struct VM {
97669766
97679767#if (CPP >= 17)
97689768 for (const auto & entry : std::filesystem::directory_iterator (pci_path)) {
9769- std::string dev_path = entry.path ();
9769+ std::string dev_path = entry.path (). string () ;
97709770#else
97719771 DIR* dir;
97729772 struct dirent * ent;
@@ -9778,20 +9778,21 @@ struct VM {
97789778
97799779 while ((ent = readdir (dir)) != nullptr ) {
97809780 std::string dev_name = ent->d_name ;
9781- if (dev_name == " ." || dev_name == " .." )
9781+
9782+ if (dev_name == " ." || dev_name == " .." ) {
97829783 continue ;
9784+ }
9785+
97839786 std::string dev_path = pci_path + " /" + dev_name;
97849787#endif
97859788 PCI_Device dev;
97869789
97879790 std::ifstream vendor_file (dev_path + " /vendor" );
97889791 std::ifstream device_file (dev_path + " /device" );
9789- if (!vendor_file || !device_file) {
9790- continue ;
9791- }
97929792
97939793 vendor_file >> std::hex >> dev.vendor_id ;
97949794 device_file >> std::hex >> dev.device_id ;
9795+
97959796 devices.push_back (dev);
97969797 }
97979798
@@ -9800,27 +9801,29 @@ struct VM {
98009801 debug (" -------------------------" );
98019802 debug (" Vendor ID | Device ID " );
98029803 debug (" -------------------------" );
9804+
98039805 for (const auto & d : devices) {
98049806 debug (
98059807 " 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.vendor_id ,
9806- " | 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.device_id ,
9808+ " | " ,
9809+ " 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.device_id ,
98079810 std::dec
98089811 );
98099812 }
98109813#endif
98119814
98129815 auto found = [](const std::string& b, const PCI_Device& d) -> bool {
98139816 debug (
9814- " PCI_VM_DEVICE_ID: found " , b,
9815- " , vendor ID = 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.vendor_id ,
9816- " device ID = 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.device_id ,
9817- std::dec
9817+ " PCI_VM_DEVICE_ID: found " , b, " , vendor ID = " ,
9818+ " 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.vendor_id ,
9819+ " device ID = 0x" , std::setw (4 ), std::setfill (' 0' ), std::hex, d.device_id
98189820 );
9821+
98199822 return true ;
9820- };
9823+ };
98219824
98229825 for (const auto & dev : devices) {
9823- const u32 id = ((dev.vendor_id << 16 ) | dev.device_id );
9826+ const u32 id = ((static_cast < u32 >( dev.vendor_id ) << 16 ) | dev.device_id );
98249827
98259828 switch (id) {
98269829 // Red Hat + Virtio
@@ -9875,7 +9878,7 @@ struct VM {
98759878 case 0x0e0f8002 : // Root Hub
98769879 case 0x0e0f8003 : // Root Hub
98779880 case 0x0e0ff80a : // Smoker FX2
9878- return found (brands::VMWARE);
9881+ return found (brands::VMWARE, dev );
98799882
98809883 // Red Hat + QEMU
98819884 case 0x1b360001 : // Red Hat, Inc. QEMU PCI-PCI bridge
@@ -9892,13 +9895,14 @@ struct VM {
98929895 case 0x1b360011 : // Red Hat, Inc. QEMU PVPanic device
98939896 case 0x1b360013 : // Red Hat, Inc. QEMU UFS Host Controller
98949897 case 0x1b360100 : // Red Hat, Inc. QXL paravirtual graphic card
9898+ return found (brands::QEMU, dev);
98959899
98969900 // QEMU
98979901 case 0x06270001 : // Adomax Technology Co., Ltd QEMU Tablet
98989902 case 0x1d1d1f1f : // CNEX Labs QEMU NVM Express LightNVM Controller
98999903 case 0x80865845 : // Intel Corporation QEMU NVM Express Controller
99009904 case 0x1d6b0200 : // Linux Foundation Qemu Audio Device
9901- return found (brands::QEMU);
9905+ return found (brands::QEMU, dev );
99029906
99039907 // vGPUs (mostly NVIDIA)
99049908 case 0x10de0fe7 : // GK107GL [GRID K100 vGPU]
@@ -9911,13 +9915,15 @@ struct VM {
99119915 // VirtualBox
99129916 case 0x80ee0021 : // USB Tablet
99139917 case 0x80ee0022 : // multitouch tablet
9914- return found (brands::VBOX);
9918+ return found (brands::VBOX, dev );
99159919
99169920 // Connectix (VirtualPC) OHCI USB 1.1 controller
9917- case 0x29556e61 : return found (brands::VPC);
9921+ case 0x29556e61 :
9922+ return found (brands::VPC, dev);
99189923
99199924 // Parallels, Inc. Virtual Machine Communication Interface
9920- case 0x1ab84000 : return found (brands::PARALLELS);
9925+ case 0x1ab84000 :
9926+ return found (brands::PARALLELS, dev);
99219927 }
99229928
99239929 // TODO: EXTRAS TO ADD (64 instead of 32 bits for device_id field)
0 commit comments