*/
#include "hds.h"
+#include "qmp-commands.h"
+#include "hw/pci/pci.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, hds);
return list_hds;
}
+
+int hds_get_pci_available_slot_num(void)
+{
+ Error *err = NULL;
+ PciInfoList *info;
+ PciDeviceInfoList *dev;
+ int pci_num = 0;
+
+ info = qmp_query_pci(&err);
+ if (err) {
+ LOG_WARNING("PCI devices not supported\n");
+ error_free(err);
+ return 0;
+ }
+
+ assert(info != NULL);
+ assert(info->value != NULL);
+
+ for (dev = info->value->devices; dev; dev = dev->next) {
+ if (dev->value->function == 0) {
+ pci_num++;
+ }
+ }
+
+ error_free(err);
+ qapi_free_PciInfoList(info);
+
+ LOG_INFO("# of PCI devices: %d, available: %d\n", pci_num, PCI_SLOT_MAX - pci_num);
+
+ return PCI_SLOT_MAX - pci_num;
+}
void set_hds_attached(const char* id, bool attached);
char* get_hds_lists(void);
+int hds_get_pci_available_slot_num(void);
#endif // _HDS_