qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel@nongnu.org
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
	borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de,
	jjherne@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v3 8/8] s390x: Disable storage key migration on old machine type
Date: Mon, 31 Aug 2015 13:00:34 +0200	[thread overview]
Message-ID: <1441018834-8993-9-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1441018834-8993-1-git-send-email-cornelia.huck@de.ibm.com>

From: "Jason J. Herne" <jjherne@linux.vnet.ibm.com>

This code disables storage key migration when an older machine type is
specified.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 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 72df19d..ba18834 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -352,12 +352,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.1

      parent reply	other threads:[~2015-08-31 11:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 11:00 [Qemu-devel] [PATCH v3 0/8] s390x: storage key migration Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 1/8] s390x: add 2.5 compat s390-ccw-virtio machine Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 2/8] s390x: Create QOM device for s390 storage keys Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 3/8] s390x: Enable new s390-storage-keys device Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 4/8] s390x: Dump storage keys qmp command Cornelia Huck
2015-08-31 14:48   ` Eric Blake
2015-08-31 15:20     ` Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 5/8] s390x: Dump-skeys hmp support Cornelia Huck
2015-08-31 16:30   ` Eric Blake
2015-08-31 18:57     ` Jason J. Herne
2015-09-01 14:30       ` Cornelia Huck
2015-09-01 16:05         ` Eric Blake
2015-09-01 16:22           ` Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 6/8] s390x: Info skeys sub-command Cornelia Huck
2015-08-31 11:00 ` [Qemu-devel] [PATCH v3 7/8] s390x: Migrate guest storage keys (initial memory only) Cornelia Huck
2015-08-31 11:00 ` Cornelia Huck [this message]

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=1441018834-8993-9-git-send-email-cornelia.huck@de.ibm.com \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=jjherne@linux.vnet.ibm.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).