thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-virtio_net-Modify-virtio_net_get_config-to-early-ret.patch

7f1c5b
From 3f55d12df35552ae948587a62d6f9015664adc13 Mon Sep 17 00:00:00 2001
7f1c5b
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
7f1c5b
Date: Wed, 21 Dec 2022 12:50:12 +0100
7f1c5b
Subject: [PATCH 1/9] virtio_net: Modify virtio_net_get_config to early return
7f1c5b
MIME-Version: 1.0
7f1c5b
Content-Type: text/plain; charset=UTF-8
7f1c5b
Content-Transfer-Encoding: 8bit
7f1c5b
7f1c5b
RH-Author: Eugenio Pérez <eperezma@redhat.com>
7f1c5b
RH-MergeRequest: 137: vDPA net SVQ guest announce support
7f1c5b
RH-Bugzilla: 2141088
7f1c5b
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
7f1c5b
RH-Acked-by: Cindy Lu <lulu@redhat.com>
7f1c5b
RH-Acked-by: Jason Wang <jasowang@redhat.com>
7f1c5b
RH-Commit: [1/4] 4f5e79afd54e157f32e6fff56ae33e2b71492525 (eperezmartin/qemu-kvm)
7f1c5b
7f1c5b
Next patches introduce more code on vhost-vdpa branch, with already have
7f1c5b
too much indentation.
7f1c5b
7f1c5b
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
7f1c5b
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7f1c5b
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
7f1c5b
Acked-by: Jason Wang <jasowang@redhat.com>
7f1c5b
Message-Id: <20221221115015.1400889-2-eperezma@redhat.com>
7f1c5b
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
7f1c5b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7f1c5b
(cherry picked from commit ebc141a62508dc91901373c1a19fe7e2cf560dfb)
7f1c5b
---
7f1c5b
 hw/net/virtio-net.c | 28 +++++++++++++++-------------
7f1c5b
 1 file changed, 15 insertions(+), 13 deletions(-)
7f1c5b
7f1c5b
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
7f1c5b
index ec974f7a76..5935e55653 100644
7f1c5b
--- a/hw/net/virtio-net.c
7f1c5b
+++ b/hw/net/virtio-net.c
7f1c5b
@@ -168,20 +168,22 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
7f1c5b
     if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
7f1c5b
         ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
7f1c5b
                                    n->config_size);
7f1c5b
-        if (ret != -1) {
7f1c5b
-            /*
7f1c5b
-             * Some NIC/kernel combinations present 0 as the mac address.  As
7f1c5b
-             * that is not a legal address, try to proceed with the
7f1c5b
-             * address from the QEMU command line in the hope that the
7f1c5b
-             * address has been configured correctly elsewhere - just not
7f1c5b
-             * reported by the device.
7f1c5b
-             */
7f1c5b
-            if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
7f1c5b
-                info_report("Zero hardware mac address detected. Ignoring.");
7f1c5b
-                memcpy(netcfg.mac, n->mac, ETH_ALEN);
7f1c5b
-            }
7f1c5b
-            memcpy(config, &netcfg, n->config_size);
7f1c5b
+        if (ret == -1) {
7f1c5b
+            return;
7f1c5b
         }
7f1c5b
+
7f1c5b
+        /*
7f1c5b
+         * Some NIC/kernel combinations present 0 as the mac address.  As that
7f1c5b
+         * is not a legal address, try to proceed with the address from the
7f1c5b
+         * QEMU command line in the hope that the address has been configured
7f1c5b
+         * correctly elsewhere - just not reported by the device.
7f1c5b
+         */
7f1c5b
+        if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
7f1c5b
+            info_report("Zero hardware mac address detected. Ignoring.");
7f1c5b
+            memcpy(netcfg.mac, n->mac, ETH_ALEN);
7f1c5b
+        }
7f1c5b
+
7f1c5b
+        memcpy(config, &netcfg, n->config_size);
7f1c5b
     }
7f1c5b
 }
7f1c5b
 
7f1c5b
-- 
7f1c5b
2.31.1
7f1c5b