[PATCH 06/24] Handle the case where vifname is not present in xenstore.

Manuel Bouyer posted 24 patches 5 years, 1 month ago
[PATCH 06/24] Handle the case where vifname is not present in xenstore.
Posted by Manuel Bouyer 5 years, 1 month ago
---
 tools/hotplug/NetBSD/vif-bridge | 5 ++++-
 tools/hotplug/NetBSD/vif-ip     | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/hotplug/NetBSD/vif-bridge b/tools/hotplug/NetBSD/vif-bridge
index b58e922601..cd428b5936 100644
--- a/tools/hotplug/NetBSD/vif-bridge
+++ b/tools/hotplug/NetBSD/vif-bridge
@@ -23,7 +23,10 @@ case $xstatus in
 	xbridge=$(xenstore-read "$xpath/bridge")
 	xfid=$(xenstore-read "$xpath/frontend-id")
 	xhandle=$(xenstore-read "$xpath/handle")
-	iface=$(xenstore-read "$xpath/vifname")
+	iface=$(xenstore-read "$xpath/vifname") || true
+	if [ x${iface} = "x" ] ; then
+		iface=xvif$xfid.$xhandle
+	fi
 	ifconfig $iface up
 	brconfig $xbridge add $iface
 	xenstore-write $xpath/hotplug-status connected
diff --git a/tools/hotplug/NetBSD/vif-ip b/tools/hotplug/NetBSD/vif-ip
index 83cbfe20e2..944f50f881 100644
--- a/tools/hotplug/NetBSD/vif-ip
+++ b/tools/hotplug/NetBSD/vif-ip
@@ -24,6 +24,10 @@ case $xstatus in
 	xfid=$(xenstore-read "$xpath/frontend-id")
 	xhandle=$(xenstore-read "$xpath/handle")
 	iface=$(xenstore-read "$xpath/vifname")
+	iface=$(xenstore-read "$xpath/vifname") || true
+	if [ x${iface} = "x" ] ; then
+		iface=xvif$xfid.$xhandle
+	fi
 	ifconfig $iface $xip up
 	xenstore-write $xpath/hotplug-status connected
 	exit 0
-- 
2.28.0


Re: [PATCH 06/24] Handle the case where vifname is not present in xenstore.
Posted by Roger Pau Monné 5 years, 1 month ago
Maybe it would be easier to just fix libxl to always set the vifname
in xenstore?

FWIW, on FreeBSD I'm passing the vifname as an environment parameter
to the script.

Thanks, Roger.

Re: [PATCH 06/24] Handle the case where vifname is not present in xenstore.
Posted by Manuel Bouyer 5 years, 1 month ago
On Tue, Dec 29, 2020 at 12:43:02PM +0100, Roger Pau Monné wrote:
> Maybe it would be easier to just fix libxl to always set the vifname
> in xenstore?
> 
> FWIW, on FreeBSD I'm passing the vifname as an environment parameter
> to the script.

Actually I don't know why the vifname is not always set. It may depend on
the Xen version ...

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--