Skip to contentSkip to conversation

libxl: set channel devid when not provided by application

PATCH In review Jim Fehlig 3 participants 3 messages Feb 26, 2018 – Mar 2, 2018

lore
Share & tools
lore

Jim Fehlig

author
#0 lore raw

PATCH v2 1/1 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().

---

V2:
Set console devid to channel devid as part of initializing a console from a channel.

 tools/libxl/libxl_console.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/libxl/libxl_console.c +4 -1
index 39d8430df8..9a02a23c2a 100644
@@ -401,6 +401,9 @@ int libxl__init_console_from_channel(libxl__gc *gc,
 
     /* Perform validation first, allocate second. */
 
+    if (channel->devid == -1)
+        channel->devid = dev_num;
+
     if (!channel->name) {
         LOG(ERROR, "channel %d has no name", channel->devid);
         return ERROR_INVAL;
@@ -446,7 +449,7 @@ int libxl__init_console_from_channel(libxl__gc *gc,
             abort();
     }
 
-    console->devid = dev_num;
+    console->devid = channel->devid;
     console->consback = LIBXL__CONSOLE_BACKEND_IOEMU;
     console->backend_domid = channel->backend_domid;
     console->name = libxl__strdup(NOGC, channel->name);
Signature · 7 lines
2.16.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 12 lines · Jim Fehlig

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

Quoted 5 lines

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().

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v2 1/1
#2 lore raw
In reply to Jim Fehlig
Quoted 12 lines · Jim Fehlig

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

Quoted 5 lines

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().

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel