Add SMBIOS/DMI table generation to PC machine
PATCH 1/1 Add SMBIOS/DMI table generation to PC machine
This patchset introduces SMBIOS/DMI table generation to qemu for PC machines. The intial patch includes all changes needed to create the tables and load them into memory. This patch depends on libuuid. The subsequent patches detect for libuuid and optionally link to the library if present. The final patch adds a -uuid option for a user to specify their own uuid.
These patches should apply against qemu-cvs. Tested on target x86_64-softmmu.
Updates:
- moved smbios.o into i386 target section
- removed open segment in hw/pc.c and moved variable declaration
- removed some uneeded externs from smbios.c
- added uuid_parse implementation allowing -uuid to be available with or without linking against libuuid.
- reduced the number of CONFIG_UUID defines
7 files changed, 848 insertions(+), 11 deletions(-) Makefile.target | 9 configure | 26 ++ hw/pc.c | 45 ++++ smbios.c | 584 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- smbios_types.h | 182 +++++++++++++++++ sysemu.h | 5 vl.c | 8
-------------------------------------------------------------------------
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
A message that is not in the archive (sent off-list or not yet received): patchbomb.1197403730-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
PATCH 1/1 export SMBIOS/DMI tables to PC machines
5 files changed, 749 insertions(+), 3 deletions(-) Makefile.target | 4 hw/pc.c | 45 ++++ smbios.c | 517 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ smbios_types.h | 182 +++++++++++++++++++ sysemu.h | 4
# HG changeset patch
# User Ryan Harper <ryanh-r/[email protected]> # Date 1197402121 21600
# Node ID e81bef5fa072360d12b87b3237b7d3f72c9b9784
# Parent 25082b761acbe8b7fa535dedb4a53e02ef74128d export SMBIOS/DMI tables to PC machines.
This patch introduces code to generate PC SMBIOS/DMI tables and load them into machine memory. The resultant machine can use standard tools like dmidecode to examine the in-memory generated table.
Moved smbios.o to TARGET_BASE_ARCH=i386 section of Makefile.target Removed inner scoping for smbios table call in hw/pc.c
Makefile.target +2 -2
@@ -440,7 +440,7 @@ VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SO VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o VL_OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o -VL_OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o +VL_OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o smbios.o CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif ifeq ($(TARGET_BASE_ARCH), ppc)
@@ -535,7 +535,7 @@ ifndef CONFIG_DARWIN ifndef CONFIG_DARWIN ifndef CONFIG_WIN32 ifndef CONFIG_SOLARIS -VL_LIBS+=-lutil +VL_LIBS+=-lutil -luuid endif endif endif
hw/pc.c +44 -1
63 lines not on this page · raw message
smbios.c new file +517 -0
517 lines not on this page · raw message
smbios_types.h new file +182 -0
182 lines not on this page · raw message
sysemu.h +4 -0
@@ -116,6 +116,10 @@ extern unsigned int nb_prom_envs;#define BIOS_SIZE (4 * 1024 * 1024)#endif +#define SMBIOS_MAXIMUM_SIZE (32 << 10) +int load_smbios_tables (uint8_t *entry,uint8_t *table, +uint32_t phys_table_start); +typedef enum {IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD }BlockInterfaceType ;
-------------------------------------------------------------------------
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
PATCH 1/1 Optionally link against libuuid if present
In reply to a message not in the archive3 files changed, 38 insertions(+), 2 deletions(-) Makefile.target | 5 ++++- configure | 26 ++++++++++++++++++++++++++ smbios.c | 9 ++++++++-
# HG changeset patch
# User Ryan Harper <ryanh-r/[email protected]> # Date 1197402122 21600
# Node ID 115f40a4994be1d5b44ef193b3ccbe8e26410eef
# Parent e81bef5fa072360d12b87b3237b7d3f72c9b9784 Optionally link against libuuid if present.
This patch makes libuuid optional. If not detected, SMBIOS tables will use canned UUID.
Makefile.target +4 -1
@@ -402,6 +402,9 @@ VL_OBJS+=block-raw.o ifdef CONFIG_ALSA LIBS += -lasound +endif +ifdef CONFIG_UUID +LIBS += -luuid endif ifdef CONFIG_DSOUND LIBS += -lole32 -ldxguid
@@ -535,7 +538,7 @@ ifndef CONFIG_DARWIN ifndef CONFIG_DARWIN ifndef CONFIG_WIN32 ifndef CONFIG_SOLARIS -VL_LIBS+=-lutil -luuid +VL_LIBS+=-lutil endif endif endif
configure +26 -0
@@ -89,6 +89,7 @@ dsound="no" dsound="no" coreaudio="no" alsa="no" +uuid="yes" fmod="no" fmod_lib="" fmod_inc=""
@@ -260,6 +261,8 @@ for opt do ;; --enable-alsa) alsa="yes" ;; + --enable-uuid) uuid="yes" + ;; --enable-dsound) dsound="yes" ;; --enable-fmod) fmod="yes"
@@ -404,6 +407,7 @@ echo " --enable-adlib enable echo " --enable-adlib enable Adlib emulation" echo " --enable-coreaudio enable Coreaudio audio driver" echo " --enable-alsa enable ALSA audio driver" +echo " --enable-uuid enable UUID generation for machines" echo " --enable-fmod enable FMOD audio driver" echo " --enable-dsound enable DirectSound audio driver" echo " --disable-vnc-tls disable TLS encryption for VNC server"
@@ -662,6 +666,23 @@ EOF fi fi +########################################## +# uuid library +if test "$uuid" = "yes" ; then + cat > $TMPC << EOF +#include <uuid/uuid.h> +int main(void) { uuid_t u; return 0; } +EOF + if $cc -o $TMPE $TMPC -luuid 2> /dev/null ; then + : + else + echo + echo "Error: Could not find uuid" + echo "Make sure to have the uuid libs and headers installed." + echo + exit 1 + fi +fi # Check if tools are available to build documentation. if [ -x "`which texi2html 2>/dev/null`" ] && \ [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -716,6 +737,7 @@ echo "Adlib support $adlib" echo "Adlib support $adlib" echo "CoreAudio support $coreaudio" echo "ALSA support $alsa" +echo "UUID support $uuid" echo "DSound support $dsound" if test "$fmod" = "yes"; then if test -z $fmod_lib || test -z $fmod_inc; then
@@ -901,6 +923,10 @@ if test "$alsa" = "yes" ; then echo "CONFIG_ALSA=yes" >> $config_mak echo "#define CONFIG_ALSA 1" >> $config_h fi +if test "$uuid" = "yes" ; then + echo "CONFIG_UUID=yes" >> $config_mak + echo "#define CONFIG_UUID 1" >> $config_h +fi if test "$dsound" = "yes" ; then echo "CONFIG_DSOUND=yes" >> $config_mak echo "#define CONFIG_DSOUND 1" >> $config_h
smbios.c +8 -1
@@ -25,11 +25,14 @@#include <stdio.h> #include <stdint.h> #include <string.h> -#include <uuid/uuid.h> #include "hw/hw.h" #include "sysemu.h" #include "smbios_types.h" #include "config-host.h" + +#ifdef CONFIG_UUID +#include <uuid/uuid.h> +#endif /* Write a two-character hex representation of 'byte' to digits[]. Pre-condition: sizeof(digits) >= 2 */
@@ -489,9 +492,13 @@ load_smbios_tables(uint8_t *entry, uint8int len;uint32_t major_version =0 ;uint32_t minor_version =9 ; +#ifdef CONFIG_UUID uuid_t uuid;uuid_generate (uuid); +#else +uint8_t uuid[16 ] ="QEMUQEMUQEMUQEMU" ; +#endif len = write_smbios_tables(entry, table, phys_table_start, smp_cpus, (ram_size >> 20),
-------------------------------------------------------------------------
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
Re: [PATCH 2 of 3] Optionally link against libuuid if present
Hi Ryan & others,
now I have been holding a SMBIOS patch on my hard disk for way to long it seems. I used a different approach from yours, so I decided to publish it for review or further ideas. What I did was to modify the bochs bios to produce the SMBIOS tables and I get the UUID using VMware backdoor port from the virtual machine.
Attached are just the changed files, creating a patch will take a while because it's against VERY OLD version of the sources.
Oh, it also contains ACPI patch for the processor descriptors which was needed for some Windows versions and Darwin. Similar patch was used in KVM before, but this one dynamically detects the number of CPUs.
Best regards,
Filip Navara
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Quoted 8 lines · Filip Navara
Hi Ryan & others,
now I have been holding a SMBIOS patch on my hard disk for way to long it seems. I used a different approach from yours, so I decided to publish it for review or further ideas. What I did was to modify the bochs bios to produce the SMBIOS tables and I get the UUID using VMware backdoor port from the virtual machine.
Quoted 6 lines
Attached are just the changed files, creating a patch will take a while because it's against VERY OLD version of the sources.
Oh, it also contains ACPI patch for the processor descriptors which was needed for some Windows versions and Darwin. Similar patch was used in KVM before, but this one dynamically detects the number of CPUs.
I strongly prefer your solution (Bochs BIOS) compared to modifying QEMU:
I already spent a lot of time moving the ACPI tables and other stuff to the Bochs BIOS just for that !
Regards,
Fabrice.
A message that is not in the archive (sent off-list or not yet received): 5b31733c0712111319s2109e935o19c9d51d091a4056-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Quoted 10 lines · Filip Navara
Hi Ryan & others,
now I have been holding a SMBIOS patch on my hard disk for way to long it seems. I used a different approach from yours, so I decided to publish it for review or further ideas. What I did was to modify the bochs bios to produce the SMBIOS tables and I get the UUID using VMware backdoor port from the virtual machine.
Attached are just the changed files, creating a patch will take a while because it's against VERY OLD version of the sources.
Filip,
Thanks for posting this. I agree with Fabrice that doing the SMBIOS tables in rombios is a better approach. The rombio32.c file you included didn't look that old to me; it has a CVS release tag of:
'rombios32.c,v 1.11 2007/08/03 13:56:13'
AFAICT, it looks like a straight-forward SMBIOS implementation. The only thing worth adding to yours is the BIOS release date string in the type 0 table. Setting this date to something newer than typical CONFIG_ACPI_BLACKLIST_YEAR value (2000 in Gutsy's kernels) lets the kernel enable ACPI features (like power-off).
Any idea on when you might have a patch that I can test?
Signature · 10 lines
Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 ryanh-r/[email protected] ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): 20080103195542.GT23913-r/[email protected]
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Hello,
attached is a patch that implements the SMBIOS within the Bochs BIOS code. Complete list of changes:
- Added generation of SSDT ACPI table that contains definitions for available processors.
- Added basic implementation of SMBIOS.
- Added querying of BIOS UUID using VMware backdoor I/O port (enable only if BX_QEMU is defined).
- Added RTC device to ACPI DSDT table.
Best regards,
Filip Navara
Index: acpi-dsdt.dsl
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/acpi-dsdt.dsl,v retrieving revision 1.1
acpi-dsdt.dsl +11 -0
@@ -170,6 +170,17 @@ /* PIIX PCI to ISA irq remapping */ OperationRegion (P40C, PCI_Config, 0x60, 0x04) + /* Real-time clock */ + Device (RTC) + { + Name (_HID, EisaId ("PNP0B00")) + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x0070, 0x0070, 0x10, 0x02) + IRQNoFlags () {8} + IO (Decode16, 0x0072, 0x0072, 0x02, 0x06) + }) + } /* Keyboard seems to be important for WinXP install */ Device (KBD)
Index: acpi-dsdt.hex
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/acpi-dsdt.hex,v retrieving revision 1.1
acpi-dsdt.hex +184 -178
383 lines not on this page · raw message
Index: rombios.c
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios.c,v
retrieving revision 1.196
rombios.c +0 -9
@@ -181,15 +181,6 @@#define IPL_TYPE_CDROM 0x03#define IPL_TYPE_BEV 0x80 -// Define the application NAME -#if defined(BX_QEMU ) -# define BX_APPNAME "QEMU" -#elif defined(PLEX86 ) -# define BX_APPNAME "Plex86" -#else -# define BX_APPNAME "Bochs" -#endif -// Sanity Checks #if BX_USE_ATADRV &&BX_CPU <3 # error The ATA/ATAPI Driver can only to be used with a 386+ cpu
Index: rombios.h
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios.h,v
retrieving revision 1.4
rombios.h +9 -0
@@ -57,3 +57,12 @@#define PM_IO_BASE 0xb000#define SMB_IO_BASE 0xb100#define CPU_COUNT_ADDR 0xf000 + +// Define the application NAME +#if defined(BX_QEMU ) +# define BX_APPNAME "QEMU" +#elif defined(PLEX86 ) +# define BX_APPNAME "Plex86" +#else +# define BX_APPNAME "Bochs" +#endif
Index: rombios32.c
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios32.c,v
retrieving revision 1.18
rombios32.c +606 -3
675 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Quoted 4 lines · Filip Navara
Hello,
attached is a patch that implements the SMBIOS within the Bochs BIOS code. Complete list of changes:
This should be submitted to the Bochs list.
Paul
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
http://sourceforge.net/tracker/index.php?func=detail&aid=1864692&group_id=12580&atid=312580
- Filip
Quoted 13 lines · Paul Brook
Quoted 3 lines · Filip Navara
Hello,
attached is a patch that implements the SMBIOS within the Bochs BIOS
code.
Quoted 1 line
Complete list of changes:
This should be submitted to the Bochs list.
Paul
A message that is not in the archive (sent off-list or not yet received): 5b31733c0801200517m166d35aencd4a4233d5ac09cc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Quoted 5 lines · Filip Navara
Hello,
attached is a patch that implements the SMBIOS within the Bochs BIOS code. Complete list of changes:
Quoted 7 lines
- Added generation of SSDT ACPI table that contains definitions for available processors.
- Added basic implementation of SMBIOS.
- Added querying of BIOS UUID using VMware backdoor I/O port (enable only ifBX_QEMUis defined).
- Added RTC device to ACPI DSDT table.
This is great news. I was eagerly waiting for this. It looks like this fixes most problems I had with running Mac OS X as a guest OS. I will definitely try this tomorrow and tell you the results.
Is the VMWare I/O backdoor implemented already or is this patch meant to be applied on top of another patch?
Regards,
Alex
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): CA9EF1A7-B046-4EF0-8DD2-0DB33F3F2042-r27SGEef+tmzQB+pC5nmwQ@public.gmane.org
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
The specific VMware backdoor call isn't implemented, but the framework is there and it wouldn't be hard to add support for it. The BIOS can fallback to some "reasonable" value if the backdoor isn't available.
Best regards,
Filip Navara
Quoted 20 lines · Alexander Graf
Quoted 5 lines · Filip Navara
Hello,
attached is a patch that implements the SMBIOS within the Bochs BIOS code. Complete list of changes:
Quoted 7 lines
- Added generation of SSDT ACPI table that contains definitions for available processors.
- Added basic implementation of SMBIOS.
- Added querying of BIOS UUID using VMware backdoor I/O port (enable only ifBX_QEMUis defined).
- Added RTC device to ACPI DSDT table.This is great news. I was eagerly waiting for this. It looks like this fixes most problems I had with running Mac OS X as a guest OS. I will definitely try this tomorrow and tell you the results.
Quoted 8 lines
Is the VMWare I/O backdoor implemented already or is this patch meant to be applied on top of another patch?
Regards,
Alex
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 5b31733c0801200837u2425876dyd2b05a565b7eb023-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Quoted 2 lines · Filip Navara
The specific VMware backdoor call isn't implemented, but the framework is there and it wouldn't be hard to add support for it. The BIOS can fallback to some "reasonable" value if the backdoor isn't available.
+ memset(bios_uuid, 0, 16);
This value? Why not put something more "reasonable" in there? Does a uuid have to meet specific criteria (checksums)? If not, why not simply put something like "QEMU" in here? If I remember correctly OSX needs a value in the uuid or it fails to boot, so it might be a good idea to give it something better than an empty string.
Quoted 24 lines
Best regards,
Filip NavaraOn Jan 20, 2008 5:20 PM, Alexander Graf <[email protected]> wrote:
Quoted 5 lines · Filip Navara
Hello,
attached is a patch that implements the SMBIOS within the Bochs BIOS code. Complete list of changes:
Quoted 7 lines
- Added generation of SSDT ACPI table that contains definitions for available processors.
- Added basic implementation of SMBIOS.
- Added querying of BIOS UUID using VMware backdoor I/O port (enable only ifBX_QEMUis defined).
- Added RTC device to ACPI DSDT table.This is great news. I was eagerly waiting for this. It looks like this fixes most problems I had with running Mac OS X as a guest OS. I will definitely try this tomorrow and tell you the results.
Quoted 8 lines
Is the VMWare I/O backdoor implemented already or is this patch meant to be applied on top of another patch?
Regards,
Alex
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): EB2C2C51-0654-4872-98EC-F8EB4497CCAA-r27SGEef+tmzQB+pC5nmwQ@public.gmane.org
Re: [Qemu-devel] [PATCH 2 of 3] Optionally link against libuuid if present
Quoted 8 lines · Alexander Graf
On Jan 20, 2008, at 5:37 PM, Filip Navara wrote:
The specific VMware backdoor call isn't implemented, but the framework is there and it wouldn't be hard to add support for it. The BIOS can fallback to some "reasonable" value if the backdoor isn't available.
Quoted 8 lines
+
memset(bios_uuid, 0, 16);This value? Why not put something more "reasonable" in there? Does a uuid have to meet specific criteria (checksums)? If not, why not simply put something like "QEMU" in here? If I remember correctly OSX needs a value in the uuid or it fails to boot, so it might be a good idea to give it something better than an empty string.
Yes, this value. All zeroes means that UUID is not present in the system. The value has to follow the criteria of SMBIOS specification, section 3.3.2.1, namely it has to be formatted like this:
DWORD time_low;
WORD time_mid;
WORD time_high_and_version;
BYTE clock_seq_hi_and_reserved;
BYTE clock_seq_low;
BYTE node_number[6];
I doubt any driver really checks the value, except maybe for the all-0xFF or all-0x00 case.
- Filip
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [PATCH 2 of 3] Optionally link against libuuid if present
In reply to Ryan HarperHi Ryan & others,
now I have been holding a SMBIOS patch on my hard disk for way to long it seems. I used a different approach from yours, so I decided to publish it for review or further ideas. What I did was to modify the bochs bios to produce the SMBIOS tables and I get the UUID using VMware backdoor port from the virtual machine.
Attached are just the changed files, creating a patch will take a while because it's against VERY OLD version of the sources.
Oh, it also contains ACPI patch for the processor descriptors which was needed for some Windows versions and Darwin. Similar patch was used in KVM before, but this one dynamically detects the number of CPUs.
Best regards,
Filip Navara
Quoted 148 lines · Ryan Harper
3 files changed, 38 insertions(+), 2 deletions(-) Makefile.target | 5 ++++- configure | 26 ++++++++++++++++++++++++++ smbios.c | 9 ++++++++-# HG changeset patch
# User Ryan Harper <[email protected]>
# Date 1197402122 21600
# Node ID115f40a4994be1d5b44ef193b3ccbe8e26410eef# Parente81bef5fa072360d12b87b3237b7d3f72c9b9784Optionally link against libuuid if present.This patch makes libuuid optional. If not detected, SMBIOS tables will use
canned UUID.Signed-off-by Ryan Harper <[email protected]>diff -r
e81bef5fa072-r115f40a4994bMakefile.targetMakefile.target Tue Dec 11 13:42:02 2007 -0600 renamed from Makefile.target Tue Dec 11 13:42:01 2007 -0600 +4
-1@@ -402,6 +402,9 @@ VL_OBJS+=block-raw.o ifdef CONFIG_ALSA LIBS += -lasound +endif +ifdef CONFIG_UUID +LIBS += -luuid endif ifdef CONFIG_DSOUND LIBS += -lole32 -ldxguid@@ -535,7 +538,7 @@ ifndef CONFIG_DARWIN ifndef CONFIG_DARWIN ifndef CONFIG_WIN32 ifndef CONFIG_SOLARIS -VL_LIBS+=-lutil -luuid +VL_LIBS+=-lutil endif endif endifdiff -r
e81bef5fa072-r115f40a4994bconfigureconfigure Tue Dec 11 13:42:02 2007 -0600 renamed from configure Tue Dec 11 13:42:01 2007 -0600 +26
-0@@ -89,6 +89,7 @@ dsound="no" dsound="no" coreaudio="no" alsa="no" +uuid="yes" fmod="no" fmod_lib="" fmod_inc=""@@ -260,6 +261,8 @@ for opt do ;; --enable-alsa) alsa="yes" ;; + --enable-uuid) uuid="yes" + ;; --enable-dsound) dsound="yes" ;; --enable-fmod) fmod="yes"@@ -404,6 +407,7 @@ echo " --enable-adlib enable echo " --enable-adlib enable Adlib emulation" echo " --enable-coreaudio enable Coreaudio audio driver" echo " --enable-alsa enable ALSA audio driver" +echo " --enable-uuid enable UUID generation for machines" echo " --enable-fmod enable FMOD audio driver" echo " --enable-dsound enable DirectSound audio driver" echo " --disable-vnc-tls disable TLS encryption for VNC server"@@ -662,6 +666,23 @@ EOF fi fi +########################################## +# uuid library +if test "$uuid" = "yes" ; then + cat > $TMPC << EOF +#include <uuid/uuid.h> +int main(void) { uuid_t u; return 0; } +EOF + if $cc -o $TMPE $TMPC -luuid 2> /dev/null ; then + : + else + echo + echo "Error: Could not find uuid" + echo "Make sure to have the uuid libs and headers installed." + echo + exit 1 + fi +fi # Check if tools are available to build documentation. if [ -x "`which texi2html 2>/dev/null`" ] && \ [ -x "`which pod2man 2>/dev/null`" ]; then@@ -716,6 +737,7 @@ echo "Adlib support $adlib" echo "Adlib support $adlib" echo "CoreAudio support $coreaudio" echo "ALSA support $alsa" +echo "UUID support $uuid" echo "DSound support $dsound" if test "$fmod" = "yes"; then if test -z $fmod_lib || test -z $fmod_inc; then@@ -901,6 +923,10 @@ if test "$alsa" = "yes" ; then echo "CONFIG_ALSA=yes" >> $config_mak echo "#define CONFIG_ALSA 1" >> $config_h fi +if test "$uuid" = "yes" ; then + echo "CONFIG_UUID=yes" >> $config_mak + echo "#define CONFIG_UUID 1" >> $config_h +fi if test "$dsound" = "yes" ; then echo "CONFIG_DSOUND=yes" >> $config_mak echo "#define CONFIG_DSOUND 1" >> $config_hdiff -r
e81bef5fa072-r115f40a4994bsmbios.csmbios.c Tue Dec 11 13:42:02 2007 -0600 renamed from smbios.c Tue Dec 11 13:42:01 2007 -0600 +8
-1@@ -25,11 +25,14 @@ #include <stdio.h> #include <stdint.h> #include <string.h> -#include <uuid/uuid.h> #include "hw/hw.h" #include "sysemu.h" #include "smbios_types.h" #include "config-host.h" + +#ifdef CONFIG_UUID +#include <uuid/uuid.h> +#endif /* Write a two-character hex representation of 'byte' to digits[]. Pre-condition: sizeof(digits) >= 2 */@@ -489,9 +492,13 @@ load_smbios_tables(uint8_t *entry, uint8 int len; uint32_t major_version = 0; uint32_t minor_version = 9; +#ifdef CONFIG_UUID uuid_t uuid; uuid_generate(uuid); +#else + uint8_t uuid[16] = "QEMUQEMUQEMUQEMU"; +#endif len = write_smbios_tables(entry, table, phys_table_start, smp_cpus, (ram_size >> 20),
PATCH 1/1 Add -uuid command line flag
In reply to a message not in the archive3 files changed, 61 insertions(+), 6 deletions(-) smbios.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ sysemu.h | 1 + vl.c | 8 ++++++++
# HG changeset patch
# User Ryan Harper <ryanh-r/[email protected]> # Date 1197402122 21600
# Node ID f1372e77455459b3e21ae908bb56cd43356159fd
# Parent 115f40a4994be1d5b44ef193b3ccbe8e26410eef
Add -uuid command line flag
This patch allows users to specify a uuid. If no uuid is specified, then one is generated.
Now supports -uuid both with and without libuuid Moved some includes into hw/hw.h and sysemh.h Reduced the number of CONFIG_UUID defines
smbios.c +52 -6
@@ -32,11 +32,47 @@#ifdef CONFIG_UUID #include <uuid/uuid.h> -#endif + +static int qemu_uuid_parse (const char *in,uint8_t *uu) +{ +if (uuid_parse (in, *((uuid_t *)uu)) <0 ) +return -1 ; + +return 0 ; +} + +#define qemu_uuid_generate (x) (uuid_generate(*((uuid_t *)x))) + +#else +#define UUID2 "%02x%02x" +#define UUID4 "%02x%02x%02x%02x" +#define UUID6 "%02x%02x%02x%02x%02x%02x" +#define UUID_FMT UUID4"-"UUID2"-"UUID2"-"UUID2"-"UUID6 + +static int qemu_uuid_parse (const char *in,uint8_t *uu) +{ +unsigned int u[16 ]; +int rv, i; + +/* NB: sscanf requires %x format to store values in unsigned int */ + rv =sscanf (in,UUID_FMT , u, u+1 , u+2 , u+3 , u+4 , u+5 , u+6 , u+7 , u+8 , + u+9 , u+10 , u+11 , u+12 , u+13 , u+14 , u+15 ); + +if (rv !=16 ) +return -1 ; + +for (i=0 ; i<16 ; i++) + uu[i] = (uint8_t )u[i]; + +return 0 ; +} +#define qemu_uuid_generate (x) (memcpy(x, "QEMUQEMUQEMUQEMU", 16)) + +#endif /* CONFIG_UUID */ /* Write a two-character hex representation of 'byte' to digits[]. Pre-condition: sizeof(digits) >= 2 */ -void +static void byte_to_hex (char *digits,uint8_t byte) {uint8_t nybbel = byte >>4 ;
@@ -493,12 +529,22 @@ load_smbios_tables(uint8_t *entry, uint8uint32_t major_version =0 ;uint32_t minor_version =9 ;#ifdef CONFIG_UUID -uuid_t uuid; - -uuid_generate (uuid); +uuid_t u; +uint8_t *uuid = (char *)&u;#else -uint8_t uuid[16 ] ="QEMUQEMUQEMUQEMU" ; +uint8_t uuid[16 ];#endif + +/* parse user-specified uuid if present */ +if (qemu_uuid !=NULL ) { +if (qemu_uuid_parse (qemu_uuid, uuid) <0 ) { +fprintf (stderr,"SMBIOS: Could not parse user UUID" +" string, check format.\n" ); +return -1 ; + } + }else { +qemu_uuid_generate (uuid); + } len = write_smbios_tables(entry, table, phys_table_start, smp_cpus, (ram_size >> 20),
sysemu.h +1 -0
@@ -90,6 +90,7 @@ extern int autostart;extern int autostart;extern int old_param;extern const char *bootp_filename; +extern const char *qemu_uuid;#ifdef USE_KQEMU
vl.c +8 -0
@@ -138,6 +138,7 @@ int inet_aton(const char *cp, struct in_#else #define SMBD_COMMAND "/usr/sbin/smbd"#endif +const char *qemu_uuid;//#define DEBUG_UNUSED_IOPORT //#define DEBUG_IOPORT
@@ -7545,6 +7546,8 @@ 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" +"-uuid %%08x-%%04x-%%04x-%%04x-%%012x\n" +" specify machine UUID\n" #ifndef _WIN32"-daemonize daemonize QEMU after initializing\n" #endif
@@ -7647,6 +7650,7 @@ enum { QEMU_OPTION_vnc, QEMU_OPTION_no_acpi, QEMU_OPTION_no_reboot, + QEMU_OPTION_uuid, QEMU_OPTION_show_cursor, QEMU_OPTION_daemonize, QEMU_OPTION_option_rom,
@@ -7742,6 +7746,7 @@ const QEMUOption qemu_options[] = { { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice }, { "smp", HAS_ARG, QEMU_OPTION_smp }, { "vnc", HAS_ARG, QEMU_OPTION_vnc }, + { "uuid", HAS_ARG, QEMU_OPTION_uuid },/* temporary options */ { "usb", 0, QEMU_OPTION_usb },
@@ -8527,6 +8532,9 @@ int main(int argc, char **argv)case QEMU_OPTION_daemonize: daemonize =1 ;break ; +case QEMU_OPTION_uuid: + qemu_uuid = optarg; +break ;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