Skip to contentSkip to conversation

libxl: fix printing hotplug arguments/environment

PATCH Superseded Roger Pau Monne 2 participants 5 messages Aug 1, 2016 – Aug 2, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: fix printing hotplug arguments/environment

A OS could decide to not pass arguments or any environment variables to hotplug scripts, and this will trigger a bug in device_hotplug logic, since it expects both the argument and the environment arrays to exist. Allow both args or env to be NULL.

---
Cc: Wei Liu <[email protected]>
Cc: Ian Jackson <[email protected]>

---
 tools/libxl/libxl_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_device.c +2 -2
index b9a6df2..0e5f546 100644
@@ -1132,7 +1132,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
 
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
-    {
+    if ( args != NULL) {
         const char *arg;
         unsigned int x;
 
@@ -1140,7 +1140,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if ( env != NULL) {
         const char *k, *v;
         unsigned int x;
 
Signature · 7 lines
2.7.4 (Apple Git-66)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 1 line · Roger Pau Monne

A OS could decide to not pass arguments or any environment variables to

"An"

Quoted 17 lines

hotplug scripts, and this will trigger a bug in device_hotplug logic, since it expects both the argument and the environment arrays to exist. Allow both args or env to be NULL.

---
Cc: Wei Liu <[email protected]>
Cc: Ian Jackson <[email protected]>

---
 tools/libxl/libxl_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_device.c +0 -0
index b9a6df2..0e5f546 100644

tools/libxl/libxl_device.c static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) · line 1135

Quoted 5 lines
tools/libxl/libxl_device.c +1 -1
@@ -1132,7 +1132,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
 
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
-    {
+    if ( args != NULL) {

Minor nit, extraneous space here.

Shouldn't this check be moved before the "calling hotplug script..." line?

Quoted 15 lines
tools/libxl/libxl_device.c +1 -1
         const char *arg;
         unsigned int x;
 
@@ -1140,7 +1140,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if ( env != NULL) {
         const char *k, *v;
         unsigned int x;
 
Signature · 1 line
2.7.4 (Apple Git-66)

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

#2 lore raw
Quoted 30 lines · Wei Liu
Quoted 1 line · Roger Pau Monne

A OS could decide to not pass arguments or any environment variables to

"An"

Quoted 17 lines

hotplug scripts, and this will trigger a bug in device_hotplug logic, since it expects both the argument and the environment arrays to exist. Allow both args or env to be NULL.

---
Cc: Wei Liu <[email protected]>
Cc: Ian Jackson <[email protected]>

---
 tools/libxl/libxl_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_device.c +0 -0
index b9a6df2..0e5f546 100644

tools/libxl/libxl_device.c static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) · line 1135

Quoted 5 lines
tools/libxl/libxl_device.c +1 -1
@@ -1132,7 +1132,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
 
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
-    {
+    if ( args != NULL) {

Minor nit, extraneous space here.

Quoted 2 lines

Shouldn't this check be moved before the "calling hotplug script..." line?

This one should be removed, args cannot be NULL or else we won't call anything, and thus libxl__get_hotplug_script_info should return 0.

Quoted 12 lines
Quoted 12 lines
tools/libxl/libxl_device.c +1 -1
         const char *arg;
         unsigned int x;
 
@@ -1140,7 +1140,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if ( env != NULL) {
         const char *k, *v;
         unsigned int x;
 
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.7.4 (Apple Git-66)

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

#3 lore raw
Quoted 31 lines · Roger Pau Monne
Quoted 30 lines · Wei Liu
Quoted 1 line · Roger Pau Monne

A OS could decide to not pass arguments or any environment variables to

"An"

Quoted 17 lines

hotplug scripts, and this will trigger a bug in device_hotplug logic, since it expects both the argument and the environment arrays to exist. Allow both args or env to be NULL.

---
Cc: Wei Liu <[email protected]>
Cc: Ian Jackson <[email protected]>

---
 tools/libxl/libxl_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_device.c +0 -0
index b9a6df2..0e5f546 100644

tools/libxl/libxl_device.c static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev) · line 1135

Quoted 5 lines
tools/libxl/libxl_device.c +1 -1
@@ -1132,7 +1132,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
 
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
-    {
+    if ( args != NULL) {

Minor nit, extraneous space here.

Quoted 6 lines
Quoted 2 lines

Shouldn't this check be moved before the "calling hotplug script..." line?

This one should be removed, args cannot be NULL or else we won't call anything, and thus libxl__get_hotplug_script_info should return 0.

OK, please update the patch commit message and content.

I will wait for v2.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
tools/libxl/libxl_device.c +1 -1
         const char *arg;
         unsigned int x;
 
@@ -1140,7 +1140,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if ( env != NULL) {
         const char *k, *v;
         unsigned int x;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.7.4 (Apple Git-66)

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