Skip to contentSkip to conversation

Common unplug and unplug request cb for memory and CPU hot-unplug.

PATCH Superseded Tang Chen 2 participants 9 messages Nov 17, 2014 – Dec 10, 2014

lore
Share & tools
lore

Tang Chen

author
#0 lore raw

cover Common unplug and unplug request cb for memory and CPU hot-unplug.

Memory and CPU hot unplug are both asynchronize procedures. When the unplug operation happens, unplug request cb is called first. And when ghest OS finished handling unplug, unplug cb will be called to do the real removal of device.

They both need pc-machine, piix4 and ich9 unplug and unplug request cb. So this patch set introduces these commom functions as part1, and memory and CPU hot-unplug will come soon as part 2 and 3.

Tang Chen (5):
acpi, pc: Add hotunplug request cb for pc machine. acpi, ich9: Add hotunplug request cb for ich9. acpi, pc: Add unplug cb for pc machine. acpi, ich9: Add unplug cb for ich9.
acpi, piix4: Add unplug cb for piix4.

 hw/acpi/ich9.c         | 14 ++++++++++++++
 hw/acpi/piix4.c        |  8 ++++++++
 hw/i386/pc.c           | 16 ++++++++++++++++
 hw/isa/lpc_ich9.c      | 14 ++++++++++++--
 include/hw/acpi/ich9.h |  4 ++++
 5 files changed, 54 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.4.2
author
#1 lore raw

PATCH 1/5 acpi, pc: Add hotunplug request cb for pc machine.

Memory and CPU hot unplug are both asynchronize procedures. They both need unplug request cb when the unplug operation happens.

This patch adds hotunplug request cb for pc machine, and memory and CPU hot unplug will base on it.

---
 hw/i386/pc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/i386/pc.c +8 -0
index 1205db8..5c48435 100644
@@ -1647,6 +1647,13 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
     }
 }
 
+static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                                DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "acpi: device unplug request for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));
+}
+
 static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
@@ -1753,6 +1760,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     pcmc->get_hotplug_handler = mc->get_hotplug_handler;
     mc->get_hotplug_handler = pc_get_hotpug_handler;
     hc->plug = pc_machine_device_plug_cb;
+    hc->unplug_request = pc_machine_device_unplug_request_cb;
 }
 
 static const TypeInfo pc_machine_info = {
Signature · 1 line
1.8.4.2
#2 lore raw

Re: [Qemu-devel] [PATCH Part1 1/5] acpi, pc: Add hotunplug request cb for pc machine.

On Mon, 17 Nov 2014 13:03:13 +0800
Tang Chen <[email protected]> wrote:

in subj s/cb/callback|handler/

Quoted 1 line

Memory and CPU hot unplug are both asynchronize procedures.

s/asynchronize/asynchronous/

Quoted 1 line

They both need unplug request cb when the unplug operation happens.

s/cb when the unplug operation happens/callback to initiate unplug operation/

Quoted 3 lines

This patch adds hotunplug request cb for pc machine, and memory and CPU hot unplug will base on it.

Add unplug handler to pc machine that will be used by following CPU and memory unplug patches.

Quoted 11 lines
---
 hw/i386/pc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/i386/pc.c +0 -0
index 1205db8..5c48435 100644

hw/i386/pc.c static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, · line 1654

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1647,6 +1647,13 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
     }
 }
 
+static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                                DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "acpi: device unplug request for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));

it's not necessarily acpi related in general so maybe drop 'acpi:' prefix. Also it would be nice to add device's ID or use it instead of type name.

Quoted 13 lines
hw/i386/pc.c +3 -0
+}
+
 static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
@@ -1753,6 +1760,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     pcmc->get_hotplug_handler = mc->get_hotplug_handler;
     mc->get_hotplug_handler = pc_get_hotpug_handler;
     hc->plug = pc_machine_device_plug_cb;
+    hc->unplug_request = pc_machine_device_unplug_request_cb;
 }
 
 static const TypeInfo pc_machine_info = {
author
#3 lore raw

Re: [Qemu-devel] [PATCH Part1 1/5] acpi, pc: Add hotunplug request cb for pc machine.

Hi Igor,

Quoted 29 lines · Igor Mammedov

On Mon, 17 Nov 2014 13:03:13 +0800
Tang Chen <[email protected]> wrote:

in subj s/cb/callback|handler/

Quoted 1 line

Memory and CPU hot unplug are both asynchronize procedures.

s/asynchronize/asynchronous/

Quoted 1 line

They both need unplug request cb when the unplug operation happens.

s/cb when the unplug operation happens/callback to initiate unplug operation/

Quoted 2 lines

This patch adds hotunplug request cb for pc machine, and memory and CPU hot unplug will base on it.

Add unplug handler to pc machine that will be used by following CPU and memory unplug patches.

Quoted 13 lines
---
  hw/i386/pc.c | 8 ++++++++
  1 file changed, 8 insertions(+)
hw/i386/pc.c +0 -0
index 1205db8..5c48435 100644
@@ -1647,6 +1647,13 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
      }
  }
 
Quoted 7 lines

hw/i386/pc.c static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, · line 1654

Quoted 5 lines
hw/i386/pc.c +5 -0
+static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                                DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "acpi: device unplug request for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));

it's not necessarily acpi related in general so maybe drop 'acpi:' prefix. Also it would be nice to add device's ID or use it instead of type name.

Since QEmu 2.2 has been released, I'm now rebasing this patch-set.

Here, you suggested to use device id instead device type name. But all existing plug handles are using device type name.

Should I send patches to change them all ?

Thanks.

Quoted 16 lines
Quoted 7 lines
hw/i386/pc.c +2 -0
+}
+
  static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
                                               DeviceState *dev)
  {

hw/i386/pc.c static void pc_machine_class_init(ObjectClass *oc, void *data) · line 1766

Quoted 7 lines
hw/i386/pc.c +1 -0
@@ -1753,6 +1760,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
      pcmc->get_hotplug_handler = mc->get_hotplug_handler;
      mc->get_hotplug_handler = pc_get_hotpug_handler;
      hc->plug = pc_machine_device_plug_cb;
+    hc->unplug_request = pc_machine_device_unplug_request_cb;
  }
 
  static const TypeInfo pc_machine_info = {

.

#4 lore raw

Re: [Qemu-devel] [PATCH Part1 1/5] acpi, pc: Add hotunplug request cb for pc machine.

Quoted 40 lines · On Wed, 10 Dec 2014 15:02:44 +0800 Tang Chen <[email protected]> wrote:

Hi Igor,

Quoted 29 lines · Igor Mammedov

On Mon, 17 Nov 2014 13:03:13 +0800
Tang Chen <[email protected]> wrote:

in subj s/cb/callback|handler/

Quoted 1 line

Memory and CPU hot unplug are both asynchronize procedures.

s/asynchronize/asynchronous/

Quoted 1 line

They both need unplug request cb when the unplug operation happens.

s/cb when the unplug operation happens/callback to initiate unplug operation/

Quoted 2 lines

This patch adds hotunplug request cb for pc machine, and memory and CPU hot unplug will base on it.

Add unplug handler to pc machine that will be used by following CPU and memory unplug patches.

Quoted 13 lines
---
  hw/i386/pc.c | 8 ++++++++
  1 file changed, 8 insertions(+)
hw/i386/pc.c +0 -0
index 1205db8..5c48435 100644
@@ -1647,6 +1647,13 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
      }
  }
 
Quoted 7 lines

hw/i386/pc.c static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, · line 1654

Quoted 5 lines
hw/i386/pc.c +5 -0
+static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                                DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "acpi: device unplug request for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));

it's not necessarily acpi related in general so maybe drop 'acpi:' prefix. Also it would be nice to add device's ID or use it instead of type name.

Quoted 6 lines

Since QEmu 2.2 has been released, I'm now rebasing this patch-set.

Here, you suggested to use device id instead device type name. But all existing plug handles are using device type name.

Should I send patches to change them all ?

May be better would be to just leave it as is for now (i.e. out of this series).

Quoted 20 lines

Thanks.

Quoted 16 lines
Quoted 7 lines
hw/i386/pc.c +2 -0
+}
+
  static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
                                               DeviceState *dev)
  {

hw/i386/pc.c static void pc_machine_class_init(ObjectClass *oc, void *data) · line 1766

Quoted 7 lines
hw/i386/pc.c +1 -0
@@ -1753,6 +1760,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
      pcmc->get_hotplug_handler = mc->get_hotplug_handler;
      mc->get_hotplug_handler = pc_get_hotpug_handler;
      hc->plug = pc_machine_device_plug_cb;
+    hc->unplug_request = pc_machine_device_unplug_request_cb;
  }
 
  static const TypeInfo pc_machine_info = {

.

author
#5 lore raw

PATCH 2/5 acpi, ich9: Add hotunplug request cb for ich9.

In reply to Tang Chen

Memory and CPU hot unplug are both asynchronize procedures. They both need unplug request cb when the unplug operation happens.

This patch adds hotunplug request cb for ich9, and memory and CPU hot unplug will base on it.

---
 hw/acpi/ich9.c         | 7 +++++++
 hw/isa/lpc_ich9.c      | 5 +++--
 include/hw/acpi/ich9.h | 2 ++
 3 files changed, 12 insertions(+), 2 deletions(-)
hw/acpi/ich9.c +7 -0
index ea991a3..5ce3aaf 100644
@@ -301,6 +301,13 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)
     }
 }
 
+void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
+                                      Error **errp)
+{
+    error_setg(errp, "acpi: device unplug request for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));
+}
+
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
 {
     ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
hw/isa/lpc_ich9.c +3 -2
index 530b074..d00b223 100644
@@ -610,8 +610,9 @@ static void ich9_device_plug_cb(HotplugHandler *hotplug_dev,
 static void ich9_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                           DeviceState *dev, Error **errp)
 {
-    error_setg(errp, "acpi: device unplug request for not supported device"
-               " type: %s", object_get_typename(OBJECT(dev)));
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
+
+    ich9_pm_device_unplug_request_cb(&lpc->pm, dev, errp);
 }
 
 static bool ich9_rst_cnt_needed(void *opaque)
include/hw/acpi/ich9.h +2 -0
index fe975e6..86853c3 100644
@@ -59,6 +59,8 @@ extern const VMStateDescription vmstate_ich9_pm;
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp);
 
 void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp);
+void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
+                                      Error **errp);
 
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
 #endif /* HW_ACPI_ICH9_H */
Signature · 1 line
1.8.4.2
author
#6 lore raw

PATCH 3/5 acpi, pc: Add unplug cb for pc machine.

In reply to Tang Chen

Memory and CPU hot unplug are both asynchronize procedures. When the unplug operation happens, unplug request cb is called first. And when ghest OS finished handling unplug, unplug cb will be called to do the real removal of device.

This patch adds hotunplug cb for pc machine, and memory and CPU hot unplug will base on it.

---
 hw/i386/pc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/i386/pc.c +8 -0
index 5c48435..d5073df 100644
@@ -1654,6 +1654,13 @@ static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                " type: %s", object_get_typename(OBJECT(dev)));
 }
 
+static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev,
+                                        DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "acpi: device unplug for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));
+}
+
 static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
@@ -1761,6 +1768,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     mc->get_hotplug_handler = pc_get_hotpug_handler;
     hc->plug = pc_machine_device_plug_cb;
     hc->unplug_request = pc_machine_device_unplug_request_cb;
+    hc->unplug = pc_machine_device_unplug_cb;
 }
 
 static const TypeInfo pc_machine_info = {
Signature · 1 line
1.8.4.2
author
#7 lore raw

PATCH 4/5 acpi, ich9: Add unplug cb for ich9.

In reply to Tang Chen

Memory and CPU hot unplug are both asynchronize procedures. When the unplug operation happens, unplug request cb is called first. And when ghest OS finished handling unplug, unplug cb will be called to do the real removal of device.

This patch adds hotunplug cb for ich9, and memory and CPU hot unplug will base on it.

---
 hw/acpi/ich9.c         | 7 +++++++
 hw/isa/lpc_ich9.c      | 9 +++++++++
 include/hw/acpi/ich9.h | 2 ++
 3 files changed, 18 insertions(+)
hw/acpi/ich9.c +7 -0
index 5ce3aaf..c48d176 100644
@@ -308,6 +308,13 @@ void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
                " type: %s", object_get_typename(OBJECT(dev)));
 }
 
+void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
+                              Error **errp)
+{
+    error_setg(errp, "acpi: device unplug for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));
+}
+
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
 {
     ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
hw/isa/lpc_ich9.c +9 -0
index d00b223..16f5a0d 100644
@@ -615,6 +615,14 @@ static void ich9_device_unplug_request_cb(HotplugHandler *hotplug_dev,
     ich9_pm_device_unplug_request_cb(&lpc->pm, dev, errp);
 }
 
+static void ich9_device_unplug_cb(HotplugHandler *hotplug_dev,
+                                  DeviceState *dev, Error **errp)
+{
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
+
+    ich9_pm_device_unplug_cb(&lpc->pm, dev, errp);
+}
+
 static bool ich9_rst_cnt_needed(void *opaque)
 {
     ICH9LPCState *lpc = opaque;
@@ -678,6 +686,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     dc->cannot_instantiate_with_device_add_yet = true;
     hc->plug = ich9_device_plug_cb;
     hc->unplug_request = ich9_device_unplug_request_cb;
+    hc->unplug = ich9_device_unplug_cb;
     adevc->ospm_status = ich9_pm_ospm_status;
 }
 
include/hw/acpi/ich9.h +2 -0
index 86853c3..fc87dad 100644
@@ -61,6 +61,8 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp);
 void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp);
 void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
                                       Error **errp);
+void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
+                              Error **errp);
 
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
 #endif /* HW_ACPI_ICH9_H */
Signature · 1 line
1.8.4.2
author
#8 lore raw

PATCH 5/5 acpi, piix4: Add unplug cb for piix4.

In reply to Tang Chen

Memory and CPU hot unplug are both asynchronize procedures. When the unplug operation happens, unplug request cb is called first. And when ghest OS finished handling unplug, unplug cb will be called to do the real removal of device.

This patch adds hotunplug cb for piix4, and memory and CPU hot unplug will base on it.

---
 hw/acpi/piix4.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/acpi/piix4.c +8 -0
index 78c0a6d..353f91a 100644
@@ -369,6 +369,13 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
     }
 }
 
+static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev,
+                                   DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "acpi: device unplug for not supported device"
+               " type: %s", object_get_typename(OBJECT(dev)));
+}
+
 static void piix4_update_bus_hotplug(PCIBus *pci_bus, void *opaque)
 {
     PIIX4PMState *s = opaque;
@@ -606,6 +613,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     hc->plug = piix4_device_plug_cb;
     hc->unplug_request = piix4_device_unplug_request_cb;
+    hc->unplug = piix4_device_unplug_cb;
     adevc->ospm_status = piix4_ospm_status;
 }
 
Signature · 1 line
1.8.4.2