diff mbox

[3/6] qapi: rename prefix QEVENT to Q_EVENT

Message ID 1382321765-29052-4-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia Oct. 21, 2013, 2:16 a.m. UTC
The define will be moved to qapi-schema.json later, so rename the
prefix to match its naming style.

Also fixed code style error reported in spice-core.c.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 balloon.c                 |    2 +-
 block.c                   |    4 +-
 block/qcow2-refcount.c    |    2 +-
 blockdev.c                |    4 +-
 blockjob.c                |    5 ++-
 cpus.c                    |    2 +-
 hw/acpi/core.c            |    2 +-
 hw/core/qdev.c            |    2 +-
 hw/misc/pvpanic.c         |    2 +-
 hw/net/virtio-net.c       |    2 +-
 hw/watchdog/watchdog.c    |    2 +-
 include/monitor/monitor.h |   58 +++++++++++++++++-----------------
 monitor.c                 |   74 ++++++++++++++++++++++----------------------
 target-s390x/kvm.c        |    2 +-
 ui/spice-core.c           |    8 ++--
 ui/vnc.c                  |    6 ++--
 vl.c                      |   14 ++++----
 17 files changed, 96 insertions(+), 95 deletions(-)

Comments

Eric Blake Oct. 21, 2013, 8:41 p.m. UTC | #1
On 10/21/2013 03:16 AM, Wenchao Xia wrote:
> The define will be moved to qapi-schema.json later, so rename the
> prefix to match its naming style.

Wouldn't it be simpler to fix the code generator to special case QEvent
to turn into QEVENT, instead of having to go through this churn?  But if
we _like_ the Q_EVENT_ prefix, then this looks fairly mechanical:

> 
> Also fixed code style error reported in spice-core.c.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  balloon.c                 |    2 +-
>  block.c                   |    4 +-
>  block/qcow2-refcount.c    |    2 +-
>  blockdev.c                |    4 +-
>  blockjob.c                |    5 ++-
>  cpus.c                    |    2 +-
>  hw/acpi/core.c            |    2 +-
>  hw/core/qdev.c            |    2 +-
>  hw/misc/pvpanic.c         |    2 +-
>  hw/net/virtio-net.c       |    2 +-
>  hw/watchdog/watchdog.c    |    2 +-
>  include/monitor/monitor.h |   58 +++++++++++++++++-----------------
>  monitor.c                 |   74 ++++++++++++++++++++++----------------------
>  target-s390x/kvm.c        |    2 +-
>  ui/spice-core.c           |    8 ++--
>  ui/vnc.c                  |    6 ++--
>  vl.c                      |   14 ++++----
>  17 files changed, 96 insertions(+), 95 deletions(-)

If no one else is as opposed to the Q_EVENT naming as I seem to be, then
you can add my reluctant

Reviewed-by: Eric Blake <eblake@redhat.com>

in that your change is mechanical and correct.
Wayne Xia Oct. 22, 2013, 2:43 a.m. UTC | #2
于 2013/10/22 4:41, Eric Blake 写道:
> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
>> The define will be moved to qapi-schema.json later, so rename the
>> prefix to match its naming style.
> Wouldn't it be simpler to fix the code generator to special case QEvent
> to turn into QEVENT, instead of having to go through this churn?  But if
> we _like_ the Q_EVENT_ prefix, then this looks fairly mechanical:
>
>> Also fixed code style error reported in spice-core.c.
>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   balloon.c                 |    2 +-
>>   block.c                   |    4 +-
>>   block/qcow2-refcount.c    |    2 +-
>>   blockdev.c                |    4 +-
>>   blockjob.c                |    5 ++-
>>   cpus.c                    |    2 +-
>>   hw/acpi/core.c            |    2 +-
>>   hw/core/qdev.c            |    2 +-
>>   hw/misc/pvpanic.c         |    2 +-
>>   hw/net/virtio-net.c       |    2 +-
>>   hw/watchdog/watchdog.c    |    2 +-
>>   include/monitor/monitor.h |   58 +++++++++++++++++-----------------
>>   monitor.c                 |   74 ++++++++++++++++++++++----------------------
>>   target-s390x/kvm.c        |    2 +-
>>   ui/spice-core.c           |    8 ++--
>>   ui/vnc.c                  |    6 ++--
>>   vl.c                      |   14 ++++----
>>   17 files changed, 96 insertions(+), 95 deletions(-)
> If no one else is as opposed to the Q_EVENT naming as I seem to be, then
> you can add my reluctant
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
> in that your change is mechanical and correct.
>
   Personally I think less special case is better, and there is no harm
to do a mechanical prefix change in code. Markus, can I have your opinion?
also cc qapi-types.py author Anthony.
Paolo Bonzini Oct. 28, 2013, 10:44 a.m. UTC | #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Il 21/10/2013 22:41, Eric Blake ha scritto:
> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
>> The define will be moved to qapi-schema.json later, so rename
>> the prefix to match its naming style.
> 
> Wouldn't it be simpler to fix the code generator to special case
> QEvent to turn into QEVENT, instead of having to go through this
> churn?  But if we _like_ the Q_EVENT_ prefix, then this looks
> fairly mechanical:

No, I disagree.  However, since something _is_ being renamed, we might
as well rename every QEVENT_ to MONITOR_EVENT_ and avoid patch 2.

Paolo

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSbj/xAAoJEBvWZb6bTYbyNkQP/R0l+qwakF5zBfwoiEc7Ru4r
YnG6B2HkCn7Bc5juDnZXYIvPdX1+n3x9tvGTcw2eP+8hiUQBmVGQEWNIlvOkPQoW
EtW7wzf0uRvROeYy0aqr5P+xU/0uDLonr3wONxv3aMc99CwZvJ918X889is5z4ps
P7CrMrnh9Ng99SgmkFgYS9KxwM004iIKyGyjKbYC+BYTKrJd7chzGfb41r687AbR
7CMb3gBCUvFRU2E2+yCdRI/cRVgRDSCMZ4Ic5VNK4DFKa6eq+yzP4zEhILkStl1o
yvPYlxpfHNLLle83iOb4rJFmBYz6mrAkVhfUOXdrKPegU6l+hod0vpuXcm3tMIO8
YJ9iMxeFrI2tFsIXVzQgugz4jaSY0BDapCP15aL9zqIzACiTpYZeaVden/gWu1Oy
iupuue9xzT2l40FCQwNXrGULOiOVRuiry8JstJ0A/valQi/xRy28cky+FI+PglNt
3eaj3GYK0oF1UyG3e22cFensIUOTWE1Znbm7/5ON12xcFOTE1e5bzvuPWUDOJ1wh
2I/p7Bn7uewQLstL14++gN1iMP+GCXJ0ce7xc0QtTP7jvtYCeTt+yBDC7jlan4Zb
N/CEISOti9obFYlDKiQL+Hdk4ivQsFjT2B1p7feGSd5JAZtLthNxBOSQrS4wg5fd
WW6UX7otKyj6MADQl3Jk
=Q+3Z
-----END PGP SIGNATURE-----
Wayne Xia Oct. 29, 2013, 5:22 a.m. UTC | #4
于 2013/10/28 18:44, Paolo Bonzini 写道:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Il 21/10/2013 22:41, Eric Blake ha scritto:
>> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
>>> The define will be moved to qapi-schema.json later, so rename
>>> the prefix to match its naming style.
>> Wouldn't it be simpler to fix the code generator to special case
>> QEvent to turn into QEVENT, instead of having to go through this
>> churn?  But if we _like_ the Q_EVENT_ prefix, then this looks
>> fairly mechanical:
> No, I disagree.  However, since something _is_ being renamed, we might
> as well rename every QEVENT_ to MONITOR_EVENT_ and avoid patch 2.
>
> Paolo
>
   MONITOR_EVENT seems tide to monitor too much, since it will be present
in qapi-schema, I think Q_EVENT_ or QMP_EVENT_KIND would be better?

   I am coding v2, which fully support event define in qapi-schema. There
is another thing I hope to know your opinion:
   Should we support use enum as discriminator?

{ 'enum': 'QEvent',
   'data': [ 'SHUTDOWN', 'POWERDOWN']

{ 'type': 'QmpEventBase',
   'data': { 'event': 'QEvent', 'timestamp': 'EventTimestamp' } }

{ 'Union': 'QmpEvent',
   'base': 'QmpEventBase',
   'discriminator': 'event',
   'data': {
       'SHUTDOWN'               : 'EventShutdown',
       'POWERDOWN'              : 'EventPowerdown'
    }
}

   By default 'QmpEvent' will generate a hidden enum type 'QmpEventKind'.
but the hidden type define is needed by query-event, so there is two way
to archieve it:
1 just use the hidden type in qapi-schema.json.
2 modified the script to support use predefined enum type.
   In my draft code, both can work, but which one do you prefer?
Eric Blake Oct. 29, 2013, 4:09 p.m. UTC | #5
On 10/28/2013 11:22 PM, Wenchao Xia wrote:

>>
>   MONITOR_EVENT seems tide to monitor too much, since it will be present
> in qapi-schema, I think Q_EVENT_ or QMP_EVENT_KIND would be better?

I don't have a strong enough opinion on the bikeshed color.
MONITOR_EVENT implies the event is always associated with delivery over
a monitor; but how else would you receive an event without a monitor?

> 
>   I am coding v2, which fully support event define in qapi-schema. There
> is another thing I hope to know your opinion:
>   Should we support use enum as discriminator?
> 
> { 'enum': 'QEvent',
>   'data': [ 'SHUTDOWN', 'POWERDOWN']
> 
> { 'type': 'QmpEventBase',
>   'data': { 'event': 'QEvent', 'timestamp': 'EventTimestamp' } }
> 
> { 'Union': 'QmpEvent',
>   'base': 'QmpEventBase',
>   'discriminator': 'event',

I raised that question when Kevin first added discriminated unions; if I
recall, the answer was along the lines: "yes, it would be a nice
addition, but someone would have to code it, and we'd have to teach the
generator.py to loudly fail if all branches of the enum are not covered
in the union's data".  So go for it!

>   'data': {
>       'SHUTDOWN'               : 'EventShutdown',
>       'POWERDOWN'              : 'EventPowerdown'
>    }
> }
> 
>   By default 'QmpEvent' will generate a hidden enum type 'QmpEventKind'.
> but the hidden type define is needed by query-event, so there is two way
> to archieve it:
> 1 just use the hidden type in qapi-schema.json.
> 2 modified the script to support use predefined enum type.
>   In my draft code, both can work, but which one do you prefer?

I'd like to see the addition of an enum-typed discriminator, rather than
forcing the discriminator to be string-only.
Kevin Wolf Oct. 29, 2013, 6:18 p.m. UTC | #6
Am 21.10.2013 um 22:41 hat Eric Blake geschrieben:
> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
> > The define will be moved to qapi-schema.json later, so rename the
> > prefix to match its naming style.
> 
> Wouldn't it be simpler to fix the code generator to special case QEvent
> to turn into QEVENT, instead of having to go through this churn?  But if
> we _like_ the Q_EVENT_ prefix, then this looks fairly mechanical:

Or rather, instead of special casing QEvent, it shouldn't insert
underscores if there is nothing between the two capital letters.

I've had a similar case with AIO in the blockdev-add series; and while
renaming it to Aio worked, this kind of thing doesn't seem to be a rare
exception in practice, so it might be worth adjusting the generator.

Kevin
Wayne Xia Oct. 30, 2013, 7:26 a.m. UTC | #7
于 2013/10/30 0:09, Eric Blake 写道:
> On 10/28/2013 11:22 PM, Wenchao Xia wrote:
>
>>    MONITOR_EVENT seems tide to monitor too much, since it will be present
>> in qapi-schema, I think Q_EVENT_ or QMP_EVENT_KIND would be better?
> I don't have a strong enough opinion on the bikeshed color.
> MONITOR_EVENT implies the event is always associated with delivery over
> a monitor; but how else would you receive an event without a monitor?
   Block code emit event already, when it is packaged as a library
it may need emit to other place. I think event doesn't have to be
bond to monitor, I can modify the qapi script to generate name correctly,
to avoid patch 2, Since it seems not right to have '_' between two capitals.


>>    I am coding v2, which fully support event define in qapi-schema. There
>> is another thing I hope to know your opinion:
>>    Should we support use enum as discriminator?
>>
>> { 'enum': 'QEvent',
>>    'data': [ 'SHUTDOWN', 'POWERDOWN']
>>
>> { 'type': 'QmpEventBase',
>>    'data': { 'event': 'QEvent', 'timestamp': 'EventTimestamp' } }
>>
>> { 'Union': 'QmpEvent',
>>    'base': 'QmpEventBase',
>>    'discriminator': 'event',
> I raised that question when Kevin first added discriminated unions; if I
> recall, the answer was along the lines: "yes, it would be a nice
> addition, but someone would have to code it, and we'd have to teach the
> generator.py to loudly fail if all branches of the enum are not covered
> in the union's data".  So go for it!
   OK, will send it soon.

>
>>    'data': {
>>        'SHUTDOWN'               : 'EventShutdown',
>>        'POWERDOWN'              : 'EventPowerdown'
>>     }
>> }
>>
>>    By default 'QmpEvent' will generate a hidden enum type 'QmpEventKind'.
>> but the hidden type define is needed by query-event, so there is two way
>> to archieve it:
>> 1 just use the hidden type in qapi-schema.json.
>> 2 modified the script to support use predefined enum type.
>>    In my draft code, both can work, but which one do you prefer?
> I'd like to see the addition of an enum-typed discriminator, rather than
> forcing the discriminator to be string-only.
>
Wayne Xia Oct. 30, 2013, 7:27 a.m. UTC | #8
于 2013/10/30 2:18, Kevin Wolf 写道:
> Am 21.10.2013 um 22:41 hat Eric Blake geschrieben:
>> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
>>> The define will be moved to qapi-schema.json later, so rename the
>>> prefix to match its naming style.
>> Wouldn't it be simpler to fix the code generator to special case QEvent
>> to turn into QEVENT, instead of having to go through this churn?  But if
>> we _like_ the Q_EVENT_ prefix, then this looks fairly mechanical:
> Or rather, instead of special casing QEvent, it shouldn't insert
> underscores if there is nothing between the two capital letters.
>
> I've had a similar case with AIO in the blockdev-add series; and while
> renaming it to Aio worked, this kind of thing doesn't seem to be a rare
> exception in practice, so it might be worth adjusting the generator.
>
> Kevin
It seems the right way, will adjust the generator.
Paolo Bonzini Oct. 30, 2013, 11:55 a.m. UTC | #9
Il 30/10/2013 08:27, Wenchao Xia ha scritto:
> 于 2013/10/30 2:18, Kevin Wolf 写道:
>> Am 21.10.2013 um 22:41 hat Eric Blake geschrieben:
>>> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
>>>> The define will be moved to qapi-schema.json later, so rename the
>>>> prefix to match its naming style.
>>> Wouldn't it be simpler to fix the code generator to special case QEvent
>>> to turn into QEVENT, instead of having to go through this churn?  But if
>>> we _like_ the Q_EVENT_ prefix, then this looks fairly mechanical:
>> Or rather, instead of special casing QEvent, it shouldn't insert
>> underscores if there is nothing between the two capital letters.

... but it should still insert one before the very last capital letter.
 For example AIOType should become AIO_TYPE, not AIOTYPE.

>> I've had a similar case with AIO in the blockdev-add series; and while
>> renaming it to Aio worked, this kind of thing doesn't seem to be a rare
>> exception in practice, so it might be worth adjusting the generator.
>
> It seems the right way, will adjust the generator.

I think even if you adjusted it, it would be a no-op in this case.  For
example:

    AIOType => AIO_TYPE
    QEvent  => Q_EVENT

Paolo
Wayne Xia Oct. 31, 2013, 5:26 a.m. UTC | #10
于 2013/10/30 19:55, Paolo Bonzini 写道:
> Il 30/10/2013 08:27, Wenchao Xia ha scritto:
>> 于 2013/10/30 2:18, Kevin Wolf 写道:
>>> Am 21.10.2013 um 22:41 hat Eric Blake geschrieben:
>>>> On 10/21/2013 03:16 AM, Wenchao Xia wrote:
>>>>> The define will be moved to qapi-schema.json later, so rename the
>>>>> prefix to match its naming style.
>>>> Wouldn't it be simpler to fix the code generator to special case QEvent
>>>> to turn into QEVENT, instead of having to go through this churn?  But if
>>>> we _like_ the Q_EVENT_ prefix, then this looks fairly mechanical:
>>> Or rather, instead of special casing QEvent, it shouldn't insert
>>> underscores if there is nothing between the two capital letters.
>
> ... but it should still insert one before the very last capital letter.
>   For example AIOType should become AIO_TYPE, not AIOTYPE.
>
>>> I've had a similar case with AIO in the blockdev-add series; and while
>>> renaming it to Aio worked, this kind of thing doesn't seem to be a rare
>>> exception in practice, so it might be worth adjusting the generator.
>>
>> It seems the right way, will adjust the generator.
>
> I think even if you adjusted it, it would be a no-op in this case.  For
> example:
>
>      AIOType => AIO_TYPE
>      QEvent  => Q_EVENT
>
> Paolo
>

   Maybe check whether there is more than two continous capitalized char?
Luiz Capitulino Nov. 1, 2013, 2:06 p.m. UTC | #11
On Tue, 29 Oct 2013 10:09:40 -0600
Eric Blake <eblake@redhat.com> wrote:

> On 10/28/2013 11:22 PM, Wenchao Xia wrote:
> 
> >>
> >   MONITOR_EVENT seems tide to monitor too much, since it will be present
> > in qapi-schema, I think Q_EVENT_ or QMP_EVENT_KIND would be better?
> 
> I don't have a strong enough opinion on the bikeshed color.
> MONITOR_EVENT implies the event is always associated with delivery over
> a monitor; but how else would you receive an event without a monitor?

Today QMP is tied to the Monitor, but one of the goals of the QAPI is
to untangle them. This would allow for a separate QMP server, which
could have QMP only features like session support.
diff mbox

Patch

diff --git a/balloon.c b/balloon.c
index e321f2c..16ea2e1 100644
--- a/balloon.c
+++ b/balloon.c
@@ -88,7 +88,7 @@  void qemu_balloon_changed(int64_t actual)
     data = qobject_from_jsonf("{ 'actual': %" PRId64 " }",
                               actual);
 
-    monitor_protocol_event(QEVENT_BALLOON_CHANGE, data);
+    monitor_protocol_event(Q_EVENT_BALLOON_CHANGE, data);
 
     qobject_decref(data);
 }
diff --git a/block.c b/block.c
index 458a4f8..002405f 100644
--- a/block.c
+++ b/block.c
@@ -1795,7 +1795,7 @@  static void bdrv_emit_qmp_eject_event(BlockDriverState *bs, bool ejected)
 
     data = qobject_from_jsonf("{ 'device': %s, 'tray-open': %i }",
                               bdrv_get_device_name(bs), ejected);
-    monitor_protocol_event(QEVENT_DEVICE_TRAY_MOVED, data);
+    monitor_protocol_event(Q_EVENT_DEVICE_TRAY_MOVED, data);
 
     qobject_decref(data);
 }
@@ -2926,7 +2926,7 @@  void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action,
                        bool is_read, int error)
 {
     assert(error >= 0);
-    bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
+    bdrv_emit_qmp_error_event(bs, Q_EVENT_BLOCK_IO_ERROR, action, is_read);
     if (action == BDRV_ACTION_STOP) {
         vm_stop(RUN_STATE_IO_ERROR);
         bdrv_iostatus_set_err(bs, error);
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 1ff43d0..f31faa9 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -1787,7 +1787,7 @@  int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
         data = qobject_from_jsonf("{ 'device': %s, 'msg': %s, 'offset': %"
                 PRId64 ", 'size': %" PRId64 " }", bs->device_name, message,
                 offset, size);
-        monitor_protocol_event(QEVENT_BLOCK_IMAGE_CORRUPTED, data);
+        monitor_protocol_event(Q_EVENT_BLOCK_IMAGE_CORRUPTED, data);
         g_free(message);
         qobject_decref(data);
 
diff --git a/blockdev.c b/blockdev.c
index b260477..ed30f3a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1725,9 +1725,9 @@  static void block_job_cb(void *opaque, int ret)
     }
 
     if (block_job_is_cancelled(bs->job)) {
-        monitor_protocol_event(QEVENT_BLOCK_JOB_CANCELLED, obj);
+        monitor_protocol_event(Q_EVENT_BLOCK_JOB_CANCELLED, obj);
     } else {
-        monitor_protocol_event(QEVENT_BLOCK_JOB_COMPLETED, obj);
+        monitor_protocol_event(Q_EVENT_BLOCK_JOB_COMPLETED, obj);
     }
     qobject_decref(obj);
 
diff --git a/blockjob.c b/blockjob.c
index 9e5fd5c..77940de 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -246,7 +246,7 @@  QObject *qobject_from_block_job(BlockJob *job)
 void block_job_ready(BlockJob *job)
 {
     QObject *data = qobject_from_block_job(job);
-    monitor_protocol_event(QEVENT_BLOCK_JOB_READY, data);
+    monitor_protocol_event(Q_EVENT_BLOCK_JOB_READY, data);
     qobject_decref(data);
 }
 
@@ -272,7 +272,8 @@  BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs,
     default:
         abort();
     }
-    bdrv_emit_qmp_error_event(job->bs, QEVENT_BLOCK_JOB_ERROR, action, is_read);
+    bdrv_emit_qmp_error_event(job->bs, Q_EVENT_BLOCK_JOB_ERROR,
+                              action, is_read);
     if (action == BDRV_ACTION_STOP) {
         block_job_pause(job);
         block_job_iostatus_set_err(job, error);
diff --git a/cpus.c b/cpus.c
index 398229e..1fe67d3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -530,7 +530,7 @@  static int do_vm_stop(RunState state)
         pause_all_vcpus();
         runstate_set(state);
         vm_state_notify(0, state);
-        monitor_protocol_event(QEVENT_STOP, NULL);
+        monitor_protocol_event(Q_EVENT_STOP, NULL);
     }
 
     bdrv_drain_all();
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 7138139..fbb8efb 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -511,7 +511,7 @@  static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
             break;
         default:
             if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */
-                monitor_protocol_event(QEVENT_SUSPEND_DISK, NULL);
+                monitor_protocol_event(Q_EVENT_SUSPEND_DISK, NULL);
                 qemu_system_shutdown_request();
             }
             break;
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 533f6dd..9dc1ac7 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -821,7 +821,7 @@  static void device_unparent(Object *obj)
         } else {
             event_data = qobject_from_jsonf("{ 'path': %s }", path);
         }
-        monitor_protocol_event(QEVENT_DEVICE_DELETED, event_data);
+        monitor_protocol_event(Q_EVENT_DEVICE_DELETED, event_data);
         qobject_decref(event_data);
         g_free(path);
     }
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index b64e3bb..192b60a 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -36,7 +36,7 @@  static void panicked_mon_event(const char *action)
     QObject *data;
 
     data = qobject_from_jsonf("{ 'action': %s }", action);
-    monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
+    monitor_protocol_event(Q_EVENT_GUEST_PANICKED, data);
     qobject_decref(data);
 }
 
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 22dbd05..c35cc8e 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -208,7 +208,7 @@  static void rxfilter_notify(NetClientState *nc)
             event_data = qobject_from_jsonf("{ 'path': %s }",
                                     object_get_canonical_path(OBJECT(n->qdev)));
         }
-        monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
+        monitor_protocol_event(Q_EVENT_NIC_RX_FILTER_CHANGED, event_data);
         qobject_decref(event_data);
 
         /* disable event notification to avoid events flooding */
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 387962e..4501685 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -105,7 +105,7 @@  static void watchdog_mon_event(const char *action)
     QObject *data;
 
     data = qobject_from_jsonf("{ 'action': %s }", action);
-    monitor_protocol_event(QEVENT_WATCHDOG, data);
+    monitor_protocol_event(Q_EVENT_WATCHDOG, data);
     qobject_decref(data);
 }
 
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 8b14a6f..b273c5b 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -21,39 +21,39 @@  extern Monitor *default_mon;
 
 /* QMP events */
 typedef enum QEvent {
-    QEVENT_SHUTDOWN,
-    QEVENT_RESET,
-    QEVENT_POWERDOWN,
-    QEVENT_STOP,
-    QEVENT_RESUME,
-    QEVENT_VNC_CONNECTED,
-    QEVENT_VNC_INITIALIZED,
-    QEVENT_VNC_DISCONNECTED,
-    QEVENT_BLOCK_IO_ERROR,
-    QEVENT_RTC_CHANGE,
-    QEVENT_WATCHDOG,
-    QEVENT_SPICE_CONNECTED,
-    QEVENT_SPICE_INITIALIZED,
-    QEVENT_SPICE_DISCONNECTED,
-    QEVENT_BLOCK_JOB_COMPLETED,
-    QEVENT_BLOCK_JOB_CANCELLED,
-    QEVENT_BLOCK_JOB_ERROR,
-    QEVENT_BLOCK_JOB_READY,
-    QEVENT_DEVICE_DELETED,
-    QEVENT_DEVICE_TRAY_MOVED,
-    QEVENT_NIC_RX_FILTER_CHANGED,
-    QEVENT_SUSPEND,
-    QEVENT_SUSPEND_DISK,
-    QEVENT_WAKEUP,
-    QEVENT_BALLOON_CHANGE,
-    QEVENT_SPICE_MIGRATE_COMPLETED,
-    QEVENT_GUEST_PANICKED,
-    QEVENT_BLOCK_IMAGE_CORRUPTED,
+    Q_EVENT_SHUTDOWN,
+    Q_EVENT_RESET,
+    Q_EVENT_POWERDOWN,
+    Q_EVENT_STOP,
+    Q_EVENT_RESUME,
+    Q_EVENT_VNC_CONNECTED,
+    Q_EVENT_VNC_INITIALIZED,
+    Q_EVENT_VNC_DISCONNECTED,
+    Q_EVENT_BLOCK_IO_ERROR,
+    Q_EVENT_RTC_CHANGE,
+    Q_EVENT_WATCHDOG,
+    Q_EVENT_SPICE_CONNECTED,
+    Q_EVENT_SPICE_INITIALIZED,
+    Q_EVENT_SPICE_DISCONNECTED,
+    Q_EVENT_BLOCK_JOB_COMPLETED,
+    Q_EVENT_BLOCK_JOB_CANCELLED,
+    Q_EVENT_BLOCK_JOB_ERROR,
+    Q_EVENT_BLOCK_JOB_READY,
+    Q_EVENT_DEVICE_DELETED,
+    Q_EVENT_DEVICE_TRAY_MOVED,
+    Q_EVENT_NIC_RX_FILTER_CHANGED,
+    Q_EVENT_SUSPEND,
+    Q_EVENT_SUSPEND_DISK,
+    Q_EVENT_WAKEUP,
+    Q_EVENT_BALLOON_CHANGE,
+    Q_EVENT_SPICE_MIGRATE_COMPLETED,
+    Q_EVENT_GUEST_PANICKED,
+    Q_EVENT_BLOCK_IMAGE_CORRUPTED,
 
     /* Add to 'monitor_event_names' array in monitor.c when
      * defining new events here */
 
-    QEVENT_MAX,
+    Q_EVENT_MAX,
 } QEvent;
 
 int monitor_cur_is_qmp(void);
diff --git a/monitor.c b/monitor.c
index 9377834..b2c64de 100644
--- a/monitor.c
+++ b/monitor.c
@@ -479,38 +479,38 @@  static void timestamp_put(QDict *qdict)
 
 
 static const char *monitor_event_names[] = {
-    [QEVENT_SHUTDOWN] = "SHUTDOWN",
-    [QEVENT_RESET] = "RESET",
-    [QEVENT_POWERDOWN] = "POWERDOWN",
-    [QEVENT_STOP] = "STOP",
-    [QEVENT_RESUME] = "RESUME",
-    [QEVENT_VNC_CONNECTED] = "VNC_CONNECTED",
-    [QEVENT_VNC_INITIALIZED] = "VNC_INITIALIZED",
-    [QEVENT_VNC_DISCONNECTED] = "VNC_DISCONNECTED",
-    [QEVENT_BLOCK_IO_ERROR] = "BLOCK_IO_ERROR",
-    [QEVENT_RTC_CHANGE] = "RTC_CHANGE",
-    [QEVENT_WATCHDOG] = "WATCHDOG",
-    [QEVENT_SPICE_CONNECTED] = "SPICE_CONNECTED",
-    [QEVENT_SPICE_INITIALIZED] = "SPICE_INITIALIZED",
-    [QEVENT_SPICE_DISCONNECTED] = "SPICE_DISCONNECTED",
-    [QEVENT_BLOCK_JOB_COMPLETED] = "BLOCK_JOB_COMPLETED",
-    [QEVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED",
-    [QEVENT_BLOCK_JOB_ERROR] = "BLOCK_JOB_ERROR",
-    [QEVENT_BLOCK_JOB_READY] = "BLOCK_JOB_READY",
-    [QEVENT_DEVICE_DELETED] = "DEVICE_DELETED",
-    [QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
-    [QEVENT_NIC_RX_FILTER_CHANGED] = "NIC_RX_FILTER_CHANGED",
-    [QEVENT_SUSPEND] = "SUSPEND",
-    [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
-    [QEVENT_WAKEUP] = "WAKEUP",
-    [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
-    [QEVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED",
-    [QEVENT_GUEST_PANICKED] = "GUEST_PANICKED",
-    [QEVENT_BLOCK_IMAGE_CORRUPTED] = "BLOCK_IMAGE_CORRUPTED",
+    [Q_EVENT_SHUTDOWN] = "SHUTDOWN",
+    [Q_EVENT_RESET] = "RESET",
+    [Q_EVENT_POWERDOWN] = "POWERDOWN",
+    [Q_EVENT_STOP] = "STOP",
+    [Q_EVENT_RESUME] = "RESUME",
+    [Q_EVENT_VNC_CONNECTED] = "VNC_CONNECTED",
+    [Q_EVENT_VNC_INITIALIZED] = "VNC_INITIALIZED",
+    [Q_EVENT_VNC_DISCONNECTED] = "VNC_DISCONNECTED",
+    [Q_EVENT_BLOCK_IO_ERROR] = "BLOCK_IO_ERROR",
+    [Q_EVENT_RTC_CHANGE] = "RTC_CHANGE",
+    [Q_EVENT_WATCHDOG] = "WATCHDOG",
+    [Q_EVENT_SPICE_CONNECTED] = "SPICE_CONNECTED",
+    [Q_EVENT_SPICE_INITIALIZED] = "SPICE_INITIALIZED",
+    [Q_EVENT_SPICE_DISCONNECTED] = "SPICE_DISCONNECTED",
+    [Q_EVENT_BLOCK_JOB_COMPLETED] = "BLOCK_JOB_COMPLETED",
+    [Q_EVENT_BLOCK_JOB_CANCELLED] = "BLOCK_JOB_CANCELLED",
+    [Q_EVENT_BLOCK_JOB_ERROR] = "BLOCK_JOB_ERROR",
+    [Q_EVENT_BLOCK_JOB_READY] = "BLOCK_JOB_READY",
+    [Q_EVENT_DEVICE_DELETED] = "DEVICE_DELETED",
+    [Q_EVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
+    [Q_EVENT_NIC_RX_FILTER_CHANGED] = "NIC_RX_FILTER_CHANGED",
+    [Q_EVENT_SUSPEND] = "SUSPEND",
+    [Q_EVENT_SUSPEND_DISK] = "SUSPEND_DISK",
+    [Q_EVENT_WAKEUP] = "WAKEUP",
+    [Q_EVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
+    [Q_EVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED",
+    [Q_EVENT_GUEST_PANICKED] = "GUEST_PANICKED",
+    [Q_EVENT_BLOCK_IMAGE_CORRUPTED] = "BLOCK_IMAGE_CORRUPTED",
 };
-QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
+QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != Q_EVENT_MAX)
 
-MonitorEventState monitor_event_state[QEVENT_MAX];
+MonitorEventState monitor_event_state[Q_EVENT_MAX];
 QemuMutex monitor_event_state_lock;
 
 /*
@@ -541,7 +541,7 @@  monitor_protocol_event_queue(QEvent event,
 {
     MonitorEventState *evstate;
     int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
-    assert(event < QEVENT_MAX);
+    assert(event < Q_EVENT_MAX);
 
     qemu_mutex_lock(&monitor_event_state_lock);
     evstate = &(monitor_event_state[event]);
@@ -618,7 +618,7 @@  monitor_protocol_event_throttle(QEvent event,
                                 int64_t rate)
 {
     MonitorEventState *evstate;
-    assert(event < QEVENT_MAX);
+    assert(event < Q_EVENT_MAX);
 
     evstate = &(monitor_event_state[event]);
 
@@ -640,9 +640,9 @@  static void monitor_protocol_event_init(void)
 {
     qemu_mutex_init(&monitor_event_state_lock);
     /* Limit RTC & BALLOON events to 1 per second */
-    monitor_protocol_event_throttle(QEVENT_RTC_CHANGE, 1000);
-    monitor_protocol_event_throttle(QEVENT_BALLOON_CHANGE, 1000);
-    monitor_protocol_event_throttle(QEVENT_WATCHDOG, 1000);
+    monitor_protocol_event_throttle(Q_EVENT_RTC_CHANGE, 1000);
+    monitor_protocol_event_throttle(Q_EVENT_BALLOON_CHANGE, 1000);
+    monitor_protocol_event_throttle(Q_EVENT_WATCHDOG, 1000);
 }
 
 /**
@@ -655,7 +655,7 @@  void monitor_protocol_event(QEvent event, QObject *data)
     QDict *qmp;
     const char *event_name;
 
-    assert(event < QEVENT_MAX);
+    assert(event < Q_EVENT_MAX);
 
     event_name = monitor_event_names[event];
     assert(event_name != NULL);
@@ -1069,7 +1069,7 @@  EventInfoList *qmp_query_events(Error **errp)
     EventInfoList *info, *ev_list = NULL;
     QEvent e;
 
-    for (e = 0 ; e < QEVENT_MAX ; e++) {
+    for (e = 0 ; e < Q_EVENT_MAX ; e++) {
         const char *event_name = monitor_event_names[e];
         assert(event_name != NULL);
         info = g_malloc0(sizeof(*info));
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 02ac4ba..b09a7d2 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -736,7 +736,7 @@  static int handle_intercept(S390CPU *cpu)
                     QObject *data;
 
                     data = qobject_from_jsonf("{ 'action': %s }", "pause");
-                    monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
+                    monitor_protocol_event(Q_EVENT_GUEST_PANICKED, data);
                     qobject_decref(data);
                     vm_stop(RUN_STATE_GUEST_PANICKED);
                 }
diff --git a/ui/spice-core.c b/ui/spice-core.c
index e4d533d..f3c6795 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -199,9 +199,9 @@  static void add_channel_info(QDict *dict, SpiceChannelEventInfo *info)
 static void channel_event(int event, SpiceChannelEventInfo *info)
 {
     static const int qevent[] = {
-        [ SPICE_CHANNEL_EVENT_CONNECTED    ] = QEVENT_SPICE_CONNECTED,
-        [ SPICE_CHANNEL_EVENT_INITIALIZED  ] = QEVENT_SPICE_INITIALIZED,
-        [ SPICE_CHANNEL_EVENT_DISCONNECTED ] = QEVENT_SPICE_DISCONNECTED,
+        [SPICE_CHANNEL_EVENT_CONNECTED]    = Q_EVENT_SPICE_CONNECTED,
+        [SPICE_CHANNEL_EVENT_INITIALIZED]  = Q_EVENT_SPICE_INITIALIZED,
+        [SPICE_CHANNEL_EVENT_DISCONNECTED] = Q_EVENT_SPICE_DISCONNECTED,
     };
     QDict *server, *client;
     QObject *data;
@@ -303,7 +303,7 @@  static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
 
 static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
 {
-    monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
+    monitor_protocol_event(Q_EVENT_SPICE_MIGRATE_COMPLETED, NULL);
     spice_migration_completed = true;
 }
 
diff --git a/ui/vnc.c b/ui/vnc.c
index 47fda54..b7c6f63 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1033,7 +1033,7 @@  void vnc_disconnect_finish(VncState *vs)
     vnc_jobs_join(vs); /* Wait encoding jobs */
 
     vnc_lock_output(vs);
-    vnc_qmp_event(vs, QEVENT_VNC_DISCONNECTED);
+    vnc_qmp_event(vs, Q_EVENT_VNC_DISCONNECTED);
 
     buffer_free(&vs->input);
     buffer_free(&vs->output);
@@ -2315,7 +2315,7 @@  static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
     vnc_flush(vs);
 
     vnc_client_cache_auth(vs);
-    vnc_qmp_event(vs, QEVENT_VNC_INITIALIZED);
+    vnc_qmp_event(vs, Q_EVENT_VNC_INITIALIZED);
 
     vnc_read_when(vs, protocol_client_msg, 1);
 
@@ -2819,7 +2819,7 @@  static void vnc_connect(VncDisplay *vd, int csock,
     }
 
     vnc_client_cache_addr(vs);
-    vnc_qmp_event(vs, QEVENT_VNC_CONNECTED);
+    vnc_qmp_event(vs, Q_EVENT_VNC_CONNECTED);
     vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING);
 
     vs->vd = vd;
diff --git a/vl.c b/vl.c
index b42ac67..6586072 100644
--- a/vl.c
+++ b/vl.c
@@ -746,7 +746,7 @@  void rtc_change_mon_event(struct tm *tm)
     QObject *data;
 
     data = qobject_from_jsonf("{ 'offset': %d }", qemu_timedate_diff(tm));
-    monitor_protocol_event(QEVENT_RTC_CHANGE, data);
+    monitor_protocol_event(Q_EVENT_RTC_CHANGE, data);
     qobject_decref(data);
 }
 
@@ -1699,7 +1699,7 @@  void vm_start(void)
         runstate_set(RUN_STATE_RUNNING);
         vm_state_notify(1, RUN_STATE_RUNNING);
         resume_all_vcpus();
-        monitor_protocol_event(QEVENT_RESUME, NULL);
+        monitor_protocol_event(Q_EVENT_RESUME, NULL);
     }
 }
 
@@ -1847,7 +1847,7 @@  void qemu_system_reset(bool report)
         qemu_devices_reset();
     }
     if (report) {
-        monitor_protocol_event(QEVENT_RESET, NULL);
+        monitor_protocol_event(Q_EVENT_RESET, NULL);
     }
     cpu_synchronize_all_post_reset();
 }
@@ -1868,7 +1868,7 @@  static void qemu_system_suspend(void)
     pause_all_vcpus();
     notifier_list_notify(&suspend_notifiers, NULL);
     runstate_set(RUN_STATE_SUSPENDED);
-    monitor_protocol_event(QEVENT_SUSPEND, NULL);
+    monitor_protocol_event(Q_EVENT_SUSPEND, NULL);
 }
 
 void qemu_system_suspend_request(void)
@@ -1929,7 +1929,7 @@  void qemu_system_shutdown_request(void)
 
 static void qemu_system_powerdown(void)
 {
-    monitor_protocol_event(QEVENT_POWERDOWN, NULL);
+    monitor_protocol_event(Q_EVENT_POWERDOWN, NULL);
     notifier_list_notify(&powerdown_notifiers, NULL);
 }
 
@@ -1967,7 +1967,7 @@  static bool main_loop_should_exit(void)
     }
     if (qemu_shutdown_requested()) {
         qemu_kill_report();
-        monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
+        monitor_protocol_event(Q_EVENT_SHUTDOWN, NULL);
         if (no_shutdown) {
             vm_stop(RUN_STATE_SHUTDOWN);
         } else {
@@ -1990,7 +1990,7 @@  static bool main_loop_should_exit(void)
         notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
         wakeup_reason = QEMU_WAKEUP_REASON_NONE;
         resume_all_vcpus();
-        monitor_protocol_event(QEVENT_WAKEUP, NULL);
+        monitor_protocol_event(Q_EVENT_WAKEUP, NULL);
     }
     if (qemu_powerdown_requested()) {
         qemu_system_powerdown();