scsi: prefer UUID to VM name for the initiator name
The UUID is unique even across multiple hosts, thus it is better than a VM name even if it is less user-friendly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
2d1fe1873a
commit
5accc8408f
|
@ -33,6 +33,8 @@
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "block/scsi.h"
|
#include "block/scsi.h"
|
||||||
#include "qemu/iov.h"
|
#include "qemu/iov.h"
|
||||||
|
#include "sysemu/sysemu.h"
|
||||||
|
#include "qmp-commands.h"
|
||||||
|
|
||||||
#include <iscsi/iscsi.h>
|
#include <iscsi/iscsi.h>
|
||||||
#include <iscsi/scsi-lowlevel.h>
|
#include <iscsi/scsi-lowlevel.h>
|
||||||
|
@ -922,8 +924,9 @@ static char *parse_initiator_name(const char *target)
|
||||||
{
|
{
|
||||||
QemuOptsList *list;
|
QemuOptsList *list;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
const char *name = NULL;
|
const char *name;
|
||||||
const char *iscsi_name = qemu_get_vm_name();
|
char *iscsi_name;
|
||||||
|
UuidInfo *uuid_info;
|
||||||
|
|
||||||
list = qemu_find_opts("iscsi");
|
list = qemu_find_opts("iscsi");
|
||||||
if (list) {
|
if (list) {
|
||||||
|
@ -933,16 +936,22 @@ static char *parse_initiator_name(const char *target)
|
||||||
}
|
}
|
||||||
if (opts) {
|
if (opts) {
|
||||||
name = qemu_opt_get(opts, "initiator-name");
|
name = qemu_opt_get(opts, "initiator-name");
|
||||||
|
if (name) {
|
||||||
|
return g_strdup(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) {
|
uuid_info = qmp_query_uuid(NULL);
|
||||||
return g_strdup(name);
|
if (strcmp(uuid_info->UUID, UUID_NONE) == 0) {
|
||||||
|
name = qemu_get_vm_name();
|
||||||
} else {
|
} else {
|
||||||
return g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s",
|
name = uuid_info->UUID;
|
||||||
iscsi_name ? ":" : "",
|
|
||||||
iscsi_name ? iscsi_name : "");
|
|
||||||
}
|
}
|
||||||
|
iscsi_name = g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s",
|
||||||
|
name ? ":" : "", name ? name : "");
|
||||||
|
qapi_free_UuidInfo(uuid_info);
|
||||||
|
return iscsi_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LIBISCSI_FEATURE_NOP_COUNTER)
|
#if defined(LIBISCSI_FEATURE_NOP_COUNTER)
|
||||||
|
|
|
@ -17,7 +17,9 @@ extern const char *bios_name;
|
||||||
extern const char *qemu_name;
|
extern const char *qemu_name;
|
||||||
extern uint8_t qemu_uuid[];
|
extern uint8_t qemu_uuid[];
|
||||||
int qemu_uuid_parse(const char *str, uint8_t *uuid);
|
int qemu_uuid_parse(const char *str, uint8_t *uuid);
|
||||||
|
|
||||||
#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
|
#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
|
||||||
|
#define UUID_NONE "00000000-0000-0000-0000-000000000000"
|
||||||
|
|
||||||
bool runstate_check(RunState state);
|
bool runstate_check(RunState state);
|
||||||
void runstate_set(RunState new_state);
|
void runstate_set(RunState new_state);
|
||||||
|
|
|
@ -22,6 +22,7 @@ stub-obj-y += reset.o
|
||||||
stub-obj-y += set-fd-handler.o
|
stub-obj-y += set-fd-handler.o
|
||||||
stub-obj-y += slirp.o
|
stub-obj-y += slirp.o
|
||||||
stub-obj-y += sysbus.o
|
stub-obj-y += sysbus.o
|
||||||
|
stub-obj-y += uuid.o
|
||||||
stub-obj-y += vm-stop.o
|
stub-obj-y += vm-stop.o
|
||||||
stub-obj-y += vmstate.o
|
stub-obj-y += vmstate.o
|
||||||
stub-obj-$(CONFIG_WIN32) += fd-register.o
|
stub-obj-$(CONFIG_WIN32) += fd-register.o
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "qemu-common.h"
|
||||||
|
#include "sysemu/sysemu.h"
|
||||||
|
#include "qmp-commands.h"
|
||||||
|
|
||||||
|
UuidInfo *qmp_query_uuid(Error **errp)
|
||||||
|
{
|
||||||
|
UuidInfo *info = g_malloc0(sizeof(*info));
|
||||||
|
|
||||||
|
info->UUID = g_strdup(UUID_NONE);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue