From: Johannes Berg <johannes@sipsolutions.net>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org, "Michael S . Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [RFC] contrib: add vhost-user-sim
Date: Mon, 23 Sep 2019 11:33:41 +0200 [thread overview]
Message-ID: <24d18f1c38356b19461e77275b94a1ebf89838f1.camel@sipsolutions.net> (raw)
In-Reply-To: <20190923092548.GA26219@stefanha-x1.localdomain> (sfid-20190923_112553_080668_DB35AF28)
On Mon, 2019-09-23 at 10:25 +0100, Stefan Hajnoczi wrote:
>
> According to unix(7):
>
> The addrlen argument that describes the enclosing sockaddr_un
> structure should have a value of at least:
>
> offsetof(struct sockaddr_un, sun_path)+strlen(addr.sun_path)+1
>
> or, more simply, addrlen can be specified as sizeof(struct sockaddr_un).
>
> Please either increase len by 1 or use sizeof(struct sockaddr_un).
Good catch, I actually realized this later as I was porting it elsewhere
but forgot to update this code.
> g_new0() cannot return NULL, please remove this if statement.
:-)
Shows I don't work with glib much ...
> > +static int full_read(int fd, void *_buf, size_t len)
> > +{
> > + unsigned char *buf = _buf;
> > + ssize_t ret;
> > +
> > + do {
> > + ret = read(fd, buf, len);
> > + if (ret > 0) {
> > + buf += ret;
> > + len -= ret;
> > + } else if (ret == 0) {
> > + return 0;
> > + } else {
> > + return -errno;
> > + }
>
> Want to loop on EINTR?
Can we even get EINTR? We're not really expecting to deal with any
signals in this code, do we?
But I guess we can.
> > + switch (msg->op) {
> > + case UM_TIMETRAVEL_REQUEST:
> > + if (calendar_entry_remove(&conn->entry)) {
> > + conn->entry.time = conn->offset + msg->time;
> > + calendar_entry_add(&conn->entry);
> > + DPRINT(" %d | calendar entry added for %lld\n", conn->idx, msg->time);
> > + } else {
> > + conn->entry.time = conn->offset + msg->time;
> > + DPRINT(" %d | calendar entry time updated for %lld\n", conn->idx, msg->time);
> > + }
>
> Just checking the expected semantics:
>
> If the entry was already added, then we update the time and it stays
> scheduled. If the entry was not already added then we just stash away
> the time but don't schedule it?
Right.
The first case is the "normally running" case, where the request is
coming in after UM_TIMETRAVEL_WAIT but before we sent it
UM_TIMETRAVEL_RUN, i.e. when the sender of the message got an interrupt
from elsewhere and needs to change the next runtime.
The second case is when it's requesting before it went into
UM_TIMETRAVEL_WAIT, in which case we just want the entry to the calendar
to be added for when we actually get _WAIT.
> Also, are the DPRINT() messages swapped in the if ... else ... bodies?
> They seem to be talking about the other case.
Or better rephrased I guess :)
> > diff --git a/include/standard-headers/linux/um_timetravel.h b/include/standard-headers/linux/um_timetravel.h
> > new file mode 100644
> > index 000000000000..3aaced426a92
> > --- /dev/null
> > +++ b/include/standard-headers/linux/um_timetravel.h
> > @@ -0,0 +1,107 @@
>
> Please use scripts/update-linux-headers.sh to import this header file
> with the necessary conversions (e.g. #include <linux/types.h> ->
> #include "standard-headers/linux/types.h", __u64 -> uint64_t).
Hah, sure, wasn't aware of that.
Note, I'm not happy with this code at all, it deadlocks all the time.
Unfortunately I haven't really been able to figure out how to make glib
do what I wanted.
The first issue is that sometimes glib actually seems to reports an FD
as readable when it's not, so I even put them into non-blocking mode :(
The second is that I can't seem to understand how to do recursive
mainloops.
To really do this *well*, it should remain a single-threaded
application, but would need a hook like
run_mainloop_until_fd_readable(vdev->call_fd)
inside the libvhost-user.c code, and that's a bit ugly ... if I even
could figure out how to implement that in glib.
johannes
next prev parent reply other threads:[~2019-09-23 9:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-17 12:26 [Qemu-devel] [RFC] contrib: add vhost-user-sim Johannes Berg
2019-09-17 18:51 ` no-reply
2019-09-17 19:01 ` no-reply
2019-09-17 19:02 ` no-reply
2019-09-23 9:25 ` Stefan Hajnoczi
2019-09-23 9:33 ` Johannes Berg [this message]
2019-10-09 14:00 ` Stefan Hajnoczi
2019-10-09 15:01 ` Johannes Berg
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=24d18f1c38356b19461e77275b94a1ebf89838f1.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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 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).