[PATCH 3/3] qemu: Don't lie about @ndevAlias when translating FSInfo

Michal Privoznik mprivozn at redhat.com
Mon Feb 15 16:29:34 UTC 2021


When virDomainGetFSInfo() is called over a QEMU/KVM domain it
results into calling of 'guest-get-fsinfo' guest agent command to
which it replies with info on guest (mounted) filesystems. When
filling return structure we also try to do basic lookup and
translate guest agent provided disk address into disk target (as
seen in domain XML). This can of course fail - guest can have
variety of disks not recorded in domain XML (iSCSI, scsi_debug,
NFS to name a few). If that's the case, a debug message is logged
and no disk target is added into the return structure.

However, due to the way our code is written the caller is led to
believe that the target was added into the structure. This may
lead to a situation where the array of disk targets (strings)
contains NULL. But our RPC structure says the array contains only
non-NULL strings. This results in somewhat 'cryptic' (at least to
users) error message:

  error: Unable to get filesystem information
  error: Unable to encode message payload

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1919783
Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_driver.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d30cf75b73..0da9264b49 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18932,9 +18932,8 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
 
     if (agent->disks)
         ret->devAlias = g_new0(char *, agent->ndisks);
-    ret->ndevAlias = agent->ndisks;
 
-    for (i = 0; i < ret->ndevAlias; i++) {
+    for (i = 0; i < agent->ndisks; i++) {
         qemuAgentDiskAddressPtr agentdisk = agent->disks[i];
         virDomainDiskDefPtr diskDef;
 
@@ -18945,7 +18944,7 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
                                          agentdisk->target,
                                          agentdisk->unit);
         if (diskDef != NULL)
-            ret->devAlias[i] = g_strdup(diskDef->dst);
+            ret->devAlias[ret->ndevAlias++] = g_strdup(diskDef->dst);
         else
             VIR_DEBUG("Missing target name for '%s'.", ret->mountpoint);
     }
-- 
2.26.2




More information about the libvir-list mailing list