Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 17 participants
- 40169 discussions
17 Apr '11
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
2
2
[libvirt] [PATCH] esx: Move the Event type from the VI generator to manually written code
by Matthias Bolte 16 Apr '11
by Matthias Bolte 16 Apr '11
16 Apr '11
Accept all types on deserialization in order to accept all Event subtypes.
This will be used for the upcoming domain event support.
---
src/esx/esx_vi_generator.input | 21 ++++----
src/esx/esx_vi_generator.py | 1 -
src/esx/esx_vi_types.c | 100 ++++++++++++++++++++++++++++++++++++++-
src/esx/esx_vi_types.h | 34 ++++++++++++++
4 files changed, 142 insertions(+), 14 deletions(-)
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 98b5206..4ec9f93 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -209,16 +209,12 @@ object ElementDescription extends Description
end
-object Event
- Int key r
- Int chainId r
- DateTime createdTime r
- String userName r
- DatacenterEventArgument datacenter i
- ComputeResourceEventArgument computeResource i
- HostEventArgument host i
- VmEventArgument vm i
- String fullFormattedMessage o
+object EntityEventArgument extends EventArgument
+ String name r
+end
+
+
+object EventArgument
end
@@ -709,6 +705,11 @@ object VmDiskFileQueryFlags
end
+object VmEventArgument extends EntityEventArgument
+ ManagedObjectReference vm r
+end
+
+
object VmLogFileInfo extends FileInfo
end
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index ab127a3..ac15c7f 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1430,7 +1430,6 @@ additional_object_features = { "AutoStartDefaults" : Object.FEATURE__AN
"AutoStartPowerInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
"DatastoreHostMount" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"DatastoreInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST,
- "Event" : Object.FEATURE__LIST,
"FileInfo" : Object.FEATURE__DYNAMIC_CAST,
"FileQuery" : Object.FEATURE__DYNAMIC_CAST,
"HostConfigManager" : Object.FEATURE__ANY_TYPE,
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index d264583..dd83954 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -271,13 +271,14 @@
-#define ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, _extra, _deserialize) \
+#define ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, _extra1, _extra2, \
+ _deserialize) \
int \
esxVI_##_type##_Deserialize(xmlNodePtr node, esxVI_##_type **ptrptr) \
{ \
xmlNodePtr childNode = NULL; \
\
- _extra \
+ _extra1 \
\
if (ptrptr == NULL || *ptrptr != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
@@ -289,6 +290,8 @@
return -1; \
} \
\
+ _extra2 \
+ \
for (childNode = node->children; childNode != NULL; \
childNode = childNode->next) { \
if (childNode->type != XML_ELEMENT_NODE) { \
@@ -317,7 +320,8 @@
#define ESX_VI__TEMPLATE__DESERIALIZE(_type, _deserialize) \
- ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, /* nothing */, _deserialize)
+ ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, /* nothing */, /* nothing */, \
+ _deserialize)
@@ -647,6 +651,7 @@
__FUNCTION__, esxVI_Type_ToString(type)); \
return -1; \
}, \
+ /* nothing */, \
_deserialize)
@@ -773,6 +778,9 @@ esxVI_Type_ToString(esxVI_Type type)
case esxVI_Type_ManagedObjectReference:
return "ManagedObjectReference";
+ case esxVI_Type_Event:
+ return "Event";
+
#include "esx_vi_types.generated.typetostring"
case esxVI_Type_Other:
@@ -805,6 +813,8 @@ esxVI_Type_FromString(const char *type)
return esxVI_Type_MethodFault;
} else if (STREQ(type, "ManagedObjectReference")) {
return esxVI_Type_ManagedObjectReference;
+ } else if (STREQ(type, "Event")) {
+ return esxVI_Type_Event;
}
#include "esx_vi_types.generated.typefromstring"
@@ -1664,6 +1674,90 @@ esxVI_ManagedObjectReference_Deserialize
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Type: Event
+ */
+
+/* esxVI_Event_Alloc */
+ESX_VI__TEMPLATE__ALLOC(Event)
+
+/* esxVI_Event_Free */
+ESX_VI__TEMPLATE__FREE(Event,
+{
+ esxVI_Event_Free(&item->_next);
+ VIR_FREE(item->_actualType);
+
+ esxVI_Int_Free(&item->key);
+ esxVI_Int_Free(&item->chainId);
+ esxVI_DateTime_Free(&item->createdTime);
+ VIR_FREE(item->userName);
+ /* FIXME: datacenter is currently ignored */
+ /* FIXME: computeResource is currently ignored */
+ /* FIXME: host is currently ignored */
+ esxVI_VmEventArgument_Free(&item->vm);
+ VIR_FREE(item->fullFormattedMessage);
+})
+
+/* esxVI_Event_Validate */
+ESX_VI__TEMPLATE__VALIDATE(Event,
+{
+ ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key)
+ ESX_VI__TEMPLATE__PROPERTY__REQUIRE(chainId)
+ ESX_VI__TEMPLATE__PROPERTY__REQUIRE(createdTime)
+ ESX_VI__TEMPLATE__PROPERTY__REQUIRE(userName)
+ /* FIXME: datacenter is currently ignored */
+ /* FIXME: computeResource is currently ignored */
+ /* FIXME: host is currently ignored */
+})
+
+/* esxVI_Event_AppendToList */
+ESX_VI__TEMPLATE__LIST__APPEND(Event)
+
+/* esxVI_Event_CastFromAnyType */
+ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(Event,
+{
+ case esxVI_Type_Other:
+ /* Just accept everything here */
+ break;
+})
+
+/* esxVI_Event_CastListFromAnyType */
+ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(Event)
+
+/* esxVI_Event_Deserialize */
+ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(Event, /* nothing */,
+{
+ (*ptrptr)->_actualType =
+ (char *)xmlGetNsProp(node, BAD_CAST "type",
+ BAD_CAST "http://www.w3.org/2001/XMLSchema-instance");
+
+ if ((*ptrptr)->_actualType == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s is missing 'type' property"),
+ esxVI_Type_ToString((*ptrptr)->_type));
+ goto failure;
+ }
+},
+{
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, key)
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, chainId)
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, createdTime)
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, userName)
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(datacenter) /* FIXME */
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(computeResource) /* FIXME */
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(host) /* FIXME */
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(VmEventArgument, vm)
+ ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, fullFormattedMessage)
+
+ /* Don't warn about unexpected properties */
+ continue;
+})
+
+/* esxVI_Event_DeserializeList */
+ESX_VI__TEMPLATE__LIST__DESERIALIZE(Event)
+
+
+
#include "esx_vi_types.generated.c"
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index ac3741f..d141a38 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -55,8 +55,10 @@ typedef struct _esxVI_Fault esxVI_Fault;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Objects
*/
+
typedef struct _esxVI_MethodFault esxVI_MethodFault;
typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference;
+typedef struct _esxVI_Event esxVI_Event;
# include "esx_vi_types.generated.typedef"
@@ -78,6 +80,7 @@ enum _esxVI_Type {
esxVI_Type_Fault,
esxVI_Type_MethodFault,
esxVI_Type_ManagedObjectReference,
+ esxVI_Type_Event,
# include "esx_vi_types.generated.typeenum"
@@ -345,6 +348,37 @@ int esxVI_ManagedObjectReference_Deserialize
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Type: Event
+ */
+
+struct _esxVI_Event {
+ esxVI_Event *_next; /* optional */
+ esxVI_Type _type; /* required */
+ char *_actualType; /* required */
+
+ esxVI_Int *key; /* required */
+ esxVI_Int *chainId; /* required */
+ esxVI_DateTime *createdTime; /* required */
+ char *userName; /* required */
+ /* FIXME: datacenter is currently ignored */
+ /* FIXME: computeResource is currently ignored */
+ /* FIXME: host is currently ignored */
+ esxVI_VmEventArgument *vm; /* optional */
+ char *fullFormattedMessage; /* optional */
+};
+
+int esxVI_Event_Alloc(esxVI_Event **item);
+void esxVI_Event_Free(esxVI_Event **item);
+int esxVI_Event_Validate(esxVI_Event *item);
+int esxVI_Event_AppendToList(esxVI_Event **list, esxVI_Event *item);
+int esxVI_Event_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Event **item);
+int esxVI_Event_CastListFromAnyType(esxVI_AnyType *anyType, esxVI_Event **list);
+int esxVI_Event_Deserialize(xmlNodePtr node, esxVI_Event **item);
+int esxVI_Event_DeserializeList(xmlNodePtr node, esxVI_Event **list);
+
+
+
# include "esx_vi_types.generated.h"
--
1.7.0.4
1
0
Hi
Does anybody know if 'virsh memset' is working ok with its parameters
with the late libvirt code
(>= 0.8.8 )? With what libcgroup version ?
thanks
Zvi Dubitzky
Email:dubi@il.ibm.com
2
2
16 Apr '11
commit d4601696 introduces two more generated files: esx_vi.generated.h
and esx_vi.generated.h. But we do not include them into dist file.
It will break building if using dist file to build.
---
src/Makefile.am | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index dce866e..1eaa7d1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -332,7 +332,9 @@ ESX_DRIVER_GENERATED = \
esx/esx_vi_types.generated.typedef \
esx/esx_vi_types.generated.typeenum \
esx/esx_vi_types.generated.typetostring \
- esx/esx_vi_types.generated.typefromstring
+ esx/esx_vi_types.generated.typefromstring \
+ esx/esx_vi.generated.c \
+ esx/esx_vi.generated.h
ESX_DRIVER_EXTRA_DIST = \
esx/README \
--
1.7.1
2
2
Problem example:
# virsh -d 5 vol-create --pool default col.xml
vol-create: pool(optdata): default
vol-create: pool(optdata): col.xml
error: command 'vol-create' requires <file> option
It gets same "vshCmdOptDef" for both "--pool default"
and "col.xml".
This patch fixes it by increase "data_ct" when things like
"--pool default" is successfully parsed, so that could
get right "vshCmdOptDef" for the other arguments which
are not with option name together.
---
tools/virsh.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 19e3449..4d52bfb 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -11750,6 +11750,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
VSH_OT_INT ? _("number") : _("string"));
goto syntaxError;
}
+
+ data_ct++;
} else {
tkdata = NULL;
if (optstr) {
--
1.7.4
3
13
[libvirt] [PATCH] esx: Fix gcc 4.6 warning about initialized but unused variables
by Matthias Bolte 15 Apr '11
by Matthias Bolte 15 Apr '11
15 Apr '11
This is a speculative patch as I don't have gcc 4.6 at hand to test it.
Matthias
3
2
---
tools/libvirt-guests.init.sh | 2 ++
tools/libvirt-guests.sysconf | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh
index f247e5e..b462ea8 100644
--- a/tools/libvirt-guests.init.sh
+++ b/tools/libvirt-guests.init.sh
@@ -42,6 +42,7 @@ URIS=default
ON_BOOT=start
ON_SHUTDOWN=suspend
SHUTDOWN_TIMEOUT=0
+BOOT_TIMEOUT=0
test -f "$sysconfdir"/sysconfig/libvirt-guests &&
. "$sysconfdir"/sysconfig/libvirt-guests
@@ -166,6 +167,7 @@ start() {
gettext "already active"; echo
else
retval run_virsh "$uri" start "$name" >/dev/null && \
+ sleep $BOOT_TIMEOUT && \
gettext "done"; echo
fi
fi
diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf
index cd58728..e970a00 100644
--- a/tools/libvirt-guests.sysconf
+++ b/tools/libvirt-guests.sysconf
@@ -10,6 +10,9 @@
# libvirtd
#ON_BOOT=start
+# number of seconds to wait before starting the next guest
+#BOOT_TIMEOUT=0
+
# action taken on host shutdown
# - suspend all running guests are suspended using virsh managedsave
# - shutdown all running guests are asked to shutdown. Please be careful with
--
1.7.1
4
8
[libvirt] [PATCH v2] Merge all returns paths from dispatcher into single path
by Daniel P. Berrange 15 Apr '11
by Daniel P. Berrange 15 Apr '11
15 Apr '11
The dispatcher functions have numerous places where they
return to the caller. This leads to duplicated cleanup
code, often resulting in memory leaks. It makes it harder
to ensure that errors are dispatched before freeing objects,
which may overwrite the original error.
The standard pattern is now
remoteDispatchXXX(...) {
int rv = -1;
....
if (XXX < 0)
goto cleanup;
...
if (XXXX < 0)
goto cleanup;
...
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
...free all other stuff..
return rv;
}
* daemon/remote.c: Centralize all cleanup paths
* daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
* daemon/dispatch.c, daemon/dispatch.h: Replace
remoteDispatchConnError with remoteDispatchError
removing unused virConnectPtr
---
daemon/dispatch.c | 3 +-
daemon/dispatch.h | 3 +-
daemon/remote.c | 4889 ++++++++++++++++++++++++++++++++---------------------
daemon/stream.c | 6 +-
4 files changed, 2926 insertions(+), 1975 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..a25c095 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,45 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_get_scheduler_parameters_args *args,
remote_domain_get_scheduler_parameters_ret *ret)
{
- virDomainPtr dom;
- virSchedParameterPtr params;
+ virDomainPtr dom = NULL;
+ virSchedParameterPtr params = NULL;
int i, r, nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
- }
- if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
+ if (VIR_ALLOC_N(params, nparams) < 0)
+ goto no_memory;
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetSchedulerParameters(dom, params, &nparams);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* Serialise the scheduler parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -898,23 +966,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 +998,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;
+ virSchedParameterPtr params = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr, _("Field %s too big for destination"),
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
args->params.params_val[i].field);
- return -1;
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -972,21 +1045,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 +1073,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 +1099,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 +1118,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 +1147,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 +1166,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 +1210,15 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->stats.stats_val[i].val = stats[i].val;
}
ret->stats.stats_len = nr_stats;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(stats);
- return 0;
+ return rv;
}
static int
@@ -1146,21 +1230,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 +1252,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 +1289,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 +1348,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 +1384,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 +1420,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 +1456,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 +1492,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 +1525,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 +1559,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 +1593,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 +1629,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 +1665,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 +1701,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 +1739,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 +1752,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 +1771,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 +1784,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 +1804,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 +1840,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 +1864,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 +1883,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 +1920,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 +1957,46 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_security_label_args *args,
remote_domain_get_security_label_ret *ret)
{
- virDomainPtr dom;
- virSecurityLabelPtr seclabel;
+ virDomainPtr dom = NULL;
+ virSecurityLabelPtr seclabel = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (VIR_ALLOC(seclabel) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return -1;
+ goto cleanup;
}
ret->label.label_len = strlen(seclabel->label) + 1;
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
- virDomainFree(dom);
- VIR_FREE(seclabel);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->label.label_val, seclabel->label);
ret->enforcing = seclabel->enforcing;
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(seclabel);
+ return rv;
}
static int
@@ -1832,33 +2009,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 +2052,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 +2093,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 +2147,24 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
ret->cpumaps.cpumaps_val = (char *) cpumaps;
+ cpumaps = NULL;
- VIR_FREE(info);
- virDomainFree(dom);
- return 0;
+ rv = 0;
-oom:
- VIR_FREE(info);
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->info.info_val);
+ }
VIR_FREE(cpumaps);
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ VIR_FREE(info);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -1989,27 +2176,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 +2219,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 +2231,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 +2249,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 +2273,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 +2295,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 +2317,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 +2331,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 +2360,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 +2372,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 +2381,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 +2391,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 +2408,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 +2423,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 +2449,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 +2498,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 +2543,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 +2577,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 +2611,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 +2645,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 +2674,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 +2718,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 +2754,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 +2782,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 +2818,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 +2854,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 +2890,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 +2926,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 +2962,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 +2998,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 +3037,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;
+ virMemoryParameterPtr params = NULL;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -2799,21 +3106,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 +3139,37 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
remote_domain_get_memory_parameters_ret
* ret)
{
- virDomainPtr dom;
- virMemoryParameterPtr params;
+ virDomainPtr dom = NULL;
+ virMemoryParameterPtr params = NULL;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -2877,13 +3182,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 +3223,29 @@ 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);
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -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;
+ virBlkioParameterPtr params = NULL;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -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;
- virBlkioParameterPtr params;
+ virDomainPtr dom = NULL;
+ virBlkioParameterPtr params = NULL;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -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,28 +4841,25 @@ 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);
+ if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL)
goto error;
- }
/* Get remote address in form IPADDR:PORT */
sa.len = sizeof(sa.data.stor);
if (getpeername(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("failed to get peer address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
VIR_FREE(localAddr);
goto error;
}
if ((remoteAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
VIR_FREE(localAddr);
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4600,7 +5124,8 @@ 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();
+ remoteDispatchError(rerr);
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4701,7 +5226,8 @@ 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();
+ remoteDispatchError(rerr);
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -5059,33 +5585,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 +5630,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 +5675,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 +5688,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 +5709,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 +5745,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 +5779,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 +5813,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 +5850,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 +5886,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 +5922,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 +5958,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 +5981,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 +6000,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 +6038,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 +6075,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 +6109,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 +6143,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 +6185,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 +6221,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 +6257,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 +6286,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 +6315,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) {
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
}
- virStoragePoolFree(pool);
-
- return 0;
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5725,28 +6369,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 +6413,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 +6454,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 +6504,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 +6540,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 +6576,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 +6617,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 +6656,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 +6695,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 +6737,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 +6772,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 +6811,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 +6843,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 +6867,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 +6890,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 +6925,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 +6964,18 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_get_parent_args *args,
remote_node_device_get_parent_ret *ret)
{
- virNodeDevicePtr dev;
- const char *parent;
+ virNodeDevicePtr dev = NULL;
+ const char *parent = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
parent = virNodeDeviceGetParent(dev);
@@ -6267,21 +6986,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;
+ if (!(*parent_p = strdup(parent))) {
+ VIR_FREE(parent_p);
+ virReportOOMError();
+ goto cleanup;
}
ret->parent = parent_p;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6294,28 +7017,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 +7055,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 +7109,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 +7146,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 +7183,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 +7220,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 +7255,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 +7290,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 +7341,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 +7398,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 +7415,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 +7437,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 +7484,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 +7494,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 +7521,9 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
xdr_destroy(&xdr);
return;
-xdr_error:
+xdr_cleanup:
xdr_destroy(&xdr);
-error:
+cleanup:
VIR_FREE(msg);
}
@@ -6774,18 +7536,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 +7565,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 +7608,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 +7641,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 +7683,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 +7719,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 +7753,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 +7789,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 +7824,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 +7858,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 +7895,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 +7932,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 +7969,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 +8006,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 +8043,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 +8080,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 +8117,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 +8155,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 +8187,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 +8219,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 +8231,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 +8254,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 +8285,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 +8305,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 +8342,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 +8378,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
@@ -7541,33 +8414,37 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_create_xml_args *args,
remote_domain_snapshot_create_xml_ret *ret)
{
- virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainSnapshotPtr snapshot = NULL;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7581,11 +8458,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 +8478,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 +8499,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 +8536,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 +8566,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
@@ -7708,33 +8590,37 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
remote_domain_snapshot_lookup_by_name_args *args,
remote_domain_snapshot_lookup_by_name_ret *ret)
{
- virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainSnapshotPtr snapshot = NULL;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7746,32 +8632,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
@@ -7783,33 +8672,37 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_snapshot_current_args *args,
remote_domain_snapshot_current_ret *ret)
{
- virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainSnapshotPtr snapshot = NULL;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCurrent(domain, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7823,11 +8716,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 +8734,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 +8757,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 +8775,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 +8798,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 +8821,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 +8845,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 +8888,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 +8922,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 +8957,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 +8992,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 +9028,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 +9074,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 +9113,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 +9143,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 +9184,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 +9223,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 +9248,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
2
1
15 Apr '11
Hi all,
on a previous thread [1] Eric Blake mentioned:
> Without more code on the libvirt front, I think you're stuck renaming
> the guests to enforce naming order (assuming that libvirt even goes by
> sorted name order, as opposed to readdir() order where you have no control).
I poked around the code and experimented a little bit and found the following.
* When you first create new guest (or start already created guest) it is
assigned a sequential ID, name and also UUID. IDs start from 1 and increase as
long as libvirtd is running.
* When libvirt-guests wants to start/shutdown guests it relies on the file
/var/lib/libvirt/libvirt-guests. The format of this file is:
URI <list of uuids>
libvirt-guests script will start the guests as written in the file.
* The libvirt-guests file is initially created from the output of `virsh list'
and `virsh dominfo' (to get the UUID). virsh list will list the guests ordered
by their ID.
* Order of starting/stopping guests is unreliable.
The only thing that matters wrt start/shutdown order is the guest ID at the time
when the libvirt-guests file is generated. By default the order is the order in
which guests were created and it can change if you randomly stop/start guests
while libvirtd is running . Names or UUIDs don't play here at all.
I'm not exactly sure what IDs are used for but they change every time when a
guest is stopped/started manually. Which in turn reflects the order in which
libvirt-guests stops/starts all guests.
Example:
On a freshly installed system I created 5 guests in the following order:
a1, b1, a2, c1, a11. Then I left all guests running.
Upon stop/start of the libvirt-guests service the guests were stoped/started in
the same order.
Then I stopped libvirt-guests and libvirtd, renamed a1 to c2 and restarted both
services. c2 was first in the list - name doesn't matter.
virsh list shows IDs are 1 to 5 (c2 = 1).
Then I did: virsh shutdown c2 && virsh start c2. c2 now has id of 6.
Doing service libvirt-guests stop/start again now showed me a different order:
b1, a2, c1, a11, c2
You see how the order in which guests are started/stopped is unreliable. If I
were to stop c1 while all other guests were running and then start it again
(e.g. after attaching a new disk image) then it will have the highest ID number
and will become last in the list used for stopping/starting guests.
I'm not sure if this can easily be fixed or it needs the concept of
groups/relations implemented.
[1] - https://www.redhat.com/archives/libvir-list/2011-April/msg00789.html
Regards,
Alexander.
1
0
This patch series introduce a new API virDomainSetSchedulerParametersFlags
to change the scheduler setting persistently.
The new API accepts two flags, VIR_DOMAIN_SCHED_PARAMS_LIVE and
VIR_DOMAIN_SCHED_PARAMS_PERSISTENT, "LIVE" flag affects the running domain
config, "PERSISTENT" affects both the running and persistent domain config,
both flags require the domain is running. "LIVE" flags is used by default.
It's not like "setvcpus", which accepts "--live", "--config", and "--current"
flags, as scheduler setting relates with cgroup (QEMU/LXC), upper layer apps
probably need to use virDomainGetSchedulerParameter and virDomainSetSchedulerParametersFlags
together, such as virsh, virDomainGetSchedulerParameter looks up parameters,
so support changing the scheduler setting on inactive domain probably is not
good idea.
Regards
Osier
1
8
[libvirt] [PATCH 0/2] Network: Add TXT record and hosts support for DNS on virtual network
by Michal Novotny 15 Apr '11
by Michal Novotny 15 Apr '11
15 Apr '11
Hi,
this is the patch to introduce the TXT record support for the DNS
service on the virtual network. This can be defined using the
txt-record subelement in the dns element of the network XML
description.
First patch is adding TXT record support to the DNS service on
the virtual network and the second patch is adding support for
defining hosts for the DNS service.
The new definition syntax is:
<dns>
<txt-record name="example name" value="example value" />
<host ip='192.168.122.1'>
<hostname>gateway</hostname>
<hostname>host</hostname>
</host>
</dns>
Where multiple host elements can be defined to put the aliases
for specified IP addresses.
The patch series has been tested for the configuration and it
was working fine and also RelaxNG schema with the tests have
been both altered to add test cases to test those patches.
Both of the patches passed make, syntax checking and all the
tests.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Michal Novotny (2):
Network: Add TXT record support for virtual DNS service
Network: Add support for DNS hosts definition
docs/formatnetwork.html.in | 37 +++++-
docs/schemas/network.rng | 20 +++
src/conf/network_conf.c | 148 ++++++++++++++++++++
src/conf/network_conf.h | 26 ++++
src/network/bridge_driver.c | 93 ++++++++++++
tests/networkxml2xmlin/nat-network-dns-hosts.xml | 27 ++++
.../nat-network-dns-txt-record.xml | 24 +++
tests/networkxml2xmlout/nat-network-dns-hosts.xml | 27 ++++
.../nat-network-dns-txt-record.xml | 24 +++
tests/networkxml2xmltest.c | 2 +
10 files changed, 427 insertions(+), 1 deletions(-)
create mode 100644 tests/networkxml2xmlin/nat-network-dns-hosts.xml
create mode 100644 tests/networkxml2xmlin/nat-network-dns-txt-record.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-hosts.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-txt-record.xml
--
1.7.3.2
4
16
[libvirt] [PATCH] network: truncate bridges' dummy tap device names to IFNAMSIZ (15) chars
by Laine Stump 14 Apr '11
by Laine Stump 14 Apr '11
14 Apr '11
This patch addresses:
https://bugzilla.redhat.com/show_bug.cgi?id=694382
In order to give each libvirt-created bridge a fixed MAC address,
commit 5754dbd56d4738112a86776c09e810e32f7c3224, added code to create
a dummy tap device with guaranteed lowest MAC address and attach it to
the bridge. This tap device was given the name "${bridgename}-nic".
However, an interface device name must be IFNAMSIZ (15) characters or
less, so a valid ${bridgename} such as "verylongname123" (15
characters) would lead to an invalid tap device name
("verylongname123-nic" - 19 characters), and that in turn led to a
failure to bring up the network.
The solution is to shorten the part of the original name used to
generate the tap device name. However, simply truncating it is
insufficient, because the last few characters of an interface name are
often a number used to indicate one of a list of several similar
devices (for example, "verylongname123", "verylongname124", etc) and
simple truncation would lead to duplicate names. So instead we take
the first 8 characters of $bridgename ("verylong" in the example), add
on the final 3 bytes ("123"), then add "-nic" (so "verylong123-nic").
Not pretty, but it is much more likely to generate a unique name, and
is reproducible (unlike, say, a random number).
---
src/network/bridge_driver.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ea2bfd4..ef89bf5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -143,7 +143,19 @@ networkBridgeDummyNicName(const char *brname)
{
char *nicname;
- virAsprintf(&nicname, "%s-nic", brname);
+ if (strlen(brname) > (IFNAMSIZ - 5)) {
+ /* because the length of an ifname is limited to IFNAMSIZ-1
+ * (usually 15), and we're adding 4 more characters, we must
+ * truncate the original name to 11 to fit. In order to catch
+ * a possible numeric ending (eg virbr0, virbr1, etc), we grab
+ * the first 8 and last 3 characters of the string.
+ */
+ virAsprintf(&nicname, "%.*s%s-nic",
+ IFNAMSIZ - 8, /* space for last 3 chars + "-nic" + NULL */
+ brname, brname + strlen(brname) - 3);
+ } else {
+ virAsprintf(&nicname, "%s-nic", brname);
+ }
return nicname;
}
--
1.7.3.4
2
6
Subject: ppc: Enable starting of VMs on ppc host
Due to differences in /proc/cpuinfo the parsing of the cpu data is
different between architectures. On PPC /proc/cpuinfo looks like this:
[original formatting with tabs]
processor : 0
cpu : PPC970MP, altivec supported
clock : 2297.700000MHz
revision : 1.1 (pvr 0044 0101)
processor : 1
cpu : PPC970MP, altivec supported
clock : 2297.700000MHz
revision : 1.1 (pvr 0044 0101)
[..]
timebase : 14318000
platform : pSeries
model : IBM,8844-AC1
machine : CHRP IBM,8844-AC1
The patch adapts the parsing of the data found in /proc/cpuinfo.
/sys/devices/system/cpu/cpuX/topology/physical_package_id also
always returns -1. Check for it on ppc and make it '0' if found negative.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
Index: libvirt/src/nodeinfo.c
===================================================================
--- libvirt.orig/src/nodeinfo.c
+++ libvirt/src/nodeinfo.c
@@ -163,7 +163,14 @@ cleanup:
static int parse_socket(unsigned int cpu)
{
- return get_cpu_value(cpu, "topology/physical_package_id", false);
+ int ret = get_cpu_value(cpu, "topology/physical_package_id", false);
+#if defined(__powerpc__) || \
+ defined(__powerpc64__)
+ /* ppc has -1 */
+ if (ret < 0)
+ ret = 0;
+#endif
+ return ret;
}
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
@@ -206,6 +213,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuin
return -1;
}
nodeinfo->cpus++;
+#if defined(__x86_64__) || \
+ defined(__amd64__) || \
+ defined(__i386__)
} else if (STRPREFIX(buf, "cpu MHz")) {
char *p;
unsigned int ui;
@@ -237,6 +247,27 @@ int linuxNodeInfoCPUPopulate(FILE *cpuin
&& id > nodeinfo->cores)
nodeinfo->cores = id;
}
+#elif defined(__powerpc__) || \
+ defined(__powerpc64__)
+ } else if (STRPREFIX(buf, "clock")) {
+ char *p;
+ unsigned int ui;
+ buf += 5;
+ while (*buf && c_isspace(*buf))
+ buf++;
+ if (*buf != ':' || !buf[1]) {
+ nodeReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("parsing cpuinfo cpu MHz"));
+ return -1;
+ }
+ if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
+ /* Accept trailing fractional part. */
+ && (*p == '\0' || *p == '.' || c_isspace(*p)))
+ nodeinfo->mhz = ui;
+ }
+#else
+# warning Parser for /proc/cpuinfo needs to be adapted for your
architecture
+#endif
}
if (!nodeinfo->cpus) {
2
3
This patch enables the migration of Qemu VMs between hosts of different
endianess. I tested this by migrating a i686 VM between a x86 and ppc64
host.
I am converting the 'int's in the VM's state header to uint32_t assuming
this doesn't break compatibility with existing deployments other than Linux.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -43,6 +43,7 @@
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/un.h>
+#include <byteswap.h>
#include "qemu_driver.h"
@@ -1881,13 +1882,22 @@ VIR_ENUM_IMPL(qemudSaveCompression, QEMU
struct qemud_save_header {
char magic[sizeof(QEMUD_SAVE_MAGIC)-1];
- int version;
- int xml_len;
- int was_running;
- int compressed;
- int unused[15];
+ uint32_t version;
+ uint32_t xml_len;
+ uint32_t was_running;
+ uint32_t compressed;
+ uint32_t unused[15];
};
+static inline void
+bswap_header(struct qemud_save_header *hdr) {
+ hdr->version = bswap_32(hdr->version);
+ hdr->xml_len = bswap_32(hdr->xml_len);
+ hdr->was_running = bswap_32(hdr->was_running);
+ hdr->compressed = bswap_32(hdr->compressed);
+}
+
+
/* return -errno on failure, or 0 on success */
static int
qemuDomainSaveHeader(int fd, const char *path, char *xml,
@@ -3097,6 +3107,11 @@ qemuDomainSaveImageOpen(struct qemud_dri
}
if (header.version > QEMUD_SAVE_VERSION) {
+ /* convert endianess and try again */
+ bswap_header(&header);
+ }
+
+ if (header.version > QEMUD_SAVE_VERSION) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("image version is not supported (%d > %d)"),
header.version, QEMUD_SAVE_VERSION);
3
12
Phyp still had several memory leaks and in general some bad
copy-and-paste design. This series consolidates some common
patterns into simpler helpers, avoiding leaks in the process.
Eric Blake (4):
phyp: prefer memcpy over memmove when legal
phyp: avoid memory leaks in return values
phyp: avoid memory leaks in command values
phyp: another simplification
src/phyp/phyp_driver.c | 1128 +++++++-----------------------------------------
1 files changed, 163 insertions(+), 965 deletions(-)
--
1.7.4.2
2
7
gcc 4.6 warns when a variable is initialized but isn't used afterwards:
vmware/vmware_driver.c:449:18: warning: variable 'vmxPath' set but not used [-Wunused-but-set-variable]
This patch fixes these warnings. There are still 2 offending files:
- vbox_tmpl.c: the variable is used inside an #ifdef and is assigned several
times outside of #ifdef. Fixing the warning would have required wrapping
all the assignment inside #ifdef which hurts readability.
vbox/vbox_tmpl.c: In function 'vboxAttachDrives':
vbox/vbox_tmpl.c:3918:22: warning: variable 'accessMode' set but not used [-Wunused-but-set-variable]
- esx_vi_types.generated.c: the name implies it's generated code and I
didn't want to dive into the code generator
esx/esx_vi_types.generated.c: In function 'esxVI_FileQueryFlags_Free':
esx/esx_vi_types.generated.c:1203:3: warning: variable 'item' set but not used [-Wunused-but-set-variable]
---
src/nwfilter/nwfilter_ebiptables_driver.c | 7 +++----
src/util/logging.c | 3 +--
src/vmware/vmware_driver.c | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 6c9c470..977f74b 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -1634,7 +1634,7 @@ iptablesCreateRuleInstanceStateCtrl(virNWFilterDefPtr nwfilter,
bool isIPv6)
{
int rc;
- int directionIn = 0, directionOut = 0;
+ int directionIn = 0;
char chainPrefix[2];
bool maySkipICMP, inout = false;
char *matchState = NULL;
@@ -1643,9 +1643,8 @@ iptablesCreateRuleInstanceStateCtrl(virNWFilterDefPtr nwfilter,
if ((rule->tt == VIR_NWFILTER_RULE_DIRECTION_IN) ||
(rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT)) {
directionIn = 1;
- directionOut = inout = (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT);
- } else
- directionOut = 1;
+ inout = (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT);
+ }
chainPrefix[0] = 'F';
diff --git a/src/util/logging.c b/src/util/logging.c
index 9d18752..bb3ba13 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -389,7 +389,7 @@ static void virLogDumpAllFD(const char *msg, int len) {
void
virLogEmergencyDumpAll(int signum) {
int len;
- int oldLogStart, oldLogLen, oldLogEnd;
+ int oldLogStart, oldLogLen;
switch (signum) {
#ifdef SIGFPE
@@ -444,7 +444,6 @@ virLogEmergencyDumpAll(int signum) {
* so it's best to reset it first.
*/
oldLogStart = virLogStart;
- oldLogEnd = virLogEnd;
oldLogLen = virLogLen;
virLogEnd = 0;
virLogLen = 0;
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index b5e416b..bbfb1a4 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -467,7 +467,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED)
}
vmwareSetSentinal(cmd, vmw_types[driver->type]);
- vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
+ vmwareSetSentinal(cmd, vmxPath);
if (vm->state != VIR_DOMAIN_RUNNING) {
--
1.7.4.4
2
6
This series covers several things I came across while improving the
semantic of phypVolumeGetKey.
Matthias
3
17
Make: passed
Make check: passed
Make syntax-check: passed
Hi,
this is the commit to introduce the function to create new character
device definition for the domain as advised by Cole Robinson
<crobinso(a)redhat.com>.
The function is used on the relevant places and also new tests has
been added.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
---
src/conf/domain_conf.c | 20 +++++++++--
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 5 ++-
src/xenxs/xen_sxpr.c | 7 ++--
src/xenxs/xen_xm.c | 8 +++-
.../qemuxml2argv-serial-target-port-auto.xml | 31 ++++++++++++++++
.../qemuxml2xmlout-serial-target-port-auto.xml | 37 ++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
9 files changed, 102 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 90a1317..a80719c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3212,6 +3212,22 @@ error:
goto cleanup;
}
+/* Create a new character device definition and set
+ * default port.
+ */
+virDomainChrDefPtr
+virDomainChrDefNew(void) {
+ virDomainChrDefPtr def = NULL;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ def->target.port = -1;
+ return def;
+}
+
/* Parse the XML definition for a character device
* @param node XML nodeset to parse for net definition
*
@@ -3260,10 +3276,8 @@ virDomainChrDefParseXML(virCapsPtr caps,
virDomainChrDefPtr def;
int remaining;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
type = virXMLPropString(node, "type");
if (type == NULL) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95bd11e..ecf44ca 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1229,6 +1229,8 @@ void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
+virDomainChrDefPtr virDomainChrDefNew(void);
+
/* live == true means def describes an active domain (being migrated or
* restored) as opposed to a new persistent configuration of the domain */
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 54e4482..4175ca0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -201,6 +201,7 @@ virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
virDomainChrDefFree;
+virDomainChrDefNew;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fea0068..029ed7d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -36,6 +36,7 @@
#include "c-ctype.h"
#include "domain_nwfilter.h"
#include "qemu_audit.h"
+#include "domain_conf.h"
#include <sys/utsname.h>
#include <sys/stat.h>
@@ -5315,8 +5316,8 @@ qemuParseCommandLineChr(const char *val)
{
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0)
- goto no_memory;
+ if (!(def = virDomainChrDefNew()))
+ goto error;
if (STREQ(val, "null")) {
def->source.type = VIR_DOMAIN_CHR_TYPE_NULL;
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 3a412a6..b590517 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -168,10 +168,8 @@ xenParseSxprChar(const char *value,
char *tmp;
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
prefix = value;
@@ -1328,6 +1326,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[def->nserials++] = chr;
}
}
@@ -1343,6 +1342,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[def->nparallels++] = chr;
}
} else {
@@ -1350,6 +1350,7 @@ xenParseSxpr(const struct sexpr *root,
if (!(def->console = xenParseSxprChar("pty", tty)))
goto error;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
VIR_FREE(tty);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 22ad788..89f75a5 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -36,6 +36,7 @@
#include "xenxs_private.h"
#include "xen_xm.h"
#include "xen_sxpr.h"
+#include "domain_conf.h"
/* Convenience method to grab a int from the config file object */
static int xenXMConfigGetBool(virConfPtr conf,
@@ -957,6 +958,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[0] = chr;
def->nparallels++;
chr = NULL;
@@ -981,8 +983,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
continue;
}
- if (VIR_ALLOC(chr) < 0)
- goto no_memory;
+ if (!(chr = virDomainChrDefNew()))
+ goto cleanup;
if (!(chr = xenParseSxprChar(port, NULL)))
goto cleanup;
@@ -1010,6 +1012,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[0] = chr;
def->nserials++;
}
@@ -1018,6 +1021,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (!(def->console = xenParseSxprChar("pty", NULL)))
goto cleanup;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml
new file mode 100644
index 0000000..0f98f51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'/>
+ <serial type='null'/>
+ <serial type='stdio'/>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
new file mode 100644
index 0000000..878418a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <serial type='null'>
+ <target port='1'/>
+ </serial>
+ <serial type='stdio'>
+ <target port='2'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b86dbee..27330a9 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -195,6 +195,7 @@ mymain(int argc, char **argv)
DO_TEST_DIFFERENT("console-compat-auto");
DO_TEST_DIFFERENT("disk-scsi-device-auto");
DO_TEST_DIFFERENT("console-virtio");
+ DO_TEST_DIFFERENT("serial-target-port-auto");
virCapabilitiesFree(driver.caps);
--
1.7.3.2
3
2
[libvirt] [PATCH v2] Spice: support auid, images and stream compression
by Michal Privoznik 14 Apr '11
by Michal Privoznik 14 Apr '11
14 Apr '11
This extends the SPICE XML to allow variable compression settings for audio,
images and streaming:
<graphics type='spice' port='5901' tlsPort='-1' autoport='yes'>
<image compression='auto_glz'/>
<jpeg compression='auto'/>
<zlib compression='auto'/>
<playback compression='on'/>
</graphics>
All new element are optional.
---
Diff to v1:
- _DEFAULT in all enums
- VIR_ERR_CONFIG_UNSUPPORTED if TypeFromString fails
docs/formatdomain.html.in | 12 ++
docs/schemas/domain.rng | 50 ++++++++
src/conf/domain_conf.c | 125 ++++++++++++++++++++
src/conf/domain_conf.h | 46 +++++++
src/libvirt_private.syms | 8 ++
src/qemu/qemu_command.c | 12 ++
.../qemuxml2argv-graphics-spice.args | 4 +-
.../qemuxml2argv-graphics-spice.xml | 4 +
8 files changed, 260 insertions(+), 1 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3c4c656..c5edf53 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1664,6 +1664,18 @@ qemu-kvm -net nic,model=? /dev/null
<channel name='main' mode='secure'/>
<channel name='record' mode='insecure'/>
</graphics></pre>
+ <p>
+Spice supports variable compression settings for audio, images and streaming.
+This setting are accessible via <code>compression</code> attribute in all
+following elements: <code>image</code> to set image compression (accept
+<code>auto_glz</code>, <code>auto_lz</code>, <code>quic</code>,
+<code>glz</code>, <code>lz</code>, <code>off</code>), <code>jpeg</code> for
+JPEG compression for images over wan (accept <code>auto</code>,
+<code>never</code>, <code>always</code>), <code>zlib</code> for configuring
+wan image compression (accept <code>auto</code>, <code>never</code>,
+<code>always</code>) and <code>playback</code> for enabling audio stream
+compression (accept <code>on</code> or <code>off</code>)
+ </p>
</dd>
<dt><code>"rdp"</code></dt>
<dd>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 0fbf326..f0578f8 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1283,6 +1283,56 @@
<empty/>
</element>
</zeroOrMore>
+ <optional>
+ <element name="image">
+ <attribute name="compression">
+ <choice>
+ <value>auto_glz</value>
+ <value>auto_lz</value>
+ <value>quic</value>
+ <value>glz</value>
+ <value>lz</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="jpeg">
+ <attribute name="compression">
+ <choice>
+ <value>auto</value>
+ <value>never</value>
+ <value>always</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="zlib">
+ <attribute name="compression">
+ <choice>
+ <value>auto</value>
+ <value>never</value>
+ <value>always</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="playback">
+ <attribute name="compression">
+ <choice>
+ <value>on</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
</group>
<group>
<attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 90a1317..a380db3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -322,6 +322,36 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceChannelMode,
"secure",
"insecure");
+VIR_ENUM_IMPL(virDomainGraphicsSpiceImageCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST,
+ "default",
+ "auto_glz",
+ "auto_lz",
+ "quic",
+ "glz",
+ "lz",
+ "off");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpiceJpegCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST,
+ "default",
+ "auto",
+ "never",
+ "always");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpiceZlibCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST,
+ "default",
+ "auto",
+ "never",
+ "always");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST,
+ "default",
+ "on",
+ "off");
+
VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
"subsystem",
"capabilities")
@@ -3954,6 +3984,89 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
VIR_FREE(mode);
def->data.spice.channels[nameval] = modeval;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "image")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice image missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpiceImageCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice image compression %s"),
+ compression);
+ VIR_FREE(compression);
+ goto error;
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.image = compressionVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "jpeg")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice jpeg missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpiceJpegCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice jpeg compression %s"),
+ compression);
+ VIR_FREE(compression);
+ goto error;
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.jpeg = compressionVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "zlib")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice zlib missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpiceZlibCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice zlib compression %s"),
+ compression);
+ VIR_FREE(compression);
+ goto error;
+ }
+
+ def->data.spice.zlib = compressionVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "playback")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice playback missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpicePlaybackCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice playback compression"));
+ VIR_FREE(compression);
+ goto error;
+
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.playback = compressionVal;
}
}
cur = cur->next;
@@ -7817,6 +7930,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
virDomainGraphicsSpiceChannelNameTypeToString(i),
virDomainGraphicsSpiceChannelModeTypeToString(mode));
}
+ if (def->data.spice.image)
+ virBufferVSprintf(buf, " <image compression='%s'/>\n",
+ virDomainGraphicsSpiceImageCompressionTypeToString(def->data.spice.image));
+ if (def->data.spice.jpeg)
+ virBufferVSprintf(buf, " <jpeg compression='%s'/>\n",
+ virDomainGraphicsSpiceJpegCompressionTypeToString(def->data.spice.jpeg));
+ if (def->data.spice.zlib)
+ virBufferVSprintf(buf, " <zlib compression='%s'/>\n",
+ virDomainGraphicsSpiceZlibCompressionTypeToString(def->data.spice.zlib));
+ if (def->data.spice.playback)
+ virBufferVSprintf(buf, " <playback compression='%s'/>\n",
+ virDomainGraphicsSpicePlaybackCompressionTypeToString(def->data.spice.playback));
}
if (children) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95bd11e..60a33ce 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -658,6 +658,44 @@ enum virDomainGraphicsSpiceChannelMode {
VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST
};
+enum virDomainGraphicsSpiceImageCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_QUIC,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST
+};
+
+enum virDomainGraphicsSpiceJpegCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_AUTO,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_NEVER,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_ALWAYS,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST
+};
+
+enum virDomainGraphicsSpiceZlibCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_AUTO,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_NEVER,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_ALWAYS,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST
+};
+
+enum virDomainGraphicsSpicePlaybackCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_ON,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_OFF,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST
+};
+
typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
struct _virDomainGraphicsDef {
@@ -695,6 +733,10 @@ struct _virDomainGraphicsDef {
virDomainGraphicsAuthDef auth;
unsigned int autoport :1;
int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
+ int image;
+ int jpeg;
+ int zlib;
+ int playback;
} spice;
} data;
};
@@ -1423,6 +1465,10 @@ VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
+VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
VIR_ENUM_DECL(virDomainSeclabel)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 54e4482..d2aa077 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -262,6 +262,14 @@ virDomainGraphicsSpiceChannelModeTypeFromString;
virDomainGraphicsSpiceChannelModeTypeToString;
virDomainGraphicsSpiceChannelNameTypeFromString;
virDomainGraphicsSpiceChannelNameTypeToString;
+virDomainGraphicsSpiceImageCompressionTypeToString;
+virDomainGraphicsSpiceImageCompressionTypeFromString;
+virDomainGraphicsSpiceJpegCompressionTypeFromString;
+virDomainGraphicsSpiceJpegCompressionTypeToString;
+virDomainGraphicsSpicePlaybackCompressionTypeFromString;
+virDomainGraphicsSpicePlaybackCompressionTypeToString;
+virDomainGraphicsSpiceZlibCompressionTypeFromString;
+virDomainGraphicsSpiceZlibCompressionTypeToString;
virDomainGraphicsTypeFromString;
virDomainGraphicsTypeToString;
virDomainHostdevDefFree;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fea0068..89668d4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4032,6 +4032,18 @@ qemuBuildCommandLine(virConnectPtr conn,
break;
}
}
+ if (def->graphics[0]->data.spice.image)
+ virBufferVSprintf(&opt, ",image-compression=%s",
+ virDomainGraphicsSpiceImageCompressionTypeToString(def->graphics[0]->data.spice.image));
+ if (def->graphics[0]->data.spice.jpeg)
+ virBufferVSprintf(&opt, ",jpeg-wan-compression=%s",
+ virDomainGraphicsSpiceJpegCompressionTypeToString(def->graphics[0]->data.spice.jpeg));
+ if (def->graphics[0]->data.spice.zlib)
+ virBufferVSprintf(&opt, ",zlib-glz-wan-compression=%s",
+ virDomainGraphicsSpiceZlibCompressionTypeToString(def->graphics[0]->data.spice.zlib));
+ if (def->graphics[0]->data.spice.playback)
+ virBufferVSprintf(&opt, ",playback-compression=%s",
+ virDomainGraphicsSpicePlaybackCompressionTypeToString(def->graphics[0]->data.spice.playback));
virCommandAddArg(cmd, "-spice");
virCommandAddArgBuffer(cmd, &opt);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
index c788bb6..70cd35b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
@@ -2,6 +2,8 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefaults -monitor \
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
/dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
-x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs -vga \
+x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs,\
+image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
+playback-compression=on -vga \
qxl -global qxl.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
index 5d46509..a29f50d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
@@ -24,6 +24,10 @@
<graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'>
<channel name='main' mode='secure'/>
<channel name='inputs' mode='insecure'/>
+ <image compression='auto_glz'/>
+ <jpeg compression='auto'/>
+ <zlib compression='auto'/>
+ <playback compression='on'/>
</graphics>
<video>
<model type='qxl' vram='18432' heads='1'/>
--
1.7.4.2
2
1
Make: passed
Make check: passed
Make syntax-check: passed
Hi,
this is the commit to introduce the function to create new character
device definition for the domain as advised by Cole Robinson
<crobinso(a)redhat.com>.
The function is used on the relevant places and also new tests has
been added.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
---
src/conf/domain_conf.c | 20 +++++++++--
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 3 +-
src/xenxs/xen_sxpr.c | 5 ++-
src/xenxs/xen_xm.c | 6 +++-
.../qemuxml2argv-multiple-serials.xml | 31 ++++++++++++++++
.../qemuxml2xmlout-multiple-serials.xml | 37 ++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
9 files changed, 100 insertions(+), 6 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 90a1317..a80719c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3212,6 +3212,22 @@ error:
goto cleanup;
}
+/* Create a new character device definition and set
+ * default port.
+ */
+virDomainChrDefPtr
+virDomainChrDefNew(void) {
+ virDomainChrDefPtr def = NULL;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ def->target.port = -1;
+ return def;
+}
+
/* Parse the XML definition for a character device
* @param node XML nodeset to parse for net definition
*
@@ -3260,10 +3276,8 @@ virDomainChrDefParseXML(virCapsPtr caps,
virDomainChrDefPtr def;
int remaining;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
type = virXMLPropString(node, "type");
if (type == NULL) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95bd11e..ecf44ca 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1229,6 +1229,8 @@ void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
+virDomainChrDefPtr virDomainChrDefNew(void);
+
/* live == true means def describes an active domain (being migrated or
* restored) as opposed to a new persistent configuration of the domain */
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 54e4482..4175ca0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -201,6 +201,7 @@ virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
virDomainChrDefFree;
+virDomainChrDefNew;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fea0068..d258712 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -36,6 +36,7 @@
#include "c-ctype.h"
#include "domain_nwfilter.h"
#include "qemu_audit.h"
+#include "domain_conf.h"
#include <sys/utsname.h>
#include <sys/stat.h>
@@ -5315,7 +5316,7 @@ qemuParseCommandLineChr(const char *val)
{
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0)
+ if (!(def = virDomainChrDefNew()))
goto no_memory;
if (STREQ(val, "null")) {
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 3a412a6..d1a0b0e 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -168,7 +168,7 @@ xenParseSxprChar(const char *value,
char *tmp;
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0) {
+ if (!(def = virDomainChrDefNew())) {
virReportOOMError();
return NULL;
}
@@ -1328,6 +1328,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[def->nserials++] = chr;
}
}
@@ -1343,6 +1344,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[def->nparallels++] = chr;
}
} else {
@@ -1350,6 +1352,7 @@ xenParseSxpr(const struct sexpr *root,
if (!(def->console = xenParseSxprChar("pty", tty)))
goto error;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
VIR_FREE(tty);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 22ad788..22d84dd 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -36,6 +36,7 @@
#include "xenxs_private.h"
#include "xen_xm.h"
#include "xen_sxpr.h"
+#include "domain_conf.h"
/* Convenience method to grab a int from the config file object */
static int xenXMConfigGetBool(virConfPtr conf,
@@ -957,6 +958,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[0] = chr;
def->nparallels++;
chr = NULL;
@@ -981,7 +983,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
continue;
}
- if (VIR_ALLOC(chr) < 0)
+ if (!(chr = virDomainChrDefNew()))
goto no_memory;
if (!(chr = xenParseSxprChar(port, NULL)))
goto cleanup;
@@ -1010,6 +1012,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[0] = chr;
def->nserials++;
}
@@ -1018,6 +1021,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (!(def->console = xenParseSxprChar("pty", NULL)))
goto cleanup;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port= 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml b/tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml
new file mode 100644
index 0000000..0f98f51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'/>
+ <serial type='null'/>
+ <serial type='stdio'/>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml
new file mode 100644
index 0000000..878418a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <serial type='null'>
+ <target port='1'/>
+ </serial>
+ <serial type='stdio'>
+ <target port='2'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b86dbee..dbc3279 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -195,6 +195,7 @@ mymain(int argc, char **argv)
DO_TEST_DIFFERENT("console-compat-auto");
DO_TEST_DIFFERENT("disk-scsi-device-auto");
DO_TEST_DIFFERENT("console-virtio");
+ DO_TEST_DIFFERENT("multiple-serials");
virCapabilitiesFree(driver.caps);
--
1.7.3.2
2
3
cpumask doesn't get freed when vcpupinDef being freed, this leaks
memory.
---
src/conf/domain_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1de4c7a..7b6b044 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -858,6 +858,7 @@ virDomainVcpupinDefFree(virDomainVcpupinDefPtr *def,
return;
for(i = 0; i < nvcpupin; i++) {
+ VIR_FREE(def[i]->cpumask);
VIR_FREE(def[i]);
}
--
1.7.3.1
3
2
[libvirt] [PATCH] esx: Make the parsed URI part of the private connection data
by Matthias Bolte 14 Apr '11
by Matthias Bolte 14 Apr '11
14 Apr '11
This will be used to make esxVI_Context clonable.
Also move cleanup code for esxPrivate to esxFreePrivate().
---
src/esx/esx_driver.c | 103 ++++++++++++++++++++++++-------------------------
src/esx/esx_private.h | 4 +-
2 files changed, 52 insertions(+), 55 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index ef76350..bfb3c16 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3,7 +3,7 @@
* esx_driver.c: core driver functions for managing VMware ESX hosts
*
* Copyright (C) 2010-2011 Red Hat, Inc.
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max(a)rfc2324.org>
*
* This library is free software; you can redistribute it and/or
@@ -57,6 +57,22 @@ struct _esxVMX_Data {
+static void
+esxFreePrivate(esxPrivate **priv)
+{
+ if (priv == NULL || *priv == NULL) {
+ return;
+ }
+
+ esxVI_Context_Free(&(*priv)->host);
+ esxVI_Context_Free(&(*priv)->vCenter);
+ esxUtil_FreeParsedUri(&(*priv)->parsedUri);
+ virCapabilitiesFree((*priv)->caps);
+ VIR_FREE(*priv);
+}
+
+
+
/*
* Parse a file name from a .vmx file and convert it to datastore path format.
* A .vmx file can contain file names in various formats:
@@ -619,7 +635,6 @@ static int
esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
const char *hostname, int port,
const char *predefinedUsername,
- esxUtil_ParsedUri *parsedUri,
esxVI_ProductVersion expectedProductVersion,
char **vCenterIpAddress)
{
@@ -671,16 +686,16 @@ esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
goto cleanup;
}
- if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
- port) < 0) {
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
+ hostname, port) < 0) {
virReportOOMError();
goto cleanup;
}
if (esxVI_Context_Alloc(&priv->host) < 0 ||
esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
- parsedUri) < 0 ||
- esxVI_Context_LookupObjectsByPath(priv->host, parsedUri) < 0) {
+ priv->parsedUri) < 0 ||
+ esxVI_Context_LookupObjectsByPath(priv->host, priv->parsedUri) < 0) {
goto cleanup;
}
@@ -750,8 +765,7 @@ static int
esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
const char *hostname, int port,
const char *predefinedUsername,
- const char *hostSystemIpAddress,
- esxUtil_ParsedUri *parsedUri)
+ const char *hostSystemIpAddress)
{
int result = -1;
char ipAddress[NI_MAXHOST] = "";
@@ -761,8 +775,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
char *url = NULL;
if (hostSystemIpAddress == NULL &&
- (parsedUri->path_datacenter == NULL ||
- parsedUri->path_computeResource == NULL)) {
+ (priv->parsedUri->path_datacenter == NULL ||
+ priv->parsedUri->path_computeResource == NULL)) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the datacenter and compute resource"));
return -1;
@@ -801,15 +815,15 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
goto cleanup;
}
- if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
- port) < 0) {
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
+ hostname, port) < 0) {
virReportOOMError();
goto cleanup;
}
if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
- password, parsedUri) < 0) {
+ password, priv->parsedUri) < 0) {
goto cleanup;
}
@@ -829,7 +843,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
goto cleanup;
}
} else {
- if (esxVI_Context_LookupObjectsByPath(priv->vCenter, parsedUri) < 0) {
+ if (esxVI_Context_LookupObjectsByPath(priv->vCenter,
+ priv->parsedUri) < 0) {
goto cleanup;
}
}
@@ -896,7 +911,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
{
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
esxPrivate *priv = NULL;
- esxUtil_ParsedUri *parsedUri = NULL;
char *potentialVCenterIpAddress = NULL;
char vCenterIpAddress[NI_MAXHOST] = "";
@@ -919,18 +933,15 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (esxUtil_ParseUri(&parsedUri, conn->uri) < 0) {
+ if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) {
goto cleanup;
}
- priv->transport = parsedUri->transport;
- parsedUri->transport = NULL;
-
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->supportsLongMode = esxVI_Boolean_Undefined;
- priv->autoAnswer = parsedUri->autoAnswer ? esxVI_Boolean_True
- : esxVI_Boolean_False;
+ priv->autoAnswer = priv->parsedUri->autoAnswer ? esxVI_Boolean_True
+ : esxVI_Boolean_False;
priv->usedCpuTimeCounterId = -1;
/*
@@ -942,13 +953,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
if (conn->uri->port == 0) {
if (STRCASEEQ(conn->uri->scheme, "vpx") ||
STRCASEEQ(conn->uri->scheme, "esx")) {
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
conn->uri->port = 443;
} else {
conn->uri->port = 80;
}
} else { /* GSX */
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
conn->uri->port = 8333;
} else {
conn->uri->port = 8222;
@@ -960,7 +971,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
STRCASEEQ(conn->uri->scheme, "gsx")) {
/* Connect to host */
if (esxConnectToHost(priv, auth, conn->uri->server, conn->uri->port,
- conn->uri->user, parsedUri,
+ conn->uri->user,
STRCASEEQ(conn->uri->scheme, "esx")
? esxVI_ProductVersion_ESX
: esxVI_ProductVersion_GSX,
@@ -969,8 +980,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
/* Connect to vCenter */
- if (parsedUri->vCenter != NULL) {
- if (STREQ(parsedUri->vCenter, "*")) {
+ if (priv->parsedUri->vCenter != NULL) {
+ if (STREQ(priv->parsedUri->vCenter, "*")) {
if (potentialVCenterIpAddress == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("This host is not managed by a vCenter"));
@@ -985,7 +996,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
} else {
- if (esxUtil_ResolveHostname(parsedUri->vCenter,
+ if (esxUtil_ResolveHostname(priv->parsedUri->vCenter,
vCenterIpAddress, NI_MAXHOST) < 0) {
goto cleanup;
}
@@ -996,7 +1007,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
_("This host is managed by a vCenter with IP "
"address %s, but a mismachting vCenter '%s' "
"(%s) has been specified"),
- potentialVCenterIpAddress, parsedUri->vCenter,
+ potentialVCenterIpAddress, priv->parsedUri->vCenter,
vCenterIpAddress);
goto cleanup;
}
@@ -1004,7 +1015,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
if (esxConnectToVCenter(priv, auth, vCenterIpAddress,
conn->uri->port, NULL,
- priv->host->ipAddress, parsedUri) < 0) {
+ priv->host->ipAddress) < 0) {
goto cleanup;
}
}
@@ -1013,15 +1024,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
} else { /* VPX */
/* Connect to vCenter */
if (esxConnectToVCenter(priv, auth, conn->uri->server, conn->uri->port,
- conn->uri->user, NULL, parsedUri) < 0) {
+ conn->uri->user, NULL) < 0) {
goto cleanup;
}
priv->primary = priv->vCenter;
}
- conn->privateData = priv;
-
/* Setup capabilities */
priv->caps = esxCapsInit(priv);
@@ -1029,20 +1038,15 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
+ conn->privateData = priv;
+
result = VIR_DRV_OPEN_SUCCESS;
cleanup:
- if (result == VIR_DRV_OPEN_ERROR && priv != NULL) {
- esxVI_Context_Free(&priv->host);
- esxVI_Context_Free(&priv->vCenter);
-
- virCapabilitiesFree(priv->caps);
-
- VIR_FREE(priv->transport);
- VIR_FREE(priv);
+ if (result == VIR_DRV_OPEN_ERROR) {
+ esxFreePrivate(&priv);
}
- esxUtil_FreeParsedUri(&parsedUri);
VIR_FREE(potentialVCenterIpAddress);
return result;
@@ -1061,8 +1065,6 @@ esxClose(virConnectPtr conn)
esxVI_Logout(priv->host) < 0) {
result = -1;
}
-
- esxVI_Context_Free(&priv->host);
}
if (priv->vCenter != NULL) {
@@ -1070,14 +1072,9 @@ esxClose(virConnectPtr conn)
esxVI_Logout(priv->vCenter) < 0) {
result = -1;
}
-
- esxVI_Context_Free(&priv->vCenter);
}
- virCapabilitiesFree(priv->caps);
-
- VIR_FREE(priv->transport);
- VIR_FREE(priv);
+ esxFreePrivate(&priv);
conn->privateData = NULL;
@@ -2627,7 +2624,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
goto cleanup;
}
- virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->transport,
+ virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->parsedUri->transport,
domain->conn->uri->server, domain->conn->uri->port);
virBufferURIEncodeString(&buffer, directoryAndFileName);
virBufferAddLit(&buffer, "?dcPath=");
@@ -3078,7 +3075,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
}
- virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->transport,
+ virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->parsedUri->transport,
conn->uri->server, conn->uri->port);
if (directoryName != NULL) {
@@ -3960,7 +3957,7 @@ esxIsEncrypted(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
return 1;
} else {
return 0;
@@ -3974,7 +3971,7 @@ esxIsSecure(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
return 1;
} else {
return 0;
diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h
index 6c7edb1..1da2552 100644
--- a/src/esx/esx_private.h
+++ b/src/esx/esx_private.h
@@ -2,7 +2,7 @@
/*
* esx_private.h: private driver struct for the VMware ESX driver
*
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -36,8 +36,8 @@ typedef struct _esxPrivate {
esxVI_Context *primary; /* points to host or vCenter */
esxVI_Context *host;
esxVI_Context *vCenter;
+ esxUtil_ParsedUri *parsedUri;
virCapsPtr caps;
- char *transport;
int32_t maxVcpus;
esxVI_Boolean supportsVMotion;
esxVI_Boolean supportsLongMode; /* aka x86_64 */
--
1.7.0.4
2
2
14 Apr '11
---
src/esx/esx_vi_types.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 9e23030..29a3c39 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -77,12 +77,12 @@
int \
esxVI_##__type##_Validate(esxVI_##__type *item) \
{ \
- const char *type_name = esxVI_Type_ToString(esxVI_Type_##__type); \
+ const char *typeName = esxVI_Type_ToString(esxVI_Type_##__type); \
\
if (item->_type <= esxVI_Type_Undefined || \
item->_type >= esxVI_Type_Other) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "%s object has invalid dynamic type", type_name); \
+ _("%s object has invalid dynamic type"), typeName); \
return -1; \
} \
\
@@ -293,7 +293,7 @@
childNode = childNode->next) { \
if (childNode->type != XML_ELEMENT_NODE) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Wrong XML element type %d", childNode->type); \
+ _("Wrong XML element type %d"), childNode->type);\
goto failure; \
} \
\
@@ -343,22 +343,22 @@
\
if (string == NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "XML node doesn't contain text, expecting an " \
- _xsdType" value"); \
+ _("XML node doesn't contain text, expecting an %s " \
+ "value"), _xsdType); \
goto cleanup; \
} \
\
if (virStrToLong_ll(string, NULL, 10, &value) < 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Unknown value '%s' for "_xsdType, string); \
+ _("Unknown value '%s' for %s"), string, _xsdType); \
goto cleanup; \
} \
\
if (((_min) != INT64_MIN && value < (_min)) \
|| ((_max) != INT64_MAX && value > (_max))) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Value '%s' is not representable as "_xsdType, \
- (const char *)string); \
+ _("Value '%s' is not representable as %s"), \
+ string, _xsdType); \
goto cleanup; \
} \
\
@@ -482,8 +482,8 @@
#define ESX_VI__TEMPLATE__PROPERTY__REQUIRE(_name) \
if (item->_name == 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "%s object is missing the required '%s' property", \
- type_name, #_name); \
+ _("%s object is missing the required '%s' property"), \
+ typeName, #_name); \
return -1; \
}
--
1.7.0.4
2
2
[libvirt] [PATCH] esx: Extend VI generator to cover managed object types
by Matthias Bolte 14 Apr '11
by Matthias Bolte 14 Apr '11
14 Apr '11
Generate lookup functions for managed object types.
---
src/esx/esx_vi.c | 414 +++++++++++++++++++++++-----------------
src/esx/esx_vi.h | 2 +
src/esx/esx_vi_generator.input | 28 +++-
src/esx/esx_vi_generator.py | 411 ++++++++++++++++++++++++++++++++++++++--
src/esx/esx_vi_types.c | 349 ++++++----------------------------
src/esx/esx_vi_types.h | 102 ++---------
6 files changed, 728 insertions(+), 578 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 7446ec5..fbab347 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -3,7 +3,7 @@
* esx_vi.c: client for the VMware VI API 2.5 to manage ESX hosts
*
* Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -481,107 +481,26 @@ int
esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
esxUtil_ParsedUri *parsedUri)
{
- int result = -1;
- esxVI_String *propertyNameList = NULL;
- char *name = NULL;
- esxVI_ObjectContent *datacenterList = NULL;
- esxVI_ObjectContent *datacenter = NULL;
- esxVI_ObjectContent *computeResourceList = NULL;
- esxVI_ObjectContent *computeResource = NULL;
char *hostSystemName = NULL;
- esxVI_ObjectContent *hostSystemList = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
-
/* Lookup Datacenter */
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "vmFolder\0"
- "hostFolder\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->service->rootFolder,
- "Datacenter", propertyNameList,
- &datacenterList,
- esxVI_Occurrence_RequiredList) < 0) {
- goto cleanup;
- }
-
- if (parsedUri->path_datacenter != NULL) {
- for (datacenter = datacenterList; datacenter != NULL;
- datacenter = datacenter->_next) {
- name = NULL;
-
- if (esxVI_GetStringValue(datacenter, "name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
-
- if (STREQ(name, parsedUri->path_datacenter)) {
- break;
- }
- }
-
- if (datacenter == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not find datacenter '%s'"),
- parsedUri->path_datacenter);
- goto cleanup;
- }
- } else {
- datacenter = datacenterList;
- }
-
- if (esxVI_Datacenter_CastFromObjectContent(datacenter,
- &ctx->datacenter) < 0) {
- goto cleanup;
+ if (esxVI_LookupDatacenter(ctx, parsedUri->path_datacenter,
+ ctx->service->rootFolder, NULL, &ctx->datacenter,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ return -1;
}
/* Lookup (Cluster)ComputeResource */
- esxVI_String_Free(&propertyNameList);
-
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "host\0"
- "resourcePool\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->datacenter->hostFolder,
- "ComputeResource", propertyNameList,
- &computeResourceList,
- esxVI_Occurrence_RequiredList) < 0) {
- goto cleanup;
- }
-
- if (parsedUri->path_computeResource != NULL) {
- for (computeResource = computeResourceList; computeResource != NULL;
- computeResource = computeResource->_next) {
- name = NULL;
-
- if (esxVI_GetStringValue(computeResource, "name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
-
- if (STREQ(name, parsedUri->path_computeResource)) {
- break;
- }
- }
-
- if (computeResource == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not find compute resource '%s'"),
- parsedUri->path_computeResource);
- goto cleanup;
- }
- } else {
- computeResource = computeResourceList;
- }
-
- if (esxVI_ComputeResource_CastFromObjectContent(computeResource,
- &ctx->computeResource) < 0) {
- goto cleanup;
+ if (esxVI_LookupComputeResource(ctx, parsedUri->path_computeResource,
+ ctx->datacenter->hostFolder, NULL,
+ &ctx->computeResource,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ return -1;
}
if (ctx->computeResource->resourcePool == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve resource pool"));
- goto cleanup;
+ return -1;
}
/* Lookup HostSystem */
@@ -590,19 +509,7 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
"ClusterComputeResource")) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the host system"));
- goto cleanup;
- }
-
- esxVI_String_Free(&propertyNameList);
-
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "configManager\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->computeResource->_reference,
- "HostSystem", propertyNameList,
- &hostSystemList,
- esxVI_Occurrence_RequiredList) < 0) {
- goto cleanup;
+ return -1;
}
if (parsedUri->path_hostSystem != NULL ||
@@ -613,44 +520,16 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
} else {
hostSystemName = parsedUri->path_computeResource;
}
-
- for (hostSystem = hostSystemList; hostSystem != NULL;
- hostSystem = hostSystem->_next) {
- name = NULL;
-
- if (esxVI_GetStringValue(hostSystem, "name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
-
- if (STREQ(name, hostSystemName)) {
- break;
- }
- }
-
- if (hostSystem == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not find host system '%s'"), hostSystemName);
- goto cleanup;
- }
- } else {
- hostSystem = hostSystemList;
}
- if (esxVI_HostSystem_CastFromObjectContent(hostSystem,
- &ctx->hostSystem) < 0) {
- goto cleanup;
+ if (esxVI_LookupHostSystem(ctx, hostSystemName,
+ ctx->computeResource->_reference, NULL,
+ &ctx->hostSystem,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ return -1;
}
- result = 0;
-
- cleanup:
- esxVI_String_Free(&propertyNameList);
- esxVI_ObjectContent_Free(&datacenterList);
- esxVI_ObjectContent_Free(&computeResourceList);
- esxVI_ObjectContent_Free(&hostSystemList);
-
- return result;
+ return 0;
}
int
@@ -658,67 +537,41 @@ esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx,
const char *hostSystemIpAddress)
{
int result = -1;
- esxVI_String *propertyNameList = NULL;
esxVI_ManagedObjectReference *managedObjectReference = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
- esxVI_ObjectContent *computeResource = NULL;
- esxVI_ObjectContent *datacenter = NULL;
/* Lookup HostSystem */
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "configManager\0") < 0 ||
- esxVI_FindByIp(ctx, NULL, hostSystemIpAddress, esxVI_Boolean_False,
+ if (esxVI_FindByIp(ctx, NULL, hostSystemIpAddress, esxVI_Boolean_False,
&managedObjectReference) < 0 ||
- esxVI_LookupObjectContentByType(ctx, managedObjectReference,
- "HostSystem", propertyNameList,
- &hostSystem,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_HostSystem_CastFromObjectContent(hostSystem,
- &ctx->hostSystem) < 0) {
+ esxVI_LookupHostSystem(ctx, NULL, managedObjectReference, NULL,
+ &ctx->hostSystem,
+ esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
/* Lookup (Cluster)ComputeResource */
- esxVI_String_Free(&propertyNameList);
+ if (esxVI_LookupComputeResource(ctx, NULL, ctx->hostSystem->_reference,
+ NULL, &ctx->computeResource,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "host\0"
- "resourcePool\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, hostSystem->obj,
- "ComputeResource", propertyNameList,
- &computeResource,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_ComputeResource_CastFromObjectContent(computeResource,
- &ctx->computeResource) < 0) {
+ if (ctx->computeResource->resourcePool == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve resource pool"));
goto cleanup;
}
/* Lookup Datacenter */
- esxVI_String_Free(&propertyNameList);
-
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "vmFolder\0"
- "hostFolder\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, computeResource->obj,
- "Datacenter", propertyNameList,
- &datacenter,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_Datacenter_CastFromObjectContent(datacenter,
- &ctx->datacenter) < 0) {
+ if (esxVI_LookupDatacenter(ctx, NULL, ctx->computeResource->_reference,
+ NULL, &ctx->datacenter,
+ esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
result = 0;
cleanup:
- esxVI_String_Free(&propertyNameList);
esxVI_ManagedObjectReference_Free(&managedObjectReference);
- esxVI_ObjectContent_Free(&hostSystem);
- esxVI_ObjectContent_Free(&computeResource);
- esxVI_ObjectContent_Free(&datacenter);
return result;
}
@@ -3872,3 +3725,204 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
return -1;
}
}
+
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE_IGNORE(_name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE(_type, _name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ if (esxVI_##_type##_CastFromAnyType(dynamicProperty->val, \
+ &(*ptrptr)->_name) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_LIST_FROM_ANY_TYPE(_type, _name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ if (esxVI_##_type##_CastListFromAnyType(dynamicProperty->val, \
+ &(*ptrptr)->_name) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_VALUE_FROM_ANY_TYPE(_type, _name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ if (esxVI_##_type##_CastValueFromAnyType(dynamicProperty->val, \
+ &(*ptrptr)->_name) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__LOOKUP(_type, _complete_properties, \
+ _cast_from_anytype) \
+ int \
+ esxVI_Lookup##_type(esxVI_Context *ctx, const char* name /* optional */, \
+ esxVI_ManagedObjectReference *root, \
+ esxVI_String *selectedPropertyNameList /* optional */,\
+ esxVI_##_type **ptrptr, esxVI_Occurrence occurrence) \
+ { \
+ int result = -1; \
+ const char *completePropertyNameValueList = _complete_properties; \
+ esxVI_String *propertyNameList = NULL; \
+ esxVI_ObjectContent *objectContent = NULL; \
+ esxVI_ObjectContent *objectContentList = NULL; \
+ esxVI_DynamicProperty *dynamicProperty = NULL; \
+ \
+ if (ptrptr == NULL || *ptrptr != NULL) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
+ _("Invalid argument")); \
+ return -1; \
+ } \
+ \
+ propertyNameList = selectedPropertyNameList; \
+ \
+ if (propertyNameList == NULL && \
+ esxVI_String_AppendValueListToList \
+ (&propertyNameList, completePropertyNameValueList) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ if (esxVI_LookupManagedObjectHelper(ctx, name, root, #_type, \
+ propertyNameList, &objectContent, \
+ &objectContentList, \
+ occurrence) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ if (esxVI_##_type##_Alloc(ptrptr) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ if (esxVI_ManagedObjectReference_DeepCopy(&(*ptrptr)->_reference, \
+ objectContent->obj) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ for (dynamicProperty = objectContent->propSet; \
+ dynamicProperty != NULL; \
+ dynamicProperty = dynamicProperty->_next) { \
+ _cast_from_anytype \
+ \
+ VIR_WARN("Unexpected '%s' property", dynamicProperty->name); \
+ } \
+ \
+ if (esxVI_##_type##_Validate(*ptrptr, selectedPropertyNameList) < 0) {\
+ goto cleanup; \
+ } \
+ \
+ result = 0; \
+ \
+ cleanup: \
+ if (result < 0) { \
+ esxVI_##_type##_Free(ptrptr); \
+ } \
+ \
+ if (propertyNameList != selectedPropertyNameList) { \
+ esxVI_String_Free(&propertyNameList); \
+ } \
+ \
+ esxVI_ObjectContent_Free(&objectContentList); \
+ \
+ return result; \
+ }
+
+
+
+static int
+esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
+ const char *name /* optional */,
+ esxVI_ManagedObjectReference *root,
+ const char *type,
+ esxVI_String *propertyNameList,
+ esxVI_ObjectContent **objectContent,
+ esxVI_ObjectContent **objectContentList,
+ esxVI_Occurrence occurrence)
+{
+ int result = -1;
+ esxVI_ObjectContent *candidate = NULL;
+ char *name_candidate;
+
+ if (objectContent == NULL || *objectContent != NULL ||
+ objectContentList == NULL || *objectContentList != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ if (!esxVI_String_ListContainsValue(propertyNameList, "name")) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing 'name' property in %s lookup"), type);
+ goto cleanup;
+ }
+
+ if (esxVI_LookupObjectContentByType(ctx, root, type, propertyNameList,
+ objectContentList,
+ esxVI_Occurrence_OptionalList) < 0) {
+ goto cleanup;
+ }
+
+ /* Search for a matching item */
+ if (name != NULL) {
+ for (candidate = *objectContentList; candidate != NULL;
+ candidate = candidate->_next) {
+ name_candidate = NULL;
+
+ if (esxVI_GetStringValue(candidate, "name", &name_candidate,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
+
+ if (STREQ(name_candidate, name)) {
+ /* Found item with matching name */
+ break;
+ }
+ }
+ } else {
+ candidate = *objectContentList;
+ }
+
+ if (candidate == NULL) {
+ if (occurrence != esxVI_Occurrence_OptionalItem) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Could not find %s with name '%s'"), type, name);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ if (result < 0) {
+ esxVI_ObjectContent_Free(objectContentList);
+ } else {
+ *objectContent = candidate;
+ }
+
+ return result;
+}
+
+
+
+#include "esx_vi.generated.c"
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index e150dbf..d046bf9 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -444,4 +444,6 @@ int esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedHostCpuIdInfo,
int esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersion);
+# include "esx_vi.generated.h"
+
#endif /* __ESX_VI_H__ */
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 44d1d9b..98b5206 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -15,7 +15,7 @@
#
# Object definition:
#
-# object <name> [extends <name>]
+# [managed] object <name> [extends <name>]
# <type> <name> <occurrence>
# ...
# end
@@ -739,6 +739,32 @@ end
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Managed Objects
+#
+
+managed object ComputeResource extends ManagedEntity
+ ManagedObjectReference host ol
+ ManagedObjectReference resourcePool o
+end
+
+
+managed object Datacenter extends ManagedEntity
+ ManagedObjectReference hostFolder r
+ ManagedObjectReference vmFolder r
+end
+
+
+managed object HostSystem extends ManagedEntity
+ HostConfigManager configManager r
+end
+
+
+managed object ManagedEntity
+ String name r
+end
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Methods
#
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 0fd84dd..ab127a3 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -3,7 +3,7 @@
#
# esx_vi_generator.py: generates most of the SOAP type mapping code
#
-# Copyright (C) 2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+# Copyright (C) 2010-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -297,10 +297,15 @@ class Property:
return " esxVI_%s_Free(&item->%s);\n" % (self.type, self.name)
- def generate_validate_code(self):
+ def generate_validate_code(self, managed=False):
+ if managed:
+ macro = "ESX_VI__TEMPLATE__PROPERTY__MANAGED_REQUIRE"
+ else:
+ macro = "ESX_VI__TEMPLATE__PROPERTY__REQUIRE"
+
if self.occurrence in [OCCURRENCE__REQUIRED_ITEM,
OCCURRENCE__REQUIRED_LIST]:
- return " ESX_VI__TEMPLATE__PROPERTY__REQUIRE(%s)\n" % self.name
+ return " %s(%s)\n" % (macro, self.name)
elif self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
else:
@@ -345,6 +350,18 @@ class Property:
return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(%s, %s)\n" % (self.type, self.name)
+ def generate_lookup_code(self):
+ if self.occurrence == OCCURRENCE__IGNORED:
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE_IGNORE(%s) /* FIXME */\n" % self.name
+ elif self.occurrence in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_LIST_FROM_ANY_TYPE(%s, %s)\n" % (self.type, self.name)
+ elif self.type == "String":
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_VALUE_FROM_ANY_TYPE(String, %s)\n" % self.name
+ else:
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE(%s, %s)\n" % (self.type, self.name)
+
+
def get_type_string(self):
if self.type == "String" and \
self.occurrence not in [OCCURRENCE__REQUIRED_LIST,
@@ -572,20 +589,20 @@ class Object(Base):
def generate_header(self):
header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
- header += " * VI Type: %s\n" % self.name
+ header += " * VI Object: %s\n" % self.name
if self.extends is not None:
- header += " * extends %s\n" % self.extends
+ header += " * extends %s\n" % self.extends
first = True
if self.extended_by is not None:
for extended_by in self.extended_by:
if first:
- header += " * extended by %s\n" % extended_by
+ header += " * extended by %s\n" % extended_by
first = False
else:
- header += " * %s\n" % extended_by
+ header += " * %s\n" % extended_by
header += " */\n\n"
@@ -646,20 +663,20 @@ class Object(Base):
def generate_source(self):
source = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
- source += " * VI Type: %s\n" % self.name
+ source += " * VI Object: %s\n" % self.name
if self.extends is not None:
- source += " * extends %s\n" % self.extends
+ source += " * extends %s\n" % self.extends
first = True
if self.extended_by is not None:
for extended_by in self.extended_by:
if first:
- source += " * extended by %s\n" % extended_by
+ source += " * extended by %s\n" % extended_by
first = False
else:
- source += " * %s\n" % extended_by
+ source += " * %s\n" % extended_by
source += " */\n\n"
@@ -863,15 +880,303 @@ class Object(Base):
+class ManagedObject(Base):
+ FEATURE__LIST = (1 << 2)
+
+
+ def __init__(self, name, extends, properties, features=0, extended_by=None):
+ Base.__init__(self, "struct", name)
+ self.extends = extends
+ self.features = features
+ self.properties = properties
+ self.extended_by = extended_by
+
+ if self.extended_by is not None:
+ self.extended_by.sort()
+
+
+ def generate_struct_members(self, add_banner=False, struct_gap=False):
+ members = ""
+
+ if struct_gap:
+ members += "\n"
+
+ if self.extends is not None:
+ members += managed_objects_by_name[self.extends].generate_struct_members(add_banner=True) + "\n"
+
+ if self.extends is not None or add_banner:
+ members += " /* %s */\n" % self.name
+
+ for property in self.properties:
+ members += property.generate_struct_member()
+
+ if len(self.properties) < 1:
+ members += " /* no properties */\n"
+
+ return members
+
+
+ def generate_free_code(self, add_banner=False):
+ source = ""
+ if self.extends is not None:
+ source += managed_objects_by_name[self.extends].generate_free_code(add_banner=True) + "\n"
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+ for property in self.properties:
+ string += property.generate_free_code()
+ if len(string) < 1:
+ source += " /* no properties to be freed */\n"
+ else:
+ source += string
+ return source
+ def generate_validate_code(self, add_banner=False):
+ source = ""
+
+ if self.extends is not None:
+ source += managed_objects_by_name[self.extends].generate_validate_code(add_banner=True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+ for property in self.properties:
+ string += property.generate_validate_code(managed=True)
+
+ if len(string) < 1:
+ source += " /* no required properties */\n"
+ else:
+ source += string
+
+ return source
+
+
+ def generate_lookup_code1(self, add_banner=False):
+ source = ""
+
+ if self.extends is not None:
+ source += managed_objects_by_name[self.extends].generate_lookup_code1(add_banner=True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+
+ for property in self.properties:
+ string += " \"%s\\0\"\n" % property.name
+
+ if len(string) < 1:
+ source += " /* no properties */\n"
+ else:
+ source += string
+
+ return source
+
+
+ def generate_lookup_code2(self, add_banner=False):
+ source = ""
+
+ if self.extends is not None:
+ source += managed_objects_by_name[self.extends].generate_lookup_code2(add_banner=True) + "\n"
+
+ if self.extends is not None or add_banner:
+ source += " /* %s */\n" % self.name
+
+ if len(self.properties) < 1:
+ source += " /* no properties */\n"
+ else:
+ string = ""
+
+ for property in self.properties:
+ string += property.generate_lookup_code()
+
+ if len(string) < 1:
+ source += " /* no properties */\n"
+ else:
+ source += string
+
+ return source
+
+
+ def generate_comment(self):
+ comment = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
+ comment += " * VI Managed Object: %s\n" % self.name
+
+ if self.extends is not None:
+ comment += " * extends %s\n" % self.extends
+
+ first = True
+
+ if self.extended_by is not None:
+ for extended_by in self.extended_by:
+ if first:
+ comment += " * extended by %s\n" % extended_by
+ first = False
+ else:
+ comment += " * %s\n" % extended_by
+
+ comment += " */\n\n"
+
+ return comment
+
+
+ def generate_header(self):
+ header = self.generate_comment()
+
+ # struct
+ header += "struct _esxVI_%s {\n" % self.name
+
+ if self.features & Object.FEATURE__LIST:
+ header += aligned(" esxVI_%s *_next; " % self.name, "/* optional */\n")
+ else:
+ header += aligned(" esxVI_%s *_unused; " % self.name, "/* optional */\n")
+
+ header += aligned(" esxVI_Type _type; ", "/* required */\n")
+ header += aligned(" esxVI_ManagedObjectReference *_reference; ", "/* required */\n")
+ header += "\n"
+ header += self.generate_struct_members()
+
+ header += "};\n\n"
+
+ # functions
+ header += "int esxVI_%s_Alloc(esxVI_%s **item);\n" % (self.name, self.name)
+ header += "void esxVI_%s_Free(esxVI_%s **item);\n" % (self.name, self.name)
+ header += "int esxVI_%s_Validate(esxVI_%s *item, esxVI_String *selectedPropertyNameList);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_AppendToList(esxVI_%s **list, esxVI_%s *item);\n" % (self.name, self.name, self.name)
+
+ header += "\n\n\n"
+
+ return header
+
+
+ def generate_helper_header(self):
+ header = ""
+
+ # functions
+ header += ("int esxVI_Lookup%s(esxVI_Context *ctx, " +
+ "const char *name, " +
+ "esxVI_ManagedObjectReference *root, " +
+ "esxVI_String *selectedPropertyNameList, " +
+ "esxVI_%s **item, " +
+ "esxVI_Occurrence occurrence);\n") % (self.name, self.name)
+
+ header += "\n"
+
+ return header
+
+
+ def generate_source(self):
+ source = self.generate_comment()
+
+ # functions
+ source += "/* esxVI_%s_Alloc */\n" % self.name
+ source += "ESX_VI__TEMPLATE__ALLOC(%s)\n\n" % self.name
+
+ # free
+ if self.extended_by is None:
+ source += "/* esxVI_%s_Free */\n" % self.name
+ source += "ESX_VI__TEMPLATE__FREE(%s,\n" % self.name
+ source += "{\n"
+
+ if self.features & ManagedObject.FEATURE__LIST:
+ if self.extends is not None:
+ # avoid "dereferencing type-punned pointer will break strict-aliasing rules" warnings
+ source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" % (self.extends, self.extends)
+ source += " esxVI_%s_Free(&next);\n" % self.extends
+ source += " item->_next = (esxVI_%s *)next;\n\n" % self.name
+ else:
+ source += " esxVI_%s_Free(&item->_next);\n" % self.name
+
+ source += " esxVI_ManagedObjectReference_Free(&item->_reference);\n\n"
+
+ source += self.generate_free_code()
+
+ source += "})\n\n"
+ else:
+ source += "/* esxVI_%s_Free */\n" % self.name
+ source += "ESX_VI__TEMPLATE__DYNAMIC_FREE(%s,\n" % self.name
+ source += "{\n"
+
+ for extended_by in self.extended_by:
+ source += " ESX_VI__TEMPLATE__DISPATCH__FREE(%s)\n" % extended_by
+
+ source += "},\n"
+ source += "{\n"
+
+ if self.features & Object.FEATURE__LIST:
+ if self.extends is not None:
+ # avoid "dereferencing type-punned pointer will break strict-aliasing rules" warnings
+ source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" % (self.extends, self.extends)
+ source += " esxVI_%s_Free(&next);\n" % self.extends
+ source += " item->_next = (esxVI_%s *)next;\n\n" % self.name
+ else:
+ source += " esxVI_%s_Free(&item->_next);\n" % self.name
+
+ source += " esxVI_ManagedObjectReference_Free(&item->_reference);\n\n"
+
+ source += self.generate_free_code()
+
+ source += "})\n\n"
+
+ # validate
+ source += "/* esxVI_%s_Validate */\n" % self.name
+ source += "ESX_VI__TEMPLATE__MANAGED_VALIDATE(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_validate_code()
+
+ source += "})\n\n"
+
+ # append to list
+ if self.features & ManagedObject.FEATURE__LIST:
+ source += "/* esxVI_%s_AppendToList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__APPEND(%s)\n\n" % self.name
+
+ source += "\n\n"
+
+ return source
+
+
+ def generate_helper_source(self):
+ source = ""
+
+ # lookup
+ source += "/* esxVI_Lookup%s */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LOOKUP(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_lookup_code1()
+
+ source += "},\n"
+ source += "{\n"
+
+ source += self.generate_lookup_code2()
+
+ source += "})\n\n"
+
+ source += "\n\n"
+
+ return source
@@ -962,8 +1267,13 @@ def capitalize_first(string):
def parse_object(block):
- # expected format: object <name> [extends <name>]
+ # expected format: [managed] object <name> [extends <name>]
header_items = block[0][1].split()
+ managed = False
+
+ if header_items[0] == "managed":
+ managed = True
+ del header_items[0]
if len(header_items) < 2:
report_error("line %d: invalid block header" % (number))
@@ -994,7 +1304,10 @@ def parse_object(block):
properties.append(Property(type=items[0], name=items[1],
occurrence=items[2]))
- return Object(name = name, extends = extends, properties = properties)
+ if managed:
+ return ManagedObject(name=name, extends=extends, properties=properties)
+ else:
+ return Object(name=name, extends=extends, properties=properties)
@@ -1075,6 +1388,7 @@ def is_known_type(type):
return type in predefined_objects or \
type in predefined_enums or \
type in objects_by_name or \
+ type in managed_objects_by_name or \
type in enums_by_name
@@ -1169,11 +1483,14 @@ types_header = open_and_print(os.path.join(output_dirname, "esx_vi_types.generat
types_source = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.c"))
methods_header = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.h"))
methods_source = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.c"))
+helpers_header = open_and_print(os.path.join(output_dirname, "esx_vi.generated.h"))
+helpers_source = open_and_print(os.path.join(output_dirname, "esx_vi.generated.c"))
number = 0
objects_by_name = {}
+managed_objects_by_name = {}
enums_by_name = {}
methods_by_name = {}
block = None
@@ -1191,7 +1508,8 @@ for line in file(input_filename, "rb").readlines():
if len(line) < 1:
continue
- if line.startswith("object") or line.startswith("enum") or line.startswith("method"):
+ if line.startswith("object") or line.startswith("managed object") or \
+ line.startswith("enum") or line.startswith("method"):
if block is not None:
report_error("line %d: nested block found" % (number))
else:
@@ -1202,6 +1520,9 @@ for line in file(input_filename, "rb").readlines():
if block[0][1].startswith("object"):
obj = parse_object(block)
objects_by_name[obj.name] = obj
+ elif block[0][1].startswith("managed object"):
+ obj = parse_object(block)
+ managed_objects_by_name[obj.name] = obj
elif block[0][1].startswith("enum"):
enum = parse_enum(block)
enums_by_name[enum.name] = enum
@@ -1268,6 +1589,30 @@ for obj in objects_by_name.values():
+for obj in managed_objects_by_name.values():
+ for property in obj.properties:
+ if property.occurrence != OCCURRENCE__IGNORED and \
+ not is_known_type(property.type):
+ report_error("object '%s' contains unknown property type '%s'" % (obj.name, property.type))
+
+ if obj.extends is not None:
+ if not is_known_type(obj.extends):
+ report_error("object '%s' extends unknown object '%s'" % (obj.name, obj.extends))
+
+ # detect extended_by relation
+ if obj.extends is not None:
+ extended_obj = managed_objects_by_name[obj.extends]
+
+ if extended_obj.extended_by is None:
+ extended_obj.extended_by = [obj.name]
+ else:
+ extended_obj.extended_by.append(obj.name)
+ extended_obj.extended_by.sort()
+
+
+
+
+
for obj in objects_by_name.values():
inherit_features(obj)
@@ -1283,6 +1628,8 @@ types_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
types_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
methods_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
methods_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+helpers_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+helpers_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
# output enums
@@ -1306,7 +1653,7 @@ for name in names:
# output objects
types_typedef.write("\n\n\n" +
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
- " * VI Types\n" +
+ " * VI Objects\n" +
" */\n\n")
types_typeenum.write("\n")
types_typetostring.write("\n")
@@ -1327,6 +1674,30 @@ for name in names:
+# output managed objects
+types_typedef.write("\n\n\n" +
+ "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
+ " * VI Managed Objects\n" +
+ " */\n\n")
+types_typeenum.write("\n")
+types_typetostring.write("\n")
+types_typefromstring.write("\n")
+
+
+
+names = managed_objects_by_name.keys()
+names.sort()
+
+for name in names:
+ types_typedef.write(managed_objects_by_name[name].generate_typedef())
+ types_typeenum.write(managed_objects_by_name[name].generate_typeenum())
+ types_typetostring.write(managed_objects_by_name[name].generate_typetostring())
+ types_typefromstring.write(managed_objects_by_name[name].generate_typefromstring())
+ types_header.write(managed_objects_by_name[name].generate_header())
+ types_source.write(managed_objects_by_name[name].generate_source())
+
+
+
# output methods
names = methods_by_name.keys()
names.sort()
@@ -1334,3 +1705,13 @@ names.sort()
for name in names:
methods_header.write(methods_by_name[name].generate_header())
methods_source.write(methods_by_name[name].generate_source())
+
+
+
+# output helpers
+names = managed_objects_by_name.keys()
+names.sort()
+
+for name in names:
+ helpers_header.write(managed_objects_by_name[name].generate_helper_header())
+ helpers_source.write(managed_objects_by_name[name].generate_helper_source())
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index f3cdf2a..9e23030 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -3,7 +3,7 @@
* esx_vi_types.c: client for the VMware VI API 2.5 to manage ESX hosts
*
* Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -693,6 +693,44 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType,
+/*
+ * Macros to implement managed objects
+ */
+
+#define ESX_VI__TEMPLATE__PROPERTY__MANAGED_REQUIRE(_name) \
+ /* FIXME: This results in O(n^2) runtime in case of missing required, but \
+ * unselected properties. */ \
+ if (item->_name == 0 && \
+ esxVI_String_ListContainsValue(selectedPropertyNameList, #_name)) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ _("%s object is missing the required '%s' property"), \
+ typeName, #_name); \
+ return -1; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__MANAGED_VALIDATE(__type, _require) \
+ int \
+ esxVI_##__type##_Validate(esxVI_##__type *item, \
+ esxVI_String *selectedPropertyNameList) \
+ { \
+ const char *typeName = esxVI_Type_ToString(esxVI_Type_##__type); \
+ \
+ if (item->_type <= esxVI_Type_Undefined || \
+ item->_type >= esxVI_Type_Other) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ _("%s object has invalid dynamic type"), typeName); \
+ return -1; \
+ } \
+ \
+ _require \
+ \
+ return 0; \
+ }
+
+
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* XSI: Type
*/
@@ -735,15 +773,6 @@ esxVI_Type_ToString(esxVI_Type type)
case esxVI_Type_ManagedObjectReference:
return "ManagedObjectReference";
- case esxVI_Type_Datacenter:
- return "Datacenter";
-
- case esxVI_Type_ComputeResource:
- return "ComputeResource";
-
- case esxVI_Type_HostSystem:
- return "HostSystem";
-
#include "esx_vi_types.generated.typetostring"
case esxVI_Type_Other:
@@ -776,12 +805,6 @@ esxVI_Type_FromString(const char *type)
return esxVI_Type_MethodFault;
} else if (STREQ(type, "ManagedObjectReference")) {
return esxVI_Type_ManagedObjectReference;
- } else if (STREQ(type, "Datacenter")) {
- return esxVI_Type_Datacenter;
- } else if (STREQ(type, "ComputeResource")) {
- return esxVI_Type_ComputeResource;
- } else if (STREQ(type, "HostSystem")) {
- return esxVI_Type_HostSystem;
}
#include "esx_vi_types.generated.typefromstring"
@@ -1050,6 +1073,20 @@ ESX_VI__TEMPLATE__VALIDATE(String,
ESX_VI__TEMPLATE__PROPERTY__REQUIRE(value)
})
+bool
+esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value)
+{
+ esxVI_String *string;
+
+ for (string = stringList; string != NULL; string = string->_next) {
+ if (STREQ(string->value, value)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
/* esxVI_String_AppendToList */
ESX_VI__TEMPLATE__LIST__APPEND(String)
@@ -1452,7 +1489,7 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: Fault
+ * SOAP: Fault
*/
/* esxVI_Fault_Alloc */
@@ -1483,7 +1520,7 @@ ESX_VI__TEMPLATE__DESERIALIZE(Fault,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: MethodFault
+ * VI Object: MethodFault
*/
/* esxVI_MethodFault_Alloc */
@@ -1528,7 +1565,7 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ManagedObjectReference
+ * VI Object: ManagedObjectReference
*/
/* esxVI_ManagedObjectReference_Alloc */
@@ -1632,280 +1669,6 @@ esxVI_ManagedObjectReference_Deserialize
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: Datacenter
- * extends ManagedEntity
- */
-
-/* esxVI_Datacenter_Alloc */
-ESX_VI__TEMPLATE__ALLOC(Datacenter)
-
-/* esxVI_Datacenter_Free */
-ESX_VI__TEMPLATE__FREE(Datacenter,
-{
- esxVI_Datacenter_Free(&item->_next);
- esxVI_ManagedObjectReference_Free(&item->_reference);
-
- /* ManagedEntity */
- VIR_FREE(item->name);
-
- /* Datacenter */
- esxVI_ManagedObjectReference_Free(&item->hostFolder);
- esxVI_ManagedObjectReference_Free(&item->vmFolder);
-})
-
-/* esxVI_Datacenter_Validate */
-ESX_VI__TEMPLATE__VALIDATE(Datacenter,
-{
- /* ManagedEntity */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
-
- /* Datacenter */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(hostFolder);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(vmFolder);
-})
-
-int
-esxVI_Datacenter_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_Datacenter **datacenter)
-{
- esxVI_DynamicProperty *dynamicProperty = NULL;
-
- if (objectContent == NULL || datacenter == NULL || *datacenter != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-
- if (esxVI_Datacenter_Alloc(datacenter) < 0) {
- return -1;
- }
-
- if (esxVI_ManagedObjectReference_DeepCopy(&(*datacenter)->_reference,
- objectContent->obj) < 0) {
- goto failure;
- }
-
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "name")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
- }
-
- (*datacenter)->name = strdup(dynamicProperty->val->string);
-
- if ((*datacenter)->name == NULL) {
- virReportOOMError();
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "hostFolder")) {
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &(*datacenter)->hostFolder) < 0) {
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "vmFolder")) {
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &(*datacenter)->vmFolder) < 0) {
- goto failure;
- }
- }
- }
-
- if (esxVI_Datacenter_Validate(*datacenter) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_Datacenter_Free(datacenter);
-
- return -1;
-}
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: ComputeResource
- * extends ManagedEntity
- */
-
-/* esxVI_ComputeResource_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ComputeResource)
-
-/* esxVI_ComputeResource_Free */
-ESX_VI__TEMPLATE__FREE(ComputeResource,
-{
- esxVI_ComputeResource_Free(&item->_next);
- esxVI_ManagedObjectReference_Free(&item->_reference);
-
- /* ManagedEntity */
- VIR_FREE(item->name);
-
- /* ComputeResource */
- esxVI_ManagedObjectReference_Free(&item->host);
- esxVI_ManagedObjectReference_Free(&item->resourcePool);
-})
-
-/* esxVI_ComputeResource_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ComputeResource,
-{
- /* ManagedEntity */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
-
- /* ComputeResource */
-})
-
-int
-esxVI_ComputeResource_CastFromObjectContent
- (esxVI_ObjectContent *objectContent, esxVI_ComputeResource **computeResource)
-{
- esxVI_DynamicProperty *dynamicProperty = NULL;
-
- if (objectContent == NULL || computeResource == NULL ||
- *computeResource != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-
- if (esxVI_ComputeResource_Alloc(computeResource) < 0) {
- return -1;
- }
-
- if (esxVI_ManagedObjectReference_DeepCopy(&(*computeResource)->_reference,
- objectContent->obj) < 0) {
- goto failure;
- }
-
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "name")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
- }
-
- (*computeResource)->name = strdup(dynamicProperty->val->string);
-
- if ((*computeResource)->name == NULL) {
- virReportOOMError();
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "host")) {
- if (esxVI_ManagedObjectReference_CastListFromAnyType
- (dynamicProperty->val, &(*computeResource)->host) < 0) {
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "resourcePool")) {
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &(*computeResource)->resourcePool) < 0) {
- goto failure;
- }
- }
- }
-
- if (esxVI_ComputeResource_Validate(*computeResource) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_ComputeResource_Free(computeResource);
-
- return -1;
-}
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: HostSystem
- * extends ManagedEntity
- */
-
-/* esxVI_HostSystem_Alloc */
-ESX_VI__TEMPLATE__ALLOC(HostSystem)
-
-/* esxVI_HostSystem_Free */
-ESX_VI__TEMPLATE__FREE(HostSystem,
-{
- esxVI_HostSystem_Free(&item->_next);
- esxVI_ManagedObjectReference_Free(&item->_reference);
-
- /* ManagedEntity */
- VIR_FREE(item->name);
-
- /* HostSystem */
- esxVI_HostConfigManager_Free(&item->configManager);
-})
-
-/* esxVI_HostSystem_Validate */
-ESX_VI__TEMPLATE__VALIDATE(HostSystem,
-{
- /* ManagedEntity */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
-
- /* HostSystem */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(configManager);
-})
-
-int
-esxVI_HostSystem_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_HostSystem **hostSystem)
-{
- esxVI_DynamicProperty *dynamicProperty = NULL;
-
- if (objectContent == NULL || hostSystem == NULL || *hostSystem != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-
- if (esxVI_HostSystem_Alloc(hostSystem) < 0) {
- return -1;
- }
-
- if (esxVI_ManagedObjectReference_DeepCopy(&(*hostSystem)->_reference,
- objectContent->obj) < 0) {
- goto failure;
- }
-
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "name")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
- }
-
- (*hostSystem)->name = strdup(dynamicProperty->val->string);
-
- if ((*hostSystem)->name == NULL) {
- virReportOOMError();
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "configManager")) {
- if (esxVI_HostConfigManager_CastFromAnyType
- (dynamicProperty->val, &(*hostSystem)->configManager) < 0) {
- goto failure;
- }
- }
- }
-
- if (esxVI_HostSystem_Validate(*hostSystem) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_HostSystem_Free(hostSystem);
-
- return -1;
-}
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Enum: VirtualMachinePowerState (Additions)
*/
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index e53ccda..ac3741f 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -1,7 +1,8 @@
+
/*
* esx_vi_types.h: client for the VMware VI API 2.5 to manage ESX hosts
*
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -44,15 +45,18 @@ typedef struct _esxVI_DateTime esxVI_DateTime;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Types
+ * SOAP
*/
typedef struct _esxVI_Fault esxVI_Fault;
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Objects
+ */
typedef struct _esxVI_MethodFault esxVI_MethodFault;
typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference;
-typedef struct _esxVI_Datacenter esxVI_Datacenter;
-typedef struct _esxVI_ComputeResource esxVI_ComputeResource;
-typedef struct _esxVI_HostSystem esxVI_HostSystem;
# include "esx_vi_types.generated.typedef"
@@ -74,9 +78,6 @@ enum _esxVI_Type {
esxVI_Type_Fault,
esxVI_Type_MethodFault,
esxVI_Type_ManagedObjectReference,
- esxVI_Type_Datacenter,
- esxVI_Type_ComputeResource,
- esxVI_Type_HostSystem,
# include "esx_vi_types.generated.typeenum"
@@ -170,6 +171,7 @@ struct _esxVI_String {
int esxVI_String_Alloc(esxVI_String **string);
void esxVI_String_Free(esxVI_String **stringList);
int esxVI_String_Validate(esxVI_String *string);
+bool esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value);
int esxVI_String_AppendToList(esxVI_String **stringList, esxVI_String *string);
int esxVI_String_AppendValueToList(esxVI_String **stringList,
const char *value);
@@ -264,7 +266,7 @@ int esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: Fault
+ * SOAP: Fault
*/
struct _esxVI_Fault {
@@ -283,7 +285,7 @@ int esxVI_Fault_Deserialize(xmlNodePtr node, esxVI_Fault **fault);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: MethodFault
+ * VI Object: MethodFault
*/
/*
@@ -306,7 +308,7 @@ int esxVI_MethodFault_Deserialize(xmlNodePtr node,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ManagedObjectReference
+ * VI Object: ManagedObjectReference
*/
struct _esxVI_ManagedObjectReference {
@@ -348,84 +350,6 @@ int esxVI_ManagedObjectReference_Deserialize
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: Datacenter
- * extends ManagedEntity
- */
-
-struct _esxVI_Datacenter {
- esxVI_Datacenter *_next; /* optional */
- esxVI_Type _type; /* required */
- esxVI_ManagedObjectReference *_reference; /* required */
-
- /* ManagedEntity */
- char *name; /* required */
-
- /* Datacenter */
- esxVI_ManagedObjectReference *hostFolder; /* required */
- esxVI_ManagedObjectReference *vmFolder; /* required */
-};
-
-int esxVI_Datacenter_Alloc(esxVI_Datacenter **datacenter);
-void esxVI_Datacenter_Free(esxVI_Datacenter **datacenter);
-int esxVI_Datacenter_Validate(esxVI_Datacenter *datacenter);
-int esxVI_Datacenter_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_Datacenter **datacenter);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: ComputeResource
- * extends ManagedEntity
- */
-
-struct _esxVI_ComputeResource {
- esxVI_ComputeResource *_next; /* optional */
- esxVI_Type _type; /* required */
- esxVI_ManagedObjectReference *_reference; /* required */
-
- /* ManagedEntity */
- char *name; /* required */
-
- /* ComputeResource */
- esxVI_ManagedObjectReference *host; /* optional, list */
- esxVI_ManagedObjectReference *resourcePool; /* optional */
-};
-
-int esxVI_ComputeResource_Alloc(esxVI_ComputeResource **computeResource);
-void esxVI_ComputeResource_Free(esxVI_ComputeResource **computeResource);
-int esxVI_ComputeResource_Validate(esxVI_ComputeResource *computeResource);
-int esxVI_ComputeResource_CastFromObjectContent
- (esxVI_ObjectContent *objectContent,
- esxVI_ComputeResource **computeResource);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: HostSystem
- * extends ManagedEntity
- */
-
-struct _esxVI_HostSystem {
- esxVI_HostSystem *_next; /* optional */
- esxVI_Type _type; /* required */
- esxVI_ManagedObjectReference *_reference; /* required */
-
- /* ManagedEntity */
- char *name; /* required */
-
- /* HostSystem */
- esxVI_HostConfigManager *configManager; /* required */
-};
-
-int esxVI_HostSystem_Alloc(esxVI_HostSystem **hostSystem);
-void esxVI_HostSystem_Free(esxVI_HostSystem **hostSystem);
-int esxVI_HostSystem_Validate(esxVI_HostSystem *hostSystem);
-int esxVI_HostSystem_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_HostSystem **hostSystem);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Enum: VirtualMachinePowerState (Additions)
*/
--
1.7.0.4
2
2
14 Apr '11
Add CastFromAnyType functions for the String type.
---
src/esx/esx_vi_generator.py | 5 +--
src/esx/esx_vi_types.c | 64 +++++++++++++++++++++++++++++++-----------
src/esx/esx_vi_types.h | 2 +
3 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 622a34a..0fd84dd 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -773,12 +773,11 @@ class Object(Base):
# cast from any type
if self.features & Object.FEATURE__ANY_TYPE:
source += "/* esxVI_%s_CastFromAnyType */\n" % self.name
- source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s,\n" % self.name
if self.extended_by is None:
- source += "{\n"
- source += "})\n\n"
+ source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s)\n\n" % self.name
else:
+ source += "ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(%s,\n" % self.name
source += "{\n"
for extended_by in self.extended_by:
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index f3df2b5..f3cdf2a 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -183,32 +183,53 @@
-#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(_type, _dispatch) \
+#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(_type, _dest_type, _extra, \
+ _dest_extra) \
int \
- esxVI_##_type##_CastFromAnyType(esxVI_AnyType *anyType, \
- esxVI_##_type **ptrptr) \
+ esxVI_##_type##_Cast##_dest_extra##FromAnyType(esxVI_AnyType *anyType, \
+ _dest_type **ptrptr) \
{ \
+ _dest_type *item; \
+ \
if (anyType == NULL || ptrptr == NULL || *ptrptr != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \
} \
\
- switch (anyType->type) { \
- _dispatch \
+ item = *ptrptr; \
\
- case esxVI_Type_##_type: \
- break; \
+ _extra \
\
- default: \
+ return esxVI_##_type##_Deserialize##_dest_extra(anyType->node, \
+ ptrptr); \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(_type) \
+ ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(_type, esxVI_##_type, \
+ { \
+ if (anyType->type != esxVI_Type_##_type) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
_("Call to %s for unexpected type '%s'"), \
__FUNCTION__, anyType->other); \
return -1; \
} \
- \
- return esxVI_##_type##_Deserialize(anyType->node, ptrptr); \
- }
+ }, /* nothing */)
+
+
+
+#define ESX_VI__TEMPLATE__CAST_VALUE_FROM_ANY_TYPE(_type, _value_type) \
+ ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(_type, _value_type, \
+ { \
+ if (anyType->type != esxVI_Type_##_type) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ _("Call to %s for unexpected type '%s'"), \
+ __FUNCTION__, anyType->other); \
+ return -1; \
+ } \
+ }, Value)
@@ -591,6 +612,13 @@
+#define ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(__type, _dispatch) \
+ ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(__type, esxVI_##__type, \
+ ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
+ /* nothing */)
+
+
+
#define ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(__type, _dispatch, _serialize) \
ESX_VI__TEMPLATE__SERIALIZE_EXTRA(__type, \
ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
@@ -1111,6 +1139,12 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
return 0;
}
+/* esxVI_String_CastFromAnyType */
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(String)
+
+/* esxVI_String_CastValueFromAnyType */
+ESX_VI__TEMPLATE__CAST_VALUE_FROM_ANY_TYPE(String, char)
+
int
esxVI_String_Serialize(esxVI_String *string, const char *element,
virBufferPtr output)
@@ -1240,9 +1274,7 @@ ESX_VI__TEMPLATE__VALIDATE(Long,
ESX_VI__TEMPLATE__LIST__APPEND(Long)
/* esxVI_Long_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Long,
-{
-})
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Long)
/* esxVI_Long_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(Long,
@@ -1522,9 +1554,7 @@ ESX_VI__TEMPLATE__DEEP_COPY(ManagedObjectReference,
ESX_VI__TEMPLATE__LIST__APPEND(ManagedObjectReference)
/* esxVI_ManagedObjectReference_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference,
-{
-})
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference)
/* esxVI_ManagedObjectReference_CastListFromAnyType */
ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(ManagedObjectReference)
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index 1ab39da..e53ccda 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -178,6 +178,8 @@ int esxVI_String_AppendValueListToList(esxVI_String **stringList,
int esxVI_String_DeepCopy(esxVI_String **dest, esxVI_String *src);
int esxVI_String_DeepCopyList(esxVI_String **destList, esxVI_String *srcList);
int esxVI_String_DeepCopyValue(char **dest, const char *src);
+int esxVI_String_CastFromAnyType(esxVI_AnyType *anyType, esxVI_String **string);
+int esxVI_String_CastValueFromAnyType(esxVI_AnyType *anyType, char **string);
int esxVI_String_Serialize(esxVI_String *string, const char *element,
virBufferPtr output);
int esxVI_String_SerializeList(esxVI_String *stringList, const char *element,
--
1.7.0.4
2
2