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>
This commit is contained in:
parent
76dc75ca54
commit
222682abb3
@ -89,6 +89,12 @@ static OpenFlags guest_file_open_modes[] = {
|
|||||||
{"a+b", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS }
|
{"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)
|
static OpenFlags *find_open_flag(const char *mode_str)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
@ -518,6 +524,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_debug("enumerating devices");
|
||||||
dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
|
dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||||
for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
|
for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
|
||||||
DWORD addr, bus, slot, data, size2;
|
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)) {
|
if (g_strcmp0(buffer, dev_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
g_debug("found device %s", dev_name);
|
||||||
|
|
||||||
/* There is no need to allocate buffer in the next functions. The size
|
/* There is no need to allocate buffer in the next functions. The size
|
||||||
* is known and ULONG according to
|
* 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,
|
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
|
||||||
SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) {
|
SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) {
|
||||||
|
debug_error("failed to get bus");
|
||||||
bus = -1;
|
bus = -1;
|
||||||
partial_pci = true;
|
partial_pci = true;
|
||||||
}
|
}
|
||||||
@ -559,6 +568,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
|
|||||||
* transformed into device function and number */
|
* transformed into device function and number */
|
||||||
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
|
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
|
||||||
SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) {
|
SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) {
|
||||||
|
debug_error("failed to get address");
|
||||||
addr = -1;
|
addr = -1;
|
||||||
partial_pci = true;
|
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. */
|
* This number is typically a user-perceived slot number. */
|
||||||
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
|
if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
|
||||||
SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) {
|
SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) {
|
||||||
|
debug_error("failed to get slot");
|
||||||
slot = -1;
|
slot = -1;
|
||||||
partial_pci = true;
|
partial_pci = true;
|
||||||
}
|
}
|
||||||
@ -639,6 +650,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
|||||||
scsi_ad = &addr;
|
scsi_ad = &addr;
|
||||||
char *name = g_strndup(guid, strlen(guid)-1);
|
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,
|
vol_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||||
0, NULL);
|
0, NULL);
|
||||||
if (vol_h == INVALID_HANDLE_VALUE) {
|
if (vol_h == INVALID_HANDLE_VALUE) {
|
||||||
@ -646,6 +658,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
|||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_debug("getting bus type");
|
||||||
bus = get_disk_bus_type(vol_h, errp);
|
bus = get_disk_bus_type(vol_h, errp);
|
||||||
if (bus < 0) {
|
if (bus < 0) {
|
||||||
goto out_close;
|
goto out_close;
|
||||||
@ -653,6 +666,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
|||||||
|
|
||||||
disk = g_malloc0(sizeof(*disk));
|
disk = g_malloc0(sizeof(*disk));
|
||||||
disk->bus_type = find_bus_type(bus);
|
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
|
/* 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
|
* report -1 values for non-PCI buses rather than fail. fail the command
|
||||||
* if that doesn't hold since that suggests some other unexpected
|
* 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
|
/* We are able to use the same ioctls for different bus types
|
||||||
* according to Microsoft docs
|
* according to Microsoft docs
|
||||||
* https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx */
|
* 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,
|
if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_ad,
|
||||||
sizeof(SCSI_ADDRESS), &len, NULL)) {
|
sizeof(SCSI_ADDRESS), &len, NULL)) {
|
||||||
disk->unit = addr.Lun;
|
disk->unit = addr.Lun;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user