Commit 57407ea4 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Stefan Hajnoczi
Browse files

net: remove all cleanup methods from NIC NetClientInfos



All NICs have a cleanup function that, in most cases, zeroes the pointer
to the NICState.  In some cases, it frees data belonging to the NIC.

However, this function is never called except when exiting from QEMU.
It is not necessary to NULL pointers and free data here; the right place
to do that would be in the device's unrealize function, after calling
qemu_del_nic.  Zeroing the NIC multiple times is also wrong for multiqueue
devices.

This cleanup function gets in the way of making the NetClientStates for
the NIC hold an object_ref reference to the object, so get rid of it.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 64ea8038
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -218,13 +218,6 @@ static ssize_t aw_emac_receive(NetClientState *nc, const uint8_t *buf,
    return size;
}

static void aw_emac_cleanup(NetClientState *nc)
{
    AwEmacState *s = qemu_get_nic_opaque(nc);

    s->nic = NULL;
}

static void aw_emac_reset(DeviceState *dev)
{
    AwEmacState *s = AW_EMAC(dev);
@@ -433,7 +426,6 @@ static NetClientInfo net_aw_emac_info = {
    .size = sizeof(NICState),
    .can_receive = aw_emac_can_receive,
    .receive = aw_emac_receive,
    .cleanup = aw_emac_cleanup,
    .link_status_changed = aw_emac_set_link,
};

+0 −9
Original line number Diff line number Diff line
@@ -1209,14 +1209,6 @@ static const MemoryRegionOps gem_ops = {
    .endianness = DEVICE_LITTLE_ENDIAN,
};

static void gem_cleanup(NetClientState *nc)
{
    GemState *s = qemu_get_nic_opaque(nc);

    DB_PRINT("\n");
    s->nic = NULL;
}

static void gem_set_link(NetClientState *nc)
{
    DB_PRINT("\n");
@@ -1228,7 +1220,6 @@ static NetClientInfo net_gem_info = {
    .size = sizeof(NICState),
    .can_receive = gem_can_receive,
    .receive = gem_receive,
    .cleanup = gem_cleanup,
    .link_status_changed = gem_set_link,
};

+0 −11
Original line number Diff line number Diff line
@@ -859,22 +859,11 @@ static void nic_reset(void *opaque)
    dp8393x_update_irq(s);
}

static void nic_cleanup(NetClientState *nc)
{
    dp8393xState *s = qemu_get_nic_opaque(nc);

    timer_del(s->watchdog);
    timer_free(s->watchdog);

    g_free(s);
}

static NetClientInfo net_dp83932_info = {
    .type = NET_CLIENT_OPTIONS_KIND_NIC,
    .size = sizeof(NICState),
    .can_receive = nic_can_receive,
    .receive = nic_receive,
    .cleanup = nic_cleanup,
};

void dp83932_init(NICInfo *nd, hwaddr base, int it_shift,
+0 −9
Original line number Diff line number Diff line
@@ -1502,14 +1502,6 @@ e1000_mmio_setup(E1000State *d)
    memory_region_init_io(&d->io, OBJECT(d), &e1000_io_ops, d, "e1000-io", IOPORT_SIZE);
}

static void
e1000_cleanup(NetClientState *nc)
{
    E1000State *s = qemu_get_nic_opaque(nc);

    s->nic = NULL;
}

static void
pci_e1000_uninit(PCIDevice *dev)
{
@@ -1528,7 +1520,6 @@ static NetClientInfo net_e1000_info = {
    .can_receive = e1000_can_receive,
    .receive = e1000_receive,
    .receive_iov = e1000_receive_iov,
    .cleanup = e1000_cleanup,
    .link_status_changed = e1000_set_link_status,
};

+0 −8
Original line number Diff line number Diff line
@@ -1832,13 +1832,6 @@ static const VMStateDescription vmstate_eepro100 = {
    }
};

static void nic_cleanup(NetClientState *nc)
{
    EEPRO100State *s = qemu_get_nic_opaque(nc);

    s->nic = NULL;
}

static void pci_nic_uninit(PCIDevice *pci_dev)
{
    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
@@ -1853,7 +1846,6 @@ static NetClientInfo net_eepro100_info = {
    .size = sizeof(NICState),
    .can_receive = nic_can_receive,
    .receive = nic_receive,
    .cleanup = nic_cleanup,
};

static int e100_nic_init(PCIDevice *pci_dev)
Loading