qemu-e2k/hw
Laurent Vivier 1e157667d7 virtio-net: failover: add missing remove_migration_state_change_notifier()
In the failover case configuration, virtio_net_device_realize() uses an
add_migration_state_change_notifier() to add a state notifier, but this
notifier is not removed by the unrealize function when the virtio-net
card is unplugged.

If the card is unplugged and a migration is started, the notifier is
called and as it is not valid anymore QEMU crashes.

This patch fixes the problem by adding the
remove_migration_state_change_notifier() in virtio_net_device_unrealize().

The problem can be reproduced with:

  $ qemu-system-x86_64 -enable-kvm -m 1g -M q35 \
    -device pcie-root-port,slot=4,id=root1 \
    -device pcie-root-port,slot=5,id=root2 \
    -device virtio-net-pci,id=net1,mac=52:54:00:6f:55:cc,failover=on,bus=root1 \
    -monitor stdio disk.qcow2
  (qemu) device_del net1
  (qemu) migrate "exec:gzip -c > STATEFILE.gz"

  Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
  0x0000000000000000 in ?? ()
  (gdb) bt
  #0  0x0000000000000000 in  ()
  #1  0x0000555555d726d7 in notifier_list_notify (...)
      at .../util/notify.c:39
  #2  0x0000555555842c1a in migrate_fd_connect (...)
      at .../migration/migration.c:3975
  #3  0x0000555555950f7d in migration_channel_connect (...)
      error@entry=0x0) at .../migration/channel.c:107
  #4  0x0000555555910922 in exec_start_outgoing_migration (...)
      at .../migration/exec.c:42

Reported-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2021-05-27 11:03:55 +08:00
..
9pfs hw/9pfs/9p-synth: Replaced qemu_mutex_lock with QEMU_LOCK_GUARD 2021-03-16 11:41:49 +01:00
acpi Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
adc clock: Add ClockEvent parameter to callbacks 2021-03-08 17:20:01 +00:00
alpha Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
arm Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
audio hw: Replace anti-social QOM type names 2021-03-19 15:18:43 +01:00
avr Do not include hw/boards.h if it's not really necessary 2021-05-02 17:24:51 +02:00
block Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
char Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
core Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
cpu cpu/core: Fix "help" of CPU core device types 2021-04-09 16:05:16 -04:00
cris Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
display Do not include hw/boards.h if it's not really necessary 2021-05-02 17:24:51 +02:00
dma Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
gpio
hppa Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
hyperv
i2c Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
i386 Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
ide hw: Do not include hw/sysbus.h if it is not necessary 2021-05-02 17:24:50 +02:00
input Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
intc ppc patch queue 2021-05-04 2021-05-05 20:29:14 +01:00
ipack
ipmi hw: Do not include qemu/log.h if it is not necessary 2021-05-02 17:24:50 +02:00
isa ppc patch queue 2021-05-04 2021-05-05 20:29:14 +01:00
lm32 Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
m68k Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
mem Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
microblaze Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
mips Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
misc Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
moxie Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
net virtio-net: failover: add missing remove_migration_state_change_notifier() 2021-05-27 11:03:55 +08:00
nios2 Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
nubus hw: Do not include hw/sysbus.h if it is not necessary 2021-05-02 17:24:50 +02:00
nvram Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
openrisc Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
pci Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
pci-bridge
pci-host ppc patch queue 2021-05-04 2021-05-05 20:29:14 +01:00
pcmcia hw/pcmcia: Do not register PCMCIA type if not required 2021-05-02 17:24:50 +02:00
ppc ppc patch queue 2021-05-04 2021-05-05 20:29:14 +01:00
rdma pvrdma: wean code off pvrdma_ring.h kernel header 2021-03-15 16:41:22 +08:00
remote Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
riscv Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
rtc mc146818rtc: put it into the 'misc' category 2021-05-02 17:24:51 +02:00
rx hw/rx/rx-gdbsim: Do not accept invalid memory size 2021-05-03 10:07:41 +02:00
s390x Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
scsi Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
sd hw: Do not include qemu/log.h if it is not necessary 2021-05-02 17:24:50 +02:00
sh4 Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
smbios
sparc Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
sparc64 Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
ssi Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
timer hw: Do not include hw/irq.h if it is not necessary 2021-05-02 17:24:50 +02:00
tpm Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
tricore Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
unicore32
usb hw: Do not include qemu/log.h if it is not necessary 2021-05-02 17:24:50 +02:00
vfio Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
virtio Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
watchdog clock: Add ClockEvent parameter to callbacks 2021-03-08 17:20:01 +00:00
xen Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
xenpv
xtensa Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
Kconfig semihosting: Move hw/semihosting/ -> semihosting/ 2021-03-10 15:34:12 +00:00
meson.build semihosting: Move hw/semihosting/ -> semihosting/ 2021-03-10 15:34:12 +00:00