qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qmp: report TRAY_STATE_CHANGED events
Date: Tue, 25 Oct 2011 16:44:11 -0200	[thread overview]
Message-ID: <20111025164411.41770e46@doriath> (raw)
In-Reply-To: <1319560018-25788-1-git-send-email-pbonzini@redhat.com>

On Tue, 25 Oct 2011 18:26:58 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  QMP/qmp-events.txt |   20 ++++++++++++++++++++
>  block.c            |    9 +++++++++
>  monitor.c          |    3 +++
>  monitor.h          |    1 +
>  4 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
> index 0ce5d4e..242c7a5 100644
> --- a/QMP/qmp-events.txt
> +++ b/QMP/qmp-events.txt
> @@ -264,3 +264,23 @@ Example:
>  
>  Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is
>  followed respectively by the RESET, SHUTDOWN, or STOP events.
> +
> +
> +TRAY_STATE_CHANGED
> +------------------
> +
> +Emitted when the state of a CD-ROM tray changes.
> +
> +Data:
> +
> +- "device": device name (json-string)
> +- "state": state of the tray, one of the following (json-string)
> +   "open": tray is open
> +   "closed": tray is closed

Wouldn't be better to make this a bool?

CC'ing the block guys to get ACKs from them too.

> +
> +Example:
> +
> +{ "event": "TRAY_STATE_CHANGED",
> +    "data": { "device": "ide0-cd0",
> +              "state": "open" },
> +    "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
> diff --git a/block.c b/block.c
> index 9873b57..7b0aa62 100644
> --- a/block.c
> +++ b/block.c
> @@ -2968,10 +2968,19 @@ int bdrv_media_changed(BlockDriverState *bs)
>  void bdrv_eject(BlockDriverState *bs, int eject_flag)
>  {
>      BlockDriver *drv = bs->drv;
> +    QObject *data;
>  
>      if (drv && drv->bdrv_eject) {
>          drv->bdrv_eject(bs, eject_flag);
>      }
> +
> +    if (*bs->device_name) {
> +        data = qobject_from_jsonf("{ 'device': %s, 'state': %s }",
> +                                  bs->device_name,
> +                                  eject_flag ? "open" : "closed");
> +        monitor_protocol_event(QEVENT_TRAY_STATE_CHANGED, data);
> +        qobject_decref(data);
> +    }
>  }
>  
>  /**
> diff --git a/monitor.c b/monitor.c
> index ffda0fe..516a789 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -482,6 +482,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
>          case QEVENT_SPICE_DISCONNECTED:
>              event_name = "SPICE_DISCONNECTED";
>              break;
> +        case QEVENT_TRAY_STATE_CHANGED:
> +            event_name = "TRAY_STATE_CHANGED";
> +            break;
>          default:
>              abort();
>              break;
> diff --git a/monitor.h b/monitor.h
> index 4f2d328..b8f4bf7 100644
> --- a/monitor.h
> +++ b/monitor.h
> @@ -35,6 +35,7 @@ typedef enum MonitorEvent {
>      QEVENT_SPICE_CONNECTED,
>      QEVENT_SPICE_INITIALIZED,
>      QEVENT_SPICE_DISCONNECTED,
> +    QEVENT_TRAY_STATE_CHANGED,
>      QEVENT_MAX,
>  } MonitorEvent;
>  

  reply	other threads:[~2011-10-25 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25 16:26 [Qemu-devel] [PATCH] qmp: report TRAY_STATE_CHANGED events Paolo Bonzini
2011-10-25 18:44 ` Luiz Capitulino [this message]
2011-11-01  5:03 ` ShaoHe Feng
2011-11-04 10:53   ` Paolo Bonzini
2011-11-04 17:25     ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111025164411.41770e46@doriath \
    --to=lcapitulino@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).