* [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes
@ 2016-03-24 7:56 Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 1/3] input-linux: switch over to -object Gerd Hoffmann
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-03-24 7:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hi,
Here comes the ui patch queue, with input-linux and spice fixes.
Most notably this changes the input-linux command line as it is
switched over to -object instead of adding a new switch.
Dropped cocoa patches in v2 as Peter has picked them up.
please pull,
Gerd
The following changes since commit 2538039f2c26d66053426fb547e4f25e669baf62:
Merge remote-tracking branch 'remotes/armbru/tags/pull-ivshmem-2016-03-18' into staging (2016-03-23 12:57:44 +0000)
are available in the git repository at:
git://git.kraxel.org/qemu tags/pull-ui-20160324-1
for you to fetch changes up to 569a93cbbe428bb5c583ae4bf31447eb3acc30fe:
spice: Disallow use of gl + TCP port (2016-03-24 08:04:01 +0100)
----------------------------------------------------------------
input-linux + spice fixes
----------------------------------------------------------------
Christophe Fergeau (1):
spice: Disallow use of gl + TCP port
Gerd Hoffmann (2):
input-linux: switch over to -object
input-linux: fix Coverity warning
qemu-options.hx | 9 ---
ui/input-linux.c | 165 +++++++++++++++++++++++++++++++++++++++++++------------
ui/spice-core.c | 5 ++
vl.c | 10 ----
4 files changed, 135 insertions(+), 54 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 1/3] input-linux: switch over to -object
2016-03-24 7:56 [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Gerd Hoffmann
@ 2016-03-24 7:56 ` Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 2/3] input-linux: fix Coverity warning Gerd Hoffmann
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-03-24 7:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Gerd Hoffmann
This patches makes input-linux use -object instead of a new command line
switch. So, instead of the switch ...
-input-linux /dev/input/event$nr
... you must create an object this way:
-object input-linux,id=$name,evdev=/dev/input/event$nr
Bonus is that you can hot-add and hot-remove them via monitor now.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1457681901-30916-1-git-send-email-kraxel@redhat.com
---
qemu-options.hx | 9 ----
ui/input-linux.c | 158 +++++++++++++++++++++++++++++++++++++++++++------------
vl.c | 10 ----
3 files changed, 123 insertions(+), 54 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 732ed8c..b98fa3e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1226,15 +1226,6 @@ STEXI
Set the initial graphical resolution and depth (PPC, SPARC only).
ETEXI
-DEF("input-linux", 1, QEMU_OPTION_input_linux,
- "-input-linux <evdev>\n"
- " Use input device.\n", QEMU_ARCH_ALL)
-STEXI
-@item -input-linux @var{dev}
-@findex -input-linux
-Use input device.
-ETEXI
-
DEF("vnc", HAS_ARG, QEMU_OPTION_vnc ,
"-vnc display start a VNC server on display\n", QEMU_ARCH_ALL)
STEXI
diff --git a/ui/input-linux.c b/ui/input-linux.c
index 2cf5d49..59d9348 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -10,6 +10,7 @@
#include "qemu/sockets.h"
#include "sysemu/sysemu.h"
#include "ui/input.h"
+#include "qom/object_interfaces.h"
#include <sys/ioctl.h>
#include "standard-headers/linux/input.h"
@@ -127,10 +128,21 @@ static int qemu_input_linux_to_qcode(unsigned int lnx)
return linux_to_qcode[lnx];
}
+#define TYPE_INPUT_LINUX "input-linux"
+#define INPUT_LINUX(obj) \
+ OBJECT_CHECK(InputLinux, (obj), TYPE_INPUT_LINUX)
+#define INPUT_LINUX_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(InputLinuxClass, (obj), TYPE_INPUT_LINUX)
+#define INPUT_LINUX_CLASS(klass) \
+ OBJECT_CLASS_CHECK(InputLinuxClass, (klass), TYPE_INPUT_LINUX)
+
typedef struct InputLinux InputLinux;
+typedef struct InputLinuxClass InputLinuxClass;
struct InputLinux {
- const char *evdev;
+ Object parent;
+
+ char *evdev;
int fd;
bool repeat;
bool grab_request;
@@ -139,9 +151,14 @@ struct InputLinux {
bool keydown[KEY_CNT];
int keycount;
int wheel;
+ bool initialized;
QTAILQ_ENTRY(InputLinux) next;
};
+struct InputLinuxClass {
+ ObjectClass parent_class;
+};
+
static QTAILQ_HEAD(, InputLinux) inputs = QTAILQ_HEAD_INITIALIZER(inputs);
static void input_linux_toggle_grab(InputLinux *il)
@@ -309,25 +326,21 @@ static void input_linux_event_mouse(void *opaque)
}
}
-int input_linux_init(void *opaque, QemuOpts *opts, Error **errp)
+static void input_linux_complete(UserCreatable *uc, Error **errp)
{
- InputLinux *il = g_new0(InputLinux, 1);
+ InputLinux *il = INPUT_LINUX(uc);
uint32_t evtmap;
int rc, ver;
- il->evdev = qemu_opt_get(opts, "evdev");
- il->grab_all = qemu_opt_get_bool(opts, "grab-all", false);
- il->repeat = qemu_opt_get_bool(opts, "repeat", false);
-
if (!il->evdev) {
error_setg(errp, "no input device specified");
- goto err_free;
+ return;
}
il->fd = open(il->evdev, O_RDWR);
if (il->fd < 0) {
error_setg_file_open(errp, errno, il->evdev);
- goto err_free;
+ return;
}
qemu_set_nonblock(il->fd);
@@ -356,36 +369,111 @@ int input_linux_init(void *opaque, QemuOpts *opts, Error **errp)
}
input_linux_toggle_grab(il);
QTAILQ_INSERT_TAIL(&inputs, il, next);
- return 0;
+ il->initialized = true;
+ return;
err_close:
close(il->fd);
-err_free:
- g_free(il);
- return -1;
-}
-
-static QemuOptsList qemu_input_linux_opts = {
- .name = "input-linux",
- .head = QTAILQ_HEAD_INITIALIZER(qemu_input_linux_opts.head),
- .implied_opt_name = "evdev",
- .desc = {
- {
- .name = "evdev",
- .type = QEMU_OPT_STRING,
- },{
- .name = "grab-all",
- .type = QEMU_OPT_BOOL,
- },{
- .name = "repeat",
- .type = QEMU_OPT_BOOL,
- },
- { /* end of list */ }
- },
+ return;
+}
+
+static void input_linux_instance_finalize(Object *obj)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ if (il->initialized) {
+ QTAILQ_REMOVE(&inputs, il, next);
+ close(il->fd);
+ }
+ g_free(il->evdev);
+}
+
+static char *input_linux_get_evdev(Object *obj, Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ return g_strdup(il->evdev);
+}
+
+static void input_linux_set_evdev(Object *obj, const char *value,
+ Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ if (il->evdev) {
+ error_setg(errp, "evdev property already set");
+ return;
+ }
+ il->evdev = g_strdup(value);
+}
+
+static bool input_linux_get_grab_all(Object *obj, Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ return il->grab_all;
+}
+
+static void input_linux_set_grab_all(Object *obj, bool value,
+ Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ il->grab_all = value;
+}
+
+static bool input_linux_get_repeat(Object *obj, Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ return il->repeat;
+}
+
+static void input_linux_set_repeat(Object *obj, bool value,
+ Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+
+ il->repeat = value;
+}
+
+static void input_linux_instance_init(Object *obj)
+{
+ object_property_add_str(obj, "evdev",
+ input_linux_get_evdev,
+ input_linux_set_evdev, NULL);
+ object_property_add_bool(obj, "grab_all",
+ input_linux_get_grab_all,
+ input_linux_set_grab_all, NULL);
+ object_property_add_bool(obj, "repeat",
+ input_linux_get_repeat,
+ input_linux_set_repeat, NULL);
+}
+
+static void input_linux_class_init(ObjectClass *oc, void *data)
+{
+ UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
+
+ ucc->complete = input_linux_complete;
+}
+
+static const TypeInfo input_linux_info = {
+ .name = TYPE_INPUT_LINUX,
+ .parent = TYPE_OBJECT,
+ .class_size = sizeof(InputLinuxClass),
+ .class_init = input_linux_class_init,
+ .instance_size = sizeof(InputLinux),
+ .instance_init = input_linux_instance_init,
+ .instance_finalize = input_linux_instance_finalize,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_USER_CREATABLE },
+ { }
+ }
};
-static void input_linux_register_config(void)
+static void register_types(void)
{
- qemu_add_opts(&qemu_input_linux_opts);
+ type_register_static(&input_linux_info);
}
-opts_init(input_linux_register_config);
+
+type_init(register_types);
diff --git a/vl.c b/vl.c
index 40ed4d0..ca49e75 100644
--- a/vl.c
+++ b/vl.c
@@ -3729,12 +3729,6 @@ int main(int argc, char **argv, char **envp)
#endif
break;
}
- case QEMU_OPTION_input_linux:
- if (!qemu_opts_parse_noisily(qemu_find_opts("input-linux"),
- optarg, true)) {
- exit(1);
- }
- break;
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
@@ -4598,10 +4592,6 @@ int main(int argc, char **argv, char **envp)
qemu_spice_display_init();
}
#endif
-#ifdef CONFIG_LINUX
- qemu_opts_foreach(qemu_find_opts("input-linux"),
- input_linux_init, NULL, &error_fatal);
-#endif
if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
exit(1);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 2/3] input-linux: fix Coverity warning
2016-03-24 7:56 [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 1/3] input-linux: switch over to -object Gerd Hoffmann
@ 2016-03-24 7:56 ` Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 3/3] spice: Disallow use of gl + TCP port Gerd Hoffmann
2016-03-24 16:23 ` [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-03-24 7:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1458129049-12484-1-git-send-email-kraxel@redhat.com
---
ui/input-linux.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/ui/input-linux.c b/ui/input-linux.c
index 59d9348..6ddaa67 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -213,6 +213,13 @@ static void input_linux_event_keyboard(void *opaque)
*/
continue;
}
+ if (event.code >= KEY_CNT) {
+ /*
+ * Should not happen. But better safe than sorry,
+ * and we make Coverity happy too.
+ */
+ continue;
+ }
/* keep track of key state */
if (!il->keydown[event.code] && event.value) {
il->keydown[event.code] = true;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 3/3] spice: Disallow use of gl + TCP port
2016-03-24 7:56 [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 1/3] input-linux: switch over to -object Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 2/3] input-linux: fix Coverity warning Gerd Hoffmann
@ 2016-03-24 7:56 ` Gerd Hoffmann
2016-03-24 16:23 ` [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-03-24 7:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Christophe Fergeau
From: Christophe Fergeau <cfergeau@redhat.com>
Currently, virgl support has to go through a local unix socket, trying
to connect to a VM using -spice gl through spice://localhost:5900 will
only result in a black screen.
This commit errors out when the user tries to start a VM with both GL
support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call
into spice-server when parsing 'gl' on its command line, so we have to
do this check in QEMU instead.
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 1457955672-28758-1-git-send-email-cfergeau@redhat.com
[ applied codestyle fix: break long line ]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/spice-core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ui/spice-core.c b/ui/spice-core.c
index e117925..61db3c1 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -828,6 +828,11 @@ void qemu_spice_init(void)
#ifdef HAVE_SPICE_GL
if (qemu_opt_get_bool(opts, "gl", 0)) {
+ if ((port != 0) || (tls_port != 0)) {
+ error_report("SPICE GL support is local-only for now and "
+ "incompatible with -spice port/tls-port");
+ exit(1);
+ }
if (egl_rendernode_init() == 0) {
display_opengl = 1;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes
2016-03-24 7:56 [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Gerd Hoffmann
` (2 preceding siblings ...)
2016-03-24 7:56 ` [Qemu-devel] [PULL 3/3] spice: Disallow use of gl + TCP port Gerd Hoffmann
@ 2016-03-24 16:23 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2016-03-24 16:23 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU Developers
On 24 March 2016 at 07:56, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Hi,
>
> Here comes the ui patch queue, with input-linux and spice fixes.
> Most notably this changes the input-linux command line as it is
> switched over to -object instead of adding a new switch.
>
> Dropped cocoa patches in v2 as Peter has picked them up.
>
> please pull,
> Gerd
>
> The following changes since commit 2538039f2c26d66053426fb547e4f25e669baf62:
>
> Merge remote-tracking branch 'remotes/armbru/tags/pull-ivshmem-2016-03-18' into staging (2016-03-23 12:57:44 +0000)
>
> are available in the git repository at:
>
>
> git://git.kraxel.org/qemu tags/pull-ui-20160324-1
>
> for you to fetch changes up to 569a93cbbe428bb5c583ae4bf31447eb3acc30fe:
>
> spice: Disallow use of gl + TCP port (2016-03-24 08:04:01 +0100)
>
> ----------------------------------------------------------------
> input-linux + spice fixes
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-24 16:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-24 7:56 [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 1/3] input-linux: switch over to -object Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 2/3] input-linux: fix Coverity warning Gerd Hoffmann
2016-03-24 7:56 ` [Qemu-devel] [PULL 3/3] spice: Disallow use of gl + TCP port Gerd Hoffmann
2016-03-24 16:23 ` [Qemu-devel] [PULL v2 0/3] ui: input-linux + spice fixes Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).