All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 00/26] VM introspection
@ 2020-04-15  0:59 Adalbert Lazăr
  2020-04-15  0:59 ` [RFC PATCH v1 01/26] chardev: tcp: allow to change the reconnect timer Adalbert Lazăr
                   ` (27 more replies)
  0 siblings, 28 replies; 46+ messages in thread
From: Adalbert Lazăr @ 2020-04-15  0:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Tamas K Lengyel, Eduardo Habkost, Konrad Rzeszutek Wilk,
	Jan Kiszka, Samuel Laurén, Michael S. Tsirkin,
	Markus Armbruster, Adalbert Lazăr, Juan Quintela,
	Patrick Colp, Mathieu Tarral, Stefan Hajnoczi,
	Marc-André Lureau, Marian Rotariu, Paolo Bonzini,
	Mihai Donțu, Dr. David Alan Gilbert, Richard Henderson

The KVM introspection subsystem provides a facility for applications
running on the host or in a separate VM, to control the execution of
other VMs (pause, resume, shutdown), query the state of the vCPUs (GPRs,
MSRs etc.), alter the page access bits in the shadow page tables (only
for the hardware backed ones, eg. Intel's EPT) and receive notifications
when events of interest have taken place (shadow page table level faults,
key MSR writes, hypercalls etc.).

This is the userspace part of the KVM introspection API already posted
on the KVM list[1]. Thanks to Samuel Laurén and Mathieu Tarral, this
new VMI API has been integrated into the KVM-VMI[2] project. The pull
request into the libVMI[3] library is under review.

As suggested by Stefan Hajnoczi and Paolo Bonzini, the connection with the
introspection tool is initiated by the QEMU process of the introspected VM
using a socket. After the handshake, QEMU will hand over the file
descriptor to KVM. From this point, the introspection tool will use
the socket to send introspection commands (read/write guest memory, set
page access, etc.) directly to KVM and to receive introspection events
(breakpoint, page fault, etc.). However, for some user actions such
as pause, suspend, live migration, etc., we rely on QEMU to notify KVM,
that will notify the introspection tool, to remove the changes made to
the guest, so that the guest can run when the introspection channel
is disconnected.

The patches were tested with QEMU 2.12 (through libvirt 1.3.1) and
summarly tested with 5.0.0-rc2, except for the last two patches (25
and 26) which were not tested at all, but still included for the initial
feedback.

Patches 01-06 add some extensions to the current code, which may or
may not be needed for the next patches, but we're looking forward for your
comments about these. Except for patch 6, all are chardev/socket related.

Patch 07 adds the KVM ioctls for VM introspection:
  - KVM_INTROSPECTION_HOOK used to hand over the file descriptor
  - KVM_INTROSPETION_PREUNHOOK used on pause/suspend/live migration
  - KVM_INTROSPECTION_UNHOOK used to clean-up the introspection structures
    from KVM
  - KVM_INTROSPECTION_COMMAND and KVM_INTROSPECTION_EVENT used to mark the
    the introspection commands/events that are allowed.

Patch 08 and 09 introduce the newly added introspection object. Patch 08
contains the usage documenation of this object with all the parameters
that will be added by the next patches. We've tested the creation of
this object through QMP/libvirt and we rely on this to start the VM
introspection for any running VM.

Patches 10-12 add the handshake, the authentication of the introspection
tool and the hand over to KVM.

Patches 13-15 add some safe guards (block the destruction of the
introspection object if the introspection socket is connected and
allow only one instance of the introspection object) and force the
socket reconnection on guest reset. Blocking the destruction of the
introspection object might not be enough, because we also want to block
the destruction of the introspection socket. Or it might be too much,
because this can be done through QMP, and whoever has access to it
may crash the guest in multiple ways.

Patches 16-17 add the first intercepted commands (pause/resume) and
introduce one of the method we use to delay intercepted commands
until the introspection tool has a chance to react.

Patch 18 adds the information we save with the VM snapshot,
the VM start time.

Patches 19-20 add the interception of force-reset and live migration
commands.

Patch 21 adds an workaround to block the snapshots with memory done by
libvirt until the introspection tool has a chance to react. It hasn't
been tested with 5.0.0-rc2. For 2.12 the patch is slightly bigger.

Patch 22 adds a second method of delaying the intercepted commands,
by running the main loop.

Patches 23-24 add the interception of the shutdown command, which doesn't
seems to be done right because the shutdown signal might not be delivered
to the guest, not to mention that is desirable to catch all sources that
my trigger the shudown.

Patch 25, which is not tested, extends the handshake structures to send
the e820 table (for the x86* architectures).

Patch 26, adds the properties to control what introspection commands
and what introspection events are allowed for this guest.

[1]: https://lore.kernel.org/kvm/20200330101308.21702-1-alazar@bitdefender.com/
[2]: https://github.com/KVM-VMI/kvm-vmi
[3]: https://github.com/libvmi/libvmi

Adalbert Lazăr (20):
  chardev: tcp: allow to change the reconnect timer
  char-socket: allow vsock parameters (cid, port)
  char-socket: fix the client mode when created through QMP
  char-socket: add 'reconnecting' property
  char-socket: add 'fd' property
  E820: extend the table access interface
  linux-headers: update with VM introspection interface
  kvm: introduce the VM introspection object
  kvm: vmi: add the handshake with the introspection tool
  kvm: vmi: add 'handshake_timeout' property
  kvm: vmi: add 'key' property
  kvm: vmi: block the object destruction if the chardev is connected
  kvm: vmi: allow only one instance of the introspection object
  kvm: vmi: add 'unhook_timeout' property
  kvm: vmi: store/restore 'vm_start_time' on migrate/snapshot
  kvm: vmi: postpone the OK response from qmp_stop()
  kvm: vmi: add 'async_unhook' property
  kvm: vmi: add 'unhook_on_shutdown' property
  kvm: vmi: extend handshake to include the e820 table
  kvm: vmi: add 'command' and 'event' properties

Marian Rotariu (6):
  kvm: add VM introspection usage documentation
  kvm: vmi: reconnect the socket on reset
  kvm: vmi: intercept pause/resume
  kvm: vmi: intercept force-reset
  kvm: vmi: intercept live migration
  kvm: vmi: intercept shutdown

 accel/kvm/Makefile.objs        |    1 +
 accel/kvm/vmi.c                | 1091 ++++++++++++++++++++++++++++++++
 accel/stubs/Makefile.objs      |    1 +
 accel/stubs/vmi-stubs.c        |   14 +
 chardev/char-fe.c              |   11 +
 chardev/char-socket.c          |   72 ++-
 chardev/char.c                 |    3 +
 hw/i386/e820_memory_layout.c   |   12 +
 hw/i386/e820_memory_layout.h   |    2 +
 include/chardev/char-fe.h      |    7 +
 include/chardev/char.h         |    1 +
 include/monitor/monitor.h      |    1 +
 include/sysemu/vmi-handshake.h |   66 ++
 include/sysemu/vmi-intercept.h |   25 +
 linux-headers/linux/kvm.h      |   20 +
 migration/migration.c          |   18 +-
 migration/migration.h          |    2 +
 monitor/Makefile.objs          |    2 +-
 monitor/qmp-cmds.c             |   18 +
 monitor/qmp.c                  |   11 +
 monitor/stubs.c                |    9 +
 qemu-options.hx                |   76 +++
 22 files changed, 1455 insertions(+), 8 deletions(-)
 create mode 100644 accel/kvm/vmi.c
 create mode 100644 accel/stubs/vmi-stubs.c
 create mode 100644 include/sysemu/vmi-handshake.h
 create mode 100644 include/sysemu/vmi-intercept.h
 create mode 100644 monitor/stubs.c


base-commit: 14e5526b51910efd62cd31cd95b49baca975c83f
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Tamas K Lengyel <tamas@tklengyel.com>
CC: Mathieu Tarral <mathieu.tarral@protonmail.com>
CC: Samuel Laurén <samuel.lauren@iki.fi>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Patrick Colp <patrick.colp@oracle.com>
CC: Jan Kiszka <jan.kiszka@siemens.com>
CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Juan Quintela <quintela@redhat.com>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
CC: Marian Rotariu <marian.c.rotariu@gmail.com>
CC: Mihai Donțu <mdontu@bitdefender.com>


^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2020-04-28 14:45 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15  0:59 [RFC PATCH v1 00/26] VM introspection Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 01/26] chardev: tcp: allow to change the reconnect timer Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 02/26] char-socket: allow vsock parameters (cid, port) Adalbert Lazăr
2020-04-15 10:43   ` Marc-André Lureau
2020-04-15 12:09     ` Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 03/26] char-socket: fix the client mode when created through QMP Adalbert Lazăr
2020-04-15 10:37   ` Marc-André Lureau
2020-04-15 11:47     ` Adalbert Lazăr
2020-04-15 14:11       ` Markus Armbruster
2020-04-15 17:53         ` Adalbert Lazăr
2020-04-16  6:03           ` Markus Armbruster
2020-04-15  0:59 ` [RFC PATCH v1 04/26] char-socket: add 'reconnecting' property Adalbert Lazăr
2020-04-15 10:46   ` Marc-André Lureau
2020-04-15 12:28     ` Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 05/26] char-socket: add 'fd' property Adalbert Lazăr
2020-04-15 10:56   ` Marc-André Lureau
2020-04-15 12:55     ` Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 06/26] E820: extend the table access interface Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 07/26] linux-headers: update with VM introspection interface Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 08/26] kvm: add VM introspection usage documentation Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 09/26] kvm: introduce the VM introspection object Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 10/26] kvm: vmi: add the handshake with the introspection tool Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 11/26] kvm: vmi: add 'handshake_timeout' property Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 12/26] kvm: vmi: add 'key' property Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 13/26] kvm: vmi: block the object destruction if the chardev is connected Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 14/26] kvm: vmi: allow only one instance of the introspection object Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 15/26] kvm: vmi: reconnect the socket on reset Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 16/26] kvm: vmi: intercept pause/resume Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 17/26] kvm: vmi: add 'unhook_timeout' property Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 18/26] kvm: vmi: store/restore 'vm_start_time' on migrate/snapshot Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 19/26] kvm: vmi: intercept force-reset Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 20/26] kvm: vmi: intercept live migration Adalbert Lazăr
2020-04-27 19:08   ` Dr. David Alan Gilbert
2020-04-28 12:14     ` Adalbert Lazăr
2020-04-28 12:24       ` Dr. David Alan Gilbert
2020-04-28 13:16         ` Adalbert Lazăr
2020-04-28 13:43           ` Dr. David Alan Gilbert
2020-04-28 14:38             ` Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 21/26] kvm: vmi: postpone the OK response from qmp_stop() Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 22/26] kvm: vmi: add 'async_unhook' property Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 23/26] kvm: vmi: intercept shutdown Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 24/26] kvm: vmi: add 'unhook_on_shutdown' property Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 25/26] kvm: vmi: extend handshake to include the e820 table Adalbert Lazăr
2020-04-15  0:59 ` [RFC PATCH v1 26/26] kvm: vmi: add 'command' and 'event' properties Adalbert Lazăr
2020-04-15  2:02 ` [RFC PATCH v1 00/26] VM introspection no-reply
2020-04-15  2:26 ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.