提交 1d560104 编写于 作者: K Kevin Wolf 提交者: Jeff Cody

iscsi: Add timeout option

This was previously only available with -iscsi. Again, after this patch,
the -iscsi option only takes effect if an URL is given. New users are
supposed to use the new driver-specific option.

All -iscsi options have a corresponding driver-specific option for the
iscsi block driver now.
Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
Reviewed-by: NFam Zheng <famz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NJeff Cody <jcody@redhat.com>
上级 81aa2a0f
...@@ -1327,29 +1327,6 @@ static char *get_initiator_name(QemuOpts *opts) ...@@ -1327,29 +1327,6 @@ static char *get_initiator_name(QemuOpts *opts)
return iscsi_name; return iscsi_name;
} }
static int parse_timeout(const char *target)
{
QemuOptsList *list;
QemuOpts *opts;
const char *timeout;
list = qemu_find_opts("iscsi");
if (list) {
opts = qemu_opts_find(list, target);
if (!opts) {
opts = QTAILQ_FIRST(&list->head);
}
if (opts) {
timeout = qemu_opt_get(opts, "timeout");
if (timeout) {
return atoi(timeout);
}
}
}
return 0;
}
static void iscsi_nop_timed_event(void *opaque) static void iscsi_nop_timed_event(void *opaque)
{ {
IscsiLun *iscsilun = opaque; IscsiLun *iscsilun = opaque;
...@@ -1562,7 +1539,7 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) ...@@ -1562,7 +1539,7 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options)
QemuOptsList *list; QemuOptsList *list;
QemuOpts *opts; QemuOpts *opts;
const char *user, *password, *password_secret, *initiator_name, const char *user, *password, *password_secret, *initiator_name,
*header_digest; *header_digest, *timeout;
list = qemu_find_opts("iscsi"); list = qemu_find_opts("iscsi");
if (!list) { if (!list) {
...@@ -1601,6 +1578,11 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) ...@@ -1601,6 +1578,11 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options)
if (header_digest) { if (header_digest) {
qdict_set_default_str(options, "header-digest", header_digest); qdict_set_default_str(options, "header-digest", header_digest);
} }
timeout = qemu_opt_get(opts, "timeout");
if (timeout) {
qdict_set_default_str(options, "timeout", timeout);
}
} }
/* /*
...@@ -1656,7 +1638,6 @@ static void iscsi_parse_filename(const char *filename, QDict *options, ...@@ -1656,7 +1638,6 @@ static void iscsi_parse_filename(const char *filename, QDict *options,
iscsi_destroy_url(iscsi_url); iscsi_destroy_url(iscsi_url);
} }
/* TODO Add -iscsi options */
static QemuOptsList runtime_opts = { static QemuOptsList runtime_opts = {
.name = "iscsi", .name = "iscsi",
.head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
...@@ -1697,6 +1678,10 @@ static QemuOptsList runtime_opts = { ...@@ -1697,6 +1678,10 @@ static QemuOptsList runtime_opts = {
.name = "header-digest", .name = "header-digest",
.type = QEMU_OPT_STRING, .type = QEMU_OPT_STRING,
}, },
{
.name = "timeout",
.type = QEMU_OPT_NUMBER,
},
{ /* end of list */ } { /* end of list */ }
}, },
}; };
...@@ -1797,7 +1782,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -1797,7 +1782,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
} }
/* timeout handling is broken in libiscsi before 1.15.0 */ /* timeout handling is broken in libiscsi before 1.15.0 */
timeout = parse_timeout(target); timeout = qemu_opt_get_number(opts, "timeout", 0);
#if LIBISCSI_API_VERSION >= 20150621 #if LIBISCSI_API_VERSION >= 20150621
iscsi_set_timeout(iscsi, timeout); iscsi_set_timeout(iscsi, timeout);
#else #else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册