static void watch_read(void *opaque)
{
SpiceWatch *watch = opaque;
- watch->func(watch->fd, SPICE_WATCH_EVENT_READ, watch->opaque);
+ int fd = watch->fd;
+
+#ifdef WIN32
+ fd = _get_osfhandle(fd);
+#endif
+ watch->func(fd, SPICE_WATCH_EVENT_READ, watch->opaque);
}
static void watch_write(void *opaque)
{
SpiceWatch *watch = opaque;
- watch->func(watch->fd, SPICE_WATCH_EVENT_WRITE, watch->opaque);
+ int fd = watch->fd;
+
+#ifdef WIN32
+ fd = _get_osfhandle(fd);
+#endif
+ watch->func(fd, SPICE_WATCH_EVENT_WRITE, watch->opaque);
}
static void watch_update_mask(SpiceWatch *watch, int event_mask)
{
SpiceWatch *watch;
+#ifdef WIN32
+ fd = _open_osfhandle(fd, _O_BINARY);
+ if (fd < 0) {
+ error_setg_win32(&error_warn, WSAGetLastError(), "Couldn't associate a FD with the SOCKET");
+ return NULL;
+ }
+#endif
+
watch = g_malloc0(sizeof(*watch));
watch->fd = fd;
watch->func = func;
static void watch_remove(SpiceWatch *watch)
{
qemu_set_fd_handler(watch->fd, NULL, NULL, NULL);
+#ifdef WIN32
+ /* SOCKET is owned by spice */
+ qemu_close_socket_osfhandle(watch->fd);
+#endif
g_free(watch);
}
break;
case SPICE_CHANNEL_EVENT_INITIALIZED:
if (auth) {
- server->has_auth = true;
server->auth = g_strdup(auth);
}
add_channel_info(client, info);
.name = "unix",
.type = QEMU_OPT_BOOL,
#endif
- },{
- .name = "password",
- .type = QEMU_OPT_STRING,
},{
.name = "password-secret",
.type = QEMU_OPT_STRING,
port = qemu_opt_get_number(opts, "port", 0);
tls_port = qemu_opt_get_number(opts, "tls-port", 0);
- info->has_auth = true;
info->auth = g_strdup(auth);
-
- info->has_host = true;
info->host = g_strdup(addr ? addr : "*");
- info->has_compiled_version = true;
major = (SPICE_SERVER_VERSION & 0xff0000) >> 16;
minor = (SPICE_SERVER_VERSION & 0xff00) >> 8;
micro = SPICE_SERVER_VERSION & 0xff;
}
passwordSecret = qemu_opt_get(opts, "password-secret");
if (passwordSecret) {
- Error *local_err = NULL;
- if (qemu_opt_get(opts, "password")) {
- error_report("'password' option is mutually exclusive with "
- "'password-secret'");
- exit(1);
- }
password = qcrypto_secret_lookup_as_utf8(passwordSecret,
- &local_err);
- if (!password) {
- error_report_err(local_err);
- exit(1);
- }
- } else {
- str = qemu_opt_get(opts, "password");
- if (str) {
- warn_report("'password' option is deprecated and insecure, "
- "use 'password-secret' instead");
- password = g_strdup(str);
- }
+ &error_fatal);
}
if (tls_port) {
"incompatible with -spice port/tls-port");
exit(1);
}
- if (egl_rendernode_init(qemu_opt_get(opts, "rendernode"),
- DISPLAYGL_MODE_ON) != 0) {
- error_report("Failed to initialize EGL render node for SPICE GL");
- exit(1);
- }
- display_opengl = 1;
+ egl_init(qemu_opt_get(opts, "rendernode"), DISPLAYGL_MODE_ON, &error_fatal);
spice_opengl = 1;
}
#endif
return false;
}
-/*
- * Recursively (in reverse order) appends addresses of PCI devices as it moves
- * up in the PCI hierarchy.
- *
- * @returns true on success, false when the buffer wasn't large enough
- */
-static bool append_pci_address(char *buf, size_t buf_size, const PCIDevice *pci)
-{
- PCIBus *bus = pci_get_bus(pci);
- /*
- * equivalent to if (!pci_bus_is_root(bus)), but the function is not built
- * with PCI_CONFIG=n, avoid using an #ifdef by checking directly
- */
- if (bus->parent_dev != NULL) {
- append_pci_address(buf, buf_size, bus->parent_dev);
- }
-
- size_t len = strlen(buf);
- ssize_t written = snprintf(buf + len, buf_size - len, "/%02x.%x",
- PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn));
-
- return written > 0 && written < buf_size - len;
-}
-
-bool qemu_spice_fill_device_address(QemuConsole *con,
- char *device_address,
- size_t size)
-{
- DeviceState *dev = DEVICE(object_property_get_link(OBJECT(con),
- "device",
- &error_abort));
- PCIDevice *pci = (PCIDevice *) object_dynamic_cast(OBJECT(dev),
- TYPE_PCI_DEVICE);
-
- if (pci == NULL) {
- warn_report("Setting device address of a display device to SPICE: "
- "Not a PCI device.");
- return false;
- }
-
- strncpy(device_address, "pci/0000", size);
- if (!append_pci_address(device_address, size, pci)) {
- warn_report("Setting device address of a display device to SPICE: "
- "Too many PCI devices in the chain.");
- return false;
- }
-
- return true;
-}
-
int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con)
{
if (g_slist_find(spice_consoles, con)) {
static int qemu_spice_display_add_client(int csock, int skipauth, int tls)
{
+#ifdef WIN32
+ csock = qemu_close_socket_osfhandle(csock);
+#endif
if (tls) {
return spice_server_add_ssl_client(spice_server, csock, skipauth);
} else {
opts_init(spice_register_config);
module_opts("spice");
-#ifdef CONFIG_OPENGL
+#ifdef HAVE_SPICE_GL
module_dep("ui-opengl");
#endif