qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/5] Add OUT support to vmport.
@ 2008-06-05  8:35 Gleb Natapov
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 2/5] Add -uuid command line option Gleb Natapov
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Gleb Natapov @ 2008-06-05  8:35 UTC (permalink / raw)
  To: qemu-devel

VMWare backdoor interface should work with IN/OUT port ops, but
currently only IN is supported. BACHS bios uses OUT to query UUID.
The patch adds OUT support.

Signed-off-by: Gleb Natapov <gleb@qumranet.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
---

 hw/vmport.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/vmport.c b/hw/vmport.c
index 3655ad1..ebfa921 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -72,6 +72,13 @@ static uint32_t vmport_ioport_read(void *opaque, uint32_t addr)
     return s->func[command](s->opaque[command], addr);
 }
 
+static void vmport_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+{
+    CPUState *env = cpu_single_env;
+
+    env->regs[R_EAX] = vmport_ioport_read(opaque, addr);
+}
+
 static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)
 {
     CPUState *env = cpu_single_env;
@@ -89,6 +96,7 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
 void vmport_init(void)
 {
     register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &port_state);
+    register_ioport_write(0x5658, 1, 4, vmport_ioport_write, &port_state);
 
     /* Register some generic port commands */
     vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 2/5] Add -uuid command line option.
  2008-06-05  8:35 [Qemu-devel] [PATCH 1/5] Add OUT support to vmport Gleb Natapov
@ 2008-06-05  8:35 ` Gleb Natapov
  2008-06-05 15:13   ` Anthony Liguori
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor Gleb Natapov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Gleb Natapov @ 2008-06-05  8:35 UTC (permalink / raw)
  To: qemu-devel

Let user specify UUID of the virtual machine.

Signed-off-by: Gleb Natapov <gleb@qumranet.com>
---

 vl.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/vl.c b/vl.c
index 18ddcce..8e9e841 100644
--- a/vl.c
+++ b/vl.c
@@ -240,6 +240,8 @@ static CPUState *cur_cpu;
 static CPUState *next_cpu;
 static int event_pending = 1;
 
+const char *qemu_uuid_str;
+
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
 /***********************************************************/
@@ -7195,6 +7197,7 @@ static void help(int exitcode)
            "-g WxH[xDEPTH]  Set the initial graphical resolution and depth\n"
 #endif
            "-name string    set the name of the guest\n"
+           "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n"
            "\n"
            "Network options:\n"
            "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
@@ -7379,6 +7382,7 @@ enum {
     QEMU_OPTION_clock,
     QEMU_OPTION_startdate,
     QEMU_OPTION_tb_size,
+    QEMU_OPTION_uuid,
 };
 
 typedef struct QEMUOption {
@@ -7467,6 +7471,7 @@ const QEMUOption qemu_options[] = {
 #ifdef CONFIG_CURSES
     { "curses", 0, QEMU_OPTION_curses },
 #endif
+    { "uuid", HAS_ARG, QEMU_OPTION_uuid },
 
     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -8227,6 +8232,9 @@ int main(int argc, char **argv)
             case QEMU_OPTION_show_cursor:
                 cursor_hide = 0;
                 break;
+            case QEMU_OPTION_uuid:
+                qemu_uuid_str = optarg;
+                break;
 	    case QEMU_OPTION_daemonize:
 		daemonize = 1;
 		break;

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor.
  2008-06-05  8:35 [Qemu-devel] [PATCH 1/5] Add OUT support to vmport Gleb Natapov
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 2/5] Add -uuid command line option Gleb Natapov
@ 2008-06-05  8:35 ` Gleb Natapov
  2008-06-05 15:14   ` Anthony Liguori
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 4/5] Use libuuid if available Gleb Natapov
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface Gleb Natapov
  3 siblings, 1 reply; 14+ messages in thread
From: Gleb Natapov @ 2008-06-05  8:35 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Gleb Natapov <gleb@qumranet.com>
---

 monitor.c |    8 ++++++++
 sysemu.h  |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/monitor.c b/monitor.c
index e6abcdd..9233625 100644
--- a/monitor.c
+++ b/monitor.c
@@ -254,6 +254,12 @@ static void do_info_name(void)
         term_printf("%s\n", qemu_name);
 }
 
+static void do_info_uuid(void)
+{
+    if (qemu_uuid_str)
+        term_printf("%s\n", qemu_uuid_str);
+}
+
 static void do_info_block(void)
 {
     bdrv_info();
@@ -1442,6 +1448,8 @@ static term_cmd_t info_cmds[] = {
       "", "show the vnc server status"},
     { "name", "", do_info_name,
       "", "show the current VM name" },
+    { "uuid", "", do_info_uuid,
+      "", "show the current VM UUID" },
 #if defined(TARGET_PPC)
     { "cpustats", "", do_info_cpu_stats,
       "", "show CPU statistics", },
diff --git a/sysemu.h b/sysemu.h
index f666f73..474091a 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -8,6 +8,7 @@ extern const char *bios_dir;
 
 extern int vm_running;
 extern const char *qemu_name;
+extern const char *qemu_uuid_str;
 
 typedef struct vm_change_state_entry VMChangeStateEntry;
 typedef void VMChangeStateHandler(void *opaque, int running);

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05  8:35 [Qemu-devel] [PATCH 1/5] Add OUT support to vmport Gleb Natapov
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 2/5] Add -uuid command line option Gleb Natapov
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor Gleb Natapov
@ 2008-06-05  8:35 ` Gleb Natapov
  2008-06-05 15:18   ` Anthony Liguori
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface Gleb Natapov
  3 siblings, 1 reply; 14+ messages in thread
From: Gleb Natapov @ 2008-06-05  8:35 UTC (permalink / raw)
  To: qemu-devel

If libuuid is available use it for input validation and UUID generation if
user does not provide one.

Signed-off-by: Gleb Natapov <gleb@qumranet.com>
---

 Makefile.target |    4 ++++
 configure       |   14 ++++++++++++++
 monitor.c       |   10 ++++++++++
 vl.c            |   17 +++++++++++++++++
 4 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index e06a99e..c1385af 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -502,6 +502,10 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
 LIBS += $(CONFIG_VNC_TLS_LIBS)
 endif
 
+ifdef CONFIG_UUID
+LIBS += -luuid
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
diff --git a/configure b/configure
index f204d04..49ee04c 100755
--- a/configure
+++ b/configure
@@ -113,6 +113,7 @@ build_docs="no"
 uname_release=""
 curses="yes"
 nptl="yes"
+uuid="yes"
 
 # OS specific
 targetos=`uname -s`
@@ -314,6 +315,8 @@ for opt do
   ;;
   --enable-uname-release=*) uname_release="$optarg"
   ;;
+  --disable-uuid) uuid="no"
+  ;;
   --sparc_cpu=*)
       sparc_cpu="$optarg"
       case $sparc_cpu in
@@ -728,6 +731,12 @@ if test "$vnc_tls" = "yes" ; then
 fi
 
 ##########################################
+# uuid library
+if test "$uuid" = "yes" ; then
+  `pkg-config uuid` || uuid="no"
+fi
+
+##########################################
 # alsa sound support libraries
 
 if test "$alsa" = "yes" ; then
@@ -862,6 +871,7 @@ echo "Documentation     $build_docs"
 [ ! -z "$uname_release" ] && \
 echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
+echo "UUID support      $uuid"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1070,6 +1080,10 @@ if test "$vnc_tls" = "yes" ; then
   echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
   echo "#define CONFIG_VNC_TLS 1" >> $config_h
 fi
+if test "$uuid" = "yes" ; then
+  echo "CONFIG_UUID=yes" >> $config_mak
+  echo "#define CONFIG_UUID 1" >> $config_h
+fi
 qemu_version=`head $source_path/VERSION`
 echo "VERSION=$qemu_version" >>$config_mak
 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
diff --git a/monitor.c b/monitor.c
index 9233625..1cc9079 100644
--- a/monitor.c
+++ b/monitor.c
@@ -47,6 +47,10 @@
 #define offsetof(type, field) ((size_t) &((type *)0)->field)
 #endif
 
+#ifdef CONFIG_UUID
+#include <uuid/uuid.h>
+extern uuid_t qemu_uuid;
+#endif
 /*
  * Supported types:
  *
@@ -256,8 +260,14 @@ static void do_info_name(void)
 
 static void do_info_uuid(void)
 {
+#ifdef CONFIG_UUID
+    char uuid_str[37];
+    uuid_unparse(qemu_uuid, uuid_str);
+    term_printf("%s\n", uuid_str);
+#else
     if (qemu_uuid_str)
         term_printf("%s\n", qemu_uuid_str);
+#endif
 }
 
 static void do_info_block(void)
diff --git a/vl.c b/vl.c
index 8e9e841..be31263 100644
--- a/vl.c
+++ b/vl.c
@@ -131,6 +131,11 @@ int inet_aton(const char *cp, struct in_addr *ia);
 
 #include "exec-all.h"
 
+#ifdef CONFIG_UUID
+#include <uuid/uuid.h>
+uuid_t qemu_uuid;
+#endif
+
 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
 #ifdef __sun__
@@ -8234,6 +8239,13 @@ int main(int argc, char **argv)
                 break;
             case QEMU_OPTION_uuid:
                 qemu_uuid_str = optarg;
+#ifdef CONFIG_UUID
+                if (uuid_parse(qemu_uuid_str, qemu_uuid) < 0) {
+                    fprintf(stderr, "Fail to parse UUID string."
+                            " Wrong format.\n");
+                    exit(1);
+                }
+#endif
                 break;
 	    case QEMU_OPTION_daemonize:
 		daemonize = 1;
@@ -8317,6 +8329,11 @@ int main(int argc, char **argv)
         }
     }
 
+#if CONFIG_UUID
+    if (!qemu_uuid_str)
+        uuid_generate(qemu_uuid);
+#endif
+
 #ifndef _WIN32
     if (daemonize && !nographic && vnc_display == NULL) {
 	fprintf(stderr, "Can only daemonize if using -nographic or -vnc\n");

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface.
  2008-06-05  8:35 [Qemu-devel] [PATCH 1/5] Add OUT support to vmport Gleb Natapov
                   ` (2 preceding siblings ...)
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 4/5] Use libuuid if available Gleb Natapov
@ 2008-06-05  8:35 ` Gleb Natapov
  2008-06-05 15:19   ` Anthony Liguori
  3 siblings, 1 reply; 14+ messages in thread
From: Gleb Natapov @ 2008-06-05  8:35 UTC (permalink / raw)
  To: qemu-devel

Answer BOCHS BIOS query about UUID.

Signed-off-by: Gleb Natapov <gleb@qumranet.com>
---

 hw/vmport.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/hw/vmport.c b/hw/vmport.c
index ebfa921..5d32288 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -26,8 +26,16 @@
 #include "pc.h"
 #include "sysemu.h"
 
+#ifdef CONFIG_UUID
+#include <uuid/uuid.h>
+extern uuid_t qemu_uuid;
+#else
+static uint8_t qemu_uuid[16];
+#endif
+
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
+#define VMPORT_CMD_GETBIOSUUID 0x13
 
 #define VMPORT_ENTRIES 0x2c
 #define VMPORT_MAGIC   0x564D5868
@@ -93,6 +101,26 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
     return ram_size;
 }
 
+static inline uint32_t uuid2reg(const unsigned char *uuid, uint32_t idx)
+{
+    int i;
+    uint32_t reg = 0;
+
+    for (i = 0; i < 4; i++)
+        reg |= (uuid[(idx*4) + i] << (i*8));
+
+    return reg;
+}
+
+static uint32_t vmport_cmd_bios_uuid(void *opaque, uint32_t addr)
+{
+    CPUState *env = cpu_single_env;
+    env->regs[R_EBX] = uuid2reg(qemu_uuid, 1);
+    env->regs[R_ECX] = uuid2reg(qemu_uuid, 2);
+    env->regs[R_EDX] = uuid2reg(qemu_uuid, 3);
+    return uuid2reg(qemu_uuid, 0);
+}
+
 void vmport_init(void)
 {
     register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &port_state);
@@ -101,4 +129,5 @@ void vmport_init(void)
     /* Register some generic port commands */
     vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);
     vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL);
+    vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_bios_uuid, NULL);
 }

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] Add -uuid command line option.
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 2/5] Add -uuid command line option Gleb Natapov
@ 2008-06-05 15:13   ` Anthony Liguori
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2008-06-05 15:13 UTC (permalink / raw)
  To: qemu-devel

Gleb Natapov wrote:
> Let user specify UUID of the virtual machine.
>   

Looks good to me.  Note, this is a very common feature request for 
management tools running agents within a guest.  They need to have a 
unique identifier to be able to correlate guests with hosts.  Normally, 
this would be exposed via DMI tables but that's an obvious extension.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> Signed-off-by: Gleb Natapov <gleb@qumranet.com>
> ---
>
>  vl.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 18ddcce..8e9e841 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -240,6 +240,8 @@ static CPUState *cur_cpu;
>  static CPUState *next_cpu;
>  static int event_pending = 1;
>  
> +const char *qemu_uuid_str;
> +
>  #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
>  
>  /***********************************************************/
> @@ -7195,6 +7197,7 @@ static void help(int exitcode)
>             "-g WxH[xDEPTH]  Set the initial graphical resolution and depth\n"
>  #endif
>             "-name string    set the name of the guest\n"
> +           "-uuid %%08x-%%04x-%%04x-%%04x-%%012x specify machine UUID\n"
>             "\n"
>             "Network options:\n"
>             "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
> @@ -7379,6 +7382,7 @@ enum {
>      QEMU_OPTION_clock,
>      QEMU_OPTION_startdate,
>      QEMU_OPTION_tb_size,
> +    QEMU_OPTION_uuid,
>  };
>  
>  typedef struct QEMUOption {
> @@ -7467,6 +7471,7 @@ const QEMUOption qemu_options[] = {
>  #ifdef CONFIG_CURSES
>      { "curses", 0, QEMU_OPTION_curses },
>  #endif
> +    { "uuid", HAS_ARG, QEMU_OPTION_uuid },
>  
>      /* temporary options */
>      { "usb", 0, QEMU_OPTION_usb },
> @@ -8227,6 +8232,9 @@ int main(int argc, char **argv)
>              case QEMU_OPTION_show_cursor:
>                  cursor_hide = 0;
>                  break;
> +            case QEMU_OPTION_uuid:
> +                qemu_uuid_str = optarg;
> +                break;
>  	    case QEMU_OPTION_daemonize:
>  		daemonize = 1;
>  		break;
>
>
>
>   

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor.
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor Gleb Natapov
@ 2008-06-05 15:14   ` Anthony Liguori
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2008-06-05 15:14 UTC (permalink / raw)
  To: qemu-devel

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov <gleb@qumranet.com>
> ---
>
>  monitor.c |    8 ++++++++
>  sysemu.h  |    1 +
>  2 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index e6abcdd..9233625 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -254,6 +254,12 @@ static void do_info_name(void)
>          term_printf("%s\n", qemu_name);
>  }
>  
> +static void do_info_uuid(void)
> +{
> +    if (qemu_uuid_str)
> +        term_printf("%s\n", qemu_uuid_str);
> +}
> +
>  static void do_info_block(void)
>  {
>      bdrv_info();
> @@ -1442,6 +1448,8 @@ static term_cmd_t info_cmds[] = {
>        "", "show the vnc server status"},
>      { "name", "", do_info_name,
>        "", "show the current VM name" },
> +    { "uuid", "", do_info_uuid,
> +      "", "show the current VM UUID" },
>  #if defined(TARGET_PPC)
>      { "cpustats", "", do_info_cpu_stats,
>        "", "show CPU statistics", },
> diff --git a/sysemu.h b/sysemu.h
> index f666f73..474091a 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -8,6 +8,7 @@ extern const char *bios_dir;
>  
>  extern int vm_running;
>  extern const char *qemu_name;
> +extern const char *qemu_uuid_str;
>  
>  typedef struct vm_change_state_entry VMChangeStateEntry;
>  typedef void VMChangeStateHandler(void *opaque, int running);
>
>
>
>   

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 4/5] Use libuuid if available Gleb Natapov
@ 2008-06-05 15:18   ` Anthony Liguori
  2008-06-05 20:20     ` Gleb Natapov
  0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2008-06-05 15:18 UTC (permalink / raw)
  To: qemu-devel

Gleb Natapov wrote:
> If libuuid is available use it for input validation and UUID generation if
> user does not provide one.
>
> Signed-off-by: Gleb Natapov <gleb@qumranet.com>
> ---
>
>  Makefile.target |    4 ++++
>  configure       |   14 ++++++++++++++
>  monitor.c       |   10 ++++++++++
>  vl.c            |   17 +++++++++++++++++
>  4 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/Makefile.target b/Makefile.target
> index e06a99e..c1385af 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -502,6 +502,10 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
>  LIBS += $(CONFIG_VNC_TLS_LIBS)
>  endif
>  
> +ifdef CONFIG_UUID
> +LIBS += -luuid
> +endif
> +
>  # SCSI layer
>  OBJS+= lsi53c895a.o esp.o
>  
> diff --git a/configure b/configure
> index f204d04..49ee04c 100755
> --- a/configure
> +++ b/configure
> @@ -113,6 +113,7 @@ build_docs="no"
>  uname_release=""
>  curses="yes"
>  nptl="yes"
> +uuid="yes"
>  
>  # OS specific
>  targetos=`uname -s`
> @@ -314,6 +315,8 @@ for opt do
>    ;;
>    --enable-uname-release=*) uname_release="$optarg"
>    ;;
> +  --disable-uuid) uuid="no"
> +  ;;
>    --sparc_cpu=*)
>        sparc_cpu="$optarg"
>        case $sparc_cpu in
> @@ -728,6 +731,12 @@ if test "$vnc_tls" = "yes" ; then
>  fi
>  
>  ##########################################
> +# uuid library
> +if test "$uuid" = "yes" ; then
> +  `pkg-config uuid` || uuid="no"
> +fi
> +
> +##########################################
>   

Need to redirect stderr to avoid ugly warnings to the user if the 
command isn't found.  Make sure you test with pkg-config renamed and 
ensure that no nasty messages get printed.

>  # alsa sound support libraries
>  
>  if test "$alsa" = "yes" ; then
> @@ -862,6 +871,7 @@ echo "Documentation     $build_docs"
>  [ ! -z "$uname_release" ] && \
>  echo "uname -r          $uname_release"
>  echo "NPTL support      $nptl"
> +echo "UUID support      $uuid"
>  
>  if test $sdl_too_old = "yes"; then
>  echo "-> Your SDL version is too old - please upgrade to have SDL support"
> @@ -1070,6 +1080,10 @@ if test "$vnc_tls" = "yes" ; then
>    echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
>    echo "#define CONFIG_VNC_TLS 1" >> $config_h
>  fi
> +if test "$uuid" = "yes" ; then
> +  echo "CONFIG_UUID=yes" >> $config_mak
> +  echo "#define CONFIG_UUID 1" >> $config_h
> +fi
>  qemu_version=`head $source_path/VERSION`
>  echo "VERSION=$qemu_version" >>$config_mak
>  echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
> diff --git a/monitor.c b/monitor.c
> index 9233625..1cc9079 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -47,6 +47,10 @@
>  #define offsetof(type, field) ((size_t) &((type *)0)->field)
>  #endif
>  
> +#ifdef CONFIG_UUID
> +#include <uuid/uuid.h>
> +extern uuid_t qemu_uuid;
> +#endif
>   

uuid_t is just an unsigned char[16] so just use that to represent that 
data type.  That will eliminate a lot of the CONFIG_UUID stuff.

>  /*
>   * Supported types:
>   *
> @@ -256,8 +260,14 @@ static void do_info_name(void)
>  
>  static void do_info_uuid(void)
>  {
> +#ifdef CONFIG_UUID
> +    char uuid_str[37];
> +    uuid_unparse(qemu_uuid, uuid_str);
> +    term_printf("%s\n", uuid_str);
> +#else
>   

Just use a printf() string here again to eliminate the need for CONFIG_UUID.

Regards,

Anthony Liguori

>      if (qemu_uuid_str)
>          term_printf("%s\n", qemu_uuid_str);
> +#endif
>  }
>  
>  static void do_info_block(void)
> diff --git a/vl.c b/vl.c
> index 8e9e841..be31263 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -131,6 +131,11 @@ int inet_aton(const char *cp, struct in_addr *ia);
>  
>  #include "exec-all.h"
>  
> +#ifdef CONFIG_UUID
> +#include <uuid/uuid.h>
> +uuid_t qemu_uuid;
> +#endif
> +
>  #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
>  #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
>  #ifdef __sun__
> @@ -8234,6 +8239,13 @@ int main(int argc, char **argv)
>                  break;
>              case QEMU_OPTION_uuid:
>                  qemu_uuid_str = optarg;
> +#ifdef CONFIG_UUID
> +                if (uuid_parse(qemu_uuid_str, qemu_uuid) < 0) {
> +            2        fprintf(stderr, "Fail to parse UUID string."
> +                            " Wrong format.\n");
> +                    exit(1);
> +                }
> +#endif
>                  break;
>  	    case QEMU_OPTION_daemonize:
>  		daemonize = 1;
> @@ -8317,6 +8329,11 @@ int main(int argc, char **argv)
>          }
>      }
>  
> +#if CONFIG_UUID
> +    if (!qemu_uuid_str)
> +        uuid_generate(qemu_uuid);
> +#endif
> +
>  #ifndef _WIN32
>      if (daemonize && !nographic && vnc_display == NULL) {
>  	fprintf(stderr, "Can only daemonize if using -nographic or -vnc\n");
>
>
>
>   

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface.
  2008-06-05  8:35 ` [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface Gleb Natapov
@ 2008-06-05 15:19   ` Anthony Liguori
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2008-06-05 15:19 UTC (permalink / raw)
  To: qemu-devel

Gleb Natapov wrote:
> Answer BOCHS BIOS query about UUID.
>
> Signed-off-by: Gleb Natapov <gleb@qumranet.com>
> ---
>
>  hw/vmport.c |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
>
> diff --git a/hw/vmport.c b/hw/vmport.c
> index ebfa921..5d32288 100644
> --- a/hw/vmport.c
> +++ b/hw/vmport.c
> @@ -26,8 +26,16 @@
>  #include "pc.h"
>  #include "sysemu.h"
>  
> +#ifdef CONFIG_UUID
> +#include <uuid/uuid.h>
> +extern uuid_t qemu_uuid;
> +#else
> +static uint8_t qemu_uuid[16];
> +#endif
>   

Just eliminate the #ifdef and always use uint8_t[16].

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05 15:18   ` Anthony Liguori
@ 2008-06-05 20:20     ` Gleb Natapov
  2008-06-05 20:27       ` Anthony Liguori
  0 siblings, 1 reply; 14+ messages in thread
From: Gleb Natapov @ 2008-06-05 20:20 UTC (permalink / raw)
  To: qemu-devel

Anthony, thanks for the review.

On Thu, Jun 05, 2008 at 10:18:15AM -0500, Anthony Liguori wrote:
>> @@ -256,8 +260,14 @@ static void do_info_name(void)
>>   static void do_info_uuid(void)
>>  {
>> +#ifdef CONFIG_UUID
>> +    char uuid_str[37];
>> +    uuid_unparse(qemu_uuid, uuid_str);
>> +    term_printf("%s\n", uuid_str);
>> +#else
>>   
>
> Just use a printf() string here again to eliminate the need for CONFIG_UUID.
>
So may be do not use libuuid at all and just write simple uuid string
parsing function?

--
			Gleb.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05 20:20     ` Gleb Natapov
@ 2008-06-05 20:27       ` Anthony Liguori
  2008-06-05 22:22         ` Paul Brook
  0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2008-06-05 20:27 UTC (permalink / raw)
  To: qemu-devel

Gleb Natapov wrote:
> Anthony, thanks for the review.
>
> On Thu, Jun 05, 2008 at 10:18:15AM -0500, Anthony Liguori wrote:
>   
>>> @@ -256,8 +260,14 @@ static void do_info_name(void)
>>>   static void do_info_uuid(void)
>>>  {
>>> +#ifdef CONFIG_UUID
>>> +    char uuid_str[37];
>>> +    uuid_unparse(qemu_uuid, uuid_str);
>>> +    term_printf("%s\n", uuid_str);
>>> +#else
>>>   
>>>       
>> Just use a printf() string here again to eliminate the need for CONFIG_UUID.
>>
>>     
> So may be do not use libuuid at all and just write simple uuid string
> parsing function?
>   

For parsing, sure. But uuid generation requires implementing an 
algorithm from an RFC. I think that warrants using libuuid.

So I'd say only use libuuid for generating random uuids.

Regards,

Anthony Liguori

> --
> 			Gleb.
>
>
>   

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05 20:27       ` Anthony Liguori
@ 2008-06-05 22:22         ` Paul Brook
  2008-06-06  0:18           ` Anthony Liguori
  2008-06-06  9:18           ` Daniel P. Berrange
  0 siblings, 2 replies; 14+ messages in thread
From: Paul Brook @ 2008-06-05 22:22 UTC (permalink / raw)
  To: qemu-devel

On Thursday 05 June 2008, Anthony Liguori wrote:
> Gleb Natapov wrote:
> > Anthony, thanks for the review.
> >
> > On Thu, Jun 05, 2008 at 10:18:15AM -0500, Anthony Liguori wrote:
> >>> @@ -256,8 +260,14 @@ static void do_info_name(void)
> >>>   static void do_info_uuid(void)
> >>>  {
> >>> +#ifdef CONFIG_UUID
> >>> +    char uuid_str[37];
> >>> +    uuid_unparse(qemu_uuid, uuid_str);
> >>> +    term_printf("%s\n", uuid_str);
> >>> +#else
> >>
> >> Just use a printf() string here again to eliminate the need for
> >> CONFIG_UUID.
> >
> > So may be do not use libuuid at all and just write simple uuid string
> > parsing function?
>
> For parsing, sure. But uuid generation requires implementing an
> algorithm from an RFC. I think that warrants using libuuid.

Can we punt this to management tools? Having qemu create randomly different 
machines seems like it's going to cause as many problems as it solves.  We've 
already got things like MAC addresses which are fixed but need to be unique.

Paul

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05 22:22         ` Paul Brook
@ 2008-06-06  0:18           ` Anthony Liguori
  2008-06-06  9:18           ` Daniel P. Berrange
  1 sibling, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2008-06-06  0:18 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

Paul Brook wrote:
> On Thursday 05 June 2008, Anthony Liguori wrote:
>   
>> Gleb Natapov wrote:
>>     
>>> Anthony, thanks for the review.
>>>
>>> On Thu, Jun 05, 2008 at 10:18:15AM -0500, Anthony Liguori wrote:
>>>       
>>>>> @@ -256,8 +260,14 @@ static void do_info_name(void)
>>>>>   static void do_info_uuid(void)
>>>>>  {
>>>>> +#ifdef CONFIG_UUID
>>>>> +    char uuid_str[37];
>>>>> +    uuid_unparse(qemu_uuid, uuid_str);
>>>>> +    term_printf("%s\n", uuid_str);
>>>>> +#else
>>>>>           
>>>> Just use a printf() string here again to eliminate the need for
>>>> CONFIG_UUID.
>>>>         
>>> So may be do not use libuuid at all and just write simple uuid string
>>> parsing function?
>>>       
>> For parsing, sure. But uuid generation requires implementing an
>> algorithm from an RFC. I think that warrants using libuuid.
>>     
>
> Can we punt this to management tools? Having qemu create randomly different 
> machines seems like it's going to cause as many problems as it solves.  We've 
> already got things like MAC addresses which are fixed but need to be unique.
>   

Yeah, I was thinking this myself too.  It's not really worth it for just 
uuid generation.

Regards,

Anthony Liguori

> Paul
>   

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] Use libuuid if available.
  2008-06-05 22:22         ` Paul Brook
  2008-06-06  0:18           ` Anthony Liguori
@ 2008-06-06  9:18           ` Daniel P. Berrange
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel P. Berrange @ 2008-06-06  9:18 UTC (permalink / raw)
  To: qemu-devel

On Thu, Jun 05, 2008 at 11:22:17PM +0100, Paul Brook wrote:
> On Thursday 05 June 2008, Anthony Liguori wrote:
> > Gleb Natapov wrote:
> > > Anthony, thanks for the review.
> > >
> > > On Thu, Jun 05, 2008 at 10:18:15AM -0500, Anthony Liguori wrote:
> > >>> @@ -256,8 +260,14 @@ static void do_info_name(void)
> > >>>   static void do_info_uuid(void)
> > >>>  {
> > >>> +#ifdef CONFIG_UUID
> > >>> +    char uuid_str[37];
> > >>> +    uuid_unparse(qemu_uuid, uuid_str);
> > >>> +    term_printf("%s\n", uuid_str);
> > >>> +#else
> > >>
> > >> Just use a printf() string here again to eliminate the need for
> > >> CONFIG_UUID.
> > >
> > > So may be do not use libuuid at all and just write simple uuid string
> > > parsing function?
> >
> > For parsing, sure. But uuid generation requires implementing an
> > algorithm from an RFC. I think that warrants using libuuid.
> 
> Can we punt this to management tools? Having qemu create randomly different 
> machines seems like it's going to cause as many problems as it solves.  We've 
> already got things like MAC addresses which are fixed but need to be unique.

FYI, once you have the -uuid argument supported in QEMU, I'll update libvirt
to use it, and libvirt will always generate a random UUID when invoking QEMU
if the user didn't specify one explicitly. So for any management tool using
libvirt, there's no need for QEMU itself to generate random UUIDs.

Regards,
Daniel.
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-06-06  9:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-05  8:35 [Qemu-devel] [PATCH 1/5] Add OUT support to vmport Gleb Natapov
2008-06-05  8:35 ` [Qemu-devel] [PATCH 2/5] Add -uuid command line option Gleb Natapov
2008-06-05 15:13   ` Anthony Liguori
2008-06-05  8:35 ` [Qemu-devel] [PATCH 3/5] Add "info uuid" command to monitor Gleb Natapov
2008-06-05 15:14   ` Anthony Liguori
2008-06-05  8:35 ` [Qemu-devel] [PATCH 4/5] Use libuuid if available Gleb Natapov
2008-06-05 15:18   ` Anthony Liguori
2008-06-05 20:20     ` Gleb Natapov
2008-06-05 20:27       ` Anthony Liguori
2008-06-05 22:22         ` Paul Brook
2008-06-06  0:18           ` Anthony Liguori
2008-06-06  9:18           ` Daniel P. Berrange
2008-06-05  8:35 ` [Qemu-devel] [PATCH 5/5] Add support for UUID query to vmport interface Gleb Natapov
2008-06-05 15:19   ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).