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); -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list