All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] QMP event missed during startup
Date: Thu, 09 Nov 2017 15:14:36 +0100	[thread overview]
Message-ID: <87d14rfsj7.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20171030171814.GB5438@work-vm> (David Alan Gilbert's message of "Mon, 30 Oct 2017 17:18:15 +0000")

"Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:

> * Ross Lagerwall (ross.lagerwall@citrix.com) wrote:
>> Hi,
>> 
>> I have found an issue where QEMU emits the RESUME event during startup when
>> it starts VM execution, but it is not possible to receive this event.
>> 
>> To repro this, run:
>> qemu-system-i386 -m 256 -trace
>> enable=monitor_protocol_event_emit,file=/tmp/out -qmp
>> unix:/tmp/qmp,server,wait
>> 
>> QEMU will not start execution of the VM until something connects to the QMP
>> socket (e.g. qmp-shell). Once connected, no event is received on the QMP
>> connection but the tracepoint is hit indicating that an event has been
>> emitted. I suspect that the event is emitted while the QMP client is doing
>> the initial negotiation.
>> 
>> The reason I want to receive this event is that QEMU currently uses xenstore
>> to communicate this information to the Xen toolstack (see
>> xen-common.c:xen_change_state_handler) but we want to move to using QMP
>> rather than xenstore for this kind of thing.
>> 
>> Is this a known issue or just a bug that should be fixed?
>
> I'll leave it to Markus to say if it's a bug or not, but can't
> you work around this by starting qemu with -S which leaves the guest
> paused, and then continuing the guest when you have your QMP ?

You can:

<-- {"QMP": {"version": {"qemu": {"micro": 50, "minor": 10, "major": 2}, "package": " (v2.10.0-613-g10656079e1-dirty)"}, "capabilities": []}}
--> { "execute": "qmp_capabilities" }
<-- {"return": {}}
--> { "execute": "cont" }
<-- {"timestamp": {"seconds": 1510235984, "microseconds": 108550}, "event": "RESUME"}
<-- {"return": {}}

RESUME is sent in vm_prepare_start(), called from main() via vm_start(),
but only if @autostart, i.e. no -S.

The "wait" in the argument of -qmp makes QEMU wait for a QMP client to
connect to the QMP socket, long before vm_start() gets called.  However,
having connected is not sufficient for receiving events, you also have
to exit capabilities negotiation mode.  Not possible until QEMU is
running the main loop, which runs after the vm_start() quoted above.

If QMP monitors became usable before entering main_loop(), we'd have a
race condition instead.  The only reliable way to get the RESUME event
is -S.

This adds one minor item to the long list of reasons why management
software should pass -S.

All clear now?

  reply	other threads:[~2017-11-09 14:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30 10:50 [Qemu-devel] QMP event missed during startup Ross Lagerwall
2017-10-30 17:18 ` Dr. David Alan Gilbert
2017-11-09 14:14   ` Markus Armbruster [this message]
2017-11-10 10:43     ` Ross Lagerwall

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=87d14rfsj7.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ross.lagerwall@citrix.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.