Third shot at adding IPMI to qemu
PATCH 6/18 qemu-char: Fix a race reporting opens and closes
In reply to [email protected]From: Corey Minyard <[email protected]>
When an open event is reported, it is done through a bh. But close events are reported immediately. So if an open event is in the bh and a close occurs, an extraneous open happens, which can confuse a user.
To fix this, this patch sets the "opened" flag immediately instead of in the bh handler and checks to make sure the opened flag is set before reporting an open event.
This also modifies the spice code to call qemu_chr_generic_open to report an open, to keep things consistent.
--- qemu-char.c | 18 ++++++++++++++++-- spice-qemu-char.c | 7 +++++-- 2 files changed, 21 insertions(+), 4 deletions(-)
qemu-char.c +16 -2
@@ -111,10 +111,13 @@ void qemu_chr_be_event(CharDriverState *s, int event)/* Keep track if the char device is open */ switch (event) {case CHR_EVENT_OPENED : +/* +* See the comment in qemu_chr_generic_open_bh() for why +* 's->opened = 1' is not here. +*/ if (s->recon_timer) {qemu_del_timer (s->recon_timer); } - s->opened =1 ;break ;case CHR_EVENT_CLOSED :if (s->recon_timer) {
@@ -134,13 +137,24 @@ void qemu_chr_be_event(CharDriverState *s, int event)static void qemu_chr_generic_open_bh (void *opaque) {CharDriverState *s = opaque; -qemu_chr_be_event (s,CHR_EVENT_OPENED ); +/* +* Since the "close" event doesn't go through a bh, there is a +* possible race condition if a close comes in after an open, but +* the open is in the bh queue. So we double-check here, and we +* set opened in qemu_chr_generic_open() instead of +* qemu_chr_be_event(). +*/ +if (s->opened) { +qemu_chr_be_event (s,CHR_EVENT_OPENED ); + }qemu_bh_delete (s->bh); s->bh =NULL ; }void qemu_chr_generic_open (CharDriverState *s) { +/* See the comment in qemu_chr_generic_open_bh() for why this is here */ + s->opened =1 ;if (s->bh ==NULL ) { s->bh =qemu_bh_new (qemu_chr_generic_open_bh, s);qemu_bh_schedule (s->bh);
spice-qemu-char.c +5 -2
@@ -93,8 +93,11 @@ static void vmc_state(SpiceCharDeviceInstance *sin, int connected)return ; } -qemu_chr_be_event (scd->chr, - connected ?CHR_EVENT_OPENED :CHR_EVENT_CLOSED ); +if (connected) { +qemu_chr_generic_open (scd->chr); + }else { +qemu_chr_be_event (scd->chr,CHR_EVENT_CLOSED ); + } }static SpiceCharDeviceInterface vmc_interface = {
Signature · 1 line
1.7.4.1
PATCH 4/18 qemu-char: Allocate CharDriverState in qemu_chr_new_from_opts
In reply to [email protected]From: Corey Minyard <[email protected]>
This allocates the CharDriverState structure in a more logical place. It reduces code size and it allows a coming option to automatically attempt to reconnect a chardev if the connection fails.
--- console.c | 6 +--- console.h | 2 +- hw/baum.c | 6 +-- hw/baum.h | 2 +- hw/msmouse.c | 5 +-- hw/msmouse.h | 2 +- qemu-char.c | 93 +++++++++++++++++++++------------------------------- spice-qemu-char.c | 4 +-- ui/qemu-spice.h | 2 +- 9 files changed, 47 insertions(+), 75 deletions(-)
console.c +1 -5
@@ -1513,15 +1513,12 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds) chr->init (chr); } -CharDriverState *text_console_init (QemuOpts *opts) +CharDriverState *text_console_init (CharDriverState *chr,QemuOpts *opts) { -CharDriverState *chr;TextConsole *s;unsigned width;unsigned height; - chr =g_malloc0 (sizeof (CharDriverState)); - width =qemu_opt_get_number (opts,"width" ,0 );if (width ==0 ) width =qemu_opt_get_number (opts,"cols" ,0 ) *FONT_WIDTH ;
@@ -1537,7 +1534,6 @@ CharDriverState *text_console_init(QemuOpts *opts) }if (!s) { -g_free (chr);return NULL ; }
console.h +1 -1
@@ -359,7 +359,7 @@ void vga_hw_text_update(console_ch_t *chardata);int is_graphic_console (void );int is_fixedsize_console (void ); -CharDriverState *text_console_init (QemuOpts *opts); +CharDriverState *text_console_init (CharDriverState *chr,QemuOpts *opts);void text_consoles_set_display (DisplayState *ds);void console_select (unsigned int index);void console_color_init (DisplayState *ds);
hw/baum.c +2 -4
@@ -562,10 +562,9 @@ static void baum_close(struct CharDriverState *chr)g_free (baum); } -CharDriverState *chr_baum_init (QemuOpts *opts) +CharDriverState *chr_baum_init (CharDriverState *chr,QemuOpts *opts) {BaumDriverState *baum; -CharDriverState *chr;brlapi_handle_t *handle;#ifdef CONFIG_SDL SDL_SysWMinfo info;
@@ -573,7 +572,7 @@ CharDriverState *chr_baum_init(QemuOpts *opts)int tty; baum =g_malloc0 (sizeof (BaumDriverState)); - baum->chr = chr =g_malloc0 (sizeof (CharDriverState)); + baum->chr = chr; chr->opaque = baum; chr->chr_write = baum_write;
@@ -621,7 +620,6 @@ fail:brlapi__closeConnection (handle); fail_handle:g_free (handle); -g_free (chr);g_free (baum);return NULL ; }
hw/baum.h +1 -1
@@ -23,4 +23,4 @@*/ /* char device */ -CharDriverState *chr_baum_init (QemuOpts *opts); +CharDriverState *chr_baum_init (CharDriverState *chr,QemuOpts *opts);
hw/msmouse.c +1 -4
@@ -64,11 +64,8 @@ static void msmouse_chr_close (struct CharDriverState *chr)g_free (chr); } -CharDriverState *qemu_chr_open_msmouse (QemuOpts *opts) +CharDriverState *qemu_chr_open_msmouse (CharDriverState *chr,QemuOpts *opts) { -CharDriverState *chr; - - chr =g_malloc0 (sizeof (CharDriverState)); chr->chr_write = msmouse_chr_write; chr->chr_close = msmouse_chr_close;
hw/msmouse.h +1 -1
@@ -1,2 +1,2 @@/* msmouse.c */ -CharDriverState *qemu_chr_open_msmouse (QemuOpts *opts); +CharDriverState *qemu_chr_open_msmouse (CharDriverState *chr,QemuOpts *opts);
qemu-char.c +38 -55
305 lines not on this page · raw message
spice-qemu-char.c +1 -3
@@ -188,9 +188,8 @@ static void print_allowed_subtypes(void)fprintf (stderr,"\n" ); } -CharDriverState *qemu_chr_open_spice (QemuOpts *opts) +CharDriverState *qemu_chr_open_spice (CharDriverState *chr,QemuOpts *opts) { -CharDriverState *chr;SpiceCharDriver *s;const char * name =qemu_opt_get (opts,"name" );uint32_t debug =qemu_opt_get_number (opts,"debug" ,0 );
@@ -214,7 +213,6 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)return NULL ; } - chr =g_malloc0 (sizeof (CharDriverState)); s =g_malloc0 (sizeof (SpiceCharDriver)); s->chr = chr; s->debug = debug;
ui/qemu-spice.h +1 -1
@@ -45,7 +45,7 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,void do_info_spice_print (Monitor *mon,const QObject *data);void do_info_spice (Monitor *mon,QObject **ret_data); -CharDriverState *qemu_chr_open_spice (QemuOpts *opts); +CharDriverState *qemu_chr_open_spice (CharDriverState *chr,QemuOpts *opts);#else /* CONFIG_SPICE */ #include "monitor.h"
Signature · 1 line
1.7.4.1
PATCH 10/18 qom: release previous object when setting
In reply to [email protected]From: Corey Minyard <[email protected]>
When setting an object, if you don't release the previous object that was there, it may become unusable. This change allows a chardev to be removed from one object's properties and added to another's.
--- qom/object.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
qom/object.c +3 -0
@@ -731,6 +731,9 @@ void object_property_set(Object *obj, Visitor *v, const char *name,if (!prop->set) {error_set (errp,QERR_PERMISSION_DENIED ); }else { +if (prop->release) { + prop->release (obj, name, prop->opaque); + } prop->set (obj, v, prop->opaque, name, errp); } }
Signature · 1 line
1.7.4.1
PATCH 1/18 smbios: Add a function to directly add an entry
In reply to [email protected]From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
--- hw/smbios.c | 27 +++++++++++++++++++++++++++ hw/smbios.h | 15 ++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)
hw/smbios.c +27 -0
@@ -178,6 +178,33 @@ static void smbios_build_type_1_fields(const char *t) strlen(buf) + 1, buf); } +int smbios_table_entry_add (struct smbios_structure_header *entry) +{ +struct smbios_table *table; +struct smbios_structure_header *header; +unsigned int size = entry->length; + +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + +sizeof (*table) + size); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); + + header = (struct smbios_structure_header *)(table->data); +memcpy (header, entry, size); + +smbios_check_collision (header->type,SMBIOS_TABLE_ENTRY ); + + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +return 0 ; +} +int smbios_entry_add (const char *t) {char buf[1024 ];
hw/smbios.h +8 -7
@@ -13,21 +13,22 @@* */ +/* This goes at the beginning of every SMBIOS structure. */ +struct smbios_structure_header { +uint8_t type; +uint8_t length; +uint16_t handle; +}QEMU_PACKED ; +int smbios_entry_add (const char *t);void smbios_add_field (int type,int offset,int len,void *data);uint8_t *smbios_get_table (size_t *length); +int smbios_table_entry_add (struct smbios_structure_header *entry);/* * SMBIOS spec defined tables */ -/* This goes at the beginning of every SMBIOS structure. */ -struct smbios_structure_header { -uint8_t type; -uint8_t length; -uint16_t handle; -}QEMU_PACKED ; -/* SMBIOS type 0 - BIOS Information */ struct smbios_type_0 {struct smbios_structure_header header;
Signature · 1 line
1.7.4.1
PATCH 7/18 qemu-char: remove free of chr from win_stdio_close
In reply to [email protected]From: Corey Minyard <[email protected]>
This will result in a double free on close, because it's freed in qemu_chr_delete() right after calling the close function.
--- qemu-char.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
qemu-char.c +0 -1
@@ -1949,7 +1949,6 @@ static void win_stdio_close(CharDriverState *chr) }g_free (chr->opaque); -g_free (chr); stdio_nb_clients--; }
Signature · 1 line
1.7.4.1
PATCH 9/18 qdev: Add a pre-firmware init capability
In reply to [email protected]From: Corey Minyard <[email protected]>
Some devices may need to do some firmware-type initialization before the firmware itself is initialized. For instance, any device that adds SMBIOS table entries (like IPMI) will need to do that before the BIOS is initialized.
So add a list of devices that get initialized before the firmware initialization. Since those devices get removed from the list so they don't get initialized twice, convert the qemu_opt_foreach() to use the safe list traversal.
--- hw/pc.c | 2 ++ hw/qdev-monitor.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 3 +++ qemu-option.c | 4 ++-- 4 files changed, 59 insertions(+), 2 deletions(-)
hw/pc.c +2 -0
@@ -1010,6 +1010,8 @@ void *pc_bios_init(const char *kernel_filename,void *fw_cfg;int linux_boot, i; +qdev_prefw_init_check (); +/* Initialize PC system firmware */ pc_system_firmware_init (rom_memory);
hw/qdev-monitor.c +52 -0
58 lines not on this page · raw message
hw/qdev.h +3 -0
@@ -167,6 +167,9 @@ int qdev_simple_unplug_cb(DeviceState *dev);void qdev_machine_creation_done (void );bool qdev_machine_modified (void ); +void qdev_add_prefw_init (const char *name); +void qdev_prefw_init_check (void ); +qemu_irq qdev_get_gpio_in (DeviceState *dev,int n);void qdev_connect_gpio_out (DeviceState *dev,int n,qemu_irq pin);
qemu-option.c +2 -2
@@ -709,10 +709,10 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)int qemu_opt_foreach (QemuOpts *opts,qemu_opt_loopfunc func,void *opaque,int abort_on_failure) { -QemuOpt *opt; +QemuOpt *opt, *next_opt;int rc =0 ; - QTAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH_SAFE(opt, &opts->head, next, next_opt) { rc =func (opt->name, opt->str, opaque);if (abort_on_failure && rc !=0 )break ;
Signature · 1 line
1.7.4.1
Ok, everything passes through checkpatch without an error now. I have added some tests to verify basic operation of the device, and I've hacked in some documentation, though I'm not sure if it's in the proper location, as I never got a response to my questions about it.
I would have liked to add tests for the watchdog timer, but there doesn't appear to be a way to intercept resets or NMIs in the test framework.
-corey
PATCH 11/18 Add a base IPMI interface
From: Corey Minyard <[email protected]>
Add the basic IPMI types and infrastructure to QEMU. Low-level interfaces and simulation interfaces will register with this; it's kind of the go-between to tie them together.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 2 + hw/ipmi.c | 167 +++++++++++++++++++++++++ hw/ipmi.h | 236 ++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 2 + 6 files changed, 409 insertions(+), 0 deletions(-) create mode 100644 hw/ipmi.c create mode 100644 hw/ipmi.h
default-configs/i386-softmmu.mak +1 -0
@@ -7,6 +7,7 @@ CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -7,6 +7,7 @@ CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +2 -0
@@ -20,6 +20,8 @@ hw-obj-$(CONFIG_M48T59) += m48t59.o hw-obj-$(CONFIG_ESCC) += escc.o hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o +hw-obj-$(CONFIG_IPMI) += ipmi.o + hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
hw/ipmi.c new file +167 -0
167 lines not on this page · raw message
hw/ipmi.h new file +236 -0
236 lines not on this page · raw message
qemu-doc.texi +2 -0
@@ -195,6 +195,8 @@ PCI and ISA network adapters @item Serial ports @item +IPMI BMC, either and internal or external one +@item Creative SoundBlaster 16 sound card @item ENSONIQ AudioPCI ES1370 sound card
Signature · 1 line
1.7.4.1
PATCH 3/18 vl: Move init_timer_alarm() earlier
In reply to [email protected]From: Corey Minyard <[email protected]>
The timers may be used in initialization, so move them earlier so they are ready. A reconnect options will be added to qemu-char, and it uses a timer, but the timer alarm wasn't initialized yet.
--- vl.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
vl.c +5 -5
@@ -3245,6 +3245,11 @@ int main(int argc, char **argv, char **envp)qemu_set_version (machine->hw_version); } +if (init_timer_alarm () <0 ) { +fprintf (stderr,"could not initialize alarm timer\n" ); +exit (1 ); + } +/* Init CPU def lists, based on config * - Must be called after all the qemu_read_config_file() calls * - Must be called before list_cpus()
@@ -3422,11 +3427,6 @@ int main(int argc, char **argv, char **envp)os_set_line_buffering (); -if (init_timer_alarm () <0 ) { -fprintf (stderr,"could not initialize alarm timer\n" ); -exit (1 ); - } -#ifdef CONFIG_SPICE /* spice needs the timers to be initialized by this point */ qemu_spice_init ();
Signature · 1 line
1.7.4.1
PATCH 5/18 qemu-char: Allow a chardev to reconnect if disconnected
In reply to [email protected]From: Corey Minyard <[email protected]>
Allow a socket that connects to reconnect on a periodic basis if it fails to connect at startup or if the connection drops while in use.
--- qemu-char.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++---- qemu-char.h | 4 +++ qemu-config.c | 3 ++ qemu-options.hx | 11 +++++++-- 4 files changed, 72 insertions(+), 8 deletions(-)
qemu-char.c +57 -5
@@ -111,9 +111,17 @@ void qemu_chr_be_event(CharDriverState *s, int event)/* Keep track if the char device is open */ switch (event) {case CHR_EVENT_OPENED : +if (s->recon_timer) { +qemu_del_timer (s->recon_timer); + } s->opened =1 ;break ;case CHR_EVENT_CLOSED : +if (s->recon_timer) { +qemu_mod_timer (s->recon_timer, + (qemu_get_clock_ns (vm_clock) + + (s->recon_time *1000000000ULL ))); + } s->opened =0 ;break ; }
@@ -2726,6 +2734,20 @@ static const struct {#endif }; +static void recon_timeout (void *opaque) +{ +CharDriverState *chr = opaque; + +if (chr->opened) { +return ; + } + +qemu_mod_timer (chr->recon_timer, + (qemu_get_clock_ns (vm_clock) + + (chr->recon_time *1000000000ULL ))); + backend_table[chr->backend].open (chr, chr->opts); +} +CharDriverState *qemu_chr_new_from_opts (QemuOpts *opts,void (*init)(struct CharDriverState *s)) {
@@ -2753,11 +2775,37 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, } chr =g_malloc0 (sizeof (CharDriverState)); + + chr->backend = i; + chr->recon_time =qemu_opt_get_number (opts,"reconnect" ,0 ); +if (chr->recon_time) { +if (strcmp (qemu_opt_get (opts,"backend" ),"socket" ) !=0 ) { +g_free (chr); +fprintf (stderr,"chardev: reconnect only supported on sockets\n" ); +return NULL ; + } +if (qemu_opt_get_bool (opts,"server" ,0 )) { +g_free (chr); +fprintf (stderr,"chardev: server device cannot reconnect\n" ); +return NULL ; + } + chr->opts = opts; + chr->recon_timer =qemu_new_timer_ns (vm_clock, recon_timeout, chr); + +/* Make sure it connects in time. */ +qemu_mod_timer (chr->recon_timer, + (qemu_get_clock_ns (vm_clock) + + (chr->recon_time *1000000000ULL ))); + } +if (!backend_table[i].open (chr, opts)) { -g_free (chr); -fprintf (stderr,"chardev: opening backend \"%s\" failed\n" , -qemu_opt_get (opts,"backend" )); -return NULL ; +if (!chr->recon_time) { +/* Reconnect is not enabled, give up */ +g_free (chr); +fprintf (stderr,"chardev: opening backend \"%s\" failed\n" , +qemu_opt_get (opts,"backend" )); +return NULL ; + } }if (!chr->filename)
@@ -2827,8 +2875,12 @@ void qemu_chr_fe_close(struct CharDriverState *chr)void qemu_chr_delete (CharDriverState *chr) {QTAILQ_REMOVE (&chardevs, chr, next); -if (chr->chr_close) +if (chr->chr_close) { chr->chr_close (chr); + } +if (chr->recon_timer) { +qemu_free_timer (chr->recon_timer); + }g_free (chr->filename);g_free (chr->label);g_free (chr);
qemu-char.h +4 -0
@@ -75,6 +75,10 @@ struct CharDriverState {int opened;int avail_connections;QTAILQ_ENTRY (CharDriverState) next; +int backend; +QemuOpts *opts; +QEMUTimer *recon_timer; +uint64_t recon_time; };/**
qemu-config.c +3 -0
@@ -209,6 +209,9 @@ static QemuOptsList qemu_chardev_opts = { .name = "mux", .type = QEMU_OPT_BOOL, },{ + .name = "reconnect", + .type = QEMU_OPT_NUMBER, + },{ .name = "signal", .type = QEMU_OPT_BOOL, },{
qemu-options.hx +8 -3
@@ -1620,8 +1620,9 @@ DEFHEADING(Character device options:) DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, "-chardev null,id=id[,mux=on|off]\n" "-chardev socket,id=id[,host=host],port=host[,to=to][,ipv4][,ipv6][,nodelay]\n" - " [,server][,nowait][,telnet][,mux=on|off] (tcp)\n" - "-chardev socket,id=id,path=path[,server][,nowait][,telnet],[mux=on|off] (unix)\n" + " [,server][,nowait][,telnet][,mux=on|off][,reconnect=seconds] (tcp)\n" + "-chardev socket,id=id,path=path[,server][,nowait][,telnet][,mux=on|off]\n" + " [,reconnect=seconds] (unix)\n" "-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]\n" " [,localport=localport][,ipv4][,ipv6][,mux=on|off]\n" "-chardev msmouse,id=id[,mux=on|off]\n"
@@ -1690,7 +1691,7 @@ Options to each backend are described below. A void device. This device will not emit any data, and will drop any data it receives. The null backend does not take any options. -@item -chardev socket ,id=@var{id} [@var{TCP options} or @var{unix options}] [,server] [,nowait] [,telnet] +@item -chardev socket ,id=@var{id} [@var{TCP options} or @var{unix options}] [,server] [,nowait] [,telnet] [,reconnect=@var{seconds}] Create a two-way stream socket, which can be either a TCP or a unix socket. A unix socket will be created if @option{path} is specified. Behaviour is
@@ -1704,6 +1705,10 @@ connect to a listening socket. @option{telnet} specifies that traffic on the socket should interpret telnet escape sequences. +@option{reconnect} specifies that if the socket does not come up at startup, +or if the socket is closed for some reason (like the other end exited), +wait the given number of seconds and attempt to reconnect. + TCP and unix socket options are given below: @table @option
Signature · 1 line
1.7.4.1
PATCH 2/18 pc: move SMBIOS setup to after device init
In reply to [email protected]From: Corey Minyard <[email protected]>
Setting up the firmware interface for the SMBIOS table needs to be done later in the process, after device initialization, so that devices can add entries to the table.
--- hw/pc.c | 24 ++++++++++++++---------- hw/pc.h | 11 ++++++----- hw/pc_piix.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 19 deletions(-)
hw/pc.c +14 -10
@@ -970,21 +970,13 @@ void pc_cpus_init(const char *cpu_model) } } -void *pc_memory_init (MemoryRegion *system_memory, -const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename, +void pc_memory_init (MemoryRegion *system_memory,ram_addr_t below_4g_mem_size,ram_addr_t above_4g_mem_size, -MemoryRegion *rom_memory,MemoryRegion **ram_memory) { -int linux_boot, i; -MemoryRegion *ram, *option_rom_mr; +MemoryRegion *ram;MemoryRegion *ram_below_4g, *ram_above_4g; -void *fw_cfg; - - linux_boot = (kernel_filename !=NULL );/* Allocate RAM. We allocate it as a single memory region and use * aliases to address portions of it, mostly for backwards compatibility
@@ -1006,7 +998,17 @@ void *pc_memory_init(MemoryRegion *system_memory,memory_region_add_subregion (system_memory,0x100000000ULL , ram_above_4g); } +} +void *pc_bios_init (const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +ram_addr_t below_4g_mem_size, +MemoryRegion *rom_memory) +{ +MemoryRegion *option_rom_mr; +void *fw_cfg; +int linux_boot, i;/* Initialize PC system firmware */ pc_system_firmware_init (rom_memory);
@@ -1019,6 +1021,8 @@ void *pc_memory_init(MemoryRegion *system_memory, option_rom_mr, 1); + linux_boot = (kernel_filename !=NULL ); + fw_cfg =bochs_bios_init ();rom_set_fw (fw_cfg);
hw/pc.h +6 -5
@@ -106,14 +106,15 @@ void pc_register_ferr_irq(qemu_irq irq);void pc_acpi_smi_interrupt (void *opaque,int irq,int level);void pc_cpus_init (const char *cpu_model); -void *pc_memory_init (MemoryRegion *system_memory, -const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename, +void pc_memory_init (MemoryRegion *system_memory,ram_addr_t below_4g_mem_size,ram_addr_t above_4g_mem_size, -MemoryRegion *rom_memory,MemoryRegion **ram_memory); +void *pc_bios_init (const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +ram_addr_t below_4g_mem_size, +MemoryRegion *rom_memory);qemu_irq *pc_allocate_cpu_irq (void );DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus); void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
hw/pc_piix.c +8 -4
@@ -178,10 +178,8 @@ static void pc_init1(MemoryRegion *system_memory,/* allocate ram and load rom/bios */ if (!xen_enabled ()) { - fw_cfg =pc_memory_init (system_memory, - kernel_filename, kernel_cmdline, initrd_filename, - below_4g_mem_size, above_4g_mem_size, - pci_enabled ? rom_memory : system_memory, &ram_memory); +pc_memory_init (system_memory, below_4g_mem_size, + above_4g_mem_size, &ram_memory); } gsi_state =g_malloc0 (sizeof (*gsi_state));
@@ -275,6 +273,12 @@ static void pc_init1(MemoryRegion *system_memory,pci_create_simple (pci_bus, piix3_devfn +2 ,"piix3-usb-uhci" ); } +if (!xen_enabled ()) { + fw_cfg =pc_bios_init (kernel_filename, kernel_cmdline, + initrd_filename, below_4g_mem_size, + pci_enabled ? rom_memory : system_memory); + } +if (pci_enabled && acpi_enabled) {i2c_bus *smbus;
Signature · 1 line
1.7.4.1
PATCH 14/18 IPMI: Add a BT low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the BT hardware interface for IPMI.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi_bt.c | 360 ++++++++++++++++++++++++++++++++++++ 4 files changed, 363 insertions(+), 0 deletions(-) create mode 100644 hw/ipmi_bt.c
default-configs/i386-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y +CONFIG_IPMI_BT=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y +CONFIG_IPMI_BT=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -23,6 +23,7 @@ hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o hw-obj-$(CONFIG_IPMI) += ipmi.o hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o +hw-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_bt.c new file +360 -0
360 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 18/18 IPMI: Add documentation.
In reply to [email protected]From: Corey Minyard <[email protected]>
Add some basic documentation for the IPMI device.
--- qemu-options.hx | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-)
qemu-options.hx +35 -0
@@ -558,6 +558,41 @@ Add device @var{driver}. @var{prop}=@var{value} sets driver properties. Valid properties depend on the driver. To get help on possible drivers and properties, use @code{-device ?} and @code{-device @var{driver},?}. + +Some drivers are: +@item -device isa-ipmi[,interface=kcs|bt][,iobase=@var{val}][,irq=@var{val}][,slave_addr=@var{val}][,chardev=name] + +Add an IPMI device. This also adds a corresponding SMBIOS entry to the +SMBIOS tables for x86. The following options are handled: +@table @option +@item interface=kcs|bt +Define the interface type to use. Currently the IPMI-defined KCS and +BT interfaces are handled. The default is KCS. +@item iobase=@var{val} +Define the I/O address of the interface. The default is 0xca0 for KCS +and 0xe4 for BT. +@item irq=@var{val} +Define the interrupt to use. The default is 5. To disable interrupts, +set this to 0. +@item slave_addr=@var{val} +The IPMI slave address to use for the BMC. The default is 0x20. +@item chardev=name +If a chardev is not specified, the IPMI driver uses a built-in baseboard +management controller (BMC) simulator. It provides a basic BMC with a +watchdog timer and associated sensor. + +If a chardev is specified, A connection is made to an external BMC +simulator. If you do this, it is strongly recommended that you use +the "reconnect=" chardev option to reconnect to the simulator if the +connection is lost. Note that if this is not used carefully, it can +be a security issue, as the interface has the ability to send resets, +NMIs, and power off the VM. It's best if QEMU makes a connection to +an external simulator running on a secure port on localhost, so +neither the simulator nor QEMU is exposed to any outside network. + +See the "lanserv/README.vm" file in the OpenIPMI library for more +details on the external interface. +@end table ETEXI DEFHEADING()
Signature · 1 line
1.7.4.1
PATCH 12/18 IPMI: Add a PC ISA type structure
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/isa_ipmi.c | 181 ++++++++++++++++++++++++++++++++++++ hw/smbios.h | 12 +++ 5 files changed, 196 insertions(+), 0 deletions(-) create mode 100644 hw/isa_ipmi.c
default-configs/i386-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -21,6 +21,7 @@ hw-obj-$(CONFIG_ESCC) += escc.o hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o hw-obj-$(CONFIG_IPMI) += ipmi.o +hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/isa_ipmi.c new file +181 -0
181 lines not on this page · raw message
hw/smbios.h +12 -0
@@ -155,6 +155,18 @@ struct smbios_type_32 {uint8_t boot_status; }QEMU_PACKED ; +/* SMBIOS type 38 - IPMI Device Information */ +struct smbios_type_38 { +struct smbios_structure_header header; +uint8_t interface_type; +uint8_t ipmi_version; +uint8_t i2c_slave_addr; +uint8_t nv_storage_dev_addr; +uint64_t base_addr; +uint8_t base_addr_mod_and_irq_info; +uint8_t interrupt_number; +}QEMU_PACKED ; +/* SMBIOS type 127 -- End-of-table */ struct smbios_type_127 {struct smbios_structure_header header;
Signature · 1 line
1.7.4.1
PATCH 17/18 IPMI: Add tests
In reply to [email protected]From: Corey Minyard <[email protected]>
Test the KCS interface with a local BMC and a BT interface with an external BMC.
--- tests/Makefile | 4 + tests/ipmi-test-bt.c | 440 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/ipmi-test-kcs.c | 295 +++++++++++++++++++++++++++++++++ 3 files changed, 739 insertions(+), 0 deletions(-) create mode 100644 tests/ipmi-test-bt.c create mode 100644 tests/ipmi-test-kcs.c
tests/Makefile +4 -0
@@ -22,6 +22,8 @@ check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh # really in libqtest, not in the testcases themselves. check-qtest-i386-y = tests/fdc-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-test-kcs$(EXESUF) +check-qtest-i386-y += tests/ipmi-test-bt$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) check-qtest-sparc-y = tests/m48t59-test$(EXESUF) check-qtest-sparc64-y = tests/m48t59-test$(EXESUF)
@@ -70,6 +72,8 @@ tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marsh tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(test-qapi-obj-y) tests/rtc-test$(EXESUF): tests/rtc-test.o $(trace-obj-y) +tests/ipmi-test-kcs$(EXESUF): tests/ipmi-test-kcs.o $(trace-obj-y) +tests/ipmi-test-bt$(EXESUF): tests/ipmi-test-bt.o $(trace-obj-y) tests/m48t59-test$(EXESUF): tests/m48t59-test.o $(trace-obj-y) tests/fdc-test$(EXESUF): tests/fdc-test.o tests/libqtest.o $(trace-obj-y)
tests/ipmi-test-bt.c new file +440 -0
440 lines not on this page · raw message
tests/ipmi-test-kcs.c new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 8/18 qemu-char: Close fd at end of file
In reply to [email protected]From: Corey Minyard <[email protected]>
The chardev backends that used qemu_chr_open_fd did not get their file descriptors closed at end of file or when the chardev was closed. This could result in a file descriptor leak.
--- qemu-char.c | 31 +++++++++++++++++++++++++------ 1 files changed, 25 insertions(+), 6 deletions(-)
qemu-char.c +25 -6
@@ -566,6 +566,7 @@ static int stdio_nb_clients;typedef struct {int fd_in, fd_out;int max_size; +int close_fds_on_close; }FDCharDriver ;
@@ -584,6 +585,20 @@ static int fd_chr_read_poll(void *opaque)return s->max_size; } +static void fd_close_fds (FDCharDriver *s) +{ +if (!s->close_fds_on_close) { +return ; + } + +if ((s->fd_out != s->fd_in) && (s->fd_out !=-1 )) { +close (s->fd_out); + } + s->fd_out =-1 ; +close (s->fd_in); + s->fd_in =-1 ; +} +static void fd_chr_read (void *opaque) {CharDriverState *chr = opaque;
@@ -600,6 +615,7 @@ static void fd_chr_read(void *opaque)if (size ==0 ) {/* FD has been closed. Remove it from the active list. */ qemu_set_fd_handler2 (s->fd_in,NULL ,NULL ,NULL ,NULL ); +fd_close_fds (s);qemu_chr_be_event (chr,CHR_EVENT_CLOSED );return ; }
@@ -629,6 +645,7 @@ static void fd_chr_close(struct CharDriverState *chr)if (display_type ==DT_NOGRAPHIC && s->fd_in ==0 ) { }else {qemu_set_fd_handler2 (s->fd_in,NULL ,NULL ,NULL ,NULL ); +fd_close_fds (s); } }
@@ -638,13 +655,15 @@ static void fd_chr_close(struct CharDriverState *chr)/* open a character device to a unix fd */ static CharDriverState *qemu_chr_open_fd (CharDriverState *chr, -int fd_in,int fd_out) +int fd_in,int fd_out, +int close_fds_on_close) {FDCharDriver *s; s =g_malloc0 (sizeof (FDCharDriver)); s->fd_in = fd_in; s->fd_out = fd_out; + s->close_fds_on_close = close_fds_on_close; chr->opaque = s; chr->chr_write = fd_chr_write; chr->chr_update_read_handler = fd_chr_update_read_handler;
@@ -665,7 +684,7 @@ static CharDriverState *qemu_chr_open_file_out(CharDriverState *chr,if (fd_out <0 ) {return NULL ; } -return qemu_chr_open_fd (chr,-1 , fd_out); +return qemu_chr_open_fd (chr,-1 , fd_out,1 ); }static CharDriverState *qemu_chr_open_pipe (CharDriverState *chr,QemuOpts *opts)
@@ -693,7 +712,7 @@ static CharDriverState *qemu_chr_open_pipe(CharDriverState *chr, QemuOpts *opts)return NULL ; } } -return qemu_chr_open_fd (chr, fd_in, fd_out); +return qemu_chr_open_fd (chr, fd_in, fd_out,1 ); }
@@ -797,7 +816,7 @@ static CharDriverState *qemu_chr_open_stdio(CharDriverState *chr,atexit (term_exit); } -qemu_chr_open_fd (chr,0 ,1 ); +qemu_chr_open_fd (chr,0 ,1 ,0 ); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio;qemu_set_fd_handler2 (0 , stdio_read_poll, stdio_read,NULL , chr);
@@ -1242,7 +1261,7 @@ static CharDriverState *qemu_chr_open_tty(CharDriverState *chr, QemuOpts *opts)return NULL ; }tty_serial_init (fd,115200 ,'N' ,8 ,1 ); -qemu_chr_open_fd (chr, fd, fd); +qemu_chr_open_fd (chr, fd, fd,1 ); chr->chr_ioctl = tty_serial_ioctl; chr->chr_close = qemu_chr_close_tty;return chr;
@@ -2316,7 +2335,7 @@ static void tcp_chr_read(void *opaque)CharDriverState *qemu_chr_open_eventfd (int eventfd) {CharDriverState *chr =g_malloc0 (sizeof (CharDriverState)); -return qemu_chr_open_fd (chr, eventfd, eventfd); +return qemu_chr_open_fd (chr, eventfd, eventfd,0 ); }#endif
Signature · 1 line
1.7.4.1
PATCH 13/18 IPMI: Add a KCS low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the KCS hardware interface.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi_kcs.c | 337 ++++++++++++++++++++++++++++++++++++ 4 files changed, 340 insertions(+), 0 deletions(-) create mode 100644 hw/ipmi_kcs.c
default-configs/i386-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y +CONFIG_IPMI_KCS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_ISA_IPMI=y +CONFIG_IPMI_KCS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -22,6 +22,7 @@ hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o hw-obj-$(CONFIG_IPMI) += ipmi.o hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o +hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_kcs.c new file +337 -0
337 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 16/18 IPMI: Add an external connection simulation interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This adds an interface for IPMI that connects to a remote BMC over a chardev (generally a TCP socket). The OpenIPMI lanserv simulator describes this interface, see that for interface details.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi_extern.c | 473 ++++++++++++++++++++++++++++++++++++ 4 files changed, 476 insertions(+), 0 deletions(-) create mode 100644 hw/ipmi_extern.c
default-configs/i386-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -25,6 +25,7 @@ hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o hw-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o hw-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o +hw-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_extern.c new file +473 -0
473 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 15/18 IPMI: Add a local BMC simulation
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides a minimal local BMC, basically enough to comply with the spec and provide a complete watchdog timer (including a sensor, SDR, and event).
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi_sim.c | 1547 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1550 insertions(+), 0 deletions(-) create mode 100644 hw/ipmi_sim.c
default-configs/i386-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_IPMI=y CONFIG_ISA_IPMI=y CONFIG_IPMI_KCS=y CONFIG_IPMI_BT=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -24,6 +24,7 @@ hw-obj-$(CONFIG_IPMI) += ipmi.o hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o hw-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o +hw-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_sim.c new file +1547 -0
1,547 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Il 19/07/2012 20:53, [email protected] ha scritto:
Quoted 8 lines
Ok, everything passes through checkpatch without an error now. I have added some tests to verify basic operation of the device, and I've hacked in some documentation, though I'm not sure if it's in the proper location, as I never got a response to my questions about it.
I would have liked to add tests for the watchdog timer, but there doesn't appear to be a way to intercept resets or NMIs in the test framework.
I reviewed the basic QOM plumbing and it looks ok.
Paolo
I haven't heard anything on this. Any comments or movement on this set of patches?
Thanks,
-corey
Quoted 12 lines · On 07/19/2012 01:53 PM, [email protected] wrote:
Ok, everything passes through checkpatch without an error now. I have added some tests to verify basic operation of the device, and I've hacked in some documentation, though I'm not sure if it's in the proper location, as I never got a response to my questions about it.
I would have liked to add tests for the watchdog timer, but there doesn't appear to be a way to intercept resets or NMIs in the test framework.
-corey
Re: [Qemu-devel] [PATCH 12/18] IPMI: Add a PC ISA type structure
In reply to [email protected]Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 112 lines
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/isa_ipmi.c | 181 ++++++++++++++++++++++++++++++++++++ hw/smbios.h | 12 +++ 5 files changed, 196 insertions(+), 0 deletions(-) create mode 100644 hw/isa_ipmi.cdefault-configs/i386-softmmu.mak +1
-0@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=ydefault-configs/x86_64-softmmu.mak +1
-0@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=yhw/Makefile.objs +1
-0@@ -21,6 +21,7 @@ hw-obj-$(CONFIG_ESCC) += escc.o hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o hw-obj-$(CONFIG_IPMI) += ipmi.o +hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o hw-obj-$(CONFIG_SERIAL) += serial.o hw-obj-$(CONFIG_PARALLEL) += parallel.ohw/isa_ipmi.c new file +55
-0@@ -0,0 +1,181 @@ +/* +* QEMU ISA IPMI KCS emulation +* +* Copyright (c) 2012 Corey Minyard, MontaVista Software, LLC +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#include "hw.h" +#include "isa.h" +#include "pc.h" +#include "qemu-timer.h" +#include "qemu-char.h" +#include "sysemu.h" +#include "smbios.h" +#include "ipmi.h" + + +typedef struct ISAIPMIDevice { +ISADevice dev; +char *interface; +uint32_t iobase; +uint32_t isairq; +uint8_t slave_addr; +CharDriverState *chr; +IPMIInterface *intf; +}ISAIPMIDevice ; + +static int ipmi_isa_initfn (ISADevice *dev) +{ +ISAIPMIDevice *isa =DO_UPCAST (ISAIPMIDevice, dev, dev); +struct smbios_type_38 smb38; +char typename[20 ]; +Object *intfobj; +IPMIInterface *intf; +IPMIInterfaceClass *intfk; +Object *bmcobj; +IPMIBmc *bmc; +int rc; +Error *errp =NULL ;
hw/isa_ipmi.c line 65
Quoted 10 lines
hw/isa_ipmi.c new file +10
-0+ +if (!isa->interface) { + isa->interface =g_strdup ("kcs" ); + } + +if (isa->chr) { + bmcobj =object_new ("ipmi-bmc-extern" ); + }else { + bmcobj =object_new ("ipmi-bmc-sim" ); + }
Please use TYPE_ constants instead of hardcoding strings.
hw/isa_ipmi.c line 66
Quoted 1 line
hw/isa_ipmi.c new file +1
-0+ bmc =DO_UPCAST (IPMIBmc, parent_obj, bmcobj);
Please use QOM cast macros rather than qdev's DO_UPCAST().
Quoted 70 lines
hw/isa_ipmi.c new file +70
-0+ bmc->chr = isa->chr; +snprintf (typename,sizeof (typename),"ipmi-interface-%s" , isa->interface); + intfobj =object_new (typename); + intf =DO_UPCAST (IPMIInterface, parent_obj, intfobj); + bmc->intf = intf; + intf->bmc = bmc; + intf->io_base = isa->iobase; + intf->slave_addr = isa->slave_addr; + rc =ipmi_interface_init (intf); +if (rc) { +return rc; + } + rc =ipmi_bmc_init (bmc); +if (rc) { +return rc; + } + +/* These may be set by the interface. */ + isa->iobase = intf->io_base; + isa->slave_addr = intf->slave_addr; + +if (isa->isairq !=0 ) { +isa_init_irq (dev, &intf->irq, isa->isairq); + intf->use_irq =1 ; + } + + isa->intf = intf; +object_property_add_child (OBJECT (isa),"intf" ,OBJECT (intf), &errp); +if (error_is_set (&errp)) { +fprintf (stderr,"%s\n" ,error_get_pretty (errp)); +return 1 ; + } +object_property_add_child (OBJECT (isa),"bmc" ,OBJECT (bmc), &errp); +if (error_is_set (&errp)) { +fprintf (stderr,"%s\n" ,error_get_pretty (errp)); +return 1 ; + } + +qdev_set_legacy_instance_id (&dev->qdev, intf->io_base, intf->io_length); + +isa_register_ioport (dev, &intf->io, intf->io_base); + + intfk =IPMI_INTERFACE_GET_CLASS (intf); + + smb38.header.type =38 ; + smb38.header.length =sizeof (smb38); + smb38.header.handle =0x3000 ; + smb38.interface_type = intfk->smbios_type; + smb38.ipmi_version =0x20 ; + smb38.i2c_slave_addr = intf->slave_addr; + smb38.nv_storage_dev_addr =0 ; + +/* or 1 to set it to I/O space */ + smb38.base_addr = intf->io_base |1 ; + +/* 1-byte boundaries, addr bit0=0, level triggered irq */ + smb38.base_addr_mod_and_irq_info =1 ; + smb38.interrupt_number = isa->isairq; +smbios_table_entry_add ((struct smbios_structure_header *) &smb38); + +return 0 ; +} + +static void ipmi_isa_reset (DeviceState *qdev) +{ +ISAIPMIDevice *isa =DO_UPCAST (ISAIPMIDevice, dev.qdev, qdev); + +ipmi_interface_reset (isa->intf); +} +
hw/isa_ipmi.c line 146
Quoted 10 lines
hw/isa_ipmi.c new file +10
-0+static Property ipmi_isa_properties[] = { +DEFINE_PROP_STRING ("interface" , ISAIPMIDevice, interface), +DEFINE_PROP_HEX32 ("iobase" , ISAIPMIDevice, iobase,0 ), +DEFINE_PROP_UINT32 ("irq" , ISAIPMIDevice, isairq,5 ), +DEFINE_PROP_UINT8 ("slave_addr" , ISAIPMIDevice, slave_addr,0 ), +DEFINE_PROP_CHR ("chardev" , ISAIPMIDevice, chr), +DEFINE_PROP_END_OF_LIST (), +}; + +#if 0 /* FIXME */
Fix this? x86 machines should definitely remain migratable.
Quoted 12 lines
hw/isa_ipmi.c new file +12
-0+static const VMStateDescription vmstate_isa_ipmi = { + .name ="isa-ipmi" , + .version_id =3 , + .minimum_version_id =3 , + .fields = (VMStateField []) { +/* FIXME - fill this in */ +VMSTATE_END_OF_LIST () + } +}; +#endif + +static void ipmi_isa_class_initfn (ObjectClass *klass,void *data)
hw/isa_ipmi.c line 168
Quoted 10 lines
hw/isa_ipmi.c new file +10
-0+{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); + ic->init = ipmi_isa_initfn; + dc->reset = ipmi_isa_reset; +/* dc->vmsd = &vmstate_isa_ipmi; FIXME */ + dc->props = ipmi_isa_properties; +} + +static TypeInfo ipmi_isa_info = {
static const please.
hw/isa_ipmi.c line 169
Quoted 1 line
hw/isa_ipmi.c new file +1
-0+ .name = "isa-ipmi",
Where is this used? Should probably be TYPE_..., too.
Andreas
Quoted 36 lines
hw/isa_ipmi.c new file +12
-0+ .parent = TYPE_ISA_DEVICE, + .instance_size = sizeof(ISAIPMIDevice), + .class_init = ipmi_isa_class_initfn, +}; + +static void ipmi_register_types (void ) +{ +type_register_static (&ipmi_isa_info); +qdev_add_prefw_init ("isa-ipmi" ); +} + +type_init (ipmi_register_types)hw/smbios.h +12
-0@@ -155,6 +155,18 @@ struct smbios_type_32 {uint8_t boot_status; }QEMU_PACKED ; +/* SMBIOS type 38 - IPMI Device Information */ +struct smbios_type_38 { +struct smbios_structure_header header; +uint8_t interface_type; +uint8_t ipmi_version; +uint8_t i2c_slave_addr; +uint8_t nv_storage_dev_addr; +uint64_t base_addr; +uint8_t base_addr_mod_and_irq_info; +uint8_t interrupt_number; +}QEMU_PACKED ; +/* SMBIOS type 127 -- End-of-table */ struct smbios_type_127 {struct smbios_structure_header header;
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 10/18] qom: release previous object when setting
In reply to [email protected]Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 9 lines
From: Corey Minyard <[email protected]>
When setting an object, if you don't release the previous object that was there, it may become unusable. This change allows a chardev to be removed from one object's properties and added to another's.
Signed-off-by Corey Minyard <[email protected]>Acked-by Paolo Bonzini <[email protected]>
Anthony, this looks like a valid and generic QOM memory leak fix to me. Suggesting to cherry-pick this patch to master and stable-1.1.
Andreas
Quoted 19 lines
--- qom/object.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)qom/object.c +3
-0@@ -731,6 +731,9 @@ void object_property_set(Object *obj, Visitor *v, const char *name,if (!prop->set) {error_set (errp,QERR_PERMISSION_DENIED ); }else { +if (prop->release) { + prop->release (obj, name, prop->opaque); + } prop->set (obj, v, prop->opaque, name, errp); } }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 30.07.2012 15:34, schrieb Corey Minyard:
Quoted 1 line
I haven't heard anything on this.
FWIW you did hear from Paolo. :)
Quoted 2 lines
Any comments or movement on this set
of patches?
For a third shot, you should've used --subject-prefix="PATCH v3" so that each patch becomes distinguishable on Patchwork, in inbox searches, etc.
http://wiki.qemu.org/Contribute/SubmitAPatch
I've started commenting on some non-functional code issues that you should review throughout the series. It seems in lack of how-tos you have oriented yourself on some "old-style" devices, would be nice to update that for v4 as anti-typo measure and to increase chances of people copying a modern device. ;)
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 09/18] qdev: Add a pre-firmware init capability
In reply to [email protected]Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 7 lines
From: Corey Minyard <[email protected]>
Some devices may need to do some firmware-type initialization before the firmware itself is initialized. For instance, any device that adds SMBIOS table entries (like IPMI) will need to do that before the BIOS is initialized.
Quoted 6 lines
So add a list of devices that get initialized before the firmware initialization. Since those devices get removed from the list so they don't get initialized twice, convert the
qemu_opt_foreach()to use the safe list traversal.Signed-off-by Corey Minyard <[email protected]>
I'm not so thrilled by this interface...
This doesn't seem to have anything to do with the monitor, and prefw_list doesn't really indicate it's a list of type names either, nor does qdev_add_prefw_init() precisely indicate what it's doing.
Then, your implementation of qdev_prefw_init_check() is based on re-iterating over -device options. That's not safe since there's other ways to create a device - object_new() et al. and soon a qom_create QMP command.
So what exactly is the problem you are trying to solve here? What needs to happen before this step and until when does this need to happen? For example, is this an ordering problem between device creation and MemoryRegion setup in the machine?
My thinking is that if this is a generic problem unrelated to QOM realize / DeviceState::init we could provide a new DeviceState::init_firmware hook for that purpose and call it recursively on all devices. If however this is just some PC quirk, we should not model this at qdev level but locally in hw/pc.c, then you have more degrees of freedom in designing some PC-internal API.
Regards,
Andreas
Quoted 115 lines
--- hw/pc.c | 2 ++ hw/qdev-monitor.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 3 +++ qemu-option.c | 4 ++-- 4 files changed, 59 insertions(+), 2 deletions(-)hw/pc.c +2
-0@@ -1010,6 +1010,8 @@ void *pc_bios_init(const char *kernel_filename,void *fw_cfg;int linux_boot, i; +qdev_prefw_init_check (); +/* Initialize PC system firmware */ pc_system_firmware_init (rom_memory);hw/qdev-monitor.c +52
-0@@ -486,6 +486,58 @@ DeviceState *qdev_device_add(QemuOpts *opts)return qdev; } +/* +* Some devices may need to be initialized before the firmware is +* initialized, so they may add information to the firmware +* structures. +*/ +typedef struct prefw_list { +const char *name; +struct prefw_list *next; +}prefw_list ; + +prefw_list *prefw_init; + +void qdev_add_prefw_init (const char *name) +{ +prefw_list *e =g_malloc (sizeof (*e)); + e->name = name; + e->next = prefw_init; + prefw_init = e; +} + +static int prefw_check_func (QemuOpts *opts,void *opaque) +{ +DeviceState *dev; +const char *driver; +prefw_list *e; + + driver =qemu_opt_get (opts,"driver" ); +if (!driver) { +return 0 ; + } + +for (e = prefw_init; e; e = e->next) { +if (strcmp (driver, e->name) ==0 ) { + dev =qdev_device_add (opts); +if (!dev) { +return -1 ; + } +qemu_opts_del (opts); +break ; + } + } +return 0 ; +} + +void qdev_prefw_init_check (void ) +{ +/* init generic devices */ +if (qemu_opts_foreach (qemu_find_opts ("device" ), + prefw_check_func,NULL ,1 ) !=0 ) { +exit (1 ); + } +}#define qdev_printf (fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)static void qbus_print (Monitor *mon,BusState *bus,int indent);hw/qdev.h +3
-0@@ -167,6 +167,9 @@ int qdev_simple_unplug_cb(DeviceState *dev);void qdev_machine_creation_done (void );bool qdev_machine_modified (void ); +void qdev_add_prefw_init (const char *name); +void qdev_prefw_init_check (void ); +qemu_irq qdev_get_gpio_in (DeviceState *dev,int n);void qdev_connect_gpio_out (DeviceState *dev,int n,qemu_irq pin);qemu-option.c +2
-2@@ -709,10 +709,10 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)int qemu_opt_foreach (QemuOpts *opts,qemu_opt_loopfunc func,void *opaque,int abort_on_failure) { -QemuOpt *opt; +QemuOpt *opt, *next_opt;int rc =0 ; - QTAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH_SAFE(opt, &opts->head, next, next_opt) { rc =func (opt->name, opt->str, opaque);if (abort_on_failure && rc !=0 )break ;
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 3 lines · Andreas Färber
Am 30.07.2012 15:34, schrieb Corey Minyard:
Quoted 1 line
I haven't heard anything on this.
FWIW you did hear from Paolo. :)
Yes, I did, I apologize. I think I meant to say "recently".
Quoted 6 lines
Quoted 2 lines
Any comments or movement on this set
of patches?For a third shot, you should've used --subject-prefix="PATCH v3" so that each patch becomes distinguishable on Patchwork, in inbox searches, etc.
Ok.
Quoted 6 lines
I've started commenting on some non-functional code issues that you should review throughout the series. It seems in lack of how-tos you have oriented yourself on some "old-style" devices, would be nice to update that for v4 as anti-typo measure and to increase chances of people copying a modern device. ;)
Yes, I copied the serial driver, mostly, which has probably been around a while.
Thank you,
-corey
Re: [Qemu-devel] [PATCH 09/18] qdev: Add a pre-firmware init capability
In reply to Andreas FärberQuoted 8 lines · Andreas Färber
Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 7 lines
From: Corey Minyard <[email protected]>
Some devices may need to do some firmware-type initialization before the firmware itself is initialized. For instance, any device that adds SMBIOS table entries (like IPMI) will need to do that before the BIOS is initialized.
Quoted 7 lines
Quoted 6 lines
So add a list of devices that get initialized before the firmware initialization. Since those devices get removed from the list so they don't get initialized twice, convert the
qemu_opt_foreach()to use the safe list traversal.Signed-off-by Corey Minyard <[email protected]>I'm not so thrilled by this interface...
Actually, I'm not terribly thrilled by it, either, but I need something like it.
Quoted 15 lines
This doesn't seem to have anything to do with the monitor, and
prefw_listdoesn't really indicate it's a list of type names either, nor doesqdev_add_prefw_init()precisely indicate what it's doing.Then, your implementation of
qdev_prefw_init_check()is based on re-iterating over -device options. That's not safe since there's other ways to create a device -object_new()et al. and soon aqom_createQMP command.So what exactly is the problem you are trying to solve here? What needs to happen before this step and until when does this need to happen? For example, is this an ordering problem between device creation and MemoryRegion setup in the machine?
Quoted 6 lines
My thinking is that if this is a generic problem unrelated to QOM realize /
DeviceState::initwe could provide a newDeviceState::init_firmwarehook for that purpose and call it recursively on all devices. If however this is just some PC quirk, we should not model this at qdev level but locally inhw/pc.c, then you have more degrees of freedom in designing some PC-internal API.
The basic problem is that I need to do some level of initialization on the device, at least to determine the interface address, interrupt, etc., so the SMBIOS tables can be populated. I assume something similar will be required for OF if powerpc is ported, and perhaps for uboot type interfaces if those are ever ported.
The basic problem, I guess, is that the SMBIOS tables are fixed very early, before devices have initialized. If that could be moved later, or device initialization moved earlier, the problem would go away. But with the current design, I couldn't see an easy way to delay setting the SMBIOS tables that far. I delayed it as long as I could see to do it reasonably and then put the firmware init right before that.
Thanks,
-corey
Quoted 120 lines
Regards,
AndreasQuoted 115 lines
--- hw/pc.c | 2 ++ hw/qdev-monitor.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 3 +++ qemu-option.c | 4 ++-- 4 files changed, 59 insertions(+), 2 deletions(-)hw/pc.c +2
-0@@ -1010,6 +1010,8 @@ void *pc_bios_init(const char *kernel_filename,void *fw_cfg;int linux_boot, i; +qdev_prefw_init_check (); +/* Initialize PC system firmware */ pc_system_firmware_init (rom_memory);hw/qdev-monitor.c +52
-0@@ -486,6 +486,58 @@ DeviceState *qdev_device_add(QemuOpts *opts)return qdev; } +/* +* Some devices may need to be initialized before the firmware is +* initialized, so they may add information to the firmware +* structures. +*/ +typedef struct prefw_list { +const char *name; +struct prefw_list *next; +}prefw_list ; + +prefw_list *prefw_init; + +void qdev_add_prefw_init (const char *name) +{ +prefw_list *e =g_malloc (sizeof (*e)); + e->name = name; + e->next = prefw_init; + prefw_init = e; +} + +static int prefw_check_func (QemuOpts *opts,void *opaque) +{ +DeviceState *dev; +const char *driver; +prefw_list *e; + + driver =qemu_opt_get (opts,"driver" ); +if (!driver) { +return 0 ; + } + +for (e = prefw_init; e; e = e->next) { +if (strcmp (driver, e->name) ==0 ) { + dev =qdev_device_add (opts); +if (!dev) { +return -1 ; + } +qemu_opts_del (opts); +break ; + } + } +return 0 ; +} + +void qdev_prefw_init_check (void ) +{ +/* init generic devices */ +if (qemu_opts_foreach (qemu_find_opts ("device" ), + prefw_check_func,NULL ,1 ) !=0 ) { +exit (1 ); + } +}#define qdev_printf (fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)static void qbus_print (Monitor *mon,BusState *bus,int indent);hw/qdev.h +3
-0@@ -167,6 +167,9 @@ int qdev_simple_unplug_cb(DeviceState *dev);void qdev_machine_creation_done (void );bool qdev_machine_modified (void ); +void qdev_add_prefw_init (const char *name); +void qdev_prefw_init_check (void ); +qemu_irq qdev_get_gpio_in (DeviceState *dev,int n);void qdev_connect_gpio_out (DeviceState *dev,int n,qemu_irq pin);qemu-option.c +2
-2@@ -709,10 +709,10 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)int qemu_opt_foreach (QemuOpts *opts,qemu_opt_loopfunc func,void *opaque,int abort_on_failure) { -QemuOpt *opt; +QemuOpt *opt, *next_opt;int rc =0 ; - QTAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH_SAFE(opt, &opts->head, next, next_opt) { rc =func (opt->name, opt->str, opaque);if (abort_on_failure && rc !=0 )break ;
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
In reply to [email protected]Quoted 8 lines · [email protected] writes:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Signed-off-by Corey Minyard <[email protected]>
I don't expect that hardware ever adds SMBIOS entries. Rather, the BIOS adds the entries by probing the hardware.
So I think you should solve this in SeaBIOS, instead of trying to do it in QEMU. I think that also solves the problem you have with pre-firmware init.
Regards,
Anthony Liguori
Quoted 79 lines
--- hw/smbios.c | 27 +++++++++++++++++++++++++++ hw/smbios.h | 15 ++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)hw/smbios.c +27
-0@@ -178,6 +178,33 @@ static void smbios_build_type_1_fields(const char *t) strlen(buf) + 1, buf); } +int smbios_table_entry_add (struct smbios_structure_header *entry) +{ +struct smbios_table *table; +struct smbios_structure_header *header; +unsigned int size = entry->length; + +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + +sizeof (*table) + size); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); + + header = (struct smbios_structure_header *)(table->data); +memcpy (header, entry, size); + +smbios_check_collision (header->type,SMBIOS_TABLE_ENTRY ); + + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +return 0 ; +} +int smbios_entry_add (const char *t) {char buf[1024 ];hw/smbios.h +8
-7@@ -13,21 +13,22 @@* */ +/* This goes at the beginning of every SMBIOS structure. */ +struct smbios_structure_header { +uint8_t type; +uint8_t length; +uint16_t handle; +}QEMU_PACKED ; +int smbios_entry_add (const char *t);void smbios_add_field (int type,int offset,int len,void *data);uint8_t *smbios_get_table (size_t *length); +int smbios_table_entry_add (struct smbios_structure_header *entry);/* * SMBIOS spec defined tables */ -/* This goes at the beginning of every SMBIOS structure. */ -struct smbios_structure_header { -uint8_t type; -uint8_t length; -uint16_t handle; -}QEMU_PACKED ; -/* SMBIOS type 0 - BIOS Information */ struct smbios_type_0 {struct smbios_structure_header header;Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 09/18] qdev: Add a pre-firmware init capability
In reply to [email protected]Quoted 7 lines · [email protected] writes:
From: Corey Minyard <[email protected]>
Some devices may need to do some firmware-type initialization before the firmware itself is initialized. For instance, any device that adds SMBIOS table entries (like IPMI) will need to do that before the BIOS is initialized.
Quoted 6 lines
So add a list of devices that get initialized before the firmware initialization. Since those devices get removed from the list so they don't get initialized twice, convert the
qemu_opt_foreach()to use the safe list traversal.Signed-off-by Corey Minyard <[email protected]>
This should go away if you move the SMBIOS changes to BIOS.
Regards,
Anthony Liguori
Quoted 116 lines
--- hw/pc.c | 2 ++ hw/qdev-monitor.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 3 +++ qemu-option.c | 4 ++-- 4 files changed, 59 insertions(+), 2 deletions(-)hw/pc.c +2
-0@@ -1010,6 +1010,8 @@ void *pc_bios_init(const char *kernel_filename,void *fw_cfg;int linux_boot, i; +qdev_prefw_init_check (); +/* Initialize PC system firmware */ pc_system_firmware_init (rom_memory);hw/qdev-monitor.c +52
-0@@ -486,6 +486,58 @@ DeviceState *qdev_device_add(QemuOpts *opts)return qdev; } +/* +* Some devices may need to be initialized before the firmware is +* initialized, so they may add information to the firmware +* structures. +*/ +typedef struct prefw_list { +const char *name; +struct prefw_list *next; +}prefw_list ; + +prefw_list *prefw_init; + +void qdev_add_prefw_init (const char *name) +{ +prefw_list *e =g_malloc (sizeof (*e)); + e->name = name; + e->next = prefw_init; + prefw_init = e; +} + +static int prefw_check_func (QemuOpts *opts,void *opaque) +{ +DeviceState *dev; +const char *driver; +prefw_list *e; + + driver =qemu_opt_get (opts,"driver" ); +if (!driver) { +return 0 ; + } + +for (e = prefw_init; e; e = e->next) { +if (strcmp (driver, e->name) ==0 ) { + dev =qdev_device_add (opts); +if (!dev) { +return -1 ; + } +qemu_opts_del (opts); +break ; + } + } +return 0 ; +} + +void qdev_prefw_init_check (void ) +{ +/* init generic devices */ +if (qemu_opts_foreach (qemu_find_opts ("device" ), + prefw_check_func,NULL ,1 ) !=0 ) { +exit (1 ); + } +}#define qdev_printf (fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)static void qbus_print (Monitor *mon,BusState *bus,int indent);hw/qdev.h +3
-0@@ -167,6 +167,9 @@ int qdev_simple_unplug_cb(DeviceState *dev);void qdev_machine_creation_done (void );bool qdev_machine_modified (void ); +void qdev_add_prefw_init (const char *name); +void qdev_prefw_init_check (void ); +qemu_irq qdev_get_gpio_in (DeviceState *dev,int n);void qdev_connect_gpio_out (DeviceState *dev,int n,qemu_irq pin);qemu-option.c +2
-2@@ -709,10 +709,10 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)int qemu_opt_foreach (QemuOpts *opts,qemu_opt_loopfunc func,void *opaque,int abort_on_failure) { -QemuOpt *opt; +QemuOpt *opt, *next_opt;int rc =0 ; - QTAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH_SAFE(opt, &opts->head, next, next_opt) { rc =func (opt->name, opt->str, opaque);if (abort_on_failure && rc !=0 )break ;Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
In reply to Anthony LiguoriQuoted 4 lines · Anthony Liguori
Quoted 2 lines · [email protected] writes:
From: Corey Minyard <[email protected]>
Quoted 8 lines
Quoted 6 lines
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Signed-off-by Corey Minyard <[email protected]>I don't expect that hardware ever adds SMBIOS entries. Rather, the BIOS adds the entries by probing the hardware.
Well, memory entries are added by QEMU, why not let the BIOS probe for that? Plus, I really doubt that BIOSes on real systems probe for this. I'd guess they are hard-coded.
Quoted 4 lines
So I think you should solve this in SeaBIOS, instead of trying to do it in QEMU. I think that also solves the problem you have with pre-firmware init.
The user can pass the I/O base and IRQ values in on the QEMU command line, and they can be arbitrary values. The BIOS is not going to be able to probe for those.
-corey
Re: [Qemu-devel] [PATCH 12/18] IPMI: Add a PC ISA type structure
In reply to Andreas FärberQuoted 15 lines · Andreas Färber
Am 19.07.2012 20:53, schrieb [email protected]:
hw/isa_ipmi.c line 146
Quoted 13 lines
From: Corey Minyard <[email protected]>
hw/isa_ipmi.c new file +11
-0+ +static Property ipmi_isa_properties[] = { +DEFINE_PROP_STRING ("interface" , ISAIPMIDevice, interface), +DEFINE_PROP_HEX32 ("iobase" , ISAIPMIDevice, iobase,0 ), +DEFINE_PROP_UINT32 ("irq" , ISAIPMIDevice, isairq,5 ), +DEFINE_PROP_UINT8 ("slave_addr" , ISAIPMIDevice, slave_addr,0 ), +DEFINE_PROP_CHR ("chardev" , ISAIPMIDevice, chr), +DEFINE_PROP_END_OF_LIST (), +}; + +#if 0 /* FIXME */ Fix this? x86 machines should definitely remain migratable.
Yeah, I need to fix that so it works. I'll definitely get that in before the next iteration.
Quoted 24 lines
Quoted 12 lines
hw/isa_ipmi.c new file +12
-0+static const VMStateDescription vmstate_isa_ipmi = { + .name ="isa-ipmi" , + .version_id =3 , + .minimum_version_id =3 , + .fields = (VMStateField []) { +/* FIXME - fill this in */ +VMSTATE_END_OF_LIST () + } +}; +#endif + +static void ipmi_isa_class_initfn (ObjectClass *klass,void *data)hw/isa_ipmi.c line 168
Quoted 10 lines
hw/isa_ipmi.c new file +10
-0+{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISADeviceClass *ic =ISA_DEVICE_CLASS (klass); + ic->init = ipmi_isa_initfn; + dc->reset = ipmi_isa_reset; +/* dc->vmsd = &vmstate_isa_ipmi; FIXME */ + dc->props = ipmi_isa_properties; +} + +static TypeInfo ipmi_isa_info = {static const please.
Quoted 2 lines
Quoted 1 line
+ .name = "isa-ipmi",
Where is this used? Should probably be
TYPE_..., too.
That's what the user specified on the -device line. Does it need to be referenced someplace else?
Thanks,
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
In reply to Corey MinyardQuoted 10 lines · Corey Minyard
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · [email protected] writes:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>I don't expect that hardware ever adds SMBIOS entries. Rather, the BIOS adds the entries by probing the hardware.
Well, memory entries are added by QEMU, why not let the BIOS probe for that?
QEMU doesn't add any entries by default. SeaBIOS owns SMBIOS. QEMU uses a backchannel to hand SeaBIOS tables that SeaBIOS can then expose. The reason we use a table based interface is because type 0 and type 1 tables can have vendor extensions that are in a vendor specific format.
But SeaBIOS unquestionably owns SMBIOS generation.
Quoted 2 lines
Plus, I really doubt that BIOSes on real systems probe for this.
I'd guess they are hard-coded.
I think you'd be surprised how little is hard coded on modern BIOSes.
Quoted 7 lines
Quoted 3 lines
So I think you should solve this in SeaBIOS, instead of trying to do it in QEMU. I think that also solves the problem you have with pre-firmware init.
The user can pass the I/O base and IRQ values in on the QEMU command line, and they can be arbitrary values. The BIOS is not going to be able to probe for those.
Then pass the information that the BIOS needs through fw_cfg. That's what it's there for.
Regards,
Anthony Liguoi
Quoted 2 lines
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 28 lines · Anthony Liguori
Quoted 10 lines · Corey Minyard
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · [email protected] writes:
From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>I don't expect that hardware ever adds SMBIOS entries. Rather, the BIOS adds the entries by probing the hardware.
Well, memory entries are added by QEMU, why not let the BIOS probe for that?
QEMU doesn't add any entries by default. SeaBIOS owns SMBIOS. QEMU uses a backchannel to hand SeaBIOS tables that SeaBIOS can then expose. The reason we use a table based interface is because type 0 and type 1 tables can have vendor extensions that are in a vendor specific format.
But SeaBIOS unquestionably owns SMBIOS generation.
Quoted 2 lines
Plus, I really doubt that BIOSes on real systems probe for this.
I'd guess they are hard-coded.I think you'd be surprised how little is hard coded on modern BIOSes.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
So I think you should solve this in SeaBIOS, instead of trying to do it in QEMU. I think that also solves the problem you have with pre-firmware init.
The user can pass the I/O base and IRQ values in on the QEMU command line, and they can be arbitrary values. The BIOS is not going to be able to probe for those.
Then pass the information that the BIOS needs through
fw_cfg. That's what it's there for.
Ok, I understand. Thanks, I'll look at doing it this way.
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
In reply to Anthony LiguoriQuoted 18 lines · Anthony Liguori
Quoted 11 lines · Corey Minyard
Quoted 7 lines · Anthony Liguori
Quoted 4 lines · [email protected] writes:
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
I don't expect that hardware ever adds SMBIOS entries. Rather, the BIOS adds the entries by probing the hardware.
Well, memory entries are added by QEMU, why not let the BIOS probe for that?
QEMU doesn't add any entries by default. SeaBIOS owns SMBIOS. QEMU uses a backchannel to hand SeaBIOS tables that SeaBIOS can then expose. The reason we use a table based interface is because type 0 and type 1 tables can have vendor extensions that are in a vendor specific format.
But SeaBIOS unquestionably owns SMBIOS generation.
[...]
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
So I think you should solve this in SeaBIOS, instead of trying to do it in QEMU. I think that also solves the problem you have with pre-firmware init.
The user can pass the I/O base and IRQ values in on the QEMU command line, and they can be arbitrary values. The BIOS is not going to be able to probe for those.
Then pass the information that the BIOS needs through
fw_cfg. That's what it's there for.
This approach, unfortunately, leads to extra code and "double handling" of infomation.
The ultimate consumer of the data wants a binary struct which looks like:
struct smbios_type_38 {
struct smbios_structure_header header;
u8 interface_type;
u8 ipmi_version;
u8 i2c_slave_addr;
u8 nv_storage_dev_addr;
u64 base_addr;
u8 base_addr_mod_and_irq_info;
u8 interrupt_number;
};The proposed solution is to put the info in a binary struct which looks like:
struct ipmi_info {
u8 str_version;
u8 interface;
u8 reg_space;
u8 reg_spacing;
u8 slave_addr;
u8 irq;
u8 version;
u8 reserved1;
u64 base_addr;
} PACKED;and then have SeaBIOS translate the latter binary struct into the former. However, there's no compelling reason to introduce a new binary struct instead of using the industry standard binary struct.
I'd prefer QEMU to just pass the SMBIOS struct and let SeaBIOS pass it through to the OS. I also think the existing fw_cfg mechanism for passing SMBIOS tables should be used. I understand that this causes some contortions due to the current SMBIOS fw_cfg impementation in QEMU, but it seems wrong to introduce a new fw_cfg port that accomplishes the same goal as an existing fw_cfg port.
-Kevin
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 37 lines · Kevin O'Connor
This approach, unfortunately, leads to extra code and "double handling" of infomation.
The ultimate consumer of the data wants a binary struct which looks like:
struct smbios_type_38 { struct smbios_structure_header header; u8 interface_type; u8 ipmi_version; u8 i2c_slave_addr; u8 nv_storage_dev_addr; u64 base_addr; u8 base_addr_mod_and_irq_info; u8 interrupt_number; };The proposed solution is to put the info in a binary struct which looks like:
struct ipmi_info { u8 str_version; u8 interface; u8 reg_space; u8 reg_spacing; u8 slave_addr; u8 irq; u8 version; u8 reserved1; u64 base_addr; } PACKED;and then have SeaBIOS translate the latter binary struct into the former. However, there's no compelling reason to introduce a new binary struct instead of using the industry standard binary struct.
Quoted 6 lines
I'd prefer QEMU to just pass the SMBIOS struct and let SeaBIOS pass it through to the OS. I also think the existing
fw_cfgmechanism for passing SMBIOS tables should be used. I understand that this causes some contortions due to the current SMBIOSfw_cfgimpementation in QEMU, but it seems wrong to introduce a newfw_cfgport that accomplishes the same goal as an existingfw_cfgport.
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).
I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 45 lines · Corey Minyard
Quoted 37 lines · Kevin O'Connor
This approach, unfortunately, leads to extra code and "double handling" of infomation.
The ultimate consumer of the data wants a binary struct which looks like:
struct smbios_type_38 { struct smbios_structure_header header; u8 interface_type; u8 ipmi_version; u8 i2c_slave_addr; u8 nv_storage_dev_addr; u64 base_addr; u8 base_addr_mod_and_irq_info; u8 interrupt_number; };The proposed solution is to put the info in a binary struct which looks like:
struct ipmi_info { u8 str_version; u8 interface; u8 reg_space; u8 reg_spacing; u8 slave_addr; u8 irq; u8 version; u8 reserved1; u64 base_addr; } PACKED;and then have SeaBIOS translate the latter binary struct into the former. However, there's no compelling reason to introduce a new binary struct instead of using the industry standard binary struct.
Quoted 6 lines
I'd prefer QEMU to just pass the SMBIOS struct and let SeaBIOS pass it through to the OS. I also think the existing
fw_cfgmechanism for passing SMBIOS tables should be used. I understand that this causes some contortions due to the current SMBIOSfw_cfgimpementation in QEMU, but it seems wrong to introduce a newfw_cfgport that accomplishes the same goal as an existingfw_cfgport.
Quoted 6 lines
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).
I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
Okay, I was actually going to ask if there was an ACPI table for this.
Maybe this argues in favor of doing a fw_cfg interface?
Another question--is it really necessary for all of this to be user specified? Can't we just use a static SMBIOS/ACPI entry? Then SeaBIOS only needs to be concerned with whether or not an IPMI device exists.
Regards,
Anthony Liguori
Quoted 2 lines
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Corey Minyard
On 08/01/2012 08:15 PM, Kevin O'Connor wrote:
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
Quoted 7 lines
Okay, I was actually going to ask if there was an ACPI table for this.
Maybe this argues in favor of doing a
fw_cfginterface?Another question--is it really necessary for all of this to be user specified? Can't we just use a static SMBIOS/ACPI entry? Then SeaBIOS only needs to be concerned with whether or not an IPMI device exists.
That's a good question At least the interrupt is important for the user to be able to specify. The specific interface type may also be important if the user is trying to accomplish some specific emulation. Two other standard emulations exist, too, one in memory and one over I2C. I'd eventually like to add those, if for nothing else my ability to test the interfaces.
If the user is trying to emulate some specific machine, setting the address is also important, and I need to add the ability to specify register spacing and the address space. This will become more important for non-x86 machines.
-corey
Quoted 5 lines
Regards,
Anthony Liguori
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 14 lines · Corey Minyard
Quoted 13 lines · Anthony Liguori
Quoted 7 lines · Corey Minyard
On 08/01/2012 08:15 PM, Kevin O'Connor wrote:
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
Okay, I was actually going to ask if there was an ACPI table for this.
Maybe this argues in favor of doing a
fw_cfginterface?
Quoted 7 lines
Quoted 3 lines
Another question--is it really necessary for all of this to be user specified? Can't we just use a static SMBIOS/ACPI entry? Then SeaBIOS only needs to be concerned with whether or not an IPMI device exists.
That's a good question At least the interrupt is important for the user to be able to specify. The specific interface type may also be important if the user is trying to accomplish some specific emulation.
Why is it important to specify the interrupt? Is this important for a typical user, or important for the IPMI maintainer who needs to test a bunch of different scenarios? :-)
If it's the later, we can probably express the interrupt number as a #define in SeaBIOS, but still make it configurable in QEMU. Then you could build multiple copies of SeaBIOS and then just point QEMU at the right version.
Quoted 3 lines
Two other standard emulations exist, too, one in memory and one over I2C. I'd eventually like to add those, if for nothing else my ability to test the interfaces.
Right, see above. It may be easier to just build multiple copies of the BIOS then to try and make this all dynamic.
Regards,
Anthony Liguori
Quoted 13 lines
If the user is trying to emulate some specific machine, setting the address is also important, and I need to add the ability to specify register spacing and the address space. This will become more important for non-x86 machines.
-corey
Quoted 5 lines
Regards,
Anthony Liguori
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 19 lines · Anthony Liguori
Quoted 17 lines · Corey Minyard
Quoted 16 lines · Anthony Liguori
Quoted 7 lines · Corey Minyard
On 08/01/2012 08:15 PM, Kevin O'Connor wrote:
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
Okay, I was actually going to ask if there was an ACPI table for this.
Maybe this argues in favor of doing a
fw_cfginterface?Another question--is it really necessary for all of this to be user specified? Can't we just use a static SMBIOS/ACPI entry? Then SeaBIOS only needs to be concerned with whether or not an IPMI device exists.
Quoted 6 lines
Quoted 3 lines
That's a good question At least the interrupt is important for the user to be able to specify. The specific interface type may also be important if the user is trying to accomplish some specific emulation.
Why is it important to specify the interrupt? Is this important for a typical user, or important for the IPMI maintainer who needs to test a bunch of different scenarios? :-)
I'm not too worried about the IPMI maintainer, he can hack in what he likes :).
I would be worried about conflicts on interrupts with other devices. I really don't know how people use qemu out in the wild, though. If they are trying to get close to some specific machine, or if nobody really cares about stuff like that.
I also don't know if people will be wanting this on other architectures. IPMI is certainly available on ia64. In fact it's quite common there. I've seen it on practically everything else, though it's not so common. It's in the PPC device trees for sure, and in some uboot device trees on other arches.
Quoted 4 lines
If it's the later, we can probably express the interrupt number as a #define in SeaBIOS, but still make it configurable in QEMU. Then you could build multiple copies of SeaBIOS and then just point QEMU at the right version.
That philosophy sounds like a recipe for version overload. I'd prefer to avoid that.
Quoted 6 lines
Quoted 4 lines
Two other standard emulations exist, too, one in memory and one over I2C. I'd eventually like to add those, if for nothing else my ability to test the interfaces.
Right, see above. It may be easier to just build multiple copies of the BIOS then to try and make this all dynamic.
In my experience, if you need the flexibility and don't make it dynamic, you make things harder in the long run. But adding unnecessary flexibility is extra work without value.
IMHO, we should either have a single IPMI interface type at a fixed location with a fixed interrupt, or we should make it flexible. Even if we make it fixed, the BIOS will have to be told if the device is present and will have to dynamically chose to add the SMBIOS table and ACPI name space entries.
Thanks,
-corey
Quoted 16 lines
Regards,
Anthony Liguori
Quoted 12 lines
If the user is trying to emulate some specific machine, setting the address is also important, and I need to add the ability to specify register spacing and the address space. This will become more important for non-x86 machines.
-corey
Quoted 5 lines
Regards,
Anthony Liguori
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 27 lines · Corey Minyard
Quoted 19 lines · Anthony Liguori
Quoted 17 lines · Corey Minyard
Quoted 16 lines · Anthony Liguori
Quoted 7 lines · Corey Minyard
On 08/01/2012 08:15 PM, Kevin O'Connor wrote:
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
Okay, I was actually going to ask if there was an ACPI table for this.
Maybe this argues in favor of doing a
fw_cfginterface?Another question--is it really necessary for all of this to be user specified? Can't we just use a static SMBIOS/ACPI entry? Then SeaBIOS only needs to be concerned with whether or not an IPMI device exists.
Quoted 6 lines
Quoted 3 lines
That's a good question At least the interrupt is important for the user to be able to specify. The specific interface type may also be important if the user is trying to accomplish some specific emulation.
Why is it important to specify the interrupt? Is this important for a typical user, or important for the IPMI maintainer who needs to test a bunch of different scenarios? :-)
Quoted 7 lines
I'm not too worried about the IPMI maintainer, he can hack in what he likes :).
I would be worried about conflicts on interrupts with other devices. I really don't know how people use qemu out in the wild, though. If they are trying to get close to some specific machine, or if nobody really cares about stuff like that.
It's an LPC device? Ther aren't going to be many of those device types that would be user controllable (basically TPM and IPMI) so I don't think interrupt conflicts are a real likely issue.
Quoted 2 lines
I also don't know if people will be wanting this on other architectures. IPMI is certainly available on ia64.
I doubt QEMU will ever support ia64 since noone seems to care about it anymore.
Quoted 4 lines
In fact it's quite
common there. I've seen it on practically everything else, though it's not so common. It's in the PPC device trees for sure, and in some uboot device trees on other arches.
Right, but this is specifically about SMBIOS/ACPI support which won't be on other architectures.
Quoted 10 lines
Quoted 5 lines
If it's the later, we can probably express the interrupt number as a #define in SeaBIOS, but still make it configurable in QEMU. Then you could build multiple copies of SeaBIOS and then just point QEMU at the right version.
That philosophy sounds like a recipe for version overload. I'd prefer to avoid that.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Two other standard emulations exist, too, one in memory and one over I2C. I'd eventually like to add those, if for nothing else my ability to test the interfaces.
Right, see above. It may be easier to just build multiple copies of the BIOS then to try and make this all dynamic.
In my experience, if you need the flexibility and don't make it dynamic, you make things harder in the long run. But adding unnecessary flexibility is extra work without value.
Exactly.
Quoted 2 lines
IMHO, we should either have a single IPMI interface type at a fixed location with a fixed interrupt, or we should make it flexible.
I think fixed interrupt is what makes the most sense now. If there's a
pressing need in the future to do otherwise, we can revisit.
Regards,
Anthony Liguori
Quoted 25 lines
Even if
we make it fixed, the BIOS will have to be told if the device is present and will have to dynamically chose to add the SMBIOS table and ACPI name space entries.Thanks,
-corey
Quoted 16 lines
Regards,
Anthony Liguori
Quoted 12 lines
If the user is trying to emulate some specific machine, setting the address is also important, and I need to add the ability to specify register spacing and the address space. This will become more important for non-x86 machines.
-corey
Quoted 5 lines
Regards,
Anthony Liguori
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH 01/18] smbios: Add a function to directly add an entry
Quoted 31 lines · Anthony Liguori
Quoted 29 lines · Corey Minyard
Quoted 19 lines · Anthony Liguori
Quoted 17 lines · Corey Minyard
Quoted 16 lines · Anthony Liguori
Quoted 7 lines · Corey Minyard
On 08/01/2012 08:15 PM, Kevin O'Connor wrote:
Well, I should also probably add the ACPI name space definition for this information, too, and the SMBIOS information is not capable of passing all the information required for this (though the above structure can).I've been studying this, but I don't see an obvious way to dynamically add something to the ACPI name space. At least an easy way.
Okay, I was actually going to ask if there was an ACPI table for this.
Maybe this argues in favor of doing a
fw_cfginterface?Another question--is it really necessary for all of this to be user specified? Can't we just use a static SMBIOS/ACPI entry? Then SeaBIOS only needs to be concerned with whether or not an IPMI device exists.
Quoted 6 lines
Quoted 3 lines
That's a good question At least the interrupt is important for the user to be able to specify. The specific interface type may also be important if the user is trying to accomplish some specific emulation.
Why is it important to specify the interrupt? Is this important for a typical user, or important for the IPMI maintainer who needs to test a bunch of different scenarios? :-)
I'm not too worried about the IPMI maintainer, he can hack in what he likes :).
Quoted 8 lines
Quoted 4 lines
I would be worried about conflicts on interrupts with other devices. I really don't know how people use qemu out in the wild, though. If they are trying to get close to some specific machine, or if nobody really cares about stuff like that.
It's an LPC device? Ther aren't going to be many of those device types that would be user controllable (basically TPM and IPMI) so I don't think interrupt conflicts are a real likely issue.
The implementation depends. But for SMBIOS concerns, you are probably correct.
Quoted 2 lines
Right, but this is specifically about SMBIOS/ACPI support which won't be on other architectures.
No, it's not. This is about passing information to the firmware. At least PPC and SPARC use the same mechanisms.
Quoted 16 lines
Quoted 8 lines
Quoted 5 lines
If it's the later, we can probably express the interrupt number as a #define in SeaBIOS, but still make it configurable in QEMU. Then you could build multiple copies of SeaBIOS and then just point QEMU at the right version.
That philosophy sounds like a recipe for version overload. I'd prefer to avoid that.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Two other standard emulations exist, too, one in memory and one over I2C. I'd eventually like to add those, if for nothing else my ability to test the interfaces.
Right, see above. It may be easier to just build multiple copies of the BIOS then to try and make this all dynamic.
In my experience, if you need the flexibility and don't make it dynamic, you make things harder in the long run. But adding unnecessary flexibility is extra work without value.
Quoted 6 lines
Exactly.
Quoted 2 lines
IMHO, we should either have a single IPMI interface type at a fixed location with a fixed interrupt, or we should make it flexible.
I think fixed interrupt is what makes the most sense now. If there's a
pressing need in the future to do otherwise, we can revisit.
I wanted to think about this a bit, and in my mind if you have to pass anything, you might as well pass everything. It's not that big a difference. Since you are going to have to pass something along, the difference between passing a flag saying "IPMI is available" and passing a structure with the information doesn't seem to be that much. The main difference is the firmware is going to pull the data out of a passed in structure verses setting it to fixed values. Passing the structure gives the user the ability to specify anything and have it just work.
Thanks,
-corey
Quoted 30 lines
Regards,
Anthony Liguori
Quoted 25 lines
Even if
we make it fixed, the BIOS will have to be told if the device is present and will have to dynamically chose to add the SMBIOS table and ACPI name space entries.Thanks,
-corey
Quoted 16 lines
Regards,
Anthony Liguori
Quoted 12 lines
If the user is trying to emulate some specific machine, setting the address is also important, and I need to add the ability to specify register spacing and the address space. This will become more important for non-x86 machines.
-corey
Quoted 5 lines
Regards,
Anthony Liguori
Quoted 1 line
-corey
Re: [Qemu-devel] [PATCH 10/18] qom: release previous object when setting
In reply to Andreas FärberAm 30.07.2012 15:51, schrieb Andreas Färber:
Quoted 8 lines
Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 7 lines
From: Corey Minyard <[email protected]>
When setting an object, if you don't release the previous object that was there, it may become unusable. This change allows a chardev to be removed from one object's properties and added to another's.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Corey Minyard <[email protected]>Acked-by Paolo Bonzini <[email protected]>Reviewed-by Andreas Färber <[email protected]>Anthony, this looks like a valid and generic QOM memory leak fix to me. Suggesting to cherry-pick this patch to master and stable-1.1.
Ping?
Quoted 24 lines
Andreas
Quoted 19 lines
--- qom/object.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)qom/object.c +3
-0@@ -731,6 +731,9 @@ void object_property_set(Object *obj, Visitor *v, const char *name,if (!prop->set) {error_set (errp,QERR_PERMISSION_DENIED ); }else { +if (prop->release) { + prop->release (obj, name, prop->opaque); + } prop->set (obj, v, prop->opaque, name, errp); } }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 8 lines
Ok, everything passes through checkpatch without an error now. I have added some tests to verify basic operation of the device, and I've hacked in some documentation, though I'm not sure if it's in the proper location, as I never got a response to my questions about it.
I would have liked to add tests for the watchdog timer, but there doesn't appear to be a way to intercept resets or NMIs in the test framework.
Corey, the v1.3 merge window is open now, do you have a v4 of this series already?
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 11 lines · Andreas Färber
Am 19.07.2012 20:53, schrieb [email protected]:
Quoted 8 lines
Ok, everything passes through checkpatch without an error now. I have added some tests to verify basic operation of the device, and I've hacked in some documentation, though I'm not sure if it's in the proper location, as I never got a response to my questions about it.
I would have liked to add tests for the watchdog timer, but there doesn't appear to be a way to intercept resets or NMIs in the test framework.
Corey, the v1.3 merge window is open now, do you have a v4 of this series already?
I'm waiting for the SeaBIOS decisions to be made.
-corey
Quoted 3 lines
Regards,
Andreas