xref: /qemu/include/ui/qemu-spice.h (revision 2e31e210a8590461d428855426a04dfa49717b51)
129b0040bSGerd Hoffmann /*
229b0040bSGerd Hoffmann  * Copyright (C) 2010 Red Hat, Inc.
329b0040bSGerd Hoffmann  *
429b0040bSGerd Hoffmann  * This program is free software; you can redistribute it and/or
529b0040bSGerd Hoffmann  * modify it under the terms of the GNU General Public License as
629b0040bSGerd Hoffmann  * published by the Free Software Foundation; either version 2 or
729b0040bSGerd Hoffmann  * (at your option) version 3 of the License.
829b0040bSGerd Hoffmann  *
929b0040bSGerd Hoffmann  * This program is distributed in the hope that it will be useful,
1029b0040bSGerd Hoffmann  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1129b0040bSGerd Hoffmann  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1229b0040bSGerd Hoffmann  * GNU General Public License for more details.
1329b0040bSGerd Hoffmann  *
1429b0040bSGerd Hoffmann  * You should have received a copy of the GNU General Public License
1529b0040bSGerd Hoffmann  * along with this program; if not, see <http://www.gnu.org/licenses/>.
1629b0040bSGerd Hoffmann  */
1729b0040bSGerd Hoffmann 
1829b0040bSGerd Hoffmann #ifndef QEMU_SPICE_H
1929b0040bSGerd Hoffmann #define QEMU_SPICE_H
2029b0040bSGerd Hoffmann 
21da34e65cSMarkus Armbruster #include "qapi/error.h"
22*2e31e210SGerd Hoffmann #include "ui/qemu-spice-module.h"
23f7d48052SMarc-André Lureau 
2429b0040bSGerd Hoffmann #ifdef CONFIG_SPICE
2529b0040bSGerd Hoffmann 
2629b0040bSGerd Hoffmann #include <spice.h>
271de7afc9SPaolo Bonzini #include "qemu/config-file.h"
2829b0040bSGerd Hoffmann 
2929b0040bSGerd Hoffmann void qemu_spice_init(void);
30864401c2SGerd Hoffmann void qemu_spice_input_init(void);
319fa03286SGerd Hoffmann void qemu_spice_display_init(void);
32f1f5f407SDaniel P. Berrange int qemu_spice_display_add_client(int csock, int skipauth, int tls);
3329b0040bSGerd Hoffmann int qemu_spice_add_interface(SpiceBaseInstance *sin);
349fa03286SGerd Hoffmann bool qemu_spice_have_display_interface(QemuConsole *con);
359fa03286SGerd Hoffmann int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
367572150cSGerd Hoffmann int qemu_spice_set_passwd(const char *passwd,
377572150cSGerd Hoffmann                           bool fail_if_connected, bool disconnect_if_connected);
387572150cSGerd Hoffmann int qemu_spice_set_pw_expire(time_t expires);
39e866e239SGerd Hoffmann int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
403b5704b2SMarkus Armbruster                             const char *subject);
4129b0040bSGerd Hoffmann 
422368635dSPranith Kumar #if !defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06)
432368635dSPranith Kumar #define SPICE_NEEDS_SET_MM_TIME 1
442368635dSPranith Kumar #else
452368635dSPranith Kumar #define SPICE_NEEDS_SET_MM_TIME 0
462368635dSPranith Kumar #endif
47cbcc6336SAlon Levy 
4829b0040bSGerd Hoffmann #else  /* CONFIG_SPICE */
4929b0040bSGerd Hoffmann 
506f0c894cSEduardo Habkost #include "qemu/error-report.h"
516f0c894cSEduardo Habkost 
5258ae52a8SGerd Hoffmann #define spice_displays 0
5314da8345SJes Sorensen static inline int qemu_spice_set_passwd(const char *passwd,
5414da8345SJes Sorensen                                         bool fail_if_connected,
5514da8345SJes Sorensen                                         bool disconnect_if_connected)
5614da8345SJes Sorensen {
5714da8345SJes Sorensen     return -1;
5814da8345SJes Sorensen }
5914da8345SJes Sorensen static inline int qemu_spice_set_pw_expire(time_t expires)
6014da8345SJes Sorensen {
6114da8345SJes Sorensen     return -1;
6214da8345SJes Sorensen }
63edc5cb1aSYonit Halperin static inline int qemu_spice_migrate_info(const char *h, int p, int t,
643b5704b2SMarkus Armbruster                                           const char *s)
65edc5cb1aSYonit Halperin {
66edc5cb1aSYonit Halperin     return -1;
67edc5cb1aSYonit Halperin }
6829b0040bSGerd Hoffmann 
69f1f5f407SDaniel P. Berrange static inline int qemu_spice_display_add_client(int csock, int skipauth,
70f1f5f407SDaniel P. Berrange                                                 int tls)
71f1f5f407SDaniel P. Berrange {
72f1f5f407SDaniel P. Berrange     return -1;
73f1f5f407SDaniel P. Berrange }
74f1f5f407SDaniel P. Berrange 
756f0c894cSEduardo Habkost static inline void qemu_spice_display_init(void)
766f0c894cSEduardo Habkost {
776f0c894cSEduardo Habkost     /* This must never be called if CONFIG_SPICE is disabled */
786f0c894cSEduardo Habkost     error_report("spice support is disabled");
796f0c894cSEduardo Habkost     abort();
806f0c894cSEduardo Habkost }
816f0c894cSEduardo Habkost 
826f0c894cSEduardo Habkost static inline void qemu_spice_init(void)
836f0c894cSEduardo Habkost {
846f0c894cSEduardo Habkost }
856f0c894cSEduardo Habkost 
8629b0040bSGerd Hoffmann #endif /* CONFIG_SPICE */
8729b0040bSGerd Hoffmann 
88b25d81baSMarkus Armbruster static inline bool qemu_using_spice(Error **errp)
89b25d81baSMarkus Armbruster {
90b25d81baSMarkus Armbruster     if (!using_spice) {
91cfa9bb23SMarkus Armbruster         error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE,
92cfa9bb23SMarkus Armbruster                   "SPICE is not in use");
93b25d81baSMarkus Armbruster         return false;
94b25d81baSMarkus Armbruster     }
95b25d81baSMarkus Armbruster     return true;
96b25d81baSMarkus Armbruster }
97b25d81baSMarkus Armbruster 
9829b0040bSGerd Hoffmann #endif /* QEMU_SPICE_H */
99