Skip to contentSkip to conversation

tools/xl: fix channel configuration setting

PATCH Superseded Juergen Gross 2 participants 2 messages Feb 24, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xl: fix channel configuration setting

Channels work differently than other device types: their devid should be -1 initially in order to distinguish them from the primary console which has the devid of 0.

So when parsing the channel configuration, set devid explicitly to -1 after expanding the channels array, as this expansion of the array will have set the devid to the index of the item in the array, overwriting the -1 initialization done by libxl_device_channel_init().

---
 tools/xl/xl_parse.c | 3 +++
 1 file changed, 3 insertions(+)
tools/xl/xl_parse.c +3 -0
index 3d85be7dd4..4705f6fd4b 100644
@@ -2426,6 +2426,9 @@ void parse_config_data(const char *config_source,
             chn = ARRAY_EXTEND_INIT(d_config->channels, d_config->num_channels,
                                    libxl_device_channel_init);
 
+            /* ARRAY_EXTEND_INIT() has set the devid, but it must be -1. */
+            chn->devid = -1;
+
             split_string_into_string_list(buf, ",", &pairs);
             len = libxl_string_list_length(&pairs);
             for (i = 0; i < len; i++) {
Signature · 1 line
2.43.0
#1 lore raw
Quoted 19 lines · Juergen Gross

Channels work differently than other device types: their devid should be -1 initially in order to distinguish them from the primary console which has the devid of 0.

So when parsing the channel configuration, set devid explicitly to -1 after expanding the channels array, as this expansion of the array will have set the devid to the index of the item in the array, overwriting the -1 initialization done by libxl_device_channel_init().

---
 tools/xl/xl_parse.c | 3 +++
 1 file changed, 3 insertions(+)
tools/xl/xl_parse.c +0 -0
index 3d85be7dd4..4705f6fd4b 100644

tools/xl/xl_parse.c void parse_config_data(const char *config_source, · line 2431

Quoted 6 lines
tools/xl/xl_parse.c +3 -0
@@ -2426,6 +2426,9 @@ void parse_config_data(const char *config_source,
             chn = ARRAY_EXTEND_INIT(d_config->channels, d_config->num_channels,
                                    libxl_device_channel_init);
 
+            /* ARRAY_EXTEND_INIT() has set the devid, but it must be -1. */
+            chn->devid = -1;
+

You can use ARRAY_EXTEND_INIT_NODEVID() instead which doesn't touch devid and let the value set by libxl_device_channel_init().

Cheers,

Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech