[libvirt] [PATCHv2] Add cputune support to libxl driver
by Markus Groß
Here is a new version of this patch:
https://www.redhat.com/archives/libvir-list/2011-April/msg00337.html
v2:
- store the cputune info for the whole runtime of the domain
- remove cputune info when domain is destroyed
The nodeGetInfo code had to be moved into a helper
function to reuse it without a virConnectPtr.
---
src/libxl/libxl_driver.c | 159 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 122 insertions(+), 37 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 3040914..247d78e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -199,6 +199,46 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
virDomainObjUnlock(vm);
}
+static int
+libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
+{
+ libxl_physinfo phy_info;
+ const libxl_version_info* ver_info;
+ struct utsname utsname;
+
+ if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxl_get_physinfo_info failed"));
+ return -1;
+ }
+
+ if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxl_get_version_info failed"));
+ return -1;
+ }
+
+ uname(&utsname);
+ if (virStrncpy(info->model,
+ utsname.machine,
+ strlen(utsname.machine),
+ sizeof(info->model)) == NULL) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("machine type %s too big for destination"),
+ utsname.machine);
+ return -1;
+ }
+
+ info->memory = phy_info.total_pages * (ver_info->pagesize / 1024);
+ info->cpus = phy_info.nr_cpus;
+ info->nodes = phy_info.nr_nodes;
+ info->cores = phy_info.cores_per_socket;
+ info->threads = phy_info.threads_per_core;
+ info->sockets = 1;
+ info->mhz = phy_info.cpu_khz / 1000;
+ return 0;
+}
+
/*
* Cleanup function for domain that has reached shutoff state.
*
@@ -210,6 +250,7 @@ libxlVmCleanup(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
libxlDomainObjPrivatePtr priv = vm->privateData;
int vnc_port;
char *file;
+ int i;
if (priv->eventHdl >= 0) {
virEventRemoveHandle(priv->eventHdl);
@@ -238,6 +279,16 @@ libxlVmCleanup(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
}
}
+ /* Remove any cputune settings */
+ if (vm->def->cputune.nvcpupin) {
+ for (i = 0; i < vm->def->cputune.nvcpupin; ++i) {
+ VIR_FREE(vm->def->cputune.vcpupin[i]->cpumask);
+ VIR_FREE(vm->def->cputune.vcpupin[i]);
+ }
+ VIR_FREE(vm->def->cputune.vcpupin);
+ vm->def->cputune.nvcpupin = 0;
+ }
+
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) > 0) {
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name);
@@ -391,6 +442,62 @@ error:
return -1;
}
+static int
+libxlDomainSetVcpuAffinites(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
+{
+ libxlDomainObjPrivatePtr priv = vm->privateData;
+ virDomainDefPtr def = vm->def;
+ libxl_cpumap map;
+ uint8_t *cpumask = NULL;
+ uint8_t *cpumap = NULL;
+ virNodeInfo nodeinfo;
+ size_t cpumaplen;
+ unsigned int pos;
+ int vcpu, i;
+ int ret = -1;
+
+ if (libxlDoNodeGetInfo(driver, &nodeinfo) < 0)
+ goto cleanup;
+
+ cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
+
+ for (vcpu = 0; vcpu < def->cputune.nvcpupin; ++vcpu) {
+ if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
+ continue;
+
+ if (VIR_ALLOC_N(cpumap, cpumaplen) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ cpumask = (uint8_t*) def->cputune.vcpupin[vcpu]->cpumask;
+
+ for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; ++i) {
+ if (cpumask[i]) {
+ pos = i / 8;
+ cpumap[pos] |= 1 << (i % 8);
+ }
+ }
+
+ map.size = cpumaplen;
+ map.map = cpumap;
+
+ if (libxl_set_vcpuaffinity(&priv->ctx, def->id, vcpu, &map) != 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to pin vcpu '%d' with libxenlight"), vcpu);
+ goto cleanup;
+ }
+
+ VIR_FREE(cpumap);
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cpumap);
+ return ret;
+}
+
/*
* Start a domain through libxenlight.
*
@@ -440,6 +547,9 @@ libxlVmStart(libxlDriverPrivatePtr driver,
if (libxlCreateDomEvents(vm) < 0)
goto error;
+ if (libxlDomainSetVcpuAffinites(driver, vm) < 0)
+ goto error;
+
if (!start_paused) {
libxl_domain_unpause(&priv->ctx, domid);
vm->state = VIR_DOMAIN_RUNNING;
@@ -756,7 +866,7 @@ libxlReload(void)
&libxl_driver->domains,
libxl_driver->configDir,
libxl_driver->autostartDir,
- 0, NULL, libxl_driver);
+ 1, NULL, libxl_driver);
virHashForEach(libxl_driver->domains.objs, libxlAutostartDomain,
libxl_driver);
@@ -869,42 +979,7 @@ libxlGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
static int
libxlNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
{
- libxl_physinfo phy_info;
- const libxl_version_info* ver_info;
- libxlDriverPrivatePtr driver = conn->privateData;
- struct utsname utsname;
-
- if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxl_get_physinfo_info failed"));
- return -1;
- }
-
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxl_get_version_info failed"));
- return -1;
- }
-
- uname(&utsname);
- if (virStrncpy(info->model,
- utsname.machine,
- strlen(utsname.machine),
- sizeof(info->model)) == NULL) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("machine type %s too big for destination"),
- utsname.machine);
- return -1;
- }
-
- info->memory = phy_info.total_pages * (ver_info->pagesize / 1024);
- info->cpus = phy_info.nr_cpus;
- info->nodes = phy_info.nr_nodes;
- info->cores = phy_info.cores_per_socket;
- info->threads = phy_info.threads_per_core;
- info->sockets = 1;
- info->mhz = phy_info.cpu_khz / 1000;
- return 0;
+ return libxlDoNodeGetInfo(conn->privateData, info);
}
static char *
@@ -1712,6 +1787,16 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
}
+
+ if (virDomainVcpupinAdd(vm->def, cpumap, maplen, vcpu) < 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("failed to update or add vcpupin xml"));
+ goto cleanup;
+ }
+
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
--
1.7.1
13 years, 7 months
[libvirt] [PATCH] Update and sort msg_gen_function list and mark unmarked messages
by Matthias Bolte
Inspired by Eric Blake
---
cfg.mk | 45 ++++++++++++++++++++++++++++++++++-------
src/interface/netcf_driver.c | 43 ++++++++++++++++++---------------------
src/nodeinfo.c | 2 +-
src/phyp/phyp_driver.c | 18 ++++++++--------
src/util/stats_linux.c | 2 +-
5 files changed, 68 insertions(+), 42 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index e54d170..72dd69c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -380,47 +380,76 @@ sc_prohibit_xmlGetProp:
msg_gen_function =
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
-msg_gen_function += macvtapError
-msg_gen_function += remoteError
+msg_gen_function += PHYP_ERROR
+msg_gen_function += VIR_ERROR
+msg_gen_function += VIR_ERROR0
+msg_gen_function += VMX_ERROR
+msg_gen_function += XENXS_ERROR
+msg_gen_function += eventReportError
+msg_gen_function += ifaceError
+msg_gen_function += interfaceReportError
+msg_gen_function += iptablesError
msg_gen_function += lxcError
-msg_gen_function += networkLog
+msg_gen_function += libxlError
+msg_gen_function += macvtapError
msg_gen_function += networkReportError
-msg_gen_function += oneError
+msg_gen_function += nodeReportError
msg_gen_function += openvzError
+msg_gen_function += pciReportError
msg_gen_function += qemuReportError
msg_gen_function += qemudDispatchClientFailure
msg_gen_function += regerror
+msg_gen_function += remoteError
msg_gen_function += remoteDispatchFormatError
+msg_gen_function += statsError
+msg_gen_function += streamsReportError
+msg_gen_function += usbReportError
msg_gen_function += umlReportError
msg_gen_function += vah_error
msg_gen_function += vah_warning
msg_gen_function += vboxError
msg_gen_function += virCommandError
msg_gen_function += virConfError
+msg_gen_function += virCPUReportError
+msg_gen_function += virEventError
msg_gen_function += virDomainReportError
+msg_gen_function += virGenericReportError
msg_gen_function += virHashError
+msg_gen_function += virHookReportError
+msg_gen_function += virInterfaceReportError
+msg_gen_function += virJSONError
msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError
+msg_gen_function += virLibDomainSnapshotError
+msg_gen_function += virLibInterfaceError
+msg_gen_function += virLibNetworkError
+msg_gen_function += virLibNodeDeviceError
+msg_gen_function += virLibNWFilterError
+msg_gen_function += virLibSecretError
+msg_gen_function += virLibStoragePoolError
+msg_gen_function += virLibStorageVolError
msg_gen_function += virNetworkReportError
msg_gen_function += virNodeDeviceReportError
+msg_gen_function += virNWFilterReportError
msg_gen_function += virRaiseError
msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError
+msg_gen_function += virSecretReportError
msg_gen_function += virSecurityReportError
msg_gen_function += virSexprError
+msg_gen_function += virSmbiosReportError
+msg_gen_function += virSocketError
+msg_gen_function += virStatsError
msg_gen_function += virStorageReportError
+msg_gen_function += virUtilError
msg_gen_function += virXMLError
msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError
msg_gen_function += vmwareError
msg_gen_function += xenapiSessionErrorHandler
-msg_gen_function += libxlError
msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
-msg_gen_function += VIR_ERROR
-msg_gen_function += VIR_ERROR0
-msg_gen_function += statsError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index 0190bf4..709f09b 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -102,11 +102,12 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac
int errcode = ncf_error(ncf, &errmsg, &details);
if (errcode != NETCF_NOERROR) {
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface named '%s' (netcf: %s - %s)",
- ifinfo->name, errmsg, details ? details : "");
+ _("couldn't find interface named '%s' (netcf: %s - %s)"),
+ ifinfo->name, errmsg, details ? details : "");
} else {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface named '%s'", ifinfo->name);
+ _("couldn't find interface named '%s'"),
+ ifinfo->name);
}
}
return iface;
@@ -182,8 +183,7 @@ static int interfaceNumOfInterfaces(virConnectPtr conn)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to get number of interfaces on host"),
+ _("failed to get number of interfaces on host (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -203,8 +203,7 @@ static int interfaceListInterfaces(virConnectPtr conn, char **const names, int n
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to list host interfaces"),
+ _("failed to list host interfaces (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -224,8 +223,7 @@ static int interfaceNumOfDefinedInterfaces(virConnectPtr conn)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to get number of defined interfaces on host"),
+ _("failed to get number of defined interfaces on host (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -245,8 +243,7 @@ static int interfaceListDefinedInterfaces(virConnectPtr conn, char **const names
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to list host defined interfaces"),
+ _("failed to list host defined interfaces (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -269,11 +266,11 @@ static virInterfacePtr interfaceLookupByName(virConnectPtr conn,
int errcode = ncf_error(driver->netcf, &errmsg, &details);
if (errcode != NETCF_NOERROR) {
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface named '%s' (netcf: %s - %s)",
+ _("couldn't find interface named '%s' (netcf: %s - %s)"),
name, errmsg, details ? details : "");
} else {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface named '%s'", name);
+ _("couldn't find interface named '%s'"), name);
}
goto cleanup;
}
@@ -301,13 +298,13 @@ static virInterfacePtr interfaceLookupByMACString(virConnectPtr conn,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface with MAC address '%s' (netcf: %s - %s)",
+ _("couldn't find interface with MAC address '%s' (netcf: %s - %s)"),
macstr, errmsg, details ? details : "");
goto cleanup;
}
if (niface == 0) {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface with MAC address '%s'",
+ _("couldn't find interface with MAC address '%s'"),
macstr);
goto cleanup;
}
@@ -351,8 +348,8 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "could not get interface XML description (netcf: %s - %s)",
- errmsg, details ? details : "");
+ _("could not get interface XML description (netcf: %s - %s)"),
+ errmsg, details ? details : "");
goto cleanup;
}
@@ -405,8 +402,8 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "could not get interface XML description (netcf: %s - %s)",
- errmsg, details ? details : "");
+ _("could not get interface XML description (netcf: %s - %s)"),
+ errmsg, details ? details : "");
goto cleanup;
}
@@ -438,7 +435,7 @@ static int interfaceUndefine(virInterfacePtr ifinfo) {
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to undefine interface %s (netcf: %s - %s)",
+ _("failed to undefine interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -469,7 +466,7 @@ static int interfaceCreate(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to create (start) interface %s (netcf: %s - %s)",
+ _("failed to create (start) interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -500,7 +497,7 @@ static int interfaceDestroy(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to destroy (stop) interface %s (netcf: %s - %s)",
+ _("failed to destroy (stop) interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -530,7 +527,7 @@ static int interfaceIsActive(virInterfacePtr ifinfo)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to get status of interface %s (netcf: %s - %s)",
+ _("failed to get status of interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index facac15..e0221f0 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -239,7 +239,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
buf++;
if (*buf != ':' || !buf[1]) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
- "parsing cpuinfo cpu cores %c", *buf);
+ _("parsing cpuinfo cpu cores %c"), *buf);
return -1;
}
if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 8f8c3ba..c65824a 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3659,28 +3659,28 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!def->mem.cur_balloon) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<memory>\" on the domain XML file is missing or has "
- "invalid value."));
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <memory> on the domain XML file is missing or has "
+ "invalid value."));
goto cleanup;
}
if (!def->mem.max_balloon) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<currentMemory>\" on the domain XML file is missing or"
- " has invalid value."));
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <currentMemory> on the domain XML file is missing or "
+ "has invalid value."));
goto cleanup;
}
if (def->ndisks < 1) {
PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
- _("Domain XML must contain at least one \"<disk>\" element."));
+ _("Domain XML must contain at least one <disk> element."));
goto cleanup;
}
if (!def->disks[0]->src) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<src>\" under \"<disk>\" on the domain XML file is "
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <src> under <disk> on the domain XML file is "
"missing."));
goto cleanup;
}
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index 173cdc5..e728b7b 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -107,7 +107,7 @@ linuxDomainInterfaceStats(const char *path,
VIR_FORCE_FCLOSE(fp);
virStatsError(VIR_ERR_INTERNAL_ERROR,
- "/proc/net/dev: Interface not found");
+ _("/proc/net/dev: Interface not found"));
return -1;
}
--
1.7.0.4
13 years, 7 months
[libvirt] [PATCHv2 0/9] round 2 of phyp cleanups
by Eric Blake
Smaller code and fewer bugs. Rebase of earlier version at:
https://www.redhat.com/archives/libvir-list/2011-April/msg00677.html
Eric Blake (9):
maint: use lighter-weight function for straight appends
phyp: avoid a logic bug
phyp: avoid memory leak on failure
phyp: more return handling cleanup
phyp: use consistent style for labels
phyp: prefer memcpy over memmove when legal
phyp: use consistent return string handling
phyp: avoid memory leaks in command values
phyp: another simplification
src/conf/nwfilter_conf.c | 16 +-
src/phyp/phyp_driver.c | 1355 ++++++++---------------------------------
src/qemu/qemu_command.c | 30 +-
src/security/virt-aa-helper.c | 2 +-
src/util/sexpr.c | 4 +-
src/xen/xend_internal.c | 6 +-
src/xenxs/xen_sxpr.c | 2 +-
src/xenxs/xen_xm.c | 4 +-
8 files changed, 290 insertions(+), 1129 deletions(-)
--
1.7.4.2
13 years, 7 months
[libvirt] [PATCH] util: Simplify hash implementation
by Jiri Denemark
So far first entries for each hash key are stored directly in the hash
table while other entries mapped to the same key are linked through
pointers. As a result of that, the code is cluttered with special
handling for the first items.
Commit 9677cd33eea4c65d78ba463b46b8b45ed2da1709 made it possible to
remove current entry when iterating through all hash entries. However,
it didn't add the special first item handling which could cause libvirtd
crash or hang.
Instead of adding more clutter, this patch fixes the crash by linking
all entries (even the first ones) through pointers which significantly
simplifies the code and makes it more maintainable.
---
src/util/hash.c | 290 ++++++++++++++++++-------------------------------------
1 files changed, 94 insertions(+), 196 deletions(-)
diff --git a/src/util/hash.c b/src/util/hash.c
index 48a94ad..dbb34ec 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -50,14 +50,13 @@ struct _virHashEntry {
struct _virHashEntry *next;
void *name;
void *payload;
- int valid;
};
/*
* The entire hash table
*/
struct _virHashTable {
- struct _virHashEntry *table;
+ virHashEntryPtr *table;
int size;
int nbElems;
/* True iff we are iterating over hash entries. */
@@ -165,7 +164,7 @@ virHashTablePtr virHashCreateFull(int size,
*
* Create a new virHashTablePtr.
*
- * Returns the newly created object, or NULL if an error occured.
+ * Returns the newly created object, or NULL if an error occurred.
*/
virHashTablePtr virHashCreate(int size, virHashDataFree dataFree)
{
@@ -189,10 +188,8 @@ virHashTablePtr virHashCreate(int size, virHashDataFree dataFree)
static int
virHashGrow(virHashTablePtr table, int size)
{
- unsigned long key;
int oldsize, i;
- virHashEntryPtr iter, next;
- struct _virHashEntry *oldtable;
+ virHashEntryPtr *oldtable;
#ifdef DEBUG_GROW
unsigned long nbElem = 0;
@@ -217,43 +214,18 @@ virHashGrow(virHashTablePtr table, int size)
}
table->size = size;
- /* If the two loops are merged, there would be situations where
- * a new entry needs to allocated and data copied into it from
- * the main table. So instead, we run through the array twice, first
- * copying all the elements in the main array (where we can't get
- * conflicts) and then the rest, so we only free (and don't allocate)
- */
- for (i = 0; i < oldsize; i++) {
- if (oldtable[i].valid == 0)
- continue;
- key = virHashComputeKey(table, oldtable[i].name);
- memcpy(&(table->table[key]), &(oldtable[i]), sizeof(virHashEntry));
- table->table[key].next = NULL;
- }
-
for (i = 0; i < oldsize; i++) {
- iter = oldtable[i].next;
+ virHashEntryPtr iter = oldtable[i];
while (iter) {
- next = iter->next;
+ virHashEntryPtr next = iter->next;
+ unsigned long key = virHashComputeKey(table, iter->name);
- /*
- * put back the entry in the new table
- */
-
- key = virHashComputeKey(table, iter->name);
- if (table->table[key].valid == 0) {
- memcpy(&(table->table[key]), iter, sizeof(virHashEntry));
- table->table[key].next = NULL;
- VIR_FREE(iter);
- } else {
- iter->next = table->table[key].next;
- table->table[key].next = iter;
- }
+ iter->next = table->table[key];
+ table->table[key] = iter;
#ifdef DEBUG_GROW
nbElem++;
#endif
-
iter = next;
}
}
@@ -279,36 +251,24 @@ void
virHashFree(virHashTablePtr table)
{
int i;
- virHashEntryPtr iter;
- virHashEntryPtr next;
- int inside_table = 0;
- int nbElems;
if (table == NULL)
return;
- if (table->table) {
- nbElems = table->nbElems;
- for (i = 0; (i < table->size) && (nbElems > 0); i++) {
- iter = &(table->table[i]);
- if (iter->valid == 0)
- continue;
- inside_table = 1;
- while (iter) {
- next = iter->next;
- if ((table->dataFree != NULL) && (iter->payload != NULL))
- table->dataFree(iter->payload, iter->name);
- if (table->keyFree)
- table->keyFree(iter->name);
- iter->payload = NULL;
- if (!inside_table)
- VIR_FREE(iter);
- nbElems--;
- inside_table = 0;
- iter = next;
- }
+
+ for (i = 0; i < table->size; i++) {
+ virHashEntryPtr iter = table->table[i];
+ while (iter) {
+ virHashEntryPtr next = iter->next;
+
+ if (table->dataFree)
+ table->dataFree(iter->payload, iter->name);
+ if (table->keyFree)
+ table->keyFree(iter->name);
+ VIR_FREE(iter);
+ iter = next;
}
- VIR_FREE(table->table);
}
+
VIR_FREE(table);
}
@@ -319,9 +279,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
{
unsigned long key, len = 0;
virHashEntryPtr entry;
- virHashEntryPtr insert;
char *new_name;
- bool found;
if ((table == NULL) || (name == NULL))
return (-1);
@@ -329,67 +287,40 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
if (table->iterating)
virHashIterationError(-1);
- /*
- * Check for duplicate and insertion location.
- */
- found = false;
key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0) {
- insert = NULL;
- } else {
- for (insert = &(table->table[key]); insert->next != NULL;
- insert = insert->next) {
- if (table->keyEqual(insert->name, name)) {
- found = true;
- break;
- }
- len++;
- }
- if (table->keyEqual(insert->name, name))
- found = true;
- }
-
- if (found) {
- if (is_update) {
- if (table->dataFree)
- table->dataFree(insert->payload, insert->name);
- insert->payload = userdata;
- return (0);
- } else {
- return (-1);
- }
- }
- if (insert == NULL) {
- entry = &(table->table[key]);
- } else {
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
- return (-1);
+ /* Check for duplicate entry */
+ for (entry = table->table[key]; entry; entry = entry->next) {
+ if (table->keyEqual(entry->name, name)) {
+ if (is_update) {
+ if (table->dataFree)
+ table->dataFree(entry->payload, entry->name);
+ entry->payload = userdata;
+ return 0;
+ } else {
+ return -1;
+ }
}
+ len++;
}
- new_name = table->keyCopy(name);
- if (new_name == NULL) {
+ if (VIR_ALLOC(entry) < 0 || !(new_name = table->keyCopy(name))) {
virReportOOMError();
- if (insert != NULL)
- VIR_FREE(entry);
- return (-1);
+ VIR_FREE(entry);
+ return -1;
}
+
entry->name = new_name;
entry->payload = userdata;
- entry->next = NULL;
- entry->valid = 1;
-
- if (insert != NULL)
- insert->next = entry;
+ entry->next = table->table[key];
+ table->table[key] = entry;
table->nbElems++;
if (len > MAX_HASH_LEN)
virHashGrow(table, MAX_HASH_LEN * table->size);
- return (0);
+ return 0;
}
/**
@@ -443,18 +374,15 @@ virHashLookup(virHashTablePtr table, const void *name)
unsigned long key;
virHashEntryPtr entry;
- if (table == NULL)
- return (NULL);
- if (name == NULL)
- return (NULL);
+ if (!table || !name)
+ return NULL;
+
key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0)
- return (NULL);
- for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
+ for (entry = table->table[key]; entry; entry = entry->next) {
if (table->keyEqual(entry->name, name))
- return (entry->payload);
+ return entry->payload;
}
- return (NULL);
+ return NULL;
}
@@ -512,47 +440,31 @@ virHashSize(virHashTablePtr table)
int
virHashRemoveEntry(virHashTablePtr table, const void *name)
{
- unsigned long key;
virHashEntryPtr entry;
- virHashEntryPtr prev = NULL;
+ virHashEntryPtr *nextptr;
if (table == NULL || name == NULL)
return (-1);
- key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0) {
- return (-1);
- } else {
- for (entry = &(table->table[key]); entry != NULL;
- entry = entry->next) {
- if (table->keyEqual(entry->name, name)) {
- if (table->iterating && table->current != entry)
- virHashIterationError(-1);
- if (table->dataFree && (entry->payload != NULL))
- table->dataFree(entry->payload, entry->name);
- entry->payload = NULL;
- if (table->keyFree)
- table->keyFree(entry->name);
- if (prev) {
- prev->next = entry->next;
- VIR_FREE(entry);
- } else {
- if (entry->next == NULL) {
- entry->valid = 0;
- } else {
- entry = entry->next;
- memcpy(&(table->table[key]), entry,
- sizeof(virHashEntry));
- VIR_FREE(entry);
- }
- }
- table->nbElems--;
- return (0);
- }
- prev = entry;
+ nextptr = table->table + virHashComputeKey(table, name);
+ for (entry = *nextptr; entry; entry = entry->next) {
+ if (table->keyEqual(entry->name, name)) {
+ if (table->iterating && table->current != entry)
+ virHashIterationError(-1);
+
+ if (table->dataFree)
+ table->dataFree(entry->payload, entry->name);
+ if (table->keyFree)
+ table->keyFree(entry->name);
+ *nextptr = entry->next;
+ VIR_FREE(entry);
+ table->nbElems--;
+ return 0;
}
- return (-1);
+ nextptr = &entry->next;
}
+
+ return -1;
}
@@ -581,15 +493,15 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr entry = table->table + i;
+ virHashEntryPtr entry = table->table[i];
while (entry) {
virHashEntryPtr next = entry->next;
- if (entry->valid) {
- table->current = entry;
- iter(entry->payload, entry->name, data);
- table->current = NULL;
- count++;
- }
+
+ table->current = entry;
+ iter(entry->payload, entry->name, data);
+ table->current = NULL;
+
+ count++;
entry = next;
}
}
@@ -612,7 +524,10 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
*
* Returns number of items removed on success, -1 on failure
*/
-int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data) {
+int virHashRemoveSet(virHashTablePtr table,
+ virHashSearcher iter,
+ const void *data)
+{
int i, count = 0;
if (table == NULL || iter == NULL)
@@ -624,44 +539,27 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr prev = NULL;
- virHashEntryPtr entry = &(table->table[i]);
+ virHashEntryPtr *nextptr = table->table + i;
- while (entry && entry->valid) {
- if (iter(entry->payload, entry->name, data)) {
+ while (*nextptr) {
+ virHashEntryPtr entry = *nextptr;
+ if (!iter(entry->payload, entry->name, data)) {
+ *nextptr = entry->next;
+ } else {
count++;
if (table->dataFree)
table->dataFree(entry->payload, entry->name);
if (table->keyFree)
table->keyFree(entry->name);
+ *nextptr = entry->next;
+ VIR_FREE(entry);
table->nbElems--;
- if (prev) {
- prev->next = entry->next;
- VIR_FREE(entry);
- entry = prev;
- } else {
- if (entry->next == NULL) {
- entry->valid = 0;
- entry->name = NULL;
- } else {
- entry = entry->next;
- memcpy(&(table->table[i]), entry,
- sizeof(virHashEntry));
- VIR_FREE(entry);
- entry = &(table->table[i]);
- continue;
- }
- }
- }
- prev = entry;
- if (entry) {
- entry = entry->next;
}
}
}
table->iterating = false;
- return (count);
+ return count;
}
/**
@@ -675,7 +573,10 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
* returns non-zero will be returned by this function.
* The elements are processed in a undefined order
*/
-void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data) {
+void *virHashSearch(virHashTablePtr table,
+ virHashSearcher iter,
+ const void *data)
+{
int i;
if (table == NULL || iter == NULL)
@@ -687,18 +588,15 @@ void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *dat
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr entry = table->table + i;
- while (entry) {
- if (entry->valid) {
- if (iter(entry->payload, entry->name, data)) {
- table->iterating = false;
- return entry->payload;
- }
+ virHashEntryPtr entry;
+ for (entry = table->table[i]; entry; entry = entry->next) {
+ if (iter(entry->payload, entry->name, data)) {
+ table->iterating = false;
+ return entry->payload;
}
- entry = entry->next;
}
}
table->iterating = false;
- return (NULL);
+ return NULL;
}
--
1.7.5.rc1
13 years, 7 months
[libvirt] Is a libvirt connection remote?
by Richard W.M. Jones
What's a good way to ask if a libvirt connection is remote or not?
(Fundamentally I want to know if the disk images are openable as local
files, and I'm using "remote" as an proxy for this property.)
One way might be to compare virConnectGetHostname with the local
hostname. This would fail if the client and server had the hostname
set incorrectly (eg. "localhost.localdomain").
Another way might be some hairy libvirt URL parsing.
Another way would be to speculatively open the disk images. This
would fail if the client and server had guests with coincidentally
named disk images.
Or I could write a qemu block driver that could use
virDomainBlockPeek.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
13 years, 7 months
[libvirt] [PATCH] Merge all returns paths from dispatcher into single path
by Daniel P. Berrange
The dispatcher functions have numerous places where they
return to the caller. This leads to duplicated cleanup
code, often resulting in memory leaks. It makes it harder
to ensure that errors are dispatched before freeing objects,
which may overwrite the original error.
The standard pattern is now
remoteDispatchXXX(...) {
int rv = -1;
....
if (XXX < 0)
goto cleanup;
...
if (XXXX < 0)
goto cleanup;
...
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
...free all other stuff..
return rv;
}
* daemon/remote.c: Centralize all cleanup paths
* daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
* daemon/dispatch.c, daemon/dispatch.h: Replace
remoteDispatchConnError with remoteDispatchError
removing unused virConnectPtr
NB this was a tedious manual conversion of the code, so it
has potential for errors....
---
daemon/dispatch.c | 3 +-
daemon/dispatch.h | 3 +-
daemon/remote.c | 4862 ++++++++++++++++++++++++++++++++---------------------
daemon/stream.c | 6 +-
4 files changed, 2912 insertions(+), 1962 deletions(-)
diff --git a/daemon/dispatch.c b/daemon/dispatch.c
index 4814017..7453451 100644
--- a/daemon/dispatch.c
+++ b/daemon/dispatch.c
@@ -112,8 +112,7 @@ void remoteDispatchOOMError (remote_error *rerr)
}
-void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn ATTRIBUTE_UNUSED)
+void remoteDispatchError(remote_error *rerr)
{
virErrorPtr verr = virGetLastError();
diff --git a/daemon/dispatch.h b/daemon/dispatch.h
index 85f8fc3..79d35ac 100644
--- a/daemon/dispatch.h
+++ b/daemon/dispatch.h
@@ -46,8 +46,7 @@ void remoteDispatchFormatError (remote_error *rerr,
void remoteDispatchAuthError (remote_error *rerr);
void remoteDispatchGenericError (remote_error *rerr);
void remoteDispatchOOMError (remote_error *rerr);
-void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn);
+void remoteDispatchError(remote_error *rerr);
int
diff --git a/daemon/remote.c b/daemon/remote.c
index 5de1055..8f4d6a6 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -64,6 +64,10 @@
#define VIR_FROM_THIS VIR_FROM_REMOTE
+#define virNetError(code, ...) \
+ virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
+
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
static virInterfacePtr get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface);
@@ -398,18 +402,18 @@ remoteDispatchOpen(struct qemud_server *server,
struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
{
const char *name;
- int flags, rc;
-
- /* Already opened? */
- if (conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection already open"));
- return -1;
- }
+ int flags;
+ int rv = -1;
virMutexLock(&server->lock);
virMutexLock(&client->lock);
virMutexUnlock(&server->lock);
+ if (conn) {
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection already open"));
+ goto cleanup;
+ }
+
name = args->name ? *args->name : NULL;
/* If this connection arrived on a readonly socket, force
@@ -423,12 +427,17 @@ remoteDispatchOpen(struct qemud_server *server,
? virConnectOpenReadOnly(name)
: virConnectOpen(name);
- if (client->conn == NULL)
- remoteDispatchConnError(rerr, NULL);
+ if (client->conn == NULL) {
+ goto cleanup;
+ }
+
+ rv = 0;
- rc = client->conn ? 0 : -1;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
virMutexUnlock(&client->lock);
- return rc;
+ return rv;
}
@@ -458,20 +467,25 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_error *rerr,
remote_supports_feature_args *args, remote_supports_feature_ret *ret)
{
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->supported = virDrvSupportsFeature(conn, args->feature);
if (ret->supported == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -483,16 +497,16 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
{
const char *type;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
type = virConnectGetType(conn);
if (type == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* We have to strdup because remoteDispatchClientRequest will
@@ -500,11 +514,16 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->type = strdup(type);
if (!ret->type) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -517,19 +536,24 @@ remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_version_ret *ret)
{
unsigned long hvVer;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virConnectGetVersion(conn, &hvVer) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->hv_ver = hvVer;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -542,19 +566,24 @@ remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_lib_version_ret *ret)
{
unsigned long libVer;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virConnectGetLibVersion(conn, &libVer) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->lib_ver = libVer;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -567,20 +596,25 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_hostname_ret *ret)
{
char *hostname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
hostname = virConnectGetHostname(conn);
if (hostname == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->hostname = hostname;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -593,20 +627,25 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_uri_ret *ret)
{
char *uri;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri = virConnectGetURI(conn);
if (uri == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->uri = uri;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -620,21 +659,26 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
{
unsigned int flags;
char *sysinfo;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
flags = args->flags;
sysinfo = virConnectGetSysinfo(conn, flags);
if (sysinfo == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->sysinfo = sysinfo;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -647,20 +691,25 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_max_vcpus_ret *ret)
{
char *type;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
type = args->type ? *args->type : NULL;
ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
if (ret->max_vcpus == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -673,15 +722,15 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_info_ret *ret)
{
virNodeInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virNodeGetInfo(conn, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
memcpy(ret->model, info.model, sizeof ret->model);
@@ -693,7 +742,12 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->cores = info.cores;
ret->threads = info.threads;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -706,20 +760,25 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_capabilities_ret *ret)
{
char *caps;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
caps = virConnectGetCapabilities(conn);
if (caps == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->capabilities = caps;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -732,22 +791,23 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_get_cells_free_memory_ret *ret)
{
int err;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->freeMems.freeMems_val, args->maxCells) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
err = virNodeGetCellsFreeMemory(conn,
@@ -755,13 +815,18 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
args->startCell,
args->maxCells);
if (err <= 0) {
- VIR_FREE(ret->freeMems.freeMems_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->freeMems.freeMems_len = err;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->freeMems.freeMems_val);
+ }
+ return rv;
}
@@ -775,19 +840,24 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_free_memory_ret *ret)
{
unsigned long long freeMem;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
freeMem = virNodeGetFreeMemory(conn);
if (freeMem == 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->freeMem = freeMem;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -800,32 +870,36 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_scheduler_type_args *args,
remote_domain_get_scheduler_type_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *type;
int nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
type = virDomainGetSchedulerType(dom, &nparams);
if (type == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->type = type;
ret->nparams = nparams;
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -837,51 +911,47 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_get_scheduler_parameters_args *args,
remote_domain_get_scheduler_parameters_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virSchedParameterPtr params;
int i, r, nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetSchedulerParameters(dom, params, &nparams);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* Serialise the scheduler parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -898,23 +968,27 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
ret->params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- virDomainFree(dom);
- VIR_FREE(params);
- return 0;
+ rv = 0;
-oom:
- remoteDispatchOOMError(rerr);
cleanup:
- virDomainFree(dom);
- for (i = 0 ; i < nparams ; i++)
- VIR_FREE(ret->params.params_val[i].field);
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0 ; i < nparams ; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -926,32 +1000,33 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_set_scheduler_parameters_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virSchedParameterPtr params;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr, _("Field %s too big for destination"),
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
args->params.params_val[i].field);
- return -1;
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -972,21 +1047,23 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetSchedulerParameters(dom, params, nparams);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(params);
+ return rv;
}
static int
@@ -998,28 +1075,25 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_block_stats_args *args,
remote_domain_block_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
struct _virDomainBlockStats stats;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
if (virDomainBlockStats(dom, path, &stats, sizeof stats) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
ret->rd_req = stats.rd_req;
ret->rd_bytes = stats.rd_bytes;
@@ -1027,7 +1101,14 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->wr_bytes = stats.wr_bytes;
ret->errs = stats.errs;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1039,28 +1120,25 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_interface_stats_args *args,
remote_domain_interface_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
struct _virDomainInterfaceStats stats;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
ret->rx_bytes = stats.rx_bytes;
ret->rx_packets = stats.rx_packets;
@@ -1071,7 +1149,14 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->tx_errs = stats.tx_errs;
ret->tx_drop = stats.tx_drop;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1083,48 +1168,42 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_memory_stats_args *args,
remote_domain_memory_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
struct _virDomainMemoryStat *stats;
unsigned int nr_stats, i;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate stats array for making dispatch call */
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
if (nr_stats == -1) {
- VIR_FREE(stats);
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
/* Allocate return buffer */
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
- VIR_FREE(stats);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Copy the stats into the xdr return structure */
@@ -1133,8 +1212,15 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->stats.stats_val[i].val = stats[i].val;
}
ret->stats.stats_len = nr_stats;
- VIR_FREE(stats);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(stats);
+ return rv;
}
static int
@@ -1146,21 +1232,21 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_block_peek_args *args,
remote_domain_block_peek_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
unsigned long long offset;
size_t size;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
offset = args->offset;
@@ -1168,29 +1254,32 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags;
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr,
- "%s", _("size > maximum buffer size"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("size > maximum buffer size"));
+ goto cleanup;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainBlockPeek(dom, path, offset, size,
ret->buffer.buffer_val, flags) == -1) {
- /* free(ret->buffer.buffer_val); - caller frees */
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->buffer.buffer_val);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1202,49 +1291,54 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_memory_peek_args *args,
remote_domain_memory_peek_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
unsigned long long offset;
size_t size;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
offset = args->offset;
size = args->size;
flags = args->flags;
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr,
- "%s", _("size > maximum buffer size"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("size > maximum buffer size"));
+ goto cleanup;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainMemoryPeek(dom, offset, size,
ret->buffer.buffer_val, flags) == -1) {
- /* free(ret->buffer.buffer_val); - caller frees */
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ if (dom)
+ virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->buffer.buffer_val);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1256,26 +1350,31 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_attach_device_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAttachDevice(dom, args->xml) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1287,26 +1386,31 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_attach_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1318,26 +1422,31 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_update_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1349,26 +1458,31 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCreate(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1380,23 +1494,28 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_create_with_flags_args *args,
remote_domain_create_with_flags_ret *ret)
{
- virDomainPtr dom;
+ int rv = -1;
+ virDomainPtr dom = NULL;
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCreateWithFlags(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1408,23 +1527,29 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_create_xml_args *args,
remote_domain_create_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1436,23 +1561,29 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_define_xml_args *args,
remote_domain_define_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainDefineXML(conn, args->xml);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1464,26 +1595,31 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDestroy(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1495,27 +1631,31 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_detach_device_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDetachDevice(dom, args->xml) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1527,27 +1667,31 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_detach_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1559,28 +1703,33 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_dump_xml_args *args,
remote_domain_dump_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virDomainGetXMLDesc(dom, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1592,9 +1741,11 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_from_native_args *args,
remote_domain_xml_from_native_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
@@ -1603,10 +1754,14 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->nativeConfig,
args->flags);
if (!ret->domainXml) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -1618,9 +1773,11 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_to_native_args *args,
remote_domain_xml_to_native_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
@@ -1629,10 +1786,14 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->domainXml,
args->flags);
if (!ret->nativeConfig) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -1645,26 +1806,31 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_autostart_args *args,
remote_domain_get_autostart_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetAutostart(dom, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1676,24 +1842,22 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_info_args *args,
remote_domain_get_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetInfo(dom, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->state = info.state;
@@ -1702,9 +1866,14 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->nr_virt_cpu = info.nrVirtCpu;
ret->cpu_time = info.cpuTime;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1716,27 +1885,32 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_max_memory_args *args,
remote_domain_get_max_memory_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->memory = virDomainGetMaxMemory(dom);
if (ret->memory == 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1748,27 +1922,32 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_max_vcpus_args *args,
remote_domain_get_max_vcpus_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainGetMaxVcpus(dom);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1780,46 +1959,46 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_security_label_args *args,
remote_domain_get_security_label_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virSecurityLabelPtr seclabel;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (VIR_ALLOC(seclabel) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return -1;
+ goto cleanup;
}
ret->label.label_len = strlen(seclabel->label) + 1;
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
- virDomainFree(dom);
- VIR_FREE(seclabel);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->label.label_val, seclabel->label);
ret->enforcing = seclabel->enforcing;
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(seclabel);
+ return rv;
}
static int
@@ -1832,33 +2011,38 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_security_model_ret *ret)
{
virSecurityModel secmodel;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
memset(&secmodel, 0, sizeof secmodel);
if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->model.model_len = strlen(secmodel.model) + 1;
if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->model.model_val, secmodel.model);
ret->doi.doi_len = strlen(secmodel.doi) + 1;
if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->doi.doi_val, secmodel.doi);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -1870,28 +2054,32 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_os_type_args *args,
remote_domain_get_os_type_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this */
ret->type = virDomainGetOSType(dom);
if (ret->type == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1907,52 +2095,46 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
virVcpuInfoPtr info = NULL;
unsigned char *cpumaps = NULL;
int info_len, i;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
+ goto cleanup;
}
if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+ goto cleanup;
}
/* Allocate buffers to take the results. */
if (VIR_ALLOC_N(info, args->maxinfo) < 0)
- goto oom;
+ goto no_memory;
if (args->maplen > 0 &&
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
- goto oom;
+ goto no_memory;
info_len = virDomainGetVcpus(dom,
info, args->maxinfo,
cpumaps, args->maplen);
if (info_len == -1) {
- remoteDispatchConnError(rerr, conn);
- VIR_FREE(info);
- VIR_FREE(cpumaps);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
/* Allocate the return buffer for info. */
ret->info.info_len = info_len;
if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < info_len; ++i) {
ret->info.info_val[i].number = info[i].number;
@@ -1967,17 +2149,24 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
ret->cpumaps.cpumaps_val = (char *) cpumaps;
+ cpumaps = NULL;
+
+ rv = 0;
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->info.info_val);
+ }
+ VIR_FREE(cpumaps);
VIR_FREE(info);
- virDomainFree(dom);
- return 0;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
-oom:
- VIR_FREE(info);
- VIR_FREE(cpumaps);
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -1989,27 +2178,32 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_vcpus_flags_args *args,
remote_domain_get_vcpus_flags_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainGetVcpusFlags(dom, args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2027,10 +2221,11 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
char *uri_in;
char **uri_out;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
@@ -2038,17 +2233,15 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource);
if (r == -1) {
- VIR_FREE(uri_out);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2058,12 +2251,18 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->cookie.cookie_val = cookie;
if (*uri_out == NULL) {
ret->uri_out = NULL;
- VIR_FREE(uri_out);
} else {
ret->uri_out = uri_out;
+ uri_out = NULL;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(uri_out);
+ return rv;
}
static int
@@ -2076,18 +2275,18 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
int r;
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2098,13 +2297,17 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags, dname, args->resource);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2116,11 +2319,12 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish_args *args,
remote_domain_migrate_finish_ret *ret)
{
- virDomainPtr ddom;
+ virDomainPtr ddom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ddom = virDomainMigrateFinish(conn, args->dname,
@@ -2129,13 +2333,18 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags);
if (ddom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->ddom, ddom);
- virDomainFree(ddom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (ddom)
+ virDomainFree(ddom);
+ return rv;
}
static int
@@ -2153,10 +2362,11 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
char *uri_in;
char **uri_out;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
@@ -2164,8 +2374,8 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
@@ -2173,8 +2383,7 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2184,7 +2393,12 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
ret->cookie.cookie_val = cookie;
ret->uri_out = *uri_out == NULL ? NULL : uri_out;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2196,11 +2410,12 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish2_args *args,
remote_domain_migrate_finish2_ret *ret)
{
- virDomainPtr ddom;
+ virDomainPtr ddom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ddom = virDomainMigrateFinish2(conn, args->dname,
@@ -2210,14 +2425,19 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
args->flags,
args->retcode);
if (ddom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->ddom, ddom);
- virDomainFree(ddom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (ddom)
+ virDomainFree(ddom);
+ return rv;
}
static int
@@ -2231,38 +2451,44 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
{
int r;
char *dname;
- struct qemud_client_stream *stream;
+ struct qemud_client_stream *stream = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dname = args->dname == NULL ? NULL : *args->dname;
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepareTunnel(conn, stream->st,
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
if (remoteAddClientStream(client, stream, 0) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ if (stream) {
+ virStreamAbort(stream->st);
+ remoteFreeClientStream(client, stream);
+ }
+ }
+ return rv;
}
static int
@@ -2274,33 +2500,40 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_domains_args *args,
remote_list_defined_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedDomains(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -2312,22 +2545,29 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_id_args *args,
remote_domain_lookup_by_id_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByID(conn, args->id);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2339,22 +2579,29 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_name_args *args,
remote_domain_lookup_by_name_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByName(conn, args->name);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2366,22 +2613,29 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_uuid_args *args,
remote_domain_lookup_by_uuid_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2393,18 +2647,24 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedDomains(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2416,36 +2676,39 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_pin_vcpu_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
- int rv;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
+ goto cleanup;
}
rv = virDomainPinVcpu(dom, args->vcpu,
(unsigned char *) args->cpumap.cpumap_val,
args->cpumap.cpumap_len);
if (rv == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2457,26 +2720,31 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_reboot_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainReboot(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2488,17 +2756,23 @@ remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_restore_args *args,
void *ret ATTRIBUTE_UNUSED)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virDomainRestore(conn, args->from) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2510,26 +2784,31 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_resume_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainResume(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2541,26 +2820,31 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_save_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSave(dom, args->to) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2572,26 +2856,31 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_core_dump_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCoreDump(dom, args->to, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2603,26 +2892,31 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetAutostart(dom, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2634,26 +2928,31 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_max_memory_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMaxMemory(dom, args->memory) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2665,26 +2964,31 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_memory_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMemory(dom, args->memory) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2696,26 +3000,31 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_memory_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMemoryFlags(dom, args->memory, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2730,37 +3039,37 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
remote_domain_set_memory_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virMemoryParameterPtr params;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -2799,21 +3108,23 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(params);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2830,41 +3141,37 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
remote_domain_get_memory_parameters_ret
* ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virMemoryParameterPtr params;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -2877,13 +3184,13 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
/* Serialise the memory parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -2918,25 +3225,27 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
params[i].value.b;
break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- success:
- virDomainFree(dom);
- VIR_FREE(params);
-
- return 0;
+success:
+ rv = 0;
- oom:
- remoteDispatchOOMError(rerr);
- cleanup:
- virDomainFree(dom);
- for (i = 0; i < nparams; i++)
- VIR_FREE(ret->params.params_val[i].field);
+no_memory:
+ virReportOOMError();
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
}
static int
@@ -2951,37 +3260,37 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
remote_domain_set_blkio_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virBlkioParameterPtr params;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -3020,21 +3329,23 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(params);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3051,41 +3362,37 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
remote_domain_get_blkio_parameters_ret
* ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virBlkioParameterPtr params;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -3098,13 +3405,13 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
/* Serialise the blkio parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
// remoteDispatchClientRequest will free this:
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -3139,25 +3446,29 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
params[i].value.b;
break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- success:
- virDomainFree(dom);
- VIR_FREE(params);
-
- return 0;
+success:
+ rv = 0;
- oom:
- remoteDispatchOOMError(rerr);
- cleanup:
- virDomainFree(dom);
- for (i = 0; i < nparams; i++)
- VIR_FREE(ret->params.params_val[i].field);
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
VIR_FREE(params);
- return -1;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -3169,26 +3480,31 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_vcpus_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetVcpus(dom, args->nvcpus) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3200,26 +3516,31 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_vcpus_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3231,26 +3552,31 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_shutdown_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainShutdown(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3262,26 +3588,31 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_suspend_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSuspend(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3293,26 +3624,31 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainUndefine(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3324,33 +3660,40 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_networks_args *args,
remote_list_defined_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedNetworks(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -3362,32 +3705,39 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_domains_args *args,
remote_list_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->ids.ids_val, args->maxids) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->ids.ids_len = virConnectListDomains(conn,
ret->ids.ids_val, args->maxids);
if (ret->ids.ids_len == -1) {
- VIR_FREE(ret->ids.ids_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->ids.ids_val);
+ }
+ return rv;
}
static int
@@ -3399,26 +3749,31 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_managed_save_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainManagedSave(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3430,27 +3785,32 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
remote_domain_has_managed_save_image_args *args,
remote_domain_has_managed_save_image_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
if (ret->ret == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3462,26 +3822,31 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_managed_save_remove_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainManagedSaveRemove(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3493,33 +3858,40 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_networks_args *args,
remote_list_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListNetworks(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -3531,26 +3903,31 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkCreate(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3562,22 +3939,29 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_create_xml_args *args,
remote_network_create_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkCreateXML(conn, args->xml);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3589,22 +3973,29 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_define_xml_args *args,
remote_network_define_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkDefineXML(conn, args->xml);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3616,26 +4007,31 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkDestroy(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3647,28 +4043,33 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_dump_xml_args *args,
remote_network_dump_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNetworkGetXMLDesc(net, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3680,26 +4081,31 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_get_autostart_args *args,
remote_network_get_autostart_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkGetAutostart(net, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3711,28 +4117,33 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_get_bridge_name_args *args,
remote_network_get_bridge_name_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->name = virNetworkGetBridgeName(net);
if (!ret->name) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3744,22 +4155,29 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_lookup_by_name_args *args,
remote_network_lookup_by_name_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkLookupByName(conn, args->name);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3771,22 +4189,29 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_lookup_by_uuid_args *args,
remote_network_lookup_by_uuid_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3798,26 +4223,31 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkSetAutostart(net, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3829,26 +4259,31 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkUndefine(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3860,18 +4295,24 @@ remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedNetworks(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3883,18 +4324,24 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDomains(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3906,18 +4353,24 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfNetworks(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -3931,18 +4384,24 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfInterfaces(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3954,33 +4413,40 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_interfaces_args *args,
remote_list_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListInterfaces(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -3992,18 +4458,24 @@ remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedInterfaces(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -4015,33 +4487,40 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
remote_list_defined_interfaces_args *args,
remote_list_defined_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedInterfaces(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -4053,22 +4532,29 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
remote_interface_lookup_by_name_args *args,
remote_interface_lookup_by_name_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceLookupByName(conn, args->name);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4080,22 +4566,29 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
remote_interface_lookup_by_mac_string_args *args,
remote_interface_lookup_by_mac_string_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceLookupByMACString(conn, args->mac);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4107,28 +4600,33 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_get_xml_desc_args *args,
remote_interface_get_xml_desc_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4140,22 +4638,29 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_define_xml_args *args,
remote_interface_define_xml_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceDefineXML(conn, args->xml, args->flags);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4167,26 +4672,31 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceUndefine(iface) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4198,26 +4708,31 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceCreate(iface, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4229,26 +4744,31 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceDestroy(iface, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
/*-------------------------------------------------------------*/
@@ -4262,10 +4782,12 @@ remoteDispatchAuthList(struct qemud_server *server,
void *args ATTRIBUTE_UNUSED,
remote_auth_list_ret *ret)
{
+ int rv = -1;
+
ret->types.types_len = 1;
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
virMutexLock(&server->lock);
virMutexLock(&client->lock);
@@ -4273,7 +4795,12 @@ remoteDispatchAuthList(struct qemud_server *server,
ret->types.types_val[0] = client->auth;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -4287,7 +4814,7 @@ remoteDispatchAuthList(struct qemud_server *server,
static int
remoteDispatchAuthSaslInit(struct qemud_server *server,
struct qemud_client *client,
- virConnectPtr conn,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
remote_message_header *hdr ATTRIBUTE_UNUSED,
remote_error *rerr,
void *args ATTRIBUTE_UNUSED,
@@ -4314,13 +4841,12 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
sa.len = sizeof(sa.data.stor);
if (getsockname(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr,
- _("failed to get sock address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to get sock address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4328,14 +4854,13 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
sa.len = sizeof(sa.data.stor);
if (getpeername(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("failed to get peer address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
VIR_FREE(localAddr);
goto error;
}
if ((remoteAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
VIR_FREE(localAddr);
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4439,7 +4964,7 @@ authfail:
error:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
virMutexUnlock(&client->lock);
- return -1;
+ goto error;
}
@@ -4600,7 +5125,7 @@ remoteDispatchAuthSaslStart(struct qemud_server *server,
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4701,7 +5226,7 @@ remoteDispatchAuthSaslStep(struct qemud_server *server,
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4878,7 +5403,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
client->auth = REMOTE_AUTH_NONE;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
authfail:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
@@ -5010,7 +5535,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
client->auth = REMOTE_AUTH_NONE;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
authfail:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
@@ -5059,33 +5584,40 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
remote_list_defined_storage_pools_args *args,
remote_list_defined_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedStoragePools(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -5097,33 +5629,40 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_storage_pools_args *args,
remote_list_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListStoragePools(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -5135,9 +5674,11 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
remote_find_storage_pool_sources_args *args,
remote_find_storage_pool_sources_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->xml =
@@ -5146,11 +5687,15 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
args->srcSpec ? *args->srcSpec : NULL,
args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -5163,26 +5708,31 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolCreate(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5194,22 +5744,29 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_create_xml_args *args,
remote_storage_pool_create_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5221,22 +5778,29 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_define_xml_args *args,
remote_storage_pool_define_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5248,26 +5812,31 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_build_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolBuild(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5280,26 +5849,31 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolDestroy(pool) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5311,26 +5885,31 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolDelete(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5342,26 +5921,31 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_refresh_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolRefresh(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5373,24 +5957,22 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_get_info_args *args,
remote_storage_pool_get_info_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
virStoragePoolInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolGetInfo(pool, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
ret->state = info.state;
@@ -5398,9 +5980,14 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->allocation = info.allocation;
ret->available = info.available;
- virStoragePoolFree(pool);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5412,28 +5999,33 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_dump_xml_args *args,
remote_storage_pool_dump_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5445,26 +6037,31 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_get_autostart_args *args,
remote_storage_pool_get_autostart_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolGetAutostart(pool, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5477,22 +6074,29 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_lookup_by_name_args *args,
remote_storage_pool_lookup_by_name_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolLookupByName(conn, args->name);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5504,22 +6108,29 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_lookup_by_uuid_args *args,
remote_storage_pool_lookup_by_uuid_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5531,31 +6142,37 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
remote_storage_pool_lookup_by_volume_args *args,
remote_storage_pool_lookup_by_volume_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
pool = virStoragePoolLookupByVolume(vol);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5567,26 +6184,31 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolSetAutostart(pool, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5598,26 +6220,31 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolUndefine(pool) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5629,18 +6256,24 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfStoragePools(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -5652,18 +6285,24 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedStoragePools(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -5675,44 +6314,48 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_pool_list_volumes_args *args,
remote_storage_pool_list_volumes_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- virStoragePoolFree(pool);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virStoragePoolListVolumes(pool,
ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ if (ret->names.names_len == -1) {
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5725,28 +6368,32 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_num_of_volumes_args *args,
remote_storage_pool_num_of_volumes_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virStoragePoolNumOfVolumes(pool);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5765,31 +6412,36 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_create_xml_args *args,
remote_storage_vol_create_xml_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
vol = virStorageVolCreateXML(pool, args->xml, args->flags);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5801,41 +6453,45 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_vol_create_xml_from_args *args,
remote_storage_vol_create_xml_from_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr clonevol, newvol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr clonevol = NULL;
+ virStorageVolPtr newvol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
clonevol = get_nonnull_storage_vol(conn, args->clonevol);
if (clonevol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
args->flags);
if (newvol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, newvol);
- virStorageVolFree(newvol);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (newvol)
+ virStorageVolFree(newvol);
+ if (clonevol)
+ virStorageVolFree(clonevol);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5847,26 +6503,31 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStorageVolDelete(vol, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5878,32 +6539,31 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_wipe_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int retval = -1;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- goto out;
+ goto cleanup;
}
if (virStorageVolWipe(vol, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- goto out;
+ goto cleanup;
}
- retval = 0;
+ rv = 0;
-out:
- if (vol != NULL) {
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
virStorageVolFree(vol);
- }
- return retval;
+ return rv;
}
static int
@@ -5915,33 +6575,36 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_get_info_args *args,
remote_storage_vol_get_info_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
virStorageVolInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStorageVolGetInfo(vol, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
ret->type = info.type;
ret->capacity = info.capacity;
ret->allocation = info.allocation;
- virStorageVolFree(vol);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5953,28 +6616,33 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_dump_xml_args *args,
remote_storage_vol_dump_xml_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -5987,28 +6655,33 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_get_path_args *args,
remote_storage_vol_get_path_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->name = virStorageVolGetPath(vol);
if (!ret->name) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6021,31 +6694,37 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_vol_lookup_by_name_args *args,
remote_storage_vol_lookup_by_name_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
vol = virStorageVolLookupByName(pool, args->name);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -6057,22 +6736,29 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
remote_storage_vol_lookup_by_key_args *args,
remote_storage_vol_lookup_by_key_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = virStorageVolLookupByKey(conn, args->key);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6085,22 +6771,29 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_vol_lookup_by_path_args *args,
remote_storage_vol_lookup_by_path_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = virStorageVolLookupByPath(conn, args->path);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6117,20 +6810,26 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_num_of_devices_args *args,
remote_node_num_of_devices_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virNodeNumOfDevices(conn,
args->cap ? *args->cap : NULL,
args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -6143,21 +6842,23 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_list_devices_args *args,
remote_node_list_devices_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
@@ -6165,12 +6866,17 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
args->cap ? *args->cap : NULL,
ret->names.names_val, args->maxnames, args->flags);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
@@ -6183,22 +6889,29 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_device_lookup_by_name_args *args,
remote_node_device_lookup_by_name_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_node_device(&ret->dev, dev);
- virNodeDeviceFree(dev);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6211,28 +6924,33 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dump_xml_args *args,
remote_node_device_dump_xml_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6245,18 +6963,18 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_get_parent_args *args,
remote_node_device_get_parent_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
const char *parent;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
parent = virNodeDeviceGetParent(dev);
@@ -6267,21 +6985,25 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
char **parent_p;
if (VIR_ALLOC(parent_p) < 0) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
*parent_p = strdup(parent);
if (*parent_p == NULL) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->parent = parent_p;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6294,28 +7016,32 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_num_of_caps_args *args,
remote_node_device_num_of_caps_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virNodeDeviceNumOfCaps(dev);
if (ret->num < 0) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6328,45 +7054,48 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_list_caps_args *args,
remote_node_device_list_caps_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
- virNodeDeviceFree(dev);
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virNodeDeviceListCaps(dev, ret->names.names_val,
args->maxnames);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6379,27 +7108,31 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dettach_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceDettach(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6412,27 +7145,31 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_re_attach_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceReAttach(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6445,27 +7182,31 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_reset_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceReset(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6478,23 +7219,29 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_create_xml_args *args,
remote_node_device_create_xml_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_node_device(&ret->dev, dev);
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6507,28 +7254,33 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceDestroy(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
+
static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client,
virConnectPtr conn,
@@ -6537,47 +7289,46 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
remote_storage_vol_upload_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int rv = -1;
struct qemud_client_stream *stream = NULL;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (virStorageVolUpload(vol, stream->st,
args->offset, args->length,
args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (remoteAddClientStream(client, stream, 0) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
goto cleanup;
}
rv = 0;
cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (vol)
virStorageVolFree(vol);
- if (stream && rv != 0)
+ if (stream && rv != 0) {
+ virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
+ }
return rv;
}
@@ -6589,47 +7340,46 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
remote_storage_vol_download_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int rv = -1;
struct qemud_client_stream *stream = NULL;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (virStorageVolDownload(vol, stream->st,
args->offset, args->length,
args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
goto cleanup;
}
rv = 0;
cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (vol)
virStorageVolFree(vol);
- if (stream && rv != 0)
+ if (stream && rv != 0) {
+ virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
+ }
return rv;
}
@@ -6647,15 +7397,16 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
{
int callbackID;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
- remoteDispatchFormatError(rerr, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+ goto cleanup;
}
if ((callbackID = virConnectDomainEventRegisterAny(conn,
@@ -6663,13 +7414,17 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
client, NULL)) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -6681,24 +7436,30 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] == -1) {
- remoteDispatchFormatError(rerr, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+ goto cleanup;
}
if (virConnectDomainEventDeregisterAny(conn,
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static void
@@ -6722,7 +7483,7 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
msg->hdr.status = REMOTE_OK;
if (remoteEncodeClientMessageHeader(msg) < 0)
- goto error;
+ goto cleanup;
/* Serialise the return header and event. */
xdrmem_create(&xdr,
@@ -6732,20 +7493,20 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
/* Skip over the header we just wrote */
if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
- goto xdr_error;
+ goto xdr_cleanup;
if (!(proc)(&xdr, data)) {
VIR_WARN("Failed to serialize domain event %d", procnr);
- goto xdr_error;
+ goto xdr_cleanup;
}
/* Update length word to include payload*/
len = msg->bufferOffset = xdr_getpos(&xdr);
if (xdr_setpos(&xdr, 0) == 0)
- goto xdr_error;
+ goto xdr_cleanup;
if (!xdr_u_int(&xdr, &len))
- goto xdr_error;
+ goto xdr_cleanup;
/* Send it. */
msg->async = 1;
@@ -6759,9 +7520,9 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
xdr_destroy(&xdr);
return;
-xdr_error:
+xdr_cleanup:
xdr_destroy(&xdr);
-error:
+cleanup:
VIR_FREE(msg);
}
@@ -6774,18 +7535,24 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_secrets_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfSecrets(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -6797,31 +7564,38 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_secrets_args *args,
remote_list_secrets_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
+ goto cleanup;
}
if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->uuids.uuids_len = virConnectListSecrets(conn, ret->uuids.uuids_val,
args->maxuuids);
if (ret->uuids.uuids_len == -1) {
- VIR_FREE(ret->uuids.uuids_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->uuids.uuids_val);
+ }
+ return rv;
}
static int
@@ -6833,22 +7607,28 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_define_xml_args *args,
remote_secret_define_xml_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretDefineXML(conn, args->xml, args->flags);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6860,32 +7640,37 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_get_value_args *args,
remote_secret_get_value_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
size_t value_size;
unsigned char *value;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
value = virSecretGetValue(secret, &value_size, args->flags);
if (value == NULL) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
ret->value.value_len = value_size;
ret->value.value_val = (char *)value;
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6897,26 +7682,31 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_get_xml_desc_args *args,
remote_secret_get_xml_desc_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->xml = virSecretGetXMLDesc(secret, args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6928,22 +7718,29 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_lookup_by_uuid_args *args,
remote_secret_lookup_by_uuid_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6955,27 +7752,31 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_set_value_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
args->value.value_len, args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6987,26 +7788,30 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virSecretUndefine(secret) < 0) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -7018,22 +7823,29 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_lookup_by_usage_args *args,
remote_secret_lookup_by_usage_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
@@ -7045,29 +7857,33 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
remote_domain_is_active_args *args,
remote_domain_is_active_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virDomainIsActive(domain);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7078,29 +7894,33 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
remote_domain_is_persistent_args *args,
remote_domain_is_persistent_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virDomainIsPersistent(domain);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7111,29 +7931,33 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
remote_domain_is_updated_args *args,
remote_domain_is_updated_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->updated = virDomainIsUpdated(domain);
if (ret->updated < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7144,29 +7968,33 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
remote_interface_is_active_args *args,
remote_interface_is_active_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virInterfaceIsActive(iface);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7177,29 +8005,33 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
remote_network_is_active_args *args,
remote_network_is_active_ret *ret)
{
- virNetworkPtr network;
+ virNetworkPtr network = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virNetworkIsActive(network);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(network);
- return -1;
+ goto cleanup;
}
- virNetworkFree(network);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (network)
+ virNetworkFree(network);
+ return rv;
}
static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7210,29 +8042,33 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
remote_network_is_persistent_args *args,
remote_network_is_persistent_ret *ret)
{
- virNetworkPtr network;
+ virNetworkPtr network = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virNetworkIsPersistent(network);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(network);
- return -1;
+ goto cleanup;
}
- virNetworkFree(network);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (network)
+ virNetworkFree(network);
+ return rv;
}
static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7243,29 +8079,33 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
remote_storage_pool_is_active_args *args,
remote_storage_pool_is_active_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virStoragePoolIsActive(pool);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7276,29 +8116,33 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
remote_storage_pool_is_persistent_args *args,
remote_storage_pool_is_persistent_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virStoragePoolIsPersistent(pool);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -7310,19 +8154,25 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_is_secure_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->secure = virConnectIsSecure(conn);
if (ret->secure < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7336,20 +8186,25 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_cpu_compare_ret *ret)
{
int result;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
result = virConnectCompareCPU(conn, args->xml, args->flags);
if (result == VIR_CPU_COMPARE_ERROR) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->result = result;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7363,10 +8218,11 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_cpu_baseline_ret *ret)
{
char *cpu;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
cpu = virConnectBaselineCPU(conn,
@@ -7374,13 +8230,17 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
args->xmlCPUs.xmlCPUs_len,
args->flags);
if (cpu == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->cpu = cpu;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7393,24 +8253,22 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_job_info_args *args,
remote_domain_get_job_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainJobInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetJobInfo(dom, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->type = info.type;
@@ -7426,9 +8284,14 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->fileProcessed = info.fileProcessed;
ret->fileRemaining = info.fileRemaining;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
@@ -7441,28 +8304,31 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_abort_job_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAbortJob(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
@@ -7475,28 +8341,31 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
remote_domain_migrate_set_max_downtime_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -7508,28 +8377,31 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_migrate_set_max_speed_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -7542,32 +8414,36 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_create_xml_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7581,11 +8457,11 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7601,17 +8477,16 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
if (!ret->xml)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
static int
@@ -7623,29 +8498,32 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_snapshot_num_args *args,
remote_domain_snapshot_num_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainSnapshotNum(domain, args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7657,30 +8535,29 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_list_names_args *args,
remote_domain_snapshot_list_names_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->nameslen) < 0) {
- virDomainFree(domain);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len = virDomainSnapshotListNames(domain,
@@ -7688,15 +8565,19 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
args->nameslen,
args->flags);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7709,32 +8590,36 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
remote_domain_snapshot_lookup_by_name_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7746,32 +8631,35 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_has_current_snapshot_args *args,
remote_domain_has_current_snapshot_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
int result;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
result = virDomainHasCurrentSnapshot(domain, args->flags);
if (result < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
ret->result = result;
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7784,32 +8672,36 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_snapshot_current_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCurrent(domain, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7823,11 +8715,11 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7841,17 +8733,16 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
if (virDomainRevertToSnapshot(snapshot, args->flags) == -1)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
static int
@@ -7865,11 +8756,11 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7883,17 +8774,16 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
if (virDomainSnapshotDelete(snapshot, args->flags) == -1)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
@@ -7907,21 +8797,22 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
void *ret ATTRIBUTE_UNUSED)
{
int callbackID;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
- remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
+ goto cleanup;
}
if (client->domainEventCallbackID[args->eventID] != -1) {
- remoteDispatchFormatError(rerr, _("domain event %d already registered"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), args->eventID);
+ goto cleanup;
}
if ((callbackID = virConnectDomainEventRegisterAny(conn,
@@ -7929,13 +8820,17 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
args->eventID,
domainEventCallbacks[args->eventID],
client, NULL)) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[args->eventID] = callbackID;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7949,31 +8844,36 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
void *ret ATTRIBUTE_UNUSED)
{
int callbackID = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
- remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
+ goto cleanup;
}
callbackID = client->domainEventCallbackID[args->eventID];
if (callbackID < 0) {
- remoteDispatchFormatError(rerr, _("domain event %d not registered"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
+ goto cleanup;
}
if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[args->eventID] = -1;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7987,22 +8887,29 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_lookup_by_name_args *args,
remote_nwfilter_lookup_by_name_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterLookupByName(conn, args->name);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
static int
@@ -8014,22 +8921,29 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_lookup_by_uuid_args *args,
remote_nwfilter_lookup_by_uuid_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8042,22 +8956,29 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_define_xml_args *args,
remote_nwfilter_define_xml_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterDefineXML(conn, args->xml);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8070,26 +8991,31 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNWFilterUndefine(nwfilter) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNWFilterFree(nwfilter);
- return -1;
+ goto cleanup;
}
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
static int
@@ -8101,33 +9027,40 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_nwfilters_args *args,
remote_list_nwfilters_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListNWFilters(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
@@ -8140,28 +9073,33 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_get_xml_desc_args *args,
remote_nwfilter_get_xml_desc_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNWFilterFree(nwfilter);
- return -1;
+ goto cleanup;
}
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8174,18 +9112,24 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_nwfilters_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfNWFilters(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -8198,33 +9142,36 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_block_info_args *args,
remote_domain_get_block_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainBlockInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->capacity = info.capacity;
ret->allocation = info.allocation;
ret->physical = info.physical;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -8236,29 +9183,32 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
qemu_monitor_command_args *args,
qemu_monitor_command_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
@@ -8272,25 +9222,24 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
int r;
- struct qemud_client_stream *stream;
- virDomainPtr dom;
+ struct qemud_client_stream *stream = NULL;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->domain);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainOpenConsole(dom,
@@ -8298,22 +9247,25 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
stream->st,
args->flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (stream && rv < 0) {
virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
- return -1;
}
-
- virDomainFree(dom);
- return 0;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
diff --git a/daemon/stream.c b/daemon/stream.c
index b94e3df..b71df92 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -403,7 +403,7 @@ remoteStreamHandleWriteData(struct qemud_client *client,
} else {
VIR_INFO0("Stream send failed");
stream->closed = 1;
- remoteDispatchConnError(&rerr, client->conn);
+ remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
}
@@ -437,7 +437,7 @@ remoteStreamHandleFinish(struct qemud_client *client,
ret = virStreamFinish(stream->st);
if (ret < 0) {
- remoteDispatchConnError(&rerr, client->conn);
+ remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
} else {
/* Send zero-length confirm */
@@ -569,7 +569,7 @@ remoteStreamHandleRead(struct qemud_client *client,
} else if (ret < 0) {
remote_error rerr;
memset(&rerr, 0, sizeof rerr);
- remoteDispatchConnError(&rerr, NULL);
+ remoteDispatchError(&rerr);
ret = remoteSerializeStreamError(client, &rerr, stream->procedure, stream->serial);
} else {
--
1.7.4.2
13 years, 7 months
[libvirt] [PATCHv9 0/4] persistent device modification for qemu
by KAMEZAWA Hiroyuki
Updated against the latest git tree, no major changes since a week ago.
Thank you for reviews in previous ones.
Purpose of patches:
Now, virsh at(de)tach-device/disk/...etc.. doesn't support to update
inactive domain's definition even with the --persistent flag.
To update persistent modification of inactive domains, we have to use
virsh edit.
So, if we want to update inactive domain definition with scripts, we need to
use other command/libs than libvirt. I'd like to use libvirt/virsh in scripts.
This patches adds to support for updating domain definition via virsh with
scripts. This series just includes 'disk' updates but I'll add more.
Thanks,
-Kame
13 years, 7 months
[libvirt] [PATCH] xen: Replace statsErrorFunc with a macro
by Matthias Bolte
Also mark error messages in block_stats.c for translation, add the
new macro to the msg_gen functions in cfg.mk and add block_stats.c
to po/POTFILES.in
---
cfg.mk | 1 +
po/POTFILES.in | 1 +
src/xen/block_stats.c | 79 ++++++++++++++++++------------------------------
3 files changed, 32 insertions(+), 49 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 94db937..e54d170 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -420,6 +420,7 @@ msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
msg_gen_function += VIR_ERROR
msg_gen_function += VIR_ERROR0
+msg_gen_function += statsError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cfa7cf8..766f8f6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -114,6 +114,7 @@ src/vbox/vbox_tmpl.c
src/vmware/vmware_conf.c
src/vmware/vmware_driver.c
src/vmx/vmx.c
+src/xen/block_stats.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index a28212c..1cb5455 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -31,34 +31,12 @@
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
-/**
- * statsErrorFunc:
- * @conn: the connection
- * @error: the error number
- * @func: the function failing
- * @info: extra information string
- * @value: extra information number
- *
- * Handle a stats error.
- */
-static void
-statsErrorFunc (virErrorNumber error, const char *func, const char *info,
- int value)
-{
- char fullinfo[1000];
- const char *errmsg;
-
- errmsg = virErrorMsg(error, info);
- if (func != NULL) {
- snprintf(fullinfo, sizeof (fullinfo) - 1, "%s: %s", func, info);
- fullinfo[sizeof (fullinfo) - 1] = 0;
- info = fullinfo;
- }
- virRaiseError(NULL, NULL, VIR_FROM_STATS_LINUX, error,
- VIR_ERR_ERROR,
- errmsg, info, NULL, value, 0, errmsg, info,
- value);
-}
+
+
+# define statsError(code, ...) \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, __FUNCTION__, \
+ __LINE__, __VA_ARGS__)
+
/*-------------------- Xen: block stats --------------------*/
@@ -194,8 +172,9 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
if (stats->rd_req == -1 && stats->rd_bytes == -1 &&
stats->wr_req == -1 && stats->wr_bytes == -1 &&
stats->errs == -1) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Failed to read any block statistics", domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to read any block statistics for domain %d"),
+ domid);
return -1;
}
@@ -207,8 +186,9 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
stats->wr_req == 0 && stats->wr_bytes == 0 &&
stats->errs == 0 &&
!check_bd_connected (priv, device, domid)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Frontend block device not connected", domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("Frontend block device not connected for domain %d"),
+ domid);
return -1;
}
@@ -217,18 +197,18 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
*/
if (stats->rd_bytes > 0) {
if (stats->rd_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->rd_bytes would overflow 64 bit counter",
- domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("stats->rd_bytes would overflow 64 bit counter for domain %d"),
+ domid);
return -1;
}
stats->rd_bytes *= 512;
}
if (stats->wr_bytes > 0) {
if (stats->wr_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->wr_bytes would overflow 64 bit counter",
- domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("stats->wr_bytes would overflow 64 bit counter for domain %d"),
+ domid);
return -1;
}
stats->wr_bytes *= 512;
@@ -346,20 +326,21 @@ xenLinuxDomainDeviceID(int domid, const char *path)
* beginning of the strings for better error messages
*/
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/sd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range sda[1-15] - sdiv[1-15]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "sda[1-15] - sdiv[1-15] for domain %d"), domid);
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/hd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range hda[1-63] - hdt[1-63]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "hda[1-63] - hdt[1-63] for domain %d"), domid);
else if (strlen(mod_path) >= 8 && STRPREFIX(mod_path, "/dev/xvd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range xvda[1-15] - xvdiz[1-15]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "xvda[1-15] - xvdiz[1-15] for domain %d"), domid);
else
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "unsupported path, use xvdN, hdN, or sdN", domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("unsupported path, use xvdN, hdN, or sdN for domain %d"),
+ domid);
VIR_FREE(mod_path);
--
1.7.0.4
13 years, 7 months
[libvirt] [PATCH v2] Remove virConnectPtr from virRaiseErrorFull
by Matthias Bolte
And from all related macros and functions.
---
I posted v1 a year ago :)
https://www.redhat.com/archives/libvir-list/2010-April/msg00164.html
src/conf/cpu_conf.c | 2 +-
src/conf/domain_conf.c | 2 +-
src/conf/domain_event.c | 2 +-
src/conf/interface_conf.c | 2 +-
src/conf/network_conf.c | 2 +-
src/conf/node_device_conf.h | 2 +-
src/conf/nwfilter_conf.h | 6 ++--
src/conf/secret_conf.h | 2 +-
src/conf/storage_conf.h | 2 +-
src/cpu/cpu.h | 2 +-
src/datatypes.c | 2 +-
src/esx/esx_private.h | 2 +-
src/esx/esx_vi.h | 2 +-
src/fdstream.c | 2 +-
src/interface/netcf_driver.c | 2 +-
src/internal.h | 3 +-
src/libvirt-qemu.c | 4 +-
src/libvirt.c | 26 +++++++++---------
src/libxl/libxl_conf.h | 2 +-
src/lxc/lxc_conf.h | 2 +-
src/lxc/veth.c | 2 +-
src/network/bridge_driver.c | 2 +-
src/nodeinfo.c | 2 +-
src/openvz/openvz_conf.h | 2 +-
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_conf.h | 2 +-
src/remote/remote_driver.c | 11 +++-----
src/security/security_manager.h | 2 +-
src/test/test_driver.c | 2 +-
src/uml/uml_conf.h | 2 +-
src/util/command.c | 2 +-
src/util/conf.c | 4 +-
src/util/event_poll.c | 2 +-
src/util/hooks.c | 2 +-
src/util/hostusb.c | 2 +-
src/util/interface.c | 2 +-
src/util/iptables.c | 2 +-
src/util/json.c | 2 +-
src/util/macvtap.c | 2 +-
src/util/network.c | 2 +-
src/util/pci.c | 2 +-
src/util/sexpr.c | 4 +-
src/util/stats_linux.c | 2 +-
src/util/sysinfo.c | 2 +-
src/util/util.c | 2 +-
src/util/virterror.c | 14 +++------
src/util/virterror_internal.h | 13 ++++-----
src/util/xml.c | 2 +-
src/vbox/vbox_driver.c | 2 +-
src/vbox/vbox_tmpl.c | 2 +-
src/vmware/vmware_conf.h | 2 +-
src/vmx/vmx.c | 2 +-
src/xen/block_stats.c | 57 +++++++++++++++++++--------------------
src/xen/block_stats.h | 2 +-
src/xen/xen_driver.c | 2 +-
src/xen/xen_hypervisor.c | 6 ++--
src/xen/xen_inotify.c | 2 +-
src/xen/xend_internal.c | 2 +-
src/xen/xm_internal.c | 2 +-
src/xen/xs_internal.c | 2 +-
src/xenapi/xenapi_driver.c | 2 +-
src/xenapi/xenapi_utils.c | 4 +-
src/xenxs/xenxs_private.h | 2 +-
63 files changed, 122 insertions(+), 132 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 7f03eaa..ad49916 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -32,7 +32,7 @@
#define VIR_FROM_THIS VIR_FROM_CPU
#define virCPUReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_CPU, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c827ef5..6b733d4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -415,7 +415,7 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
"smpsafe");
#define virDomainReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_DOMAIN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 5f086bd..f0380d3 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -32,7 +32,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define eventReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virDomainMeta {
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index b24526f..2fa2fa0 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -46,7 +46,7 @@ virInterfaceDefDevFormat(virBufferPtr buf,
const virInterfaceDefPtr def, int level);
#define virInterfaceReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_INTERFACE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_INTERFACE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index dcab9de..5738757 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -53,7 +53,7 @@ VIR_ENUM_IMPL(virNetworkForward,
"none", "nat", "route" )
#define virNetworkReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NETWORK, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets,
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index fe0f2bf..975abb3 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -219,7 +219,7 @@ struct _virDeviceMonitorState {
};
# define virNodeDeviceReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NODEDEV, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
int virNodeDeviceHasCap(const virNodeDeviceObjPtr dev, const char *cap);
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 9281f56..12e2a5c 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -647,9 +647,9 @@ void virNWFilterUnlockFilterUpdates(void);
int virNWFilterConfLayerInit(virHashIterator domUpdateCB);
void virNWFilterConfLayerShutdown(void);
-# define virNWFilterReportError(code, fmt...) \
- virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+# define virNWFilterReportError(code, fmt...) \
+ virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
+ __FUNCTION__, __LINE__, fmt)
typedef int (*virNWFilterRebuild)(virConnectPtr conn,
diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h
index 66294ce..4b47c52 100644
--- a/src/conf/secret_conf.h
+++ b/src/conf/secret_conf.h
@@ -27,7 +27,7 @@
# include "util.h"
# define virSecretReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_SECRET, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_DECL(virSecretUsageType)
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 9e1f534..271441a 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -324,7 +324,7 @@ static inline int virStoragePoolObjIsActive(virStoragePoolObjPtr pool) {
}
# define virStorageReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_STORAGE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
int virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 76d0e8e..9f01f17 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -31,7 +31,7 @@
# define virCPUReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_CPU, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/datatypes.c b/src/datatypes.c
index 3edd1ff..4c4cbd0 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -32,7 +32,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virLibConnError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/************************************************************************
diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h
index 1da2552..7ce237e 100644
--- a/src/esx/esx_private.h
+++ b/src/esx/esx_private.h
@@ -29,7 +29,7 @@
# include "esx_vi.h"
# define ESX_ERROR(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
typedef struct _esxPrivate {
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 560b2a6..75469ab 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -36,7 +36,7 @@
# define ESX_VI_ERROR(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
diff --git a/src/fdstream.c b/src/fdstream.c
index 3475bfd..d2325ae 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -45,7 +45,7 @@
#define VIR_FROM_THIS VIR_FROM_STREAMS
#define streamsReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Tunnelled migration stream support */
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index 0217b90..0190bf4 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -34,7 +34,7 @@
#define VIR_FROM_THIS VIR_FROM_INTERFACE
#define interfaceReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Main driver state */
diff --git a/src/internal.h b/src/internal.h
index 4641fc1..0fa097c 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -232,8 +232,7 @@
do { \
unsigned long __unsuppflags = flags & ~(supported); \
if (__unsuppflags) { \
- virReportErrorHelper(NULL, \
- VIR_FROM_THIS, \
+ virReportErrorHelper(VIR_FROM_THIS, \
VIR_ERR_INVALID_ARG, \
__FILE__, \
__FUNCTION__, \
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
index d914ac8..46727c8 100644
--- a/src/libvirt-qemu.c
+++ b/src/libvirt-qemu.c
@@ -29,11 +29,11 @@
#include "libvirt/libvirt-qemu.h"
#define virLibConnError(conn, error, info) \
- virReportErrorHelper(conn, VIR_FROM_NONE, error, NULL, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_NONE, error, NULL, __FUNCTION__, \
__LINE__, info)
#define virLibDomainError(domain, error, info) \
- virReportErrorHelper(NULL, VIR_FROM_DOM, error, NULL, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_DOM, error, NULL, __FUNCTION__, \
__LINE__, info)
int
diff --git a/src/libvirt.c b/src/libvirt.c
index 0da9885..9e6784b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -469,37 +469,37 @@ DllMain (HINSTANCE instance ATTRIBUTE_UNUSED,
#endif
#define virLibConnError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibDomainError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_DOM, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibNetworkError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NETWORK, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibStoragePoolError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_STORAGE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibStorageVolError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_STORAGE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibInterfaceError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_INTERFACE, code, __FILE__,\
+ virReportErrorHelper(VIR_FROM_INTERFACE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibNodeDeviceError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NODEDEV, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibSecretError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_SECRET, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibStreamError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_STREAMS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_STREAMS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibNWFilterError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-#define virLibDomainSnapshotError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_DOMAIN_SNAPSHOT, code, __FILE__, \
+#define virLibDomainSnapshotError(code, ...) \
+ virReportErrorHelper(VIR_FROM_DOMAIN_SNAPSHOT, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
@@ -1056,7 +1056,7 @@ do_open (const char *name,
STRCASEEQ(ret->uri->scheme, "xenapi") ||
#endif
false)) {
- virReportErrorHelper(NULL, VIR_FROM_NONE, VIR_ERR_INVALID_ARG,
+ virReportErrorHelper(VIR_FROM_NONE, VIR_ERR_INVALID_ARG,
__FILE__, __FUNCTION__, __LINE__,
_("libvirt was built without the '%s' driver"),
ret->uri->scheme);
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index f2f0d8a..8c87786 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -87,7 +87,7 @@ struct _libxlDomainObjPrivate {
# define libxlError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_LIBXL, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_LIBXL, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
virCapsPtr
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index f820d6d..4f1ead3 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -66,7 +66,7 @@ int lxcLoadDriverConfig(lxc_driver_t *driver);
virCapsPtr lxcCapsInit(void);
# define lxcError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_LXC, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_LXC, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#endif /* LXC_CONF_H */
diff --git a/src/lxc/veth.c b/src/lxc/veth.c
index 26bf4ff..a00aa23 100644
--- a/src/lxc/veth.c
+++ b/src/lxc/veth.c
@@ -27,7 +27,7 @@
#define VIR_FROM_THIS VIR_FROM_LXC
#define vethError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_LXC, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_LXC, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Functions */
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f3952d4..8b5c1b6 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -70,7 +70,7 @@
#define VIR_FROM_THIS VIR_FROM_NETWORK
#define networkReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NETWORK, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Main driver state */
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index e1c9ad3..facac15 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -51,7 +51,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define nodeReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#ifdef __linux__
diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h
index 4673fa6..9a57551 100644
--- a/src/openvz/openvz_conf.h
+++ b/src/openvz/openvz_conf.h
@@ -34,7 +34,7 @@
# include "threads.h"
# define openvzError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_OPENVZ, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_OPENVZ, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index ae2ed70..8f8c3ba 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -65,7 +65,7 @@
#define VIR_FROM_THIS VIR_FROM_PHYP
#define PHYP_ERROR(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
/*
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 94918f6..f2bfa1e 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -146,7 +146,7 @@ struct _qemuDomainCmdlineDef {
# define QEMUD_MIGRATION_NUM_PORTS 64
# define qemuReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_QEMU, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_QEMU, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b979f71..e30780c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -242,7 +242,7 @@ static int remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int
#endif /* HAVE_POLKIT */
#define remoteError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_REMOTE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_REMOTE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
@@ -8644,8 +8644,7 @@ remoteStreamHasError(virStreamPtr st) {
}
VIR_DEBUG0("Raising async error");
- virRaiseErrorFull(st->conn,
- __FILE__, __FUNCTION__, __LINE__,
+ virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__,
privst->err.domain,
privst->err.code,
privst->err.level,
@@ -10908,8 +10907,7 @@ cleanup:
* convert missing remote entry points into the unsupported
* feature error
*/
- virRaiseErrorFull(flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- __FILE__, __FUNCTION__, __LINE__,
+ virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__,
thiscall->err.domain,
VIR_ERR_NO_SUPPORT,
thiscall->err.level,
@@ -10921,8 +10919,7 @@ cleanup:
"%s", *thiscall->err.message);
rv = -1;
} else {
- virRaiseErrorFull(flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- __FILE__, __FUNCTION__, __LINE__,
+ virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__,
thiscall->err.domain,
thiscall->err.code,
thiscall->err.level,
diff --git a/src/security/security_manager.h b/src/security/security_manager.h
index 3f88801..8d7c220 100644
--- a/src/security/security_manager.h
+++ b/src/security/security_manager.h
@@ -24,7 +24,7 @@
# define VIR_SECURITY_MANAGER_H__
# define virSecurityReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_SECURITY, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_SECURITY, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 17f5ad9..0978214 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -117,7 +117,7 @@ static const virNodeInfo defaultNodeInfo = {
#define testError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_TEST, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_TEST, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static int testClose(virConnectPtr conn);
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
index 64df5f7..1105f84 100644
--- a/src/uml/uml_conf.h
+++ b/src/uml/uml_conf.h
@@ -64,7 +64,7 @@ struct uml_driver {
# define umlReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_UML, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_UML, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
virCapsPtr umlCapsInit (void);
diff --git a/src/util/command.c b/src/util/command.c
index 2e475a0..862a913 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -38,7 +38,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
enum {
diff --git a/src/util/conf.c b/src/util/conf.c
index 71a344f..4b8afb8 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -100,13 +100,13 @@ virConfError(virConfParserCtxtPtr ctxt,
/* Construct the string 'filename:line: info' if we have that. */
if (ctxt && ctxt->filename) {
- virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
+ virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
info, ctxt->filename, NULL,
ctxt->line, 0,
"%s:%d: %s", ctxt->filename, ctxt->line, info);
} else {
format = virErrorMsg(error, info);
- virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
+ virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
info, NULL, NULL,
ctxt ? ctxt->line : 0, 0,
format, info);
diff --git a/src/util/event_poll.c b/src/util/event_poll.c
index cd1ff4a..c5eedd3 100644
--- a/src/util/event_poll.c
+++ b/src/util/event_poll.c
@@ -44,7 +44,7 @@
#define VIR_FROM_THIS VIR_FROM_EVENT
#define virEventError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_EVENT, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_EVENT, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static int virEventPollInterruptLocked(void);
diff --git a/src/util/hooks.c b/src/util/hooks.c
index 819c95c..a409d77 100644
--- a/src/util/hooks.c
+++ b/src/util/hooks.c
@@ -42,7 +42,7 @@
#define VIR_FROM_THIS VIR_FROM_HOOK
#define virHookReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_HOOK, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_HOOK, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define LIBVIRT_HOOK_DIR SYSCONFDIR "/libvirt/hooks"
diff --git a/src/util/hostusb.c b/src/util/hostusb.c
index 2d6e414..d5b478b 100644
--- a/src/util/hostusb.c
+++ b/src/util/hostusb.c
@@ -55,7 +55,7 @@ struct _usbDevice {
#define VIR_FROM_THIS VIR_FROM_NONE
#define usbReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static int usbSysReadFile(const char *f_name, const char *d_name,
diff --git a/src/util/interface.c b/src/util/interface.c
index fe58823..5e1987a 100644
--- a/src/util/interface.c
+++ b/src/util/interface.c
@@ -42,7 +42,7 @@
#include "files.h"
#define ifaceError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NET, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#if __linux__
diff --git a/src/util/iptables.c b/src/util/iptables.c
index 59f5cc7..76d412c 100644
--- a/src/util/iptables.c
+++ b/src/util/iptables.c
@@ -46,7 +46,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define iptablesError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
enum {
diff --git a/src/util/json.c b/src/util/json.c
index be47f64..0daeae9 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -37,7 +37,7 @@
/* XXX fixme */
#define VIR_FROM_THIS VIR_FROM_NONE
#define virJSONError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 346eaf6..a7af0cb 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -63,7 +63,7 @@
# define VIR_FROM_THIS VIR_FROM_NET
# define macvtapError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NET, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
# define MACVTAP_NAME_PREFIX "macvtap"
diff --git a/src/util/network.c b/src/util/network.c
index 33028aa..eb16e0c 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -18,7 +18,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virSocketError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/*
diff --git a/src/util/pci.c b/src/util/pci.c
index ff950d1..945f32a 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -82,7 +82,7 @@ struct _pciDeviceList {
#define VIR_FROM_THIS VIR_FROM_NONE
#define pciReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Specifications referenced in comments:
diff --git a/src/util/sexpr.c b/src/util/sexpr.c
index da3d4b3..d6668f8 100644
--- a/src/util/sexpr.c
+++ b/src/util/sexpr.c
@@ -25,8 +25,8 @@
#define VIR_FROM_THIS VIR_FROM_SEXPR
#define virSexprError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
+ virReportErrorHelper(VIR_FROM_SEXPR, code, __FILE__, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
/**
* sexpr_new:
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index 5397320..173cdc5 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -30,7 +30,7 @@
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
# define virStatsError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 2b764ae..a865d25 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -41,7 +41,7 @@
#define VIR_FROM_THIS VIR_FROM_SYSINFO
#define virSmbiosReportError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_SYSINFO, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_SYSINFO, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define SYSINFO_SMBIOS_DECODER "dmidecode"
diff --git a/src/util/util.c b/src/util/util.c
index 526f51c..d4d2610 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -89,7 +89,7 @@ verify(sizeof(gid_t) <= sizeof (unsigned int) &&
#define VIR_FROM_THIS VIR_FROM_NONE
#define virUtilError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Like read(), but restarts after EINTR */
diff --git a/src/util/virterror.c b/src/util/virterror.c
index b7d8924..fbb4a45 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -663,7 +663,6 @@ virDispatchError(virConnectPtr conn)
/**
* virRaiseErrorFull:
- * @conn: the connection to the hypervisor if available
* @filename: filename where error was raised
* @funcname: function name where error was raised
* @linenr: line number where error was raised
@@ -682,8 +681,7 @@ virDispatchError(virConnectPtr conn)
* immediately if a callback is found and store it for later handling.
*/
void
-virRaiseErrorFull(virConnectPtr conn ATTRIBUTE_UNUSED,
- const char *filename ATTRIBUTE_UNUSED,
+virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
const char *funcname,
size_t linenr,
int domain,
@@ -1214,7 +1212,6 @@ virErrorMsg(virErrorNumber error, const char *info)
/**
* virReportErrorHelper:
*
- * @conn: the connection to the hypervisor if available
* @domcode: the virErrorDomain indicating where it's coming from
* @errcode: the virErrorNumber code for the error
* @filename: Source file error is dispatched from
@@ -1226,8 +1223,7 @@ virErrorMsg(virErrorNumber error, const char *info)
* Helper function to do most of the grunt work for individual driver
* ReportError
*/
-void virReportErrorHelper(virConnectPtr conn,
- int domcode,
+void virReportErrorHelper(int domcode,
int errcode,
const char *filename,
const char *funcname,
@@ -1248,7 +1244,7 @@ void virReportErrorHelper(virConnectPtr conn,
}
virerr = virErrorMsg(errcode, (errorMessage[0] ? errorMessage : NULL));
- virRaiseErrorFull(conn, filename, funcname, linenr,
+ virRaiseErrorFull(filename, funcname, linenr,
domcode, errcode, VIR_ERR_ERROR,
virerr, errorMessage, NULL,
-1, -1, virerr, errorMessage);
@@ -1324,7 +1320,7 @@ void virReportSystemErrorFull(int domcode,
if (!msgDetail)
msgDetail = errnoDetail;
- virRaiseErrorFull(NULL, filename, funcname, linenr,
+ virRaiseErrorFull(filename, funcname, linenr,
domcode, VIR_ERR_SYSTEM_ERROR, VIR_ERR_ERROR,
msg, msgDetail, NULL, -1, -1, msg, msgDetail);
errno = save_errno;
@@ -1348,7 +1344,7 @@ void virReportOOMErrorFull(int domcode,
const char *virerr;
virerr = virErrorMsg(VIR_ERR_NO_MEMORY, NULL);
- virRaiseErrorFull(NULL, filename, funcname, linenr,
+ virRaiseErrorFull(filename, funcname, linenr,
domcode, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
virerr, NULL, NULL, -1, -1, virerr, NULL);
}
diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h
index 8f32f41..df4b1d2 100644
--- a/src/util/virterror_internal.h
+++ b/src/util/virterror_internal.h
@@ -33,8 +33,7 @@ extern void *virUserData;
* *
************************************************************************/
int virErrorInitialize(void);
-void virRaiseErrorFull(virConnectPtr conn,
- const char *filename,
+void virRaiseErrorFull(const char *filename,
const char *funcname,
size_t linenr,
int domain,
@@ -46,22 +45,22 @@ void virRaiseErrorFull(virConnectPtr conn,
int int1,
int int2,
const char *fmt, ...)
- ATTRIBUTE_FMT_PRINTF(13, 14);
+ ATTRIBUTE_FMT_PRINTF(12, 13);
/* Includes 'dom' and 'net' for compatbility, but they're ignored */
-# define virRaiseError(conn, dom, net, domain, code, level, \
+# define virRaiseError(dom, net, domain, code, level, \
str1, str2, str3, int1, int2, msg, ...) \
- virRaiseErrorFull(conn, __FILE__, __FUNCTION__, __LINE__, \
+ virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
domain, code, level, str1, str2, str3, int1, int2, \
msg, __VA_ARGS__)
const char *virErrorMsg(virErrorNumber error, const char *info);
-void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode,
+void virReportErrorHelper(int domcode, int errcode,
const char *filename ATTRIBUTE_UNUSED,
const char *funcname ATTRIBUTE_UNUSED,
size_t linenr ATTRIBUTE_UNUSED,
const char *fmt, ...)
- ATTRIBUTE_FMT_PRINTF(7, 8);
+ ATTRIBUTE_FMT_PRINTF(6, 7);
void virReportSystemErrorFull(int domcode,
int theerrno,
diff --git a/src/util/xml.c b/src/util/xml.c
index 2c50e14..d2989e2 100644
--- a/src/util/xml.c
+++ b/src/util/xml.c
@@ -26,7 +26,7 @@
#define VIR_FROM_THIS VIR_FROM_XML
#define virGenericReportError(from, code, ...) \
- virReportErrorHelper(NULL, from, code, __FILE__, \
+ virReportErrorHelper(from, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virXMLError(code, ...) \
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 9526ee4..fc43b8c 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -66,7 +66,7 @@ static virDriver vboxDriverDummy;
#define VIR_FROM_THIS VIR_FROM_VBOX
#define vboxError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_VBOX, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_VBOX, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
int vboxRegister(void) {
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 3ca34dd..8241d34 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -133,7 +133,7 @@ typedef IMediumAttachment IHardDiskAttachment;
#endif /* VBOX_API_VERSION >= 3001 */
#define vboxError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_VBOX, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_VBOX, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define DEBUGPRUnichar(msg, strUtf16) \
diff --git a/src/vmware/vmware_conf.h b/src/vmware/vmware_conf.h
index e47ce62..b6d9d60 100644
--- a/src/vmware/vmware_conf.h
+++ b/src/vmware/vmware_conf.h
@@ -31,7 +31,7 @@
# define PROGRAM_SENTINAL ((char *)0x1)
# define vmwareError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_VMWARE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_VMWARE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
# define TYPE_PLAYER 0
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index b0d3218..daeedc3 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -471,7 +471,7 @@ def->parallels[0]...
#define VIR_FROM_THIS VIR_FROM_NONE
#define VMX_ERROR(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
#define VMX_BUILD_NAME_EXTRA(_suffix, _extra) \
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index 1918257..a28212c 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -42,8 +42,7 @@
* Handle a stats error.
*/
static void
-statsErrorFunc (virConnectPtr conn,
- virErrorNumber error, const char *func, const char *info,
+statsErrorFunc (virErrorNumber error, const char *func, const char *info,
int value)
{
char fullinfo[1000];
@@ -55,7 +54,7 @@ statsErrorFunc (virConnectPtr conn,
fullinfo[sizeof (fullinfo) - 1] = 0;
info = fullinfo;
}
- virRaiseError(conn, NULL, NULL, VIR_FROM_STATS_LINUX, error,
+ virRaiseError(NULL, NULL, VIR_FROM_STATS_LINUX, error,
VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info,
value);
@@ -180,8 +179,8 @@ check_bd_connected (xenUnifiedPrivatePtr priv, int device, int domid)
}
static int
-read_bd_stats (virConnectPtr conn, xenUnifiedPrivatePtr priv,
- int device, int domid, struct _virDomainBlockStats *stats)
+read_bd_stats(xenUnifiedPrivatePtr priv,
+ int device, int domid, struct _virDomainBlockStats *stats)
{
stats->rd_req = read_bd_stat (device, domid, "rd_req");
stats->rd_bytes = read_bd_stat (device, domid, "rd_sect");
@@ -195,8 +194,8 @@ read_bd_stats (virConnectPtr conn, xenUnifiedPrivatePtr priv,
if (stats->rd_req == -1 && stats->rd_bytes == -1 &&
stats->wr_req == -1 && stats->wr_bytes == -1 &&
stats->errs == -1) {
- statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Failed to read any block statistics", domid);
+ statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+ "Failed to read any block statistics", domid);
return -1;
}
@@ -208,8 +207,8 @@ read_bd_stats (virConnectPtr conn, xenUnifiedPrivatePtr priv,
stats->wr_req == 0 && stats->wr_bytes == 0 &&
stats->errs == 0 &&
!check_bd_connected (priv, device, domid)) {
- statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Frontend block device not connected", domid);
+ statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+ "Frontend block device not connected", domid);
return -1;
}
@@ -218,18 +217,18 @@ read_bd_stats (virConnectPtr conn, xenUnifiedPrivatePtr priv,
*/
if (stats->rd_bytes > 0) {
if (stats->rd_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->rd_bytes would overflow 64 bit counter",
- domid);
+ statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+ "stats->rd_bytes would overflow 64 bit counter",
+ domid);
return -1;
}
stats->rd_bytes *= 512;
}
if (stats->wr_bytes > 0) {
if (stats->wr_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->wr_bytes would overflow 64 bit counter",
- domid);
+ statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
+ "stats->wr_bytes would overflow 64 bit counter",
+ domid);
return -1;
}
stats->wr_bytes *= 512;
@@ -270,7 +269,7 @@ disk_re_match(const char *regex, const char *path, int *part)
}
int
-xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
+xenLinuxDomainDeviceID(int domid, const char *path)
{
int major, minor;
int part;
@@ -347,20 +346,20 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
* beginning of the strings for better error messages
*/
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/sd"))
- statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range sda[1-15] - sdiv[1-15]",
- domid);
+ statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
+ "invalid path, device names must be in the range sda[1-15] - sdiv[1-15]",
+ domid);
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/hd"))
- statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range hda[1-63] - hdt[1-63]",
- domid);
+ statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
+ "invalid path, device names must be in the range hda[1-63] - hdt[1-63]",
+ domid);
else if (strlen(mod_path) >= 8 && STRPREFIX(mod_path, "/dev/xvd"))
- statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range xvda[1-15] - xvdiz[1-15]",
- domid);
+ statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
+ "invalid path, device names must be in the range xvda[1-15] - xvdiz[1-15]",
+ domid);
else
- statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
- "unsupported path, use xvdN, hdN, or sdN", domid);
+ statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
+ "unsupported path, use xvdN, hdN, or sdN", domid);
VIR_FREE(mod_path);
@@ -373,12 +372,12 @@ xenLinuxDomainBlockStats (xenUnifiedPrivatePtr priv,
const char *path,
struct _virDomainBlockStats *stats)
{
- int device = xenLinuxDomainDeviceID(dom->conn, dom->id, path);
+ int device = xenLinuxDomainDeviceID(dom->id, path);
if (device < 0)
return -1;
- return read_bd_stats (dom->conn, priv, device, dom->id, stats);
+ return read_bd_stats(priv, device, dom->id, stats);
}
#endif /* __linux__ */
diff --git a/src/xen/block_stats.h b/src/xen/block_stats.h
index ba113d7..c94f645 100644
--- a/src/xen/block_stats.h
+++ b/src/xen/block_stats.h
@@ -19,7 +19,7 @@ extern int xenLinuxDomainBlockStats (xenUnifiedPrivatePtr priv,
virDomainPtr dom, const char *path,
struct _virDomainBlockStats *stats);
-extern int xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *dev);
+extern int xenLinuxDomainDeviceID(int domid, const char *dev);
# endif /* __linux__ */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 9f47722..2a07b7b 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -79,7 +79,7 @@ static int inside_daemon;
#endif
#define xenUnifiedError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_XEN, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_XEN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/**
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 8a9dae5..9a5b41d 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -843,7 +843,7 @@ struct xenUnifiedDriver xenHypervisorDriver = {
#define virXenError(code, ...) \
if (in_init == 0) \
- virReportErrorHelper(NULL, VIR_FROM_XEN, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_XEN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/**
@@ -870,11 +870,11 @@ virXenErrorFunc(virErrorNumber error, const char *func, const char *info,
if (func != NULL) {
snprintf(fullinfo, 999, "%s: %s", func, info);
fullinfo[999] = 0;
- virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
+ virRaiseError(NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo,
value);
} else {
- virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
+ virRaiseError(NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info,
value);
}
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 5a997e6..d809c45 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -46,7 +46,7 @@
#define VIR_FROM_THIS VIR_FROM_XEN_INOTIFY
#define virXenInotifyError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_XEN_INOTIFY, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_XEN_INOTIFY, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct xenUnifiedDriver xenInotifyDriver = {
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 57422d3..b608a43 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -68,7 +68,7 @@ virDomainXMLDevID(virDomainPtr domain,
int ref_len);
#define virXendError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_XEND, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_XEND, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virXendErrorInt(code, ival) \
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 9225808..db47a02 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -121,7 +121,7 @@ struct xenUnifiedDriver xenXMDriver = {
};
#define xenXMError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_XENXM, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_XENXM, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#ifndef WITH_XEN_INOTIFY
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index d9aad1f..c318f6c 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -83,7 +83,7 @@ struct xenUnifiedDriver xenStoreDriver = {
};
#define virXenStoreError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_XENSTORE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/************************************************************************
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 60b23c7..3fbdcc6 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -44,7 +44,7 @@
#define VIR_FROM_THIS VIR_FROM_XENAPI
#define xenapiError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/*
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index f50610a..ae20bf7 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -386,11 +386,11 @@ xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
if (buf == NULL && priv != NULL && priv->session != NULL) {
char *ret = returnErrorFromSession(priv->session);
- virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
+ virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
xen_session_clear_error(priv->session);
VIR_FREE(ret);
} else {
- virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf);
+ virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf);
}
}
diff --git a/src/xenxs/xenxs_private.h b/src/xenxs/xenxs_private.h
index 9bf1223..60d27d2 100644
--- a/src/xenxs/xenxs_private.h
+++ b/src/xenxs/xenxs_private.h
@@ -57,7 +57,7 @@
# define VIR_FROM_THIS VIR_FROM_NONE
# define XENXS_ERROR(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, __FUNCTION__, \
+ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
#endif /* __VIR_XENXS_PRIVATE_H__ */
--
1.7.0.4
13 years, 7 months