qemu-system-x86_64: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed when paused vm migrating (with shared storage) from dest to src host
Host environment
- Operating system: LINUX
- OS/kernel version: kernel-5.10.134
- Architecture: x86
- QEMU flavor: qemu-system-x86_64
- QEMU version: QEMU emulator version 8.0.0
- QEMU command line:
/usr/bin/qemu-system-x86_64
663 -name guest=test,debug-threads=on
664 -S
665 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-6-test/master-key.aes"}'
666 -machine pc-i440fx-4.1,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=on
667 -accel kvm
668 -cpu qemu64,x2apic=on,hypervisor=on,lahf-lm=on,svm=off
669 -m 4096
670 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":4294967296}'
671 -overcommit mem-lock=off
672 -smp 4,sockets=4,cores=1,threads=1
673 -uuid 2b895e49-0000-995a-1001-xxxxxxxxxx
674 -no-user-config
675 -nodefaults
676 -chardev socket,id=charmonitor,fd=43,server=on,wait=off
677 -mon chardev=charmonitor,id=monitor,mode=control
678 -rtc base=utc
679 -no-shutdown
680 -boot strict=on
681 -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}'
682 -device '{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.0","addr":"0x3"}'
683 -blockdev '{"driver":"file","filename":"/mnt/test-x86_64.qcow2","node-name":"libvirt-1-storage","auto -read-only":true,"discard":"unmap"}'
684 -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage","backing":null}'
685 -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"libvirt-1-format","id":"virtio-disk0","bootindex":1}'
686 -chardev pty,id=charserial0
687 -device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}'
688 -chardev socket,id=charchannel0,fd=42,server=on,wait=off
689 -device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}'
690 -audiodev '{"id":"audio1","driver":"none"}'
691 -vnc 0.0.0.0:0,audiodev=audio1
692 -k en-us
693 -device '{"driver":"cirrus-vga","id":"video0","bus":"pci.0","addr":"0x2"}'
694 -incoming defer
695 -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x5"}'
696 -sandbox off
697 -msg timestamp=on
Emulated/Virtualized environment
- Operating system: Linux
- OS/kernel version: kernel-3.10
- Architecture: x86
Description of problem
We are doing migration tests with share storage (nfs) as follows: First, we pause the virtual machine using the 'virsh suspend'command, then migrate the virtual machine to the destination host by 'virsh migrate' command, and there is no problem. After the migration is complete, the virtual machine remains paused on the destination host. However, when we migrate the virtual machine back to the original host, an assertion error is triggered on the current host(dest host):
705 qemu-system-x86_64: ../block.c:6748: bdrv_inactivate_recurse: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed.
706 2024-06-17 11:15:59.972+0000: shutting down, reason=crashed
and virsh migrate commant return error:
**virsh migrate test qemu+tcp://host_ip/system tcp://host_ip --live --verbose --unsafe
Migration: [ 98 %]error: operation failed: domain is not running**
Steps to reproduce
- We create an vm with shareable storage and then paused vm in source host:
virsh create test.xml running
virsh suspend test paused
- Migrate vm to the destination host:
virsh migrate test qemu+tcp://dest_ip/system tcp://dest_ip --live --verbose --unsafe - In destination host,vm is paused.
- Migrate vm back to the source host,and then migration failed and assert error in qemu log in destination host:
virsh migrate test qemu+tcp://host_ip/system tcp://host_ip --live --verbose --unsafe Migration: [ 98 %]error: operation failed: domain is not running705 qemu-system-x86_64: ../block.c:6748: bdrv_inactivate_recurse: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed. 706 2024-06-17 11:15:59.972+0000: shutting down, reason=crashed
Additional information
- src -----> dest
migration_thread()
migration_completion
global_state_store()
vm_stop_force_state(RUN_STATE_FINISH_MIGRATE)
qemu_savevm_state_complete_precopy_nop_iterable()
bdrv_inactivate_all ()
bdrv_inactivate_recurse()
bs->open_flags |= BDRV_O_INACTIVE; (BDRV_O_INACTIVE=0x0800)
- dest -----> src
migration_thread()
qemu_savevm_state_complete_precopy_non_iterable()
bdrv_inactivate_all ()
bdrv_inactivate_recurse()
assert(!(bs->open_flags & BDRV_O_INACTIVE)); Assert and Crash
I'm not sure how to address this issue. If QEMU does not support such a migration, a gentler way would be to directly report an error and exit, just like what did in migrate_prepare function, instead of crash qemu.
If you have any ideas, please let me know, thanks.