agree,I have tested the flag and it works well, i will post another patch later. 

Thanks very much!

2014-11-03 20:03 GMT+08:00 Ján Tomko <jtomko@redhat.com>:
On 11/03/2014 05:22 AM, weiwei li wrote:
> mig->nbd is initialized by qemuMigrationCookieXMLParse(called
> by qemuMigrationEatCookie),with a condition that
> the nbd infomation contained in Cookie string. I found in debug info
> that qemuMigrationStartNBDServer had been called in
> qemuMigrationPrepareAny(mig->nbd not null), but at
> in qemuMigrationFinish qemuMigrationStopNBDServer can not really
> stop nbd server bucause mig->nbd is not initialized(that is because cookie
> string does not contain nbd information ).
>
> so ,there are two solutions:
> 1 qemuMigrationStopNBDServer  ignore mig->nbd null ptr
> 2 add cookie info for nbd same stage (that is lost in which stage i am not sure~ )
>
> I choose an easy way solution 1 with least code changing, maybe is not google
> way :)
>
> cookie log is like this:
> 2014-10-30 08:38:14.106+0000: 15078: debug : qemuMigrationRun:3254 :
> driver=0x7f936413cd40, vm=0x7f934400b850, cookiein=<qemu-migration>
>   <name>3cd4c349-e058-4a1a-8b3d-cc988efd11e2</name>
>   <uuid>3cd4c349-e058-4a1a-8b3d-cc988efd11e2</uuid>
>   <hostname>50e54929-059c-ffff-ffff-ffffffffffff_10.180.39.36</hostname>
>   <hostuuid>50e54929-059c-ffff-ffff-ffffffffffff</hostuuid>
>  <nbd port='49153'/>
> </qemu-migration>
>
> 2014-10-30 08:39:12.527+0000: 15076: debug : virObjectRef:296 : OBJECT_REF:
> obj=0x7f9364138880
> 2014-10-30 08:39:12.527+0000: 15076: debug : qemuMigrationFinish:4507 :
> driver=0x7f936413cd40, dconn=0x7f9358002720, vm=0x7f935c002da0,
> cookiein=<qemu-migration>
>   <name>3cd4c349-e058-4a1a-8b3d-cc988efd11e2</name>
>   <uuid>3cd4c349-e058-4a1a-8b3d-cc988efd11e2</uuid>
>   <hostname>50e54929-059c-ffff-ffff-ffffffffffff_10.180.39.36</hostname>
>   <hostuuid>50e54929-059c-ffff-ffff-ffffffffffff</hostuuid>
>   <feature name='persistent'/>

...

>       <memballoon model='virtio'>
>         <address type='pci' domain='0x0000' bus='0x00' slot='0x06'
> function='0x0'/>
>       </memballoon>
>     </devices>
>   </domain>

>   <nbd/>

So the <nbd/> element is there, we just don't parse it because
qemuMigrationFinish calls qemuMigrationEatCookie without the
QEMU_MIGRATION_COOKIE_NBD flag.

I believe the proper fix is to add this flag there.

Jan

> </qemu-migration>
> , cookieinlen=2567, cookieout=0x7f93722eab08, cookieoutlen=0x7f93722eab14,
> flags=289, retcode=0
>