diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2018-10-15 15:46:59 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-10-15 15:46:59 +0200 |
commit | 811de87d5ede98023ad862bbfd0fbe959efbaed9 (patch) | |
tree | 1da24315eac37266b45a96a2399f3dd08aa22a6f /virtiotest.c | |
parent | 3df9f3572bb4e5da99aa2d9fd5c031cdb1653bfd (diff) | |
download | drminfo-811de87d5ede98023ad862bbfd0fbe959efbaed9.tar.gz |
fix getparam ioctl
Diffstat (limited to 'virtiotest.c')
-rw-r--r-- | virtiotest.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/virtiotest.c b/virtiotest.c index bf16bc8..fe56948 100644 --- a/virtiotest.c +++ b/virtiotest.c @@ -36,32 +36,38 @@ static struct { #endif }; -static uint64_t virtio_get_cap(uint64_t cap) +static int virtio_get_cap(uint64_t cap, int *value) { struct drm_virtgpu_getparam args; - int value = 0; int rc; args.param = cap; - args.value = (intptr_t)(&value); + args.value = (intptr_t)(value); rc = drmIoctl(fd, DRM_IOCTL_VIRTGPU_GETPARAM, &args); if (rc != 0) { - fprintf(stderr, "ioctl DRM_IOCTL_VIRTGPU_GETPARAM(%" PRId64 "): %s\n", - cap, strerror(errno)); - exit(1); + if (errno == EINVAL) { + return -1; + } else { + fprintf(stderr, "ioctl DRM_IOCTL_VIRTGPU_GETPARAM(%" PRId64 "): %s\n", + cap, strerror(errno)); + exit(1); + } } - return value; + return 0; } static void virtio_print_caps(void) { - uint64_t value; - int i; + int i, rc, value; printf("virtio capabilities\n"); for (i = 0; i < ARRAY_SIZE(virtio_caps); i++) { - value = virtio_get_cap(virtio_caps[i].cap); - printf(" %s: %" PRId64 "\n", virtio_caps[i].name, value); + rc = virtio_get_cap(virtio_caps[i].cap, &value); + if (rc == -1) { + printf(" %-12s: not available\n", virtio_caps[i].name); + } else { + printf(" %-12s: %d\n", virtio_caps[i].name, value); + } } } |