diff options
Diffstat (limited to 'hw/net')
-rw-r--r-- | hw/net/virtio-net.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 439f823..96a3cc8 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); } } |