Hi,
On 24/01/2022 16:02, Roger Pau Monne wrote:
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 :).
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.
thus blocks libxl waiting for such state in order to launch the
hotplug script (see libxl__wait_device_connection).
Reported-by: James Dingwall <james-...@dingwall.me.uk>
Signed-off-by: Roger Pau Monné <roger....@citrix.com>
Tested-by: James Dingwall <james-...@dingwall.me.uk>
I could easily reproduced by adding a sleep(1) before reading the key
and use 'xl network-attach ...'.
Tested-by: Julien Grall <jgr...@amazon.com>
---
Cc: Wei Liu <wei....@kernel.org>
Cc: Paul Durrant <p...@xen.org>
---
tools/libs/light/libxl_nic.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/libs/light/libxl_nic.c b/tools/libs/light/libxl_nic.c
index 0b45469dca..0b9e70c9d1 100644
--- a/tools/libs/light/libxl_nic.c
+++ b/tools/libs/light/libxl_nic.c
@@ -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;
}
Cheers,
--
Julien Grall