Skip to contentSkip to conversation

qmp: add ACPI_DEVICE_OST event handling

PATCH In review Igor Mammedov 5 participants 8 messages Jun 20, 2014 – Jun 23, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 qmp: add ACPI_DEVICE_OST event handling

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

---
v2:
- use new QAPI event infrastructure
from rebased PCI tree on top of today's QMP pull request

---
 hw/acpi/memory_hotplug.c |    7 ++++++-
 qapi-event.json          |   10 ++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
hw/acpi/memory_hotplug.c +6 -1
index e7009bc..38ca415 100644
@@ -3,6 +3,7 @@
 #include "hw/mem/pc-dimm.h"
 #include "hw/boards.h"
 #include "trace.h"
+#include "qapi-event.h"
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -88,6 +89,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
 {
     MemHotplugState *mem_st = opaque;
     MemStatus *mdev;
+    ACPIOSTInfo *info;
 
     if (!mem_st->dev_count) {
         return;
@@ -119,8 +121,11 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
         mdev = &mem_st->devs[mem_st->selector];
         mdev->ost_status = data;
         trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
-        /* TODO: report async error */
         /* TODO: implement memory removal on guest signal */
+
+        info = acpi_memory_device_status(mem_st->selector, mdev);
+        qapi_event_send_acpi_device_ost(info, &error_abort);
+        qapi_free_ACPIOSTInfo(info);
         break;
     case 0x14:
         mdev = &mem_st->devs[mem_st->selector];
qapi-event.json +10 -0
index fbdda48..6876327 100644
@@ -304,3 +304,13 @@
 { 'event': 'QUORUM_REPORT_BAD',
   'data': { '*error': 'str', 'node-name': 'str',
             'sector-num': 'int', 'sector-count': 'int' } }
+
+##
+# @ACPI_DEVICE_OST
+#
+# Emitted when guest executes ACPI _OST method.
+#
+# @info: ACPIOSTInfo type as described in qapi-schema.json
+##
+{ 'event': 'ACPI_DEVICE_OST',
+     'data': { 'info': 'ACPIOSTInfo' } }
Signature · 1 line
1.7.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 16 lines · Igor Mammedov

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

---
v2:
- use new QAPI event infrastructure
from rebased PCI tree on top of today's QMP pull request

---
 hw/acpi/memory_hotplug.c |    7 ++++++-
 qapi-event.json          |   10 ++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)

+++ b/qapi-event.json

qapi-event.json line 313

Quoted 10 lines
qapi-event.json +7 -0
@@ -304,3 +304,13 @@
 { 'event': 'QUORUM_REPORT_BAD',
   'data': { '*error': 'str', 'node-name': 'str',
             'sector-num': 'int', 'sector-count': 'int' } }
+
+##
+# @ACPI_DEVICE_OST
+#
+# Emitted when guest executes ACPI _OST method.
+#
+# @info: ACPIOSTInfo type as described in qapi-schema.json

Needs 'Since: 2.1'.

qapi-event.json line 316

Quoted 4 lines
qapi-event.json +3 -0
+##
+{ 'event': 'ACPI_DEVICE_OST',
+     'data': { 'info': 'ACPIOSTInfo' } }

Not your fault, as the problem already exists, but it's a bit awkward that qapi-event.json is not self-contained, and your patch is only making it worse. qapi-event.json only makes sense when included by qapi-schema.json, when ideally it would be nice if it made sense if compiled in isolation. I already pointed this fact out on Wenchao's series that made events part of QAPI, but fixing it first requires teaching the code generators to flag places where a type is used without a pre-definition, so that we know which types have to be moved into a common include. So don't let this comment hold up your patch.

If you add the Since line,

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by
#2 lore raw
Quoted 15 lines · Eric Blake
Quoted 13 lines · Igor Mammedov

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

---
v2:
- use new QAPI event infrastructure
from rebased PCI tree on top of today's QMP pull request

---
  hw/acpi/memory_hotplug.c |    7 ++++++-
  qapi-event.json          |   10 ++++++++++
  2 files changed, 16 insertions(+), 1 deletions(-)
Quoted 15 lines

qapi-event.json line 313

Quoted 12 lines

+++ b/qapi-event.json

qapi-event.json +7 -0
@@ -304,3 +304,13 @@
  { 'event': 'QUORUM_REPORT_BAD',
    'data': { '*error': 'str', 'node-name': 'str',
              'sector-num': 'int', 'sector-count': 'int' } }
+
+##
+# @ACPI_DEVICE_OST
+#
+# Emitted when guest executes ACPI _OST method.
+#
+# @info: ACPIOSTInfo type as described in qapi-schema.json

Needs 'Since: 2.1'.

With above added,

Quoted 15 lines

qapi-event.json line 316

Quoted 4 lines
qapi-event.json +3 -0
+##
+{ 'event': 'ACPI_DEVICE_OST',
+     'data': { 'info': 'ACPIOSTInfo' } }

Not your fault, as the problem already exists, but it's a bit awkward that qapi-event.json is not self-contained, and your patch is only making it worse. qapi-event.json only makes sense when included by qapi-schema.json, when ideally it would be nice if it made sense if compiled in isolation. I already pointed this fact out on Wenchao's series that made events part of QAPI, but fixing it first requires teaching the code generators to flag places where a type is used without

Quoted 3 lines

a pre-definition, so that we know which types have to be moved into a common include. So don't let this comment hold up your patch.

I think two issues should be addressed:
1 don't let generator guess the type if define is not found. 2 Support duplicated include, that is:

             qapi/types.json
                     |
      ---------------------------
      |                          |

qapi/qapi-event.json qapi/block.json
| |
qapi-schema-json

Making sure above include doesn't generate two copy of types from
qapi/types.json.
We can improve it later.

Quoted 3 lines

If you add the Since line,

#3 lore raw
Quoted 60 lines · Wenchao Xia
Quoted 15 lines · Eric Blake
Quoted 13 lines · Igor Mammedov

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

---
v2:
- use new QAPI event infrastructure
from rebased PCI tree on top of today's QMP pull request

---
  hw/acpi/memory_hotplug.c |    7 ++++++-
  qapi-event.json          |   10 ++++++++++
  2 files changed, 16 insertions(+), 1 deletions(-)
Quoted 15 lines

qapi-event.json line 313

Quoted 12 lines

+++ b/qapi-event.json

qapi-event.json +7 -0
@@ -304,3 +304,13 @@
  { 'event': 'QUORUM_REPORT_BAD',
    'data': { '*error': 'str', 'node-name': 'str',
              'sector-num': 'int', 'sector-count': 'int' } }
+
+##
+# @ACPI_DEVICE_OST
+#
+# Emitted when guest executes ACPI _OST method.
+#
+# @info: ACPIOSTInfo type as described in qapi-schema.json

Needs 'Since: 2.1'.

With above added,

Quoted 15 lines

qapi-event.json line 316

Quoted 4 lines
qapi-event.json +3 -0
+##
+{ 'event': 'ACPI_DEVICE_OST',
+     'data': { 'info': 'ACPIOSTInfo' } }

Not your fault, as the problem already exists, but it's a bit awkward that qapi-event.json is not self-contained, and your patch is only making it worse. qapi-event.json only makes sense when included by qapi-schema.json, when ideally it would be nice if it made sense if compiled in isolation. I already pointed this fact out on Wenchao's series that made events part of QAPI, but fixing it first requires teaching the code generators to flag places where a type is used without

Quoted 3 lines

a pre-definition, so that we know which types have to be moved into a common include. So don't let this comment hold up your patch.

I think two issues should be addressed:
1 don't let generator guess the type if define is not found. 2 Support duplicated include, that is:

             qapi/types.json
                     |
      ---------------------------
      |                          |
Quoted 6 lines

qapi/qapi-event.json qapi/block.json
| |
qapi-schema-json

Making sure above include doesn't generate two copy of types from
qapi/types.json.

See Benoît's commit 24fd848 "qapi: skip redundant includes".

Quoted 4 lines

We can improve it later.

Quoted 2 lines

If you add the Since line,

#4 lore raw
In reply to Wenchao Xia
Quoted 10 lines · Wenchao Xia
Quoted 10 lines

Not your fault, as the problem already exists, but it's a bit awkward that qapi-event.json is not self-contained, and your patch is only making it worse. qapi-event.json only makes sense when included by qapi-schema.json, when ideally it would be nice if it made sense if compiled in isolation. I already pointed this fact out on Wenchao's series that made events part of QAPI, but fixing it first requires teaching the code generators to flag places where a type is used without a pre-definition, so that we know which types have to be moved into a common include. So don't let this comment hold up your patch.

Quoted 2 lines

I think two issues should be addressed:
1 don't let generator guess the type if define is not found.

But we WANT to allow use of a type so long as it gets defined later in the same file. So the trick is distinguishing between:

base.json - use of 'TypeFoo'
total.json: include base.json, define 'TypeFoo'

(broken, base.json was not self-contained)

vs.

base.json - define 'TypeFoo'
total.json - use of 'TypeFoo', then include base.json

(supported - even though 'TypeFoo' was used prior to being defined, the include later in the file meant that total.json was self-contained)

Quoted 6 lines

2 Support duplicated include, that is:

             qapi/types.json
                     |
      ---------------------------
      |                          |
Quoted 6 lines

qapi/qapi-event.json qapi/block.json
| |
qapi-schema-json

Making sure above include doesn't generate two copy of types from
qapi/types.json.

We already support that.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw
In reply to Igor Mammedov
Quoted 4 lines · Igor Mammedov

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

The subject and commit log are confusing here. We already have
Author: Igor Mammedov <[email protected]>
qmp: add ACPI_DEVICE_OST event handling

So I am guessing this reworks existing functionality to use the new QMP infrastructure.
Please rewrite both subject and commit log.

Quoted 62 lines

---
v2:
- use new QAPI event infrastructure
from rebased PCI tree on top of today's QMP pull request

---
 hw/acpi/memory_hotplug.c |    7 ++++++-
 qapi-event.json          |   10 ++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
hw/acpi/memory_hotplug.c +6 -1
index e7009bc..38ca415 100644
@@ -3,6 +3,7 @@
 #include "hw/mem/pc-dimm.h"
 #include "hw/boards.h"
 #include "trace.h"
+#include "qapi-event.h"
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -88,6 +89,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
 {
     MemHotplugState *mem_st = opaque;
     MemStatus *mdev;
+    ACPIOSTInfo *info;
 
     if (!mem_st->dev_count) {
         return;
@@ -119,8 +121,11 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
         mdev = &mem_st->devs[mem_st->selector];
         mdev->ost_status = data;
         trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
-        /* TODO: report async error */
         /* TODO: implement memory removal on guest signal */
+
+        info = acpi_memory_device_status(mem_st->selector, mdev);
+        qapi_event_send_acpi_device_ost(info, &error_abort);
+        qapi_free_ACPIOSTInfo(info);
         break;
     case 0x14:
         mdev = &mem_st->devs[mem_st->selector];
qapi-event.json +10 -0
index fbdda48..6876327 100644
@@ -304,3 +304,13 @@
 { 'event': 'QUORUM_REPORT_BAD',
   'data': { '*error': 'str', 'node-name': 'str',
             'sector-num': 'int', 'sector-count': 'int' } }
+
+##
+# @ACPI_DEVICE_OST
+#
+# Emitted when guest executes ACPI _OST method.
+#
+# @info: ACPIOSTInfo type as described in qapi-schema.json
+##
+{ 'event': 'ACPI_DEVICE_OST',
+     'data': { 'info': 'ACPIOSTInfo' } }
Signature · 1 line
1.7.1
#6 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Igor Mammedov

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

Quoted 9 lines

The subject and commit log are confusing here. We already have
Author: Igor Mammedov <[email protected]>
qmp: add ACPI_DEVICE_OST event handling

So I am guessing this reworks existing functionality to use the new QMP infrastructure.
Please rewrite both subject and commit log.

Based on IRC chatter, it looks like Igor has reworked the patch to be applied as part of Luiz' QMP queue in a way that minimizes the conflicts there. Igor's rework is more-or-less a revert of the v2 patch that was applied prematurely in mst's tree, combined with this v3 patch to apply correctly in Wenchao's event-as-qapi series on Luiz' tree.

At this point, I'd wait for a PULL request from Luiz to determine if anything further is needed on this front.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw
Quoted 17 lines · Eric Blake
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Igor Mammedov

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

Quoted 9 lines

The subject and commit log are confusing here. We already have
Author: Igor Mammedov <[email protected]>
qmp: add ACPI_DEVICE_OST event handling

So I am guessing this reworks existing functionality to use the new QMP infrastructure.
Please rewrite both subject and commit log.

Quoted 8 lines

Based on IRC chatter, it looks like Igor has reworked the patch to be applied as part of Luiz' QMP queue in a way that minimizes the conflicts there. Igor's rework is more-or-less a revert of the v2 patch that was applied prematurely in mst's tree, combined with this v3 patch to apply correctly in Wenchao's event-as-qapi series on Luiz' tree.

At this point, I'd wait for a PULL request from Luiz to determine if anything further is needed on this front.

Indeed,
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg05424.html (in particular 33/43) solves the problems.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org