File 0001-utilities-Add-script-to-support-DPDK-option-migratio.patch of Package openvswitch.10111

From 4f543e486836e9e48fd771ce64808136ac9ce887 Mon Sep 17 00:00:00 2001
From: Markos Chandras <mchandras@suse.de>
Date: Fri, 10 Feb 2017 09:51:03 +0000
Subject: [PATCH] utilities: Add script to support DPDK option migration from
 OvS<2.6

Open vSwitch 2.6 now requires DPDK options to be in the Open vSwitch
database so add a script to migration options from
/etc/sysconfig/openvswitch to the database.

Commit: bab6940971336510c1f4342cde0bc17da46b99f1 ("netdev-dpdk: Convert
initialization from cmdline to db")
Signed-off-by: Markos Chandras <mchandras@suse.de>
---
 rhel/usr_lib_systemd_system_openvswitch.service |  1 +
 utilities/ovs-dpdk-migrate-2.6.sh               | 88 +++++++++++++++++++++++++
 2 files changed, 89 insertions(+)
 create mode 100644 utilities/ovs-dpdk-migrate-2.6.sh

diff --git a/rhel/usr_lib_systemd_system_openvswitch.service b/rhel/usr_lib_systemd_system_openvswitch.service
index e823c5454..4cdb8e75d 100644
--- a/rhel/usr_lib_systemd_system_openvswitch.service
+++ b/rhel/usr_lib_systemd_system_openvswitch.service
@@ -9,6 +9,7 @@ BindsTo=ovs-vswitchd.service
 [Service]
 Type=oneshot
 ExecStart=/bin/true
+ExecStartPost=/usr/share/openvswitch/scripts/ovs-dpdk-migrate-2.6.sh
 ExecReload=/bin/true
 ExecStop=/bin/true
 RemainAfterExit=yes
diff --git a/utilities/ovs-dpdk-migrate-2.6.sh b/utilities/ovs-dpdk-migrate-2.6.sh
new file mode 100644
index 000000000..6a3f1e08c
--- /dev/null
+++ b/utilities/ovs-dpdk-migrate-2.6.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# Copyright (c) 2017 SUSE LINUX GmbH
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Author:     Markos Chandras <mchandras@suse.de>
+# Maintainer: Markos Chandras <mchandras@suse.de>
+
+
+# The script will try its best to migrate the DPDK options from
+# /etc/sysconfig/openvswitch to the new Open vSwitch db options introduced
+# in Open vSwitch 2.6
+
+set -eu
+
+extra_string=''
+
+do_ovs_print() {
+    logger="$(which logger || false) -t $(basename $0) -- [dpdk options migration]"
+    echo "[dpdk options migration]" $@
+    eval $logger $@
+}
+
+do_ovs_db() {
+    field=$1; shift
+    args="$@"
+    ovsctl="ovs-vsctl set Open_vSwitch . other_config:$field='$args'"
+    do_ovs_print "Executing '$ovsctl'"
+    eval $ovsctl
+}
+
+OVS_SYSCONFIG=/etc/sysconfig/openvswitch
+
+# Exit if for whatever reason there is no sysconfig file
+[[ ! -e $OVS_SYSCONFIG ]] && exit 0
+
+source $OVS_SYSCONFIG
+
+# Exit if no DPDK_OPTIONS are set
+[[ "${DPDK_OPTIONS:-x__unset__x}" == "x__unset__x" ]] && exit 0
+
+# If other_config:dpdk-init exists in db then we don't need to do anything
+$(type -p ovs-vsctl) get Open_vSwitch . other_config:dpdk-init &> /dev/null && exit 0
+
+OPTIONS=$(getopt -u -o b:c:d:l:m:n:r:v:w: --long xen-dom0:,syslog,socket-mem:,lcores:,master-lcore:,huge-dir,proc-type,file-prefix,vmware-tsc-map,vdev:,base-virtaddr,create-uio-dev,no-shconf,no-pci,no-hpet,no-huge -n ${0} -- $DPDK_OPTIONS)
+
+set -- $OPTIONS
+
+do_ovs_db dpdk-init true
+
+while true; do
+    case $1 in
+        -c) do_ovs_db dpdk-lcore-mask $2; shift 2;;
+        --socket-mem) do_ovs_db dpdk-socket-mem $2; shift 2;;
+        --) shift; break ;;
+        *)
+            if [[ ${2:-x__unset__x} != x__unset__x ]]; then
+                extra_string+="$1 $2 " && shift 2
+            else
+                extra_string+="$1 " && shift 1
+            fi
+            ;;
+    esac
+done
+
+[[ -n "$extra_string" ]] && do_ovs_db dpdk-extra "$extra_string"
+
+# And now disable DPDK_OPTIONS
+sed -i -e '/^DPDK_OPTIONS=/i \
+# ------------------------ WARNING -------------------------- \
+# DPDK options now belong to the Open vSwitch database. See \
+# man ovs-vswitchd.conf.db(5)' -e 's/^DPDK_OPTIONS=/#&/' $OVS_SYSCONFIG
+
+# Restart it so new changes take effect
+systemctl -q restart openvswitch
+
+exit 0
-- 
2.11.0

openSUSE Build Service is sponsored by