I'm ok with the patch idea. On Sat, Apr 26, 2014 at 06:19:12PM +0800, zhanghailiang wrote: > For e1000/rtl8139, qemu can still send/receive packets when VM is paused. ^^^^^^^^^ -> isn't running
There are many kinds of RunState, "is paused" doesn't equal to "isn't running". > If this happened in *migration's* last PAUSE VM stage, the new dirty RAM > related to the packets will be missed. > To avoid this, do things like virtio-net, forbid sending/receiving > packets when VM is suspend. ^^^^^^^^^^^ -> isn't running. > Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com> > --- > hw/net/e1000.c | 5 +++-- > hw/net/rtl8139.c | 3 +++ > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/hw/net/e1000.c b/hw/net/e1000.c > index 8387443..94108fd 100644 > --- a/hw/net/e1000.c > +++ b/hw/net/e1000.c > @@ -885,9 +885,10 @@ static int > e1000_can_receive(NetClientState *nc) > { > E1000State *s = qemu_get_nic_opaque(nc); > - > + int vmstat = runstate_is_running(); > + > return (s->mac_reg[STATUS] & E1000_STATUS_LU) && > - (s->mac_reg[RCTL] & E1000_RCTL_EN) && e1000_has_rxbufs(s, 1); > + (s->mac_reg[RCTL] & E1000_RCTL_EN) && e1000_has_rxbufs(s, 1) && > vmstat; > } > > static uint64_t rx_desc_base(E1000State *s) > diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c > index 5329f44..3c60c84 100644 > --- a/hw/net/rtl8139.c > +++ b/hw/net/rtl8139.c > @@ -799,7 +799,10 @@ static int rtl8139_can_receive(NetClientState *nc) > { > RTL8139State *s = qemu_get_nic_opaque(nc); > int avail; > + int vmstat = runstate_is_running(); > > + if (!vmstat) > + return 0; if (!runstate_is_running()) return 0; > /* Receive (drop) packets if card is disabled. */ > if (!s->clock_enabled) > return 1; > -- > 1.7.12.4 > -- Amos.