qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: lvivier@redhat.com, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Fam Zheng" <fam@euphon.net>,
	"Thomas Huth" <thuth@redhat.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	qemu-block@nongnu.org, "Amit Shah" <amit@kernel.org>,
	"Jason Wang" <jasowang@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>
Subject: [RFC v4 0/6] hmp,qmp: Add some commands to introspect virtio devices
Date: Thu,  7 May 2020 15:47:54 +0200	[thread overview]
Message-ID: <20200507134800.10837-1-lvivier@redhat.com> (raw)

This series introduces new QMP/HMP commands to dump the status\r
of a a virtio device at different levels.\r
\r
1. Main command\r
\r
 HMP Only:\r
\r
     x-debug-virtio [subcommand]\r
\r
   Example:\r
\r
    List all sub-commands:\r
\r
    (qemu) x-debug-virtio\r
    x-debug-virtio query  -- List all available virtio devices\r
    x-debug-virtio status path -- Display status of a given virtio device\r
    x-debug-virtio queue-status path queue -- Display status of a given virtio queue\r
    x-debug-virtio queue-element path queue [index] -- Display element of a given virtio queue\r
\r
2. List available virtio devices in the machine\r
\r
  HMP Form:\r
\r
    x-debug-virtio query\r
\r
  Example:\r
\r
    (qemu) x-debug-virtio query\r
    /machine/peripheral-anon/device[3]/virtio-backend [virtio-net]\r
    /machine/peripheral-anon/device[1]/virtio-backend [virtio-serial]\r
    /machine/peripheral-anon/device[0]/virtio-backend [virtio-blk]\r
\r
  QMP Form:\r
\r
    { 'command': 'x-debug-query-virtio', 'returns': ['VirtioInfo'] }\r
\r
  Example:\r
\r
  -> { "execute": "x-debug-query-virtio" }\r
  <- { "return": [\r
         {\r
             "path": "/machine/peripheral-anon/device[3]/virtio-backend",\r
             "type": "virtio-net"\r
         },\r
         {\r
             "path": "/machine/peripheral-anon/device[1]/virtio-backend",\r
             "type": "virtio-serial"\r
         },\r
         {\r
             "path": "/machine/peripheral-anon/device[0]/virtio-backend",\r
             "type": "virtio-blk"\r
         }\r
       ]\r
     }\r
\r
3. Display status of a given virtio device\r
\r
  HMP Form:\r
\r
    x-debug-virtio status <path>\r
\r
  Example:\r
\r
    (qemu) x-debug-virtio status /machine/peripheral-anon/device[3]/virtio-backend\r
    /machine/peripheral-anon/device[3]/virtio-backend:\r
      Device Id:        1\r
      Guest features:   event-idx, indirect-desc, version-1\r
                        ctrl-mac-addr, guest-announce, ctrl-vlan, ctrl-rx, ctrl-vq, status, mrg-rxbuf, host-ufo, host-ecn, host-tso6, host-tso4, guest-ufo, guest-ecn, guest-tso6, guest-tso4, mac, ctrl-guest-offloads, guest-csum, csum\r
      Host features:    event-idx, indirect-desc, bad-feature, version-1, any-layout, notify-on-empty\r
                        gso, ctrl-mac-addr, guest-announce, ctrl-rx-extra, ctrl-vlan, ctrl-rx, ctrl-vq, status, mrg-rxbuf, host-ufo, host-ecn, host-tso6, host-tso4, guest-ufo, guest-ecn, guest-tso6, guest-tso4, mac, ctrl-guest-offloads, guest-csum, csum\r
      Backend features:\r
      Endianness:       little\r
      VirtQueues:       3\r
\r
  QMP Form:\r
\r
    { 'command': 'x-debug-virtio-status',\r
      'data': { 'path': 'str' },\r
      'returns': 'VirtioStatus'\r
    }\r
\r
  Example:\r
\r
  -> { "execute": "x-debug-virtio-status",\r
       "arguments": {\r
           "path": "/machine/peripheral-anon/device[3]/virtio-backend"\r
       }\r
    }\r
  <- { "return": {\r
       "device-endian": "little",\r
       "device-id": 1,\r
       "backend-features": {\r
         "device": {\r
           "type": "virtio-net",\r
           "data": []\r
         },\r
         "unknown": 0,\r
         "transport": []\r
       },\r
       "num-vqs": 3,\r
       "guest-features": {\r
         "device": {\r
           "type": "virtio-net",\r
           "data": [ "ctrl-mac-addr", "guest-announce", "ctrl-vlan", "ctrl-rx",\r
                     "ctrl-vq", "status", "mrg-rxbuf", "host-ufo", "host-ecn",\r
                     "host-tso6", "host-tso4", "guest-ufo", "guest-ecn",\r
                     "guest-tso6", "guest-tso4", "mac", "ctrl-guest-offloads",\r
                     "guest-csum", "csum" ]\r
         },\r
         "unknown": 0,\r
         "transport": [ "event-idx", "indirect-desc", "version-1" ]\r
       },\r
       "host-features": {\r
         "device": {\r
           "type": "virtio-net",\r
           "data": [ "gso", "ctrl-mac-addr", "guest-announce", "ctrl-rx-extra",\r
                     "ctrl-vlan", "ctrl-rx", "ctrl-vq", "status", "mrg-rxbuf",\r
                     "host-ufo", "host-ecn", "host-tso6", "host-tso4",\r
                     "guest-ufo", "guest-ecn", "guest-tso6", "guest-tso4",\r
                     "mac", "ctrl-guest-offloads", "guest-csum", "csum" ]\r
           },\r
           "unknown": 0,\r
           "transport": [ "event-idx", "indirect-desc", "bad-feature",\r
                          "version-1", "any-layout", "notify-on-empty" ]\r
         }\r
       }\r
     }\r
\r
4. Display status of a given virtio queue\r
\r
  HMP Form:\r
\r
    x-debug-virtio queue-status <path> <queue>\r
\r
  Example:\r
\r
    (qemu) x-debug-virtio queue-status /machine/peripheral-anon/device[3]/virtio-backend 0\r
    /machine/peripheral-anon/device[3]/virtio-backend:\r
      index:                0\r
      inuse:                0\r
      last_avail_idx:       61\r
      shadow_avail_idx:     292\r
      signalled_used:       61\r
      signalled_used_valid: 1\r
      VRing:\r
        num:         256\r
        num_default: 256\r
        align:       4096\r
        desc:        0x000000006c352000\r
        avail:       0x000000006c353000\r
        used:        0x000000006c353240\r
\r
  QMP Form:\r
\r
    { 'command': 'x-debug-virtio-queue-status',\r
      'data': { 'path': 'str', 'queue': 'uint16' },\r
      'returns': 'VirtQueueStatus'\r
    }\r
\r
  Example:\r
\r
  -> { "execute": "x-debug-virtio-queue-status",\r
       "arguments": {\r
           "path": "/machine/peripheral-anon/device[3]/virtio-backend",\r
           "queue": 0\r
       }\r
    }\r
  <- { "return": {\r
       "signalled_used": 373,\r
       "inuse": 0,\r
       "vring_desc": 864411648,\r
       "vring_num_default": 256,\r
       "signalled_used_valid": 1,\r
       "vring_avail": 864415744,\r
       "last_avail_idx": 373,\r
       "queue_index": 0,\r
       "vring_used": 864416320,\r
       "shadow_avail_idx": 619,\r
       "used_idx": 373,\r
       "vring_num": 256,\r
       "vring_align": 4096\r
       }\r
     }\r
\r
5. Display element of a given virtio queue\r
\r
  HMP Form:\r
\r
    x-debug-virtio queue-element <path> <queue> [index]\r
\r
  Example:\r
\r
    Dump the information of the head element of the first queue of\r
    the first virtio device::\r
\r
      (qemu) x-debug-virtio queue-element/machine/peripheral-anon/device[3]/virtio-backend 0\r
      index:  67\r
      ndescs: 1\r
      descs:  addr 0x6fe69800 len 1536 (write)\r
\r
      (qemu) xp/128bx 0x6fe69800\r
      000000006fe69800: 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00\r
      000000006fe69808: 0x00 0x00 0x01 0x00 0x52 0x54 0x00 0x12\r
      000000006fe69810: 0x34 0x56 0x52 0x54 0x00 0x09 0x51 0xde\r
      000000006fe69818: 0x08 0x00 0x45 0x00 0x00 0x4c 0x8f 0x32\r
\r
    device[3] is a virtio-net device and we can see in the element buffer the\r
    MAC address of the card::\r
\r
      [root@localhost ~]# ip link show ens4\r
      2: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP m0\r
          link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff\r
\r
    and the MAC address of the gateway::\r
\r
      [root@localhost ~]# arp -a\r
      _gateway (192.168.122.1) at 52:54:00:09:51:de [ether] on ens4\r
\r
  QMP Form:\r
\r
    { 'command': 'x-debug-virtio-queue-element',\r
      'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' },\r
      'returns': 'VirtioQueueElement'\r
    }\r
\r
  Example:\r
\r
  -> { "execute": "x-debug-virtio-queue-element",\r
       "arguments": {\r
           "path": "/machine/peripheral-anon/device[3]/virtio-backend",\r
           "queue": 0\r
       }\r
    }\r
  -> { "return": {\r
          "index": 109,\r
          "ndescs": 1,\r
          "descs": [\r
              { "flags": [ "write" ], "len": 1536, "addr": 853145600 }\r
          ]\r
       }\r
    }\r
\r
v4: re-send series as v3 didn't reach qemu-devel\r
\r
v3: use qapi_free_VirtioInfoList() on the head of the list, not on the tail\r
    prefix the commands with x-debug-\r
\r
v2: introduce VirtioType enum\r
    use an enum for the endianness\r
    change field names to stick to naming conventions (s/_/-/)\r
    add a patch to decode feature bits\r
    don't check if the queue is empty to allow to displa old elements\r
    use enum for desc flags\r
    manage indirect desc\r
    decode device features in the HMP command\r
\r
Laurent Vivier (6):\r
  qmp: add QMP command x-debug-query-virtio\r
  qmp: add QMP command x-debug-virtio-status\r
  qmp: decode feature bits in virtio-status\r
  qmp: add QMP command x-debug-virtio-queue-status\r
  qmp: add QMP command x-debug-virtio-queue-element\r
  hmp: add x-debug-virtio commands\r
\r
 Makefile                     |   2 +-\r
 Makefile.target              |   7 +-\r
 docs/system/monitor.rst      |   2 +\r
 hmp-commands-virtio.hx       | 160 +++++++++++\r
 hmp-commands.hx              |  10 +\r
 hw/block/virtio-blk.c        |  23 ++\r
 hw/char/virtio-serial-bus.c  |  11 +\r
 hw/display/virtio-gpu-base.c |  10 +\r
 hw/net/virtio-net.c          |  35 +++\r
 hw/scsi/virtio-scsi.c        |  12 +\r
 hw/virtio/Makefile.objs      |   2 +\r
 hw/virtio/virtio-balloon.c   |  13 +\r
 hw/virtio/virtio-iommu.c     |  14 +\r
 hw/virtio/virtio-stub.c      |  34 +++\r
 hw/virtio/virtio.c           | 542 +++++++++++++++++++++++++++++++++++\r
 include/hw/virtio/virtio.h   |  14 +\r
 include/monitor/hmp.h        |   4 +\r
 monitor/misc.c               |  17 ++\r
 qapi/Makefile.objs           |   2 +-\r
 qapi/qapi-schema.json        |   1 +\r
 qapi/virtio.json             | 502 ++++++++++++++++++++++++++++++++\r
 tests/qtest/qmp-cmd-test.c   |   1 +\r
 22 files changed, 1414 insertions(+), 4 deletions(-)\r
 create mode 100644 hmp-commands-virtio.hx\r
 create mode 100644 hw/virtio/virtio-stub.c\r
 create mode 100644 qapi/virtio.json\r
\r
-- \r
2.26.2\r
\r



             reply	other threads:[~2020-05-07 13:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 13:47 Laurent Vivier [this message]
2020-05-07 13:47 ` [RFC v4 1/6] qmp: add QMP command x-debug-query-virtio Laurent Vivier
2020-05-07 13:47 ` [RFC v4 2/6] qmp: add QMP command x-debug-virtio-status Laurent Vivier
2020-05-07 13:47 ` [RFC v4 3/6] qmp: decode feature bits in virtio-status Laurent Vivier
2020-05-07 13:47 ` [RFC v4 4/6] qmp: add QMP command x-debug-virtio-queue-status Laurent Vivier
2020-05-07 13:47 ` [RFC v4 5/6] qmp: add QMP command x-debug-virtio-queue-element Laurent Vivier
2020-05-07 13:48 ` [RFC v4 6/6] hmp: add x-debug-virtio commands Laurent Vivier
2020-05-13 10:51   ` Dr. David Alan Gilbert
2020-05-15 15:20     ` Laurent Vivier
2020-05-15 15:45       ` Dr. David Alan Gilbert
2020-05-15 15:57         ` Laurent Vivier
2020-05-07 20:11 ` [RFC v4 0/6] hmp, qmp: Add some commands to introspect virtio devices no-reply

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=20200507134800.10837-1-lvivier@redhat.com \
    --to=lvivier@redhat.com \
    --cc=amit@kernel.org \
    --cc=armbru@redhat.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --subject='Re: [RFC v4 0/6] hmp,qmp: Add some commands to introspect virtio devices' \
    /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

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).