Bug 1755075 - [qemu-guest-agent] fsinfo doesn't return disk info on s390x
Summary: [qemu-guest-agent] fsinfo doesn't return disk info on s390x
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.1
Hardware: s390x
OS: Linux
low
medium
Target Milestone: beta
: 8.4
Assignee: Thomas Huth
QA Contact: smitterl
URL:
Whiteboard:
Depends On:
Blocks: 1858771 1897024
TreeView+ depends on / blocked
 
Reported: 2019-09-24 17:10 UTC by smitterl
Modified: 2021-05-25 06:41 UTC (History)
11 users (show)

Fixed In Version: qemu-kvm-5.2.0-3.module+el8.4.0+9499+42e58f08
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1858771 (view as bug list)
Environment:
Last Closed: 2021-05-25 06:41:20 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description smitterl 2019-09-24 17:10:14 UTC
Description of problem:
virsh domfsinfo <domain> returns no value in Target

Version-Release number of selected component (if applicable):
qemu-kvm-4.1.0-11.module+el8.1.0+4250+4f5fbfdc
libvirt-5.6.0-6.module+el8.1.0+4244+9aa4e6bb

How reproducible:
Always

Steps to Reproduce:
1. Add to domxml 
<channel type='unix'>
   <source mode='bind' path='/var/lib/libvirt/qemu/f16s390x.agent'/>
   <target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
2. Start machine, wait for guest agent to be running
3. virsh domsinfo <domain>

Actual results:
 Mountpoint   Name   Type   Target
------------------------------------
 /            dm-0   xfs    
 /boot        vda1   xfs    


Expected results:
 Mountpoint   Name   Type   Target
------------------------------------
 /            dm-0   xfs    /dev/mapper/rhel-root
 /boot        vda1   xfs    /dev/vda1



Additional info:
1. disk is empty list, returned by qemu-ga:
2019-09-24 16:38:07.507+0000: 19935: debug : qemuAgentIOProcessLine:289 : Line [{"return": [{"name": "vda1", "total-bytes": 1063256064, "mountpoint": "/boot", "disk": [], "used-bytes": 115691520, "type": "xfs"}, {"name": "dm-0", "total-bytes": 8575254528, "mountpoint": "/", "disk": [], "used-bytes": 1521668096, "type": "xfs"}]}]
2019-09-24 16:38:07.507+0000: 19935: debug : virJSONValueFromString:1845 : string={"return": [{"name": "vda1", "total-bytes": 1063256064, "mountpoint": "/boot", "disk": [], "used-bytes": 115691520, "type": "xfs"}, {"name": "dm-0", "total-bytes": 8575254528, "mountpoint": "/", "disk": [], "used-bytes": 1521668096, "type": "xfs"}]}
2. x86_64 for comparison:
2019-09-24 16:46:32.061+0000: 30342: debug : qemuAgentIOProcessLine:291 : Line [{"return": [{"name": "vda1", "total-bytes": 1063256064, "mountpoint": "/boot", "disk": [{"bus-type": "virtio", "bus": 0, "unit": 0, "pci-controller": {"bus": 4, "slot": 0, "domain": 0, "function": 0}, "dev": "/dev/vda1", "target": 0}], "used-bytes": 159887360, "type": "xfs"}, {"name": "dm-0", "total-bytes": 8575254528, "mountpoint": "/", "disk": [{"bus-type": "virtio", "bus": 0, "unit": 0, "pci-controller": {"bus": 4, "slot": 0, "domain": 0, "function": 0}, "dev": "/dev/vda2", "target": 0}], "used-bytes": 1454747648, "type": "xfs"}]}]
2019-09-24 16:46:32.061+0000: 30342: debug : virJSONValueFromString:1814 : string={"return": [{"name": "vda1", "total-bytes": 1063256064, "mountpoint": "/boot", "disk": [{"bus-type": "virtio", "bus": 0, "unit": 0, "pci-controller": {"bus": 4, "slot": 0, "domain": 0, "function": 0}, "dev": "/dev/vda1", "target": 0}], "used-bytes": 159887360, "type": "xfs"}, {"name": "dm-0", "total-bytes": 8575254528, "mountpoint": "/", "disk": [{"bus-type": "virtio", "bus": 0, "unit": 0, "pci-controller": {"bus": 4, "slot": 0, "domain": 0, "function": 0}, "dev": "/dev/vda2", "target": 0}], "used-bytes": 1454747648, "type": "xfs"}]}
3. Not sure this is the right Product/Component, couldn't find qemu-guest-agent for RHEL >= 8.

Comment 2 smitterl 2019-09-30 07:31:56 UTC
Automated test case tp-libvirt/libvirt rhel.virsh.domfsinfo.positive_tests.no_freezed_fs

Comment 3 Thomas Huth 2020-07-15 09:51:33 UTC
I've had a look at this now and the problem is in the qemu-guest-agent indeed (i.e. not in the libvirt side).

The related function build_guest_fsinfo_for_real_device() in the file qga/commands-posix.c starts with this check:

    p = strstr(syspath, "/devices/pci");
    if (!p || sscanf(p + 12, "%*x:%*x/%x:%x:%x.%x%n",
                     pci, pci + 1, pci + 2, pci + 3, &pcilen) < 4) {
        g_debug("only pci device is supported: sysfs path '%s'", syspath);
        return;
    }

That means the fields are only filled in for PCI devices. Since we are using CCW devices on s390x, the information is not gathered by the guest agent.

I'll have a look how this can be fixed...

Comment 4 Thomas Huth 2020-07-20 08:38:26 UTC
I had to learn the hard way that libvirt needs some modifications, too.
The function qemuAgentFSInfoToPublic() in src/qemu_driver.c can currently only deal with PCI disks:

   for (i = 0; i < ret->ndevAlias; i++) {
        qemuAgentDiskInfoPtr agentdisk = agent->disks[i];
        virDomainDiskDefPtr diskDef;

        if (!(diskDef = virDomainDiskByAddress(vmdef,
                                               &agentdisk->pci_controller,
                                               agentdisk->bus,
                                               agentdisk->target,
                                               agentdisk->unit)))
            continue;

        ret->devAlias[i] = g_strdup(diskDef->dst);
    }

... i.e. the devAlias (which is shown as the "Target" in "virsh domfsinfo") is currently only set for PCI disks.

Comment 5 Thomas Huth 2020-07-20 11:17:10 UTC
Suggested patches for QEMU:

https://lore.kernel.org/qemu-devel/20200720110133.4366-1-thuth@redhat.com/

Comment 12 smitterl 2020-11-05 15:22:12 UTC
Please, note that the reported Expected result is wrong. The Target column contains as per manpage "unique target names used in  the  domain  XML  (<target dev='name'/>)". I confirmed that on x86_64.

Expected results:

 Mountpoint   Name   Type   Target
------------------------------------
 /            dm-0   xfs    vda
 /boot        vda1   xfs    vda

Comment 13 smitterl 2020-11-05 15:44:11 UTC
E2E test failed. Info on https://bugzilla.redhat.com/show_bug.cgi?id=1858771#c8
I'm not sure if QEMU part works as expected so not changing status for now until I know more.

Comment 14 smitterl 2020-11-05 15:54:00 UTC
Confirmed with Peter that the passed json reads a pci address while we should expect a ccw address. Setting back to assigned, sorry for inconvenience.

Steps:
1. Set up guest to have
 a. qcow2 boot image in guest with <target dev='vda'/>
 b. qemu-agent channel set up
<channel type='unix'>
   <source mode='bind' path='/var/lib/libvirt/qemu/f16s390x.agent'/>
   <target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
 c. qemu-guest-agent installed
2. Start guest
3. Send command '{"execute":"guest-get-fsinfo"}'

Actual result:
[
  {
    "return": [
      {
        "name": "vda1",
        "total-bytes": 1063256064,
        "mountpoint": "/boot",
        "disk": [
          {
            "bus-type": "virtio",
            "bus": 0,
            "unit": 0,
            "pci-controller": {
              "bus": -1,
              "slot": -1,
              "domain": -1,
              "function": -1
            },
            "dev": "/dev/vda1",
            "target": 0
          }
        ],
        "used-bytes": 130871296,
        "type": "xfs"
      },
      {
        "name": "dm-0",
        "total-bytes": 3743416320,
        "mountpoint": "/",
        "disk": [
          {
            "bus-type": "virtio",
            "bus": 0,
            "unit": 0,
            "pci-controller": {
              "bus": -1,
              "slot": -1,
              "domain": -1,
              "function": -1
            },
            "dev": "/dev/vda2",
            "target": 0
          }
        ],
        "used-bytes": 1565663232,
        "type": "xfs"
      }
    ]
  }
]

Expected result:
Not sure but it should not be an invalid pci address but most likely a ccw address.

Comment 15 smitterl 2020-11-05 17:08:28 UTC
Thomas, based on the libvirt codebase (qemu_agent.c, qemu_driver.c, remote_daemon_dispatch.c, virsh_domain.c, libvirt_domain.c), the response from "execute":"guest-get-fsinfo" on libvirt side is only used in commands (local or remote):

* virsh domfsinfo
* virsh guestinfo

Neither use the pci address info. A possible conclusing is this BZ for the qemu component might not require change for fixing the libvirt output on related BZ:

# virsh guestinfo
user.count          : 0
os.id               : rhel
os.name             : Red Hat Enterprise Linux
os.pretty-name      : Red Hat Enterprise Linux 8.4 Beta (Ootpa)
os.version          : 8.4 (Ootpa)
os.version-id       : 8.4
os.machine          : s390x
os.kernel-release   : 4.18.0-240.10.el8.s390x
os.kernel-version   : #1 SMP Fri Oct 30 03:50:29 EDT 2020
timezone.name       : CST
timezone.offset     : 28800
hostname            : localhost.localdomain
fs.count            : 2
fs.0.name           : dm-0
fs.0.mountpoint     : /
fs.0.fstype         : xfs
fs.0.total-bytes    : 3743416320
fs.0.used-bytes     : 1583079424
fs.0.disk.count     : 1
fs.0.disk.0.device  : /dev/vda2
fs.1.name           : vda1
fs.1.mountpoint     : /boot
fs.1.fstype         : xfs
fs.1.total-bytes    : 1063256064
fs.1.used-bytes     : 130871296
fs.1.disk.count     : 1
fs.1.disk.0.device  : /dev/vda1

Comment 16 Thomas Huth 2020-11-05 19:14:32 UTC
I think the QEMU side here is fine. The "pci-controller" section in the JSON is unfortunately mandatory, so it can't be skipped and has to be marked as invalid with these "-1" values (see https://www.qemu.org/docs/master/interop/qemu-ga-ref.html#index-GuestDiskAddress ). And CCW addresses are not possible there yet either. But you're right, the output on the libvirt side does not match what you'd expect from other architectures, so BZ 1858771 needs to be reworked...

Comment 17 Thomas Huth 2020-11-12 22:19:48 UTC
The QEMU part is fine, the remaining problem is on the libvirt side indeed. Moving this part here back to ON_QA ... and will post a patch for libvirt as soon as possible later.

Comment 18 Thomas Huth 2020-11-16 10:29:55 UTC
After discussing the libvirt side of this problem a little bit further, it seems like there might some additional work to be done on the QEMU side, too. After all we likely need to send the CCW address, too. Moving the state back to ASSIGNED.

Comment 20 Thomas Huth 2020-11-25 11:03:47 UTC
I've now posted the patch upstream that should provide the necessary information from the QEMU guest agent side:
https://lore.kernel.org/qemu-devel/20201125105417.380317-1-thuth@redhat.com/

Comment 28 smitterl 2021-01-19 15:22:38 UTC
Sanity tested with
qemu-guest-agent-5.2.0-3.module+el8.4.0+9499+42e58f08.s390x
qemu-kvm-5.2.0-3.module+el8.4.0+9499+42e58f08.s390x
libvirt-7.0.0-1.module+el8.4.0+9464+3e71831a.s390x

Run virsh domfsinfo vm

Result:
A)
# virsh domfsinfo vm
 Mountpoint   Name   Type   Target
------------------------------------
 /            dm-0   xfs    vda
 /boot        vda1   xfs    vda

B)
QEMU request from libvirt log:
[
  {
    "return": [
      {
        "name": "vda1",
        "total-bytes": 1063256064,
        "mountpoint": "/boot",
        "disk": [
          {
            "ccw-address": {
              "cssid": 0,
              "ssid": 0,
              "subchno": 2,
              "devno": 0
            },
            "bus-type": "virtio",
            "bus": 0,
            "unit": 0,
            "pci-controller": {
              "bus": -1,
              "slot": -1,
              "domain": -1,
              "function": -1
            },
            "dev": "/dev/vda1",
            "target": 0
          }
        ],
        "used-bytes": 132022272,
        "type": "xfs"
      },
      {
        "name": "dm-0",
        "total-bytes": 3743416320,
        "mountpoint": "/",
        "disk": [
          {
            "ccw-address": {
              "cssid": 0,
              "ssid": 0,
              "subchno": 2,
              "devno": 0
            },
            "bus-type": "virtio",
            "bus": 0,
            "unit": 0,
            "pci-controller": {
              "bus": -1,
              "slot": -1,
              "domain": -1,
              "function": -1
            },
            "dev": "/dev/vda2",
            "target": 0
          }
        ],
        "used-bytes": 1658707968,
        "type": "xfs"
      }
    ]
  }
]

Comment 32 errata-xmlrpc 2021-05-25 06:41:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:2098


Note You need to log in before you can comment on or make changes to this bug.