Skip to contentSkip to conversation

qemu-ga-win: 'guest-get-fsinfo' command wont query storage devices of bus type USB

PATCH In review Kfir Manor 3 participants 7 messages Nov 20, 2022 – Dec 26, 2022

lore
Share & tools
lore

Kfir Manor

author
#0 lore raw

cover qemu-ga-win: 'guest-get-fsinfo' command wont query storage devices of bus type USB

guest-get-fsinfo won't query storage devices of bus-type USB (https://bugzilla.redhat.com/show_bug.cgi?id=2090333).

Bug, get_pci_info function returns an error after not finding any storage port device info on the USB disk parent device (because of USB abstraction).

Fix, skip getting PCI info (get_pci_info function) for USB disks (as USB disk doesn't have PCI info), and return an empty PCI address instead to keep with schema.

Kfir Manor (2):
adding a empty PCI address creation function
skip getting pci info for USB disks

 qga/commands-win32.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
Signature · 1 line
2.38.1
author
#1 lore raw

PATCH 1/2 qga:/qga-win: adding a empty PCI address creation function

Refactoring code to avoid duplication of creating an empty PCI address code.

---
 qga/commands-win32.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
qga/commands-win32.c +13 -7
index ec9f55b453..a645480496 100644
@@ -599,6 +599,18 @@ static void get_pci_address_for_device(GuestPCIAddress *pci,
     }
 }
 
+static GuestPCIAddress *get_empty_pci_address(void)
+{
+    GuestPCIAddress *pci = NULL;
+
+    pci = g_malloc0(sizeof(*pci));
+    pci->domain = -1;
+    pci->slot = -1;
+    pci->function = -1;
+    pci->bus = -1;
+    return pci;
+}
+
 static GuestPCIAddress *get_pci_info(int number, Error **errp)
 {
     HDEVINFO dev_info = INVALID_HANDLE_VALUE;
@@ -608,13 +620,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
     SP_DEVICE_INTERFACE_DATA dev_iface_data;
     HANDLE dev_file;
     int i;
-    GuestPCIAddress *pci = NULL;
-
-    pci = g_malloc0(sizeof(*pci));
-    pci->domain = -1;
-    pci->slot = -1;
-    pci->function = -1;
-    pci->bus = -1;
+    GuestPCIAddress *pci = get_empty_pci_address();
 
     dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0,
                                    DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
Signature · 1 line
2.38.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] qga:/qga-win: adding a empty PCI address creation function

Quoted 52 lines · Kfir Manor

Refactoring code to avoid duplication of creating an empty PCI address code.

---
 qga/commands-win32.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
qga/commands-win32.c +12 -0
index ec9f55b453..a645480496 100644
@@ -599,6 +599,18 @@ static void
 get_pci_address_for_device(GuestPCIAddress *pci,
     }
 }
 
+static GuestPCIAddress *get_empty_pci_address(void)
+{
+    GuestPCIAddress *pci = NULL;
+
+    pci = g_malloc0(sizeof(*pci));
+    pci->domain = -1;
+    pci->slot = -1;
+    pci->function = -1;
+    pci->bus = -1;
+    return pci;
+}
+
 static GuestPCIAddress *get_pci_info(int number, Error **errp)
 {
     HDEVINFO dev_info = INVALID_HANDLE_VALUE;
qga/commands-win32.c +1 -7
@@ -608,13 +620,7 @@ static GuestPCIAddress *get_pci_info(int number,
 Error **errp)
     SP_DEVICE_INTERFACE_DATA dev_iface_data;
     HANDLE dev_file;
     int i;
-    GuestPCIAddress *pci = NULL;
-
-    pci = g_malloc0(sizeof(*pci));
-    pci->domain = -1;
-    pci->slot = -1;
-    pci->function = -1;
-    pci->bus = -1;
+    GuestPCIAddress *pci = get_empty_pci_address();
 
     dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0,
                                    DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);

--
2.38.1

author
#3 lore raw

PATCH 2/2 qga:/qga-win: skip getting pci info for USB disks

In reply to Kfir Manor

Skip getting PCI info from disks type USB and give them an empty PCI address instead.

---
 qga/commands-win32.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
qga/commands-win32.c +8 -4
index a645480496..14c43b3de5 100644
@@ -878,10 +878,14 @@ static void get_single_disk_info(int disk_number,
      * if that doesn't hold since that suggests some other unexpected
      * breakage
      */
-    disk->pci_controller = get_pci_info(disk_number, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        goto err_close;
+    if (disk->bus_type == GUEST_DISK_BUS_TYPE_USB) {
+        disk->pci_controller = get_empty_pci_address();
+    } else {
+        disk->pci_controller = get_pci_info(disk_number, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            goto err_close;
+        }
     }
     if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI
             || disk->bus_type == GUEST_DISK_BUS_TYPE_IDE
Signature · 1 line
2.38.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] qga:/qga-win: skip getting pci info for USB disks

Quoted 35 lines · Kfir Manor

Skip getting PCI info from disks type USB and give them an empty PCI address instead.

---
 qga/commands-win32.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
qga/commands-win32.c +8 -5
index a645480496..14c43b3de5 100644
@@ -878,10 +878,14 @@ static void get_single_disk_info(int disk_number,
      * if that doesn't hold since that suggests some other unexpected
      * breakage
      */
-    disk->pci_controller = get_pci_info(disk_number, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        goto err_close;
+    if (disk->bus_type == GUEST_DISK_BUS_TYPE_USB) {
+        disk->pci_controller = get_empty_pci_address();
+    } else {
+        disk->pci_controller = get_pci_info(disk_number, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            goto err_close;
+        }
     }
     if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI
             || disk->bus_type == GUEST_DISK_BUS_TYPE_IDE
--

2.38.1

Reviewed-by on the v1 series
#5 lore raw
In reply to Kfir Manor

Hi

Quoted 12 lines · Kfir Manor

guest-get-fsinfo won't query storage devices of bus-type USB (https://bugzilla.redhat.com/show_bug.cgi?id=2090333).

Bug, get_pci_info function returns an error after not finding any storage port device info on the USB disk parent device (because of USB abstraction).

Fix, skip getting PCI info (get_pci_info function) for USB disks (as USB disk doesn't have PCI info), and return an empty PCI address instead to keep with schema.

Kfir Manor (2):
adding a empty PCI address creation function
skip getting pci info for USB disks

Quoted 7 lines
 qga/commands-win32.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

--
2.38.1

Signature · 1 line
Marc-André Lureau
#6 lore raw

the series was merged

Best Regards,
Konstantin Kostiuk.

Quoted 36 lines · Marc-André Lureau

Hi

Quoted 2 lines · Kfir Manor

guest-get-fsinfo won't query storage devices of bus-type USB (

https://bugzilla.redhat.com/show_bug.cgi?id=2090333).

Quoted 2 lines

Bug, get_pci_info function returns an error after not finding any

storage port device info on the USB disk parent device (because of USB abstraction).

Quoted 2 lines

Fix, skip getting PCI info (get_pci_info function) for USB disks (as USB

disk doesn't have PCI info), and return an empty PCI address instead to keep with schema.

Quoted 6 lines

Kfir Manor (2):
adding a empty PCI address creation function
skip getting pci info for USB disks

Quoted 7 lines
 qga/commands-win32.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

--
2.38.1

--
Marc-André Lureau