dm: virtio-blk: fix parameter err

Fix the truncate issue for virtio block parameter.

Tracked-On: #8162
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Conghui 2022-09-21 11:07:04 +08:00 committed by acrnsi-robot
parent c6cbd6b6df
commit fcd92f1c2f
1 changed files with 10 additions and 4 deletions

View File

@ -500,13 +500,16 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
WPRINTF(("%s: strdup failed\n", __func__));
return -1;
}
if (strstr(opts, "nodisk") != NULL) {
dummy_bctxt = true;
} else if ((opt = strsep(&opts_tmp, ",")) != NULL) {
if (strstr(opts, "nodisk") == NULL) {
opt = strsep(&opts_tmp, ",");
if (strcmp("iothread", opt) == 0) {
use_iothread = true;
} else {
opts_tmp = opts_start;
/* The opts_start is truncated by strsep, opts_tmp is also
* changed by strsetp, so use opts which points to the
* original parameter string
*/
opts_tmp = opts;
}
bctxt = blockif_open(opts_tmp, bident);
if (bctxt == NULL) {
@ -514,7 +517,10 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
free(opts_start);
return -1;
}
} else {
dummy_bctxt = true;
}
free(opts_start);