Skip to contentSkip to conversation

libxl: set channel devid when not provided by application

PATCH Superseded Jim Fehlig 3 participants 4 messages Feb 8, 2018 – Feb 23, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jim Fehlig

author
#0 lore raw

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

---

I get the feeling that if needed devid should be set earlier, but this seems like the most opportune spot. Suggestions for improvements welcome.

 tools/libxl/libxl_console.c | 3 +++
 1 file changed, 3 insertions(+)
tools/libxl/libxl_console.c +3 -0
index 39d8430df8..8faf3a24f3 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;
Signature · 7 lines
2.16.0


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

Any comments on this patch? Thanks!

Regards,
Jim

Quoted 32 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

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

---

I get the feeling that if needed devid should be set earlier, but this seems like the most opportune spot. Suggestions for improvements welcome.

  tools/libxl/libxl_console.c | 3 +++
  1 file changed, 3 insertions(+)
tools/libxl/libxl_console.c +0 -0
index 39d8430df8..8faf3a24f3 100644

tools/libxl/libxl_console.c int libxl__init_console_from_channel(libxl__gc *gc, · line 409

Quoted 9 lines
tools/libxl/libxl_console.c +3 -0
@@ -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;

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

#2 lore raw
In reply to Jim Fehlig
Quoted 31 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

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

---

I get the feeling that if needed devid should be set earlier, but this seems like the most opportune spot. Suggestions for improvements welcome.

 tools/libxl/libxl_console.c | 3 +++
 1 file changed, 3 insertions(+)
tools/libxl/libxl_console.c +0 -0
index 39d8430df8..8faf3a24f3 100644

tools/libxl/libxl_console.c int libxl__init_console_from_channel(libxl__gc *gc, · line 405

Quoted 5 lines
tools/libxl/libxl_console.c +2 -0
@@ -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;

This chunk looks fine, but below in this function there's a:

console->devid = dev_num;

Which needs to be replaced with:

console->devid = channel->devid;

In this same patch.

Thanks, Roger.

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

#3 lore raw
In reply to Jim Fehlig
Quoted 16 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

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

Quoted 6 lines

---

I get the feeling that if needed devid should be set earlier, but this seems like the most opportune spot. Suggestions for improvements welcome.

I think this approach is fine.

Wei.

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