Add an IPMI device to QEMU
PATCH v5 9/16 ipmi: Add a firmware configuration repository
In reply to [email protected]From: Corey Minyard <[email protected]>
Add a way for IPMI devices to register their firmware information with the IPMI subsystem so that various firmware entities can pull that information later for adding to firmware tables.
--- hw/ipmi/ipmi.c | 27 +++++++++++++++++++++++++++ include/hw/ipmi/ipmi.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+)
hw/ipmi/ipmi.c +27 -0
@@ -123,3 +123,30 @@ static void ipmi_register_types(void) }type_init (ipmi_register_types) + +static IPMIFwInfo *ipmi_fw_info; +static unsigned int ipmi_fw_info_len; + +static uint32_t current_uuid =1 ; + +void ipmi_add_fwinfo (IPMIFwInfo *info,Error **errp) +{ + info->uuid = current_uuid++; + ipmi_fw_info =g_realloc (ipmi_fw_info, +sizeof (*ipmi_fw_info) * (ipmi_fw_info_len +1 )); + ipmi_fw_info[ipmi_fw_info_len] = *info; +} + +IPMIFwInfo *ipmi_first_fwinfo (void ) +{ +return ipmi_fw_info; +} + +IPMIFwInfo *ipmi_next_fwinfo (IPMIFwInfo *current) +{ + current++; +if (current >= &ipmi_fw_info[ipmi_fw_info_len]) { +return NULL ; + } +return current; +}
include/hw/ipmi/ipmi.h +35 -0
@@ -168,6 +168,41 @@ typedef struct IPMIBmcClass {*/ void ipmi_bmc_find_and_link (Object *obj,Object **bmc); +/* +* Used for transferring information to interfaces that add +* entries to firmware tables. +*/ +typedef struct IPMIFwInfo { +const char *interface_name; +int interface_type; +uint8_t ipmi_spec_major_revision; +uint8_t ipmi_spec_minor_revision; +uint8_t i2c_slave_address; +uint32_t uuid; + +uint64_t base_address; +uint64_t register_length; +uint8_t register_spacing; +enum { +IPMI_MEMSPACE_IO , +IPMI_MEMSPACE_MEM32 , +IPMI_MEMSPACE_MEM64 , +IPMI_MEMSPACE_SMBUS + } memspace; + +int interrupt_number; +enum { +IPMI_LEVEL_IRQ , +IPMI_EDGE_IRQ + } irq_type; + +const char *acpi_parent; +}IPMIFwInfo ; + +void ipmi_add_fwinfo (IPMIFwInfo *info,Error **errp); +IPMIFwInfo *ipmi_first_fwinfo (void ); +IPMIFwInfo *ipmi_next_fwinfo (IPMIFwInfo *current); +#ifdef IPMI_DEBUG #define ipmi_debug (fs, ...) \ fprintf(stderr, "IPMI (%s): " fs, __func__, ##__VA_ARGS__)
Signature · 1 line
2.5.0
PATCH v5 7/16 ipmi: Add documentation
In reply to [email protected]From: Corey Minyard <[email protected]>
Add some basic documentation for the IPMI device.
--- qemu-options.hx | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
qemu-options.hx +52 -0
@@ -381,6 +381,58 @@ 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 ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}] + +Add an IPMI BMC. This is a simulation of a hardware management +interface processor that normally sits on a system. It provides +a watchdog and the ability to reset and power control the system. +You need to connect this to an IPMI interface to make it useful + +The IPMI slave address to use for the BMC. The default is 0x20. +This address is the BMC's address on the I2C network of management +controllers. If you don't know what this means, it is safe to ignore +it. + +@item -device ipmi-bmc-extern,id=@var{id},chardev=@var{id}[,slave_addr=@var{val}] + +Add a connection to an external IPMI BMC simulator. Instead of +locally emulating the BMC like the above item, instead connect +to an external entity that provides the IPMI services. + +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. + +@item -device isa-ipmi-kcs,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}] + +Add a KCS IPMI interafce on the ISA bus. This also adds a +corresponding ACPI and SMBIOS entries, if appropriate. + +@table @option +@item bmc=@var{id} +The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above. +@item ioport=@var{val} +Define the I/O address of the interface. The default is 0xca0 for KCS. +@item irq=@var{val} +Define the interrupt to use. The default is 5. To disable interrupts, +set this to 0. +@end table + +@item -device isa-ipmi-bt,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}] + +Like the KCS interface, but defines a BT interface. The default port is +0xe4 and the default interrupt is 5. + ETEXI DEF("name", HAS_ARG, QEMU_OPTION_name,
Signature · 1 line
2.5.0
PATCH v5 8/16 ipmi: Add migration capability to the IPMI devices.
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/ipmi/ipmi_bmc_extern.c | 34 ++++++++++++++++++++++++++++++++++ hw/ipmi/ipmi_bmc_sim.c | 30 ++++++++++++++++++++++++++++++ hw/ipmi/isa_ipmi_bt.c | 24 ++++++++++++++++++++++++ hw/ipmi/isa_ipmi_kcs.c | 26 ++++++++++++++++++++++++++ 4 files changed, 114 insertions(+)
hw/ipmi/ipmi_bmc_extern.c +34 -0
@@ -439,11 +439,45 @@ static void ipmi_bmc_extern_realize(DeviceState *dev, Error **errp)qemu_chr_add_handlers (ibe->chr, can_receive, receive, chr_event, ibe); } +static int ipmi_bmc_extern_post_migrate (void *opaque,int version_id) +{ +IPMIBmcExtern *ibe = opaque; + +/* +* We don't directly restore waiting_rsp, Instead, we return an +* error on the interface if a response was being waited for. +*/ +if (ibe->waiting_rsp) { +IPMIInterface *ii = ibe->parent.intf; +IPMIInterfaceClass *iic =IPMI_INTERFACE_GET_CLASS (ii); + + ibe->waiting_rsp = false; + ibe->inbuf[1 ] = ibe->outbuf[1 ] |0x04 ; + ibe->inbuf[2 ] = ibe->outbuf[2 ]; + ibe->inbuf[3 ] =IPMI_CC_BMC_INIT_IN_PROGRESS ; + iic->handle_rsp (ii, ibe->outbuf[0 ], ibe->inbuf +1 ,3 ); + } +return 0 ; +} + +static const VMStateDescription vmstate_ipmi_bmc_extern = { + .name =TYPE_IPMI_BMC_EXTERN , + .version_id =1 , + .minimum_version_id =1 , + .post_load = ipmi_bmc_extern_post_migrate, + .fields = (VMStateField []) { +VMSTATE_BOOL (send_reset, IPMIBmcExtern), +VMSTATE_BOOL (waiting_rsp, IPMIBmcExtern), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_bmc_extern_init (Object *obj) {IPMIBmcExtern *ibe =IPMI_BMC_EXTERN (obj); ibe->extern_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , extern_timeout, ibe); +vmstate_register (NULL ,0 , &vmstate_ipmi_bmc_extern, ibe); }static Property ipmi_bmc_extern_properties[] = {
hw/ipmi/ipmi_bmc_sim.c +30 -0
@@ -1658,6 +1658,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, IPMIBmcSim), +VMSTATE_UINT8 (msg_flags, IPMIBmcSim), +VMSTATE_BOOL (watchdog_initialized, IPMIBmcSim), +VMSTATE_UINT8 (watchdog_use, IPMIBmcSim), +VMSTATE_UINT8 (watchdog_action, IPMIBmcSim), +VMSTATE_UINT8 (watchdog_pretimeout, IPMIBmcSim), +VMSTATE_BOOL (watchdog_expired, IPMIBmcSim), +VMSTATE_UINT16 (watchdog_timeout, IPMIBmcSim), +VMSTATE_BOOL (watchdog_running, IPMIBmcSim), +VMSTATE_BOOL (watchdog_preaction_ran, IPMIBmcSim), +VMSTATE_INT64 (watchdog_expiry, IPMIBmcSim), +VMSTATE_UINT8_ARRAY (evtbuf, IPMIBmcSim,16 ), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].status, IPMIBmcSim), +VMSTATE_UINT8 (sensors[IPMI_WATCHDOG_SENSOR ].reading, IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].states, IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_states, IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].deassert_states, + IPMIBmcSim), +VMSTATE_UINT16 (sensors[IPMI_WATCHDOG_SENSOR ].assert_enable, IPMIBmcSim), +VMSTATE_END_OF_LIST () + } +}; +static void ipmi_sim_init (Object *obj) {IPMIBmc *b =IPMI_BMC (obj);
@@ -1701,6 +1729,8 @@ static void ipmi_sim_init(Object *obj)register_cmds (ibs); ibs->timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , ipmi_timeout, ibs); + +vmstate_register (NULL ,0 , &vmstate_ipmi_sim, ibs); }static void ipmi_sim_class_init (ObjectClass *oc,void *data)
hw/ipmi/isa_ipmi_bt.c +24 -0
@@ -437,11 +437,35 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &iib->bt.io, iib->bt.io_base); } +static const VMStateDescription vmstate_ISAIPMIBTDevice = { + .name =TYPE_IPMI_INTERFACE , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_BOOL (bt.obf_irq_set, ISAIPMIBTDevice), +VMSTATE_BOOL (bt.atn_irq_set, ISAIPMIBTDevice), +VMSTATE_BOOL (bt.use_irq, ISAIPMIBTDevice), +VMSTATE_BOOL (bt.irqs_enabled, ISAIPMIBTDevice), +VMSTATE_UINT32 (bt.outpos, ISAIPMIBTDevice), +VMSTATE_VBUFFER_UINT32 (bt.outmsg, ISAIPMIBTDevice,1 ,NULL ,0 , + bt.outlen), +VMSTATE_VBUFFER_UINT32 (bt.inmsg, ISAIPMIBTDevice,1 ,NULL ,0 , + bt.inlen), +VMSTATE_UINT8 (bt.control_reg, ISAIPMIBTDevice), +VMSTATE_UINT8 (bt.mask_reg, ISAIPMIBTDevice), +VMSTATE_UINT8 (bt.waiting_rsp, ISAIPMIBTDevice), +VMSTATE_UINT8 (bt.waiting_seq, ISAIPMIBTDevice), +VMSTATE_END_OF_LIST () + } +}; +static void isa_ipmi_bt_init (Object *obj) {ISAIPMIBTDevice *iib =ISA_IPMI_BT (obj);ipmi_bmc_find_and_link (obj, (Object **) &iib->bt.bmc); + +vmstate_register (NULL ,0 , &vmstate_ISAIPMIBTDevice, iib); }static void *isa_ipmi_bt_get_backend_data (IPMIInterface *ii)
hw/ipmi/isa_ipmi_kcs.c +26 -0
@@ -400,11 +400,37 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp)isa_register_ioport (isadev, &iik->kcs.io, iik->kcs.io_base); } +const VMStateDescription vmstate_ISAIPMIKCSDevice = { + .name =TYPE_IPMI_INTERFACE , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_BOOL (kcs.obf_irq_set, ISAIPMIKCSDevice), +VMSTATE_BOOL (kcs.atn_irq_set, ISAIPMIKCSDevice), +VMSTATE_BOOL (kcs.use_irq, ISAIPMIKCSDevice), +VMSTATE_BOOL (kcs.irqs_enabled, ISAIPMIKCSDevice), +VMSTATE_UINT32 (kcs.outpos, ISAIPMIKCSDevice), +VMSTATE_VBUFFER_UINT32 (kcs.outmsg, ISAIPMIKCSDevice,1 ,NULL ,0 , + kcs.outlen), +VMSTATE_VBUFFER_UINT32 (kcs.inmsg, ISAIPMIKCSDevice,1 ,NULL ,0 , + kcs.inlen), +VMSTATE_BOOL (kcs.write_end, ISAIPMIKCSDevice), +VMSTATE_UINT8 (kcs.status_reg, ISAIPMIKCSDevice), +VMSTATE_UINT8 (kcs.data_out_reg, ISAIPMIKCSDevice), +VMSTATE_INT16 (kcs.data_in_reg, ISAIPMIKCSDevice), +VMSTATE_INT16 (kcs.cmd_reg, ISAIPMIKCSDevice), +VMSTATE_UINT8 (kcs.waiting_rsp, ISAIPMIKCSDevice), +VMSTATE_END_OF_LIST () + } +}; +static void isa_ipmi_kcs_init (Object *obj) {ISAIPMIKCSDevice *iik =ISA_IPMI_KCS (obj);ipmi_bmc_find_and_link (obj, (Object **) &iik->kcs.bmc); + +vmstate_register (NULL ,0 , &vmstate_ISAIPMIKCSDevice, iik); }static void *isa_ipmi_kcs_get_backend_data (IPMIInterface *ii)
Signature · 1 line
2.5.0
PATCH v5 10/16 ipmi: Add firmware registration to the ISA interface
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/ipmi/isa_ipmi_bt.c | 15 +++++++++++++++ hw/ipmi/isa_ipmi_kcs.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+)
hw/ipmi/isa_ipmi_bt.c +15 -0
@@ -407,6 +407,7 @@ typedef struct ISAIPMIBTDevice {ISADevice dev;int32 isairq;IPMIBT bt; +IPMIFwInfo fwinfo; } ISAIPMIBTDevice;static void isa_ipmi_bt_realize (DeviceState *dev,Error **errp)
@@ -435,6 +436,20 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, iib->bt.io_base, iib->bt.io_length);isa_register_ioport (isadev, &iib->bt.io, iib->bt.io_base); + + iib->fwinfo.interface_name ="bt" ; + iib->fwinfo.interface_type =IPMI_SMBIOS_BT ; + iib->fwinfo.ipmi_spec_major_revision =2 ; + iib->fwinfo.ipmi_spec_minor_revision =0 ; + iib->fwinfo.base_address = iib->bt.io_base; + iib->fwinfo.register_length = iib->bt.io_length; + iib->fwinfo.register_spacing =1 ; + iib->fwinfo.memspace =IPMI_MEMSPACE_IO ; + iib->fwinfo.irq_type =IPMI_LEVEL_IRQ ; + iib->fwinfo.interrupt_number = iib->isairq; + iib->fwinfo.acpi_parent ="\\_SB.PCI0.ISA" ; + iib->fwinfo.i2c_slave_address = iib->bt.bmc->slave_addr; +ipmi_add_fwinfo (&iib->fwinfo, errp); }static const VMStateDescription vmstate_ISAIPMIBTDevice = {
hw/ipmi/isa_ipmi_kcs.c +15 -0
@@ -370,6 +370,7 @@ typedef struct ISAIPMIKCSDevice {ISADevice dev;int32 isairq;IPMIKCS kcs; +IPMIFwInfo fwinfo; } ISAIPMIKCSDevice;static void ipmi_isa_realize (DeviceState *dev,Error **errp)
@@ -398,6 +399,20 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, iik->kcs.io_base, iik->kcs.io_length);isa_register_ioport (isadev, &iik->kcs.io, iik->kcs.io_base); + + iik->fwinfo.interface_name ="kcs" ; + iik->fwinfo.interface_type =IPMI_SMBIOS_KCS ; + iik->fwinfo.ipmi_spec_major_revision =2 ; + iik->fwinfo.ipmi_spec_minor_revision =0 ; + iik->fwinfo.base_address = iik->kcs.io_base; + iik->fwinfo.i2c_slave_address = iik->kcs.bmc->slave_addr; + iik->fwinfo.register_length = iik->kcs.io_length; + iik->fwinfo.register_spacing =1 ; + iik->fwinfo.memspace =IPMI_MEMSPACE_IO ; + iik->fwinfo.irq_type =IPMI_LEVEL_IRQ ; + iik->fwinfo.interrupt_number = iik->isairq; + iik->fwinfo.acpi_parent ="\\_SB.PCI0.ISA" ; +ipmi_add_fwinfo (&iik->fwinfo, errp); }const VMStateDescription vmstate_ISAIPMIKCSDevice = {
Signature · 1 line
2.5.0
PATCH v5 11/16 smbios: Move table build tools into an include file.
In reply to [email protected]From: Corey Minyard <[email protected]>
This will let things in other files (like IPMI) build SMBIOS tables.
--- hw/smbios/smbios.c | 70 ++++--------------------------------------- hw/smbios/smbios_build.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 64 deletions(-) create mode 100644 hw/smbios/smbios_build.h
hw/smbios/smbios.c +6 -64
@@ -22,6 +22,7 @@#include "hw/smbios/smbios.h" #include "hw/loader.h" #include "exec/cpu-common.h" +#include "smbios_build.h" /* legacy structures and constants for <= 2.0 machines */ struct smbios_header {
@@ -51,10 +52,10 @@ static bool smbios_uuid_encoded = true;/* end: legacy structures & constants for <= 2.0 machines */ -static uint8_t *smbios_tables; -static size_t smbios_tables_len; -static unsigned smbios_table_max; -static unsigned smbios_table_cnt; +uint8_t *smbios_tables; +size_t smbios_tables_len; +unsigned smbios_table_max; +unsigned smbios_table_cnt;static SmbiosEntryPointType smbios_ep_type =SMBIOS_ENTRY_POINT_21 ;static SmbiosEntryPoint ep;
@@ -427,7 +428,7 @@ uint8_t *smbios_get_table_legacy(size_t *length)/* end: legacy setup functions for <= 2.0 machines */ -static bool smbios_skip_table (uint8_t type,bool required_table) +bool smbios_skip_table (uint8_t type,bool required_table) {if (test_bit (type, have_binfile_bitmap)) {return true;/* user provided their own binary blob(s) */
@@ -441,65 +442,6 @@ static bool smbios_skip_table(uint8_t type, bool required_table)return true; } -#define SMBIOS_BUILD_TABLE_PRE (tbl_type, tbl_handle, tbl_required) \ - struct smbios_type_##tbl_type *t; \ - size_t t_off;/* table offset into smbios_tables */ \ -int str_index =0 ; \ -do { \ -/* should we skip building this table ? */ \ -if (smbios_skip_table (tbl_type, tbl_required)) { \ -return ; \ - } \ - \ -/* use offset of table t within smbios_tables */ \ -/* (pointer must be updated after each realloc) */ \ - t_off = smbios_tables_len; \ - smbios_tables_len +=sizeof (*t); \ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len); \ - t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \ - \ - t->header.type = tbl_type; \ - t->header.length =sizeof (*t); \ - t->header.handle =cpu_to_le16 (tbl_handle); \ - } while (0) - -#define SMBIOS_TABLE_SET_STR (tbl_type, field, value) \ - do { \ - int len = (value != NULL) ? strlen(value) + 1 : 0; \ - if (len > 1) { \ - smbios_tables = g_realloc(smbios_tables, \ - smbios_tables_len + len); \ - memcpy(smbios_tables + smbios_tables_len, value, len); \ - smbios_tables_len += len; \ -/* update pointer post-realloc */ \ - t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \ - t->field = ++str_index; \ - } else { \ - t->field = 0; \ - } \ - } while (0) - -#define SMBIOS_BUILD_TABLE_POST \ - do { \ - size_t term_cnt, t_size; \ - \ -/* add '\0' terminator (add two if no strings defined) */ \ - term_cnt = (str_index ==0 ) ?2 :1 ; \ - smbios_tables =g_realloc (smbios_tables, \ - smbios_tables_len + term_cnt); \ -memset (smbios_tables + smbios_tables_len,0 , term_cnt); \ - smbios_tables_len += term_cnt; \ - \ -/* update smbios max. element size */ \ - t_size = smbios_tables_len - t_off; \ -if (t_size > smbios_table_max) { \ - smbios_table_max = t_size; \ - } \ - \ -/* update smbios element count */ \ - smbios_table_cnt++; \ - }while (0 ) -static void smbios_build_type_0_table (void ) {SMBIOS_BUILD_TABLE_PRE (0 ,0x000 , false);/* optional, leave up to BIOS */
hw/smbios/smbios_build.h new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 12/16 pc: Postpone SMBIOS table installation to post machine init
In reply to [email protected]From: Corey Minyard <[email protected]>
This is the same place that the ACPI SSDT table gets added, so that devices can add themselves to the SMBIOS table.
--- hw/i386/pc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/i386/pc.c +6 -5
@@ -781,8 +781,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); -pc_build_smbios (fw_cfg); -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,
@@ -1174,6 +1172,7 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)PcGuestInfoState *guest_info_state =container_of (notifier, PcGuestInfoState, machine_done); +FWCfgState *fw_cfg = guest_info_state->info.fw_cfg;PCIBus *bus =find_i440fx ();if (bus) {
@@ -1185,15 +1184,17 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data) extra_hosts++; } } -if (extra_hosts && guest_info_state->info.fw_cfg) { +if (extra_hosts && fw_cfg) {uint64_t *val =g_malloc (sizeof (*val)); *val =cpu_to_le64 (extra_hosts); -fw_cfg_add_file (guest_info_state->info.fw_cfg, -"etc/extra-pci-roots" , val,sizeof (*val)); +fw_cfg_add_file (fw_cfg,"etc/extra-pci-roots" , val,sizeof (*val)); } }acpi_setup (&guest_info_state->info); +if (fw_cfg) { +pc_build_smbios (fw_cfg); + } }PcGuestInfo *pc_guest_info_init (PCMachineState *pcms)
Signature · 1 line
2.5.0
PATCH v5 13/16 ipmi: Add SMBIOS table entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/smbios/Makefile.objs | 2 + hw/smbios/ipmi.c | 75 ++++++++++++++++++++++++++++++++++++++ hw/smbios/noipmi.c | 14 +++++++ hw/smbios/smbios.c | 2 + include/hw/smbios/ipmi.h | 15 ++++++++ 7 files changed, 110 insertions(+) create mode 100644 hw/smbios/ipmi.c create mode 100644 hw/smbios/noipmi.c create mode 100644 include/hw/smbios/ipmi.h
default-configs/i386-softmmu.mak +1 -0
@@ -20,6 +20,7 @@ CONFIG_I8254=y CONFIG_PCSPK=y CONFIG_PCKBD=y CONFIG_FDC=y +CONFIG_SMBIOS=y CONFIG_ACPI=y CONFIG_ACPI_X86=y CONFIG_ACPI_X86_ICH=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -20,6 +20,7 @@ CONFIG_I8254=y CONFIG_PCSPK=y CONFIG_PCKBD=y CONFIG_FDC=y +CONFIG_SMBIOS=y CONFIG_ACPI=y CONFIG_ACPI_X86=y CONFIG_ACPI_X86_ICH=y
hw/smbios/Makefile.objs +2 -0
@@ -1 +1,3 @@ common-obj-$(CONFIG_SMBIOS) += smbios.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o +common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/smbios/ipmi.c new file +75 -0
75 lines not on this page · raw message
hw/smbios/noipmi.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/smbios/ipmi.h" + +void smbios_build_type_38_table (void ) +{ +}
hw/smbios/smbios.c +2 -0
@@ -23,6 +23,7 @@#include "hw/loader.h" #include "exec/cpu-common.h" #include "smbios_build.h" +#include "hw/smbios/ipmi.h" /* legacy structures and constants for <= 2.0 machines */ struct smbios_header {
@@ -846,6 +847,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array, }smbios_build_type_32_table (); +smbios_build_type_38_table ();smbios_build_type_127_table ();smbios_validate_table ();
include/hw/smbios/ipmi.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_SMBIOS_IPMI_H +#define QEMU_SMBIOS_IPMI_H + +void smbios_build_type_38_table (void ); + +#endif /* QEMU_SMBIOS_IPMI_H */
Signature · 1 line
2.5.0
PATCH v5 3/16 ipmi: Add an external connection simulation interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This adds an interface for IPMI that connects to a remote BMC over a chardev (generally a TCP socket). The OpenIPMI lanserv simulator describes this interface, see that for interface details.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_bmc_extern.c | 478 +++++++++++++++++++++++++++++++++++++ 4 files changed, 481 insertions(+) create mode 100644 hw/ipmi/ipmi_bmc_extern.c
default-configs/i386-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_VIRTIO_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=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
@@ -11,6 +11,7 @@ CONFIG_VIRTIO_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y +CONFIG_IPMI_EXTERN=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_IPMI_LOCAL) += ipmi_bmc_sim.o +common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o
hw/ipmi/ipmi_bmc_extern.c new file +478 -0
478 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 5/16 ipmi: Add a BT low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the BT hardware interface for IPMI.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi_bt.c | 489 +++++++++++++++++++++++++++++++++++++ 4 files changed, 492 insertions(+) create mode 100644 hw/ipmi/isa_ipmi_bt.c
default-configs/i386-softmmu.mak +1 -0
@@ -13,6 +13,7 @@ CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y CONFIG_ISA_IPMI_KCS=y +CONFIG_ISA_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_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y CONFIG_ISA_IPMI_KCS=y +CONFIG_ISA_IPMI_BT=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_IPMI_LOCAL) += ipmi_bmc_sim.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o +common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o
hw/ipmi/isa_ipmi_bt.c new file +489 -0
489 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 14/16 acpi: Add IPMI table entries
In reply to [email protected]From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI. This adds a function called from build_ssdt to add an SSDT entry for IPMI if IPMI is compiled in and has registered firmware. It also adds a dummy function if IPMI is not compiled in.
This conforms to section "C3-2 Locating IPMI System Interfaces in ACPI Name Space" in the IPMI 2.0 specification.
--- hw/acpi/Makefile.objs | 2 + hw/acpi/ipmi.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/noipmi.c | 14 ++++++ hw/i386/acpi-build.c | 4 ++ include/hw/acpi/ipmi.h | 16 +++++++ 5 files changed, 152 insertions(+) create mode 100644 hw/acpi/ipmi.c create mode 100644 hw/acpi/noipmi.c create mode 100644 include/hw/acpi/ipmi.h
hw/acpi/Makefile.objs +2 -0
@@ -5,3 +5,5 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o common-obj-$(CONFIG_ACPI) += aml-build.o +common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o +common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
hw/acpi/ipmi.c new file +116 -0
116 lines not on this page · raw message
hw/acpi/noipmi.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/acpi/ipmi.h" + +void acpi_add_ipmi (Aml *ssdt) +{ +}
hw/i386/acpi-build.c +4 -0
@@ -59,6 +59,8 @@#include "qapi/qmp/qint.h" #include "qom/qom-qobject.h" +#include "hw/acpi/ipmi.h" +/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows * a little bit, there should be plenty of free space since the DSDT
@@ -1346,6 +1348,8 @@ build_ssdt(GArray *table_data, GArray *linker,aml_append (ssdt, sb_scope); } +acpi_add_ipmi (ssdt); +/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, ssdt->buf->data, ssdt->buf->len); build_header(linker, table_data,
include/hw/acpi/ipmi.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* QEMU IPMI ACPI handling +* +* Copyright (c) 2015 Corey Minyard <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef HW_ACPI_IPMI_H +#define HW_ACPI_IPMI_H + +#include "hw/acpi/aml-build.h" + +void acpi_add_ipmi (Aml *ssdt); + +#endif /* HW_ACPI_IPMI_H */
Signature · 1 line
2.5.0
v5 cover Add an IPMI device to QEMU
This is based on the just-released 2.5.0 release, I believe I have fixed/answered all questions on this.
Thanks!
-corey
PATCH v5 1/16 Add a base IPMI interface
From: Corey Minyard <[email protected]>
Add the basic IPMI types and infrastructure to QEMU. Low-level interfaces and simulation interfaces will register with this; it's kind of the go-between to tie them together.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi.c | 125 ++++++++++++++++++++++++++ include/hw/ipmi/ipmi.h | 178 +++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 2 + 7 files changed, 309 insertions(+) create mode 100644 hw/ipmi/Makefile.objs create mode 100644 hw/ipmi/ipmi.c create mode 100644 include/hw/ipmi/ipmi.h
default-configs/i386-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VIRTIO_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
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VIRTIO_VGA=y CONFIG_VMMOUSE=y +CONFIG_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
hw/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += ide/ devices-dirs-$(CONFIG_SOFTMMU) += input/ devices-dirs-$(CONFIG_SOFTMMU) += intc/ devices-dirs-$(CONFIG_IPACK) += ipack/ +devices-dirs-$(CONFIG_IPMI) += 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 +125 -0
125 lines not on this page · raw message
include/hw/ipmi/ipmi.h new file +178 -0
178 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
2.5.0
PATCH v5 15/16 bios: Add tests for the IPMI ACPI and SMBIOS entries
In reply to [email protected]From: Corey Minyard <[email protected]>
--- tests/acpi-test-data/pc/SSDT.ipmikcs | Bin 0 -> 2582 bytes tests/acpi-test-data/q35/SSDT.ipmibt | Bin 0 -> 790 bytes tests/bios-tables-test.c | 58 ++++++++++++++++++++++++++++++++--- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 tests/acpi-test-data/pc/SSDT.ipmikcs create mode 100644 tests/acpi-test-data/q35/SSDT.ipmibt
tests/acpi-test-data/pc/SSDT.ipmikcs new file binary +0 -0
tests/acpi-test-data/q35/SSDT.ipmibt new file binary +0 -0
tests/bios-tables-test.c +54 -4
123 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 6/16 ipmi: Add tests
In reply to [email protected]From: Corey Minyard <[email protected]>
Test the KCS interface with a local BMC and a BT interface with an external BMC.
--- tests/Makefile | 4 + tests/ipmi-bt-test.c | 436 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ipmi-kcs-test.c | 295 ++++++++++++++++++++++++++++++++++ 3 files changed, 735 insertions(+) create mode 100644 tests/ipmi-bt-test.c create mode 100644 tests/ipmi-kcs-test.c
tests/Makefile +4 -0
@@ -166,6 +166,8 @@ gcov-files-i386-y += hw/block/hd-geometry.c check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/bios-tables-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/drive_del-test$(EXESUF)
@@ -488,6 +490,8 @@ tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) tests/fdc-test$(EXESUF): tests/fdc-test.o tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y) tests/ahci-test$(EXESUF): tests/ahci-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/bios-tables-test$(EXESUF): tests/bios-tables-test.o $(libqos-obj-y)
tests/ipmi-bt-test.c new file +436 -0
436 lines not on this page · raw message
tests/ipmi-kcs-test.c new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 4/16 ipmi: Add an ISA KCS low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the KCS hardware interface.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi_kcs.c | 452 +++++++++++++++++++++++++++++++++++++ 4 files changed, 455 insertions(+) create mode 100644 hw/ipmi/isa_ipmi_kcs.c
default-configs/i386-softmmu.mak +1 -0
@@ -12,6 +12,7 @@ CONFIG_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y +CONFIG_ISA_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_VMMOUSE=y CONFIG_IPMI=y CONFIG_IPMI_LOCAL=y CONFIG_IPMI_EXTERN=y +CONFIG_ISA_IPMI_KCS=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_IPMI_LOCAL) += ipmi_bmc_sim.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o +common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o
hw/ipmi/isa_ipmi_kcs.c new file +452 -0
452 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 2/16 ipmi: Add a local BMC simulation
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides a minimal local BMC, basically enough to comply with the spec and provide a complete watchdog timer (including a sensor, SDR, and event).
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_bmc_sim.c | 1726 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1729 insertions(+) create mode 100644 hw/ipmi/ipmi_bmc_sim.c
default-configs/i386-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VIRTIO_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_IPMI_LOCAL=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y CONFIG_VIRTIO_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_IPMI_LOCAL=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_IPMI_LOCAL) += ipmi_bmc_sim.o
hw/ipmi/ipmi_bmc_sim.c new file +1726 -0
1,726 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v5 16/16 ipmi: Add a force off function
In reply to [email protected]From: Corey Minyard <[email protected]>
Allow the IPMI interface to request a forced power off.
--- hw/ipmi/ipmi_bmc_extern.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/ipmi/ipmi_bmc_extern.c +6 -0
@@ -30,6 +30,7 @@#include <stdint.h> #include "qemu/timer.h" #include "sysemu/char.h" +#include "sysemu/sysemu.h" #include "hw/ipmi/ipmi.h" #define VM_MSG_CHAR 0xA0/* Marks end of message */
@@ -52,6 +53,7 @@#define VM_CAPABILITIES_IRQ 0x04#define VM_CAPABILITIES_NMI 0x08#define VM_CAPABILITIES_ATTN 0x10 +#define VM_CMD_FORCEOFF 0x09#define TYPE_IPMI_BMC_EXTERN "ipmi-bmc-extern"#define IPMI_BMC_EXTERN (obj) OBJECT_CHECK(IPMIBmcExtern, (obj), \
@@ -268,6 +270,10 @@ static void handle_hw_op(IPMIBmcExtern *ibe, unsigned char hw_op)case VM_CMD_SEND_NMI : k->do_hw_op (s,IPMI_SEND_NMI ,0 );break ; + +case VM_CMD_FORCEOFF : +qemu_system_shutdown_request (); +break ; } }
Signature · 1 line
2.5.0