diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/lspci.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/samples/lspci.c b/samples/lspci.c index 20d938a..61861d6 100644 --- a/samples/lspci.c +++ b/samples/lspci.c @@ -46,7 +46,8 @@ int main(void) vfu_pci_hdr_ss_t ss = { 0 }; vfu_pci_hdr_cc_t cc = { { 0 } }; vfu_cap_t pm = { .pm = { .hdr.id = PCI_CAP_ID_PM, .pmcs.nsfrst = 0x1 } }; - vfu_cap_t *caps[1] = { &pm }; + vfu_cap_t *vsc = alloca(sizeof(*vsc) + 0xd); + vfu_cap_t *caps[2] = { &pm, vsc }; vfu_ctx_t *vfu_ctx = vfu_create_ctx(VFU_TRANS_SOCK, "", LIBVFIO_USER_FLAG_ATTACH_NB, NULL, VFU_DEV_TYPE_PCI); @@ -56,13 +57,15 @@ int main(void) if (vfu_pci_setup_config_hdr(vfu_ctx, id, ss, cc, VFU_PCI_TYPE_CONVENTIONAL, 0) < 0) { err(EXIT_FAILURE, "failed to setup PCI configuration space header"); } - if (vfu_pci_setup_caps(vfu_ctx, caps, 1) < 0) { + vsc->vsc.hdr.id = PCI_CAP_ID_VNDR; + vsc->vsc.size = 0x10; + if (vfu_pci_setup_caps(vfu_ctx, caps, 2) < 0) { err(EXIT_FAILURE, "failed to setup PCI capabilities"); } if (vfu_realize_ctx(vfu_ctx) < 0) { err(EXIT_FAILURE, "failed to realize device"); } - buf = (char*)vfu_pci_get_config_space(vfu_ctx);; + buf = (char*)vfu_pci_get_config_space(vfu_ctx); printf("00:00.0 bogus PCI device\n"); for (i = 0; i < PCI_CFG_SPACE_SIZE / bytes_per_line; i++) { printf("%02x:", i * bytes_per_line); |