dm: virtio-blk: enable support for iothread
The usage is: -s <slot> virtio-blk,[iothread,]<filepath> e.g -s 3 virtio-blk,iothread,test.img Tracked-On: #7940 Signed-off-by: Conghui <conghui.chen@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
parent
fa69f79e33
commit
1bf3cb61f5
|
@ -441,8 +441,12 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||||
bool dummy_bctxt;
|
bool dummy_bctxt;
|
||||||
char bident[16];
|
char bident[16];
|
||||||
struct blockif_ctxt *bctxt;
|
struct blockif_ctxt *bctxt;
|
||||||
|
char *opts_tmp = NULL;
|
||||||
|
char *opts_start = NULL;
|
||||||
|
char *opt = NULL;
|
||||||
u_char digest[16];
|
u_char digest[16];
|
||||||
struct virtio_blk *blk;
|
struct virtio_blk *blk;
|
||||||
|
bool use_iothread;
|
||||||
int i;
|
int i;
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -450,6 +454,7 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||||
bctxt = NULL;
|
bctxt = NULL;
|
||||||
/* Assume the bctxt is valid, until identified otherwise */
|
/* Assume the bctxt is valid, until identified otherwise */
|
||||||
dummy_bctxt = false;
|
dummy_bctxt = false;
|
||||||
|
use_iothread = false;
|
||||||
|
|
||||||
if (opts == NULL) {
|
if (opts == NULL) {
|
||||||
pr_err("virtio_blk: backing device required\n");
|
pr_err("virtio_blk: backing device required\n");
|
||||||
|
@ -468,15 +473,28 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||||
* If "nodisk" keyword is found in opts, this is not a valid backend
|
* If "nodisk" keyword is found in opts, this is not a valid backend
|
||||||
* file. Skip blockif_open and set dummy bctxt in virtio_blk struct
|
* file. Skip blockif_open and set dummy bctxt in virtio_blk struct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
opts_start = opts_tmp = strdup(opts);
|
||||||
|
if (!opts_start) {
|
||||||
|
WPRINTF(("%s: strdup failed\n", __func__));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (strstr(opts, "nodisk") != NULL) {
|
if (strstr(opts, "nodisk") != NULL) {
|
||||||
dummy_bctxt = true;
|
dummy_bctxt = true;
|
||||||
} else {
|
} else if ((opt = strsep(&opts_tmp, ",")) != NULL) {
|
||||||
bctxt = blockif_open(opts, bident);
|
if (strcmp("iothread", opt) == 0) {
|
||||||
|
use_iothread = true;
|
||||||
|
} else {
|
||||||
|
opts_tmp = opts_start;
|
||||||
|
}
|
||||||
|
bctxt = blockif_open(opts_tmp, bident);
|
||||||
if (bctxt == NULL) {
|
if (bctxt == NULL) {
|
||||||
pr_err("Could not open backing file");
|
pr_err("Could not open backing file");
|
||||||
|
free(opts_start);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(opts_start);
|
||||||
|
|
||||||
|
|
||||||
blk = calloc(1, sizeof(struct virtio_blk));
|
blk = calloc(1, sizeof(struct virtio_blk));
|
||||||
|
@ -514,6 +532,7 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||||
|
|
||||||
/* init virtio struct and virtqueues */
|
/* init virtio struct and virtqueues */
|
||||||
virtio_linkup(&blk->base, &virtio_blk_ops, blk, dev, &blk->vq, BACKEND_VBSU);
|
virtio_linkup(&blk->base, &virtio_blk_ops, blk, dev, &blk->vq, BACKEND_VBSU);
|
||||||
|
blk->base.iothread = use_iothread;
|
||||||
blk->base.mtx = &blk->mtx;
|
blk->base.mtx = &blk->mtx;
|
||||||
|
|
||||||
blk->vq.qsize = VIRTIO_BLK_RINGSZ;
|
blk->vq.qsize = VIRTIO_BLK_RINGSZ;
|
||||||
|
|
Loading…
Reference in New Issue