* Shared value between host and guests @ 2018-01-19 20:03 Genevieve Bastien 2018-01-23 17:21 ` Stefan Hajnoczi 0 siblings, 1 reply; 9+ messages in thread From: Genevieve Bastien @ 2018-01-19 20:03 UTC (permalink / raw) To: kvm Hi, I'm tracing kvm guests and their host and an issue we have is to identify which host process corresponds to which guest trace so we can follow the state of the virtual cpu on the host. For our needs, we fixed this problem by adding a kernel module on host and guest where hosts and guests make an hypercall received by the other and sending a UID between them. By tracing those hypercalls and tracking the uid value, we can know which thread on the host corresponds to which guest machine. But we would like to achieve this without having to add an additional module for tracing purposes. I'm wondering if there's already a value somewhere in the kernel that is uniquely shared between the host process/threads and the corresponding guest. And if not, would it be possible/desirable to add one? For instance, the bootid of the guest could be sent to the host process at the start and stored in some system file. The trace could then retrieve it and the analysis can figure out who's who all the traces. Fyi, this is the kind of virtual machine analyses we can obtain by tracing guest and host: http://archive.eclipse.org/tracecompass.incubator/doc/org.eclipse.tracecompass.incubator.virtual.machine.analysis.doc.user/Virtual-Machine-Analysis-User-Documentation.html We have more, but it is not yet documented unfortunately. Thanks, Geneviève ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 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 0 siblings, 1 reply; 9+ messages in thread From: Stefan Hajnoczi @ 2018-01-23 17:21 UTC (permalink / raw) To: Genevieve Bastien; +Cc: kvm [-- Attachment #1: Type: text/plain, Size: 497 bytes --] On Fri, Jan 19, 2018 at 03:03:25PM -0500, Genevieve Bastien wrote: > I'm tracing kvm guests and their host and an issue we have is to > identify which host process corresponds to which guest trace so we can > follow the state of the virtual cpu on the host. There are uevents for the VM lifecycle that include the PID. Please see Linux commit 286de8f6ac9202f1c9012784639156c6ec386eb8 & fdeaf7e3eb37c6dbc4b4ac97dbe1945d239eb788. Did you check if these are appropriate for your use case? Stefan [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 455 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 2018-01-23 17:21 ` Stefan Hajnoczi @ 2018-01-24 15:56 ` Geneviève Bastien 2018-01-25 9:29 ` Stefan Hajnoczi 0 siblings, 1 reply; 9+ messages in thread From: Geneviève Bastien @ 2018-01-24 15:56 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: kvm On 2018-01-23 12:21 PM, Stefan Hajnoczi wrote: > On Fri, Jan 19, 2018 at 03:03:25PM -0500, Genevieve Bastien wrote: >> I'm tracing kvm guests and their host and an issue we have is to >> identify which host process corresponds to which guest trace so we can >> follow the state of the virtual cpu on the host. > There are uevents for the VM lifecycle that include the PID. Please see > Linux commit 286de8f6ac9202f1c9012784639156c6ec386eb8 & > fdeaf7e3eb37c6dbc4b4ac97dbe1945d239eb788. > > Did you check if these are appropriate for your use case? 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. But I'll see if I can use some udev rules to trigger <some-kvm-tracing-script> to achieve what I need. Thanks, Geneviève ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 2018-01-24 15:56 ` Geneviève Bastien @ 2018-01-25 9:29 ` Stefan Hajnoczi 2018-01-25 15:44 ` Geneviève Bastien 0 siblings, 1 reply; 9+ messages in thread From: Stefan Hajnoczi @ 2018-01-25 9:29 UTC (permalink / raw) To: Geneviève Bastien; +Cc: kvm [-- Attachment #1: Type: text/plain, Size: 1165 bytes --] On Wed, Jan 24, 2018 at 10:56:26AM -0500, Geneviève Bastien wrote: > On 2018-01-23 12:21 PM, Stefan Hajnoczi wrote: > > On Fri, Jan 19, 2018 at 03:03:25PM -0500, Genevieve Bastien wrote: > >> I'm tracing kvm guests and their host and an issue we have is to > >> identify which host process corresponds to which guest trace so we can > >> follow the state of the virtual cpu on the host. > > There are uevents for the VM lifecycle that include the PID. Please see > > Linux commit 286de8f6ac9202f1c9012784639156c6ec386eb8 & > > fdeaf7e3eb37c6dbc4b4ac97dbe1945d239eb788. > > > > Did you check if these are appropriate for your use case? > 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 455 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 2018-01-25 9:29 ` Stefan Hajnoczi @ 2018-01-25 15:44 ` Geneviève Bastien 2018-01-26 14:03 ` Stefan Hajnoczi 0 siblings, 1 reply; 9+ messages in thread From: Geneviève Bastien @ 2018-01-25 15:44 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: kvm 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. Thanks, Geneviève (tahini on irc) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 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 17:45 ` Geneviève Bastien 0 siblings, 2 replies; 9+ messages in thread From: Stefan Hajnoczi @ 2018-01-26 14:03 UTC (permalink / raw) To: Geneviève Bastien; +Cc: kvm [-- Attachment #1: Type: text/plain, Size: 2836 bytes --] 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 /proc/$PID/cmdline for the uuid. The UUID can also be fetched via the query-uuid QMP command if you don't want to search /proc/$PID/cmdline for -uuid <uuid>. Maybe you can base the host trace filename off the UUID too: host-01020304-0506-0708-090A-0B0C0D0E0F10-trace-001.dat Then the ask of correlating traces becomes pretty easy for post-processing scripts since they can look at the filenames. Stefan [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 455 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 2018-01-26 14:03 ` Stefan Hajnoczi @ 2018-01-29 0:59 ` Wanpeng Li 2018-01-29 10:18 ` Stefan Hajnoczi 2018-01-29 17:45 ` Geneviève Bastien 1 sibling, 1 reply; 9+ messages in thread From: Wanpeng Li @ 2018-01-29 0:59 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: Geneviève Bastien, kvm 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? Regards, Wanpeng Li ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 2018-01-29 0:59 ` Wanpeng Li @ 2018-01-29 10:18 ` Stefan Hajnoczi 0 siblings, 0 replies; 9+ messages in thread From: Stefan Hajnoczi @ 2018-01-29 10:18 UTC (permalink / raw) To: Wanpeng Li; +Cc: Geneviève Bastien, kvm [-- 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 --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Shared value between host and guests 2018-01-26 14:03 ` Stefan Hajnoczi 2018-01-29 0:59 ` Wanpeng Li @ 2018-01-29 17:45 ` Geneviève Bastien 1 sibling, 0 replies; 9+ messages in thread From: Geneviève Bastien @ 2018-01-29 17:45 UTC (permalink / raw) To: Stefan Hajnoczi; +Cc: kvm On 2018-01-26 09:03 AM, Stefan Hajnoczi wrote: > > 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 > /proc/$PID/cmdline for the uuid. The UUID can also be fetched via the > query-uuid QMP command if you don't want to search /proc/$PID/cmdline > for -uuid <uuid>. > > Maybe you can base the host trace filename off the UUID too: > > host-01020304-0506-0708-090A-0B0C0D0E0F10-trace-001.dat > > Then the ask of correlating traces becomes pretty easy for > post-processing scripts since they can look at the filenames. > > Stefan I think this approach would work. Requiring users to set a uuid to their VM if they plan on tracing it doesn't seem too bad a requirement. Thanks for your help, Geneviève ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-01-29 17:45 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2018-01-29 17:45 ` Geneviève Bastien
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).