diff options
author | John Levon <john.levon@nutanix.com> | 2021-01-04 17:53:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 17:53:10 +0000 |
commit | 1fa90d5abecd896362e551b2bd2ec987d8f60a6b (patch) | |
tree | 6bcb22c92d2bf52c1baf6786a644d4abbbd09604 /samples/lspci.c | |
parent | 715b7963312002980b9eea5a695719cfdf2bf6e4 (diff) | |
download | libvfio-user-1fa90d5abecd896362e551b2bd2ec987d8f60a6b.zip libvfio-user-1fa90d5abecd896362e551b2bd2ec987d8f60a6b.tar.gz libvfio-user-1fa90d5abecd896362e551b2bd2ec987d8f60a6b.tar.bz2 |
re-work PCI config setup API (#198)
Split up vfu_pci_setup_config_hdr(): individual "helpers" like vfu_pci_set_id()
are much simpler to use than making the user specify the values in
header-formatted structs; and this way if we want to add additional helpers, we
won't need to modify the existing functions.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples/lspci.c')
-rw-r--r-- | samples/lspci.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/samples/lspci.c b/samples/lspci.c index 61861d6..e2fa6fc 100644 --- a/samples/lspci.c +++ b/samples/lspci.c @@ -42,9 +42,6 @@ int main(void) int i, j; char *buf; const int bytes_per_line = 0x10; - vfu_pci_hdr_id_t id = { 0 }; - 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 *vsc = alloca(sizeof(*vsc) + 0xd); vfu_cap_t *caps[2] = { &pm, vsc }; @@ -54,8 +51,9 @@ int main(void) if (vfu_ctx == NULL) { err(EXIT_FAILURE, "failed to create libvfio-user context"); } - 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_init(vfu_ctx, VFU_PCI_TYPE_CONVENTIONAL, + PCI_HEADER_TYPE_NORMAL, 0) < 0) { + err(EXIT_FAILURE, "vfu_pci_init() failed"); } vsc->vsc.hdr.id = PCI_CAP_ID_VNDR; vsc->vsc.size = 0x10; |