Skip to contentSkip to conversation

First shot at adding IPMI to qemu

Qemu-devel In review [email protected] 5 participants 20 messages Jul 9, 2012 – Jul 10, 2012

lore
Share & tools
lore
#0 lore raw

I had asked about getting an IPMI device into qemu and received some interest, and it's useful to me, so I've done some work to add it. The following patch set has a set of patches to add an IPMI KCS device, and IPMI BT device, a built-in BMC (IPMI management controller), and a way to attach an external BMC through a chardev.

There was some discussion on whether to make the BMC internal or external, but I went ahead and added both. The internal one is fairly basic and not extensible, at least without adding code. I've modified the OpenIPMI library simulator to work with the external interface to allow it to receive connections from the qemu external simulator with a fairly basic protocol.

I've also added the ability for the OpenIPMI library to manage a VM to power it on, power it off, reset it, and handle an IPMI watchdog timer. So it looks quite like a real system. Instructions for using it are in the OpenIPMI release candidate I uploaded to
https://sourceforge.net/projects/openipmi

Since IPMI can advertise its presence via SMBIOS, I added a way for a driver to add an SMBIOS entry. I also added a way to query a free interrupt from the ISA bus, since the interrupt is in the SMBIOS entry and nobody really cares which one is used.

#1 lore raw

PATCH 1/9 smbios: Add a function to directly add an entry

From: Corey Minyard <[email protected]>

There was no way to directly add a table entry to the SMBIOS table, even though the BIOS supports this. So add a function to do this. This is in preparation for the IPMI handler adding it's SMBIOS table entry.

---
 hw/smbios.c |   27 +++++++++++++++++++++++++++
 hw/smbios.h |   15 ++++++++-------
 2 files changed, 35 insertions(+), 7 deletions(-)
hw/smbios.c +27 -0
index c57237d..98c7f99 100644
@@ -178,6 +178,33 @@ static void smbios_build_type_1_fields(const char *t)
                          strlen(buf) + 1, buf);
 }
 
+int smbios_table_entry_add(struct smbios_structure_header *entry)
+{
+    struct smbios_table *table;
+    struct smbios_structure_header *header;
+    unsigned int size = entry->length;
+
+    if (!smbios_entries) {
+        smbios_entries_len = sizeof(uint16_t);
+        smbios_entries = g_malloc0(smbios_entries_len);
+    }
+    smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
+			       sizeof(*table) + size);
+    table = (struct smbios_table *)(smbios_entries + smbios_entries_len);
+    table->header.type = SMBIOS_TABLE_ENTRY;
+    table->header.length = cpu_to_le16(sizeof(*table) + size);
+
+    header = (struct smbios_structure_header *)(table->data);
+    memcpy(header, entry, size);
+
+    smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY);
+
+    smbios_entries_len += sizeof(*table) + size;
+    (*(uint16_t *)smbios_entries) =
+	cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
+    return 0;
+}
+
 int smbios_entry_add(const char *t)
 {
     char buf[1024];
hw/smbios.h +8 -7
index 94e3641..6431a15 100644
@@ -13,21 +13,22 @@
  *
  */
 
+/* This goes at the beginning of every SMBIOS structure. */
+struct smbios_structure_header {
+    uint8_t type;
+    uint8_t length;
+    uint16_t handle;
+} QEMU_PACKED;
+
 int smbios_entry_add(const char *t);
 void smbios_add_field(int type, int offset, int len, void *data);
 uint8_t *smbios_get_table(size_t *length);
+int smbios_table_entry_add(struct smbios_structure_header *entry);
 
 /*
  * SMBIOS spec defined tables
  */
 
-/* This goes at the beginning of every SMBIOS structure. */
-struct smbios_structure_header {
-    uint8_t type;
-    uint8_t length;
-    uint16_t handle;
-} QEMU_PACKED;
-
 /* SMBIOS type 0 - BIOS Information */
 struct smbios_type_0 {
     struct smbios_structure_header header;
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/9 pc: move SMBIOS setup to after device init

In reply to [email protected]

From: Corey Minyard <[email protected]>

Setting up the firmware interface for the SMBIOS table needs to be done later in the process, after device initialization, so that devices can add entries to the table.

---
 hw/pc.c      |   22 +++++++++++++---------
 hw/pc.h      |    9 +++++----
 hw/pc_piix.c |   12 ++++++++----
 3 files changed, 26 insertions(+), 17 deletions(-)
hw/pc.c +13 -9
index fb04c8b..c0acb6a 100644
@@ -971,20 +971,12 @@ void pc_cpus_init(const char *cpu_model)
 }
 
 void pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
                     ram_addr_t below_4g_mem_size,
                     ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
                     MemoryRegion **ram_memory)
 {
-    int linux_boot, i;
-    MemoryRegion *ram, *option_rom_mr;
+    MemoryRegion *ram;
     MemoryRegion *ram_below_4g, *ram_above_4g;
-    void *fw_cfg;
-
-    linux_boot = (kernel_filename != NULL);
 
     /* Allocate RAM.  We allocate it as a single memory region and use
      * aliases to address portions of it, mostly for backwards compatibility
@@ -1006,7 +998,17 @@ void pc_memory_init(MemoryRegion *system_memory,
         memory_region_add_subregion(system_memory, 0x100000000ULL,
                                     ram_above_4g);
     }
+}
 
+void pc_bios_init(const char *kernel_filename,
+		  const char *kernel_cmdline,
+		  const char *initrd_filename,
+		  ram_addr_t below_4g_mem_size,
+		  MemoryRegion *rom_memory)
+{
+    MemoryRegion *option_rom_mr;
+    void *fw_cfg;
+    int linux_boot, i;
 
     /* Initialize PC system firmware */
     pc_system_firmware_init(rom_memory);
@@ -1019,6 +1021,8 @@ void pc_memory_init(MemoryRegion *system_memory,
                                         option_rom_mr,
                                         1);
 
+    linux_boot = (kernel_filename != NULL);
+
     fw_cfg = bochs_bios_init();
     rom_set_fw(fw_cfg);
 
hw/pc.h +5 -4
index 8ccf202..33ab689 100644
@@ -107,13 +107,14 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
 void pc_cpus_init(const char *cpu_model);
 void pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
                     ram_addr_t below_4g_mem_size,
                     ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
                     MemoryRegion **ram_memory);
+void pc_bios_init(const char *kernel_filename,
+		  const char *kernel_cmdline,
+		  const char *initrd_filename,
+		  ram_addr_t below_4g_mem_size,
+		  MemoryRegion *rom_memory);
 qemu_irq *pc_allocate_cpu_irq(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
hw/pc_piix.c +8 -4
index fb86f27..21b4f59 100644
@@ -176,10 +176,8 @@ static void pc_init1(MemoryRegion *system_memory,
 
     /* allocate ram and load rom/bios */
     if (!xen_enabled()) {
-        pc_memory_init(system_memory,
-                       kernel_filename, kernel_cmdline, initrd_filename,
-                       below_4g_mem_size, above_4g_mem_size,
-                       pci_enabled ? rom_memory : system_memory, &ram_memory);
+        pc_memory_init(system_memory, below_4g_mem_size, above_4g_mem_size,
+		       &ram_memory);
     }
 
     gsi_state = g_malloc0(sizeof(*gsi_state));
@@ -287,6 +285,12 @@ static void pc_init1(MemoryRegion *system_memory,
     if (pci_enabled) {
         pc_pci_device_init(pci_bus);
     }
+
+    if (!xen_enabled()) {
+	pc_bios_init(kernel_filename, kernel_cmdline, initrd_filename,
+		     below_4g_mem_size,
+		     pci_enabled ? rom_memory : system_memory);
+    }
 }
 
 static void pc_init_pci(ram_addr_t ram_size,
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/9 isa: Add a way to query for a free interrupt

In reply to [email protected]

From: Corey Minyard <[email protected]>

This lets devices that don't care about their interrupt number, like IPMI, just grab any unused interrupt.

---
 hw/isa-bus.c |   13 +++++++++++++
 hw/isa.h     |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)
hw/isa-bus.c +13 -0
index 5a43f03..f561f21 100644
@@ -71,6 +71,7 @@ qemu_irq isa_get_irq(ISADevice *dev, int isairq)
     if (isairq < 0 || isairq > 15) {
         hw_error("isa irq %d invalid", isairq);
     }
+    isabus->irq_inuse[isairq] = 1;
     return isabus->irqs[isairq];
 }
 
@@ -82,6 +83,18 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
     dev->nirqs++;
 }
 
+int isa_find_free_irq(ISABus *bus)
+{
+    unsigned int i;
+
+    /* 0 and 1 are called for, 2 is the chain interrupt */
+    for (i = 3; i < ISA_NUM_IRQS; i++) {
+	if (!bus->irq_inuse[i])
+	    return i;
+    }
+    return 0;
+}
+
 static inline void isa_init_ioport(ISADevice *dev, uint16_t ioport)
 {
     if (dev && (dev->ioport_id == 0 || ioport < dev->ioport_id)) {
hw/isa.h +2 -0
index f7bc4b5..9447296 100644
@@ -28,6 +28,7 @@ struct ISABus {
     BusState qbus;
     MemoryRegion *address_space_io;
     qemu_irq *irqs;
+    int irq_inuse[ISA_NUM_IRQS];
 };
 
 struct ISADevice {
@@ -41,6 +42,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
+int isa_find_free_irq(ISABus *bus);
 MemoryRegion *isa_address_space(ISADevice *dev);
 ISADevice *isa_create(ISABus *bus, const char *name);
 ISADevice *isa_try_create(ISABus *bus, const char *name);
Signature · 1 line
1.7.4.1
#4 lore raw

Re: [Qemu-devel] [PATCH 3/9] isa: Add a way to query for a free interrupt

Il 09/07/2012 21:17, [email protected] ha scritto:

Quoted 4 lines

From: Corey Minyard <[email protected]>

This lets devices that don't care about their interrupt number, like IPMI, just grab any unused interrupt.

I would try to avoid this. It is too dependent on the actual initialization order and command line. Just pick a reasonable value for the interrupt (5?) and make it customizable.

I only gave a cursory look at the series, but it looks really well done except for command-line parsing. I'll reply to the patches individually.

Paolo

#5 lore raw

PATCH 4/9 Add a base IPMI interface

In reply to [email protected]

From: Corey Minyard <[email protected]>

Add the basic IPMI types and infrastructure to QEMU. Low-level interfaces and simulation interfaces will register with this; it's kind of the go-between to tie them together.

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    2 +
 hw/ipmi.c                          |  147 +++++++++++++++++++++++++++
 hw/ipmi.h                          |  192 ++++++++++++++++++++++++++++++++++++
 qemu-doc.texi                      |    2 +
 qemu-options.hx                    |   35 +++++++
 sysemu.h                           |    8 ++
 vl.c                               |   46 +++++++++
 9 files changed, 434 insertions(+), 0 deletions(-)
 create mode 100644 hw/ipmi.c
 create mode 100644 hw/ipmi.h
default-configs/i386-softmmu.mak +1 -0
index 2c78175..eb17afc 100644
@@ -7,6 +7,7 @@ CONFIG_VGA_ISA=y
 CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
+CONFIG_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index 233a856..e4e3e4f 100644
@@ -7,6 +7,7 @@ CONFIG_VGA_ISA=y
 CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
+CONFIG_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +2 -0
index 30c0b78..0d55997 100644
@@ -20,6 +20,8 @@ hw-obj-$(CONFIG_M48T59) += m48t59.o
 hw-obj-$(CONFIG_ESCC) += escc.o
 hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 
+hw-obj-$(CONFIG_IPMI) += ipmi.o
+
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
 hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
hw/ipmi.c new file +147 -0

147 lines not on this page · raw message

hw/ipmi.h new file +192 -0

192 lines not on this page · raw message

qemu-doc.texi +2 -0
index 0af0ff4..effa2da 100644
@@ -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
qemu-options.hx +35 -0
index 125a4da..823f6bc 100644
@@ -2204,6 +2204,41 @@ Three button serial mouse. Configure the guest to use Microsoft protocol.
 @end table
 ETEXI
 
+DEF("ipmi", HAS_ARG, QEMU_OPTION_ipmi, \
+    "-ipmi [kcs|bt,]dev|local|none  IPMI interface to the dev, or internal BMC\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -ipmi [bt|kcs,]@var{dev}|local|none
+@findex -ipmi
+Set up an IPMI interface.  The physical interface may either be
+KCS or BT, the default is KCS.  Two options are available for
+simulation of the IPMI BMC.  If @code{local} is specified, then a
+minimal internal BMC is used.  This BMC is basically useful as a
+watchdog timer and for fooling a system into thinking IPMI is there.
+
+If @var{dev} is specified (see the serial section above for details on
+what can be specified for @var{dev}) then a connection to an external IPMI
+simulator is made.  This interface has the ability to do power control
+and reset, so it can do the normal IPMI types of things required.
+
+The OpenIPMI project's lanserv simulator is capable of providing
+this interface.  It is also capable of an IPMI LAN interface, and
+you can do power control (the lanserv simulator is capable of starting
+a VM, too) and reset of a virtual machine over a standard remote LAN
+interface.  For details on this, see OpenIPMI.
+
+The remote connection to a LAN interface will reconnect if disconnected,
+so if a remote BMC fails and restarts, it will still be usable.
+
+For instance, to connect to an external interface on the local machine
+port 9002 with a BT physical interface, do the following:
+@table @code
+@item -ipmi bt,tcp:localhost:9002
+@end table
+
+Use @code{-ipmi none} to disable IPMI.
+ETEXI
+
 DEF("parallel", HAS_ARG, QEMU_OPTION_parallel, \
     "-parallel dev   redirect the parallel port to char device 'dev'\n",
     QEMU_ARCH_ALL)
sysemu.h +8 -0
index eb3da5a..b71cd7a 100644
@@ -172,6 +172,14 @@ int do_pcie_aer_inject_error(Monitor *mon,
 
 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
 
+/* IPMI devices */
+
+#define MAX_IPMI_DEVICES 1
+
+extern int do_local_ipmi;
+extern int ipmi_types[MAX_IPMI_DEVICES];
+extern QemuOpts *ipmi_hds[MAX_IPMI_DEVICES];
+
 /* parallel ports */
 
 #define MAX_PARALLEL_PORTS 3
vl.c +46 -0

82 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#6 lore raw

Re: [Qemu-devel] [PATCH 4/9] Add a base IPMI interface

Quoted 32 lines · On Mon, Jul 09, 2012 at 02:17:04PM -0500, [email protected] wrote:
qemu-options.hx +23 -0
index 125a4da..823f6bc 100644
@@ -2204,6 +2204,41 @@ Three button serial mouse. Configure the guest to use Microsoft protocol.
 @end table
 ETEXI
 
+DEF("ipmi", HAS_ARG, QEMU_OPTION_ipmi, \
+    "-ipmi [kcs|bt,]dev|local|none  IPMI interface to the dev, or internal BMC\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -ipmi [bt|kcs,]@var{dev}|local|none
+@findex -ipmi
+Set up an IPMI interface.  The physical interface may either be
+KCS or BT, the default is KCS.  Two options are available for
+simulation of the IPMI BMC.  If @code{local} is specified, then a
+minimal internal BMC is used.  This BMC is basically useful as a
+watchdog timer and for fooling a system into thinking IPMI is there.
+
+If @var{dev} is specified (see the serial section above for details on
+what can be specified for @var{dev}) then a connection to an external IPMI
+simulator is made.  This interface has the ability to do power control
+and reset, so it can do the normal IPMI types of things required.
 
+The OpenIPMI project's lanserv simulator is capable of providing
+this interface.  It is also capable of an IPMI LAN interface, and
+you can do power control (the lanserv simulator is capable of starting
+a VM, too) and reset of a virtual machine over a standard remote LAN
+interface.  For details on this, see OpenIPMI.
+
+The remote connection to a LAN interface will reconnect if disconnected,

qemu-options.hx Three button serial mouse. Configure the guest to use Microsoft protocol. · line 2240

Quoted 10 lines
qemu-options.hx +10 -0
+so if a remote BMC fails and restarts, it will still be usable.
+
+For instance, to connect to an external interface on the local machine
+port 9002 with a BT physical interface, do the following:
+@table @code
+@item -ipmi bt,tcp:localhost:9002
+@end table
+
+Use @code{-ipmi none} to disable IPMI.
+ETEXI

I tend to question the wisdom of exposing a remote accessible TCP socket with no encryption or authentication, which can be used to shutdown/reset QEMU instances, and who knows what other functions in the future.

While it might be claimed that one would only enable this if QEMU were on a "trusted" management LAN, IMHO, current network threats/attacks mean there is really no such thing as a trusted LAN anymore. So I can't see this being practical to actually use in a production deployment.

BTW, the syntax you show here is the legacy approach where both front and backend device config is mixed. Does you patch work with the modern QEMU syntax which is something like

-chardev name=impi0,tcp:localhost:9002 -device bt,chardev=ipmi0

if it doesn't work, then you'll need to update your patches to support this approach.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#7 lore raw

Re: [Qemu-devel] [PATCH 4/9] Add a base IPMI interface

Quoted 43 lines · Daniel P. Berrange
Quoted 42 lines · On Mon, Jul 09, 2012 at 02:17:04PM -0500, [email protected] wrote:
qemu-options.hx +33 -0
index 125a4da..823f6bc 100644
@@ -2204,6 +2204,41 @@ Three button serial mouse. Configure the guest to use Microsoft protocol.
 @end table
 ETEXI
 
+DEF("ipmi", HAS_ARG, QEMU_OPTION_ipmi, \
+    "-ipmi [kcs|bt,]dev|local|none  IPMI interface to the dev, or internal BMC\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -ipmi [bt|kcs,]@var{dev}|local|none
+@findex -ipmi
+Set up an IPMI interface.  The physical interface may either be
+KCS or BT, the default is KCS.  Two options are available for
+simulation of the IPMI BMC.  If @code{local} is specified, then a
+minimal internal BMC is used.  This BMC is basically useful as a
+watchdog timer and for fooling a system into thinking IPMI is there.
+
+If @var{dev} is specified (see the serial section above for details on
+what can be specified for @var{dev}) then a connection to an external IPMI
+simulator is made.  This interface has the ability to do power control
+and reset, so it can do the normal IPMI types of things required.
 
+The OpenIPMI project's lanserv simulator is capable of providing
+this interface.  It is also capable of an IPMI LAN interface, and
+you can do power control (the lanserv simulator is capable of starting
+a VM, too) and reset of a virtual machine over a standard remote LAN
+interface.  For details on this, see OpenIPMI.
+
+The remote connection to a LAN interface will reconnect if disconnected,
+so if a remote BMC fails and restarts, it will still be usable.
+
+For instance, to connect to an external interface on the local machine
+port 9002 with a BT physical interface, do the following:
+@table @code
+@item -ipmi bt,tcp:localhost:9002
+@end table
+
+Use @code{-ipmi none} to disable IPMI.
+ETEXI

[...]

Quoted 8 lines

BTW, the syntax you show here is the legacy approach where both front and backend device config is mixed. Does you patch work with the modern QEMU syntax which is something like

-chardev name=impi0,tcp:localhost:9002 -device bt,chardev=ipmi0

if it doesn't work, then you'll need to update your patches to support this approach.

Yup. Working -device is mandatory for new devices. Convenience options are optional, and whether they're worth the trouble depends.

Please introduce the convenience option -ipmi in a separate patch.

#8 lore raw

Re: [Qemu-devel] [PATCH 4/9] Add a base IPMI interface

In reply to Daniel P. Berrange
Quoted 38 lines · Daniel P. Berrange
Quoted 37 lines · On Mon, Jul 09, 2012 at 02:17:04PM -0500, [email protected] wrote:
qemu-options.hx +28 -0
index 125a4da..823f6bc 100644
@@ -2204,6 +2204,41 @@ Three button serial mouse. Configure the guest to use Microsoft protocol.
  @end table
  ETEXI
 
+DEF("ipmi", HAS_ARG, QEMU_OPTION_ipmi, \
+    "-ipmi [kcs|bt,]dev|local|none  IPMI interface to the dev, or internal BMC\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -ipmi [bt|kcs,]@var{dev}|local|none
+@findex -ipmi
+Set up an IPMI interface.  The physical interface may either be
+KCS or BT, the default is KCS.  Two options are available for
+simulation of the IPMI BMC.  If @code{local} is specified, then a
+minimal internal BMC is used.  This BMC is basically useful as a
+watchdog timer and for fooling a system into thinking IPMI is there.
+
+If @var{dev} is specified (see the serial section above for details on
+what can be specified for @var{dev}) then a connection to an external IPMI
+simulator is made.  This interface has the ability to do power control
+and reset, so it can do the normal IPMI types of things required.
 
+The OpenIPMI project's lanserv simulator is capable of providing
+this interface.  It is also capable of an IPMI LAN interface, and
+you can do power control (the lanserv simulator is capable of starting
+a VM, too) and reset of a virtual machine over a standard remote LAN
+interface.  For details on this, see OpenIPMI.
+
+The remote connection to a LAN interface will reconnect if disconnected,
+so if a remote BMC fails and restarts, it will still be usable.
+
+For instance, to connect to an external interface on the local machine
+port 9002 with a BT physical interface, do the following:
+@table @code
Quoted 8 lines

qemu-options.hx Three button serial mouse. Configure the guest to use Microsoft protocol. · line 2240

Quoted 5 lines
qemu-options.hx +5 -0
+@item -ipmi bt,tcp:localhost:9002
+@end table
+
+Use @code{-ipmi none} to disable IPMI.
+ETEXI

I tend to question the wisdom of exposing a remote accessible TCP socket with no encryption or authentication, which can be used to shutdown/reset QEMU instances, and who knows what other functions in the future.

Actually, by default it's the other way around. You create a server that takes a connection, and you connect from QEMU to the server. Still not perfect security, of course.

Quoted 5 lines

While it might be claimed that one would only enable this if QEMU were on a "trusted" management LAN, IMHO, current network threats/attacks mean there is really no such thing as a trusted LAN anymore. So I can't see this being practical to actually use in a production deployment.

I would recommend not putting this on a LAN at all. Just use localhost and use a root-only socket number. That way, only root can run the server, and there's no external network access.

We debated this a bit over on the kvm list and there was no clear answer. If you want a fully extensible IPMI management controller, I don't see putting that into QEMU. It's big, the configuration is complicated, and it's limiting. It seems more appropriate to me to make that external. I could look at using ssl, but the key management will become a pain.

And you do have the "internal" version of a management controller. It doesn't do much, but if you need a secure one and you don't need a capable one, it would do fine.

-corey

#9 lore raw

Re: [Qemu-devel] [PATCH 4/9] Add a base IPMI interface

In reply to [email protected]

Il 09/07/2012 21:17, [email protected] ha scritto:

hw/ipmi.h line 87

Quoted 5 lines
hw/ipmi.h new file +5 -0
+
+/* Phyical interface types. */
+#define IPMI_KCS	1
+#define IPMI_BT		2
+#define IPMI_SMIC	3

The code is not 100% consistent for values that are defined in hardware specs (enums are preferred for new code, but that's not really enforced). However, for everything else please use enums rather than arbitrary #defines.

Paolo

#10 lore raw

PATCH 5/9 IPMI: Add a PC ISA type structure

In reply to [email protected]

From: Corey Minyard <[email protected]>

This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    1 +
 hw/isa_ipmi.c                      |  138 ++++++++++++++++++++++++++++++++++++
 hw/pc.c                            |   12 +++
 hw/pc.h                            |   18 +++++
 hw/smbios.h                        |   12 +++
 7 files changed, 183 insertions(+), 0 deletions(-)
 create mode 100644 hw/isa_ipmi.c
default-configs/i386-softmmu.mak +1 -0
index eb17afc..c0aff0d 100644
@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
+CONFIG_ISA_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index e4e3e4f..615e4f2 100644
@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
+CONFIG_ISA_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +1 -0
index 0d55997..8f27ffe 100644
@@ -21,6 +21,7 @@ hw-obj-$(CONFIG_ESCC) += escc.o
 hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 
 hw-obj-$(CONFIG_IPMI) += ipmi.o
+hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/isa_ipmi.c new file +138 -0

138 lines not on this page · raw message

hw/pc.c +12 -0
index c0acb6a..965e053 100644
@@ -1173,6 +1173,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
     *floppy = fdctrl_init_isa(isa_bus, fd);
+
+    i = 0;
+    if (do_local_ipmi) {
+	ipmi_isa_init(isa_bus, isa_find_free_irq(isa_bus), ipmi_types[i], NULL);
+	i++;
+    }
+    for(; i < MAX_IPMI_DEVICES; i++) {
+	if (ipmi_hds[i]) {
+	    ipmi_isa_init(isa_bus, isa_find_free_irq(isa_bus),
+			  ipmi_types[i], ipmi_hds[i]);
+	}
+    }
 }
 
 void pc_pci_device_init(PCIBus *pci_bus)
hw/pc.h +18 -0
index 33ab689..5b6d947 100644
@@ -223,6 +223,24 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
     return true;
 }
 
+/* IPMI */
+static inline bool ipmi_isa_init(ISABus *bus, int irq,
+				 int type, QemuOpts *opts)
+{
+    ISADevice *dev;
+
+    dev = isa_try_create(bus, "isa-ipmi");
+    if (!dev) {
+        return false;
+    }
+    qdev_prop_set_uint32(&dev->qdev, "type", type);
+    qdev_prop_set_uint32(&dev->qdev, "irq", irq);
+    qdev_prop_set_ptr(&dev->qdev, "charopts", opts);
+    if (qdev_init(&dev->qdev) < 0) {
+        return false;
+    }
+    return true;
+}
 /* pc_sysfw.c */
 void pc_system_firmware_init(MemoryRegion *rom_memory);
 
hw/smbios.h +12 -0
index 6431a15..b9e4a61 100644
@@ -155,6 +155,18 @@ struct smbios_type_32 {
     uint8_t boot_status;
 } QEMU_PACKED;
 
+/* SMBIOS type 38 - IPMI Device Information */
+struct smbios_type_38 {
+    struct smbios_structure_header header;
+    uint8_t interface_type;
+    uint8_t ipmi_version;
+    uint8_t i2c_slave_addr;
+    uint8_t nv_storage_dev_addr;
+    uint64_t base_addr;
+    uint8_t base_addr_mod_and_irq_info;
+    uint8_t interrupt_number;
+} QEMU_PACKED;
+
 /* SMBIOS type 127 -- End-of-table */
 struct smbios_type_127 {
     struct smbios_structure_header header;
Signature · 1 line
1.7.4.1
#11 lore raw

Re: [Qemu-devel] [PATCH 5/9] IPMI: Add a PC ISA type structure

Il 09/07/2012 21:17, [email protected] ha scritto:

Quoted 89 lines

From: Corey Minyard <[email protected]>

This provides the base infrastructure to tie IPMI low-level interfaces into a PC ISA bus.

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    1 +
 hw/isa_ipmi.c                      |  138 ++++++++++++++++++++++++++++++++++++
 hw/pc.c                            |   12 +++
 hw/pc.h                            |   18 +++++
 hw/smbios.h                        |   12 +++
 7 files changed, 183 insertions(+), 0 deletions(-)
 create mode 100644 hw/isa_ipmi.c
default-configs/i386-softmmu.mak +1 -0
index eb17afc..c0aff0d 100644
@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
+CONFIG_ISA_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index e4e3e4f..615e4f2 100644
@@ -8,6 +8,7 @@ CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
+CONFIG_ISA_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +1 -0
index 0d55997..8f27ffe 100644
@@ -21,6 +21,7 @@ hw-obj-$(CONFIG_ESCC) += escc.o
 hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 
 hw-obj-$(CONFIG_IPMI) += ipmi.o
+hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/isa_ipmi.c new file +30 -0
new file mode 100644
index 0000000..cad78b0
@@ -0,0 +1,138 @@
+/*
+ * QEMU ISA IPMI KCS emulation
+ *
+ * Copyright (c) 2012 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "isa.h"
+#include "pc.h"
+#include "qemu-timer.h"
+#include "sysemu.h"
+#include "smbios.h"
+#include "ipmi.h"

hw/isa_ipmi.c line 40

Quoted 10 lines
hw/isa_ipmi.c new file +10 -0
+
+
+typedef struct ISAIPMIState {
+    ISADevice dev;
+    uint32_t type;
+    uint32_t iobase;
+    uint32_t isairq;
+    uint8_t slave_addr;
+    IPMIState state;
+} ISAIPMIState;

I would prefer to have a TYPE_IPMI_INTERFACE class for IPMIState. Then you can subclass that class in patches 6/7/8, and include a pointer in ISAIPMIState.

Paolo

Quoted 173 lines
hw/isa_ipmi.c new file +97 -0
+static int ipmi_isa_initfn(ISADevice *dev)
+{
+    ISAIPMIState *isa = DO_UPCAST(ISAIPMIState, dev, dev);
+    struct smbios_type_38 smb38;
+
+    if (isa->iobase == -1) {
+	/* If no I/O base is specified, set the defaults */
+	switch (isa->type) {
+	case IPMI_KCS:
+	    isa->iobase = 0xca2;
+	    break;
+	case IPMI_BT:
+	    isa->iobase = 0xe4;
+	    break;
+	case IPMI_SMIC:
+	    isa->iobase = 0xca9;
+	    break;
+	default:
+	    fprintf(stderr, "Unknown IPMI type: %d\n", isa->type);
+	    abort();
+	}
+    }
+
+    isa->state.slave_addr = isa->slave_addr;
+
+    qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 3);
+
+    ipmi_init(isa->type, &isa->state);
+
+    if (isa->isairq > 0) {
+	isa_init_irq(dev, &isa->state.irq, isa->isairq);
+	isa->state.use_irq = 1;
+    }
+
+    isa_register_ioport(dev, &isa->state.io, isa->iobase);
+
+    smb38.header.type = 38;
+    smb38.header.length = sizeof(smb38);
+    smb38.header.handle = 0x3000;
+    smb38.interface_type = isa->state.smbios_type;
+    smb38.ipmi_version = 0x20;
+    smb38.i2c_slave_addr = isa->state.slave_addr;
+    smb38.nv_storage_dev_addr = 0;
+
+    /* or 1 to set it to I/O space */
+    smb38.base_addr = isa->iobase | 1;
+
+     /* 1-byte boundaries, addr bit0=0, level triggered irq */
+    smb38.base_addr_mod_and_irq_info = 1;
+    smb38.interrupt_number = isa->isairq;
+    smbios_table_entry_add((struct smbios_structure_header *) &smb38);
+
+    return 0;
+}
+
+static Property ipmi_isa_properties[] = {
+    DEFINE_PROP_HEX32("type", ISAIPMIState, type,  IPMI_KCS),
+    DEFINE_PROP_HEX32("iobase", ISAIPMIState, iobase,  -1),
+    DEFINE_PROP_UINT32("irq",   ISAIPMIState, isairq,  0),
+    DEFINE_PROP_UINT8("slave_addr", ISAIPMIState, slave_addr,  0),
+    DEFINE_PROP_PTR("charopts",  ISAIPMIState, state.chropts),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static const VMStateDescription vmstate_isa_ipmi = {
+    .name = "isa-ipmi",
+    .version_id = 3,
+    .minimum_version_id = 3,
+    .fields      = (VMStateField []) {
+        VMSTATE_STRUCT(state, ISAIPMIState, 0, vmstate_isa_ipmi,
+		       IPMIState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static void ipmi_isa_class_initfn(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = ipmi_isa_initfn;
+    dc->vmsd = &vmstate_isa_ipmi;
+    dc->props = ipmi_isa_properties;
+}
+
+static TypeInfo ipmi_isa_info = {
+    .name          = "isa-ipmi",
+    .parent        = TYPE_ISA_DEVICE,
+    .instance_size = sizeof(ISAIPMIState),
+    .class_init    = ipmi_isa_class_initfn,
+};
+
+static void ipmi_register_types(void)
+{
+    type_register_static(&ipmi_isa_info);
+}
+
+type_init(ipmi_register_types)
hw/pc.c +12 -0
index c0acb6a..965e053 100644
@@ -1173,6 +1173,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
     *floppy = fdctrl_init_isa(isa_bus, fd);
+
+    i = 0;
+    if (do_local_ipmi) {
+	ipmi_isa_init(isa_bus, isa_find_free_irq(isa_bus), ipmi_types[i], NULL);
+	i++;
+    }
+    for(; i < MAX_IPMI_DEVICES; i++) {
+	if (ipmi_hds[i]) {
+	    ipmi_isa_init(isa_bus, isa_find_free_irq(isa_bus),
+			  ipmi_types[i], ipmi_hds[i]);
+	}
+    }
 }
 
 void pc_pci_device_init(PCIBus *pci_bus)
hw/pc.h +18 -0
index 33ab689..5b6d947 100644
@@ -223,6 +223,24 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
     return true;
 }
 
+/* IPMI */
+static inline bool ipmi_isa_init(ISABus *bus, int irq,
+				 int type, QemuOpts *opts)
+{
+    ISADevice *dev;
+
+    dev = isa_try_create(bus, "isa-ipmi");
+    if (!dev) {
+        return false;
+    }
+    qdev_prop_set_uint32(&dev->qdev, "type", type);
+    qdev_prop_set_uint32(&dev->qdev, "irq", irq);
+    qdev_prop_set_ptr(&dev->qdev, "charopts", opts);
+    if (qdev_init(&dev->qdev) < 0) {
+        return false;
+    }
+    return true;
+}
 /* pc_sysfw.c */
 void pc_system_firmware_init(MemoryRegion *rom_memory);
 
hw/smbios.h +12 -0
index 6431a15..b9e4a61 100644
@@ -155,6 +155,18 @@ struct smbios_type_32 {
     uint8_t boot_status;
 } QEMU_PACKED;
 
+/* SMBIOS type 38 - IPMI Device Information */
+struct smbios_type_38 {
+    struct smbios_structure_header header;
+    uint8_t interface_type;
+    uint8_t ipmi_version;
+    uint8_t i2c_slave_addr;
+    uint8_t nv_storage_dev_addr;
+    uint64_t base_addr;
+    uint8_t base_addr_mod_and_irq_info;
+    uint8_t interrupt_number;
+} QEMU_PACKED;
+
 /* SMBIOS type 127 -- End-of-table */
 struct smbios_type_127 {
     struct smbios_structure_header header;
#12 lore raw

Re: [Qemu-devel] [PATCH 5/9] IPMI: Add a PC ISA type structure

In reply to [email protected]

Il 09/07/2012 21:17, [email protected] ha scritto:

hw/isa_ipmi.c line 98

Quoted 3 lines
hw/isa_ipmi.c new file +3 -0
+
+static Property ipmi_isa_properties[] = {
+    DEFINE_PROP_HEX32("type", ISAIPMIState, type,  IPMI_KCS),

You can add an enum property. There is one example called LostTickPolicy in the tree. Please do not use the generic "type" name; use "interface" for example.

Start with an empty enum, and let each of the two patches 6/7 add an item; same for the various switch statements on IPMI_KCS/IPMI_BT/IPMI_SMIC. (Actually if you do this the IPMI_SMIC branches will disappear, right?)

hw/isa_ipmi.c line 102

Quoted 4 lines
hw/isa_ipmi.c new file +4 -0
+    DEFINE_PROP_HEX32("iobase", ISAIPMIState, iobase,  -1),
+    DEFINE_PROP_UINT32("irq",   ISAIPMIState, isairq,  0),
+    DEFINE_PROP_UINT8("slave_addr", ISAIPMIState, slave_addr,  0),
+    DEFINE_PROP_PTR("charopts",  ISAIPMIState, state.chropts),

Here, you should add a "normal" chardev property so that people can use -chardev and -device to create the IPMI interface. The device can be created like this:

-chardev ...,id=charipmi -device ipmi,interface=kcs,chardev=charipmi

If the chardev is absent, the local interface is used instead.

See docs/qdev-device-use.txt for more information.

Quoted 83 lines
hw/isa_ipmi.c new file +36 -0
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static const VMStateDescription vmstate_isa_ipmi = {
+    .name = "isa-ipmi",
+    .version_id = 3,
+    .minimum_version_id = 3,
+    .fields      = (VMStateField []) {
+        VMSTATE_STRUCT(state, ISAIPMIState, 0, vmstate_isa_ipmi,
+		       IPMIState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static void ipmi_isa_class_initfn(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+    ic->init = ipmi_isa_initfn;
+    dc->vmsd = &vmstate_isa_ipmi;
+    dc->props = ipmi_isa_properties;
+}
+
+static TypeInfo ipmi_isa_info = {
+    .name          = "isa-ipmi",
+    .parent        = TYPE_ISA_DEVICE,
+    .instance_size = sizeof(ISAIPMIState),
+    .class_init    = ipmi_isa_class_initfn,
+};
+
+static void ipmi_register_types(void)
+{
+    type_register_static(&ipmi_isa_info);
+}
+
+type_init(ipmi_register_types)
hw/pc.c +12 -0
index c0acb6a..965e053 100644
@@ -1173,6 +1173,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
     *floppy = fdctrl_init_isa(isa_bus, fd);
+
+    i = 0;
+    if (do_local_ipmi) {
+	ipmi_isa_init(isa_bus, isa_find_free_irq(isa_bus), ipmi_types[i], NULL);
+	i++;
+    }
+    for(; i < MAX_IPMI_DEVICES; i++) {
+	if (ipmi_hds[i]) {
+	    ipmi_isa_init(isa_bus, isa_find_free_irq(isa_bus),
+			  ipmi_types[i], ipmi_hds[i]);
+	}
+    }
 }
 
 void pc_pci_device_init(PCIBus *pci_bus)
hw/pc.h +16 -0
index 33ab689..5b6d947 100644
@@ -223,6 +223,24 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
     return true;
 }
 
+/* IPMI */
+static inline bool ipmi_isa_init(ISABus *bus, int irq,
+				 int type, QemuOpts *opts)
+{
+    ISADevice *dev;
+
+    dev = isa_try_create(bus, "isa-ipmi");
+    if (!dev) {
+        return false;
+    }
+    qdev_prop_set_uint32(&dev->qdev, "type", type);
+    qdev_prop_set_uint32(&dev->qdev, "irq", irq);
+    qdev_prop_set_ptr(&dev->qdev, "charopts", opts);
+    if (qdev_init(&dev->qdev) < 0) {
+        return false;
+    }
#13 lore raw

Re: [Qemu-devel] [PATCH 5/9] IPMI: Add a PC ISA type structure

Quoted 10 lines · Paolo Bonzini

Here, you should add a "normal" chardev property so that people can use -chardev and -device to create the IPMI interface. The device can be created like this:

-chardev ...,id=charipmi -device ipmi,interface=kcs,chardev=charipmi

If the chardev is absent, the local interface is used instead.

See docs/qdev-device-use.txt for more information.

I had originally used a "normal" chardev here. However, I needed a way for the connection to be re-established if it dropped for some reason, for obvious reasons. The standard chardev doesn't seem to have any provision for this, at least none that I could find.

Am I missing something? If not, should I add that capability to the chardev?

-corey

#14 lore raw

PATCH 6/9 IPMI: Add a KCS low-level interface

In reply to [email protected]

From: Corey Minyard <[email protected]>

This provides the simulation of the KCS hardware interface.

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    1 +
 hw/ipmi_kcs.c                      |  259 ++++++++++++++++++++++++++++++++++++
 hw/ipmi_kcs.h                      |   82 +++++++++++
 5 files changed, 344 insertions(+), 0 deletions(-)
 create mode 100644 hw/ipmi_kcs.c
 create mode 100644 hw/ipmi_kcs.h
default-configs/i386-softmmu.mak +1 -0
index c0aff0d..b549389 100644
@@ -9,6 +9,7 @@ CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_ISA_IPMI=y
+CONFIG_IPMI_KCS=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index 615e4f2..af7d2a9 100644
@@ -9,6 +9,7 @@ CONFIG_VMWARE_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_ISA_IPMI=y
+CONFIG_IPMI_KCS=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +1 -0
index 8f27ffe..99e5d1e 100644
@@ -22,6 +22,7 @@ hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 
 hw-obj-$(CONFIG_IPMI) += ipmi.o
 hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
+hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_kcs.c new file +259 -0

259 lines not on this page · raw message

hw/ipmi_kcs.h new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#15 lore raw

PATCH 7/9 IPMI: Add a BT low-level interface

In reply to [email protected]

From: Corey Minyard <[email protected]>

This provides the simulation of the BT hardware interface for IPMI.

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    1 +
 hw/ipmi_bt.c                       |  265 ++++++++++++++++++++++++++++++++++++
 hw/ipmi_bt.h                       |   99 +++++++++++++
 5 files changed, 367 insertions(+), 0 deletions(-)
 create mode 100644 hw/ipmi_bt.c
 create mode 100644 hw/ipmi_bt.h
default-configs/i386-softmmu.mak +1 -0
index b549389..f8f8e6d 100644
@@ -10,6 +10,7 @@ CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_ISA_IPMI=y
 CONFIG_IPMI_KCS=y
+CONFIG_IPMI_BT=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index af7d2a9..8c1177d 100644
@@ -10,6 +10,7 @@ CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_ISA_IPMI=y
 CONFIG_IPMI_KCS=y
+CONFIG_IPMI_BT=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +1 -0
index 99e5d1e..e1d30cc 100644
@@ -23,6 +23,7 @@ hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 hw-obj-$(CONFIG_IPMI) += ipmi.o
 hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
 hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o
+hw-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_bt.c new file +265 -0

265 lines not on this page · raw message

hw/ipmi_bt.h new file +99 -0

99 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#16 lore raw

PATCH 8/9 IPMI: Add a local BMC simulation

In reply to [email protected]

From: Corey Minyard <[email protected]>

This provides a minimal local BMC, basically enough to comply with the spec and provide a complete watchdog timer (including a sensor, SDR, and event).

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    1 +
 hw/ipmi_sim.c                      | 1273 ++++++++++++++++++++++++++++++++++++
 hw/ipmi_sim.h                      |  270 ++++++++
 5 files changed, 1546 insertions(+), 0 deletions(-)
 create mode 100644 hw/ipmi_sim.c
 create mode 100644 hw/ipmi_sim.h
default-configs/i386-softmmu.mak +1 -0
index f8f8e6d..8c99d5d 100644
@@ -11,6 +11,7 @@ CONFIG_IPMI=y
 CONFIG_ISA_IPMI=y
 CONFIG_IPMI_KCS=y
 CONFIG_IPMI_BT=y
+CONFIG_IPMI_LOCAL=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index 8c1177d..4d01883 100644
@@ -11,6 +11,7 @@ CONFIG_IPMI=y
 CONFIG_ISA_IPMI=y
 CONFIG_IPMI_KCS=y
 CONFIG_IPMI_BT=y
+CONFIG_IPMI_LOCAL=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +1 -0
index e1d30cc..193227d 100644
@@ -24,6 +24,7 @@ hw-obj-$(CONFIG_IPMI) += ipmi.o
 hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
 hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o
 hw-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o
+hw-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_sim.c new file +1273 -0

1,273 lines not on this page · raw message

hw/ipmi_sim.h new file +270 -0

270 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#17 lore raw

PATCH 9/9 IPMI: Add an external connection simulation interface

In reply to [email protected]

From: Corey Minyard <[email protected]>

This adds an interface for IPMI that connects to a remote BMC over a chardev (generally a TCP socket). The OpenIPMI lanserv simulator describes this interface, see that for interface details.

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/Makefile.objs                   |    1 +
 hw/ipmi_extern.c                   |  421 ++++++++++++++++++++++++++++++++++++
 hw/ipmi_extern.h                   |   75 +++++++
 5 files changed, 499 insertions(+), 0 deletions(-)
 create mode 100644 hw/ipmi_extern.c
 create mode 100644 hw/ipmi_extern.h
default-configs/i386-softmmu.mak +1 -0
index 8c99d5d..325f92e 100644
@@ -12,6 +12,7 @@ CONFIG_ISA_IPMI=y
 CONFIG_IPMI_KCS=y
 CONFIG_IPMI_BT=y
 CONFIG_IPMI_LOCAL=y
+CONFIG_IPMI_EXTERN=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
default-configs/x86_64-softmmu.mak +1 -0
index 4d01883..2ac9177 100644
@@ -12,6 +12,7 @@ CONFIG_ISA_IPMI=y
 CONFIG_IPMI_KCS=y
 CONFIG_IPMI_BT=y
 CONFIG_IPMI_LOCAL=y
+CONFIG_IPMI_EXTERN=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
hw/Makefile.objs +1 -0
index 193227d..06757b0 100644
@@ -25,6 +25,7 @@ hw-obj-$(CONFIG_ISA_IPMI) += isa_ipmi.o
 hw-obj-$(CONFIG_IPMI_KCS) += ipmi_kcs.o
 hw-obj-$(CONFIG_IPMI_BT) += ipmi_bt.o
 hw-obj-$(CONFIG_IPMI_LOCAL) += ipmi_sim.o
+hw-obj-$(CONFIG_IPMI_EXTERN) += ipmi_extern.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
hw/ipmi_extern.c new file +421 -0

421 lines not on this page · raw message

hw/ipmi_extern.h new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#18 lore raw
In reply to [email protected]

Il 09/07/2012 21:17, [email protected] ha scritto:

Quoted 19 lines

I had asked about getting an IPMI device into qemu and received some interest, and it's useful to me, so I've done some work to add it. The following patch set has a set of patches to add an IPMI KCS device, and IPMI BT device, a built-in BMC (IPMI management controller), and a way to attach an external BMC through a chardev.

There was some discussion on whether to make the BMC internal or external, but I went ahead and added both. The internal one is fairly basic and not extensible, at least without adding code. I've modified the OpenIPMI library simulator to work with the external interface to allow it to receive connections from the qemu external simulator with a fairly basic protocol.

I've also added the ability for the OpenIPMI library to manage a VM to power it on, power it off, reset it, and handle an IPMI watchdog timer. So it looks quite like a real system. Instructions for using it are in the OpenIPMI release candidate I uploaded to
https://sourceforge.net/projects/openipmi

Quoted 4 lines

Since IPMI can advertise its presence via SMBIOS, I added a way for a driver to add an SMBIOS entry. I also added a way to query a free interrupt from the ISA bus, since the interrupt is in the SMBIOS entry and nobody really cares which one is used.

I provided some feedback in the individual patches, it shouldn't be a lot of work compared to what you have done already!

It would be great if you could add a basic testcase using qtest, even if only for the internal interface, to ensure it doesn't bitrot.

Paolo

#19 lore raw
Quoted 20 lines · Paolo Bonzini

Il 09/07/2012 21:17, [email protected] ha scritto:

Quoted 19 lines

I had asked about getting an IPMI device into qemu and received some interest, and it's useful to me, so I've done some work to add it. The following patch set has a set of patches to add an IPMI KCS device, and IPMI BT device, a built-in BMC (IPMI management controller), and a way to attach an external BMC through a chardev.

There was some discussion on whether to make the BMC internal or external, but I went ahead and added both. The internal one is fairly basic and not extensible, at least without adding code. I've modified the OpenIPMI library simulator to work with the external interface to allow it to receive connections from the qemu external simulator with a fairly basic protocol.

I've also added the ability for the OpenIPMI library to manage a VM to power it on, power it off, reset it, and handle an IPMI watchdog timer. So it looks quite like a real system. Instructions for using it are in the OpenIPMI release candidate I uploaded to
https://sourceforge.net/projects/openipmi

Quoted 6 lines
Quoted 4 lines

Since IPMI can advertise its presence via SMBIOS, I added a way for a driver to add an SMBIOS entry. I also added a way to query a free interrupt from the ISA bus, since the interrupt is in the SMBIOS entry and nobody really cares which one is used.

I provided some feedback in the individual patches, it shouldn't be a lot of work compared to what you have done already!

Yes, looks like all good comments. I'll work on these over the next few days and resubmit. Thanks.

Quoted 3 lines

It would be great if you could add a basic testcase using qtest, even if only for the internal interface, to ensure it doesn't bitrot.

Yes, certainly.

Thanks again,

-corey