From 1fa90d5abecd896362e551b2bd2ec987d8f60a6b Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 4 Jan 2021 17:53:10 +0000 Subject: 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 Reviewed-by: Thanos Makatos --- samples/lspci.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'samples/lspci.c') 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; -- cgit v1.1