[Spice-devel] [PATCH] debug messages improvements
Lukáš Hrázký
lhrazky at redhat.com
Tue Oct 9 15:18:15 UTC 2018
---
src/vdagent/get-xrandr-output.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/vdagent/get-xrandr-output.c b/src/vdagent/get-xrandr-output.c
index 2127e66..14e781d 100644
--- a/src/vdagent/get-xrandr-output.c
+++ b/src/vdagent/get-xrandr-output.c
@@ -64,7 +64,7 @@ static const char *connections[] = {"", "*CONNECTED*", "disconnected", "unknown
int main(int argc, char* argv[])
{
if (argc < 3) {
- ERROR("Usage: %s PCIADDR MONITORID", argv[0]);
+ ERROR("Usage: %s PCIADDR MONITORID\n", argv[0]);
}
// PCI address should be in extended BDF notation
@@ -82,6 +82,7 @@ int main(int argc, char* argv[])
snprintf(dev_path, sizeof(dev_path), DRM_DEV_NAME, DRM_DIR_NAME, i);
if (stat(dev_path, &buf) != 0) {
// no card exists, exit loop
+ ERROR("no card exists\n");
break;
}
@@ -89,15 +90,17 @@ int main(int argc, char* argv[])
// pci address for the device
char sys_path[64];
snprintf(sys_path, sizeof(sys_path), "/sys/class/drm/card%d", i);
+ printf("sys path: %s\n", sys_path);
// the file /sys/class/drm/card0/device is a symlink to a file that
// specifies the device's address. It usually points to something
// like ../../../0000:00:02.0
char sys_path_device[100], device_link[100];
snprintf(sys_path_device, sizeof(sys_path_device), "%s/device", sys_path);
+ printf("sys path device: %s\n", sys_path_device);
ssize_t res = readlink(sys_path_device, device_link, sizeof(device_link) - 1);
if (res == -1) {
- ERROR(strerror(errno));
+ ERROR("readlink error: %s\n", strerror(errno));
}
// readlink does not guarantee that the string is null-terminated
device_link[res] = '\0';
@@ -114,18 +117,18 @@ int main(int argc, char* argv[])
int fd;
fd = open(dev_path, O_RDWR);
if (fd < 0) {
- ERROR(strerror(errno));
+ ERROR("open error: %s\n", strerror(errno));
}
drmModeResPtr res = drmModeGetResources(fd);
if (!res) {
- ERROR("Unable to get resources for card");
+ ERROR("Unable to get resources for card\n");
}
// find the drm output that is equal to monitor_id
/* FIXME: verify that monitor id is 0-based */
if (res->count_connectors < (monitor_id + 1)) {
- ERROR("Unable to find output");
+ ERROR("Unable to find output\n");
}
drmModeConnectorPtr conn = drmModeGetConnector(fd, res->connectors[monitor_id]);
@@ -143,17 +146,17 @@ int main(int argc, char* argv[])
// now look up all xrandr outputs
Display *xdisplay = XOpenDisplay(NULL);
if (!xdisplay) {
- ERROR("Failed to open X dislay");
+ ERROR("Failed to open X dislay\n");
}
int rr_event_base, rr_error_base;
if (!XRRQueryExtension(xdisplay, &rr_event_base, &rr_error_base)) {
- ERROR("Failed to initialize XRandr extension");
+ ERROR("Failed to initialize XRandr extension\n");
}
XRRScreenResources *xres = XRRGetScreenResourcesCurrent(xdisplay, DefaultRootWindow(xdisplay));
if (!xres) {
- ERROR("Unable to get screen resources");
+ ERROR("Unable to get screen resources\n");
}
// Loop through xrandr outputs and check whether the xrandr
@@ -178,7 +181,7 @@ int main(int argc, char* argv[])
char *id_pos = strrchr(oinfo->name, '-') + 1;
int newid = atoi(id_pos) + 1;
if (snprintf(xname, sizeof(xname), "%s%i", oinfo->name, newid) < 0) {
- ERROR("Unable to increment name");
+ ERROR("Unable to increment name\n");
}
} else {
strncpy(xname, oinfo->name, sizeof(xname) - 1);
@@ -200,6 +203,8 @@ int main(int argc, char* argv[])
// we found the right card, abort the loop
found = true;
break;
+ } else {
+ printf("card addr '%s' does not match requested addr '%s'\n", card_addr, user_addr);
}
}
if (!found) {
--
2.19.1
More information about the Spice-devel
mailing list