qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Ryan Harper <ryanh@us.ibm.com>
Cc: kvm-devel@lists.sourceforge.net, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [kvm-devel] [PATCH 3 of 3] Add -uuid command line flag
Date: Fri, 07 Dec 2007 14:52:10 -0600	[thread overview]
Message-ID: <4759B27A.4060008@codemonkey.ws> (raw)
In-Reply-To: <5fe703a5a7bde701686f.1197059817@localhost.localdomain>

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
>
>   

           reply	other threads:[~2007-12-07 20:52 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <5fe703a5a7bde701686f.1197059817@localhost.localdomain>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4759B27A.4060008@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=qemu-devel@nongnu.org \
    --cc=ryanh@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).