The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8103

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
We've seen some systems where the driver is in an inconsistent state
briefly and returns EBUSY, effectively needing a retry.

So let's just assume that this may happen on any VF reconfig and wrap
everything with TryRunCommand.

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 55a9969fa48d094bcafdea04dc0a5adee3532eb2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Fri, 30 Oct 2020 15:57:51 -0400
Subject: [PATCH] lxd/device/sriov: Harden calls to ip link vf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We've seen some systems where the driver is in an inconsistent state
briefly and returns EBUSY, effectively needing a retry.

So let's just assume that this may happen on any VF reconfig and wrap
everything with TryRunCommand.

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/device/nic_sriov.go | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lxd/device/nic_sriov.go b/lxd/device/nic_sriov.go
index 64aa66e66e..fe358a3252 100644
--- a/lxd/device/nic_sriov.go
+++ b/lxd/device/nic_sriov.go
@@ -433,7 +433,7 @@ func (d *nicSRIOV) setupSriovParent(vfDevice string, vfID 
int, volatile map[stri
 
        // Setup VF VLAN if specified.
        if d.config["vlan"] != "" {
-               _, err := shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "vlan", 
d.config["vlan"])
+               _, err := shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "vlan", 
d.config["vlan"])
                if err != nil {
                        return vfPCIDev, err
                }
@@ -450,25 +450,25 @@ func (d *nicSRIOV) setupSriovParent(vfDevice string, vfID 
int, volatile map[stri
                }
 
                // Set MAC on VF (this combined with spoof checking prevents 
any other MAC being used).
-               _, err = shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", mac)
+               _, err = shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", mac)
                if err != nil {
                        return vfPCIDev, err
                }
 
                // Now that MAC is set on VF, we can enable spoof checking.
-               _, err = shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "spoofchk", "on")
+               _, err = shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "spoofchk", "on")
                if err != nil {
                        return vfPCIDev, err
                }
        } else {
                // Reset VF to ensure no previous MAC restriction exists.
-               _, err := shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", 
"00:00:00:00:00:00")
+               _, err := shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", 
"00:00:00:00:00:00")
                if err != nil {
                        return vfPCIDev, err
                }
 
                // Ensure spoof checking is disabled if not enabled in instance.
-               _, err = shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "spoofchk", "off")
+               _, err = shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "spoofchk", "off")
                if err != nil {
                        return vfPCIDev, err
                }
@@ -481,7 +481,7 @@ func (d *nicSRIOV) setupSriovParent(vfDevice string, vfID 
int, volatile map[stri
                                mac = volatile["last_state.hwaddr"]
                        }
 
-                       _, err = shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", mac)
+                       _, err = shared.TryRunCommand("ip", "link", "set", 
"dev", d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", mac)
                        if err != nil {
                                return vfPCIDev, err
                        }
@@ -712,7 +712,7 @@ func (d *nicSRIOV) restoreSriovParent(volatile 
map[string]string) error {
 
        // Reset VF VLAN if specified
        if volatile["last_state.vf.vlan"] != "" {
-               _, err := shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "vlan", 
volatile["last_state.vf.vlan"])
+               _, err := shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "vlan", 
volatile["last_state.vf.vlan"])
                if err != nil {
                        return err
                }
@@ -726,7 +726,7 @@ func (d *nicSRIOV) restoreSriovParent(volatile 
map[string]string) error {
                        mode = "on"
                }
 
-               _, err := shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "spoofchk", mode)
+               _, err := shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "spoofchk", mode)
                if err != nil {
                        return err
                }
@@ -734,7 +734,7 @@ func (d *nicSRIOV) restoreSriovParent(volatile 
map[string]string) error {
 
        // Reset VF MAC specified if specified.
        if volatile["last_state.vf.hwaddr"] != "" {
-               _, err := shared.RunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", 
volatile["last_state.vf.hwaddr"])
+               _, err := shared.TryRunCommand("ip", "link", "set", "dev", 
d.config["parent"], "vf", volatile["last_state.vf.id"], "mac", 
volatile["last_state.vf.hwaddr"])
                if err != nil {
                        return err
                }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to