提交 f2ef4a6d 编写于 作者: P Paolo Bonzini

iscsi: reorganize code for parse_initiator_name

Merge the occurrences of the "iqn.2008-11.org.linux-kvm" string
to avoid duplication.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 b93c94f7
...@@ -898,24 +898,21 @@ static char *parse_initiator_name(const char *target) ...@@ -898,24 +898,21 @@ static char *parse_initiator_name(const char *target)
const char *name = NULL; const char *name = NULL;
list = qemu_find_opts("iscsi"); list = qemu_find_opts("iscsi");
if (!list) { if (list) {
return g_strdup("iqn.2008-11.org.linux-kvm"); opts = qemu_opts_find(list, target);
}
opts = qemu_opts_find(list, target);
if (opts == NULL) {
opts = QTAILQ_FIRST(&list->head);
if (!opts) { if (!opts) {
return g_strdup("iqn.2008-11.org.linux-kvm"); opts = QTAILQ_FIRST(&list->head);
}
if (opts) {
name = qemu_opt_get(opts, "initiator-name");
} }
} }
name = qemu_opt_get(opts, "initiator-name"); if (name) {
if (!name) { return g_strdup(name);
} else {
return g_strdup("iqn.2008-11.org.linux-kvm"); return g_strdup("iqn.2008-11.org.linux-kvm");
} }
return g_strdup(name);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册