kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: "Geneviève Bastien" <gbastien@versatic.net>, kvm <kvm@vger.kernel.org>
Subject: Re: Shared value between host and guests
Date: Mon, 29 Jan 2018 10:18:46 +0000	[thread overview]
Message-ID: <20180129101846.GA20138@stefanha-x1.localdomain> (raw)
In-Reply-To: <CANRm+CxbLJjR82B=GfQjJ+NwK3+rGy7tnMEu-BUxfpp5vaDbFA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3034 bytes --]

On Mon, Jan 29, 2018 at 08:59:16AM +0800, Wanpeng Li wrote:
> 2018-01-26 22:03 GMT+08:00 Stefan Hajnoczi <stefanha@gmail.com>:
> > On Thu, Jan 25, 2018 at 10:44:12AM -0500, Geneviève Bastien wrote:
> >> On 2018-01-25 04:29 AM, Stefan Hajnoczi wrote:
> >> > On Wed, Jan 24, 2018 at 10:56:26AM -0500, Geneviève Bastien wrote:
> >> >> Thanks for the hint, I didn't know about those. But the uevents are only
> >> >> for the host right? There is no specific value in debugfs for guest.
> >> > I'm not sure I understand the question.
> >> >
> >> > Uevent are emitted on the host.  Given the PID field, it should be
> >> > possible to correlate them to a specific guest (e.g. by looking at
> >> > information from the user or VM management tools, or simply by looking
> >> > at /proc/$PID/cmdline for the QEMU -name argument that can be used to
> >> > identify guests on the host side).
> >> >
> >> > Stefan
> >> With the information from the host and those uevents, we can indeed
> >> easily figure out in our traces which processes are associated with a
> >> guest and get its command line and a lot more information.
> >>
> >> The missing piece is in the guest trace. For example, we have lttng
> >> traces taken on the guest and the host. We may have multiple guests and
> >> multiple hosts to trace. It's easy to know which traces are from hosts
> >> from the events, but which are from guests? And which guest trace goes
> >> with which of the kvm processes on which host? The guest trace contains
> >> no information that can be linked to the host.
> >>
> >> I was thinking that the guest could do a hypercall to the host after
> >> bootup to share some unique information, for instance its bootid, that
> >> the host could store somewhere. That information would be available in
> >> the traces so that we can easily associate the guest with its host
> >> process and the states of its virtual CPUs to that of the corresponding
> >> threads, and much more.
> >>
> >> I hope this describes our need a little better.
> >
> > The QEMU -uuid <uuid> option makes a UUID available to the guest via
> > SMBIOS and fw_cfg on x86.  Inside the guest you can print it like this:
> >
> >   # dmidecode -s system-uuid
> >   01020304-0506-0708-090A-0B0C0D0E0F10
> >
> > Maybe you can base the guest trace filename off the UUID:
> >
> >   guest-01020304-0506-0708-090A-0B0C0D0E0F10-trace-001.dat
> >
> > On the host you can either find the UUIDs in the libvirt domain XML:
> >
> >   # virsh dump my-domain
> >   <domain ...>
> >     <uuid>0102030405060708090a0b0c0d0e0f10</uuid>
> >     ...
> >
> > Or you can use the kvm.ko uevent to find the QEMU PID and then check
> 
> How to use the kvm.ko uevent to find the QEMU PID?

Add a udev rule on the host for kvm.ko EVENT=create/destroy events.
These events have a PID=<pid> field that a script can use to record the
QEMU instance that is associated with this guest.

Please see virt/kvm/kvm_main.c:kvm_uevent_notify_change().

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2018-01-29 10:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 20:03 Shared value between host and guests Genevieve Bastien
2018-01-23 17:21 ` Stefan Hajnoczi
2018-01-24 15:56   ` Geneviève Bastien
2018-01-25  9:29     ` Stefan Hajnoczi
2018-01-25 15:44       ` Geneviève Bastien
2018-01-26 14:03         ` Stefan Hajnoczi
2018-01-29  0:59           ` Wanpeng Li
2018-01-29 10:18             ` Stefan Hajnoczi [this message]
2018-01-29 17:45           ` Geneviève Bastien

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=20180129101846.GA20138@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=gbastien@versatic.net \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.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).