mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
examples: remove unneeded labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
67ded67321
commit
a7c6faa7ee
@ -10,7 +10,6 @@
|
||||
static int
|
||||
showHypervisorInfo(virConnectPtr conn)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long hvVer, major, minor, release;
|
||||
const char *hvType;
|
||||
|
||||
@ -20,17 +19,15 @@ showHypervisorInfo(virConnectPtr conn)
|
||||
* hypervisor, so check what it returns. */
|
||||
hvType = virConnectGetType(conn);
|
||||
if (!hvType) {
|
||||
ret = 1;
|
||||
printf("Failed to get hypervisor type: %s\n",
|
||||
virGetLastErrorMessage());
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != virConnectGetVersion(conn, &hvVer)) {
|
||||
ret = 1;
|
||||
printf("Failed to get hypervisor version: %s\n",
|
||||
virGetLastErrorMessage());
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
major = hvVer / 1000000;
|
||||
@ -44,15 +41,14 @@ showHypervisorInfo(virConnectPtr conn)
|
||||
minor,
|
||||
release);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
showDomains(virConnectPtr conn)
|
||||
{
|
||||
int ret = 0, numNames, numInactiveDomains, numActiveDomains;
|
||||
int numNames, numInactiveDomains, numActiveDomains;
|
||||
ssize_t i;
|
||||
int flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
|
||||
VIR_CONNECT_LIST_DOMAINS_INACTIVE;
|
||||
@ -64,18 +60,16 @@ showDomains(virConnectPtr conn)
|
||||
* unexpected results */
|
||||
numActiveDomains = virConnectNumOfDomains(conn);
|
||||
if (numActiveDomains == -1) {
|
||||
ret = 1;
|
||||
printf("Failed to get number of active domains: %s\n",
|
||||
virGetLastErrorMessage());
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
numInactiveDomains = virConnectNumOfDefinedDomains(conn);
|
||||
if (numInactiveDomains == -1) {
|
||||
ret = 1;
|
||||
printf("Failed to get number of inactive domains: %s\n",
|
||||
virGetLastErrorMessage());
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("There are %d active and %d inactive domains\n",
|
||||
@ -89,10 +83,9 @@ showDomains(virConnectPtr conn)
|
||||
&nameList,
|
||||
flags);
|
||||
if (numNames == -1) {
|
||||
ret = 1;
|
||||
printf("Failed to get a list of all domains: %s\n",
|
||||
virGetLastErrorMessage());
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < numNames; i++) {
|
||||
@ -105,8 +98,7 @@ showDomains(virConnectPtr conn)
|
||||
}
|
||||
free(nameList);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -126,10 +118,9 @@ main(int argc, char *argv[])
|
||||
conn = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0);
|
||||
|
||||
if (!conn) {
|
||||
ret = 1;
|
||||
printf("No connection to hypervisor: %s\n",
|
||||
virGetLastErrorMessage());
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uri = virConnectGetURI(conn);
|
||||
@ -162,6 +153,5 @@ main(int argc, char *argv[])
|
||||
printf("Disconnected from hypervisor\n");
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ showError(virConnectPtr conn)
|
||||
err = malloc(sizeof(*err));
|
||||
if (err == NULL) {
|
||||
printf("Could not allocate memory for error data\n");
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
|
||||
ret = virConnCopyLastError(conn, err);
|
||||
@ -37,16 +37,12 @@ showError(virConnectPtr conn)
|
||||
|
||||
virResetError(err);
|
||||
free(err);
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
showHypervisorInfo(virConnectPtr conn)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long hvVer, major, minor, release;
|
||||
const char *hvType;
|
||||
|
||||
@ -56,17 +52,15 @@ showHypervisorInfo(virConnectPtr conn)
|
||||
* hypervisor, so check what it returns. */
|
||||
hvType = virConnectGetType(conn);
|
||||
if (hvType == NULL) {
|
||||
ret = 1;
|
||||
printf("Failed to get hypervisor type\n");
|
||||
showError(conn);
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (virConnectGetVersion(conn, &hvVer) != 0) {
|
||||
ret = 1;
|
||||
printf("Failed to get hypervisor version\n");
|
||||
showError(conn);
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
major = hvVer / 1000000;
|
||||
@ -80,8 +74,7 @@ showHypervisorInfo(virConnectPtr conn)
|
||||
minor,
|
||||
release);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -227,9 +220,8 @@ main(int argc, char *argv[])
|
||||
AuthData authData;
|
||||
|
||||
if (argc != 4) {
|
||||
ret = 1;
|
||||
printf("Usage: %s <uri> <username> <password>\n", argv[0]);
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uri = argv[1];
|
||||
@ -242,10 +234,9 @@ main(int argc, char *argv[])
|
||||
conn = virConnectOpenAuth(uri, &auth, 0);
|
||||
|
||||
if (NULL == conn) {
|
||||
ret = 1;
|
||||
printf("No connection to hypervisor\n");
|
||||
showError(conn);
|
||||
goto out;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uri = virConnectGetURI(conn);
|
||||
@ -278,6 +269,5 @@ main(int argc, char *argv[])
|
||||
printf("Disconnected from hypervisor\n");
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user