aboutsummaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
authorTomáš Golembiovský <tgolembi@redhat.com>2018-10-29 18:42:19 -0500
committerMichael Roth <mdroth@linux.vnet.ibm.com>2018-10-31 09:04:20 -0500
commit222682abb3800b9c644b7832543510ade3d5138b (patch)
treed06e6d5ab98587efc26358c97c434a85c5cfdd7f /qga
parent76dc75ca549109499a7a6e275a80662f2390f686 (diff)
qga-win: add debugging information
The windows code generaly lacks debug information (compared to posix code). This patch adds some related to HW info in guest-get-fsinfo command. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-win32.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 4fe1517778..1a21aac5ad 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -89,6 +89,12 @@ static OpenFlags guest_file_open_modes[] = {
{"a+b", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS }
};
+#define debug_error(msg) do { \
+ char *suffix = g_win32_error_message(GetLastError()); \
+ g_debug("%s: %s", (msg), suffix); \
+ g_free(suffix); \
+} while (0)
+
static OpenFlags *find_open_flag(const char *mode_str)
{
int mode;
@@ -518,6 +524,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
goto out;
}
+ g_debug("enumerating devices");
dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
DWORD addr, bus, slot, data, size2;
@@ -543,6 +550,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
if (g_strcmp0(buffer, dev_name)) {
continue;
}
+ g_debug("found device %s", dev_name);
/* There is no need to allocate buffer in the next functions. The size
* is known and ULONG according to
@@ -551,6 +559,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
*/
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) {
+ debug_error("failed to get bus");
bus = -1;
partial_pci = true;
}
@@ -559,6 +568,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
* transformed into device function and number */
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) {
+ debug_error("failed to get address");
addr = -1;
partial_pci = true;
}
@@ -567,6 +577,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
* This number is typically a user-perceived slot number. */
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) {
+ debug_error("failed to get slot");
slot = -1;
partial_pci = true;
}
@@ -639,6 +650,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
scsi_ad = &addr;
char *name = g_strndup(guid, strlen(guid)-1);
+ g_debug("getting disk info for: %s", name);
vol_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
0, NULL);
if (vol_h == INVALID_HANDLE_VALUE) {
@@ -646,6 +658,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
goto out_free;
}
+ g_debug("getting bus type");
bus = get_disk_bus_type(vol_h, errp);
if (bus < 0) {
goto out_close;
@@ -653,6 +666,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
disk = g_malloc0(sizeof(*disk));
disk->bus_type = find_bus_type(bus);
+ g_debug("bus type %d", disk->bus_type);
/* always set pci_controller as required by schema. get_pci_info() should
* report -1 values for non-PCI buses rather than fail. fail the command
* if that doesn't hold since that suggests some other unexpected
@@ -672,6 +686,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
/* We are able to use the same ioctls for different bus types
* according to Microsoft docs
* https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx */
+ g_debug("getting pci-controller info");
if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_ad,
sizeof(SCSI_ADDRESS), &len, NULL)) {
disk->unit = addr.Lun;