]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qga-win: Fix guest-get-fsinfo multi-disks collection
authorPeng Ji <peng.ji@smartx.com>
Wed, 27 Dec 2023 06:32:06 +0000 (14:32 +0800)
committerKonstantin Kostiuk <kkostiuk@redhat.com>
Tue, 30 Jan 2024 10:14:11 +0000 (12:14 +0200)
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.

Details:
https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-volume_disk_extents

Signed-off-by: Peng Ji <peng.ji@smartx.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
qga/commands-win32.c

index 697c65507caa06889e4aae01cebe9f87e35eb4b0..a1015757d878c5b4636605e9f382b2bf15d2d455 100644 (file)
@@ -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(