* [Qemu-devel] [PATCH] scsi: prefer UUID to VM name for the initiator name
@ 2013-09-10 16:40 Paolo Bonzini
2013-09-12 8:38 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2013-09-10 16:40 UTC (permalink / raw)
To: qemu-devel
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>
---
block/iscsi.c | 23 ++++++++++++++++-------
include/sysemu/sysemu.h | 2 ++
stubs/Makefile.objs | 1 +
stubs/uuid.c | 12 ++++++++++++
4 files changed, 31 insertions(+), 7 deletions(-)
create mode 100644 stubs/uuid.c
diff --git a/block/iscsi.c b/block/iscsi.c
index 813abd8..60b3967 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -33,6 +33,8 @@
#include "trace.h"
#include "block/scsi.h"
#include "qemu/iov.h"
+#include "sysemu/sysemu.h"
+#include "qmp-commands.h"
#include <iscsi/iscsi.h>
#include <iscsi/scsi-lowlevel.h>
@@ -922,8 +924,9 @@ static char *parse_initiator_name(const char *target)
{
QemuOptsList *list;
QemuOpts *opts;
- const char *name = NULL;
- const char *iscsi_name = qemu_get_vm_name();
+ const char *name;
+ char *iscsi_name;
+ UuidInfo *uuid_info;
list = qemu_find_opts("iscsi");
if (list) {
@@ -933,16 +936,22 @@ static char *parse_initiator_name(const char *target)
}
if (opts) {
name = qemu_opt_get(opts, "initiator-name");
+ if (name) {
+ return g_strdup(name);
+ }
}
}
- if (name) {
- return g_strdup(name);
+ uuid_info = qmp_query_uuid(NULL);
+ if (strcmp(uuid_info->UUID, UUID_NONE) == 0) {
+ name = qemu_get_vm_name();
} else {
- return g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s",
- iscsi_name ? ":" : "",
- iscsi_name ? iscsi_name : "");
+ name = uuid_info->UUID;
}
+ 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)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index b1aa059..e2c6f58 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -17,7 +17,9 @@ extern const char *bios_name;
extern const char *qemu_name;
extern uint8_t qemu_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_NONE "00000000-0000-0000-0000-000000000000"
bool runstate_check(RunState state);
void runstate_set(RunState new_state);
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index f306cba..df92fe5 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -22,6 +22,7 @@ stub-obj-y += reset.o
stub-obj-y += set-fd-handler.o
stub-obj-y += slirp.o
stub-obj-y += sysbus.o
+stub-obj-y += uuid.o
stub-obj-y += vm-stop.o
stub-obj-y += vmstate.o
stub-obj-$(CONFIG_WIN32) += fd-register.o
diff --git a/stubs/uuid.c b/stubs/uuid.c
new file mode 100644
index 0000000..ffc0ed4
--- /dev/null
+++ b/stubs/uuid.c
@@ -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;
+}
+
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] scsi: prefer UUID to VM name for the initiator name
2013-09-10 16:40 [Qemu-devel] [PATCH] scsi: prefer UUID to VM name for the initiator name Paolo Bonzini
@ 2013-09-12 8:38 ` Stefan Hajnoczi
2013-09-12 8:51 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-09-12 8:38 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Tue, Sep 10, 2013 at 06:40:04PM +0200, Paolo Bonzini wrote:
> 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>
> ---
> block/iscsi.c | 23 ++++++++++++++++-------
> include/sysemu/sysemu.h | 2 ++
> stubs/Makefile.objs | 1 +
> stubs/uuid.c | 12 ++++++++++++
> 4 files changed, 31 insertions(+), 7 deletions(-)
> create mode 100644 stubs/uuid.c
Will changing the initiator name break existing setups/ACLs?
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] scsi: prefer UUID to VM name for the initiator name
2013-09-12 8:38 ` Stefan Hajnoczi
@ 2013-09-12 8:51 ` Paolo Bonzini
2013-09-23 13:32 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2013-09-12 8:51 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel
Il 12/09/2013 10:38, Stefan Hajnoczi ha scritto:
> On Tue, Sep 10, 2013 at 06:40:04PM +0200, Paolo Bonzini wrote:
>> 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>
>> ---
>> block/iscsi.c | 23 ++++++++++++++++-------
>> include/sysemu/sysemu.h | 2 ++
>> stubs/Makefile.objs | 1 +
>> stubs/uuid.c | 12 ++++++++++++
>> 4 files changed, 31 insertions(+), 7 deletions(-)
>> create mode 100644 stubs/uuid.c
>
> Will changing the initiator name break existing setups/ACLs?
The username for authentication is separate from the initiator name.
It could break persistent reservations, but there is a workaround
(specify the initiator name manually through "-iscsi"). I'll make sure
to document this in the release changelog.
Does it look good?
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] scsi: prefer UUID to VM name for the initiator name
2013-09-12 8:51 ` Paolo Bonzini
@ 2013-09-23 13:32 ` Stefan Hajnoczi
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-09-23 13:32 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Thu, Sep 12, 2013 at 10:51:48AM +0200, Paolo Bonzini wrote:
> Il 12/09/2013 10:38, Stefan Hajnoczi ha scritto:
> > On Tue, Sep 10, 2013 at 06:40:04PM +0200, Paolo Bonzini wrote:
> >> 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>
> >> ---
> >> block/iscsi.c | 23 ++++++++++++++++-------
> >> include/sysemu/sysemu.h | 2 ++
> >> stubs/Makefile.objs | 1 +
> >> stubs/uuid.c | 12 ++++++++++++
> >> 4 files changed, 31 insertions(+), 7 deletions(-)
> >> create mode 100644 stubs/uuid.c
> >
> > Will changing the initiator name break existing setups/ACLs?
>
> The username for authentication is separate from the initiator name.
>
> It could break persistent reservations, but there is a workaround
> (specify the initiator name manually through "-iscsi"). I'll make sure
> to document this in the release changelog.
>
> Does it look good?
It's already merged but for the record, I'm happy with the patch.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-23 13:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-10 16:40 [Qemu-devel] [PATCH] scsi: prefer UUID to VM name for the initiator name Paolo Bonzini
2013-09-12 8:38 ` Stefan Hajnoczi
2013-09-12 8:51 ` Paolo Bonzini
2013-09-23 13:32 ` Stefan Hajnoczi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.