qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Re: [kvm-devel] [PATCH 3 of 3] Add -uuid command line flag
       [not found] <5fe703a5a7bde701686f.1197059817@localhost.localdomain>
@ 2007-12-07 20:52 ` Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2007-12-07 20:52 UTC (permalink / raw)
  To: Ryan Harper; +Cc: kvm-devel, qemu-devel

Ryan Harper wrote:
> 2 files changed, 29 insertions(+), 1 deletion(-)
> smbios.c |   12 +++++++++++-
> vl.c     |   18 ++++++++++++++++++
>
>
> # HG changeset patch
> # User Ryan Harper <ryanh@us.ibm.com>
> # Date 1197058922 21600
> # Node ID 5fe703a5a7bde701686fc333c17836b308c17b4f
> # Parent  3470dd05f46cc9f14c3fc9561d06031a4bc0ce7a
> Add -uuid command line flag
>
> This patch allows users to specify a uuid.  If no uuid is specified, then one is
> generated.
>
> Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
>
> diff -r 3470dd05f46c -r 5fe703a5a7bd smbios.c
> --- a/smbios.c	Fri Dec 07 14:22:02 2007 -0600
> +++ b/smbios.c	Fri Dec 07 14:22:02 2007 -0600
> @@ -32,6 +32,7 @@
>  
>  #ifdef CONFIG_UUID
>  #include <uuid/uuid.h>
> +extern const char *qemu_uuid;
>  #endif
>   

Please move this to a header.

>  CPUState *first_cpu;
> @@ -497,7 +498,16 @@ load_smbios_tables(uint8_t *entry, uint8
>  #ifdef CONFIG_UUID
>      uuid_t uuid;
>  
> -    uuid_generate(uuid);
> +    /* parse user-specified uuid if present */
> +    if (qemu_uuid != NULL) {
> +        if (uuid_parse(qemu_uuid, uuid) < 0) {
> +            fprintf(stderr, "SMBIOS: Could not parse user UUID"
> +                            "string, check format.\n");
> +            return -1;
> +        }
> +    } else {
> +        uuid_generate(uuid);
> +    }
>  #else
>      uint8_t uuid[16] = "QEMUQEMUQEMUQEMU";
>   

I think it's worth writing a uuid_parse() for use in the absence of 
-luuid.  You can just use sscanf().  That will get rid of a lot of 
CONFIG_UUIDs too.

Regards,

Anthony Liguori

>  #endif
> diff -r 3470dd05f46c -r 5fe703a5a7bd vl.c
> --- a/vl.c	Fri Dec 07 14:22:02 2007 -0600
> +++ b/vl.c	Fri Dec 07 14:22:02 2007 -0600
> @@ -137,6 +137,9 @@ int inet_aton(const char *cp, struct in_
>  #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
>  #else
>  #define SMBD_COMMAND "/usr/sbin/smbd"
> +#endif
> +#ifdef CONFIG_UUID
> +const char *qemu_uuid;
>  #endif
>  
>  //#define DEBUG_UNUSED_IOPORT
> @@ -7545,6 +7548,10 @@ static void help(int exitcode)
>             "-no-reboot      exit instead of rebooting\n"
>             "-loadvm file    start right away with a saved state (loadvm in monitor)\n"
>  	   "-vnc display    start a VNC server on display\n"
> +#ifdef CONFIG_UUID
> +           "-uuid %%08x-%%04x-%%04x-%%04x-%%012x\n"
> +           "                specify machine UUID\n"
> +#endif
>  #ifndef _WIN32
>  	   "-daemonize      daemonize QEMU after initializing\n"
>  #endif
> @@ -7647,6 +7654,9 @@ enum {
>      QEMU_OPTION_vnc,
>      QEMU_OPTION_no_acpi,
>      QEMU_OPTION_no_reboot,
> +#ifdef CONFIG_UUID
> +    QEMU_OPTION_uuid,
> +#endif
>      QEMU_OPTION_show_cursor,
>      QEMU_OPTION_daemonize,
>      QEMU_OPTION_option_rom,
> @@ -7742,6 +7752,9 @@ const QEMUOption qemu_options[] = {
>      { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
>      { "smp", HAS_ARG, QEMU_OPTION_smp },
>      { "vnc", HAS_ARG, QEMU_OPTION_vnc },
> +#ifdef CONFIG_UUID
> +    { "uuid", HAS_ARG, QEMU_OPTION_uuid },
> +#endif
>  
>      /* temporary options */
>      { "usb", 0, QEMU_OPTION_usb },
> @@ -8527,6 +8540,11 @@ int main(int argc, char **argv)
>  	    case QEMU_OPTION_daemonize:
>  		daemonize = 1;
>  		break;
> +#ifdef CONFIG_UUID
> +            case QEMU_OPTION_uuid:
> +                qemu_uuid = optarg;
> +                break;
> +#endif
>  	    case QEMU_OPTION_option_rom:
>  		if (nb_option_roms >= MAX_OPTION_ROMS) {
>  		    fprintf(stderr, "Too many option ROMs\n");
>
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>
>   

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-12-07 20:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5fe703a5a7bde701686f.1197059817@localhost.localdomain>
2007-12-07 20:52 ` [Qemu-devel] Re: [kvm-devel] [PATCH 3 of 3] Add -uuid command line flag 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).