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