|
|
9ae3a8 |
From ca89af18d37afb4fe9cea6e4ff3e22386d0db5b0 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 23 Sep 2013 17:07:53 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 2/3] scsi: prefer UUID to VM name for the initiator name
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1379956073-3496-1-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54488
|
|
|
9ae3a8 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH] scsi: prefer UUID to VM name for the initiator name
|
|
|
9ae3a8 |
Bugzilla: 1006468
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1006468
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6317378
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The UUID is unique even across multiple hosts, thus it is
|
|
|
9ae3a8 |
better than a VM name even if it is less user-friendly.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 5accc8408f2dac1e00d888e4fe75e6174ba2a940)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/iscsi.c | 23 ++++++++++++++++-------
|
|
|
9ae3a8 |
include/sysemu/sysemu.h | 2 ++
|
|
|
9ae3a8 |
stubs/Makefile.objs | 1 +
|
|
|
9ae3a8 |
stubs/uuid.c | 12 ++++++++++++
|
|
|
9ae3a8 |
4 files changed, 31 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
create mode 100644 stubs/uuid.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/iscsi.c | 23 ++++++++++++++++-------
|
|
|
9ae3a8 |
include/sysemu/sysemu.h | 2 ++
|
|
|
9ae3a8 |
stubs/Makefile.objs | 1 +
|
|
|
9ae3a8 |
stubs/uuid.c | 12 ++++++++++++
|
|
|
9ae3a8 |
4 files changed, 31 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
create mode 100644 stubs/uuid.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/iscsi.c b/block/iscsi.c
|
|
|
9ae3a8 |
index 1294fdf..4ab9edc 100644
|
|
|
9ae3a8 |
--- a/block/iscsi.c
|
|
|
9ae3a8 |
+++ b/block/iscsi.c
|
|
|
9ae3a8 |
@@ -33,6 +33,8 @@
|
|
|
9ae3a8 |
#include "trace.h"
|
|
|
9ae3a8 |
#include "block/scsi.h"
|
|
|
9ae3a8 |
#include "qemu/iov.h"
|
|
|
9ae3a8 |
+#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
+#include "qmp-commands.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#include <iscsi/iscsi.h>
|
|
|
9ae3a8 |
#include <iscsi/scsi-lowlevel.h>
|
|
|
9ae3a8 |
@@ -923,8 +925,9 @@ static char *parse_initiator_name(const char *target)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
QemuOptsList *list;
|
|
|
9ae3a8 |
QemuOpts *opts;
|
|
|
9ae3a8 |
- const char *name = NULL;
|
|
|
9ae3a8 |
- const char *iscsi_name = qemu_get_vm_name();
|
|
|
9ae3a8 |
+ const char *name;
|
|
|
9ae3a8 |
+ char *iscsi_name;
|
|
|
9ae3a8 |
+ UuidInfo *uuid_info;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
list = qemu_find_opts("iscsi");
|
|
|
9ae3a8 |
if (list) {
|
|
|
9ae3a8 |
@@ -934,16 +937,22 @@ static char *parse_initiator_name(const char *target)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (opts) {
|
|
|
9ae3a8 |
name = qemu_opt_get(opts, "initiator-name");
|
|
|
9ae3a8 |
+ if (name) {
|
|
|
9ae3a8 |
+ return g_strdup(name);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (name) {
|
|
|
9ae3a8 |
- return g_strdup(name);
|
|
|
9ae3a8 |
+ uuid_info = qmp_query_uuid(NULL);
|
|
|
9ae3a8 |
+ if (strcmp(uuid_info->UUID, UUID_NONE) == 0) {
|
|
|
9ae3a8 |
+ name = qemu_get_vm_name();
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
- return g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s",
|
|
|
9ae3a8 |
- iscsi_name ? ":" : "",
|
|
|
9ae3a8 |
- iscsi_name ? iscsi_name : "");
|
|
|
9ae3a8 |
+ name = uuid_info->UUID;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+ iscsi_name = g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s",
|
|
|
9ae3a8 |
+ name ? ":" : "", name ? name : "");
|
|
|
9ae3a8 |
+ qapi_free_UuidInfo(uuid_info);
|
|
|
9ae3a8 |
+ return iscsi_name;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#if defined(LIBISCSI_FEATURE_NOP_COUNTER)
|
|
|
9ae3a8 |
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
|
|
|
9ae3a8 |
index d7a77b6..76c5b64 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/sysemu.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/sysemu.h
|
|
|
9ae3a8 |
@@ -17,7 +17,9 @@ extern const char *bios_name;
|
|
|
9ae3a8 |
extern const char *qemu_name;
|
|
|
9ae3a8 |
extern uint8_t qemu_uuid[];
|
|
|
9ae3a8 |
int qemu_uuid_parse(const char *str, uint8_t *uuid);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
|
|
|
9ae3a8 |
+#define UUID_NONE "00000000-0000-0000-0000-000000000000"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bool runstate_check(RunState state);
|
|
|
9ae3a8 |
void runstate_set(RunState new_state);
|
|
|
9ae3a8 |
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
|
|
|
9ae3a8 |
index 9b701b4..4b2cb7d 100644
|
|
|
9ae3a8 |
--- a/stubs/Makefile.objs
|
|
|
9ae3a8 |
+++ b/stubs/Makefile.objs
|
|
|
9ae3a8 |
@@ -21,6 +21,7 @@ stub-obj-y += reset.o
|
|
|
9ae3a8 |
stub-obj-y += set-fd-handler.o
|
|
|
9ae3a8 |
stub-obj-y += slirp.o
|
|
|
9ae3a8 |
stub-obj-y += sysbus.o
|
|
|
9ae3a8 |
+stub-obj-y += uuid.o
|
|
|
9ae3a8 |
stub-obj-y += vm-stop.o
|
|
|
9ae3a8 |
stub-obj-y += vmstate.o
|
|
|
9ae3a8 |
stub-obj-$(CONFIG_WIN32) += fd-register.o
|
|
|
9ae3a8 |
diff --git a/stubs/uuid.c b/stubs/uuid.c
|
|
|
9ae3a8 |
new file mode 100644
|
|
|
9ae3a8 |
index 0000000..ffc0ed4
|
|
|
9ae3a8 |
--- /dev/null
|
|
|
9ae3a8 |
+++ b/stubs/uuid.c
|
|
|
9ae3a8 |
@@ -0,0 +1,12 @@
|
|
|
9ae3a8 |
+#include "qemu-common.h"
|
|
|
9ae3a8 |
+#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
+#include "qmp-commands.h"
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+UuidInfo *qmp_query_uuid(Error **errp)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ UuidInfo *info = g_malloc0(sizeof(*info));
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ info->UUID = g_strdup(UUID_NONE);
|
|
|
9ae3a8 |
+ return info;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|