mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 06:55:18 +00:00
add missing error handling to virGetDomain
When creating the virDomain::snapshots hash table, virGetDomain wasn't checking if the creation was successful. This would then lead to failures in the vir*DomainSnapshot functions. Better to report this error early and make virGetDomain fail if the snapshots hash couldn't be created. * src/datatypes.c: report failure to make a hash table
This commit is contained in:
parent
7adb3fb739
commit
dad4a3f29a
@ -375,6 +375,12 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
|
|||||||
ret->id = -1;
|
ret->id = -1;
|
||||||
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
|
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
|
||||||
ret->snapshots = virHashCreate(20);
|
ret->snapshots = virHashCreate(20);
|
||||||
|
if (ret->snapshots == NULL) {
|
||||||
|
virMutexUnlock(&conn->lock);
|
||||||
|
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("failed to create domain snapshots hash"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (virHashAddEntry(conn->domains, uuidstr, ret) < 0) {
|
if (virHashAddEntry(conn->domains, uuidstr, ret) < 0) {
|
||||||
virMutexUnlock(&conn->lock);
|
virMutexUnlock(&conn->lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user