diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-08-06 10:54:41 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-08-08 14:51:59 +0200 |
commit | f2ef4a6dd9f008d4cb30bccfc0491c01b69f1ead (patch) | |
tree | 96489499bd1dd938c79f52ea61f5889990e326a7 | |
parent | b93c94f7ec74a577a0f74c724e8d251f01eaf65a (diff) |
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: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | block/iscsi.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/block/iscsi.c b/block/iscsi.c index 94063ab17d..fd954d4c1f 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -898,24 +898,21 @@ static char *parse_initiator_name(const char *target) const char *name = NULL; list = qemu_find_opts("iscsi"); - if (!list) { - return g_strdup("iqn.2008-11.org.linux-kvm"); - } - - opts = qemu_opts_find(list, target); - if (opts == NULL) { - opts = QTAILQ_FIRST(&list->head); + if (list) { + opts = qemu_opts_find(list, target); 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(name); } /* |