virtio-net: failover: add missing remove_migration_state_change_notifier()
PATCH 1/1 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--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)
hw/net/virtio-net.c +1 -0
@@ -3373,6 +3373,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)if (n->failover) {device_listener_unregister (&n->primary_listener); +remove_migration_state_change_notifier (&n->migration_state); } max_queues = n->multiqueue ? n->max_queues :1 ;
Signature · 1 line
2.30.2
Quoted 34 lines · * Laurent Vivier ([email protected]) wrote:
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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.
0x0000000000000000in ?? ()
(gdb) bt
#00x0000000000000000in ()
#10x0000555555d726d7innotifier_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
Quoted 2 lines
Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>
Yep, I think that's OK.
Quoted 19 lines
--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)hw/net/virtio-net.c +1
-0@@ -3373,6 +3373,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)if (n->failover) {device_listener_unregister (&n->primary_listener); +remove_migration_state_change_notifier (&n->migration_state); } max_queues = n->multiqueue ? n->max_queues :1 ;Signature · 1 line
2.30.2
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Philippe Mathieu-Daudé
Reviewed-byQuoted 35 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Laurent Vivier ([email protected]) wrote:
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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.
0x0000000000000000in ?? ()
(gdb) bt
#00x0000000000000000in ()
#10x0000555555d726d7innotifier_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
Quoted 4 lines
Quoted 2 lines
Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>Yep, I think that's OK.
IIUC HMP device_del ends calling device_finalize(), and per Igor's explanation of qdev transition states:
https://www.mail-archive.com/[email protected]/msg661853.html
I'd expect this to be done in instance_init/instance_finalize, but since 'failover' is a virtio_net_properties, the callbacks has to be registered in the realize() function, thus unregistered in unrealize().
Mentioning it is in realize/unrealize due to 'failover' being a property:
Quoted 21 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Quoted 19 lines
--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)hw/net/virtio-net.c +1
-0@@ -3373,6 +3373,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)if (n->failover) {device_listener_unregister (&n->primary_listener); +remove_migration_state_change_notifier (&n->migration_state); } max_queues = n->multiqueue ? n->max_queues :1 ;Signature · 1 line
2.30.2
Michael S. Tsirkin
Reviewed-byQuoted 35 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Laurent Vivier ([email protected]) wrote:
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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.
0x0000000000000000in ?? ()
(gdb) bt
#00x0000000000000000in ()
#10x0000555555d726d7innotifier_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
Quoted 7 lines
Quoted 2 lines
Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>Yep, I think that's OK.
Reviewed-by Dr. David Alan Gilbert <[email protected]>
net stuff so I expect Jason will merge this ...
Quoted 21 lines
Quoted 19 lines
--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)hw/net/virtio-net.c +1
-0@@ -3373,6 +3373,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)if (n->failover) {device_listener_unregister (&n->primary_listener); +remove_migration_state_change_notifier (&n->migration_state); } max_queues = n->multiqueue ? n->max_queues :1 ;Signature · 1 line
2.30.2Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Dr. David Alan Gilbert
Quoted 36 lines · * Laurent Vivier ([email protected]) wrote:
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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:42Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>
Quoted 7 lines
Quoted 4 lines
Yep, I think that's OK.
Reviewed-by Dr. David Alan Gilbert <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>net stuff so I expect Jason will merge this ...
Ok, I've queued this.
Thanks
Quoted 23 lines
Quoted 22 lines
Quoted 20 lines
--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)hw/net/virtio-net.c +1
-0@@ -3373,6 +3373,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)if (n->failover) {device_listener_unregister (&n->primary_listener); +remove_migration_state_change_notifier (&n->migration_state); } max_queues = n->multiqueue ? n->max_queues :1 ;Signature · 1 line
2.30.2Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 43 lines · Jason Wang
Quoted 41 lines · Michael S. Tsirkin
Quoted 40 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Laurent Vivier ([email protected]) wrote:
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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.
0x0000000000000000in ?? ()
(gdb) bt
#00x0000000000000000in ()
#10x0000555555d726d7innotifier_list_notify(...)
at.../util/notify.c:39
#20x0000555555842c1ainmigrate_fd_connect(...)
at.../migration/migration.c:3975
#30x0000555555950f7dinmigration_channel_connect(...) error@entry=0x0) at.../migration/channel.c:107
#40x0000555555910922inexec_start_outgoing_migration(...) at.../migration/exec.c:42Quoted 2 lines
Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>Yep, I think that's OK.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Reviewed-by Dr. David Alan Gilbert <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>net stuff so I expect Jason will merge this ...
Ok, I've queued this.
Thank you.
Any idea when the PR will be sent?
Thanks,
Laurent
Quoted 44 lines · Laurent Vivier
Quoted 43 lines · Jason Wang
Quoted 42 lines · Michael S. Tsirkin
Quoted 41 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Laurent Vivier ([email protected]) wrote:
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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.
0x0000000000000000in ?? ()
(gdb) bt
#00x0000000000000000in ()
#10x0000555555d726d7innotifier_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:42Quoted 2 lines
Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>Yep, I think that's OK.
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Reviewed-by Michael S. Tsirkin <[email protected]>net stuff so I expect Jason will merge this ...
Ok, I've queued this.
Thank you.
Any idea when the PR will be sent?
I would be no later than the end of this week. I plan to merge RSS so I want to have some basic for that.
Thanks
Quoted 4 lines
Thanks,
Laurent
Quoted 34 lines · Laurent Vivier
In the failover case configuration,
virtio_net_device_realize()uses anadd_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()invirtio_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
Quoted 2 lines
Reported-by Igor Mammedov <[email protected]>Signed-off-by Laurent Vivier <[email protected]>
This should be added to stable I guess.
Thanks
Quoted 16 lines
--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)hw/net/virtio-net.c +1
-0@@ -3373,6 +3373,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)if (n->failover) {device_listener_unregister (&n->primary_listener); +remove_migration_state_change_notifier (&n->migration_state); } max_queues = n->multiqueue ? n->max_queues :1 ;