summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-08-25 20:11:59 +0300
committerAlon Levy <alevy@redhat.com>2010-08-25 20:35:13 +0300
commit9f3b5da1a2824f4833ba440e912aad020e91f520 (patch)
tree60462d12d0ca18662c7bd71d336342fe41e4e032
parent98e7896c859a70379662463a4f5084547ef6d449 (diff)
spice-{vmc,vdi}: implement subtypevdiport_refactor.v2
-rw-r--r--hw/spice-vdi.c6
-rw-r--r--hw/spice-vmc.c47
2 files changed, 53 insertions, 0 deletions
diff --git a/hw/spice-vdi.c b/hw/spice-vdi.c
index 415932b81..f5fda4d06 100644
--- a/hw/spice-vdi.c
+++ b/hw/spice-vdi.c
@@ -290,12 +290,18 @@ static int vdi_port_interface_read(SpiceCharDeviceInstance *sin,
return actual_read;
}
+static const char* vdi_port_subtype(SpiceCharDeviceInstance* sin)
+{
+ return "vdagent";
+}
+
static SpiceCharDeviceInterface vdi_port_interface = {
.base.type = SPICE_INTERFACE_CHAR_DEVICE,
.base.description = "vdi port",
.base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
.base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
+ .subtype = vdi_port_subtype,
.write = vdi_port_interface_write,
.read = vdi_port_interface_read,
};
diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
index c58799ec5..b09be7a80 100644
--- a/hw/spice-vmc.c
+++ b/hw/spice-vmc.c
@@ -36,6 +36,7 @@ typedef struct SpiceVirtualChannel {
VirtIOSerialPort port;
VMChangeStateEntry *vmstate;
SpiceCharDeviceInstance sin;
+ char *subtype;
bool active;
uint8_t *buffer;
uint8_t *datapos;
@@ -86,11 +87,20 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
return bytes;
}
+static const char* vmc_subtype(SpiceCharDeviceInstance* sin)
+{
+ SpiceVirtualChannel *scd = container_of(sin, SpiceVirtualChannel, sin);
+
+ dprintf(scd, 2, "%s\n", __func__);
+ return scd->subtype;
+}
+
static SpiceCharDeviceInterface vmc_interface = {
.base.type = SPICE_INTERFACE_CHAR_DEVICE,
.base.description = "spice virtual channel char device",
.base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
.base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
+ .subtype = vmc_subtype,
.write = vmc_write,
.read = vmc_read,
};
@@ -181,15 +191,51 @@ static void vmc_reset(DeviceState *opaque)
vmc_unregister_interface(svc);
}
+static void vmc_print_optional_subtypes(void)
+{
+ const char** psubtype = spice_server_char_device_recognized_subtypes();
+ int i;
+
+ fprintf(stderr, "supported subtypes: ");
+ for(i=0; *psubtype != NULL; ++psubtype, ++i) {
+ if (i == 0) {
+ fprintf(stderr, *psubtype);
+ } else {
+ fprintf(stderr, ", %s", *psubtype);
+ }
+ }
+ fprintf(stderr, "\n");
+}
+
static int vmc_initfn(VirtIOSerialDevice *dev)
{
VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
SpiceVirtualChannel *svc = DO_UPCAST(SpiceVirtualChannel, port, port);
+ const char** psubtype = spice_server_char_device_recognized_subtypes();
+ const char *subtype = NULL;
if (!using_spice)
return -1;
dprintf(svc, 1, "%s\n", __func__);
+
+ if (svc->subtype == NULL) {
+ fprintf(stderr, "spice-vmc: you must supply a subtype\n");
+ vmc_print_optional_subtypes();
+ return -1;
+ }
+
+ for(;*psubtype != NULL; ++psubtype) {
+ if (strcmp(svc->subtype, *psubtype) == 0) {
+ subtype = *psubtype;
+ break;
+ }
+ }
+ if (subtype == NULL) {
+ fprintf(stderr, "spice-vmc: unsupported subtype\n");
+ vmc_print_optional_subtypes();
+ return -1;
+ }
port->name = qemu_strdup(VMC_GUEST_DEVICE_NAME);
svc->vmstate = qemu_add_vm_change_state_handler(
vmc_change_state_handler, svc);
@@ -222,6 +268,7 @@ static VirtIOSerialPortInfo vmc_info = {
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("nr", SpiceVirtualChannel, port.id, VIRTIO_CONSOLE_BAD_ID),
DEFINE_PROP_UINT32("debug", SpiceVirtualChannel, debug, 1),
+ DEFINE_PROP_STRING("subtype", SpiceVirtualChannel, subtype),
DEFINE_PROP_END_OF_LIST(),
}
};