qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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>

+31 -7
+16 -7
block/iscsi.c
··· 33 33 #include "trace.h" 34 34 #include "block/scsi.h" 35 35 #include "qemu/iov.h" 36 + #include "sysemu/sysemu.h" 37 + #include "qmp-commands.h" 36 38 37 39 #include <iscsi/iscsi.h> 38 40 #include <iscsi/scsi-lowlevel.h> ··· 922 924 { 923 925 QemuOptsList *list; 924 926 QemuOpts *opts; 925 - const char *name = NULL; 926 - const char *iscsi_name = qemu_get_vm_name(); 927 + const char *name; 928 + char *iscsi_name; 929 + UuidInfo *uuid_info; 927 930 928 931 list = qemu_find_opts("iscsi"); 929 932 if (list) { ··· 933 936 } 934 937 if (opts) { 935 938 name = qemu_opt_get(opts, "initiator-name"); 939 + if (name) { 940 + return g_strdup(name); 941 + } 936 942 } 937 943 } 938 944 939 - if (name) { 940 - return g_strdup(name); 945 + uuid_info = qmp_query_uuid(NULL); 946 + if (strcmp(uuid_info->UUID, UUID_NONE) == 0) { 947 + name = qemu_get_vm_name(); 941 948 } else { 942 - return g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s", 943 - iscsi_name ? ":" : "", 944 - iscsi_name ? iscsi_name : ""); 949 + name = uuid_info->UUID; 945 950 } 951 + iscsi_name = g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s", 952 + name ? ":" : "", name ? name : ""); 953 + qapi_free_UuidInfo(uuid_info); 954 + return iscsi_name; 946 955 } 947 956 948 957 #if defined(LIBISCSI_FEATURE_NOP_COUNTER)
+2
include/sysemu/sysemu.h
··· 17 17 extern const char *qemu_name; 18 18 extern uint8_t qemu_uuid[]; 19 19 int qemu_uuid_parse(const char *str, uint8_t *uuid); 20 + 20 21 #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" 22 + #define UUID_NONE "00000000-0000-0000-0000-000000000000" 21 23 22 24 bool runstate_check(RunState state); 23 25 void runstate_set(RunState new_state);
+1
stubs/Makefile.objs
··· 22 22 stub-obj-y += set-fd-handler.o 23 23 stub-obj-y += slirp.o 24 24 stub-obj-y += sysbus.o 25 + stub-obj-y += uuid.o 25 26 stub-obj-y += vm-stop.o 26 27 stub-obj-y += vmstate.o 27 28 stub-obj-$(CONFIG_WIN32) += fd-register.o
+12
stubs/uuid.c
··· 1 + #include "qemu-common.h" 2 + #include "sysemu/sysemu.h" 3 + #include "qmp-commands.h" 4 + 5 + UuidInfo *qmp_query_uuid(Error **errp) 6 + { 7 + UuidInfo *info = g_malloc0(sizeof(*info)); 8 + 9 + info->UUID = g_strdup(UUID_NONE); 10 + return info; 11 + } 12 +