aboutsummaryrefslogtreecommitdiff
path: root/hw/net/virtio-net.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-03-03 16:55:15 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-03-03 16:55:15 +0000
commitc40ae5a3ee387b13116948cbfe7824f03311db7e (patch)
tree2875222df3e41a2a1cf0811801e87317be943ac9 /hw/net/virtio-net.c
parent07dbfdd290cea5d75d3e21948dc54fdb6f5174ac (diff)
parent1d8d014e936a49795de95a35a2a1ab8000ab2e5b (diff)
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc,virtio,pci: bug fixes Fixes all over the place. Specifically this fixes a bug which made windows guests lose device config (such as the configured fixed IP) after upgrading to the new QEMU. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Tue 02 Mar 2021 14:19:51 GMT # gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469 # gpg: issuer "mst@redhat.com" # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [full] # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" [full] # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: vhost: simplify vhost_dev_init() fail_busyloop label hw/pci: Have safer pcie_bus_realize() by checking error path virtio-net: handle zero mac for a vdpa peer i386/acpi: restore device paths for pre-5.1 vms Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/net/virtio-net.c')
-rw-r--r--hw/net/virtio-net.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 439f823b19..96a3cc8357 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -126,6 +126,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
VirtIONet *n = VIRTIO_NET(vdev);
struct virtio_net_config netcfg;
NetClientState *nc = qemu_get_queue(n->nic);
+ static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
int ret = 0;
memset(&netcfg, 0 , sizeof(struct virtio_net_config));
@@ -151,6 +152,17 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
n->config_size);
if (ret != -1) {
+ /*
+ * Some NIC/kernel combinations present 0 as the mac address. As
+ * that is not a legal address, try to proceed with the
+ * address from the QEMU command line in the hope that the
+ * address has been configured correctly elsewhere - just not
+ * reported by the device.
+ */
+ if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
+ info_report("Zero hardware mac address detected. Ignoring.");
+ memcpy(netcfg.mac, n->mac, ETH_ALEN);
+ }
memcpy(config, &netcfg, n->config_size);
}
}