[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/8] qga:/qga-win: adding a empty PCI address creation function
From: |
Konstantin Kostiuk |
Subject: |
[PULL 4/8] qga:/qga-win: adding a empty PCI address creation function |
Date: |
Fri, 16 Dec 2022 15:54:35 +0200 |
From: Kfir Manor <kfir@daynix.com>
Refactoring code to avoid duplication of creating an empty PCI address code.
Signed-off-by: Kfir Manor <kfir@daynix.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
---
qga/commands-win32.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index ec9f55b453..a645480496 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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);
--
2.25.1
- [PULL 0/8] QEMU Guest Agent misc patches, Konstantin Kostiuk, 2022/12/16
- [PULL 1/8] qga: Move FS TRIM code to commands-linux.c, Konstantin Kostiuk, 2022/12/16
- [PULL 2/8] qga: Add ZFS TRIM support for FreeBSD, Konstantin Kostiuk, 2022/12/16
- [PULL 3/8] qga: Add initial OpenBSD and NetBSD support, Konstantin Kostiuk, 2022/12/16
- [PULL 4/8] qga:/qga-win: adding a empty PCI address creation function,
Konstantin Kostiuk <=
- [PULL 5/8] qga:/qga-win: skip getting pci info for USB disks, Konstantin Kostiuk, 2022/12/16
- [PULL 8/8] qga: map GLib log levels to system levels, Konstantin Kostiuk, 2022/12/16
- [PULL 6/8] qga-win: choose the right libpcre version to include in MSI package, Konstantin Kostiuk, 2022/12/16
- [PULL 7/8] qga-win: add logging to Windows event log, Konstantin Kostiuk, 2022/12/16
- Re: [PULL 0/8] QEMU Guest Agent misc patches, Peter Maydell, 2022/12/16