From patchwork Tue Nov 12 16:33:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 290720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C2BD12C00AB for ; Wed, 13 Nov 2013 03:44:16 +1100 (EST) Received: from localhost ([::1]:43923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgH4Y-0002Q5-CH for incoming@patchwork.ozlabs.org; Tue, 12 Nov 2013 11:44:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGuH-0004i7-CE for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgGu5-0007Mb-FP for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:37 -0500 Received: from mail-oa0-x230.google.com ([2607:f8b0:4003:c02::230]:54732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGu5-0007Lt-9Z for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:25 -0500 Received: by mail-oa0-f48.google.com with SMTP id n16so3228003oag.7 for ; Tue, 12 Nov 2013 08:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=E1Q61g/2lIQoAkAdTESpj+YReWU4ylrWVGVUICvHVrA=; b=CeW2/WsI3bTptyA3nBsEIa8u5Xr+5cb5ZyIjxH9u11B0hnTrZEtmyWySBopWx6lW9O isO/DoxJQ4q5LK/nTyrwY1ScTgkIp7nlJUx6rWyEgOoS9VbZuVlq0eJpu+zEJH7umD1Z 89xJ3o7NmYrhTbieyTILo5xULt2qiLAxrDJGU1BkeaCJ/exxKilaawJo9eAcSUBIspjs TkrfNjIyp2oM0irQepxjYk510QRlVT6/Ikk5miTvlX79Pbbf1Y/hqvfDoultx4RaSgWi j9a8ofwcLgTme+AonrXd/Mh/lERuRpJgGl7bzNmWortfs2fPuWUEqdzWy206Nrw/9MPj kk4g== X-Received: by 10.182.29.33 with SMTP id g1mr7379203obh.59.1384274004755; Tue, 12 Nov 2013 08:33:24 -0800 (PST) Received: from t430.minyard.home (pool-173-57-152-84.dllstx.fios.verizon.net. [173.57.152.84]) by mx.google.com with ESMTPSA id m7sm33789402obo.7.2013.11.12.08.33.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2013 08:33:23 -0800 (PST) Received: from t430.minyard.home (t430.minyard.home [127.0.0.1]) by t430.minyard.home (8.14.7/8.14.7) with ESMTP id rACGXM4c016647; Tue, 12 Nov 2013 10:33:22 -0600 Received: (from cminyard@localhost) by t430.minyard.home (8.14.7/8.14.7/Submit) id rACGXMFn016645; Tue, 12 Nov 2013 10:33:22 -0600 From: Corey Minyard To: qemu-devel@nongnu.org Date: Tue, 12 Nov 2013 10:33:12 -0600 Message-Id: <1384273995-16486-14-git-send-email-cminyard@mvista.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1384273995-16486-1-git-send-email-cminyard@mvista.com> References: <1384273995-16486-1-git-send-email-cminyard@mvista.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::230 Cc: Bret Ketchum , Corey Minyard , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 13/16] ipmi: Add migration capability to the IPMI device. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Corey Minyard io_length = 3; memory_region_init_io(&s->io, OBJECT(s), &ipmi_bt_io_ops, bt, "ipmi-bt", 3); + vmstate_register(NULL, 0, &vmstate_ipmi_bt, bt); return 0; } diff --git a/hw/ipmi/ipmi_extern.c b/hw/ipmi/ipmi_extern.c index 1cd7c11..d66797d 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; @@ -442,6 +442,39 @@ static void ipmi_extern_handle_reset(IPMIBmc *b) ipmi_unlock(s); } +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 int ipmi_extern_init(IPMIBmc *b) { IPMIExternBmc *es = IPMI_BMC_EXTERN(b); @@ -449,6 +482,7 @@ static int ipmi_extern_init(IPMIBmc *b) es->extern_timer = timer_new(QEMU_CLOCK_REALTIME, SCALE_NS, extern_timeout, es); qemu_chr_add_handlers(es->parent.chr, can_receive, receive, chr_event, es); + vmstate_register(NULL, 0, &vmstate_ipmi_extern, es); return 0; } diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c index 056a369..81f0709 100644 --- a/hw/ipmi/ipmi_kcs.c +++ b/hw/ipmi/ipmi_kcs.c @@ -304,6 +304,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 int ipmi_kcs_init(IPMIInterface *s) { IPMIKcsInterface *kcs = IPMI_INTERFACE_KCS(s); @@ -315,6 +329,7 @@ static int ipmi_kcs_init(IPMIInterface *s) memory_region_init_io(&s->io, OBJECT(s), &ipmi_kcs_io_ops, kcs, "ipmi-kcs", 2); + vmstate_register(NULL, 0, &vmstate_ipmi_kcs, kcs); return 0; } diff --git a/hw/ipmi/ipmi_sim.c b/hw/ipmi/ipmi_sim.c index 327a01c..fc124a7 100644 --- a/hw/ipmi/ipmi_sim.c +++ b/hw/ipmi/ipmi_sim.c @@ -1481,6 +1481,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 int ipmi_sim_init(IPMIBmc *b) { unsigned int i; @@ -1526,6 +1554,8 @@ static int ipmi_sim_init(IPMIBmc *b) ss->timer = timer_new(QEMU_CLOCK_VIRTUAL, SCALE_NS, ipmi_timeout, ss); + vmstate_register(NULL, 0, &vmstate_ipmi_sim, ss); + return 0; } diff --git a/hw/ipmi/isa_ipmi.c b/hw/ipmi/isa_ipmi.c index 0242a41..b38c846 100644 --- a/hw/ipmi/isa_ipmi.c +++ b/hw/ipmi/isa_ipmi.c @@ -124,12 +124,24 @@ 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; }