On Wed, Jul 16, 2014 at 5:24 PM, Andrey Korolyov <and...@xdel.ru> wrote: > On Wed, Jul 16, 2014 at 3:52 PM, Marcelo Tosatti <mtosa...@redhat.com> wrote: >> On Wed, Jul 16, 2014 at 12:38:51PM +0400, Andrey Korolyov wrote: >>> On Wed, Jul 16, 2014 at 5:16 AM, Marcelo Tosatti <mtosa...@redhat.com> >>> wrote: >>> > On Wed, Jul 16, 2014 at 03:40:47AM +0400, Andrey Korolyov wrote: >>> >> On Wed, Jul 16, 2014 at 2:01 AM, Paolo Bonzini <pbonz...@redhat.com> >>> >> wrote: >>> >> > Il 15/07/2014 23:25, Andrey Korolyov ha scritto: >>> >> > >>> >> >> On Wed, Jul 16, 2014 at 1:09 AM, Marcelo Tosatti <mtosa...@redhat.com> >>> >> >> wrote: >>> >> >>> >>> >> >>> On Tue, Jul 15, 2014 at 06:01:08PM +0400, Andrey Korolyov wrote: >>> >> >>>> >>> >> >>>> On Tue, Jul 15, 2014 at 10:52 AM, Andrey Korolyov <and...@xdel.ru> >>> >> >>>> wrote: >>> >> >>>>> >>> >> >>>>> On Tue, Jul 15, 2014 at 9:03 AM, Amit Shah <amit.s...@redhat.com> >>> >> >>>>> wrote: >>> >> >>>>>> >>> >> >>>>>> On (Sun) 13 Jul 2014 [16:28:56], Andrey Korolyov wrote: >>> >> >>>>>>> >>> >> >>>>>>> Hello, >>> >> >>>>>>> >>> >> >>>>>>> the issue is not specific to the iothread code because generic >>> >> >>>>>>> virtio-blk also hangs up: >>> >> >>>>>> >>> >> >>>>>> >>> >> >>>>>> Do you know which version works well? If you could bisect, >>> >> >>>>>> that'll >>> >> >>>>>> help a lot. >>> >> >>>>>> >>> >> >>>>>> Thanks, >>> >> >>>>>> Amit >>> >> >>>>> >>> >> >>>>> >>> >> >>>>> Hi, >>> >> >>>>> >>> >> >>>>> 2.0 works definitely well. I`ll try to finish bisection today, >>> >> >>>>> though >>> >> >>>>> every step takes about 10 minutes to complete. >>> >> >>>> >>> >> >>>> >>> >> >>>> Yay! It is even outside of virtio-blk. >>> >> >>>> >>> >> >>>> commit 9b1786829aefb83f37a8f3135e3ea91c56001b56 >>> >> >>>> Author: Marcelo Tosatti <mtosa...@redhat.com> >>> >> >>>> Date: Tue Jun 3 13:34:48 2014 -0300 >>> >> >>>> >>> >> >>>> kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec >>> >> >>>> calculation >>> >> >>>> >>> >> >>>> Ensure proper env->tsc value for kvmclock_current_nsec >>> >> >>>> calculation. >>> >> >>>> >>> >> >>>> Reported-by: Marcin Gibuła <m.gib...@beyond.pl> >>> >> >>>> Cc: qemu-sta...@nongnu.org >>> >> >>>> Signed-off-by: Marcelo Tosatti <mtosa...@redhat.com> >>> >> >>>> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> >>> >> >>> >>> >> >>> >>> >> >>> Andrey, >>> >> >>> >>> >> >>> Can you please provide instructions on how to create reproducible >>> >> >>> environment? >>> >> >>> >>> >> >>> The following patch is equivalent to the original patch, for >>> >> >>> the purposes of fixing the kvmclock problem. >>> >> >>> >>> >> >>> Perhaps it becomes easier to spot the reason for the hang you are >>> >> >>> experiencing. >>> >> >>> >>> >> >>> >>> >> >>> diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c >>> >> >>> index 272a88a..feb5fc5 100644 >>> >> >>> --- a/hw/i386/kvm/clock.c >>> >> >>> +++ b/hw/i386/kvm/clock.c >>> >> >>> @@ -17,7 +17,6 @@ >>> >> >>> #include "qemu/host-utils.h" >>> >> >>> #include "sysemu/sysemu.h" >>> >> >>> #include "sysemu/kvm.h" >>> >> >>> -#include "sysemu/cpus.h" >>> >> >>> #include "hw/sysbus.h" >>> >> >>> #include "hw/kvm/clock.h" >>> >> >>> >>> >> >>> @@ -66,7 +65,6 @@ static uint64_t >>> >> >>> kvmclock_current_nsec(KVMClockState *s) >>> >> >>> >>> >> >>> cpu_physical_memory_read(kvmclock_struct_pa, &time, >>> >> >>> sizeof(time)); >>> >> >>> >>> >> >>> - assert(time.tsc_timestamp <= migration_tsc); >>> >> >>> delta = migration_tsc - time.tsc_timestamp; >>> >> >>> if (time.tsc_shift < 0) { >>> >> >>> delta >>= -time.tsc_shift; >>> >> >>> @@ -125,8 +123,6 @@ static void kvmclock_vm_state_change(void >>> >> >>> *opaque, >>> >> >>> int running, >>> >> >>> if (s->clock_valid) { >>> >> >>> return; >>> >> >>> } >>> >> >>> - >>> >> >>> - cpu_synchronize_all_states(); >>> >> >>> ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data); >>> >> >>> if (ret < 0) { >>> >> >>> fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", >>> >> >>> strerror(ret)); >>> >> >>> diff --git a/migration.c b/migration.c >>> >> >>> index 8d675b3..34f2325 100644 >>> >> >>> --- a/migration.c >>> >> >>> +++ b/migration.c >>> >> >>> @@ -608,6 +608,7 @@ static void *migration_thread(void *opaque) >>> >> >>> >>> >> >>> qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); >>> >> >>> old_vm_running = runstate_is_running(); >>> >> >>> >>> >> >>> + cpu_synchronize_all_states(); >>> >> >>> ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); >>> >> >>> if (ret >= 0) { >>> >> >>> qemu_file_set_rate_limit(s->file, INT64_MAX); >>> >> > >>> >> > >>> >> > It could also be useful to apply the above patch _and_ revert >>> >> > a096b3a6732f846ec57dc28b47ee9435aa0609bf, then try to reproduce. >>> >> > >>> >> > Paolo >>> >> >>> >> Yes, it solved the issue for me! (it took much time to check because >>> >> most of country` debian mirrors went inconsistent by some reason) >>> >> >>> >> Also trivial addition: >>> >> >>> >> diff --git a/migration.c b/migration.c >>> >> index 34f2325..65d1c88 100644 >>> >> --- a/migration.c >>> >> +++ b/migration.c >>> >> @@ -25,6 +25,7 @@ >>> >> #include "qemu/thread.h" >>> >> #include "qmp-commands.h" >>> >> #include "trace.h" >>> >> +#include "sysemu/cpus.h" >>> > >>> > And what about not reverting a096b3a6732f846ec57dc28b47ee9435aa0609bf ? >>> > >>> > That is, test with a stock qemu.git tree and the patch sent today, >>> > on this thread, to move cpu_synchronize_all_states ? >>> > >>> > >>> >>> The main reason for things to work for me is a revert of >>> 9b1786829aefb83f37a8f3135e3ea91c56001b56 on top, not adding any other >>> patches. I had tested two cases, with Alexander`s patch completely >>> reverted plus suggestion from Marcelo and only with revert 9b178682 >>> plug same suggestion. The difference is that the until Alexander` >>> patch is not reverted, live migration is always failing by the timeout >>> value, and when reverted migration always succeeds in 8-10 seconds. >>> Appropriate diffs are attached for the reference. >> >> Andrey, >> >> Can you please apply only the following attached patch to an upstream >> QEMU git tree (move_synchronize_all_states.patch), plus the necessary >> header file corrections, and attempt to reproduce? >> >> When you reproduce, please provide a backtrace and version of the QEMU >> git tree, and instructions on how to reproduce: >> >> 1) full QEMU command line >> 2) steps to reproduce >> >> > > Marcelo, as I can see, this patch resembles second case from my > previous message exactly (there are diffs from the generic rc). I/O is > not locking up there but live migration failing and libvirt moves a > freezed state. I can try to run the same on top of rc2, but it`ll be > probably the same.
Tested on iscsi pool, though there are no-cache requirement and rbd with disabled cache may survive one migration but iscsi backend hangs always. As it was before, just rolling back problematic commit fixes the problem and adding cpu_synchronize_all_states to migration.c has no difference at a glance in a VM` behavior. The problem consist at least two separate ones: the current hang and behavior with the unreverted patch from agraf - last one causes live migration with writeback cache to fail, cache=none works well in any variant which survives first condition. Marcin, would you mind to check the current state of the problem on your environments in a spare time? It is probably easier to reproduce on iscsi because of way smaller time needed to set it up, command line and libvirt config attached (v2.1.0-rc2 plus iscsi-1.11.0).
qemu-system-x86_64 -enable-kvm -name vm27842 -S -machine pc-i440fx-2.1,accel=kvm,usb=off -m 256 -realtime mlock=off -smp 12,sockets=1,cores=12,threads=12 -numa node,nodeid=0,cpus=0,mem=256 -uuid 9a44bdae-5702-463b-aa1e-d8d85055f6af -nographic -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/vm27842.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,clock=vm,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/dev/disk/by-path/ip-10.6.0.1:3260-iscsi-iqn.2014-05.ru.flops:kvmguest-lun-1,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:10:03:40,bus=pci.0,addr=0x3 -netdev tap,fd=25,id=hostnet1,vhost=on,vhostfd=26 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:10:03:41,bus=pci.0,addr=0x4 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/vm27842.sock,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.1
<domain type='kvm'> <name>vm27842</name> <uuid>9a44bdae-5702-463b-aa1e-d8d85055f6af</uuid> <description>3145728</description> <memory unit='KiB'>262144</memory> <currentMemory unit='KiB'>262144</currentMemory> <vcpu placement='static' cpuset='0-11'>12</vcpu> <os> <type arch='x86_64' machine='pc-i440fx-2.1'>hvm</type> <boot dev='hd'/> <smbios mode='sysinfo'/> </os> <features> <acpi/> <apic/> <pae/> </features> <cpu> <topology sockets='1' cores='12' threads='12'/> <numa> <cell cpus='0' memory='262144'/> </numa> </cpu> <clock offset='utc'> <timer name='rtc' tickpolicy='catchup' track='guest'> <catchup threshold='123' slew='120' limit='10000'/> </timer> <timer name='pit' tickpolicy='delay'/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source dev='/dev/disk/by-path/ip-10.6.0.1:3260-iscsi-iqn.2014-05.ru.flops:kvmguest-lun-1'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </disk> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </controller> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='pci' index='0' model='pci-root'/> <interface type='bridge'> <mac address='52:54:00:10:03:40'/> <source bridge='oswbr0'/> <virtualport type='openvswitch'> <parameters interfaceid='0bf5d1b1-a972-40e4-839d-067730f4f20d'/> </virtualport> <target dev='vp27842l'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <interface type='bridge'> <mac address='52:54:00:10:03:41'/> <source bridge='oswbr0'/> <virtualport type='openvswitch'> <parameters interfaceid='f7ebddab-6f4d-4e01-8a5a-59ee3e434c92'/> </virtualport> <target dev='vp27842p'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </interface> <serial type='pty'> <target type='isa-serial' port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/vm27842.sock'/> <target type='virtio' name='org.qemu.guest_agent.1'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> <memballoon model='none'/> </devices> <seclabel type='none'/> </domain>
[random] rw=randrw size=768M directory=/data iodepth=32 fsync=1 direct=1 blocksize=2M numjobs=1 nrfiles=4 group_reporting ioengine=libaio loops=512