Add an IPMI device to QEMU
PATCH 3/16 qemu-char: remove free of chr from win_stdio_close
In reply to Corey MinyardThis 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 file changed, 1 deletion(-)
qemu-char.c +0 -1
@@ -2075,7 +2075,6 @@ static void win_stdio_close(CharDriverState *chr) }g_free (chr->opaque); -g_free (chr); } static CharDriverState *qemu_chr_open_stdio(CharDriverState *chr,
Signature · 1 line
1.8.3.1
PATCH 1/16 qemu-char: Allocate CharDriverState in qemu_chr_new_from_opts
In reply to Corey MinyardThis allocates the CharDriverState structure and passes it in to the open routine. This allows a coming option to automatically attempt to reconnect a chardev if the connection fails. The chardev has to be kept around so a reconnect can be done on it.
--- backends/baum.c | 6 +- backends/msmouse.c | 5 +- hw/misc/ivshmem.c | 11 ++- include/sysemu/char.h | 9 +-- include/ui/console.h | 4 +- include/ui/qemu-spice.h | 6 +- qemu-char.c | 180 ++++++++++++++++++++++-------------------------- spice-qemu-char.c | 14 ++-- ui/console.c | 10 +-- 9 files changed, 113 insertions(+), 132 deletions(-)
backends/baum.c +2 -4
@@ -561,10 +561,9 @@ static void baum_close(struct CharDriverState *chr)g_free (baum); } -CharDriverState *chr_baum_init (void ) +CharDriverState *chr_baum_init (CharDriverState *chr) {BaumDriverState *baum; -CharDriverState *chr;brlapi_handle_t *handle;#ifdef CONFIG_SDL SDL_SysWMinfo info;
@@ -572,7 +571,7 @@ CharDriverState *chr_baum_init(void)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;
@@ -618,7 +617,6 @@ fail:brlapi__closeConnection (handle); fail_handle:g_free (handle); -g_free (chr);g_free (baum);return NULL ; }
backends/msmouse.c +1 -4
@@ -63,11 +63,8 @@ static void msmouse_chr_close (struct CharDriverState *chr)g_free (chr); } -CharDriverState *qemu_chr_open_msmouse (void ) +CharDriverState *qemu_chr_open_msmouse (CharDriverState *chr) { -CharDriverState *chr; - - chr =g_malloc0 (sizeof (CharDriverState)); chr->chr_write = msmouse_chr_write; chr->chr_close = msmouse_chr_close; chr->explicit_be_open = true;
hw/misc/ivshmem.c +8 -3
@@ -291,12 +291,17 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier * {/* create a event character device based on the passed eventfd */ IVShmemState *s = opaque; -CharDriverState * chr; +CharDriverState *chr, *newchr;int eventfd =event_notifier_get_fd (n); - chr =qemu_chr_open_eventfd (eventfd); - + newchr =g_malloc0 (sizeof (*chr)); +if (newchr ==NULL ) { +fprintf (stderr,"creating eventfd for eventfd %d failed\n" , eventfd); +exit (-1 ); + } + chr =qemu_chr_open_eventfd (newchr, eventfd);if (chr ==NULL ) { +g_free (newchr);fprintf (stderr,"creating eventfd for eventfd %d failed\n" , eventfd);exit (-1 ); }
include/sysemu/char.h +5 -4
@@ -282,21 +282,22 @@ CharDriverState *qemu_chr_find(const char *name);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename); -void register_char_driver (const char *name,CharDriverState *(*open)(QemuOpts *)); +void register_char_driver (const char *name, +CharDriverState *(*open)(CharDriverState *,QemuOpts *));void register_char_driver_qapi (const char *name,ChardevBackendKind kind,void (*parse)(QemuOpts *opts,ChardevBackend *backend,Error **errp));/* add an eventfd to the qemu devices that are polled */ -CharDriverState *qemu_chr_open_eventfd (int eventfd); +CharDriverState *qemu_chr_open_eventfd (CharDriverState *chr,int eventfd);extern int term_escape_char;CharDriverState *qemu_char_get_next_serial (void );/* msmouse */ -CharDriverState *qemu_chr_open_msmouse (void ); +CharDriverState *qemu_chr_open_msmouse (CharDriverState *chr);/* baum.c */ -CharDriverState *chr_baum_init (void ); +CharDriverState *chr_baum_init (CharDriverState *chr);#endif
include/ui/console.h +2 -2
@@ -300,9 +300,9 @@ void qemu_console_copy(QemuConsole *con, int src_x, int src_y,DisplaySurface *qemu_console_surface (QemuConsole *con);DisplayState *qemu_console_displaystate (QemuConsole *console); -typedef CharDriverState *(VcHandler )(ChardevVC *vc); +typedef CharDriverState *(VcHandler )(CharDriverState *chr,ChardevVC *vc); -CharDriverState *vc_init (ChardevVC *vc); +CharDriverState *vc_init (CharDriverState *chr,ChardevVC *vc);void register_vc_handler (VcHandler *handler);/* sdl.c */
include/ui/qemu-spice.h +4 -2
@@ -46,9 +46,11 @@ 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_vmc (const char *type); +CharDriverState *qemu_chr_open_spice_vmc (CharDriverState *chr, +const char *type);#if SPICE_SERVER_VERSION >=0x000c02 -CharDriverState *qemu_chr_open_spice_port (const char *name); +CharDriverState *qemu_chr_open_spice_port (CharDriverSTate *chr, +const char *name);void qemu_spice_register_ports (void );#else static inline CharDriverState *qemu_chr_open_spice_port (const char *name)
qemu-char.c +82 -98
550 lines not on this page · raw message
spice-qemu-char.c +6 -8
@@ -240,12 +240,10 @@ static void print_allowed_subtypes(void)fprintf (stderr,"\n" ); } -static CharDriverState *chr_open (const char *subtype) +static CharDriverState *chr_open (CharDriverState *chr,const char *subtype) { -CharDriverState *chr;SpiceCharDriver *s; - chr =g_malloc0 (sizeof (CharDriverState)); s =g_malloc0 (sizeof (SpiceCharDriver)); s->chr = chr; s->active = false;
@@ -262,7 +260,7 @@ static CharDriverState *chr_open(const char *subtype)return chr; } -CharDriverState *qemu_chr_open_spice_vmc (const char *type) +CharDriverState *qemu_chr_open_spice_vmc (CharDriverState *chr,const char *type) {const char **psubtype =spice_server_char_device_recognized_subtypes ();
@@ -282,13 +280,13 @@ CharDriverState *qemu_chr_open_spice_vmc(const char *type)return NULL ; } -return chr_open (type); +return chr_open (chr, type); }#if SPICE_SERVER_VERSION >=0x000c02 -CharDriverState *qemu_chr_open_spice_port (const char *name) +CharDriverState *qemu_chr_open_spice_port (CharDriverState *chr, +const char *name) { -CharDriverState *chr;SpiceCharDriver *s;if (name ==NULL ) {
@@ -296,7 +294,7 @@ CharDriverState *qemu_chr_open_spice_port(const char *name)return NULL ; } - chr =chr_open ("port" ); +chr_open (chr,"port" ); s = chr->opaque; s->sin.portname =g_strdup (name);
ui/console.c +3 -7
@@ -1761,15 +1761,12 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds) chr->init (chr); } -static CharDriverState *text_console_init (ChardevVC *vc) +static CharDriverState *text_console_init (CharDriverState *chr,ChardevVC *vc) { -CharDriverState *chr;QemuConsole *s;unsigned width =0 ;unsigned height =0 ; - chr =g_malloc0 (sizeof (CharDriverState)); -if (vc->has_width) { width = vc->width; }else if (vc->has_cols) {
@@ -1791,7 +1788,6 @@ static CharDriverState *text_console_init(ChardevVC *vc) }if (!s) { -g_free (chr);return NULL ; }
@@ -1811,9 +1807,9 @@ static CharDriverState *text_console_init(ChardevVC *vc)static VcHandler *vc_handler = text_console_init; -CharDriverState *vc_init (ChardevVC *vc) +CharDriverState *vc_init (CharDriverState *chr,ChardevVC *vc) { -return vc_handler (vc); +return vc_handler (chr, vc); }void register_vc_handler (VcHandler *handler)
Signature · 1 line
1.8.3.1
PATCH 2/16 qemu-char: Allow a chardev to reconnect if disconnected
In reply to Corey MinyardAllow 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.
--- include/sysemu/char.h | 3 ++ qemu-char.c | 88 ++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 11 +++++-- 3 files changed, 87 insertions(+), 15 deletions(-)
include/sysemu/char.h +3 -0
@@ -81,6 +81,9 @@ struct CharDriverState {guint fd_in_tag;QemuOpts *opts;QTAILQ_ENTRY (CharDriverState) next; +GSList *backend; +QEMUTimer *recon_timer; +uint64_t recon_time; };/**
qemu-char.c +76 -12
159 lines not on this page · raw message
qemu-options.hx +8 -3
@@ -1780,8 +1780,9 @@ ETEXI 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"
@@ -1853,7 +1854,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
@@ -1867,6 +1868,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.8.3.1
PATCH 4/16 qemu-char: Close fd at end of file
In reply to Corey MinyardThe 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 | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
qemu-char.c +29 -6
@@ -820,6 +820,8 @@ typedef struct FDCharDriver {GIOChannel *fd_in, *fd_out;int max_size;QTAILQ_ENTRY (FDCharDriver) node; +int close_fdin; +int close_fdout; } FDCharDriver;static int fd_chr_write (CharDriverState *chr,const uint8_t *buf,int len)
@@ -829,6 +831,18 @@ static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)return io_channel_send (s->fd_out, buf, len); } +static void fd_close_fds (FDCharDriver *s) +{ +if ((s->close_fdin != s->close_fdout) && (s->close_fdout !=-1 )) { +close (s->close_fdout); + } + s->close_fdout =-1 ; +if (s->close_fdin !=-1 ) { +close (s->close_fdin); + } + s->close_fdin =-1 ; +} +static gboolean fd_chr_read (GIOChannel *chan,GIOCondition cond,void *opaque) {CharDriverState *chr = opaque;
@@ -850,6 +864,7 @@ static gboolean fd_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) len, &bytes_read, NULL);if (status ==G_IO_STATUS_EOF ) {remove_fd_in_watch (chr); +fd_close_fds (s);qemu_chr_be_event (chr,CHR_EVENT_CLOSED );return FALSE; }
@@ -898,19 +913,27 @@ static void fd_chr_close(struct CharDriverState *chr)g_io_channel_unref (s->fd_out); } +fd_close_fds (s);g_free (s);qemu_chr_be_event (chr,CHR_EVENT_CLOSED ); }/* 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 =io_channel_from_fd (fd_in); s->fd_out =io_channel_from_fd (fd_out); +if (close_fds_on_close) { + s->close_fdin = fd_in; + s->close_fdout = fd_out; + }else { + s->close_fdin = s->close_fdout =-1 ; + }fcntl (fd_out,F_SETFL ,O_NONBLOCK ); s->chr = chr; chr->opaque = s;
@@ -948,7 +971,7 @@ static CharDriverState *qemu_chr_open_pipe(CharDriverState *chr,return NULL ; } } -return qemu_chr_open_fd (chr, fd_in, fd_out); +return qemu_chr_open_fd (chr, fd_in, fd_out, TRUE); }/* init terminal so that we can grab keys */
@@ -1001,7 +1024,7 @@ static CharDriverState *qemu_chr_open_stdio(CharDriverState *chr,fcntl (0 ,F_SETFL ,O_NONBLOCK );atexit (term_exit); -qemu_chr_open_fd (chr,0 ,1 ); +qemu_chr_open_fd (chr,0 ,1 , FALSE); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio;if (opts->has_signal) {
@@ -1407,7 +1430,7 @@ static void qemu_chr_close_tty(CharDriverState *chr)static CharDriverState *qemu_chr_open_tty_fd (CharDriverState *chr,int fd) {tty_serial_init (fd,115200 ,'N' ,8 ,1 ); -qemu_chr_open_fd (chr, fd, fd); +qemu_chr_open_fd (chr, fd, fd, TRUE); chr->chr_ioctl = tty_serial_ioctl; chr->chr_close = qemu_chr_close_tty;return chr;
@@ -2483,7 +2506,7 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)#ifndef _WIN32CharDriverState *qemu_chr_open_eventfd (CharDriverState *chr,int eventfd) { -return qemu_chr_open_fd (chr, eventfd, eventfd); +return qemu_chr_open_fd (chr, eventfd, eventfd, FALSE); }#endif
@@ -3639,7 +3662,7 @@ static CharDriverState *qmp_chardev_open_file(CharDriverState *chr, } } -return qemu_chr_open_fd (chr, in, out); +return qemu_chr_open_fd (chr, in, out, TRUE); } static CharDriverState *qmp_chardev_open_serial(CharDriverState *chr,
Signature · 1 line
1.8.3.1
PATCH 5/16 Add a base IPMI interface
In reply to Corey MinyardAdd 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 | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi.c | 167 +++++++++++++++++++++++++ hw/ipmi/ipmi.h | 241 +++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 2 + 7 files changed, 414 insertions(+) create mode 100644 hw/ipmi/Makefile.objs create mode 100644 hw/ipmi/ipmi.c create mode 100644 hw/ipmi/ipmi.h
default-configs/i386-softmmu.mak +1 -0
@@ -10,6 +10,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
@@ -10,6 +10,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 +1 -0
@@ -12,6 +12,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += i2c/ devices-dirs-$(CONFIG_SOFTMMU) += ide/ devices-dirs-$(CONFIG_SOFTMMU) += input/ devices-dirs-$(CONFIG_SOFTMMU) += intc/ +devices-dirs-$(CONFIG_SOFTMMU) += ipmi/ devices-dirs-$(CONFIG_SOFTMMU) += isa/ devices-dirs-$(CONFIG_SOFTMMU) += misc/ devices-dirs-$(CONFIG_SOFTMMU) += net/
hw/ipmi/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +common-obj-$(CONFIG_IPMI) += ipmi.o
hw/ipmi/ipmi.c new file +167 -0
167 lines not on this page · raw message
hw/ipmi/ipmi.h new file +241 -0
241 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.8.3.1
PATCH 6/16 ipmi: Add a PC ISA type structure
In reply to Corey MinyardThis 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/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 148 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.c
default-configs/i386-softmmu.mak +1 -0
@@ -11,6 +11,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
@@ -11,6 +11,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/ipmi/Makefile.objs +1 -0
@@ -1 +1,2 @@ common-obj-$(CONFIG_IPMI) += ipmi.o +common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
hw/ipmi/isa_ipmi.c new file +148 -0
148 lines not on this page · raw message
include/hw/nvram/fw_cfg.h +10 -1
@@ -38,7 +38,16 @@#define FW_CFG_FILE_FIRST 0x20#define FW_CFG_FILE_SLOTS 0x10 -#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS) + +#define FW_CFG_IPMI_INTERFACE 0x30 +#define FW_CFG_IPMI_BASE_ADDR 0x31 +#define FW_CFG_IPMI_REG_SPACE 0x32 +#define FW_CFG_IPMI_REG_SPACING 0x33 +#define FW_CFG_IPMI_SLAVE_ADDR 0x34 +#define FW_CFG_IPMI_IRQ 0x35 +#define FW_CFG_IPMI_VERSION 0x36 + +#define FW_CFG_MAX_ENTRY (FW_CFG_IPMI_VERSION + 1)#define FW_CFG_WRITE_CHANNEL 0x4000#define FW_CFG_ARCH_LOCAL 0x8000
Signature · 1 line
1.8.3.1
PATCH 7/16 ipmi: Add a KCS low-level interface
In reply to Corey MinyardThis provides the simulation of the KCS hardware interface.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_kcs.c | 345 +++++++++++++++++++++++++++++++++++++ 4 files changed, 348 insertions(+) create mode 100644 hw/ipmi/ipmi_kcs.c
default-configs/i386-softmmu.mak +1 -0
@@ -12,6 +12,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
@@ -12,6 +12,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/ipmi/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o +common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o
hw/ipmi/ipmi_kcs.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
1.8.3.1
cover Add an IPMI device to QEMU
There are two (sets of) patches to the general code beyond the IPMI device addition.
One set adds an option to qemu-char net devices to automatically try to reconnect if the connection disconnects. This lets the IPMI device connect to a remote BMC and recover if that BMC fails.
The other set allows SMBIOS table entries to be added to the tables by drivers.
-corey
PATCH 8/16 ipmi: Add a BT low-level interface
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/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_bt.c | 367 +++++++++++++++++++++++++++++++++++++ 4 files changed, 370 insertions(+) create mode 100644 hw/ipmi/ipmi_bt.c
default-configs/i386-softmmu.mak +1 -0
@@ -13,6 +13,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
@@ -13,6 +13,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/ipmi/Makefile.objs +1 -0
@@ -1,3 +1,4 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o +common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o
hw/ipmi/ipmi_bt.c new file +367 -0
367 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 10/16 ipmi: Add an external connection simulation interface
In reply to Corey MinyardThis 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/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_extern.c | 476 +++++++++++++++++++++++++++++++++++++ 4 files changed, 479 insertions(+) create mode 100644 hw/ipmi/ipmi_extern.c
default-configs/i386-softmmu.mak +1 -0
@@ -15,6 +15,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
@@ -15,6 +15,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/ipmi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o +common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o
hw/ipmi/ipmi_extern.c new file +476 -0
476 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 12/16 ipmi: Add documentation
In reply to Corey MinyardAdd some basic documentation for the IPMI device.
--- qemu-options.hx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
qemu-options.hx +35 -0
@@ -327,6 +327,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 help} and @code{-device @var{driver},help}. + +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 DEF("name", HAS_ARG, QEMU_OPTION_name,
Signature · 1 line
1.8.3.1
PATCH 11/16 ipmi: Add tests
In reply to Corey MinyardTest the KCS interface with a local BMC and a BT interface with an external BMC.
--- tests/Makefile | 4 + tests/ipmi-bt-test.c | 440 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ipmi-kcs-test.c | 294 +++++++++++++++++++++++++++++++++ 3 files changed, 738 insertions(+) create mode 100644 tests/ipmi-bt-test.c create mode 100644 tests/ipmi-kcs-test.c
tests/Makefile +4 -0
@@ -65,6 +65,8 @@ check-qtest-i386-y += tests/hd-geo-test$(EXESUF) gcov-files-i386-y += hw/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y)
@@ -169,6 +171,8 @@ tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/endianness-test$(EXESUF): tests/endianness-test.o tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) +tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o +tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
tests/ipmi-bt-test.c new file +440 -0
440 lines not on this page · raw message
tests/ipmi-kcs-test.c new file +294 -0
294 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 13/16 ipmi: Add migration capability to the IPMI device.
In reply to Corey Minyard--- hw/ipmi/ipmi.c | 17 +++++++++++++++++ hw/ipmi/ipmi.h | 2 ++ hw/ipmi/ipmi_bt.c | 14 ++++++++++++++ hw/ipmi/ipmi_extern.c | 42 ++++++++++++++++++++++++++++++++++++++---- hw/ipmi/ipmi_kcs.c | 15 +++++++++++++++ hw/ipmi/ipmi_sim.c | 30 ++++++++++++++++++++++++++++++ hw/ipmi/isa_ipmi.c | 12 ++++++++++++ 7 files changed, 128 insertions(+), 4 deletions(-)
hw/ipmi/ipmi.c +17 -0
@@ -150,6 +150,23 @@ int ipmi_bmc_init(IPMIBmc *s)return 0 ; } +const VMStateDescription vmstate_IPMIInterface = { + .name =TYPE_IPMI_INTERFACE , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_BOOL (obf_irq_set, IPMIInterface), +VMSTATE_BOOL (atn_irq_set, IPMIInterface), +VMSTATE_BOOL (use_irq, IPMIInterface), +VMSTATE_BOOL (irqs_enabled, IPMIInterface), +VMSTATE_UINT32 (outpos, IPMIInterface), +VMSTATE_UINT32 (outlen, IPMIInterface), +VMSTATE_VBUFFER_UINT32 (inmsg, IPMIInterface,1 ,NULL ,0 , inlen), +VMSTATE_BOOL (write_end, IPMIInterface), +VMSTATE_END_OF_LIST () + } +}; +static TypeInfo ipmi_bmc_type_info = { .name =TYPE_IPMI_BMC , .parent =TYPE_OBJECT ,
hw/ipmi/ipmi.h +2 -0
@@ -187,6 +187,8 @@ typedef struct IPMIInterfaceClass { unsigned char *rsp, unsigned int rsp_len); } IPMIInterfaceClass; +extern const VMStateDescription vmstate_IPMIInterface; +int ipmi_interface_init (IPMIInterface *s);void ipmi_interface_reset (IPMIInterface *s);
hw/ipmi/ipmi_bt.c +14 -0
@@ -327,6 +327,19 @@ static void ipmi_bt_set_atn(IPMIInterface *s, int val, int irq) } } +static const VMStateDescription vmstate_ipmi_bt = { + .name =TYPE_IPMI_INTERFACE_BT , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (control_reg, IPMIBtInterface), +VMSTATE_UINT8 (mask_reg, IPMIBtInterface), +VMSTATE_UINT8 (waiting_rsp, IPMIBtInterface), +VMSTATE_UINT8 (waiting_seq, IPMIBtInterface), +VMSTATE_END_OF_LIST () + } +}; +static int ipmi_bt_init (IPMIInterface *s) {IPMIBtInterface *bt =IPMI_INTERFACE_BT (s);
@@ -337,6 +350,7 @@ static int ipmi_bt_init(IPMIInterface *s) s->io_length =3 ;memory_region_init_io (&s->io,OBJECT (s), &ipmi_bt_io_ops, bt,"ipmi-bt" ,3 ); +vmstate_register (NULL ,0 , &vmstate_ipmi_bt, bt);return 0 ; }
hw/ipmi/ipmi_extern.c +38 -4
60 lines not on this page · raw message
hw/ipmi/ipmi_kcs.c +15 -0
@@ -304,6 +304,20 @@ static void ipmi_kcs_set_atn(IPMIInterface *s, int val, int irq) } } +static const VMStateDescription vmstate_ipmi_kcs = { + .name =TYPE_IPMI_INTERFACE_KCS , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (status_reg, IPMIKcsInterface), +VMSTATE_UINT8 (data_out_reg, IPMIKcsInterface), +VMSTATE_INT16 (data_in_reg, IPMIKcsInterface), +VMSTATE_INT16 (cmd_reg, IPMIKcsInterface), +VMSTATE_UINT8 (waiting_rsp, IPMIKcsInterface), +VMSTATE_END_OF_LIST () + } +}; +static int ipmi_kcs_init (IPMIInterface *s) {IPMIKcsInterface *kcs =IPMI_INTERFACE_KCS (s);
@@ -315,6 +329,7 @@ static int ipmi_kcs_init(IPMIInterface *s)memory_region_init_io (&s->io,OBJECT (s), &ipmi_kcs_io_ops, kcs,"ipmi-kcs" ,2 ); +vmstate_register (NULL ,0 , &vmstate_ipmi_kcs, kcs);return 0 ; }
hw/ipmi/ipmi_sim.c +30 -0
@@ -1481,6 +1481,34 @@ static const uint8_t init_sdrs[] = {0xff ,0xff ,0x00 ,0x00 ,0x00 }; +static const VMStateDescription vmstate_ipmi_sim = { + .name =TYPE_IPMI_BMC_SIMULATOR , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT8 (bmc_global_enables, IPMISimBmc), +VMSTATE_UINT8 (msg_flags, IPMISimBmc), +VMSTATE_BOOL (watchdog_initialized, IPMISimBmc), +VMSTATE_UINT8 (watchdog_use, IPMISimBmc), +VMSTATE_UINT8 (watchdog_action, IPMISimBmc), +VMSTATE_UINT8 (watchdog_pretimeout, IPMISimBmc), +VMSTATE_BOOL (watchdog_expired, IPMISimBmc), +VMSTATE_UINT16 (watchdog_timeout, IPMISimBmc), +VMSTATE_BOOL (watchdog_running, IPMISimBmc), +VMSTATE_BOOL (watchdog_preaction_ran, IPMISimBmc), +VMSTATE_INT64 (watchdog_expiry, IPMISimBmc), +VMSTATE_UINT8_ARRAY (evtbuf, IPMISimBmc,16 ), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].status, IPMISimBmc), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].reading, IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].states, IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_states, IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].deassert_states, + IPMISimBmc), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_enable, IPMISimBmc), +VMSTATE_END_OF_LIST () + } +}; +static int ipmi_sim_init (IPMIBmc *b) {unsigned int i;
@@ -1526,6 +1554,8 @@ static int ipmi_sim_init(IPMIBmc *b) ss->timer =timer_new (QEMU_CLOCK_VIRTUAL ,SCALE_NS , ipmi_timeout, ss); +vmstate_register (NULL ,0 , &vmstate_ipmi_sim, ss); +return 0 ; }
hw/ipmi/isa_ipmi.c +12 -0
@@ -124,12 +124,24 @@ static Property ipmi_isa_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static const VMStateDescription vmstate_isa_ipmi = { + .name =TYPE_ISA_IPMI , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_STRUCT_POINTER (intf, ISAIPMIDevice, vmstate_IPMIInterface, + IPMIInterface *), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_isa_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->realize = ipmi_isa_realizefn; dc->reset = ipmi_isa_reset; + dc->vmsd = &vmstate_isa_ipmi; dc->props = ipmi_isa_properties; }
Signature · 1 line
1.8.3.1
PATCH 14/16 pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Corey MinyardPostpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
hw/i386/pc.c +30 -8
@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);
@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));
@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,
@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }
Signature · 1 line
1.8.3.1
PATCH 15/16 smbios: Add a function to directly add an entry
In reply to Corey MinyardThere 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/i386/smbios.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
hw/i386/smbios.c +27 -0
@@ -277,6 +277,33 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +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 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err =NULL ;
Signature · 1 line
1.8.3.1
PATCH 16/16 ipmi: Add SMBIOS table entry
In reply to Corey MinyardAdd an IPMI table entry to the SMBIOS.
--- hw/ipmi/isa_ipmi.c | 29 +++++++++++++++++++++++++++++ include/hw/i386/smbios.h | 14 ++++++++++++++ 2 files changed, 43 insertions(+)
hw/ipmi/isa_ipmi.c +29 -0
@@ -27,6 +27,7 @@#include "qemu/timer.h" #include "sysemu/char.h" #include "sysemu/sysemu.h" +#include "hw/i386/smbios.h" #include "ipmi.h" /* This is the type the user specifies on the -device command line */
@@ -36,13 +37,36 @@typedef struct ISAIPMIDevice {ISADevice dev;char *interface; +int intftype;uint32_t iobase;uint32_t isairq;uint8_t slave_addr; +uint8_t version;CharDriverState *chr;IPMIInterface *intf; }ISAIPMIDevice ; +static void ipmi_encode_smbios (ISAIPMIDevice *info) +{ +struct smbios_type_38 smb38; + + smb38.header.type =38 ; + smb38.header.length =sizeof (smb38); + smb38.header.handle =cpu_to_le16 (0x3000 ); + smb38.interface_type = info->intftype; + smb38.ipmi_spec_revision = info->version; + smb38.i2c_slave_address = info->slave_addr; + smb38.nv_storage_device_address =0 ; + +/* or 1 to set it to I/O space */ + smb38.base_address =cpu_to_le64 (info->iobase |1 ); + +/* 1-byte boundaries, addr bit0=0, level triggered irq */ + smb38.base_address_modifier =1 ; + smb38.interrupt_number = info->isairq; +smbios_table_entry_add ((struct smbios_structure_header *) &smb38); +} +static void ipmi_isa_realizefn (DeviceState *dev,Error **errp) {ISADevice *isadev =ISA_DEVICE (dev);
@@ -50,6 +74,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)char typename[20 ];Object *intfobj;IPMIInterface *intf; +IPMIInterfaceClass *intfk;Object *bmcobj;IPMIBmc *bmc;int rc;
@@ -69,10 +94,13 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) TYPE_IPMI_INTERFACE_PREFIX "%s", isa->interface); intfobj =object_new (typename); intf =IPMI_INTERFACE (intfobj); + intfk =IPMI_INTERFACE_GET_CLASS (intf); bmc->intf = intf; intf->bmc = bmc; intf->io_base = isa->iobase; intf->slave_addr = isa->slave_addr; + isa->intftype = intfk->smbios_type; + isa->version =0x20 ;/* Version 2.0 */ rc =ipmi_interface_init (intf);if (rc) {error_setg (errp,"Error initializing IPMI interface: %d\n" , rc);
@@ -106,6 +134,7 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, intf->io_base, intf->io_length);isa_register_ioport (isadev, &intf->io, intf->io_base); +ipmi_encode_smbios (isa); }static void ipmi_isa_reset (DeviceState *dev)
include/hw/i386/smbios.h +14 -0
@@ -29,6 +29,8 @@ struct smbios_structure_header {uint16_t handle; }QEMU_PACKED ; +int smbios_table_entry_add (struct smbios_structure_header *entry); +/* SMBIOS type 0 - BIOS Information */ struct smbios_type_0 {struct smbios_structure_header header;
@@ -155,6 +157,18 @@ struct smbios_type_32 {uint8_t boot_status; }QEMU_PACKED ; +/* SMBIOS type 38 - IPMI */ +struct smbios_type_38 { +struct smbios_structure_header header; +uint8_t interface_type; +uint8_t ipmi_spec_revision; +uint8_t i2c_slave_address; +uint8_t nv_storage_device_address; +uint64_t base_address; +uint8_t base_address_modifier; +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.8.3.1
PATCH 9/16 ipmi: Add a local BMC simulation
In reply to Corey MinyardThis 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/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_sim.c | 1552 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1555 insertions(+) create mode 100644 hw/ipmi/ipmi_sim.c
default-configs/i386-softmmu.mak +1 -0
@@ -14,6 +14,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
@@ -14,6 +14,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/ipmi/Makefile.objs +1 -0
@@ -2,3 +2,4 @@ common-obj-$(CONFIG_IPMI) += ipmi.o common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o +common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o
hw/ipmi/ipmi_sim.c new file +1552 -0
1,552 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected
In reply to Corey MinyardQuoted 15 lines · Corey Minyard
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.
Signed-off-by Corey Minyard <[email protected]>--- include/sysemu/char.h | 3 ++ qemu-char.c | 88 ++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 11 +++++-- 3 files changed, 87 insertions(+), 15 deletions(-)+++ b/qemu-options.hx
qemu-options.hx +0
-0@@ -1780,8 +1780,9 @@ ETEXI DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, "-chardev null,id=id[,mux=on|off]\n"
qemu-options.hx ETEXI
Quoted 10 lines
qemu-options.hx +6
-2"-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" +@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.
Sounds cool. Are you planning on also adding the QMP counterpart for specifying this option when doing hotplugs of a chardev? Does reconnect make any sense when not using server mode?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected
Quoted 11 lines · Eric Blake
Quoted 10 lines · Corey Minyard
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.
Signed-off-by Corey Minyard <[email protected]>--- include/sysemu/char.h | 3 ++ qemu-char.c | 88 ++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 11 +++++-- 3 files changed, 87 insertions(+), 15 deletions(-)
Quoted 15 lines
qemu-options.hx ETEXI · line 1788
Quoted 13 lines
+++ b/qemu-options.hx
qemu-options.hx +6
-2@@ -1780,8 +1780,9 @@ ETEXI 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" +@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.Sounds cool. Are you planning on also adding the QMP counterpart for specifying this option when doing hotplugs of a chardev?
Yes, I need to add that.
Quoted 3 lines
Does reconnect
make any sense when not using server mode?
Actually, it only really makes sense when in client mode. The option currently won't do anything in server mode. I can't see a use for it in server mode, it doesn't know where to connect.
-corey
Re: [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected
In reply to Corey MinyardHi,
qemu-char.c CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, · line 3286
Quoted 11 lines
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 +8
-0+ 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 ; + }
I think it would work *much* better to just add a "chr_reconnect" function pointer to CharDriverState. You don't need patch #1 then. Also it avoids backend-specific bits in generic code. Generic code just checks if chr->chr_reconnect exists to figure whenever reconnect is supported or not. And the socket backend can set chr_reconnect for client sockets only.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 11/16] ipmi: Add tests
In reply to Corey Minyard Having trouble with this patch (after the prior patches were
successfully applied):
git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
directory)
#
# modified: ../../../backends/baum.c # modified: ../../../backends/msmouse.c # modified: ../../../default-configs/i386-softmmu.mak # modified: ../../../default-configs/x86_64-softmmu.mak # modified: ../../../hw/Makefile.objs # modified: ../../../hw/misc/ivshmem.c # modified: ../../../include/hw/nvram/fw_cfg.h # modified: ../../../include/sysemu/char.h # modified: ../../../include/ui/console.h # modified: ../../../include/ui/qemu-spice.h # modified: ../../../qemu-char.c # modified: ../../../qemu-doc.texi # modified: ../../../qemu-options.hx # modified: ../../../spice-qemu-char.c # modified: ../../../ui/console.c
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../../
# ../../../hw/ipmi/
no changes added to commit (use "git add" and/or "git commit -a") [
git apply --verbos --check ../ipmi-patches/290712.mbox Checking patch tests/Makefile...
error: while searching for:
gcov-files-i386-y += hw/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y)
error: patch failed: tests/Makefile:65
error: tests/Makefile: patch does not apply
Checking patch tests/ipmi-bt-test.c...
Checking patch tests/ipmi-kcs-test.c...
I believe the patch for tests/Makefile should look like:
tests/Makefile +4 -0
@@ -65,6 +65,8 @@ check-qtest-i386-y += tests/hd-geo-test$(EXESUF) gcov-files-i386-y += hw/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-i386-y += tests/qom-test$(EXESUF)
@@ -194,6 +196,8 @@ tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/endianness-test$(EXESUF): tests/endianness-test.o tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) +tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o +tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
Quoted 822 lines · Corey Minyard
Test the KCS interface with a local BMC and a BT interface with an external BMC.
Signed-off-by Corey Minyard <[email protected]>--- tests/Makefile | 4 + tests/ipmi-bt-test.c | 440 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ipmi-kcs-test.c | 294 +++++++++++++++++++++++++++++++++ 3 files changed, 738 insertions(+) create mode 100644 tests/ipmi-bt-test.c create mode 100644 tests/ipmi-kcs-test.ctests/Makefile +4
-0@@ -65,6 +65,8 @@ check-qtest-i386-y += tests/hd-geo-test$(EXESUF) gcov-files-i386-y += hw/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y)@@ -169,6 +171,8 @@ tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/endianness-test$(EXESUF): tests/endianness-test.o tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) +tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o +tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)tests/ipmi-bt-test.c new file +6
-0@@ -0,0 +1,440 @@ +/* +* IPMI BT test cases, using the external interface for checking +* +* Copyright (c) 2012 Corey Minyard <[email protected]> +* +* 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.
+ */tests/ipmi-bt-test.c new file +30
-0+ +#include <sys/types.h> +#include <stdint.h> +#include <string.h> +#include <stdio.h> + +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/tcp.h> + +#include <glib.h> + +#include "libqtest.h" +#include "qemu-common.h" + +#define IPMI_IRQ 5 + +#define IPMI_BT_BASE 0xe4 + +#define IPMI_BT_CTLREG_CLR_WR_PTR 0 +#define IPMI_BT_CTLREG_CLR_RD_PTR 1 +#define IPMI_BT_CTLREG_H2B_ATN 2 +#define IPMI_BT_CTLREG_B2H_ATN 3 +#define IPMI_BT_CTLREG_SMS_ATN 4 +#define IPMI_BT_CTLREG_H_BUSY 6 +#define IPMI_BT_CTLREG_B_BUSY 7 + +#define IPMI_BT_CTLREG_GET (b) ((bt_get_ctrlreg() >> (b)) & 1) +#define IPMI_BT_CTLREG_GET_H2B_ATN ()
IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_H2B_ATN)
+#defineIPMI_BT_CTLREG_GET_B2H_ATN()IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_B2H_ATN)
+#defineIPMI_BT_CTLREG_GET_SMS_ATN()IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_SMS_ATN)tests/ipmi-bt-test.c new file +12
-0+#define IPMI_BT_CTLREG_GET_H_BUSY () IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_H_BUSY) +#define IPMI_BT_CTLREG_GET_B_BUSY() IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_B_BUSY) + +#define IPMI_BT_CTLREG_SET (b) bt_write_ctrlreg(1 << (b)) +#define IPMI_BT_CTLREG_SET_CLR_WR_PTR () IPMI_BT_CTLREG_SET( \ + IPMI_BT_CTLREG_CLR_WR_PTR) +#define IPMI_BT_CTLREG_SET_CLR_RD_PTR () IPMI_BT_CTLREG_SET( \ + IPMI_BT_CTLREG_CLR_RD_PTR) +#define IPMI_BT_CTLREG_SET_H2B_ATN () IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_H2B_ATN) +#define IPMI_BT_CTLREG_SET_B2H_ATN() IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_B2H_ATN) +#define IPMI_BT_CTLREG_SET_SMS_ATN ()IPMI_BT_CTLREG_SET (IPMI_BT_CTLREG_SMS_ATN) +#define IPMI_BT_CTLREG_SET_H_BUSY()
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_H_BUSY)tests/ipmi-bt-test.c new file +153
-0+ +static int bt_ints_enabled; + +static uint8_t bt_get_ctrlreg (void ) +{ +return inb (IPMI_BT_BASE ); +} + +static void bt_write_ctrlreg (uint8_t val) +{ +outb (IPMI_BT_BASE , val); +} + +static uint8_t bt_get_buf (void ) +{ +return inb (IPMI_BT_BASE +1 ); +} + +static void bt_write_buf (uint8_t val) +{ +outb (IPMI_BT_BASE +1 , val); +} + +static uint8_t bt_get_irqreg (void ) +{ +return inb (IPMI_BT_BASE +2 ); +} + +static void bt_write_irqreg (uint8_t val) +{ +outb (IPMI_BT_BASE +2 , val); +} + +static void bt_wait_b_busy (void ) +{ +unsigned int count =1000 ; +while (IPMI_BT_CTLREG_GET_B_BUSY () !=0 ) { +g_assert (--count !=0 ); + } +} + +static void bt_wait_b2h_atn (void ) +{ +unsigned int count =1000 ; +while (IPMI_BT_CTLREG_GET_B2H_ATN () ==0 ) { +g_assert (--count !=0 ); + } +} + + +static int emu_lfd; +static int emu_fd; +static in_port_t emu_port; +static uint8_t inbuf[100 ]; +static unsigned int inbuf_len; +static unsigned int inbuf_pos; +static int last_was_aa; + +static void read_emu_data (void ) +{ +fd_set readfds; +int rv; +struct timeval tv; + +FD_ZERO (&readfds); +FD_SET (emu_fd, &readfds); + tv.tv_sec =10 ; + tv.tv_usec =0 ; + rv =select (emu_fd +1 , &readfds,NULL ,NULL , &tv); +if (rv ==-1 ) { +perror ("select" ); + } +g_assert (rv ==1 ); + rv =read (emu_fd, inbuf,sizeof (inbuf)); +if (rv ==-1 ) { +perror ("read" ); + } +g_assert (rv >0 ); + inbuf_len = rv; + inbuf_pos =0 ; +} + +static void write_emu_msg (uint8_t *msg,unsigned int len) +{ +int rv; + +#ifdef DEBUG_TEST + { +unsigned int i; +printf ("sending:" ); +for (i =0 ; i < len; i++) { +printf (" %2.2x" , msg[i]); + } +printf ("\n" ); + } +#endif + rv =write (emu_fd, msg, len); +g_assert (rv == len); +} + +static void get_emu_msg (uint8_t *msg,unsigned int *len) +{ +unsigned int outpos =0 ; + +for (;;) { +while (inbuf_pos < inbuf_len) { +uint8_t ch = inbuf[inbuf_pos++]; + +g_assert (outpos < *len); +if (last_was_aa) { +assert (ch &0x10 ); + msg[outpos++] = ch & ~0x10 ; + last_was_aa =0 ; + }else if (ch ==0xaa ) { + last_was_aa =1 ; + }else { + msg[outpos++] = ch; +if ((ch ==0xa0 ) || (ch ==0xa1 )) { +/* Message complete */ + *len = outpos; + goto done; + } + } + } +read_emu_data (); + } + done: +#ifdef DEBUG_TEST + { +unsigned int i; +printf ("Msg:" ); +for (i =0 ; i < outpos; i++) { +printf (" %2.2x" , msg[i]); + } +printf ("\n" ); + } +#endif +return ; +} + +static uint8_t +ipmb_checksum (const unsigned char *data,int size,unsigned char start) +{ +unsigned char csum = start; + +for (; size >0 ; size--, data++) { + csum += *data; + } +return csum; +} + +static uint8_t get_dev_id_cmd[] = {0x18 ,0x01 }; +static uint8_t get_dev_id_rsp[] = {0x1c ,0x01 ,0x00 ,0x20 ,0x00 ,0x00 ,
0x00,
+0x02,0x09,0x00,0x00,0x00,0x00,0x00};tests/ipmi-bt-test.c new file +153
-0+ +static uint8_t set_bmc_globals_cmd[] = {0x18 ,0x2e ,0x0f }; +static uint8_t set_bmc_globals_rsp[] = {0x1c ,0x2e ,0x00 }; +static uint8_t enable_irq_cmd[] = {0x05 ,0xa1 }; + +static void emu_msg_handler (void ) +{ +uint8_t msg[100 ]; +unsigned int msg_len =sizeof (msg); + +get_emu_msg (msg, &msg_len); +g_assert (msg_len >=5 ); +g_assert (msg[msg_len -1 ] ==0xa0 ); + msg_len--; +g_assert (ipmb_checksum (msg, msg_len,0 ) ==0 ); + msg_len--; +if ((msg[1 ] == get_dev_id_cmd[0 ]) && (msg[2 ] == get_dev_id_cmd[1 ])) { +memcpy (msg +1 , get_dev_id_rsp,sizeof (get_dev_id_rsp)); + msg_len =sizeof (get_dev_id_rsp) +1 ; + msg[msg_len] = -ipmb_checksum (msg, msg_len,0 ); + msg_len++; + msg[msg_len++] =0xa0 ; +write_emu_msg (msg, msg_len); + }else if ((msg[1 ] == set_bmc_globals_cmd[0 ]) && + (msg[2 ] == set_bmc_globals_cmd[1 ])) { +memcpy (msg +1 , set_bmc_globals_rsp,sizeof (set_bmc_globals_rsp)); + msg_len =sizeof (set_bmc_globals_rsp) +1 ; + msg[msg_len] = -ipmb_checksum (msg, msg_len,0 ); + msg_len++; + msg[msg_len++] =0xa0 ; +write_emu_msg (msg, msg_len); +write_emu_msg (enable_irq_cmd,sizeof (enable_irq_cmd)); + }else { +g_assert (0 ); + } +} + +static void bt_cmd (uint8_t *cmd,unsigned int cmd_len, +uint8_t *rsp,unsigned int *rsp_len) +{ +unsigned int i, len, j =0 ; +uint8_t seq =5 ; + +/* Should be idle */ +g_assert (bt_get_ctrlreg () ==0 ); + +bt_wait_b_busy (); +IPMI_BT_CTLREG_SET_CLR_WR_PTR (); +bt_write_buf (cmd_len +1 ); +bt_write_buf (cmd[0 ]); +bt_write_buf (seq); +for (i =1 ; i < cmd_len; i++) { +bt_write_buf (cmd[i]); + } +IPMI_BT_CTLREG_SET_H2B_ATN (); + +emu_msg_handler ();/* We should get a message on the socket here. */ + +bt_wait_b2h_atn (); +if (bt_ints_enabled) { +g_assert ((bt_get_irqreg () &0x02 ) ==0x02 ); +g_assert (get_irq (IPMI_IRQ )); +bt_write_irqreg (0x03 ); + }else { +g_assert (!get_irq (IPMI_IRQ )); + } +IPMI_BT_CTLREG_SET_H_BUSY (); +IPMI_BT_CTLREG_SET_B2H_ATN (); +IPMI_BT_CTLREG_SET_CLR_RD_PTR (); + len =bt_get_buf (); +g_assert (len >=4 ); + rsp[0 ] =bt_get_buf (); +assert (bt_get_buf () == seq); + len--; +for (j =1 ; j < len; j++) { + rsp[j] =bt_get_buf (); + } +IPMI_BT_CTLREG_SET_H_BUSY (); + *rsp_len = j; +} + + +/* +* We should get a connect request and a short message with capabilities. +*/ +static void test_connect (void ) +{ +fd_set readfds; +int rv; +int val; +struct timeval tv; +uint8_t msg[100 ]; +unsigned int msglen; +static uint8_t exp1[] = {0xff ,0x01 ,0xa1 };/* A protocol version */ +static uint8_t exp2[] = {0x08 ,0x1f ,0xa1 };/* A capabilities cmd */ +static uint8_t exp3[] = {0x04 ,0xa1 };/* A reset is reported */ + +FD_ZERO (&readfds); +FD_SET (emu_lfd, &readfds); + tv.tv_sec =10 ; + tv.tv_usec =0 ; + rv =select (emu_lfd +1 , &readfds,NULL ,NULL , &tv); +g_assert (rv ==1 ); + emu_fd =accept (emu_lfd,NULL ,0 ); +if (emu_fd <0 ) { +perror ("accept" ); + } +g_assert (emu_fd >=0 ); + + val =1 ; + rv =setsockopt (emu_fd,IPPROTO_TCP ,TCP_NODELAY , &val,sizeof (val)); +g_assert (rv !=-1 ); + +/* Report our version */ +write_emu_msg (exp1,sizeof (exp1)); + +/* Validate that we get the info we expect. */ + msglen =sizeof (msg); +get_emu_msg (msg, &msglen); +g_assert (msglen ==sizeof (exp1)); +g_assert (memcmp (msg, exp1, msglen) ==0 ); + msglen =sizeof (msg); +get_emu_msg (msg, &msglen); +g_assert (msglen ==sizeof (exp2)); +g_assert (memcmp (msg, exp2, msglen) ==0 ); + msglen =sizeof (msg); +get_emu_msg (msg, &msglen); +g_assert (msglen ==sizeof (exp3)); +g_assert (memcmp (msg, exp3, msglen) ==0 ); +} + +/* +* Send a get_device_id to do a basic test. +*/ +static void test_bt_base (void ) +{ +uint8_t rsp[20 ]; +unsigned int rsplen =sizeof (rsp); + +bt_cmd (get_dev_id_cmd,sizeof (get_dev_id_cmd), rsp, &rsplen); +g_assert (rsplen ==sizeof (get_dev_id_rsp)); +g_assert (memcmp (get_dev_id_rsp, rsp, rsplen) ==0 ); +} + +/* +* Enable IRQs for the interface. +*/ +static void test_enable_irq (void ) +{ +uint8_t rsp[20 ]; +unsigned int rsplen =sizeof (rsp); + + bt_cmd(set_bmc_globals_cmd, sizeof(set_bmc_globals_cmd), rsp,&rsplen);
tests/ipmi-bt-test.c new file +23
-0+g_assert (rsplen ==sizeof (set_bmc_globals_rsp)); +g_assert (memcmp (set_bmc_globals_rsp, rsp, rsplen) ==0 ); +bt_write_irqreg (0x01 ); + bt_ints_enabled =1 ; +} + +/* +* Create a local TCP socket with any port, then save off the port we got. +*/ +static void open_socket (void ) +{ +struct sockaddr_in myaddr; +socklen_t addrlen; + + myaddr.sin_family =AF_INET ; + myaddr.sin_addr.s_addr =htonl (INADDR_LOOPBACK ); + myaddr.sin_port =0 ; + emu_lfd =socket (AF_INET ,SOCK_STREAM ,IPPROTO_TCP ); +if (emu_lfd ==-1 ) { +perror ("socket" ); +exit (1 ); + } +if (bind (emu_lfd, (struct sockaddr *) &myaddr,sizeof (myaddr)) ==-1 ){
tests/ipmi-bt-test.c new file +43
-1+perror ("bind" ); +exit (1 ); + } + addrlen =sizeof (myaddr); +if (getsockname (emu_lfd, (struct sockaddr *) &myaddr , &addrlen) == -1) { + perror("getsockname"); +exit (1 ); + } + emu_port =ntohs (myaddr.sin_port); +assert (listen (emu_lfd,1 ) !=-1 ); +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); +char *cmdline; +int ret; + +/* Check architecture */ +if (strcmp (arch,"i386" ) &&strcmp (arch,"x86_64" )) { +g_test_message ("Skipping test for non-x86\n" ); +return 0 ; + } + +open_socket (); + +/* Run the tests */ +g_test_init (&argc, &argv,NULL ); + + cmdline =g_strdup_printf ("-vnc none" +" -chardev socket,id=ipmi0,host=localhost,port=%d,reconnect=10" +" -device isa-ipmi,interface=bt,chardev=ipmi0" , emu_port); +qtest_start (cmdline); +qtest_irq_intercept_in (global_qtest,"ioapic" ); +qtest_add_func ("/ipmi/extern/connect" , test_connect); +qtest_add_func ("/ipmi/extern/bt_base" , test_bt_base); +qtest_add_func ("/ipmi/extern/bt_enable_irq" , test_enable_irq); +qtest_add_func ("/ipmi/extern/bt_base_irq" , test_bt_base); + ret =g_test_run (); +qtest_quit (global_qtest); + +return ret; +}tests/ipmi-kcs-test.c new file +6
-0@@ -0,0 +1,294 @@ +/* +* IPMI KCS test cases, using the local interface. +* +* Copyright (c) 2012 Corey Minyard <[email protected]> +* +* 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.
+ */tests/ipmi-kcs-test.c new file +199
-0+ +#include <stdint.h> +#include <string.h> +#include <stdio.h> + +#include <glib.h> + +#include "libqtest.h" + +#define IPMI_IRQ 5 + +#define IPMI_KCS_BASE 0xca2 + +#define IPMI_KCS_STATUS_ABORT 0x60 +#define IPMI_KCS_CMD_WRITE_START 0x61 +#define IPMI_KCS_CMD_WRITE_END 0x62 +#define IPMI_KCS_CMD_READ 0x68 + +#define IPMI_KCS_ABORTED_BY_CMD 0x01 + +#define IPMI_KCS_CMDREG_GET_STATE () ((kcs_get_cmdreg() >> 6) & 3) +#define IPMI_KCS_STATE_IDLE 0 +#define IPMI_KCS_STATE_READ 1 +#define IPMI_KCS_STATE_WRITE 2 +#define IPMI_KCS_STATE_ERROR 3 +#define IPMI_KCS_CMDREG_GET_CD () ((kcs_get_cmdreg() >> 3) & 1) +#define IPMI_KCS_CMDREG_GET_ATN () ((kcs_get_cmdreg() >> 2) & 1) +#define IPMI_KCS_CMDREG_GET_IBF () ((kcs_get_cmdreg() >> 1) & 1) +#define IPMI_KCS_CMDREG_GET_OBF () ((kcs_get_cmdreg() >> 0) & 1) + +static int kcs_ints_enabled; + +static uint8_t kcs_get_cmdreg (void ) +{ +return inb (IPMI_KCS_BASE +1 ); +} + +static void kcs_write_cmdreg (uint8_t val) +{ +outb (IPMI_KCS_BASE +1 , val); +} + +static uint8_t kcs_get_datareg (void ) +{ +return inb (IPMI_KCS_BASE ); +} + +static void kcs_write_datareg (uint8_t val) +{ +outb (IPMI_KCS_BASE , val); +} + +static void kcs_wait_ibf (void ) +{ +unsigned int count =1000 ; +while (IPMI_KCS_CMDREG_GET_IBF () !=0 ) { +g_assert (--count !=0 ); + } +} + +static void kcs_wait_obf (void ) +{ +unsigned int count =1000 ; +while (IPMI_KCS_CMDREG_GET_OBF () ==0 ) { +g_assert (--count !=0 ); + } +} + +static void kcs_clear_obf (void ) +{ +if (kcs_ints_enabled) { +g_assert (get_irq (IPMI_IRQ )); + }else { +g_assert (!get_irq (IPMI_IRQ )); + } +g_assert (IPMI_KCS_CMDREG_GET_OBF () ==1 ); +kcs_get_datareg (); +g_assert (IPMI_KCS_CMDREG_GET_OBF () ==0 ); +g_assert (!get_irq (IPMI_IRQ )); +} + +static void kcs_check_state (uint8_t state) +{ +g_assert (IPMI_KCS_CMDREG_GET_STATE () == state); +} + +static void kcs_cmd (uint8_t *cmd,unsigned int cmd_len, +uint8_t *rsp,unsigned int *rsp_len) +{ +unsigned int i, j =0 ; + +/* Should be idle */ +g_assert (kcs_get_cmdreg () ==0 ); + +kcs_write_cmdreg (IPMI_KCS_CMD_WRITE_START ); +kcs_wait_ibf (); +kcs_check_state (IPMI_KCS_STATE_WRITE ); +kcs_clear_obf (); +for (i =0 ; i < cmd_len; i++) { +kcs_write_datareg (cmd[i]); +kcs_wait_ibf (); +kcs_check_state (IPMI_KCS_STATE_WRITE ); +kcs_clear_obf (); + } +kcs_write_cmdreg (IPMI_KCS_CMD_WRITE_END ); +kcs_wait_ibf (); +kcs_check_state (IPMI_KCS_STATE_WRITE ); +kcs_clear_obf (); +kcs_write_datareg (0 ); + next_read_byte: +kcs_wait_ibf (); +switch (IPMI_KCS_CMDREG_GET_STATE ()) { +case IPMI_KCS_STATE_READ : +kcs_wait_obf (); +g_assert (j < *rsp_len); + rsp[j++] =kcs_get_datareg (); +kcs_write_datareg (IPMI_KCS_CMD_READ ); + goto next_read_byte; +break ; + +case IPMI_KCS_STATE_IDLE : +kcs_wait_obf (); +kcs_get_datareg (); +break ; + +default : +g_assert (0 ); + } + *rsp_len = j; +} + +static void kcs_abort (uint8_t *cmd,unsigned int cmd_len, +uint8_t *rsp,unsigned int *rsp_len) +{ +unsigned int i, j =0 ; +unsigned int retries =4 ; + +/* Should be idle */ +g_assert (kcs_get_cmdreg () ==0 ); + +kcs_write_cmdreg (IPMI_KCS_CMD_WRITE_START ); +kcs_wait_ibf (); +kcs_check_state (IPMI_KCS_STATE_WRITE ); +kcs_clear_obf (); +for (i =0 ; i < cmd_len; i++) { +kcs_write_datareg (cmd[i]); +kcs_wait_ibf (); +kcs_check_state (IPMI_KCS_STATE_WRITE ); +kcs_clear_obf (); + } +kcs_write_cmdreg (IPMI_KCS_CMD_WRITE_END ); +kcs_wait_ibf (); +kcs_check_state (IPMI_KCS_STATE_WRITE ); +kcs_clear_obf (); +kcs_write_datareg (0 ); +kcs_wait_ibf (); +switch (IPMI_KCS_CMDREG_GET_STATE ()) { +case IPMI_KCS_STATE_READ : +kcs_wait_obf (); +g_assert (j < *rsp_len); + rsp[j++] =kcs_get_datareg (); +kcs_write_datareg (IPMI_KCS_CMD_READ ); +break ; + +default : +g_assert (0 ); + } + +/* Start the abort here */ + retry_abort: +g_assert (retries >0 ); + +kcs_wait_ibf (); +kcs_write_cmdreg (IPMI_KCS_STATUS_ABORT ); +kcs_wait_ibf (); +kcs_clear_obf (); +kcs_write_datareg (0 ); +kcs_wait_ibf (); +if (IPMI_KCS_CMDREG_GET_STATE () !=IPMI_KCS_STATE_READ ) { + retries--; + goto retry_abort; + } +kcs_wait_obf (); + rsp[0 ] =kcs_get_datareg (); +kcs_write_datareg (IPMI_KCS_CMD_READ ); +kcs_wait_ibf (); +if (IPMI_KCS_CMDREG_GET_STATE () !=IPMI_KCS_STATE_IDLE ) { + retries--; + goto retry_abort; + } +kcs_wait_obf (); +kcs_clear_obf (); + + *rsp_len = j; +} + + +static uint8_t get_dev_id_cmd[] = {0x18 ,0x01 }; +static uint8_t get_dev_id_rsp[] = {0x1c ,0x01 ,0x00 ,0x20 ,0x00 ,0x00 ,
0x00,
+0x02,0x07,0x00,0x00,0x00,0x00,0x00};tests/ipmi-kcs-test.c new file +38
-0+ +/* +* Send a get_device_id to do a basic test. +*/ +static void test_kcs_base (void ) +{ +uint8_t rsp[20 ]; +unsigned int rsplen =sizeof (rsp); + +kcs_cmd (get_dev_id_cmd,sizeof (get_dev_id_cmd), rsp, &rsplen); +g_assert (rsplen ==sizeof (get_dev_id_rsp)); +g_assert (memcmp (get_dev_id_rsp, rsp, rsplen) ==0 ); +} + +/* +* Abort a kcs operation while reading +*/ +static void test_kcs_abort (void ) +{ +uint8_t rsp[20 ]; +unsigned int rsplen =sizeof (rsp); + +kcs_abort (get_dev_id_cmd,sizeof (get_dev_id_cmd), rsp, &rsplen); +g_assert (rsp[0 ] ==IPMI_KCS_ABORTED_BY_CMD ); +} + +static uint8_t set_bmc_globals_cmd[] = {0x18 ,0x2e ,0x0f }; +static uint8_t set_bmc_globals_rsp[] = {0x1c ,0x2e ,0x00 }; + +/* +* Enable interrupts +*/ +static void test_enable_irq (void ) +{ +uint8_t rsp[20 ]; +unsigned int rsplen =sizeof (rsp); + + kcs_cmd(set_bmc_globals_cmd, sizeof(set_bmc_globals_cmd), rsp,&rsplen);
tests/ipmi-kcs-test.c new file +33
-1+g_assert (rsplen ==sizeof (set_bmc_globals_rsp)); +g_assert (memcmp (set_bmc_globals_rsp, rsp, rsplen) ==0 ); + kcs_ints_enabled =1 ; +} + +int main (int argc,char **argv) +{ +const char *arch =qtest_get_arch (); +char *cmdline; +int ret; + +/* Check architecture */ +if (strcmp (arch,"i386" ) &&strcmp (arch,"x86_64" )) { +g_test_message ("Skipping test for non-x86\n" ); +return 0 ; + } + +/* Run the tests */ +g_test_init (&argc, &argv,NULL ); + + cmdline =g_strdup_printf ("-vnc none -device isa-ipmi" ); +qtest_start (cmdline); +qtest_irq_intercept_in (global_qtest,"ioapic" ); +qtest_add_func ("/ipmi/local/kcs_base" , test_kcs_base); +qtest_add_func ("/ipmi/local/kcs_abort" , test_kcs_abort); +qtest_add_func ("/ipmi/local/kcs_enable_irq" , test_enable_irq); +qtest_add_func ("/ipmi/local/kcs_base_irq" , test_kcs_base); +qtest_add_func ("/ipmi/local/kcs_abort_irq" , test_kcs_abort); + ret =g_test_run (); +qtest_quit (global_qtest); + +return ret; +} --1.8.3.1
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Corey MinyardHad trouble with this one:
git apply --verbos --check ../ipmi-patches/290708.mbox
Checking patch hw/i386/pc.c...
Hunk #1 succeeded at 622 (offset 15 lines).
error: while searching for:
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)apic_id_limit);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
acpi_tables, acpi_tables_len);
fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE,kvm_allows_irq0_override());
smbios_table = smbios_get_table(&smbios_len);
if (smbios_table)
fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
smbios_table, smbios_len);
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
&e820_table, sizeof(e820_table));error: patch failed: hw/i386/pc.c:631
error: hw/i386/pc.c: patch does not apply
Should probably look like:
hw/i386/pc.c +0 -0
@@ -622,8 +622,6 @@ static unsigned int pc_apic_id_limit(unsigned int
max_cpus)
static FWCfgState *bochs_bios_init(void)
{
FWCfgState *fw_cfg;
- uint8_t *smbios_table;
- size_t smbios_len;
uint64_t *numa_fw_cfg;
int i, j;
unsigned int apic_id_limit = pc_apic_id_limit(max_cpus);
@@ -646,14 +644,8 @@ static FWCfgState *bochs_bios_init(void)
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)apic_id_limit);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
- fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
- acpi_tables, acpi_tables_len);
fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE,kvm_allows_irq0_override());
- smbios_table = smbios_get_table(&smbios_len);
- if (smbios_table)
- fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
- smbios_table, smbios_len);
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
&e820_reserve, sizeof(e820_reserve));
fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
@@ -1144,6 +1136,31 @@ void pc_acpi_init(const char *default_dsdt)
}}
+struct pc_bios_post_init {
+ Notifier post_init;
+ void *fw_cfg;
+};
+
+/* Add the ACPI and SMBIOS tables after all the hardware has been initialized.
+ * This gives devices a chance to add to those tables.
+ */
+static void pc_bios_post_initfn(Notifier *n, void *opaque) +{
+ struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init,
+ post_init);
+ uint8_t *smbios_table;
+ size_t smbios_len;
+
+ fw_cfg_add_bytes(p->fw_cfg, FW_CFG_ACPI_TABLES,
+ acpi_tables, acpi_tables_len);
+ smbios_table = smbios_get_table(&smbios_len);
+ if (smbios_table)
+ fw_cfg_add_bytes(p->fw_cfg, FW_CFG_SMBIOS_ENTRIES,
+ smbios_table, smbios_len);
+}
+
+static struct pc_bios_post_init post_init;
+
FWCfgState *pc_memory_init(MemoryRegion *system_memory,
const char *kernel_filename, const char *kernel_cmdline,
@@ -1207,6 +1224,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
rom_add_option(option_rom[i].name, option_rom[i].bootindex);
}
guest_info->fw_cfg = fw_cfg;
+
+ post_init.fw_cfg = fw_cfg;
+ post_init.post_init.notify = pc_bios_post_initfn;
+ qemu_add_machine_init_done_notifier(&post_init.post_init);
+
return fw_cfg;}
Quoted 90 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Signed-off-by Corey Minyard <[email protected]>--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +0
-2@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus) static FWCfgState *bochs_bios_init(void) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit = pc_apic_id_limit(max_cpus);hw/i386/pc.c +6
-6@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized.
+ * This gives devices a chance to add to those tables.
+ */hw/i386/pc.c +3
-0+static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct
pc_bios_post_init,hw/i386/pc.c +19
-1+ post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; } --1.8.3.1
Re: [Qemu-devel] [PATCH 15/16] smbios: Add a function to directly add an entry
In reply to Corey Minyard Don't know if it matters much but this patch cannot be applied without
the prototype definition in 16/16.
Quoted 53 lines · Corey Minyard
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]>--- hw/i386/smbios.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)hw/i386/smbios.c +27
-0@@ -277,6 +277,33 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) } } +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 ; +} +void smbios_entry_add (QemuOpts *opts) {Error *local_err = NULL;--
1.8.3.1
Re: [Qemu-devel] [PATCH 12/16] ipmi: Add documentation
In reply to Corey MinyardThe actual default I/O address for KCS is 0xca2.
Quoted 59 lines · Corey Minyard
Add some basic documentation for the IPMI device.
Signed-off-by Corey Minyard <[email protected]>--- qemu-options.hx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)qemu-options.hx +0
-0@@ -327,6 +327,41 @@ Add device @var{driver}. @var{prop}=@var{value} setsdriver
properties. Valid properties depend on the driver. To get help on possible drivers and properties, use @code{-device help} and @code{-device @var{driver},help}.qemu-options.hx +3
-0+ +Some drivers are: +@item -deviceisa-ipmi[,interface=kcs|bt][,iobase=@var{val}][,irq=@var{val}][,slave_addr=@var{val}][,chardev=name]
qemu-options.hx +32
-1+ +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 DEF("name", HAS_ARG, QEMU_OPTION_name, --1.8.3.1
Re: [Qemu-devel] [PATCH 15/16] smbios: Add a function to directly add an entry
In reply to Bret KetchumAm 13.11.2013 15:37, schrieb Bret Ketchum:
Quoted 3 lines
Don't know if it matters much but this patch cannot be applied
without the prototype definition in 16/16.
It does matter for bisecting, thanks for pointing it out!
Cheers,
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 02/16] qemu-char: Allow a chardev to reconnect if disconnected
In reply to Gerd HoffmannQuoted 12 lines · Gerd Hoffmann
Hi,
qemu-char.c CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, · line 3286
Quoted 10 lines
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 +8
-0+ 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 ; + }
Quoted 6 lines
I think it would work *much* better to just add a "
chr_reconnect" function pointer to CharDriverState. You don't need patch #1 then. Also it avoids backend-specific bits in generic code. Generic code just checks ifchr->chr_reconnectexists to figure whenever reconnect is supported or not. And the socket backend can setchr_reconnectfor client sockets only.
I was trying for something more generic than one that just applies to socket devices. It may not be good for server sockets, but it might be useful for ptys and hotplug devices. Looking at the code, ptys already has its own code that does something similar; that could be pulled out and replaced with the generic code.
Also, IMHO allocating the chardev in each back end is not optimal. It breaks layering. Plus patch #1 has a net reduction in lines of code because it pulls out all the allocations and does it in one place.
Thanks,
-corey
Re: [Qemu-devel] [PATCH 11/16] ipmi: Add tests
In reply to Bret KetchumQuoted 2 lines · Bret Ketchum
Having trouble with this patch (after the prior patches were
successfully applied):
I was a couple of days behind and some other changes that came in conflicted with this.
-corey
Quoted 921 lines
git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
directory)
## modified: ../../../backends/baum.c # modified: ../../../backends/msmouse.c # modified: ../../../default-configs/i386-softmmu.mak # modified: ../../../default-configs/x86_64-softmmu.mak # modified: ../../../hw/Makefile.objs # modified: ../../../hw/misc/ivshmem.c # modified: ../../../include/hw/nvram/fw_cfg.h # modified: ../../../include/sysemu/char.h # modified: ../../../include/ui/console.h # modified: ../../../include/ui/qemu-spice.h # modified: ../../../qemu-char.c # modified: ../../../qemu-doc.texi # modified: ../../../qemu-options.hx # modified: ../../../spice-qemu-char.c # modified: ../../../ui/console.c#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../../
# ../../../hw/ipmi/
no changes added to commit (use "git add" and/or "git commit -a") [git apply --verbos --check ../ipmi-patches/290712.mbox Checking patch tests/Makefile...
error: while searching for:
gcov-files-i386-y +=hw/hd-geometry.ccheck-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y)error: patch failed: tests/Makefile:65
error: tests/Makefile: patch does not apply
Checking patchtests/ipmi-bt-test.c...
Checking patchtests/ipmi-kcs-test.c...I believe the patch for tests/Makefile should look like:
tests/Makefile +4
-0@@ -65,6 +65,8 @@ check-qtest-i386-y += tests/hd-geo-test$(EXESUF) gcov-files-i386-y += hw/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF) check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-i386-y += tests/qom-test$(EXESUF)@@ -194,6 +196,8 @@ tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/endianness-test$(EXESUF): tests/endianness-test.o tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) +tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o +tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)On Tue, Nov 12, 2013 at 10:33 AM, Corey Minyard <[email protected] <mailto:[email protected]>> wrote:
Test the KCS interface with a local BMC and a BT interface with an external BMC.
Signed-off-by Corey Minyard <[email protected]<mailto:[email protected]>>
---
tests/Makefile | 4 +
tests/ipmi-bt-test.c| 440
++++++++++++++++++++++++++++++++++++++++++++++++++
tests/ipmi-kcs-test.c| 294 +++++++++++++++++++++++++++++++++ 3 files changed, 738 insertions(+)
create mode 100644tests/ipmi-bt-test.c
create mode 100644tests/ipmi-kcs-test.cdiff --git a/tests/Makefile b/tests/Makefile
index fa4c9f0..044e7a8 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -65,6 +65,8 @@ check-qtest-i386-y += tests/hd-geo-test$(EXESUF)
gcov-files-i386-y +=hw/hd-geometry.c
check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF)
+check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF) +check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF)
check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y)
@@ -169,6 +171,8 @@ tests/m48t59-test$(EXESUF):tests/m48t59-test.o
tests/endianness-test$(EXESUF):tests/endianness-test.otests/fdc-test$(EXESUF):tests/fdc-test.otests/ide-test$(EXESUF):tests/ide-test.o$(libqos-pc-obj-y)
+tests/ipmi-kcs-test$(EXESUF):tests/ipmi-kcs-test.o+tests/ipmi-bt-test$(EXESUF):tests/ipmi-bt-test.o
tests/hd-geo-test$(EXESUF):tests/hd-geo-test.otests/boot-order-test$(EXESUF):tests/boot-order-test.o
$(libqos-obj-y)
tests/tmp105-test$(EXESUF):tests/tmp105-test.o$(libqos-omap-obj-y)
diff --gita/tests/ipmi-bt-test.cb/tests/ipmi-bt-test.cnew file mode 100644
index 0000000..c1da325
---/dev/null
+++b/tests/ipmi-bt-test.c
@@ -0,0 +1,440 @@
+/*
+ * IPMI BT test cases, using the external interface for checking
+ *
+ * Copyright (c) 2012 Corey Minyard <[email protected] <mailto:[email protected]>>
+ *
+ * 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 <sys/types.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+
+#include <glib.h>
+
+#include "libqtest.h"
+#include "qemu-common.h"
+
+#defineIPMI_IRQ5
+
+#defineIPMI_BT_BASE0xe4
+
+#defineIPMI_BT_CTLREG_CLR_WR_PTR0
+#defineIPMI_BT_CTLREG_CLR_RD_PTR1
+#defineIPMI_BT_CTLREG_H2B_ATN2
+#defineIPMI_BT_CTLREG_B2H_ATN3
+#defineIPMI_BT_CTLREG_SMS_ATN4
+#defineIPMI_BT_CTLREG_H_BUSY6
+#defineIPMI_BT_CTLREG_B_BUSY7
+
+#defineIPMI_BT_CTLREG_GET(b)((bt_get_ctrlreg()>> (b)) & 1) +#defineIPMI_BT_CTLREG_GET_H2B_ATN()IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_H2B_ATN)
+#defineIPMI_BT_CTLREG_GET_B2H_ATN()IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_B2H_ATN)
+#defineIPMI_BT_CTLREG_GET_SMS_ATN()IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_SMS_ATN)
+#defineIPMI_BT_CTLREG_GET_H_BUSY()
IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_H_BUSY)
+#defineIPMI_BT_CTLREG_GET_B_BUSY()
IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_B_BUSY)
+
+#defineIPMI_BT_CTLREG_SET(b)bt_write_ctrlreg(1 << (b))+#defineIPMI_BT_CTLREG_SET_CLR_WR_PTR()IPMI_BT_CTLREG_SET( \
+
IPMI_BT_CTLREG_CLR_WR_PTR)
+#defineIPMI_BT_CTLREG_SET_CLR_RD_PTR()IPMI_BT_CTLREG_SET( \
+
IPMI_BT_CTLREG_CLR_RD_PTR)
+#defineIPMI_BT_CTLREG_SET_H2B_ATN()
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_H2B_ATN)
+#defineIPMI_BT_CTLREG_SET_B2H_ATN()
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_B2H_ATN)
+#defineIPMI_BT_CTLREG_SET_SMS_ATN()
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_SMS_ATN)
+#defineIPMI_BT_CTLREG_SET_H_BUSY()IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_H_BUSY)
+
+static intbt_ints_enabled;
+
+staticuint8_tbt_get_ctrlreg(void)
+{
+ returninb(IPMI_BT_BASE);
+}
+
+static voidbt_write_ctrlreg(uint8_t val)
+{
+outb(IPMI_BT_BASE, val);
+}
+
+staticuint8_tbt_get_buf(void)
+{
+ returninb(IPMI_BT_BASE + 1);
+}
+
+static voidbt_write_buf(uint8_t val)
+{
+outb(IPMI_BT_BASE + 1, val);
+}
+
+staticuint8_tbt_get_irqreg(void)
+{
+ returninb(IPMI_BT_BASE + 2);
+}
+
+static voidbt_write_irqreg(uint8_t val)
+{
+outb(IPMI_BT_BASE + 2, val);
+}
+
+static voidbt_wait_b_busy(void)
+{
+ unsigned int count = 1000;
+ while (IPMI_BT_CTLREG_GET_B_BUSY()!= 0) {
+g_assert(--count != 0);
+ }
+}
+
+static voidbt_wait_b2h_atn(void)
+{
+ unsigned int count = 1000;
+ while (IPMI_BT_CTLREG_GET_B2H_ATN()== 0) {
+g_assert(--count != 0);
+ }
+}
+
+
+static intemu_lfd;
+static intemu_fd;
+staticin_port_temu_port;
+staticuint8_tinbuf[100];
+static unsigned intinbuf_len;
+static unsigned intinbuf_pos;
+static intlast_was_aa;
+
+static voidread_emu_data(void)
+{
+fd_setreadfds;
+ int rv;
+ struct timeval tv;
+
+FD_ZERO(&readfds);
+FD_SET(emu_fd, &readfds);
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+ rv =select(emu_fd + 1, &readfds, NULL, NULL, &tv);
+ if (rv == -1) {
+perror("select");
+ }
+g_assert(rv == 1);
+ rv =read(emu_fd, inbuf, sizeof(inbuf));
+ if (rv == -1) {
+perror("read");
+ }
+g_assert(rv > 0);
+inbuf_len= rv;
+inbuf_pos= 0;
+}
+
+static voidwrite_emu_msg(uint8_t *msg, unsigned int len)+{
+ int rv;
+
+#ifdefDEBUG_TEST
+ {
+ unsigned int i;
+printf("sending:");
+ for (i = 0; i < len; i++) {
+printf(" %2.2x", msg[i]);
+ }
+printf("\n");
+ }
+#endif
+ rv =write(emu_fd, msg, len);
+g_assert(rv == len);
+}
+
+static voidget_emu_msg(uint8_t *msg, unsigned int *len)+{
+ unsigned int outpos = 0;
+
+ for (;;) {
+ while (inbuf_pos<inbuf_len) {
+uint8_tch = inbuf[inbuf_pos++];
+
+g_assert(outpos < *len);
+ if (last_was_aa) {
+assert(ch & 0x10);
+ msg[outpos++] = ch & ~0x10;
+last_was_aa= 0;
+ } else if (ch ==0xaa) {
+last_was_aa= 1;
+ } else {
+ msg[outpos++] = ch;
+ if ((ch ==0xa0) || (ch ==0xa1)) {
+ /* Message complete */
+ *len = outpos;
+ goto done;
+ }
+ }
+ }
+read_emu_data();
+ }
+ done:
+#ifdefDEBUG_TEST
+ {
+ unsigned int i;
+printf("Msg:");
+ for (i = 0; i < outpos; i++) {
+printf(" %2.2x", msg[i]);
+ }
+printf("\n");
+ }
+#endif
+ return;
+}
+
+staticuint8_t
+ipmb_checksum(const unsigned char *data, int size, unsigned char start)
+{
+ unsigned char csum = start;
+
+ for (; size > 0; size--, data++) {
+ csum += *data;
+ }
+ return csum;
+}
+
+staticuint8_tget_dev_id_cmd[] = {0x18,0x01}; +staticuint8_tget_dev_id_rsp[] = {0x1c,0x01,0x00,0x20,0x00,0x00,0x00,
+0x02,0x09,0x00,0x00,0x00,
0x00,0x00};
+
+staticuint8_tset_bmc_globals_cmd[] = {0x18,0x2e,0x0f}; +staticuint8_tset_bmc_globals_rsp[] = {0x1c,0x2e,0x00}; +staticuint8_tenable_irq_cmd[] = {0x05,0xa1};
+
+static voidemu_msg_handler(void)
+{
+uint8_tmsg[100];
+ unsigned intmsg_len= sizeof(msg);
+
+get_emu_msg(msg, &msg_len);
+g_assert(msg_len >= 5);
+g_assert(msg[msg_len - 1] == 0xa0);
+ msg_len--;
+g_assert(ipmb_checksum(msg, msg_len, 0) == 0);
+ msg_len--;
+ if ((msg[1] == get_dev_id_cmd[0]) && (msg[2] ==
get_dev_id_cmd[1])) {
+memcpy(msg + 1, get_dev_id_rsp, sizeof(get_dev_id_rsp));
+msg_len=sizeof(get_dev_id_rsp)+ 1;
+ msg[msg_len] = -ipmb_checksum(msg,msg_len, 0);
+ msg_len++;
+ msg[msg_len++] =0xa0;
+write_emu_msg(msg, msg_len);
+ } else if ((msg[1] == set_bmc_globals_cmd[0]) &&
+ (msg[2] == set_bmc_globals_cmd[1])) {
+ memcpy(msg + 1,set_bmc_globals_rsp,
sizeof(set_bmc_globals_rsp));
+msg_len=sizeof(set_bmc_globals_rsp)+ 1;
+ msg[msg_len] = -ipmb_checksum(msg,msg_len, 0);
+ msg_len++;
+ msg[msg_len++] =0xa0;
+write_emu_msg(msg, msg_len);
+write_emu_msg(enable_irq_cmd, sizeof(enable_irq_cmd));
+ } else {
+g_assert(0);
+ }
+}
+
+static void bt_cmd(uint8_t *cmd, unsigned intcmd_len,
+uint8_t*rsp, unsigned int*rsp_len)
+{
+ unsigned int i, len, j = 0;
+uint8_tseq = 5;
+
+ /* Should be idle */
+g_assert(bt_get_ctrlreg() == 0);
+
+bt_wait_b_busy();
+IPMI_BT_CTLREG_SET_CLR_WR_PTR();
+bt_write_buf(cmd_len + 1);
+bt_write_buf(cmd[0]);
+bt_write_buf(seq);
+ for (i = 1; i <cmd_len; i++) {
+bt_write_buf(cmd[i]);
+ }
+IPMI_BT_CTLREG_SET_H2B_ATN();
+
+emu_msg_handler(); /* We should get a message on the socket
here. */
+
+bt_wait_b2h_atn();
+ if (bt_ints_enabled) {
+g_assert((bt_get_irqreg() & 0x02) == 0x02);
+ g_assert(get_irq(IPMI_IRQ));
+bt_write_irqreg(0x03);
+ } else {
+ g_assert(!get_irq(IPMI_IRQ));
+ }
+IPMI_BT_CTLREG_SET_H_BUSY();
+IPMI_BT_CTLREG_SET_B2H_ATN();
+IPMI_BT_CTLREG_SET_CLR_RD_PTR();
+ len =bt_get_buf();
+g_assert(len >= 4);
+ rsp[0] =bt_get_buf();
+assert(bt_get_buf() == seq);
+ len--;
+ for (j = 1; j < len; j++) {
+ rsp[j] =bt_get_buf();
+ }
+IPMI_BT_CTLREG_SET_H_BUSY();
+*rsp_len= j;
+}
+
+
+/*
+ * We should get a connect request and a short message with capabilities.
+ */
+static voidtest_connect(void)
+{
+fd_setreadfds;
+ int rv;
+ int val;
+ struct timeval tv;
+uint8_tmsg[100];
+ unsigned int msglen;
+ staticuint8_texp1[] = {0xff,0x01,0xa1}; /* A protocol
version */
+ staticuint8_texp2[] = {0x08,0x1f,0xa1}; /* A
capabilities cmd */
+ staticuint8_texp3[] = {0x04,0xa1}; /* A reset is reported */
+
+FD_ZERO(&readfds);
+FD_SET(emu_lfd, &readfds);
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+ rv =select(emu_lfd + 1, &readfds, NULL, NULL, &tv);
+g_assert(rv == 1);
+emu_fd=accept(emu_lfd, NULL, 0);
+ if (emu_fd< 0) {
+perror("accept");
+ }
+g_assert(emu_fd >= 0);
+
+ val = 1;
+ rv = setsockopt(emu_fd,IPPROTO_TCP,TCP_NODELAY, &val,
sizeof(val));
+g_assert(rv != -1);
+
+ /* Report our version */
+write_emu_msg(exp1, sizeof(exp1));
+
+ /* Validate that we get the info we expect. */
+ msglen = sizeof(msg);
+get_emu_msg(msg, &msglen);
+g_assert(msglen == sizeof(exp1));
+g_assert(memcmp(msg, exp1, msglen) == 0);
+ msglen = sizeof(msg);
+get_emu_msg(msg, &msglen);
+g_assert(msglen == sizeof(exp2));
+g_assert(memcmp(msg, exp2, msglen) == 0);
+ msglen = sizeof(msg);
+get_emu_msg(msg, &msglen);
+g_assert(msglen == sizeof(exp3));
+g_assert(memcmp(msg, exp3, msglen) == 0);
+}
+
+/*
+ * Send aget_device_idto do a basic test.
+ */
+static voidtest_bt_base(void)
+{
+uint8_trsp[20];
+ unsigned int rsplen = sizeof(rsp);
+
+bt_cmd(get_dev_id_cmd, sizeof(get_dev_id_cmd), rsp, &rsplen);
+g_assert(rsplen == sizeof(get_dev_id_rsp));
+g_assert(memcmp(get_dev_id_rsp, rsp, rsplen) == 0);
+}
+
+/*
+ * Enable IRQs for the interface.
+ */
+static voidtest_enable_irq(void)
+{
+uint8_trsp[20];
+ unsigned int rsplen = sizeof(rsp);
+
+ bt_cmd(set_bmc_globals_cmd,sizeof(set_bmc_globals_cmd), rsp,
&rsplen);
+g_assert(rsplen == sizeof(set_bmc_globals_rsp));
+g_assert(memcmp(set_bmc_globals_rsp, rsp, rsplen) == 0);
+bt_write_irqreg(0x01);
+bt_ints_enabled= 1;
+}
+
+/*
+ * Create a local TCP socket with any port, then save off the port we got.
+ */
+static voidopen_socket(void)
+{
+ structsockaddr_inmyaddr;
+socklen_taddrlen;
+
+ myaddr.sin_family =AF_INET;
+ myaddr.sin_addr.s_addr =htonl(INADDR_LOOPBACK);
+ myaddr.sin_port = 0;
+emu_lfd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (emu_lfd== -1) {
+perror("socket");
+ exit(1);
+ }
+ if (bind(emu_lfd, (struct sockaddr *) &myaddr,
sizeof(myaddr)) == -1) {
+perror("bind");
+ exit(1);
+ }
+ addrlen = sizeof(myaddr);
+ if (getsockname(emu_lfd, (struct sockaddr *) &myaddr ,
&addrlen) == -1) {
+perror("getsockname");
+ exit(1);
+ }
+emu_port=ntohs(myaddr.sin_port);
+assert(listen(emu_lfd, 1) != -1);
+}
+
+intmain(int argc, char **argv)
+{
+ const char *arch =qtest_get_arch();
+ char *cmdline;
+ int ret;
+
+ /* Check architecture */
+ if (strcmp(arch, "i386")&&strcmp(arch, "x86_64")) {
+g_test_message("Skipping test for non-x86\n");
+ return 0;
+ }
+
+open_socket();
+
+ /* Run the tests */
+g_test_init(&argc, &argv, NULL);
+
+ cmdline = g_strdup_printf("-vnc none"
+ " -chardev
socket,id=ipmi0,host=localhost,port=%d,reconnect=10"
+ " -device isa-ipmi,interface=bt,chardev=ipmi0",emu_port);
+qtest_start(cmdline);
+qtest_irq_intercept_in(global_qtest, "ioapic");
+qtest_add_func("/ipmi/extern/connect", test_connect);
+qtest_add_func("/ipmi/extern/bt_base", test_bt_base);
+qtest_add_func("/ipmi/extern/bt_enable_irq", test_enable_irq);
+qtest_add_func("/ipmi/extern/bt_base_irq", test_bt_base);
+ ret =g_test_run();
+qtest_quit(global_qtest);
+
+ return ret;
+}
diff --gita/tests/ipmi-kcs-test.cb/tests/ipmi-kcs-test.cnew file mode 100644
index 0000000..e2e1bdb
---/dev/null
+++b/tests/ipmi-kcs-test.c
@@ -0,0 +1,294 @@
+/*
+ * IPMI KCS test cases, using the local interface.
+ *
+ * Copyright (c) 2012 Corey Minyard <[email protected] <mailto:[email protected]>>
+ *
+ * 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 <stdint.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <glib.h>
+
+#include "libqtest.h"
+
+#defineIPMI_IRQ5
+
+#defineIPMI_KCS_BASE0xca2
+
+#defineIPMI_KCS_STATUS_ABORT0x60
+#defineIPMI_KCS_CMD_WRITE_START0x61
+#defineIPMI_KCS_CMD_WRITE_END0x62
+#defineIPMI_KCS_CMD_READ0x68
+
+#defineIPMI_KCS_ABORTED_BY_CMD0x01
+
+#defineIPMI_KCS_CMDREG_GET_STATE()((kcs_get_cmdreg()>> 6) & 3)
+#defineIPMI_KCS_STATE_IDLE0
+#defineIPMI_KCS_STATE_READ1
+#defineIPMI_KCS_STATE_WRITE2
+#defineIPMI_KCS_STATE_ERROR3
+#defineIPMI_KCS_CMDREG_GET_CD()((kcs_get_cmdreg()>> 3) & 1)
+#defineIPMI_KCS_CMDREG_GET_ATN()((kcs_get_cmdreg()>> 2) & 1)
+#defineIPMI_KCS_CMDREG_GET_IBF()((kcs_get_cmdreg()>> 1) & 1)
+#defineIPMI_KCS_CMDREG_GET_OBF()((kcs_get_cmdreg()>> 0) & 1)
+
+static intkcs_ints_enabled;
+
+staticuint8_tkcs_get_cmdreg(void)
+{
+ returninb(IPMI_KCS_BASE + 1);
+}
+
+static voidkcs_write_cmdreg(uint8_t val)
+{
+outb(IPMI_KCS_BASE + 1, val);
+}
+
+staticuint8_tkcs_get_datareg(void)
+{
+ returninb(IPMI_KCS_BASE);
+}
+
+static voidkcs_write_datareg(uint8_t val)
+{
+outb(IPMI_KCS_BASE, val);
+}
+
+static voidkcs_wait_ibf(void)
+{
+ unsigned int count = 1000;
+ while (IPMI_KCS_CMDREG_GET_IBF()!= 0) {
+g_assert(--count != 0);
+ }
+}
+
+static voidkcs_wait_obf(void)
+{
+ unsigned int count = 1000;
+ while (IPMI_KCS_CMDREG_GET_OBF()== 0) {
+g_assert(--count != 0);
+ }
+}
+
+static voidkcs_clear_obf(void)
+{
+ if (kcs_ints_enabled) {
+ g_assert(get_irq(IPMI_IRQ));
+ } else {
+ g_assert(!get_irq(IPMI_IRQ));
+ }
+g_assert(IPMI_KCS_CMDREG_GET_OBF() == 1);
+kcs_get_datareg();
+g_assert(IPMI_KCS_CMDREG_GET_OBF() == 0);
+ g_assert(!get_irq(IPMI_IRQ));
+}
+
+static voidkcs_check_state(uint8_t state)
+{
+g_assert(IPMI_KCS_CMDREG_GET_STATE() == state);
+}
+
+static void kcs_cmd(uint8_t *cmd, unsigned intcmd_len,
+uint8_t*rsp, unsigned int*rsp_len)
+{
+ unsigned int i, j = 0;
+
+ /* Should be idle */
+g_assert(kcs_get_cmdreg() == 0);
+
+kcs_write_cmdreg(IPMI_KCS_CMD_WRITE_START);
+kcs_wait_ibf();
+kcs_check_state(IPMI_KCS_STATE_WRITE);
+kcs_clear_obf();
+ for (i = 0; i <cmd_len; i++) {
+kcs_write_datareg(cmd[i]);
+kcs_wait_ibf();
+kcs_check_state(IPMI_KCS_STATE_WRITE);
+kcs_clear_obf();
+ }
+kcs_write_cmdreg(IPMI_KCS_CMD_WRITE_END);
+kcs_wait_ibf();
+kcs_check_state(IPMI_KCS_STATE_WRITE);
+kcs_clear_obf();
+kcs_write_datareg(0);
+next_read_byte:
+kcs_wait_ibf();
+ switch (IPMI_KCS_CMDREG_GET_STATE()) {
+ caseIPMI_KCS_STATE_READ:
+kcs_wait_obf();
+g_assert(j < *rsp_len);
+ rsp[j++] =kcs_get_datareg();
+kcs_write_datareg(IPMI_KCS_CMD_READ);
+ gotonext_read_byte;
+ break;
+
+ caseIPMI_KCS_STATE_IDLE:
+kcs_wait_obf();
+kcs_get_datareg();
+ break;
+
+ default:
+g_assert(0);
+ }
+*rsp_len= j;
+}
+
+static void kcs_abort(uint8_t *cmd, unsigned intcmd_len,
+uint8_t*rsp, unsigned int*rsp_len)
+{
+ unsigned int i, j = 0;
+ unsigned int retries = 4;
+
+ /* Should be idle */
+g_assert(kcs_get_cmdreg() == 0);
+
+kcs_write_cmdreg(IPMI_KCS_CMD_WRITE_START);
+kcs_wait_ibf();
+kcs_check_state(IPMI_KCS_STATE_WRITE);
+kcs_clear_obf();
+ for (i = 0; i <cmd_len; i++) {
+kcs_write_datareg(cmd[i]);
+kcs_wait_ibf();
+kcs_check_state(IPMI_KCS_STATE_WRITE);
+kcs_clear_obf();
+ }
+kcs_write_cmdreg(IPMI_KCS_CMD_WRITE_END);
+kcs_wait_ibf();
+kcs_check_state(IPMI_KCS_STATE_WRITE);
+kcs_clear_obf();
+kcs_write_datareg(0);
+kcs_wait_ibf();
+ switch (IPMI_KCS_CMDREG_GET_STATE()) {
+ caseIPMI_KCS_STATE_READ:
+kcs_wait_obf();
+g_assert(j < *rsp_len);
+ rsp[j++] =kcs_get_datareg();
+kcs_write_datareg(IPMI_KCS_CMD_READ);
+ break;
+
+ default:
+g_assert(0);
+ }
+
+ /* Start the abort here */
+retry_abort:
+g_assert(retries > 0);
+
+kcs_wait_ibf();
+kcs_write_cmdreg(IPMI_KCS_STATUS_ABORT);
+kcs_wait_ibf();
+kcs_clear_obf();
+kcs_write_datareg(0);
+kcs_wait_ibf();
+ if (IPMI_KCS_CMDREG_GET_STATE()!=IPMI_KCS_STATE_READ) {
+ retries--;
+ gotoretry_abort;
+ }
+kcs_wait_obf();
+ rsp[0] =kcs_get_datareg();
+kcs_write_datareg(IPMI_KCS_CMD_READ);
+kcs_wait_ibf();
+ if (IPMI_KCS_CMDREG_GET_STATE()!=IPMI_KCS_STATE_IDLE) {
+ retries--;
+ gotoretry_abort;
+ }
+kcs_wait_obf();
+kcs_clear_obf();
+
+*rsp_len= j;
+}
+
+
+staticuint8_tget_dev_id_cmd[] = {0x18,0x01}; +staticuint8_tget_dev_id_rsp[] = {0x1c,0x01,0x00,0x20,0x00,0x00,0x00,
+0x02,0x07,0x00,0x00,0x00,
0x00,0x00};
+
+/*
+ * Send aget_device_idto do a basic test.
+ */
+static voidtest_kcs_base(void)
+{
+uint8_trsp[20];
+ unsigned int rsplen = sizeof(rsp);
+
+kcs_cmd(get_dev_id_cmd, sizeof(get_dev_id_cmd), rsp, &rsplen);
+g_assert(rsplen == sizeof(get_dev_id_rsp));
+g_assert(memcmp(get_dev_id_rsp, rsp, rsplen) == 0);
+}
+
+/*
+ * Abort a kcs operation while reading
+ */
+static voidtest_kcs_abort(void)
+{
+uint8_trsp[20];
+ unsigned int rsplen = sizeof(rsp);
+
+kcs_abort(get_dev_id_cmd, sizeof(get_dev_id_cmd), rsp, &rsplen);
+g_assert(rsp[0] == IPMI_KCS_ABORTED_BY_CMD);
+}
+
+staticuint8_tset_bmc_globals_cmd[] = {0x18,0x2e,0x0f}; +staticuint8_tset_bmc_globals_rsp[] = {0x1c,0x2e,0x00}; +
+/*
+ * Enable interrupts
+ */
+static voidtest_enable_irq(void)
+{
+uint8_trsp[20];
+ unsigned int rsplen = sizeof(rsp);
+
+ kcs_cmd(set_bmc_globals_cmd,sizeof(set_bmc_globals_cmd),
rsp, &rsplen);
+g_assert(rsplen == sizeof(set_bmc_globals_rsp));
+g_assert(memcmp(set_bmc_globals_rsp, rsp, rsplen) == 0);
+kcs_ints_enabled= 1;
+}
+
+intmain(int argc, char **argv)
+{
+ const char *arch =qtest_get_arch();
+ char *cmdline;
+ int ret;
+
+ /* Check architecture */
+ if (strcmp(arch, "i386")&&strcmp(arch, "x86_64")) {
+g_test_message("Skipping test for non-x86\n");
+ return 0;
+ }
+
+ /* Run the tests */
+g_test_init(&argc, &argv, NULL);
+
+ cmdline =g_strdup_printf("-vnc none -device isa-ipmi");
+qtest_start(cmdline);
+qtest_irq_intercept_in(global_qtest, "ioapic");
+qtest_add_func("/ipmi/local/kcs_base", test_kcs_base);
+qtest_add_func("/ipmi/local/kcs_abort", test_kcs_abort);
+qtest_add_func("/ipmi/local/kcs_enable_irq", test_enable_irq);
+qtest_add_func("/ipmi/local/kcs_base_irq", test_kcs_base);
+qtest_add_func("/ipmi/local/kcs_abort_irq", test_kcs_abort);
+ ret =g_test_run();
+qtest_quit(global_qtest);
+
+ return ret;
+}
--
1.8.3.1
Re: [Qemu-devel] [PATCH 15/16] smbios: Add a function to directly add an entry
In reply to Bret KetchumQuoted 3 lines · Bret Ketchum
Don't know if it matters much but this patch cannot be applied
without the prototype definition in 16/16.
Thanks, I'll fix this.
-corey
Quoted 60 lines
On Tue, Nov 12, 2013 at 10:33 AM, Corey Minyard <[email protected] <mailto:[email protected]>> wrote:
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]<mailto:[email protected]>>
---
hw/i386/smbios.c| 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)diff --git
a/hw/i386/smbios.cb/hw/i386/smbios.cindex d3f1ee6..9c53131 100644
---a/hw/i386/smbios.c
+++b/hw/i386/smbios.c
@@ -277,6 +277,33 @@ static voidsave_opt(const char **dest, QemuOpts *opts, const char *name)
}
}+int
smbios_table_entry_add(struct smbios_structure_header *entry)+{
+ structsmbios_table*table;
+ structsmbios_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 = (structsmbios_table*)(smbios_entries +
smbios_entries_len);
+table->header.type=SMBIOS_TABLE_ENTRY;
+table->header.length=cpu_to_le16(sizeof(*table) + size);
+
+ header = (structsmbios_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;
+}
+
voidsmbios_entry_add(QemuOpts *opts)
{
Error*local_err= NULL;
--
1.8.3.1
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Corey MinyardQuoted 5 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Signed-off-by Corey Minyard <[email protected]>
Why delay adding FW_CFG_ACPI_TABLES?
These are normally specified by user so they are constant.
Quoted 78 lines
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +30
-8@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected
In reply to Corey MinyardQuoted 30 lines · Corey Minyard
Quoted 11 lines · Eric Blake
Quoted 10 lines · Corey Minyard
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.
Signed-off-by Corey Minyard <[email protected]>--- include/sysemu/char.h | 3 ++ qemu-char.c | 88 ++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 11 +++++-- 3 files changed, 87 insertions(+), 15 deletions(-)Quoted 15 lines
qemu-options.hx ETEXI · line 1788
Quoted 13 lines
+++ b/qemu-options.hx
qemu-options.hx +6
-2@@ -1780,8 +1780,9 @@ ETEXI 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" +@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.Sounds cool. Are you planning on also adding the QMP counterpart for specifying this option when doing hotplugs of a chardev?
Yes, I need to add that.
Quoted 8 lines
Quoted 3 lines
Does reconnect
make any sense when not using server mode?Actually, it only really makes sense when in client mode. The option currently won't do anything in server mode. I can't see a use for it in server mode, it doesn't know where to connect.
-corey
I guess it could mean "allow reconnect from a client"?
Re: [Qemu-devel] [PATCH 16/16] ipmi: Add SMBIOS table entry
In reply to Corey MinyardBTW you included this:
Cc: [email protected], Andreas Färber <[email protected]>,
Bret Ketchum <[email protected]>,
Corey Minyard <[email protected]>
the last address: [email protected] is bouncing.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Michael S. TsirkinQuoted 8 lines · Michael S. Tsirkin
Quoted 5 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Signed-off-by Corey Minyard <[email protected]>Why delay adding
FW_CFG_ACPI_TABLES?
These are normally specified by user so they are constant.
Because the IPMI device has to dynamically add an entry based on its configuration. As it is the tables get added to the BIOS access before devices initialize.
-corey
Quoted 79 lines
Quoted 79 lines
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +30
-8@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected
In reply to Michael S. TsirkinQuoted 33 lines · Michael S. Tsirkin
Quoted 32 lines · Corey Minyard
Quoted 11 lines · Eric Blake
Quoted 10 lines · Corey Minyard
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.
Signed-off-by Corey Minyard <[email protected]>--- include/sysemu/char.h | 3 ++ qemu-char.c | 88 ++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 11 +++++-- 3 files changed, 87 insertions(+), 15 deletions(-)Quoted 15 lines
qemu-options.hx ETEXI · line 1788
Quoted 13 lines
+++ b/qemu-options.hx
qemu-options.hx +6
-2@@ -1780,8 +1780,9 @@ ETEXI 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" +@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.Sounds cool. Are you planning on also adding the QMP counterpart for specifying this option when doing hotplugs of a chardev?
Yes, I need to add that.
Quoted 3 lines
Does reconnect
make any sense when not using server mode?
Quoted 7 lines
Quoted 5 lines
Actually, it only really makes sense when in client mode. The option currently won't do anything in server mode. I can't see a use for it in server mode, it doesn't know where to connect.
-corey
I guess it could mean "allow reconnect from a client"?
Yes, rephrasing that is definitely in order.
-corey
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Corey MinyardQuoted 6 lines · Corey Minyard
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>Why delay adding
FW_CFG_ACPI_TABLES?
These are normally specified by user so they are constant.Because the IPMI device has to dynamically add an entry based on its configuration.
Where? Which patch does this? It would be a strange thing to do because FW_CFG_ACPI_TABLES is normally intended for user-supplied tables (though q35 misused it for other purposes).
Quoted 84 lines
As it is the tables get added to the BIOS access before devices initialize.
-corey
Quoted 79 lines
Quoted 79 lines
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +30
-8@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Corey Minyard
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>Why delay adding
FW_CFG_ACPI_TABLES?
These are normally specified by user so they are constant.Because the IPMI device has to dynamically add an entry based on its configuration.
Where? Which patch does this? It would be a strange thing to do because
FW_CFG_ACPI_TABLESis normally intended for user-supplied tables (though q35 misused it for other purposes).
I don't have that patch out yet. I had written some code to dynamically generate ACPI tables, but that was rejected and from what I understand something was done recently so these tables can be dynamically generated some other way. I haven't had time to look into this, but I wanted to get the main patch set out first.
I know that these tables are generally fixed, but the entry for IPMI should only be present if the device is specified, and its contents depend on the configuration supplied,
-corey
Quoted 84 lines
Quoted 84 lines
As it is the tables get added to the BIOS access before devices initialize.
-corey
Quoted 78 lines
Quoted 78 lines
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +30
-8@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 16/16] ipmi: Add SMBIOS table entry
In reply to Michael S. TsirkinQuoted 8 lines · Michael S. Tsirkin
BTW you included this:
Cc: [email protected], Andreas Färber <[email protected]>,
Bret Ketchum <[email protected]>,
Corey Minyard <[email protected]>the last address: [email protected] is bouncing.
That's actually not the one bouncing. The one bouncing is [email protected], which I obviously didn't get right.
-corey
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Corey MinyardQuoted 17 lines · Corey Minyard
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Corey Minyard
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>Why delay adding
FW_CFG_ACPI_TABLES?
These are normally specified by user so they are constant.Because the IPMI device has to dynamically add an entry based on its configuration.
Where? Which patch does this? It would be a strange thing to do because
FW_CFG_ACPI_TABLESis normally intended for user-supplied tables (though q35 misused it for other purposes).
Quoted 5 lines
I don't have that patch out yet. I had written some code to dynamically generate ACPI tables, but that was rejected and from what I understand something was done recently so these tables can be dynamically generated some other way. I haven't had time to look into this, but I wanted to get the main patch set out first.
OK so for review, it might be a good idea to split out the changes required for necessary functionality as opposed to groundwork that will be used down the line.
Quoted 6 lines
I know that these tables are generally fixed, but the entry for IPMI should only be present if the device is specified, and its contents depend on the configuration supplied,
-corey
I see. These tables are generated in hw/i386/acpi-build.c This is invoked in machine done callback so there shouldn't in an issue to probe for IPMI and it's configuration using QOM.
Quoted 84 lines
Quoted 84 lines
Quoted 84 lines
As it is the tables get added to the BIOS access before devices initialize.
-corey
Quoted 78 lines
Quoted 78 lines
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +30
-8@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/16] qemu-char: Allow a chardev to reconnect if disconnected
In reply to Corey MinyardQuoted 26 lines · Corey Minyard
Quoted 12 lines · Gerd Hoffmann
Hi,
qemu-char.c CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, · line 3286
Quoted 10 lines
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 +8
-0+ 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 ; + }Quoted 6 lines
I think it would work *much* better to just add a "
chr_reconnect" function pointer to CharDriverState. You don't need patch #1 then. Also it avoids backend-specific bits in generic code. Generic code just checks ifchr->chr_reconnectexists to figure whenever reconnect is supported or not. And the socket backend can setchr_reconnectfor client sockets only.I was trying for something more generic than one that just applies to socket devices. It may not be good for server sockets, but it might be useful for ptys and hotplug devices. Looking at the code, ptys already has its own code that does something similar; that could be pulled out and replaced with the generic code.
Quoted 7 lines
Also, IMHO allocating the chardev in each back end is not optimal. It breaks layering. Plus patch #1 has a net reduction in lines of code because it pulls out all the allocations and does it in one place.
Thanks,
-corey
I guess this was just one suggestion.
What Gerd is asking for here is that we avoid
code like
strcmp(qemu_opt_get(opts, "backend"), "socket")
in generic code, instead making a backend report
reconnect support.
This sounds reasonable, does it not?
Re: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg
In reply to Corey MinyardQuoted 23 lines · Corey Minyard
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Corey Minyard
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Corey Minyard
Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Corey Minyard <[email protected]>Why delay adding
FW_CFG_ACPI_TABLES?
These are normally specified by user so they are constant.Because the IPMI device has to dynamically add an entry based on its configuration.
Where? Which patch does this? It would be a strange thing to do because
FW_CFG_ACPI_TABLESis normally intended for user-supplied tables (though q35 misused it for other purposes).I don't have that patch out yet. I had written some code to dynamically generate ACPI tables, but that was rejected and from what I understand something was done recently so these tables can be dynamically generated some other way. I haven't had time to look into this, but I wanted to get the main patch set out first.
Quoted 5 lines
I know that these tables are generally fixed, but the entry for IPMI should only be present if the device is specified, and its contents depend on the configuration supplied,
-corey
OK need some help with that?
Main options are
- write code in ASL, supply entry in ACPI always, patch some fields to enable/disable it dynamically
see how pvpanic entry is disabled for an example
- write code in ASL append it to ACPI if necessary
see how CPU entries are added depending on number of CPUs for an example
- generate code in AML directly
see acpi based pci hotplug on pci branch in my tree for an example
Quoted 84 lines
Quoted 84 lines
Quoted 84 lines
As it is the tables get added to the BIOS access before devices initialize.
-corey
Quoted 78 lines
Quoted 78 lines
--- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)hw/i386/pc.c +30
-8@@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_table; -size_t smbios_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);@@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void)fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )apic_id_limit);fw_cfg_add_i32 (fw_cfg,FW_CFG_ID ,1 );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size); -fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , - acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); -if (smbios_table) -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_table, smbios_len);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_table,sizeof (e820_table));@@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { +Notifier post_init; +void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. +* This gives devices a chance to add to those tables. +*/ +static void pc_bios_post_initfn (Notifier *n,void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); +uint8_t *smbios_table; +size_t smbios_len; + +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_ACPI_TABLES , + acpi_tables, acpi_tables_len); + smbios_table =smbios_get_table (&smbios_len); +if (smbios_table) +fw_cfg_add_bytes (p->fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline,@@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,rom_add_option (option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; +qemu_add_machine_init_done_notifier (&post_init.post_init); +return fw_cfg; }Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 01/16] qemu-char: Allocate CharDriverState in qemu_chr_new_from_opts
In reply to Corey MinyardAm 12.11.2013 17:33, schrieb Corey Minyard:
Quoted 6 lines
This allocates the CharDriverState structure and passes it in to the open routine. This allows a coming option to automatically attempt to reconnect a chardev if the connection fails. The chardev has to be kept around so a reconnect can be done on it.
Signed-off-by Corey Minyard <[email protected]>
[...]
Quoted 5 lines
include/ui/qemu-spice.h +0
-0
include/ui/qemu-spice.h int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, · line 52
Quoted 9 lines
include/ui/qemu-spice.h +3
-2@@ -46,9 +46,11 @@ 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_vmc (const char *type); +CharDriverState *qemu_chr_open_spice_vmc (CharDriverState *chr, +const char *type);#if SPICE_SERVER_VERSION >=0x000c02 -CharDriverState *qemu_chr_open_spice_port (const char *name); +CharDriverState *qemu_chr_open_spice_port(CharDriverSTate *chr,
This needs to be CharDriverState.
include/ui/qemu-spice.h int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, · line 56
Quoted 4 lines
include/ui/qemu-spice.h +1
-0+ const char *name);void qemu_spice_register_ports (void );#else static inline CharDriverState *qemu_chr_open_spice_port (const char *name)
[snip]
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 01/16] qemu-char: Allocate CharDriverState in qemu_chr_new_from_opts
Am 23.01.2014 14:32, schrieb Andreas Färber:
Quoted 25 lines
Am 12.11.2013 17:33, schrieb Corey Minyard:
Quoted 6 lines
This allocates the CharDriverState structure and passes it in to the open routine. This allows a coming option to automatically attempt to reconnect a chardev if the connection fails. The chardev has to be kept around so a reconnect can be done on it.
Signed-off-by Corey Minyard <[email protected]>[...]
Quoted 5 lines
include/ui/qemu-spice.h +0
-0include/ui/qemu-spice.h int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, · line 52
Quoted 9 lines
include/ui/qemu-spice.h +3
-2@@ -46,9 +46,11 @@ 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_vmc (const char *type); +CharDriverState *qemu_chr_open_spice_vmc (CharDriverState *chr, +const char *type);#if SPICE_SERVER_VERSION >=0x000c02 -CharDriverState *qemu_chr_open_spice_port (const char *name); +CharDriverState *qemu_chr_open_spice_port(CharDriverSTate *chr,This needs to be CharDriverState.
Quoted 5 lines
Quoted 4 lines
include/ui/qemu-spice.h +1
-0+ const char *name);void qemu_spice_register_ports (void );#else static inline CharDriverState *qemu_chr_open_spice_port (const char *name)[snip]
I also needed the following:
ui/gtk.c +0 -0
@@ -1113,11 +1113,8 @@ static int gd_vc_chr_write(CharDriverState *chr,
const uint8_t *buf, int len)
static int nb_vcs;
static CharDriverState *vcs[MAX_VCS];
-static CharDriverState *gd_vc_handler(ChardevVC *unused) +static CharDriverState *gd_vc_handler(CharDriverState *chr, ChardevVC *unused)
{
- CharDriverState *chr;
-
- chr = g_malloc0(sizeof(*chr));
chr->chr_write = gd_vc_chr_write;
/* defer OPENED events until our vc is fully initialized */
chr->explicit_be_open = true;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 06/16] ipmi: Add a PC ISA type structure
In reply to Corey MinyardAm 12.11.2013 17:33, schrieb Corey Minyard:
Quoted 4 lines
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>
[...]
Quoted 61 lines
hw/ipmi/isa_ipmi.c new file +55
-0@@ -0,0 +1,148 @@ +/* +* QEMU ISA IPMI 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/hw.h" +#include "hw/isa/isa.h" +#include "hw/i386/pc.h" +#include "qemu/timer.h" +#include "sysemu/char.h" +#include "sysemu/sysemu.h" +#include "ipmi.h" + +/* This is the type the user specifies on the -device command line */ +#define TYPE_ISA_IPMI "isa-ipmi" +#define ISA_IPMI (obj) OBJECT_CHECK(ISAIPMIDevice, (obj), \ + TYPE_ISA_IPMI) +typedef struct ISAIPMIDevice { +ISADevice dev; +char *interface; +uint32_t iobase; +uint32_t isairq; +uint8_t slave_addr; +CharDriverState *chr; +IPMIInterface *intf; +}ISAIPMIDevice ; + +static void ipmi_isa_realizefn (DeviceState *dev,Error **errp) +{ +ISADevice *isadev =ISA_DEVICE (dev); +ISAIPMIDevice *isa =ISA_IPMI (dev); +char typename[20 ]; +Object *intfobj; +IPMIInterface *intf; +Object *bmcobj; +IPMIBmc *bmc; +int rc;
hw/ipmi/isa_ipmi.c line 65
Quoted 10 lines
hw/ipmi/isa_ipmi.c new file +10
-0+ +if (!isa->interface) { + isa->interface =g_strdup ("kcs" ); + } + +if (isa->chr) { + bmcobj =object_new (TYPE_IPMI_BMC_EXTERN ); + }else { + bmcobj =object_new (TYPE_IPMI_BMC_SIMULATOR ); + }
[snip]
This depends on types registered in patches 09 and 10.
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