Add SMBIOS/DMI table generation to PC machine
PATCH 1/1 Add -uuid command line flag
In reply to Ryan Harper2 files changed, 29 insertions(+), 1 deletion(-) smbios.c | 12 +++++++++++- vl.c | 18 ++++++++++++++++++
# HG changeset patch
# User Ryan Harper <[email protected]>
# 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.
smbios.c +11 -1
@@ -32,6 +32,7 @@#ifdef CONFIG_UUID #include <uuid/uuid.h> +extern const char *qemu_uuid;#endif 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" ;#endif
vl.c +18 -0
@@ -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" );
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.
7 files changed, 821 insertions(+), 5 deletions(-) Makefile.target | 9 configure | 26 ++ hw/pc.c | 47 ++++ smbios.c | 540 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- smbios_types.h | 182 ++++++++++++++++++ sysemu.h | 4 vl.c | 18 +
PATCH 1/1 export SMBIOS/DMI tables to PC machines
5 files changed, 754 insertions(+), 2 deletions(-) Makefile.target | 4 hw/pc.c | 47 ++++ smbios.c | 519 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ smbios_types.h | 182 +++++++++++++++++++ sysemu.h | 4
# HG changeset patch
# User Ryan Harper <[email protected]>
# Date 1197058922 21600
# Node ID 37bf559ffcf74bfe62ec038c5818e4cf29b817f5 # 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.
Makefile.target +2 -2
@@ -396,7 +396,7 @@ endif endif # must use static linking to avoid leaving stuff in virtual address space -VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o +VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o smbios.o # XXX: suppress QEMU_TOOL tests VL_OBJS+=block-raw.o
@@ -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 +47 -0
59 lines not on this page · raw message
smbios.c new file +519 -0
519 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 ;
PATCH 1/1 Optionally link against libuuid if present
In reply to Ryan Harper3 files changed, 38 insertions(+), 2 deletions(-) Makefile.target | 5 ++++- configure | 26 ++++++++++++++++++++++++++ smbios.c | 9 ++++++++-
# HG changeset patch
# User Ryan Harper <[email protected]>
# Date 1197058922 21600
# Node ID 3470dd05f46cc9f14c3fc9561d06031a4bc0ce7a # Parent 37bf559ffcf74bfe62ec038c5818e4cf29b817f5 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 CPUState *first_cpu;
@@ -491,9 +494,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),