]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Don't lie about @ndevAlias when translating FSInfo
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Feb 2021 14:39:19 +0000 (15:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 16 Feb 2021 13:06:31 +0000 (14:06 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index d30cf75b73c9f8429b23ccdfb20fee6e3c6568ae..0da9264b49caec46e72474585ef20316523d9a69 100644 (file)
@@ -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);
     }