Update to adding an IPMI device to qemu
cover Update to adding an IPMI device to qemu
The major changes from last time are:
* Don't use callbacks for adding firmware tables, provide binary blobs instead.
* Add the SSDT as a separate table.
* Modify the BIOS tests to test for the IPMI tables.
-corey
PATCH 1/17 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 | 135 +++++++++++++++++++++++ hw/ipmi/ipmi.h | 215 +++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 2 + 7 files changed, 356 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
@@ -8,6 +8,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
@@ -8,6 +8,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
@@ -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_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 +135 -0
135 lines not on this page · raw message
hw/ipmi/ipmi.h new file +215 -0
215 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 2/17 ipmi: Add a PC ISA type structure
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 144 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.c
default-configs/i386-softmmu.mak +1 -0
@@ -9,6 +9,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
@@ -9,6 +9,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_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += ipmi.o
hw/ipmi/isa_ipmi.c new file +144 -0
144 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 3/17 ipmi: Add a KCS low-level interface
In reply to [email protected]From: Corey Minyard <[email protected]>
This provides the simulation of the KCS hardware interface.
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_kcs.c | 337 +++++++++++++++++++++++++++++++++++++ 4 files changed, 340 insertions(+) create mode 100644 hw/ipmi/ipmi_kcs.c
default-configs/i386-softmmu.mak +1 -0
@@ -10,6 +10,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
@@ -10,6 +10,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_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += ipmi.o +common-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o
hw/ipmi/ipmi_kcs.c new file +337 -0
337 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 4/17 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/ipmi_bt.c | 374 +++++++++++++++++++++++++++++++++++++ 4 files changed, 377 insertions(+) create mode 100644 hw/ipmi/ipmi_bt.c
default-configs/i386-softmmu.mak +1 -0
@@ -11,6 +11,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
@@ -11,6 +11,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_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += 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 +374 -0
374 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 5/17 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_sim.c | 1730 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1733 insertions(+) create mode 100644 hw/ipmi/ipmi_sim.c
default-configs/i386-softmmu.mak +1 -0
@@ -12,6 +12,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
@@ -12,6 +12,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_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += 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 +1730 -0
1,730 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 6/17 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_extern.c | 457 +++++++++++++++++++++++++++++++++++++ 4 files changed, 460 insertions(+) create mode 100644 hw/ipmi/ipmi_extern.c
default-configs/i386-softmmu.mak +1 -0
@@ -13,6 +13,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
@@ -13,6 +13,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_IPMI) += 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 +457 -0
457 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 7/17 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 | 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
@@ -146,6 +146,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)
@@ -326,6 +328,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 +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 8/17 ipmi: Add documentation
In reply to [email protected]From: Corey Minyard <[email protected]>
Add some basic documentation for the IPMI device.
--- qemu-options.hx | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
qemu-options.hx +38 -0
@@ -373,6 +373,44 @@ 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 ACPI and SMBIOS entries, +if appropriate. 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. +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 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 9/17 ipmi: Add migration capability to the IPMI device.
In reply to [email protected]From: Corey Minyard <[email protected]>
--- 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
@@ -118,6 +118,23 @@ void ipmi_bmc_init(IPMIBmc *s, Error **errp) } } +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
@@ -153,6 +153,8 @@ typedef struct IPMIInterfaceClass { unsigned char *rsp, unsigned int rsp_len); } IPMIInterfaceClass; +extern const VMStateDescription vmstate_IPMIInterface; +void ipmi_interface_init (IPMIInterface *s,Error **errp);void ipmi_interface_reset (IPMIInterface *s);
hw/ipmi/ipmi_bt.c +14 -0
@@ -335,6 +335,19 @@ static void ipmi_bt_handle_reset(IPMIInterface *s, bool is_cold) } } +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 void ipmi_bt_init (IPMIInterface *s,Error **errp) {IPMIBtInterface *bt =IPMI_INTERFACE_BT (s);
@@ -345,6 +358,7 @@ static void ipmi_bt_init(IPMIInterface *s, Error **errp) s->io_length =3 ;memory_region_init_io (&s->io,NULL , &ipmi_bt_io_ops, bt,"ipmi-bt" ,3 ); +vmstate_register (NULL ,0 , &vmstate_ipmi_bt, bt); }static void ipmi_bt_class_init (ObjectClass *klass,void *data)
hw/ipmi/ipmi_extern.c +38 -4
60 lines not on this page · raw message
hw/ipmi/ipmi_kcs.c +15 -0
@@ -299,6 +299,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 void ipmi_kcs_init (IPMIInterface *s,Error **errp) {IPMIKcsInterface *kcs =IPMI_INTERFACE_KCS (s);
@@ -309,6 +323,7 @@ static void ipmi_kcs_init(IPMIInterface *s, Error **errp) s->io_length =2 ;memory_region_init_io (&s->io,NULL , &ipmi_kcs_io_ops, kcs,"ipmi-kcs" ,2 ); +vmstate_register (NULL ,0 , &vmstate_ipmi_kcs, kcs); }static void ipmi_kcs_class_init (ObjectClass *class,void *data)
hw/ipmi/ipmi_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, 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 void ipmi_sim_init (IPMIBmc *b,Error **errp) {unsigned int i;
@@ -1705,6 +1733,8 @@ static void ipmi_sim_init(IPMIBmc *b, Error **errp)register_cmds (ss); ss->timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , ipmi_timeout, ss); + +vmstate_register (NULL ,0 , &vmstate_ipmi_sim, ss); }static void ipmi_sim_class_init (ObjectClass *klass,void *data)
hw/ipmi/isa_ipmi.c +12 -0
@@ -121,11 +121,23 @@ 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 10/17 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 | 25 +++++++++++++++++++++++++ hw/ipmi/ipmi.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
hw/ipmi/ipmi.c +25 -0
@@ -150,3 +150,28 @@ static void ipmi_register_types(void) }type_init (ipmi_register_types) + +struct fw_entry_handlers { +IPMIFwHandler handler; +void *opaque; +QSLIST_ENTRY (fw_entry_handlers) next; +}; +static QSLIST_HEAD(, fw_entry_handlers) fw_entries; + +void ipmi_add_fwinfo (IPMIFwInfo *info) +{ +struct fw_entry_handlers *e; + + QSLIST_FOREACH(e, &fw_entries, next) { + e->handler (info, e->opaque); + } +} + +void ipmi_register_fwinfo_handler (IPMIFwHandler handler,void *opaque) +{ +struct fw_entry_handlers *e =g_malloc (sizeof (*e)); + + e->handler = handler; + e->opaque = opaque; +QSLIST_INSERT_HEAD (&fw_entries, e, next); +}
hw/ipmi/ipmi.h +36 -0
@@ -25,6 +25,7 @@#ifndef HW_IPMI_H #define HW_IPMI_H +#include <qemu/queue.h> #include "exec/memory.h" #include "qemu-common.h" #include "hw/qdev.h"
@@ -207,6 +208,41 @@ typedef struct IPMIBmcClass {void ipmi_bmc_init (IPMIBmc *s,Error **errp); +/* +* 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; + +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 ; + +typedef void (*IPMIFwHandler )(IPMIFwInfo *info,void *opaque); + +void ipmi_add_fwinfo (IPMIFwInfo *info); +void ipmi_register_fwinfo_handler (IPMIFwHandler handler,void *opaque); +#ifdef IPMI_DEBUG #define ipmi_debug (fs, ...) \ fprintf(stderr, "IPMI (%s): " fs, __func__, ##__VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH 12/17 smbios: Add a function to directly add an entry
In reply to [email protected]From: Corey Minyard <[email protected]>
There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.
--- hw/i386/smbios.c | 153 +++++++++++++++++++++++++++++++---------------- include/hw/i386/smbios.h | 8 +++ 2 files changed, 109 insertions(+), 52 deletions(-)
hw/i386/smbios.c +101 -52
@@ -831,6 +831,92 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } +struct smbios_table_entry { +void *data; +int size; +bool append_zeros; +QSLIST_ENTRY (smbios_table_entry) next; +}; + +static QSLIST_HEAD(, smbios_table_entry) table_entries; + +void smbios_add_table_entry (void *data,int size,bool append_zeros) +{ +struct smbios_table_entry *e =g_malloc (sizeof (*e)); + + e->data =g_malloc (size); +memcpy (e->data, data, size); + e->size = size; + e->append_zeros = append_zeros; +QSLIST_INSERT_HEAD (&table_entries, e, next); +} + +static void smbios_table_entry_append (void *data,int size,bool append_zeros) +{ +struct smbios_structure_header *header; +struct smbios_table *table;/* legacy mode only */ + +/* +* NOTE: standard double '\0' terminator expected, per smbios spec. +* (except in legacy mode, where the second '\0' is implicit and +* will be inserted by the BIOS). +*/ +if (append_zeros) { + size +=2 ; + } + smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); + header = (struct smbios_structure_header *)(smbios_tables + + smbios_tables_len); + +memcpy (header, data, size); +if (append_zeros) { +memset (smbios_tables + smbios_tables_len + size -2 ,0 ,2 ); + } + +if (test_bit (header->type, have_fields_bitmap)) { +error_report ("can't load type %d struct, fields already specified!" , + header->type); +exit (1 ); + } +set_bit (header->type, have_binfile_bitmap); + +if (header->type ==4 ) { + smbios_type4_count++; + } + + smbios_tables_len += size; +if (size > smbios_table_max) { + smbios_table_max = size; + } + smbios_table_cnt++; + +/* add a copy of the newly loaded blob to legacy smbios_entries */ +/* NOTE: This code runs before smbios_set_defaults(), so we don't +* yet know which mode (legacy vs. aggregate-table) will be +* required. We therefore add the binary blob to both legacy +* (smbios_entries) and aggregate (smbios_tables) tables, and +* delete the one we don't need from smbios_set_defaults(), +* once we know which machine version has been requested. +*/ +if (!smbios_entries) { + smbios_entries_len =sizeof (uint16_t ); + smbios_entries =g_malloc0 (smbios_entries_len); + } +if (append_zeros) { + size -=1 ;/* The BIOS adds the second zero in legacy mode. */ + } + smbios_entries =g_realloc (smbios_entries, smbios_entries_len + + size +sizeof (*table)); + table = (struct smbios_table *)(smbios_entries + smbios_entries_len); + table->header.type =SMBIOS_TABLE_ENTRY ; + table->header.length =cpu_to_le16 (sizeof (*table) + size); +memcpy (table->data, header, size); + smbios_entries_len +=sizeof (*table) + size; + (*(uint16_t *)smbios_entries) = +cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); +/* end: add a copy of the newly loaded blob to legacy smbios_entries */ +} +void smbios_get_tables (uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) {
@@ -875,6 +961,16 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, }smbios_build_type_32_table (); + +while (!QSLIST_EMPTY (&table_entries)) { +struct smbios_table_entry *e =QSLIST_FIRST (&table_entries); + +QSLIST_REMOVE_HEAD (&table_entries, next); +smbios_table_entry_append (e->data, e->size, e->append_zeros); +g_free (e->data); +g_free (e); + } +smbios_build_type_127_table ();smbios_validate_table ();
@@ -907,9 +1003,8 @@ void smbios_entry_add(QemuOpts *opts) val =qemu_opt_get (opts,"file" );if (val) { -struct smbios_structure_header *header;int size; -struct smbios_table *table;/* legacy mode only */ +uint8_t *data;qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err);if (local_err) {
@@ -923,60 +1018,14 @@ void smbios_entry_add(QemuOpts *opts)exit (1 ); } -/* -* NOTE: standard double '\0' terminator expected, per smbios spec. -* (except in legacy mode, where the second '\0' is implicit and -* will be inserted by the BIOS). -*/ - smbios_tables =g_realloc (smbios_tables, smbios_tables_len + size); - header = (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); - -if (load_image (val, (uint8_t *)header) != size) { + data =g_malloc (size); +if (load_image (val, data) != size) {error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); } -if (test_bit (header->type, have_fields_bitmap)) { -error_report ("can't load type %d struct, fields already specified!" , - header->type); -exit (1 ); - } -set_bit (header->type, have_binfile_bitmap); - -if (header->type ==4 ) { - smbios_type4_count++; - } - - smbios_tables_len += size; -if (size > smbios_table_max) { - smbios_table_max = size; - } - smbios_table_cnt++; - -/* add a copy of the newly loaded blob to legacy smbios_entries */ -/* NOTE: This code runs before smbios_set_defaults(), so we don't -* yet know which mode (legacy vs. aggregate-table) will be -* required. We therefore add the binary blob to both legacy -* (smbios_entries) and aggregate (smbios_tables) tables, and -* delete the one we don't need from smbios_set_defaults(), -* once we know which machine version has been requested. -*/ -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 + - size +sizeof (*table)); - table = (struct smbios_table *)(smbios_entries + smbios_entries_len); - table->header.type =SMBIOS_TABLE_ENTRY ; - table->header.length =cpu_to_le16 (sizeof (*table) + size); -memcpy (table->data, header, size); - smbios_entries_len +=sizeof (*table) + size; - (*(uint16_t *)smbios_entries) = -cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -/* end: add a copy of the newly loaded blob to legacy smbios_entries */ - +smbios_table_entry_append (data, size, false); +g_free (data);return ; }
include/hw/i386/smbios.h +8 -0
@@ -27,6 +27,14 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len);/* +* Add an external entry to the SMBIOS table. Can only be called +* from a registered device table handler. This will store the +* given data in a queue and append it when the SMBIOS table is +* built. +*/ +void smbios_add_table_entry (void *data,int size,bool append_zeros); + +/* * SMBIOS spec defined tables */
Signature · 1 line
1.8.3.1
PATCH 13/17 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 | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
hw/i386/pc.c +18 -17
@@ -680,8 +680,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)static FWCfgState *bochs_bios_init (void ) {FWCfgState *fw_cfg; -uint8_t *smbios_tables, *smbios_anchor; -size_t smbios_tables_len, smbios_anchor_len;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);
@@ -707,21 +705,6 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_tables =smbios_get_table_legacy (&smbios_tables_len); -if (smbios_tables) { -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_tables, smbios_tables_len); - } - -smbios_get_tables (&smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); -if (smbios_anchor) { -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , - smbios_tables, smbios_tables_len); -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , - smbios_anchor, smbios_anchor_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,
@@ -1119,7 +1102,25 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)PcGuestInfoState *guest_info_state =container_of (notifier, PcGuestInfoState, machine_done); +uint8_t *smbios_tables, *smbios_anchor; +size_t smbios_tables_len, smbios_anchor_len; +FWCfgState *fw_cfg = guest_info_state->info.fw_cfg; +acpi_setup (&guest_info_state->info); + + smbios_tables =smbios_get_table_legacy (&smbios_tables_len); +if (smbios_tables) { +fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_tables, smbios_tables_len); + } +smbios_get_tables (&smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); +if (smbios_anchor) { +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , + smbios_tables, smbios_tables_len); +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , + smbios_anchor, smbios_anchor_len); + } } PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
Signature · 1 line
1.8.3.1
PATCH 14/17 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/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_smbios.c | 89 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 hw/ipmi/ipmi_smbios.c
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_APM=y CONFIG_I8257=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_APM=y CONFIG_I8257=y
hw/ipmi/Makefile.objs +1 -0
@@ -4,3 +4,4 @@ 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 +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o
hw/ipmi/ipmi_smbios.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 15/17 acpi: Add a way for devices to add ACPI tables
In reply to [email protected]From: Corey Minyard <[email protected]>
Some devices, like IPMI, need to add ACPI table entries to report their presence. Add a method for adding these entries.
--- hw/acpi/Makefile.objs | 1 + hw/acpi/acpi-dev-tables.c | 80 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 17 +++++++++ include/hw/acpi/acpi-dev-tables.h | 38 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 hw/acpi/acpi-dev-tables.c create mode 100644 include/hw/acpi/acpi-dev-tables.h
hw/acpi/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ common-obj-$(CONFIG_ACPI) += 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-$(CONFIG_ACPI) += acpi-dev-tables.o
hw/acpi/acpi-dev-tables.c new file +80 -0
80 lines not on this page · raw message
hw/i386/acpi-build.c +17 -0
@@ -35,6 +35,7 @@#include "hw/timer/hpet.h" #include "hw/i386/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h" #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/loader.h"
@@ -1377,6 +1378,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)AcpiMcfgInfo mcfg;PcPciInfo pci;uint8_t *u; +struct acpi_dev_table *dt;size_t aml_len =0 ;GArray *tables_blob = tables->table_data;
@@ -1448,6 +1450,21 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)build_dmar_q35 (tables_blob, tables->linker); } +/* Add tables from devices. */ +for (dt =acpi_dev_table_first (); dt; dt =acpi_dev_table_next (dt)) { +unsigned len =acpi_dev_table_len (dt); +void *data =acpi_dev_table_data (dt); + +acpi_add_table (table_offsets, tables_blob); +acpi_data_push (tables_blob,sizeof (AcpiTableHeader)); +g_array_append_vals (tables_blob, data, len); +build_header (tables->linker, tables_blob, + (void *)(tables_blob->data + tables_blob->len - + len -sizeof (AcpiTableHeader)), +acpi_dev_table_sig (dt), len +sizeof (AcpiTableHeader), +acpi_dev_table_rev (dt)); + } +/* Add tables supplied by user (if any) */ for (u =acpi_table_first (); u; u =acpi_table_next (u)) {unsigned len =acpi_table_len (u);
include/hw/acpi/acpi-dev-tables.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Add and get ACPI tables registered by devices. +* +* Copyright (C) 2015 Corey Minyard <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef QEMU_HW_ACPI_HOOKS_H +#define QEMU_HW_ACPI_HOOKS_H + +#include <hw/acpi/aml-build.h> + +void add_acpi_dev_table (void *data,int size,const char *sig,uint8_t rev); + +struct acpi_dev_table ; + +struct acpi_dev_table *acpi_dev_table_first (void ); +struct acpi_dev_table *acpi_dev_table_next (struct acpi_dev_table *current); +uint8_t *acpi_dev_table_data (struct acpi_dev_table *); +unsigned acpi_dev_table_len (struct acpi_dev_table *); +const char *acpi_dev_table_sig (struct acpi_dev_table *); +uint8_t acpi_dev_table_rev (struct acpi_dev_table *); + +#endif /* QEMU_HW_ACPI_HOOKS_H */
Signature · 1 line
1.8.3.1
PATCH 16/17 ipmi: Add ACPI 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.
--- hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_acpi.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ipmi/isa_ipmi.c | 4 ++ 3 files changed, 127 insertions(+) create mode 100644 hw/ipmi/ipmi_acpi.c
hw/ipmi/Makefile.objs +1 -0
@@ -5,3 +5,4 @@ common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_ACPI)) += ipmi_acpi.o
hw/ipmi/ipmi_acpi.c new file +122 -0
122 lines not on this page · raw message
hw/ipmi/isa_ipmi.c +4 -0
@@ -37,6 +37,8 @@ typedef struct ISAIPMIDevice {ISADevice dev;char *interface;uint32_t iobase; +uint32_t iolength; +uint8_t regspacing;int32 isairq;uint8_t slave_addr;CharDriverState *chr;
@@ -73,12 +75,14 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) intfk =IPMI_INTERFACE_GET_CLASS (intf); bmc->intf = intf; intf->bmc = bmc; + ipmi->regspacing =1 ; intf->io_base = ipmi->iobase; intf->slave_addr = ipmi->slave_addr;ipmi_interface_init (intf, errp);if (*errp) {return ; } + ipmi->iolength = intf->io_length;ipmi_bmc_init (bmc, errp);if (*errp) {return ;
Signature · 1 line
1.8.3.1
PATCH 17/17 bios: Add tests for the IPMI ACPI and SMBIOS entries
In reply to [email protected]From: Corey Minyard <[email protected]>
--- tests/bios-tables-test.c | 112 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 107 insertions(+), 5 deletions(-)
tests/bios-tables-test.c +107 -5
@@ -51,6 +51,10 @@ typedef struct {GArray *tables;uint32_t smbios_ep_addr;struct smbios_entry_point smbios_ep_table; +uint8_t *ssdt_compare; +int ssdt_compare_len; +uint8_t *required_struct_types; +int required_struct_types_len; } test_data;#define LOW (x) ((x) & 0xff)
@@ -105,6 +109,12 @@ typedef struct {ACPI_READ_FIELD ((table)->asl_compiler_revision, addr); \ }while (0 ); +static bool acpi_cmp32 (uint32_t actual,const char *expected) +{ + actual =cpu_to_le32 (actual); +return memcmp (&actual, expected,4 ) ==0 ; +} +#define ACPI_ASSERT_CMP (actual, expected) do { \ uint32_t ACPI_ASSERT_CMP_le = cpu_to_le32(actual); \ char ACPI_ASSERT_CMP_str[5] = {}; \
@@ -376,15 +386,28 @@ static void test_acpi_tables(test_data *data) {int tables_nr = data->rsdt_tables_nr -1 ;/* fadt is first */ int i; +bool match_found = !data->ssdt_compare;for (i =0 ; i < tables_nr; i++) {AcpiSdtTable ssdt_table; -memset (&ssdt_table,0 ,sizeof (ssdt_table)); +memset (&ssdt_table,0 ,sizeof (ssdt_table));uint32_t addr = data->rsdt_tables_addr[i +1 ];/* fadt is first */ test_dst_table (&ssdt_table, addr); -g_array_append_val (data->tables, ssdt_table); + +if (data->ssdt_compare && +acpi_cmp32 (ssdt_table.header.signature,"SSDT" ) && + data->ssdt_compare_len == ssdt_table.aml_len && +memcmp (data->ssdt_compare, ssdt_table.aml, + ssdt_table.aml_len) ==0 ) { + match_found = true; +g_free (ssdt_table.aml); + }else { +g_array_append_val (data->tables, ssdt_table); + } } + +g_assert (match_found); }static void dump_aml_files (test_data *data,bool rebuild)
@@ -672,7 +695,6 @@ static void test_smbios_structs(test_data *data)uint32_t addr = ep_table->structure_table_address;int i, len, max_len =0 ;uint8_t type, prv, crt; -uint8_t required_struct_types[] = {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,127 };/* walk the smbios tables */ for (i =0 ; i < ep_table->number_of_structures; i++) {
@@ -712,8 +734,8 @@ static void test_smbios_structs(test_data *data) g_assert_cmpuint(ep_table->max_structure_size, ==, max_len);/* required struct types must all be present */ -for (i =0 ; i <ARRAY_SIZE (required_struct_types); i++) { -g_assert (test_bit (required_struct_types[i], struct_bitmap)); +for (i =0 ; i < data->required_struct_types_len; i++) { +g_assert (test_bit (data->required_struct_types[i], struct_bitmap)); } }
@@ -775,6 +797,9 @@ static void test_acpi_one(const char *params, test_data *data)g_free (args); } +static uint8_t base_required_struct_types[] = + {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,127 }; +static void test_acpi_piix4_tcg (void ) {test_data data;
@@ -784,6 +809,8 @@ static void test_acpi_piix4_tcg(void)*/ memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine accel=tcg" , &data);free_test_data (&data); }
@@ -795,6 +822,8 @@ static void test_acpi_piix4_tcg_bridge(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; data.variant =".bridge" ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine accel=tcg -device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); }
@@ -805,6 +834,8 @@ static void test_acpi_q35_tcg(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine q35,accel=tcg" , &data);free_test_data (&data); }
@@ -816,11 +847,80 @@ static void test_acpi_q35_tcg_bridge(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; data.variant =".bridge" ; + data.required_struct_types = base_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); } +static uint8_t ipmi_ssdt_bt_irq5[] = { +0x10 ,0x42 ,0x06 ,0x5c ,0x2f ,0x03 ,0x5f ,0x53 , +0x42 ,0x5f ,0x50 ,0x43 ,0x49 ,0x30 ,0x49 ,0x53 , +0x41 ,0x5f ,0x5b ,0x82 ,0x4f ,0x04 ,0x4d ,0x49 , +0x30 ,0x5f ,0x08 ,0x5f ,0x48 ,0x49 ,0x44 ,0x0c , +0x26 ,0x09 ,0x00 ,0x01 ,0x08 ,0x5f ,0x53 ,0x54 , +0x52 ,0x0d ,0x69 ,0x70 ,0x6d ,0x69 ,0x5f ,0x62 , +0x74 ,0x00 ,0x08 ,0x5f ,0x55 ,0x49 ,0x44 ,0x00 , +0x08 ,0x5f ,0x43 ,0x52 ,0x53 ,0x11 ,0x10 ,0x0a , +0x0d ,0x47 ,0x01 ,0xe4 ,0x00 ,0xe6 ,0x00 ,0x00 , +0x03 ,0x22 ,0x20 ,0x00 ,0x79 ,0x00 ,0x14 ,0x09 , +0x5f ,0x49 ,0x46 ,0x54 ,0x00 ,0xa4 ,0x0a ,0x03 , +0x14 ,0x0a ,0x5f ,0x53 ,0x52 ,0x56 ,0x00 ,0xa4 , +0x0b ,0x00 ,0x02 +}; + +static uint8_t ipmi_ssdt_kcs_irq0[] = { +0x10 ,0x4f ,0x05 ,0x5c ,0x2f ,0x03 ,0x5f ,0x53 , +0x42 ,0x5f ,0x50 ,0x43 ,0x49 ,0x30 ,0x49 ,0x53 , +0x41 ,0x5f ,0x5b ,0x82 ,0x4c ,0x04 ,0x4d ,0x49 , +0x30 ,0x5f ,0x08 ,0x5f ,0x48 ,0x49 ,0x44 ,0x0c , +0x26 ,0x09 ,0x00 ,0x01 ,0x08 ,0x5f ,0x53 ,0x54 , +0x52 ,0x0d ,0x69 ,0x70 ,0x6d ,0x69 ,0x5f ,0x6b , +0x63 ,0x73 ,0x00 ,0x08 ,0x5f ,0x55 ,0x49 ,0x44 , +0x00 ,0x08 ,0x5f ,0x43 ,0x52 ,0x53 ,0x11 ,0x0d , +0x0a ,0x0a ,0x47 ,0x01 ,0xa2 ,0x0c ,0xa3 ,0x0c , +0x00 ,0x02 ,0x79 ,0x00 ,0x14 ,0x08 ,0x5f ,0x49 , +0x46 ,0x54 ,0x00 ,0xa4 ,0x01 ,0x14 ,0x0a ,0x5f , +0x53 ,0x52 ,0x56 ,0x00 ,0xa4 ,0x0b ,0x00 ,0x02 +}; + +static uint8_t ipmi_required_struct_types[] = + {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,38 ,127 }; + +static void test_acpi_q35_tcg_ipmi (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.ssdt_compare = ipmi_ssdt_bt_irq5; + data.ssdt_compare_len =sizeof (ipmi_ssdt_bt_irq5); + data.required_struct_types = ipmi_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (ipmi_required_struct_types); +test_acpi_one ("-machine q35,accel=tcg -device isa-ipmi,interface=bt" , + &data); +free_test_data (&data); +} + +static void test_acpi_piix4_tcg_ipmi (void ) +{ +test_data data; + +/* Supplying -machine accel argument overrides the default (qtest). +* This is to make guest actually run. +*/ +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.ssdt_compare = ipmi_ssdt_kcs_irq0; + data.ssdt_compare_len =sizeof (ipmi_ssdt_kcs_irq0); + data.required_struct_types = ipmi_required_struct_types; + data.required_struct_types_len =ARRAY_SIZE (ipmi_required_struct_types); +test_acpi_one ("-machine accel=tcg -device isa-ipmi,interface=kcs,irq=0" , + &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -841,6 +941,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/tcg/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35/tcg" , test_acpi_q35_tcg);qtest_add_func ("acpi/q35/tcg/bridge" , test_acpi_q35_tcg_bridge); +qtest_add_func ("acpi/piix4/tcg/ipmi" , test_acpi_piix4_tcg_ipmi); +qtest_add_func ("acpi/q35/tcg/ipmi" , test_acpi_q35_tcg_ipmi); } ret =g_test_run ();unlink (disk);
Signature · 1 line
1.8.3.1
Quoted 1 line · On 04/23/2015 04:57 PM, [email protected] wrote:
The major changes from last time are:
That says this series should probably be named v2 (git format-patch/send-email -v2) or later, as part of the subject line. If the previous version is more than a couple weeks ago, it's also nice (but not required) to provide a URL to the archives of the previous discussion.
Quoted 8 lines
* Don't use callbacks for adding firmware tables, provide binary blobs instead.
* Add the SSDT as a separate table.
* Modify the BIOS tests to test for the IPMI tables.
Also, you might want to use git format-patch --cover-letter, which helps form a 00/17 letter with a diffstat pre-filled; the diffstat gives reviewers a quick glance at what files are touched, and how many lines of code are being impacted, which makes it easier to decide when to schedule a review for the series.
More patch submission hints at: http://wiki.qemu.org/Contribute/SubmitAPatch
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 8 lines · On 24/04/2015 00:57, [email protected] wrote:
The major changes from last time are:
* Don't use callbacks for adding firmware tables, provide binary blobs instead.
* Add the SSDT as a separate table.
* Modify the BIOS tests to test for the IPMI tables.
I disagree with both of the first two changes, but thanks for doing them nevertheless. Michael, is this okay with you now?
Paolo
Quoted 4 lines · Paolo Bonzini
Quoted 2 lines · On 24/04/2015 00:57, [email protected] wrote:
The major changes from last time are:
Quoted 8 lines
Quoted 6 lines
* Don't use callbacks for adding firmware tables, provide binary blobs instead.
* Add the SSDT as a separate table.
* Modify the BIOS tests to test for the IPMI tables.
I disagree with both of the first two changes, but thanks for doing them nevertheless. Michael, is this okay with you now?
To me it was not a big deal either way. The change made the code a bit more consistent with what was already there, and having the SSDT as a separate table made the testing a lot easier, as Michael said it would.
-corey
Re: [Qemu-devel] [PATCH 16/17] ipmi: Add ACPI table entries
In reply to [email protected]Quoted 6 lines · On Thu, Apr 23, 2015 at 05:57:57PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
Use the new ACPI table construction tools to create an ACPI entry for IPMI.
Signed-off-by Corey Minyard <[email protected]>
Quoted 175 lines
--- hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_acpi.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ipmi/isa_ipmi.c | 4 ++ 3 files changed, 127 insertions(+) create mode 100644 hw/ipmi/ipmi_acpi.chw/ipmi/Makefile.objs +1
-0@@ -5,3 +5,4 @@ common-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.o +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_ACPI)) += ipmi_acpi.ohw/ipmi/ipmi_acpi.c new file +122
-0@@ -0,0 +1,122 @@ +/* +* IPMI ACPI firmware handling +* +* Copyright (c) 2015 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 "ipmi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-dev-tables.h" +#include <qemu/error-report.h> + +static Aml *aml_ipmi_crs (IPMIFwInfo *info) +{ +Aml *crs =aml_resource_template (); +uint8_t regspacing = info->register_spacing; + +if (regspacing ==1 ) { + regspacing =0 ; + } + +switch (info->memspace) { +case IPMI_MEMSPACE_IO : +aml_append (crs,aml_io (aml_decode16, info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_MEM32 : +aml_append (crs, +aml_dword_memory (aml_pos_decode, + aml_min_fixed, aml_max_fixed, + aml_non_cacheable, aml_ReadWrite, +0xffffffff , + info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_MEM64 : +aml_append (crs, +aml_qword_memory (aml_pos_decode, + aml_min_fixed, aml_max_fixed, + aml_non_cacheable, aml_ReadWrite, +0xffffffffffffffffULL , + info->base_address, + info->base_address + info->register_length -1 , + regspacing, info->register_length)); +break ; +case IPMI_MEMSPACE_SMBUS : +aml_append (crs,aml_return (aml_int (info->base_address))); +break ; + } + +if (info->interrupt_number) { +aml_append (crs,aml_irq_no_flags (info->interrupt_number)); + } + +return crs; +} + +static void +ipmi_encode_one_acpi (IPMIFwInfo *info,void *opaque) +{ +Aml *ssdt, *scope, *dev, *method; +char *name; +int version = ((info->ipmi_spec_major_revision <<8 ) + | (info->ipmi_spec_minor_revision <<4 )); + +if (!info->acpi_parent) { +ipmi_debug ("device %s not compatible with ACPI, no parent given." , + info->interface_name); +return ; + } + + ssdt =init_aml_allocator (); + + scope =aml_scope ("%s" , info->acpi_parent); + name =g_strdup_printf ("ipmi_%s" , info->interface_name); + + dev =aml_device ("MI0" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("IPI0001" ))); +aml_append (dev,aml_name_decl ("_STR" ,aml_string ("%s" , name))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_CRS" ,aml_ipmi_crs (info))); + method =aml_method ("_IFT" ,0 ); +aml_append (method,aml_return (aml_int (info->interface_type))); +aml_append (dev, method); + method =aml_method ("_SRV" ,0 ); +aml_append (method,aml_return (aml_int (version))); +aml_append (dev, method); + +aml_append (scope, dev); + +aml_append (ssdt, scope); + +add_acpi_dev_table (ssdt->buf->data, ssdt->buf->len,"SSDT" ,1 ); +free_aml_allocator (); +} + +static void ipmi_acpi_init (void ) +{ +ipmi_register_fwinfo_handler (ipmi_encode_one_acpi,NULL ); +} + +type_init (ipmi_acpi_init);hw/ipmi/isa_ipmi.c +4
-0@@ -37,6 +37,8 @@ typedef struct ISAIPMIDevice {ISADevice dev;char *interface;uint32_t iobase; +uint32_t iolength; +uint8_t regspacing;int32 isairq;uint8_t slave_addr;CharDriverState *chr;@@ -73,12 +75,14 @@ static void ipmi_isa_realizefn(DeviceState *dev, Error **errp) intfk =IPMI_INTERFACE_GET_CLASS (intf); bmc->intf = intf; intf->bmc = bmc; + ipmi->regspacing =1 ; intf->io_base = ipmi->iobase; intf->slave_addr = ipmi->slave_addr;ipmi_interface_init (intf, errp);if (*errp) {return ; } + ipmi->iolength = intf->io_length;ipmi_bmc_init (bmc, errp);if (*errp) {return ;Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 14/17] ipmi: Add SMBIOS table entry
In reply to [email protected]Quoted 5 lines · On Thu, Apr 23, 2015 at 05:57:55PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
Signed-off-by Corey Minyard <[email protected]>
Quoted 139 lines
--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/ipmi_smbios.c | 89 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 hw/ipmi/ipmi_smbios.cdefault-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_APM=y CONFIG_I8257=ydefault-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_APM=y CONFIG_I8257=yhw/ipmi/Makefile.objs +1
-0@@ -4,3 +4,4 @@ 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 +common-obj-$(call land,$(CONFIG_IPMI),$(CONFIG_SMBIOS)) += ipmi_smbios.ohw/ipmi/ipmi_smbios.c new file +89
-0@@ -0,0 +1,89 @@ +/* +* IPMI SMBIOS firmware handling +* +* Copyright (c) 2015 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 "ipmi.h" +#include <hw/i386/smbios.h> +#include <qemu/error-report.h> + +/* 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 ; + +static void ipmi_encode_one_smbios (IPMIFwInfo *info,void *opaque) +{ +struct smbios_type_38 smb38; +uint64_t baseaddr = info->base_address; + + smb38.header.type =38 ; + smb38.header.length =sizeof (smb38); + smb38.header.handle =cpu_to_le16 (0x3000 ); + smb38.interface_type = info->interface_type; + smb38.ipmi_spec_revision = ((info->ipmi_spec_major_revision <<4 ) + | info->ipmi_spec_minor_revision); + smb38.i2c_slave_address = info->i2c_slave_address; + smb38.nv_storage_device_address =0 ; + +/* or 1 to set it to I/O space */ +switch (info->memspace) { +case IPMI_MEMSPACE_IO : baseaddr |=1 ;break ; +case IPMI_MEMSPACE_MEM32 :break ; +case IPMI_MEMSPACE_MEM64 :break ; +case IPMI_MEMSPACE_SMBUS : baseaddr <<=1 ;break ; + } + + smb38.base_address =cpu_to_le64 (baseaddr); + + smb38.base_address_modifier =0 ; +if (info->irq_type ==IPMI_LEVEL_IRQ ) { + smb38.base_address_modifier |=1 ; + } +switch (info->register_spacing) { +case 1 :break ; +case 4 : smb38.base_address_modifier |=1 <<6 ;break ; +case 16 : smb38.base_address_modifier |=2 <<6 ;break ; +default : +error_report ("IPMI register spacing %d is not compatible with" +" SMBIOS, ignoring this entry." , info->register_spacing); +return ; + } + smb38.interrupt_number = info->interrupt_number; + +smbios_add_table_entry ((struct smbios_structure_header *) &smb38, +sizeof (smb38), true); +} + +static void smbios_init (void ) +{ +ipmi_register_fwinfo_handler (ipmi_encode_one_smbios,NULL ); +} + +type_init (smbios_init);Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to [email protected]Quoted 111 lines · On Thu, Apr 23, 2015 at 05:57:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 144 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.cdefault-configs/i386-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=ydefault-configs/x86_64-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=yhw/ipmi/Makefile.objs +1
-0@@ -1 +1,2 @@ +common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/ipmi/isa_ipmi.c new file +59
-0@@ -0,0 +1,144 @@ +/* +* 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; +int32 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 *ipmi =ISA_IPMI (dev); +char typename[20 ]; +Object *intfobj; +IPMIInterface *intf; +Object *bmcobj; +IPMIBmc *bmc; + +if (!ipmi->interface) { + ipmi->interface =g_strdup ("kcs" ); + } +
hw/ipmi/isa_ipmi.c line 69
Quoted 10 lines
hw/ipmi/isa_ipmi.c new file +10
-0+if (ipmi->chr) { + bmcobj =object_new (TYPE_IPMI_BMC_EXTERN ); + }else { + bmcobj =object_new (TYPE_IPMI_BMC_SIMULATOR ); + } + bmc =IPMI_BMC (bmcobj); + bmc->chr = ipmi->chr; +snprintf (typename,sizeof (typename), +TYPE_IPMI_INTERFACE_PREFIX "%s" , ipmi->interface); + intfobj =object_new (typename);
I wonder what Andreas thinks about this. There are only 3 legal types, correct?
I think it would be cleaner to avoid the prefix trick, and just do a plain
if (!ipmi->interface)) {
typename = TYPE_IPMI_INTERFACE_KCS
} else if (!strcmp(ipmi->interface, "kcs")) {
typename = TYPE_IPMI_INTERFACE_KCS
} else if ....etc
Quoted 23 lines
hw/ipmi/isa_ipmi.c new file +23
-0+ intf =IPMI_INTERFACE (intfobj); + bmc->intf = intf; + intf->bmc = bmc; + intf->io_base = ipmi->iobase; + intf->slave_addr = ipmi->slave_addr; +ipmi_interface_init (intf, errp); +if (*errp) { +return ; + } +ipmi_bmc_init (bmc, errp); +if (*errp) { +return ; + } + +/* These may be set by the interface. */ + ipmi->iobase = intf->io_base; + ipmi->slave_addr = intf->slave_addr; + +if (ipmi->isairq >0 ) { +isa_init_irq (isadev, &intf->irq, ipmi->isairq); + intf->use_irq =1 ; + } +
hw/ipmi/isa_ipmi.c line 102
Quoted 10 lines
hw/ipmi/isa_ipmi.c new file +10
-0+ ipmi->intf = intf; +object_property_add_child (OBJECT (isadev),"intf" ,OBJECT (intf), errp); +if (*errp) { +return ; + } +object_property_add_child (OBJECT (isadev),"bmc" ,OBJECT (bmc), errp); +if (*errp) { +return ; + } +
Should the created object be destroyed before return?
Quoted 67 lines
hw/ipmi/isa_ipmi.c new file +42
-0+qdev_set_legacy_instance_id (dev, intf->io_base, intf->io_length); + +isa_register_ioport (isadev, &intf->io, intf->io_base); +} + +static void ipmi_isa_reset (DeviceState *qdev) +{ +ISAIPMIDevice *isa =ISA_IPMI (qdev); + +ipmi_interface_reset (isa->intf); +} + +static Property ipmi_isa_properties[] = { +DEFINE_PROP_STRING ("interface" , ISAIPMIDevice, interface), +DEFINE_PROP_UINT32 ("iobase" , ISAIPMIDevice, iobase,0 ), +DEFINE_PROP_INT32 ("irq" , ISAIPMIDevice, isairq,5 ), +DEFINE_PROP_UINT8 ("slave_addr" , ISAIPMIDevice, slave_addr,0 ), +DEFINE_PROP_CHR ("chardev" , ISAIPMIDevice, chr), +DEFINE_PROP_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->props = ipmi_isa_properties; +} + +static const TypeInfo ipmi_isa_info = { + .name =TYPE_ISA_IPMI , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISAIPMIDevice), + .class_init = ipmi_isa_class_initfn, +}; + +static void ipmi_register_types (void ) +{ +type_register_static (&ipmi_isa_info); +} + +type_init (ipmi_register_types)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 0x8000Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to [email protected]Quoted 208 lines · On Thu, Apr 23, 2015 at 05:57:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 144 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.cdefault-configs/i386-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=ydefault-configs/x86_64-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=yhw/ipmi/Makefile.objs +1
-0@@ -1 +1,2 @@ +common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/ipmi/isa_ipmi.c new file +144
-0@@ -0,0 +1,144 @@ +/* +* 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; +int32 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 *ipmi =ISA_IPMI (dev); +char typename[20 ]; +Object *intfobj; +IPMIInterface *intf; +Object *bmcobj; +IPMIBmc *bmc; + +if (!ipmi->interface) { + ipmi->interface =g_strdup ("kcs" ); + } + +if (ipmi->chr) { + bmcobj =object_new (TYPE_IPMI_BMC_EXTERN ); + }else { + bmcobj =object_new (TYPE_IPMI_BMC_SIMULATOR ); + } + bmc =IPMI_BMC (bmcobj); + bmc->chr = ipmi->chr; +snprintf (typename,sizeof (typename), +TYPE_IPMI_INTERFACE_PREFIX "%s" , ipmi->interface); + intfobj =object_new (typename); + intf =IPMI_INTERFACE (intfobj); + bmc->intf = intf; + intf->bmc = bmc; + intf->io_base = ipmi->iobase; + intf->slave_addr = ipmi->slave_addr; +ipmi_interface_init (intf, errp); +if (*errp) { +return ; + } +ipmi_bmc_init (bmc, errp); +if (*errp) { +return ; + } + +/* These may be set by the interface. */ + ipmi->iobase = intf->io_base; + ipmi->slave_addr = intf->slave_addr; + +if (ipmi->isairq >0 ) { +isa_init_irq (isadev, &intf->irq, ipmi->isairq); + intf->use_irq =1 ; + } + + ipmi->intf = intf; +object_property_add_child (OBJECT (isadev),"intf" ,OBJECT (intf), errp); +if (*errp) { +return ; + } +object_property_add_child (OBJECT (isadev),"bmc" ,OBJECT (bmc), errp); +if (*errp) { +return ; + } + +qdev_set_legacy_instance_id (dev, intf->io_base, intf->io_length); + +isa_register_ioport (isadev, &intf->io, intf->io_base); +} + +static void ipmi_isa_reset (DeviceState *qdev) +{ +ISAIPMIDevice *isa =ISA_IPMI (qdev); + +ipmi_interface_reset (isa->intf); +} + +static Property ipmi_isa_properties[] = { +DEFINE_PROP_STRING ("interface" , ISAIPMIDevice, interface), +DEFINE_PROP_UINT32 ("iobase" , ISAIPMIDevice, iobase,0 ), +DEFINE_PROP_INT32 ("irq" , ISAIPMIDevice, isairq,5 ), +DEFINE_PROP_UINT8 ("slave_addr" , ISAIPMIDevice, slave_addr,0 ), +DEFINE_PROP_CHR ("chardev" , ISAIPMIDevice, chr), +DEFINE_PROP_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->props = ipmi_isa_properties; +} + +static const TypeInfo ipmi_isa_info = { + .name =TYPE_ISA_IPMI , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISAIPMIDevice), + .class_init = ipmi_isa_class_initfn, +}; + +static void ipmi_register_types (void ) +{ +type_register_static (&ipmi_isa_info); +} + +type_init (ipmi_register_types)include/hw/nvram/fw_cfg.h +3
-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
include/hw/nvram/fw_cfg.h line 53
Quoted 10 lines
include/hw/nvram/fw_cfg.h +7
-0+#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
Can IPMI use fw cfg file interface?
This is, generally, preferred.
Quoted 3 lines
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to Michael S. TsirkinQuoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · On Thu, Apr 23, 2015 at 05:57:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>
BTW can you version patches please?
recent git format-patch has a -v flag, older
ones let you use --subject-prefix='PATCH vX'.
Am 24.04.2015 um 01:11 schrieb Eric Blake:
Quoted 8 lines · On 04/23/2015 04:57 PM, [email protected] wrote:
Quoted 1 line
The major changes from last time are:
That says this series should probably be named v2 (git format-patch/send-email -v2) or later, as part of the subject line. If the previous version is more than a couple weeks ago, it's also nice (but not required) to provide a URL to the archives of the previous discussion.
Even worse, I don't see any update on the licensing questions previously raised... did Intel ever get back to you?
Quoted 3 lines
Also, you might want to use git format-patch --cover-letter, which helps form a 00/17 letter with a diffstat pre-filled; the diffstat gives reviewers a quick glance at what files are touched, [...]
+1.
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Quoted 8 lines · Andreas Färber
Quoted 5 lines
That says this series should probably be named v2 (git format-patch/send-email -v2) or later, as part of the subject line. If the previous version is more than a couple weeks ago, it's also nice (but not required) to provide a URL to the archives of the previous discussion.
Even worse, I don't see any update on the licensing questions previously raised... did Intel ever get back to you?
A reminder for the lazy and/or uninformed?
Paolo
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to Michael S. TsirkinQuoted 10 lines · Michael S. Tsirkin
include/hw/nvram/fw_cfg.h line 50
Quoted 10 lines
include/hw/nvram/fw_cfg.h +10
-0+ +#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)
Also, what is this used for? I haven't seen firmware patches, maybe it's obsoleted by SMBIOS support in QEMU?
Paolo
Quoted 10 lines · Andreas Färber
Am 24.04.2015 um 01:11 schrieb Eric Blake:
Quoted 7 lines · On 04/23/2015 04:57 PM, [email protected] wrote:
Quoted 1 line
The major changes from last time are:
That says this series should probably be named v2 (git format-patch/send-email -v2) or later, as part of the subject line. If the previous version is more than a couple weeks ago, it's also nice (but not required) to provide a URL to the archives of the previous discussion.
Even worse, I don't see any update on the licensing questions previously raised... did Intel ever get back to you?
This is the last update I received from Bret Ketchum. From what he says we will get nothing from Intel on this and everything seems ok:
From my understanding you'll not be receiving anything official from
Intel. My understanding from Tom is that there are open source KCS/BT drivers existing in the wild with no IPMI adopters asserting IP on those drivers. The specification places requirement son VMC but does not do the same for software.
The Adotpers Agreement may be looked at as benign/beneficial. At one
level the agreement limits the extent that fellow Adopters can assert IP claims against other signers.
I only bring this up (again) in that I've a request for the update
to these patches I mentioned on the mailing list.
Another option may be for some other than yourself to post these
patches which would absolve you from any recompense.
On Thu, Mar 6, 2014 at 6:48 PM, Corey Minyard <[email protected] <mailto:[email protected]>> wrote:
On 03/06/2014 06:02 AM, Bret Ketchum wrote:
>
>
> What needs to be done to unstick the IPMI patches? Are you waiting
> on something from Intel legal? My email exchanges with Tom Slaight and > Akkiah_Maddukuri do not suggest a legal issue with regards to a shim > protocol that facilitates a IPMI client talking to an IPMI server. >
I'm waiting for something from Intel. I don't have contact info for anyone at Intel. And email from Tom Slaight would probably be good enough
It's more than just a shim protocol, too. There is an implementation of simulated KCS and BT hardware and a small simulated BMC that provides basic function and a watchdog. We could lose the BMC, but not the hardware simulations.
Thanks,
-corey
>
> On Tue, Mar 4, 2014 at 6:38 PM, <[email protected] <mailto:[email protected]>
> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>
> This patch set was part of the IPMI patches, but people have asked
> it to be
> separated out because it's useful by itself and the IPMI patches
> are stuck
> in legal limbo.
>
> I have left the patch to move allocating CharDriverState in
one place
> (patch 1). I didn't get much opinion either way, but I think
it is
> an improvement and a net reduction in code. I also added a patch
> (patch 6)
> that goes another step there, it makes the error handling in
> qmp_chardev_add() consistent and is also a net reduction in code.
>
> The main patches to add the feature are patch 2 and patch 3.
>
> The rest are little possible bug fixes that I noticed while
> working in the
> code.
>
> I went through all the comments and I believe I fixed everything.
>
> Thanks to everyone that reviewed this before.
>
>
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to Paolo BonziniQuoted 15 lines · Paolo Bonzini
Quoted 10 lines · Michael S. Tsirkin
include/hw/nvram/fw_cfg.h line 50
Quoted 10 lines
include/hw/nvram/fw_cfg.h +10
-0+ +#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)Also, what is this used for? I haven't seen firmware patches, maybe it's obsoleted by SMBIOS support in QEMU?
Quoted 1 line
Paolo
Finally back on this. This is bogus, it was left over from something else, and I missed it because it was at the end of the file.
-corey
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to Michael S. TsirkinQuoted 127 lines · Michael S. Tsirkin
Quoted 111 lines · On Thu, Apr 23, 2015 at 05:57:43PM -0500, [email protected] wrote:
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 144 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.cdefault-configs/i386-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=ydefault-configs/x86_64-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=yhw/ipmi/Makefile.objs +1
-0@@ -1 +1,2 @@ +common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/ipmi/isa_ipmi.c new file +59
-0@@ -0,0 +1,144 @@ +/* +* 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; +int32 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 *ipmi =ISA_IPMI (dev); +char typename[20 ]; +Object *intfobj; +IPMIInterface *intf; +Object *bmcobj; +IPMIBmc *bmc; + +if (!ipmi->interface) { + ipmi->interface =g_strdup ("kcs" ); + } +hw/ipmi/isa_ipmi.c line 69
Quoted 10 lines
hw/ipmi/isa_ipmi.c new file +10
-0+if (ipmi->chr) { + bmcobj =object_new (TYPE_IPMI_BMC_EXTERN ); + }else { + bmcobj =object_new (TYPE_IPMI_BMC_SIMULATOR ); + } + bmc =IPMI_BMC (bmcobj); + bmc->chr = ipmi->chr; +snprintf (typename,sizeof (typename), +TYPE_IPMI_INTERFACE_PREFIX "%s" , ipmi->interface); + intfobj =object_new (typename);I wonder what Andreas thinks about this. There are only 3 legal types, correct?
I think it would be cleaner to avoid the prefix trick, and just do a plain
Quoted 8 lines
if (!ipmi->interface)) { typename = TYPE_IPMI_INTERFACE_KCS } else if (!strcmp(ipmi->interface, "kcs")) { typename = TYPE_IPMI_INTERFACE_KCS } else if ....etc
Well, I'm fine either way. The way I had it seems clear enough to me, but I wrote it :).
If Andreas or you want it changed, not a problem. Just say so.
Quoted 29 lines
Quoted 29 lines
hw/ipmi/isa_ipmi.c new file +26
-0+ intf =IPMI_INTERFACE (intfobj); + bmc->intf = intf; + intf->bmc = bmc; + intf->io_base = ipmi->iobase; + intf->slave_addr = ipmi->slave_addr; +ipmi_interface_init (intf, errp); +if (*errp) { +return ; + } +ipmi_bmc_init (bmc, errp); +if (*errp) { +return ; + } + +/* These may be set by the interface. */ + ipmi->iobase = intf->io_base; + ipmi->slave_addr = intf->slave_addr; + +if (ipmi->isairq >0 ) { +isa_init_irq (isadev, &intf->irq, ipmi->isairq); + intf->use_irq =1 ; + } + + ipmi->intf = intf; +object_property_add_child (OBJECT (isadev),"intf" ,OBJECT (intf), errp); +if (*errp) {
Quoted 8 lines
hw/ipmi/isa_ipmi.c line 102
Quoted 7 lines
hw/ipmi/isa_ipmi.c new file +7
-0+return ; + } +object_property_add_child (OBJECT (isadev),"bmc" ,OBJECT (bmc), errp); +if (*errp) { +return ; + } +Should the created object be destroyed before return?
Returning an error from the realize here appears to result in an error being printed and qemu being terminated, as far as I can tell. So it shouldn't matter here, right?
-corey
Quoted 67 lines
Quoted 67 lines
hw/ipmi/isa_ipmi.c new file +42
-0+qdev_set_legacy_instance_id (dev, intf->io_base, intf->io_length); + +isa_register_ioport (isadev, &intf->io, intf->io_base); +} + +static void ipmi_isa_reset (DeviceState *qdev) +{ +ISAIPMIDevice *isa =ISA_IPMI (qdev); + +ipmi_interface_reset (isa->intf); +} + +static Property ipmi_isa_properties[] = { +DEFINE_PROP_STRING ("interface" , ISAIPMIDevice, interface), +DEFINE_PROP_UINT32 ("iobase" , ISAIPMIDevice, iobase,0 ), +DEFINE_PROP_INT32 ("irq" , ISAIPMIDevice, isairq,5 ), +DEFINE_PROP_UINT8 ("slave_addr" , ISAIPMIDevice, slave_addr,0 ), +DEFINE_PROP_CHR ("chardev" , ISAIPMIDevice, chr), +DEFINE_PROP_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->props = ipmi_isa_properties; +} + +static const TypeInfo ipmi_isa_info = { + .name =TYPE_ISA_IPMI , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISAIPMIDevice), + .class_init = ipmi_isa_class_initfn, +}; + +static void ipmi_register_types (void ) +{ +type_register_static (&ipmi_isa_info); +} + +type_init (ipmi_register_types)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 0x8000Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Quoted 10 lines · Corey Minyard
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
hw/ipmi/isa_ipmi.c new file +10
-0+ ipmi->intf = intf; +object_property_add_child (OBJECT (isadev),"intf" ,OBJECT (intf), errp); +if (*errp) { +return ; + } +object_property_add_child (OBJECT (isadev),"bmc" ,OBJECT (bmc), errp); +if (*errp) { +return ; + } +
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Should the created object be destroyed before return?
Returning an error from the realize here appears to result in an error being printed and qemu being terminated, as far as I can tell. So it shouldn't matter here, right?
I would just use &error_abort and ignore error handling.
Paolo
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
In reply to Corey MinyardAm 08.05.2015 um 23:16 schrieb Corey Minyard:
Quoted 135 lines · Michael S. Tsirkin
Quoted 134 lines · On Thu, Apr 23, 2015 at 05:57:43PM -0500, [email protected] wrote:
Quoted 111 lines
From: Corey Minyard <[email protected]>
This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.
Signed-off-by Corey Minyard <[email protected]>--- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/ipmi/Makefile.objs | 1 + hw/ipmi/isa_ipmi.c | 144 +++++++++++++++++++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 11 ++- 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 hw/ipmi/isa_ipmi.cdefault-configs/i386-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=ydefault-configs/x86_64-softmmu.mak +1
-0@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y CONFIG_VMMOUSE=y CONFIG_IPMI=y +CONFIG_ISA_IPMI=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_I8254=yhw/ipmi/Makefile.objs +1
-0@@ -1 +1,2 @@ +common-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o common-obj-$(CONFIG_IPMI) += ipmi.ohw/ipmi/isa_ipmi.c new file +59
-0@@ -0,0 +1,144 @@ +/* +* 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; +int32 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 *ipmi =ISA_IPMI (dev); +char typename[20 ]; +Object *intfobj; +IPMIInterface *intf; +Object *bmcobj; +IPMIBmc *bmc; + +if (!ipmi->interface) { + ipmi->interface =g_strdup ("kcs" ); + } +hw/ipmi/isa_ipmi.c line 69
Quoted 10 lines
hw/ipmi/isa_ipmi.c new file +10
-0+if (ipmi->chr) { + bmcobj =object_new (TYPE_IPMI_BMC_EXTERN ); + }else { + bmcobj =object_new (TYPE_IPMI_BMC_SIMULATOR ); + } + bmc =IPMI_BMC (bmcobj); + bmc->chr = ipmi->chr; +snprintf (typename,sizeof (typename), +TYPE_IPMI_INTERFACE_PREFIX "%s" , ipmi->interface); + intfobj =object_new (typename);I wonder what Andreas thinks about this. There are only 3 legal types, correct?
I think it would be cleaner to avoid the prefix trick, and just do a plainif (!ipmi->interface)) { typename = TYPE_IPMI_INTERFACE_KCS } else if (!strcmp(ipmi->interface, "kcs")) { typename = TYPE_IPMI_INTERFACE_KCS } else if ....
Quoted 6 lines
Quoted 1 line
etc
Well, I'm fine either way. The way I had it seems clear enough to me, but I wrote it :).
If Andreas or you want it changed, not a problem. Just say so.
I do prefer mst's suggestion. You are right that your code is clear, but it's duplicated and thus makes refactorings harder. For clarity I would even propose to skip bmcobj in favor of bmc. Same for the other objects. OBJECT() is cheap, unlike other casts.
Another problem is that you're using object_new() in realize at all, which means that it's too late for any management interface to tweak properties on the new device. One possible solution would be to create the object in a property setter, before realizing the object. Did you look at how some of the other backends are implemented, such as rng?
Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
hw/ipmi/isa_ipmi.c new file +26
-0+ intf =IPMI_INTERFACE (intfobj); + bmc->intf = intf; + intf->bmc = bmc; + intf->io_base = ipmi->iobase; + intf->slave_addr = ipmi->slave_addr; +ipmi_interface_init (intf, errp); +if (*errp) { +return ; + } +ipmi_bmc_init (bmc, errp); +if (*errp) { +return ; + } + +/* These may be set by the interface. */ + ipmi->iobase = intf->io_base; + ipmi->slave_addr = intf->slave_addr; + +if (ipmi->isairq >0 ) { +isa_init_irq (isadev, &intf->irq, ipmi->isairq); + intf->use_irq =1 ; + } + + ipmi->intf = intf; +object_property_add_child (OBJECT (isadev),"intf" ,OBJECT (intf), errp); +if (*errp) {Quoted 8 lines
hw/ipmi/isa_ipmi.c line 102
Quoted 7 lines
hw/ipmi/isa_ipmi.c new file +7
-0+return ; + } +object_property_add_child (OBJECT (isadev),"bmc" ,OBJECT (bmc), errp); +if (*errp) { +return ; + } +Should the created object be destroyed before return?
Quoted 3 lines
Returning an error from the realize here appears to result in an error being printed and qemu being terminated, as far as I can tell. So it shouldn't matter here, right?
Negative, this is a property setter that has nothing to do with what its callers do. For one, you cannot rely on errp != NULL, so you need to use a local Error *err = NULL; and call error_propagate() when necessary.
Also keep in mind that this realized property is publicly accessible. When set to false and re-set to true those will definitely fail as I see no unrealize implementation ever deleting these properties. In that case, with your guest running, terminating QEMU is not desired.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
hw/ipmi/isa_ipmi.c new file +14
-0+qdev_set_legacy_instance_id (dev, intf->io_base, intf->io_length); + +isa_register_ioport (isadev, &intf->io, intf->io_base); +} + +static void ipmi_isa_reset (DeviceState *qdev) +{ +ISAIPMIDevice *isa =ISA_IPMI (qdev); + +ipmi_interface_reset (isa->intf); +} + +static Property ipmi_isa_properties[] = { +DEFINE_PROP_STRING ("interface" , ISAIPMIDevice, interface),
Quoted 8 lines
Quoted 8 lines
hw/ipmi/isa_ipmi.c line 124
Quoted 8 lines
hw/ipmi/isa_ipmi.c new file +8
-0+DEFINE_PROP_UINT32 ("iobase" , ISAIPMIDevice, iobase,0 ), +DEFINE_PROP_INT32 ("irq" , ISAIPMIDevice, isairq,5 ), +DEFINE_PROP_UINT8 ("slave_addr" , ISAIPMIDevice, slave_addr,0 ), +DEFINE_PROP_CHR ("chardev" , ISAIPMIDevice, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ipmi_isa_class_initfn (ObjectClass *klass,void *data)
s/klass/oc/ preferred.
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
hw/ipmi/isa_ipmi.c new file +20
-0+{ +DeviceClass *dc =DEVICE_CLASS (klass); + dc->realize = ipmi_isa_realizefn; + dc->reset = ipmi_isa_reset; + dc->props = ipmi_isa_properties; +} + +static const TypeInfo ipmi_isa_info = { + .name =TYPE_ISA_IPMI , + .parent =TYPE_ISA_DEVICE , + .instance_size =sizeof (ISAIPMIDevice), + .class_init = ipmi_isa_class_initfn, +}; + +static void ipmi_register_types (void ) +{ +type_register_static (&ipmi_isa_info); +} + +type_init (ipmi_register_types)include/hw/nvram/fw_cfg.h +0
-0@@ -38,7 +38,16 @@
Quoted 11 lines
Quoted 11 lines
include/hw/nvram/fw_cfg.h line 48
Quoted 11 lines
include/hw/nvram/fw_cfg.h +8
-1#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
Do we really need all those fw_cfg entries for an optional device?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
include/hw/nvram/fw_cfg.h +2
-0+ +#define FW_CFG_MAX_ENTRY (FW_CFG_IPMI_VERSION + 1)#define FW_CFG_WRITE_CHANNEL 0x4000#define FW_CFG_ARCH_LOCAL 0x8000Signature · 1 line
1.8.3.1
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Quoted 5 lines · Andreas Färber
Another problem is that you're using
object_new()in realize at all, which means that it's too late for any management interface to tweak properties on the new device. One possible solution would be to create the object in a property setter, before realizing the object. Did you look at how some of the other backends are implemented, such as rng?
Note that this is not exactly a backend. It's a different guest-visible I/O interface. But there are no properties on the interface, so it's okay to create it at realize time.
Paolo
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Quoted 7 lines · Paolo Bonzini
Quoted 5 lines · Andreas Färber
Another problem is that you're using
object_new()in realize at all, which means that it's too late for any management interface to tweak properties on the new device. One possible solution would be to create the object in a property setter, before realizing the object. Did you look at how some of the other backends are implemented, such as rng?
Quoted 5 lines
Note that this is not exactly a backend. It's a different guest-visible I/O interface. But there are no properties on the interface, so it's okay to create it at realize time.
Paolo
I've debated this in my mind since I've been learning more about qemu. Some of
the bmc properties are being passed in to the interface and passed on to the bmc.
Plus some IPMI systems have multiple interfaces that point to the same bmc. It
might be best to have the user create a bmc device then tie an interface device to it.
If I do this, what is the acceptable way to look up another object this way? I hunted
a bit and didn't come up with anything clean.
Thanks,
-corey
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Quoted 8 lines · Corey Minyard
I've debated this in my mind since I've been learning more about qemu. Some of the bmc properties are being passed in to the interface and passed on to the bmc. Plus some IPMI systems have multiple interfaces that point to the same bmc. It might be best to have the user create a bmc device then tie an interface device to it.
If I do this, what is the acceptable way to look up another object this way? I hunted a bit and didn't come up with anything clean.
Yes, you're right indeed!!! I think you want something like
-object ipmi-bmc-extern,id=bmc0,chardev=foo
-device isa-ipmi-kcs,bmc=bmc0
vs.
-object ipmi-bmc,id=bmc0
-device isa-ipmi-bt,bmc=bmc0
ipmi-bmc would be a subclass of Object like the one that you have, but it needs to implement the UserCreatable interface; see backends/rng.c for an example.
Then ipmi-isa-kcs would be your usual ISA device, so a subclass of TYPE_ISA_DEVICE; however it would implement IPMIInterface, which would be an interface rather than an abstract class. For an example of interface boilerplate, see hw/core/hotplug.c. For an example of how to implement the "bmc" property, see hw/mem/pc-dimm.c.
Paolo
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Quoted 24 lines · Paolo Bonzini
Quoted 8 lines · Corey Minyard
I've debated this in my mind since I've been learning more about qemu. Some of the bmc properties are being passed in to the interface and passed on to the bmc. Plus some IPMI systems have multiple interfaces that point to the same bmc. It might be best to have the user create a bmc device then tie an interface device to it.
If I do this, what is the acceptable way to look up another object this way? I hunted a bit and didn't come up with anything clean.
Yes, you're right indeed!!! I think you want something like
-object ipmi-bmc-extern,id=bmc0,chardev=foo
-device isa-ipmi-kcs,bmc=bmc0vs.
-object ipmi-bmc,id=bmc0
-device isa-ipmi-bt,bmc=bmc0ipmi-bmc would be a subclass of Object like the one that you have, but it needs to implement the UserCreatable interface; see
backends/rng.cfor an example.
Quoted 7 lines
Then ipmi-isa-kcs would be your usual ISA device, so a subclass of
TYPE_ISA_DEVICE; however it would implement IPMIInterface, which would be an interface rather than an abstract class. For an example of interface boilerplate, seehw/core/hotplug.c. For an example of how to implement the "bmc" property, seehw/mem/pc-dimm.c.Paolo
I've been trying to piece this together, and the problem is that BT and KCS can sit on different kinds of busses, not just ISA. There are PCI and memory based implementations. I'd prefer to have one implementation for all, so I'm trying to figure out a way to piece all these things together.
What I've come up with is the following class structure:
IPMIBmc (abstract subclass of Device)
Implements the base BMC handling
IPMIBmcInternal (subclass of IPMIBmc)
An internal BMC
IPMIBmcExternal (subclass of IPMIBmc)
A connection to an external BMC
BusDevice (subclass of Interface)
An interface where a device can connect to a bus and do I/O and
interrupts.
BusDeviceISA (subclass of ISADevice, implements BusDevice)
An ISA interface for BusDevice
IPMIInterface (subclass of Interface)
An Interface that connects between a BMC and a physical IPMI interface (BT, KCS, SMBus)
IPMIDevice (abstract subclass of Device, implements IPMIInterface)
The base class for the various IPMI devices. This code finds the IPMIBmc and the BusDevice objects and plugs them in to the subclasses of this class.
IPMIDevKCS (subclass of IPMIDevice)
KCS interface
IPMIDevBT (subclass of IPMIDevice)
BT interface
So on the command line, you would say:
-device isadev,irq=5,id=ipmiisadev,addr=0xca2 -device
ipmi-bmc-internal,id=bmc1
-device ipmi-kcs,bmc=bmc1,busdev=ipmiisadev
This seems rather complicated, but it seem like the only way to break this up. And
I don't know if object_property_add_link() works on interfaces, but that should be easy
to fix if it doesn't.
Does this sound plausible?
Thanks,
-corey
Re: [Qemu-devel] [PATCH 02/17] ipmi: Add a PC ISA type structure
Quoted 38 lines · Corey Minyard
Quoted 24 lines · Paolo Bonzini
Quoted 8 lines · Corey Minyard
I've debated this in my mind since I've been learning more about qemu. Some of the bmc properties are being passed in to the interface and passed on to the bmc. Plus some IPMI systems have multiple interfaces that point to the same bmc. It might be best to have the user create a bmc device then tie an interface device to it.
If I do this, what is the acceptable way to look up another object this way? I hunted a bit and didn't come up with anything clean.
Yes, you're right indeed!!! I think you want something like
-object ipmi-bmc-extern,id=bmc0,chardev=foo
-device isa-ipmi-kcs,bmc=bmc0vs.
-object ipmi-bmc,id=bmc0
-device isa-ipmi-bt,bmc=bmc0ipmi-bmc would be a subclass of Object like the one that you have, but it needs to implement the UserCreatable interface; see
backends/rng.cfor an example.Quoted 7 lines
Then ipmi-isa-kcs would be your usual ISA device, so a subclass of
TYPE_ISA_DEVICE; however it would implement IPMIInterface, which would be an interface rather than an abstract class. For an example of interface boilerplate, seehw/core/hotplug.c. For an example of how to implement the "bmc" property, seehw/mem/pc-dimm.c.Paolo
I've been trying to piece this together, and the problem is that BT and KCS can sit on different kinds of busses, not just ISA. There are PCI and memory based implementations. I'd prefer to have one implementation for all, so I'm trying to figure out a way to piece all these things together.
Quoted 4 lines
What I've come up with is the following class structure:
IPMIBmc (abstract subclass of Device)
Implements the base BMC handling
This is actually a subclass of Object that implements UserCreatable. But that's a detail.
Quoted 5 lines
IPMIBmcInternal (subclass of IPMIBmc)
An internal BMCIPMIBmcExternal (subclass of IPMIBmc)
A connection to an external BMC
These are good.
Quoted 6 lines
BusDevice (subclass of Interface)
An interface where a device can connect to a bus and do I/O and
interrupts.BusDeviceISA (subclass of ISADevice, implements BusDevice)
An ISA interface for BusDevice
See below...
Quoted 3 lines
IPMIInterface (subclass of Interface)
An Interface that connects between a BMC and a physical IPMI interface (BT, KCS, SMBus)
This is okay.
Quoted 10 lines
IPMIDevice (abstract subclass of Device, implements IPMIInterface)
The base class for the various IPMI devices. This code finds the IPMIBmc and the BusDevice objects and plugs them in to the subclasses of this class.IPMIDevKCS (subclass of IPMIDevice)
KCS interfaceIPMIDevBT (subclass of IPMIDevice)
BT interface
For now I would just make IPMIDevKCS and IPMIDevBT two ISADevice subclasses. Any code reuse between them can be placed in the implementation of IPMIInterface: interface methods need not be abstract, they can have a default implementation.
Regarding BusDevice, if a PCI interface is added in the future we can use C composition (structs :)) to group the common KCS and BT code. There's no need for an explicit class hierarchy; for an example see the AHCI and EHCI devices.
The SMBus interface can be added already (through a subclass of I2CSlave that implements IPMIInterface.
Quoted 5 lines
So on the command line, you would say:
-device isadev,irq=5,id=ipmiisadev,addr=0xca2 -device
ipmi-bmc-internal,id=bmc1
-device ipmi-kcs,bmc=bmc1,busdev=ipmiisadev
In my proposal this would be
-object ipmi-bmc-internal,id=bmc1 -device isa-ipmi-kcs,bmc=bmc1,irq=5,iobase=0xca2
(the irq and iobase can be given suitable defaults of course; iobase is a more standard name for ISA I/O ports).
Quoted 2 lines
This seems rather complicated, but it seem like the only way to break this up.
If you want a pure QOM solution it is. But we can use plain struct composition too, in order to keep the implementation simple. The same is done in the kernel, which uses structs or kobjects depending on the use case.
Quoted 1 line
And I don't know if
object_property_add_link()works on interfaces
Yes, it does.
Quoted 1 line
Does this sound plausible?
It did---does what I wrote also sound plausible? :)
Paolo