From: Victor Kaplansky <victork@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marc-Andre Lureau <mlureau@redhat.com>,
qemu-devel@nongnu.org, peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4] tests/vhost-user-bridge: implement logging of dirty pages
Date: Tue, 17 Nov 2015 13:40:12 +0200 [thread overview]
Message-ID: <20151117133456-mutt-send-email-victork@redhat.com> (raw)
In-Reply-To: <20151117130042-mutt-send-email-mst@redhat.com>
On Tue, Nov 17, 2015 at 01:04:33PM +0200, Michael S. Tsirkin wrote:
> On Tue, Nov 17, 2015 at 12:04:06PM +0200, Victor Kaplansky wrote:
> > During migration devices continue writing to the guest's memory.
> > The writes has to be reported to QEMU. This change implements
> > minimal support in vhost-user-bridge required for successful
> > migration of a guest with virtio-net device.
> >
> > Signed-off-by: Victor Kaplansky <victork@redhat.com>
> > ---
> > v4:
> > - implement set_vring_enable()
> > - stop the device on vubr_get_vring_base_exec() and
> > start on setting kick_fd as a work-around to QEMU bug
> > enabling vrings too early.
>
> You do want to address that FIXME but at least it's
> a documented bug.
>
> > v3:
> > - Get rid of vhost_log_chunk_t. Just use uint8_t.
> > - Implement vubr_set_log_fd_exec().
> > - Kick the log if log_call_fd has been set up.
> > - Mark bits in log table atomically to enable more then one
> > simultaneous vhost-user backend.
> > - Fix the calculations of required log table size in an
> > assert.
> > - Fix the coding style: only single space before assignment
> > operator.
> > - Add a comment on the hack to determine that queues are
> > ready for processing.
> > - Other minor cosmetic fixes.
> > v2:
> > - use log_guest_addr for used ring reported by qemu instead of
> > translating.
> > - use mmap_size and mmap_offset defined in new
> > VHOST_USER_SET_LOG_BASE interface. See the patch
> > "vhost-user: modify SET_LOG_BASE to pass mmap size and
> > offset".
> > - start logging dirty pages only after the appropriate feature
> > is set by a VHOST_USER_GET_PROTOCOL_FEATURES request.
> > - updated TODO list.
> >
> > tests/vhost-user-bridge.c | 220 ++++++++++++++++++++++++++++++++++++++++------
> > 1 file changed, 195 insertions(+), 25 deletions(-)
> >
> > diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
> > index 864f69e..7bdfc98 100644
> > --- a/tests/vhost-user-bridge.c
> > +++ b/tests/vhost-user-bridge.c
> > @@ -466,11 +507,39 @@ vubr_virtqueue_kick(VubrVirtq *vq)
> > }
> >
> > static void
> > +vubr_log_page(uint8_t *log_table, uint64_t page)
> > +{
> > + DPRINT("Logged dirty guest page: %"PRId64"\n", page);
> > + atomic_or(&log_table[page / 8], 1 << (page % 8));
>
> One thing you definitely want here is a check
> against log size.
> Otherwise it's a security hole:
> remote can corrupt your memory by making you
> set random bits outside the mapped buffer.
>
> What to do on error? Probably abort.
>
vubr_log_write() has an assert checking the address.
In the next version I'll replace if by an if statement.
> > +}
> > +
> > +static void
> > +vubr_log_write(VubrDev *dev, uint64_t address, uint64_t length)
> > +{
> > + uint64_t page;
> > +
> > + if (!(dev->features & (1ULL << VHOST_F_LOG_ALL)) ||
> > + !dev->log_table || !length) {
> > + return;
> > + }
> > +
> > + assert(dev->log_size > ((address + length - 1) / VHOST_LOG_PAGE / 8));
> > +
> > + page = address / VHOST_LOG_PAGE;
> > + while (page * VHOST_LOG_PAGE < address + length) {
> > + vubr_log_page(dev->log_table, page);
> > + page += VHOST_LOG_PAGE;
> > + }
> > + vubr_log_kick(dev);
> > +}
> > +
-- Victor
next prev parent reply other threads:[~2015-11-17 11:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 10:04 [Qemu-devel] [PATCH v4] tests/vhost-user-bridge: implement logging of dirty pages Victor Kaplansky
2015-11-17 11:04 ` Michael S. Tsirkin
2015-11-17 11:40 ` Victor Kaplansky [this message]
2015-11-17 12:34 ` Michael S. Tsirkin
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=20151117133456-mutt-send-email-victork@redhat.com \
--to=victork@redhat.com \
--cc=mlureau@redhat.com \
--cc=mst@redhat.com \
--cc=peterx@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).