Skip to contentSkip to conversation

DEVICE_NOT_DELETED/DEVICE_UNPLUG_ERROR QAPI events

PATCH In review Daniel Henrique Barboza 4 participants 20 messages Mar 12, 2021 – Apr 20, 2021

lore
Share & tools
lore
#0 lore raw

cover DEVICE_NOT_DELETED/DEVICE_UNPLUG_ERROR QAPI events

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

[1] https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg01900.html

Daniel Henrique Barboza (4):
qapi/qdev.json: add DEVICE_NOT_DELETED event spapr_drc.c: send DEVICE_NOT_DELETED event on unplug timeout qapi/machine.json: add DEVICE_UNPLUG_ERROR QAPI event spapr.c: use DEVICE_UNPLUG_ERROR event in
spapr_memory_unplug_rollback()

 hw/ppc/spapr.c     |  2 +-
 hw/ppc/spapr_drc.c |  8 ++++++++
 qapi/machine.json  | 23 +++++++++++++++++++++++
 qapi/qdev.json     | 28 ++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 1 deletion(-)
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/4 qapi/qdev.json: add DEVICE_NOT_DELETED event

This new event informs QAPI listeners that a previously issued 'device_del' command failed to delete the device from the machine.

Note that no assertion can be made about the failure reason. The goal of this event is to inform management that QEMU is not able to assess whether the hotunplug is taking too long to complete or failed in the guest and, as result, the device is not removed from QOM. When receiving this event, users/management must check inside the guest to verify the result of the hotunplug operation.

This scenario happens with architectures where the guest does not have an official way to report the hotunplug error back to the hypervisor, such as PowerPC and the pseries machine type.

---
 qapi/qdev.json | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
qapi/qdev.json +28 -0
index b83178220b..df9a1b9e67 100644
@@ -124,3 +124,31 @@
 ##
 { 'event': 'DEVICE_DELETED',
   'data': { '*device': 'str', 'path': 'str' } }
+
+##
+# @DEVICE_NOT_DELETED:
+#
+# Emitted whenever the device removal process expired and the device
+# still exists in QOM. This indicates that the guest took too long
+# to acknowlege the device removal, and we can not be sure of whether
+# the process will be completed in the guest later on or a guest
+# side error occurred.
+#
+# It is not safe to reuse the specified device ID.
+#
+# @device: device name
+#
+# @path: device path
+#
+# Since: 6.0
+#
+# Example:
+#
+# <- { "event": "DEVICE_NOT_DELETED",
+#      "data": { "device": "core1",
+#                "path": "/machine/peripheral/core1" },
+#      "timestamp": { "seconds": 1615570254, "microseconds": 573986 } }
+#
+##
+{ 'event': 'DEVICE_NOT_DELETED',
+  'data': { '*device': 'str', 'path': 'str' } }
\ No newline at end of file
Signature · 1 line
2.29.2
#2 lore raw

Re: [PATCH 1/4] qapi/qdev.json: add DEVICE_NOT_DELETED event

Quoted 24 lines · Daniel Henrique Barboza

This new event informs QAPI listeners that a previously issued 'device_del' command failed to delete the device from the machine.

Note that no assertion can be made about the failure reason. The goal of this event is to inform management that QEMU is not able to assess whether the hotunplug is taking too long to complete or failed in the guest and, as result, the device is not removed from QOM. When receiving this event, users/management must check inside the guest to verify the result of the hotunplug operation.

This scenario happens with architectures where the guest does not have an official way to report the hotunplug error back to the hypervisor, such as PowerPC and the pseries machine type.

---
 qapi/qdev.json | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
qapi/qdev.json +0 -0
index b83178220b..df9a1b9e67 100644

qapi/qdev.json line 133

Quoted 10 lines
qapi/qdev.json +7 -0
@@ -124,3 +124,31 @@
 ##
 { 'event': 'DEVICE_DELETED',
   'data': { '*device': 'str', 'path': 'str' } }
+
+##
+# @DEVICE_NOT_DELETED:
+#
+# Emitted whenever the device removal process expired and the device
+# still exists in QOM. This indicates that the guest took too long
+# to acknowlege the device removal, and we can not be sure of whether

acknowledge

qapi/qdev.json line 143

Quoted 10 lines
qapi/qdev.json +10 -0
+# the process will be completed in the guest later on or a guest
+# side error occurred.
+#
+# It is not safe to reuse the specified device ID.
+#
+# @device: device name
+#
+# @path: device path
+#
+# Since: 6.0

This is a new event, and we've missed feature freeze; is this fixing a bug that was not present in 5.2 (in which case it is fine for -rc1), or is this a long-standing problem where one more release without the mechanism won't make life any worse?

qapi/qdev.json line 154

Quoted 12 lines
qapi/qdev.json +11 -0
+#
+# Example:
+#
+# <- { "event": "DEVICE_NOT_DELETED",
+#      "data": { "device": "core1",
+#                "path": "/machine/peripheral/core1" },
+#      "timestamp": { "seconds": 1615570254, "microseconds": 573986 } }
+#
+##
+{ 'event': 'DEVICE_NOT_DELETED',
+  'data': { '*device': 'str', 'path': 'str' } }
\ No newline at end of file

You'll want to fix that.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Re: [PATCH 1/4] qapi/qdev.json: add DEVICE_NOT_DELETED event

Quoted 38 lines · Eric Blake
Quoted 24 lines · Daniel Henrique Barboza

This new event informs QAPI listeners that a previously issued 'device_del' command failed to delete the device from the machine.

Note that no assertion can be made about the failure reason. The goal of this event is to inform management that QEMU is not able to assess whether the hotunplug is taking too long to complete or failed in the guest and, as result, the device is not removed from QOM. When receiving this event, users/management must check inside the guest to verify the result of the hotunplug operation.

This scenario happens with architectures where the guest does not have an official way to report the hotunplug error back to the hypervisor, such as PowerPC and the pseries machine type.

---
  qapi/qdev.json | 28 ++++++++++++++++++++++++++++
  1 file changed, 28 insertions(+)
qapi/qdev.json +0 -0
index b83178220b..df9a1b9e67 100644

qapi/qdev.json line 133

Quoted 10 lines
qapi/qdev.json +7 -0
@@ -124,3 +124,31 @@
  ##
  { 'event': 'DEVICE_DELETED',
    'data': { '*device': 'str', 'path': 'str' } }
+
+##
+# @DEVICE_NOT_DELETED:
+#
+# Emitted whenever the device removal process expired and the device
+# still exists in QOM. This indicates that the guest took too long
+# to acknowlege the device removal, and we can not be sure of whether

acknowledge

Quoted 15 lines

qapi/qdev.json line 143

Quoted 10 lines
qapi/qdev.json +10 -0
+# the process will be completed in the guest later on or a guest
+# side error occurred.
+#
+# It is not safe to reuse the specified device ID.
+#
+# @device: device name
+#
+# @path: device path
+#
+# Since: 6.0

This is a new event, and we've missed feature freeze; is this fixing a bug that was not present in 5.2 (in which case it is fine for -rc1), or is this a long-standing problem where one more release without the mechanism won't make life any worse?

I believe these events I'm trying to add can be postponed to the next release.

Quoted 15 lines

qapi/qdev.json line 154

Quoted 13 lines
qapi/qdev.json +11 -0
+#
+# Example:
+#
+# <- { "event": "DEVICE_NOT_DELETED",
+#      "data": { "device": "core1",
+#                "path": "/machine/peripheral/core1" },
+#      "timestamp": { "seconds": 1615570254, "microseconds": 573986 } }
+#
+##
+{ 'event': 'DEVICE_NOT_DELETED',
+  'data': { '*device': 'str', 'path': 'str' } }
\ No newline at end of file

You'll want to fix that.

Yep, in both patches (1 and 3).

Thanks,

DHB

Quoted 1 line
#4 lore raw

PATCH 2/4 spapr_drc.c: send DEVICE_NOT_DELETED event on unplug timeout

In reply to Daniel Henrique Barboza

The newly added DEVICE_NOT_DELETED QAPI event is adequate to be sent when the hotunplug timeout expires, letting users know that something happened inside the guest and the pseries machine didn't delete the device from QOM.

After this patch, if an user try to hotunplug the last online CPU of the guest, the "DEIVCE_NOT_DELETED" event will be issued when the hotunplug timeout for 'core1' is expired:

{"execute": "device_del", "arguments": {"id": "core1"} } {"return": {}}

{"execute": "device_del", "arguments": {"id": "core1"} } {"error": {"class": "GenericError",

           "desc": "core-id 1 unplug is still pending, 12 seconds timeout remaining"}}

{"execute": "device_del", "arguments": {"id": "core1"} } {"error": {"class": "GenericError",

           "desc": "core-id 1 unplug is still pending, 5 seconds timeout remaining"}}

{"timestamp": {"seconds": 1615570254, "microseconds": 573986},
"event": "DEVICE_NOT_DELETED",
"data": {"device": "core1", "path": "/machine/peripheral/core1"}}

---
 hw/ppc/spapr_drc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ppc/spapr_drc.c +8 -0
index 8a71b03800..14f39cec71 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qnull.h"
+#include "qapi/qapi-events-qdev.h"
 #include "cpu.h"
 #include "qemu/cutils.h"
 #include "hw/ppc/spapr_drc.h"
@@ -529,9 +530,16 @@ static const VMStateDescription vmstate_spapr_drc = {
 static void drc_unplug_timeout_cb(void *opaque)
 {
     SpaprDrc *drc = opaque;
+    DeviceState *dev = drc->dev;
 
     if (drc->unplug_requested) {
         drc->unplug_requested = false;
+
+        if (dev) {
+            qapi_event_send_device_not_deleted(!!dev->id,
+                                               dev->id,
+                                               dev->canonical_path);
+        }
     }
 }
 
Signature · 1 line
2.29.2
#5 lore raw

PATCH 3/4 qapi/machine.json: add DEVICE_UNPLUG_ERROR QAPI event

In reply to Daniel Henrique Barboza

At this moment we only provide one event to report a hotunplug error, MEM_UNPLUG_ERROR. There will be other device types that are going to be throwing unplug errors in the future though.

Instead of creating a (device_type)_UNPLUG_ERROR for each new device, create a generic DEVICE_UNPLUG_ERROR event that can be used by all unplug errors in the future.

---
 qapi/machine.json | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
qapi/machine.json +23 -0
index 330189efe3..9b2c93aad3 100644
@@ -1471,3 +1471,26 @@
 ##
 { 'event': 'MEM_UNPLUG_ERROR',
   'data': { 'device': 'str', 'msg': 'str' } }
+
+##
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message
+#
+# Since: 6.0
+#
+# Example:
+#
+# <- { "event": "DEVICE_UNPLUG_ERROR"
+#      "data": { "device": "dimm1",
+#                "msg": "Memory hotunplug rejected by the guest for device dimm1"
+#      },
+#      "timestamp": { "seconds": 1615570772, "microseconds": 202844 } }
+#
+##
+{ 'event': 'DEVICE_UNPLUG_ERROR',
+  'data': { 'device': 'str', 'msg': 'str' } }
\ No newline at end of file
Signature · 1 line
2.29.2
#6 lore raw

PATCH 4/4 spapr.c: use DEVICE_UNPLUG_ERROR event in spapr_memory_unplug_rollback()

In reply to Daniel Henrique Barboza

Other device types in the pseries machine will use DEVICE_UNPLUG_ERROR to report hotunplug errors. Use it to report the memory hotunplug error in spapr_memory_unplug_rollback() as well.

---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index d56418ca29..697664e72f 100644
@@ -3624,7 +3624,7 @@ void spapr_memory_unplug_rollback(SpaprMachineState *spapr, DeviceState *dev)
      */
     qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                  "for device %s", dev->id);
-    qapi_event_send_mem_unplug_error(dev->id, qapi_error);
+    qapi_event_send_device_unplug_error(dev->id, qapi_error);
 }
 
 /* Callback to be called during DRC release. */
Signature · 1 line
2.29.2
#7 lore raw
In reply to Daniel Henrique Barboza
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#8 lore raw
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Thanks,

DHB

Quoted 1 line
#9 lore raw
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Thoughs, Markus?

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#10 lore raw
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

I believe that's already covered by the existing API:

+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

     qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                  "for device %s", dev->id);
     qapi_event_send_device_unplug_error(dev->id, qapi_error);

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

     qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
     qapi_event_send_device_unplug_error(dev->id, qapi_error);

Thanks,

DHB

Quoted 3 lines

Thoughs, Markus?

#11 lore raw
Quoted 62 lines · Daniel Henrique Barboza
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

I believe that's already covered by the existing API:

Review

Quoted 7 lines
(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

Oh, sorry, I missed that

Quoted 9 lines

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

     qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                  "for device %s", dev->id);
     qapi_event_send_device_unplug_error(dev->id, qapi_error);
Quoted 6 lines

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

     qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
     qapi_event_send_device_unplug_error(dev->id, qapi_error);

I think that makes sense for the cases on papr. Less sure about the cases Markus has mentioned.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#12 lore raw
In reply to Daniel Henrique Barboza
Quoted 50 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

Quoted 21 lines

I believe that's already covered by the existing API:

(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

      qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                   "for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);
Quoted 7 lines

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

      qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

lets make everything support ACPI (just kidding).

maybe we can reuse already existing ACPI_DEVICE_OST instead of DEVICE_UNPLUG_ERROR which sort of does the same thing (and more) but instead of strings uses status codes defined by spec.

Idea similar to DEVICE_UNPLUG_ERROR was considered back then, but instead of QEMU being a poor translator of status codes to non machine-readable strings we went with exposing well documented status codes to user. This way user can implement specific reactions to particular errors just looking at JSON + spec.

Quoted 9 lines

Thanks,

DHB

Quoted 3 lines

Thoughs, Markus?

#13 lore raw
Quoted 53 lines · Igor Mammedov
Quoted 50 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

Uh.. not as such. In the PAPR model, hotplugs and unplugs are mostly guest directed, so the question doesn't really arise.

Quoted 2 lines

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

Possible, but probably not that likely. The mechanism we use to "cancel" the hotplugs is that we just fail the hypercalls that the guest will need to call to actually complete the hotplug. We also fail those in some other situations, and that seems to work.

That said, I no longer think this cancelling on timeout is a good idea, since it mismatches what happens on other platforms more than I think we need to.

My now preferred approach is to revert the timeout changes, but instead allow retries of unplugs to be issued. I think that's just a matter of resending the unplug message to the guest, while making it otherwise a no-op on the qemu side.

Quoted 24 lines
Quoted 24 lines

I believe that's already covered by the existing API:

(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

      qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                   "for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

Quoted 5 lines
Quoted 3 lines
      qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

lets make everything support ACPI (just kidding).

Heh. If nothing else, doesn't help us with existing guests.

Quoted 3 lines

maybe we can reuse already existing ACPI_DEVICE_OST instead of DEVICE_UNPLUG_ERROR which sort of does the same thing (and more) but instead of strings uses status codes defined by spec.

Hmm. I'm a bit dubious about issuing ACPI messages for a non ACPI guest, but maybe that could work.

Quoted 15 lines

Idea similar to DEVICE_UNPLUG_ERROR was considered back then, but instead of QEMU being a poor translator of status codes to non machine-readable strings we went with exposing well documented status codes to user. This way user can implement specific reactions to particular errors just looking at JSON + spec.

Quoted 9 lines

Thanks,

DHB

Quoted 3 lines

Thoughs, Markus?

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#14 lore raw
Quoted 74 lines · On Wed, 31 Mar 2021 10:46:49 +1100 David Gibson <[email protected]>…
Quoted 53 lines · Igor Mammedov
Quoted 50 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

Uh.. not as such. In the PAPR model, hotplugs and unplugs are mostly guest directed, so the question doesn't really arise.

Quoted 2 lines

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

Possible, but probably not that likely. The mechanism we use to "cancel" the hotplugs is that we just fail the hypercalls that the guest will need to call to actually complete the hotplug. We also fail those in some other situations, and that seems to work.

Quoted 8 lines

That said, I no longer think this cancelling on timeout is a good idea, since it mismatches what happens on other platforms more than I think we need to.

My now preferred approach is to revert the timeout changes, but instead allow retries of unplugs to be issued. I think that's just a matter of resending the unplug message to the guest, while making it otherwise a no-op on the qemu side.

Yep, all we need to do is notify QEMU user, so it knows that unplug has failed. Then It can decide on it's own what to do with it and also when.

Quoted 30 lines
Quoted 24 lines
Quoted 24 lines

I believe that's already covered by the existing API:

(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

      qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                   "for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

Quoted 5 lines
Quoted 3 lines
      qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

lets make everything support ACPI (just kidding).

Quoted 8 lines

Heh. If nothing else, doesn't help us with existing guests.

Quoted 3 lines

maybe we can reuse already existing ACPI_DEVICE_OST instead of DEVICE_UNPLUG_ERROR which sort of does the same thing (and more) but instead of strings uses status codes defined by spec.

Hmm. I'm a bit dubious about issuing ACPI messages for a non ACPI guest, but maybe that could work.

May be we can rename it to be ACPI agnostic (though I'm not sure how renaming QAPI interfaces should be done (it might upset libvirt for example)).

(My point was that ACPI spec had already gone through all the trouble defining status of completion and documenting it. Also libvirt supports this notification. It looks like worthwhile thing to consider if can somehow reuse it outside of x86 world)

Quoted 16 lines
Quoted 15 lines

Idea similar to DEVICE_UNPLUG_ERROR was considered back then, but instead of QEMU being a poor translator of status codes to non machine-readable strings we went with exposing well documented status codes to user. This way user can implement specific reactions to particular errors just looking at JSON + spec.

Quoted 9 lines

Thanks,

DHB

Quoted 3 lines

Thoughs, Markus?

#15 lore raw
Quoted 81 lines · Igor Mammedov
Quoted 78 lines · On Wed, 31 Mar 2021 10:46:49 +1100 David Gibson <[email protected]>…
Quoted 53 lines · Igor Mammedov
Quoted 50 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

Uh.. not as such. In the PAPR model, hotplugs and unplugs are mostly guest directed, so the question doesn't really arise.

Quoted 2 lines

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

Possible, but probably not that likely. The mechanism we use to "cancel" the hotplugs is that we just fail the hypercalls that the guest will need to call to actually complete the hotplug. We also fail those in some other situations, and that seems to work.

That said, I no longer think this cancelling on timeout is a good idea, since it mismatches what happens on other platforms more than I think we need to.

Quoted 7 lines
Quoted 4 lines

My now preferred approach is to revert the timeout changes, but instead allow retries of unplugs to be issued. I think that's just a matter of resending the unplug message to the guest, while making it otherwise a no-op on the qemu side.

Yep, all we need to do is notify QEMU user, so it knows that unplug has failed. Then It can decide on it's own what to do with it and also when.

I'm not sure even that makes sense. I mean in the cases that the guest specifically signals failure, then yes, we should definitely notify the user. But for the cases the timeout was covering, I'm not convinced a notification is useful: we *don't* know the unplug has failed, we only suspect it, and I don't see that qemu really has any more information than the user about what the expected time for an unplug should be.

Quoted 39 lines
Quoted 30 lines
Quoted 24 lines
Quoted 24 lines

I believe that's already covered by the existing API:

(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

      qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                   "for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

Quoted 5 lines
Quoted 3 lines
      qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
      qapi_event_send_device_unplug_error(dev->id, qapi_error);

lets make everything support ACPI (just kidding).

Quoted 8 lines

Heh. If nothing else, doesn't help us with existing guests.

Quoted 3 lines

maybe we can reuse already existing ACPI_DEVICE_OST instead of DEVICE_UNPLUG_ERROR which sort of does the same thing (and more) but instead of strings uses status codes defined by spec.

Hmm. I'm a bit dubious about issuing ACPI messages for a non ACPI guest, but maybe that could work.

Quoted 7 lines

May be we can rename it to be ACPI agnostic (though I'm not sure how renaming QAPI interfaces should be done (it might upset libvirt for example)).

(My point was that ACPI spec had already gone through all the trouble defining status of completion and documenting it. Also libvirt supports this notification. It looks like worthwhile thing to consider if can somehow reuse it outside of x86 world)

Yeah, that's a fair point.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#16 lore raw
In reply to David Gibson
Quoted 74 lines · David Gibson
Quoted 53 lines · Igor Mammedov
Quoted 50 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

Uh.. not as such. In the PAPR model, hotplugs and unplugs are mostly guest directed, so the question doesn't really arise.

Quoted 2 lines

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

Possible, but probably not that likely. The mechanism we use to "cancel" the hotplugs is that we just fail the hypercalls that the guest will need to call to actually complete the hotplug. We also fail those in some other situations, and that seems to work.

Quoted 8 lines

That said, I no longer think this cancelling on timeout is a good idea, since it mismatches what happens on other platforms more than I think we need to.

My now preferred approach is to revert the timeout changes, but instead allow retries of unplugs to be issued. I think that's just a matter of resending the unplug message to the guest, while making it otherwise a no-op on the qemu side.

I used this approach in a patch I sent back in January:

"[PATCH v2 1/1] spapr.c: always pulse guest IRQ in spapr_core_unplug_request()"

https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg04399.html

Let me know and I'll revert the timeout mechanism and re-post this one. I guess there's still time to make this change in the 6.0.0 window, avoiding releasing a mechanism we're not happy with.

Thanks,

DHB

Quoted 56 lines
Quoted 25 lines
Quoted 25 lines

I believe that's already covered by the existing API:

(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

       qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                    "for device %s", dev->id);
       qapi_event_send_device_unplug_error(dev->id, qapi_error);

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

Quoted 5 lines
Quoted 3 lines
       qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
       qapi_event_send_device_unplug_error(dev->id, qapi_error);

lets make everything support ACPI (just kidding).

Heh. If nothing else, doesn't help us with existing guests.

Quoted 3 lines

maybe we can reuse already existing ACPI_DEVICE_OST instead of DEVICE_UNPLUG_ERROR which sort of does the same thing (and more) but instead of strings uses status codes defined by spec.

Hmm. I'm a bit dubious about issuing ACPI messages for a non ACPI guest, but maybe that could work.

Quoted 15 lines

Idea similar to DEVICE_UNPLUG_ERROR was considered back then, but instead of QEMU being a poor translator of status codes to non machine-readable strings we went with exposing well documented status codes to user. This way user can implement specific reactions to particular errors just looking at JSON + spec.

Quoted 9 lines

Thanks,

DHB

Quoted 3 lines

Thoughs, Markus?

#17 lore raw
Quoted 79 lines · Daniel Henrique Barboza
Quoted 76 lines · David Gibson
Quoted 51 lines · Igor Mammedov
Quoted 48 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 47 lines · David Gibson
Quoted 27 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

Uh.. not as such. In the PAPR model, hotplugs and unplugs are mostly guest directed, so the question doesn't really arise.

Quoted 2 lines

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

Possible, but probably not that likely. The mechanism we use to "cancel" the hotplugs is that we just fail the hypercalls that the guest will need to call to actually complete the hotplug. We also fail those in some other situations, and that seems to work.

That said, I no longer think this cancelling on timeout is a good idea, since it mismatches what happens on other platforms more than I think we need to.

Quoted 6 lines
Quoted 4 lines

My now preferred approach is to revert the timeout changes, but instead allow retries of unplugs to be issued. I think that's just a matter of resending the unplug message to the guest, while making it otherwise a no-op on the qemu side.

I used this approach in a patch I sent back in January:

Yes, you did. I rejected it at the time, but the discussion since has convinced me that I made a mistake. In particular, the point that a really loaded host could pretty much arbitrarily extend the time for the guest to process the request is convincing to me.

Quoted 1 line

"[PATCH v2 1/1] spapr.c: always pulse guest IRQ in spapr_core_unplug_request()"

Although.. I think we should actually do a full resend of the unplug request message to the queue, not just pulse the irq. AFAICT an unplug request on a DRC that is already unplugged should be safe (remove-LMB-by-count-only requests might have to be an exception).

Quoted 6 lines

https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg04399.html

Let me know and I'll revert the timeout mechanism and re-post this one. I guess there's still time to make this change in the 6.0.0 window, avoiding releasing a mechanism we're not happy with.

Yes, please, I think this is the way to go.

1) Revert timeouts (6.0)
2) Allow retries (6.0)
3) Add notifications when the guest positively signals failure (6.1)

I think this gives us the best mix of a) user experience, b) not allowing nasty edge cases on loaded systems, c) matching x86 behaviour where possible.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#18 lore raw
In reply to Igor Mammedov
Quoted 53 lines · Igor Mammedov
Quoted 50 lines · On Wed, 24 Mar 2021 16:09:59 -0300 Daniel Henrique Barboza…
Quoted 49 lines · David Gibson
Quoted 28 lines · Daniel Henrique Barboza
Quoted 10 lines · David Gibson
Quoted 8 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

Quoted 6 lines

Implementation looks fine, but I think there's a bit more to discuss before we can apply.

I think it would make sense to re-order this and put UNPLUG_ERROR first. Its semantics are clearer, and I think there's a stronger case for it.

Alright

Quoted 4 lines

I'm a bit less sold on DEVICE_NOT_DELETED, after consideration. Does it really tell the user/management anything useful beyond what receiving neither a DEVICE_DELETED nor a DEVICE_UNPLUG_ERROR does?

Quoted 4 lines

It informs that the hotunplug operation exceed the timeout that QEMU internals considers adequate, but QEMU can't assert that it was caused by an error or an unexpected delay. The end result is that the device is not going to be deleted from QMP, so DEVICE_NOT_DELETED.

Is it, though? I mean, it is with this implementation for papr:
because we clear the unplug_requested flag, even if the guest later tries to complete the unplug, it will fail.

But if I understand what Markus was saying correctly, that might not be possible for all hotplug systems. I believe Markus was suggesting that DEVICE_NOT_DELETED could just mean that we haven't deleted the device yet, but it could still happen later.

And in that case, I'm not yet sold on the value of a message that essentially just means "Ayup, still dunno what's happening, sorry".

Quoted 2 lines

Perhaps we should just be straightforward and create a DEVICE_UNPLUG_TIMEOUT event.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

Hm... what if we added a "reason" field to UNPLUG_ERROR. That could be "guest rejected hotplug", or something more specific, in the rare case that the guest has a way of signalling something more specific, or "timeout" - but the later *only* to be sent in cases where on the timeout we're able to block any later completion of the unplug (as we can on papr).

Is canceling unplug on timeout documented somewhere (like some spec)?

Nope.

Quoted 3 lines

If not it might (theoretically) confuse guest when it tries to unplug after timeout and leave guest in some unexpected state.

I consider this a remote possibility due to the generous timeout we're using in the machine, but it is a possibility nevertheless.

Quoted 26 lines
Quoted 26 lines

I believe that's already covered by the existing API:

(quoted diff) +7 -0
+# @DEVICE_UNPLUG_ERROR:
+#
+# Emitted when a device hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message

The 'informative message' would be the reason the event occurred. In patch 4/4, for the memory hotunplug refused by the guest, it is being set as:

       qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest "
                                    "for device %s", dev->id);
       qapi_event_send_device_unplug_error(dev->id, qapi_error);

We could use the same DEVICE_UNPLUG_ERROR event in the CPU hotunplug timeout case (currently on patch 2/4) by just changing 'msg', e.g.:

Quoted 5 lines
Quoted 3 lines
       qapi_error = g_strdup_printf("CPU hotunplug timeout for device %s", dev->id);
       qapi_event_send_device_unplug_error(dev->id, qapi_error);

lets make everything support ACPI (just kidding).

I would love to make PAPR more ACPI and less .... PAPR.

Quoted 9 lines

maybe we can reuse already existing ACPI_DEVICE_OST instead of DEVICE_UNPLUG_ERROR which sort of does the same thing (and more) but instead of strings uses status codes defined by spec.

Idea similar to DEVICE_UNPLUG_ERROR was considered back then, but instead of QEMU being a poor translator of status codes to non machine-readable strings we went with exposing well documented status codes to user. This way user can implement specific reactions to particular errors just looking at JSON + spec.

This is not a bad idea. Problem is that we don't have all ACPI_DEVICE_OST fields to fill in because, well, both the timeout and the cancell mechanism aren't specified there.

Thanks,

DHB

Quoted 11 lines
Quoted 10 lines

Thanks,

DHB

Quoted 3 lines

Thoughs, Markus?

#19 lore raw
In reply to Daniel Henrique Barboza

Hello,

Quick update about this work:

- the hotunplug timeout was reverted in the pSeries machine for 6.0.0. This means that we have no use for a DEVICE_NOT_DELETED event or similar. I'll drop it for the next version of the series.

- there is a good chance that the pSeries kernel will introduce a way to report hotunplug errors in v5.13 ([1] for more info). This would make the DEVICE_UNPLUG_ERROR event relevant again (otherwise it would just be a rebranding of the existing mem_unplug_error) since we'll be able to properly report guest side unplug errors for all devices in the pSeries machine, starting with CPUs.

Thanks,

DHB

[1] https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/

Quoted 25 lines · Daniel Henrique Barboza

Hi,

This series adds 2 new QAPI events, DEVICE_NOT_DELETED and DEVICE_UNPLUG_ERROR. They were (and are still being) discussed in [1].

Patches 1 and 3 are independent of the ppc patches and can be applied separately. Patches 2 and 4 are based on David's ppc-for-6.0 branch and are dependent on the QAPI patches.

[1] https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg01900.html

Daniel Henrique Barboza (4):
qapi/qdev.json: add DEVICE_NOT_DELETED event spapr_drc.c: send DEVICE_NOT_DELETED event on unplug timeout qapi/machine.json: add DEVICE_UNPLUG_ERROR QAPI event spapr.c: use DEVICE_UNPLUG_ERROR event in
spapr_memory_unplug_rollback()

  hw/ppc/spapr.c     |  2 +-
  hw/ppc/spapr_drc.c |  8 ++++++++
  qapi/machine.json  | 23 +++++++++++++++++++++++
  qapi/qdev.json     | 28 ++++++++++++++++++++++++++++
  4 files changed, 60 insertions(+), 1 deletion(-)