svn commit: r338210 - head/usr.sbin/bhyve
Marcelo Araujo
araujo at FreeBSD.org
Wed Aug 22 20:23:10 UTC 2018
Author: araujo
Date: Wed Aug 22 20:23:08 2018
New Revision: 338210
URL: https://svnweb.freebsd.org/changeset/base/338210
Log:
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.
Modified:
head/usr.sbin/bhyve/bhyverun.c
head/usr.sbin/bhyve/pci_emul.c
head/usr.sbin/bhyve/pci_emul.h
head/usr.sbin/bhyve/pci_lpc.c
head/usr.sbin/bhyve/pci_lpc.h
Modified: head/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- head/usr.sbin/bhyve/bhyverun.c Wed Aug 22 19:38:48 2018 (r338209)
+++ head/usr.sbin/bhyve/bhyverun.c Wed Aug 22 20:23:08 2018 (r338210)
@@ -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;
Modified: head/usr.sbin/bhyve/pci_emul.c
==============================================================================
--- head/usr.sbin/bhyve/pci_emul.c Wed Aug 22 19:38:48 2018 (r338209)
+++ head/usr.sbin/bhyve/pci_emul.c Wed Aug 22 20:23:08 2018 (r338210)
@@ -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)
{
Modified: head/usr.sbin/bhyve/pci_emul.h
==============================================================================
--- head/usr.sbin/bhyve/pci_emul.h Wed Aug 22 19:38:48 2018 (r338209)
+++ head/usr.sbin/bhyve/pci_emul.h Wed Aug 22 20:23:08 2018 (r338210)
@@ -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,
Modified: head/usr.sbin/bhyve/pci_lpc.c
==============================================================================
--- head/usr.sbin/bhyve/pci_lpc.c Wed Aug 22 19:38:48 2018 (r338209)
+++ head/usr.sbin/bhyve/pci_lpc.c Wed Aug 22 20:23:08 2018 (r338210)
@@ -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)
{
Modified: head/usr.sbin/bhyve/pci_lpc.h
==============================================================================
--- head/usr.sbin/bhyve/pci_lpc.h Wed Aug 22 19:38:48 2018 (r338209)
+++ head/usr.sbin/bhyve/pci_lpc.h Wed Aug 22 20:23:08 2018 (r338210)
@@ -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);
More information about the svn-src-all
mailing list