[meta-arm,1/4] arm-autonomy/xen-tools: vif-nat script fixes

Submitted by Diego Sueiro on July 30, 2020, 3:52 p.m. | Patch ID: 174905

Details

Message ID 1596124338-106961-1-git-send-email-diego.sueiro@arm.com
State New
Headers show

Commit Message

Diego Sueiro July 30, 2020, 3:52 p.m.
This patch introduces two fixes for the vif-nat script:
1- Setting the hostname is failing because the "$XENBUS_PATH/domain"
   doesn't exist anymore. To fix this we set it to dom$domid.
2- Copy temp files used to add/remove dhcpd configurations to avoid
   replacing potential symlinks.

Change-Id: I5f2ed917c15bbe1c6ff9ec3cc9ad2fc4e1c0fb60
Issue-Id: SCM-1019
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
---
 .../xen/xen-tools/0001-vif-nat-fix-hostname.patch  | 18 +++++++++
 .../0002-vif-nat-fix-symlink-removal.patch         | 45 ++++++++++++++++++++++
 .../recipes-extended/xen/xen-tools_%.bbappend      |  5 +++
 3 files changed, 68 insertions(+)
 create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
 create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
 create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend

Patch hide | download patch | download mbox

diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
new file mode 100644
index 0000000..87f25e2
--- /dev/null
+++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
@@ -0,0 +1,18 @@ 
+Upstream-Status: Pending
+Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
+
+Setting the hostname is failing because the "$XENBUS_PATH/domain"
+doesn't exist anymore. To fix this we set it to dom$domid
+
+Index: git/tools/hotplug/Linux/vif-nat
+===================================================================
+--- git.orig/tools/hotplug/Linux/vif-nat
++++ git/tools/hotplug/Linux/vif-nat
+@@ -86,6 +86,7 @@ router_ip=$(routing_ip "$ip")
+ vif_ip=`echo ${ip} | awk -F/ '{print $1}'`
+ 
+ hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----')
++[ -z "${hostname}" ] && hostname=dom$domid
+ if [ "$vifid" != "1" ]
+ then
+   hostname="$hostname-$vifid"
diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
new file mode 100644
index 0000000..bcd5778
--- /dev/null
+++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
@@ -0,0 +1,45 @@ 
+Upstream-Status: Pending
+Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
+
+Copy temp files used to add/remove dhcpd configurations to avoid
+replacing potential symlinks.
+
+Index: git/tools/hotplug/Linux/vif-nat
+===================================================================
+--- git.orig/tools/hotplug/Linux/vif-nat
++++ git/tools/hotplug/Linux/vif-nat
+@@ -99,7 +100,8 @@ dhcparg_remove_entry()
+   then
+     rm "$tmpfile"
+   else
+-    mv "$tmpfile" "$dhcpd_arg_file"
++    cp "$tmpfile" "$dhcpd_arg_file"
++    rm "$tmpfile"
+   fi
+ }
+ 
+@@ -109,11 +111,11 @@ dhcparg_add_entry()
+   local tmpfile=$(mktemp)
+   # handle Red Hat, SUSE, and Debian styles, with or without quotes
+   sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
+-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
+   sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
+-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
+   sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
+-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
+   rm -f "$tmpfile"
+ }
+ 
+@@ -125,7 +127,8 @@ dhcp_remove_entry()
+   then
+     rm "$tmpfile"
+   else
+-    mv "$tmpfile" "$dhcpd_conf_file"
++    cp "$tmpfile" "$dhcpd_conf_file"
++    rm "$tmpfile"
+   fi
+   dhcparg_remove_entry
+ }
diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
new file mode 100644
index 0000000..ef8eddd
--- /dev/null
+++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
@@ -0,0 +1,5 @@ 
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += "file://0001-vif-nat-fix-hostname.patch \
+            file://0002-vif-nat-fix-symlink-removal.patch \
+           "

Comments

Bertrand Marquis July 30, 2020, 3:55 p.m.
> On 30 Jul 2020, at 17:52, Diego Sueiro via lists.yoctoproject.org <diego.sueiro=arm.com@lists.yoctoproject.org> wrote:
> 
> This patch introduces two fixes for the vif-nat script:
> 1- Setting the hostname is failing because the "$XENBUS_PATH/domain"
>   doesn't exist anymore. To fix this we set it to dom$domid.
> 2- Copy temp files used to add/remove dhcpd configurations to avoid
>   replacing potential symlinks.
> 
> Change-Id: I5f2ed917c15bbe1c6ff9ec3cc9ad2fc4e1c0fb60
> Issue-Id: SCM-1019
> Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

> ---
> .../xen/xen-tools/0001-vif-nat-fix-hostname.patch  | 18 +++++++++
> .../0002-vif-nat-fix-symlink-removal.patch         | 45 ++++++++++++++++++++++
> .../recipes-extended/xen/xen-tools_%.bbappend      |  5 +++
> 3 files changed, 68 insertions(+)
> create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
> create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
> create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
> 
> diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
> new file mode 100644
> index 0000000..87f25e2
> --- /dev/null
> +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
> @@ -0,0 +1,18 @@
> +Upstream-Status: Pending
> +Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
> +
> +Setting the hostname is failing because the "$XENBUS_PATH/domain"
> +doesn't exist anymore. To fix this we set it to dom$domid
> +
> +Index: git/tools/hotplug/Linux/vif-nat
> +===================================================================
> +--- git.orig/tools/hotplug/Linux/vif-nat
> ++++ git/tools/hotplug/Linux/vif-nat
> +@@ -86,6 +86,7 @@ router_ip=$(routing_ip "$ip")
> + vif_ip=`echo ${ip} | awk -F/ '{print $1}'`
> + 
> + hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----')
> ++[ -z "${hostname}" ] && hostname=dom$domid
> + if [ "$vifid" != "1" ]
> + then
> +   hostname="$hostname-$vifid"
> diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
> new file mode 100644
> index 0000000..bcd5778
> --- /dev/null
> +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
> @@ -0,0 +1,45 @@
> +Upstream-Status: Pending
> +Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
> +
> +Copy temp files used to add/remove dhcpd configurations to avoid
> +replacing potential symlinks.
> +
> +Index: git/tools/hotplug/Linux/vif-nat
> +===================================================================
> +--- git.orig/tools/hotplug/Linux/vif-nat
> ++++ git/tools/hotplug/Linux/vif-nat
> +@@ -99,7 +100,8 @@ dhcparg_remove_entry()
> +   then
> +     rm "$tmpfile"
> +   else
> +-    mv "$tmpfile" "$dhcpd_arg_file"
> ++    cp "$tmpfile" "$dhcpd_arg_file"
> ++    rm "$tmpfile"
> +   fi
> + }
> + 
> +@@ -109,11 +111,11 @@ dhcparg_add_entry()
> +   local tmpfile=$(mktemp)
> +   # handle Red Hat, SUSE, and Debian styles, with or without quotes
> +   sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
> +-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
> ++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
> +   sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
> +-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
> ++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
> +   sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
> +-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
> ++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
> +   rm -f "$tmpfile"
> + }
> + 
> +@@ -125,7 +127,8 @@ dhcp_remove_entry()
> +   then
> +     rm "$tmpfile"
> +   else
> +-    mv "$tmpfile" "$dhcpd_conf_file"
> ++    cp "$tmpfile" "$dhcpd_conf_file"
> ++    rm "$tmpfile"
> +   fi
> +   dhcparg_remove_entry
> + }
> diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
> new file mode 100644
> index 0000000..ef8eddd
> --- /dev/null
> +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
> @@ -0,0 +1,5 @@
> +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
> +
> +SRC_URI += "file://0001-vif-nat-fix-hostname.patch \
> +            file://0002-vif-nat-fix-symlink-removal.patch \
> +           "
> -- 
> 2.7.4
> 
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#925): https://lists.yoctoproject.org/g/meta-arm/message/925
Mute This Topic: https://lists.yoctoproject.org/mt/75888987/3617530
Group Owner: meta-arm+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-
Jon Mason July 30, 2020, 8:25 p.m.
On Thu, Jul 30, 2020 at 03:55:37PM +0000, Bertrand Marquis wrote:
> 
> 
> > On 30 Jul 2020, at 17:52, Diego Sueiro via lists.yoctoproject.org <diego.sueiro=arm.com@lists.yoctoproject.org> wrote:
> > 
> > This patch introduces two fixes for the vif-nat script:
> > 1- Setting the hostname is failing because the "$XENBUS_PATH/domain"
> >   doesn't exist anymore. To fix this we set it to dom$domid.
> > 2- Copy temp files used to add/remove dhcpd configurations to avoid
> >   replacing potential symlinks.
> > 
> > Change-Id: I5f2ed917c15bbe1c6ff9ec3cc9ad2fc4e1c0fb60
> > Issue-Id: SCM-1019
> > Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Series applied to master.

Thanks,
Jon

> 
> > ---
> > .../xen/xen-tools/0001-vif-nat-fix-hostname.patch  | 18 +++++++++
> > .../0002-vif-nat-fix-symlink-removal.patch         | 45 ++++++++++++++++++++++
> > .../recipes-extended/xen/xen-tools_%.bbappend      |  5 +++
> > 3 files changed, 68 insertions(+)
> > create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
> > create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
> > create mode 100644 meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
> > 
> > diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
> > new file mode 100644
> > index 0000000..87f25e2
> > --- /dev/null
> > +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0001-vif-nat-fix-hostname.patch
> > @@ -0,0 +1,18 @@
> > +Upstream-Status: Pending
> > +Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
> > +
> > +Setting the hostname is failing because the "$XENBUS_PATH/domain"
> > +doesn't exist anymore. To fix this we set it to dom$domid
> > +
> > +Index: git/tools/hotplug/Linux/vif-nat
> > +===================================================================
> > +--- git.orig/tools/hotplug/Linux/vif-nat
> > ++++ git/tools/hotplug/Linux/vif-nat
> > +@@ -86,6 +86,7 @@ router_ip=$(routing_ip "$ip")
> > + vif_ip=`echo ${ip} | awk -F/ '{print $1}'`
> > + 
> > + hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----')
> > ++[ -z "${hostname}" ] && hostname=dom$domid
> > + if [ "$vifid" != "1" ]
> > + then
> > +   hostname="$hostname-$vifid"
> > diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
> > new file mode 100644
> > index 0000000..bcd5778
> > --- /dev/null
> > +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools/0002-vif-nat-fix-symlink-removal.patch
> > @@ -0,0 +1,45 @@
> > +Upstream-Status: Pending
> > +Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
> > +
> > +Copy temp files used to add/remove dhcpd configurations to avoid
> > +replacing potential symlinks.
> > +
> > +Index: git/tools/hotplug/Linux/vif-nat
> > +===================================================================
> > +--- git.orig/tools/hotplug/Linux/vif-nat
> > ++++ git/tools/hotplug/Linux/vif-nat
> > +@@ -99,7 +100,8 @@ dhcparg_remove_entry()
> > +   then
> > +     rm "$tmpfile"
> > +   else
> > +-    mv "$tmpfile" "$dhcpd_arg_file"
> > ++    cp "$tmpfile" "$dhcpd_arg_file"
> > ++    rm "$tmpfile"
> > +   fi
> > + }
> > + 
> > +@@ -109,11 +111,11 @@ dhcparg_add_entry()
> > +   local tmpfile=$(mktemp)
> > +   # handle Red Hat, SUSE, and Debian styles, with or without quotes
> > +   sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
> > +-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
> > ++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
> > +   sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
> > +-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
> > ++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
> > +   sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
> > +-     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
> > ++     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
> > +   rm -f "$tmpfile"
> > + }
> > + 
> > +@@ -125,7 +127,8 @@ dhcp_remove_entry()
> > +   then
> > +     rm "$tmpfile"
> > +   else
> > +-    mv "$tmpfile" "$dhcpd_conf_file"
> > ++    cp "$tmpfile" "$dhcpd_conf_file"
> > ++    rm "$tmpfile"
> > +   fi
> > +   dhcparg_remove_entry
> > + }
> > diff --git a/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
> > new file mode 100644
> > index 0000000..ef8eddd
> > --- /dev/null
> > +++ b/meta-arm-autonomy/recipes-extended/xen/xen-tools_%.bbappend
> > @@ -0,0 +1,5 @@
> > +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
> > +
> > +SRC_URI += "file://0001-vif-nat-fix-hostname.patch \
> > +            file://0002-vif-nat-fix-symlink-removal.patch \
> > +           "
> > -- 
> > 2.7.4
> > 
> > 
> 

>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#933): https://lists.yoctoproject.org/g/meta-arm/message/933
Mute This Topic: https://lists.yoctoproject.org/mt/75888987/3617530
Group Owner: meta-arm+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-