Received: from eggs.gnu.org ([2001:4830:134:3::10]:60070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUGok-0002EE-Lb for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:11:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUGoh-0001wl-AU for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:11:22 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:59898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUGog-0001vu-W7 for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:11:19 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Aug 2015 17:11:18 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id E07BA1B08061 for ; Tue, 25 Aug 2015 17:12:46 +0100 (BST) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7PGBFKc15991032 for ; Tue, 25 Aug 2015 16:11:15 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7PGB4fR017732 for ; Tue, 25 Aug 2015 10:11:05 -0600 From: Cornelia Huck Date: Tue, 25 Aug 2015 18:10:50 +0200 Message-Id: <1440519050-17986-9-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1440519050-17986-1-git-send-email-cornelia.huck@de.ibm.com> References: <1440519050-17986-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH v2 8/8] s390x: Disable storage key migration on old machine type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de, jjherne@linux.vnet.ibm.com From: "Jason J. Herne" This code disables storage key migration when an older machine type is specified. Reviewed-by: David Hildenbrand Signed-off-by: Jason J. Herne Signed-off-by: Cornelia Huck --- hw/s390x/s390-skeys.c | 33 ++++++++++++++++++++++++++++++--- hw/s390x/s390-virtio-ccw.c | 12 ++++++++++++ include/hw/s390x/storage-keys.h | 1 + 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 9d4a79d..392d547 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -363,12 +363,39 @@ static int s390_storage_keys_load(QEMUFile *f, void *opaque, int version_id) return ret; } -static void s390_skeys_instance_init(Object *obj) +static inline bool s390_skeys_get_migration_enabled(Object *obj, Error **errp) +{ + S390SKeysState *ss = S390_SKEYS(obj); + + return ss->migration_enabled; +} + +static inline void s390_skeys_set_migration_enabled(Object *obj, bool value, + Error **errp) { S390SKeysState *ss = S390_SKEYS(obj); - register_savevm(NULL, TYPE_S390_SKEYS, 0, 1, s390_storage_keys_save, - s390_storage_keys_load, ss); + /* Prevent double registration of savevm handler */ + if (ss->migration_enabled == value) { + return; + } + + ss->migration_enabled = value; + + if (ss->migration_enabled) { + register_savevm(NULL, TYPE_S390_SKEYS, 0, 1, s390_storage_keys_save, + s390_storage_keys_load, ss); + } else { + unregister_savevm(DEVICE(ss), TYPE_S390_SKEYS, ss); + } +} + +static void s390_skeys_instance_init(Object *obj) +{ + object_property_add_bool(obj, "migration-enabled", + s390_skeys_get_migration_enabled, + s390_skeys_set_migration_enabled, NULL); + object_property_set_bool(obj, true, "migration-enabled", NULL); } static void s390_skeys_class_init(ObjectClass *oc, void *data) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 0a057ae..e2a26e9 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -282,12 +282,24 @@ static const TypeInfo ccw_machine_info = { }, }; +#define CCW_COMPAT_2_4 \ + {\ + .driver = TYPE_S390_SKEYS,\ + .property = "migration-enabled",\ + .value = "off",\ + }, + static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + static GlobalProperty compat_props[] = { + CCW_COMPAT_2_4 + { /* end of list */ } + }; mc->name = "s390-ccw-virtio-2.4"; mc->desc = "VirtIO-ccw based S390 machine v2.4"; + mc->compat_props = compat_props; } static const TypeInfo ccw_machine_2_4_info = { diff --git a/include/hw/s390x/storage-keys.h b/include/hw/s390x/storage-keys.h index 18e08d2..72b850c 100644 --- a/include/hw/s390x/storage-keys.h +++ b/include/hw/s390x/storage-keys.h @@ -21,6 +21,7 @@ typedef struct S390SKeysState { DeviceState parent_obj; + bool migration_enabled; } S390SKeysState; -- 2.5.0