[Spice-devel] [spice-server 2/3] test-display-base: Pass proper types to spice_server_add_interface
Christophe Fergeau
cfergeau at redhat.com
Mon Jan 30 17:30:39 UTC 2017
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.
---
server/tests/test-display-base.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/server/tests/test-display-base.c b/server/tests/test-display-base.c
index 5a7e775..302d468 100644
--- a/server/tests/test-display-base.c
+++ b/server/tests/test-display-base.c
@@ -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",
};
--
2.9.3
More information about the Spice-devel
mailing list