test-display-base: Pass proper types to spice_server_add_interface

This is a revert of 93b4f4050^ and 93b4f4050.
For a SpiceCharDeviceInstance, the base interface must be a
SpiceCharDeviceInterface instance, not a SpiceBaseInterface instance, or
spice-server code will end up reading out of bounds.

vmc_state/vmc_write/vmc_read implementations also have to be provided.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Christophe Fergeau 2017-01-26 18:30:54 +01:00
parent 14b2f053ab
commit 1afa86c3ee

View File

@ -816,16 +816,43 @@ void test_add_display_interface(Test* test)
spice_server_add_interface(test->server, &test->qxl_instance.base);
}
static SpiceBaseInterface base = {
.type = SPICE_INTERFACE_CHAR_DEVICE,
.description = "test spice virtual channel char device",
.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
static int vmc_write(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
SPICE_GNUC_UNUSED const uint8_t *buf,
int len)
{
printf("%s: %d\n", __func__, len);
return len;
}
static int vmc_read(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
SPICE_GNUC_UNUSED uint8_t *buf,
int len)
{
printf("%s: %d\n", __func__, len);
return 0;
}
static void vmc_state(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
int connected)
{
printf("%s: %d\n", __func__, connected);
}
static SpiceCharDeviceInterface vdagent_sif = {
.base.type = SPICE_INTERFACE_CHAR_DEVICE,
.base.description = "test spice virtual channel char device",
.base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
.base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
.state = vmc_state,
.write = vmc_write,
.read = vmc_read,
};
SpiceCharDeviceInstance vdagent_sin = {
.base = {
.sif = &base,
.sif = &vdagent_sif.base,
},
.subtype = "vdagent",
};