qemu: Don't lie about @ndevAlias when translating FSInfo

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>
This commit is contained in:
Michal Privoznik 2021-02-15 15:39:19 +01:00
parent 9ad1e1d897
commit 2642cc0f66

View 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);
}