From: minyard@acm.org
To: qemu-devel@nongnu.org
Cc: Corey Minyard <cminyard@mvista.com>
Subject: [Qemu-devel] [PATCH 09/16] ipmi: Add migration capability to the IPMI device.
Date: Fri, 12 Dec 2014 13:15:44 -0600 [thread overview]
Message-ID: <1418411751-3614-10-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1418411751-3614-1-git-send-email-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com
---
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(-)
diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c
index b046517..f3e5e9e 100644
--- a/hw/ipmi/ipmi.c
+++ b/hw/ipmi/ipmi.c
@@ -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,
diff --git a/hw/ipmi/ipmi.h b/hw/ipmi/ipmi.h
index 6b2a3e9..56cb423 100644
--- a/hw/ipmi/ipmi.h
+++ b/hw/ipmi/ipmi.h
@@ -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);
diff --git a/hw/ipmi/ipmi_bt.c b/hw/ipmi/ipmi_bt.c
index 95beb71..105b978 100644
--- a/hw/ipmi/ipmi_bt.c
+++ b/hw/ipmi/ipmi_bt.c
@@ -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)
diff --git a/hw/ipmi/ipmi_extern.c b/hw/ipmi/ipmi_extern.c
index b59ff8a..aace0b3 100644
--- a/hw/ipmi/ipmi_extern.c
+++ b/hw/ipmi/ipmi_extern.c
@@ -63,10 +63,10 @@ typedef struct IPMIExternBmc {
unsigned char inbuf[MAX_IPMI_MSG_SIZE + 2];
unsigned int inpos;
- int in_escape;
- int in_too_many;
- int waiting_rsp;
- int sending_cmd;
+ bool in_escape;
+ bool in_too_many;
+ bool waiting_rsp;
+ bool sending_cmd;
unsigned char outbuf[(MAX_IPMI_MSG_SIZE + 2) * 2 + 1];
unsigned int outpos;
@@ -425,12 +425,46 @@ static void ipmi_extern_handle_reset(IPMIBmc *b)
continue_send(es);
}
+static int ipmi_extern_post_migrate(void *opaque, int version_id)
+{
+ IPMIExternBmc *es = opaque;
+
+ /*
+ * We don't directly restore waiting_rsp, Instead, we return an
+ * error on the interface if a response was being waited for.
+ */
+ if (es->waiting_rsp) {
+ IPMIInterface *s = es->parent.intf;
+ IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
+
+ es->waiting_rsp = 0;
+ es->inbuf[1] = es->outbuf[1] | 0x04;
+ es->inbuf[2] = es->outbuf[2];
+ es->inbuf[3] = IPMI_CC_BMC_INIT_IN_PROGRESS;
+ k->handle_rsp(s, es->outbuf[0], es->inbuf + 1, 3);
+ }
+ return 0;
+}
+
+static const VMStateDescription vmstate_ipmi_extern = {
+ .name = TYPE_IPMI_BMC_EXTERN,
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .post_load = ipmi_extern_post_migrate,
+ .fields = (VMStateField[]) {
+ VMSTATE_BOOL(send_reset, IPMIExternBmc),
+ VMSTATE_BOOL(waiting_rsp, IPMIExternBmc),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static void ipmi_extern_init(IPMIBmc *b, Error **errp)
{
IPMIExternBmc *es = IPMI_BMC_EXTERN(b);
es->extern_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, extern_timeout, es);
qemu_chr_add_handlers(es->parent.chr, can_receive, receive, chr_event, es);
+ vmstate_register(NULL, 0, &vmstate_ipmi_extern, es);
}
static void ipmi_extern_class_init(ObjectClass *klass, void *data)
diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c
index 411799e..e3af39e 100644
--- a/hw/ipmi/ipmi_kcs.c
+++ b/hw/ipmi/ipmi_kcs.c
@@ -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)
diff --git a/hw/ipmi/ipmi_sim.c b/hw/ipmi/ipmi_sim.c
index 8028f40..7480d00 100644
--- a/hw/ipmi/ipmi_sim.c
+++ b/hw/ipmi/ipmi_sim.c
@@ -1657,6 +1657,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;
@@ -1703,6 +1731,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)
diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c
index 1c1ab8d..e62f744 100644
--- a/hw/ipmi/isa_ipmi.c
+++ b/hw/ipmi/isa_ipmi.c
@@ -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;
}
--
1.8.3.1
next prev parent reply other threads:[~2014-12-12 19:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 19:15 [Qemu-devel] [PATCH 00/16] Add an IPMI device to qemu minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 01/16] Add a base IPMI interface minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 02/16] ipmi: Add a PC ISA type structure minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 03/16] ipmi: Add a KCS low-level interface minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 04/16] ipmi: Add a BT " minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 05/16] ipmi: Add a local BMC simulation minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 06/16] ipmi: Add an external connection simulation interface minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 07/16] ipmi: Add tests minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 08/16] ipmi: Add documentation minyard
2014-12-12 19:15 ` minyard [this message]
2014-12-12 19:15 ` [Qemu-devel] [PATCH 10/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 11/16] smbios: Add a function to directly add an entry minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 12/16] ipmi: Add SMBIOS table entry minyard
2015-02-19 2:53 ` Benjamin Herrenschmidt
2014-12-12 19:15 ` [Qemu-devel] [PATCH 13/16] acpi: Add a way to extend tables minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 14/16] acpi: Add table construction tools minyard
2014-12-12 19:15 ` [Qemu-devel] [PATCH 15/16] ipmi: Add ACPI table entries for BMCs minyard
2015-02-19 2:54 ` Benjamin Herrenschmidt
2015-02-20 3:16 ` Corey Minyard
2015-02-22 20:48 ` Benjamin Herrenschmidt
2014-12-12 19:15 ` [Qemu-devel] [PATCH 16/16] ipmi: Add a thread to better simulate a BMC minyard
2014-12-15 21:11 ` Paolo Bonzini
2014-12-15 21:33 ` Corey Minyard
2014-12-15 21:21 ` [Qemu-devel] [PATCH 00/16] Add an IPMI device to qemu Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418411751-3614-10-git-send-email-minyard@acm.org \
--to=minyard@acm.org \
--cc=cminyard@mvista.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).