[libvirt] [PATCH v2] qemu_migration: Avoid crashing if domain dies too quickly

Michal Privoznik mprivozn at redhat.com
Fri Oct 18 06:36:51 UTC 2013


On 18.10.2013 08:22, Wangyufei (A) wrote:
> I'm sorry. I didn't get what you mean.
> 
> In virQEMUCapsInitQMP
> 
>     if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)) ||
>         !(vm = virDomainObjNew(xmlopt)))
>         goto cleanup;
> 
>     vm->pid = pid;   //Apparently vm is not NULL here.
> 
>     if (!(mon = qemuMonitorOpen(vm, &config, true, &callbacks, NULL))) {  //If qemuMonitorOpen returns NULL here, but not do mon->vm = virObjectRef(vm); in qemuMonitorOpenInternal.
>         ret = 0;
>         goto cleanup;  // We go to cleanup here.
>     }
> 
>     virObjectLock(mon);
> 
>     if (virQEMUCapsInitQMPMonitor(qemuCaps, mon) < 0)
>         goto cleanup;
> 
>     ret = 0;
> 
> cleanup:
>     if (mon)
>         virObjectUnlock(mon);
>     qemuMonitorClose(mon);
>     virCommandAbort(cmd);
>     virCommandFree(cmd);
>     VIR_FREE(monarg);
>     VIR_FREE(monpath);
>     virObjectUnref(vm);    //vm is not NULL here, and we'll do something about vm->refs, right?

Yes. In fact we dispose @vm as we are the only one holding reference to
it and we don't longer need it. If qemuMonitorOpenInternal would do
virObjectRef(vm), then vm->refs = 2 before executing this line. After
the execution, the refs is decremented to 1 as @mon is the only one
holding reference to @vm.

>     virObjectUnref(xmlopt);




More information about the libvir-list mailing list