From patchwork Wed Nov 21 14:46:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 200788 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7B8592C008F for ; Thu, 22 Nov 2012 01:46:53 +1100 (EST) Received: from localhost ([::1]:32862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbBZj-00016c-Np for incoming@patchwork.ozlabs.org; Wed, 21 Nov 2012 09:46:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbBYv-0007PN-8v for qemu-devel@nongnu.org; Wed, 21 Nov 2012 09:46:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbBYn-0001ql-Mn for qemu-devel@nongnu.org; Wed, 21 Nov 2012 09:46:01 -0500 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:38725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbBYn-0001qX-Ai for qemu-devel@nongnu.org; Wed, 21 Nov 2012 09:45:53 -0500 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Nov 2012 14:45:52 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Nov 2012 14:45:50 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qALEjgTa59572370 for ; Wed, 21 Nov 2012 14:45:42 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qALEjnFE020087 for ; Wed, 21 Nov 2012 07:45:49 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qALEjngj020077; Wed, 21 Nov 2012 07:45:49 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 30825122442E; Wed, 21 Nov 2012 15:45:49 +0100 (CET) From: Christian Borntraeger To: Alexander Graf Date: Wed, 21 Nov 2012 15:46:05 +0100 Message-Id: <1353509165-26865-4-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1353509165-26865-1-git-send-email-borntraeger@de.ibm.com> References: <1353509165-26865-1-git-send-email-borntraeger@de.ibm.com> x-cbid: 12112114-4966-0000-0000-000004272355 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.106 Cc: Christian Borntraeger , Jens Freimann , Heinz Graalfs , qemu-devel , "Jason J. herne" Subject: [Qemu-devel] [PATCH 3/3] s390/migration: Add code to support SCLP live migration 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 From: Heinz Graalfs This patch adds the necessary life migration pieces to the sclp code. Signed-off-by: Heinz Graalfs Signed-off-by: Christian Borntraeger --- hw/s390x/event-facility.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/event-facility.h | 3 +++ hw/s390x/sclpconsole.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/sclpquiesce.c | 18 ++++++++++++++++++ 4 files changed, 113 insertions(+) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 9367660..47a1bab 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -312,6 +312,49 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code) } } +static void event_facility_save(QEMUFile *f, void *opaque) +{ + S390SCLPDevice *sdev = opaque; + BusChild *kid; + SCLPEvent *event; + SCLPEventClass *event_class; + + qemu_put_be32(f, sdev->ef->receive_mask); + + QTAILQ_FOREACH(kid, &sdev->ef->sbus.qbus.children, sibling) { + DeviceState *qdev = kid->child; + event = DO_UPCAST(SCLPEvent, qdev, qdev); + event_class = SCLP_EVENT_GET_CLASS(event); + if (event_class->save) { + event_class->save(f, event); + } + } +} + +static int event_facility_load(QEMUFile *f, void *opaque, int version_id) +{ + S390SCLPDevice *sdev = opaque; + int rc = 0; + BusChild *kid; + SCLPEvent *event; + SCLPEventClass *event_class; + + sdev->ef->receive_mask = qemu_get_be32(f); + + QTAILQ_FOREACH(kid, &sdev->ef->sbus.qbus.children, sibling) { + DeviceState *qdev = kid->child; + event = DO_UPCAST(SCLPEvent, qdev, qdev); + event_class = SCLP_EVENT_GET_CLASS(event); + if (event_class->load) { + rc = event_class->load(f, event, version_id); + if (rc) { + break; + } + } + } + return rc; +} + static int init_event_facility(S390SCLPDevice *sdev) { SCLPEventFacility *event_facility; @@ -334,6 +377,9 @@ static int init_event_facility(S390SCLPDevice *sdev) } qdev_init_nofail(quiesce); + register_savevm(&sdev->busdev.qdev, "event-facility", -1, 0, + event_facility_save, event_facility_load, sdev); + return 0; } diff --git a/hw/s390x/event-facility.h b/hw/s390x/event-facility.h index 30af0a7..4405022 100644 --- a/hw/s390x/event-facility.h +++ b/hw/s390x/event-facility.h @@ -91,6 +91,9 @@ typedef struct SCLPEventClass { /* returns the supported event type */ int (*event_type)(void); + /* live migration */ + int (*load)(QEMUFile *f, void *opaque, int version_id); + void (*save)(QEMUFile *f, void *opaque); } SCLPEventClass; #endif diff --git a/hw/s390x/sclpconsole.c b/hw/s390x/sclpconsole.c index 0ec5623..96168a1 100644 --- a/hw/s390x/sclpconsole.c +++ b/hw/s390x/sclpconsole.c @@ -243,6 +243,50 @@ static void trigger_ascii_console_data(void *env, int n, int level) /* qemu object creation and initialization functions */ /* tell character layer our call-back functions */ + +static void console_save(QEMUFile *f, void *opaque) +{ + SCLPConsole *scon = opaque; + + if (!scon->iov) { + return; + } + + qemu_put_be16(f, scon->event.event_pending ? 1 : 0); + qemu_put_be32(f, scon->iov_data_len); + qemu_put_be32(f, scon->iov_sclp_rest); + qemu_put_be32(f, scon->iov_sclp - scon->iov); + qemu_put_be32(f, scon->iov_bs - scon->iov); + if (scon->event.event_pending) { + qemu_put_buffer(f, scon->iov, SIZE_BUFFER_VT220); + } +} + +static int console_load(QEMUFile *f, void *opaque, int version_id) +{ + SCLPConsole *scon = opaque; + int l; + + if (!scon->iov) { + scon->iov = g_malloc0(SIZE_BUFFER_VT220); + } + + scon->event.event_pending = qemu_get_be16(f) ? true : false; + scon->iov_data_len = qemu_get_be32(f); + scon->iov_sclp_rest = qemu_get_be32(f); + scon->iov_bs = scon->iov + qemu_get_be32(f); + scon->iov_sclp = scon->iov + qemu_get_be32(f); + if (scon->event.event_pending) { + l = qemu_get_buffer(f, scon->iov, SIZE_BUFFER_VT220); + if (l != SIZE_BUFFER_VT220) { + error_report("Failed to restore SCLP console buffer."); + return -1; + } + } + + return 0; +} + static int console_init(SCLPEvent *event) { static bool console_available; @@ -288,6 +332,8 @@ static void console_class_init(ObjectClass *klass, void *data) ec->event_type = event_type; ec->read_event_data = read_event_data; ec->write_event_data = write_event_data; + ec->load = console_load; + ec->save = console_save; } static TypeInfo sclp_console_info = { diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c index 9a773b8..e12fb7c 100644 --- a/hw/s390x/sclpquiesce.c +++ b/hw/s390x/sclpquiesce.c @@ -65,6 +65,22 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr, return 1; } +static void quiesce_save(QEMUFile *f, void *opaque) +{ + SCLPEvent *event = opaque; + + qemu_put_be16(f, event->event_pending ? 1 : 0); +} + +static int quiesce_load(QEMUFile *f, void *opaque, int version_id) +{ + SCLPEvent *event = opaque; + + event->event_pending = qemu_get_be16(f) ? true : false; + + return 0; +} + typedef struct QuiesceNotifier QuiesceNotifier; static struct QuiesceNotifier { @@ -105,6 +121,8 @@ static void quiesce_class_init(ObjectClass *klass, void *data) k->event_type = event_type; k->read_event_data = read_event_data; k->write_event_data = NULL; + k->load = quiesce_load; + k->save = quiesce_save; } static TypeInfo sclp_quiesce_info = {