summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-08-31 10:52:28 +0300
committerAlon Levy <alevy@redhat.com>2010-08-31 11:37:03 +0300
commitec545d35e836715961f33abb4cc68d16265fe080 (patch)
treeebfbdeacd54a78d6a41985d1af3dabce0781c3e5
parent3a80db1a2927009c5c95c8268cf842fa257c97bb (diff)
spice-{vmc,vdi}: implement subtypespice.kvm.v14
-rw-r--r--hw/spice-vdi.c2
-rw-r--r--hw/spice-vmc.c39
2 files changed, 41 insertions, 0 deletions
diff --git a/hw/spice-vdi.c b/hw/spice-vdi.c
index 415932b81..cd7594fbb 100644
--- a/hw/spice-vdi.c
+++ b/hw/spice-vdi.c
@@ -290,6 +290,7 @@ static int vdi_port_interface_read(SpiceCharDeviceInstance *sin,
return actual_read;
}
+
static SpiceCharDeviceInterface vdi_port_interface = {
.base.type = SPICE_INTERFACE_CHAR_DEVICE,
.base.description = "vdi port",
@@ -505,6 +506,7 @@ static int vdi_port_init(PCIDevice *dev)
vdi->ram_size = ram_size;
vdi->new_gen_on_resume = false;
vdi->running = false;
+ vdi->sin.subtype = "vdagent";
pci_config_set_vendor_id(config, REDHAT_PCI_VENDOR_ID);
pci_config_set_device_id(config, VDI_PORT_DEVICE_ID);
diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
index b3410c051..434c70fa3 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(),
}
};