Skip to contentSkip to conversation

ipmi: Minor fixes

PATCH New [email protected] 1 participant 7 messages Sep 8, 2016 – Sep 12, 2016

lore
Share & tools
lore
#0 lore raw

cover ipmi: Minor fixes

These patches are fixes for various small issues. Nothing that's that big of a deal, but they need to be fixed.

#1 lore raw

PATCH 1/5 ipmi: Remove hotplug from IPMI BMCs

From: Corey Minyard <[email protected]>

No hotplug support, make sure it doesn't happen.

---
 hw/ipmi/ipmi_bmc_extern.c | 1 +
 hw/ipmi/ipmi_bmc_sim.c    | 1 +
 2 files changed, 2 insertions(+)
hw/ipmi/ipmi_bmc_extern.c +1 -0
index 157879e..ebd0d8d 100644
@@ -499,6 +499,7 @@ static void ipmi_bmc_extern_class_init(ObjectClass *oc, void *data)
 
     bk->handle_command = ipmi_bmc_extern_handle_command;
     bk->handle_reset = ipmi_bmc_extern_handle_reset;
+    dc->hotpluggable = false;
     dc->realize = ipmi_bmc_extern_realize;
     dc->props = ipmi_bmc_extern_properties;
 }
hw/ipmi/ipmi_bmc_sim.c +1 -0
index dc9c14c..190e169 100644
@@ -1791,6 +1791,7 @@ static void ipmi_sim_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIBmcClass *bk = IPMI_BMC_CLASS(oc);
 
+    dc->hotpluggable = false;
     dc->realize = ipmi_sim_realize;
     bk->handle_command = ipmi_sim_handle_command;
 }
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/5 ipmi_bmc_sim: Remove an unnecessary mutex

In reply to [email protected]

From: Corey Minyard <[email protected]>

Get rid of the unnecessary mutex, it was a vestige of something else that was not done. That way we don't have to free it.

---
 hw/ipmi/ipmi_bmc_sim.c | 6 ------
 1 file changed, 6 deletions(-)
hw/ipmi/ipmi_bmc_sim.c +0 -6
index 190e169..b38f4f0 100644
@@ -217,7 +217,6 @@ struct IPMIBmcSim {
     /* Odd netfns are for responses, so we only need the even ones. */
     const IPMINetfn *netfns[MAX_NETFNS / 2];
 
-    QemuMutex lock;
     /* We allow one event in the buffer */
     uint8_t evtbuf[16];
 
@@ -940,7 +939,6 @@ static void get_msg(IPMIBmcSim *ibs,
 {
     IPMIRcvBufEntry *msg;
 
-    qemu_mutex_lock(&ibs->lock);
     if (QTAILQ_EMPTY(&ibs->rcvbufs)) {
         rsp_buffer_set_error(rsp, 0x80); /* Queue empty */
         goto out;
@@ -960,7 +958,6 @@ static void get_msg(IPMIBmcSim *ibs,
     }
 
 out:
-    qemu_mutex_unlock(&ibs->lock);
     return;
 }
 
@@ -1055,11 +1052,9 @@ static void send_msg(IPMIBmcSim *ibs,
  end_msg:
     msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
     msg->len++;
-    qemu_mutex_lock(&ibs->lock);
     QTAILQ_INSERT_TAIL(&ibs->rcvbufs, msg, entry);
     ibs->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
     k->set_atn(s, 1, attn_irq_enabled(ibs));
-    qemu_mutex_unlock(&ibs->lock);
 }
 
 static void do_watchdog_reset(IPMIBmcSim *ibs)
@@ -1753,7 +1748,6 @@ static void ipmi_sim_realize(DeviceState *dev, Error **errp)
     unsigned int i;
     IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
 
-    qemu_mutex_init(&ibs->lock);
     QTAILQ_INIT(&ibs->rcvbufs);
 
     ibs->bmc_global_enables = (1 << IPMI_BMC_EVENT_LOG_BIT);
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/5 ipmi: chassis poweroff should use qemu_system_shutdown_request()

In reply to [email protected]

From: Cédric Le Goater <[email protected]>

When issuing a chassis 'powerdown' control command, the routine qemu_system_shutdown_request() should be used to exit the guest. qemu_system_powerdown_request() will initiate a soft shutdown which is not what is required by the IPMI (28.3 Chassis Control Command):

0h = power down. Force system into soft off (S4/S45) state. This is for 'emergency' management power down actions. The command does not initiate a clean shut-down of the operating system prior to powering down the system

---
 hw/ipmi/ipmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ipmi/ipmi.c +1 -1
index f09f217..f91c7b7 100644
@@ -51,7 +51,7 @@ static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
         if (checkonly) {
             return 0;
         }
-        qemu_system_powerdown_request();
+        qemu_system_shutdown_request();
         return 0;
 
     case IPMI_SEND_NMI:
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/5 ipmi: Implement shutdown via ACPI overtemp

In reply to [email protected]

From: Corey Minyard <[email protected]>

This is allowed by the IPMI specification for graceful shutdown, so implement it.

---
 hw/ipmi/ipmi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
hw/ipmi/ipmi.c +7 -1
index f91c7b7..5cf1caa 100644
@@ -61,9 +61,15 @@ static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
         qmp_inject_nmi(NULL);
         return 0;
 
+    case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
+        if (checkonly) {
+            return 0;
+        }
+        qemu_system_powerdown_request();
+        return 0;
+
     case IPMI_POWERCYCLE_CHASSIS:
     case IPMI_PULSE_DIAG_IRQ:
-    case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
     case IPMI_POWERON_CHASSIS:
     default:
         return IPMI_CC_COMMAND_NOT_SUPPORTED;
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/5 ipmi: fix build config variable name for ipmi_bmc_extern.o

In reply to [email protected]

From: "Daniel P. Berrange" <[email protected]>

The original commit:

commit 67aa56fc03bea44ccf384ea400515a8a58844a50
Author: Corey Minyard <[email protected]>
Date: Thu Dec 17 12:50:06 2015 -0600

ipmi: Add an external connection simulation interface

defined a new variable CONFIG_IPMI_EXTERN, but then went on to mistakely use the pre-existing CONFIG_IPMI_LOCAL variable.

---
 hw/ipmi/Makefile.objs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ipmi/Makefile.objs +1 -1
index a90318d..1b422bb 100644
@@ -1,5 +1,5 @@
 common-obj-$(CONFIG_IPMI) += ipmi.o
 common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
-common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o
+common-obj-$(CONFIG_IPMI_EXTERN) += ipmi_bmc_extern.o
 common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o
 common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o
Signature · 1 line
2.7.4
#6 lore raw

PATCH 1/1 ipmi: Add graceful shutdown handling to the external BMC

In reply to [email protected]

From: Corey Minyard <[email protected]>

I misunderstood the workings of the power settings, the power off is a force off operation and there needs to be a separate graceful shutdown operation. So replace the force off operation with a graceful shutdown.

---
 hw/ipmi/ipmi_bmc_extern.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

This is the final patch to implement proper shutdown for the external interface. OpenIPMI is changed to match this.

hw/ipmi/ipmi_bmc_extern.c +8 -3
index 032720a..a141f0a 100644
@@ -54,7 +54,8 @@
 #define   VM_CAPABILITIES_IRQ      0x04
 #define   VM_CAPABILITIES_NMI      0x08
 #define   VM_CAPABILITIES_ATTN     0x10
-#define VM_CMD_FORCEOFF            0x09
+#define   VM_CAPABILITIES_GRACEFUL_SHUTDOWN 0x20
+#define VM_CMD_GRACEFUL_SHUTDOWN   0x09
 
 #define TYPE_IPMI_BMC_EXTERN "ipmi-bmc-extern"
 #define IPMI_BMC_EXTERN(obj) OBJECT_CHECK(IPMIBmcExtern, (obj), \
@@ -272,8 +273,8 @@ static void handle_hw_op(IPMIBmcExtern *ibe, unsigned char hw_op)
         k->do_hw_op(s, IPMI_SEND_NMI, 0);
         break;
 
-    case VM_CMD_FORCEOFF:
-        qemu_system_shutdown_request();
+    case VM_CMD_GRACEFUL_SHUTDOWN:
+        k->do_hw_op(s, IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP, 0);
         break;
     }
 }
@@ -397,6 +398,10 @@ static void chr_event(void *opaque, int event)
         if (k->do_hw_op(ibe->parent.intf, IPMI_POWEROFF_CHASSIS, 1) == 0) {
             v |= VM_CAPABILITIES_POWER;
         }
+        if (k->do_hw_op(ibe->parent.intf, IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP, 1)
+            == 0) {
+            v |= VM_CAPABILITIES_GRACEFUL_SHUTDOWN;
+        }
         if (k->do_hw_op(ibe->parent.intf, IPMI_RESET_CHASSIS, 1) == 0) {
             v |= VM_CAPABILITIES_RESET;
         }
Signature · 1 line
2.7.4