reds: Check QXL ID registering interface

Avoid to register multiple interface with the same ID.
This would result in issues as 2 channels would have the same
(channel_type, channel_id) which must be unique.
Qemu always allocates QXL interface with IDs starting from 0.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2019-02-13 14:46:16 +00:00
parent d15382d9a7
commit 818e44b5df

View File

@ -3378,6 +3378,14 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
}
qxl = SPICE_UPCAST(QXLInstance, sin);
if (qxl->id < 0) {
spice_warning("invalid QXL ID");
return -1;
}
if (reds_find_channel(reds, SPICE_CHANNEL_DISPLAY, qxl->id)) {
spice_warning("QXL ID already allocated");
return -1;
}
red_qxl_init(reds, qxl);
reds->qxl_instances = g_list_prepend(reds->qxl_instances, qxl);