MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vhost_blk_bdev_construct

Function vhost_blk_bdev_construct

dpdk/examples/vhost_blk/vhost_blk.c:754–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752};
753
754static struct vhost_block_dev *
755vhost_blk_bdev_construct(const char *bdev_name,
756 const char *bdev_serial, uint32_t blk_size, uint64_t blk_cnt,
757 bool wce_enable)
758{
759 struct vhost_block_dev *bdev;
760
761 bdev = rte_zmalloc(NULL, sizeof(*bdev), RTE_CACHE_LINE_SIZE);
762 if (!bdev)
763 return NULL;
764
765 snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name);
766 snprintf(bdev->product_name, sizeof(bdev->product_name), "%s",
767 bdev_serial);
768 bdev->blocklen = blk_size;
769 bdev->blockcnt = blk_cnt;
770 bdev->write_cache = wce_enable;
771
772 fprintf(stdout, "Blocklen=%d, blockcnt=%"PRIx64"\n", bdev->blocklen,
773 bdev->blockcnt);
774
775 /* use memory as disk storage space */
776 bdev->data = rte_zmalloc(NULL, blk_cnt * blk_size, 0);
777 if (!bdev->data) {
778 fprintf(stderr, "No enough reserved huge memory for disk\n");
779 rte_free(bdev);
780 return NULL;
781 }
782
783 return bdev;
784}
785
786static struct vhost_blk_ctrlr *
787vhost_blk_ctrlr_construct(const char *ctrlr_name)

Callers 1

Calls 3

rte_zmallocFunction · 0.85
snprintfFunction · 0.85
rte_freeFunction · 0.85

Tested by

no test coverage detected