libxl: set channel devid when not provided by application
authorJim Fehlig <jfehlig@suse.com>
Mon, 26 Feb 2018 18:28:39 +0000 (11:28 -0700)
committerWei Liu <wei.liu2@citrix.com>
Fri, 2 Mar 2018 11:47:39 +0000 (11:47 +0000)
commit3a667963476664ea50956d72e04bafdd4bef31b2
tree439fc512ee9cc02a5189af512e4fa7b96694f499
parent9eaaedfcdee5dd50f8440d72cc759775ec3ce164
libxl: set channel devid when not provided by application

Applications like libvirt may not populate a device devid field,
delegating that to libxl. If needed, the application can later
retrieve the libxl-produced devid. Indeed most devices are handled
this way in libvirt, channel devices included.

This works well when only one channel device is defined, but more
than one results in

qemu-system-i386: -chardev socket,id=libxl-channel-1,\
path=/tmp/test-org.qemu.guest_agent.00,server,nowait:
Duplicate ID 'libxl-channel-1' for chardev

Besides the odd '-1' value in the id, multiple channels have the same
id, causing qemu to fail. A simple fix is to set an uninitialized
devid (-1) to the dev_num passed to libxl__init_console_from_channel().

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
tools/libxl/libxl_console.c