public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "jlebon at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug runtime/13078] investigate qemu virtio-serial channel for talking to stap-sh
Date: Fri, 09 Aug 2013 18:17:00 -0000	[thread overview]
Message-ID: <bug-13078-6586-jUBttS4t0M@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-13078-6586@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=13078

Jonathan Lebon <jlebon at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlebon at redhat dot com

--- Comment #3 from Jonathan Lebon <jlebon at redhat dot com> ---
<brain_dump>

I'm currently working on making this work with virtio-serial. However, there
are two peculiarities of virtio-serial to be aware of:

(1) There is no way for the host to know if/when the guest is connected. In our
case specifically, when stapsh exits, stap doesn't get EOF at its fgets() or
fread(). It just hangs there. This is by design since the virtio-serial ports
are meant to be hot-pluggable.

(2) There can be old data left on the virtio-serial buffer. If stapsh ended
abruptly for some reason and didn't read all the data from
/dev/virtio-ports/systemtap.0, then the next stapsh session will pick up that
data. Similarly, stap has to be ready to read garbage from /tmp/foo before
reaching messages from the current stapsh session.

To work around (1), we can make stapsh send a QUITTING message to stap before
exiting. However, this would be indistinguishable from a possible output from
staprun. One way around this is to prepend all the output from staprun with
"staprun:" and replies/messages from stapsh (such as the OK acks) with
"stapsh:". This would also mean always reading from /tmp/foo line-by-line
rather than in blocks, regardless of --remote-prefix.

To work around (2), we can use a synchronization scheme in which the handshake
also includes a unique/random token, which is then used throughout the session.

I'm currently working on these workarounds.

Finally, I'm also thinking about adding a -d option to stapsh so that it acts
as a daemon, i.e. constantly waiting for input on the virtio-serial port (this
would be a bit harder than just calling read() since, as mentioned in (1),
read() will just return EOF if stap hasn't opened the socket yet -- I may have
a resolution for this without having to resort to using the KVM virtio-serial's
API).

And to bring it all together, have a script/small app which can modify
libvirt-managed VMs using virsh/libvirt API/libxml to add/verify proper
virtio-serial port setup, as well as somehow setting up a systemd service for
stapsh, possibly using libguestfs to modify the harddrive directly. This small
app could even down the road be used to do something like

stap --remote vm:VM_NAME

and it would take care of looking into the VM's configuration to find the UNIX
socket's path. This is actually what libguestfs does currently.

For non-libvirt-managed VMs, we can just document the command-line that users
need to add to the qemu invocation.

</brain_dump>

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2013-08-09 18:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11 18:21 [Bug runtime/13078] New: " fche at redhat dot com
2011-08-17  0:42 ` [Bug runtime/13078] " jistone at redhat dot com
2011-08-17  0:43 ` jistone at redhat dot com
2011-08-17 22:54 ` jistone at redhat dot com
2013-08-09 18:17 ` jlebon at redhat dot com [this message]
2013-08-20 21:40 ` jistone at redhat dot com
2013-08-21 13:29 ` fche at redhat dot com
2013-08-21 14:00 ` jlebon at redhat dot com
2013-08-21 17:32 ` jistone at redhat dot com
2013-08-26 18:07 ` jlebon at redhat dot com
2013-08-27 16:20 ` jlebon at redhat dot com
2013-08-28 16:21 ` jlebon at redhat dot com
2013-08-30 20:37 ` jlebon at redhat dot com
2013-09-04 16:18 ` jlebon at redhat dot com
2013-09-11 18:49 ` jlebon at redhat dot com
2013-09-24 21:23 ` jlebon at redhat dot com
2013-09-26 20:54 ` jlebon at redhat dot com
2013-10-18 14:26 ` jlebon at redhat dot com

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=bug-13078-6586-jUBttS4t0M@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).