mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
vbox: remove unneeded cleanup labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6c63adc4a0
commit
adf9c3f952
@ -2199,21 +2199,21 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!data->vboxObj)
|
if (!data->vboxObj)
|
||||||
return ret;
|
return -1;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!dom->name) {
|
if (!dom->name) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Error while reading the domain name"));
|
_("Error while reading the domain name"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES);
|
rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES);
|
||||||
if (NS_FAILED(rc)) {
|
if (NS_FAILED(rc)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get list of machines, rc=%08x"), (unsigned)rc);
|
_("Could not get list of machines, rc=%08x"), (unsigned)rc);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < machines.count; ++i) {
|
for (i = 0; i < machines.count; ++i) {
|
||||||
@ -2257,7 +2257,6 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
/* Do the cleanup and take care you dont leak any memory */
|
/* Do the cleanup and take care you dont leak any memory */
|
||||||
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2752,13 +2751,13 @@ static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!data->vboxObj)
|
if (!data->vboxObj)
|
||||||
return ret;
|
return -1;
|
||||||
|
|
||||||
rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES);
|
rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES);
|
||||||
if (NS_FAILED(rc)) {
|
if (NS_FAILED(rc)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get list of machines, rc=%08x"), (unsigned)rc);
|
_("Could not get list of machines, rc=%08x"), (unsigned)rc);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->nrVirtCpu = 0;
|
info->nrVirtCpu = 0;
|
||||||
@ -2820,7 +2819,6 @@ static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
|
|
||||||
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,18 +749,17 @@ virVBoxSnapshotConfAddSnapshotToXmlMachine(virVBoxSnapshotConfSnapshotPtr snapsh
|
|||||||
virVBoxSnapshotConfMachinePtr machine,
|
virVBoxSnapshotConfMachinePtr machine,
|
||||||
const char *snapshotParentName)
|
const char *snapshotParentName)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
virVBoxSnapshotConfSnapshotPtr parentSnapshot = NULL;
|
virVBoxSnapshotConfSnapshotPtr parentSnapshot = NULL;
|
||||||
|
|
||||||
if (snapshot == NULL) {
|
if (snapshot == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Snapshot is Null"));
|
_("Snapshot is Null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (machine == NULL) {
|
if (machine == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Machine is Null"));
|
_("Machine is Null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*If parent is NULL and the machine has no snapshot yet,
|
/*If parent is NULL and the machine has no snapshot yet,
|
||||||
@ -770,32 +769,29 @@ virVBoxSnapshotConfAddSnapshotToXmlMachine(virVBoxSnapshotConfSnapshotPtr snapsh
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Unable to add this snapshot, there is already a snapshot "
|
_("Unable to add this snapshot, there is already a snapshot "
|
||||||
"linked to the machine"));
|
"linked to the machine"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
machine->snapshot = snapshot;
|
machine->snapshot = snapshot;
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
} else {
|
} else {
|
||||||
if (machine->snapshot == NULL) {
|
if (machine->snapshot == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("The machine has no snapshot and it should have it"));
|
_("The machine has no snapshot and it should have it"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
parentSnapshot = virVBoxSnapshotConfSnapshotByName(machine->snapshot, snapshotParentName);
|
parentSnapshot = virVBoxSnapshotConfSnapshotByName(machine->snapshot, snapshotParentName);
|
||||||
if (parentSnapshot == NULL) {
|
if (parentSnapshot == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to find the snapshot %s"), snapshotParentName);
|
_("Unable to find the snapshot %s"), snapshotParentName);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (VIR_EXPAND_N(parentSnapshot->children, parentSnapshot->nchildren, 1) < 0)
|
if (VIR_EXPAND_N(parentSnapshot->children, parentSnapshot->nchildren, 1) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
parentSnapshot->children[parentSnapshot->nchildren - 1] = snapshot;
|
parentSnapshot->children[parentSnapshot->nchildren - 1] = snapshot;
|
||||||
ret = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -809,18 +805,17 @@ virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr har
|
|||||||
virVBoxSnapshotConfMediaRegistryPtr mediaRegistry,
|
virVBoxSnapshotConfMediaRegistryPtr mediaRegistry,
|
||||||
const char *parentHardDiskId)
|
const char *parentHardDiskId)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
virVBoxSnapshotConfHardDiskPtr parentDisk = NULL;
|
virVBoxSnapshotConfHardDiskPtr parentDisk = NULL;
|
||||||
if (hardDisk == NULL) {
|
if (hardDisk == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Hard disk is null"));
|
_("Hard disk is null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (mediaRegistry == NULL) {
|
if (mediaRegistry == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Media Registry is null"));
|
_("Media Registry is null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < mediaRegistry->ndisks; i++) {
|
for (i = 0; i < mediaRegistry->ndisks; i++) {
|
||||||
@ -831,19 +826,17 @@ virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr har
|
|||||||
if (parentDisk == NULL) {
|
if (parentDisk == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Unable to get the parent disk"));
|
_("Unable to get the parent disk"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
/*Hard disk found*/
|
/*Hard disk found*/
|
||||||
if (VIR_EXPAND_N(parentDisk->children, parentDisk->nchildren, 1) < 0)
|
if (VIR_EXPAND_N(parentDisk->children, parentDisk->nchildren, 1) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
parentDisk->children[parentDisk->nchildren - 1] = hardDisk;
|
parentDisk->children[parentDisk->nchildren - 1] = hardDisk;
|
||||||
if (hardDisk->parent == NULL)
|
if (hardDisk->parent == NULL)
|
||||||
hardDisk->parent = parentDisk;
|
hardDisk->parent = parentDisk;
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -856,48 +849,47 @@ int
|
|||||||
virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine,
|
virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine,
|
||||||
const char *snapshotName)
|
const char *snapshotName)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
virVBoxSnapshotConfSnapshotPtr snapshot = NULL;
|
virVBoxSnapshotConfSnapshotPtr snapshot = NULL;
|
||||||
virVBoxSnapshotConfSnapshotPtr parentSnapshot = NULL;
|
virVBoxSnapshotConfSnapshotPtr parentSnapshot = NULL;
|
||||||
if (machine == NULL) {
|
if (machine == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("machine is null"));
|
_("machine is null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (snapshotName == NULL) {
|
if (snapshotName == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("snapshotName is null"));
|
_("snapshotName is null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (machine->snapshot == NULL) {
|
if (machine->snapshot == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("the machine has no snapshot"));
|
_("the machine has no snapshot"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
snapshot = virVBoxSnapshotConfSnapshotByName(machine->snapshot, snapshotName);
|
snapshot = virVBoxSnapshotConfSnapshotByName(machine->snapshot, snapshotName);
|
||||||
if (snapshot == NULL) {
|
if (snapshot == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to find the snapshot with name %s"), snapshotName);
|
_("Unable to find the snapshot with name %s"), snapshotName);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (snapshot->nchildren > 0) {
|
if (snapshot->nchildren > 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("This snapshot has children, "
|
_("This snapshot has children, "
|
||||||
"please delete theses snapshots before"));
|
"please delete theses snapshots before"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot->parent == NULL) {
|
if (snapshot->parent == NULL) {
|
||||||
if (machine->snapshot != snapshot) {
|
if (machine->snapshot != snapshot) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("You are trying to remove a snapshot which does not exists"));
|
_("You are trying to remove a snapshot which does not exists"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
machine->snapshot = NULL;
|
machine->snapshot = NULL;
|
||||||
virVBoxSnapshotConfSnapshotFree(snapshot);
|
virVBoxSnapshotConfSnapshotFree(snapshot);
|
||||||
ret = 0;
|
|
||||||
goto cleanup;
|
return 0;
|
||||||
}
|
}
|
||||||
parentSnapshot = snapshot->parent;
|
parentSnapshot = snapshot->parent;
|
||||||
|
|
||||||
@ -905,11 +897,9 @@ virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine,
|
|||||||
while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot)
|
while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot)
|
||||||
++i;
|
++i;
|
||||||
if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0)
|
if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -922,19 +912,18 @@ int
|
|||||||
virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegistry,
|
virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegistry,
|
||||||
const char *uuid)
|
const char *uuid)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
virVBoxSnapshotConfHardDiskPtr hardDisk = NULL;
|
virVBoxSnapshotConfHardDiskPtr hardDisk = NULL;
|
||||||
virVBoxSnapshotConfHardDiskPtr parentHardDisk = NULL;
|
virVBoxSnapshotConfHardDiskPtr parentHardDisk = NULL;
|
||||||
if (mediaRegistry == NULL) {
|
if (mediaRegistry == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Media registry is null"));
|
_("Media registry is null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (uuid == NULL) {
|
if (uuid == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Uuid is null"));
|
_("Uuid is null"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < mediaRegistry->ndisks; i++) {
|
for (i = 0; i < mediaRegistry->ndisks; i++) {
|
||||||
@ -945,7 +934,7 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis
|
|||||||
if (hardDisk == NULL) {
|
if (hardDisk == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to find the hard disk with uuid %s"), uuid);
|
_("Unable to find the hard disk with uuid %s"), uuid);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (hardDisk->parent == NULL) {
|
if (hardDisk->parent == NULL) {
|
||||||
/* it means that the hard disk is in 'root' */
|
/* it means that the hard disk is in 'root' */
|
||||||
@ -954,9 +943,9 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (VIR_DELETE_ELEMENT(mediaRegistry->disks, i, mediaRegistry->ndisks) < 0)
|
if (VIR_DELETE_ELEMENT(mediaRegistry->disks, i, mediaRegistry->ndisks) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
ret = 0;
|
|
||||||
goto cleanup;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
parentHardDisk = hardDisk->parent;
|
parentHardDisk = hardDisk->parent;
|
||||||
@ -965,11 +954,9 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis
|
|||||||
++i;
|
++i;
|
||||||
hardDisk->parent = NULL;
|
hardDisk->parent = NULL;
|
||||||
if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0)
|
if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*vboxSnapshotSaveVboxFile: Create a VirtualBox XML file from a vboxSnapshotXmlMachinePtr.
|
/*vboxSnapshotSaveVboxFile: Create a VirtualBox XML file from a vboxSnapshotXmlMachinePtr.
|
||||||
|
Loading…
Reference in New Issue
Block a user