From: Stefan Hajnoczi <stefanha@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Amit Shah <amit@kernel.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] virtio-rng: stop virtqueue while the CPU is stopped
Date: Wed, 12 Apr 2017 10:57:31 +0100 [thread overview]
Message-ID: <20170412095731.GA26272@stefanha-x1.localdomain> (raw)
In-Reply-To: <560dec08-1b57-9850-ff30-5f326130a59d@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1464 bytes --]
On Tue, Apr 11, 2017 at 07:42:02PM +0200, Laurent Vivier wrote:
> On 11/04/2017 19:02, Stefan Hajnoczi wrote:
> > On Tue, Apr 11, 2017 at 03:17:33PM +0200, Laurent Vivier wrote:
> >> diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
> >> index 9639f4e..d270d56 100644
> >> --- a/hw/virtio/virtio-rng.c
> >> +++ b/hw/virtio/virtio-rng.c
> >> @@ -53,6 +53,15 @@ static void chr_read(void *opaque, const void *buf, size_t size)
> >> return;
> >> }
> >>
> >> + /* we can't modify the virtqueue until
> >> + * our state is fully synced
> >> + */
> >> +
> >> + if (!runstate_check(RUN_STATE_RUNNING)) {
> >> + trace_virtio_rng_cpu_is_stopped(vrng);
> >> + return;
> >> + }
> >> +
> >
> > I'm concerned about what happens when the guest is stopped and resumed
> > (e.g. 'stop' and 'cont' monitor commands). Since we throw away the
> > chr_read() callback the device will hang unless the guest kicks it
> > again?
> >
> > It's not clear to me that the rate limit timer will help us...
>
> I think you're right (even if it seems hard to generate this case)
>
> What is the best solution:
>
> - re-arming the timer/the backend request by calling
> virtio_rng_process() before the "return;"
This would waste CPU and throw away entropy bits.
> or
>
> - adding a vmstate change handler to call virtio_rng_process()?
Yes, I think vm change handlers solve the problem.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2017-04-12 9:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-11 13:17 [Qemu-devel] [PATCH 0/2] migration: fix virtio-rng Laurent Vivier
2017-04-11 13:17 ` [Qemu-devel] [PATCH 1/2] migration: don't close a file descriptor while it can be in use Laurent Vivier
2017-04-11 13:17 ` [Qemu-devel] [PATCH 2/2] virtio-rng: stop virtqueue while the CPU is stopped Laurent Vivier
2017-04-11 17:02 ` Stefan Hajnoczi
2017-04-11 17:42 ` Laurent Vivier
2017-04-12 9:57 ` Stefan Hajnoczi [this message]
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=20170412095731.GA26272@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=amit@kernel.org \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@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).