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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18.10.2013 09:22, Wangyufei (A) wrote:
> 
> 
>> -----Original Message-----
>> From: Michal Privoznik [mailto:mprivozn@xxxxxxxxxx]
>> Sent: Friday, October 18, 2013 2:37 PM
>> To: Wangyufei (A)
>> Cc: libvir-list@xxxxxxxxxx; Wangrui (K)
>> Subject: Re:  [PATCH v2] qemu_migration: Avoid crashing if domain
>> dies too quickly
>>
>> 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
> 
> If qemuMonitorOpenInternal did not do virObjectRef(vm) and return NULL before it, then vm->refs = 1 before executing this line. Right?
> Now we do virObjectUnref(vm), vm will be disposed here, and that's we expected. Fine, I've got you. Thanks a lot.

Exactly. We don't want to leave @vm allocated if there was an error.
However, we do want to leave @vm allocated if monitor is successfully
opened. Then, the qemuMonitorDispose will be the one to dispose the @vm.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]