typedef struct IscsiAIOCB {
BlockAIOCB common;
- QEMUIOVector *qiov;
QEMUBH *bh;
IscsiLun *iscsilun;
struct scsi_task *task;
}
static int
-coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int count)
+coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
struct unmap_list list;
int r = 0;
- if (!is_byte_request_lun_aligned(offset, count, iscsilun)) {
+ if (!is_byte_request_lun_aligned(offset, bytes, iscsilun)) {
return -ENOTSUP;
}
}
list.lba = offset / iscsilun->block_size;
- list.num = count / iscsilun->block_size;
+ list.num = bytes / iscsilun->block_size;
iscsi_co_init_iscsitask(iscsilun, &iTask);
qemu_mutex_lock(&iscsilun->mutex);
}
iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
- count >> BDRV_SECTOR_BITS);
+ bytes >> BDRV_SECTOR_BITS);
out_unlock:
qemu_mutex_unlock(&iscsilun->mutex);
static int
coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
- int count, BdrvRequestFlags flags)
+ int bytes, BdrvRequestFlags flags)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
bool use_16_for_ws = iscsilun->use_16_for_rw;
int r = 0;
- if (!is_byte_request_lun_aligned(offset, count, iscsilun)) {
+ if (!is_byte_request_lun_aligned(offset, bytes, iscsilun)) {
return -ENOTSUP;
}
}
lba = offset / iscsilun->block_size;
- nb_blocks = count / iscsilun->block_size;
+ nb_blocks = bytes / iscsilun->block_size;
if (iscsilun->zeroblock == NULL) {
iscsilun->zeroblock = g_try_malloc0(iscsilun->block_size);
if (iTask.status != SCSI_STATUS_GOOD) {
iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
- count >> BDRV_SECTOR_BITS);
+ bytes >> BDRV_SECTOR_BITS);
r = iTask.err_code;
goto out_unlock;
}
if (flags & BDRV_REQ_MAY_UNMAP) {
iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS,
- count >> BDRV_SECTOR_BITS);
+ bytes >> BDRV_SECTOR_BITS);
} else {
iscsi_allocmap_set_allocated(iscsilun, offset >> BDRV_SECTOR_BITS,
- count >> BDRV_SECTOR_BITS);
+ bytes >> BDRV_SECTOR_BITS);
}
out_unlock:
.name = "timeout",
.type = QEMU_OPT_NUMBER,
},
+ {
+ .name = "filename",
+ .type = QEMU_OPT_STRING,
+ },
{ /* end of list */ }
},
};
char *initiator_name = NULL;
QemuOpts *opts;
Error *local_err = NULL;
- const char *transport_name, *portal, *target;
+ const char *transport_name, *portal, *target, *filename;
#if LIBISCSI_API_VERSION >= (20160603)
enum iscsi_transport_type transport;
#endif
int i, ret = 0, timeout = 0, lun;
+ /* If we are given a filename, parse the filename, with precedence given to
+ * filename encoded options */
+ filename = qdict_get_try_str(options, "filename");
+ if (filename) {
+ warn_report("'filename' option specified. "
+ "This is an unsupported option, and may be deprecated "
+ "in the future");
+ iscsi_parse_filename(filename, options, &local_err);
+ if (local_err) {
+ ret = -EINVAL;
+ error_propagate(errp, local_err);
+ goto exit;
+ }
+ }
+
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
}
memset(iscsilun, 0, sizeof(IscsiLun));
}
+exit:
return ret;
}
}
}
-static int iscsi_truncate(BlockDriverState *bs, int64_t offset)
+static int iscsi_truncate(BlockDriverState *bs, int64_t offset,
+ PreallocMode prealloc, Error **errp)
{
IscsiLun *iscsilun = bs->opaque;
Error *local_err = NULL;
+ if (prealloc != PREALLOC_MODE_OFF) {
+ error_setg(errp, "Unsupported preallocation mode '%s'",
+ PreallocMode_lookup[prealloc]);
+ return -ENOTSUP;
+ }
+
if (iscsilun->type != TYPE_DISK) {
+ error_setg(errp, "Cannot resize non-disk iSCSI devices");
return -ENOTSUP;
}
iscsi_readcapacity_sync(iscsilun, &local_err);
if (local_err != NULL) {
- error_free(local_err);
+ error_propagate(errp, local_err);
return -EIO;
}
if (offset > iscsi_getlength(bs)) {
+ error_setg(errp, "Cannot grow iSCSI devices");
return -EINVAL;
}
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
+ Error *local_err = NULL;
bs = bdrv_new();
iscsilun = bs->opaque;
bs_options = qdict_new();
- qdict_put(bs_options, "filename", qstring_from_str(filename));
- ret = iscsi_open(bs, bs_options, 0, NULL);
+ iscsi_parse_filename(filename, bs_options, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ ret = -EINVAL;
+ } else {
+ ret = iscsi_open(bs, bs_options, 0, NULL);
+ }
QDECREF(bs_options);
if (ret != 0) {