Hello, guys! I am doing some experiment to control XenServer with libvirt, when I define a domain, it always fails and gives the following message: error: Failed to define domain from /root/new.xml error: internal error: Couldn't get VM information from XML so I diving into the souce and found it always fails at network creating, and the code in libvirt-1.3.5\src\xenapi\xenapi_utils.c, line 437 is following: xen_vif_create(session, &vif, vif_record); if (!vif) { xen_vif_free(vif); xen_vif_record_free(vif_record); xen_network_record_free(net_rec); xen_network_set_free(net_set); return 0; } xen_vif_record_free(vif_record); xen_network_record_free(net_rec); ... ... return -1; should this if be if (vif) {...}, if the vif is null, why need to free it?
Michal Privoznik
2016-Aug-01 06:52 UTC
Re: [libvirt-users] Some question about code of xenapi
On 31.07.2016 15:46, netcas wrote:> Hello, guys! I am doing some experiment to control XenServer with libvirt, when I define a domain, it always fails and gives the following message: > > > error: Failed to define domain from /root/new.xml > error: internal error: Couldn't get VM information from XML > > > so I diving into the souce and found it always fails at network creating, and the code in libvirt-1.3.5\src\xenapi\xenapi_utils.c, line 437 is following: > > > xen_vif_create(session, &vif, vif_record); > if (!vif) { > xen_vif_free(vif); > xen_vif_record_free(vif_record); > xen_network_record_free(net_rec); > xen_network_set_free(net_set); > return 0; > } > xen_vif_record_free(vif_record); > xen_network_record_free(net_rec); > ... ... > return -1; > > should this if be if (vif) {...}, if the vif is null, why need to free it?Frankly, I have no idea. It is very hard to get any documentation. The only way I've found to check is to look into the sources. Now, libxenserver package is not easy to get (you'd have to register at citrix webpage), but I've found this clone: https://github.com/sukinull/libxenserver/blob/master/src/xen_vif.c#L225 There, it looks to me like vif is always going to be NULL no matter what. Unfortunately, I don't have a setup to try the driver out. Michal