summaryrefslogtreecommitdiff
path: root/hw/spice-vmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/spice-vmc.c')
-rw-r--r--hw/spice-vmc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
index 738de307e..8e8255258 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;
@@ -172,18 +173,55 @@ static void vmc_have_data(VirtIOSerialPort *port, const uint8_t *buf, size_t len
spice_server_char_device_wakeup(&svc->sin);
}
+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);
+ svc->sin.subtype = svc->subtype;
virtio_serial_open(port);
return 0;
}
@@ -212,6 +250,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(),
}
};