[PATCH v3] tests/drm_virtgpu: Add functional coverage for core VirtIO-GPU ioctls

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri Jun 6 15:55:22 UTC 2025


Hi Dorinda,
On 2025-05-30 at 11:02:20 +0200, Dorinda Bassey wrote:
> This test suite adds coverage for multiple DRM ioctls specific
> to the VirtIO-GPU driver, verifying functionality such as
> resource creation, memory mapping, 3D transfers, context
> initialization, and parameter querying.
> Each test validates a key ioctl to ensure correct behavior from
> user space and backend implementations. Each subtest is
> self-contained and can be executed independently.
> 
> Included subtests:
>   - drm-virtgpu-map
>   - drm-virtgpu-execbuffer
>   - drm-virtgpu-resource-info
>   - drm-virtgpu-3d-transfer-to-host
>   - drm-virtgpu-3d-transfer-from-host
>   - drm-virtgpu-3d-wait
>   - drm-virtgpu-resource-create-blob
>   - drm-virtgpu-get-caps
>   - drm-virtgpu-context-init
>   - drm-virtgpu-getparam
> 
> How to Test with QEMU virtio-vga-gl or rustvmm vhost-device-gpu
> 
> 1. Launch a QEMU guest with virtio-vga-gl
> ./build/qemu-system-x86_64 \
>   -enable-kvm \
>   -cpu host \
>   -m 4096 \
>   -machine q35 \
>   -display gtk,gl=on \
>   -vga none \
>   -device virtio-vga-gl \
>   -drive file=image.qcow2,format=qcow2 \
>   -netdev user,id=n0,hostfwd=tcp::2222-:22 \
>   -device virtio-net-pci,netdev=n0
> 
> ssh into the guest and run the tests.
> 
> 2. Start the vhost-device-gpu backend and Launch a QEMU
> guest with vhost-user-gpu-pci or vhost-user-vga, see guide on:
> https://crates.io/crates/vhost-device-gpu
> 
> Signed-off-by: Dorinda Bassey <dbassey at redhat.com>

Please use checkpatch.pl script from Linux kernel, for usefull
options see CONTRIBUTING.md
You could ignore MAINTAINER or CamelCase but please fix others.

With that fixed
Acked-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

I will wait with merge for a review from someone in your Cc list.

One more nit below.

> ---
> v3:
> Fix resource format and clarify capset IDs
> 
>  tests/drm_virtgpu.c | 420 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build   |   1 +
>  2 files changed, 421 insertions(+)
>  create mode 100644 tests/drm_virtgpu.c
> 
> diff --git a/tests/drm_virtgpu.c b/tests/drm_virtgpu.c
> new file mode 100644
> index 000000000..4d7c9e8f5
> --- /dev/null
> +++ b/tests/drm_virtgpu.c
> @@ -0,0 +1,420 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2025 Red Hat Inc.
> + *
> + * Authors: Dorinda Bassey <dbassey at redhat.com>
> + */
> +
> +/**
> + * TEST: drm virtgpu ioctls
> + * Description: Testing of the virtIO-GPU driver DRM ioctls
> + * Category: Core
> + * Mega feature: General Core features
> + * Sub-category:  virtIO-GPU DRM ioctls
> + * Functionality: drm_ioctls
> + * Feature: Virtualization graphics support
> + * Test category: functionality test
> + */
> +
> +#include <fcntl.h>
> +#include <errno.h>
> +#include <string.h>
> +#include <sys/ioctl.h>
> +
> +#include "drm.h"
> +#include "virtgpu_drm.h"
> +#include "igt.h"
> +
> +/**
> + * SUBTEST: drm-virtgpu-map
> + *
> + * SUBTEST: drm-virtgpu-execbuffer
> + *
> + * SUBTEST: drm-virtgpu-resource-info
> + *
> + * SUBTEST: drm-virtgpu-3d-transfer-to-host
> + *
> + * SUBTEST: drm-virtgpu-3d-transfer-from-host
> + *
> + * SUBTEST: drm-virtgpu-3d-wait
> + *
> + * SUBTEST: drm-virtgpu-resource-create
> + *
> + * SUBTEST: drm-virtgpu-resource-create-blob
> + *
> + * SUBTEST: drm-virtgpu-get-caps
> +
> + * SUBTEST: drm-virtgpu-context-init
> + *
> + * SUBTEST: drm-virtgpu-getparam
> + */
> +
> +IGT_TEST_DESCRIPTION("Testing of the virtIO-GPU driver DRM ioctls");
> +
> +#define VIRTGPU_DEVICE "/dev/dri/card0"
> +
> +#define CAPS_BUFFER_SIZE 4096
> +#define MAX_CARDS 16
> +
> +int drm_fd;
> +struct drm_virtgpu_resource_create args;
> +bool resource_created;
> +
> +static int open_virtgpu_device(void)
> +{
> +	drmVersionPtr version;
> +
> +	for (int i = 0; i < MAX_CARDS; i++) {
> +		char path[64];
> +
> +		snprintf(path, sizeof(path), "/dev/dri/card%d", i);
> +		drm_fd = open(path, O_RDWR | O_CLOEXEC);
> +		if (drm_fd < 0)
> +			continue;
> +
> +		version = drmGetVersion(drm_fd);
> +		if (version && strcmp(version->name, "virtio_gpu") == 0) {
> +			drmFreeVersion(version);

You could print path here (with igt_info or igt_debug).

> +			return drm_fd;
> +		}
> +
> +		drmFreeVersion(version);
> +		close(drm_fd);
> +	}

Same here, you could print number of opened devices (with drm_fd >=0)

Regards,
Kamil

> +	return -1;
> +}
> +
> +static const struct {
> +	const char *name;
> +	uint64_t id;
> +} params[] = {
> +	{"3D_FEATURES", VIRTGPU_PARAM_3D_FEATURES},
> +	{"CAPSET_QUERY_FIX", VIRTGPU_PARAM_CAPSET_QUERY_FIX},
> +	{"RESOURCE_BLOB", VIRTGPU_PARAM_RESOURCE_BLOB},
> +	{"HOST_VISIBLE", VIRTGPU_PARAM_HOST_VISIBLE},
> +	{"CROSS_DEVICE", VIRTGPU_PARAM_CROSS_DEVICE},
> +	{"CONTEXT_INIT", VIRTGPU_PARAM_CONTEXT_INIT},
> +	{"SUPPORTED_CAPSET_IDs", VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs},
> +	{"EXPLICIT_DEBUG_NAME", VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME},
> +};
> +

...cut...

> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 20ddddb89..ac85cac30 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -13,6 +13,7 @@ test_progs = [
>  	'drm_buddy',
>  	'drm_mm',
>  	'drm_read',
> +	'drm_virtgpu',
>  	'fbdev',
>  	'kms_3d',
>  	'kms_addfb_basic',
> -- 
> 2.48.1
> 


More information about the igt-dev mailing list