Add -s "help" and -l "help" to print a list of supported PCI and LPC devices.
For tools that uses bhyve such like libvirt, it is important to be able to probe what features are supported by the given bhyve binary. To give more context, libvirt probes bhyve's capabilities in a not very effective way: - Running 'bhyve -h' and parsing output. - To detect devices, it runs 'bhyve -s 0,dev' for every each device and parses error output to identify if the device is supported or not. PR: 2101111 Submitted by: novel MFC after: 2 weeks Relnotes: yes Sponsored by: iXsystems Inc.
This commit is contained in:
parent
2e5630c90a
commit
d332a47a7d
@ -960,13 +960,19 @@ main(int argc, char *argv[])
|
||||
gdb_port = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
if (lpc_device_parse(optarg) != 0) {
|
||||
if (strncmp(optarg, "help", strlen(optarg)) == 0) {
|
||||
lpc_print_supported_devices();
|
||||
exit(0);
|
||||
} else if (lpc_device_parse(optarg) != 0) {
|
||||
errx(EX_USAGE, "invalid lpc device "
|
||||
"configuration '%s'", optarg);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (pci_parse_slot(optarg) != 0)
|
||||
if (strncmp(optarg, "help", strlen(optarg)) == 0) {
|
||||
pci_print_supported_devices();
|
||||
exit(0);
|
||||
} else if (pci_parse_slot(optarg) != 0)
|
||||
exit(4);
|
||||
else
|
||||
break;
|
||||
|
@ -237,6 +237,17 @@ done:
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
pci_print_supported_devices()
|
||||
{
|
||||
struct pci_devemu **pdpp, *pdp;
|
||||
|
||||
SET_FOREACH(pdpp, pci_devemu_set) {
|
||||
pdp = *pdpp;
|
||||
printf("%s\n", pdp->pe_emu);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
pci_valid_pba_offset(struct pci_devinst *pi, uint64_t offset)
|
||||
{
|
||||
|
@ -234,6 +234,7 @@ int pci_msix_table_bar(struct pci_devinst *pi);
|
||||
int pci_msix_pba_bar(struct pci_devinst *pi);
|
||||
int pci_msi_maxmsgnum(struct pci_devinst *pi);
|
||||
int pci_parse_slot(char *opt);
|
||||
void pci_print_supported_devices();
|
||||
void pci_populate_msicap(struct msicap *cap, int msgs, int nextptr);
|
||||
int pci_emul_add_msixcap(struct pci_devinst *pi, int msgnum, int barnum);
|
||||
int pci_emul_msix_twrite(struct pci_devinst *pi, uint64_t offset, int size,
|
||||
|
@ -114,6 +114,16 @@ done:
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
lpc_print_supported_devices()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf("bootrom\n");
|
||||
for (i = 0; i < LPC_UART_NUM; i++)
|
||||
printf("%s\n", lpc_uart_names[i]);
|
||||
}
|
||||
|
||||
const char *
|
||||
lpc_bootrom(void)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ struct lpc_sysres {
|
||||
#define SYSRES_MEM(base, length) LPC_SYSRES(LPC_SYSRES_MEM, base, length)
|
||||
|
||||
int lpc_device_parse(const char *opt);
|
||||
void lpc_print_supported_devices();
|
||||
char *lpc_pirq_name(int pin);
|
||||
void lpc_pirq_routed(void);
|
||||
const char *lpc_bootrom(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user