mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
Adapt to VIR_ALLOC and virAsprintf in src/xenapi/*
This commit is contained in:
parent
d582618e11
commit
2f5560d32f
@ -77,10 +77,8 @@ getCapsObject(void)
|
||||
virCapsGuestDomainPtr domain1, domain2;
|
||||
virCapsPtr caps = virCapabilitiesNew(virArchFromHost(), 0, 0);
|
||||
|
||||
if (!caps) {
|
||||
virReportOOMError();
|
||||
if (!caps)
|
||||
return NULL;
|
||||
}
|
||||
guest1 = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, "", "", 0, NULL);
|
||||
if (!guest1)
|
||||
goto error_cleanup;
|
||||
@ -155,15 +153,11 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(privP) < 0) {
|
||||
virReportOOMError();
|
||||
if (VIR_ALLOC(privP) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virAsprintf(&privP->url, "https://%s", conn->uri->server) < 0) {
|
||||
virReportOOMError();
|
||||
if (virAsprintf(&privP->url, "https://%s", conn->uri->server) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (xenapiUtil_ParseQuery(conn, conn->uri, &privP->noVerify) < 0)
|
||||
goto error;
|
||||
@ -1372,7 +1366,6 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
||||
return NULL;
|
||||
}
|
||||
if (VIR_ALLOC(defPtr) < 0) {
|
||||
virReportOOMError();
|
||||
xen_vm_set_free(vms);
|
||||
return NULL;
|
||||
}
|
||||
@ -1502,12 +1495,12 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
||||
defPtr->nnets = vif_set->size;
|
||||
if (VIR_ALLOC_N(defPtr->nets, vif_set->size) < 0) {
|
||||
xen_vif_set_free(vif_set);
|
||||
goto error_cleanup;
|
||||
goto error;
|
||||
}
|
||||
for (i = 0; i < vif_set->size; i++) {
|
||||
if (VIR_ALLOC(defPtr->nets[i]) < 0) {
|
||||
xen_vif_set_free(vif_set);
|
||||
goto error_cleanup;
|
||||
goto error;
|
||||
}
|
||||
defPtr->nets[i]->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||
vif = vif_set->contents[i];
|
||||
@ -1534,13 +1527,10 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
||||
virDomainDefFree(defPtr);
|
||||
return xml;
|
||||
|
||||
error_cleanup:
|
||||
virReportOOMError();
|
||||
error:
|
||||
xen_vm_set_free(vms);
|
||||
virDomainDefFree(defPtr);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -347,10 +347,8 @@ allocStringMap(xen_string_string_map **strings, char *key, char *val)
|
||||
int sz = ((*strings) == NULL) ? 0 : (*strings)->size;
|
||||
sz++;
|
||||
if (VIR_REALLOC_N(*strings, sizeof(xen_string_string_map) +
|
||||
sizeof(xen_string_string_map_contents) * sz) < 0) {
|
||||
virReportOOMError();
|
||||
sizeof(xen_string_string_map_contents) * sz) < 0)
|
||||
return -1;
|
||||
}
|
||||
(*strings)->size = sz;
|
||||
if (VIR_STRDUP((*strings)->contents[sz-1].key, key) < 0 ||
|
||||
VIR_STRDUP((*strings)->contents[sz-1].val, val) < 0)
|
||||
@ -427,7 +425,7 @@ createVifNetwork(virConnectPtr conn, xen_vm vm, int device,
|
||||
vif_record->other_config = xen_string_string_map_alloc(0);
|
||||
vif_record->runtime_properties = xen_string_string_map_alloc(0);
|
||||
vif_record->qos_algorithm_params = xen_string_string_map_alloc(0);
|
||||
if (virAsprintf(&vif_record->device, "%d", device) < 0)
|
||||
if (virAsprintfQuiet(&vif_record->device, "%d", device) < 0)
|
||||
return -1;
|
||||
xen_vif_create(session, &vif, vif_record);
|
||||
if (!vif) {
|
||||
@ -545,22 +543,21 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
|
||||
char *mac;
|
||||
|
||||
if (VIR_ALLOC_N(mac, VIR_MAC_STRING_BUFLEN) < 0)
|
||||
goto error_cleanup;
|
||||
goto error;
|
||||
virMacAddrFormat(&def->nets[i]->mac, mac);
|
||||
|
||||
if (createVifNetwork(conn, *vm, device_number,
|
||||
def->nets[i]->data.bridge.brname,
|
||||
mac) < 0) {
|
||||
VIR_FREE(mac);
|
||||
goto error_cleanup;
|
||||
virReportOOMError();
|
||||
goto error;
|
||||
}
|
||||
device_number++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
error_cleanup:
|
||||
virReportOOMError();
|
||||
error:
|
||||
xen_vm_record_free(*record);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user