libxl: force netback to wait for hotplug execution before connecting
PATCH 1/1 libxl: force netback to wait for hotplug execution before connecting
By writing an empty "hotplug-status" xenstore node in the backend path libxl can force Linux netback to wait for hotplug script execution before proceeding to the 'connected' state.
This is required so that netback doesn't skip state 2 (InitWait) and thus blocks libxl waiting for such state in order to launch the hotplug script (see libxl__wait_device_connection).
---
Cc: Wei Liu <[email protected]>
Cc: Paul Durrant <[email protected]>
--- tools/libs/light/libxl_nic.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/libs/light/libxl_nic.c +7 -0
@@ -248,6 +248,13 @@ static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid,flexarray_append (ro_front,"mtu" );flexarray_append (ro_front,GCSPRINTF ("%u" , nic->mtu)); +/* +* Force backend to wait for hotplug script execution before switching to +* connected state. +*/ +flexarray_append (back,"hotplug-status" ); +flexarray_append (back,"" ); +return 0 ; }
Signature · 1 line
2.34.1
Quoted 8 lines · Roger Pau Monne
By writing an empty "hotplug-status" xenstore node in the backend path libxl can force Linux netback to wait for hotplug script execution before proceeding to the 'connected' state.
This is required so that netback doesn't skip state 2 (InitWait) and thus blocks libxl waiting for such state in order to launch the hotplug script (see
libxl__wait_device_connection).
Quoted 6 lines
Reported-by James Dingwall <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>Tested-by James Dingwall <[email protected]>---
Cc: Wei Liu <[email protected]>
Cc: Paul Durrant <[email protected]>
Quoted 22 lines
--- tools/libs/light/libxl_nic.c | 7 +++++++ 1 file changed, 7 insertions(+)tools/libs/light/libxl_nic.c +7
-0@@ -248,6 +248,13 @@ static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid,flexarray_append (ro_front,"mtu" );flexarray_append (ro_front,GCSPRINTF ("%u" , nic->mtu)); +/* +* Force backend to wait for hotplug script execution before switching to +* connected state. +*/ +flexarray_append (back,"hotplug-status" ); +flexarray_append (back,"" ); +return 0 ; }
Hi,
Quoted 3 lines · Roger Pau Monne
By writing an empty "hotplug-status" xenstore node in the backend path libxl can force Linux netback to wait for hotplug script execution before proceeding to the 'connected' state.
I was actually chasing the same issue today :).
Quoted 2 lines
This is required so that netback doesn't skip state 2 (InitWait) and
Technically netback never skip state 2 (otherwise it would always be reproducible). Instead, libxl may not be able to observe state 2 because receive a watch is asynchronous and doesn't contain the value of the node. So the backend may have moved to Connected before the state is read.
Quoted 6 lines
thus blocks libxl waiting for such state in order to launch the hotplug script (see
libxl__wait_device_connection).Reported-by James Dingwall <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>Tested-by James Dingwall <[email protected]>
I could easily reproduced by adding a sleep(1) before reading the key and use 'xl network-attach ...'.
Quoted 15 lines
---
Cc: Wei Liu <[email protected]>
Cc: Paul Durrant <[email protected]>--- tools/libs/light/libxl_nic.c | 7 +++++++ 1 file changed, 7 insertions(+)tools/libs/light/libxl_nic.c +0
-0@@ -248,6 +248,13 @@ static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid,flexarray_append (ro_front,"mtu" );flexarray_append (ro_front,GCSPRINTF ("%u" , nic->mtu));
tools/libs/light/libxl_nic.c static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid, · line 260
Quoted 10 lines
tools/libs/light/libxl_nic.c +7
-0+/* +* Force backend to wait for hotplug script execution before switching to +* connected state. +*/ +flexarray_append (back,"hotplug-status" ); +flexarray_append (back,"" ); +return 0 ; }
Cheers,
Signature · 1 line
Julien Grall
Quoted 10 lines · Julien Grall
Hi,
Quoted 3 lines · Roger Pau Monne
By writing an empty "hotplug-status" xenstore node in the backend path libxl can force Linux netback to wait for hotplug script execution before proceeding to the 'connected' state.
I was actually chasing the same issue today :).
Quoted 1 line
Quoted 6 lines
Quoted 1 line
This is required so that netback doesn't skip state 2 (InitWait) and
Technically netback never skip state 2 (otherwise it would always be reproducible). Instead, libxl may not be able to observe state 2 because receive a watch is asynchronous and doesn't contain the value of the node. So the backend may have moved to Connected before the state is read.
Right, might be more accurate to say it skips waiting for hotplug script execution, and thus jumps from state 2 into 4. Note I think it's also possible that by the time we setup the watch in libxl the state has already been set to 4.
Thanks, Roger.
Hi Roger,
Quoted 13 lines · Roger Pau Monné
Quoted 12 lines · Julien Grall
Hi,
Quoted 3 lines · Roger Pau Monne
By writing an empty "hotplug-status" xenstore node in the backend path libxl can force Linux netback to wait for hotplug script execution before proceeding to the 'connected' state.
I was actually chasing the same issue today :).
Quoted 2 lines
This is required so that netback doesn't skip state 2 (InitWait) and
Quoted 7 lines
Quoted 4 lines
Technically netback never skip state 2 (otherwise it would always be reproducible). Instead, libxl may not be able to observe state 2 because receive a watch is asynchronous and doesn't contain the value of the node. So the backend may have moved to Connected before the state is read.
Right, might be more accurate to say it skips waiting for hotplug script execution, and thus jumps from state 2 into 4.
I would add the jump happens when the frontend decides to connect.
Quoted 3 lines
Note I think
it's also possible that by the time we setup the watch in libxl the state has already been set to 4.
Correct.
Cheers,
Signature · 1 line
Julien Grall
Quoted 11 lines · Roger Pau Monne
By writing an empty "hotplug-status" xenstore node in the backend path libxl can force Linux netback to wait for hotplug script execution before proceeding to the 'connected' state.
This is required so that netback doesn't skip state 2 (InitWait) and thus blocks libxl waiting for such state in order to launch the hotplug script (see
libxl__wait_device_connection).Reported-by James Dingwall <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>Tested-by James Dingwall <[email protected]>