#define VIR_FROM_THIS VIR_FROM_REMOTE
+#define virNetError(code, ...) \
+ virReportErrorHelper(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);
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
? 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;
}
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
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
*/
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
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
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
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
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
{
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
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
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);
ret->cores = info.cores;
ret->threads = info.threads;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
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
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,
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;
}
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;
}
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
remote_domain_get_scheduler_parameters_args *args,
remote_domain_get_scheduler_parameters_ret *ret)
{
- virDomainPtr dom;
- virSchedParameterPtr params;
+ virDomainPtr dom = NULL;
+ virSchedParameterPtr params = NULL;
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;
- }
- if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
+ if (VIR_ALLOC_N(params, nparams) < 0)
+ goto no_memory;
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) {
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
remote_domain_set_scheduler_parameters_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
- virSchedParameterPtr params;
+ virSchedParameterPtr params = 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;
}
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) {
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
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;
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
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;
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
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 */
ret->stats.stats_val[i].val = stats[i].val;
}
ret->stats.stats_len = nr_stats;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(stats);
- return 0;
+ return rv;
}
static int
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;
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
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
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
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
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
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
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
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
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
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
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
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
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
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. */
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
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. */
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;
}
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
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;
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
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
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
remote_domain_get_security_label_args *args,
remote_domain_get_security_label_ret *ret)
{
- virDomainPtr dom;
- virSecurityLabelPtr seclabel;
+ virDomainPtr dom = NULL;
+ virSecurityLabelPtr seclabel = 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 (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
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
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
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;
*/
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
ret->cpumaps.cpumaps_val = (char *) cpumaps;
+ cpumaps = NULL;
- VIR_FREE(info);
- virDomainFree(dom);
- return 0;
+ rv = 0;
-oom:
- VIR_FREE(info);
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->info.info_val);
+ }
VIR_FREE(cpumaps);
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ VIR_FREE(info);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
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
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;
/* 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
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
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;
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
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,
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
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;
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
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
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
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,
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
{
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
remote_domain_set_memory_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
- virMemoryParameterPtr params;
+ virMemoryParameterPtr params = NULL;
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) {
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
remote_domain_get_memory_parameters_ret
* ret)
{
- virDomainPtr dom;
- virMemoryParameterPtr params;
+ virDomainPtr dom = NULL;
+ virMemoryParameterPtr params = NULL;
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
/* 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) {
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);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
remote_domain_set_blkio_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
- virBlkioParameterPtr params;
+ virBlkioParameterPtr params = NULL;
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) {
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
remote_domain_get_blkio_parameters_ret
* ret)
{
- virDomainPtr dom;
- virBlkioParameterPtr params;
+ virDomainPtr dom = NULL;
+ virBlkioParameterPtr params = NULL;
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
/* 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) {
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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;
}
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
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
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
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
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
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
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
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
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
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
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;
}
/*-------------------------------------------------------------*/
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);
ret->types.types_val[0] = client->auth;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
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,
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);
+ if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL)
goto error;
- }
/* Get remote address in form IPADDR:PORT */
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;
}
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
+ remoteDispatchError(rerr);
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
+ remoteDispatchError(rerr);
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
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
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
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 =
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;
}
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
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
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
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;
}
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
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
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
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;
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
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
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;
}
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
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
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
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
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
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
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
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) {
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
}
- virStoragePoolFree(pool);
-
- return 0;
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
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;
}
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
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
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
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
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
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;
}
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;
}
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
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;
}
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;
}
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;
}
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 =
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;
}
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;
}
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;
}
remote_node_device_get_parent_args *args,
remote_node_device_get_parent_ret *ret)
{
- virNodeDevicePtr dev;
- const char *parent;
+ virNodeDevicePtr dev = NULL;
+ const char *parent = 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;
}
parent = virNodeDeviceGetParent(dev);
/* 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;
+ if (!(*parent_p = strdup(parent))) {
+ VIR_FREE(parent_p);
+ 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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,
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;
}
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;
}
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,
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
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
msg->hdr.status = REMOTE_OK;
if (remoteEncodeClientMessageHeader(msg) < 0)
- goto error;
+ goto cleanup;
/* Serialise the return header and event. */
xdrmem_create(&xdr,
/* 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;
xdr_destroy(&xdr);
return;
-xdr_error:
+xdr_cleanup:
xdr_destroy(&xdr);
-error:
+cleanup:
VIR_FREE(msg);
}
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
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
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
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
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
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
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
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
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;
}
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,
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,
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,
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,
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,
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,
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,
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;
}
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;
}
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;
}
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,
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;
}
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;
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;
}
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;
}
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
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
remote_domain_snapshot_create_xml_args *args,
remote_domain_snapshot_create_xml_ret *ret)
{
- virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainSnapshotPtr snapshot = NULL;
+ 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
{
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);
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
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
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,
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
remote_domain_snapshot_lookup_by_name_args *args,
remote_domain_snapshot_lookup_by_name_ret *ret)
{
- virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainSnapshotPtr snapshot = NULL;
+ 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
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
remote_domain_snapshot_current_args *args,
remote_domain_snapshot_current_ret *ret)
{
- virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainSnapshotPtr snapshot = NULL;
+ 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
{
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);
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
{
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);
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;
}
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,
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;
}
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;
}
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
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;
}
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;
}
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
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;
}
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;
}
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;
}
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
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;
}
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,
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;
}