Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 17 participants
- 40169 discussions
Good morning!
I am one of the developers of OurGrid (http://www.ourgrid.org) a middleware
that enables the creation of peer-to-peer computational grids, and we are
studying your Libvirt API in order to see if it satisfies our middleware's
demands.
So we found out your Application Development Guide, and it is being quite
useful. I just found small mistakes in the code examples. Even though don't
know if this is the appropriate place to notify you guys, here you are:
At section 3.9, in the main function, the if block above:
if (conn4 == NULL) {
fprintf(stderr, "Failed to open connection to
qemu:///system\n");
virConnectClose(conn3);
virConnectClose(conn2);
virConnectClose(conn1);
return 3;
}
The 'return 3' was meant to be 'return 4', right?
And I guess that the final If block at section 4.3 is just missing a return
statement too.
With that being said, I want to take this opportunity to say that
documentation of section 9.3 (Java bindings) would be of great help to us,
since we are developing everything using Java.
Cheers and congratulations for this great job you guys are doing.
Moreover, sorry for my poor english.
Guilherme Santos
--
Guilherme Santos G. Baptista
Graduando em Ciência da Computação pela UFCG
LSD - Laboratório de Sistemas Distribuídos
1
0
[libvirt] [libvirt-snmp][PATCH v5 0/4] Add SNMP trap/notification support
by Michal Privoznik 20 Apr '11
by Michal Privoznik 20 Apr '11
20 Apr '11
The fifth version.
In case we build against libvirt older than 0.9.0 (which have old event API),
we need to include some sources from libvirt git. So we are able to run even
on older RHELs, like 5.6. Those files were copied to our git and modified
very slighty.
Finally, we have a proof-of-concept implementation of SNMP trap.
Two new files were first generated using mib2c then edited, so be
careful when re-generating them.
Destination of traps is defined in snmpd.conf (trap2sink), and to
receive them snmptrapd must be configured and up.
The idea behind is - create a thread in which we poll for domain
events. Once we receive event notification, we just fire up
trap sending.
Michal Privoznik (4):
Add notification-type object to libvirt MIB
Add libvirt error handling function
Create functions to fill in and send notification packets.
Add SNMP trap/notification support.
INSTALL.1st | 9 +-
configure.ac | 17 +-
libvirt-snmp.spec.in | 7 +-
src/LIBVIRT-MIB.txt | 9 +
src/Makefile.am | 25 ++-
src/README.txt | 9 +-
src/event_poll.c | 724 ++++++++++++++++++++++++++++++++++++++++++++
src/event_poll.h | 132 ++++++++
src/ignore-value.h | 64 ++++
src/internal.h | 267 ++++++++++++++++
src/libvirtNotifications.c | 122 ++++++++
src/libvirtNotifications.h | 33 ++
src/libvirtSnmp.c | 154 +++++++++-
src/libvirtSnmpError.c | 34 ++
src/libvirtSnmpError.h | 31 ++
src/memory.c | 313 +++++++++++++++++++
src/memory.h | 212 +++++++++++++
src/threads.c | 251 +++++++++++++++
src/threads.h | 101 ++++++
src/util.c | 105 +++++++
src/util.h | 38 +++
21 files changed, 2643 insertions(+), 14 deletions(-)
create mode 100644 src/event_poll.c
create mode 100644 src/event_poll.h
create mode 100644 src/ignore-value.h
create mode 100644 src/internal.h
create mode 100644 src/libvirtNotifications.c
create mode 100644 src/libvirtNotifications.h
create mode 100644 src/libvirtSnmpError.c
create mode 100644 src/libvirtSnmpError.h
create mode 100644 src/memory.c
create mode 100644 src/memory.h
create mode 100644 src/threads.c
create mode 100644 src/threads.h
create mode 100644 src/util.c
create mode 100644 src/util.h
--
1.7.4.2
2
5
also add flags for this function, currently not used.
---
src/libvirt-php.c | 31 +++++++++++++++++++++++++++++++
src/libvirt-php.h | 1 +
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index d436e1c..54331bb 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -129,6 +129,7 @@ static function_entry libvirt_functions[] = {
PHP_FE(libvirt_storagepool_refresh, NULL)
PHP_FE(libvirt_storagepool_set_autostart, NULL)
PHP_FE(libvirt_storagepool_get_autostart, NULL)
+ PHP_FE(libvirt_storagepool_build, NULL)
/* Network functions */
PHP_FE(libvirt_network_define_xml, NULL)
PHP_FE(libvirt_network_undefine, NULL)
@@ -542,6 +543,13 @@ PHP_MINIT_FUNCTION(libvirt)
/* Forcibly modify device (ex. force eject a cdrom) */
REGISTER_LONG_CONSTANT("VIR_DOMAIN_DEVICE_MODIFY_FORCE", 4, CONST_CS | CONST_PERSISTENT);
+ /* REGISTER_LONG_CONSTANT */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_NEW", 0, CONST_CS | CONST_PERSISTENT);
+ /* Repair / reinitialize */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_REPAIR", 1, CONST_CS | CONST_PERSISTENT);
+ /* Extend existing pool */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_RESIZE", 2, CONST_CS | CONST_PERSISTENT);
+
REGISTER_INI_ENTRIES();
/* Initialize libvirt and set up error callback */
@@ -3582,6 +3590,29 @@ PHP_FUNCTION(libvirt_storagepool_get_autostart)
}
}
+/*
+ Function name: libvirt_storagepool_build
+ Since version: 0.4.2
+ Description: Function is used to Build the underlying storage pool, e.g. create the destination directory for NFS
+ Arguments: @res [resource]: libvirt storagepool resource
+ Returns: TRUE if success, FALSE on error
+*/
+PHP_FUNCTION(libvirt_storagepool_build)
+{
+ php_libvirt_storagepool *pool = NULL;
+ zval *zpool;
+ int flags = 0;
+
+ GET_STORAGEPOOL_FROM_ARGS ("r", &zpool);
+
+ if (virStoragePoolBuild (pool->pool, flags) == 0)
+ {
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+
/* Listing functions */
/*
Function name: libvirt_list_storagepools
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 4e8dec6..2d79f60 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -193,6 +193,7 @@ PHP_FUNCTION(libvirt_storagepool_get_volume_count);
PHP_FUNCTION(libvirt_storagepool_refresh);
PHP_FUNCTION(libvirt_storagepool_set_autostart);
PHP_FUNCTION(libvirt_storagepool_get_autostart);
+PHP_FUNCTION(libvirt_storagepool_build);
/* Network functions */
PHP_FUNCTION(libvirt_network_define_xml);
PHP_FUNCTION(libvirt_network_undefine);
--
1.7.3.4
2
1
[libvirt] [RFC][PATCHv1 0/5] libvirt - show per cpu accounting information
by KAMEZAWA Hiroyuki 20 Apr '11
by KAMEZAWA Hiroyuki 20 Apr '11
20 Apr '11
When running 'virt-top -1' , "show percpu statistics mode",
virt-top shows a fake value.
When running 'while true; do echo hello;done' on a 4vcpu guest,
==
0 0.0
1 0.0
2 0.0
3 0.0
4 25.0 25.0=
5 25.0 25.0=#
6 25.0 25.0=
7 25.0 25.0=
==
All cpus just used equally ;)
This is because there is no interface to get per-cpu usage of domain.
This patch adds an interface virDomainPcpuStats() to get per-cpu
statistics, cpuTime in nanoseconds.
Here is a test result with a python script using new interface.
==
[root@bluextal python]# ./virt-cpuacct.py
({'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 4679204346L}, {'cpuTime': 2103820380L}, {'cpuTime': 8904513019L}, {'cpuTime': 7424701195L})
[root@bluextal python]# ./virt-cpuacct.py
({'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 57010689139L}, {'cpuTime': 26152907202L}, {'cpuTime': 53759693931L}, {'cpuTime': 43074348218L})
==
Although I added a new interface, I still wonder what interface is better...
any comments are welcome.
Thanks,
-Kame
4
13
[libvirt] [PATCHv10 0/6] libvirt - support persistent device modification
by KAMEZAWA Hiroyuki 20 Apr '11
by KAMEZAWA Hiroyuki 20 Apr '11
20 Apr '11
Hi, this is v10, totally refleshed. Thank you for advices.
This version includes Eric's cleanup and Hu's Update device works.
(And droppped some sanity check patches.)
Because of many changes from v9, it may be better to write [RFC] in subject ;)
This patch series does
consolidate Attach/Detach/Update device's codes as..
==
shared code (prepare lock, get objects etc..)
switch(action) {
case ATTACH
case DETACH
case UPDATE
}
shared code.
==
After that, adding persistent modification support as
==
shared code (prepare lock, get objects etc...)
if (MODIFY_CONFIG) {
switch (action) {
case ATTACH:
case DETACH:
case UPDATE:
}
}
if (MODIFY_LIVE) {
switch (action) {
case ATTACH:
case DETACH:
case UPDATE:
}
}
shared code. (save config etc.)
==
Thanks,
-Kame
2
14
19 Apr '11
Ebtables filtering doesn't work on macvtap device. Remove support for
direct type of interface.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
docs/formatnwfilter.html.in | 2 --
src/conf/domain_conf.c | 1 -
src/nwfilter/nwfilter_ebiptables_driver.c | 16 +---------------
3 files changed, 1 insertion(+), 18 deletions(-)
Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -2862,7 +2862,6 @@ virDomainNetDefParseXML(virCapsPtr caps,
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_DIRECT:
def->filter = filter;
filter = NULL;
def->filterparams = filterparams;
Index: libvirt-acl/docs/formatnwfilter.html.in
===================================================================
--- libvirt-acl.orig/docs/formatnwfilter.html.in
+++ libvirt-acl/docs/formatnwfilter.html.in
@@ -52,8 +52,6 @@
<li><code>network</code></li>
<li><code>ethernet</code> -- must be used in bridging mode</li>
<li><code>bridge</code></li>
- <li><code>direct</code> -- only protocols mac, arp, ip and ipv6
- can be filtered</li>
</ul>
<p>
The interface XML is used to reference a top-level filter. In the
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -2357,7 +2357,7 @@ err_exit:
*/
static int
ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
- enum virDomainNetType nettype,
+ enum virDomainNetType nettype
ATTRIBUTE_UNUSED,
virNWFilterDefPtr nwfilter,
virNWFilterRuleDefPtr rule,
const char *ifname,
@@ -2409,13 +2409,6 @@ ebiptablesCreateRuleInstance(virConnectP
case VIR_NWFILTER_RULE_PROTOCOL_ICMP:
case VIR_NWFILTER_RULE_PROTOCOL_IGMP:
case VIR_NWFILTER_RULE_PROTOCOL_ALL:
- if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
- _("'%s' protocol not support for net type '%s'"),
-
virNWFilterRuleProtocolTypeToString(rule->prtclType),
- virDomainNetTypeToString(nettype));
- return 1;
- }
isIPv6 = 0;
rc = iptablesCreateRuleInstance(nwfilter,
rule,
@@ -2433,13 +2426,6 @@ ebiptablesCreateRuleInstance(virConnectP
case VIR_NWFILTER_RULE_PROTOCOL_SCTPoIPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6:
- if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
- _("'%s' protocol not support for net type '%s'"),
-
virNWFilterRuleProtocolTypeToString(rule->prtclType),
- virDomainNetTypeToString(nettype));
- return 1;
- }
isIPv6 = 1;
rc = iptablesCreateRuleInstance(nwfilter,
rule,
2
2
[libvirt] [PATCH] Allow handshake with child process during startup
by Daniel P. Berrange 19 Apr '11
by Daniel P. Berrange 19 Apr '11
19 Apr '11
Allow the parent process to perform a bi-directional handshake
with the child process during fork/exec. The child process
will fork and do its initial setup. Immediately prior to the
exec(), it will stop & wait for a handshake from the parent
process. The parent process will spawn the child and wait
until the child reaches the handshake point. It will do
whatever extra setup work is required, before signalling the
child to continue.
The implementation of this is done using two pairs of blocking
pipes. The first pair is used to block the parent, until the
child writes a single byte. Then the second pair pair is used
to block the child, until the parent confirms with another
single byte.
* src/util/command.c, src/util/command.h,
src/libvirt_private.syms: Add APIs to perform a handshake
---
src/libvirt_private.syms | 3 +
src/util/command.c | 161 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/command.h | 22 ++++++
3 files changed, 185 insertions(+), 1 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b787811..b91727a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -106,11 +106,14 @@ virCommandAddEnvString;
virCommandClearCaps;
virCommandDaemonize;
virCommandFree;
+virCommandHandshakeNotify;
+virCommandHandshakeWait;
virCommandNew;
virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPreserveFD;
+virCommandRequireHandshake;
virCommandRun;
virCommandRunAsync;
virCommandSetErrorBuffer;
diff --git a/src/util/command.c b/src/util/command.c
index 862a913..6213a3d 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -35,6 +35,8 @@
#include "files.h"
#include "buf.h"
+#include <stdlib.h>
+
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
@@ -76,6 +78,10 @@ struct _virCommand {
int *outfdptr;
int *errfdptr;
+ bool handshake;
+ int handshakeWait[2];
+ int handshakeNotify[2];
+
virExecHook hook;
void *opaque;
@@ -107,6 +113,11 @@ virCommandNewArgs(const char *const*args)
if (VIR_ALLOC(cmd) < 0)
return NULL;
+ cmd->handshakeWait[0] = -1;
+ cmd->handshakeWait[1] = -1;
+ cmd->handshakeNotify[0] = -1;
+ cmd->handshakeNotify[1] = -1;
+
FD_ZERO(&cmd->preserve);
FD_ZERO(&cmd->transfer);
cmd->infd = cmd->outfd = cmd->errfd = -1;
@@ -1125,12 +1136,61 @@ virCommandHook(void *data)
virCommandPtr cmd = data;
int res = 0;
- if (cmd->hook)
+ if (cmd->hook) {
+ VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
res = cmd->hook(cmd->opaque);
+ VIR_DEBUG("Done hook %d", res);
+ }
if (res == 0 && cmd->pwd) {
VIR_DEBUG("Running child in %s", cmd->pwd);
res = chdir(cmd->pwd);
+ if (res < 0) {
+ virReportSystemError(errno,
+ _("Unable to change to %s"), cmd->pwd);
+ }
+ }
+ if (cmd->handshake) {
+ char c = res < 0 ? '0' : '1';
+ int rv;
+ VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify parent process"));
+ return -1;
+ }
+
+ /* On failure we pass the error message back to parent,
+ * so they don't have to dig through stderr logs
+ */
+ if (res < 0) {
+ virErrorPtr err = virGetLastError();
+ const char *msg = err ? err->message :
+ _("Unknown failure during hook execution");
+ size_t len = strlen(msg) + 1;
+ if (safewrite(cmd->handshakeWait[1], msg, len) != len) {
+ virReportSystemError(errno, "%s", _("Unable to send error to parent process"));
+ return -1;
+ }
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d", cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s", _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL, _("Unexpected confirm code '%c' from parent process"), c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
}
+
+ VIR_DEBUG("Hook is done %d", res);
+
return res;
}
@@ -1220,6 +1280,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
FD_CLR(i, &cmd->transfer);
}
}
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ }
if (ret == 0 && pid)
*pid = cmd->pid;
@@ -1360,6 +1424,94 @@ virCommandAbort(virCommandPtr cmd ATTRIBUTE_UNUSED)
}
#endif
+
+void virCommandRequireHandshake(virCommandPtr cmd)
+{
+ if (!cmd || cmd->has_error)
+ return;
+
+ if (pipe(cmd->handshakeWait) < 0) {
+ cmd->has_error = errno;
+ return;
+ }
+ if (pipe(cmd->handshakeNotify) < 0) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ cmd->has_error = errno;
+ return;
+ }
+
+ VIR_DEBUG("Transfer handshake wait=%d notify=%d",
+ cmd->handshakeWait[1], cmd->handshakeNotify[0]);
+ virCommandPreserveFD(cmd, cmd->handshakeWait[1]);
+ virCommandPreserveFD(cmd, cmd->handshakeNotify[0]);
+ cmd->handshake = true;
+}
+
+int virCommandHandshakeWait(virCommandPtr cmd)
+{
+ char c;
+ int rv;
+ if (!cmd ||cmd->has_error == ENOMEM) {
+ virReportOOMError();
+ return -1;
+ }
+ if (cmd->has_error) {
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("invalid use of command API"));
+ return -1;
+ }
+
+ VIR_DEBUG("Wait for handshake on %d", cmd->handshakeWait[0]);
+ if ((rv = saferead(cmd->handshakeWait[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait for child process"));
+ else
+ virReportSystemError(EIO, "%s", _("Child process quit during startup handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ char *msg;
+ ssize_t len;
+ if (VIR_ALLOC_N(msg, 1024) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if ((len = saferead(cmd->handshakeWait[0], msg, 1024)) < 0) {
+ VIR_FREE(msg);
+ virReportSystemError(errno, "%s", _("No error message from child failure"));
+ return -1;
+ }
+ msg[len-1] = '\0';
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
+ VIR_FREE(msg);
+ return -1;
+ }
+ return 0;
+}
+
+int virCommandHandshakeNotify(virCommandPtr cmd)
+{
+ char c = '1';
+ if (!cmd ||cmd->has_error == ENOMEM) {
+ virReportOOMError();
+ return -1;
+ }
+ if (cmd->has_error) {
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("invalid use of command API"));
+ return -1;
+ }
+
+ VIR_DEBUG("Notify handshake on %d", cmd->handshakeWait[0]);
+ if (safewrite(cmd->handshakeNotify[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify child process"));
+ return -1;
+ }
+ return 0;
+}
+
+
/*
* Release all resources
*/
@@ -1391,6 +1543,13 @@ virCommandFree(virCommandPtr cmd)
VIR_FREE(cmd->pwd);
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[1]);
+ }
+
VIR_FREE(cmd->pidfile);
if (cmd->reap)
diff --git a/src/util/command.h b/src/util/command.h
index ff8ccf5..f1b372b 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -275,6 +275,28 @@ int virCommandWait(virCommandPtr cmd,
int *exitstatus) ATTRIBUTE_RETURN_CHECK;
/*
+ * Request that the child perform a handshake with
+ * the parent when the hook function has completed
+ * execution. The child will not exec() until the
+ * parent has notified
+ */
+void virCommandRequireHandshake(virCommandPtr cmd);
+
+/*
+ * Wait for the child to complete execution of its
+ * hook function
+ */
+int virCommandHandshakeWait(virCommandPtr cmd)
+ ATTRIBUTE_RETURN_CHECK;
+
+/*
+ * Notify the child that it is OK to exec() the
+ * real binary now
+ */
+int virCommandHandshakeNotify(virCommandPtr cmd)
+ ATTRIBUTE_RETURN_CHECK;
+
+/*
* Abort an async command if it is running, without issuing
* any errors or affecting errno. Designed for error paths
* where some but not all paths to the cleanup code might
--
1.7.4.4
1
0
Gnulib already guarantees <stdbool.h>, so it is easier to just
use the standardized spellings.
* tools/virsh.c (vshCmdDef): Change callback to return real bool.
(__vshControl): Change several fields to bool.
(vshCommandOptBool): Change return type.
All callers updated.
* tools/Makefile.am (virsh-net-edit.c, virsh-pool-edit.c):
Likewise.
---
Mostly mechanical.
tools/Makefile.am | 4 +-
tools/virsh.c | 1674 ++++++++++++++++++++++++++---------------------------
2 files changed, 835 insertions(+), 843 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 3e31dbd..826674a 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -64,7 +64,7 @@ BUILT_SOURCES = virsh-net-edit.c virsh-pool-edit.c
virsh-net-edit.c: virsh.c Makefile.am
$(AM_V_GEN)rm -f $@-tmp && \
echo '/* Automatically generated from: $^ */' > $@-tmp && \
- echo 'static int' >> $@-tmp && \
+ echo 'static bool' >> $@-tmp && \
awk '/^cmdEdit/, /^}/' $< \
| sed -e 's/domain/network/g' \
-e 's/Domain/Network/g' \
@@ -79,7 +79,7 @@ virsh-net-edit.c: virsh.c Makefile.am
virsh-pool-edit.c: virsh.c Makefile.am
$(AM_V_GEN)rm -f $@-tmp && \
echo '/* Automatically generated from: $^ */' > $@-tmp && \
- echo 'static int' >> $@-tmp && \
+ echo 'static bool' >> $@-tmp && \
awk '/^cmdEdit/, /^}/' $< \
| sed -e 's/domain/pool/g' \
-e 's/vshCommandOptDomain/vshCommandOptPool/g' \
diff --git a/tools/virsh.c b/tools/virsh.c
index 486442e..21560d8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -61,11 +61,6 @@
static char *progname;
-#ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-#endif
-
#define VIRSH_MAX_XML_FILE 10*1024*1024
#define VSH_PROMPT_RW "virsh # "
@@ -195,7 +190,7 @@ typedef struct vshCmdOpt {
*/
typedef struct {
const char *name;
- int (*handler) (vshControl *, const vshCmd *); /* command handler */
+ bool (*handler) (vshControl *, const vshCmd *); /* command handler */
const vshCmdOptDef *opts; /* definition of command options */
const vshCmdInfo *info; /* details about command */
} vshCmdDef;
@@ -217,11 +212,11 @@ typedef struct __vshControl {
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
vshCmd *cmd; /* the current command */
char *cmdstr; /* string with command */
- int imode; /* interactive mode? */
- int quiet; /* quiet mode */
+ bool imode; /* interactive mode? */
+ bool quiet; /* quiet mode */
int debug; /* print debug messages? */
- int timing; /* print timing info? */
- int readonly; /* connect readonly (first time only, not
+ bool timing; /* print timing info? */
+ bool readonly; /* connect readonly (first time only, not
* during explicit connect command)
*/
char *logfile; /* log file name */
@@ -271,7 +266,7 @@ static int vshCommandOptLongLong(const vshCmd *cmd, const char *name,
static int vshCommandOptULongLong(const vshCmd *cmd, const char *name,
unsigned long long *value)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
-static int vshCommandOptBool(const vshCmd *cmd, const char *name);
+static bool vshCommandOptBool(const vshCmd *cmd, const char *name);
static char *vshCommandOptArgv(const vshCmd *cmd, int count);
#define VSH_BYID (1 << 1)
@@ -599,7 +594,7 @@ static const vshCmdOptDef opts_help[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdHelp(vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
@@ -621,7 +616,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "\n");
}
- return TRUE;
+ return true;
}
if (vshCmddefSearch(name)) {
@@ -630,7 +625,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
return vshCmdGrpHelp(ctl, name);
} else {
vshError(ctl, _("command or command group '%s' doesn't exist"), name);
- return FALSE;
+ return false;
}
}
@@ -650,7 +645,7 @@ static const vshCmdOptDef opts_autostart[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAutostart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -658,10 +653,10 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -671,7 +666,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("Failed to unmark domain %s as autostarted"), name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (autostart)
@@ -680,7 +675,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Domain %s unmarked as autostarted\n"), name);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -700,17 +695,17 @@ static const vshCmdOptDef opts_connect[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdConnect(vshControl *ctl, const vshCmd *cmd)
{
- int ro = vshCommandOptBool(cmd, "readonly");
+ bool ro = vshCommandOptBool(cmd, "readonly");
const char *name = NULL;
if (ctl->conn) {
int ret;
if ((ret = virConnectClose(ctl->conn)) != 0) {
vshError(ctl, _("Failed to disconnect from the hypervisor, %d leaked reference(s)"), ret);
- return FALSE;
+ return false;
}
ctl->conn = NULL;
}
@@ -718,15 +713,11 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
VIR_FREE(ctl->name);
if (vshCommandOptString(cmd, "name", &name) < 0) {
vshError(ctl, "%s", _("Please specify valid connection URI"));
- return FALSE;
+ return false;
}
ctl->name = vshStrdup(ctl, name);
- if (!ro) {
- ctl->readonly = 0;
- } else {
- ctl->readonly = 1;
- }
+ ctl->readonly = ro;
ctl->conn = virConnectOpenAuth(ctl->name, virConnectAuthPtrDefault,
ctl->readonly ? VIR_CONNECT_RO : 0);
@@ -734,7 +725,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
if (!ctl->conn)
vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
- return ctl->conn ? TRUE : FALSE;
+ return !!ctl->conn;
}
#ifndef WIN32
@@ -755,10 +746,10 @@ static const vshCmdOptDef opts_console[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
{
- int ret = FALSE;
+ bool ret = false;
virDomainInfo dominfo;
if (virDomainGetInfo(dom, &dominfo) < 0) {
@@ -774,25 +765,25 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
vshPrintExtra(ctl, "%s", _("Escape character is ^]\n"));
if (vshRunConsole(dom, name) == 0)
- ret = TRUE;
+ ret = true;
cleanup:
return ret;
}
-static int
+static bool
cmdConsole(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "devname", &name) < 0) {
vshError(ctl, "%s", _("Invalid devname"));
@@ -825,7 +816,7 @@ static const vshCmdOptDef opts_list[] = {
};
-static int
+static bool
cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -837,13 +828,13 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxid = virConnectNumOfDomains(ctl->conn);
if (maxid < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
- return FALSE;
+ return false;
}
if (maxid) {
ids = vshMalloc(ctl, sizeof(int) * maxid);
@@ -851,7 +842,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
VIR_FREE(ids);
- return FALSE;
+ return false;
}
qsort(&ids[0], maxid, sizeof(int), idsorter);
@@ -862,7 +853,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxname < 0) {
vshError(ctl, "%s", _("Failed to list inactive domains"));
VIR_FREE(ids);
- return FALSE;
+ return false;
}
if (maxname) {
names = vshMalloc(ctl, sizeof(char *) * maxname);
@@ -871,7 +862,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive domains"));
VIR_FREE(ids);
VIR_FREE(names);
- return FALSE;
+ return false;
}
qsort(&names[0], maxname, sizeof(char*), namesorter);
@@ -923,7 +914,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(ids);
VIR_FREE(names);
- return TRUE;
+ return true;
}
/*
@@ -940,24 +931,24 @@ static const vshCmdOptDef opts_domstate[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomstate(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainGetInfo(dom, &info) == 0)
vshPrint(ctl, "%s\n",
_(vshDomainStateToString(info.state)));
else
- ret = FALSE;
+ ret = false;
virDomainFree(dom);
return ret;
@@ -977,7 +968,7 @@ static const vshCmdOptDef opts_domblkstat[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -985,20 +976,20 @@ cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
struct _virDomainBlockStats stats;
if (!vshConnectionUsability (ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain (ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "device", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainBlockStats (dom, device, &stats, sizeof stats) == -1) {
vshError(ctl, _("Failed to get block stats %s %s"), name, device);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (stats.rd_req >= 0)
@@ -1017,7 +1008,7 @@ cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, "%s errs %lld\n", device, stats.errs);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/* "domifstat" command
@@ -1034,7 +1025,7 @@ static const vshCmdOptDef opts_domifstat[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -1042,20 +1033,20 @@ cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
struct _virDomainInterfaceStats stats;
if (!vshConnectionUsability (ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain (ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "interface", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainInterfaceStats (dom, device, &stats, sizeof stats) == -1) {
vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (stats.rx_bytes >= 0)
@@ -1083,7 +1074,7 @@ cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, "%s tx_drop %lld\n", device, stats.tx_drop);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -1100,7 +1091,7 @@ static const vshCmdOptDef opts_dommemstat[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -1109,16 +1100,16 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
unsigned int nr_stats, i;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
nr_stats = virDomainMemoryStats (dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
if (nr_stats == -1) {
vshError(ctl, _("Failed to get memory statistics for domain %s"), name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
for (i = 0; i < nr_stats; i++) {
@@ -1137,7 +1128,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -1155,28 +1146,28 @@ static const vshCmdOptDef opts_domblkinfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainBlockInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *device = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "device", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity);
@@ -1201,24 +1192,24 @@ static const vshCmdOptDef opts_suspend[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSuspend(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainSuspend(dom) == 0) {
vshPrint(ctl, _("Domain %s suspended\n"), name);
} else {
vshError(ctl, _("Failed to suspend domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1243,12 +1234,12 @@ static const vshCmdOptDef opts_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCreate(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
@@ -1256,13 +1247,13 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
if (vshCommandOptBool(cmd, "paused"))
flags |= VIR_DOMAIN_START_PAUSED;
@@ -1280,7 +1271,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
virDomainFree(dom);
} else {
vshError(ctl, _("Failed to create domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -1299,22 +1290,22 @@ static const vshCmdOptDef opts_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDefine(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
dom = virDomainDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -1325,7 +1316,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
virDomainFree(dom);
} else {
vshError(ctl, _("Failed to define domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -1344,19 +1335,19 @@ static const vshCmdOptDef opts_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdUndefine(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name = NULL;
int id;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "domain", &name) <= 0)
- return FALSE;
+ return false;
if (name && virStrToLong_i(name, NULL, 10, &id) == 0
&& id >= 0 && (dom = virDomainLookupByID(ctl->conn, id))) {
@@ -1366,17 +1357,17 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
" using its name or UUID"),
name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (!(dom = vshCommandOptDomainBy(ctl, cmd, &name,
VSH_BYNAME|VSH_BYUUID)))
- return FALSE;
+ return false;
if (virDomainUndefine(dom) == 0) {
vshPrint(ctl, _("Domain %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1404,27 +1395,27 @@ static const vshCmdOptDef opts_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdStart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
#endif
unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME | VSH_BYUUID)))
- return FALSE;
+ return false;
if (virDomainGetID(dom) != (unsigned int)-1) {
vshError(ctl, "%s", _("Domain is already active"));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "paused"))
@@ -1441,7 +1432,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
#endif
} else {
vshError(ctl, _("Failed to start domain %s"), virDomainGetName(dom));
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
return ret;
@@ -1462,28 +1453,28 @@ static const vshCmdOptDef opts_save[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name = NULL;
const char *to = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainSave(dom, to) == 0) {
vshPrint(ctl, _("Domain %s saved to %s\n"), name, to);
} else {
vshError(ctl, _("Failed to save domain %s to %s"), name, to);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1507,24 +1498,24 @@ static const vshCmdOptDef opts_managedsave[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainManagedSave(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s state saved by libvirt\n"), name);
} else {
vshError(ctl, _("Failed to save domain %s state"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1545,19 +1536,19 @@ static const vshCmdOptDef opts_managedsaveremove[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = FALSE;
+ bool ret = false;
int hassave;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
hassave = virDomainHasManagedSaveImage(dom, 0);
if (hassave < 0) {
@@ -1578,7 +1569,7 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Domain %s has no manage save image; removal skipped"),
name);
- ret = TRUE;
+ ret = true;
cleanup:
virDomainFree(dom);
@@ -1602,7 +1593,7 @@ static const vshCmdOptDef opts_schedinfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
virSchedParameterPtr param)
{
@@ -1696,7 +1687,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
}
-static int
+static bool
cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
{
char *schedulertype;
@@ -1705,13 +1696,13 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
int nparams = 0;
int update = 0;
int i, ret;
- int ret_val = FALSE;
+ int ret_val = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
/* Print SchedulerType */
schedulertype = virDomainGetSchedulerType(dom, &nparams);
@@ -1763,7 +1754,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
}
}
- ret_val = TRUE;
+ ret_val = true;
for (i = 0; i < nparams; i++){
switch (params[i].type) {
case VIR_DOMAIN_SCHED_FIELD_INT:
@@ -1810,23 +1801,23 @@ static const vshCmdOptDef opts_restore[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdRestore(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virDomainRestore(ctl->conn, from) == 0) {
vshPrint(ctl, _("Domain restored from %s\n"), from);
} else {
vshError(ctl, _("Failed to restore domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -1848,23 +1839,23 @@ static const vshCmdOptDef opts_dump[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDump(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name = NULL;
const char *to = NULL;
- int ret = TRUE;
+ bool ret = true;
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptBool (cmd, "live"))
flags |= VIR_DUMP_LIVE;
@@ -1875,7 +1866,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Domain %s dumped to %s\n"), name, to);
} else {
vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1896,24 +1887,24 @@ static const vshCmdOptDef opts_resume[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdResume(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainResume(dom) == 0) {
vshPrint(ctl, _("Domain %s resumed\n"), name);
} else {
vshError(ctl, _("Failed to resume domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1934,24 +1925,24 @@ static const vshCmdOptDef opts_shutdown[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdShutdown(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainShutdown(dom) == 0) {
vshPrint(ctl, _("Domain %s is being shutdown\n"), name);
} else {
vshError(ctl, _("Failed to shutdown domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1972,24 +1963,24 @@ static const vshCmdOptDef opts_reboot[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdReboot(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainReboot(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s is being rebooted\n"), name);
} else {
vshError(ctl, _("Failed to reboot domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -2010,24 +2001,24 @@ static const vshCmdOptDef opts_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDestroy(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainDestroy(dom) == 0) {
vshPrint(ctl, _("Domain %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -2048,7 +2039,7 @@ static const vshCmdOptDef opts_dominfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDominfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
@@ -2056,15 +2047,16 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virSecurityModel secmodel;
virSecurityLabelPtr seclabel;
int persistent = 0;
- int ret = TRUE, autostart;
+ bool ret = true;
+ int autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
id = virDomainGetID(dom);
if (id == ((unsigned int)-1))
@@ -2106,7 +2098,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
info.memory);
} else {
- ret = FALSE;
+ ret = false;
}
/* Check and display whether the domain is persistent or not */
@@ -2128,7 +2120,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
if (virNodeGetSecurityModel(ctl->conn, &secmodel) == -1) {
if (last_error->code != VIR_ERR_NO_SUPPORT) {
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
virFreeError(last_error);
last_error = NULL;
@@ -2142,13 +2134,13 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
/* Security labels are only valid for active domains */
if (VIR_ALLOC(seclabel) < 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
virDomainFree(dom);
VIR_FREE(seclabel);
- return FALSE;
+ return false;
} else {
if (seclabel->label[0] != '\0')
vshPrint(ctl, "%-15s %s (%s)\n", _("Security label:"),
@@ -2177,18 +2169,18 @@ static const vshCmdOptDef opts_domjobinfo[] = {
};
-static int
+static bool
cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainJobInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainGetJobInfo(dom, &info) == 0) {
const char *unit;
@@ -2238,7 +2230,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-17s %-.3lf %s\n", _("File total:"), val, unit);
}
} else {
- ret = FALSE;
+ ret = false;
}
cleanup:
virDomainFree(dom);
@@ -2259,20 +2251,20 @@ static const vshCmdOptDef opts_domjobabort[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainAbortJob(dom) < 0)
- ret = FALSE;
+ ret = false;
virDomainFree(dom);
return ret;
@@ -2293,10 +2285,10 @@ static const vshCmdOptDef opts_freecell[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdFreecell(vshControl *ctl, const vshCmd *cmd)
{
- int func_ret = FALSE;
+ int func_ret = false;
int ret;
int cell = -1, cell_given;
unsigned long long memory;
@@ -2312,7 +2304,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if ( (cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) {
vshError(ctl, "%s", _("cell number has to be a number"));
@@ -2399,7 +2391,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%d: %llu kB\n", cell, (memory/1024));
}
- func_ret = TRUE;
+ func_ret = true;
cleanup:
xmlXPathFreeContext(ctxt);
@@ -2426,7 +2418,7 @@ static const vshCmdOptDef opts_maxvcpus[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
{
const char *type = NULL;
@@ -2434,18 +2426,18 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptString(cmd, "type", &type) < 0) {
vshError(ctl, "%s", _("Invalid type"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
vcpus = virConnectGetMaxVcpus(ctl->conn, type);
if (vcpus < 0)
- return FALSE;
+ return false;
vshPrint(ctl, "%d\n", vcpus);
- return TRUE;
+ return true;
}
/*
@@ -2466,11 +2458,11 @@ static const vshCmdOptDef opts_vcpucount[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int current = vshCommandOptBool(cmd, "current");
int config = vshCommandOptBool(cmd, "config");
@@ -2481,12 +2473,12 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (maximum && current) {
vshError(ctl, "%s",
_("--maximum and --current cannot both be specified"));
- return FALSE;
+ return false;
}
if (config && live) {
vshError(ctl, "%s",
_("--config and --live cannot both be specified"));
- return FALSE;
+ return false;
}
/* We want one of each pair of mutually exclusive options; that
* is, use of flags requires exactly two options. */
@@ -2497,14 +2489,14 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
: config ? "config" : "live"),
maximum + current ? "config" : "maximum",
maximum + current ? "live" : "current");
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
/* In all cases, try the new API first; if it fails because we are
* talking to an older client, try a fallback API before giving
@@ -2528,7 +2520,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("maximum"), _("config"),
count);
@@ -2549,7 +2541,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("maximum"), _("live"),
count);
@@ -2586,7 +2578,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("current"), _("config"),
count);
@@ -2608,7 +2600,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("current"), _("live"),
count);
@@ -2637,7 +2629,7 @@ static const vshCmdOptDef opts_vcpuinfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
@@ -2647,22 +2639,22 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
unsigned char *cpumap;
int ncpus;
size_t cpumaplen;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
cpuinfo = vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu);
@@ -2700,7 +2692,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s",
_("Domain shut off, virtual CPUs not present."));
}
- ret = FALSE;
+ ret = false;
}
VIR_FREE(cpumap);
@@ -2725,7 +2717,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
@@ -2733,44 +2725,44 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
virNodeInfo nodeinfo;
int vcpu;
const char *cpulist = NULL;
- int ret = TRUE;
+ bool ret = true;
unsigned char *cpumap;
int cpumaplen;
int i;
enum { expect_num, expect_num_or_comma } state;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "vcpu", &vcpu) <= 0) {
vshError(ctl, "%s", _("vcpupin: Invalid or missing vCPU number."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "cpulist", &cpulist) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
vshError(ctl, "%s", _("vcpupin: failed to get domain informations."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vcpu >= info.nrVirtCpu) {
vshError(ctl, "%s", _("vcpupin: Invalid vCPU number."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
/* Check that the cpulist parameter is a comma-separated list of
@@ -2779,7 +2771,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
if (cpulist[0] == '\0') {
vshError(ctl, "%s", _("cpulist: Invalid format. Empty string."));
virDomainFree (dom);
- return FALSE;
+ return false;
}
state = expect_num;
@@ -2791,7 +2783,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
"digit at position %d (near '%c')."),
cpulist, i, cpulist[i]);
virDomainFree (dom);
- return FALSE;
+ return false;
}
state = expect_num_or_comma;
break;
@@ -2803,7 +2795,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
"digit or comma at position %d (near '%c')."),
cpulist, i, cpulist[i]);
virDomainFree (dom);
- return FALSE;
+ return false;
}
}
}
@@ -2812,7 +2804,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
"at position %d."),
cpulist, i);
virDomainFree (dom);
- return FALSE;
+ return false;
}
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
@@ -2827,7 +2819,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
VIR_FREE(cpumap);
virDomainFree(dom);
- return FALSE;
+ return false;
}
cpulist = strchr(cpulist, ',');
if (cpulist)
@@ -2835,7 +2827,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
} while (cpulist);
if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
- ret = FALSE;
+ ret = false;
}
VIR_FREE(cpumap);
@@ -2861,12 +2853,12 @@ static const vshCmdOptDef opts_setvcpus[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int count;
- int ret = TRUE;
+ bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
@@ -2875,10 +2867,10 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
(live ? VIR_DOMAIN_VCPU_LIVE : 0));
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "count", &count) < 0) {
vshError(ctl, "%s", _("Invalid number of virtual CPUs"));
@@ -2887,7 +2879,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
if (!flags) {
if (virDomainSetVcpus(dom, count) != 0) {
- ret = FALSE;
+ ret = false;
}
} else {
/* If the --maximum flag was given, we need to ensure only the
@@ -2903,14 +2895,14 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
/* Warn the user about the invalid flag combination */
vshError(ctl, _("--maximum must be used with --config only"));
- ret = FALSE;
+ ret = false;
goto cleanup;
}
}
/* Apply the virtual cpu changes */
if (virDomainSetVcpusFlags(dom, count, flags) < 0) {
- ret = FALSE;
+ ret = false;
}
}
@@ -2937,13 +2929,13 @@ static const vshCmdOptDef opts_setmem[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetmem(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainInfo info;
unsigned long kilobytes = 0;
- int ret = TRUE;
+ bool ret = true;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
@@ -2952,7 +2944,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
- return FALSE;
+ return false;
}
flags = VIR_DOMAIN_MEM_CURRENT;
} else {
@@ -2966,42 +2958,42 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptUL(cmd, "kilobytes", &kilobytes) < 0) {
vshError(ctl, "%s", _("memory size has to be a number"));
- return FALSE;
+ return false;
}
if (kilobytes <= 0) {
virDomainFree(dom);
vshError(ctl, _("Invalid value of %lu for memory size"), kilobytes);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, "%s", _("Unable to verify MaxMemorySize"));
- return FALSE;
+ return false;
}
if (kilobytes > info.maxMem) {
virDomainFree(dom);
vshError(ctl, _("Requested memory size %lu kb is larger than maximum of %lu kb"),
kilobytes, info.maxMem);
- return FALSE;
+ return false;
}
if (flags == -1) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
- ret = FALSE;
+ ret = false;
}
} else {
if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
- ret = FALSE;
+ ret = false;
}
}
@@ -3027,13 +3019,13 @@ static const vshCmdOptDef opts_setmaxmem[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainInfo info;
int kilobytes = 0;
- int ret = TRUE;
+ bool ret = true;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
@@ -3042,7 +3034,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
- return FALSE;
+ return false;
}
} else {
if (config)
@@ -3055,37 +3047,37 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "kilobytes", &kilobytes) < 0) {
vshError(ctl, "%s", _("memory size has to be a number"));
- return FALSE;
+ return false;
}
if (kilobytes <= 0) {
virDomainFree(dom);
vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, "%s", _("Unable to verify current MemorySize"));
- return FALSE;
+ return false;
}
if (flags == -1) {
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
+ ret = false;
}
} else {
if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
+ ret = false;
}
}
@@ -3112,7 +3104,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
@@ -3120,13 +3112,13 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
int nparams = 0;
unsigned int i = 0;
virBlkioParameterPtr params = NULL, temp = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "weight", &weight) < 0) {
vshError(ctl, "%s",
@@ -3153,7 +3145,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
if (nparams == 0) {
/* nothing to output */
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -3195,7 +3187,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
}
}
- ret = TRUE;
+ ret = true;
} else {
/* set the blkio parameters */
params = vshCalloc(ctl, nparams, sizeof(*params));
@@ -3214,7 +3206,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
if (virDomainSetBlkioParameters(dom, params, nparams, 0) != 0)
vshError(ctl, "%s", _("Unable to change blkio parameters"));
else
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -3248,7 +3240,7 @@ static const vshCmdOptDef opts_memtune[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMemtune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
@@ -3257,13 +3249,13 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
int nparams = 0;
unsigned int i = 0;
virMemoryParameterPtr params = NULL, temp = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptLongLong(cmd, "hard-limit", &hard_limit) < 0 ||
vshCommandOptLongLong(cmd, "soft-limit", &soft_limit) < 0 ||
@@ -3296,7 +3288,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
if (nparams == 0) {
/* nothing to output */
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -3341,7 +3333,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
}
}
- ret = TRUE;
+ ret = true;
} else {
/* set the memory parameters */
params = vshCalloc(ctl, nparams, sizeof(*params));
@@ -3385,7 +3377,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
if (virDomainSetMemoryParameters(dom, params, nparams, 0) != 0)
vshError(ctl, "%s", _("Unable to change memory parameters"));
else
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -3403,17 +3395,17 @@ static const vshCmdInfo info_nodeinfo[] = {
{NULL, NULL}
};
-static int
+static bool
cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virNodeInfo info;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (virNodeGetInfo(ctl->conn, &info) < 0) {
vshError(ctl, "%s", _("failed to get node information"));
- return FALSE;
+ return false;
}
vshPrint(ctl, "%-20s %s\n", _("CPU model:"), info.model);
vshPrint(ctl, "%-20s %d\n", _("CPU(s):"), info.cpus);
@@ -3424,7 +3416,7 @@ cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, "%-20s %d\n", _("NUMA cell(s):"), info.nodes);
vshPrint(ctl, "%-20s %lu kB\n", _("Memory size:"), info.memory);
- return TRUE;
+ return true;
}
/*
@@ -3436,22 +3428,22 @@ static const vshCmdInfo info_capabilities[] = {
{NULL, NULL}
};
-static int
+static bool
cmdCapabilities (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *caps;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if ((caps = virConnectGetCapabilities (ctl->conn)) == NULL) {
vshError(ctl, "%s", _("failed to get capabilities"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", caps);
VIR_FREE(caps);
- return TRUE;
+ return true;
}
/*
@@ -3471,11 +3463,11 @@ static const vshCmdOptDef opts_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
char *dump;
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -3490,17 +3482,17 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_XML_UPDATE_CPU;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virDomainGetXMLDesc(dom, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -3522,10 +3514,10 @@ static const vshCmdOptDef opts_domxmlfromnative[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
const char *format = NULL;
const char *configFile = NULL;
char *configData;
@@ -3533,21 +3525,21 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "format", &format) < 0 ||
vshCommandOptString(cmd, "config", &configFile) < 0)
- return FALSE;
+ return false;
if (virFileReadAll(configFile, 1024*1024, &configData) < 0)
- return FALSE;
+ return false;
xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
if (xmlData != NULL) {
vshPrint(ctl, "%s", xmlData);
VIR_FREE(xmlData);
} else {
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -3568,10 +3560,10 @@ static const vshCmdOptDef opts_domxmltonative[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
const char *format = NULL;
const char *xmlFile = NULL;
char *configData;
@@ -3579,21 +3571,21 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "format", &format) < 0
|| vshCommandOptString(cmd, "xml", &xmlFile) < 0)
- return FALSE;
+ return false;
if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0)
- return FALSE;
+ return false;
configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
if (configData != NULL) {
vshPrint(ctl, "%s", configData);
VIR_FREE(configData);
} else {
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -3613,20 +3605,20 @@ static const vshCmdOptDef opts_domname[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomname(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYID|VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virDomainGetName(dom));
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -3643,17 +3635,17 @@ static const vshCmdOptDef opts_domid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomid(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
unsigned int id;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYUUID)))
- return FALSE;
+ return false;
id = virDomainGetID(dom);
if (id == ((unsigned int)-1))
@@ -3661,7 +3653,7 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd)
else
vshPrint(ctl, "%d\n", id);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -3678,17 +3670,17 @@ static const vshCmdOptDef opts_domuuid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYID)))
- return FALSE;
+ return false;
if (virDomainGetUUIDString(dom, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
@@ -3696,7 +3688,7 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("failed to get domain UUID"));
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -3849,7 +3841,7 @@ print_job_progress(unsigned long long remaining, unsigned long long total)
fprintf(stderr, "\rMigration: [%3d %%]", progress);
}
-static int
+static bool
cmdMigrate (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
@@ -3874,13 +3866,13 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd)
#endif
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptBool (cmd, "verbose"))
verbose = true;
if (vshCommandOptBool (cmd, "live"))
- live_flag = TRUE;
+ live_flag = true;
if (vshCommandOptInt(cmd, "timeout", &timeout) > 0) {
if (! live_flag) {
vshError(ctl, "%s", _("migrate: Unexpected timeout for offline migration"));
@@ -3929,15 +3921,15 @@ repoll:
if (ret > 0) {
if (saferead(p[0], &retchar, sizeof(retchar)) > 0) {
if (retchar == '0') {
- ret = TRUE;
+ ret = true;
if (verbose) {
/* print [100 %] */
print_job_progress(0, 1);
}
} else
- ret = FALSE;
+ ret = false;
} else
- ret = FALSE;
+ ret = false;
break;
}
@@ -3945,7 +3937,7 @@ repoll:
if (errno == EINTR) {
if (intCaught) {
virDomainAbortJob(dom);
- ret = FALSE;
+ ret = false;
intCaught = 0;
} else
goto repoll;
@@ -4001,18 +3993,18 @@ static const vshCmdOptDef opts_migrate_setmaxdowntime[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
long long downtime = 0;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptLongLong(cmd, "downtime", &downtime) < 0 ||
downtime < 1) {
@@ -4023,7 +4015,7 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
if (virDomainMigrateSetMaxDowntime(dom, downtime, 0))
goto done;
- ret = TRUE;
+ ret = true;
done:
virDomainFree(dom);
@@ -4046,7 +4038,7 @@ static const vshCmdOptDef opts_network_autostart[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
@@ -4054,10 +4046,10 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -4067,7 +4059,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("failed to unmark network %s as autostarted"), name);
virNetworkFree(network);
- return FALSE;
+ return false;
}
if (autostart)
@@ -4076,7 +4068,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Network %s unmarked as autostarted\n"), name);
virNetworkFree(network);
- return TRUE;
+ return true;
}
/*
@@ -4093,22 +4085,22 @@ static const vshCmdOptDef opts_network_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
network = virNetworkCreateXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -4119,7 +4111,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
virNetworkFree(network);
} else {
vshError(ctl, _("Failed to create network from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -4139,22 +4131,22 @@ static const vshCmdOptDef opts_network_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
network = virNetworkDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -4165,7 +4157,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
virNetworkFree(network);
} else {
vshError(ctl, _("Failed to define network from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -4185,24 +4177,24 @@ static const vshCmdOptDef opts_network_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNetworkDestroy(network) == 0) {
vshPrint(ctl, _("Network %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy network %s"), name);
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
@@ -4224,25 +4216,25 @@ static const vshCmdOptDef opts_network_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virNetworkGetXMLDesc(network, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
@@ -4263,7 +4255,7 @@ static const vshCmdOptDef opts_network_info[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
@@ -4274,11 +4266,11 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
char *bridge = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name"), virNetworkGetName(network));
@@ -4305,7 +4297,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %s\n", _("Bridge:"), bridge);
virNetworkFree(network);
- return TRUE;
+ return true;
}
/*
@@ -4322,10 +4314,10 @@ static const vshCmdOptDef opts_interface_edit[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virInterfacePtr iface = NULL;
char *tmp = NULL;
char *doc = NULL;
@@ -4360,7 +4352,7 @@ cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Interface %s XML configuration not changed.\n"),
virInterfaceGetName (iface));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -4387,7 +4379,7 @@ cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, _("Interface %s XML configuration edited.\n"),
virInterfaceGetName(iface));
- ret = TRUE;
+ ret = true;
cleanup:
if (iface)
@@ -4420,7 +4412,7 @@ static const vshCmdOptDef opts_network_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -4431,13 +4423,13 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxactive = virConnectNumOfNetworks(ctl->conn);
if (maxactive < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
- return FALSE;
+ return false;
}
if (maxactive) {
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
@@ -4446,7 +4438,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
@@ -4457,7 +4449,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive networks"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
if (maxinactive) {
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
@@ -4468,7 +4460,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive networks"));
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return FALSE;
+ return false;
}
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter);
@@ -4528,7 +4520,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return TRUE;
+ return true;
}
@@ -4546,20 +4538,20 @@ static const vshCmdOptDef opts_network_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virNetworkGetName(network));
virNetworkFree(network);
- return TRUE;
+ return true;
}
@@ -4577,17 +4569,17 @@ static const vshCmdOptDef opts_network_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, VSH_BYNAME)))
- return FALSE;
+ return false;
if (virNetworkCreate(network) == 0) {
vshPrint(ctl, _("Network %s started\n"),
@@ -4595,7 +4587,7 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
} else {
vshError(ctl, _("Failed to start network %s"),
virNetworkGetName(network));
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
return ret;
@@ -4616,24 +4608,24 @@ static const vshCmdOptDef opts_network_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNetworkUndefine(network) == 0) {
vshPrint(ctl, _("Network %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine network %s"), name);
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
@@ -4655,18 +4647,18 @@ static const vshCmdOptDef opts_network_uuid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (virNetworkGetUUIDString(network, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
@@ -4674,7 +4666,7 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("failed to get network UUID"));
virNetworkFree(network);
- return TRUE;
+ return true;
}
@@ -4693,7 +4685,7 @@ static const vshCmdOptDef opts_interface_list[] = {
{"all", VSH_OT_BOOL, 0, N_("list inactive & active interfaces")},
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -4704,13 +4696,13 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxactive = virConnectNumOfInterfaces(ctl->conn);
if (maxactive < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
- return FALSE;
+ return false;
}
if (maxactive) {
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
@@ -4719,7 +4711,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
@@ -4730,7 +4722,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
if (maxinactive) {
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
@@ -4741,7 +4733,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return FALSE;
+ return false;
}
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter);
@@ -4787,7 +4779,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return TRUE;
+ return true;
}
@@ -4805,20 +4797,20 @@ static const vshCmdOptDef opts_interface_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceName(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL,
VSH_BYMAC)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virInterfaceGetName(iface));
virInterfaceFree(iface);
- return TRUE;
+ return true;
}
/*
@@ -4835,20 +4827,20 @@ static const vshCmdOptDef opts_interface_mac[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virInterfaceGetMACString(iface));
virInterfaceFree(iface);
- return TRUE;
+ return true;
}
/*
@@ -4866,11 +4858,11 @@ static const vshCmdOptDef opts_interface_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
char *dump;
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -4879,17 +4871,17 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -4910,22 +4902,22 @@ static const vshCmdOptDef opts_interface_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
iface = virInterfaceDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -4936,7 +4928,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
virInterfaceFree (iface);
} else {
vshError(ctl, _("Failed to define interface from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -4955,24 +4947,24 @@ static const vshCmdOptDef opts_interface_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceUndefine(iface) == 0) {
vshPrint(ctl, _("Interface %s undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -4993,24 +4985,24 @@ static const vshCmdOptDef opts_interface_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceCreate(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s started\n"), name);
} else {
vshError(ctl, _("Failed to start interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -5031,24 +5023,24 @@ static const vshCmdOptDef opts_interface_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceDestroy(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -5070,22 +5062,22 @@ static const vshCmdOptDef opts_nwfilter_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
nwfilter = virNWFilterDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -5096,7 +5088,7 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
virNWFilterFree(nwfilter);
} else {
vshError(ctl, _("Failed to define network filter from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -5116,24 +5108,24 @@ static const vshCmdOptDef opts_nwfilter_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNWFilterUndefine(nwfilter) == 0) {
vshPrint(ctl, _("Network filter %s undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine network filter %s"), name);
- ret = FALSE;
+ ret = false;
}
virNWFilterFree(nwfilter);
@@ -5155,25 +5147,25 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virNWFilterGetXMLDesc(nwfilter, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virNWFilterFree(nwfilter);
@@ -5193,7 +5185,7 @@ static const vshCmdOptDef opts_nwfilter_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int numfilters, i;
@@ -5201,12 +5193,12 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
numfilters = virConnectNumOfNWFilters(ctl->conn);
if (numfilters < 0) {
vshError(ctl, "%s", _("Failed to list network filters"));
- return FALSE;
+ return false;
}
names = vshMalloc(ctl, sizeof(char *) * numfilters);
@@ -5215,7 +5207,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
numfilters)) < 0) {
vshError(ctl, "%s", _("Failed to list network filters"));
VIR_FREE(names);
- return FALSE;
+ return false;
}
qsort(&names[0], numfilters, sizeof(char *), namesorter);
@@ -5243,7 +5235,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(names);
- return TRUE;
+ return true;
}
@@ -5261,10 +5253,10 @@ static const vshCmdOptDef opts_nwfilter_edit[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virNWFilterPtr nwfilter = NULL;
char *tmp = NULL;
char *doc = NULL;
@@ -5298,7 +5290,7 @@ cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Network filter %s XML configuration not changed.\n"),
virNWFilterGetName (nwfilter));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -5325,7 +5317,7 @@ cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, _("Network filter %s XML configuration edited.\n"),
virNWFilterGetName(nwfilter));
- ret = TRUE;
+ ret = true;
cleanup:
if (nwfilter)
@@ -5361,7 +5353,7 @@ static const vshCmdOptDef opts_pool_autostart[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -5369,10 +5361,10 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -5382,7 +5374,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("failed to unmark pool %s as autostarted"), name);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
if (autostart)
@@ -5391,7 +5383,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Pool %s unmarked as autostarted\n"), name);
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
/*
@@ -5409,22 +5401,22 @@ static const vshCmdOptDef opts_pool_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
pool = virStoragePoolCreateXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -5435,7 +5427,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to create pool from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -5459,22 +5451,22 @@ static const vshCmdOptDef opts_node_device_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr dev = NULL;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -5485,7 +5477,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
virNodeDeviceFree(dev);
} else {
vshError(ctl, _("Failed to create node device from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -5508,19 +5500,19 @@ static const vshCmdOptDef opts_node_device_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr dev = NULL;
- int ret = TRUE;
+ bool ret = true;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn)) {
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "name", &name) <= 0)
- return FALSE;
+ return false;
dev = virNodeDeviceLookupByName(ctl->conn, name);
@@ -5528,7 +5520,7 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Destroyed node device '%s'\n"), name);
} else {
vshError(ctl, _("Failed to destroy node device '%s'"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(dev);
@@ -5600,16 +5592,16 @@ static int buildPoolXML(const vshCmd *cmd, const char **retname, char **xml) {
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
*xml = virBufferContentAndReset(&buf);
*retname = name;
- return TRUE;
+ return true;
cleanup:
virBufferFreeAndReset(&buf);
- return FALSE;
+ return false;
}
/*
@@ -5621,7 +5613,7 @@ static const vshCmdInfo info_pool_create_as[] = {
{NULL, NULL}
};
-static int
+static bool
cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -5630,10 +5622,10 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
int printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!buildPoolXML(cmd, &name, &xml))
- return FALSE;
+ return false;
if (printXML) {
vshPrint(ctl, "%s", xml);
@@ -5647,10 +5639,10 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to create pool %s"), name);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
@@ -5668,22 +5660,22 @@ static const vshCmdOptDef opts_pool_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
pool = virStoragePoolDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -5694,7 +5686,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to define pool from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -5709,7 +5701,7 @@ static const vshCmdInfo info_pool_define_as[] = {
{NULL, NULL}
};
-static int
+static bool
cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -5718,10 +5710,10 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
int printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!buildPoolXML(cmd, &name, &xml))
- return FALSE;
+ return false;
if (printXML) {
vshPrint(ctl, "%s", xml);
@@ -5735,10 +5727,10 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to define pool %s"), name);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
@@ -5756,24 +5748,24 @@ static const vshCmdOptDef opts_pool_build[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolBuild(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s built\n"), name);
} else {
vshError(ctl, _("Failed to build pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5796,24 +5788,24 @@ static const vshCmdOptDef opts_pool_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolDestroy(pool) == 0) {
vshPrint(ctl, _("Pool %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5835,24 +5827,24 @@ static const vshCmdOptDef opts_pool_delete[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDelete(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolDelete(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s deleted\n"), name);
} else {
vshError(ctl, _("Failed to delete pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5874,24 +5866,24 @@ static const vshCmdOptDef opts_pool_refresh[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolRefresh(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s refreshed\n"), name);
} else {
vshError(ctl, _("Failed to refresh pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5913,25 +5905,25 @@ static const vshCmdOptDef opts_pool_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
dump = virStoragePoolGetXMLDesc(pool, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5955,7 +5947,7 @@ static const vshCmdOptDef opts_pool_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStoragePoolInfo info;
@@ -5985,14 +5977,14 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Retrieve the number of active storage pools */
if (active) {
numActivePools = virConnectNumOfStoragePools(ctl->conn);
if (numActivePools < 0) {
vshError(ctl, "%s", _("Failed to list active pools"));
- return FALSE;
+ return false;
}
}
@@ -6001,7 +5993,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
numInactivePools = virConnectNumOfDefinedStoragePools(ctl->conn);
if (numInactivePools < 0) {
vshError(ctl, "%s", _("Failed to list inactive pools"));
- return FALSE;
+ return false;
}
}
@@ -6020,7 +6012,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list active pools"));
VIR_FREE(poolInfoTexts);
VIR_FREE(poolNames);
- return FALSE;
+ return false;
}
}
@@ -6032,7 +6024,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive pools"));
VIR_FREE(poolInfoTexts);
VIR_FREE(poolNames);
- return FALSE;
+ return false;
}
}
@@ -6210,7 +6202,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
}
@@ -6308,7 +6300,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
asprintf_failure:
@@ -6323,7 +6315,7 @@ asprintf_failure:
/* Some other error */
vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
- functionReturn = FALSE;
+ functionReturn = false;
cleanup:
@@ -6365,7 +6357,7 @@ static const vshCmdOptDef opts_find_storage_pool_sources_as[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
const char *type = NULL, *host = NULL;
@@ -6377,11 +6369,11 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
vshCommandOptString(cmd, "host", &host) < 0 ||
vshCommandOptString(cmd, "initiator", &initiator) < 0) {
vshError(ctl,"%s", _("missing argument"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (host) {
const char *port = NULL;
@@ -6390,7 +6382,7 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
if (vshCommandOptString(cmd, "port", &port) < 0) {
vshError(ctl, "%s", _("missing argument"));
virBufferFreeAndReset(&buf);
- return FALSE;
+ return false;
}
virBufferAddLit(&buf, "<source>\n");
virBufferVSprintf(&buf, " <host name='%s'", host);
@@ -6405,7 +6397,7 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
virBufferAddLit(&buf, "</source>\n");
if (virBufferError(&buf)) {
vshError(ctl, "%s", _("Out of memory"));
- return FALSE;
+ return false;
}
srcSpec = virBufferContentAndReset(&buf);
}
@@ -6414,12 +6406,12 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s", srcList);
VIR_FREE(srcList);
- return TRUE;
+ return true;
}
@@ -6440,36 +6432,36 @@ static const vshCmdOptDef opts_find_storage_pool_sources[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
const char *type = NULL, *srcSpecFile = NULL;
char *srcSpec = NULL, *srcList;
if (vshCommandOptString(cmd, "type", &type) <= 0)
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "srcSpec", &srcSpecFile) < 0) {
vshError(ctl, "%s", _("missing option"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (srcSpecFile && virFileReadAll(srcSpecFile, VIRSH_MAX_XML_FILE, &srcSpec) < 0)
- return FALSE;
+ return false;
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s", srcList);
VIR_FREE(srcList);
- return TRUE;
+ return true;
}
@@ -6487,21 +6479,21 @@ static const vshCmdOptDef opts_pool_info[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
int autostart = 0;
int persistent = 0;
- int ret = TRUE;
+ bool ret = true;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name:"), virStoragePoolGetName(pool));
@@ -6562,7 +6554,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit);
}
} else {
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -6584,20 +6576,20 @@ static const vshCmdOptDef opts_pool_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolName(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
@@ -6615,24 +6607,24 @@ static const vshCmdOptDef opts_pool_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolStart(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME)))
- return FALSE;
+ return false;
if (virStoragePoolCreate(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s started\n"),
virStoragePoolGetName(pool));
} else {
vshError(ctl, _("Failed to start pool %s"), virStoragePoolGetName(pool));
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -6688,7 +6680,7 @@ static int cmdVolSize(const char *data, unsigned long long *val)
return 0;
}
-static int
+static bool
cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -6700,11 +6692,11 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "name", &name) <= 0)
goto cleanup;
@@ -6771,13 +6763,13 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
}
if (snapVol == NULL) {
vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
- return FALSE;
+ return false;
}
char *snapshotStrVolPath;
if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
virStorageVolFree(snapVol);
- return FALSE;
+ return false;
}
/* Create XML for the backing store */
@@ -6796,7 +6788,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
vol = virStorageVolCreateXML(pool, xml, 0);
@@ -6806,16 +6798,16 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vol != NULL) {
vshPrint(ctl, _("Vol %s created\n"), name);
virStorageVolFree(vol);
- return TRUE;
+ return true;
} else {
vshError(ctl, _("Failed to create vol %s"), name);
- return FALSE;
+ return false;
}
cleanup:
virBufferFreeAndReset(&buf);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
@@ -6833,24 +6825,24 @@ static const vshCmdOptDef opts_pool_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolUndefine(pool) == 0) {
vshPrint(ctl, _("Pool %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -6872,18 +6864,18 @@ static const vshCmdOptDef opts_pool_uuid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (virStoragePoolGetUUIDString(pool, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
@@ -6891,7 +6883,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("failed to get pool UUID"));
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
@@ -6910,31 +6902,31 @@ static const vshCmdOptDef opts_vol_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
vol = virStorageVolCreateXML(pool, buffer, 0);
@@ -6947,7 +6939,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
virStorageVolFree(vol);
} else {
vshError(ctl, _("Failed to create vol from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -6969,13 +6961,13 @@ static const vshCmdOptDef opts_vol_create_from[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool = NULL;
virStorageVolPtr newvol = NULL, inputvol = NULL;
const char *from = NULL;
- int ret = FALSE;
+ bool ret = false;
char *buffer = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -7006,7 +6998,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(buffer);
if (pool)
@@ -7066,7 +7058,7 @@ static const vshCmdOptDef opts_vol_clone[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolClone(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr origpool = NULL;
@@ -7074,7 +7066,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
const char *name = NULL;
char *origxml = NULL;
xmlChar *newxml = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -7112,7 +7104,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(origxml);
@@ -7154,12 +7146,12 @@ cmdVolUploadSource(virStreamPtr st ATTRIBUTE_UNUSED,
return saferead(*fd, bytes, nbytes);
}
-static int
+static bool
cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
virStorageVolPtr vol = NULL;
- int ret = FALSE;
+ bool ret = false;
int fd = -1;
virStreamPtr st = NULL;
const char *name = NULL;
@@ -7170,16 +7162,16 @@ cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (vshCommandOptULongLong(cmd, "length", &length) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "file", &file) < 0) {
@@ -7214,7 +7206,7 @@ cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
if (vol)
@@ -7255,12 +7247,12 @@ cmdVolDownloadSink(virStreamPtr st ATTRIBUTE_UNUSED,
return safewrite(*fd, bytes, nbytes);
}
-static int
+static bool
cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
virStorageVolPtr vol = NULL;
- int ret = FALSE;
+ bool ret = false;
int fd = -1;
virStreamPtr st = NULL;
const char *name = NULL;
@@ -7272,16 +7264,16 @@ cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (vshCommandOptULongLong(cmd, "length", &length) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &file) < 0) {
vshError(ctl, _("file must not be empty"));
@@ -7319,10 +7311,10 @@ cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
- if (ret == FALSE && created)
+ if (ret == false && created)
unlink(file);
if (vol)
virStorageVolFree(vol);
@@ -7348,25 +7340,25 @@ static const vshCmdOptDef opts_vol_delete[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (virStorageVolDelete(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s deleted\n"), name);
} else {
vshError(ctl, _("Failed to delete vol %s"), name);
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7389,25 +7381,25 @@ static const vshCmdOptDef opts_vol_wipe[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (virStorageVolWipe(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s wiped\n"), name);
} else {
vshError(ctl, _("Failed to wipe vol %s"), name);
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7430,18 +7422,18 @@ static const vshCmdOptDef opts_vol_info[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolInfo info;
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name:"), virStorageVolGetName(vol));
@@ -7458,7 +7450,7 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
val = prettyCapacity(info.allocation, &unit);
vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
} else {
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7481,25 +7473,25 @@ static const vshCmdOptDef opts_vol_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
dump = virStorageVolGetXMLDesc(vol, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7522,7 +7514,7 @@ static const vshCmdOptDef opts_vol_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStorageVolInfo volumeInfo;
@@ -7548,11 +7540,11 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Look up the pool information given to us by the user */
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
/* Determine the number of volumes in the pool */
numVolumes = virStoragePoolNumOfVolumes(pool);
@@ -7560,7 +7552,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (numVolumes < 0) {
vshError(ctl, "%s", _("Failed to list storage volumes"));
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
/* Retrieve the list of volume names in the pool */
@@ -7571,7 +7563,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list active vols"));
VIR_FREE(activeNames);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
/* Sort the volume names */
@@ -7679,7 +7671,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
}
@@ -7750,7 +7742,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
asprintf_failure:
@@ -7765,7 +7757,7 @@ asprintf_failure:
/* Some other error */
vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
- functionReturn = FALSE;
+ functionReturn = false;
cleanup:
@@ -7804,21 +7796,21 @@ static const vshCmdOptDef opts_vol_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolName(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStorageVolGetName(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
@@ -7837,7 +7829,7 @@ static const vshCmdOptDef opts_vol_pool[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolPool(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -7846,12 +7838,12 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Use the supplied string to locate the volume */
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID))) {
- return FALSE;
+ return false;
}
/* Look up the parent storage pool for the volume */
@@ -7859,7 +7851,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
if (pool == NULL) {
vshError(ctl, "%s", _("failed to get parent pool"));
virStorageVolFree(vol);
- return FALSE;
+ return false;
}
/* Return the requested details of the parent storage pool */
@@ -7875,7 +7867,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
/* Cleanup */
virStorageVolFree(vol);
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
@@ -7894,20 +7886,20 @@ static const vshCmdOptDef opts_vol_key[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolKey(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
@@ -7927,22 +7919,22 @@ static const vshCmdOptDef opts_vol_path[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolPath(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s\n", virStorageVolGetPath(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
@@ -7960,7 +7952,7 @@ static const vshCmdOptDef opts_secret_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
@@ -7969,29 +7961,29 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
res = virSecretDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
if (res == NULL) {
vshError(ctl, _("Failed to set attributes from %s"), from);
- return FALSE;
+ return false;
}
if (virSecretGetUUIDString(res, &(uuid[0])) < 0) {
vshError(ctl, "%s", _("Failed to get UUID of created secret"));
virSecretFree(res);
- return FALSE;
+ return false;
}
vshPrint(ctl, _("Secret %s created\n"), uuid);
virSecretFree(res);
- return TRUE;
+ return true;
}
/*
@@ -8008,26 +8000,26 @@ static const vshCmdOptDef opts_secret_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
- int ret = FALSE;
+ bool ret = false;
char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
xml = virSecretGetXMLDesc(secret, 0);
if (xml == NULL)
goto cleanup;
vshPrint(ctl, "%s", xml);
VIR_FREE(xml);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8049,21 +8041,21 @@ static const vshCmdOptDef opts_secret_set_value[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
size_t value_size;
const char *base64 = NULL;
char *value;
- int res, ret = FALSE;
+ int res, ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "base64", &base64) <= 0)
goto cleanup;
@@ -8074,7 +8066,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
}
if (value == NULL) {
vshError(ctl, "%s", _("Failed to allocate memory"));
- return FALSE;
+ return false;
}
res = virSecretSetValue(secret, (unsigned char *)value, value_size, 0);
@@ -8086,7 +8078,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
vshPrint(ctl, "%s", _("Secret value set\n"));
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8107,21 +8099,21 @@ static const vshCmdOptDef opts_secret_get_value[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
char *base64;
unsigned char *value;
size_t value_size;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
value = virSecretGetValue(secret, &value_size, 0);
if (value == NULL)
@@ -8138,7 +8130,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%s", base64);
memset(base64, 0, strlen(base64));
VIR_FREE(base64);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8159,26 +8151,26 @@ static const vshCmdOptDef opts_secret_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
- int ret = FALSE;
+ bool ret = false;
const char *uuid;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, &uuid);
if (secret == NULL)
- return FALSE;
+ return false;
if (virSecretUndefine(secret) < 0) {
vshError(ctl, _("Failed to delete secret %s"), uuid);
goto cleanup;
}
vshPrint(ctl, _("Secret %s deleted\n"), uuid);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8194,19 +8186,19 @@ static const vshCmdInfo info_secret_list[] = {
{NULL, NULL}
};
-static int
+static bool
cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int maxuuids = 0, i;
char **uuids = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
maxuuids = virConnectNumOfSecrets(ctl->conn);
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
- return FALSE;
+ return false;
}
uuids = vshMalloc(ctl, sizeof(*uuids) * maxuuids);
@@ -8214,7 +8206,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
VIR_FREE(uuids);
- return FALSE;
+ return false;
}
qsort(uuids, maxuuids, sizeof(char *), namesorter);
@@ -8249,7 +8241,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
VIR_FREE(uuids[i]);
}
VIR_FREE(uuids);
- return TRUE;
+ return true;
}
@@ -8263,7 +8255,7 @@ static const vshCmdInfo info_version[] = {
};
-static int
+static bool
cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
unsigned long hvVersion;
@@ -8277,12 +8269,12 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
unsigned int rel;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
hvType = virConnectGetType(ctl->conn);
if (hvType == NULL) {
vshError(ctl, "%s", _("failed to get hypervisor type"));
- return FALSE;
+ return false;
}
includeVersion = LIBVIR_VERSION_NUMBER;
@@ -8296,7 +8288,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
ret = virGetVersion(&libVersion, hvType, &apiVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the library version"));
- return FALSE;
+ return false;
}
major = libVersion / 1000000;
libVersion %= 1000000;
@@ -8315,7 +8307,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
ret = virConnectGetVersion(ctl->conn, &hvVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the hypervisor version"));
- return FALSE;
+ return false;
}
if (hvVersion == 0) {
vshPrint(ctl,
@@ -8329,7 +8321,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, _("Running hypervisor: %s %d.%d.%d\n"),
hvType, major, minor, rel);
}
- return TRUE;
+ return true;
}
/*
@@ -8427,7 +8419,7 @@ cmdNodeListDevicesPrint(vshControl *ctl,
}
}
-static int
+static bool
cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *cap = NULL;
@@ -8436,7 +8428,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
int tree = vshCommandOptBool(cmd, "tree");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "cap", &cap) <= 0)
cap = NULL;
@@ -8444,9 +8436,9 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
num_devices = virNodeNumOfDevices(ctl->conn, cap, 0);
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to count node devices"));
- return FALSE;
+ return false;
} else if (num_devices == 0) {
- return TRUE;
+ return true;
}
devices = vshMalloc(ctl, sizeof(char *) * num_devices);
@@ -8455,7 +8447,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to list node devices"));
VIR_FREE(devices);
- return FALSE;
+ return false;
}
qsort(&devices[0], num_devices, sizeof(char*), namesorter);
if (tree) {
@@ -8496,7 +8488,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
}
VIR_FREE(devices);
- return TRUE;
+ return true;
}
/*
@@ -8514,7 +8506,7 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
@@ -8522,24 +8514,24 @@ cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
xml = virNodeDeviceGetXMLDesc(device, 0);
if (!xml) {
virNodeDeviceFree(device);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s\n", xml);
VIR_FREE(xml);
virNodeDeviceFree(device);
- return TRUE;
+ return true;
}
/*
@@ -8557,27 +8549,27 @@ static const vshCmdOptDef opts_node_device_dettach[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDettach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceDettach(device) == 0) {
vshPrint(ctl, _("Device %s dettached\n"), name);
} else {
vshError(ctl, _("Failed to dettach device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
@@ -8598,27 +8590,27 @@ static const vshCmdOptDef opts_node_device_reattach[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceReAttach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceReAttach(device) == 0) {
vshPrint(ctl, _("Device %s re-attached\n"), name);
} else {
vshError(ctl, _("Failed to re-attach device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
@@ -8639,27 +8631,27 @@ static const vshCmdOptDef opts_node_device_reset[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceReset (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceReset(device) == 0) {
vshPrint(ctl, _("Device %s reset\n"), name);
} else {
vshError(ctl, _("Failed to reset device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
@@ -8674,24 +8666,24 @@ static const vshCmdInfo info_hostname[] = {
{NULL, NULL}
};
-static int
+static bool
cmdHostname (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *hostname;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
hostname = virConnectGetHostname (ctl->conn);
if (hostname == NULL) {
vshError(ctl, "%s", _("failed to get hostname"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", hostname);
VIR_FREE(hostname);
- return TRUE;
+ return true;
}
/*
@@ -8703,24 +8695,24 @@ static const vshCmdInfo info_uri[] = {
{NULL, NULL}
};
-static int
+static bool
cmdURI (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *uri;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
uri = virConnectGetURI (ctl->conn);
if (uri == NULL) {
vshError(ctl, "%s", _("failed to get URI"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", uri);
VIR_FREE(uri);
- return TRUE;
+ return true;
}
/*
@@ -8733,24 +8725,24 @@ static const vshCmdInfo info_sysinfo[] = {
{NULL, NULL}
};
-static int
+static bool
cmdSysinfo (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *sysinfo;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
sysinfo = virConnectGetSysinfo (ctl->conn, 0);
if (sysinfo == NULL) {
vshError(ctl, "%s", _("failed to get sysinfo"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s", sysinfo);
VIR_FREE(sysinfo);
- return TRUE;
+ return true;
}
/*
@@ -8767,22 +8759,22 @@ static const vshCmdOptDef opts_vncdisplay[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
int port = 0;
char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
doc = virDomainGetXMLDesc(dom, 0);
if (!doc)
@@ -8817,7 +8809,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
}
xmlXPathFreeObject(obj);
obj = NULL;
- ret = TRUE;
+ ret = true;
cleanup:
xmlXPathFreeObject(obj);
@@ -8842,21 +8834,21 @@ static const vshCmdOptDef opts_ttyconsole[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
doc = virDomainGetXMLDesc(dom, 0);
if (!doc)
@@ -8878,7 +8870,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
vshPrint(ctl, "%s\n", (const char *)obj->stringval);
- ret = TRUE;
+ ret = true;
cleanup:
xmlXPathFreeObject(obj);
@@ -8905,30 +8897,30 @@ static const vshCmdOptDef opts_attach_device[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
@@ -8944,13 +8936,13 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
if (ret < 0) {
vshError(ctl, _("Failed to attach device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device attached successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
@@ -8970,30 +8962,30 @@ static const vshCmdOptDef opts_detach_device[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
@@ -9009,13 +9001,13 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
if (ret < 0) {
vshError(ctl, _("Failed to detach device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device detached successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
@@ -9036,30 +9028,30 @@ static const vshCmdOptDef opts_update_device[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
@@ -9079,13 +9071,13 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
if (ret < 0) {
vshError(ctl, _("Failed to update device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device updated successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
@@ -9110,13 +9102,13 @@ static const vshCmdOptDef opts_attach_interface[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *mac = NULL, *target = NULL, *script = NULL,
*type = NULL, *source = NULL, *model = NULL;
- int typ, ret = FALSE;
+ int typ, ret = false;
unsigned int flags;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xml;
@@ -9171,7 +9163,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
@@ -9189,10 +9181,10 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach interface"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Interface attached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9219,7 +9211,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
@@ -9231,7 +9223,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
const char *mac =NULL, *type = NULL;
char *doc;
char buf[64];
- int i = 0, diff_mac, ret = FALSE;
+ int i = 0, diff_mac, ret = false;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -9327,10 +9319,10 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach interface"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9367,13 +9359,13 @@ static const vshCmdOptDef opts_attach_disk[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *source = NULL, *target = NULL, *driver = NULL,
*subdriver = NULL, *type = NULL, *mode = NULL;
- int isFile = 0, ret = FALSE;
+ int isFile = 0, ret = false;
unsigned int flags;
const char *stype = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -9447,7 +9439,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
@@ -9465,10 +9457,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach disk"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Disk attached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9494,7 +9486,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
@@ -9505,7 +9497,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom = NULL;
const char *target = NULL;
char *doc;
- int i = 0, diff_tgt, ret = FALSE;
+ int i = 0, diff_tgt, ret = false;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -9586,10 +9578,10 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach disk"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Disk detached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9618,22 +9610,22 @@ static const vshCmdOptDef opts_cpu_compare[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
int result;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
result = virConnectCompareCPU(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -9642,25 +9634,25 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
case VIR_CPU_COMPARE_INCOMPATIBLE:
vshPrint(ctl, _("CPU described in %s is incompatible with host CPU\n"),
from);
- ret = FALSE;
+ ret = false;
break;
case VIR_CPU_COMPARE_IDENTICAL:
vshPrint(ctl, _("CPU described in %s is identical to host CPU\n"),
from);
- ret = TRUE;
+ ret = true;
break;
case VIR_CPU_COMPARE_SUPERSET:
vshPrint(ctl, _("Host CPU is a superset of CPU described in %s\n"),
from);
- ret = TRUE;
+ ret = true;
break;
case VIR_CPU_COMPARE_ERROR:
default:
vshError(ctl, _("Failed to compare host CPU with %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -9680,11 +9672,11 @@ static const vshCmdOptDef opts_cpu_baseline[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
char *result = NULL;
const char **list = NULL;
@@ -9698,13 +9690,13 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
int res, i;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
doc = xmlNewDoc(NULL);
if (doc == NULL)
@@ -9714,7 +9706,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
(const xmlChar *)buffer, &node_list);
if (res != 0) {
vshError(ctl, _("Failed to parse XML fragment %s"), from);
- ret = FALSE;
+ ret = false;
goto cleanup;
}
@@ -9751,7 +9743,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (count == 0) {
vshError(ctl, _("No host CPU specified in '%s'"), from);
- ret = FALSE;
+ ret = false;
goto cleanup;
}
@@ -9760,7 +9752,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (result)
vshPrint(ctl, "%s", result);
else
- ret = FALSE;
+ ret = false;
cleanup:
xmlXPathFreeObject(obj);
@@ -9778,7 +9770,7 @@ cleanup:
no_memory:
vshError(ctl, "%s", _("Out of memory"));
- ret = FALSE;
+ ret = false;
goto cleanup;
}
@@ -9909,16 +9901,16 @@ static const vshCmdOptDef opts_cd[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *dir = NULL;
char *dir_malloced = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!ctl->imode) {
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "dir", &dir) <= 0) {
@@ -9930,7 +9922,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (chdir(dir) == -1) {
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
- ret = FALSE;
+ ret = false;
}
VIR_FREE(dir_malloced);
@@ -9949,12 +9941,12 @@ static const vshCmdInfo info_pwd[] = {
{NULL, NULL}
};
-static int
+static bool
cmdPwd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *cwd;
size_t path_max;
- int err = TRUE;
+ int err = true;
path_max = (size_t) PATH_MAX + 2;
cwd = vshMalloc (ctl, path_max);
@@ -9997,7 +9989,7 @@ static const vshCmdOptDef opts_echo[] = {
/* Exists mainly for debugging virsh, but also handy for adding back
* quotes for later evaluation.
*/
-static int
+static bool
cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd)
{
bool shell = false;
@@ -10043,13 +10035,13 @@ cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
arg = virBufferContentAndReset(&buf);
if (arg)
vshPrint(ctl, "%s", arg);
VIR_FREE(arg);
- return TRUE;
+ return true;
}
/*
@@ -10069,10 +10061,10 @@ static const vshCmdOptDef opts_edit[] = {
/* This function also acts as a template to generate cmdNetworkEdit
* and cmdPoolEdit functions (below) using a sed script in the Makefile.
*/
-static int
+static bool
cmdEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virDomainPtr dom = NULL;
char *tmp = NULL;
char *doc = NULL;
@@ -10107,7 +10099,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Domain %s XML configuration not changed.\n"),
virDomainGetName (dom));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -10134,7 +10126,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, _("Domain %s XML configuration edited.\n"),
virDomainGetName(dom));
- ret = TRUE;
+ ret = true;
cleanup:
if (dom)
@@ -10196,11 +10188,11 @@ static const vshCmdInfo info_quit[] = {
{NULL, NULL}
};
-static int
+static bool
cmdQuit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
- ctl->imode = FALSE;
- return TRUE;
+ ctl->imode = false;
+ return true;
}
/*
@@ -10218,11 +10210,11 @@ static const vshCmdOptDef opts_snapshot_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *from = NULL;
char *buffer = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -10284,7 +10276,7 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _(" from '%s'"), from);
vshPrint(ctl, "\n");
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(name);
@@ -10315,11 +10307,11 @@ static const vshCmdOptDef opts_snapshot_current[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
int current;
virDomainSnapshotPtr snapshot = NULL;
@@ -10347,7 +10339,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
VIR_FREE(xml);
}
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
@@ -10372,11 +10364,11 @@ static const vshCmdOptDef opts_snapshot_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
int numsnaps;
char **names = NULL;
int actual = 0;
@@ -10455,7 +10447,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
}
}
- ret = TRUE;
+ ret = true;
cleanup:
/* this frees up memory from the last iteration of the loop */
@@ -10490,11 +10482,11 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
char *xml = NULL;
@@ -10519,7 +10511,7 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%s", xml);
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(xml);
@@ -10546,11 +10538,11 @@ static const vshCmdOptDef opts_snapshot_revert[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -10571,7 +10563,7 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
if (virDomainRevertToSnapshot(snapshot, 0) < 0)
goto cleanup;
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
@@ -10598,11 +10590,11 @@ static const vshCmdOptDef opts_snapshot_delete[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
unsigned int flags = 0;
@@ -10627,7 +10619,7 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
if (virDomainSnapshotDelete(snapshot, flags) < 0)
goto cleanup;
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
@@ -10654,11 +10646,11 @@ static const vshCmdOptDef opts_qemu_monitor_command[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *monitor_cmd = NULL;
char *result = NULL;
unsigned int flags = 0;
@@ -10683,7 +10675,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
printf("%s\n", result);
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(result);
@@ -11071,7 +11063,7 @@ vshCmdGrpHelp(vshControl *ctl, const char *grpname)
if (!grp) {
vshError(ctl, _("command group '%s' doesn't exist"), grpname);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, _(" %s (help keyword '%s'):\n"), grp->name,
grp->keyword);
@@ -11082,7 +11074,7 @@ vshCmdGrpHelp(vshControl *ctl, const char *grpname)
}
}
- return TRUE;
+ return true;
}
static int
@@ -11092,7 +11084,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
if (!def) {
vshError(ctl, _("command '%s' doesn't exist"), cmdname);
- return FALSE;
+ return false;
} else {
const char *desc = _(vshCmddefGetInfo(def, "desc"));
const char *help = _(vshCmddefGetInfo(def, "help"));
@@ -11103,7 +11095,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
vshError(ctl, _("internal error: bad options in command: '%s'"),
def->name);
- return FALSE;
+ return false;
}
fputs(_(" NAME\n"), stdout);
@@ -11183,7 +11175,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
}
fputc('\n', stdout);
}
- return TRUE;
+ return true;
}
/* ---------------
@@ -11362,12 +11354,12 @@ vshCommandOptULongLong(const vshCmd *cmd, const char *name,
/*
- * Returns TRUE/FALSE if the option exists
+ * Returns true/false if the option exists
*/
-static int
+static bool
vshCommandOptBool(const vshCmd *cmd, const char *name)
{
- return vshCommandOpt(cmd, name) ? TRUE : FALSE;
+ return vshCommandOpt(cmd, name) != NULL;
}
/*
@@ -11698,7 +11690,7 @@ vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
static int
vshCommandRun(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
while (cmd) {
struct timeval before, after;
@@ -11715,11 +11707,11 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
if (enable_timing)
GETTIMEOFDAY(&after);
- if (ret == FALSE)
+ if (ret == false)
virshReportError(ctl);
/* try to automatically catch disconnections */
- if ((ret == FALSE) &&
+ if ((ret == false) &&
((disconnected != 0) ||
((last_error != NULL) &&
(((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
@@ -11915,7 +11907,7 @@ get_data:
break;
}
- return TRUE;
+ return true;
syntaxError:
if (ctl->cmd) {
@@ -11925,7 +11917,7 @@ get_data:
if (first)
vshCommandOptFree(first);
VIR_FREE(tkdata);
- return FALSE;
+ return false;
}
/* --------------------
@@ -11951,7 +11943,7 @@ static int vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
vshCommandParser parser;
if (nargs <= 0)
- return FALSE;
+ return false;
parser.arg_pos = argv;
parser.arg_end = argv + nargs;
@@ -12029,7 +12021,7 @@ static int vshCommandStringParse(vshControl *ctl, char *cmdstr)
vshCommandParser parser;
if (cmdstr == NULL || *cmdstr == '\0')
- return FALSE;
+ return false;
parser.pos = cmdstr;
parser.getNextArg = vshCommandStringGetArg;
@@ -12086,9 +12078,9 @@ vshConnectionUsability(vshControl *ctl, virConnectPtr conn)
*/
if (!conn) {
vshError(ctl, "%s", _("no valid connection"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void
@@ -12114,7 +12106,7 @@ vshPrintExtra(vshControl *ctl, const char *format, ...)
va_list ap;
char *str;
- if (ctl && ctl->quiet == TRUE)
+ if (ctl && ctl->quiet == true)
return;
va_start(ap, format);
@@ -12160,7 +12152,7 @@ static int
vshInit(vshControl *ctl)
{
if (ctl->conn)
- return FALSE;
+ return false;
vshOpenLogFile(ctl);
@@ -12171,7 +12163,7 @@ vshInit(vshControl *ctl)
vshSetupSignals();
if (virEventRegisterDefaultImpl() < 0)
- return FALSE;
+ return false;
ctl->conn = virConnectOpenAuth(ctl->name,
virConnectAuthPtrDefault,
@@ -12185,10 +12177,10 @@ vshInit(vshControl *ctl)
if (!ctl->conn) {
virshReportError(ctl);
vshError(ctl, "%s", _("failed to connect to the hypervisor"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
@@ -12557,7 +12549,7 @@ vshDeinit(vshControl *ctl)
}
virResetLastError();
- return TRUE;
+ return true;
}
/*
@@ -12759,10 +12751,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
help = true;
break;
case 'q':
- ctl->quiet = TRUE;
+ ctl->quiet = true;
break;
case 't':
- ctl->timing = TRUE;
+ ctl->timing = true;
break;
case 'c':
ctl->name = vshStrdup(ctl, optarg);
@@ -12777,7 +12769,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
vshShowVersion(ctl);
exit(EXIT_SUCCESS);
case 'r':
- ctl->readonly = TRUE;
+ ctl->readonly = true;
break;
case 'l':
ctl->logfile = vshStrdup(ctl, optarg);
@@ -12801,7 +12793,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
if (argc > optind) {
/* parse command */
- ctl->imode = FALSE;
+ ctl->imode = false;
if (argc - optind == 1) {
vshDebug(ctl, 2, "commands: \"%s\"\n", argv[optind]);
return vshCommandStringParse(ctl, argv[optind]);
@@ -12809,7 +12801,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
return vshCommandArgvParse(ctl, argc - optind, argv + optind);
}
}
- return TRUE;
+ return true;
}
int
@@ -12817,7 +12809,7 @@ main(int argc, char **argv)
{
vshControl _ctl, *ctl = &_ctl;
char *defaultConn;
- int ret = TRUE;
+ bool ret = true;
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
@@ -12838,7 +12830,7 @@ main(int argc, char **argv)
progname++;
memset(ctl, 0, sizeof(vshControl));
- ctl->imode = TRUE; /* default is interactive mode */
+ ctl->imode = true; /* default is interactive mode */
ctl->log_fd = -1; /* Initialize log file descriptor */
if ((defaultConn = getenv("VIRSH_DEFAULT_CONNECT_URI"))) {
--
1.7.1
2
2
The libvirtd daemon uses fnmatch. Although we don't yet build
it on Win32, we should use gnulib's fnmatch module to ensure
portability to all platforms.
* bootstrap.conf: Add fnmatch
---
bootstrap.conf | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 293f86e..8db4e87 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -34,6 +34,7 @@ count-one-bits
crypto/md5
dirname-lgpl
fcntl-h
+fnmatch
func
getaddrinfo
gethostname
--
1.7.4.4
2
1
[libvirt] [PATCH 1/3] qemu: avoid qemu_driver being unlocked twice when virThreadPoolNew() failed
by Wen Congyang 19 Apr '11
by Wen Congyang 19 Apr '11
19 Apr '11
We do not lock qemu_driver when calling virThreadPoolNew(). If it failed,
we will unlock qemu_driver. It is dangerous.
We may use this pool during auto starting domains. So we must create it before
calling qemuAutostartDomains(). Otherwise, libvirtd will crash.
---
src/qemu/qemu_driver.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 48fe266..dd84f65 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -624,14 +624,14 @@ qemudStartup(int privileged) {
virHashForEach(qemu_driver->domains.objs, qemuDomainSnapshotLoad,
qemu_driver->snapshotDir);
- qemuDriverUnlock(qemu_driver);
-
- qemuAutostartDomains(qemu_driver);
-
qemu_driver->workerPool = virThreadPoolNew(0, 1, processWatchdogEvent, qemu_driver);
if (!qemu_driver->workerPool)
goto error;
+ qemuDriverUnlock(qemu_driver);
+
+ qemuAutostartDomains(qemu_driver);
+
if (conn)
virConnectClose(conn);
--
1.7.1
4
17
[libvirt] [PATCH] Allow handshake with child process during startup
by Daniel P. Berrange 19 Apr '11
by Daniel P. Berrange 19 Apr '11
19 Apr '11
Allow the parent process to perform a bi-directional handshake
with the child process during fork/exec. The child process
will fork and do its initial setup. Immediately prior to the
exec(), it will stop & wait for a handshake from the parent
process. The parent process will spawn the child and wait
until the child reaches the handshake point. It will do
whatever extra setup work is required, before signalling the
child to continue.
The implementation of this is done using two pairs of blocking
pipes. The first pair is used to block the parent, until the
child writes a single byte. Then the second pair pair is used
to block the child, until the parent confirms with another
single byte.
* src/util/command.c, src/util/command.h,
src/libvirt_private.syms: Add APIs to perform a handshake
---
src/libvirt_private.syms | 3 +
src/util/command.c | 142 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/command.h | 5 ++
3 files changed, 148 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 114bc2e..87f0432 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -106,11 +106,14 @@ virCommandAddEnvString;
virCommandClearCaps;
virCommandDaemonize;
virCommandFree;
+virCommandHandshakeNotify;
+virCommandHandshakeWait;
virCommandNew;
virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPreserveFD;
+virCommandRequireHandshake;
virCommandRun;
virCommandRunAsync;
virCommandSetErrorBuffer;
diff --git a/src/util/command.c b/src/util/command.c
index 2e475a0..d8440ca 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -35,6 +35,11 @@
#include "files.h"
#include "buf.h"
+#include <stdlib.h>
+#include <stdbool.h>
+#include <poll.h>
+#include <sys/wait.h>
+
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
@@ -76,6 +81,10 @@ struct _virCommand {
int *outfdptr;
int *errfdptr;
+ bool handshake;
+ int handshakeWait[2];
+ int handshakeNotify[2];
+
virExecHook hook;
void *opaque;
@@ -107,6 +116,11 @@ virCommandNewArgs(const char *const*args)
if (VIR_ALLOC(cmd) < 0)
return NULL;
+ cmd->handshakeWait[0] = -1;
+ cmd->handshakeWait[1] = -1;
+ cmd->handshakeNotify[0] = -1;
+ cmd->handshakeNotify[1] = -1;
+
FD_ZERO(&cmd->preserve);
FD_ZERO(&cmd->transfer);
cmd->infd = cmd->outfd = cmd->errfd = -1;
@@ -1115,7 +1129,6 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
return ret;
}
-
/*
* Perform all virCommand-specific actions, along with the user hook.
*/
@@ -1125,12 +1138,61 @@ virCommandHook(void *data)
virCommandPtr cmd = data;
int res = 0;
- if (cmd->hook)
+ if (cmd->hook) {
+ VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
res = cmd->hook(cmd->opaque);
+ VIR_DEBUG("Done hook %d", res);
+ }
if (res == 0 && cmd->pwd) {
VIR_DEBUG("Running child in %s", cmd->pwd);
res = chdir(cmd->pwd);
+ if (res < 0) {
+ virReportSystemError(errno,
+ _("Unable to change to %s"), cmd->pwd);
+ }
+ }
+ if (cmd->handshake) {
+ char c = res < 0 ? '0' : '1';
+ int rv;
+ VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify parent process"));
+ return -1;
+ }
+
+ /* On failure we pass the error message back to parent,
+ * so they don't have to dig through stderr logs
+ */
+ if (res < 0) {
+ virErrorPtr err = virGetLastError();
+ const char *msg = err ? err->message :
+ _("Unknown failure during hook execution");
+ size_t len = strlen(msg) + 1;
+ if (safewrite(cmd->handshakeWait[1], msg, len) != len) {
+ virReportSystemError(errno, "%s", _("Unable to send error to parent process"));
+ return -1;
+ }
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d", cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s", _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL, _("Unexpected confirm code '%c' from parent process"), c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
}
+
+ VIR_DEBUG("Hook is done %d", res);
+
return res;
}
@@ -1220,6 +1282,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
FD_CLR(i, &cmd->transfer);
}
}
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ }
if (ret == 0 && pid)
*pid = cmd->pid;
@@ -1360,6 +1426,71 @@ virCommandAbort(virCommandPtr cmd ATTRIBUTE_UNUSED)
}
#endif
+
+void virCommandRequireHandshake(virCommandPtr cmd)
+{
+ if (pipe(cmd->handshakeWait) < 0) {
+ cmd->has_error = errno;
+ return;
+ }
+ if (pipe(cmd->handshakeNotify) < 0) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ cmd->has_error = errno;
+ return;
+ }
+
+ VIR_DEBUG("Transfer handshake wait=%d notify=%d",
+ cmd->handshakeWait[1], cmd->handshakeNotify[0]);
+ virCommandPreserveFD(cmd, cmd->handshakeWait[1]);
+ virCommandPreserveFD(cmd, cmd->handshakeNotify[0]);
+ cmd->handshake = true;
+}
+
+int virCommandHandshakeWait(virCommandPtr cmd)
+{
+ char c;
+ int rv;
+ VIR_DEBUG("Wait for handshake on %d", cmd->handshakeWait[0]);
+ if ((rv = saferead(cmd->handshakeWait[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait for child process"));
+ else
+ virReportSystemError(EIO, "%s", _("Child process quit during startup handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ char *msg;
+ ssize_t len;
+ if (VIR_ALLOC_N(msg, 1024) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if ((len = saferead(cmd->handshakeWait[0], msg, 1024)) < 0) {
+ VIR_FREE(msg);
+ virReportSystemError(errno, "%s", _("No error message from child failure"));
+ return -1;
+ }
+ msg[len-1] = '\0';
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
+ VIR_FREE(msg);
+ return -1;
+ }
+ return 0;
+}
+
+int virCommandHandshakeNotify(virCommandPtr cmd)
+{
+ char c = '1';
+ VIR_DEBUG("Notify handshake on %d", cmd->handshakeWait[0]);
+ if (safewrite(cmd->handshakeNotify[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify child process"));
+ return -1;
+ }
+ return 0;
+}
+
+
/*
* Release all resources
*/
@@ -1391,6 +1522,13 @@ virCommandFree(virCommandPtr cmd)
VIR_FREE(cmd->pwd);
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[1]);
+ }
+
VIR_FREE(cmd->pidfile);
if (cmd->reap)
diff --git a/src/util/command.h b/src/util/command.h
index ff8ccf5..4712301 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -274,6 +274,11 @@ int virCommandRunAsync(virCommandPtr cmd,
int virCommandWait(virCommandPtr cmd,
int *exitstatus) ATTRIBUTE_RETURN_CHECK;
+void virCommandRequireHandshake(virCommandPtr cmd);
+
+int virCommandHandshakeWait(virCommandPtr cmd);
+int virCommandHandshakeNotify(virCommandPtr cmd);
+
/*
* Abort an async command if it is running, without issuing
* any errors or affecting errno. Designed for error paths
--
1.7.4
2
2
Re: [libvirt] [PATCH DISCUSSION ONLY] Add inspection thread to virt-manager.
by Richard W.M. Jones 19 Apr '11
by Richard W.M. Jones 19 Apr '11
19 Apr '11
On Mon, Apr 18, 2011 at 05:50:01PM -0400, Cole Robinson wrote:
> First, thanks a lot for the patch! I'm sure everyone will be glad to see
> libguestfs integration in virt-manager.
>
> > [This patch is incomplete and just for discussion]
> >
> > Using libguestfs inspection[1], we can find out a lot about a virtual
> > machine, such as what operating system is installed, the OS version,
> > the OS distro, the hostname, the (real) disk usage, what apps are
> > installed, and lots more. It would be nice if virt-manager could use
> > this information: for example we could change the generic "computer"
> > icon into a Windows or Fedora logo if Windows or Fedora was installed
> > in the virtual machine.
> >
>
> That icon bit was originally intended for the current design, but since we've
> never really tracked OS info after install time, it never came about.
>
> Particularly for OS type/version tracking, I think we need a few things:
>
> - Everything standardize on some naming scheme, ideally libosinfo (though
> nothing is using it yet :/ ). libosinfo could also distribute the OS icons
We sort of got bored of waiting for that train. We have a primitive
but rather effective system in libguestfs, which I explain at the end
of this email.
> - Libvirt domain XML schema is extended with a field to track the
> installed OS. For most libvirt drivers this would just be metadata
> (vmware/esx the exception). Even though the data might be out of
> date if the guest is upgraded, I think it has become clear that
> there is a lot of value in tracking this in XML.
Yes, I agree. This also solves the persistence problem.
It's a bit of a shame that the <description> field in the libvirt XML
isn't structured, at least so that different applications could store
their own data there without it being trampled upon by users or other
applications. (CC'd to libvir-list in case they have any thoughts
about that).
> - virt-manager can offer an option to set the XML OS value from libguestfs
> inspection. Maybe even some preference to do this automatically for vms which
> have no XML value, or some warning if the inspected OS doesn't match the
> stored value.
>
> None of this affects the validity of the patch btw.
>
> > This patch adds a daemon thread running in the background which
> > performs batch inspection on the virt-manager VMs. If inspection is
> > successful, it then passes the results up to the UI (ie. the
> > vmmManager object) to be displayed.
> >
> > Currently I've just added the inspected hostname to the UI as you can
> > see in this screenshot:
> >
> > http://oirase.annexia.org/tmp/vmm-hostnames.png
> >
>
> Ah, that's a nice idea, but I'd probably want to run it by the UX guys first.
I've removed that from the code already. It was just a quick hack to
show what could be done.
> At the very least a first step would be showing the hostname under
> Details->Overview, probably just add a new field under the Name:
Agreed.
> > In future there is room for much greater customization of the UI, such
> > as changing the icons, displaying disk usage and more.
> >
> > The background thread is transparent to the UI. Well, in fact because
> > of a bug in libguestfs, it is currently NOT transparent because we
> > weren't releasing the Python GIL across libguestfs calls. If you
> > apply the following patch to libguestfs, then it *is* transparent and
> > doesn't interrupt the UI:
> >
> > https://www.redhat.com/archives/libguestfs/2011-April/msg00076.html
> >
>
> Okay, so when this patch is committed we probably want to add a libguestfs
> version check to make sure we aren't using bad bindings.
Agreed. Also I have pushed the Python fix into:
stable branch 1.8 version >= 1.8.6
stable branch 1.10 version >= 1.10.1
development branch version >= 1.11.2
and these should be available in Fedora 14 onwards in a few weeks.
> > I think that virt-manager should probably cache the inspection data
> > across runs. However I don't know if virt-manager has a mechanism to
> > do this already or if we'd need to add one.
>
> Do you mean cache across runs of virt-manager? We could use gconf, we already
> have examples of setting per-vm preferences like console scaling, we could use
> the same to store hostname, os type/distro, etc. But then we have to decide
> when to repoll this info, and if/how to allow the user to force repolling.
Or libvirt XML maybe .. see above.
> > Also this patch doesn't yet change ./configure, so it'll just fail if
> > the python-libguestfs package is not installed.
> >
>
> We don't really use configure for package checks actually. It's pretty easy in
> the code to just try the import and disable the feature if the package isn't
> available. Then distros just use rpm/dpkg deps to pull in the packages we want
We should probably do the check entirely at runtime and make
python-libguestfs completely optional (but on Debian, map it to an
Enhances-type dependency). There's no need to have virt-manager
depending on libguestfs, since this is just an extra feature, not a
requirement.
> > [1] http://libguestfs.org/virt-inspector.1.html
> >
>
> On 04/18/2011 01:01 PM, Richard W.M. Jones wrote:
> > From 11278a7509e4edbcb28eac4c2c4a50fc8d68342e Mon Sep 17 00:00:00 2001
> > From: Richard W.M. Jones <rjones(a)redhat.com>
> > Date: Mon, 18 Apr 2011 17:44:51 +0100
> > Subject: [PATCH] Add inspection thread to virt-manager.
> >
> > ---
> > src/virtManager/engine.py | 14 ++++
> > src/virtManager/inspection.py | 162 +++++++++++++++++++++++++++++++++++++++++
> > src/virtManager/manager.py | 26 ++++++-
> > 3 files changed, 200 insertions(+), 2 deletions(-)
> > create mode 100644 src/virtManager/inspection.py
> >
> > diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py
> > index 383deb3..40d5b39 100644
> > --- a/src/virtManager/engine.py
> > +++ b/src/virtManager/engine.py
> > @@ -45,6 +45,7 @@ from virtManager.create import vmmCreate
> > from virtManager.host import vmmHost
> > from virtManager.error import vmmErrorDialog
> > from virtManager.systray import vmmSystray
> > +from virtManager.inspection import vmmInspection
> > import virtManager.uihelpers as uihelpers
> > import virtManager.util as util
> >
> > @@ -239,6 +240,9 @@ class vmmEngine(vmmGObject):
> > if not self.config.support_threading:
> > logging.debug("Libvirt doesn't support threading, skipping.")
> >
> > + self.inspection_thread = None
> > + self.create_inspection_thread()
> > +
> > # Counter keeping track of how many manager and details windows
> > # are open. When it is decremented to 0, close the app or
> > # keep running in system tray if enabled
> > @@ -533,6 +537,16 @@ class vmmEngine(vmmGObject):
> > logging.debug("Exiting app normally.")
> > gtk.main_quit()
> >
> > + def create_inspection_thread(self):
> > + if not self.config.support_threading:
> > + logging.debug("No inspection thread because "
> > + "libvirt is not thread-safe.")
> > + return
> > + self.inspection_thread = vmmInspection(self)
> > + self.inspection_thread.daemon = True
> > + self.inspection_thread.start()
> > + return
> > +
> > def add_connection(self, uri, readOnly=None, autoconnect=False):
> > conn = self._check_connection(uri)
> > if conn:
> > diff --git a/src/virtManager/inspection.py b/src/virtManager/inspection.py
> > new file mode 100644
> > index 0000000..70f2f52
> > --- /dev/null
> > +++ b/src/virtManager/inspection.py
> > @@ -0,0 +1,162 @@
> > +#
> > +# Copyright (C) 2011 Red Hat, Inc.
> > +#
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of the GNU General Public License as published by
> > +# the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version.
> > +#
> > +# This program is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write to the Free Software
> > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> > +# MA 02110-1301 USA.
> > +#
> > +
> > +import sys
> > +import time
> > +import traceback
> > +from Queue import Queue
> > +from threading import Thread
> > +
> > +from guestfs import GuestFS
> > +
> > +import logging
> > +import util
> > +
> > +class vmmInspection(Thread):
> > + _name = "inspection thread"
> > + _wait = 60 # seconds
> > +
> > + def __init__(self, engine):
> > + Thread.__init__(self, name=self._name)
> > + self._q = Queue()
> > + self._engine = engine
> > + self._vmcache = dict()
> > +
> > + # Called by the main thread whenever a VM is added to vmlist.
> > + def vm_added(self, connection, vmuuid):
> > + obj = (connection, vmuuid)
> > + self._q.put(obj)
> > +
> > + def run(self):
> > + # Wait a few seconds before we do anything. This prevents
> > + # inspection from being a burden for initial virt-manager
> > + # interactivity (although it shouldn't affect interactivity at
> > + # all).
> > + logging.debug("%s: waiting" % self._name)
> > + time.sleep(self._wait)
> > +
> > + logging.debug("%s: ready" % self._name)
> > +
> > + while True:
> > + obj = self._q.get(True)
> > + (connection, vmuuid) = obj
> > +
> > + logging.debug("%s: %s: processing started, connection = %s" %
> > + (self._name, vmuuid, connection))
> > + try:
> > + self._process(connection, vmuuid)
> > + except:
> > + logging.debug("%s: %s: processing raised:\n%s" %
> > + (self._name, vmuuid, traceback.format_exc()))
> > +
> > + self._q.task_done()
> > + logging.debug("%s: %s: processing done" % (self._name, vmuuid))
> > +
> > + def _process(self, connection, vmuuid):
> > + if vmuuid in self._vmcache:
> > + self._update_ui(connection, vmuuid)
> > + return
> > +
> > + if not connection or connection.is_remote():
> > + logging.debug("%s: %s: no connection object or "
> > + "connection is remote" % (self._name, vmuuid))
> > + return
> > + vm = connection.get_vm(vmuuid)
> > + if not vm:
> > + logging.debug("%s: %s: no vm object" % (self._name, vmuuid))
> > + return
> > +
> > + xml = vm.get_xml()
> > + if not xml:
> > + logging.debug("%s: %s: cannot get domain XML" %
> > + (self._name, vmuuid))
> > + return
> > +
>
> This 2 calls won't ever be none, they'll either return something or throw an
> exception.
OK, I will fix it.
> > + g = GuestFS()
> > + # One day we will be able to do ...
> > + #g.add_libvirt_dom(...)
> > + # but until that day comes ...
> > + disks = self._get_disks_from_xml(xml)
> > + for (disk, format) in disks:
> > + g.add_drive_opts(disk, readonly=1, format=format)
> > +
> > + g.launch()
> > +
> > + # Inspect the operating system.
> > + roots = g.inspect_os()
> > + if len(roots) == 0:
> > + logging.debug("%s: %s: no operating systems found" %
> > + (self._name, vmuuid))
> > + return
> > +
> > + # Arbitrarily pick the first root device.
> > + root = roots[0]
> > +
> > + # Inspection.
> > + name = g.inspect_get_type (root)
> > + distro = g.inspect_get_distro (root)
> > + hostname = g.inspect_get_hostname (root)
> > +
> > + self._vmcache[vmuuid] = (name, distro, hostname)
> > +
> > + # Force the libguestfs handle to close right now.
> > + del g
> > +
> > + # Update the UI.
> > + self._update_ui(connection, vmuuid)
> > +
> > + # Call back into the manager (if one is displayed) to update the
> > + # inspection data for the particular VM.
> > + def _update_ui(self, connection, vmuuid):
> > + wm = self._engine.windowManager
> > + if not wm: return
> > +
> > + name, distro, hostname = self._vmcache[vmuuid]
> > +
> > + wm.vm_set_inspection_data(connection, vmuuid, name, distro, hostname)
> > +
>
> The preferred way to do this would be with gtk signals. Have the
> inspection thread do something like vm.set_hostname(), which will
> trigger a self.emit("config-changed"), which is already wired up in
> manager.py to refresh the row listing. This will let you drop
> self._engine (generally if we are passing engine around there is
> probably a cleaner way to do things, but we aren't too disciplined
> on that at the moment).
OK, I will fix this too once I work out what gtk signals are ..
> > + # Get the list of disks belonging to this VM from the libvirt XML.
> > + def _get_disks_from_xml(self, xml):
> > + def f(doc, ctx):
> > + nodes = ctx.xpathEval("//devices/disk")
> > + disks = []
> > + for node in nodes:
> > + ctx.setContextNode(node)
> > + types = ctx.xpathEval("./@type")
> > +
> > + if types and types[0].content:
> > + t = types[0].content
> > + disk = None
> > +
> > + if t == "file":
> > + disk = ctx.xpathEval("./source/@file")
> > + elif t == "block":
> > + disk = ctx.xpathEval("./source/@dev")
> > +
> > + if disk and disk[0].content:
> > + d = disk[0].content
> > + types = ctx.xpathEval("./driver/@type")
> > + if types and types[0].content:
> > + disks.append((d, types[0].content))
> > + else:
> > + disks.append((d, None))
> > +
> > + return disks
>
> This _get_disk_from_xml function isn't needed. You can just do:
>
> for disk in vm.get_disk_devices():
> path = disk.path
> driver_type = disk.driver_type
> disks.append((path, driver_type))
>
> the 'disk' in this case is a virtinst.VirtualDisk instance, incase you need
> other XML values in the future
OK, that's a much better idea! I'll make these and other changes and
send an update in a few days.
Thanks for looking at this.
Rich.
----------------------------------------------------------------------
Operating systems are classified at two levels, 'type' and 'distro':
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_type
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_distro
The version number of the OS is classified separately:
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_major_version
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_minor_version
And finally in order to distinguish between certain flavours of
Windows and RHEL you also need the "product variant":
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_product_variant
In the patch I sent, 'type' and 'distro' fields are pushed up to the
vmmManager object already.
----------------------------------------------------------------------
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
3
2
---
libvirt-php.spec.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/libvirt-php.spec.in b/libvirt-php.spec.in
index 07e11a1..41408a2 100644
--- a/libvirt-php.spec.in
+++ b/libvirt-php.spec.in
@@ -46,6 +46,7 @@ For more details see: http://www.libvirt.org/php/
%package -n libvirt-php-doc
Summary: Document of libvirt-php
Group: Development/Libraries/PHP
+BuildArch: noarch
Requires: libvirt-php = %{version}
%description -n libvirt-php-doc
--
1.7.3.4
2
1
Hi,
I've upgraded to 0.9.0 today on my Debian Squeeze boxes. Everything went
fine, expect on one node (and only on that one, although the setup is
identical), the first start of libvirtd since boot (and again, only that
start) crashes with SEGV.
Here are traces from gdb:
http://pastebin.com/DiZrw0S5
http://pastebin.com/eacJRv07
If I delete the PID-file and start libvirtd again, it works fine. It
doesn't seem to matter when the first start since boot happens, I've
deactivated startup of libvirtd at boot time.
Any ideas or further infos needed?
thanks & regards,
thomas
3
7
Hi,
This is v3 of virNodeGetCpuTime() API.
It returns cpu utilization or
cumulative cpu time of the node from /proc/stat since node boots up.
This patch only supports linux host.
Changes
v2->v3
- Change user I/F. It is able to request what the user want by the @flags.
- Minor change of virsh nodecputime I/F.
v1->v2
- Change user I/F like virDomainGetMemoryStats()
- It can return either cpu utilization or cumulative cpu time of the node
depends on each driver.
Minoru Usui (6):
[v3 1/6] virNodeGetCPUTime: Expose new API
[v3 2/6] virNodeGetCPUTime: Define internal driver API
[v3 3/6] virNodeGetCPUTime: Implement public API
[v3 4/6] virNodeGetCPUTime: Implement remote protocol
[v3 5/6] virNodeGetCPUTime: Implement virsh support
[v3 6/6] virNodeGetCPUTime: Implement linux support
daemon/remote.c | 46 +++++++++++++++++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 +++
daemon/remote_dispatch_ret.h | 1 +
daemon/remote_dispatch_table.h | 5 ++
include/libvirt/libvirt.h.in | 50 +++++++++++++++++++++
src/driver.h | 8 +++
src/esx/esx_driver.c | 1 +
src/libvirt.c | 79 ++++++++++++++++++++++++++++++++
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 ++
src/libxl/libxl_driver.c | 1 +
src/lxc/lxc_driver.c | 1 +
src/nodeinfo.c | 78 ++++++++++++++++++++++++++++++++
src/nodeinfo.h | 5 ++-
src/openvz/openvz_driver.c | 1 +
src/phyp/phyp_driver.c | 1 +
src/qemu/qemu_driver.c | 1 +
src/remote/remote_driver.c | 37 +++++++++++++++
src/remote/remote_protocol.c | 22 +++++++++
src/remote/remote_protocol.h | 20 ++++++++
src/remote/remote_protocol.x | 15 ++++++-
src/remote_protocol-structs | 10 ++++
src/test/test_driver.c | 1 +
src/uml/uml_driver.c | 1 +
src/vbox/vbox_tmpl.c | 1 +
src/vmware/vmware_driver.c | 1 +
src/xen/xen_driver.c | 1 +
src/xenapi/xenapi_driver.c | 1 +
tools/virsh.c | 84 +++++++++++++++++++++++++++++++++++
tools/virsh.pod | 4 ++
31 files changed, 489 insertions(+), 2 deletions(-)
--
Minoru Usui <usui(a)mxm.nes.nec.co.jp>
2
8
From: Alan Pevec <apevec(a)redhat.com>
To install it, disable libvirtd sysv initscript:
chkconfig libvirtd off
service libvirtd stop
and enable libvirtd upstart job:
cp /usr/share/doc/libvirt-*/libvirtd.upstart \
/etc/init/libvirtd.conf
initctl reload-configuration
initctl start libvirtd
Test:
initctl status libvirtd
libvirtd start/running, process 3929
killall -9 libvirtd
initctl status libvirtd
libvirtd start/running, process 4047
I looked into the possibility to use the upstart script from Ubuntu or
at least getting inspiration from it but that's not possible. "expect
daemon" is a nice thing but it only works if the process is defined with
exec stanza instead of script ... no script. Unfortunately, with exec
stanza environment variables can only be set within upstart script
(i.e., configuration in /etc/sysconfig/libvirtd can't work). Hence, we
need to use script stanza, source sysconfig, and execute libvirtd
without --daemon. For similar reasons we can't use limit stanza and need
to handle DAEMON_COREFILE_LIMIT in job's script.
---
Notes:
Version 2:
- I took Allan's script and modified it a bit
- DAEMON_COREFILE_LIMIT from sysconfig works
- PID file handling limited to just removing it
daemon/Makefile.am | 1 +
daemon/libvirtd.upstart | 46 ++++++++++++++++++++++++++++++++++++++++++++++
libvirt.spec.in | 1 +
3 files changed, 48 insertions(+), 0 deletions(-)
create mode 100644 daemon/libvirtd.upstart
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index cacec1c..af71188 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -26,6 +26,7 @@ EXTRA_DIST = \
remote_generate_stubs.pl \
libvirtd.conf \
libvirtd.init.in \
+ libvirtd.upstart \
libvirtd.policy-0 \
libvirtd.policy-1 \
libvirtd.sasl \
diff --git a/daemon/libvirtd.upstart b/daemon/libvirtd.upstart
new file mode 100644
index 0000000..fd1d951
--- /dev/null
+++ b/daemon/libvirtd.upstart
@@ -0,0 +1,46 @@
+# libvirtd upstart job
+#
+# XXX wait for rc to get all dependent initscripts started
+# from sysv libvirtd initscript: Required-Start: $network messagebus
+start on stopped rc RUNLEVEL=[345]
+stop on runlevel [!345]
+
+respawn
+
+script
+ LIBVIRTD_CONFIG=
+ LIBVIRTD_ARGS=
+ KRB5_KTNAME=/etc/libvirt/krb5.tab
+
+ if [ -f /etc/sysconfig/libvirtd ]; then
+ . /etc/sysconfig/libvirtd
+ fi
+
+ export QEMU_AUDIO_DRV
+ export SDL_AUDIODRIVER
+ export KRB5_KTNAME
+
+ LIBVIRTD_CONFIG_ARGS=
+ if [ -n "$LIBVIRTD_CONFIG" ]; then
+ LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
+ fi
+
+ # DAEMON_COREFILE_LIMIT from /etc/sysconfig/libvirtd is not handled
+ # automatically
+ if [ -n "$DAEMON_COREFILE_LIMIT" ]; then
+ ulimit -c "$DAEMON_COREFILE_LIMIT"
+ fi
+
+ # Clean up a pidfile that might be left around
+ rm -f /var/run/libvirtd.pid
+
+ mkdir -p /var/cache/libvirt
+ rm -rf /var/cache/libvirt/*
+
+ exec /usr/sbin/libvirtd $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
+end script
+
+post-stop script
+ rm -f $PIDFILE
+ rm -rf /var/cache/libvirt/*
+end script
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 4162fba..bf6b9df 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -895,6 +895,7 @@ fi
%{_sysconfdir}/libvirt/nwfilter/*.xml
%{_sysconfdir}/rc.d/init.d/libvirtd
+%doc daemon/libvirtd.upstart
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
%if %{with_dtrace}
--
1.7.5.rc1
3
5
Here is a new version of this patch:
https://www.redhat.com/archives/libvir-list/2011-April/msg00337.html
v2:
- store the cputune info for the whole runtime of the domain
- remove cputune info when domain is destroyed
The nodeGetInfo code had to be moved into a helper
function to reuse it without a virConnectPtr.
---
src/libxl/libxl_driver.c | 159 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 122 insertions(+), 37 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 3040914..247d78e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -199,6 +199,46 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
virDomainObjUnlock(vm);
}
+static int
+libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
+{
+ libxl_physinfo phy_info;
+ const libxl_version_info* ver_info;
+ struct utsname utsname;
+
+ if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxl_get_physinfo_info failed"));
+ return -1;
+ }
+
+ if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxl_get_version_info failed"));
+ return -1;
+ }
+
+ uname(&utsname);
+ if (virStrncpy(info->model,
+ utsname.machine,
+ strlen(utsname.machine),
+ sizeof(info->model)) == NULL) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("machine type %s too big for destination"),
+ utsname.machine);
+ return -1;
+ }
+
+ info->memory = phy_info.total_pages * (ver_info->pagesize / 1024);
+ info->cpus = phy_info.nr_cpus;
+ info->nodes = phy_info.nr_nodes;
+ info->cores = phy_info.cores_per_socket;
+ info->threads = phy_info.threads_per_core;
+ info->sockets = 1;
+ info->mhz = phy_info.cpu_khz / 1000;
+ return 0;
+}
+
/*
* Cleanup function for domain that has reached shutoff state.
*
@@ -210,6 +250,7 @@ libxlVmCleanup(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
libxlDomainObjPrivatePtr priv = vm->privateData;
int vnc_port;
char *file;
+ int i;
if (priv->eventHdl >= 0) {
virEventRemoveHandle(priv->eventHdl);
@@ -238,6 +279,16 @@ libxlVmCleanup(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
}
}
+ /* Remove any cputune settings */
+ if (vm->def->cputune.nvcpupin) {
+ for (i = 0; i < vm->def->cputune.nvcpupin; ++i) {
+ VIR_FREE(vm->def->cputune.vcpupin[i]->cpumask);
+ VIR_FREE(vm->def->cputune.vcpupin[i]);
+ }
+ VIR_FREE(vm->def->cputune.vcpupin);
+ vm->def->cputune.nvcpupin = 0;
+ }
+
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) > 0) {
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name);
@@ -391,6 +442,62 @@ error:
return -1;
}
+static int
+libxlDomainSetVcpuAffinites(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
+{
+ libxlDomainObjPrivatePtr priv = vm->privateData;
+ virDomainDefPtr def = vm->def;
+ libxl_cpumap map;
+ uint8_t *cpumask = NULL;
+ uint8_t *cpumap = NULL;
+ virNodeInfo nodeinfo;
+ size_t cpumaplen;
+ unsigned int pos;
+ int vcpu, i;
+ int ret = -1;
+
+ if (libxlDoNodeGetInfo(driver, &nodeinfo) < 0)
+ goto cleanup;
+
+ cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
+
+ for (vcpu = 0; vcpu < def->cputune.nvcpupin; ++vcpu) {
+ if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
+ continue;
+
+ if (VIR_ALLOC_N(cpumap, cpumaplen) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ cpumask = (uint8_t*) def->cputune.vcpupin[vcpu]->cpumask;
+
+ for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; ++i) {
+ if (cpumask[i]) {
+ pos = i / 8;
+ cpumap[pos] |= 1 << (i % 8);
+ }
+ }
+
+ map.size = cpumaplen;
+ map.map = cpumap;
+
+ if (libxl_set_vcpuaffinity(&priv->ctx, def->id, vcpu, &map) != 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to pin vcpu '%d' with libxenlight"), vcpu);
+ goto cleanup;
+ }
+
+ VIR_FREE(cpumap);
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cpumap);
+ return ret;
+}
+
/*
* Start a domain through libxenlight.
*
@@ -440,6 +547,9 @@ libxlVmStart(libxlDriverPrivatePtr driver,
if (libxlCreateDomEvents(vm) < 0)
goto error;
+ if (libxlDomainSetVcpuAffinites(driver, vm) < 0)
+ goto error;
+
if (!start_paused) {
libxl_domain_unpause(&priv->ctx, domid);
vm->state = VIR_DOMAIN_RUNNING;
@@ -756,7 +866,7 @@ libxlReload(void)
&libxl_driver->domains,
libxl_driver->configDir,
libxl_driver->autostartDir,
- 0, NULL, libxl_driver);
+ 1, NULL, libxl_driver);
virHashForEach(libxl_driver->domains.objs, libxlAutostartDomain,
libxl_driver);
@@ -869,42 +979,7 @@ libxlGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
static int
libxlNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
{
- libxl_physinfo phy_info;
- const libxl_version_info* ver_info;
- libxlDriverPrivatePtr driver = conn->privateData;
- struct utsname utsname;
-
- if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxl_get_physinfo_info failed"));
- return -1;
- }
-
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxl_get_version_info failed"));
- return -1;
- }
-
- uname(&utsname);
- if (virStrncpy(info->model,
- utsname.machine,
- strlen(utsname.machine),
- sizeof(info->model)) == NULL) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("machine type %s too big for destination"),
- utsname.machine);
- return -1;
- }
-
- info->memory = phy_info.total_pages * (ver_info->pagesize / 1024);
- info->cpus = phy_info.nr_cpus;
- info->nodes = phy_info.nr_nodes;
- info->cores = phy_info.cores_per_socket;
- info->threads = phy_info.threads_per_core;
- info->sockets = 1;
- info->mhz = phy_info.cpu_khz / 1000;
- return 0;
+ return libxlDoNodeGetInfo(conn->privateData, info);
}
static char *
@@ -1712,6 +1787,16 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
}
+
+ if (virDomainVcpupinAdd(vm->def, cpumap, maplen, vcpu) < 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("failed to update or add vcpupin xml"));
+ goto cleanup;
+ }
+
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
--
1.7.1
2
1
[libvirt] [PATCH] Update and sort msg_gen_function list and mark unmarked messages
by Matthias Bolte 18 Apr '11
by Matthias Bolte 18 Apr '11
18 Apr '11
Inspired by Eric Blake
---
cfg.mk | 45 ++++++++++++++++++++++++++++++++++-------
src/interface/netcf_driver.c | 43 ++++++++++++++++++---------------------
src/nodeinfo.c | 2 +-
src/phyp/phyp_driver.c | 18 ++++++++--------
src/util/stats_linux.c | 2 +-
5 files changed, 68 insertions(+), 42 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index e54d170..72dd69c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -380,47 +380,76 @@ sc_prohibit_xmlGetProp:
msg_gen_function =
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
-msg_gen_function += macvtapError
-msg_gen_function += remoteError
+msg_gen_function += PHYP_ERROR
+msg_gen_function += VIR_ERROR
+msg_gen_function += VIR_ERROR0
+msg_gen_function += VMX_ERROR
+msg_gen_function += XENXS_ERROR
+msg_gen_function += eventReportError
+msg_gen_function += ifaceError
+msg_gen_function += interfaceReportError
+msg_gen_function += iptablesError
msg_gen_function += lxcError
-msg_gen_function += networkLog
+msg_gen_function += libxlError
+msg_gen_function += macvtapError
msg_gen_function += networkReportError
-msg_gen_function += oneError
+msg_gen_function += nodeReportError
msg_gen_function += openvzError
+msg_gen_function += pciReportError
msg_gen_function += qemuReportError
msg_gen_function += qemudDispatchClientFailure
msg_gen_function += regerror
+msg_gen_function += remoteError
msg_gen_function += remoteDispatchFormatError
+msg_gen_function += statsError
+msg_gen_function += streamsReportError
+msg_gen_function += usbReportError
msg_gen_function += umlReportError
msg_gen_function += vah_error
msg_gen_function += vah_warning
msg_gen_function += vboxError
msg_gen_function += virCommandError
msg_gen_function += virConfError
+msg_gen_function += virCPUReportError
+msg_gen_function += virEventError
msg_gen_function += virDomainReportError
+msg_gen_function += virGenericReportError
msg_gen_function += virHashError
+msg_gen_function += virHookReportError
+msg_gen_function += virInterfaceReportError
+msg_gen_function += virJSONError
msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError
+msg_gen_function += virLibDomainSnapshotError
+msg_gen_function += virLibInterfaceError
+msg_gen_function += virLibNetworkError
+msg_gen_function += virLibNodeDeviceError
+msg_gen_function += virLibNWFilterError
+msg_gen_function += virLibSecretError
+msg_gen_function += virLibStoragePoolError
+msg_gen_function += virLibStorageVolError
msg_gen_function += virNetworkReportError
msg_gen_function += virNodeDeviceReportError
+msg_gen_function += virNWFilterReportError
msg_gen_function += virRaiseError
msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError
+msg_gen_function += virSecretReportError
msg_gen_function += virSecurityReportError
msg_gen_function += virSexprError
+msg_gen_function += virSmbiosReportError
+msg_gen_function += virSocketError
+msg_gen_function += virStatsError
msg_gen_function += virStorageReportError
+msg_gen_function += virUtilError
msg_gen_function += virXMLError
msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError
msg_gen_function += vmwareError
msg_gen_function += xenapiSessionErrorHandler
-msg_gen_function += libxlError
msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
-msg_gen_function += VIR_ERROR
-msg_gen_function += VIR_ERROR0
-msg_gen_function += statsError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index 0190bf4..709f09b 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -102,11 +102,12 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac
int errcode = ncf_error(ncf, &errmsg, &details);
if (errcode != NETCF_NOERROR) {
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface named '%s' (netcf: %s - %s)",
- ifinfo->name, errmsg, details ? details : "");
+ _("couldn't find interface named '%s' (netcf: %s - %s)"),
+ ifinfo->name, errmsg, details ? details : "");
} else {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface named '%s'", ifinfo->name);
+ _("couldn't find interface named '%s'"),
+ ifinfo->name);
}
}
return iface;
@@ -182,8 +183,7 @@ static int interfaceNumOfInterfaces(virConnectPtr conn)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to get number of interfaces on host"),
+ _("failed to get number of interfaces on host (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -203,8 +203,7 @@ static int interfaceListInterfaces(virConnectPtr conn, char **const names, int n
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to list host interfaces"),
+ _("failed to list host interfaces (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -224,8 +223,7 @@ static int interfaceNumOfDefinedInterfaces(virConnectPtr conn)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to get number of defined interfaces on host"),
+ _("failed to get number of defined interfaces on host (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -245,8 +243,7 @@ static int interfaceListDefinedInterfaces(virConnectPtr conn, char **const names
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to list host defined interfaces"),
+ _("failed to list host defined interfaces (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -269,11 +266,11 @@ static virInterfacePtr interfaceLookupByName(virConnectPtr conn,
int errcode = ncf_error(driver->netcf, &errmsg, &details);
if (errcode != NETCF_NOERROR) {
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface named '%s' (netcf: %s - %s)",
+ _("couldn't find interface named '%s' (netcf: %s - %s)"),
name, errmsg, details ? details : "");
} else {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface named '%s'", name);
+ _("couldn't find interface named '%s'"), name);
}
goto cleanup;
}
@@ -301,13 +298,13 @@ static virInterfacePtr interfaceLookupByMACString(virConnectPtr conn,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface with MAC address '%s' (netcf: %s - %s)",
+ _("couldn't find interface with MAC address '%s' (netcf: %s - %s)"),
macstr, errmsg, details ? details : "");
goto cleanup;
}
if (niface == 0) {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface with MAC address '%s'",
+ _("couldn't find interface with MAC address '%s'"),
macstr);
goto cleanup;
}
@@ -351,8 +348,8 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "could not get interface XML description (netcf: %s - %s)",
- errmsg, details ? details : "");
+ _("could not get interface XML description (netcf: %s - %s)"),
+ errmsg, details ? details : "");
goto cleanup;
}
@@ -405,8 +402,8 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "could not get interface XML description (netcf: %s - %s)",
- errmsg, details ? details : "");
+ _("could not get interface XML description (netcf: %s - %s)"),
+ errmsg, details ? details : "");
goto cleanup;
}
@@ -438,7 +435,7 @@ static int interfaceUndefine(virInterfacePtr ifinfo) {
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to undefine interface %s (netcf: %s - %s)",
+ _("failed to undefine interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -469,7 +466,7 @@ static int interfaceCreate(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to create (start) interface %s (netcf: %s - %s)",
+ _("failed to create (start) interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -500,7 +497,7 @@ static int interfaceDestroy(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to destroy (stop) interface %s (netcf: %s - %s)",
+ _("failed to destroy (stop) interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -530,7 +527,7 @@ static int interfaceIsActive(virInterfacePtr ifinfo)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to get status of interface %s (netcf: %s - %s)",
+ _("failed to get status of interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index facac15..e0221f0 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -239,7 +239,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
buf++;
if (*buf != ':' || !buf[1]) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
- "parsing cpuinfo cpu cores %c", *buf);
+ _("parsing cpuinfo cpu cores %c"), *buf);
return -1;
}
if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 8f8c3ba..c65824a 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3659,28 +3659,28 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!def->mem.cur_balloon) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<memory>\" on the domain XML file is missing or has "
- "invalid value."));
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <memory> on the domain XML file is missing or has "
+ "invalid value."));
goto cleanup;
}
if (!def->mem.max_balloon) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<currentMemory>\" on the domain XML file is missing or"
- " has invalid value."));
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <currentMemory> on the domain XML file is missing or "
+ "has invalid value."));
goto cleanup;
}
if (def->ndisks < 1) {
PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
- _("Domain XML must contain at least one \"<disk>\" element."));
+ _("Domain XML must contain at least one <disk> element."));
goto cleanup;
}
if (!def->disks[0]->src) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<src>\" under \"<disk>\" on the domain XML file is "
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <src> under <disk> on the domain XML file is "
"missing."));
goto cleanup;
}
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index 173cdc5..e728b7b 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -107,7 +107,7 @@ linuxDomainInterfaceStats(const char *path,
VIR_FORCE_FCLOSE(fp);
virStatsError(VIR_ERR_INTERNAL_ERROR,
- "/proc/net/dev: Interface not found");
+ _("/proc/net/dev: Interface not found"));
return -1;
}
--
1.7.0.4
2
2
Smaller code and fewer bugs. Rebase of earlier version at:
https://www.redhat.com/archives/libvir-list/2011-April/msg00677.html
Eric Blake (9):
maint: use lighter-weight function for straight appends
phyp: avoid a logic bug
phyp: avoid memory leak on failure
phyp: more return handling cleanup
phyp: use consistent style for labels
phyp: prefer memcpy over memmove when legal
phyp: use consistent return string handling
phyp: avoid memory leaks in command values
phyp: another simplification
src/conf/nwfilter_conf.c | 16 +-
src/phyp/phyp_driver.c | 1355 ++++++++---------------------------------
src/qemu/qemu_command.c | 30 +-
src/security/virt-aa-helper.c | 2 +-
src/util/sexpr.c | 4 +-
src/xen/xend_internal.c | 6 +-
src/xenxs/xen_sxpr.c | 2 +-
src/xenxs/xen_xm.c | 4 +-
8 files changed, 290 insertions(+), 1129 deletions(-)
--
1.7.4.2
2
25
So far first entries for each hash key are stored directly in the hash
table while other entries mapped to the same key are linked through
pointers. As a result of that, the code is cluttered with special
handling for the first items.
Commit 9677cd33eea4c65d78ba463b46b8b45ed2da1709 made it possible to
remove current entry when iterating through all hash entries. However,
it didn't add the special first item handling which could cause libvirtd
crash or hang.
Instead of adding more clutter, this patch fixes the crash by linking
all entries (even the first ones) through pointers which significantly
simplifies the code and makes it more maintainable.
---
src/util/hash.c | 290 ++++++++++++++++++-------------------------------------
1 files changed, 94 insertions(+), 196 deletions(-)
diff --git a/src/util/hash.c b/src/util/hash.c
index 48a94ad..dbb34ec 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -50,14 +50,13 @@ struct _virHashEntry {
struct _virHashEntry *next;
void *name;
void *payload;
- int valid;
};
/*
* The entire hash table
*/
struct _virHashTable {
- struct _virHashEntry *table;
+ virHashEntryPtr *table;
int size;
int nbElems;
/* True iff we are iterating over hash entries. */
@@ -165,7 +164,7 @@ virHashTablePtr virHashCreateFull(int size,
*
* Create a new virHashTablePtr.
*
- * Returns the newly created object, or NULL if an error occured.
+ * Returns the newly created object, or NULL if an error occurred.
*/
virHashTablePtr virHashCreate(int size, virHashDataFree dataFree)
{
@@ -189,10 +188,8 @@ virHashTablePtr virHashCreate(int size, virHashDataFree dataFree)
static int
virHashGrow(virHashTablePtr table, int size)
{
- unsigned long key;
int oldsize, i;
- virHashEntryPtr iter, next;
- struct _virHashEntry *oldtable;
+ virHashEntryPtr *oldtable;
#ifdef DEBUG_GROW
unsigned long nbElem = 0;
@@ -217,43 +214,18 @@ virHashGrow(virHashTablePtr table, int size)
}
table->size = size;
- /* If the two loops are merged, there would be situations where
- * a new entry needs to allocated and data copied into it from
- * the main table. So instead, we run through the array twice, first
- * copying all the elements in the main array (where we can't get
- * conflicts) and then the rest, so we only free (and don't allocate)
- */
- for (i = 0; i < oldsize; i++) {
- if (oldtable[i].valid == 0)
- continue;
- key = virHashComputeKey(table, oldtable[i].name);
- memcpy(&(table->table[key]), &(oldtable[i]), sizeof(virHashEntry));
- table->table[key].next = NULL;
- }
-
for (i = 0; i < oldsize; i++) {
- iter = oldtable[i].next;
+ virHashEntryPtr iter = oldtable[i];
while (iter) {
- next = iter->next;
+ virHashEntryPtr next = iter->next;
+ unsigned long key = virHashComputeKey(table, iter->name);
- /*
- * put back the entry in the new table
- */
-
- key = virHashComputeKey(table, iter->name);
- if (table->table[key].valid == 0) {
- memcpy(&(table->table[key]), iter, sizeof(virHashEntry));
- table->table[key].next = NULL;
- VIR_FREE(iter);
- } else {
- iter->next = table->table[key].next;
- table->table[key].next = iter;
- }
+ iter->next = table->table[key];
+ table->table[key] = iter;
#ifdef DEBUG_GROW
nbElem++;
#endif
-
iter = next;
}
}
@@ -279,36 +251,24 @@ void
virHashFree(virHashTablePtr table)
{
int i;
- virHashEntryPtr iter;
- virHashEntryPtr next;
- int inside_table = 0;
- int nbElems;
if (table == NULL)
return;
- if (table->table) {
- nbElems = table->nbElems;
- for (i = 0; (i < table->size) && (nbElems > 0); i++) {
- iter = &(table->table[i]);
- if (iter->valid == 0)
- continue;
- inside_table = 1;
- while (iter) {
- next = iter->next;
- if ((table->dataFree != NULL) && (iter->payload != NULL))
- table->dataFree(iter->payload, iter->name);
- if (table->keyFree)
- table->keyFree(iter->name);
- iter->payload = NULL;
- if (!inside_table)
- VIR_FREE(iter);
- nbElems--;
- inside_table = 0;
- iter = next;
- }
+
+ for (i = 0; i < table->size; i++) {
+ virHashEntryPtr iter = table->table[i];
+ while (iter) {
+ virHashEntryPtr next = iter->next;
+
+ if (table->dataFree)
+ table->dataFree(iter->payload, iter->name);
+ if (table->keyFree)
+ table->keyFree(iter->name);
+ VIR_FREE(iter);
+ iter = next;
}
- VIR_FREE(table->table);
}
+
VIR_FREE(table);
}
@@ -319,9 +279,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
{
unsigned long key, len = 0;
virHashEntryPtr entry;
- virHashEntryPtr insert;
char *new_name;
- bool found;
if ((table == NULL) || (name == NULL))
return (-1);
@@ -329,67 +287,40 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
if (table->iterating)
virHashIterationError(-1);
- /*
- * Check for duplicate and insertion location.
- */
- found = false;
key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0) {
- insert = NULL;
- } else {
- for (insert = &(table->table[key]); insert->next != NULL;
- insert = insert->next) {
- if (table->keyEqual(insert->name, name)) {
- found = true;
- break;
- }
- len++;
- }
- if (table->keyEqual(insert->name, name))
- found = true;
- }
-
- if (found) {
- if (is_update) {
- if (table->dataFree)
- table->dataFree(insert->payload, insert->name);
- insert->payload = userdata;
- return (0);
- } else {
- return (-1);
- }
- }
- if (insert == NULL) {
- entry = &(table->table[key]);
- } else {
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
- return (-1);
+ /* Check for duplicate entry */
+ for (entry = table->table[key]; entry; entry = entry->next) {
+ if (table->keyEqual(entry->name, name)) {
+ if (is_update) {
+ if (table->dataFree)
+ table->dataFree(entry->payload, entry->name);
+ entry->payload = userdata;
+ return 0;
+ } else {
+ return -1;
+ }
}
+ len++;
}
- new_name = table->keyCopy(name);
- if (new_name == NULL) {
+ if (VIR_ALLOC(entry) < 0 || !(new_name = table->keyCopy(name))) {
virReportOOMError();
- if (insert != NULL)
- VIR_FREE(entry);
- return (-1);
+ VIR_FREE(entry);
+ return -1;
}
+
entry->name = new_name;
entry->payload = userdata;
- entry->next = NULL;
- entry->valid = 1;
-
- if (insert != NULL)
- insert->next = entry;
+ entry->next = table->table[key];
+ table->table[key] = entry;
table->nbElems++;
if (len > MAX_HASH_LEN)
virHashGrow(table, MAX_HASH_LEN * table->size);
- return (0);
+ return 0;
}
/**
@@ -443,18 +374,15 @@ virHashLookup(virHashTablePtr table, const void *name)
unsigned long key;
virHashEntryPtr entry;
- if (table == NULL)
- return (NULL);
- if (name == NULL)
- return (NULL);
+ if (!table || !name)
+ return NULL;
+
key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0)
- return (NULL);
- for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
+ for (entry = table->table[key]; entry; entry = entry->next) {
if (table->keyEqual(entry->name, name))
- return (entry->payload);
+ return entry->payload;
}
- return (NULL);
+ return NULL;
}
@@ -512,47 +440,31 @@ virHashSize(virHashTablePtr table)
int
virHashRemoveEntry(virHashTablePtr table, const void *name)
{
- unsigned long key;
virHashEntryPtr entry;
- virHashEntryPtr prev = NULL;
+ virHashEntryPtr *nextptr;
if (table == NULL || name == NULL)
return (-1);
- key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0) {
- return (-1);
- } else {
- for (entry = &(table->table[key]); entry != NULL;
- entry = entry->next) {
- if (table->keyEqual(entry->name, name)) {
- if (table->iterating && table->current != entry)
- virHashIterationError(-1);
- if (table->dataFree && (entry->payload != NULL))
- table->dataFree(entry->payload, entry->name);
- entry->payload = NULL;
- if (table->keyFree)
- table->keyFree(entry->name);
- if (prev) {
- prev->next = entry->next;
- VIR_FREE(entry);
- } else {
- if (entry->next == NULL) {
- entry->valid = 0;
- } else {
- entry = entry->next;
- memcpy(&(table->table[key]), entry,
- sizeof(virHashEntry));
- VIR_FREE(entry);
- }
- }
- table->nbElems--;
- return (0);
- }
- prev = entry;
+ nextptr = table->table + virHashComputeKey(table, name);
+ for (entry = *nextptr; entry; entry = entry->next) {
+ if (table->keyEqual(entry->name, name)) {
+ if (table->iterating && table->current != entry)
+ virHashIterationError(-1);
+
+ if (table->dataFree)
+ table->dataFree(entry->payload, entry->name);
+ if (table->keyFree)
+ table->keyFree(entry->name);
+ *nextptr = entry->next;
+ VIR_FREE(entry);
+ table->nbElems--;
+ return 0;
}
- return (-1);
+ nextptr = &entry->next;
}
+
+ return -1;
}
@@ -581,15 +493,15 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr entry = table->table + i;
+ virHashEntryPtr entry = table->table[i];
while (entry) {
virHashEntryPtr next = entry->next;
- if (entry->valid) {
- table->current = entry;
- iter(entry->payload, entry->name, data);
- table->current = NULL;
- count++;
- }
+
+ table->current = entry;
+ iter(entry->payload, entry->name, data);
+ table->current = NULL;
+
+ count++;
entry = next;
}
}
@@ -612,7 +524,10 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
*
* Returns number of items removed on success, -1 on failure
*/
-int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data) {
+int virHashRemoveSet(virHashTablePtr table,
+ virHashSearcher iter,
+ const void *data)
+{
int i, count = 0;
if (table == NULL || iter == NULL)
@@ -624,44 +539,27 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr prev = NULL;
- virHashEntryPtr entry = &(table->table[i]);
+ virHashEntryPtr *nextptr = table->table + i;
- while (entry && entry->valid) {
- if (iter(entry->payload, entry->name, data)) {
+ while (*nextptr) {
+ virHashEntryPtr entry = *nextptr;
+ if (!iter(entry->payload, entry->name, data)) {
+ *nextptr = entry->next;
+ } else {
count++;
if (table->dataFree)
table->dataFree(entry->payload, entry->name);
if (table->keyFree)
table->keyFree(entry->name);
+ *nextptr = entry->next;
+ VIR_FREE(entry);
table->nbElems--;
- if (prev) {
- prev->next = entry->next;
- VIR_FREE(entry);
- entry = prev;
- } else {
- if (entry->next == NULL) {
- entry->valid = 0;
- entry->name = NULL;
- } else {
- entry = entry->next;
- memcpy(&(table->table[i]), entry,
- sizeof(virHashEntry));
- VIR_FREE(entry);
- entry = &(table->table[i]);
- continue;
- }
- }
- }
- prev = entry;
- if (entry) {
- entry = entry->next;
}
}
}
table->iterating = false;
- return (count);
+ return count;
}
/**
@@ -675,7 +573,10 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
* returns non-zero will be returned by this function.
* The elements are processed in a undefined order
*/
-void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data) {
+void *virHashSearch(virHashTablePtr table,
+ virHashSearcher iter,
+ const void *data)
+{
int i;
if (table == NULL || iter == NULL)
@@ -687,18 +588,15 @@ void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *dat
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr entry = table->table + i;
- while (entry) {
- if (entry->valid) {
- if (iter(entry->payload, entry->name, data)) {
- table->iterating = false;
- return entry->payload;
- }
+ virHashEntryPtr entry;
+ for (entry = table->table[i]; entry; entry = entry->next) {
+ if (iter(entry->payload, entry->name, data)) {
+ table->iterating = false;
+ return entry->payload;
}
- entry = entry->next;
}
}
table->iterating = false;
- return (NULL);
+ return NULL;
}
--
1.7.5.rc1
3
8
What's a good way to ask if a libvirt connection is remote or not?
(Fundamentally I want to know if the disk images are openable as local
files, and I'm using "remote" as an proxy for this property.)
One way might be to compare virConnectGetHostname with the local
hostname. This would fail if the client and server had the hostname
set incorrectly (eg. "localhost.localdomain").
Another way might be some hairy libvirt URL parsing.
Another way would be to speculatively open the disk images. This
would fail if the client and server had guests with coincidentally
named disk images.
Or I could write a qemu block driver that could use
virDomainBlockPeek.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
2
1
[libvirt] [PATCH] Merge all returns paths from dispatcher into single path
by Daniel P. Berrange 18 Apr '11
by Daniel P. Berrange 18 Apr '11
18 Apr '11
The dispatcher functions have numerous places where they
return to the caller. This leads to duplicated cleanup
code, often resulting in memory leaks. It makes it harder
to ensure that errors are dispatched before freeing objects,
which may overwrite the original error.
The standard pattern is now
remoteDispatchXXX(...) {
int rv = -1;
....
if (XXX < 0)
goto cleanup;
...
if (XXXX < 0)
goto cleanup;
...
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
...free all other stuff..
return rv;
}
* daemon/remote.c: Centralize all cleanup paths
* daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
* daemon/dispatch.c, daemon/dispatch.h: Replace
remoteDispatchConnError with remoteDispatchError
removing unused virConnectPtr
NB this was a tedious manual conversion of the code, so it
has potential for errors....
---
daemon/dispatch.c | 3 +-
daemon/dispatch.h | 3 +-
daemon/remote.c | 4862 ++++++++++++++++++++++++++++++++---------------------
daemon/stream.c | 6 +-
4 files changed, 2912 insertions(+), 1962 deletions(-)
diff --git a/daemon/dispatch.c b/daemon/dispatch.c
index 4814017..7453451 100644
--- a/daemon/dispatch.c
+++ b/daemon/dispatch.c
@@ -112,8 +112,7 @@ void remoteDispatchOOMError (remote_error *rerr)
}
-void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn ATTRIBUTE_UNUSED)
+void remoteDispatchError(remote_error *rerr)
{
virErrorPtr verr = virGetLastError();
diff --git a/daemon/dispatch.h b/daemon/dispatch.h
index 85f8fc3..79d35ac 100644
--- a/daemon/dispatch.h
+++ b/daemon/dispatch.h
@@ -46,8 +46,7 @@ void remoteDispatchFormatError (remote_error *rerr,
void remoteDispatchAuthError (remote_error *rerr);
void remoteDispatchGenericError (remote_error *rerr);
void remoteDispatchOOMError (remote_error *rerr);
-void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn);
+void remoteDispatchError(remote_error *rerr);
int
diff --git a/daemon/remote.c b/daemon/remote.c
index 5de1055..8f4d6a6 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -64,6 +64,10 @@
#define VIR_FROM_THIS VIR_FROM_REMOTE
+#define virNetError(code, ...) \
+ virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
+
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
static virInterfacePtr get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface);
@@ -398,18 +402,18 @@ remoteDispatchOpen(struct qemud_server *server,
struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
{
const char *name;
- int flags, rc;
-
- /* Already opened? */
- if (conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection already open"));
- return -1;
- }
+ int flags;
+ int rv = -1;
virMutexLock(&server->lock);
virMutexLock(&client->lock);
virMutexUnlock(&server->lock);
+ if (conn) {
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection already open"));
+ goto cleanup;
+ }
+
name = args->name ? *args->name : NULL;
/* If this connection arrived on a readonly socket, force
@@ -423,12 +427,17 @@ remoteDispatchOpen(struct qemud_server *server,
? virConnectOpenReadOnly(name)
: virConnectOpen(name);
- if (client->conn == NULL)
- remoteDispatchConnError(rerr, NULL);
+ if (client->conn == NULL) {
+ goto cleanup;
+ }
+
+ rv = 0;
- rc = client->conn ? 0 : -1;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
virMutexUnlock(&client->lock);
- return rc;
+ return rv;
}
@@ -458,20 +467,25 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_error *rerr,
remote_supports_feature_args *args, remote_supports_feature_ret *ret)
{
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->supported = virDrvSupportsFeature(conn, args->feature);
if (ret->supported == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -483,16 +497,16 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
{
const char *type;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
type = virConnectGetType(conn);
if (type == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* We have to strdup because remoteDispatchClientRequest will
@@ -500,11 +514,16 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->type = strdup(type);
if (!ret->type) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -517,19 +536,24 @@ remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_version_ret *ret)
{
unsigned long hvVer;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virConnectGetVersion(conn, &hvVer) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->hv_ver = hvVer;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -542,19 +566,24 @@ remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_lib_version_ret *ret)
{
unsigned long libVer;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virConnectGetLibVersion(conn, &libVer) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->lib_ver = libVer;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -567,20 +596,25 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_hostname_ret *ret)
{
char *hostname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
hostname = virConnectGetHostname(conn);
if (hostname == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->hostname = hostname;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -593,20 +627,25 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_uri_ret *ret)
{
char *uri;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri = virConnectGetURI(conn);
if (uri == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->uri = uri;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -620,21 +659,26 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
{
unsigned int flags;
char *sysinfo;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
flags = args->flags;
sysinfo = virConnectGetSysinfo(conn, flags);
if (sysinfo == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->sysinfo = sysinfo;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -647,20 +691,25 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_max_vcpus_ret *ret)
{
char *type;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
type = args->type ? *args->type : NULL;
ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
if (ret->max_vcpus == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -673,15 +722,15 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_info_ret *ret)
{
virNodeInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virNodeGetInfo(conn, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
memcpy(ret->model, info.model, sizeof ret->model);
@@ -693,7 +742,12 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->cores = info.cores;
ret->threads = info.threads;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -706,20 +760,25 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_capabilities_ret *ret)
{
char *caps;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
caps = virConnectGetCapabilities(conn);
if (caps == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->capabilities = caps;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -732,22 +791,23 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_get_cells_free_memory_ret *ret)
{
int err;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->freeMems.freeMems_val, args->maxCells) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
err = virNodeGetCellsFreeMemory(conn,
@@ -755,13 +815,18 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
args->startCell,
args->maxCells);
if (err <= 0) {
- VIR_FREE(ret->freeMems.freeMems_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->freeMems.freeMems_len = err;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->freeMems.freeMems_val);
+ }
+ return rv;
}
@@ -775,19 +840,24 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_free_memory_ret *ret)
{
unsigned long long freeMem;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
freeMem = virNodeGetFreeMemory(conn);
if (freeMem == 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->freeMem = freeMem;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -800,32 +870,36 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_scheduler_type_args *args,
remote_domain_get_scheduler_type_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *type;
int nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
type = virDomainGetSchedulerType(dom, &nparams);
if (type == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->type = type;
ret->nparams = nparams;
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -837,51 +911,47 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_get_scheduler_parameters_args *args,
remote_domain_get_scheduler_parameters_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virSchedParameterPtr params;
int i, r, nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetSchedulerParameters(dom, params, &nparams);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* Serialise the scheduler parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -898,23 +968,27 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
ret->params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- virDomainFree(dom);
- VIR_FREE(params);
- return 0;
+ rv = 0;
-oom:
- remoteDispatchOOMError(rerr);
cleanup:
- virDomainFree(dom);
- for (i = 0 ; i < nparams ; i++)
- VIR_FREE(ret->params.params_val[i].field);
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0 ; i < nparams ; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -926,32 +1000,33 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_set_scheduler_parameters_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virSchedParameterPtr params;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr, _("Field %s too big for destination"),
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
args->params.params_val[i].field);
- return -1;
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -972,21 +1047,23 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetSchedulerParameters(dom, params, nparams);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(params);
+ return rv;
}
static int
@@ -998,28 +1075,25 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_block_stats_args *args,
remote_domain_block_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
struct _virDomainBlockStats stats;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
if (virDomainBlockStats(dom, path, &stats, sizeof stats) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
ret->rd_req = stats.rd_req;
ret->rd_bytes = stats.rd_bytes;
@@ -1027,7 +1101,14 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->wr_bytes = stats.wr_bytes;
ret->errs = stats.errs;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1039,28 +1120,25 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_interface_stats_args *args,
remote_domain_interface_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
struct _virDomainInterfaceStats stats;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
ret->rx_bytes = stats.rx_bytes;
ret->rx_packets = stats.rx_packets;
@@ -1071,7 +1149,14 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->tx_errs = stats.tx_errs;
ret->tx_drop = stats.tx_drop;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1083,48 +1168,42 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_memory_stats_args *args,
remote_domain_memory_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
struct _virDomainMemoryStat *stats;
unsigned int nr_stats, i;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate stats array for making dispatch call */
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
if (nr_stats == -1) {
- VIR_FREE(stats);
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
/* Allocate return buffer */
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
- VIR_FREE(stats);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Copy the stats into the xdr return structure */
@@ -1133,8 +1212,15 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->stats.stats_val[i].val = stats[i].val;
}
ret->stats.stats_len = nr_stats;
- VIR_FREE(stats);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(stats);
+ return rv;
}
static int
@@ -1146,21 +1232,21 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_block_peek_args *args,
remote_domain_block_peek_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
unsigned long long offset;
size_t size;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
offset = args->offset;
@@ -1168,29 +1254,32 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags;
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr,
- "%s", _("size > maximum buffer size"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("size > maximum buffer size"));
+ goto cleanup;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainBlockPeek(dom, path, offset, size,
ret->buffer.buffer_val, flags) == -1) {
- /* free(ret->buffer.buffer_val); - caller frees */
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->buffer.buffer_val);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1202,49 +1291,54 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_memory_peek_args *args,
remote_domain_memory_peek_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
unsigned long long offset;
size_t size;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
offset = args->offset;
size = args->size;
flags = args->flags;
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr,
- "%s", _("size > maximum buffer size"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("size > maximum buffer size"));
+ goto cleanup;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainMemoryPeek(dom, offset, size,
ret->buffer.buffer_val, flags) == -1) {
- /* free(ret->buffer.buffer_val); - caller frees */
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ if (dom)
+ virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->buffer.buffer_val);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1256,26 +1350,31 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_attach_device_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAttachDevice(dom, args->xml) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1287,26 +1386,31 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_attach_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1318,26 +1422,31 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_update_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1349,26 +1458,31 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCreate(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1380,23 +1494,28 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_create_with_flags_args *args,
remote_domain_create_with_flags_ret *ret)
{
- virDomainPtr dom;
+ int rv = -1;
+ virDomainPtr dom = NULL;
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCreateWithFlags(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1408,23 +1527,29 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_create_xml_args *args,
remote_domain_create_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1436,23 +1561,29 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_define_xml_args *args,
remote_domain_define_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainDefineXML(conn, args->xml);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1464,26 +1595,31 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDestroy(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1495,27 +1631,31 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_detach_device_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDetachDevice(dom, args->xml) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1527,27 +1667,31 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_detach_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1559,28 +1703,33 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_dump_xml_args *args,
remote_domain_dump_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virDomainGetXMLDesc(dom, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1592,9 +1741,11 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_from_native_args *args,
remote_domain_xml_from_native_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
@@ -1603,10 +1754,14 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->nativeConfig,
args->flags);
if (!ret->domainXml) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -1618,9 +1773,11 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_to_native_args *args,
remote_domain_xml_to_native_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
@@ -1629,10 +1786,14 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->domainXml,
args->flags);
if (!ret->nativeConfig) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -1645,26 +1806,31 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_autostart_args *args,
remote_domain_get_autostart_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetAutostart(dom, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1676,24 +1842,22 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_info_args *args,
remote_domain_get_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetInfo(dom, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->state = info.state;
@@ -1702,9 +1866,14 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->nr_virt_cpu = info.nrVirtCpu;
ret->cpu_time = info.cpuTime;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1716,27 +1885,32 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_max_memory_args *args,
remote_domain_get_max_memory_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->memory = virDomainGetMaxMemory(dom);
if (ret->memory == 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1748,27 +1922,32 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_max_vcpus_args *args,
remote_domain_get_max_vcpus_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainGetMaxVcpus(dom);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1780,46 +1959,46 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_security_label_args *args,
remote_domain_get_security_label_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virSecurityLabelPtr seclabel;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (VIR_ALLOC(seclabel) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return -1;
+ goto cleanup;
}
ret->label.label_len = strlen(seclabel->label) + 1;
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
- virDomainFree(dom);
- VIR_FREE(seclabel);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->label.label_val, seclabel->label);
ret->enforcing = seclabel->enforcing;
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(seclabel);
+ return rv;
}
static int
@@ -1832,33 +2011,38 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_security_model_ret *ret)
{
virSecurityModel secmodel;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
memset(&secmodel, 0, sizeof secmodel);
if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->model.model_len = strlen(secmodel.model) + 1;
if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->model.model_val, secmodel.model);
ret->doi.doi_len = strlen(secmodel.doi) + 1;
if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->doi.doi_val, secmodel.doi);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -1870,28 +2054,32 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_os_type_args *args,
remote_domain_get_os_type_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this */
ret->type = virDomainGetOSType(dom);
if (ret->type == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1907,52 +2095,46 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
virVcpuInfoPtr info = NULL;
unsigned char *cpumaps = NULL;
int info_len, i;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
+ goto cleanup;
}
if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+ goto cleanup;
}
/* Allocate buffers to take the results. */
if (VIR_ALLOC_N(info, args->maxinfo) < 0)
- goto oom;
+ goto no_memory;
if (args->maplen > 0 &&
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
- goto oom;
+ goto no_memory;
info_len = virDomainGetVcpus(dom,
info, args->maxinfo,
cpumaps, args->maplen);
if (info_len == -1) {
- remoteDispatchConnError(rerr, conn);
- VIR_FREE(info);
- VIR_FREE(cpumaps);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
/* Allocate the return buffer for info. */
ret->info.info_len = info_len;
if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < info_len; ++i) {
ret->info.info_val[i].number = info[i].number;
@@ -1967,17 +2149,24 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
ret->cpumaps.cpumaps_val = (char *) cpumaps;
+ cpumaps = NULL;
+
+ rv = 0;
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->info.info_val);
+ }
+ VIR_FREE(cpumaps);
VIR_FREE(info);
- virDomainFree(dom);
- return 0;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
-oom:
- VIR_FREE(info);
- VIR_FREE(cpumaps);
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -1989,27 +2178,32 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_vcpus_flags_args *args,
remote_domain_get_vcpus_flags_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainGetVcpusFlags(dom, args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2027,10 +2221,11 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
char *uri_in;
char **uri_out;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
@@ -2038,17 +2233,15 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource);
if (r == -1) {
- VIR_FREE(uri_out);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2058,12 +2251,18 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->cookie.cookie_val = cookie;
if (*uri_out == NULL) {
ret->uri_out = NULL;
- VIR_FREE(uri_out);
} else {
ret->uri_out = uri_out;
+ uri_out = NULL;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(uri_out);
+ return rv;
}
static int
@@ -2076,18 +2275,18 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
int r;
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2098,13 +2297,17 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags, dname, args->resource);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2116,11 +2319,12 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish_args *args,
remote_domain_migrate_finish_ret *ret)
{
- virDomainPtr ddom;
+ virDomainPtr ddom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ddom = virDomainMigrateFinish(conn, args->dname,
@@ -2129,13 +2333,18 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags);
if (ddom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->ddom, ddom);
- virDomainFree(ddom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (ddom)
+ virDomainFree(ddom);
+ return rv;
}
static int
@@ -2153,10 +2362,11 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
char *uri_in;
char **uri_out;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
@@ -2164,8 +2374,8 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
@@ -2173,8 +2383,7 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2184,7 +2393,12 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
ret->cookie.cookie_val = cookie;
ret->uri_out = *uri_out == NULL ? NULL : uri_out;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2196,11 +2410,12 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish2_args *args,
remote_domain_migrate_finish2_ret *ret)
{
- virDomainPtr ddom;
+ virDomainPtr ddom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ddom = virDomainMigrateFinish2(conn, args->dname,
@@ -2210,14 +2425,19 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
args->flags,
args->retcode);
if (ddom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->ddom, ddom);
- virDomainFree(ddom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (ddom)
+ virDomainFree(ddom);
+ return rv;
}
static int
@@ -2231,38 +2451,44 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
{
int r;
char *dname;
- struct qemud_client_stream *stream;
+ struct qemud_client_stream *stream = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dname = args->dname == NULL ? NULL : *args->dname;
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepareTunnel(conn, stream->st,
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
if (remoteAddClientStream(client, stream, 0) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ if (stream) {
+ virStreamAbort(stream->st);
+ remoteFreeClientStream(client, stream);
+ }
+ }
+ return rv;
}
static int
@@ -2274,33 +2500,40 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_domains_args *args,
remote_list_defined_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedDomains(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -2312,22 +2545,29 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_id_args *args,
remote_domain_lookup_by_id_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByID(conn, args->id);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2339,22 +2579,29 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_name_args *args,
remote_domain_lookup_by_name_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByName(conn, args->name);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2366,22 +2613,29 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_uuid_args *args,
remote_domain_lookup_by_uuid_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2393,18 +2647,24 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedDomains(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2416,36 +2676,39 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_pin_vcpu_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
- int rv;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
+ goto cleanup;
}
rv = virDomainPinVcpu(dom, args->vcpu,
(unsigned char *) args->cpumap.cpumap_val,
args->cpumap.cpumap_len);
if (rv == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2457,26 +2720,31 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_reboot_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainReboot(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2488,17 +2756,23 @@ remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_restore_args *args,
void *ret ATTRIBUTE_UNUSED)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virDomainRestore(conn, args->from) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2510,26 +2784,31 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_resume_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainResume(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2541,26 +2820,31 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_save_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSave(dom, args->to) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2572,26 +2856,31 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_core_dump_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCoreDump(dom, args->to, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2603,26 +2892,31 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetAutostart(dom, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2634,26 +2928,31 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_max_memory_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMaxMemory(dom, args->memory) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2665,26 +2964,31 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_memory_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMemory(dom, args->memory) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2696,26 +3000,31 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_memory_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMemoryFlags(dom, args->memory, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2730,37 +3039,37 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
remote_domain_set_memory_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virMemoryParameterPtr params;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -2799,21 +3108,23 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(params);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2830,41 +3141,37 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
remote_domain_get_memory_parameters_ret
* ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virMemoryParameterPtr params;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -2877,13 +3184,13 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
/* Serialise the memory parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -2918,25 +3225,27 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
params[i].value.b;
break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- success:
- virDomainFree(dom);
- VIR_FREE(params);
-
- return 0;
+success:
+ rv = 0;
- oom:
- remoteDispatchOOMError(rerr);
- cleanup:
- virDomainFree(dom);
- for (i = 0; i < nparams; i++)
- VIR_FREE(ret->params.params_val[i].field);
+no_memory:
+ virReportOOMError();
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
}
static int
@@ -2951,37 +3260,37 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
remote_domain_set_blkio_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virBlkioParameterPtr params;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -3020,21 +3329,23 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(params);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3051,41 +3362,37 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
remote_domain_get_blkio_parameters_ret
* ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virBlkioParameterPtr params;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -3098,13 +3405,13 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
/* Serialise the blkio parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
// remoteDispatchClientRequest will free this:
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -3139,25 +3446,29 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
params[i].value.b;
break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- success:
- virDomainFree(dom);
- VIR_FREE(params);
-
- return 0;
+success:
+ rv = 0;
- oom:
- remoteDispatchOOMError(rerr);
- cleanup:
- virDomainFree(dom);
- for (i = 0; i < nparams; i++)
- VIR_FREE(ret->params.params_val[i].field);
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
VIR_FREE(params);
- return -1;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -3169,26 +3480,31 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_vcpus_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetVcpus(dom, args->nvcpus) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3200,26 +3516,31 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_vcpus_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3231,26 +3552,31 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_shutdown_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainShutdown(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3262,26 +3588,31 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_suspend_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSuspend(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3293,26 +3624,31 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainUndefine(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3324,33 +3660,40 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_networks_args *args,
remote_list_defined_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedNetworks(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -3362,32 +3705,39 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_domains_args *args,
remote_list_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->ids.ids_val, args->maxids) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->ids.ids_len = virConnectListDomains(conn,
ret->ids.ids_val, args->maxids);
if (ret->ids.ids_len == -1) {
- VIR_FREE(ret->ids.ids_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->ids.ids_val);
+ }
+ return rv;
}
static int
@@ -3399,26 +3749,31 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_managed_save_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainManagedSave(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3430,27 +3785,32 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
remote_domain_has_managed_save_image_args *args,
remote_domain_has_managed_save_image_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
if (ret->ret == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3462,26 +3822,31 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_managed_save_remove_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainManagedSaveRemove(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3493,33 +3858,40 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_networks_args *args,
remote_list_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListNetworks(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -3531,26 +3903,31 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkCreate(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3562,22 +3939,29 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_create_xml_args *args,
remote_network_create_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkCreateXML(conn, args->xml);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3589,22 +3973,29 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_define_xml_args *args,
remote_network_define_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkDefineXML(conn, args->xml);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3616,26 +4007,31 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkDestroy(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3647,28 +4043,33 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_dump_xml_args *args,
remote_network_dump_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNetworkGetXMLDesc(net, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3680,26 +4081,31 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_get_autostart_args *args,
remote_network_get_autostart_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkGetAutostart(net, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3711,28 +4117,33 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_get_bridge_name_args *args,
remote_network_get_bridge_name_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->name = virNetworkGetBridgeName(net);
if (!ret->name) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3744,22 +4155,29 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_lookup_by_name_args *args,
remote_network_lookup_by_name_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkLookupByName(conn, args->name);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3771,22 +4189,29 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_lookup_by_uuid_args *args,
remote_network_lookup_by_uuid_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3798,26 +4223,31 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkSetAutostart(net, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3829,26 +4259,31 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkUndefine(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3860,18 +4295,24 @@ remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedNetworks(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3883,18 +4324,24 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDomains(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3906,18 +4353,24 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfNetworks(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -3931,18 +4384,24 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfInterfaces(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3954,33 +4413,40 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_interfaces_args *args,
remote_list_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListInterfaces(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -3992,18 +4458,24 @@ remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedInterfaces(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -4015,33 +4487,40 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
remote_list_defined_interfaces_args *args,
remote_list_defined_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedInterfaces(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -4053,22 +4532,29 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
remote_interface_lookup_by_name_args *args,
remote_interface_lookup_by_name_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceLookupByName(conn, args->name);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4080,22 +4566,29 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
remote_interface_lookup_by_mac_string_args *args,
remote_interface_lookup_by_mac_string_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceLookupByMACString(conn, args->mac);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4107,28 +4600,33 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_get_xml_desc_args *args,
remote_interface_get_xml_desc_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4140,22 +4638,29 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_define_xml_args *args,
remote_interface_define_xml_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceDefineXML(conn, args->xml, args->flags);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4167,26 +4672,31 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceUndefine(iface) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4198,26 +4708,31 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceCreate(iface, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4229,26 +4744,31 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceDestroy(iface, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
/*-------------------------------------------------------------*/
@@ -4262,10 +4782,12 @@ remoteDispatchAuthList(struct qemud_server *server,
void *args ATTRIBUTE_UNUSED,
remote_auth_list_ret *ret)
{
+ int rv = -1;
+
ret->types.types_len = 1;
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
virMutexLock(&server->lock);
virMutexLock(&client->lock);
@@ -4273,7 +4795,12 @@ remoteDispatchAuthList(struct qemud_server *server,
ret->types.types_val[0] = client->auth;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -4287,7 +4814,7 @@ remoteDispatchAuthList(struct qemud_server *server,
static int
remoteDispatchAuthSaslInit(struct qemud_server *server,
struct qemud_client *client,
- virConnectPtr conn,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
remote_message_header *hdr ATTRIBUTE_UNUSED,
remote_error *rerr,
void *args ATTRIBUTE_UNUSED,
@@ -4314,13 +4841,12 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
sa.len = sizeof(sa.data.stor);
if (getsockname(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr,
- _("failed to get sock address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to get sock address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4328,14 +4854,13 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
sa.len = sizeof(sa.data.stor);
if (getpeername(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("failed to get peer address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
VIR_FREE(localAddr);
goto error;
}
if ((remoteAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
VIR_FREE(localAddr);
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4439,7 +4964,7 @@ authfail:
error:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
virMutexUnlock(&client->lock);
- return -1;
+ goto error;
}
@@ -4600,7 +5125,7 @@ remoteDispatchAuthSaslStart(struct qemud_server *server,
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4701,7 +5226,7 @@ remoteDispatchAuthSaslStep(struct qemud_server *server,
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4878,7 +5403,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
client->auth = REMOTE_AUTH_NONE;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
authfail:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
@@ -5010,7 +5535,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
client->auth = REMOTE_AUTH_NONE;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
authfail:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
@@ -5059,33 +5584,40 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
remote_list_defined_storage_pools_args *args,
remote_list_defined_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedStoragePools(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -5097,33 +5629,40 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_storage_pools_args *args,
remote_list_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListStoragePools(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -5135,9 +5674,11 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
remote_find_storage_pool_sources_args *args,
remote_find_storage_pool_sources_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->xml =
@@ -5146,11 +5687,15 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
args->srcSpec ? *args->srcSpec : NULL,
args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -5163,26 +5708,31 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolCreate(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5194,22 +5744,29 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_create_xml_args *args,
remote_storage_pool_create_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5221,22 +5778,29 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_define_xml_args *args,
remote_storage_pool_define_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5248,26 +5812,31 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_build_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolBuild(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5280,26 +5849,31 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolDestroy(pool) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5311,26 +5885,31 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolDelete(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5342,26 +5921,31 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_refresh_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolRefresh(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5373,24 +5957,22 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_get_info_args *args,
remote_storage_pool_get_info_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
virStoragePoolInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolGetInfo(pool, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
ret->state = info.state;
@@ -5398,9 +5980,14 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->allocation = info.allocation;
ret->available = info.available;
- virStoragePoolFree(pool);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5412,28 +5999,33 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_dump_xml_args *args,
remote_storage_pool_dump_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5445,26 +6037,31 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_get_autostart_args *args,
remote_storage_pool_get_autostart_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolGetAutostart(pool, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5477,22 +6074,29 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_lookup_by_name_args *args,
remote_storage_pool_lookup_by_name_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolLookupByName(conn, args->name);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5504,22 +6108,29 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_lookup_by_uuid_args *args,
remote_storage_pool_lookup_by_uuid_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5531,31 +6142,37 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
remote_storage_pool_lookup_by_volume_args *args,
remote_storage_pool_lookup_by_volume_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
pool = virStoragePoolLookupByVolume(vol);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5567,26 +6184,31 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolSetAutostart(pool, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5598,26 +6220,31 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolUndefine(pool) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5629,18 +6256,24 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfStoragePools(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -5652,18 +6285,24 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedStoragePools(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -5675,44 +6314,48 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_pool_list_volumes_args *args,
remote_storage_pool_list_volumes_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- virStoragePoolFree(pool);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virStoragePoolListVolumes(pool,
ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ if (ret->names.names_len == -1) {
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5725,28 +6368,32 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_num_of_volumes_args *args,
remote_storage_pool_num_of_volumes_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virStoragePoolNumOfVolumes(pool);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5765,31 +6412,36 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_create_xml_args *args,
remote_storage_vol_create_xml_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
vol = virStorageVolCreateXML(pool, args->xml, args->flags);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5801,41 +6453,45 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_vol_create_xml_from_args *args,
remote_storage_vol_create_xml_from_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr clonevol, newvol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr clonevol = NULL;
+ virStorageVolPtr newvol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
clonevol = get_nonnull_storage_vol(conn, args->clonevol);
if (clonevol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
args->flags);
if (newvol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, newvol);
- virStorageVolFree(newvol);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (newvol)
+ virStorageVolFree(newvol);
+ if (clonevol)
+ virStorageVolFree(clonevol);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5847,26 +6503,31 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStorageVolDelete(vol, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5878,32 +6539,31 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_wipe_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int retval = -1;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- goto out;
+ goto cleanup;
}
if (virStorageVolWipe(vol, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- goto out;
+ goto cleanup;
}
- retval = 0;
+ rv = 0;
-out:
- if (vol != NULL) {
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
virStorageVolFree(vol);
- }
- return retval;
+ return rv;
}
static int
@@ -5915,33 +6575,36 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_get_info_args *args,
remote_storage_vol_get_info_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
virStorageVolInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStorageVolGetInfo(vol, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
ret->type = info.type;
ret->capacity = info.capacity;
ret->allocation = info.allocation;
- virStorageVolFree(vol);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5953,28 +6616,33 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_dump_xml_args *args,
remote_storage_vol_dump_xml_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -5987,28 +6655,33 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_get_path_args *args,
remote_storage_vol_get_path_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->name = virStorageVolGetPath(vol);
if (!ret->name) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6021,31 +6694,37 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_vol_lookup_by_name_args *args,
remote_storage_vol_lookup_by_name_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
vol = virStorageVolLookupByName(pool, args->name);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -6057,22 +6736,29 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
remote_storage_vol_lookup_by_key_args *args,
remote_storage_vol_lookup_by_key_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = virStorageVolLookupByKey(conn, args->key);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6085,22 +6771,29 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_vol_lookup_by_path_args *args,
remote_storage_vol_lookup_by_path_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = virStorageVolLookupByPath(conn, args->path);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6117,20 +6810,26 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_num_of_devices_args *args,
remote_node_num_of_devices_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virNodeNumOfDevices(conn,
args->cap ? *args->cap : NULL,
args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -6143,21 +6842,23 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_list_devices_args *args,
remote_node_list_devices_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
@@ -6165,12 +6866,17 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
args->cap ? *args->cap : NULL,
ret->names.names_val, args->maxnames, args->flags);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
@@ -6183,22 +6889,29 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_device_lookup_by_name_args *args,
remote_node_device_lookup_by_name_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_node_device(&ret->dev, dev);
- virNodeDeviceFree(dev);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6211,28 +6924,33 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dump_xml_args *args,
remote_node_device_dump_xml_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6245,18 +6963,18 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_get_parent_args *args,
remote_node_device_get_parent_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
const char *parent;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
parent = virNodeDeviceGetParent(dev);
@@ -6267,21 +6985,25 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
char **parent_p;
if (VIR_ALLOC(parent_p) < 0) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
*parent_p = strdup(parent);
if (*parent_p == NULL) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->parent = parent_p;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6294,28 +7016,32 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_num_of_caps_args *args,
remote_node_device_num_of_caps_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virNodeDeviceNumOfCaps(dev);
if (ret->num < 0) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6328,45 +7054,48 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_list_caps_args *args,
remote_node_device_list_caps_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
- virNodeDeviceFree(dev);
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virNodeDeviceListCaps(dev, ret->names.names_val,
args->maxnames);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6379,27 +7108,31 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dettach_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceDettach(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6412,27 +7145,31 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_re_attach_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceReAttach(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6445,27 +7182,31 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_reset_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceReset(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6478,23 +7219,29 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_create_xml_args *args,
remote_node_device_create_xml_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_node_device(&ret->dev, dev);
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6507,28 +7254,33 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceDestroy(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
+
static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client,
virConnectPtr conn,
@@ -6537,47 +7289,46 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
remote_storage_vol_upload_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int rv = -1;
struct qemud_client_stream *stream = NULL;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (virStorageVolUpload(vol, stream->st,
args->offset, args->length,
args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (remoteAddClientStream(client, stream, 0) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
goto cleanup;
}
rv = 0;
cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (vol)
virStorageVolFree(vol);
- if (stream && rv != 0)
+ if (stream && rv != 0) {
+ virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
+ }
return rv;
}
@@ -6589,47 +7340,46 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
remote_storage_vol_download_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int rv = -1;
struct qemud_client_stream *stream = NULL;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (virStorageVolDownload(vol, stream->st,
args->offset, args->length,
args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
goto cleanup;
}
rv = 0;
cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (vol)
virStorageVolFree(vol);
- if (stream && rv != 0)
+ if (stream && rv != 0) {
+ virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
+ }
return rv;
}
@@ -6647,15 +7397,16 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
{
int callbackID;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
- remoteDispatchFormatError(rerr, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+ goto cleanup;
}
if ((callbackID = virConnectDomainEventRegisterAny(conn,
@@ -6663,13 +7414,17 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
client, NULL)) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -6681,24 +7436,30 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] == -1) {
- remoteDispatchFormatError(rerr, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+ goto cleanup;
}
if (virConnectDomainEventDeregisterAny(conn,
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static void
@@ -6722,7 +7483,7 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
msg->hdr.status = REMOTE_OK;
if (remoteEncodeClientMessageHeader(msg) < 0)
- goto error;
+ goto cleanup;
/* Serialise the return header and event. */
xdrmem_create(&xdr,
@@ -6732,20 +7493,20 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
/* Skip over the header we just wrote */
if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
- goto xdr_error;
+ goto xdr_cleanup;
if (!(proc)(&xdr, data)) {
VIR_WARN("Failed to serialize domain event %d", procnr);
- goto xdr_error;
+ goto xdr_cleanup;
}
/* Update length word to include payload*/
len = msg->bufferOffset = xdr_getpos(&xdr);
if (xdr_setpos(&xdr, 0) == 0)
- goto xdr_error;
+ goto xdr_cleanup;
if (!xdr_u_int(&xdr, &len))
- goto xdr_error;
+ goto xdr_cleanup;
/* Send it. */
msg->async = 1;
@@ -6759,9 +7520,9 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
xdr_destroy(&xdr);
return;
-xdr_error:
+xdr_cleanup:
xdr_destroy(&xdr);
-error:
+cleanup:
VIR_FREE(msg);
}
@@ -6774,18 +7535,24 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_secrets_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfSecrets(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -6797,31 +7564,38 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_secrets_args *args,
remote_list_secrets_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
+ goto cleanup;
}
if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->uuids.uuids_len = virConnectListSecrets(conn, ret->uuids.uuids_val,
args->maxuuids);
if (ret->uuids.uuids_len == -1) {
- VIR_FREE(ret->uuids.uuids_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->uuids.uuids_val);
+ }
+ return rv;
}
static int
@@ -6833,22 +7607,28 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_define_xml_args *args,
remote_secret_define_xml_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretDefineXML(conn, args->xml, args->flags);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6860,32 +7640,37 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_get_value_args *args,
remote_secret_get_value_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
size_t value_size;
unsigned char *value;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
value = virSecretGetValue(secret, &value_size, args->flags);
if (value == NULL) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
ret->value.value_len = value_size;
ret->value.value_val = (char *)value;
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6897,26 +7682,31 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_get_xml_desc_args *args,
remote_secret_get_xml_desc_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->xml = virSecretGetXMLDesc(secret, args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6928,22 +7718,29 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_lookup_by_uuid_args *args,
remote_secret_lookup_by_uuid_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6955,27 +7752,31 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_set_value_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
args->value.value_len, args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6987,26 +7788,30 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virSecretUndefine(secret) < 0) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -7018,22 +7823,29 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_lookup_by_usage_args *args,
remote_secret_lookup_by_usage_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
@@ -7045,29 +7857,33 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
remote_domain_is_active_args *args,
remote_domain_is_active_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virDomainIsActive(domain);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7078,29 +7894,33 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
remote_domain_is_persistent_args *args,
remote_domain_is_persistent_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virDomainIsPersistent(domain);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7111,29 +7931,33 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
remote_domain_is_updated_args *args,
remote_domain_is_updated_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->updated = virDomainIsUpdated(domain);
if (ret->updated < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7144,29 +7968,33 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
remote_interface_is_active_args *args,
remote_interface_is_active_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virInterfaceIsActive(iface);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7177,29 +8005,33 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
remote_network_is_active_args *args,
remote_network_is_active_ret *ret)
{
- virNetworkPtr network;
+ virNetworkPtr network = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virNetworkIsActive(network);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(network);
- return -1;
+ goto cleanup;
}
- virNetworkFree(network);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (network)
+ virNetworkFree(network);
+ return rv;
}
static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7210,29 +8042,33 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
remote_network_is_persistent_args *args,
remote_network_is_persistent_ret *ret)
{
- virNetworkPtr network;
+ virNetworkPtr network = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virNetworkIsPersistent(network);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(network);
- return -1;
+ goto cleanup;
}
- virNetworkFree(network);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (network)
+ virNetworkFree(network);
+ return rv;
}
static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7243,29 +8079,33 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
remote_storage_pool_is_active_args *args,
remote_storage_pool_is_active_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virStoragePoolIsActive(pool);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7276,29 +8116,33 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
remote_storage_pool_is_persistent_args *args,
remote_storage_pool_is_persistent_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virStoragePoolIsPersistent(pool);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -7310,19 +8154,25 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_is_secure_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->secure = virConnectIsSecure(conn);
if (ret->secure < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7336,20 +8186,25 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_cpu_compare_ret *ret)
{
int result;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
result = virConnectCompareCPU(conn, args->xml, args->flags);
if (result == VIR_CPU_COMPARE_ERROR) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->result = result;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7363,10 +8218,11 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_cpu_baseline_ret *ret)
{
char *cpu;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
cpu = virConnectBaselineCPU(conn,
@@ -7374,13 +8230,17 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
args->xmlCPUs.xmlCPUs_len,
args->flags);
if (cpu == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->cpu = cpu;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7393,24 +8253,22 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_job_info_args *args,
remote_domain_get_job_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainJobInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetJobInfo(dom, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->type = info.type;
@@ -7426,9 +8284,14 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->fileProcessed = info.fileProcessed;
ret->fileRemaining = info.fileRemaining;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
@@ -7441,28 +8304,31 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_abort_job_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAbortJob(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
@@ -7475,28 +8341,31 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
remote_domain_migrate_set_max_downtime_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -7508,28 +8377,31 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_migrate_set_max_speed_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -7542,32 +8414,36 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_create_xml_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7581,11 +8457,11 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7601,17 +8477,16 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
if (!ret->xml)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
static int
@@ -7623,29 +8498,32 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_snapshot_num_args *args,
remote_domain_snapshot_num_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainSnapshotNum(domain, args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7657,30 +8535,29 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_list_names_args *args,
remote_domain_snapshot_list_names_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->nameslen) < 0) {
- virDomainFree(domain);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len = virDomainSnapshotListNames(domain,
@@ -7688,15 +8565,19 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
args->nameslen,
args->flags);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7709,32 +8590,36 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
remote_domain_snapshot_lookup_by_name_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7746,32 +8631,35 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_has_current_snapshot_args *args,
remote_domain_has_current_snapshot_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
int result;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
result = virDomainHasCurrentSnapshot(domain, args->flags);
if (result < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
ret->result = result;
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7784,32 +8672,36 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_snapshot_current_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCurrent(domain, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7823,11 +8715,11 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7841,17 +8733,16 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
if (virDomainRevertToSnapshot(snapshot, args->flags) == -1)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
static int
@@ -7865,11 +8756,11 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7883,17 +8774,16 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
if (virDomainSnapshotDelete(snapshot, args->flags) == -1)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
@@ -7907,21 +8797,22 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
void *ret ATTRIBUTE_UNUSED)
{
int callbackID;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
- remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
+ goto cleanup;
}
if (client->domainEventCallbackID[args->eventID] != -1) {
- remoteDispatchFormatError(rerr, _("domain event %d already registered"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), args->eventID);
+ goto cleanup;
}
if ((callbackID = virConnectDomainEventRegisterAny(conn,
@@ -7929,13 +8820,17 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
args->eventID,
domainEventCallbacks[args->eventID],
client, NULL)) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[args->eventID] = callbackID;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7949,31 +8844,36 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
void *ret ATTRIBUTE_UNUSED)
{
int callbackID = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
- remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
+ goto cleanup;
}
callbackID = client->domainEventCallbackID[args->eventID];
if (callbackID < 0) {
- remoteDispatchFormatError(rerr, _("domain event %d not registered"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
+ goto cleanup;
}
if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[args->eventID] = -1;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7987,22 +8887,29 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_lookup_by_name_args *args,
remote_nwfilter_lookup_by_name_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterLookupByName(conn, args->name);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
static int
@@ -8014,22 +8921,29 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_lookup_by_uuid_args *args,
remote_nwfilter_lookup_by_uuid_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8042,22 +8956,29 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_define_xml_args *args,
remote_nwfilter_define_xml_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterDefineXML(conn, args->xml);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8070,26 +8991,31 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNWFilterUndefine(nwfilter) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNWFilterFree(nwfilter);
- return -1;
+ goto cleanup;
}
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
static int
@@ -8101,33 +9027,40 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_nwfilters_args *args,
remote_list_nwfilters_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListNWFilters(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
@@ -8140,28 +9073,33 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_get_xml_desc_args *args,
remote_nwfilter_get_xml_desc_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNWFilterFree(nwfilter);
- return -1;
+ goto cleanup;
}
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8174,18 +9112,24 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_nwfilters_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfNWFilters(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -8198,33 +9142,36 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_block_info_args *args,
remote_domain_get_block_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainBlockInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->capacity = info.capacity;
ret->allocation = info.allocation;
ret->physical = info.physical;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -8236,29 +9183,32 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
qemu_monitor_command_args *args,
qemu_monitor_command_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
@@ -8272,25 +9222,24 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
int r;
- struct qemud_client_stream *stream;
- virDomainPtr dom;
+ struct qemud_client_stream *stream = NULL;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->domain);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainOpenConsole(dom,
@@ -8298,22 +9247,25 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
stream->st,
args->flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (stream && rv < 0) {
virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
- return -1;
}
-
- virDomainFree(dom);
- return 0;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
diff --git a/daemon/stream.c b/daemon/stream.c
index b94e3df..b71df92 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -403,7 +403,7 @@ remoteStreamHandleWriteData(struct qemud_client *client,
} else {
VIR_INFO0("Stream send failed");
stream->closed = 1;
- remoteDispatchConnError(&rerr, client->conn);
+ remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
}
@@ -437,7 +437,7 @@ remoteStreamHandleFinish(struct qemud_client *client,
ret = virStreamFinish(stream->st);
if (ret < 0) {
- remoteDispatchConnError(&rerr, client->conn);
+ remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
} else {
/* Send zero-length confirm */
@@ -569,7 +569,7 @@ remoteStreamHandleRead(struct qemud_client *client,
} else if (ret < 0) {
remote_error rerr;
memset(&rerr, 0, sizeof rerr);
- remoteDispatchConnError(&rerr, NULL);
+ remoteDispatchError(&rerr);
ret = remoteSerializeStreamError(client, &rerr, stream->procedure, stream->serial);
} else {
--
1.7.4.2
3
8
18 Apr '11
Updated against the latest git tree, no major changes since a week ago.
Thank you for reviews in previous ones.
Purpose of patches:
Now, virsh at(de)tach-device/disk/...etc.. doesn't support to update
inactive domain's definition even with the --persistent flag.
To update persistent modification of inactive domains, we have to use
virsh edit.
So, if we want to update inactive domain definition with scripts, we need to
use other command/libs than libvirt. I'd like to use libvirt/virsh in scripts.
This patches adds to support for updating domain definition via virsh with
scripts. This series just includes 'disk' updates but I'll add more.
Thanks,
-Kame
3
14
17 Apr '11
I think this change is pretty self-explanatory.
Richard
2
1
Also mark error messages in block_stats.c for translation, add the
new macro to the msg_gen functions in cfg.mk and add block_stats.c
to po/POTFILES.in
---
cfg.mk | 1 +
po/POTFILES.in | 1 +
src/xen/block_stats.c | 79 ++++++++++++++++++------------------------------
3 files changed, 32 insertions(+), 49 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 94db937..e54d170 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -420,6 +420,7 @@ msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
msg_gen_function += VIR_ERROR
msg_gen_function += VIR_ERROR0
+msg_gen_function += statsError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cfa7cf8..766f8f6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -114,6 +114,7 @@ src/vbox/vbox_tmpl.c
src/vmware/vmware_conf.c
src/vmware/vmware_driver.c
src/vmx/vmx.c
+src/xen/block_stats.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index a28212c..1cb5455 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -31,34 +31,12 @@
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
-/**
- * statsErrorFunc:
- * @conn: the connection
- * @error: the error number
- * @func: the function failing
- * @info: extra information string
- * @value: extra information number
- *
- * Handle a stats error.
- */
-static void
-statsErrorFunc (virErrorNumber error, const char *func, const char *info,
- int value)
-{
- char fullinfo[1000];
- const char *errmsg;
-
- errmsg = virErrorMsg(error, info);
- if (func != NULL) {
- snprintf(fullinfo, sizeof (fullinfo) - 1, "%s: %s", func, info);
- fullinfo[sizeof (fullinfo) - 1] = 0;
- info = fullinfo;
- }
- virRaiseError(NULL, NULL, VIR_FROM_STATS_LINUX, error,
- VIR_ERR_ERROR,
- errmsg, info, NULL, value, 0, errmsg, info,
- value);
-}
+
+
+# define statsError(code, ...) \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, __FUNCTION__, \
+ __LINE__, __VA_ARGS__)
+
/*-------------------- Xen: block stats --------------------*/
@@ -194,8 +172,9 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
if (stats->rd_req == -1 && stats->rd_bytes == -1 &&
stats->wr_req == -1 && stats->wr_bytes == -1 &&
stats->errs == -1) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Failed to read any block statistics", domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to read any block statistics for domain %d"),
+ domid);
return -1;
}
@@ -207,8 +186,9 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
stats->wr_req == 0 && stats->wr_bytes == 0 &&
stats->errs == 0 &&
!check_bd_connected (priv, device, domid)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Frontend block device not connected", domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("Frontend block device not connected for domain %d"),
+ domid);
return -1;
}
@@ -217,18 +197,18 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
*/
if (stats->rd_bytes > 0) {
if (stats->rd_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->rd_bytes would overflow 64 bit counter",
- domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("stats->rd_bytes would overflow 64 bit counter for domain %d"),
+ domid);
return -1;
}
stats->rd_bytes *= 512;
}
if (stats->wr_bytes > 0) {
if (stats->wr_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->wr_bytes would overflow 64 bit counter",
- domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("stats->wr_bytes would overflow 64 bit counter for domain %d"),
+ domid);
return -1;
}
stats->wr_bytes *= 512;
@@ -346,20 +326,21 @@ xenLinuxDomainDeviceID(int domid, const char *path)
* beginning of the strings for better error messages
*/
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/sd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range sda[1-15] - sdiv[1-15]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "sda[1-15] - sdiv[1-15] for domain %d"), domid);
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/hd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range hda[1-63] - hdt[1-63]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "hda[1-63] - hdt[1-63] for domain %d"), domid);
else if (strlen(mod_path) >= 8 && STRPREFIX(mod_path, "/dev/xvd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range xvda[1-15] - xvdiz[1-15]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "xvda[1-15] - xvdiz[1-15] for domain %d"), domid);
else
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "unsupported path, use xvdN, hdN, or sdN", domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("unsupported path, use xvdN, hdN, or sdN for domain %d"),
+ domid);
VIR_FREE(mod_path);
--
1.7.0.4
2
2