[PATCH] qga-win: Fix guest-get-fsinfo multi-disks collection

peng.ji@smartx.com posted 1 patch 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231227063206.4025543-1-peng.ji@smartx.com
Maintainers: Konstantin Kostiuk <kkostiuk@redhat.com>, Michael Roth <michael.roth@amd.com>
There is a newer version of this series
qga/commands-win32.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] qga-win: Fix guest-get-fsinfo multi-disks collection
Posted by peng.ji@smartx.com 11 months ago
From: Peng Ji <peng.ji@smartx.com>

When a volume has more than one disk, all disks cannot be
returned correctly because there is not enough malloced memory
for disk extents, so before executing DeviceIoControl for the
second time, get the correct size of the required memory space
to store all disk extents.

Signed-off-by: Peng Ji <peng.ji@smartx.com>
---
 qga/commands-win32.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 697c65507c..a1015757d8 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -935,6 +935,8 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
         DWORD last_err = GetLastError();
         if (last_err == ERROR_MORE_DATA) {
             /* Try once more with big enough buffer */
+            size = sizeof(VOLUME_DISK_EXTENTS) +
+               (sizeof(DISK_EXTENT) * (extents->NumberOfDiskExtents - 1));
             g_free(extents);
             extents = g_malloc0(size);
             if (!DeviceIoControl(
-- 
2.27.0