Skip to contentSkip to conversation

qga-win: Fix guest-get-fsinfo multi-disks collection

PATCH In review [email protected] 3 participants 4 messages Dec 27, 2023 – Jan 16, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga-win: Fix guest-get-fsinfo multi-disks collection

From: Peng Ji <[email protected]>

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.

---
 qga/commands-win32.c | 2 ++
 1 file changed, 2 insertions(+)
qga/commands-win32.c +2 -0
index 697c65507c..a1015757d8 100644
@@ -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(
Signature · 1 line
2.27.0
#1 lore raw
Quoted 9 lines · On 27/12/23 08:15, [email protected] wrote:

From: Peng Ji <[email protected]>

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.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2075

Quoted 17 lines
---
  qga/commands-win32.c | 2 ++
  1 file changed, 2 insertions(+)
qga/commands-win32.c +2 -0
index 697c65507c..a1015757d8 100644
@@ -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(
author
#2 lore raw

ping !
please review this patch :
https://patchew.org/QEMU/[email protected]/

thanks

Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 9 lines · On 27/12/23 08:15, [email protected] wrote:

From: Peng Ji <[email protected]>

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.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2075

qga/commands-win32.c static GuestDiskAddressList

Quoted 9 lines
---
  qga/commands-win32.c | 2 ++
  1 file changed, 2 insertions(+)
qga/commands-win32.c +0 -0
index 697c65507c..a1015757d8 100644
@@ -935,6 +935,8 @@ static GuestDiskAddressList

*build_guest_disk_info(char *guid, Error **errp)

qga/commands-win32.c static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)

Quoted 5 lines
qga/commands-win32.c +2 -0
          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));

Quoted 3 lines
qga/commands-win32.c +0 -0
              g_free(extents);
              extents = g_malloc0(size);
              if (!DeviceIoControl(
Reviewed-by
#3 lore raw
Quoted 44 lines · Peng Ji

ping !
please review this patch : https://patchew.org/QEMU/[email protected]/

thanks

Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 9 lines · On 27/12/23 08:15, [email protected] wrote:

From: Peng Ji <[email protected]>

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.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2075

qga/commands-win32.c static GuestDiskAddressList

Quoted 9 lines
---
  qga/commands-win32.c | 2 ++
  1 file changed, 2 insertions(+)
qga/commands-win32.c +0 -0
index 697c65507c..a1015757d8 100644
@@ -935,6 +935,8 @@ static GuestDiskAddressList

*build_guest_disk_info(char *guid, Error **errp)

qga/commands-win32.c static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)

Quoted 5 lines
qga/commands-win32.c +2 -0
          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));

Quoted 3 lines
qga/commands-win32.c +0 -0
              g_free(extents);
              extents = g_malloc0(size);
              if (!DeviceIoControl(