All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: dahi@linux.vnet.ibm.com, agraf@suse.de, borntraeger@de.ibm.com,
	imammedo@redhat.com, bharata@linux.vnet.ibm.com,
	cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de,
	rth@twiddle.net
Subject: [Qemu-devel] [PATCH v5 5/6] s390/virtio-ccw: Add hotplug handler
Date: Thu, 18 Feb 2016 23:03:36 -0500	[thread overview]
Message-ID: <1455854617-30964-6-git-send-email-mjrosato@linux.vnet.ibm.com> (raw)
In-Reply-To: <1455854617-30964-1-git-send-email-mjrosato@linux.vnet.ibm.com>

First consumer will be CPU hotplug, to update machine/cpu[n]
links during cpu plug.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index b05ed8b..31c1082 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -156,10 +156,46 @@ static void ccw_init(MachineState *machine)
                     gtod_save, gtod_load, kvm_state);
 }
 
+static void s390_cpu_plug(HotplugHandler *hotplug_dev,
+                        DeviceState *dev, Error **errp)
+{
+    gchar *name;
+    S390CPU *cpu = S390_CPU(dev);
+    CPUState *cs = CPU(dev);
+
+    name = g_strdup_printf("cpu[%i]", cpu->env.cpu_num);
+    object_property_set_link(OBJECT(qdev_get_machine()), OBJECT(cs), name,
+                             errp);
+}
+
+static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
+                                     DeviceState *dev, Error **errp)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        s390_cpu_plug(hotplug_dev, dev, errp);
+    }
+}
+
+static void s390_machine_device_unplug(HotplugHandler *hotplug_dev,
+                                       DeviceState *dev, Error **errp)
+{
+
+}
+
+static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
+                                                DeviceState *dev)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        return HOTPLUG_HANDLER(machine);
+    }
+    return NULL;
+}
+
 static void ccw_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
     NMIClass *nc = NMI_CLASS(oc);
+    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
 
     mc->init = ccw_init;
     mc->reset = s390_machine_reset;
@@ -171,6 +207,9 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
     mc->no_sdcard = 1;
     mc->use_sclp = 1;
     mc->max_cpus = 255;
+    mc->get_hotplug_handler = s390_get_hotplug_handler;
+    hc->plug = s390_machine_device_plug;
+    hc->unplug = s390_machine_device_unplug;
     nc->nmi_monitor_handler = s390_nmi;
 }
 
@@ -232,6 +271,7 @@ static const TypeInfo ccw_machine_info = {
     .class_init    = ccw_machine_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_NMI },
+        { TYPE_HOTPLUG_HANDLER},
         { }
     },
 };
-- 
1.9.1

  parent reply	other threads:[~2016-02-19  4:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19  4:03 [Qemu-devel] [PATCH v5 0/6] Allow hotplug of s390 CPUs Matthew Rosato
2016-02-19  4:03 ` [Qemu-devel] [PATCH v5 1/6] s390x/cpu: Cleanup init in preparation for hotplug Matthew Rosato
2016-02-19  4:03 ` [Qemu-devel] [PATCH v5 2/6] s390x/cpu: Set initial CPU state in common routine Matthew Rosato
2016-02-19  4:03 ` [Qemu-devel] [PATCH v5 3/6] s390x/cpu: Move some CPU initialization into realize Matthew Rosato
2016-02-19  4:03 ` [Qemu-devel] [PATCH v5 4/6] s390x/cpu: Add CPU property links Matthew Rosato
2016-02-19  4:03 ` Matthew Rosato [this message]
2016-02-19 14:33   ` [Qemu-devel] [PATCH v5 5/6] s390/virtio-ccw: Add hotplug handler Igor Mammedov
2016-02-19  4:03 ` [Qemu-devel] [PATCH v5 6/6] s390x/cpu: Allow hotplug of CPUs Matthew Rosato
2016-02-19 14:28   ` Igor Mammedov
2016-02-19 14:40     ` Matthew Rosato
2016-02-19 16:18       ` Igor Mammedov

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=1455854617-30964-6-git-send-email-mjrosato@linux.vnet.ibm.com \
    --to=mjrosato@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.