static int create_shared_memory_BAR(IVShmemState *s, int fd, uint8_t attr,

                                    Error **errp)

{

    void * ptr;



    ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

    if (ptr == MAP_FAILED) {

        error_setg_errno(errp, errno, "Failed to mmap shared memory");

        return -1;

    }



    s->shm_fd = fd;



    memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), "ivshmem.bar2",

                               s->ivshmem_size, ptr);

    vmstate_register_ram(&s->ivshmem, DEVICE(s));

    memory_region_add_subregion(&s->bar, 0, &s->ivshmem);



    /* region for shared memory */

    pci_register_bar(PCI_DEVICE(s), 2, attr, &s->bar);



    return 0;

}

static int create_shared_memory_BAR(IVShmemState *s, int fd, uint8_t attr,

                                    Error **errp)

{

    void * ptr;



    ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

    if (ptr == MAP_FAILED) {

        error_setg_errno(errp, errno, "Failed to mmap shared memory");

        return -1;

    }



    s->shm_fd = fd;



    memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), "ivshmem.bar2",

                               s->ivshmem_size, ptr);

    vmstate_register_ram(&s->ivshmem, DEVICE(s));

    memory_region_add_subregion(&s->bar, 0, &s->ivshmem);



    

    pci_register_bar(PCI_DEVICE(s), 2, attr, &s->bar);



    return 0;

}

    s->shm_fd = fd;
static int FUNC_0(IVShmemState *VAR_0, int VAR_1, uint8_t VAR_2,

                                    Error **VAR_3)

{

    void * VAR_4;



    VAR_4 = mmap(0, VAR_0->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, VAR_1, 0);

    if (VAR_4 == MAP_FAILED) {

        error_setg_errno(VAR_3, errno, "Failed to mmap shared memory");

        return -1;

    }



    VAR_0->shm_fd = VAR_1;



    memory_region_init_ram_ptr(&VAR_0->ivshmem, OBJECT(VAR_0), "ivshmem.bar2",

                               VAR_0->ivshmem_size, VAR_4);

    vmstate_register_ram(&VAR_0->ivshmem, DEVICE(VAR_0));

    memory_region_add_subregion(&VAR_0->bar, 0, &VAR_0->ivshmem);



    

    pci_register_bar(PCI_DEVICE(VAR_0), 2, VAR_2, &VAR_0->bar);



    return 0;

}

static int FUNC_0(IVShmemState *VAR_0, int VAR_1, uint8_t VAR_2,
Error **VAR_3)
{ void * VAR_4; VAR_4 = mmap(0, VAR_0->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, VAR_1, 0); if (VAR_4 == MAP_FAILED) { error_setg_errno(VAR_3, errno, "Failed to mmap shared memory"); return -1; } VAR_0->shm_fd = VAR_1; memory_region_init_ram_ptr(&VAR_0->ivshmem, OBJECT(VAR_0), "ivshmem.bar2",
VAR_0->ivshmem_size, VAR_4); vmstate_register_ram(&VAR_0->ivshmem, DEVICE(VAR_0)); memory_region_add_subregion(&VAR_0->bar, 0, &VAR_0->ivshmem); pci_register_bar(PCI_DEVICE(VAR_0), 2, VAR_2, &VAR_0->bar); return 0; }