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
- 19 participants
- 40177 discussions
This is an major update to
http://www.redhat.com/archives/libvir-list/2011-February/msg00257.html
In this update
- Bug fixes from previous review
- Remove assert() usage
- Introduce SPICE graphics relocation
- Refactoring of peer2peer & tunnelled migration code
- Support for v3 migration with p2p & tunnelled migration
- A (broken) attempt to make job signal/status updates work
with tunnelled migration
The latter item seemed to be working fine, but I've since
found that it can cause QEMU to deadlock. While we're sending
QEMU a montor command to update status, QEMU may be trying to
write some migration data and it often blocks on write() to
the migration socket. This could be a bug with us not giving
it a non-blocking socket, or it could be a QEMU limitation.
To be investigated....
2
19
21 Apr '11
The two ends of the pipe used for feeding QEMU tunnelled
migration data were interchanged, so QEMU got given the
"write" end instead of the "read" end.
The qemuMigrationPrepareTunnel method was also immediately
closing the "write" end of the pipe, so the stream failed
to actually write anything.
* src/qemu/qemu_migration.c: Swap tunnelled migration
pipe FDs & don't close pipe given to stream
---
src/qemu/qemu_migration.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index bba76d5..7f4b111 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -301,7 +301,7 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
vm->def->id = -1;
if (pipe(dataFD) < 0 ||
- virSetCloseExec(dataFD[0]) < 0) {
+ virSetCloseExec(dataFD[1]) < 0) {
virReportSystemError(errno, "%s",
_("cannot create pipe for tunnelled migration"));
goto endjob;
@@ -318,7 +318,7 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
/* Start the QEMU daemon, with the same command-line arguments plus
* -incoming stdio (which qemu_command might convert to exec:cat or fd:n)
*/
- internalret = qemuProcessStart(dconn, driver, vm, "stdio", true, dataFD[1],
+ internalret = qemuProcessStart(dconn, driver, vm, "stdio", true, dataFD[0],
NULL, VIR_VM_OP_MIGRATE_IN_START);
if (internalret < 0) {
qemuAuditDomainStart(vm, "migrated", false);
@@ -332,7 +332,7 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
goto endjob;
}
- if (virFDStreamOpen(st, dataFD[0]) < 0) {
+ if (virFDStreamOpen(st, dataFD[1]) < 0) {
qemuAuditDomainStart(vm, "migrated", false);
qemuProcessStop(driver, vm, 0);
if (!vm->persistent) {
@@ -344,6 +344,7 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
_("cannot pass pipe for tunnelled migration"));
goto endjob;
}
+ dataFD[1] = -1; /* 'st' owns the FD now & will close it */
qemuAuditDomainStart(vm, "migrated", true);
--
1.7.4.4
2
1
21 Apr '11
Remove the artificial minimum of 4096 KB for guest memory. It's drivers'
job to set the limit if needed.
---
src/libvirt.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 9e6784b..10c3cdf 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2738,7 +2738,7 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
- if (memory < 4096) {
+ if (!memory) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
@@ -2792,7 +2792,7 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory)
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
- if (memory < 4096) {
+ if (!memory) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
@@ -2861,7 +2861,7 @@ virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
goto error;
}
- if (memory < 4096) {
+ if (!memory) {
virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
--
1.7.5.rc1
2
2
Hi,
is tunnelled migration with libvirt 0.9.0 and qemu-kvm 0.14.0 broken ?
all I get is an error "unknown migration protocol"
while looking at the code in src/qemu/qemu_migration.c
src/qemu/qemu_migration.c:
/* Start the QEMU daemon, with the same command-line arguments plus
* -incoming stdin (which qemu_command might convert to exec:cat or
fd:n)
*/
internalret = qemuProcessStart(dconn, driver, vm, "stdin", true,
dataFD[1],
NULL, VIR_VM_OP_MIGRATE_IN_START);
migrateFrom is set to "stdin" but in src/qemu/qemu_command.c
there is no such match which ends in the above error.
Regards,
Jason
5
7
Adding reboot <domain> function for pHyp driver.
---
src/phyp/phyp_driver.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index bb0e0ac..228751d 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3384,6 +3384,39 @@ cleanup:
}
static int
+phypDomainReboot(virDomainPtr dom)
+{
+ int result = -1;
+ ConnectionData *connection_data = dom->conn->networkPrivateData;
+ virConnectPtr conn = dom->conn;
+ LIBSSH2_SESSION *session = connection_data->session;
+ phyp_driverPtr phyp_driver = conn->privateData;
+ int system_type = phyp_driver->system_type;
+ char *managed_system = phyp_driver->managed_system;
+ int exit_status = 0;
+ char *ret = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virBufferAddLit(&buf, "chsysstate");
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, " -m %s", managed_system);
+ virBufferVSprintf(&buf,
+ " -r lpar -o shutdown --id %d --immed --restart",
+ dom->id);
+ ret = phypExecBuffer(session, &buf, &exit_status, dom->conn, false);
+
+ if (exit_status < 0)
+ goto cleanup;
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(ret);
+
+ return result;
+}
+
+static int
phypDomainShutdown(virDomainPtr dom)
{
int result = -1;
@@ -3707,7 +3740,7 @@ static virDriver phypDriver = {
NULL, /* domainSuspend */
phypDomainResume, /* domainResume */
phypDomainShutdown, /* domainShutdown */
- NULL, /* domainReboot */
+ phypDomainReboot, /* domainReboot */
phypDomainDestroy, /* domainDestroy */
NULL, /* domainGetOSType */
NULL, /* domainGetMaxMemory */
--
1.7.1
2
1
21 Apr '11
To be used to share a CURL handle between multiple threads in the
upcoming domain event support.
---
src/esx/esx_vi.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/esx/esx_vi.h | 19 ++++++
2 files changed, 195 insertions(+), 0 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 2fd09cd..84ff2e2 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -85,6 +85,16 @@ ESX_VI__TEMPLATE__ALLOC(CURL)
/* esxVI_CURL_Free */
ESX_VI__TEMPLATE__FREE(CURL,
{
+ esxVI_SharedCURL *shared = item->shared;
+
+ if (shared != NULL) {
+ esxVI_SharedCURL_Remove(shared, item);
+
+ if (shared->count == 0) {
+ esxVI_SharedCURL_Free(&shared);
+ }
+ }
+
if (item->handle != NULL) {
curl_easy_cleanup(item->handle);
}
@@ -418,6 +428,172 @@ esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * SharedCURL
+ */
+
+static void
+esxVI_SharedCURL_Lock(CURL *handle ATTRIBUTE_UNUSED, curl_lock_data data,
+ curl_lock_access access_ ATTRIBUTE_UNUSED, void *userptr)
+{
+ int i;
+ esxVI_SharedCURL *shared = userptr;
+
+ switch (data) {
+ case CURL_LOCK_DATA_SHARE:
+ i = 0;
+ break;
+
+ case CURL_LOCK_DATA_COOKIE:
+ i = 1;
+ break;
+
+ case CURL_LOCK_DATA_DNS:
+ i = 2;
+ break;
+
+ default:
+ VIR_ERROR(_("Trying to lock unknown SharedCURL lock %d"), (int)data);
+ return;
+ }
+
+ virMutexLock(&shared->locks[i]);
+}
+
+static void
+esxVI_SharedCURL_Unlock(CURL *handle ATTRIBUTE_UNUSED, curl_lock_data data,
+ void *userptr)
+{
+ int i;
+ esxVI_SharedCURL *shared = userptr;
+
+ switch (data) {
+ case CURL_LOCK_DATA_SHARE:
+ i = 0;
+ break;
+
+ case CURL_LOCK_DATA_COOKIE:
+ i = 1;
+ break;
+
+ case CURL_LOCK_DATA_DNS:
+ i = 2;
+ break;
+
+ default:
+ VIR_ERROR(_("Trying to unlock unknown SharedCURL lock %d"), (int)data);
+ return;
+ }
+
+ virMutexUnlock(&shared->locks[i]);
+}
+
+/* esxVI_SharedCURL_Alloc */
+ESX_VI__TEMPLATE__ALLOC(SharedCURL)
+
+/* esxVI_SharedCURL_Free */
+ESX_VI__TEMPLATE__FREE(SharedCURL,
+{
+ int i;
+
+ if (item->count > 0) {
+ /* Better leak than crash */
+ VIR_ERROR0(_("Trying to free SharedCURL object that is still in use"));
+ return;
+ }
+
+ if (item->handle != NULL) {
+ curl_share_cleanup(item->handle);
+ }
+
+ for (i = 0; i < ARRAY_CARDINALITY(item->locks); ++i) {
+ virMutexDestroy(&item->locks[i]);
+ }
+})
+
+int
+esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_CURL *curl)
+{
+ int i;
+
+ if (curl->handle == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot share uninitialized CURL handle"));
+ return -1;
+ }
+
+ if (curl->shared != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot share CURL handle that is already shared"));
+ return -1;
+ }
+
+ if (shared->handle == NULL) {
+ shared->handle = curl_share_init();
+
+ if (shared->handle == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not initialize CURL (share)"));
+ return -1;
+ }
+
+ curl_share_setopt(shared->handle, CURLSHOPT_LOCKFUNC,
+ esxVI_SharedCURL_Lock);
+ curl_share_setopt(shared->handle, CURLSHOPT_UNLOCKFUNC,
+ esxVI_SharedCURL_Unlock);
+ curl_share_setopt(shared->handle, CURLSHOPT_USERDATA, shared);
+ curl_share_setopt(shared->handle, CURLSHOPT_SHARE,
+ CURL_LOCK_DATA_COOKIE);
+ curl_share_setopt(shared->handle, CURLSHOPT_SHARE,
+ CURL_LOCK_DATA_DNS);
+
+ for (i = 0; i < ARRAY_CARDINALITY(shared->locks); ++i) {
+ if (virMutexInit(&shared->locks[i]) < 0) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not initialize a CURL (share) mutex"));
+ return -1;
+ }
+ }
+ }
+
+ curl_easy_setopt(curl->handle, CURLOPT_SHARE, shared->handle);
+
+ curl->shared = shared;
+ ++shared->count;
+
+ return 0;
+}
+
+int
+esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl)
+{
+ if (curl->handle == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot unshare uninitialized CURL handle"));
+ return -1;
+ }
+
+ if (curl->shared == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot unshare CURL handle that is not shared"));
+ return -1;
+ }
+
+ if (curl->shared != shared) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (share) mismatch"));
+ return -1;
+ }
+
+ curl_easy_setopt(curl->handle, CURLOPT_SHARE, NULL);
+
+ curl->shared = NULL;
+ --shared->count;
+
+ return 0;
+}
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Context
*/
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 57788ac..560b2a6 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -83,6 +83,7 @@ typedef enum _esxVI_ProductVersion esxVI_ProductVersion;
typedef enum _esxVI_Occurrence esxVI_Occurrence;
typedef struct _esxVI_ParsedHostCpuIdInfo esxVI_ParsedHostCpuIdInfo;
typedef struct _esxVI_CURL esxVI_CURL;
+typedef struct _esxVI_SharedCURL esxVI_SharedCURL;
typedef struct _esxVI_Context esxVI_Context;
typedef struct _esxVI_Response esxVI_Response;
typedef struct _esxVI_Enumeration esxVI_Enumeration;
@@ -151,6 +152,7 @@ struct _esxVI_CURL {
virMutex lock;
struct curl_slist *headers;
char error[CURL_ERROR_SIZE];
+ esxVI_SharedCURL *shared;
};
int esxVI_CURL_Alloc(esxVI_CURL **curl);
@@ -162,6 +164,23 @@ int esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * SharedCURL
+ */
+
+struct _esxVI_SharedCURL {
+ CURLSH *handle;
+ virMutex locks[3]; /* share, cookie, dns */
+ size_t count;
+};
+
+int esxVI_SharedCURL_Alloc(esxVI_SharedCURL **shared);
+void esxVI_SharedCURL_Free(esxVI_SharedCURL **shared);
+int esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_CURL *curl);
+int esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl);
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Context
*/
--
1.7.0.4
1
1
This series adds a virObject structure that manages reference-counting.
Some notes about referece-counting introduced by this series:
A thread owns a virObject by incrementing its reference-count by 1.
If a thread owns a virObject, the virObject is guarenteed not be
freed until the thread releases ownership by decrementing its
reference-count by 1. A thread can't access a virObject after it
releases the ownership of virObject because it can be freed at
anytime.
A thread can own a virObject legally in these ways:
- a thread owns a virObject that it creates.
- a thread owns a virObject if another thread passes the ownership
to it. Example: qemuMonitorOpen
- a thread gets a virObject from a container.
Example: virDomainFindByUUID
- a container owns a virObject by incrementing its reference-count
by 1 before adding it to the container
- if a virObject is removed from a container its reference-count
must be decremented by 1
By following these rules, there is no need to protect operations on
an object's reference-count by an external lock. (like in old ways
virDomainObj lock protects qemu monitor's ref-count.)
This series is a draft and posted for early review. Any comments are
welcome.
Hu Tao (6):
Add virObject and virAtomic.
use virObject to manage reference-count of qemud_client
use virObject to manage reference-count of virDomainObj
qemu: use virObject to manages reference-counting for qemu monitor
remove qemuDomainObjEnterMonitorWithDriver and
qemuDomainObjExitMonitorWithDriver
remove qemuDomainObjBeginJobWithDriver
daemon/dispatch.c | 2 -
daemon/libvirtd.c | 62 ++++++--
daemon/libvirtd.h | 5 +-
src/Makefile.am | 2 +
src/conf/domain_conf.c | 56 ++++----
src/conf/domain_conf.h | 6 +-
src/libvirt_private.syms | 5 +
src/openvz/openvz_conf.c | 8 +-
src/qemu/qemu_domain.c | 121 +--------------
src/qemu/qemu_domain.h | 8 +-
src/qemu/qemu_driver.c | 358 ++++++++++++++++++++-------------------------
src/qemu/qemu_hotplug.c | 90 ++++++------
src/qemu/qemu_migration.c | 101 ++++++-------
src/qemu/qemu_monitor.c | 109 ++++++++-------
src/qemu/qemu_monitor.h | 4 +-
src/qemu/qemu_process.c | 99 ++++++-------
src/util/viratomic.c | 46 ++++++
src/util/viratomic.h | 30 ++++
src/util/virobject.c | 52 +++++++
src/util/virobject.h | 39 +++++
src/vmware/vmware_conf.c | 2 +-
21 files changed, 628 insertions(+), 577 deletions(-)
create mode 100644 src/util/viratomic.c
create mode 100644 src/util/viratomic.h
create mode 100644 src/util/virobject.c
create mode 100644 src/util/virobject.h
--
1.7.3.1
4
35
I am trying to get virsh commands with timestamp logged into a file
along with logs collected from libvirt. Finding that virsh and libvirt
logs into separate log files. Please suggest on what could be a right
approach to get both virsh and libvirt logs into a single file.
Thanks,
Supriya
1
0
Good morning!
I am one of the developers of OurGrid (http://www.ourgrid.org) a middleware
that enables the creation of peer-to-peer computational grids, and we are
studying your Libvirt API in order to see if it satisfies our middleware's
demands.
So we found out your Application Development Guide, and it is being quite
useful. I just found small mistakes in the code examples. Even though don't
know if this is the appropriate place to notify you guys, here you are:
At section 3.9, in the main function, the if block above:
if (conn4 == NULL) {
fprintf(stderr, "Failed to open connection to
qemu:///system\n");
virConnectClose(conn3);
virConnectClose(conn2);
virConnectClose(conn1);
return 3;
}
The 'return 3' was meant to be 'return 4', right?
And I guess that the final If block at section 4.3 is just missing a return
statement too.
With that being said, I want to take this opportunity to say that
documentation of section 9.3 (Java bindings) would be of great help to us,
since we are developing everything using Java.
Cheers and congratulations for this great job you guys are doing.
Moreover, sorry for my poor english.
Guilherme Santos
--
Guilherme Santos G. Baptista
Graduando em Ciência da Computação pela UFCG
LSD - Laboratório de Sistemas Distribuídos
1
0
[libvirt] [libvirt-snmp][PATCH v5 0/4] Add SNMP trap/notification support
by Michal Privoznik 20 Apr '11
by Michal Privoznik 20 Apr '11
20 Apr '11
The fifth version.
In case we build against libvirt older than 0.9.0 (which have old event API),
we need to include some sources from libvirt git. So we are able to run even
on older RHELs, like 5.6. Those files were copied to our git and modified
very slighty.
Finally, we have a proof-of-concept implementation of SNMP trap.
Two new files were first generated using mib2c then edited, so be
careful when re-generating them.
Destination of traps is defined in snmpd.conf (trap2sink), and to
receive them snmptrapd must be configured and up.
The idea behind is - create a thread in which we poll for domain
events. Once we receive event notification, we just fire up
trap sending.
Michal Privoznik (4):
Add notification-type object to libvirt MIB
Add libvirt error handling function
Create functions to fill in and send notification packets.
Add SNMP trap/notification support.
INSTALL.1st | 9 +-
configure.ac | 17 +-
libvirt-snmp.spec.in | 7 +-
src/LIBVIRT-MIB.txt | 9 +
src/Makefile.am | 25 ++-
src/README.txt | 9 +-
src/event_poll.c | 724 ++++++++++++++++++++++++++++++++++++++++++++
src/event_poll.h | 132 ++++++++
src/ignore-value.h | 64 ++++
src/internal.h | 267 ++++++++++++++++
src/libvirtNotifications.c | 122 ++++++++
src/libvirtNotifications.h | 33 ++
src/libvirtSnmp.c | 154 +++++++++-
src/libvirtSnmpError.c | 34 ++
src/libvirtSnmpError.h | 31 ++
src/memory.c | 313 +++++++++++++++++++
src/memory.h | 212 +++++++++++++
src/threads.c | 251 +++++++++++++++
src/threads.h | 101 ++++++
src/util.c | 105 +++++++
src/util.h | 38 +++
21 files changed, 2643 insertions(+), 14 deletions(-)
create mode 100644 src/event_poll.c
create mode 100644 src/event_poll.h
create mode 100644 src/ignore-value.h
create mode 100644 src/internal.h
create mode 100644 src/libvirtNotifications.c
create mode 100644 src/libvirtNotifications.h
create mode 100644 src/libvirtSnmpError.c
create mode 100644 src/libvirtSnmpError.h
create mode 100644 src/memory.c
create mode 100644 src/memory.h
create mode 100644 src/threads.c
create mode 100644 src/threads.h
create mode 100644 src/util.c
create mode 100644 src/util.h
--
1.7.4.2
2
5
also add flags for this function, currently not used.
---
src/libvirt-php.c | 31 +++++++++++++++++++++++++++++++
src/libvirt-php.h | 1 +
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index d436e1c..54331bb 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -129,6 +129,7 @@ static function_entry libvirt_functions[] = {
PHP_FE(libvirt_storagepool_refresh, NULL)
PHP_FE(libvirt_storagepool_set_autostart, NULL)
PHP_FE(libvirt_storagepool_get_autostart, NULL)
+ PHP_FE(libvirt_storagepool_build, NULL)
/* Network functions */
PHP_FE(libvirt_network_define_xml, NULL)
PHP_FE(libvirt_network_undefine, NULL)
@@ -542,6 +543,13 @@ PHP_MINIT_FUNCTION(libvirt)
/* Forcibly modify device (ex. force eject a cdrom) */
REGISTER_LONG_CONSTANT("VIR_DOMAIN_DEVICE_MODIFY_FORCE", 4, CONST_CS | CONST_PERSISTENT);
+ /* REGISTER_LONG_CONSTANT */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_NEW", 0, CONST_CS | CONST_PERSISTENT);
+ /* Repair / reinitialize */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_REPAIR", 1, CONST_CS | CONST_PERSISTENT);
+ /* Extend existing pool */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_RESIZE", 2, CONST_CS | CONST_PERSISTENT);
+
REGISTER_INI_ENTRIES();
/* Initialize libvirt and set up error callback */
@@ -3582,6 +3590,29 @@ PHP_FUNCTION(libvirt_storagepool_get_autostart)
}
}
+/*
+ Function name: libvirt_storagepool_build
+ Since version: 0.4.2
+ Description: Function is used to Build the underlying storage pool, e.g. create the destination directory for NFS
+ Arguments: @res [resource]: libvirt storagepool resource
+ Returns: TRUE if success, FALSE on error
+*/
+PHP_FUNCTION(libvirt_storagepool_build)
+{
+ php_libvirt_storagepool *pool = NULL;
+ zval *zpool;
+ int flags = 0;
+
+ GET_STORAGEPOOL_FROM_ARGS ("r", &zpool);
+
+ if (virStoragePoolBuild (pool->pool, flags) == 0)
+ {
+ RETURN_TRUE;
+ }
+
+ RETURN_FALSE;
+}
+
/* Listing functions */
/*
Function name: libvirt_list_storagepools
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 4e8dec6..2d79f60 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -193,6 +193,7 @@ PHP_FUNCTION(libvirt_storagepool_get_volume_count);
PHP_FUNCTION(libvirt_storagepool_refresh);
PHP_FUNCTION(libvirt_storagepool_set_autostart);
PHP_FUNCTION(libvirt_storagepool_get_autostart);
+PHP_FUNCTION(libvirt_storagepool_build);
/* Network functions */
PHP_FUNCTION(libvirt_network_define_xml);
PHP_FUNCTION(libvirt_network_undefine);
--
1.7.3.4
2
1
[libvirt] [RFC][PATCHv1 0/5] libvirt - show per cpu accounting information
by KAMEZAWA Hiroyuki 20 Apr '11
by KAMEZAWA Hiroyuki 20 Apr '11
20 Apr '11
When running 'virt-top -1' , "show percpu statistics mode",
virt-top shows a fake value.
When running 'while true; do echo hello;done' on a 4vcpu guest,
==
0 0.0
1 0.0
2 0.0
3 0.0
4 25.0 25.0=
5 25.0 25.0=#
6 25.0 25.0=
7 25.0 25.0=
==
All cpus just used equally ;)
This is because there is no interface to get per-cpu usage of domain.
This patch adds an interface virDomainPcpuStats() to get per-cpu
statistics, cpuTime in nanoseconds.
Here is a test result with a python script using new interface.
==
[root@bluextal python]# ./virt-cpuacct.py
({'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 4679204346L}, {'cpuTime': 2103820380L}, {'cpuTime': 8904513019L}, {'cpuTime': 7424701195L})
[root@bluextal python]# ./virt-cpuacct.py
({'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 0L}, {'cpuTime': 57010689139L}, {'cpuTime': 26152907202L}, {'cpuTime': 53759693931L}, {'cpuTime': 43074348218L})
==
Although I added a new interface, I still wonder what interface is better...
any comments are welcome.
Thanks,
-Kame
4
13
[libvirt] [PATCHv10 0/6] libvirt - support persistent device modification
by KAMEZAWA Hiroyuki 20 Apr '11
by KAMEZAWA Hiroyuki 20 Apr '11
20 Apr '11
Hi, this is v10, totally refleshed. Thank you for advices.
This version includes Eric's cleanup and Hu's Update device works.
(And droppped some sanity check patches.)
Because of many changes from v9, it may be better to write [RFC] in subject ;)
This patch series does
consolidate Attach/Detach/Update device's codes as..
==
shared code (prepare lock, get objects etc..)
switch(action) {
case ATTACH
case DETACH
case UPDATE
}
shared code.
==
After that, adding persistent modification support as
==
shared code (prepare lock, get objects etc...)
if (MODIFY_CONFIG) {
switch (action) {
case ATTACH:
case DETACH:
case UPDATE:
}
}
if (MODIFY_LIVE) {
switch (action) {
case ATTACH:
case DETACH:
case UPDATE:
}
}
shared code. (save config etc.)
==
Thanks,
-Kame
2
14
19 Apr '11
Ebtables filtering doesn't work on macvtap device. Remove support for
direct type of interface.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
docs/formatnwfilter.html.in | 2 --
src/conf/domain_conf.c | 1 -
src/nwfilter/nwfilter_ebiptables_driver.c | 16 +---------------
3 files changed, 1 insertion(+), 18 deletions(-)
Index: libvirt-acl/src/conf/domain_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/domain_conf.c
+++ libvirt-acl/src/conf/domain_conf.c
@@ -2862,7 +2862,6 @@ virDomainNetDefParseXML(virCapsPtr caps,
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
- case VIR_DOMAIN_NET_TYPE_DIRECT:
def->filter = filter;
filter = NULL;
def->filterparams = filterparams;
Index: libvirt-acl/docs/formatnwfilter.html.in
===================================================================
--- libvirt-acl.orig/docs/formatnwfilter.html.in
+++ libvirt-acl/docs/formatnwfilter.html.in
@@ -52,8 +52,6 @@
<li><code>network</code></li>
<li><code>ethernet</code> -- must be used in bridging mode</li>
<li><code>bridge</code></li>
- <li><code>direct</code> -- only protocols mac, arp, ip and ipv6
- can be filtered</li>
</ul>
<p>
The interface XML is used to reference a top-level filter. In the
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -2357,7 +2357,7 @@ err_exit:
*/
static int
ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
- enum virDomainNetType nettype,
+ enum virDomainNetType nettype
ATTRIBUTE_UNUSED,
virNWFilterDefPtr nwfilter,
virNWFilterRuleDefPtr rule,
const char *ifname,
@@ -2409,13 +2409,6 @@ ebiptablesCreateRuleInstance(virConnectP
case VIR_NWFILTER_RULE_PROTOCOL_ICMP:
case VIR_NWFILTER_RULE_PROTOCOL_IGMP:
case VIR_NWFILTER_RULE_PROTOCOL_ALL:
- if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
- _("'%s' protocol not support for net type '%s'"),
-
virNWFilterRuleProtocolTypeToString(rule->prtclType),
- virDomainNetTypeToString(nettype));
- return 1;
- }
isIPv6 = 0;
rc = iptablesCreateRuleInstance(nwfilter,
rule,
@@ -2433,13 +2426,6 @@ ebiptablesCreateRuleInstance(virConnectP
case VIR_NWFILTER_RULE_PROTOCOL_SCTPoIPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6:
- if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
- _("'%s' protocol not support for net type '%s'"),
-
virNWFilterRuleProtocolTypeToString(rule->prtclType),
- virDomainNetTypeToString(nettype));
- return 1;
- }
isIPv6 = 1;
rc = iptablesCreateRuleInstance(nwfilter,
rule,
2
2
[libvirt] [PATCH] Allow handshake with child process during startup
by Daniel P. Berrange 19 Apr '11
by Daniel P. Berrange 19 Apr '11
19 Apr '11
Allow the parent process to perform a bi-directional handshake
with the child process during fork/exec. The child process
will fork and do its initial setup. Immediately prior to the
exec(), it will stop & wait for a handshake from the parent
process. The parent process will spawn the child and wait
until the child reaches the handshake point. It will do
whatever extra setup work is required, before signalling the
child to continue.
The implementation of this is done using two pairs of blocking
pipes. The first pair is used to block the parent, until the
child writes a single byte. Then the second pair pair is used
to block the child, until the parent confirms with another
single byte.
* src/util/command.c, src/util/command.h,
src/libvirt_private.syms: Add APIs to perform a handshake
---
src/libvirt_private.syms | 3 +
src/util/command.c | 161 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/command.h | 22 ++++++
3 files changed, 185 insertions(+), 1 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b787811..b91727a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -106,11 +106,14 @@ virCommandAddEnvString;
virCommandClearCaps;
virCommandDaemonize;
virCommandFree;
+virCommandHandshakeNotify;
+virCommandHandshakeWait;
virCommandNew;
virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPreserveFD;
+virCommandRequireHandshake;
virCommandRun;
virCommandRunAsync;
virCommandSetErrorBuffer;
diff --git a/src/util/command.c b/src/util/command.c
index 862a913..6213a3d 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -35,6 +35,8 @@
#include "files.h"
#include "buf.h"
+#include <stdlib.h>
+
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
@@ -76,6 +78,10 @@ struct _virCommand {
int *outfdptr;
int *errfdptr;
+ bool handshake;
+ int handshakeWait[2];
+ int handshakeNotify[2];
+
virExecHook hook;
void *opaque;
@@ -107,6 +113,11 @@ virCommandNewArgs(const char *const*args)
if (VIR_ALLOC(cmd) < 0)
return NULL;
+ cmd->handshakeWait[0] = -1;
+ cmd->handshakeWait[1] = -1;
+ cmd->handshakeNotify[0] = -1;
+ cmd->handshakeNotify[1] = -1;
+
FD_ZERO(&cmd->preserve);
FD_ZERO(&cmd->transfer);
cmd->infd = cmd->outfd = cmd->errfd = -1;
@@ -1125,12 +1136,61 @@ virCommandHook(void *data)
virCommandPtr cmd = data;
int res = 0;
- if (cmd->hook)
+ if (cmd->hook) {
+ VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
res = cmd->hook(cmd->opaque);
+ VIR_DEBUG("Done hook %d", res);
+ }
if (res == 0 && cmd->pwd) {
VIR_DEBUG("Running child in %s", cmd->pwd);
res = chdir(cmd->pwd);
+ if (res < 0) {
+ virReportSystemError(errno,
+ _("Unable to change to %s"), cmd->pwd);
+ }
+ }
+ if (cmd->handshake) {
+ char c = res < 0 ? '0' : '1';
+ int rv;
+ VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify parent process"));
+ return -1;
+ }
+
+ /* On failure we pass the error message back to parent,
+ * so they don't have to dig through stderr logs
+ */
+ if (res < 0) {
+ virErrorPtr err = virGetLastError();
+ const char *msg = err ? err->message :
+ _("Unknown failure during hook execution");
+ size_t len = strlen(msg) + 1;
+ if (safewrite(cmd->handshakeWait[1], msg, len) != len) {
+ virReportSystemError(errno, "%s", _("Unable to send error to parent process"));
+ return -1;
+ }
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d", cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s", _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL, _("Unexpected confirm code '%c' from parent process"), c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
}
+
+ VIR_DEBUG("Hook is done %d", res);
+
return res;
}
@@ -1220,6 +1280,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
FD_CLR(i, &cmd->transfer);
}
}
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ }
if (ret == 0 && pid)
*pid = cmd->pid;
@@ -1360,6 +1424,94 @@ virCommandAbort(virCommandPtr cmd ATTRIBUTE_UNUSED)
}
#endif
+
+void virCommandRequireHandshake(virCommandPtr cmd)
+{
+ if (!cmd || cmd->has_error)
+ return;
+
+ if (pipe(cmd->handshakeWait) < 0) {
+ cmd->has_error = errno;
+ return;
+ }
+ if (pipe(cmd->handshakeNotify) < 0) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ cmd->has_error = errno;
+ return;
+ }
+
+ VIR_DEBUG("Transfer handshake wait=%d notify=%d",
+ cmd->handshakeWait[1], cmd->handshakeNotify[0]);
+ virCommandPreserveFD(cmd, cmd->handshakeWait[1]);
+ virCommandPreserveFD(cmd, cmd->handshakeNotify[0]);
+ cmd->handshake = true;
+}
+
+int virCommandHandshakeWait(virCommandPtr cmd)
+{
+ char c;
+ int rv;
+ if (!cmd ||cmd->has_error == ENOMEM) {
+ virReportOOMError();
+ return -1;
+ }
+ if (cmd->has_error) {
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("invalid use of command API"));
+ return -1;
+ }
+
+ VIR_DEBUG("Wait for handshake on %d", cmd->handshakeWait[0]);
+ if ((rv = saferead(cmd->handshakeWait[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait for child process"));
+ else
+ virReportSystemError(EIO, "%s", _("Child process quit during startup handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ char *msg;
+ ssize_t len;
+ if (VIR_ALLOC_N(msg, 1024) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if ((len = saferead(cmd->handshakeWait[0], msg, 1024)) < 0) {
+ VIR_FREE(msg);
+ virReportSystemError(errno, "%s", _("No error message from child failure"));
+ return -1;
+ }
+ msg[len-1] = '\0';
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
+ VIR_FREE(msg);
+ return -1;
+ }
+ return 0;
+}
+
+int virCommandHandshakeNotify(virCommandPtr cmd)
+{
+ char c = '1';
+ if (!cmd ||cmd->has_error == ENOMEM) {
+ virReportOOMError();
+ return -1;
+ }
+ if (cmd->has_error) {
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("invalid use of command API"));
+ return -1;
+ }
+
+ VIR_DEBUG("Notify handshake on %d", cmd->handshakeWait[0]);
+ if (safewrite(cmd->handshakeNotify[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify child process"));
+ return -1;
+ }
+ return 0;
+}
+
+
/*
* Release all resources
*/
@@ -1391,6 +1543,13 @@ virCommandFree(virCommandPtr cmd)
VIR_FREE(cmd->pwd);
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[1]);
+ }
+
VIR_FREE(cmd->pidfile);
if (cmd->reap)
diff --git a/src/util/command.h b/src/util/command.h
index ff8ccf5..f1b372b 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -275,6 +275,28 @@ int virCommandWait(virCommandPtr cmd,
int *exitstatus) ATTRIBUTE_RETURN_CHECK;
/*
+ * Request that the child perform a handshake with
+ * the parent when the hook function has completed
+ * execution. The child will not exec() until the
+ * parent has notified
+ */
+void virCommandRequireHandshake(virCommandPtr cmd);
+
+/*
+ * Wait for the child to complete execution of its
+ * hook function
+ */
+int virCommandHandshakeWait(virCommandPtr cmd)
+ ATTRIBUTE_RETURN_CHECK;
+
+/*
+ * Notify the child that it is OK to exec() the
+ * real binary now
+ */
+int virCommandHandshakeNotify(virCommandPtr cmd)
+ ATTRIBUTE_RETURN_CHECK;
+
+/*
* Abort an async command if it is running, without issuing
* any errors or affecting errno. Designed for error paths
* where some but not all paths to the cleanup code might
--
1.7.4.4
1
0
Gnulib already guarantees <stdbool.h>, so it is easier to just
use the standardized spellings.
* tools/virsh.c (vshCmdDef): Change callback to return real bool.
(__vshControl): Change several fields to bool.
(vshCommandOptBool): Change return type.
All callers updated.
* tools/Makefile.am (virsh-net-edit.c, virsh-pool-edit.c):
Likewise.
---
Mostly mechanical.
tools/Makefile.am | 4 +-
tools/virsh.c | 1674 ++++++++++++++++++++++++++---------------------------
2 files changed, 835 insertions(+), 843 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 3e31dbd..826674a 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -64,7 +64,7 @@ BUILT_SOURCES = virsh-net-edit.c virsh-pool-edit.c
virsh-net-edit.c: virsh.c Makefile.am
$(AM_V_GEN)rm -f $@-tmp && \
echo '/* Automatically generated from: $^ */' > $@-tmp && \
- echo 'static int' >> $@-tmp && \
+ echo 'static bool' >> $@-tmp && \
awk '/^cmdEdit/, /^}/' $< \
| sed -e 's/domain/network/g' \
-e 's/Domain/Network/g' \
@@ -79,7 +79,7 @@ virsh-net-edit.c: virsh.c Makefile.am
virsh-pool-edit.c: virsh.c Makefile.am
$(AM_V_GEN)rm -f $@-tmp && \
echo '/* Automatically generated from: $^ */' > $@-tmp && \
- echo 'static int' >> $@-tmp && \
+ echo 'static bool' >> $@-tmp && \
awk '/^cmdEdit/, /^}/' $< \
| sed -e 's/domain/pool/g' \
-e 's/vshCommandOptDomain/vshCommandOptPool/g' \
diff --git a/tools/virsh.c b/tools/virsh.c
index 486442e..21560d8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -61,11 +61,6 @@
static char *progname;
-#ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-#endif
-
#define VIRSH_MAX_XML_FILE 10*1024*1024
#define VSH_PROMPT_RW "virsh # "
@@ -195,7 +190,7 @@ typedef struct vshCmdOpt {
*/
typedef struct {
const char *name;
- int (*handler) (vshControl *, const vshCmd *); /* command handler */
+ bool (*handler) (vshControl *, const vshCmd *); /* command handler */
const vshCmdOptDef *opts; /* definition of command options */
const vshCmdInfo *info; /* details about command */
} vshCmdDef;
@@ -217,11 +212,11 @@ typedef struct __vshControl {
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
vshCmd *cmd; /* the current command */
char *cmdstr; /* string with command */
- int imode; /* interactive mode? */
- int quiet; /* quiet mode */
+ bool imode; /* interactive mode? */
+ bool quiet; /* quiet mode */
int debug; /* print debug messages? */
- int timing; /* print timing info? */
- int readonly; /* connect readonly (first time only, not
+ bool timing; /* print timing info? */
+ bool readonly; /* connect readonly (first time only, not
* during explicit connect command)
*/
char *logfile; /* log file name */
@@ -271,7 +266,7 @@ static int vshCommandOptLongLong(const vshCmd *cmd, const char *name,
static int vshCommandOptULongLong(const vshCmd *cmd, const char *name,
unsigned long long *value)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
-static int vshCommandOptBool(const vshCmd *cmd, const char *name);
+static bool vshCommandOptBool(const vshCmd *cmd, const char *name);
static char *vshCommandOptArgv(const vshCmd *cmd, int count);
#define VSH_BYID (1 << 1)
@@ -599,7 +594,7 @@ static const vshCmdOptDef opts_help[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdHelp(vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
@@ -621,7 +616,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "\n");
}
- return TRUE;
+ return true;
}
if (vshCmddefSearch(name)) {
@@ -630,7 +625,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
return vshCmdGrpHelp(ctl, name);
} else {
vshError(ctl, _("command or command group '%s' doesn't exist"), name);
- return FALSE;
+ return false;
}
}
@@ -650,7 +645,7 @@ static const vshCmdOptDef opts_autostart[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAutostart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -658,10 +653,10 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -671,7 +666,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("Failed to unmark domain %s as autostarted"), name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (autostart)
@@ -680,7 +675,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Domain %s unmarked as autostarted\n"), name);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -700,17 +695,17 @@ static const vshCmdOptDef opts_connect[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdConnect(vshControl *ctl, const vshCmd *cmd)
{
- int ro = vshCommandOptBool(cmd, "readonly");
+ bool ro = vshCommandOptBool(cmd, "readonly");
const char *name = NULL;
if (ctl->conn) {
int ret;
if ((ret = virConnectClose(ctl->conn)) != 0) {
vshError(ctl, _("Failed to disconnect from the hypervisor, %d leaked reference(s)"), ret);
- return FALSE;
+ return false;
}
ctl->conn = NULL;
}
@@ -718,15 +713,11 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
VIR_FREE(ctl->name);
if (vshCommandOptString(cmd, "name", &name) < 0) {
vshError(ctl, "%s", _("Please specify valid connection URI"));
- return FALSE;
+ return false;
}
ctl->name = vshStrdup(ctl, name);
- if (!ro) {
- ctl->readonly = 0;
- } else {
- ctl->readonly = 1;
- }
+ ctl->readonly = ro;
ctl->conn = virConnectOpenAuth(ctl->name, virConnectAuthPtrDefault,
ctl->readonly ? VIR_CONNECT_RO : 0);
@@ -734,7 +725,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
if (!ctl->conn)
vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
- return ctl->conn ? TRUE : FALSE;
+ return !!ctl->conn;
}
#ifndef WIN32
@@ -755,10 +746,10 @@ static const vshCmdOptDef opts_console[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
{
- int ret = FALSE;
+ bool ret = false;
virDomainInfo dominfo;
if (virDomainGetInfo(dom, &dominfo) < 0) {
@@ -774,25 +765,25 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, const char *name)
vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
vshPrintExtra(ctl, "%s", _("Escape character is ^]\n"));
if (vshRunConsole(dom, name) == 0)
- ret = TRUE;
+ ret = true;
cleanup:
return ret;
}
-static int
+static bool
cmdConsole(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "devname", &name) < 0) {
vshError(ctl, "%s", _("Invalid devname"));
@@ -825,7 +816,7 @@ static const vshCmdOptDef opts_list[] = {
};
-static int
+static bool
cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -837,13 +828,13 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxid = virConnectNumOfDomains(ctl->conn);
if (maxid < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
- return FALSE;
+ return false;
}
if (maxid) {
ids = vshMalloc(ctl, sizeof(int) * maxid);
@@ -851,7 +842,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
VIR_FREE(ids);
- return FALSE;
+ return false;
}
qsort(&ids[0], maxid, sizeof(int), idsorter);
@@ -862,7 +853,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxname < 0) {
vshError(ctl, "%s", _("Failed to list inactive domains"));
VIR_FREE(ids);
- return FALSE;
+ return false;
}
if (maxname) {
names = vshMalloc(ctl, sizeof(char *) * maxname);
@@ -871,7 +862,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive domains"));
VIR_FREE(ids);
VIR_FREE(names);
- return FALSE;
+ return false;
}
qsort(&names[0], maxname, sizeof(char*), namesorter);
@@ -923,7 +914,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(ids);
VIR_FREE(names);
- return TRUE;
+ return true;
}
/*
@@ -940,24 +931,24 @@ static const vshCmdOptDef opts_domstate[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomstate(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainGetInfo(dom, &info) == 0)
vshPrint(ctl, "%s\n",
_(vshDomainStateToString(info.state)));
else
- ret = FALSE;
+ ret = false;
virDomainFree(dom);
return ret;
@@ -977,7 +968,7 @@ static const vshCmdOptDef opts_domblkstat[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -985,20 +976,20 @@ cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
struct _virDomainBlockStats stats;
if (!vshConnectionUsability (ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain (ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "device", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainBlockStats (dom, device, &stats, sizeof stats) == -1) {
vshError(ctl, _("Failed to get block stats %s %s"), name, device);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (stats.rd_req >= 0)
@@ -1017,7 +1008,7 @@ cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, "%s errs %lld\n", device, stats.errs);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/* "domifstat" command
@@ -1034,7 +1025,7 @@ static const vshCmdOptDef opts_domifstat[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -1042,20 +1033,20 @@ cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
struct _virDomainInterfaceStats stats;
if (!vshConnectionUsability (ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain (ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "interface", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainInterfaceStats (dom, device, &stats, sizeof stats) == -1) {
vshError(ctl, _("Failed to get interface stats %s %s"), name, device);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (stats.rx_bytes >= 0)
@@ -1083,7 +1074,7 @@ cmdDomIfstat (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, "%s tx_drop %lld\n", device, stats.tx_drop);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -1100,7 +1091,7 @@ static const vshCmdOptDef opts_dommemstat[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
@@ -1109,16 +1100,16 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
unsigned int nr_stats, i;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
nr_stats = virDomainMemoryStats (dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
if (nr_stats == -1) {
vshError(ctl, _("Failed to get memory statistics for domain %s"), name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
for (i = 0; i < nr_stats; i++) {
@@ -1137,7 +1128,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -1155,28 +1146,28 @@ static const vshCmdOptDef opts_domblkinfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainBlockInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *device = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString (cmd, "device", &device) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity);
@@ -1201,24 +1192,24 @@ static const vshCmdOptDef opts_suspend[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSuspend(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainSuspend(dom) == 0) {
vshPrint(ctl, _("Domain %s suspended\n"), name);
} else {
vshError(ctl, _("Failed to suspend domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1243,12 +1234,12 @@ static const vshCmdOptDef opts_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCreate(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
@@ -1256,13 +1247,13 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
if (vshCommandOptBool(cmd, "paused"))
flags |= VIR_DOMAIN_START_PAUSED;
@@ -1280,7 +1271,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
virDomainFree(dom);
} else {
vshError(ctl, _("Failed to create domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -1299,22 +1290,22 @@ static const vshCmdOptDef opts_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDefine(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
dom = virDomainDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -1325,7 +1316,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
virDomainFree(dom);
} else {
vshError(ctl, _("Failed to define domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -1344,19 +1335,19 @@ static const vshCmdOptDef opts_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdUndefine(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name = NULL;
int id;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "domain", &name) <= 0)
- return FALSE;
+ return false;
if (name && virStrToLong_i(name, NULL, 10, &id) == 0
&& id >= 0 && (dom = virDomainLookupByID(ctl->conn, id))) {
@@ -1366,17 +1357,17 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
" using its name or UUID"),
name);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (!(dom = vshCommandOptDomainBy(ctl, cmd, &name,
VSH_BYNAME|VSH_BYUUID)))
- return FALSE;
+ return false;
if (virDomainUndefine(dom) == 0) {
vshPrint(ctl, _("Domain %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1404,27 +1395,27 @@ static const vshCmdOptDef opts_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdStart(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
#ifndef WIN32
int console = vshCommandOptBool(cmd, "console");
#endif
unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME | VSH_BYUUID)))
- return FALSE;
+ return false;
if (virDomainGetID(dom) != (unsigned int)-1) {
vshError(ctl, "%s", _("Domain is already active"));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "paused"))
@@ -1441,7 +1432,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
#endif
} else {
vshError(ctl, _("Failed to start domain %s"), virDomainGetName(dom));
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
return ret;
@@ -1462,28 +1453,28 @@ static const vshCmdOptDef opts_save[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name = NULL;
const char *to = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainSave(dom, to) == 0) {
vshPrint(ctl, _("Domain %s saved to %s\n"), name, to);
} else {
vshError(ctl, _("Failed to save domain %s to %s"), name, to);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1507,24 +1498,24 @@ static const vshCmdOptDef opts_managedsave[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainManagedSave(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s state saved by libvirt\n"), name);
} else {
vshError(ctl, _("Failed to save domain %s state"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1545,19 +1536,19 @@ static const vshCmdOptDef opts_managedsaveremove[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name;
- int ret = FALSE;
+ bool ret = false;
int hassave;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
hassave = virDomainHasManagedSaveImage(dom, 0);
if (hassave < 0) {
@@ -1578,7 +1569,7 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Domain %s has no manage save image; removal skipped"),
name);
- ret = TRUE;
+ ret = true;
cleanup:
virDomainFree(dom);
@@ -1602,7 +1593,7 @@ static const vshCmdOptDef opts_schedinfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
virSchedParameterPtr param)
{
@@ -1696,7 +1687,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
}
-static int
+static bool
cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
{
char *schedulertype;
@@ -1705,13 +1696,13 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
int nparams = 0;
int update = 0;
int i, ret;
- int ret_val = FALSE;
+ int ret_val = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
/* Print SchedulerType */
schedulertype = virDomainGetSchedulerType(dom, &nparams);
@@ -1763,7 +1754,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
}
}
- ret_val = TRUE;
+ ret_val = true;
for (i = 0; i < nparams; i++){
switch (params[i].type) {
case VIR_DOMAIN_SCHED_FIELD_INT:
@@ -1810,23 +1801,23 @@ static const vshCmdOptDef opts_restore[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdRestore(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virDomainRestore(ctl->conn, from) == 0) {
vshPrint(ctl, _("Domain restored from %s\n"), from);
} else {
vshError(ctl, _("Failed to restore domain from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -1848,23 +1839,23 @@ static const vshCmdOptDef opts_dump[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDump(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *name = NULL;
const char *to = NULL;
- int ret = TRUE;
+ bool ret = true;
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (vshCommandOptBool (cmd, "live"))
flags |= VIR_DUMP_LIVE;
@@ -1875,7 +1866,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Domain %s dumped to %s\n"), name, to);
} else {
vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1896,24 +1887,24 @@ static const vshCmdOptDef opts_resume[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdResume(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainResume(dom) == 0) {
vshPrint(ctl, _("Domain %s resumed\n"), name);
} else {
vshError(ctl, _("Failed to resume domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1934,24 +1925,24 @@ static const vshCmdOptDef opts_shutdown[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdShutdown(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainShutdown(dom) == 0) {
vshPrint(ctl, _("Domain %s is being shutdown\n"), name);
} else {
vshError(ctl, _("Failed to shutdown domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -1972,24 +1963,24 @@ static const vshCmdOptDef opts_reboot[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdReboot(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainReboot(dom, 0) == 0) {
vshPrint(ctl, _("Domain %s is being rebooted\n"), name);
} else {
vshError(ctl, _("Failed to reboot domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -2010,24 +2001,24 @@ static const vshCmdOptDef opts_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDestroy(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virDomainDestroy(dom) == 0) {
vshPrint(ctl, _("Domain %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy domain %s"), name);
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -2048,7 +2039,7 @@ static const vshCmdOptDef opts_dominfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDominfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
@@ -2056,15 +2047,16 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virSecurityModel secmodel;
virSecurityLabelPtr seclabel;
int persistent = 0;
- int ret = TRUE, autostart;
+ bool ret = true;
+ int autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
id = virDomainGetID(dom);
if (id == ((unsigned int)-1))
@@ -2106,7 +2098,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
info.memory);
} else {
- ret = FALSE;
+ ret = false;
}
/* Check and display whether the domain is persistent or not */
@@ -2128,7 +2120,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
if (virNodeGetSecurityModel(ctl->conn, &secmodel) == -1) {
if (last_error->code != VIR_ERR_NO_SUPPORT) {
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
virFreeError(last_error);
last_error = NULL;
@@ -2142,13 +2134,13 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
/* Security labels are only valid for active domains */
if (VIR_ALLOC(seclabel) < 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
virDomainFree(dom);
VIR_FREE(seclabel);
- return FALSE;
+ return false;
} else {
if (seclabel->label[0] != '\0')
vshPrint(ctl, "%-15s %s (%s)\n", _("Security label:"),
@@ -2177,18 +2169,18 @@ static const vshCmdOptDef opts_domjobinfo[] = {
};
-static int
+static bool
cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainJobInfo info;
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainGetJobInfo(dom, &info) == 0) {
const char *unit;
@@ -2238,7 +2230,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-17s %-.3lf %s\n", _("File total:"), val, unit);
}
} else {
- ret = FALSE;
+ ret = false;
}
cleanup:
virDomainFree(dom);
@@ -2259,20 +2251,20 @@ static const vshCmdOptDef opts_domjobabort[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virDomainAbortJob(dom) < 0)
- ret = FALSE;
+ ret = false;
virDomainFree(dom);
return ret;
@@ -2293,10 +2285,10 @@ static const vshCmdOptDef opts_freecell[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdFreecell(vshControl *ctl, const vshCmd *cmd)
{
- int func_ret = FALSE;
+ int func_ret = false;
int ret;
int cell = -1, cell_given;
unsigned long long memory;
@@ -2312,7 +2304,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if ( (cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) {
vshError(ctl, "%s", _("cell number has to be a number"));
@@ -2399,7 +2391,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%d: %llu kB\n", cell, (memory/1024));
}
- func_ret = TRUE;
+ func_ret = true;
cleanup:
xmlXPathFreeContext(ctxt);
@@ -2426,7 +2418,7 @@ static const vshCmdOptDef opts_maxvcpus[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
{
const char *type = NULL;
@@ -2434,18 +2426,18 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptString(cmd, "type", &type) < 0) {
vshError(ctl, "%s", _("Invalid type"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
vcpus = virConnectGetMaxVcpus(ctl->conn, type);
if (vcpus < 0)
- return FALSE;
+ return false;
vshPrint(ctl, "%d\n", vcpus);
- return TRUE;
+ return true;
}
/*
@@ -2466,11 +2458,11 @@ static const vshCmdOptDef opts_vcpucount[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int current = vshCommandOptBool(cmd, "current");
int config = vshCommandOptBool(cmd, "config");
@@ -2481,12 +2473,12 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (maximum && current) {
vshError(ctl, "%s",
_("--maximum and --current cannot both be specified"));
- return FALSE;
+ return false;
}
if (config && live) {
vshError(ctl, "%s",
_("--config and --live cannot both be specified"));
- return FALSE;
+ return false;
}
/* We want one of each pair of mutually exclusive options; that
* is, use of flags requires exactly two options. */
@@ -2497,14 +2489,14 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
: config ? "config" : "live"),
maximum + current ? "config" : "maximum",
maximum + current ? "live" : "current");
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
/* In all cases, try the new API first; if it fails because we are
* talking to an older client, try a fallback API before giving
@@ -2528,7 +2520,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("maximum"), _("config"),
count);
@@ -2549,7 +2541,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("maximum"), _("live"),
count);
@@ -2586,7 +2578,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("current"), _("config"),
count);
@@ -2608,7 +2600,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
if (count < 0) {
virshReportError(ctl);
- ret = FALSE;
+ ret = false;
} else if (all) {
vshPrint(ctl, "%-12s %-12s %3d\n", _("current"), _("live"),
count);
@@ -2637,7 +2629,7 @@ static const vshCmdOptDef opts_vcpuinfo[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
@@ -2647,22 +2639,22 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
unsigned char *cpumap;
int ncpus;
size_t cpumaplen;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
cpuinfo = vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu);
@@ -2700,7 +2692,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s",
_("Domain shut off, virtual CPUs not present."));
}
- ret = FALSE;
+ ret = false;
}
VIR_FREE(cpumap);
@@ -2725,7 +2717,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
@@ -2733,44 +2725,44 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
virNodeInfo nodeinfo;
int vcpu;
const char *cpulist = NULL;
- int ret = TRUE;
+ bool ret = true;
unsigned char *cpumap;
int cpumaplen;
int i;
enum { expect_num, expect_num_or_comma } state;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "vcpu", &vcpu) <= 0) {
vshError(ctl, "%s", _("vcpupin: Invalid or missing vCPU number."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "cpulist", &cpulist) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
vshError(ctl, "%s", _("vcpupin: failed to get domain informations."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vcpu >= info.nrVirtCpu) {
vshError(ctl, "%s", _("vcpupin: Invalid vCPU number."));
virDomainFree(dom);
- return FALSE;
+ return false;
}
/* Check that the cpulist parameter is a comma-separated list of
@@ -2779,7 +2771,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
if (cpulist[0] == '\0') {
vshError(ctl, "%s", _("cpulist: Invalid format. Empty string."));
virDomainFree (dom);
- return FALSE;
+ return false;
}
state = expect_num;
@@ -2791,7 +2783,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
"digit at position %d (near '%c')."),
cpulist, i, cpulist[i]);
virDomainFree (dom);
- return FALSE;
+ return false;
}
state = expect_num_or_comma;
break;
@@ -2803,7 +2795,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
"digit or comma at position %d (near '%c')."),
cpulist, i, cpulist[i]);
virDomainFree (dom);
- return FALSE;
+ return false;
}
}
}
@@ -2812,7 +2804,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
"at position %d."),
cpulist, i);
virDomainFree (dom);
- return FALSE;
+ return false;
}
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
@@ -2827,7 +2819,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
VIR_FREE(cpumap);
virDomainFree(dom);
- return FALSE;
+ return false;
}
cpulist = strchr(cpulist, ',');
if (cpulist)
@@ -2835,7 +2827,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
} while (cpulist);
if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
- ret = FALSE;
+ ret = false;
}
VIR_FREE(cpumap);
@@ -2861,12 +2853,12 @@ static const vshCmdOptDef opts_setvcpus[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int count;
- int ret = TRUE;
+ bool ret = true;
int maximum = vshCommandOptBool(cmd, "maximum");
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
@@ -2875,10 +2867,10 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
(live ? VIR_DOMAIN_VCPU_LIVE : 0));
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "count", &count) < 0) {
vshError(ctl, "%s", _("Invalid number of virtual CPUs"));
@@ -2887,7 +2879,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
if (!flags) {
if (virDomainSetVcpus(dom, count) != 0) {
- ret = FALSE;
+ ret = false;
}
} else {
/* If the --maximum flag was given, we need to ensure only the
@@ -2903,14 +2895,14 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
/* Warn the user about the invalid flag combination */
vshError(ctl, _("--maximum must be used with --config only"));
- ret = FALSE;
+ ret = false;
goto cleanup;
}
}
/* Apply the virtual cpu changes */
if (virDomainSetVcpusFlags(dom, count, flags) < 0) {
- ret = FALSE;
+ ret = false;
}
}
@@ -2937,13 +2929,13 @@ static const vshCmdOptDef opts_setmem[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetmem(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainInfo info;
unsigned long kilobytes = 0;
- int ret = TRUE;
+ bool ret = true;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
@@ -2952,7 +2944,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
- return FALSE;
+ return false;
}
flags = VIR_DOMAIN_MEM_CURRENT;
} else {
@@ -2966,42 +2958,42 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptUL(cmd, "kilobytes", &kilobytes) < 0) {
vshError(ctl, "%s", _("memory size has to be a number"));
- return FALSE;
+ return false;
}
if (kilobytes <= 0) {
virDomainFree(dom);
vshError(ctl, _("Invalid value of %lu for memory size"), kilobytes);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, "%s", _("Unable to verify MaxMemorySize"));
- return FALSE;
+ return false;
}
if (kilobytes > info.maxMem) {
virDomainFree(dom);
vshError(ctl, _("Requested memory size %lu kb is larger than maximum of %lu kb"),
kilobytes, info.maxMem);
- return FALSE;
+ return false;
}
if (flags == -1) {
if (virDomainSetMemory(dom, kilobytes) != 0) {
- ret = FALSE;
+ ret = false;
}
} else {
if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
- ret = FALSE;
+ ret = false;
}
}
@@ -3027,13 +3019,13 @@ static const vshCmdOptDef opts_setmaxmem[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
virDomainInfo info;
int kilobytes = 0;
- int ret = TRUE;
+ bool ret = true;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
@@ -3042,7 +3034,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
- return FALSE;
+ return false;
}
} else {
if (config)
@@ -3055,37 +3047,37 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "kilobytes", &kilobytes) < 0) {
vshError(ctl, "%s", _("memory size has to be a number"));
- return FALSE;
+ return false;
}
if (kilobytes <= 0) {
virDomainFree(dom);
vshError(ctl, _("Invalid value of %d for memory size"), kilobytes);
- return FALSE;
+ return false;
}
if (virDomainGetInfo(dom, &info) != 0) {
virDomainFree(dom);
vshError(ctl, "%s", _("Unable to verify current MemorySize"));
- return FALSE;
+ return false;
}
if (flags == -1) {
if (virDomainSetMaxMemory(dom, kilobytes) != 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
+ ret = false;
}
} else {
if (virDomainSetMemoryFlags(dom, kilobytes, flags) < 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
- ret = FALSE;
+ ret = false;
}
}
@@ -3112,7 +3104,7 @@ static const vshCmdOptDef opts_blkiotune[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
@@ -3120,13 +3112,13 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
int nparams = 0;
unsigned int i = 0;
virBlkioParameterPtr params = NULL, temp = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptInt(cmd, "weight", &weight) < 0) {
vshError(ctl, "%s",
@@ -3153,7 +3145,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
if (nparams == 0) {
/* nothing to output */
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -3195,7 +3187,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
}
}
- ret = TRUE;
+ ret = true;
} else {
/* set the blkio parameters */
params = vshCalloc(ctl, nparams, sizeof(*params));
@@ -3214,7 +3206,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
if (virDomainSetBlkioParameters(dom, params, nparams, 0) != 0)
vshError(ctl, "%s", _("Unable to change blkio parameters"));
else
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -3248,7 +3240,7 @@ static const vshCmdOptDef opts_memtune[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMemtune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
@@ -3257,13 +3249,13 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
int nparams = 0;
unsigned int i = 0;
virMemoryParameterPtr params = NULL, temp = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptLongLong(cmd, "hard-limit", &hard_limit) < 0 ||
vshCommandOptLongLong(cmd, "soft-limit", &soft_limit) < 0 ||
@@ -3296,7 +3288,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
if (nparams == 0) {
/* nothing to output */
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -3341,7 +3333,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
}
}
- ret = TRUE;
+ ret = true;
} else {
/* set the memory parameters */
params = vshCalloc(ctl, nparams, sizeof(*params));
@@ -3385,7 +3377,7 @@ cmdMemtune(vshControl * ctl, const vshCmd * cmd)
if (virDomainSetMemoryParameters(dom, params, nparams, 0) != 0)
vshError(ctl, "%s", _("Unable to change memory parameters"));
else
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -3403,17 +3395,17 @@ static const vshCmdInfo info_nodeinfo[] = {
{NULL, NULL}
};
-static int
+static bool
cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virNodeInfo info;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (virNodeGetInfo(ctl->conn, &info) < 0) {
vshError(ctl, "%s", _("failed to get node information"));
- return FALSE;
+ return false;
}
vshPrint(ctl, "%-20s %s\n", _("CPU model:"), info.model);
vshPrint(ctl, "%-20s %d\n", _("CPU(s):"), info.cpus);
@@ -3424,7 +3416,7 @@ cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, "%-20s %d\n", _("NUMA cell(s):"), info.nodes);
vshPrint(ctl, "%-20s %lu kB\n", _("Memory size:"), info.memory);
- return TRUE;
+ return true;
}
/*
@@ -3436,22 +3428,22 @@ static const vshCmdInfo info_capabilities[] = {
{NULL, NULL}
};
-static int
+static bool
cmdCapabilities (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *caps;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if ((caps = virConnectGetCapabilities (ctl->conn)) == NULL) {
vshError(ctl, "%s", _("failed to get capabilities"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", caps);
VIR_FREE(caps);
- return TRUE;
+ return true;
}
/*
@@ -3471,11 +3463,11 @@ static const vshCmdOptDef opts_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int ret = TRUE;
+ bool ret = true;
char *dump;
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -3490,17 +3482,17 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_XML_UPDATE_CPU;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virDomainGetXMLDesc(dom, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virDomainFree(dom);
@@ -3522,10 +3514,10 @@ static const vshCmdOptDef opts_domxmlfromnative[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
const char *format = NULL;
const char *configFile = NULL;
char *configData;
@@ -3533,21 +3525,21 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "format", &format) < 0 ||
vshCommandOptString(cmd, "config", &configFile) < 0)
- return FALSE;
+ return false;
if (virFileReadAll(configFile, 1024*1024, &configData) < 0)
- return FALSE;
+ return false;
xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
if (xmlData != NULL) {
vshPrint(ctl, "%s", xmlData);
VIR_FREE(xmlData);
} else {
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -3568,10 +3560,10 @@ static const vshCmdOptDef opts_domxmltonative[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
const char *format = NULL;
const char *xmlFile = NULL;
char *configData;
@@ -3579,21 +3571,21 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "format", &format) < 0
|| vshCommandOptString(cmd, "xml", &xmlFile) < 0)
- return FALSE;
+ return false;
if (virFileReadAll(xmlFile, 1024*1024, &xmlData) < 0)
- return FALSE;
+ return false;
configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
if (configData != NULL) {
vshPrint(ctl, "%s", configData);
VIR_FREE(configData);
} else {
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -3613,20 +3605,20 @@ static const vshCmdOptDef opts_domname[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomname(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYID|VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virDomainGetName(dom));
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -3643,17 +3635,17 @@ static const vshCmdOptDef opts_domid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomid(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
unsigned int id;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYUUID)))
- return FALSE;
+ return false;
id = virDomainGetID(dom);
if (id == ((unsigned int)-1))
@@ -3661,7 +3653,7 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd)
else
vshPrint(ctl, "%d\n", id);
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -3678,17 +3670,17 @@ static const vshCmdOptDef opts_domuuid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYID)))
- return FALSE;
+ return false;
if (virDomainGetUUIDString(dom, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
@@ -3696,7 +3688,7 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("failed to get domain UUID"));
virDomainFree(dom);
- return TRUE;
+ return true;
}
/*
@@ -3849,7 +3841,7 @@ print_job_progress(unsigned long long remaining, unsigned long long total)
fprintf(stderr, "\rMigration: [%3d %%]", progress);
}
-static int
+static bool
cmdMigrate (vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
@@ -3874,13 +3866,13 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd)
#endif
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptBool (cmd, "verbose"))
verbose = true;
if (vshCommandOptBool (cmd, "live"))
- live_flag = TRUE;
+ live_flag = true;
if (vshCommandOptInt(cmd, "timeout", &timeout) > 0) {
if (! live_flag) {
vshError(ctl, "%s", _("migrate: Unexpected timeout for offline migration"));
@@ -3929,15 +3921,15 @@ repoll:
if (ret > 0) {
if (saferead(p[0], &retchar, sizeof(retchar)) > 0) {
if (retchar == '0') {
- ret = TRUE;
+ ret = true;
if (verbose) {
/* print [100 %] */
print_job_progress(0, 1);
}
} else
- ret = FALSE;
+ ret = false;
} else
- ret = FALSE;
+ ret = false;
break;
}
@@ -3945,7 +3937,7 @@ repoll:
if (errno == EINTR) {
if (intCaught) {
virDomainAbortJob(dom);
- ret = FALSE;
+ ret = false;
intCaught = 0;
} else
goto repoll;
@@ -4001,18 +3993,18 @@ static const vshCmdOptDef opts_migrate_setmaxdowntime[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
long long downtime = 0;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptLongLong(cmd, "downtime", &downtime) < 0 ||
downtime < 1) {
@@ -4023,7 +4015,7 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
if (virDomainMigrateSetMaxDowntime(dom, downtime, 0))
goto done;
- ret = TRUE;
+ ret = true;
done:
virDomainFree(dom);
@@ -4046,7 +4038,7 @@ static const vshCmdOptDef opts_network_autostart[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
@@ -4054,10 +4046,10 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -4067,7 +4059,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("failed to unmark network %s as autostarted"), name);
virNetworkFree(network);
- return FALSE;
+ return false;
}
if (autostart)
@@ -4076,7 +4068,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Network %s unmarked as autostarted\n"), name);
virNetworkFree(network);
- return TRUE;
+ return true;
}
/*
@@ -4093,22 +4085,22 @@ static const vshCmdOptDef opts_network_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
network = virNetworkCreateXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -4119,7 +4111,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
virNetworkFree(network);
} else {
vshError(ctl, _("Failed to create network from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -4139,22 +4131,22 @@ static const vshCmdOptDef opts_network_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
network = virNetworkDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -4165,7 +4157,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
virNetworkFree(network);
} else {
vshError(ctl, _("Failed to define network from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -4185,24 +4177,24 @@ static const vshCmdOptDef opts_network_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNetworkDestroy(network) == 0) {
vshPrint(ctl, _("Network %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy network %s"), name);
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
@@ -4224,25 +4216,25 @@ static const vshCmdOptDef opts_network_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virNetworkGetXMLDesc(network, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
@@ -4263,7 +4255,7 @@ static const vshCmdOptDef opts_network_info[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
@@ -4274,11 +4266,11 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
char *bridge = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name"), virNetworkGetName(network));
@@ -4305,7 +4297,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %s\n", _("Bridge:"), bridge);
virNetworkFree(network);
- return TRUE;
+ return true;
}
/*
@@ -4322,10 +4314,10 @@ static const vshCmdOptDef opts_interface_edit[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virInterfacePtr iface = NULL;
char *tmp = NULL;
char *doc = NULL;
@@ -4360,7 +4352,7 @@ cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Interface %s XML configuration not changed.\n"),
virInterfaceGetName (iface));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -4387,7 +4379,7 @@ cmdInterfaceEdit (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, _("Interface %s XML configuration edited.\n"),
virInterfaceGetName(iface));
- ret = TRUE;
+ ret = true;
cleanup:
if (iface)
@@ -4420,7 +4412,7 @@ static const vshCmdOptDef opts_network_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -4431,13 +4423,13 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxactive = virConnectNumOfNetworks(ctl->conn);
if (maxactive < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
- return FALSE;
+ return false;
}
if (maxactive) {
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
@@ -4446,7 +4438,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
@@ -4457,7 +4449,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive networks"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
if (maxinactive) {
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
@@ -4468,7 +4460,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive networks"));
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return FALSE;
+ return false;
}
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter);
@@ -4528,7 +4520,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return TRUE;
+ return true;
}
@@ -4546,20 +4538,20 @@ static const vshCmdOptDef opts_network_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virNetworkGetName(network));
virNetworkFree(network);
- return TRUE;
+ return true;
}
@@ -4577,17 +4569,17 @@ static const vshCmdOptDef opts_network_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, VSH_BYNAME)))
- return FALSE;
+ return false;
if (virNetworkCreate(network) == 0) {
vshPrint(ctl, _("Network %s started\n"),
@@ -4595,7 +4587,7 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
} else {
vshError(ctl, _("Failed to start network %s"),
virNetworkGetName(network));
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
return ret;
@@ -4616,24 +4608,24 @@ static const vshCmdOptDef opts_network_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNetworkUndefine(network) == 0) {
vshPrint(ctl, _("Network %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine network %s"), name);
- ret = FALSE;
+ ret = false;
}
virNetworkFree(network);
@@ -4655,18 +4647,18 @@ static const vshCmdOptDef opts_network_uuid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
{
virNetworkPtr network;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (virNetworkGetUUIDString(network, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
@@ -4674,7 +4666,7 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("failed to get network UUID"));
virNetworkFree(network);
- return TRUE;
+ return true;
}
@@ -4693,7 +4685,7 @@ static const vshCmdOptDef opts_interface_list[] = {
{"all", VSH_OT_BOOL, 0, N_("list inactive & active interfaces")},
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -4704,13 +4696,13 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (active) {
maxactive = virConnectNumOfInterfaces(ctl->conn);
if (maxactive < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
- return FALSE;
+ return false;
}
if (maxactive) {
activeNames = vshMalloc(ctl, sizeof(char *) * maxactive);
@@ -4719,7 +4711,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
qsort(&activeNames[0], maxactive, sizeof(char *), namesorter);
@@ -4730,7 +4722,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
VIR_FREE(activeNames);
- return FALSE;
+ return false;
}
if (maxinactive) {
inactiveNames = vshMalloc(ctl, sizeof(char *) * maxinactive);
@@ -4741,7 +4733,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return FALSE;
+ return false;
}
qsort(&inactiveNames[0], maxinactive, sizeof(char*), namesorter);
@@ -4787,7 +4779,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(activeNames);
VIR_FREE(inactiveNames);
- return TRUE;
+ return true;
}
@@ -4805,20 +4797,20 @@ static const vshCmdOptDef opts_interface_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceName(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL,
VSH_BYMAC)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virInterfaceGetName(iface));
virInterfaceFree(iface);
- return TRUE;
+ return true;
}
/*
@@ -4835,20 +4827,20 @@ static const vshCmdOptDef opts_interface_mac[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virInterfaceGetMACString(iface));
virInterfaceFree(iface);
- return TRUE;
+ return true;
}
/*
@@ -4866,11 +4858,11 @@ static const vshCmdOptDef opts_interface_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
char *dump;
int flags = 0;
int inactive = vshCommandOptBool(cmd, "inactive");
@@ -4879,17 +4871,17 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -4910,22 +4902,22 @@ static const vshCmdOptDef opts_interface_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
iface = virInterfaceDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -4936,7 +4928,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
virInterfaceFree (iface);
} else {
vshError(ctl, _("Failed to define interface from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -4955,24 +4947,24 @@ static const vshCmdOptDef opts_interface_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceUndefine(iface) == 0) {
vshPrint(ctl, _("Interface %s undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -4993,24 +4985,24 @@ static const vshCmdOptDef opts_interface_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceCreate(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s started\n"), name);
} else {
vshError(ctl, _("Failed to start interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -5031,24 +5023,24 @@ static const vshCmdOptDef opts_interface_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
{
virInterfacePtr iface;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virInterfaceDestroy(iface, 0) == 0) {
vshPrint(ctl, _("Interface %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy interface %s"), name);
- ret = FALSE;
+ ret = false;
}
virInterfaceFree(iface);
@@ -5070,22 +5062,22 @@ static const vshCmdOptDef opts_nwfilter_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
nwfilter = virNWFilterDefineXML(ctl->conn, buffer);
VIR_FREE(buffer);
@@ -5096,7 +5088,7 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
virNWFilterFree(nwfilter);
} else {
vshError(ctl, _("Failed to define network filter from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -5116,24 +5108,24 @@ static const vshCmdOptDef opts_nwfilter_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name)))
- return FALSE;
+ return false;
if (virNWFilterUndefine(nwfilter) == 0) {
vshPrint(ctl, _("Network filter %s undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine network filter %s"), name);
- ret = FALSE;
+ ret = false;
}
virNWFilterFree(nwfilter);
@@ -5155,25 +5147,25 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterPtr nwfilter;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL)))
- return FALSE;
+ return false;
dump = virNWFilterGetXMLDesc(nwfilter, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virNWFilterFree(nwfilter);
@@ -5193,7 +5185,7 @@ static const vshCmdOptDef opts_nwfilter_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int numfilters, i;
@@ -5201,12 +5193,12 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
numfilters = virConnectNumOfNWFilters(ctl->conn);
if (numfilters < 0) {
vshError(ctl, "%s", _("Failed to list network filters"));
- return FALSE;
+ return false;
}
names = vshMalloc(ctl, sizeof(char *) * numfilters);
@@ -5215,7 +5207,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
numfilters)) < 0) {
vshError(ctl, "%s", _("Failed to list network filters"));
VIR_FREE(names);
- return FALSE;
+ return false;
}
qsort(&names[0], numfilters, sizeof(char *), namesorter);
@@ -5243,7 +5235,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
VIR_FREE(names);
- return TRUE;
+ return true;
}
@@ -5261,10 +5253,10 @@ static const vshCmdOptDef opts_nwfilter_edit[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virNWFilterPtr nwfilter = NULL;
char *tmp = NULL;
char *doc = NULL;
@@ -5298,7 +5290,7 @@ cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Network filter %s XML configuration not changed.\n"),
virNWFilterGetName (nwfilter));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -5325,7 +5317,7 @@ cmdNWFilterEdit (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, _("Network filter %s XML configuration edited.\n"),
virNWFilterGetName(nwfilter));
- ret = TRUE;
+ ret = true;
cleanup:
if (nwfilter)
@@ -5361,7 +5353,7 @@ static const vshCmdOptDef opts_pool_autostart[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -5369,10 +5361,10 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -5382,7 +5374,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshError(ctl, _("failed to unmark pool %s as autostarted"), name);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
if (autostart)
@@ -5391,7 +5383,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Pool %s unmarked as autostarted\n"), name);
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
/*
@@ -5409,22 +5401,22 @@ static const vshCmdOptDef opts_pool_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
pool = virStoragePoolCreateXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -5435,7 +5427,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to create pool from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -5459,22 +5451,22 @@ static const vshCmdOptDef opts_node_device_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr dev = NULL;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -5485,7 +5477,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
virNodeDeviceFree(dev);
} else {
vshError(ctl, _("Failed to create node device from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -5508,19 +5500,19 @@ static const vshCmdOptDef opts_node_device_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
{
virNodeDevicePtr dev = NULL;
- int ret = TRUE;
+ bool ret = true;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn)) {
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "name", &name) <= 0)
- return FALSE;
+ return false;
dev = virNodeDeviceLookupByName(ctl->conn, name);
@@ -5528,7 +5520,7 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _("Destroyed node device '%s'\n"), name);
} else {
vshError(ctl, _("Failed to destroy node device '%s'"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(dev);
@@ -5600,16 +5592,16 @@ static int buildPoolXML(const vshCmd *cmd, const char **retname, char **xml) {
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
*xml = virBufferContentAndReset(&buf);
*retname = name;
- return TRUE;
+ return true;
cleanup:
virBufferFreeAndReset(&buf);
- return FALSE;
+ return false;
}
/*
@@ -5621,7 +5613,7 @@ static const vshCmdInfo info_pool_create_as[] = {
{NULL, NULL}
};
-static int
+static bool
cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -5630,10 +5622,10 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
int printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!buildPoolXML(cmd, &name, &xml))
- return FALSE;
+ return false;
if (printXML) {
vshPrint(ctl, "%s", xml);
@@ -5647,10 +5639,10 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to create pool %s"), name);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
@@ -5668,22 +5660,22 @@ static const vshCmdOptDef opts_pool_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
pool = virStoragePoolDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -5694,7 +5686,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to define pool from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -5709,7 +5701,7 @@ static const vshCmdInfo info_pool_define_as[] = {
{NULL, NULL}
};
-static int
+static bool
cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -5718,10 +5710,10 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
int printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!buildPoolXML(cmd, &name, &xml))
- return FALSE;
+ return false;
if (printXML) {
vshPrint(ctl, "%s", xml);
@@ -5735,10 +5727,10 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
virStoragePoolFree(pool);
} else {
vshError(ctl, _("Failed to define pool %s"), name);
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
@@ -5756,24 +5748,24 @@ static const vshCmdOptDef opts_pool_build[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolBuild(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s built\n"), name);
} else {
vshError(ctl, _("Failed to build pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5796,24 +5788,24 @@ static const vshCmdOptDef opts_pool_destroy[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolDestroy(pool) == 0) {
vshPrint(ctl, _("Pool %s destroyed\n"), name);
} else {
vshError(ctl, _("Failed to destroy pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5835,24 +5827,24 @@ static const vshCmdOptDef opts_pool_delete[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDelete(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolDelete(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s deleted\n"), name);
} else {
vshError(ctl, _("Failed to delete pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5874,24 +5866,24 @@ static const vshCmdOptDef opts_pool_refresh[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolRefresh(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s refreshed\n"), name);
} else {
vshError(ctl, _("Failed to refresh pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5913,25 +5905,25 @@ static const vshCmdOptDef opts_pool_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
dump = virStoragePoolGetXMLDesc(pool, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -5955,7 +5947,7 @@ static const vshCmdOptDef opts_pool_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStoragePoolInfo info;
@@ -5985,14 +5977,14 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Retrieve the number of active storage pools */
if (active) {
numActivePools = virConnectNumOfStoragePools(ctl->conn);
if (numActivePools < 0) {
vshError(ctl, "%s", _("Failed to list active pools"));
- return FALSE;
+ return false;
}
}
@@ -6001,7 +5993,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
numInactivePools = virConnectNumOfDefinedStoragePools(ctl->conn);
if (numInactivePools < 0) {
vshError(ctl, "%s", _("Failed to list inactive pools"));
- return FALSE;
+ return false;
}
}
@@ -6020,7 +6012,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list active pools"));
VIR_FREE(poolInfoTexts);
VIR_FREE(poolNames);
- return FALSE;
+ return false;
}
}
@@ -6032,7 +6024,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list inactive pools"));
VIR_FREE(poolInfoTexts);
VIR_FREE(poolNames);
- return FALSE;
+ return false;
}
}
@@ -6210,7 +6202,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
}
@@ -6308,7 +6300,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
asprintf_failure:
@@ -6323,7 +6315,7 @@ asprintf_failure:
/* Some other error */
vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
- functionReturn = FALSE;
+ functionReturn = false;
cleanup:
@@ -6365,7 +6357,7 @@ static const vshCmdOptDef opts_find_storage_pool_sources_as[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
const char *type = NULL, *host = NULL;
@@ -6377,11 +6369,11 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
vshCommandOptString(cmd, "host", &host) < 0 ||
vshCommandOptString(cmd, "initiator", &initiator) < 0) {
vshError(ctl,"%s", _("missing argument"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (host) {
const char *port = NULL;
@@ -6390,7 +6382,7 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
if (vshCommandOptString(cmd, "port", &port) < 0) {
vshError(ctl, "%s", _("missing argument"));
virBufferFreeAndReset(&buf);
- return FALSE;
+ return false;
}
virBufferAddLit(&buf, "<source>\n");
virBufferVSprintf(&buf, " <host name='%s'", host);
@@ -6405,7 +6397,7 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
virBufferAddLit(&buf, "</source>\n");
if (virBufferError(&buf)) {
vshError(ctl, "%s", _("Out of memory"));
- return FALSE;
+ return false;
}
srcSpec = virBufferContentAndReset(&buf);
}
@@ -6414,12 +6406,12 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s", srcList);
VIR_FREE(srcList);
- return TRUE;
+ return true;
}
@@ -6440,36 +6432,36 @@ static const vshCmdOptDef opts_find_storage_pool_sources[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
{
const char *type = NULL, *srcSpecFile = NULL;
char *srcSpec = NULL, *srcList;
if (vshCommandOptString(cmd, "type", &type) <= 0)
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "srcSpec", &srcSpecFile) < 0) {
vshError(ctl, "%s", _("missing option"));
- return FALSE;
+ return false;
}
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (srcSpecFile && virFileReadAll(srcSpecFile, VIRSH_MAX_XML_FILE, &srcSpec) < 0)
- return FALSE;
+ return false;
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s", srcList);
VIR_FREE(srcList);
- return TRUE;
+ return true;
}
@@ -6487,21 +6479,21 @@ static const vshCmdOptDef opts_pool_info[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
int autostart = 0;
int persistent = 0;
- int ret = TRUE;
+ bool ret = true;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name:"), virStoragePoolGetName(pool));
@@ -6562,7 +6554,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit);
}
} else {
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -6584,20 +6576,20 @@ static const vshCmdOptDef opts_pool_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolName(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
@@ -6615,24 +6607,24 @@ static const vshCmdOptDef opts_pool_start[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolStart(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME)))
- return FALSE;
+ return false;
if (virStoragePoolCreate(pool, 0) == 0) {
vshPrint(ctl, _("Pool %s started\n"),
virStoragePoolGetName(pool));
} else {
vshError(ctl, _("Failed to start pool %s"), virStoragePoolGetName(pool));
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -6688,7 +6680,7 @@ static int cmdVolSize(const char *data, unsigned long long *val)
return 0;
}
-static int
+static bool
cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -6700,11 +6692,11 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "name", &name) <= 0)
goto cleanup;
@@ -6771,13 +6763,13 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
}
if (snapVol == NULL) {
vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
- return FALSE;
+ return false;
}
char *snapshotStrVolPath;
if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
virStorageVolFree(snapVol);
- return FALSE;
+ return false;
}
/* Create XML for the backing store */
@@ -6796,7 +6788,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
vol = virStorageVolCreateXML(pool, xml, 0);
@@ -6806,16 +6798,16 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vol != NULL) {
vshPrint(ctl, _("Vol %s created\n"), name);
virStorageVolFree(vol);
- return TRUE;
+ return true;
} else {
vshError(ctl, _("Failed to create vol %s"), name);
- return FALSE;
+ return false;
}
cleanup:
virBufferFreeAndReset(&buf);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
@@ -6833,24 +6825,24 @@ static const vshCmdOptDef opts_pool_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
- return FALSE;
+ return false;
if (virStoragePoolUndefine(pool) == 0) {
vshPrint(ctl, _("Pool %s has been undefined\n"), name);
} else {
vshError(ctl, _("Failed to undefine pool %s"), name);
- ret = FALSE;
+ ret = false;
}
virStoragePoolFree(pool);
@@ -6872,18 +6864,18 @@ static const vshCmdOptDef opts_pool_uuid[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (virStoragePoolGetUUIDString(pool, uuid) != -1)
vshPrint(ctl, "%s\n", uuid);
@@ -6891,7 +6883,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("failed to get pool UUID"));
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
@@ -6910,31 +6902,31 @@ static const vshCmdOptDef opts_vol_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
vol = virStorageVolCreateXML(pool, buffer, 0);
@@ -6947,7 +6939,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
virStorageVolFree(vol);
} else {
vshError(ctl, _("Failed to create vol from %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
}
@@ -6969,13 +6961,13 @@ static const vshCmdOptDef opts_vol_create_from[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool = NULL;
virStorageVolPtr newvol = NULL, inputvol = NULL;
const char *from = NULL;
- int ret = FALSE;
+ bool ret = false;
char *buffer = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -7006,7 +6998,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(buffer);
if (pool)
@@ -7066,7 +7058,7 @@ static const vshCmdOptDef opts_vol_clone[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolClone(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr origpool = NULL;
@@ -7074,7 +7066,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
const char *name = NULL;
char *origxml = NULL;
xmlChar *newxml = NULL;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -7112,7 +7104,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(origxml);
@@ -7154,12 +7146,12 @@ cmdVolUploadSource(virStreamPtr st ATTRIBUTE_UNUSED,
return saferead(*fd, bytes, nbytes);
}
-static int
+static bool
cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
virStorageVolPtr vol = NULL;
- int ret = FALSE;
+ bool ret = false;
int fd = -1;
virStreamPtr st = NULL;
const char *name = NULL;
@@ -7170,16 +7162,16 @@ cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (vshCommandOptULongLong(cmd, "length", &length) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "file", &file) < 0) {
@@ -7214,7 +7206,7 @@ cmdVolUpload (vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
if (vol)
@@ -7255,12 +7247,12 @@ cmdVolDownloadSink(virStreamPtr st ATTRIBUTE_UNUSED,
return safewrite(*fd, bytes, nbytes);
}
-static int
+static bool
cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
virStorageVolPtr vol = NULL;
- int ret = FALSE;
+ bool ret = false;
int fd = -1;
virStreamPtr st = NULL;
const char *name = NULL;
@@ -7272,16 +7264,16 @@ cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (vshCommandOptULongLong(cmd, "length", &length) < 0) {
vshError(ctl, _("Unable to parse integer"));
- return FALSE;
+ return false;
}
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &file) < 0) {
vshError(ctl, _("file must not be empty"));
@@ -7319,10 +7311,10 @@ cmdVolDownload (vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- ret = TRUE;
+ ret = true;
cleanup:
- if (ret == FALSE && created)
+ if (ret == false && created)
unlink(file);
if (vol)
virStorageVolFree(vol);
@@ -7348,25 +7340,25 @@ static const vshCmdOptDef opts_vol_delete[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (virStorageVolDelete(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s deleted\n"), name);
} else {
vshError(ctl, _("Failed to delete vol %s"), name);
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7389,25 +7381,25 @@ static const vshCmdOptDef opts_vol_wipe[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
if (virStorageVolWipe(vol, 0) == 0) {
vshPrint(ctl, _("Vol %s wiped\n"), name);
} else {
vshError(ctl, _("Failed to wipe vol %s"), name);
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7430,18 +7422,18 @@ static const vshCmdOptDef opts_vol_info[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolInfo info;
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%-15s %s\n", _("Name:"), virStorageVolGetName(vol));
@@ -7458,7 +7450,7 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
val = prettyCapacity(info.allocation, &unit);
vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
} else {
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7481,25 +7473,25 @@ static const vshCmdOptDef opts_vol_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
- int ret = TRUE;
+ bool ret = true;
char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
dump = virStorageVolGetXMLDesc(vol, 0);
if (dump != NULL) {
vshPrint(ctl, "%s", dump);
VIR_FREE(dump);
} else {
- ret = FALSE;
+ ret = false;
}
virStorageVolFree(vol);
@@ -7522,7 +7514,7 @@ static const vshCmdOptDef opts_vol_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStorageVolInfo volumeInfo;
@@ -7548,11 +7540,11 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Look up the pool information given to us by the user */
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
- return FALSE;
+ return false;
/* Determine the number of volumes in the pool */
numVolumes = virStoragePoolNumOfVolumes(pool);
@@ -7560,7 +7552,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (numVolumes < 0) {
vshError(ctl, "%s", _("Failed to list storage volumes"));
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
/* Retrieve the list of volume names in the pool */
@@ -7571,7 +7563,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshError(ctl, "%s", _("Failed to list active vols"));
VIR_FREE(activeNames);
virStoragePoolFree(pool);
- return FALSE;
+ return false;
}
/* Sort the volume names */
@@ -7679,7 +7671,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
}
@@ -7750,7 +7742,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/* Cleanup and return */
- functionReturn = TRUE;
+ functionReturn = true;
goto cleanup;
asprintf_failure:
@@ -7765,7 +7757,7 @@ asprintf_failure:
/* Some other error */
vshError(ctl, _("virAsprintf failed (errno %d)"), errno);
}
- functionReturn = FALSE;
+ functionReturn = false;
cleanup:
@@ -7804,21 +7796,21 @@ static const vshCmdOptDef opts_vol_name[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolName(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStorageVolGetName(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
@@ -7837,7 +7829,7 @@ static const vshCmdOptDef opts_vol_pool[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolPool(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolPtr pool;
@@ -7846,12 +7838,12 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
/* Use the supplied string to locate the volume */
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
VSH_BYUUID))) {
- return FALSE;
+ return false;
}
/* Look up the parent storage pool for the volume */
@@ -7859,7 +7851,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
if (pool == NULL) {
vshError(ctl, "%s", _("failed to get parent pool"));
virStorageVolFree(vol);
- return FALSE;
+ return false;
}
/* Return the requested details of the parent storage pool */
@@ -7875,7 +7867,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
/* Cleanup */
virStorageVolFree(vol);
virStoragePoolFree(pool);
- return TRUE;
+ return true;
}
@@ -7894,20 +7886,20 @@ static const vshCmdOptDef opts_vol_key[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolKey(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
- return FALSE;
+ return false;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
@@ -7927,22 +7919,22 @@ static const vshCmdOptDef opts_vol_path[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVolPath(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s\n", virStorageVolGetPath(vol));
virStorageVolFree(vol);
- return TRUE;
+ return true;
}
@@ -7960,7 +7952,7 @@ static const vshCmdOptDef opts_secret_define[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
@@ -7969,29 +7961,29 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
res = virSecretDefineXML(ctl->conn, buffer, 0);
VIR_FREE(buffer);
if (res == NULL) {
vshError(ctl, _("Failed to set attributes from %s"), from);
- return FALSE;
+ return false;
}
if (virSecretGetUUIDString(res, &(uuid[0])) < 0) {
vshError(ctl, "%s", _("Failed to get UUID of created secret"));
virSecretFree(res);
- return FALSE;
+ return false;
}
vshPrint(ctl, _("Secret %s created\n"), uuid);
virSecretFree(res);
- return TRUE;
+ return true;
}
/*
@@ -8008,26 +8000,26 @@ static const vshCmdOptDef opts_secret_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
- int ret = FALSE;
+ bool ret = false;
char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
xml = virSecretGetXMLDesc(secret, 0);
if (xml == NULL)
goto cleanup;
vshPrint(ctl, "%s", xml);
VIR_FREE(xml);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8049,21 +8041,21 @@ static const vshCmdOptDef opts_secret_set_value[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
size_t value_size;
const char *base64 = NULL;
char *value;
- int res, ret = FALSE;
+ int res, ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "base64", &base64) <= 0)
goto cleanup;
@@ -8074,7 +8066,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
}
if (value == NULL) {
vshError(ctl, "%s", _("Failed to allocate memory"));
- return FALSE;
+ return false;
}
res = virSecretSetValue(secret, (unsigned char *)value, value_size, 0);
@@ -8086,7 +8078,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
vshPrint(ctl, "%s", _("Secret value set\n"));
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8107,21 +8099,21 @@ static const vshCmdOptDef opts_secret_get_value[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
char *base64;
unsigned char *value;
size_t value_size;
- int ret = FALSE;
+ bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL)
- return FALSE;
+ return false;
value = virSecretGetValue(secret, &value_size, 0);
if (value == NULL)
@@ -8138,7 +8130,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%s", base64);
memset(base64, 0, strlen(base64));
VIR_FREE(base64);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8159,26 +8151,26 @@ static const vshCmdOptDef opts_secret_undefine[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd)
{
virSecretPtr secret;
- int ret = FALSE;
+ bool ret = false;
const char *uuid;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
secret = vshCommandOptSecret(ctl, cmd, &uuid);
if (secret == NULL)
- return FALSE;
+ return false;
if (virSecretUndefine(secret) < 0) {
vshError(ctl, _("Failed to delete secret %s"), uuid);
goto cleanup;
}
vshPrint(ctl, _("Secret %s deleted\n"), uuid);
- ret = TRUE;
+ ret = true;
cleanup:
virSecretFree(secret);
@@ -8194,19 +8186,19 @@ static const vshCmdInfo info_secret_list[] = {
{NULL, NULL}
};
-static int
+static bool
cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
int maxuuids = 0, i;
char **uuids = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
maxuuids = virConnectNumOfSecrets(ctl->conn);
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
- return FALSE;
+ return false;
}
uuids = vshMalloc(ctl, sizeof(*uuids) * maxuuids);
@@ -8214,7 +8206,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
VIR_FREE(uuids);
- return FALSE;
+ return false;
}
qsort(uuids, maxuuids, sizeof(char *), namesorter);
@@ -8249,7 +8241,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
VIR_FREE(uuids[i]);
}
VIR_FREE(uuids);
- return TRUE;
+ return true;
}
@@ -8263,7 +8255,7 @@ static const vshCmdInfo info_version[] = {
};
-static int
+static bool
cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
unsigned long hvVersion;
@@ -8277,12 +8269,12 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
unsigned int rel;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
hvType = virConnectGetType(ctl->conn);
if (hvType == NULL) {
vshError(ctl, "%s", _("failed to get hypervisor type"));
- return FALSE;
+ return false;
}
includeVersion = LIBVIR_VERSION_NUMBER;
@@ -8296,7 +8288,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
ret = virGetVersion(&libVersion, hvType, &apiVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the library version"));
- return FALSE;
+ return false;
}
major = libVersion / 1000000;
libVersion %= 1000000;
@@ -8315,7 +8307,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
ret = virConnectGetVersion(ctl->conn, &hvVersion);
if (ret < 0) {
vshError(ctl, "%s", _("failed to get the hypervisor version"));
- return FALSE;
+ return false;
}
if (hvVersion == 0) {
vshPrint(ctl,
@@ -8329,7 +8321,7 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, _("Running hypervisor: %s %d.%d.%d\n"),
hvType, major, minor, rel);
}
- return TRUE;
+ return true;
}
/*
@@ -8427,7 +8419,7 @@ cmdNodeListDevicesPrint(vshControl *ctl,
}
}
-static int
+static bool
cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *cap = NULL;
@@ -8436,7 +8428,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
int tree = vshCommandOptBool(cmd, "tree");
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "cap", &cap) <= 0)
cap = NULL;
@@ -8444,9 +8436,9 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
num_devices = virNodeNumOfDevices(ctl->conn, cap, 0);
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to count node devices"));
- return FALSE;
+ return false;
} else if (num_devices == 0) {
- return TRUE;
+ return true;
}
devices = vshMalloc(ctl, sizeof(char *) * num_devices);
@@ -8455,7 +8447,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to list node devices"));
VIR_FREE(devices);
- return FALSE;
+ return false;
}
qsort(&devices[0], num_devices, sizeof(char*), namesorter);
if (tree) {
@@ -8496,7 +8488,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
}
VIR_FREE(devices);
- return TRUE;
+ return true;
}
/*
@@ -8514,7 +8506,7 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
@@ -8522,24 +8514,24 @@ cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
xml = virNodeDeviceGetXMLDesc(device, 0);
if (!xml) {
virNodeDeviceFree(device);
- return FALSE;
+ return false;
}
vshPrint(ctl, "%s\n", xml);
VIR_FREE(xml);
virNodeDeviceFree(device);
- return TRUE;
+ return true;
}
/*
@@ -8557,27 +8549,27 @@ static const vshCmdOptDef opts_node_device_dettach[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceDettach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceDettach(device) == 0) {
vshPrint(ctl, _("Device %s dettached\n"), name);
} else {
vshError(ctl, _("Failed to dettach device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
@@ -8598,27 +8590,27 @@ static const vshCmdOptDef opts_node_device_reattach[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceReAttach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceReAttach(device) == 0) {
vshPrint(ctl, _("Device %s re-attached\n"), name);
} else {
vshError(ctl, _("Failed to re-attach device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
@@ -8639,27 +8631,27 @@ static const vshCmdOptDef opts_node_device_reset[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdNodeDeviceReset (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
- int ret = TRUE;
+ bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "device", &name) <= 0)
- return FALSE;
+ return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
vshError(ctl, "%s '%s'", _("Could not find matching device"), name);
- return FALSE;
+ return false;
}
if (virNodeDeviceReset(device) == 0) {
vshPrint(ctl, _("Device %s reset\n"), name);
} else {
vshError(ctl, _("Failed to reset device %s"), name);
- ret = FALSE;
+ ret = false;
}
virNodeDeviceFree(device);
return ret;
@@ -8674,24 +8666,24 @@ static const vshCmdInfo info_hostname[] = {
{NULL, NULL}
};
-static int
+static bool
cmdHostname (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *hostname;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
hostname = virConnectGetHostname (ctl->conn);
if (hostname == NULL) {
vshError(ctl, "%s", _("failed to get hostname"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", hostname);
VIR_FREE(hostname);
- return TRUE;
+ return true;
}
/*
@@ -8703,24 +8695,24 @@ static const vshCmdInfo info_uri[] = {
{NULL, NULL}
};
-static int
+static bool
cmdURI (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *uri;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
uri = virConnectGetURI (ctl->conn);
if (uri == NULL) {
vshError(ctl, "%s", _("failed to get URI"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s\n", uri);
VIR_FREE(uri);
- return TRUE;
+ return true;
}
/*
@@ -8733,24 +8725,24 @@ static const vshCmdInfo info_sysinfo[] = {
{NULL, NULL}
};
-static int
+static bool
cmdSysinfo (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *sysinfo;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
sysinfo = virConnectGetSysinfo (ctl->conn, 0);
if (sysinfo == NULL) {
vshError(ctl, "%s", _("failed to get sysinfo"));
- return FALSE;
+ return false;
}
vshPrint (ctl, "%s", sysinfo);
VIR_FREE(sysinfo);
- return TRUE;
+ return true;
}
/*
@@ -8767,22 +8759,22 @@ static const vshCmdOptDef opts_vncdisplay[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
int port = 0;
char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
doc = virDomainGetXMLDesc(dom, 0);
if (!doc)
@@ -8817,7 +8809,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
}
xmlXPathFreeObject(obj);
obj = NULL;
- ret = TRUE;
+ ret = true;
cleanup:
xmlXPathFreeObject(obj);
@@ -8842,21 +8834,21 @@ static const vshCmdOptDef opts_ttyconsole[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
virDomainPtr dom;
- int ret = FALSE;
+ bool ret = false;
char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
doc = virDomainGetXMLDesc(dom, 0);
if (!doc)
@@ -8878,7 +8870,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
vshPrint(ctl, "%s\n", (const char *)obj->stringval);
- ret = TRUE;
+ ret = true;
cleanup:
xmlXPathFreeObject(obj);
@@ -8905,30 +8897,30 @@ static const vshCmdOptDef opts_attach_device[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
@@ -8944,13 +8936,13 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
if (ret < 0) {
vshError(ctl, _("Failed to attach device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device attached successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
@@ -8970,30 +8962,30 @@ static const vshCmdOptDef opts_detach_device[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
@@ -9009,13 +9001,13 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
if (ret < 0) {
vshError(ctl, _("Failed to detach device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device detached successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
@@ -9036,30 +9028,30 @@ static const vshCmdOptDef opts_update_device[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
const char *from = NULL;
char *buffer;
- int ret = TRUE;
+ bool ret = true;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
virshReportError(ctl);
virDomainFree(dom);
- return FALSE;
+ return false;
}
if (vshCommandOptBool(cmd, "persistent")) {
@@ -9079,13 +9071,13 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
if (ret < 0) {
vshError(ctl, _("Failed to update device from %s"), from);
virDomainFree(dom);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, "%s", _("Device updated successfully\n"));
}
virDomainFree(dom);
- return TRUE;
+ return true;
}
@@ -9110,13 +9102,13 @@ static const vshCmdOptDef opts_attach_interface[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *mac = NULL, *target = NULL, *script = NULL,
*type = NULL, *source = NULL, *model = NULL;
- int typ, ret = FALSE;
+ int typ, ret = false;
unsigned int flags;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xml;
@@ -9171,7 +9163,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
@@ -9189,10 +9181,10 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach interface"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Interface attached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9219,7 +9211,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
@@ -9231,7 +9223,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
const char *mac =NULL, *type = NULL;
char *doc;
char buf[64];
- int i = 0, diff_mac, ret = FALSE;
+ int i = 0, diff_mac, ret = false;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -9327,10 +9319,10 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach interface"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9367,13 +9359,13 @@ static const vshCmdOptDef opts_attach_disk[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *source = NULL, *target = NULL, *driver = NULL,
*subdriver = NULL, *type = NULL, *mode = NULL;
- int isFile = 0, ret = FALSE;
+ int isFile = 0, ret = false;
unsigned int flags;
const char *stype = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -9447,7 +9439,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
xml = virBufferContentAndReset(&buf);
@@ -9465,10 +9457,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach disk"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Disk attached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9494,7 +9486,7 @@ static const vshCmdOptDef opts_detach_disk[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
{
xmlDocPtr xml = NULL;
@@ -9505,7 +9497,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom = NULL;
const char *target = NULL;
char *doc;
- int i = 0, diff_tgt, ret = FALSE;
+ int i = 0, diff_tgt, ret = false;
unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -9586,10 +9578,10 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach disk"));
- ret = FALSE;
+ ret = false;
} else {
vshPrint(ctl, "%s", _("Disk detached successfully\n"));
- ret = TRUE;
+ ret = true;
}
cleanup:
@@ -9618,22 +9610,22 @@ static const vshCmdOptDef opts_cpu_compare[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
int result;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
result = virConnectCompareCPU(ctl->conn, buffer, 0);
VIR_FREE(buffer);
@@ -9642,25 +9634,25 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
case VIR_CPU_COMPARE_INCOMPATIBLE:
vshPrint(ctl, _("CPU described in %s is incompatible with host CPU\n"),
from);
- ret = FALSE;
+ ret = false;
break;
case VIR_CPU_COMPARE_IDENTICAL:
vshPrint(ctl, _("CPU described in %s is identical to host CPU\n"),
from);
- ret = TRUE;
+ ret = true;
break;
case VIR_CPU_COMPARE_SUPERSET:
vshPrint(ctl, _("Host CPU is a superset of CPU described in %s\n"),
from);
- ret = TRUE;
+ ret = true;
break;
case VIR_CPU_COMPARE_ERROR:
default:
vshError(ctl, _("Failed to compare host CPU with %s"), from);
- ret = FALSE;
+ ret = false;
}
return ret;
@@ -9680,11 +9672,11 @@ static const vshCmdOptDef opts_cpu_baseline[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
{
const char *from = NULL;
- int ret = TRUE;
+ bool ret = true;
char *buffer;
char *result = NULL;
const char **list = NULL;
@@ -9698,13 +9690,13 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
int res, i;
if (!vshConnectionUsability(ctl, ctl->conn))
- return FALSE;
+ return false;
if (vshCommandOptString(cmd, "file", &from) <= 0)
- return FALSE;
+ return false;
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
- return FALSE;
+ return false;
doc = xmlNewDoc(NULL);
if (doc == NULL)
@@ -9714,7 +9706,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
(const xmlChar *)buffer, &node_list);
if (res != 0) {
vshError(ctl, _("Failed to parse XML fragment %s"), from);
- ret = FALSE;
+ ret = false;
goto cleanup;
}
@@ -9751,7 +9743,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (count == 0) {
vshError(ctl, _("No host CPU specified in '%s'"), from);
- ret = FALSE;
+ ret = false;
goto cleanup;
}
@@ -9760,7 +9752,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (result)
vshPrint(ctl, "%s", result);
else
- ret = FALSE;
+ ret = false;
cleanup:
xmlXPathFreeObject(obj);
@@ -9778,7 +9770,7 @@ cleanup:
no_memory:
vshError(ctl, "%s", _("Out of memory"));
- ret = FALSE;
+ ret = false;
goto cleanup;
}
@@ -9909,16 +9901,16 @@ static const vshCmdOptDef opts_cd[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *dir = NULL;
char *dir_malloced = NULL;
- int ret = TRUE;
+ bool ret = true;
if (!ctl->imode) {
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
- return FALSE;
+ return false;
}
if (vshCommandOptString(cmd, "dir", &dir) <= 0) {
@@ -9930,7 +9922,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (chdir(dir) == -1) {
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
- ret = FALSE;
+ ret = false;
}
VIR_FREE(dir_malloced);
@@ -9949,12 +9941,12 @@ static const vshCmdInfo info_pwd[] = {
{NULL, NULL}
};
-static int
+static bool
cmdPwd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
char *cwd;
size_t path_max;
- int err = TRUE;
+ int err = true;
path_max = (size_t) PATH_MAX + 2;
cwd = vshMalloc (ctl, path_max);
@@ -9997,7 +9989,7 @@ static const vshCmdOptDef opts_echo[] = {
/* Exists mainly for debugging virsh, but also handy for adding back
* quotes for later evaluation.
*/
-static int
+static bool
cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd)
{
bool shell = false;
@@ -10043,13 +10035,13 @@ cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd)
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
- return FALSE;
+ return false;
}
arg = virBufferContentAndReset(&buf);
if (arg)
vshPrint(ctl, "%s", arg);
VIR_FREE(arg);
- return TRUE;
+ return true;
}
/*
@@ -10069,10 +10061,10 @@ static const vshCmdOptDef opts_edit[] = {
/* This function also acts as a template to generate cmdNetworkEdit
* and cmdPoolEdit functions (below) using a sed script in the Makefile.
*/
-static int
+static bool
cmdEdit (vshControl *ctl, const vshCmd *cmd)
{
- int ret = FALSE;
+ bool ret = false;
virDomainPtr dom = NULL;
char *tmp = NULL;
char *doc = NULL;
@@ -10107,7 +10099,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
if (STREQ (doc, doc_edited)) {
vshPrint (ctl, _("Domain %s XML configuration not changed.\n"),
virDomainGetName (dom));
- ret = TRUE;
+ ret = true;
goto cleanup;
}
@@ -10134,7 +10126,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, _("Domain %s XML configuration edited.\n"),
virDomainGetName(dom));
- ret = TRUE;
+ ret = true;
cleanup:
if (dom)
@@ -10196,11 +10188,11 @@ static const vshCmdInfo info_quit[] = {
{NULL, NULL}
};
-static int
+static bool
cmdQuit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
- ctl->imode = FALSE;
- return TRUE;
+ ctl->imode = false;
+ return true;
}
/*
@@ -10218,11 +10210,11 @@ static const vshCmdOptDef opts_snapshot_create[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *from = NULL;
char *buffer = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -10284,7 +10276,7 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _(" from '%s'"), from);
vshPrint(ctl, "\n");
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(name);
@@ -10315,11 +10307,11 @@ static const vshCmdOptDef opts_snapshot_current[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
int current;
virDomainSnapshotPtr snapshot = NULL;
@@ -10347,7 +10339,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
VIR_FREE(xml);
}
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
@@ -10372,11 +10364,11 @@ static const vshCmdOptDef opts_snapshot_list[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
int numsnaps;
char **names = NULL;
int actual = 0;
@@ -10455,7 +10447,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
}
}
- ret = TRUE;
+ ret = true;
cleanup:
/* this frees up memory from the last iteration of the loop */
@@ -10490,11 +10482,11 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
char *xml = NULL;
@@ -10519,7 +10511,7 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%s", xml);
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(xml);
@@ -10546,11 +10538,11 @@ static const vshCmdOptDef opts_snapshot_revert[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -10571,7 +10563,7 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
if (virDomainRevertToSnapshot(snapshot, 0) < 0)
goto cleanup;
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
@@ -10598,11 +10590,11 @@ static const vshCmdOptDef opts_snapshot_delete[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *name = NULL;
virDomainSnapshotPtr snapshot = NULL;
unsigned int flags = 0;
@@ -10627,7 +10619,7 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
if (virDomainSnapshotDelete(snapshot, flags) < 0)
goto cleanup;
- ret = TRUE;
+ ret = true;
cleanup:
if (snapshot)
@@ -10654,11 +10646,11 @@ static const vshCmdOptDef opts_qemu_monitor_command[] = {
{NULL, 0, 0, NULL}
};
-static int
+static bool
cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- int ret = FALSE;
+ bool ret = false;
const char *monitor_cmd = NULL;
char *result = NULL;
unsigned int flags = 0;
@@ -10683,7 +10675,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
printf("%s\n", result);
- ret = TRUE;
+ ret = true;
cleanup:
VIR_FREE(result);
@@ -11071,7 +11063,7 @@ vshCmdGrpHelp(vshControl *ctl, const char *grpname)
if (!grp) {
vshError(ctl, _("command group '%s' doesn't exist"), grpname);
- return FALSE;
+ return false;
} else {
vshPrint(ctl, _(" %s (help keyword '%s'):\n"), grp->name,
grp->keyword);
@@ -11082,7 +11074,7 @@ vshCmdGrpHelp(vshControl *ctl, const char *grpname)
}
}
- return TRUE;
+ return true;
}
static int
@@ -11092,7 +11084,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
if (!def) {
vshError(ctl, _("command '%s' doesn't exist"), cmdname);
- return FALSE;
+ return false;
} else {
const char *desc = _(vshCmddefGetInfo(def, "desc"));
const char *help = _(vshCmddefGetInfo(def, "help"));
@@ -11103,7 +11095,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
vshError(ctl, _("internal error: bad options in command: '%s'"),
def->name);
- return FALSE;
+ return false;
}
fputs(_(" NAME\n"), stdout);
@@ -11183,7 +11175,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
}
fputc('\n', stdout);
}
- return TRUE;
+ return true;
}
/* ---------------
@@ -11362,12 +11354,12 @@ vshCommandOptULongLong(const vshCmd *cmd, const char *name,
/*
- * Returns TRUE/FALSE if the option exists
+ * Returns true/false if the option exists
*/
-static int
+static bool
vshCommandOptBool(const vshCmd *cmd, const char *name)
{
- return vshCommandOpt(cmd, name) ? TRUE : FALSE;
+ return vshCommandOpt(cmd, name) != NULL;
}
/*
@@ -11698,7 +11690,7 @@ vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
static int
vshCommandRun(vshControl *ctl, const vshCmd *cmd)
{
- int ret = TRUE;
+ bool ret = true;
while (cmd) {
struct timeval before, after;
@@ -11715,11 +11707,11 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
if (enable_timing)
GETTIMEOFDAY(&after);
- if (ret == FALSE)
+ if (ret == false)
virshReportError(ctl);
/* try to automatically catch disconnections */
- if ((ret == FALSE) &&
+ if ((ret == false) &&
((disconnected != 0) ||
((last_error != NULL) &&
(((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
@@ -11915,7 +11907,7 @@ get_data:
break;
}
- return TRUE;
+ return true;
syntaxError:
if (ctl->cmd) {
@@ -11925,7 +11917,7 @@ get_data:
if (first)
vshCommandOptFree(first);
VIR_FREE(tkdata);
- return FALSE;
+ return false;
}
/* --------------------
@@ -11951,7 +11943,7 @@ static int vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
vshCommandParser parser;
if (nargs <= 0)
- return FALSE;
+ return false;
parser.arg_pos = argv;
parser.arg_end = argv + nargs;
@@ -12029,7 +12021,7 @@ static int vshCommandStringParse(vshControl *ctl, char *cmdstr)
vshCommandParser parser;
if (cmdstr == NULL || *cmdstr == '\0')
- return FALSE;
+ return false;
parser.pos = cmdstr;
parser.getNextArg = vshCommandStringGetArg;
@@ -12086,9 +12078,9 @@ vshConnectionUsability(vshControl *ctl, virConnectPtr conn)
*/
if (!conn) {
vshError(ctl, "%s", _("no valid connection"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void
@@ -12114,7 +12106,7 @@ vshPrintExtra(vshControl *ctl, const char *format, ...)
va_list ap;
char *str;
- if (ctl && ctl->quiet == TRUE)
+ if (ctl && ctl->quiet == true)
return;
va_start(ap, format);
@@ -12160,7 +12152,7 @@ static int
vshInit(vshControl *ctl)
{
if (ctl->conn)
- return FALSE;
+ return false;
vshOpenLogFile(ctl);
@@ -12171,7 +12163,7 @@ vshInit(vshControl *ctl)
vshSetupSignals();
if (virEventRegisterDefaultImpl() < 0)
- return FALSE;
+ return false;
ctl->conn = virConnectOpenAuth(ctl->name,
virConnectAuthPtrDefault,
@@ -12185,10 +12177,10 @@ vshInit(vshControl *ctl)
if (!ctl->conn) {
virshReportError(ctl);
vshError(ctl, "%s", _("failed to connect to the hypervisor"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
@@ -12557,7 +12549,7 @@ vshDeinit(vshControl *ctl)
}
virResetLastError();
- return TRUE;
+ return true;
}
/*
@@ -12759,10 +12751,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
help = true;
break;
case 'q':
- ctl->quiet = TRUE;
+ ctl->quiet = true;
break;
case 't':
- ctl->timing = TRUE;
+ ctl->timing = true;
break;
case 'c':
ctl->name = vshStrdup(ctl, optarg);
@@ -12777,7 +12769,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
vshShowVersion(ctl);
exit(EXIT_SUCCESS);
case 'r':
- ctl->readonly = TRUE;
+ ctl->readonly = true;
break;
case 'l':
ctl->logfile = vshStrdup(ctl, optarg);
@@ -12801,7 +12793,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
if (argc > optind) {
/* parse command */
- ctl->imode = FALSE;
+ ctl->imode = false;
if (argc - optind == 1) {
vshDebug(ctl, 2, "commands: \"%s\"\n", argv[optind]);
return vshCommandStringParse(ctl, argv[optind]);
@@ -12809,7 +12801,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
return vshCommandArgvParse(ctl, argc - optind, argv + optind);
}
}
- return TRUE;
+ return true;
}
int
@@ -12817,7 +12809,7 @@ main(int argc, char **argv)
{
vshControl _ctl, *ctl = &_ctl;
char *defaultConn;
- int ret = TRUE;
+ bool ret = true;
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
@@ -12838,7 +12830,7 @@ main(int argc, char **argv)
progname++;
memset(ctl, 0, sizeof(vshControl));
- ctl->imode = TRUE; /* default is interactive mode */
+ ctl->imode = true; /* default is interactive mode */
ctl->log_fd = -1; /* Initialize log file descriptor */
if ((defaultConn = getenv("VIRSH_DEFAULT_CONNECT_URI"))) {
--
1.7.1
2
2
The libvirtd daemon uses fnmatch. Although we don't yet build
it on Win32, we should use gnulib's fnmatch module to ensure
portability to all platforms.
* bootstrap.conf: Add fnmatch
---
bootstrap.conf | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 293f86e..8db4e87 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -34,6 +34,7 @@ count-one-bits
crypto/md5
dirname-lgpl
fcntl-h
+fnmatch
func
getaddrinfo
gethostname
--
1.7.4.4
2
1
[libvirt] [PATCH 1/3] qemu: avoid qemu_driver being unlocked twice when virThreadPoolNew() failed
by Wen Congyang 19 Apr '11
by Wen Congyang 19 Apr '11
19 Apr '11
We do not lock qemu_driver when calling virThreadPoolNew(). If it failed,
we will unlock qemu_driver. It is dangerous.
We may use this pool during auto starting domains. So we must create it before
calling qemuAutostartDomains(). Otherwise, libvirtd will crash.
---
src/qemu/qemu_driver.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 48fe266..dd84f65 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -624,14 +624,14 @@ qemudStartup(int privileged) {
virHashForEach(qemu_driver->domains.objs, qemuDomainSnapshotLoad,
qemu_driver->snapshotDir);
- qemuDriverUnlock(qemu_driver);
-
- qemuAutostartDomains(qemu_driver);
-
qemu_driver->workerPool = virThreadPoolNew(0, 1, processWatchdogEvent, qemu_driver);
if (!qemu_driver->workerPool)
goto error;
+ qemuDriverUnlock(qemu_driver);
+
+ qemuAutostartDomains(qemu_driver);
+
if (conn)
virConnectClose(conn);
--
1.7.1
4
17
[libvirt] [PATCH] Allow handshake with child process during startup
by Daniel P. Berrange 19 Apr '11
by Daniel P. Berrange 19 Apr '11
19 Apr '11
Allow the parent process to perform a bi-directional handshake
with the child process during fork/exec. The child process
will fork and do its initial setup. Immediately prior to the
exec(), it will stop & wait for a handshake from the parent
process. The parent process will spawn the child and wait
until the child reaches the handshake point. It will do
whatever extra setup work is required, before signalling the
child to continue.
The implementation of this is done using two pairs of blocking
pipes. The first pair is used to block the parent, until the
child writes a single byte. Then the second pair pair is used
to block the child, until the parent confirms with another
single byte.
* src/util/command.c, src/util/command.h,
src/libvirt_private.syms: Add APIs to perform a handshake
---
src/libvirt_private.syms | 3 +
src/util/command.c | 142 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/command.h | 5 ++
3 files changed, 148 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 114bc2e..87f0432 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -106,11 +106,14 @@ virCommandAddEnvString;
virCommandClearCaps;
virCommandDaemonize;
virCommandFree;
+virCommandHandshakeNotify;
+virCommandHandshakeWait;
virCommandNew;
virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPreserveFD;
+virCommandRequireHandshake;
virCommandRun;
virCommandRunAsync;
virCommandSetErrorBuffer;
diff --git a/src/util/command.c b/src/util/command.c
index 2e475a0..d8440ca 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -35,6 +35,11 @@
#include "files.h"
#include "buf.h"
+#include <stdlib.h>
+#include <stdbool.h>
+#include <poll.h>
+#include <sys/wait.h>
+
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
@@ -76,6 +81,10 @@ struct _virCommand {
int *outfdptr;
int *errfdptr;
+ bool handshake;
+ int handshakeWait[2];
+ int handshakeNotify[2];
+
virExecHook hook;
void *opaque;
@@ -107,6 +116,11 @@ virCommandNewArgs(const char *const*args)
if (VIR_ALLOC(cmd) < 0)
return NULL;
+ cmd->handshakeWait[0] = -1;
+ cmd->handshakeWait[1] = -1;
+ cmd->handshakeNotify[0] = -1;
+ cmd->handshakeNotify[1] = -1;
+
FD_ZERO(&cmd->preserve);
FD_ZERO(&cmd->transfer);
cmd->infd = cmd->outfd = cmd->errfd = -1;
@@ -1115,7 +1129,6 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
return ret;
}
-
/*
* Perform all virCommand-specific actions, along with the user hook.
*/
@@ -1125,12 +1138,61 @@ virCommandHook(void *data)
virCommandPtr cmd = data;
int res = 0;
- if (cmd->hook)
+ if (cmd->hook) {
+ VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
res = cmd->hook(cmd->opaque);
+ VIR_DEBUG("Done hook %d", res);
+ }
if (res == 0 && cmd->pwd) {
VIR_DEBUG("Running child in %s", cmd->pwd);
res = chdir(cmd->pwd);
+ if (res < 0) {
+ virReportSystemError(errno,
+ _("Unable to change to %s"), cmd->pwd);
+ }
+ }
+ if (cmd->handshake) {
+ char c = res < 0 ? '0' : '1';
+ int rv;
+ VIR_DEBUG("Notifying parent for handshake start on %d", cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify parent process"));
+ return -1;
+ }
+
+ /* On failure we pass the error message back to parent,
+ * so they don't have to dig through stderr logs
+ */
+ if (res < 0) {
+ virErrorPtr err = virGetLastError();
+ const char *msg = err ? err->message :
+ _("Unknown failure during hook execution");
+ size_t len = strlen(msg) + 1;
+ if (safewrite(cmd->handshakeWait[1], msg, len) != len) {
+ virReportSystemError(errno, "%s", _("Unable to send error to parent process"));
+ return -1;
+ }
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d", cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s", _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL, _("Unexpected confirm code '%c' from parent process"), c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
}
+
+ VIR_DEBUG("Hook is done %d", res);
+
return res;
}
@@ -1220,6 +1282,10 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
FD_CLR(i, &cmd->transfer);
}
}
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ }
if (ret == 0 && pid)
*pid = cmd->pid;
@@ -1360,6 +1426,71 @@ virCommandAbort(virCommandPtr cmd ATTRIBUTE_UNUSED)
}
#endif
+
+void virCommandRequireHandshake(virCommandPtr cmd)
+{
+ if (pipe(cmd->handshakeWait) < 0) {
+ cmd->has_error = errno;
+ return;
+ }
+ if (pipe(cmd->handshakeNotify) < 0) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ cmd->has_error = errno;
+ return;
+ }
+
+ VIR_DEBUG("Transfer handshake wait=%d notify=%d",
+ cmd->handshakeWait[1], cmd->handshakeNotify[0]);
+ virCommandPreserveFD(cmd, cmd->handshakeWait[1]);
+ virCommandPreserveFD(cmd, cmd->handshakeNotify[0]);
+ cmd->handshake = true;
+}
+
+int virCommandHandshakeWait(virCommandPtr cmd)
+{
+ char c;
+ int rv;
+ VIR_DEBUG("Wait for handshake on %d", cmd->handshakeWait[0]);
+ if ((rv = saferead(cmd->handshakeWait[0], &c, sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s", _("Unable to wait for child process"));
+ else
+ virReportSystemError(EIO, "%s", _("Child process quit during startup handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ char *msg;
+ ssize_t len;
+ if (VIR_ALLOC_N(msg, 1024) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if ((len = saferead(cmd->handshakeWait[0], msg, 1024)) < 0) {
+ VIR_FREE(msg);
+ virReportSystemError(errno, "%s", _("No error message from child failure"));
+ return -1;
+ }
+ msg[len-1] = '\0';
+ virCommandError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
+ VIR_FREE(msg);
+ return -1;
+ }
+ return 0;
+}
+
+int virCommandHandshakeNotify(virCommandPtr cmd)
+{
+ char c = '1';
+ VIR_DEBUG("Notify handshake on %d", cmd->handshakeWait[0]);
+ if (safewrite(cmd->handshakeNotify[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s", _("Unable to notify child process"));
+ return -1;
+ }
+ return 0;
+}
+
+
/*
* Release all resources
*/
@@ -1391,6 +1522,13 @@ virCommandFree(virCommandPtr cmd)
VIR_FREE(cmd->pwd);
+ if (cmd->handshake) {
+ VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[1]);
+ }
+
VIR_FREE(cmd->pidfile);
if (cmd->reap)
diff --git a/src/util/command.h b/src/util/command.h
index ff8ccf5..4712301 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -274,6 +274,11 @@ int virCommandRunAsync(virCommandPtr cmd,
int virCommandWait(virCommandPtr cmd,
int *exitstatus) ATTRIBUTE_RETURN_CHECK;
+void virCommandRequireHandshake(virCommandPtr cmd);
+
+int virCommandHandshakeWait(virCommandPtr cmd);
+int virCommandHandshakeNotify(virCommandPtr cmd);
+
/*
* Abort an async command if it is running, without issuing
* any errors or affecting errno. Designed for error paths
--
1.7.4
2
2
Re: [libvirt] [PATCH DISCUSSION ONLY] Add inspection thread to virt-manager.
by Richard W.M. Jones 19 Apr '11
by Richard W.M. Jones 19 Apr '11
19 Apr '11
On Mon, Apr 18, 2011 at 05:50:01PM -0400, Cole Robinson wrote:
> First, thanks a lot for the patch! I'm sure everyone will be glad to see
> libguestfs integration in virt-manager.
>
> > [This patch is incomplete and just for discussion]
> >
> > Using libguestfs inspection[1], we can find out a lot about a virtual
> > machine, such as what operating system is installed, the OS version,
> > the OS distro, the hostname, the (real) disk usage, what apps are
> > installed, and lots more. It would be nice if virt-manager could use
> > this information: for example we could change the generic "computer"
> > icon into a Windows or Fedora logo if Windows or Fedora was installed
> > in the virtual machine.
> >
>
> That icon bit was originally intended for the current design, but since we've
> never really tracked OS info after install time, it never came about.
>
> Particularly for OS type/version tracking, I think we need a few things:
>
> - Everything standardize on some naming scheme, ideally libosinfo (though
> nothing is using it yet :/ ). libosinfo could also distribute the OS icons
We sort of got bored of waiting for that train. We have a primitive
but rather effective system in libguestfs, which I explain at the end
of this email.
> - Libvirt domain XML schema is extended with a field to track the
> installed OS. For most libvirt drivers this would just be metadata
> (vmware/esx the exception). Even though the data might be out of
> date if the guest is upgraded, I think it has become clear that
> there is a lot of value in tracking this in XML.
Yes, I agree. This also solves the persistence problem.
It's a bit of a shame that the <description> field in the libvirt XML
isn't structured, at least so that different applications could store
their own data there without it being trampled upon by users or other
applications. (CC'd to libvir-list in case they have any thoughts
about that).
> - virt-manager can offer an option to set the XML OS value from libguestfs
> inspection. Maybe even some preference to do this automatically for vms which
> have no XML value, or some warning if the inspected OS doesn't match the
> stored value.
>
> None of this affects the validity of the patch btw.
>
> > This patch adds a daemon thread running in the background which
> > performs batch inspection on the virt-manager VMs. If inspection is
> > successful, it then passes the results up to the UI (ie. the
> > vmmManager object) to be displayed.
> >
> > Currently I've just added the inspected hostname to the UI as you can
> > see in this screenshot:
> >
> > http://oirase.annexia.org/tmp/vmm-hostnames.png
> >
>
> Ah, that's a nice idea, but I'd probably want to run it by the UX guys first.
I've removed that from the code already. It was just a quick hack to
show what could be done.
> At the very least a first step would be showing the hostname under
> Details->Overview, probably just add a new field under the Name:
Agreed.
> > In future there is room for much greater customization of the UI, such
> > as changing the icons, displaying disk usage and more.
> >
> > The background thread is transparent to the UI. Well, in fact because
> > of a bug in libguestfs, it is currently NOT transparent because we
> > weren't releasing the Python GIL across libguestfs calls. If you
> > apply the following patch to libguestfs, then it *is* transparent and
> > doesn't interrupt the UI:
> >
> > https://www.redhat.com/archives/libguestfs/2011-April/msg00076.html
> >
>
> Okay, so when this patch is committed we probably want to add a libguestfs
> version check to make sure we aren't using bad bindings.
Agreed. Also I have pushed the Python fix into:
stable branch 1.8 version >= 1.8.6
stable branch 1.10 version >= 1.10.1
development branch version >= 1.11.2
and these should be available in Fedora 14 onwards in a few weeks.
> > I think that virt-manager should probably cache the inspection data
> > across runs. However I don't know if virt-manager has a mechanism to
> > do this already or if we'd need to add one.
>
> Do you mean cache across runs of virt-manager? We could use gconf, we already
> have examples of setting per-vm preferences like console scaling, we could use
> the same to store hostname, os type/distro, etc. But then we have to decide
> when to repoll this info, and if/how to allow the user to force repolling.
Or libvirt XML maybe .. see above.
> > Also this patch doesn't yet change ./configure, so it'll just fail if
> > the python-libguestfs package is not installed.
> >
>
> We don't really use configure for package checks actually. It's pretty easy in
> the code to just try the import and disable the feature if the package isn't
> available. Then distros just use rpm/dpkg deps to pull in the packages we want
We should probably do the check entirely at runtime and make
python-libguestfs completely optional (but on Debian, map it to an
Enhances-type dependency). There's no need to have virt-manager
depending on libguestfs, since this is just an extra feature, not a
requirement.
> > [1] http://libguestfs.org/virt-inspector.1.html
> >
>
> On 04/18/2011 01:01 PM, Richard W.M. Jones wrote:
> > From 11278a7509e4edbcb28eac4c2c4a50fc8d68342e Mon Sep 17 00:00:00 2001
> > From: Richard W.M. Jones <rjones(a)redhat.com>
> > Date: Mon, 18 Apr 2011 17:44:51 +0100
> > Subject: [PATCH] Add inspection thread to virt-manager.
> >
> > ---
> > src/virtManager/engine.py | 14 ++++
> > src/virtManager/inspection.py | 162 +++++++++++++++++++++++++++++++++++++++++
> > src/virtManager/manager.py | 26 ++++++-
> > 3 files changed, 200 insertions(+), 2 deletions(-)
> > create mode 100644 src/virtManager/inspection.py
> >
> > diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py
> > index 383deb3..40d5b39 100644
> > --- a/src/virtManager/engine.py
> > +++ b/src/virtManager/engine.py
> > @@ -45,6 +45,7 @@ from virtManager.create import vmmCreate
> > from virtManager.host import vmmHost
> > from virtManager.error import vmmErrorDialog
> > from virtManager.systray import vmmSystray
> > +from virtManager.inspection import vmmInspection
> > import virtManager.uihelpers as uihelpers
> > import virtManager.util as util
> >
> > @@ -239,6 +240,9 @@ class vmmEngine(vmmGObject):
> > if not self.config.support_threading:
> > logging.debug("Libvirt doesn't support threading, skipping.")
> >
> > + self.inspection_thread = None
> > + self.create_inspection_thread()
> > +
> > # Counter keeping track of how many manager and details windows
> > # are open. When it is decremented to 0, close the app or
> > # keep running in system tray if enabled
> > @@ -533,6 +537,16 @@ class vmmEngine(vmmGObject):
> > logging.debug("Exiting app normally.")
> > gtk.main_quit()
> >
> > + def create_inspection_thread(self):
> > + if not self.config.support_threading:
> > + logging.debug("No inspection thread because "
> > + "libvirt is not thread-safe.")
> > + return
> > + self.inspection_thread = vmmInspection(self)
> > + self.inspection_thread.daemon = True
> > + self.inspection_thread.start()
> > + return
> > +
> > def add_connection(self, uri, readOnly=None, autoconnect=False):
> > conn = self._check_connection(uri)
> > if conn:
> > diff --git a/src/virtManager/inspection.py b/src/virtManager/inspection.py
> > new file mode 100644
> > index 0000000..70f2f52
> > --- /dev/null
> > +++ b/src/virtManager/inspection.py
> > @@ -0,0 +1,162 @@
> > +#
> > +# Copyright (C) 2011 Red Hat, Inc.
> > +#
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of the GNU General Public License as published by
> > +# the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version.
> > +#
> > +# This program is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write to the Free Software
> > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> > +# MA 02110-1301 USA.
> > +#
> > +
> > +import sys
> > +import time
> > +import traceback
> > +from Queue import Queue
> > +from threading import Thread
> > +
> > +from guestfs import GuestFS
> > +
> > +import logging
> > +import util
> > +
> > +class vmmInspection(Thread):
> > + _name = "inspection thread"
> > + _wait = 60 # seconds
> > +
> > + def __init__(self, engine):
> > + Thread.__init__(self, name=self._name)
> > + self._q = Queue()
> > + self._engine = engine
> > + self._vmcache = dict()
> > +
> > + # Called by the main thread whenever a VM is added to vmlist.
> > + def vm_added(self, connection, vmuuid):
> > + obj = (connection, vmuuid)
> > + self._q.put(obj)
> > +
> > + def run(self):
> > + # Wait a few seconds before we do anything. This prevents
> > + # inspection from being a burden for initial virt-manager
> > + # interactivity (although it shouldn't affect interactivity at
> > + # all).
> > + logging.debug("%s: waiting" % self._name)
> > + time.sleep(self._wait)
> > +
> > + logging.debug("%s: ready" % self._name)
> > +
> > + while True:
> > + obj = self._q.get(True)
> > + (connection, vmuuid) = obj
> > +
> > + logging.debug("%s: %s: processing started, connection = %s" %
> > + (self._name, vmuuid, connection))
> > + try:
> > + self._process(connection, vmuuid)
> > + except:
> > + logging.debug("%s: %s: processing raised:\n%s" %
> > + (self._name, vmuuid, traceback.format_exc()))
> > +
> > + self._q.task_done()
> > + logging.debug("%s: %s: processing done" % (self._name, vmuuid))
> > +
> > + def _process(self, connection, vmuuid):
> > + if vmuuid in self._vmcache:
> > + self._update_ui(connection, vmuuid)
> > + return
> > +
> > + if not connection or connection.is_remote():
> > + logging.debug("%s: %s: no connection object or "
> > + "connection is remote" % (self._name, vmuuid))
> > + return
> > + vm = connection.get_vm(vmuuid)
> > + if not vm:
> > + logging.debug("%s: %s: no vm object" % (self._name, vmuuid))
> > + return
> > +
> > + xml = vm.get_xml()
> > + if not xml:
> > + logging.debug("%s: %s: cannot get domain XML" %
> > + (self._name, vmuuid))
> > + return
> > +
>
> This 2 calls won't ever be none, they'll either return something or throw an
> exception.
OK, I will fix it.
> > + g = GuestFS()
> > + # One day we will be able to do ...
> > + #g.add_libvirt_dom(...)
> > + # but until that day comes ...
> > + disks = self._get_disks_from_xml(xml)
> > + for (disk, format) in disks:
> > + g.add_drive_opts(disk, readonly=1, format=format)
> > +
> > + g.launch()
> > +
> > + # Inspect the operating system.
> > + roots = g.inspect_os()
> > + if len(roots) == 0:
> > + logging.debug("%s: %s: no operating systems found" %
> > + (self._name, vmuuid))
> > + return
> > +
> > + # Arbitrarily pick the first root device.
> > + root = roots[0]
> > +
> > + # Inspection.
> > + name = g.inspect_get_type (root)
> > + distro = g.inspect_get_distro (root)
> > + hostname = g.inspect_get_hostname (root)
> > +
> > + self._vmcache[vmuuid] = (name, distro, hostname)
> > +
> > + # Force the libguestfs handle to close right now.
> > + del g
> > +
> > + # Update the UI.
> > + self._update_ui(connection, vmuuid)
> > +
> > + # Call back into the manager (if one is displayed) to update the
> > + # inspection data for the particular VM.
> > + def _update_ui(self, connection, vmuuid):
> > + wm = self._engine.windowManager
> > + if not wm: return
> > +
> > + name, distro, hostname = self._vmcache[vmuuid]
> > +
> > + wm.vm_set_inspection_data(connection, vmuuid, name, distro, hostname)
> > +
>
> The preferred way to do this would be with gtk signals. Have the
> inspection thread do something like vm.set_hostname(), which will
> trigger a self.emit("config-changed"), which is already wired up in
> manager.py to refresh the row listing. This will let you drop
> self._engine (generally if we are passing engine around there is
> probably a cleaner way to do things, but we aren't too disciplined
> on that at the moment).
OK, I will fix this too once I work out what gtk signals are ..
> > + # Get the list of disks belonging to this VM from the libvirt XML.
> > + def _get_disks_from_xml(self, xml):
> > + def f(doc, ctx):
> > + nodes = ctx.xpathEval("//devices/disk")
> > + disks = []
> > + for node in nodes:
> > + ctx.setContextNode(node)
> > + types = ctx.xpathEval("./@type")
> > +
> > + if types and types[0].content:
> > + t = types[0].content
> > + disk = None
> > +
> > + if t == "file":
> > + disk = ctx.xpathEval("./source/@file")
> > + elif t == "block":
> > + disk = ctx.xpathEval("./source/@dev")
> > +
> > + if disk and disk[0].content:
> > + d = disk[0].content
> > + types = ctx.xpathEval("./driver/@type")
> > + if types and types[0].content:
> > + disks.append((d, types[0].content))
> > + else:
> > + disks.append((d, None))
> > +
> > + return disks
>
> This _get_disk_from_xml function isn't needed. You can just do:
>
> for disk in vm.get_disk_devices():
> path = disk.path
> driver_type = disk.driver_type
> disks.append((path, driver_type))
>
> the 'disk' in this case is a virtinst.VirtualDisk instance, incase you need
> other XML values in the future
OK, that's a much better idea! I'll make these and other changes and
send an update in a few days.
Thanks for looking at this.
Rich.
----------------------------------------------------------------------
Operating systems are classified at two levels, 'type' and 'distro':
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_type
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_distro
The version number of the OS is classified separately:
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_major_version
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_minor_version
And finally in order to distinguish between certain flavours of
Windows and RHEL you also need the "product variant":
http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_product_variant
In the patch I sent, 'type' and 'distro' fields are pushed up to the
vmmManager object already.
----------------------------------------------------------------------
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
3
2
---
libvirt-php.spec.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/libvirt-php.spec.in b/libvirt-php.spec.in
index 07e11a1..41408a2 100644
--- a/libvirt-php.spec.in
+++ b/libvirt-php.spec.in
@@ -46,6 +46,7 @@ For more details see: http://www.libvirt.org/php/
%package -n libvirt-php-doc
Summary: Document of libvirt-php
Group: Development/Libraries/PHP
+BuildArch: noarch
Requires: libvirt-php = %{version}
%description -n libvirt-php-doc
--
1.7.3.4
2
1
Hi,
I've upgraded to 0.9.0 today on my Debian Squeeze boxes. Everything went
fine, expect on one node (and only on that one, although the setup is
identical), the first start of libvirtd since boot (and again, only that
start) crashes with SEGV.
Here are traces from gdb:
http://pastebin.com/DiZrw0S5
http://pastebin.com/eacJRv07
If I delete the PID-file and start libvirtd again, it works fine. It
doesn't seem to matter when the first start since boot happens, I've
deactivated startup of libvirtd at boot time.
Any ideas or further infos needed?
thanks & regards,
thomas
3
7
Hi,
This is v3 of virNodeGetCpuTime() API.
It returns cpu utilization or
cumulative cpu time of the node from /proc/stat since node boots up.
This patch only supports linux host.
Changes
v2->v3
- Change user I/F. It is able to request what the user want by the @flags.
- Minor change of virsh nodecputime I/F.
v1->v2
- Change user I/F like virDomainGetMemoryStats()
- It can return either cpu utilization or cumulative cpu time of the node
depends on each driver.
Minoru Usui (6):
[v3 1/6] virNodeGetCPUTime: Expose new API
[v3 2/6] virNodeGetCPUTime: Define internal driver API
[v3 3/6] virNodeGetCPUTime: Implement public API
[v3 4/6] virNodeGetCPUTime: Implement remote protocol
[v3 5/6] virNodeGetCPUTime: Implement virsh support
[v3 6/6] virNodeGetCPUTime: Implement linux support
daemon/remote.c | 46 +++++++++++++++++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 +++
daemon/remote_dispatch_ret.h | 1 +
daemon/remote_dispatch_table.h | 5 ++
include/libvirt/libvirt.h.in | 50 +++++++++++++++++++++
src/driver.h | 8 +++
src/esx/esx_driver.c | 1 +
src/libvirt.c | 79 ++++++++++++++++++++++++++++++++
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 ++
src/libxl/libxl_driver.c | 1 +
src/lxc/lxc_driver.c | 1 +
src/nodeinfo.c | 78 ++++++++++++++++++++++++++++++++
src/nodeinfo.h | 5 ++-
src/openvz/openvz_driver.c | 1 +
src/phyp/phyp_driver.c | 1 +
src/qemu/qemu_driver.c | 1 +
src/remote/remote_driver.c | 37 +++++++++++++++
src/remote/remote_protocol.c | 22 +++++++++
src/remote/remote_protocol.h | 20 ++++++++
src/remote/remote_protocol.x | 15 ++++++-
src/remote_protocol-structs | 10 ++++
src/test/test_driver.c | 1 +
src/uml/uml_driver.c | 1 +
src/vbox/vbox_tmpl.c | 1 +
src/vmware/vmware_driver.c | 1 +
src/xen/xen_driver.c | 1 +
src/xenapi/xenapi_driver.c | 1 +
tools/virsh.c | 84 +++++++++++++++++++++++++++++++++++
tools/virsh.pod | 4 ++
31 files changed, 489 insertions(+), 2 deletions(-)
--
Minoru Usui <usui(a)mxm.nes.nec.co.jp>
2
8
From: Alan Pevec <apevec(a)redhat.com>
To install it, disable libvirtd sysv initscript:
chkconfig libvirtd off
service libvirtd stop
and enable libvirtd upstart job:
cp /usr/share/doc/libvirt-*/libvirtd.upstart \
/etc/init/libvirtd.conf
initctl reload-configuration
initctl start libvirtd
Test:
initctl status libvirtd
libvirtd start/running, process 3929
killall -9 libvirtd
initctl status libvirtd
libvirtd start/running, process 4047
I looked into the possibility to use the upstart script from Ubuntu or
at least getting inspiration from it but that's not possible. "expect
daemon" is a nice thing but it only works if the process is defined with
exec stanza instead of script ... no script. Unfortunately, with exec
stanza environment variables can only be set within upstart script
(i.e., configuration in /etc/sysconfig/libvirtd can't work). Hence, we
need to use script stanza, source sysconfig, and execute libvirtd
without --daemon. For similar reasons we can't use limit stanza and need
to handle DAEMON_COREFILE_LIMIT in job's script.
---
Notes:
Version 2:
- I took Allan's script and modified it a bit
- DAEMON_COREFILE_LIMIT from sysconfig works
- PID file handling limited to just removing it
daemon/Makefile.am | 1 +
daemon/libvirtd.upstart | 46 ++++++++++++++++++++++++++++++++++++++++++++++
libvirt.spec.in | 1 +
3 files changed, 48 insertions(+), 0 deletions(-)
create mode 100644 daemon/libvirtd.upstart
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index cacec1c..af71188 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -26,6 +26,7 @@ EXTRA_DIST = \
remote_generate_stubs.pl \
libvirtd.conf \
libvirtd.init.in \
+ libvirtd.upstart \
libvirtd.policy-0 \
libvirtd.policy-1 \
libvirtd.sasl \
diff --git a/daemon/libvirtd.upstart b/daemon/libvirtd.upstart
new file mode 100644
index 0000000..fd1d951
--- /dev/null
+++ b/daemon/libvirtd.upstart
@@ -0,0 +1,46 @@
+# libvirtd upstart job
+#
+# XXX wait for rc to get all dependent initscripts started
+# from sysv libvirtd initscript: Required-Start: $network messagebus
+start on stopped rc RUNLEVEL=[345]
+stop on runlevel [!345]
+
+respawn
+
+script
+ LIBVIRTD_CONFIG=
+ LIBVIRTD_ARGS=
+ KRB5_KTNAME=/etc/libvirt/krb5.tab
+
+ if [ -f /etc/sysconfig/libvirtd ]; then
+ . /etc/sysconfig/libvirtd
+ fi
+
+ export QEMU_AUDIO_DRV
+ export SDL_AUDIODRIVER
+ export KRB5_KTNAME
+
+ LIBVIRTD_CONFIG_ARGS=
+ if [ -n "$LIBVIRTD_CONFIG" ]; then
+ LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
+ fi
+
+ # DAEMON_COREFILE_LIMIT from /etc/sysconfig/libvirtd is not handled
+ # automatically
+ if [ -n "$DAEMON_COREFILE_LIMIT" ]; then
+ ulimit -c "$DAEMON_COREFILE_LIMIT"
+ fi
+
+ # Clean up a pidfile that might be left around
+ rm -f /var/run/libvirtd.pid
+
+ mkdir -p /var/cache/libvirt
+ rm -rf /var/cache/libvirt/*
+
+ exec /usr/sbin/libvirtd $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
+end script
+
+post-stop script
+ rm -f $PIDFILE
+ rm -rf /var/cache/libvirt/*
+end script
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 4162fba..bf6b9df 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -895,6 +895,7 @@ fi
%{_sysconfdir}/libvirt/nwfilter/*.xml
%{_sysconfdir}/rc.d/init.d/libvirtd
+%doc daemon/libvirtd.upstart
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
%if %{with_dtrace}
--
1.7.5.rc1
3
5
Here is a new version of this patch:
https://www.redhat.com/archives/libvir-list/2011-April/msg00337.html
v2:
- store the cputune info for the whole runtime of the domain
- remove cputune info when domain is destroyed
The nodeGetInfo code had to be moved into a helper
function to reuse it without a virConnectPtr.
---
src/libxl/libxl_driver.c | 159 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 122 insertions(+), 37 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 3040914..247d78e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -199,6 +199,46 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
virDomainObjUnlock(vm);
}
+static int
+libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
+{
+ libxl_physinfo phy_info;
+ const libxl_version_info* ver_info;
+ struct utsname utsname;
+
+ if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxl_get_physinfo_info failed"));
+ return -1;
+ }
+
+ if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxl_get_version_info failed"));
+ return -1;
+ }
+
+ uname(&utsname);
+ if (virStrncpy(info->model,
+ utsname.machine,
+ strlen(utsname.machine),
+ sizeof(info->model)) == NULL) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("machine type %s too big for destination"),
+ utsname.machine);
+ return -1;
+ }
+
+ info->memory = phy_info.total_pages * (ver_info->pagesize / 1024);
+ info->cpus = phy_info.nr_cpus;
+ info->nodes = phy_info.nr_nodes;
+ info->cores = phy_info.cores_per_socket;
+ info->threads = phy_info.threads_per_core;
+ info->sockets = 1;
+ info->mhz = phy_info.cpu_khz / 1000;
+ return 0;
+}
+
/*
* Cleanup function for domain that has reached shutoff state.
*
@@ -210,6 +250,7 @@ libxlVmCleanup(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
libxlDomainObjPrivatePtr priv = vm->privateData;
int vnc_port;
char *file;
+ int i;
if (priv->eventHdl >= 0) {
virEventRemoveHandle(priv->eventHdl);
@@ -238,6 +279,16 @@ libxlVmCleanup(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
}
}
+ /* Remove any cputune settings */
+ if (vm->def->cputune.nvcpupin) {
+ for (i = 0; i < vm->def->cputune.nvcpupin; ++i) {
+ VIR_FREE(vm->def->cputune.vcpupin[i]->cpumask);
+ VIR_FREE(vm->def->cputune.vcpupin[i]);
+ }
+ VIR_FREE(vm->def->cputune.vcpupin);
+ vm->def->cputune.nvcpupin = 0;
+ }
+
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) > 0) {
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name);
@@ -391,6 +442,62 @@ error:
return -1;
}
+static int
+libxlDomainSetVcpuAffinites(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
+{
+ libxlDomainObjPrivatePtr priv = vm->privateData;
+ virDomainDefPtr def = vm->def;
+ libxl_cpumap map;
+ uint8_t *cpumask = NULL;
+ uint8_t *cpumap = NULL;
+ virNodeInfo nodeinfo;
+ size_t cpumaplen;
+ unsigned int pos;
+ int vcpu, i;
+ int ret = -1;
+
+ if (libxlDoNodeGetInfo(driver, &nodeinfo) < 0)
+ goto cleanup;
+
+ cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
+
+ for (vcpu = 0; vcpu < def->cputune.nvcpupin; ++vcpu) {
+ if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
+ continue;
+
+ if (VIR_ALLOC_N(cpumap, cpumaplen) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ cpumask = (uint8_t*) def->cputune.vcpupin[vcpu]->cpumask;
+
+ for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; ++i) {
+ if (cpumask[i]) {
+ pos = i / 8;
+ cpumap[pos] |= 1 << (i % 8);
+ }
+ }
+
+ map.size = cpumaplen;
+ map.map = cpumap;
+
+ if (libxl_set_vcpuaffinity(&priv->ctx, def->id, vcpu, &map) != 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to pin vcpu '%d' with libxenlight"), vcpu);
+ goto cleanup;
+ }
+
+ VIR_FREE(cpumap);
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cpumap);
+ return ret;
+}
+
/*
* Start a domain through libxenlight.
*
@@ -440,6 +547,9 @@ libxlVmStart(libxlDriverPrivatePtr driver,
if (libxlCreateDomEvents(vm) < 0)
goto error;
+ if (libxlDomainSetVcpuAffinites(driver, vm) < 0)
+ goto error;
+
if (!start_paused) {
libxl_domain_unpause(&priv->ctx, domid);
vm->state = VIR_DOMAIN_RUNNING;
@@ -756,7 +866,7 @@ libxlReload(void)
&libxl_driver->domains,
libxl_driver->configDir,
libxl_driver->autostartDir,
- 0, NULL, libxl_driver);
+ 1, NULL, libxl_driver);
virHashForEach(libxl_driver->domains.objs, libxlAutostartDomain,
libxl_driver);
@@ -869,42 +979,7 @@ libxlGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
static int
libxlNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
{
- libxl_physinfo phy_info;
- const libxl_version_info* ver_info;
- libxlDriverPrivatePtr driver = conn->privateData;
- struct utsname utsname;
-
- if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxl_get_physinfo_info failed"));
- return -1;
- }
-
- if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxl_get_version_info failed"));
- return -1;
- }
-
- uname(&utsname);
- if (virStrncpy(info->model,
- utsname.machine,
- strlen(utsname.machine),
- sizeof(info->model)) == NULL) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("machine type %s too big for destination"),
- utsname.machine);
- return -1;
- }
-
- info->memory = phy_info.total_pages * (ver_info->pagesize / 1024);
- info->cpus = phy_info.nr_cpus;
- info->nodes = phy_info.nr_nodes;
- info->cores = phy_info.cores_per_socket;
- info->threads = phy_info.threads_per_core;
- info->sockets = 1;
- info->mhz = phy_info.cpu_khz / 1000;
- return 0;
+ return libxlDoNodeGetInfo(conn->privateData, info);
}
static char *
@@ -1712,6 +1787,16 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
_("Failed to pin vcpu '%d' with libxenlight"), vcpu);
goto cleanup;
}
+
+ if (virDomainVcpupinAdd(vm->def, cpumap, maplen, vcpu) < 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("failed to update or add vcpupin xml"));
+ goto cleanup;
+ }
+
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
--
1.7.1
2
1
[libvirt] [PATCH] Update and sort msg_gen_function list and mark unmarked messages
by Matthias Bolte 18 Apr '11
by Matthias Bolte 18 Apr '11
18 Apr '11
Inspired by Eric Blake
---
cfg.mk | 45 ++++++++++++++++++++++++++++++++++-------
src/interface/netcf_driver.c | 43 ++++++++++++++++++---------------------
src/nodeinfo.c | 2 +-
src/phyp/phyp_driver.c | 18 ++++++++--------
src/util/stats_linux.c | 2 +-
5 files changed, 68 insertions(+), 42 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index e54d170..72dd69c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -380,47 +380,76 @@ sc_prohibit_xmlGetProp:
msg_gen_function =
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
-msg_gen_function += macvtapError
-msg_gen_function += remoteError
+msg_gen_function += PHYP_ERROR
+msg_gen_function += VIR_ERROR
+msg_gen_function += VIR_ERROR0
+msg_gen_function += VMX_ERROR
+msg_gen_function += XENXS_ERROR
+msg_gen_function += eventReportError
+msg_gen_function += ifaceError
+msg_gen_function += interfaceReportError
+msg_gen_function += iptablesError
msg_gen_function += lxcError
-msg_gen_function += networkLog
+msg_gen_function += libxlError
+msg_gen_function += macvtapError
msg_gen_function += networkReportError
-msg_gen_function += oneError
+msg_gen_function += nodeReportError
msg_gen_function += openvzError
+msg_gen_function += pciReportError
msg_gen_function += qemuReportError
msg_gen_function += qemudDispatchClientFailure
msg_gen_function += regerror
+msg_gen_function += remoteError
msg_gen_function += remoteDispatchFormatError
+msg_gen_function += statsError
+msg_gen_function += streamsReportError
+msg_gen_function += usbReportError
msg_gen_function += umlReportError
msg_gen_function += vah_error
msg_gen_function += vah_warning
msg_gen_function += vboxError
msg_gen_function += virCommandError
msg_gen_function += virConfError
+msg_gen_function += virCPUReportError
+msg_gen_function += virEventError
msg_gen_function += virDomainReportError
+msg_gen_function += virGenericReportError
msg_gen_function += virHashError
+msg_gen_function += virHookReportError
+msg_gen_function += virInterfaceReportError
+msg_gen_function += virJSONError
msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError
+msg_gen_function += virLibDomainSnapshotError
+msg_gen_function += virLibInterfaceError
+msg_gen_function += virLibNetworkError
+msg_gen_function += virLibNodeDeviceError
+msg_gen_function += virLibNWFilterError
+msg_gen_function += virLibSecretError
+msg_gen_function += virLibStoragePoolError
+msg_gen_function += virLibStorageVolError
msg_gen_function += virNetworkReportError
msg_gen_function += virNodeDeviceReportError
+msg_gen_function += virNWFilterReportError
msg_gen_function += virRaiseError
msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError
+msg_gen_function += virSecretReportError
msg_gen_function += virSecurityReportError
msg_gen_function += virSexprError
+msg_gen_function += virSmbiosReportError
+msg_gen_function += virSocketError
+msg_gen_function += virStatsError
msg_gen_function += virStorageReportError
+msg_gen_function += virUtilError
msg_gen_function += virXMLError
msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError
msg_gen_function += vmwareError
msg_gen_function += xenapiSessionErrorHandler
-msg_gen_function += libxlError
msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
-msg_gen_function += VIR_ERROR
-msg_gen_function += VIR_ERROR0
-msg_gen_function += statsError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index 0190bf4..709f09b 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -102,11 +102,12 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac
int errcode = ncf_error(ncf, &errmsg, &details);
if (errcode != NETCF_NOERROR) {
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface named '%s' (netcf: %s - %s)",
- ifinfo->name, errmsg, details ? details : "");
+ _("couldn't find interface named '%s' (netcf: %s - %s)"),
+ ifinfo->name, errmsg, details ? details : "");
} else {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface named '%s'", ifinfo->name);
+ _("couldn't find interface named '%s'"),
+ ifinfo->name);
}
}
return iface;
@@ -182,8 +183,7 @@ static int interfaceNumOfInterfaces(virConnectPtr conn)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to get number of interfaces on host"),
+ _("failed to get number of interfaces on host (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -203,8 +203,7 @@ static int interfaceListInterfaces(virConnectPtr conn, char **const names, int n
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to list host interfaces"),
+ _("failed to list host interfaces (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -224,8 +223,7 @@ static int interfaceNumOfDefinedInterfaces(virConnectPtr conn)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to get number of defined interfaces on host"),
+ _("failed to get number of defined interfaces on host (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -245,8 +243,7 @@ static int interfaceListDefinedInterfaces(virConnectPtr conn, char **const names
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "%s (netcf: %s - %s)",
- _("failed to list host defined interfaces"),
+ _("failed to list host defined interfaces (netcf: %s - %s)"),
errmsg, details ? details : "");
}
@@ -269,11 +266,11 @@ static virInterfacePtr interfaceLookupByName(virConnectPtr conn,
int errcode = ncf_error(driver->netcf, &errmsg, &details);
if (errcode != NETCF_NOERROR) {
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface named '%s' (netcf: %s - %s)",
+ _("couldn't find interface named '%s' (netcf: %s - %s)"),
name, errmsg, details ? details : "");
} else {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface named '%s'", name);
+ _("couldn't find interface named '%s'"), name);
}
goto cleanup;
}
@@ -301,13 +298,13 @@ static virInterfacePtr interfaceLookupByMACString(virConnectPtr conn,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "couldn't find interface with MAC address '%s' (netcf: %s - %s)",
+ _("couldn't find interface with MAC address '%s' (netcf: %s - %s)"),
macstr, errmsg, details ? details : "");
goto cleanup;
}
if (niface == 0) {
interfaceReportError(VIR_ERR_NO_INTERFACE,
- "couldn't find interface with MAC address '%s'",
+ _("couldn't find interface with MAC address '%s'"),
macstr);
goto cleanup;
}
@@ -351,8 +348,8 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "could not get interface XML description (netcf: %s - %s)",
- errmsg, details ? details : "");
+ _("could not get interface XML description (netcf: %s - %s)"),
+ errmsg, details ? details : "");
goto cleanup;
}
@@ -405,8 +402,8 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "could not get interface XML description (netcf: %s - %s)",
- errmsg, details ? details : "");
+ _("could not get interface XML description (netcf: %s - %s)"),
+ errmsg, details ? details : "");
goto cleanup;
}
@@ -438,7 +435,7 @@ static int interfaceUndefine(virInterfacePtr ifinfo) {
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to undefine interface %s (netcf: %s - %s)",
+ _("failed to undefine interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -469,7 +466,7 @@ static int interfaceCreate(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to create (start) interface %s (netcf: %s - %s)",
+ _("failed to create (start) interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -500,7 +497,7 @@ static int interfaceDestroy(virInterfacePtr ifinfo,
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to destroy (stop) interface %s (netcf: %s - %s)",
+ _("failed to destroy (stop) interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
@@ -530,7 +527,7 @@ static int interfaceIsActive(virInterfacePtr ifinfo)
const char *errmsg, *details;
int errcode = ncf_error(driver->netcf, &errmsg, &details);
interfaceReportError(netcf_to_vir_err(errcode),
- "failed to get status of interface %s (netcf: %s - %s)",
+ _("failed to get status of interface %s (netcf: %s - %s)"),
ifinfo->name, errmsg, details ? details : "");
goto cleanup;
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index facac15..e0221f0 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -239,7 +239,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
buf++;
if (*buf != ':' || !buf[1]) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
- "parsing cpuinfo cpu cores %c", *buf);
+ _("parsing cpuinfo cpu cores %c"), *buf);
return -1;
}
if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 8f8c3ba..c65824a 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3659,28 +3659,28 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!def->mem.cur_balloon) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<memory>\" on the domain XML file is missing or has "
- "invalid value."));
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <memory> on the domain XML file is missing or has "
+ "invalid value."));
goto cleanup;
}
if (!def->mem.max_balloon) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<currentMemory>\" on the domain XML file is missing or"
- " has invalid value."));
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <currentMemory> on the domain XML file is missing or "
+ "has invalid value."));
goto cleanup;
}
if (def->ndisks < 1) {
PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
- _("Domain XML must contain at least one \"<disk>\" element."));
+ _("Domain XML must contain at least one <disk> element."));
goto cleanup;
}
if (!def->disks[0]->src) {
- PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
- _("Field \"<src>\" under \"<disk>\" on the domain XML file is "
+ PHYP_ERROR(VIR_ERR_XML_ERROR, "%s",
+ _("Field <src> under <disk> on the domain XML file is "
"missing."));
goto cleanup;
}
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index 173cdc5..e728b7b 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -107,7 +107,7 @@ linuxDomainInterfaceStats(const char *path,
VIR_FORCE_FCLOSE(fp);
virStatsError(VIR_ERR_INTERNAL_ERROR,
- "/proc/net/dev: Interface not found");
+ _("/proc/net/dev: Interface not found"));
return -1;
}
--
1.7.0.4
2
2
Smaller code and fewer bugs. Rebase of earlier version at:
https://www.redhat.com/archives/libvir-list/2011-April/msg00677.html
Eric Blake (9):
maint: use lighter-weight function for straight appends
phyp: avoid a logic bug
phyp: avoid memory leak on failure
phyp: more return handling cleanup
phyp: use consistent style for labels
phyp: prefer memcpy over memmove when legal
phyp: use consistent return string handling
phyp: avoid memory leaks in command values
phyp: another simplification
src/conf/nwfilter_conf.c | 16 +-
src/phyp/phyp_driver.c | 1355 ++++++++---------------------------------
src/qemu/qemu_command.c | 30 +-
src/security/virt-aa-helper.c | 2 +-
src/util/sexpr.c | 4 +-
src/xen/xend_internal.c | 6 +-
src/xenxs/xen_sxpr.c | 2 +-
src/xenxs/xen_xm.c | 4 +-
8 files changed, 290 insertions(+), 1129 deletions(-)
--
1.7.4.2
2
25
So far first entries for each hash key are stored directly in the hash
table while other entries mapped to the same key are linked through
pointers. As a result of that, the code is cluttered with special
handling for the first items.
Commit 9677cd33eea4c65d78ba463b46b8b45ed2da1709 made it possible to
remove current entry when iterating through all hash entries. However,
it didn't add the special first item handling which could cause libvirtd
crash or hang.
Instead of adding more clutter, this patch fixes the crash by linking
all entries (even the first ones) through pointers which significantly
simplifies the code and makes it more maintainable.
---
src/util/hash.c | 290 ++++++++++++++++++-------------------------------------
1 files changed, 94 insertions(+), 196 deletions(-)
diff --git a/src/util/hash.c b/src/util/hash.c
index 48a94ad..dbb34ec 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -50,14 +50,13 @@ struct _virHashEntry {
struct _virHashEntry *next;
void *name;
void *payload;
- int valid;
};
/*
* The entire hash table
*/
struct _virHashTable {
- struct _virHashEntry *table;
+ virHashEntryPtr *table;
int size;
int nbElems;
/* True iff we are iterating over hash entries. */
@@ -165,7 +164,7 @@ virHashTablePtr virHashCreateFull(int size,
*
* Create a new virHashTablePtr.
*
- * Returns the newly created object, or NULL if an error occured.
+ * Returns the newly created object, or NULL if an error occurred.
*/
virHashTablePtr virHashCreate(int size, virHashDataFree dataFree)
{
@@ -189,10 +188,8 @@ virHashTablePtr virHashCreate(int size, virHashDataFree dataFree)
static int
virHashGrow(virHashTablePtr table, int size)
{
- unsigned long key;
int oldsize, i;
- virHashEntryPtr iter, next;
- struct _virHashEntry *oldtable;
+ virHashEntryPtr *oldtable;
#ifdef DEBUG_GROW
unsigned long nbElem = 0;
@@ -217,43 +214,18 @@ virHashGrow(virHashTablePtr table, int size)
}
table->size = size;
- /* If the two loops are merged, there would be situations where
- * a new entry needs to allocated and data copied into it from
- * the main table. So instead, we run through the array twice, first
- * copying all the elements in the main array (where we can't get
- * conflicts) and then the rest, so we only free (and don't allocate)
- */
- for (i = 0; i < oldsize; i++) {
- if (oldtable[i].valid == 0)
- continue;
- key = virHashComputeKey(table, oldtable[i].name);
- memcpy(&(table->table[key]), &(oldtable[i]), sizeof(virHashEntry));
- table->table[key].next = NULL;
- }
-
for (i = 0; i < oldsize; i++) {
- iter = oldtable[i].next;
+ virHashEntryPtr iter = oldtable[i];
while (iter) {
- next = iter->next;
+ virHashEntryPtr next = iter->next;
+ unsigned long key = virHashComputeKey(table, iter->name);
- /*
- * put back the entry in the new table
- */
-
- key = virHashComputeKey(table, iter->name);
- if (table->table[key].valid == 0) {
- memcpy(&(table->table[key]), iter, sizeof(virHashEntry));
- table->table[key].next = NULL;
- VIR_FREE(iter);
- } else {
- iter->next = table->table[key].next;
- table->table[key].next = iter;
- }
+ iter->next = table->table[key];
+ table->table[key] = iter;
#ifdef DEBUG_GROW
nbElem++;
#endif
-
iter = next;
}
}
@@ -279,36 +251,24 @@ void
virHashFree(virHashTablePtr table)
{
int i;
- virHashEntryPtr iter;
- virHashEntryPtr next;
- int inside_table = 0;
- int nbElems;
if (table == NULL)
return;
- if (table->table) {
- nbElems = table->nbElems;
- for (i = 0; (i < table->size) && (nbElems > 0); i++) {
- iter = &(table->table[i]);
- if (iter->valid == 0)
- continue;
- inside_table = 1;
- while (iter) {
- next = iter->next;
- if ((table->dataFree != NULL) && (iter->payload != NULL))
- table->dataFree(iter->payload, iter->name);
- if (table->keyFree)
- table->keyFree(iter->name);
- iter->payload = NULL;
- if (!inside_table)
- VIR_FREE(iter);
- nbElems--;
- inside_table = 0;
- iter = next;
- }
+
+ for (i = 0; i < table->size; i++) {
+ virHashEntryPtr iter = table->table[i];
+ while (iter) {
+ virHashEntryPtr next = iter->next;
+
+ if (table->dataFree)
+ table->dataFree(iter->payload, iter->name);
+ if (table->keyFree)
+ table->keyFree(iter->name);
+ VIR_FREE(iter);
+ iter = next;
}
- VIR_FREE(table->table);
}
+
VIR_FREE(table);
}
@@ -319,9 +279,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
{
unsigned long key, len = 0;
virHashEntryPtr entry;
- virHashEntryPtr insert;
char *new_name;
- bool found;
if ((table == NULL) || (name == NULL))
return (-1);
@@ -329,67 +287,40 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
if (table->iterating)
virHashIterationError(-1);
- /*
- * Check for duplicate and insertion location.
- */
- found = false;
key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0) {
- insert = NULL;
- } else {
- for (insert = &(table->table[key]); insert->next != NULL;
- insert = insert->next) {
- if (table->keyEqual(insert->name, name)) {
- found = true;
- break;
- }
- len++;
- }
- if (table->keyEqual(insert->name, name))
- found = true;
- }
-
- if (found) {
- if (is_update) {
- if (table->dataFree)
- table->dataFree(insert->payload, insert->name);
- insert->payload = userdata;
- return (0);
- } else {
- return (-1);
- }
- }
- if (insert == NULL) {
- entry = &(table->table[key]);
- } else {
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
- return (-1);
+ /* Check for duplicate entry */
+ for (entry = table->table[key]; entry; entry = entry->next) {
+ if (table->keyEqual(entry->name, name)) {
+ if (is_update) {
+ if (table->dataFree)
+ table->dataFree(entry->payload, entry->name);
+ entry->payload = userdata;
+ return 0;
+ } else {
+ return -1;
+ }
}
+ len++;
}
- new_name = table->keyCopy(name);
- if (new_name == NULL) {
+ if (VIR_ALLOC(entry) < 0 || !(new_name = table->keyCopy(name))) {
virReportOOMError();
- if (insert != NULL)
- VIR_FREE(entry);
- return (-1);
+ VIR_FREE(entry);
+ return -1;
}
+
entry->name = new_name;
entry->payload = userdata;
- entry->next = NULL;
- entry->valid = 1;
-
- if (insert != NULL)
- insert->next = entry;
+ entry->next = table->table[key];
+ table->table[key] = entry;
table->nbElems++;
if (len > MAX_HASH_LEN)
virHashGrow(table, MAX_HASH_LEN * table->size);
- return (0);
+ return 0;
}
/**
@@ -443,18 +374,15 @@ virHashLookup(virHashTablePtr table, const void *name)
unsigned long key;
virHashEntryPtr entry;
- if (table == NULL)
- return (NULL);
- if (name == NULL)
- return (NULL);
+ if (!table || !name)
+ return NULL;
+
key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0)
- return (NULL);
- for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
+ for (entry = table->table[key]; entry; entry = entry->next) {
if (table->keyEqual(entry->name, name))
- return (entry->payload);
+ return entry->payload;
}
- return (NULL);
+ return NULL;
}
@@ -512,47 +440,31 @@ virHashSize(virHashTablePtr table)
int
virHashRemoveEntry(virHashTablePtr table, const void *name)
{
- unsigned long key;
virHashEntryPtr entry;
- virHashEntryPtr prev = NULL;
+ virHashEntryPtr *nextptr;
if (table == NULL || name == NULL)
return (-1);
- key = virHashComputeKey(table, name);
- if (table->table[key].valid == 0) {
- return (-1);
- } else {
- for (entry = &(table->table[key]); entry != NULL;
- entry = entry->next) {
- if (table->keyEqual(entry->name, name)) {
- if (table->iterating && table->current != entry)
- virHashIterationError(-1);
- if (table->dataFree && (entry->payload != NULL))
- table->dataFree(entry->payload, entry->name);
- entry->payload = NULL;
- if (table->keyFree)
- table->keyFree(entry->name);
- if (prev) {
- prev->next = entry->next;
- VIR_FREE(entry);
- } else {
- if (entry->next == NULL) {
- entry->valid = 0;
- } else {
- entry = entry->next;
- memcpy(&(table->table[key]), entry,
- sizeof(virHashEntry));
- VIR_FREE(entry);
- }
- }
- table->nbElems--;
- return (0);
- }
- prev = entry;
+ nextptr = table->table + virHashComputeKey(table, name);
+ for (entry = *nextptr; entry; entry = entry->next) {
+ if (table->keyEqual(entry->name, name)) {
+ if (table->iterating && table->current != entry)
+ virHashIterationError(-1);
+
+ if (table->dataFree)
+ table->dataFree(entry->payload, entry->name);
+ if (table->keyFree)
+ table->keyFree(entry->name);
+ *nextptr = entry->next;
+ VIR_FREE(entry);
+ table->nbElems--;
+ return 0;
}
- return (-1);
+ nextptr = &entry->next;
}
+
+ return -1;
}
@@ -581,15 +493,15 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr entry = table->table + i;
+ virHashEntryPtr entry = table->table[i];
while (entry) {
virHashEntryPtr next = entry->next;
- if (entry->valid) {
- table->current = entry;
- iter(entry->payload, entry->name, data);
- table->current = NULL;
- count++;
- }
+
+ table->current = entry;
+ iter(entry->payload, entry->name, data);
+ table->current = NULL;
+
+ count++;
entry = next;
}
}
@@ -612,7 +524,10 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
*
* Returns number of items removed on success, -1 on failure
*/
-int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *data) {
+int virHashRemoveSet(virHashTablePtr table,
+ virHashSearcher iter,
+ const void *data)
+{
int i, count = 0;
if (table == NULL || iter == NULL)
@@ -624,44 +539,27 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr prev = NULL;
- virHashEntryPtr entry = &(table->table[i]);
+ virHashEntryPtr *nextptr = table->table + i;
- while (entry && entry->valid) {
- if (iter(entry->payload, entry->name, data)) {
+ while (*nextptr) {
+ virHashEntryPtr entry = *nextptr;
+ if (!iter(entry->payload, entry->name, data)) {
+ *nextptr = entry->next;
+ } else {
count++;
if (table->dataFree)
table->dataFree(entry->payload, entry->name);
if (table->keyFree)
table->keyFree(entry->name);
+ *nextptr = entry->next;
+ VIR_FREE(entry);
table->nbElems--;
- if (prev) {
- prev->next = entry->next;
- VIR_FREE(entry);
- entry = prev;
- } else {
- if (entry->next == NULL) {
- entry->valid = 0;
- entry->name = NULL;
- } else {
- entry = entry->next;
- memcpy(&(table->table[i]), entry,
- sizeof(virHashEntry));
- VIR_FREE(entry);
- entry = &(table->table[i]);
- continue;
- }
- }
- }
- prev = entry;
- if (entry) {
- entry = entry->next;
}
}
}
table->iterating = false;
- return (count);
+ return count;
}
/**
@@ -675,7 +573,10 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
* returns non-zero will be returned by this function.
* The elements are processed in a undefined order
*/
-void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *data) {
+void *virHashSearch(virHashTablePtr table,
+ virHashSearcher iter,
+ const void *data)
+{
int i;
if (table == NULL || iter == NULL)
@@ -687,18 +588,15 @@ void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *dat
table->iterating = true;
table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
- virHashEntryPtr entry = table->table + i;
- while (entry) {
- if (entry->valid) {
- if (iter(entry->payload, entry->name, data)) {
- table->iterating = false;
- return entry->payload;
- }
+ virHashEntryPtr entry;
+ for (entry = table->table[i]; entry; entry = entry->next) {
+ if (iter(entry->payload, entry->name, data)) {
+ table->iterating = false;
+ return entry->payload;
}
- entry = entry->next;
}
}
table->iterating = false;
- return (NULL);
+ return NULL;
}
--
1.7.5.rc1
3
8
What's a good way to ask if a libvirt connection is remote or not?
(Fundamentally I want to know if the disk images are openable as local
files, and I'm using "remote" as an proxy for this property.)
One way might be to compare virConnectGetHostname with the local
hostname. This would fail if the client and server had the hostname
set incorrectly (eg. "localhost.localdomain").
Another way might be some hairy libvirt URL parsing.
Another way would be to speculatively open the disk images. This
would fail if the client and server had guests with coincidentally
named disk images.
Or I could write a qemu block driver that could use
virDomainBlockPeek.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
2
1
[libvirt] [PATCH] Merge all returns paths from dispatcher into single path
by Daniel P. Berrange 18 Apr '11
by Daniel P. Berrange 18 Apr '11
18 Apr '11
The dispatcher functions have numerous places where they
return to the caller. This leads to duplicated cleanup
code, often resulting in memory leaks. It makes it harder
to ensure that errors are dispatched before freeing objects,
which may overwrite the original error.
The standard pattern is now
remoteDispatchXXX(...) {
int rv = -1;
....
if (XXX < 0)
goto cleanup;
...
if (XXXX < 0)
goto cleanup;
...
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
...free all other stuff..
return rv;
}
* daemon/remote.c: Centralize all cleanup paths
* daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
* daemon/dispatch.c, daemon/dispatch.h: Replace
remoteDispatchConnError with remoteDispatchError
removing unused virConnectPtr
NB this was a tedious manual conversion of the code, so it
has potential for errors....
---
daemon/dispatch.c | 3 +-
daemon/dispatch.h | 3 +-
daemon/remote.c | 4862 ++++++++++++++++++++++++++++++++---------------------
daemon/stream.c | 6 +-
4 files changed, 2912 insertions(+), 1962 deletions(-)
diff --git a/daemon/dispatch.c b/daemon/dispatch.c
index 4814017..7453451 100644
--- a/daemon/dispatch.c
+++ b/daemon/dispatch.c
@@ -112,8 +112,7 @@ void remoteDispatchOOMError (remote_error *rerr)
}
-void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn ATTRIBUTE_UNUSED)
+void remoteDispatchError(remote_error *rerr)
{
virErrorPtr verr = virGetLastError();
diff --git a/daemon/dispatch.h b/daemon/dispatch.h
index 85f8fc3..79d35ac 100644
--- a/daemon/dispatch.h
+++ b/daemon/dispatch.h
@@ -46,8 +46,7 @@ void remoteDispatchFormatError (remote_error *rerr,
void remoteDispatchAuthError (remote_error *rerr);
void remoteDispatchGenericError (remote_error *rerr);
void remoteDispatchOOMError (remote_error *rerr);
-void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn);
+void remoteDispatchError(remote_error *rerr);
int
diff --git a/daemon/remote.c b/daemon/remote.c
index 5de1055..8f4d6a6 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -64,6 +64,10 @@
#define VIR_FROM_THIS VIR_FROM_REMOTE
+#define virNetError(code, ...) \
+ virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
+
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
static virInterfacePtr get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface);
@@ -398,18 +402,18 @@ remoteDispatchOpen(struct qemud_server *server,
struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
{
const char *name;
- int flags, rc;
-
- /* Already opened? */
- if (conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection already open"));
- return -1;
- }
+ int flags;
+ int rv = -1;
virMutexLock(&server->lock);
virMutexLock(&client->lock);
virMutexUnlock(&server->lock);
+ if (conn) {
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection already open"));
+ goto cleanup;
+ }
+
name = args->name ? *args->name : NULL;
/* If this connection arrived on a readonly socket, force
@@ -423,12 +427,17 @@ remoteDispatchOpen(struct qemud_server *server,
? virConnectOpenReadOnly(name)
: virConnectOpen(name);
- if (client->conn == NULL)
- remoteDispatchConnError(rerr, NULL);
+ if (client->conn == NULL) {
+ goto cleanup;
+ }
+
+ rv = 0;
- rc = client->conn ? 0 : -1;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
virMutexUnlock(&client->lock);
- return rc;
+ return rv;
}
@@ -458,20 +467,25 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_error *rerr,
remote_supports_feature_args *args, remote_supports_feature_ret *ret)
{
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->supported = virDrvSupportsFeature(conn, args->feature);
if (ret->supported == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -483,16 +497,16 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
{
const char *type;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
type = virConnectGetType(conn);
if (type == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* We have to strdup because remoteDispatchClientRequest will
@@ -500,11 +514,16 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->type = strdup(type);
if (!ret->type) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -517,19 +536,24 @@ remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_version_ret *ret)
{
unsigned long hvVer;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virConnectGetVersion(conn, &hvVer) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->hv_ver = hvVer;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -542,19 +566,24 @@ remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_lib_version_ret *ret)
{
unsigned long libVer;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virConnectGetLibVersion(conn, &libVer) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->lib_ver = libVer;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -567,20 +596,25 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_hostname_ret *ret)
{
char *hostname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
hostname = virConnectGetHostname(conn);
if (hostname == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->hostname = hostname;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -593,20 +627,25 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_uri_ret *ret)
{
char *uri;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri = virConnectGetURI(conn);
if (uri == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->uri = uri;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -620,21 +659,26 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
{
unsigned int flags;
char *sysinfo;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
flags = args->flags;
sysinfo = virConnectGetSysinfo(conn, flags);
if (sysinfo == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->sysinfo = sysinfo;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -647,20 +691,25 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_max_vcpus_ret *ret)
{
char *type;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
type = args->type ? *args->type : NULL;
ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
if (ret->max_vcpus == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -673,15 +722,15 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_info_ret *ret)
{
virNodeInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virNodeGetInfo(conn, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
memcpy(ret->model, info.model, sizeof ret->model);
@@ -693,7 +742,12 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->cores = info.cores;
ret->threads = info.threads;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -706,20 +760,25 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_capabilities_ret *ret)
{
char *caps;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
caps = virConnectGetCapabilities(conn);
if (caps == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->capabilities = caps;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -732,22 +791,23 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_get_cells_free_memory_ret *ret)
{
int err;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->freeMems.freeMems_val, args->maxCells) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
err = virNodeGetCellsFreeMemory(conn,
@@ -755,13 +815,18 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
args->startCell,
args->maxCells);
if (err <= 0) {
- VIR_FREE(ret->freeMems.freeMems_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->freeMems.freeMems_len = err;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->freeMems.freeMems_val);
+ }
+ return rv;
}
@@ -775,19 +840,24 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_free_memory_ret *ret)
{
unsigned long long freeMem;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
freeMem = virNodeGetFreeMemory(conn);
if (freeMem == 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->freeMem = freeMem;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -800,32 +870,36 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_scheduler_type_args *args,
remote_domain_get_scheduler_type_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *type;
int nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
type = virDomainGetSchedulerType(dom, &nparams);
if (type == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->type = type;
ret->nparams = nparams;
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -837,51 +911,47 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_get_scheduler_parameters_args *args,
remote_domain_get_scheduler_parameters_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virSchedParameterPtr params;
int i, r, nparams;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetSchedulerParameters(dom, params, &nparams);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* Serialise the scheduler parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -898,23 +968,27 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
ret->params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- virDomainFree(dom);
- VIR_FREE(params);
- return 0;
+ rv = 0;
-oom:
- remoteDispatchOOMError(rerr);
cleanup:
- virDomainFree(dom);
- for (i = 0 ; i < nparams ; i++)
- VIR_FREE(ret->params.params_val[i].field);
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0 ; i < nparams ; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -926,32 +1000,33 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
remote_domain_set_scheduler_parameters_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virSchedParameterPtr params;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr, _("Field %s too big for destination"),
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
args->params.params_val[i].field);
- return -1;
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -972,21 +1047,23 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetSchedulerParameters(dom, params, nparams);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(params);
+ return rv;
}
static int
@@ -998,28 +1075,25 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_block_stats_args *args,
remote_domain_block_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
struct _virDomainBlockStats stats;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
if (virDomainBlockStats(dom, path, &stats, sizeof stats) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
ret->rd_req = stats.rd_req;
ret->rd_bytes = stats.rd_bytes;
@@ -1027,7 +1101,14 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->wr_bytes = stats.wr_bytes;
ret->errs = stats.errs;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1039,28 +1120,25 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_interface_stats_args *args,
remote_domain_interface_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
struct _virDomainInterfaceStats stats;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
ret->rx_bytes = stats.rx_bytes;
ret->rx_packets = stats.rx_packets;
@@ -1071,7 +1149,14 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->tx_errs = stats.tx_errs;
ret->tx_drop = stats.tx_drop;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1083,48 +1168,42 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_memory_stats_args *args,
remote_domain_memory_stats_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
struct _virDomainMemoryStat *stats;
unsigned int nr_stats, i;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate stats array for making dispatch call */
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
if (nr_stats == -1) {
- VIR_FREE(stats);
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
/* Allocate return buffer */
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
- VIR_FREE(stats);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Copy the stats into the xdr return structure */
@@ -1133,8 +1212,15 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->stats.stats_val[i].val = stats[i].val;
}
ret->stats.stats_len = nr_stats;
- VIR_FREE(stats);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(stats);
+ return rv;
}
static int
@@ -1146,21 +1232,21 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_block_peek_args *args,
remote_domain_block_peek_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *path;
unsigned long long offset;
size_t size;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
path = args->path;
offset = args->offset;
@@ -1168,29 +1254,32 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags;
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr,
- "%s", _("size > maximum buffer size"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("size > maximum buffer size"));
+ goto cleanup;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainBlockPeek(dom, path, offset, size,
ret->buffer.buffer_val, flags) == -1) {
- /* free(ret->buffer.buffer_val); - caller frees */
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->buffer.buffer_val);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1202,49 +1291,54 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_memory_peek_args *args,
remote_domain_memory_peek_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
unsigned long long offset;
size_t size;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
offset = args->offset;
size = args->size;
flags = args->flags;
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr,
- "%s", _("size > maximum buffer size"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("size > maximum buffer size"));
+ goto cleanup;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainMemoryPeek(dom, offset, size,
ret->buffer.buffer_val, flags) == -1) {
- /* free(ret->buffer.buffer_val); - caller frees */
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ if (dom)
+ virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->buffer.buffer_val);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1256,26 +1350,31 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_attach_device_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAttachDevice(dom, args->xml) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1287,26 +1386,31 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_attach_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1318,26 +1422,31 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_update_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1349,26 +1458,31 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCreate(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1380,23 +1494,28 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_create_with_flags_args *args,
remote_domain_create_with_flags_ret *ret)
{
- virDomainPtr dom;
+ int rv = -1;
+ virDomainPtr dom = NULL;
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCreateWithFlags(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1408,23 +1527,29 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_create_xml_args *args,
remote_domain_create_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1436,23 +1561,29 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_define_xml_args *args,
remote_domain_define_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainDefineXML(conn, args->xml);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1464,26 +1595,31 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDestroy(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1495,27 +1631,31 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_detach_device_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDetachDevice(dom, args->xml) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1527,27 +1667,31 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_detach_device_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1559,28 +1703,33 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_dump_xml_args *args,
remote_domain_dump_xml_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virDomainGetXMLDesc(dom, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1592,9 +1741,11 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_from_native_args *args,
remote_domain_xml_from_native_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
@@ -1603,10 +1754,14 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->nativeConfig,
args->flags);
if (!ret->domainXml) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -1618,9 +1773,11 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_to_native_args *args,
remote_domain_xml_to_native_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
@@ -1629,10 +1786,14 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->domainXml,
args->flags);
if (!ret->nativeConfig) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -1645,26 +1806,31 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_autostart_args *args,
remote_domain_get_autostart_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetAutostart(dom, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1676,24 +1842,22 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_info_args *args,
remote_domain_get_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetInfo(dom, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->state = info.state;
@@ -1702,9 +1866,14 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->nr_virt_cpu = info.nrVirtCpu;
ret->cpu_time = info.cpuTime;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1716,27 +1885,32 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_max_memory_args *args,
remote_domain_get_max_memory_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->memory = virDomainGetMaxMemory(dom);
if (ret->memory == 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1748,27 +1922,32 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_max_vcpus_args *args,
remote_domain_get_max_vcpus_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainGetMaxVcpus(dom);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1780,46 +1959,46 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_get_security_label_args *args,
remote_domain_get_security_label_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virSecurityLabelPtr seclabel;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (VIR_ALLOC(seclabel) < 0) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return -1;
+ goto cleanup;
}
ret->label.label_len = strlen(seclabel->label) + 1;
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
- virDomainFree(dom);
- VIR_FREE(seclabel);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->label.label_val, seclabel->label);
ret->enforcing = seclabel->enforcing;
- virDomainFree(dom);
- VIR_FREE(seclabel);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ VIR_FREE(seclabel);
+ return rv;
}
static int
@@ -1832,33 +2011,38 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_security_model_ret *ret)
{
virSecurityModel secmodel;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
memset(&secmodel, 0, sizeof secmodel);
if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->model.model_len = strlen(secmodel.model) + 1;
if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->model.model_val, secmodel.model);
ret->doi.doi_len = strlen(secmodel.doi) + 1;
if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
strcpy(ret->doi.doi_val, secmodel.doi);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -1870,28 +2054,32 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_os_type_args *args,
remote_domain_get_os_type_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this */
ret->type = virDomainGetOSType(dom);
if (ret->type == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -1907,52 +2095,46 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
virVcpuInfoPtr info = NULL;
unsigned char *cpumaps = NULL;
int info_len, i;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
+ goto cleanup;
}
if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+ goto cleanup;
}
/* Allocate buffers to take the results. */
if (VIR_ALLOC_N(info, args->maxinfo) < 0)
- goto oom;
+ goto no_memory;
if (args->maplen > 0 &&
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
- goto oom;
+ goto no_memory;
info_len = virDomainGetVcpus(dom,
info, args->maxinfo,
cpumaps, args->maplen);
if (info_len == -1) {
- remoteDispatchConnError(rerr, conn);
- VIR_FREE(info);
- VIR_FREE(cpumaps);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
/* Allocate the return buffer for info. */
ret->info.info_len = info_len;
if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < info_len; ++i) {
ret->info.info_val[i].number = info[i].number;
@@ -1967,17 +2149,24 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
ret->cpumaps.cpumaps_val = (char *) cpumaps;
+ cpumaps = NULL;
+
+ rv = 0;
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->info.info_val);
+ }
+ VIR_FREE(cpumaps);
VIR_FREE(info);
- virDomainFree(dom);
- return 0;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
-oom:
- VIR_FREE(info);
- VIR_FREE(cpumaps);
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -1989,27 +2178,32 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_vcpus_flags_args *args,
remote_domain_get_vcpus_flags_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainGetVcpusFlags(dom, args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2027,10 +2221,11 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
char *uri_in;
char **uri_out;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
@@ -2038,17 +2233,15 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource);
if (r == -1) {
- VIR_FREE(uri_out);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2058,12 +2251,18 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->cookie.cookie_val = cookie;
if (*uri_out == NULL) {
ret->uri_out = NULL;
- VIR_FREE(uri_out);
} else {
ret->uri_out = uri_out;
+ uri_out = NULL;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(uri_out);
+ return rv;
}
static int
@@ -2076,18 +2275,18 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
int r;
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2098,13 +2297,17 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags, dname, args->resource);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2116,11 +2319,12 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish_args *args,
remote_domain_migrate_finish_ret *ret)
{
- virDomainPtr ddom;
+ virDomainPtr ddom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ddom = virDomainMigrateFinish(conn, args->dname,
@@ -2129,13 +2333,18 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags);
if (ddom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->ddom, ddom);
- virDomainFree(ddom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (ddom)
+ virDomainFree(ddom);
+ return rv;
}
static int
@@ -2153,10 +2362,11 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
char *uri_in;
char **uri_out;
char *dname;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
@@ -2164,8 +2374,8 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
/* Wacky world of XDR ... */
if (VIR_ALLOC(uri_out) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
@@ -2173,8 +2383,7 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2184,7 +2393,12 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
ret->cookie.cookie_val = cookie;
ret->uri_out = *uri_out == NULL ? NULL : uri_out;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2196,11 +2410,12 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish2_args *args,
remote_domain_migrate_finish2_ret *ret)
{
- virDomainPtr ddom;
+ virDomainPtr ddom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ddom = virDomainMigrateFinish2(conn, args->dname,
@@ -2210,14 +2425,19 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
args->flags,
args->retcode);
if (ddom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->ddom, ddom);
- virDomainFree(ddom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (ddom)
+ virDomainFree(ddom);
+ return rv;
}
static int
@@ -2231,38 +2451,44 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
{
int r;
char *dname;
- struct qemud_client_stream *stream;
+ struct qemud_client_stream *stream = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dname = args->dname == NULL ? NULL : *args->dname;
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainMigratePrepareTunnel(conn, stream->st,
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
if (remoteAddClientStream(client, stream, 0) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ if (stream) {
+ virStreamAbort(stream->st);
+ remoteFreeClientStream(client, stream);
+ }
+ }
+ return rv;
}
static int
@@ -2274,33 +2500,40 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_domains_args *args,
remote_list_defined_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedDomains(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -2312,22 +2545,29 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_id_args *args,
remote_domain_lookup_by_id_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByID(conn, args->id);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2339,22 +2579,29 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_name_args *args,
remote_domain_lookup_by_name_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByName(conn, args->name);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2366,22 +2613,29 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_lookup_by_uuid_args *args,
remote_domain_lookup_by_uuid_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_domain(&ret->dom, dom);
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2393,18 +2647,24 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedDomains(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2416,36 +2676,39 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_pin_vcpu_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
- int rv;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
- virDomainFree(dom);
- remoteDispatchFormatError(rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
+ goto cleanup;
}
rv = virDomainPinVcpu(dom, args->vcpu,
(unsigned char *) args->cpumap.cpumap_val,
args->cpumap.cpumap_len);
if (rv == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2457,26 +2720,31 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_reboot_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainReboot(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2488,17 +2756,23 @@ remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_restore_args *args,
void *ret ATTRIBUTE_UNUSED)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (virDomainRestore(conn, args->from) == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -2510,26 +2784,31 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_resume_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainResume(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2541,26 +2820,31 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_save_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSave(dom, args->to) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2572,26 +2856,31 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_core_dump_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainCoreDump(dom, args->to, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2603,26 +2892,31 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetAutostart(dom, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2634,26 +2928,31 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_max_memory_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMaxMemory(dom, args->memory) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2665,26 +2964,31 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_memory_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMemory(dom, args->memory) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2696,26 +3000,31 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_memory_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetMemoryFlags(dom, args->memory, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2730,37 +3039,37 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
remote_domain_set_memory_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virMemoryParameterPtr params;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -2799,21 +3108,23 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(params);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -2830,41 +3141,37 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
remote_domain_get_memory_parameters_ret
* ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virMemoryParameterPtr params;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -2877,13 +3184,13 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
/* Serialise the memory parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -2918,25 +3225,27 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
params[i].value.b;
break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- success:
- virDomainFree(dom);
- VIR_FREE(params);
-
- return 0;
+success:
+ rv = 0;
- oom:
- remoteDispatchOOMError(rerr);
- cleanup:
- virDomainFree(dom);
- for (i = 0; i < nparams; i++)
- VIR_FREE(ret->params.params_val[i].field);
+no_memory:
+ virReportOOMError();
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
+ if (dom)
+ virDomainFree(dom);
VIR_FREE(params);
- return -1;
+ return rv;
}
static int
@@ -2951,37 +3260,37 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
remote_domain_set_blkio_parameters_args
* args, void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
int i, r, nparams;
virBlkioParameterPtr params;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->params.params_len;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
/* Deserialise parameters. */
for (i = 0; i < nparams; ++i) {
if (virStrcpyStatic
(params[i].field, args->params.params_val[i].field) == NULL) {
- remoteDispatchFormatError(rerr,
- _
- ("Field %s too big for destination"),
- args->params.params_val[i].field);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("Field %s too big for destination"),
+ args->params.params_val[i].field);
+ goto cleanup;
}
params[i].type = args->params.params_val[i].value.type;
switch (params[i].type) {
@@ -3020,21 +3329,23 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- VIR_FREE(params);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ VIR_FREE(params);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3051,41 +3362,37 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
remote_domain_get_blkio_parameters_ret
* ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virBlkioParameterPtr params;
int i, r, nparams;
unsigned int flags;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nparams = args->nparams;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
- remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+ goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- VIR_FREE(params);
- return -1;
+ goto cleanup;
}
/* In this case, we need to send back the number of parameters
* supported
@@ -3098,13 +3405,13 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
/* Serialise the blkio parameters. */
ret->params.params_len = nparams;
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
- goto oom;
+ goto no_memory;
for (i = 0; i < nparams; ++i) {
// remoteDispatchClientRequest will free this:
ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
- goto oom;
+ goto no_memory;
ret->params.params_val[i].value.type = params[i].type;
switch (params[i].type) {
@@ -3139,25 +3446,29 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
params[i].value.b;
break;
default:
- remoteDispatchFormatError(rerr, "%s", _("unknown type"));
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
goto cleanup;
}
}
- success:
- virDomainFree(dom);
- VIR_FREE(params);
-
- return 0;
+success:
+ rv = 0;
- oom:
- remoteDispatchOOMError(rerr);
- cleanup:
- virDomainFree(dom);
- for (i = 0; i < nparams; i++)
- VIR_FREE(ret->params.params_val[i].field);
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ for (i = 0; i < nparams; i++)
+ VIR_FREE(ret->params.params_val[i].field);
+ VIR_FREE(ret->params.params_val);
+ }
VIR_FREE(params);
- return -1;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
static int
@@ -3169,26 +3480,31 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_vcpus_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetVcpus(dom, args->nvcpus) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3200,26 +3516,31 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_set_vcpus_flags_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3231,26 +3552,31 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_shutdown_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainShutdown(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3262,26 +3588,31 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_suspend_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainSuspend(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3293,26 +3624,31 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainUndefine(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3324,33 +3660,40 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_networks_args *args,
remote_list_defined_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedNetworks(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -3362,32 +3705,39 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_domains_args *args,
remote_list_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->ids.ids_val, args->maxids) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->ids.ids_len = virConnectListDomains(conn,
ret->ids.ids_val, args->maxids);
if (ret->ids.ids_len == -1) {
- VIR_FREE(ret->ids.ids_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->ids.ids_val);
+ }
+ return rv;
}
static int
@@ -3399,26 +3749,31 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_managed_save_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainManagedSave(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3430,27 +3785,32 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
remote_domain_has_managed_save_image_args *args,
remote_domain_has_managed_save_image_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
if (ret->ret == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3462,26 +3822,31 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_managed_save_remove_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainManagedSaveRemove(dom, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -3493,33 +3858,40 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_networks_args *args,
remote_list_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListNetworks(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -3531,26 +3903,31 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkCreate(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3562,22 +3939,29 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_create_xml_args *args,
remote_network_create_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkCreateXML(conn, args->xml);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3589,22 +3973,29 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_define_xml_args *args,
remote_network_define_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkDefineXML(conn, args->xml);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3616,26 +4007,31 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkDestroy(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3647,28 +4043,33 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_dump_xml_args *args,
remote_network_dump_xml_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNetworkGetXMLDesc(net, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3680,26 +4081,31 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_get_autostart_args *args,
remote_network_get_autostart_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkGetAutostart(net, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3711,28 +4117,33 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_get_bridge_name_args *args,
remote_network_get_bridge_name_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->name = virNetworkGetBridgeName(net);
if (!ret->name) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3744,22 +4155,29 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_lookup_by_name_args *args,
remote_network_lookup_by_name_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkLookupByName(conn, args->name);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3771,22 +4189,29 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_lookup_by_uuid_args *args,
remote_network_lookup_by_uuid_ret *ret)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_network(&ret->net, net);
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3798,26 +4223,31 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkSetAutostart(net, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3829,26 +4259,31 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_network_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNetworkPtr net;
+ virNetworkPtr net = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNetworkUndefine(net) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(net);
- return -1;
+ goto cleanup;
}
- virNetworkFree(net);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (net)
+ virNetworkFree(net);
+ return rv;
}
static int
@@ -3860,18 +4295,24 @@ remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedNetworks(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3883,18 +4324,24 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_domains_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDomains(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3906,18 +4353,24 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_networks_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfNetworks(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -3931,18 +4384,24 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfInterfaces(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -3954,33 +4413,40 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_interfaces_args *args,
remote_list_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListInterfaces(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -3992,18 +4458,24 @@ remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedInterfaces(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -4015,33 +4487,40 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
remote_list_defined_interfaces_args *args,
remote_list_defined_interfaces_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedInterfaces(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
static int
@@ -4053,22 +4532,29 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
remote_interface_lookup_by_name_args *args,
remote_interface_lookup_by_name_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceLookupByName(conn, args->name);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4080,22 +4566,29 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
remote_interface_lookup_by_mac_string_args *args,
remote_interface_lookup_by_mac_string_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceLookupByMACString(conn, args->mac);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4107,28 +4600,33 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_get_xml_desc_args *args,
remote_interface_get_xml_desc_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4140,22 +4638,29 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_define_xml_args *args,
remote_interface_define_xml_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = virInterfaceDefineXML(conn, args->xml, args->flags);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_interface(&ret->iface, iface);
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4167,26 +4672,31 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceUndefine(iface) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4198,26 +4708,31 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceCreate(iface, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int
@@ -4229,26 +4744,31 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_interface_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virInterfaceDestroy(iface, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
/*-------------------------------------------------------------*/
@@ -4262,10 +4782,12 @@ remoteDispatchAuthList(struct qemud_server *server,
void *args ATTRIBUTE_UNUSED,
remote_auth_list_ret *ret)
{
+ int rv = -1;
+
ret->types.types_len = 1;
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
virMutexLock(&server->lock);
virMutexLock(&client->lock);
@@ -4273,7 +4795,12 @@ remoteDispatchAuthList(struct qemud_server *server,
ret->types.types_val[0] = client->auth;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -4287,7 +4814,7 @@ remoteDispatchAuthList(struct qemud_server *server,
static int
remoteDispatchAuthSaslInit(struct qemud_server *server,
struct qemud_client *client,
- virConnectPtr conn,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
remote_message_header *hdr ATTRIBUTE_UNUSED,
remote_error *rerr,
void *args ATTRIBUTE_UNUSED,
@@ -4314,13 +4841,12 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
sa.len = sizeof(sa.data.stor);
if (getsockname(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr,
- _("failed to get sock address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to get sock address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4328,14 +4854,13 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
sa.len = sizeof(sa.data.stor);
if (getpeername(client->fd, &sa.data.sa, &sa.len) < 0) {
char ebuf[1024];
- remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("failed to get peer address: %s"),
+ virStrerror(errno, ebuf, sizeof ebuf));
VIR_FREE(localAddr);
goto error;
}
if ((remoteAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
VIR_FREE(localAddr);
- remoteDispatchConnError(rerr, conn);
goto error;
}
@@ -4439,7 +4964,7 @@ authfail:
error:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
virMutexUnlock(&client->lock);
- return -1;
+ goto error;
}
@@ -4600,7 +5125,7 @@ remoteDispatchAuthSaslStart(struct qemud_server *server,
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4701,7 +5226,7 @@ remoteDispatchAuthSaslStep(struct qemud_server *server,
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (serverout) {
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
- remoteDispatchOOMError(rerr);
+ virReportOOMError();
goto error;
}
memcpy(ret->data.data_val, serverout, serveroutlen);
@@ -4878,7 +5403,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
client->auth = REMOTE_AUTH_NONE;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
authfail:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
@@ -5010,7 +5535,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
client->auth = REMOTE_AUTH_NONE;
virMutexUnlock(&client->lock);
- return 0;
+ rv = 0;
authfail:
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
@@ -5059,33 +5584,40 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
remote_list_defined_storage_pools_args *args,
remote_list_defined_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListDefinedStoragePools(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -5097,33 +5629,40 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_storage_pools_args *args,
remote_list_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListStoragePools(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
static int
@@ -5135,9 +5674,11 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
remote_find_storage_pool_sources_args *args,
remote_find_storage_pool_sources_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->xml =
@@ -5146,11 +5687,15 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
args->srcSpec ? *args->srcSpec : NULL,
args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -5163,26 +5708,31 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolCreate(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5194,22 +5744,29 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_create_xml_args *args,
remote_storage_pool_create_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5221,22 +5778,29 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_define_xml_args *args,
remote_storage_pool_define_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5248,26 +5812,31 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_build_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolBuild(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5280,26 +5849,31 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolDestroy(pool) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5311,26 +5885,31 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolDelete(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5342,26 +5921,31 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_refresh_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolRefresh(pool, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5373,24 +5957,22 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_get_info_args *args,
remote_storage_pool_get_info_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
virStoragePoolInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolGetInfo(pool, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
ret->state = info.state;
@@ -5398,9 +5980,14 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->allocation = info.allocation;
ret->available = info.available;
- virStoragePoolFree(pool);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5412,28 +5999,33 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_dump_xml_args *args,
remote_storage_pool_dump_xml_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5445,26 +6037,31 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_get_autostart_args *args,
remote_storage_pool_get_autostart_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolGetAutostart(pool, &ret->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5477,22 +6074,29 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_lookup_by_name_args *args,
remote_storage_pool_lookup_by_name_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolLookupByName(conn, args->name);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5504,22 +6108,29 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_lookup_by_uuid_args *args,
remote_storage_pool_lookup_by_uuid_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5531,31 +6142,37 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
remote_storage_pool_lookup_by_volume_args *args,
remote_storage_pool_lookup_by_volume_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
pool = virStoragePoolLookupByVolume(vol);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
make_nonnull_storage_pool(&ret->pool, pool);
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5567,26 +6184,31 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_set_autostart_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolSetAutostart(pool, args->autostart) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5598,26 +6220,31 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_pool_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStoragePoolUndefine(pool) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5629,18 +6256,24 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfStoragePools(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -5652,18 +6285,24 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_storage_pools_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfDefinedStoragePools(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -5675,44 +6314,48 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_pool_list_volumes_args *args,
remote_storage_pool_list_volumes_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- virStoragePoolFree(pool);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virStoragePoolListVolumes(pool,
ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ if (ret->names.names_len == -1) {
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5725,28 +6368,32 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_pool_num_of_volumes_args *args,
remote_storage_pool_num_of_volumes_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virStoragePoolNumOfVolumes(pool);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -5765,31 +6412,36 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_create_xml_args *args,
remote_storage_vol_create_xml_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
vol = virStorageVolCreateXML(pool, args->xml, args->flags);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5801,41 +6453,45 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
remote_storage_vol_create_xml_from_args *args,
remote_storage_vol_create_xml_from_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr clonevol, newvol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr clonevol = NULL;
+ virStorageVolPtr newvol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
clonevol = get_nonnull_storage_vol(conn, args->clonevol);
if (clonevol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
args->flags);
if (newvol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, newvol);
- virStorageVolFree(newvol);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (newvol)
+ virStorageVolFree(newvol);
+ if (clonevol)
+ virStorageVolFree(clonevol);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int
@@ -5847,26 +6503,31 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStorageVolDelete(vol, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5878,32 +6539,31 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_wipe_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int retval = -1;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- goto out;
+ goto cleanup;
}
if (virStorageVolWipe(vol, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- goto out;
+ goto cleanup;
}
- retval = 0;
+ rv = 0;
-out:
- if (vol != NULL) {
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
virStorageVolFree(vol);
- }
- return retval;
+ return rv;
}
static int
@@ -5915,33 +6575,36 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_get_info_args *args,
remote_storage_vol_get_info_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
virStorageVolInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virStorageVolGetInfo(vol, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
ret->type = info.type;
ret->capacity = info.capacity;
ret->allocation = info.allocation;
- virStorageVolFree(vol);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -5953,28 +6616,33 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_dump_xml_args *args,
remote_storage_vol_dump_xml_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -5987,28 +6655,33 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_storage_vol_get_path_args *args,
remote_storage_vol_get_path_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->name = virStorageVolGetPath(vol);
if (!ret->name) {
- remoteDispatchConnError(rerr, conn);
- virStorageVolFree(vol);
- return -1;
+ goto cleanup;
}
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6021,31 +6694,37 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_vol_lookup_by_name_args *args,
remote_storage_vol_lookup_by_name_ret *ret)
{
- virStoragePoolPtr pool;
- virStorageVolPtr vol;
+ virStoragePoolPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
vol = virStorageVolLookupByName(pool, args->name);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
static int
@@ -6057,22 +6736,29 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
remote_storage_vol_lookup_by_key_args *args,
remote_storage_vol_lookup_by_key_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = virStorageVolLookupByKey(conn, args->key);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6085,22 +6771,29 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
remote_storage_vol_lookup_by_path_args *args,
remote_storage_vol_lookup_by_path_ret *ret)
{
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = virStorageVolLookupByPath(conn, args->path);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_storage_vol(&ret->vol, vol);
- virStorageVolFree(vol);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (vol)
+ virStorageVolFree(vol);
+ return rv;
}
@@ -6117,20 +6810,26 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_num_of_devices_args *args,
remote_node_num_of_devices_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virNodeNumOfDevices(conn,
args->cap ? *args->cap : NULL,
args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -6143,21 +6842,23 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_list_devices_args *args,
remote_node_list_devices_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
@@ -6165,12 +6866,17 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
args->cap ? *args->cap : NULL,
ret->names.names_val, args->maxnames, args->flags);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ return rv;
}
@@ -6183,22 +6889,29 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_device_lookup_by_name_args *args,
remote_node_device_lookup_by_name_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_node_device(&ret->dev, dev);
- virNodeDeviceFree(dev);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6211,28 +6924,33 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dump_xml_args *args,
remote_node_device_dump_xml_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6245,18 +6963,18 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_get_parent_args *args,
remote_node_device_get_parent_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
const char *parent;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
parent = virNodeDeviceGetParent(dev);
@@ -6267,21 +6985,25 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
char **parent_p;
if (VIR_ALLOC(parent_p) < 0) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
*parent_p = strdup(parent);
if (*parent_p == NULL) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->parent = parent_p;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6294,28 +7016,32 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_num_of_caps_args *args,
remote_node_device_num_of_caps_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virNodeDeviceNumOfCaps(dev);
if (ret->num < 0) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6328,45 +7054,48 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_list_caps_args *args,
remote_node_device_list_caps_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
- virNodeDeviceFree(dev);
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- virNodeDeviceFree(dev);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virNodeDeviceListCaps(dev, ret->names.names_val,
args->maxnames);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6379,27 +7108,31 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dettach_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceDettach(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6412,27 +7145,31 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_re_attach_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceReAttach(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6445,27 +7182,31 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_reset_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceReset(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6478,23 +7219,29 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_create_xml_args *args,
remote_node_device_create_xml_ret *ret)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_node_device(&ret->dev, dev);
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
@@ -6507,28 +7254,33 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNodeDevicePtr dev;
+ virNodeDevicePtr dev = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNodeDeviceDestroy(dev) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNodeDeviceFree(dev);
- return -1;
+ goto cleanup;
}
- virNodeDeviceFree(dev);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dev)
+ virNodeDeviceFree(dev);
+ return rv;
}
+
static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client,
virConnectPtr conn,
@@ -6537,47 +7289,46 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
remote_storage_vol_upload_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int rv = -1;
struct qemud_client_stream *stream = NULL;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (virStorageVolUpload(vol, stream->st,
args->offset, args->length,
args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (remoteAddClientStream(client, stream, 0) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
goto cleanup;
}
rv = 0;
cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (vol)
virStorageVolFree(vol);
- if (stream && rv != 0)
+ if (stream && rv != 0) {
+ virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
+ }
return rv;
}
@@ -6589,47 +7340,46 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
remote_storage_vol_download_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int rv = -1;
struct qemud_client_stream *stream = NULL;
- virStorageVolPtr vol;
+ virStorageVolPtr vol = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (virStorageVolDownload(vol, stream->st,
args->offset, args->length,
args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
goto cleanup;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- remoteDispatchConnError(rerr, conn);
- virStreamAbort(stream->st);
goto cleanup;
}
rv = 0;
cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (vol)
virStorageVolFree(vol);
- if (stream && rv != 0)
+ if (stream && rv != 0) {
+ virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
+ }
return rv;
}
@@ -6647,15 +7397,16 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
{
int callbackID;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
- remoteDispatchFormatError(rerr, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+ goto cleanup;
}
if ((callbackID = virConnectDomainEventRegisterAny(conn,
@@ -6663,13 +7414,17 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
client, NULL)) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -6681,24 +7436,30 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] == -1) {
- remoteDispatchFormatError(rerr, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+ goto cleanup;
}
if (virConnectDomainEventDeregisterAny(conn,
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static void
@@ -6722,7 +7483,7 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
msg->hdr.status = REMOTE_OK;
if (remoteEncodeClientMessageHeader(msg) < 0)
- goto error;
+ goto cleanup;
/* Serialise the return header and event. */
xdrmem_create(&xdr,
@@ -6732,20 +7493,20 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
/* Skip over the header we just wrote */
if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
- goto xdr_error;
+ goto xdr_cleanup;
if (!(proc)(&xdr, data)) {
VIR_WARN("Failed to serialize domain event %d", procnr);
- goto xdr_error;
+ goto xdr_cleanup;
}
/* Update length word to include payload*/
len = msg->bufferOffset = xdr_getpos(&xdr);
if (xdr_setpos(&xdr, 0) == 0)
- goto xdr_error;
+ goto xdr_cleanup;
if (!xdr_u_int(&xdr, &len))
- goto xdr_error;
+ goto xdr_cleanup;
/* Send it. */
msg->async = 1;
@@ -6759,9 +7520,9 @@ remoteDispatchDomainEventSend(struct qemud_client *client,
xdr_destroy(&xdr);
return;
-xdr_error:
+xdr_cleanup:
xdr_destroy(&xdr);
-error:
+cleanup:
VIR_FREE(msg);
}
@@ -6774,18 +7535,24 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_secrets_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfSecrets(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
static int
@@ -6797,31 +7564,38 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_secrets_args *args,
remote_list_secrets_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
+ goto cleanup;
}
if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->uuids.uuids_len = virConnectListSecrets(conn, ret->uuids.uuids_val,
args->maxuuids);
if (ret->uuids.uuids_len == -1) {
- VIR_FREE(ret->uuids.uuids_val);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->uuids.uuids_val);
+ }
+ return rv;
}
static int
@@ -6833,22 +7607,28 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_define_xml_args *args,
remote_secret_define_xml_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretDefineXML(conn, args->xml, args->flags);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6860,32 +7640,37 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_get_value_args *args,
remote_secret_get_value_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
size_t value_size;
unsigned char *value;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
value = virSecretGetValue(secret, &value_size, args->flags);
if (value == NULL) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
ret->value.value_len = value_size;
ret->value.value_val = (char *)value;
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6897,26 +7682,31 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_get_xml_desc_args *args,
remote_secret_get_xml_desc_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->xml = virSecretGetXMLDesc(secret, args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6928,22 +7718,29 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_lookup_by_uuid_args *args,
remote_secret_lookup_by_uuid_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6955,27 +7752,31 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_set_value_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
args->value.value_len, args->flags) < 0) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -6987,26 +7788,30 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virSecretUndefine(secret) < 0) {
- remoteDispatchConnError(rerr, conn);
- virSecretFree(secret);
- return -1;
+ goto cleanup;
}
- virSecretFree(secret);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
static int
@@ -7018,22 +7823,29 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_secret_lookup_by_usage_args *args,
remote_secret_lookup_by_usage_ret *ret)
{
- virSecretPtr secret;
+ virSecretPtr secret = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
if (secret == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_secret(&ret->secret, secret);
- virSecretFree(secret);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (secret)
+ virSecretFree(secret);
+ return rv;
}
@@ -7045,29 +7857,33 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
remote_domain_is_active_args *args,
remote_domain_is_active_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virDomainIsActive(domain);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7078,29 +7894,33 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
remote_domain_is_persistent_args *args,
remote_domain_is_persistent_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virDomainIsPersistent(domain);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7111,29 +7931,33 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
remote_domain_is_updated_args *args,
remote_domain_is_updated_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->updated = virDomainIsUpdated(domain);
if (ret->updated < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7144,29 +7968,33 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
remote_interface_is_active_args *args,
remote_interface_is_active_ret *ret)
{
- virInterfacePtr iface;
+ virInterfacePtr iface = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virInterfaceIsActive(iface);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virInterfaceFree(iface);
- return -1;
+ goto cleanup;
}
- virInterfaceFree(iface);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (iface)
+ virInterfaceFree(iface);
+ return rv;
}
static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7177,29 +8005,33 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
remote_network_is_active_args *args,
remote_network_is_active_ret *ret)
{
- virNetworkPtr network;
+ virNetworkPtr network = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virNetworkIsActive(network);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(network);
- return -1;
+ goto cleanup;
}
- virNetworkFree(network);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (network)
+ virNetworkFree(network);
+ return rv;
}
static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7210,29 +8042,33 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
remote_network_is_persistent_args *args,
remote_network_is_persistent_ret *ret)
{
- virNetworkPtr network;
+ virNetworkPtr network = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virNetworkIsPersistent(network);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virNetworkFree(network);
- return -1;
+ goto cleanup;
}
- virNetworkFree(network);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (network)
+ virNetworkFree(network);
+ return rv;
}
static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7243,29 +8079,33 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
remote_storage_pool_is_active_args *args,
remote_storage_pool_is_active_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->active = virStoragePoolIsActive(pool);
if (ret->active < 0) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -7276,29 +8116,33 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
remote_storage_pool_is_persistent_args *args,
remote_storage_pool_is_persistent_ret *ret)
{
- virStoragePoolPtr pool;
+ virStoragePoolPtr pool = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->persistent = virStoragePoolIsPersistent(pool);
if (ret->persistent < 0) {
- remoteDispatchConnError(rerr, conn);
- virStoragePoolFree(pool);
- return -1;
+ goto cleanup;
}
- virStoragePoolFree(pool);
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (pool)
+ virStoragePoolFree(pool);
+ return rv;
}
@@ -7310,19 +8154,25 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_is_secure_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->secure = virConnectIsSecure(conn);
if (ret->secure < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7336,20 +8186,25 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_cpu_compare_ret *ret)
{
int result;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
result = virConnectCompareCPU(conn, args->xml, args->flags);
if (result == VIR_CPU_COMPARE_ERROR) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->result = result;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7363,10 +8218,11 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_cpu_baseline_ret *ret)
{
char *cpu;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
cpu = virConnectBaselineCPU(conn,
@@ -7374,13 +8230,17 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
args->xmlCPUs.xmlCPUs_len,
args->flags);
if (cpu == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->cpu = cpu;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7393,24 +8253,22 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_job_info_args *args,
remote_domain_get_job_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainJobInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetJobInfo(dom, &info) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->type = info.type;
@@ -7426,9 +8284,14 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->fileProcessed = info.fileProcessed;
ret->fileRemaining = info.fileRemaining;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
@@ -7441,28 +8304,31 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_abort_job_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainAbortJob(dom) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
@@ -7475,28 +8341,31 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
remote_domain_migrate_set_max_downtime_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -7508,28 +8377,31 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_migrate_set_max_speed_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -7542,32 +8414,36 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_create_xml_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7581,11 +8457,11 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7601,17 +8477,16 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
if (!ret->xml)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
static int
@@ -7623,29 +8498,32 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_snapshot_num_args *args,
remote_domain_snapshot_num_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
ret->num = virDomainSnapshotNum(domain, args->flags);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7657,30 +8535,29 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_list_names_args *args,
remote_domain_snapshot_list_names_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) {
- remoteDispatchFormatError(rerr, "%s",
- _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->nameslen) < 0) {
- virDomainFree(domain);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len = virDomainSnapshotListNames(domain,
@@ -7688,15 +8565,19 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
args->nameslen,
args->flags);
if (ret->names.names_len == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- VIR_FREE(ret->names.names_val);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_val);
+ }
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7709,32 +8590,36 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
remote_domain_snapshot_lookup_by_name_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7746,32 +8631,35 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_has_current_snapshot_args *args,
remote_domain_has_current_snapshot_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
int result;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
result = virDomainHasCurrentSnapshot(domain, args->flags);
if (result < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
ret->result = result;
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7784,32 +8672,36 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_snapshot_current_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
snapshot = virDomainSnapshotCurrent(domain, args->flags);
if (snapshot == NULL) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
make_nonnull_domain_snapshot(&ret->snap, snapshot);
- virDomainSnapshotFree(snapshot);
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (snapshot)
+ virDomainSnapshotFree(snapshot);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
static int
@@ -7823,11 +8715,11 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7841,17 +8733,16 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
if (virDomainRevertToSnapshot(snapshot, args->flags) == -1)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
static int
@@ -7865,11 +8756,11 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
- int rc = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->snap.domain);
@@ -7883,17 +8774,16 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
if (virDomainSnapshotDelete(snapshot, args->flags) == -1)
goto cleanup;
- rc = 0;
+ rv = 0;
cleanup:
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
+ if (rv < 0)
+ remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
-
- return rc;
+ return rv;
}
@@ -7907,21 +8797,22 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
void *ret ATTRIBUTE_UNUSED)
{
int callbackID;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
- remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
+ goto cleanup;
}
if (client->domainEventCallbackID[args->eventID] != -1) {
- remoteDispatchFormatError(rerr, _("domain event %d already registered"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), args->eventID);
+ goto cleanup;
}
if ((callbackID = virConnectDomainEventRegisterAny(conn,
@@ -7929,13 +8820,17 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
args->eventID,
domainEventCallbacks[args->eventID],
client, NULL)) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[args->eventID] = callbackID;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7949,31 +8844,36 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
void *ret ATTRIBUTE_UNUSED)
{
int callbackID = -1;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
- remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
+ goto cleanup;
}
callbackID = client->domainEventCallbackID[args->eventID];
if (callbackID < 0) {
- remoteDispatchFormatError(rerr, _("domain event %d not registered"), args->eventID);
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
+ goto cleanup;
}
if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
client->domainEventCallbackID[args->eventID] = -1;
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -7987,22 +8887,29 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_lookup_by_name_args *args,
remote_nwfilter_lookup_by_name_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterLookupByName(conn, args->name);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
static int
@@ -8014,22 +8921,29 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_lookup_by_uuid_args *args,
remote_nwfilter_lookup_by_uuid_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8042,22 +8956,29 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_define_xml_args *args,
remote_nwfilter_define_xml_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = virNWFilterDefineXML(conn, args->xml);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8070,26 +8991,31 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virNWFilterUndefine(nwfilter) == -1) {
- remoteDispatchConnError(rerr, conn);
- virNWFilterFree(nwfilter);
- return -1;
+ goto cleanup;
}
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
static int
@@ -8101,33 +9027,40 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_nwfilters_args *args,
remote_list_nwfilters_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
if (args->maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) {
- remoteDispatchFormatError(rerr,
- "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
+ goto cleanup;
}
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
ret->names.names_len =
virConnectListNWFilters(conn,
ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
- VIR_FREE(ret->names.names_len);
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0) {
+ remoteDispatchError(rerr);
+ VIR_FREE(ret->names.names_len);
+ }
+ return rv;
}
@@ -8140,28 +9073,33 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_nwfilter_get_xml_desc_args *args,
remote_nwfilter_get_xml_desc_ret *ret)
{
- virNWFilterPtr nwfilter;
+ virNWFilterPtr nwfilter = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
/* remoteDispatchClientRequest will free this. */
ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
if (!ret->xml) {
- remoteDispatchConnError(rerr, conn);
- virNWFilterFree(nwfilter);
- return -1;
+ goto cleanup;
}
- virNWFilterFree(nwfilter);
- return 0;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (nwfilter)
+ virNWFilterFree(nwfilter);
+ return rv;
}
@@ -8174,18 +9112,24 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_nwfilters_ret *ret)
{
+ int rv = -1;
+
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
ret->num = virConnectNumOfNWFilters(conn);
if (ret->num == -1) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
- return 0;
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ return rv;
}
@@ -8198,33 +9142,36 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_get_block_info_args *args,
remote_domain_get_block_info_ret *ret)
{
- virDomainPtr dom;
+ virDomainPtr dom = NULL;
virDomainBlockInfo info;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- return -1;
+ goto cleanup;
}
ret->capacity = info.capacity;
ret->allocation = info.allocation;
ret->physical = info.physical;
- virDomainFree(dom);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
static int
@@ -8236,29 +9183,32 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
qemu_monitor_command_args *args,
qemu_monitor_command_ret *ret)
{
- virDomainPtr domain;
+ virDomainPtr domain = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
args->flags) == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(domain);
- return -1;
+ goto cleanup;
}
- virDomainFree(domain);
+ rv = 0;
- return 0;
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (domain)
+ virDomainFree(domain);
+ return rv;
}
@@ -8272,25 +9222,24 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
int r;
- struct qemud_client_stream *stream;
- virDomainPtr dom;
+ struct qemud_client_stream *stream = NULL;
+ virDomainPtr dom = NULL;
+ int rv = -1;
if (!conn) {
- remoteDispatchFormatError(rerr, "%s", _("connection not open"));
- return -1;
+ virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+ goto cleanup;
}
dom = get_nonnull_domain(conn, args->domain);
if (dom == NULL) {
- remoteDispatchConnError(rerr, conn);
- return -1;
+ goto cleanup;
}
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
- virDomainFree(dom);
- remoteDispatchOOMError(rerr);
- return -1;
+ virReportOOMError();
+ goto cleanup;
}
r = virDomainOpenConsole(dom,
@@ -8298,22 +9247,25 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
stream->st,
args->flags);
if (r == -1) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
- remoteFreeClientStream(client, stream);
- return -1;
+ goto cleanup;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- remoteDispatchConnError(rerr, conn);
- virDomainFree(dom);
+ goto cleanup;
+ }
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ remoteDispatchError(rerr);
+ if (stream && rv < 0) {
virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
- return -1;
}
-
- virDomainFree(dom);
- return 0;
+ if (dom)
+ virDomainFree(dom);
+ return rv;
}
diff --git a/daemon/stream.c b/daemon/stream.c
index b94e3df..b71df92 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -403,7 +403,7 @@ remoteStreamHandleWriteData(struct qemud_client *client,
} else {
VIR_INFO0("Stream send failed");
stream->closed = 1;
- remoteDispatchConnError(&rerr, client->conn);
+ remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
}
@@ -437,7 +437,7 @@ remoteStreamHandleFinish(struct qemud_client *client,
ret = virStreamFinish(stream->st);
if (ret < 0) {
- remoteDispatchConnError(&rerr, client->conn);
+ remoteDispatchError(&rerr);
return remoteSerializeReplyError(client, &rerr, &msg->hdr);
} else {
/* Send zero-length confirm */
@@ -569,7 +569,7 @@ remoteStreamHandleRead(struct qemud_client *client,
} else if (ret < 0) {
remote_error rerr;
memset(&rerr, 0, sizeof rerr);
- remoteDispatchConnError(&rerr, NULL);
+ remoteDispatchError(&rerr);
ret = remoteSerializeStreamError(client, &rerr, stream->procedure, stream->serial);
} else {
--
1.7.4.2
3
8
18 Apr '11
Updated against the latest git tree, no major changes since a week ago.
Thank you for reviews in previous ones.
Purpose of patches:
Now, virsh at(de)tach-device/disk/...etc.. doesn't support to update
inactive domain's definition even with the --persistent flag.
To update persistent modification of inactive domains, we have to use
virsh edit.
So, if we want to update inactive domain definition with scripts, we need to
use other command/libs than libvirt. I'd like to use libvirt/virsh in scripts.
This patches adds to support for updating domain definition via virsh with
scripts. This series just includes 'disk' updates but I'll add more.
Thanks,
-Kame
3
14
17 Apr '11
I think this change is pretty self-explanatory.
Richard
2
1
Also mark error messages in block_stats.c for translation, add the
new macro to the msg_gen functions in cfg.mk and add block_stats.c
to po/POTFILES.in
---
cfg.mk | 1 +
po/POTFILES.in | 1 +
src/xen/block_stats.c | 79 ++++++++++++++++++------------------------------
3 files changed, 32 insertions(+), 49 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 94db937..e54d170 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -420,6 +420,7 @@ msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
msg_gen_function += VIR_ERROR
msg_gen_function += VIR_ERROR0
+msg_gen_function += statsError
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cfa7cf8..766f8f6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -114,6 +114,7 @@ src/vbox/vbox_tmpl.c
src/vmware/vmware_conf.c
src/vmware/vmware_driver.c
src/vmx/vmx.c
+src/xen/block_stats.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index a28212c..1cb5455 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -31,34 +31,12 @@
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
-/**
- * statsErrorFunc:
- * @conn: the connection
- * @error: the error number
- * @func: the function failing
- * @info: extra information string
- * @value: extra information number
- *
- * Handle a stats error.
- */
-static void
-statsErrorFunc (virErrorNumber error, const char *func, const char *info,
- int value)
-{
- char fullinfo[1000];
- const char *errmsg;
-
- errmsg = virErrorMsg(error, info);
- if (func != NULL) {
- snprintf(fullinfo, sizeof (fullinfo) - 1, "%s: %s", func, info);
- fullinfo[sizeof (fullinfo) - 1] = 0;
- info = fullinfo;
- }
- virRaiseError(NULL, NULL, VIR_FROM_STATS_LINUX, error,
- VIR_ERR_ERROR,
- errmsg, info, NULL, value, 0, errmsg, info,
- value);
-}
+
+
+# define statsError(code, ...) \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, __FUNCTION__, \
+ __LINE__, __VA_ARGS__)
+
/*-------------------- Xen: block stats --------------------*/
@@ -194,8 +172,9 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
if (stats->rd_req == -1 && stats->rd_bytes == -1 &&
stats->wr_req == -1 && stats->wr_bytes == -1 &&
stats->errs == -1) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Failed to read any block statistics", domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to read any block statistics for domain %d"),
+ domid);
return -1;
}
@@ -207,8 +186,9 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
stats->wr_req == 0 && stats->wr_bytes == 0 &&
stats->errs == 0 &&
!check_bd_connected (priv, device, domid)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "Frontend block device not connected", domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("Frontend block device not connected for domain %d"),
+ domid);
return -1;
}
@@ -217,18 +197,18 @@ read_bd_stats(xenUnifiedPrivatePtr priv,
*/
if (stats->rd_bytes > 0) {
if (stats->rd_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->rd_bytes would overflow 64 bit counter",
- domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("stats->rd_bytes would overflow 64 bit counter for domain %d"),
+ domid);
return -1;
}
stats->rd_bytes *= 512;
}
if (stats->wr_bytes > 0) {
if (stats->wr_bytes >= ((unsigned long long)1)<<(63-9)) {
- statsErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "stats->wr_bytes would overflow 64 bit counter",
- domid);
+ statsError(VIR_ERR_INTERNAL_ERROR,
+ _("stats->wr_bytes would overflow 64 bit counter for domain %d"),
+ domid);
return -1;
}
stats->wr_bytes *= 512;
@@ -346,20 +326,21 @@ xenLinuxDomainDeviceID(int domid, const char *path)
* beginning of the strings for better error messages
*/
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/sd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range sda[1-15] - sdiv[1-15]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "sda[1-15] - sdiv[1-15] for domain %d"), domid);
else if (strlen(mod_path) >= 7 && STRPREFIX(mod_path, "/dev/hd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range hda[1-63] - hdt[1-63]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "hda[1-63] - hdt[1-63] for domain %d"), domid);
else if (strlen(mod_path) >= 8 && STRPREFIX(mod_path, "/dev/xvd"))
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid path, device names must be in the range xvda[1-15] - xvdiz[1-15]",
- domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("invalid path, device names must be in the range "
+ "xvda[1-15] - xvdiz[1-15] for domain %d"), domid);
else
- statsErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__,
- "unsupported path, use xvdN, hdN, or sdN", domid);
+ statsError(VIR_ERR_INVALID_ARG,
+ _("unsupported path, use xvdN, hdN, or sdN for domain %d"),
+ domid);
VIR_FREE(mod_path);
--
1.7.0.4
2
2
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
---
src/esx/esx_vi_generator.py | 177 +++++++++++++++++--------------------------
1 files changed, 71 insertions(+), 106 deletions(-)
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 3d068f3..622a34a 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -41,6 +41,11 @@ valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
+def aligned(left, right):
+ while len(left) < 59:
+ left += " "
+
+ return left + right
@@ -64,9 +69,6 @@ class Parameter:
def is_enum(self):
- global predefined_enums
- global enums_by_name
-
return self.type in predefined_enums or self.type in enums_by_name
@@ -88,10 +90,7 @@ class Parameter:
else:
string += ", "
- while len(string) < 59:
- string += " "
-
- return string + self.get_occurrence_comment() + "\n"
+ return aligned(string, self.get_occurrence_comment() + "\n")
def generate_return(self, offset = 0, end_of_line = ";"):
@@ -102,10 +101,7 @@ class Parameter:
string += " " * offset
string += "%s%s)%s" % (self.get_type_string(True), self.name, end_of_line)
- while len(string) < 59:
- string += " "
-
- return string + self.get_occurrence_comment() + "\n"
+ return aligned(string, self.get_occurrence_comment() + "\n")
def generate_require_code(self):
@@ -274,9 +270,6 @@ class Property:
def is_enum(self):
- global predefined_enums
- global enums_by_name
-
return self.type in predefined_enums or self.type in enums_by_name
@@ -286,10 +279,7 @@ class Property:
else:
string = " %s%s; " % (self.get_type_string(), self.name)
- while len(string) < 59:
- string += " "
-
- return string + self.get_occurrence_comment() + "\n"
+ return aligned(string, self.get_occurrence_comment() + "\n")
def generate_free_code(self):
@@ -380,7 +370,37 @@ class Property:
-class Object:
+class Base:
+ def __init__(self, kind, name):
+ self.kind = kind
+ self.name = name
+
+
+ def generate_typedef(self):
+ return "typedef %s _esxVI_%s esxVI_%s;\n" % (self.kind, self.name, self.name)
+
+
+ def generate_typeenum(self):
+ return " esxVI_Type_%s,\n" % self.name
+
+
+ def generate_typetostring(self):
+ string = " case esxVI_Type_%s:\n" % self.name
+ string += " return \"%s\";\n\n" % self.name
+
+ return string
+
+
+ def generate_typefromstring(self):
+ string = " else if (STREQ(type, \"%s\")) {\n" % self.name
+ string += " return esxVI_Type_%s;\n" % self.name
+ string += " }\n"
+
+ return string
+
+
+
+class Object(Base):
FEATURE__DYNAMIC_CAST = (1 << 1)
FEATURE__LIST = (1 << 2)
FEATURE__DEEP_COPY = (1 << 3)
@@ -390,34 +410,24 @@ class Object:
def __init__(self, name, extends, properties, features = 0, extended_by = None):
- self.name = name
+ Base.__init__(self, "struct", name)
self.extends = extends
self.features = features | Object.FEATURE__SERIALIZE | Object.FEATURE__DESERIALIZE
self.properties = properties
self.extended_by = extended_by
if self.extended_by is not None:
- self.extended_by.sort();
+ self.extended_by.sort()
- def generate_struct_members(self, add_banner = False, struct_gap = False):
- global objects_by_name
+ def generate_struct_members(self, add_banner=False, struct_gap=False):
members = ""
- if self.extends is None:
- struct_gap = True
- string = " esxVI_Type _type; "
-
- while len(string) < 59:
- string += " "
-
- members += string + "/* required */\n"
-
- if struct_gap and self.extends is None:
+ if struct_gap:
members += "\n"
if self.extends is not None:
- members += objects_by_name[self.extends].generate_struct_members(add_banner = True, struct_gap = False) + "\n"
+ members += objects_by_name[self.extends].generate_struct_members(add_banner=True, struct_gap=False) + "\n"
if self.extends is not None or add_banner:
members += " /* %s */\n" % self.name
@@ -431,12 +441,11 @@ class Object:
return members
- def generate_free_code(self, add_banner = False):
- global objects_by_name
+ def generate_free_code(self, add_banner=False):
source = ""
if self.extends is not None:
- source += objects_by_name[self.extends].generate_free_code(add_banner = True) + "\n"
+ source += 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
@@ -457,12 +466,11 @@ class Object:
return source
- def generate_validate_code(self, add_banner = False):
- global objects_by_name
+ def generate_validate_code(self, add_banner=False):
source = ""
if self.extends is not None:
- source += objects_by_name[self.extends].generate_validate_code(add_banner = True) + "\n"
+ source += 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
@@ -484,7 +492,6 @@ class Object:
def generate_dynamic_cast_code(self, is_first = True):
- global objects_by_name
source = ""
if self.extended_by is not None:
@@ -503,7 +510,6 @@ class Object:
def generate_deep_copy_code(self, add_banner = False):
- global objects_by_name
source = ""
if self.extends is not None:
@@ -529,7 +535,6 @@ class Object:
def generate_serialize_code(self, add_banner = False):
- global objects_by_name
source = ""
if self.extends is not None:
@@ -548,11 +553,10 @@ class Object:
def generate_deserialize_code(self, add_banner = False):
- global objects_by_name
source = ""
if self.extends is not None:
- source += objects_by_name[self.extends].generate_deserialize_code(add_banner = True) + "\n"
+ source += objects_by_name[self.extends].generate_deserialize_code(add_banner=True) + "\n"
if self.extends is not None or add_banner:
source += " /* %s */\n" % self.name
@@ -566,29 +570,6 @@ class Object:
return source
- def generate_typedef(self):
- return "typedef struct _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
-
-
- def generate_typeenum(self):
- return " esxVI_Type_%s,\n" % self.name
-
-
- def generate_typetostring(self):
- string = " case esxVI_Type_%s:\n" % self.name
- string += " return \"%s\";\n\n" % self.name
-
- return string
-
-
- def generate_typefromstring(self):
- string = " else if (STREQ(type, \"%s\")) {\n" % self.name
- string += " return esxVI_Type_%s;\n" % self.name
- string += " }\n"
-
- return string
-
-
def generate_header(self):
header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
header += " * VI Type: %s\n" % self.name
@@ -612,17 +593,12 @@ class Object:
header += "struct _esxVI_%s {\n" % self.name
if self.features & Object.FEATURE__LIST:
- string = " esxVI_%s *_next; " % self.name
+ header += aligned(" esxVI_%s *_next; " % self.name, "/* optional */\n")
else:
- string = " esxVI_%s *_unused; " % self.name
-
- while len(string) < 59:
- string += " "
-
- header += string + "/* optional */\n"
-
- header += self.generate_struct_members(struct_gap = True)
+ header += aligned(" esxVI_%s *_unused; " % self.name, "/* optional */\n")
+ header += aligned(" esxVI_Type _type; ", "/* required */\n")
+ header += self.generate_struct_members(struct_gap=True)
header += "};\n\n"
# functions
@@ -888,39 +864,28 @@ class Object:
-class Enum:
- FEATURE__ANY_TYPE = (1 << 1)
- FEATURE__SERIALIZE = (1 << 2)
- FEATURE__DESERIALIZE = (1 << 3)
- def __init__(self, name, values, features = 0):
- self.name = name
- self.values = values
- self.features = features | Enum.FEATURE__SERIALIZE | Enum.FEATURE__DESERIALIZE
- def generate_typedef(self):
- return "typedef enum _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
- def generate_typeenum(self):
- return " esxVI_Type_%s,\n" % self.name
- def generate_typetostring(self):
- string = " case esxVI_Type_%s:\n" % self.name
- string += " return \"%s\";\n\n" % self.name
- return string
- def generate_typefromstring(self):
- string = " else if (STREQ(type, \"%s\")) {\n" % self.name
- string += " return esxVI_Type_%s;\n" % self.name
- string += " }\n"
- return string
+class Enum(Base):
+ FEATURE__ANY_TYPE = (1 << 1)
+ FEATURE__SERIALIZE = (1 << 2)
+ FEATURE__DESERIALIZE = (1 << 3)
+
+
+ def __init__(self, name, values, features=0):
+ Base.__init__(self, "enum", name)
+ self.values = values
+ self.features = features | Enum.FEATURE__SERIALIZE | Enum.FEATURE__DESERIALIZE
def generate_header(self):
@@ -1027,8 +992,8 @@ def parse_object(block):
if items[2] not in valid_occurrences:
report_error("line %d: invalid occurrence" % line[0])
- properties.append(Property(type = items[0], name = items[1],
- occurrence = items[2]))
+ properties.append(Property(type=items[0], name=items[1],
+ occurrence=items[2]))
return Object(name = name, extends = extends, properties = properties)
@@ -1051,7 +1016,7 @@ def parse_enum(block):
# expected format: <value>
values.append(line[1])
- return Enum(name = name, values = values)
+ return Enum(name=name, values=values)
@@ -1071,8 +1036,8 @@ def parse_method(block):
if header_items[2] != "returns":
report_error("line %d: invalid block header" % (number))
else:
- returns = Parameter(type = header_items[3], name = "output",
- occurrence = header_items[4])
+ returns = Parameter(type=header_items[3], name="output",
+ occurrence=header_items[4])
parameters = []
@@ -1086,10 +1051,10 @@ def parse_method(block):
if items[2] not in valid_occurrences:
report_error("line %d: invalid occurrence" % line[0])
- parameters.append(Parameter(type = items[0], name = items[1],
- occurrence = items[2]))
+ parameters.append(Parameter(type=items[0], name=items[1],
+ occurrence=items[2]))
- return Method(name = name, parameters = parameters, returns = returns)
+ return Method(name=name, parameters=parameters, returns=returns)
--
1.7.0.4
2
2
If brSetForwardDelay() fails, we go to err1 where we want to access
macTapIfName variable which was just VIR_FREE'd a few lines above.
---
src/network/bridge_driver.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ea2bfd4..97d8ce0 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1616,7 +1616,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
bool v4present = false, v6present = false;
virErrorPtr save_err = NULL;
virNetworkIpDefPtr ipdef;
- char *macTapIfName;
+ char *macTapIfName = NULL;
if (virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_OPERATION_INVALID,
@@ -1657,7 +1657,6 @@ networkStartNetworkDaemon(struct network_driver *driver,
VIR_FREE(macTapIfName);
goto err0;
}
- VIR_FREE(macTapIfName);
}
/* Set bridge options */
@@ -1731,6 +1730,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
goto err5;
}
+ VIR_FREE(macTapIfName);
VIR_INFO(_("Starting up network '%s'"), network->def->name);
network->active = 1;
@@ -1778,6 +1778,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
macTapIfName, network->def->bridge,
virStrerror(err, ebuf, sizeof ebuf));
}
+ VIR_FREE(macTapIfName);
err0:
if (!save_err)
--
1.7.4.2
2
2
[libvirt] [PATCH] docs: Serial and parallel device target ports actually start from 0
by Matthias Bolte 14 Apr '11
by Matthias Bolte 14 Apr '11
14 Apr '11
Reported by Igor Galić
---
docs/formatdomain.html.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 574fee5..ea021e8 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1807,7 +1807,7 @@ qemu-kvm -net nic,model=? /dev/null
<p>
<code>target</code> can have a <code>port</code> attribute, which
- specifies the port number. Ports are numbered starting from 1. There are
+ specifies the port number. Ports are numbered starting from 0. There are
usually 0, 1 or 2 parallel ports.
</p>
@@ -1825,7 +1825,7 @@ qemu-kvm -net nic,model=? /dev/null
<p>
<code>target</code> can have a <code>port</code> attribute, which
- specifies the port number. Ports are numbered starting from 1. There are
+ specifies the port number. Ports are numbered starting from 0. There are
usually 0, 1 or 2 serial ports.
</p>
--
1.7.0.4
2
2
Hi
For some reason recent libvirt code (0.8.3 and even before) the 'virsh
shutdown <domain> ' is not effective .
It issues an ok message by the domians remains in a runnning state . Only
th e destroy works fine.
Any idea ?
Zvi Dubitzky
Email:dubi@il.ibm.com
3
2
If brSetForwardDelay() fails, we go to err1 where we want to access
macTapIfName variable which was just VIR_FREE'd a few lines above.
---
src/network/bridge_driver.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ea2bfd4..abde150 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1616,7 +1616,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
bool v4present = false, v6present = false;
virErrorPtr save_err = NULL;
virNetworkIpDefPtr ipdef;
- char *macTapIfName;
+ char *macTapIfName = NULL;
if (virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_OPERATION_INVALID,
@@ -1657,7 +1657,6 @@ networkStartNetworkDaemon(struct network_driver *driver,
VIR_FREE(macTapIfName);
goto err0;
}
- VIR_FREE(macTapIfName);
}
/* Set bridge options */
@@ -1687,6 +1686,8 @@ networkStartNetworkDaemon(struct network_driver *driver,
if (networkAddIptablesRules(driver, network) < 0)
goto err1;
+ VIR_FREE(macTapIfName);
+
for (ii = 0;
(ipdef = virNetworkDefGetIpByIndex(network->def, AF_UNSPEC, ii));
ii++) {
--
1.7.4.2
2
1
14 Apr '11
The libvirt APIs reserve any negative value for indicating an
error. Thus checks
if (virXXXX() == -1)
Should instead be
if (virXXXX() < 0)
* daemon/remote.c: s/ == -1/ < 0/
---
daemon/remote.c | 339 +++++++++++++++++++++++++++++--------------------------
1 files changed, 180 insertions(+), 159 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 8f4d6a6..325ba90 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -476,7 +476,7 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->supported = virDrvSupportsFeature(conn, args->feature);
- if (ret->supported == -1) {
+ if (ret->supported < 0) {
goto cleanup;
}
@@ -543,7 +543,7 @@ remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virConnectGetVersion(conn, &hvVer) == -1) {
+ if (virConnectGetVersion(conn, &hvVer) < 0) {
goto cleanup;
}
@@ -573,7 +573,7 @@ remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virConnectGetLibVersion(conn, &libVer) == -1) {
+ if (virConnectGetLibVersion(conn, &libVer) < 0) {
goto cleanup;
}
@@ -700,7 +700,7 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
type = args->type ? *args->type : NULL;
ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
- if (ret->max_vcpus == -1) {
+ if (ret->max_vcpus < 0) {
goto cleanup;
}
@@ -729,7 +729,7 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNodeGetInfo(conn, &info) == -1) {
+ if (virNodeGetInfo(conn, &info) < 0) {
goto cleanup;
}
@@ -938,7 +938,7 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
}
r = virDomainGetSchedulerParameters(dom, params, &nparams);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -1051,7 +1051,7 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
}
r = virDomainSetSchedulerParameters(dom, params, nparams);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -1091,7 +1091,7 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
path = args->path;
- if (virDomainBlockStats(dom, path, &stats, sizeof stats) == -1) {
+ if (virDomainBlockStats(dom, path, &stats, sizeof stats) < 0) {
goto cleanup;
}
@@ -1136,7 +1136,7 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
path = args->path;
- if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) == -1) {
+ if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) < 0) {
goto cleanup;
}
@@ -1170,7 +1170,7 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom = NULL;
struct _virDomainMemoryStat *stats;
- unsigned int nr_stats, i;
+ int nr_stats, i;
int rv = -1;
if (!conn) {
@@ -1196,7 +1196,7 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
- if (nr_stats == -1) {
+ if (nr_stats < 0) {
goto cleanup;
}
@@ -1266,7 +1266,7 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainBlockPeek(dom, path, offset, size,
- ret->buffer.buffer_val, flags) == -1) {
+ ret->buffer.buffer_val, flags) < 0) {
goto cleanup;
}
@@ -1323,7 +1323,7 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainMemoryPeek(dom, offset, size,
- ret->buffer.buffer_val, flags) == -1) {
+ ret->buffer.buffer_val, flags) < 0) {
goto cleanup;
}
if (dom)
@@ -1363,7 +1363,7 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainAttachDevice(dom, args->xml) == -1) {
+ if (virDomainAttachDevice(dom, args->xml) < 0) {
goto cleanup;
}
@@ -1399,7 +1399,7 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) == -1) {
+ if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) < 0) {
goto cleanup;
}
@@ -1435,7 +1435,7 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) == -1) {
+ if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0) {
goto cleanup;
}
@@ -1471,7 +1471,7 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainCreate(dom) == -1) {
+ if (virDomainCreate(dom) < 0) {
goto cleanup;
}
@@ -1502,7 +1502,7 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- if (virDomainCreateWithFlags(dom, args->flags) == -1) {
+ if (virDomainCreateWithFlags(dom, args->flags) < 0) {
goto cleanup;
}
@@ -1608,7 +1608,7 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainDestroy(dom) == -1) {
+ if (virDomainDestroy(dom) < 0) {
goto cleanup;
}
@@ -1644,7 +1644,7 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainDetachDevice(dom, args->xml) == -1) {
+ if (virDomainDetachDevice(dom, args->xml) < 0) {
goto cleanup;
}
@@ -1680,7 +1680,7 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) == -1) {
+ if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) < 0) {
goto cleanup;
}
@@ -1819,7 +1819,7 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainGetAutostart(dom, &ret->autostart) == -1) {
+ if (virDomainGetAutostart(dom, &ret->autostart) < 0) {
goto cleanup;
}
@@ -1856,7 +1856,7 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainGetInfo(dom, &info) == -1) {
+ if (virDomainGetInfo(dom, &info) < 0) {
goto cleanup;
}
@@ -1936,7 +1936,7 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virDomainGetMaxVcpus(dom);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -1978,7 +1978,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
+ if (virDomainGetSecurityLabel(dom, seclabel) < 0) {
goto cleanup;
}
@@ -2019,7 +2019,7 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
}
memset(&secmodel, 0, sizeof secmodel);
- if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
+ if (virNodeGetSecurityModel(conn, &secmodel) < 0) {
goto cleanup;
}
@@ -2127,7 +2127,7 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
info_len = virDomainGetVcpus(dom,
info, args->maxinfo,
cpumaps, args->maplen);
- if (info_len == -1) {
+ if (info_len < 0) {
goto cleanup;
}
@@ -2192,7 +2192,7 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virDomainGetVcpusFlags(dom, args->flags);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -2240,7 +2240,7 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
r = virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -2296,7 +2296,7 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
args->cookie.cookie_len,
args->uri,
args->flags, dname, args->resource);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -2382,7 +2382,7 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
uri_in, uri_out,
args->flags, dname, args->resource,
args->dom_xml);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -2470,7 +2470,7 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
r = virDomainMigratePrepareTunnel(conn, stream->st,
args->flags, dname, args->resource,
args->dom_xml);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -2501,6 +2501,7 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_domains_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -2519,12 +2520,12 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virConnectListDefinedDomains(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListDefinedDomains(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -2655,7 +2656,7 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfDefinedDomains(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -2697,7 +2698,7 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
rv = virDomainPinVcpu(dom, args->vcpu,
(unsigned char *) args->cpumap.cpumap_val,
args->cpumap.cpumap_len);
- if (rv == -1) {
+ if (rv < 0) {
goto cleanup;
}
@@ -2733,7 +2734,7 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainReboot(dom, args->flags) == -1) {
+ if (virDomainReboot(dom, args->flags) < 0) {
goto cleanup;
}
@@ -2763,7 +2764,7 @@ remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainRestore(conn, args->from) == -1) {
+ if (virDomainRestore(conn, args->from) < 0) {
goto cleanup;
}
@@ -2797,7 +2798,7 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainResume(dom) == -1) {
+ if (virDomainResume(dom) < 0) {
goto cleanup;
}
@@ -2833,7 +2834,7 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSave(dom, args->to) == -1) {
+ if (virDomainSave(dom, args->to) < 0) {
goto cleanup;
}
@@ -2869,7 +2870,7 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainCoreDump(dom, args->to, args->flags) == -1) {
+ if (virDomainCoreDump(dom, args->to, args->flags) < 0) {
goto cleanup;
}
@@ -2905,7 +2906,7 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSetAutostart(dom, args->autostart) == -1) {
+ if (virDomainSetAutostart(dom, args->autostart) < 0) {
goto cleanup;
}
@@ -2941,7 +2942,7 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSetMaxMemory(dom, args->memory) == -1) {
+ if (virDomainSetMaxMemory(dom, args->memory) < 0) {
goto cleanup;
}
@@ -2977,7 +2978,7 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSetMemory(dom, args->memory) == -1) {
+ if (virDomainSetMemory(dom, args->memory) < 0) {
goto cleanup;
}
@@ -3013,7 +3014,7 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSetMemoryFlags(dom, args->memory, args->flags) == -1) {
+ if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0) {
goto cleanup;
}
@@ -3112,7 +3113,7 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
}
r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -3170,7 +3171,7 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
}
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
/* In this case, we need to send back the number of parameters
@@ -3333,7 +3334,7 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
}
r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
@@ -3391,7 +3392,7 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
}
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
/* In this case, we need to send back the number of parameters
@@ -3493,7 +3494,7 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSetVcpus(dom, args->nvcpus) == -1) {
+ if (virDomainSetVcpus(dom, args->nvcpus) < 0) {
goto cleanup;
}
@@ -3529,7 +3530,7 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) == -1) {
+ if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0) {
goto cleanup;
}
@@ -3565,7 +3566,7 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainShutdown(dom) == -1) {
+ if (virDomainShutdown(dom) < 0) {
goto cleanup;
}
@@ -3601,7 +3602,7 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainSuspend(dom) == -1) {
+ if (virDomainSuspend(dom) < 0) {
goto cleanup;
}
@@ -3637,7 +3638,7 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainUndefine(dom) == -1) {
+ if (virDomainUndefine(dom) < 0) {
goto cleanup;
}
@@ -3661,6 +3662,7 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_networks_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -3679,12 +3681,12 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virConnectListDefinedNetworks(conn,
+ len = virConnectListDefinedNetworks(conn,
ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -3706,6 +3708,7 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_domains_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -3724,11 +3727,12 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->ids.ids_len = virConnectListDomains(conn,
- ret->ids.ids_val, args->maxids);
- if (ret->ids.ids_len == -1) {
+ len = virConnectListDomains(conn,
+ ret->ids.ids_val, args->maxids);
+ if (len < 0) {
goto cleanup;
}
+ ret->ids.ids_len = len;
rv = 0;
@@ -3762,7 +3766,7 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainManagedSave(dom, args->flags) == -1) {
+ if (virDomainManagedSave(dom, args->flags) < 0) {
goto cleanup;
}
@@ -3799,7 +3803,7 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
}
ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
- if (ret->ret == -1) {
+ if (ret->ret < 0) {
goto cleanup;
}
@@ -3835,7 +3839,7 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (virDomainManagedSaveRemove(dom, args->flags) == -1) {
+ if (virDomainManagedSaveRemove(dom, args->flags) < 0) {
goto cleanup;
}
@@ -3859,6 +3863,7 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_networks_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -3877,12 +3882,12 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virConnectListNetworks(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListNetworks(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -3916,7 +3921,7 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNetworkCreate(net) == -1) {
+ if (virNetworkCreate(net) < 0) {
goto cleanup;
}
@@ -4020,7 +4025,7 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNetworkDestroy(net) == -1) {
+ if (virNetworkDestroy(net) < 0) {
goto cleanup;
}
@@ -4094,7 +4099,7 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNetworkGetAutostart(net, &ret->autostart) == -1) {
+ if (virNetworkGetAutostart(net, &ret->autostart) < 0) {
goto cleanup;
}
@@ -4236,7 +4241,7 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNetworkSetAutostart(net, args->autostart) == -1) {
+ if (virNetworkSetAutostart(net, args->autostart) < 0) {
goto cleanup;
}
@@ -4272,7 +4277,7 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNetworkUndefine(net) == -1) {
+ if (virNetworkUndefine(net) < 0) {
goto cleanup;
}
@@ -4296,16 +4301,18 @@ remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_num_of_defined_networks_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
- ret->num = virConnectNumOfDefinedNetworks(conn);
- if (ret->num == -1) {
+ len = virConnectNumOfDefinedNetworks(conn);
+ if (len < 0) {
goto cleanup;
}
+ ret->num = len;
rv = 0;
@@ -4332,7 +4339,7 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfDomains(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -4361,7 +4368,7 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfNetworks(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -4392,7 +4399,7 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfInterfaces(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -4414,6 +4421,7 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_interfaces_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -4432,12 +4440,12 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virConnectListInterfaces(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListInterfaces(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -4459,16 +4467,18 @@ remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSE
remote_num_of_defined_interfaces_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
- ret->num = virConnectNumOfDefinedInterfaces(conn);
- if (ret->num == -1) {
+ len = virConnectNumOfDefinedInterfaces(conn);
+ if (len < 0) {
goto cleanup;
}
+ ret->num = len;
rv = 0;
@@ -4488,6 +4498,7 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
remote_list_defined_interfaces_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -4506,12 +4517,12 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- ret->names.names_len =
- virConnectListDefinedInterfaces(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListDefinedInterfaces(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -4685,7 +4696,7 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virInterfaceUndefine(iface) == -1) {
+ if (virInterfaceUndefine(iface) < 0) {
goto cleanup;
}
@@ -4721,7 +4732,7 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virInterfaceCreate(iface, args->flags) == -1) {
+ if (virInterfaceCreate(iface, args->flags) < 0) {
goto cleanup;
}
@@ -4757,7 +4768,7 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virInterfaceDestroy(iface, args->flags) == -1) {
+ if (virInterfaceDestroy(iface, args->flags) < 0) {
goto cleanup;
}
@@ -5585,6 +5596,7 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
remote_list_defined_storage_pools_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -5603,12 +5615,12 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- ret->names.names_len =
- virConnectListDefinedStoragePools(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListDefinedStoragePools(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -5630,6 +5642,7 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_storage_pools_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -5648,12 +5661,12 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virConnectListStoragePools(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListStoragePools(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -5721,7 +5734,7 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolCreate(pool, args->flags) == -1) {
+ if (virStoragePoolCreate(pool, args->flags) < 0) {
goto cleanup;
}
@@ -5825,7 +5838,7 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolBuild(pool, args->flags) == -1) {
+ if (virStoragePoolBuild(pool, args->flags) < 0) {
goto cleanup;
}
@@ -5862,7 +5875,7 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolDestroy(pool) == -1) {
+ if (virStoragePoolDestroy(pool) < 0) {
goto cleanup;
}
@@ -5898,7 +5911,7 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolDelete(pool, args->flags) == -1) {
+ if (virStoragePoolDelete(pool, args->flags) < 0) {
goto cleanup;
}
@@ -5934,7 +5947,7 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolRefresh(pool, args->flags) == -1) {
+ if (virStoragePoolRefresh(pool, args->flags) < 0) {
goto cleanup;
}
@@ -5971,7 +5984,7 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolGetInfo(pool, &info) == -1) {
+ if (virStoragePoolGetInfo(pool, &info) < 0) {
goto cleanup;
}
@@ -6050,7 +6063,7 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (virStoragePoolGetAutostart(pool, &ret->autostart) == -1) {
+ if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0) {
goto cleanup;
}
@@ -6197,7 +6210,7 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (virStoragePoolSetAutostart(pool, args->autostart) == -1) {
+ if (virStoragePoolSetAutostart(pool, args->autostart) < 0) {
goto cleanup;
}
@@ -6233,7 +6246,7 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStoragePoolUndefine(pool) == -1) {
+ if (virStoragePoolUndefine(pool) < 0) {
goto cleanup;
}
@@ -6264,7 +6277,7 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfStoragePools(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -6293,7 +6306,7 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
}
ret->num = virConnectNumOfDefinedStoragePools(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -6316,6 +6329,7 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
{
virStoragePoolPtr pool = NULL;
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -6339,12 +6353,12 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- ret->names.names_len =
- virStoragePoolListVolumes(pool,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virStoragePoolListVolumes(pool,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -6382,7 +6396,7 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
}
ret->num = virStoragePoolNumOfVolumes(pool);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -6516,7 +6530,7 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStorageVolDelete(vol, args->flags) == -1) {
+ if (virStorageVolDelete(vol, args->flags) < 0) {
goto cleanup;
}
@@ -6552,7 +6566,7 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStorageVolWipe(vol, args->flags) == -1) {
+ if (virStorageVolWipe(vol, args->flags) < 0) {
goto cleanup;
}
@@ -6589,7 +6603,7 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virStorageVolGetInfo(vol, &info) == -1) {
+ if (virStorageVolGetInfo(vol, &info) < 0) {
goto cleanup;
}
@@ -6820,7 +6834,7 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->num = virNodeNumOfDevices(conn,
args->cap ? *args->cap : NULL,
args->flags);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -6843,6 +6857,7 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_list_devices_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -6861,13 +6876,13 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virNodeListDevices(conn,
- args->cap ? *args->cap : NULL,
- ret->names.names_val, args->maxnames, args->flags);
- if (ret->names.names_len == -1) {
+ len = virNodeListDevices(conn,
+ args->cap ? *args->cap : NULL,
+ ret->names.names_val, args->maxnames, args->flags);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -7056,6 +7071,7 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNodeDevicePtr dev = NULL;
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -7079,12 +7095,12 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virNodeDeviceListCaps(dev, ret->names.names_val,
- args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virNodeDeviceListCaps(dev, ret->names.names_val,
+ args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -7121,7 +7137,7 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNodeDeviceDettach(dev) == -1) {
+ if (virNodeDeviceDettach(dev) < 0) {
goto cleanup;
}
@@ -7158,7 +7174,7 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNodeDeviceReAttach(dev) == -1) {
+ if (virNodeDeviceReAttach(dev) < 0) {
goto cleanup;
}
@@ -7195,7 +7211,7 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNodeDeviceReset(dev) == -1) {
+ if (virNodeDeviceReset(dev) < 0) {
goto cleanup;
}
@@ -7267,7 +7283,7 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNodeDeviceDestroy(dev) == -1) {
+ if (virNodeDeviceDestroy(dev) < 0) {
goto cleanup;
}
@@ -7443,7 +7459,7 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] == -1) {
+ if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
goto cleanup;
}
@@ -7543,7 +7559,7 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfSecrets(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -7565,6 +7581,7 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_secrets_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -7582,11 +7599,12 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->uuids.uuids_len = virConnectListSecrets(conn, ret->uuids.uuids_val,
- args->maxuuids);
- if (ret->uuids.uuids_len == -1) {
+ len = virConnectListSecrets(conn, ret->uuids.uuids_val,
+ args->maxuuids);
+ if (len < 0) {
goto cleanup;
}
+ ret->uuids.uuids_len = len;
rv = 0;
@@ -8267,7 +8285,7 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainGetJobInfo(dom, &info) == -1) {
+ if (virDomainGetJobInfo(dom, &info) < 0) {
goto cleanup;
}
@@ -8317,7 +8335,7 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainAbortJob(dom) == -1) {
+ if (virDomainAbortJob(dom) < 0) {
goto cleanup;
}
@@ -8354,7 +8372,7 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
goto cleanup;
}
- if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) == -1) {
+ if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0) {
goto cleanup;
}
@@ -8390,7 +8408,7 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
goto cleanup;
}
- if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) == -1) {
+ if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0) {
goto cleanup;
}
@@ -8512,7 +8530,7 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virDomainSnapshotNum(domain, args->flags);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -8537,6 +8555,7 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
{
virDomainPtr domain = NULL;
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -8560,13 +8579,14 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- ret->names.names_len = virDomainSnapshotListNames(domain,
- ret->names.names_val,
- args->nameslen,
- args->flags);
- if (ret->names.names_len == -1) {
+ len = virDomainSnapshotListNames(domain,
+ ret->names.names_val,
+ args->nameslen,
+ args->flags);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -8730,7 +8750,7 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
if (snapshot == NULL)
goto cleanup;
- if (virDomainRevertToSnapshot(snapshot, args->flags) == -1)
+ if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
goto cleanup;
rv = 0;
@@ -8771,7 +8791,7 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
if (snapshot == NULL)
goto cleanup;
- if (virDomainSnapshotDelete(snapshot, args->flags) == -1)
+ if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
goto cleanup;
rv = 0;
@@ -9004,7 +9024,7 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNWFilterUndefine(nwfilter) == -1) {
+ if (virNWFilterUndefine(nwfilter) < 0) {
goto cleanup;
}
@@ -9028,6 +9048,7 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_nwfilters_ret *ret)
{
int rv = -1;
+ int len;
if (!conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -9046,12 +9067,12 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->names.names_len =
- virConnectListNWFilters(conn,
- ret->names.names_val, args->maxnames);
- if (ret->names.names_len == -1) {
+ len = virConnectListNWFilters(conn,
+ ret->names.names_val, args->maxnames);
+ if (len < 0) {
goto cleanup;
}
+ ret->names.names_len = len;
rv = 0;
@@ -9120,7 +9141,7 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfNWFilters(conn);
- if (ret->num == -1) {
+ if (ret->num < 0) {
goto cleanup;
}
@@ -9156,7 +9177,7 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) == -1) {
+ if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) < 0) {
goto cleanup;
}
@@ -9197,7 +9218,7 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
- args->flags) == -1) {
+ args->flags) < 0) {
goto cleanup;
}
@@ -9246,7 +9267,7 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
args->devname ? *args->devname : NULL,
stream->st,
args->flags);
- if (r == -1) {
+ if (r < 0) {
goto cleanup;
}
--
1.7.4.2
2
2
The defualt CFLAGS is `-g -Wall'. We can change it with
./configure CFLAGS="your option". The `-g' options also make
it able to build debugsource & debuginfo packages.
---
src/Makefile.am | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 76ebee6..6fab5f0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,8 +8,8 @@ EXTRA_DIST = libvirt-php.c libvirt-php.h
all-am: build clean-temp
build:
- $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt-php.c $(LIBXML_CFLAGS) $(DEFINES)
- $(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(LIBXML_LIBS)
+ $(CC) $(CFLAGS) -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt-php.c $(LIBXML_CFLAGS) $(DEFINES)
+ $(CC) $(CFLAGS) -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(LIBXML_LIBS)
$(ECHO) "Extension compiled as $(PACKAGE).so"
install-exec-local:
--
1.7.3.4
2
3
Hi,
this is the commit to introduce the function to create new character
device definition for the domain as advices by Cole Robinson
<crobinso(a)redhat.com>.
The function is used on the relevant places and the make, make check
and make syntax-check all passed.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Signed-off-by: Michal Novotny <mignov(a)gmail.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_xm.c | 3 ++-
5 files changed, 24 insertions(+), 5 deletions(-)
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..c13e416 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -333,6 +333,7 @@ virDomainWatchdogActionTypeFromString;
virDomainWatchdogActionTypeToString;
virDomainWatchdogModelTypeFromString;
virDomainWatchdogModelTypeToString;
+virDomainChrDefNew;
# domain_event.h
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_xm.c b/src/xenxs/xen_xm.c
index 22ad788..0b47f1f 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,
@@ -981,7 +982,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;
--
1.7.3.2
3
4
[libvirt] [PATCH V2] check whether domain is active after qemuDomainObjExitMonitor* returns
by Wen Congyang 14 Apr '11
by Wen Congyang 14 Apr '11
14 Apr '11
qemu may quited unexpectedly when invoking a monitor command. And priv->mon
will be NULL after qemuDomainObjExitMonitor* returns. So we must not use it.
Unfortunately we still use it, and it will cause libvirtd crashed.
As Eric suggested, qemuDomainObjExitMonitor* should be made to return the value
of vm active after regaining lock, and marked ATTRIBUTE_RETURN_CHECK, to force
all other callers to detect the case of a monitor command completing successfully
but then the VM disappearing in the window between command completion and regaining
the vm lock.
---
src/qemu/qemu_domain.c | 28 +++++++-
src/qemu/qemu_domain.h | 6 +-
src/qemu/qemu_driver.c | 51 ++++++++------
src/qemu/qemu_hotplug.c | 177 ++++++++++++++++++++++-----------------------
src/qemu/qemu_migration.c | 73 +++++++++++--------
src/qemu/qemu_process.c | 38 ++++++----
6 files changed, 212 insertions(+), 161 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a947b4e..44ad6a3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -580,7 +580,7 @@ void qemuDomainObjEnterMonitor(virDomainObjPtr obj)
*
* Should be paired with an earlier qemuDomainObjEnterMonitor() call
*/
-void qemuDomainObjExitMonitor(virDomainObjPtr obj)
+int qemuDomainObjExitMonitor(virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
int refs;
@@ -590,11 +590,22 @@ void qemuDomainObjExitMonitor(virDomainObjPtr obj)
if (refs > 0)
qemuMonitorUnlock(priv->mon);
+ /* Note: qemu may quited unexpectedly here, and the monitor will be freed.
+ * If it happened, priv->mon will be null.
+ */
+
virDomainObjLock(obj);
if (refs == 0) {
priv->mon = NULL;
}
+
+ if (priv->mon == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("guest unexpectedly quit"));
+ return -1;
+ } else
+ return 0;
}
@@ -623,8 +634,8 @@ void qemuDomainObjEnterMonitorWithDriver(struct qemud_driver *driver,
*
* Should be paired with an earlier qemuDomainObjEnterMonitorWithDriver() call
*/
-void qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
- virDomainObjPtr obj)
+int qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
+ virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
int refs;
@@ -634,12 +645,23 @@ void qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
if (refs > 0)
qemuMonitorUnlock(priv->mon);
+ /* Note: qemu may quited unexpectedly here, and the monitor will be freed.
+ * If it happened, priv->mon will be null.
+ */
+
qemuDriverLock(driver);
virDomainObjLock(obj);
if (refs == 0) {
priv->mon = NULL;
}
+
+ if (priv->mon == NULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("guest unexpectedly quit"));
+ return -1;
+ } else
+ return 0;
}
void qemuDomainObjEnterRemoteWithDriver(struct qemud_driver *driver,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 8258900..92fccda 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -99,11 +99,11 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver,
virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
int qemuDomainObjEndJob(virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
void qemuDomainObjEnterMonitor(virDomainObjPtr obj);
-void qemuDomainObjExitMonitor(virDomainObjPtr obj);
+int qemuDomainObjExitMonitor(virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
void qemuDomainObjEnterMonitorWithDriver(struct qemud_driver *driver,
virDomainObjPtr obj);
-void qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
- virDomainObjPtr obj);
+int qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
+ virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
void qemuDomainObjEnterRemoteWithDriver(struct qemud_driver *driver,
virDomainObjPtr obj);
void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 04a5f65..cb9f3fa 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1452,7 +1452,8 @@ static int qemudDomainShutdown(virDomainPtr dom) {
priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
ret = qemuMonitorSystemPowerdown(priv->mon);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
endjob:
if (qemuDomainObjEndJob(vm) == 0)
@@ -1659,7 +1660,8 @@ static int qemudDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
r = qemuMonitorSetBalloon(priv->mon, newmem);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ r = -1;
qemuAuditMemory(vm, vm->def->mem.cur_balloon, newmem, "update",
r == 1);
if (r < 0)
@@ -1749,7 +1751,8 @@ static int qemudDomainGetInfo(virDomainPtr dom,
else {
qemuDomainObjEnterMonitor(vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ err = -1;
}
if (qemuDomainObjEndJob(vm) == 0) {
vm = NULL;
@@ -2524,7 +2527,8 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
ret = 0;
cleanup:
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
vm->def->vcpus = vcpus;
qemuAuditVcpu(vm, oldvcpus, nvcpus, "update", rc == 1);
return ret;
@@ -3295,7 +3299,8 @@ static char *qemudDomainDumpXML(virDomainPtr dom,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ err = -1;
if (qemuDomainObjEndJob(vm) == 0) {
vm = NULL;
goto cleanup;
@@ -4843,7 +4848,8 @@ qemudDomainBlockStats (virDomainPtr dom,
&stats->wr_req,
&stats->wr_bytes,
&stats->errs);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
endjob:
if (qemuDomainObjEndJob(vm) == 0)
@@ -4944,7 +4950,8 @@ qemudDomainMemoryStats (virDomainPtr dom,
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
ret = qemuMonitorGetMemoryStats(priv->mon, stats, nr_stats);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
} else {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
@@ -5085,17 +5092,15 @@ qemudDomainMemoryPeek (virDomainPtr dom,
priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
if (flags == VIR_MEMORY_VIRTUAL) {
- if (qemuMonitorSaveVirtualMemory(priv->mon, offset, size, tmp) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto endjob;
- }
+ ret = qemuMonitorSaveVirtualMemory(priv->mon, offset, size, tmp);
} else {
- if (qemuMonitorSavePhysicalMemory(priv->mon, offset, size, tmp) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto endjob;
- }
+ ret = qemuMonitorSavePhysicalMemory(priv->mon, offset, size, tmp);
}
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
+
+ if (ret < -1)
+ goto endjob;
/* Read the memory file into buffer. */
if (saferead (fd, buffer, size) == (ssize_t) -1) {
@@ -5259,7 +5264,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
ret = qemuMonitorGetBlockExtent(priv->mon,
disk->info.alias,
&info->allocation);
- qemuDomainObjExitMonitor(vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
}
if (qemuDomainObjEndJob(vm) == 0)
@@ -6101,7 +6107,8 @@ qemuDomainSnapshotCreateActive(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
cleanup:
if (resume && virDomainObjIsActive(vm) &&
@@ -6434,7 +6441,8 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
priv = vm->privateData;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
rc = qemuMonitorLoadSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ rc = -1;
if (rc < 0)
goto endjob;
}
@@ -6557,7 +6565,7 @@ static int qemuDomainSnapshotDiscard(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
/* we continue on even in the face of error */
qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ignore_value(qemuDomainObjExitMonitorWithDriver(driver, vm));
}
if (snap == vm->current_snapshot) {
@@ -6770,7 +6778,8 @@ static int qemuDomainMonitorCommand(virDomainPtr domain, const char *cmd,
goto cleanup;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
if (qemuDomainObjEndJob(vm) == 0) {
vm = NULL;
goto cleanup;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b03f774..1ecac80 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -106,7 +106,8 @@ int qemuDomainChangeEjectableMedia(struct qemud_driver *driver,
} else {
ret = qemuMonitorEjectMedia(priv->mon, driveAlias, force);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditDisk(vm, origdisk, disk, "update", ret >= 0);
@@ -201,7 +202,8 @@ int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver,
memcpy(&disk->info.addr.pci, &guestAddr, sizeof(guestAddr));
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditDisk(vm, NULL, disk, "attach", ret >= 0);
@@ -277,7 +279,8 @@ int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver,
type,
&controller->info.addr.pci);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
if (ret == 0) {
controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
@@ -433,7 +436,8 @@ int qemuDomainAttachSCSIDisk(struct qemud_driver *driver,
memcpy(&disk->info.addr.drive, &driveAddr, sizeof(driveAddr));
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditDisk(vm, NULL, disk, "attach", ret >= 0);
@@ -516,7 +520,8 @@ int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver,
} else {
ret = qemuMonitorAddUSBDisk(priv->mon, disk->src);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditDisk(vm, NULL, disk, "attach", ret >= 0);
@@ -632,21 +637,19 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCapsGet(qemuCaps, QEMU_CAPS_NETDEV) &&
qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorAddNetdev(priv->mon, netstr, tapfd, tapfd_name,
- vhostfd, vhostfd_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, NULL, net, "attach", false);
- goto cleanup;
- }
+ ret = qemuMonitorAddNetdev(priv->mon, netstr, tapfd, tapfd_name,
+ vhostfd, vhostfd_name);
} else {
- if (qemuMonitorAddHostNetwork(priv->mon, netstr, tapfd, tapfd_name,
- vhostfd, vhostfd_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, NULL, net, "attach", false);
- goto cleanup;
- }
+ ret = qemuMonitorAddHostNetwork(priv->mon, netstr, tapfd, tapfd_name,
+ vhostfd, vhostfd_name);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
+
+ qemuAuditNet(vm, NULL, net, "attach", ret >= 0);
+
+ if (ret < 0)
+ goto cleanup;
VIR_FORCE_CLOSE(tapfd);
VIR_FORCE_CLOSE(vhostfd);
@@ -667,25 +670,23 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, NULL, net, "attach", false);
- goto try_remove;
- }
+ ret = qemuMonitorAddDevice(priv->mon, nicstr);
} else {
- if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
- &guestAddr) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, NULL, net, "attach", false);
- goto try_remove;
+ ret = qemuMonitorAddPCINetwork(priv->mon, nicstr,
+ &guestAddr);
+ if (ret == 0) {
+ net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+ memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
}
- net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditNet(vm, NULL, net, "attach", true);
+ if (ret < 0)
+ goto try_remove;
+
ret = 0;
vm->def->nets[vm->def->nnets++] = net;
@@ -723,7 +724,7 @@ try_remove:
if (qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0)
VIR_WARN("Failed to remove network backend for netdev %s",
netdev_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ignore_value(qemuDomainObjExitMonitorWithDriver(driver, vm));
VIR_FREE(netdev_name);
} else {
VIR_WARN0("Unable to remove network backend");
@@ -736,7 +737,7 @@ try_remove:
if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
VIR_WARN("Failed to remove network backend for vlan %d, net %s",
vlan, hostnet_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ignore_value(qemuDomainObjExitMonitorWithDriver(driver, vm));
VIR_FREE(hostnet_name);
}
goto cleanup;
@@ -795,7 +796,8 @@ int qemuDomainAttachHostPciDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
configfd, configfd_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
} else {
virDomainDevicePCIAddress guestAddr;
@@ -803,7 +805,8 @@ int qemuDomainAttachHostPciDevice(struct qemud_driver *driver,
ret = qemuMonitorAddPCIHostDevice(priv->mon,
&hostdev->source.subsys.u.pci,
&guestAddr);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
hostdev->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&hostdev->info.addr.pci, &guestAddr, sizeof(guestAddr));
@@ -886,7 +889,8 @@ int qemuDomainAttachHostUsbDevice(struct qemud_driver *driver,
ret = qemuMonitorAddUSBDeviceExact(priv->mon,
hostdev->source.subsys.u.usb.bus,
hostdev->source.subsys.u.usb.device);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditHostdev(vm, hostdev, "attach", ret == 0);
if (ret < 0)
goto error;
@@ -1145,25 +1149,24 @@ int qemuDomainDetachPciDiskDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
- }
+ ret = qemuMonitorDelDevice(priv->mon, detach->info.alias);
} else {
- if (qemuMonitorRemovePCIDevice(priv->mon,
- &detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
- }
+ ret = qemuMonitorRemovePCIDevice(priv->mon,
+ &detach->info.addr.pci);
}
/* disconnect guest from host device */
- qemuMonitorDriveDel(priv->mon, drivestr);
+ if (ret == 0)
+ qemuMonitorDriveDel(priv->mon, drivestr);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitor(vm) < 0)
+ ret = -1;
qemuAuditDisk(vm, detach, NULL, "detach", ret >= 0);
+ if (ret < 0)
+ goto cleanup;
+
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0)
VIR_WARN("Unable to release PCI address on %s", dev->data.disk->src);
@@ -1235,18 +1238,20 @@ int qemuDomainDetachDiskDevice(struct qemud_driver *driver,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
- }
+ ret = qemuMonitorDelDevice(priv->mon, detach->info.alias);
/* disconnect guest from host device */
- qemuMonitorDriveDel(priv->mon, drivestr);
+ if (ret == 0)
+ qemuMonitorDriveDel(priv->mon, drivestr);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditDisk(vm, detach, NULL, "detach", ret >= 0);
+ if (ret < 0)
+ goto cleanup;
+
virDomainDiskRemove(vm->def, i);
virDomainDiskDefFree(detach);
@@ -1364,18 +1369,16 @@ int qemuDomainDetachPciControllerDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
- }
+ ret = qemuMonitorDelDevice(priv->mon, detach->info.alias);
} else {
- if (qemuMonitorRemovePCIDevice(priv->mon,
- &detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
- }
+ ret = qemuMonitorRemovePCIDevice(priv->mon,
+ &detach->info.addr.pci);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
+
+ if (ret < 0)
+ goto cleanup;
if (vm->def->ncontrollers > 1) {
memmove(vm->def->controllers + i,
@@ -1452,37 +1455,30 @@ int qemuDomainDetachNetDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitor(vm);
- qemuAuditNet(vm, detach, NULL, "detach", false);
- goto cleanup;
- }
+ ret = qemuMonitorDelDevice(priv->mon, detach->info.alias);
} else {
- if (qemuMonitorRemovePCIDevice(priv->mon,
- &detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, detach, NULL, "detach", false);
- goto cleanup;
- }
+ ret = qemuMonitorRemovePCIDevice(priv->mon,
+ &detach->info.addr.pci);
}
+ if (ret < 0)
+ goto exitmonitor;
+
if (qemuCapsGet(qemuCaps, QEMU_CAPS_NETDEV) &&
qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, detach, NULL, "detach", false);
- goto cleanup;
- }
+ ret = qemuMonitorRemoveNetdev(priv->mon, hostnet_name);
} else {
- if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, detach, NULL, "detach", false);
- goto cleanup;
- }
+ ret = qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- qemuAuditNet(vm, detach, NULL, "detach", true);
+exitmonitor:
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
+
+ qemuAuditNet(vm, detach, NULL, "detach", ret >= 0);
+
+ if (ret < 0)
+ goto cleanup;
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0)
@@ -1582,7 +1578,8 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
} else {
ret = qemuMonitorRemovePCIDevice(priv->mon, &detach->info.addr.pci);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditHostdev(vm, detach, "detach", ret == 0);
if (ret < 0)
return -1;
@@ -1681,7 +1678,8 @@ int qemuDomainDetachHostUsbDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorDelDevice(priv->mon, detach->info.alias);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
qemuAuditHostdev(vm, detach, "detach", ret == 0);
if (ret < 0)
return -1;
@@ -1798,7 +1796,8 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
}
cleanup:
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
return ret;
}
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 43741e1..bdc05c0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -125,7 +125,8 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm)
VIR_DEBUG0("Cancelling job at client request");
qemuDomainObjEnterMonitorWithDriver(driver, vm);
rc = qemuMonitorMigrateCancel(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ rc = -1;
if (rc < 0) {
VIR_WARN0("Unable to cancel job");
}
@@ -142,7 +143,8 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm)
VIR_DEBUG("Setting migration downtime to %llums", ms);
qemuDomainObjEnterMonitorWithDriver(driver, vm);
rc = qemuMonitorSetMigrationDowntime(priv->mon, ms);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ rc = -1;
if (rc < 0)
VIR_WARN0("Unable to set migration downtime");
} else if (priv->jobSignals & QEMU_JOB_SIGNAL_MIGRATE_SPEED) {
@@ -153,7 +155,8 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm)
VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
qemuDomainObjEnterMonitorWithDriver(driver, vm);
rc = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ rc = -1;
if (rc < 0)
VIR_WARN0("Unable to set migration speed");
}
@@ -173,7 +176,8 @@ qemuMigrationWaitForCompletion(struct qemud_driver *driver, virDomainObjPtr vm)
&memProcessed,
&memRemaining,
&memTotal);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ rc = -1;
if (rc < 0) {
priv->jobInfo.type = VIR_DOMAIN_JOB_FAILED;
@@ -608,11 +612,13 @@ static int doNativeMigrate(struct qemud_driver *driver,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (resource > 0 &&
- qemuMonitorSetMigrationSpeed(priv->mon, resource) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
- }
+ if (resource > 0)
+ ret = qemuMonitorSetMigrationSpeed(priv->mon, resource);
+ else
+ ret = 0;
+
+ if (ret < 0)
+ goto exitmonitor;
if (flags & VIR_MIGRATE_NON_SHARED_DISK)
background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
@@ -620,12 +626,15 @@ static int doNativeMigrate(struct qemud_driver *driver,
if (flags & VIR_MIGRATE_NON_SHARED_INC)
background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
- if (qemuMonitorMigrateToHost(priv->mon, background_flags, uribits->server,
- uribits->port) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ret = qemuMonitorMigrateToHost(priv->mon, background_flags, uribits->server,
+ uribits->port);
+
+exitmonitor:
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
+
+ if (ret < 0)
goto cleanup;
- }
- qemuDomainObjExitMonitorWithDriver(driver, vm);
if (qemuMigrationWaitForCompletion(driver, vm) < 0)
goto cleanup;
@@ -824,7 +833,8 @@ static int doTunnelMigrate(struct qemud_driver *driver,
} else {
internalret = -1;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ internalret = -1;
if (internalret < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("tunnelled migration monitor command failed"));
@@ -844,17 +854,15 @@ static int doTunnelMigrate(struct qemud_driver *driver,
* rather failed later on. Check the output of "info migrate"
*/
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorGetMigrationStatus(priv->mon,
- &status,
- &transferred,
- &remaining,
- &total) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cancel;
- }
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ retval = qemuMonitorGetMigrationStatus(priv->mon,
+ &status,
+ &transferred,
+ &remaining,
+ &total);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ retval = -1;
- if (status == QEMU_MONITOR_MIGRATION_STATUS_ERROR) {
+ if (retval < 0 || status == QEMU_MONITOR_MIGRATION_STATUS_ERROR) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s",_("migrate failed"));
goto cancel;
@@ -875,7 +883,7 @@ cancel:
if (retval != 0 && virDomainObjIsActive(vm)) {
qemuDomainObjEnterMonitorWithDriver(driver, vm);
qemuMonitorMigrateCancel(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ignore_value(qemuDomainObjExitMonitorWithDriver(driver, vm));
}
finish:
@@ -1372,12 +1380,12 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
if (virSetCloseExec(pipeFD[1]) < 0) {
virReportSystemError(errno, "%s",
_("Unable to set cloexec flag"));
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
+ rc = -1;
+ goto exitmonitor;
}
if (virCommandRunAsync(cmd, NULL) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
+ rc = -1;
+ goto exitmonitor;
}
rc = qemuMonitorMigrateToFd(priv->mon,
QEMU_MONITOR_MIGRATE_BACKGROUND,
@@ -1391,7 +1399,10 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
args, path, offset);
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+
+exitmonitor:
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ rc = -1;
if (rc < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7295f9e..374de0f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -662,7 +662,8 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorSetCapabilities(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
error:
@@ -1070,7 +1071,8 @@ qemuProcessWaitForMonitor(struct qemud_driver* driver,
priv = vm->privateData;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorGetPtyPaths(priv->mon, paths);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
VIR_DEBUG("qemuMonitorGetPtyPaths returned %i", ret);
if (ret == 0)
@@ -1122,11 +1124,12 @@ qemuProcessDetectVcpuPIDs(struct qemud_driver *driver,
/* What follows is now all KVM specific */
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ncpupids = -1;
+
+ if (ncpupids < 0)
return -1;
- }
- qemuDomainObjExitMonitorWithDriver(driver, vm);
/* Treat failure to get VCPU<->PID mapping as non-fatal */
if (ncpupids == 0)
@@ -1322,7 +1325,8 @@ qemuProcessInitPasswords(virConnectPtr conn,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
VIR_FREE(secret);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
if (ret < 0)
goto cleanup;
}
@@ -1713,7 +1717,10 @@ qemuProcessInitPCIAddresses(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
naddrs = qemuMonitorGetAllPCIAddresses(priv->mon,
&addrs);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0) {
+ VIR_FREE(addrs);
+ return -1;
+ }
ret = qemuProcessDetectPCIAddresses(vm, addrs, naddrs);
@@ -1890,7 +1897,8 @@ qemuProcessStartCPUs(struct qemud_driver *driver, virDomainObjPtr vm,
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorStartCPUs(priv->mon, conn);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
if (ret == 0) {
vm->state = VIR_DOMAIN_RUNNING;
}
@@ -1908,7 +1916,8 @@ int qemuProcessStopCPUs(struct qemud_driver *driver, virDomainObjPtr vm)
vm->state = VIR_DOMAIN_PAUSED;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorStopCPUs(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
if (ret < 0) {
vm->state = oldState;
}
@@ -2389,11 +2398,12 @@ int qemuProcessStart(virConnectPtr conn,
VIR_DEBUG0("Setting initial memory amount");
cur_balloon = vm->def->mem.cur_balloon;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorSetBalloon(priv->mon, cur_balloon) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ ret = qemuMonitorSetBalloon(priv->mon, cur_balloon);
+ if (qemuDomainObjExitMonitorWithDriver(driver, vm) < 0)
+ ret = -1;
+
+ if (ret < 0)
goto cleanup;
- }
- qemuDomainObjExitMonitorWithDriver(driver, vm);
if (!start_paused) {
VIR_DEBUG0("Starting domain CPUs");
--
1.7.1
1
0
[libvirt] [PATCH] Allow to dynamically set the size of the debug buffer
by Daniel Veillard 14 Apr '11
by Daniel Veillard 14 Apr '11
14 Apr '11
This is the part allowing to dynamically resize the debug log
buffer from it's default 64kB size. The buffer is now dynamically
allocated.
It adds a new API virLogSetBufferSize() which resizes the buffer
(possibly dynamically but in that case the existing content is lost -
the complexity wasn't looking like worth it).
If passed a zero size, the buffer is deallocated and we do the small
optimization of not formatting messages which are not output anymore.
On the daemon side, it just adds a new option log_buffer_size to
libvirtd.conf and call virLogSetBufferSize() if needed (minor
pbm of the GET_CONF_* macros is you can't guess if the value was set
or not)
Seems to work fine, I tried to keep the code as simple as needed,
this allowed me to find out that on a quiet daemon startup we emit
half a megabyte of debug log !
The next patch missing now is the update of the documentation for the
log buffer.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
3
7
[libvirt] [PATCH] Write error check conditionals in more compact form for dispatcher
by Daniel P. Berrange 14 Apr '11
by Daniel P. Berrange 14 Apr '11
14 Apr '11
Replace cases of
type = virConnectGetType(conn);
if (type == NULL)
goto cleanup;
With
if (!(type = virConnectGetType(conn)))
goto cleanup;
* daemon/remote.c: Write error checks in compat form
---
daemon/remote.c | 795 +++++++++++++++++++------------------------------------
1 files changed, 278 insertions(+), 517 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 247a226..66df9f7 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -473,9 +473,7 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->supported = virDrvSupportsFeature(conn, args->feature);
-
- if (ret->supported < 0)
+ if ((ret->supported = virDrvSupportsFeature(conn, args->feature)) < 0)
goto cleanup;
rv = 0;
@@ -502,15 +500,13 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- type = virConnectGetType(conn);
- if (type == NULL)
+ if (!(type = virConnectGetType(conn)))
goto cleanup;
/* We have to strdup because remoteDispatchClientRequest will
* free this string after it's been serialised.
*/
- ret->type = strdup(type);
- if (!ret->type) {
+ if (!(ret->type = strdup(type))) {
virReportOOMError();
goto cleanup;
}
@@ -598,8 +594,7 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- hostname = virConnectGetHostname(conn);
- if (hostname == NULL)
+ if (!(hostname = virConnectGetHostname(conn)))
goto cleanup;
ret->hostname = hostname;
@@ -628,8 +623,7 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- uri = virConnectGetURI(conn);
- if (uri == NULL)
+ if (!(uri = virConnectGetURI(conn)))
goto cleanup;
ret->uri = uri;
@@ -660,8 +654,7 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
}
flags = args->flags;
- sysinfo = virConnectGetSysinfo(conn, flags);
- if (sysinfo == NULL)
+ if (!(sysinfo = virConnectGetSysinfo(conn, flags)))
goto cleanup;
ret->sysinfo = sysinfo;
@@ -691,8 +684,7 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
}
type = args->type ? *args->type : NULL;
- ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
- if (ret->max_vcpus < 0)
+ if ((ret->max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
goto cleanup;
rv = 0;
@@ -757,8 +749,7 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- caps = virConnectGetCapabilities(conn);
- if (caps == NULL)
+ if (!(caps = virConnectGetCapabilities(conn)))
goto cleanup;
ret->capabilities = caps;
@@ -779,7 +770,7 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
remote_node_get_cells_free_memory_args *args,
remote_node_get_cells_free_memory_ret *ret)
{
- int err;
+ int len;
int rv = -1;
if (!conn) {
@@ -799,13 +790,13 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- err = virNodeGetCellsFreeMemory(conn,
+ len = virNodeGetCellsFreeMemory(conn,
(unsigned long long *)ret->freeMems.freeMems_val,
args->startCell,
args->maxCells);
- if (err <= 0)
+ if (len <= 0)
goto cleanup;
- ret->freeMems.freeMems_len = err;
+ ret->freeMems.freeMems_len = len;
rv = 0;
@@ -835,8 +826,7 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- freeMem = virNodeGetFreeMemory(conn);
- if (freeMem == 0)
+ if ((freeMem = virNodeGetFreeMemory(conn)) == 0)
goto cleanup;
ret->freeMem = freeMem;
rv = 0;
@@ -867,12 +857,10 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- type = virDomainGetSchedulerType(dom, &nparams);
- if (type == NULL)
+ if (!(type = virDomainGetSchedulerType(dom, &nparams)))
goto cleanup;
ret->type = type;
@@ -898,7 +886,7 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
{
virDomainPtr dom = NULL;
virSchedParameterPtr params;
- int i, r, nparams;
+ int i, nparams;
int rv = -1;
if (!conn) {
@@ -917,12 +905,10 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- r = virDomainGetSchedulerParameters(dom, params, &nparams);
- if (r < 0)
+ if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0)
goto cleanup;
/* Serialise the scheduler parameters. */
@@ -984,7 +970,7 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom = NULL;
- int i, r, nparams;
+ int i, nparams;
virSchedParameterPtr params;
int rv = -1;
@@ -1028,12 +1014,10 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
}
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- r = virDomainSetSchedulerParameters(dom, params, nparams);
- if (r < 0)
+ if (virDomainSetSchedulerParameters(dom, params, nparams) < 0)
goto cleanup;
rv = 0;
@@ -1066,8 +1050,7 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
path = args->path;
@@ -1109,8 +1092,7 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
path = args->path;
@@ -1161,8 +1143,7 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
/* Allocate stats array for making dispatch call */
@@ -1219,8 +1200,7 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
path = args->path;
offset = args->offset;
@@ -1275,8 +1255,7 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
offset = args->offset;
size = args->size;
@@ -1329,8 +1308,7 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainAttachDevice(dom, args->xml) < 0)
@@ -1363,8 +1341,7 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) < 0)
@@ -1397,8 +1374,7 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0)
@@ -1431,8 +1407,7 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainCreate(dom) < 0)
@@ -1460,8 +1435,7 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
int rv = -1;
virDomainPtr dom = NULL;
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainCreateWithFlags(dom, args->flags) < 0)
@@ -1496,8 +1470,7 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
- if (dom == NULL)
+ if (!(dom = virDomainCreateXML(conn, args->xml_desc, args->flags)))
goto cleanup;
make_nonnull_domain(&ret->dom, dom);
@@ -1529,8 +1502,7 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = virDomainDefineXML(conn, args->xml);
- if (dom == NULL)
+ if (!(dom = virDomainDefineXML(conn, args->xml)))
goto cleanup;
make_nonnull_domain(&ret->dom, dom);
@@ -1562,8 +1534,7 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainDestroy(dom) < 0)
@@ -1596,8 +1567,7 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainDetachDevice(dom, args->xml) < 0)
@@ -1630,8 +1600,7 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) < 0)
@@ -1664,13 +1633,11 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virDomainGetXMLDesc(dom, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virDomainGetXMLDesc(dom, args->flags)))
goto cleanup;
rv = 0;
@@ -1700,12 +1667,12 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
}
/* remoteDispatchClientRequest will free this. */
- ret->domainXml = virConnectDomainXMLFromNative(conn,
- args->nativeFormat,
- args->nativeConfig,
- args->flags);
- if (!ret->domainXml)
+ if (!(ret->domainXml = virConnectDomainXMLFromNative(conn,
+ args->nativeFormat,
+ args->nativeConfig,
+ args->flags)))
goto cleanup;
+
rv = 0;
cleanup:
@@ -1731,12 +1698,12 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
}
/* remoteDispatchClientRequest will free this. */
- ret->nativeConfig = virConnectDomainXMLToNative(conn,
- args->nativeFormat,
- args->domainXml,
- args->flags);
- if (!ret->nativeConfig)
+ if (!(ret->nativeConfig = virConnectDomainXMLToNative(conn,
+ args->nativeFormat,
+ args->domainXml,
+ args->flags)))
goto cleanup;
+
rv = 0;
cleanup:
@@ -1763,8 +1730,7 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetAutostart(dom, &ret->autostart) < 0)
@@ -1798,8 +1764,7 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetInfo(dom, &info) < 0)
@@ -1838,12 +1803,10 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->memory = virDomainGetMaxMemory(dom);
- if (ret->memory == 0)
+ if ((ret->memory = virDomainGetMaxMemory(dom)) == 0)
goto cleanup;
rv = 0;
@@ -1873,12 +1836,10 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->num = virDomainGetMaxVcpus(dom);
- if (ret->num < 0)
+ if ((ret->num = virDomainGetMaxVcpus(dom)) < 0)
goto cleanup;
rv = 0;
@@ -1909,8 +1870,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (VIR_ALLOC(seclabel) < 0) {
@@ -2000,14 +1960,13 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
/* remoteDispatchClientRequest will free this */
- ret->type = virDomainGetOSType(dom);
- if (ret->type == NULL)
+ if (!(ret->type = virDomainGetOSType(dom)))
goto cleanup;
+
rv = 0;
cleanup:
@@ -2038,8 +1997,7 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
@@ -2059,10 +2017,9 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
goto no_memory;
- info_len = virDomainGetVcpus(dom,
- info, args->maxinfo,
- cpumaps, args->maplen);
- if (info_len < 0)
+ if ((info_len = virDomainGetVcpus(dom,
+ info, args->maxinfo,
+ cpumaps, args->maplen)) < 0)
goto cleanup;
/* Allocate the return buffer for info. */
@@ -2120,12 +2077,10 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->num = virDomainGetVcpusFlags(dom, args->flags);
- if (ret->num < 0)
+ if ((ret->num = virDomainGetVcpusFlags(dom, args->flags)) < 0)
goto cleanup;
rv = 0;
@@ -2147,7 +2102,6 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_prepare_args *args,
remote_domain_migrate_prepare_ret *ret)
{
- int r;
char *cookie = NULL;
int cookielen = 0;
char *uri_in;
@@ -2169,10 +2123,9 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- r = virDomainMigratePrepare(conn, &cookie, &cookielen,
+ if (virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
- args->flags, dname, args->resource);
- if (r < 0)
+ args->flags, dname, args->resource) < 0)
goto cleanup;
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2205,7 +2158,6 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_perform_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int r;
virDomainPtr dom = NULL;
char *dname;
int rv = -1;
@@ -2215,18 +2167,16 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
dname = args->dname == NULL ? NULL : *args->dname;
- r = virDomainMigratePerform(dom,
+ if (virDomainMigratePerform(dom,
args->cookie.cookie_val,
args->cookie.cookie_len,
args->uri,
- args->flags, dname, args->resource);
- if (r < 0)
+ args->flags, dname, args->resource) < 0)
goto cleanup;
rv = 0;
@@ -2256,12 +2206,11 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ddom = virDomainMigrateFinish(conn, args->dname,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags);
- if (ddom == NULL)
+ if (!(ddom = virDomainMigrateFinish(conn, args->dname,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags)))
goto cleanup;
make_nonnull_domain(&ret->ddom, ddom);
@@ -2284,7 +2233,6 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_migrate_prepare2_args *args,
remote_domain_migrate_prepare2_ret *ret)
{
- int r;
char *cookie = NULL;
int cookielen = 0;
char *uri_in;
@@ -2306,11 +2254,10 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
+ if (virDomainMigratePrepare2(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource,
- args->dom_xml);
- if (r < 0)
+ args->dom_xml) < 0)
goto cleanup;
/* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2345,13 +2292,12 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ddom = virDomainMigrateFinish2(conn, args->dname,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags,
- args->retcode);
- if (ddom == NULL)
+ if (!(ddom = virDomainMigrateFinish2(conn, args->dname,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags,
+ args->retcode)))
goto cleanup;
make_nonnull_domain(&ret->ddom, ddom);
@@ -2375,7 +2321,6 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
remote_domain_migrate_prepare_tunnel_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int r;
char *dname;
struct qemud_client_stream *stream = NULL;
int rv = -1;
@@ -2387,16 +2332,14 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
dname = args->dname == NULL ? NULL : *args->dname;
- stream = remoteCreateClientStream(conn, hdr);
- if (!stream) {
+ if (!(stream = remoteCreateClientStream(conn, hdr))) {
virReportOOMError();
goto cleanup;
}
- r = virDomainMigratePrepareTunnel(conn, stream->st,
+ if (virDomainMigratePrepareTunnel(conn, stream->st,
args->flags, dname, args->resource,
- args->dom_xml);
- if (r < 0)
+ args->dom_xml) < 0)
goto cleanup;
if (remoteAddClientStream(client, stream, 0) < 0)
@@ -2477,8 +2420,7 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = virDomainLookupByID(conn, args->id);
- if (dom == NULL)
+ if (!(dom = virDomainLookupByID(conn, args->id)))
goto cleanup;
make_nonnull_domain(&ret->dom, dom);
@@ -2510,8 +2452,7 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = virDomainLookupByName(conn, args->name);
- if (dom == NULL)
+ if (!(dom = virDomainLookupByName(conn, args->name)))
goto cleanup;
make_nonnull_domain(&ret->dom, dom);
@@ -2543,8 +2484,7 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
- if (dom == NULL)
+ if (!(dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid)))
goto cleanup;
make_nonnull_domain(&ret->dom, dom);
@@ -2575,8 +2515,7 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfDefinedDomains(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfDefinedDomains(conn)) < 0)
goto cleanup;
rv = 0;
@@ -2604,8 +2543,7 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
@@ -2613,10 +2551,9 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- rv = virDomainPinVcpu(dom, args->vcpu,
- (unsigned char *) args->cpumap.cpumap_val,
- args->cpumap.cpumap_len);
- if (rv < 0)
+ if (virDomainPinVcpu(dom, args->vcpu,
+ (unsigned char *) args->cpumap.cpumap_val,
+ args->cpumap.cpumap_len) < 0)
goto cleanup;
rv = 0;
@@ -2646,8 +2583,7 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainReboot(dom, args->flags) < 0)
@@ -2707,8 +2643,7 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainResume(dom) < 0)
@@ -2741,8 +2676,7 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSave(dom, args->to) < 0)
@@ -2775,8 +2709,7 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainCoreDump(dom, args->to, args->flags) < 0)
@@ -2809,8 +2742,7 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSetAutostart(dom, args->autostart) < 0)
@@ -2843,8 +2775,7 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSetMaxMemory(dom, args->memory) < 0)
@@ -2877,8 +2808,7 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSetMemory(dom, args->memory) < 0)
@@ -2911,8 +2841,7 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0)
@@ -2941,7 +2870,7 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
* args, void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom = NULL;
- int i, r, nparams;
+ int i, nparams;
virMemoryParameterPtr params;
unsigned int flags;
int rv = -1;
@@ -3007,12 +2936,10 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
}
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- if (r < 0)
+ if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0)
goto cleanup;
rv = 0;
@@ -3042,7 +2969,7 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
{
virDomainPtr dom = NULL;
virMemoryParameterPtr params;
- int i, r, nparams;
+ int i, nparams;
unsigned int flags;
int rv = -1;
@@ -3063,13 +2990,12 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
- if (r < 0)
+ if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
goto cleanup;
+
/* In this case, we need to send back the number of parameters
* supported
*/
@@ -3158,7 +3084,7 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
* args, void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom = NULL;
- int i, r, nparams;
+ int i, nparams;
virBlkioParameterPtr params;
unsigned int flags;
int rv = -1;
@@ -3224,12 +3150,10 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
}
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- if (r < 0)
+ if (virDomainSetBlkioParameters(dom, params, nparams, flags) < 0)
goto cleanup;
rv = 0;
@@ -3259,7 +3183,7 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
{
virDomainPtr dom = NULL;
virBlkioParameterPtr params;
- int i, r, nparams;
+ int i, nparams;
unsigned int flags;
int rv = -1;
@@ -3280,13 +3204,12 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
- if (r < 0)
+ if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
goto cleanup;
+
/* In this case, we need to send back the number of parameters
* supported
*/
@@ -3381,8 +3304,7 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSetVcpus(dom, args->nvcpus) < 0)
@@ -3415,8 +3337,7 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0)
@@ -3449,8 +3370,7 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainShutdown(dom) < 0)
@@ -3483,8 +3403,7 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainSuspend(dom) < 0)
@@ -3517,8 +3436,7 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainUndefine(dom) < 0)
@@ -3641,8 +3559,7 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainManagedSave(dom, args->flags) < 0)
@@ -3675,12 +3592,10 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
- if (ret->ret < 0)
+ if ((ret->ret = virDomainHasManagedSaveImage(dom, args->flags)) < 0)
goto cleanup;
rv = 0;
@@ -3710,8 +3625,7 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainManagedSaveRemove(dom, args->flags) < 0)
@@ -3789,8 +3703,7 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
if (virNetworkCreate(net) < 0)
@@ -3823,8 +3736,7 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = virNetworkCreateXML(conn, args->xml);
- if (net == NULL)
+ if (!(net = virNetworkCreateXML(conn, args->xml)))
goto cleanup;
make_nonnull_network(&ret->net, net);
@@ -3856,8 +3768,7 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = virNetworkDefineXML(conn, args->xml);
- if (net == NULL)
+ if (!(net = virNetworkDefineXML(conn, args->xml)))
goto cleanup;
make_nonnull_network(&ret->net, net);
@@ -3889,8 +3800,7 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
if (virNetworkDestroy(net) < 0)
@@ -3923,13 +3833,11 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virNetworkGetXMLDesc(net, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virNetworkGetXMLDesc(net, args->flags)))
goto cleanup;
rv = 0;
@@ -3959,8 +3867,7 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
if (virNetworkGetAutostart(net, &ret->autostart) < 0)
@@ -3993,13 +3900,11 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->name = virNetworkGetBridgeName(net);
- if (!ret->name)
+ if (!(ret->name = virNetworkGetBridgeName(net)))
goto cleanup;
rv = 0;
@@ -4029,8 +3934,7 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = virNetworkLookupByName(conn, args->name);
- if (net == NULL)
+ if (!(net = virNetworkLookupByName(conn, args->name)))
goto cleanup;
make_nonnull_network(&ret->net, net);
@@ -4062,8 +3966,7 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
- if (net == NULL)
+ if (!(net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid)))
goto cleanup;
make_nonnull_network(&ret->net, net);
@@ -4095,8 +3998,7 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
if (virNetworkSetAutostart(net, args->autostart) < 0)
@@ -4129,8 +4031,7 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- net = get_nonnull_network(conn, args->net);
- if (net == NULL)
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
if (virNetworkUndefine(net) < 0)
@@ -4192,8 +4093,7 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfDomains(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfDomains(conn)) < 0)
goto cleanup;
rv = 0;
@@ -4220,8 +4120,7 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfNetworks(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfNetworks(conn)) < 0)
goto cleanup;
rv = 0;
@@ -4250,8 +4149,7 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfInterfaces(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfInterfaces(conn)) < 0)
goto cleanup;
rv = 0;
@@ -4399,8 +4297,7 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- iface = virInterfaceLookupByName(conn, args->name);
- if (iface == NULL)
+ if (!(iface = virInterfaceLookupByName(conn, args->name)))
goto cleanup;
make_nonnull_interface(&ret->iface, iface);
@@ -4432,8 +4329,7 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- iface = virInterfaceLookupByMACString(conn, args->mac);
- if (iface == NULL)
+ if (!(iface = virInterfaceLookupByMACString(conn, args->mac)))
goto cleanup;
make_nonnull_interface(&ret->iface, iface);
@@ -4465,13 +4361,11 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL)
+ if (!(iface = get_nonnull_interface(conn, args->iface)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virInterfaceGetXMLDesc(iface, args->flags)))
goto cleanup;
rv = 0;
@@ -4501,8 +4395,7 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- iface = virInterfaceDefineXML(conn, args->xml, args->flags);
- if (iface == NULL)
+ if (!(iface = virInterfaceDefineXML(conn, args->xml, args->flags)))
goto cleanup;
make_nonnull_interface(&ret->iface, iface);
@@ -4534,8 +4427,7 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL)
+ if (!(iface = get_nonnull_interface(conn, args->iface)))
goto cleanup;
if (virInterfaceUndefine(iface) < 0)
@@ -4568,8 +4460,7 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL)
+ if (!(iface = get_nonnull_interface(conn, args->iface)))
goto cleanup;
if (virInterfaceCreate(iface, args->flags) < 0)
@@ -4602,8 +4493,7 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL)
+ if (!(iface = get_nonnull_interface(conn, args->iface)))
goto cleanup;
if (virInterfaceDestroy(iface, args->flags) < 0)
@@ -5528,12 +5418,11 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- ret->xml =
- virConnectFindStoragePoolSources(conn,
- args->type,
- args->srcSpec ? *args->srcSpec : NULL,
- args->flags);
- if (ret->xml == NULL)
+ if (!(ret->xml =
+ virConnectFindStoragePoolSources(conn,
+ args->type,
+ args->srcSpec ? *args->srcSpec : NULL,
+ args->flags)))
goto cleanup;
rv = 0;
@@ -5562,8 +5451,7 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolCreate(pool, args->flags) < 0)
@@ -5596,8 +5484,7 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
- if (pool == NULL)
+ if (!(pool = virStoragePoolCreateXML(conn, args->xml, args->flags)))
goto cleanup;
make_nonnull_storage_pool(&ret->pool, pool);
@@ -5629,8 +5516,7 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
- if (pool == NULL)
+ if (!(pool = virStoragePoolDefineXML(conn, args->xml, args->flags)))
goto cleanup;
make_nonnull_storage_pool(&ret->pool, pool);
@@ -5662,8 +5548,7 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolBuild(pool, args->flags) < 0)
@@ -5697,8 +5582,7 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolDestroy(pool) < 0)
@@ -5731,8 +5615,7 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolDelete(pool, args->flags) < 0)
@@ -5765,8 +5648,7 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolRefresh(pool, args->flags) < 0)
@@ -5800,8 +5682,7 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolGetInfo(pool, &info) < 0)
@@ -5839,13 +5720,11 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virStoragePoolGetXMLDesc(pool, args->flags)))
goto cleanup;
rv = 0;
@@ -5875,8 +5754,7 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0)
@@ -5910,8 +5788,7 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- pool = virStoragePoolLookupByName(conn, args->name);
- if (pool == NULL)
+ if (!(pool = virStoragePoolLookupByName(conn, args->name)))
goto cleanup;
make_nonnull_storage_pool(&ret->pool, pool);
@@ -5943,8 +5820,7 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
- if (pool == NULL)
+ if (!(pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid)))
goto cleanup;
make_nonnull_storage_pool(&ret->pool, pool);
@@ -5977,12 +5853,10 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
- pool = virStoragePoolLookupByVolume(vol);
- if (pool == NULL)
+ if (!(pool = virStoragePoolLookupByVolume(vol)))
goto cleanup;
make_nonnull_storage_pool(&ret->pool, pool);
@@ -6016,8 +5890,7 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolSetAutostart(pool, args->autostart) < 0)
@@ -6050,8 +5923,7 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
if (virStoragePoolUndefine(pool) < 0)
@@ -6083,8 +5955,7 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfStoragePools(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfStoragePools(conn)) < 0)
goto cleanup;
rv = 0;
@@ -6111,8 +5982,7 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
goto cleanup;
}
- ret->num = virConnectNumOfDefinedStoragePools(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfDefinedStoragePools(conn)) < 0)
goto cleanup;
rv = 0;
@@ -6147,8 +6017,7 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
/* Allocate return buffer. */
@@ -6193,12 +6062,10 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
- ret->num = virStoragePoolNumOfVolumes(pool);
- if (ret->num < 0)
+ if ((ret->num = virStoragePoolNumOfVolumes(pool)) < 0)
goto cleanup;
rv = 0;
@@ -6236,12 +6103,10 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
- vol = virStorageVolCreateXML(pool, args->xml, args->flags);
- if (vol == NULL)
+ if (!(vol = virStorageVolCreateXML(pool, args->xml, args->flags)))
goto cleanup;
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6276,17 +6141,14 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
- clonevol = get_nonnull_storage_vol(conn, args->clonevol);
- if (clonevol == NULL)
+ if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol)))
goto cleanup;
- newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
- args->flags);
- if (newvol == NULL)
+ if (!(newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
+ args->flags)))
goto cleanup;
make_nonnull_storage_vol(&ret->vol, newvol);
@@ -6321,8 +6183,7 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
if (virStorageVolDelete(vol, args->flags) < 0)
@@ -6355,8 +6216,7 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
if (virStorageVolWipe(vol, args->flags) < 0)
@@ -6390,8 +6250,7 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
if (virStorageVolGetInfo(vol, &info) < 0)
@@ -6428,13 +6287,11 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virStorageVolGetXMLDesc(vol, args->flags)))
goto cleanup;
rv = 0;
@@ -6465,13 +6322,11 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->name = virStorageVolGetPath(vol);
- if (!ret->name)
+ if (!(ret->name = virStorageVolGetPath(vol)))
goto cleanup;
rv = 0;
@@ -6503,12 +6358,10 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
- vol = virStorageVolLookupByName(pool, args->name);
- if (vol == NULL)
+ if (!(vol = virStorageVolLookupByName(pool, args->name)))
goto cleanup;
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6542,8 +6395,7 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- vol = virStorageVolLookupByKey(conn, args->key);
- if (vol == NULL)
+ if (!(vol = virStorageVolLookupByKey(conn, args->key)))
goto cleanup;
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6576,8 +6428,7 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- vol = virStorageVolLookupByPath(conn, args->path);
- if (vol == NULL)
+ if (!(vol = virStorageVolLookupByPath(conn, args->path)))
goto cleanup;
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6613,10 +6464,9 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virNodeNumOfDevices(conn,
- args->cap ? *args->cap : NULL,
- args->flags);
- if (ret->num < 0)
+ if ((ret->num = virNodeNumOfDevices(conn,
+ args->cap ? *args->cap : NULL,
+ args->flags)) < 0)
goto cleanup;
rv = 0;
@@ -6692,8 +6542,7 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
make_nonnull_node_device(&ret->dev, dev);
@@ -6726,13 +6575,11 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags)))
goto cleanup;
rv = 0;
@@ -6764,8 +6611,7 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
parent = virNodeDeviceGetParent(dev);
@@ -6815,12 +6661,10 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
- ret->num = virNodeDeviceNumOfCaps(dev);
- if (ret->num < 0)
+ if ((ret->num = virNodeDeviceNumOfCaps(dev)) < 0)
goto cleanup;
rv = 0;
@@ -6852,8 +6696,7 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
@@ -6904,8 +6747,7 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
if (virNodeDeviceDettach(dev) < 0)
@@ -6939,8 +6781,7 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
if (virNodeDeviceReAttach(dev) < 0)
@@ -6974,8 +6815,7 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
if (virNodeDeviceReset(dev) < 0)
@@ -7009,8 +6849,7 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags)))
goto cleanup;
make_nonnull_node_device(&ret->dev, dev);
@@ -7043,8 +6882,7 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL)
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
if (virNodeDeviceDestroy(dev) < 0)
@@ -7077,12 +6915,10 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
- stream = remoteCreateClientStream(conn, hdr);
- if (!stream)
+ if (!(stream = remoteCreateClientStream(conn, hdr)))
goto cleanup;
if (virStorageVolUpload(vol, stream->st,
@@ -7124,12 +6960,10 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
goto cleanup;
}
- vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL)
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
- stream = remoteCreateClientStream(conn, hdr);
- if (!stream)
+ if (!(stream = remoteCreateClientStream(conn, hdr)))
goto cleanup;
if (virStorageVolDownload(vol, stream->st,
@@ -7311,8 +7145,7 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfSecrets(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfSecrets(conn)) < 0)
goto cleanup;
rv = 0;
@@ -7384,8 +7217,7 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = virSecretDefineXML(conn, args->xml, args->flags);
- if (secret == NULL)
+ if (!(secret = virSecretDefineXML(conn, args->xml, args->flags)))
goto cleanup;
make_nonnull_secret(&ret->secret, secret);
@@ -7418,12 +7250,10 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL)
+ if (!(secret = get_nonnull_secret(conn, args->secret)))
goto cleanup;
- value = virSecretGetValue(secret, &value_size, args->flags);
- if (value == NULL)
+ if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
goto cleanup;
ret->value.value_len = value_size;
@@ -7456,11 +7286,9 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL)
+ if (!(secret = get_nonnull_secret(conn, args->secret)))
goto cleanup;
- ret->xml = virSecretGetXMLDesc(secret, args->flags);
- if (ret->xml == NULL)
+ if (!(ret->xml = virSecretGetXMLDesc(secret, args->flags)))
goto cleanup;
rv = 0;
@@ -7490,8 +7318,7 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
- if (secret == NULL)
+ if (!(secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid)))
goto cleanup;
make_nonnull_secret(&ret->secret, secret);
@@ -7523,8 +7350,7 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL)
+ if (!(secret = get_nonnull_secret(conn, args->secret)))
goto cleanup;
if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
args->value.value_len, args->flags) < 0)
@@ -7557,8 +7383,7 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL)
+ if (!(secret = get_nonnull_secret(conn, args->secret)))
goto cleanup;
if (virSecretUndefine(secret) < 0)
goto cleanup;
@@ -7590,8 +7415,7 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
- if (secret == NULL)
+ if (!(secret = virSecretLookupByUsage(conn, args->usageType, args->usageID)))
goto cleanup;
make_nonnull_secret(&ret->secret, secret);
@@ -7623,13 +7447,10 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->dom);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->active = virDomainIsActive(domain);
-
- if (ret->active < 0)
+ if ((ret->active = virDomainIsActive(domain)) < 0)
goto cleanup;
rv = 0;
@@ -7658,13 +7479,10 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->dom);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->persistent = virDomainIsPersistent(domain);
-
- if (ret->persistent < 0)
+ if ((ret->persistent = virDomainIsPersistent(domain)) < 0)
goto cleanup;
rv = 0;
@@ -7693,13 +7511,10 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->dom);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- ret->updated = virDomainIsUpdated(domain);
-
- if (ret->updated < 0)
+ if ((ret->updated = virDomainIsUpdated(domain)) < 0)
goto cleanup;
rv = 0;
@@ -7728,13 +7543,10 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
goto cleanup;
}
- iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL)
+ if (!(iface = get_nonnull_interface(conn, args->iface)))
goto cleanup;
- ret->active = virInterfaceIsActive(iface);
-
- if (ret->active < 0)
+ if ((ret->active = virInterfaceIsActive(iface)) < 0)
goto cleanup;
rv = 0;
@@ -7763,13 +7575,10 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- network = get_nonnull_network(conn, args->net);
- if (network == NULL)
+ if (!(network = get_nonnull_network(conn, args->net)))
goto cleanup;
- ret->active = virNetworkIsActive(network);
-
- if (ret->active < 0)
+ if ((ret->active = virNetworkIsActive(network)) < 0)
goto cleanup;
rv = 0;
@@ -7798,13 +7607,10 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
goto cleanup;
}
- network = get_nonnull_network(conn, args->net);
- if (network == NULL)
+ if (!(network = get_nonnull_network(conn, args->net)))
goto cleanup;
- ret->persistent = virNetworkIsPersistent(network);
-
- if (ret->persistent < 0)
+ if ((ret->persistent = virNetworkIsPersistent(network)) < 0)
goto cleanup;
rv = 0;
@@ -7833,13 +7639,10 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
- ret->active = virStoragePoolIsActive(pool);
-
- if (ret->active < 0)
+ if ((ret->active = virStoragePoolIsActive(pool)) < 0)
goto cleanup;
rv = 0;
@@ -7868,13 +7671,10 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
goto cleanup;
}
- pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL)
+ if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
goto cleanup;
- ret->persistent = virStoragePoolIsPersistent(pool);
-
- if (ret->persistent < 0)
+ if ((ret->persistent = virStoragePoolIsPersistent(pool)) < 0)
goto cleanup;
rv = 0;
@@ -7903,9 +7703,7 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->secure = virConnectIsSecure(conn);
-
- if (ret->secure < 0)
+ if ((ret->secure = virConnectIsSecure(conn)) < 0)
goto cleanup;
rv = 0;
@@ -7934,8 +7732,7 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- result = virConnectCompareCPU(conn, args->xml, args->flags);
- if (result == VIR_CPU_COMPARE_ERROR)
+ if ((result = virConnectCompareCPU(conn, args->xml, args->flags)) == VIR_CPU_COMPARE_ERROR)
goto cleanup;
ret->result = result;
@@ -7965,11 +7762,10 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- cpu = virConnectBaselineCPU(conn,
- (const char **) args->xmlCPUs.xmlCPUs_val,
- args->xmlCPUs.xmlCPUs_len,
- args->flags);
- if (cpu == NULL)
+ if (!(cpu = virConnectBaselineCPU(conn,
+ (const char **) args->xmlCPUs.xmlCPUs_val,
+ args->xmlCPUs.xmlCPUs_len,
+ args->flags)))
goto cleanup;
ret->cpu = cpu;
@@ -8001,8 +7797,7 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetJobInfo(dom, &info) < 0)
@@ -8049,8 +7844,7 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainAbortJob(dom) < 0)
@@ -8084,8 +7878,7 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0)
@@ -8118,8 +7911,7 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0)
@@ -8153,12 +7945,10 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
- if (snapshot == NULL)
+ if (!(snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags)))
goto cleanup;
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8193,17 +7983,14 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->snap.domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
goto cleanup;
- snapshot = get_nonnull_domain_snapshot(domain, args->snap);
- if (snapshot == NULL)
+ if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags)))
goto cleanup;
rv = 0;
@@ -8235,12 +8022,10 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- ret->num = virDomainSnapshotNum(domain, args->flags);
- if (ret->num < 0)
+ if ((ret->num = virDomainSnapshotNum(domain, args->flags)) < 0)
goto cleanup;
rv = 0;
@@ -8277,8 +8062,7 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
/* Allocate return buffer. */
@@ -8325,12 +8109,10 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
- if (snapshot == NULL)
+ if (!(snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags)))
goto cleanup;
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8365,8 +8147,7 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
result = virDomainHasCurrentSnapshot(domain, args->flags);
@@ -8403,12 +8184,10 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- snapshot = virDomainSnapshotCurrent(domain, args->flags);
- if (snapshot == NULL)
+ if (!(snapshot = virDomainSnapshotCurrent(domain, args->flags)))
goto cleanup;
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8443,12 +8222,10 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->snap.domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
goto cleanup;
- snapshot = get_nonnull_domain_snapshot(domain, args->snap);
- if (snapshot == NULL)
+ if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
goto cleanup;
if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
@@ -8484,12 +8261,10 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->snap.domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
goto cleanup;
- snapshot = get_nonnull_domain_snapshot(domain, args->snap);
- if (snapshot == NULL)
+ if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
goto cleanup;
if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
@@ -8577,8 +8352,7 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
goto cleanup;
}
- callbackID = client->domainEventCallbackID[args->eventID];
- if (callbackID < 0) {
+ if ((callbackID = client->domainEventCallbackID[args->eventID]) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
goto cleanup;
}
@@ -8614,8 +8388,7 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- nwfilter = virNWFilterLookupByName(conn, args->name);
- if (nwfilter == NULL)
+ if (!(nwfilter = virNWFilterLookupByName(conn, args->name)))
goto cleanup;
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8647,8 +8420,7 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
- if (nwfilter == NULL)
+ if (!(nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid)))
goto cleanup;
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8681,8 +8453,7 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- nwfilter = virNWFilterDefineXML(conn, args->xml);
- if (nwfilter == NULL)
+ if (!(nwfilter = virNWFilterDefineXML(conn, args->xml)))
goto cleanup;
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8715,8 +8486,7 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
- if (nwfilter == NULL)
+ if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
goto cleanup;
if (virNWFilterUndefine(nwfilter) < 0)
@@ -8795,13 +8565,11 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
- if (nwfilter == NULL)
+ if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
- ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
- if (!ret->xml)
+ if (!(ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags)))
goto cleanup;
rv = 0;
@@ -8831,8 +8599,7 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- ret->num = virConnectNumOfNWFilters(conn);
- if (ret->num < 0)
+ if ((ret->num = virConnectNumOfNWFilters(conn)) < 0)
goto cleanup;
rv = 0;
@@ -8862,8 +8629,7 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) < 0)
@@ -8900,8 +8666,7 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL)
+ if (!(domain = get_nonnull_domain(conn, args->domain)))
goto cleanup;
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
@@ -8928,7 +8693,6 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_open_console_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- int r;
struct qemud_client_stream *stream = NULL;
virDomainPtr dom = NULL;
int rv = -1;
@@ -8938,21 +8702,18 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- dom = get_nonnull_domain(conn, args->domain);
- if (dom == NULL)
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- stream = remoteCreateClientStream(conn, hdr);
- if (!stream) {
+ if (!(stream = remoteCreateClientStream(conn, hdr))) {
virReportOOMError();
goto cleanup;
}
- r = virDomainOpenConsole(dom,
+ if (virDomainOpenConsole(dom,
args->devname ? *args->devname : NULL,
stream->st,
- args->flags);
- if (r < 0)
+ args->flags) < 0)
goto cleanup;
if (remoteAddClientStream(client, stream, 1) < 0)
--
1.7.4.2
2
1
[libvirt] [PATCH] Remove curly braces on all single-line conditional jumps in dispatcher
by Daniel P. Berrange 14 Apr '11
by Daniel P. Berrange 14 Apr '11
14 Apr '11
Replace all occurrances of
if (....) {
goto cleanup;
}
With
if (.....)
goto cleanup;
to save one line of code
* daemon/remote.c: Remove curly braces on single line conditionals
---
daemon/remote.c | 951 ++++++++++++++++++------------------------------------
1 files changed, 317 insertions(+), 634 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 325ba90..247a226 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -427,9 +427,8 @@ remoteDispatchOpen(struct qemud_server *server,
? virConnectOpenReadOnly(name)
: virConnectOpen(name);
- if (client->conn == NULL) {
+ if (client->conn == NULL)
goto cleanup;
- }
rv = 0;
@@ -476,9 +475,8 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->supported = virDrvSupportsFeature(conn, args->feature);
- if (ret->supported < 0) {
+ if (ret->supported < 0)
goto cleanup;
- }
rv = 0;
@@ -505,9 +503,8 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
}
type = virConnectGetType(conn);
- if (type == NULL) {
+ if (type == NULL)
goto cleanup;
- }
/* We have to strdup because remoteDispatchClientRequest will
* free this string after it's been serialised.
@@ -543,9 +540,8 @@ remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virConnectGetVersion(conn, &hvVer) < 0) {
+ if (virConnectGetVersion(conn, &hvVer) < 0)
goto cleanup;
- }
ret->hv_ver = hvVer;
rv = 0;
@@ -573,9 +569,8 @@ remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virConnectGetLibVersion(conn, &libVer) < 0) {
+ if (virConnectGetLibVersion(conn, &libVer) < 0)
goto cleanup;
- }
ret->lib_ver = libVer;
rv = 0;
@@ -604,9 +599,8 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
}
hostname = virConnectGetHostname(conn);
- if (hostname == NULL) {
+ if (hostname == NULL)
goto cleanup;
- }
ret->hostname = hostname;
rv = 0;
@@ -635,9 +629,8 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
}
uri = virConnectGetURI(conn);
- if (uri == NULL) {
+ if (uri == NULL)
goto cleanup;
- }
ret->uri = uri;
rv = 0;
@@ -668,9 +661,8 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags;
sysinfo = virConnectGetSysinfo(conn, flags);
- if (sysinfo == NULL) {
+ if (sysinfo == NULL)
goto cleanup;
- }
ret->sysinfo = sysinfo;
rv = 0;
@@ -700,9 +692,8 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
type = args->type ? *args->type : NULL;
ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
- if (ret->max_vcpus < 0) {
+ if (ret->max_vcpus < 0)
goto cleanup;
- }
rv = 0;
@@ -729,9 +720,8 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virNodeGetInfo(conn, &info) < 0) {
+ if (virNodeGetInfo(conn, &info) < 0)
goto cleanup;
- }
memcpy(ret->model, info.model, sizeof ret->model);
ret->memory = info.memory;
@@ -768,9 +758,8 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
}
caps = virConnectGetCapabilities(conn);
- if (caps == NULL) {
+ if (caps == NULL)
goto cleanup;
- }
ret->capabilities = caps;
rv = 0;
@@ -814,9 +803,8 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
(unsigned long long *)ret->freeMems.freeMems_val,
args->startCell,
args->maxCells);
- if (err <= 0) {
+ if (err <= 0)
goto cleanup;
- }
ret->freeMems.freeMems_len = err;
rv = 0;
@@ -848,9 +836,8 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
}
freeMem = virNodeGetFreeMemory(conn);
- if (freeMem == 0) {
+ if (freeMem == 0)
goto cleanup;
- }
ret->freeMem = freeMem;
rv = 0;
@@ -881,14 +868,12 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
type = virDomainGetSchedulerType(dom, &nparams);
- if (type == NULL) {
+ if (type == NULL)
goto cleanup;
- }
ret->type = type;
ret->nparams = nparams;
@@ -933,14 +918,12 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
r = virDomainGetSchedulerParameters(dom, params, &nparams);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
/* Serialise the scheduler parameters. */
ret->params.params_len = nparams;
@@ -1046,14 +1029,12 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
r = virDomainSetSchedulerParameters(dom, params, nparams);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
rv = 0;
@@ -1086,14 +1067,12 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
path = args->path;
- if (virDomainBlockStats(dom, path, &stats, sizeof stats) < 0) {
+ if (virDomainBlockStats(dom, path, &stats, sizeof stats) < 0)
goto cleanup;
- }
ret->rd_req = stats.rd_req;
ret->rd_bytes = stats.rd_bytes;
@@ -1131,14 +1110,12 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
path = args->path;
- if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) < 0) {
+ if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) < 0)
goto cleanup;
- }
ret->rx_bytes = stats.rx_bytes;
ret->rx_packets = stats.rx_packets;
@@ -1185,9 +1162,8 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
/* Allocate stats array for making dispatch call */
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
@@ -1196,9 +1172,8 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
- if (nr_stats < 0) {
+ if (nr_stats < 0)
goto cleanup;
- }
/* Allocate return buffer */
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
@@ -1245,9 +1220,8 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
path = args->path;
offset = args->offset;
size = args->size;
@@ -1266,9 +1240,8 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainBlockPeek(dom, path, offset, size,
- ret->buffer.buffer_val, flags) < 0) {
+ ret->buffer.buffer_val, flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -1303,9 +1276,8 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
offset = args->offset;
size = args->size;
flags = args->flags;
@@ -1323,9 +1295,8 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainMemoryPeek(dom, offset, size,
- ret->buffer.buffer_val, flags) < 0) {
+ ret->buffer.buffer_val, flags) < 0)
goto cleanup;
- }
if (dom)
virDomainFree(dom);
@@ -1359,13 +1330,11 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainAttachDevice(dom, args->xml) < 0) {
+ if (virDomainAttachDevice(dom, args->xml) < 0)
goto cleanup;
- }
rv = 0;
@@ -1395,13 +1364,11 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) < 0) {
+ if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -1431,13 +1398,11 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0) {
+ if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -1467,13 +1432,11 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainCreate(dom) < 0) {
+ if (virDomainCreate(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -1498,13 +1461,11 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
virDomainPtr dom = NULL;
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainCreateWithFlags(dom, args->flags) < 0) {
+ if (virDomainCreateWithFlags(dom, args->flags) < 0)
goto cleanup;
- }
make_nonnull_domain(&ret->dom, dom);
@@ -1536,9 +1497,8 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->dom, dom);
@@ -1570,9 +1530,8 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = virDomainDefineXML(conn, args->xml);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->dom, dom);
@@ -1604,13 +1563,11 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainDestroy(dom) < 0) {
+ if (virDomainDestroy(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -1640,13 +1597,11 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainDetachDevice(dom, args->xml) < 0) {
+ if (virDomainDetachDevice(dom, args->xml) < 0)
goto cleanup;
- }
rv = 0;
@@ -1676,13 +1631,11 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) < 0) {
+ if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -1712,15 +1665,13 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virDomainGetXMLDesc(dom, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -1753,9 +1704,8 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->nativeFormat,
args->nativeConfig,
args->flags);
- if (!ret->domainXml) {
+ if (!ret->domainXml)
goto cleanup;
- }
rv = 0;
cleanup:
@@ -1785,9 +1735,8 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
args->nativeFormat,
args->domainXml,
args->flags);
- if (!ret->nativeConfig) {
+ if (!ret->nativeConfig)
goto cleanup;
- }
rv = 0;
cleanup:
@@ -1815,13 +1764,11 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainGetAutostart(dom, &ret->autostart) < 0) {
+ if (virDomainGetAutostart(dom, &ret->autostart) < 0)
goto cleanup;
- }
rv = 0;
@@ -1852,13 +1799,11 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainGetInfo(dom, &info) < 0) {
+ if (virDomainGetInfo(dom, &info) < 0)
goto cleanup;
- }
ret->state = info.state;
ret->max_mem = info.maxMem;
@@ -1894,14 +1839,12 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
ret->memory = virDomainGetMaxMemory(dom);
- if (ret->memory == 0) {
+ if (ret->memory == 0)
goto cleanup;
- }
rv = 0;
@@ -1931,14 +1874,12 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
ret->num = virDomainGetMaxVcpus(dom);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -1969,18 +1910,16 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
if (VIR_ALLOC(seclabel) < 0) {
virReportOOMError();
goto cleanup;
}
- if (virDomainGetSecurityLabel(dom, seclabel) < 0) {
+ if (virDomainGetSecurityLabel(dom, seclabel) < 0)
goto cleanup;
- }
ret->label.label_len = strlen(seclabel->label) + 1;
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
@@ -2019,9 +1958,8 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
}
memset(&secmodel, 0, sizeof secmodel);
- if (virNodeGetSecurityModel(conn, &secmodel) < 0) {
+ if (virNodeGetSecurityModel(conn, &secmodel) < 0)
goto cleanup;
- }
ret->model.model_len = strlen(secmodel.model) + 1;
if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
@@ -2063,15 +2001,13 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this */
ret->type = virDomainGetOSType(dom);
- if (ret->type == NULL) {
+ if (ret->type == NULL)
goto cleanup;
- }
rv = 0;
cleanup:
@@ -2103,9 +2039,8 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
@@ -2127,9 +2062,8 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
info_len = virDomainGetVcpus(dom,
info, args->maxinfo,
cpumaps, args->maplen);
- if (info_len < 0) {
+ if (info_len < 0)
goto cleanup;
- }
/* Allocate the return buffer for info. */
ret->info.info_len = info_len;
@@ -2187,14 +2121,12 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
ret->num = virDomainGetVcpusFlags(dom, args->flags);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -2240,9 +2172,8 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
r = virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
/* remoteDispatchClientRequest will free cookie, uri_out and
* the string if there is one.
@@ -2285,9 +2216,8 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2296,9 +2226,8 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
args->cookie.cookie_len,
args->uri,
args->flags, dname, args->resource);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
rv = 0;
@@ -2332,9 +2261,8 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
args->cookie.cookie_len,
args->uri,
args->flags);
- if (ddom == NULL) {
+ if (ddom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->ddom, ddom);
rv = 0;
@@ -2382,9 +2310,8 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
uri_in, uri_out,
args->flags, dname, args->resource,
args->dom_xml);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
/* remoteDispatchClientRequest will free cookie, uri_out and
* the string if there is one.
@@ -2424,9 +2351,8 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
args->uri,
args->flags,
args->retcode);
- if (ddom == NULL) {
+ if (ddom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->ddom, ddom);
@@ -2470,13 +2396,11 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
r = virDomainMigratePrepareTunnel(conn, stream->st,
args->flags, dname, args->resource,
args->dom_xml);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
- if (remoteAddClientStream(client, stream, 0) < 0) {
+ if (remoteAddClientStream(client, stream, 0) < 0)
goto cleanup;
- }
rv = 0;
@@ -2522,9 +2446,8 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListDefinedDomains(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -2555,9 +2478,8 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = virDomainLookupByID(conn, args->id);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->dom, dom);
@@ -2589,9 +2511,8 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = virDomainLookupByName(conn, args->name);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->dom, dom);
@@ -2623,9 +2544,8 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
make_nonnull_domain(&ret->dom, dom);
@@ -2656,9 +2576,8 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfDefinedDomains(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -2686,9 +2605,8 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
@@ -2698,9 +2616,8 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
rv = virDomainPinVcpu(dom, args->vcpu,
(unsigned char *) args->cpumap.cpumap_val,
args->cpumap.cpumap_len);
- if (rv < 0) {
+ if (rv < 0)
goto cleanup;
- }
rv = 0;
@@ -2730,13 +2647,11 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainReboot(dom, args->flags) < 0) {
+ if (virDomainReboot(dom, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -2764,9 +2679,8 @@ remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (virDomainRestore(conn, args->from) < 0) {
+ if (virDomainRestore(conn, args->from) < 0)
goto cleanup;
- }
rv = 0;
@@ -2794,13 +2708,11 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainResume(dom) < 0) {
+ if (virDomainResume(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -2830,13 +2742,11 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSave(dom, args->to) < 0) {
+ if (virDomainSave(dom, args->to) < 0)
goto cleanup;
- }
rv = 0;
@@ -2866,13 +2776,11 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainCoreDump(dom, args->to, args->flags) < 0) {
+ if (virDomainCoreDump(dom, args->to, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -2902,13 +2810,11 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSetAutostart(dom, args->autostart) < 0) {
+ if (virDomainSetAutostart(dom, args->autostart) < 0)
goto cleanup;
- }
rv = 0;
@@ -2938,13 +2844,11 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSetMaxMemory(dom, args->memory) < 0) {
+ if (virDomainSetMaxMemory(dom, args->memory) < 0)
goto cleanup;
- }
rv = 0;
@@ -2974,13 +2878,11 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSetMemory(dom, args->memory) < 0) {
+ if (virDomainSetMemory(dom, args->memory) < 0)
goto cleanup;
- }
rv = 0;
@@ -3010,13 +2912,11 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0) {
+ if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -3108,14 +3008,12 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
rv = 0;
@@ -3166,14 +3064,12 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
/* In this case, we need to send back the number of parameters
* supported
*/
@@ -3329,14 +3225,12 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
rv = 0;
@@ -3387,14 +3281,12 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
/* In this case, we need to send back the number of parameters
* supported
*/
@@ -3490,13 +3382,11 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSetVcpus(dom, args->nvcpus) < 0) {
+ if (virDomainSetVcpus(dom, args->nvcpus) < 0)
goto cleanup;
- }
rv = 0;
@@ -3526,13 +3416,11 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0) {
+ if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -3562,13 +3450,11 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainShutdown(dom) < 0) {
+ if (virDomainShutdown(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -3598,13 +3484,11 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainSuspend(dom) < 0) {
+ if (virDomainSuspend(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -3634,13 +3518,11 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainUndefine(dom) < 0) {
+ if (virDomainUndefine(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -3683,9 +3565,8 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListDefinedNetworks(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -3729,9 +3610,8 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListDomains(conn,
ret->ids.ids_val, args->maxids);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->ids.ids_len = len;
rv = 0;
@@ -3762,13 +3642,11 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainManagedSave(dom, args->flags) < 0) {
+ if (virDomainManagedSave(dom, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -3798,14 +3676,12 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
- if (ret->ret < 0) {
+ if (ret->ret < 0)
goto cleanup;
- }
rv = 0;
@@ -3835,13 +3711,11 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainManagedSaveRemove(dom, args->flags) < 0) {
+ if (virDomainManagedSaveRemove(dom, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -3884,9 +3758,8 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListNetworks(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -3917,13 +3790,11 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
- if (virNetworkCreate(net) < 0) {
+ if (virNetworkCreate(net) < 0)
goto cleanup;
- }
rv = 0;
@@ -3953,9 +3824,8 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = virNetworkCreateXML(conn, args->xml);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
make_nonnull_network(&ret->net, net);
@@ -3987,9 +3857,8 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = virNetworkDefineXML(conn, args->xml);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
make_nonnull_network(&ret->net, net);
@@ -4021,13 +3890,11 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
- if (virNetworkDestroy(net) < 0) {
+ if (virNetworkDestroy(net) < 0)
goto cleanup;
- }
rv = 0;
@@ -4057,15 +3924,13 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virNetworkGetXMLDesc(net, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -4095,13 +3960,11 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
- if (virNetworkGetAutostart(net, &ret->autostart) < 0) {
+ if (virNetworkGetAutostart(net, &ret->autostart) < 0)
goto cleanup;
- }
rv = 0;
@@ -4131,15 +3994,13 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->name = virNetworkGetBridgeName(net);
- if (!ret->name) {
+ if (!ret->name)
goto cleanup;
- }
rv = 0;
@@ -4169,9 +4030,8 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = virNetworkLookupByName(conn, args->name);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
make_nonnull_network(&ret->net, net);
@@ -4203,9 +4063,8 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
make_nonnull_network(&ret->net, net);
@@ -4237,13 +4096,11 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
- if (virNetworkSetAutostart(net, args->autostart) < 0) {
+ if (virNetworkSetAutostart(net, args->autostart) < 0)
goto cleanup;
- }
rv = 0;
@@ -4273,13 +4130,11 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
}
net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (net == NULL)
goto cleanup;
- }
- if (virNetworkUndefine(net) < 0) {
+ if (virNetworkUndefine(net) < 0)
goto cleanup;
- }
rv = 0;
@@ -4309,9 +4164,8 @@ remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
}
len = virConnectNumOfDefinedNetworks(conn);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->num = len;
rv = 0;
@@ -4339,9 +4193,8 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfDomains(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -4368,9 +4221,8 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfNetworks(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -4399,9 +4251,8 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfInterfaces(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -4442,9 +4293,8 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListInterfaces(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -4475,9 +4325,8 @@ remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSE
}
len = virConnectNumOfDefinedInterfaces(conn);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->num = len;
rv = 0;
@@ -4519,9 +4368,8 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
len = virConnectListDefinedInterfaces(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -4552,9 +4400,8 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
}
iface = virInterfaceLookupByName(conn, args->name);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
make_nonnull_interface(&ret->iface, iface);
@@ -4586,9 +4433,8 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
}
iface = virInterfaceLookupByMACString(conn, args->mac);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
make_nonnull_interface(&ret->iface, iface);
@@ -4620,15 +4466,13 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
}
iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -4658,9 +4502,8 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
iface = virInterfaceDefineXML(conn, args->xml, args->flags);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
make_nonnull_interface(&ret->iface, iface);
@@ -4692,13 +4535,11 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
}
iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
- if (virInterfaceUndefine(iface) < 0) {
+ if (virInterfaceUndefine(iface) < 0)
goto cleanup;
- }
rv = 0;
@@ -4728,13 +4569,11 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
}
iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
- if (virInterfaceCreate(iface, args->flags) < 0) {
+ if (virInterfaceCreate(iface, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -4764,13 +4603,11 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
}
iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
- if (virInterfaceDestroy(iface, args->flags) < 0) {
+ if (virInterfaceDestroy(iface, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -4857,9 +4694,8 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
- if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
+ if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL)
goto error;
- }
/* Get remote address in form IPADDR:PORT */
sa.len = sizeof(sa.data.stor);
@@ -5617,9 +5453,8 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
len = virConnectListDefinedStoragePools(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -5663,9 +5498,8 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListStoragePools(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -5699,9 +5533,8 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
args->type,
args->srcSpec ? *args->srcSpec : NULL,
args->flags);
- if (ret->xml == NULL) {
+ if (ret->xml == NULL)
goto cleanup;
- }
rv = 0;
@@ -5730,13 +5563,11 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolCreate(pool, args->flags) < 0) {
+ if (virStoragePoolCreate(pool, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -5766,9 +5597,8 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
make_nonnull_storage_pool(&ret->pool, pool);
@@ -5800,9 +5630,8 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
make_nonnull_storage_pool(&ret->pool, pool);
@@ -5834,13 +5663,11 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolBuild(pool, args->flags) < 0) {
+ if (virStoragePoolBuild(pool, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -5871,13 +5698,11 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolDestroy(pool) < 0) {
+ if (virStoragePoolDestroy(pool) < 0)
goto cleanup;
- }
rv = 0;
@@ -5907,13 +5732,11 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolDelete(pool, args->flags) < 0) {
+ if (virStoragePoolDelete(pool, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -5943,13 +5766,11 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolRefresh(pool, args->flags) < 0) {
+ if (virStoragePoolRefresh(pool, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -5980,13 +5801,11 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolGetInfo(pool, &info) < 0) {
+ if (virStoragePoolGetInfo(pool, &info) < 0)
goto cleanup;
- }
ret->state = info.state;
ret->capacity = info.capacity;
@@ -6021,15 +5840,13 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -6059,13 +5876,11 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0) {
+ if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0)
goto cleanup;
- }
rv = 0;
@@ -6096,9 +5911,8 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
}
pool = virStoragePoolLookupByName(conn, args->name);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
make_nonnull_storage_pool(&ret->pool, pool);
@@ -6130,9 +5944,8 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
}
pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
make_nonnull_storage_pool(&ret->pool, pool);
@@ -6165,14 +5978,12 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
pool = virStoragePoolLookupByVolume(vol);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
make_nonnull_storage_pool(&ret->pool, pool);
@@ -6206,13 +6017,11 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolSetAutostart(pool, args->autostart) < 0) {
+ if (virStoragePoolSetAutostart(pool, args->autostart) < 0)
goto cleanup;
- }
rv = 0;
@@ -6242,13 +6051,11 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
- if (virStoragePoolUndefine(pool) < 0) {
+ if (virStoragePoolUndefine(pool) < 0)
goto cleanup;
- }
rv = 0;
@@ -6277,9 +6084,8 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfStoragePools(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -6306,9 +6112,8 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
}
ret->num = virConnectNumOfDefinedStoragePools(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -6343,9 +6148,8 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
@@ -6355,9 +6159,8 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
len = virStoragePoolListVolumes(pool,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -6391,14 +6194,12 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
ret->num = virStoragePoolNumOfVolumes(pool);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -6436,14 +6237,12 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
vol = virStorageVolCreateXML(pool, args->xml, args->flags);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
make_nonnull_storage_vol(&ret->vol, vol);
rv = 0;
@@ -6478,20 +6277,17 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
clonevol = get_nonnull_storage_vol(conn, args->clonevol);
- if (clonevol == NULL) {
+ if (clonevol == NULL)
goto cleanup;
- }
newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
args->flags);
- if (newvol == NULL) {
+ if (newvol == NULL)
goto cleanup;
- }
make_nonnull_storage_vol(&ret->vol, newvol);
rv = 0;
@@ -6526,13 +6322,11 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
- if (virStorageVolDelete(vol, args->flags) < 0) {
+ if (virStorageVolDelete(vol, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -6562,13 +6356,11 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
- if (virStorageVolWipe(vol, args->flags) < 0) {
+ if (virStorageVolWipe(vol, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -6599,13 +6391,11 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
- if (virStorageVolGetInfo(vol, &info) < 0) {
+ if (virStorageVolGetInfo(vol, &info) < 0)
goto cleanup;
- }
ret->type = info.type;
ret->capacity = info.capacity;
@@ -6639,15 +6429,13 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -6678,15 +6466,13 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->name = virStorageVolGetPath(vol);
- if (!ret->name) {
+ if (!ret->name)
goto cleanup;
- }
rv = 0;
@@ -6718,14 +6504,12 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
vol = virStorageVolLookupByName(pool, args->name);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6759,9 +6543,8 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
}
vol = virStorageVolLookupByKey(conn, args->key);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6794,9 +6577,8 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
}
vol = virStorageVolLookupByPath(conn, args->path);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
make_nonnull_storage_vol(&ret->vol, vol);
@@ -6834,9 +6616,8 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->num = virNodeNumOfDevices(conn,
args->cap ? *args->cap : NULL,
args->flags);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -6879,9 +6660,8 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virNodeListDevices(conn,
args->cap ? *args->cap : NULL,
ret->names.names_val, args->maxnames, args->flags);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -6913,9 +6693,8 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
make_nonnull_node_device(&ret->dev, dev);
@@ -6948,15 +6727,13 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -6988,9 +6765,8 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
parent = virNodeDeviceGetParent(dev);
@@ -7040,14 +6816,12 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
ret->num = virNodeDeviceNumOfCaps(dev);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -7079,9 +6853,8 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
virNetError(VIR_ERR_INTERNAL_ERROR,
@@ -7097,9 +6870,8 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virNodeDeviceListCaps(dev, ret->names.names_val,
args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -7133,13 +6905,11 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
- if (virNodeDeviceDettach(dev) < 0) {
+ if (virNodeDeviceDettach(dev) < 0)
goto cleanup;
- }
rv = 0;
@@ -7170,13 +6940,11 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
- if (virNodeDeviceReAttach(dev) < 0) {
+ if (virNodeDeviceReAttach(dev) < 0)
goto cleanup;
- }
rv = 0;
@@ -7207,13 +6975,11 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
- if (virNodeDeviceReset(dev) < 0) {
+ if (virNodeDeviceReset(dev) < 0)
goto cleanup;
- }
rv = 0;
@@ -7244,9 +7010,8 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
make_nonnull_node_device(&ret->dev, dev);
@@ -7279,13 +7044,11 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dev = virNodeDeviceLookupByName(conn, args->name);
- if (dev == NULL) {
+ if (dev == NULL)
goto cleanup;
- }
- if (virNodeDeviceDestroy(dev) < 0) {
+ if (virNodeDeviceDestroy(dev) < 0)
goto cleanup;
- }
rv = 0;
@@ -7315,24 +7078,20 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
stream = remoteCreateClientStream(conn, hdr);
- if (!stream) {
+ if (!stream)
goto cleanup;
- }
if (virStorageVolUpload(vol, stream->st,
args->offset, args->length,
- args->flags) < 0) {
+ args->flags) < 0)
goto cleanup;
- }
- if (remoteAddClientStream(client, stream, 0) < 0) {
+ if (remoteAddClientStream(client, stream, 0) < 0)
goto cleanup;
- }
rv = 0;
@@ -7366,24 +7125,20 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
}
vol = get_nonnull_storage_vol(conn, args->vol);
- if (vol == NULL) {
+ if (vol == NULL)
goto cleanup;
- }
stream = remoteCreateClientStream(conn, hdr);
- if (!stream) {
+ if (!stream)
goto cleanup;
- }
if (virStorageVolDownload(vol, stream->st,
args->offset, args->length,
- args->flags) < 0) {
+ args->flags) < 0)
goto cleanup;
- }
- if (remoteAddClientStream(client, stream, 1) < 0) {
+ if (remoteAddClientStream(client, stream, 1) < 0)
goto cleanup;
- }
rv = 0;
@@ -7429,9 +7184,8 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
NULL,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
- client, NULL)) < 0) {
+ client, NULL)) < 0)
goto cleanup;
- }
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
@@ -7465,9 +7219,8 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
}
if (virConnectDomainEventDeregisterAny(conn,
- client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0) {
+ client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0)
goto cleanup;
- }
client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
rv = 0;
@@ -7559,9 +7312,8 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfSecrets(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -7601,9 +7353,8 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListSecrets(conn, ret->uuids.uuids_val,
args->maxuuids);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->uuids.uuids_len = len;
rv = 0;
@@ -7634,9 +7385,8 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = virSecretDefineXML(conn, args->xml, args->flags);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
make_nonnull_secret(&ret->secret, secret);
rv = 0;
@@ -7669,14 +7419,12 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
value = virSecretGetValue(secret, &value_size, args->flags);
- if (value == NULL) {
+ if (value == NULL)
goto cleanup;
- }
ret->value.value_len = value_size;
ret->value.value_val = (char *)value;
@@ -7709,13 +7457,11 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
ret->xml = virSecretGetXMLDesc(secret, args->flags);
- if (ret->xml == NULL) {
+ if (ret->xml == NULL)
goto cleanup;
- }
rv = 0;
@@ -7745,9 +7491,8 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
make_nonnull_secret(&ret->secret, secret);
@@ -7779,13 +7524,11 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
- args->value.value_len, args->flags) < 0) {
+ args->value.value_len, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -7815,12 +7558,10 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = get_nonnull_secret(conn, args->secret);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
- if (virSecretUndefine(secret) < 0) {
+ if (virSecretUndefine(secret) < 0)
goto cleanup;
- }
rv = 0;
@@ -7850,9 +7591,8 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
}
secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
- if (secret == NULL) {
+ if (secret == NULL)
goto cleanup;
- }
make_nonnull_secret(&ret->secret, secret);
@@ -7884,15 +7624,13 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
}
domain = get_nonnull_domain(conn, args->dom);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
ret->active = virDomainIsActive(domain);
- if (ret->active < 0) {
+ if (ret->active < 0)
goto cleanup;
- }
rv = 0;
@@ -7921,15 +7659,13 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
}
domain = get_nonnull_domain(conn, args->dom);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
ret->persistent = virDomainIsPersistent(domain);
- if (ret->persistent < 0) {
+ if (ret->persistent < 0)
goto cleanup;
- }
rv = 0;
@@ -7958,15 +7694,13 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
}
domain = get_nonnull_domain(conn, args->dom);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
ret->updated = virDomainIsUpdated(domain);
- if (ret->updated < 0) {
+ if (ret->updated < 0)
goto cleanup;
- }
rv = 0;
@@ -7995,15 +7729,13 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
}
iface = get_nonnull_interface(conn, args->iface);
- if (iface == NULL) {
+ if (iface == NULL)
goto cleanup;
- }
ret->active = virInterfaceIsActive(iface);
- if (ret->active < 0) {
+ if (ret->active < 0)
goto cleanup;
- }
rv = 0;
@@ -8032,15 +7764,13 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
}
network = get_nonnull_network(conn, args->net);
- if (network == NULL) {
+ if (network == NULL)
goto cleanup;
- }
ret->active = virNetworkIsActive(network);
- if (ret->active < 0) {
+ if (ret->active < 0)
goto cleanup;
- }
rv = 0;
@@ -8069,15 +7799,13 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
}
network = get_nonnull_network(conn, args->net);
- if (network == NULL) {
+ if (network == NULL)
goto cleanup;
- }
ret->persistent = virNetworkIsPersistent(network);
- if (ret->persistent < 0) {
+ if (ret->persistent < 0)
goto cleanup;
- }
rv = 0;
@@ -8106,15 +7834,13 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
ret->active = virStoragePoolIsActive(pool);
- if (ret->active < 0) {
+ if (ret->active < 0)
goto cleanup;
- }
rv = 0;
@@ -8143,15 +7869,13 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
}
pool = get_nonnull_storage_pool(conn, args->pool);
- if (pool == NULL) {
+ if (pool == NULL)
goto cleanup;
- }
ret->persistent = virStoragePoolIsPersistent(pool);
- if (ret->persistent < 0) {
+ if (ret->persistent < 0)
goto cleanup;
- }
rv = 0;
@@ -8181,9 +7905,8 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
ret->secure = virConnectIsSecure(conn);
- if (ret->secure < 0) {
+ if (ret->secure < 0)
goto cleanup;
- }
rv = 0;
@@ -8212,9 +7935,8 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
}
result = virConnectCompareCPU(conn, args->xml, args->flags);
- if (result == VIR_CPU_COMPARE_ERROR) {
+ if (result == VIR_CPU_COMPARE_ERROR)
goto cleanup;
- }
ret->result = result;
rv = 0;
@@ -8247,9 +7969,8 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
(const char **) args->xmlCPUs.xmlCPUs_val,
args->xmlCPUs.xmlCPUs_len,
args->flags);
- if (cpu == NULL) {
+ if (cpu == NULL)
goto cleanup;
- }
ret->cpu = cpu;
@@ -8281,13 +8002,11 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainGetJobInfo(dom, &info) < 0) {
+ if (virDomainGetJobInfo(dom, &info) < 0)
goto cleanup;
- }
ret->type = info.type;
ret->timeElapsed = info.timeElapsed;
@@ -8331,13 +8050,11 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainAbortJob(dom) < 0) {
+ if (virDomainAbortJob(dom) < 0)
goto cleanup;
- }
rv = 0;
@@ -8368,13 +8085,11 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0) {
+ if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -8404,13 +8119,11 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0) {
+ if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -8441,14 +8154,12 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
- if (snapshot == NULL) {
+ if (snapshot == NULL)
goto cleanup;
- }
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8525,14 +8236,12 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
ret->num = virDomainSnapshotNum(domain, args->flags);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -8569,9 +8278,8 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
/* Allocate return buffer. */
if (VIR_ALLOC_N(ret->names.names_val, args->nameslen) < 0) {
@@ -8583,9 +8291,8 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
ret->names.names_val,
args->nameslen,
args->flags);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -8619,14 +8326,12 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
- if (snapshot == NULL) {
+ if (snapshot == NULL)
goto cleanup;
- }
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8661,14 +8366,12 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
result = virDomainHasCurrentSnapshot(domain, args->flags);
- if (result < 0) {
+ if (result < 0)
goto cleanup;
- }
ret->result = result;
@@ -8701,14 +8404,12 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
snapshot = virDomainSnapshotCurrent(domain, args->flags);
- if (snapshot == NULL) {
+ if (snapshot == NULL)
goto cleanup;
- }
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8839,9 +8540,8 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
NULL,
args->eventID,
domainEventCallbacks[args->eventID],
- client, NULL)) < 0) {
+ client, NULL)) < 0)
goto cleanup;
- }
client->domainEventCallbackID[args->eventID] = callbackID;
@@ -8883,9 +8583,8 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
goto cleanup;
}
- if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) {
+ if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0)
goto cleanup;
- }
client->domainEventCallbackID[args->eventID] = -1;
rv = 0;
@@ -8916,9 +8615,8 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nwfilter = virNWFilterLookupByName(conn, args->name);
- if (nwfilter == NULL) {
+ if (nwfilter == NULL)
goto cleanup;
- }
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8950,9 +8648,8 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
- if (nwfilter == NULL) {
+ if (nwfilter == NULL)
goto cleanup;
- }
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8985,9 +8682,8 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nwfilter = virNWFilterDefineXML(conn, args->xml);
- if (nwfilter == NULL) {
+ if (nwfilter == NULL)
goto cleanup;
- }
make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -9020,13 +8716,11 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
- if (nwfilter == NULL) {
+ if (nwfilter == NULL)
goto cleanup;
- }
- if (virNWFilterUndefine(nwfilter) < 0) {
+ if (virNWFilterUndefine(nwfilter) < 0)
goto cleanup;
- }
rv = 0;
@@ -9069,9 +8763,8 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
len = virConnectListNWFilters(conn,
ret->names.names_val, args->maxnames);
- if (len < 0) {
+ if (len < 0)
goto cleanup;
- }
ret->names.names_len = len;
rv = 0;
@@ -9103,15 +8796,13 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
}
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
- if (nwfilter == NULL) {
+ if (nwfilter == NULL)
goto cleanup;
- }
/* remoteDispatchClientRequest will free this. */
ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
- if (!ret->xml) {
+ if (!ret->xml)
goto cleanup;
- }
rv = 0;
@@ -9141,9 +8832,8 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->num = virConnectNumOfNWFilters(conn);
- if (ret->num < 0) {
+ if (ret->num < 0)
goto cleanup;
- }
rv = 0;
@@ -9173,13 +8863,11 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->dom);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
- if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) < 0) {
+ if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) < 0)
goto cleanup;
- }
ret->capacity = info.capacity;
ret->allocation = info.allocation;
@@ -9213,14 +8901,12 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
}
domain = get_nonnull_domain(conn, args->domain);
- if (domain == NULL) {
+ if (domain == NULL)
goto cleanup;
- }
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
- args->flags) < 0) {
+ args->flags) < 0)
goto cleanup;
- }
rv = 0;
@@ -9253,9 +8939,8 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
}
dom = get_nonnull_domain(conn, args->domain);
- if (dom == NULL) {
+ if (dom == NULL)
goto cleanup;
- }
stream = remoteCreateClientStream(conn, hdr);
if (!stream) {
@@ -9267,13 +8952,11 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
args->devname ? *args->devname : NULL,
stream->st,
args->flags);
- if (r < 0) {
+ if (r < 0)
goto cleanup;
- }
- if (remoteAddClientStream(client, stream, 1) < 0) {
+ if (remoteAddClientStream(client, stream, 1) < 0)
goto cleanup;
- }
rv = 0;
--
1.7.4.2
2
1
[libvirt] [PATCH] Change some variable names to follow standard in daemon dispatcher
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
Replace some occurrances of
virDomainPtr domain;
virNetworkPtr network;
With
virDomainPtr dom;
virNetworkPtr net;
* daemon/remote.c: Fix variable naming to follow standard
---
daemon/remote.c | 194 +++++++++++++++++++++++++++---------------------------
1 files changed, 97 insertions(+), 97 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 66df9f7..eb2727d 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -75,7 +75,7 @@ static virStoragePoolPtr get_nonnull_storage_pool(virConnectPtr conn, remote_non
static virStorageVolPtr get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol);
static virSecretPtr get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret);
static virNWFilterPtr get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
-static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr domain, remote_nonnull_domain_snapshot snapshot);
+static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot);
static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src);
static void make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src);
static void make_nonnull_interface(remote_nonnull_interface *interface_dst, virInterfacePtr interface_src);
@@ -2198,7 +2198,7 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish_args *args,
remote_domain_migrate_finish_ret *ret)
{
- virDomainPtr ddom = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -2206,21 +2206,21 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(ddom = virDomainMigrateFinish(conn, args->dname,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags)))
+ if (!(dom = virDomainMigrateFinish(conn, args->dname,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags)))
goto cleanup;
- make_nonnull_domain(&ret->ddom, ddom);
+ make_nonnull_domain(&ret->ddom, dom);
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (ddom)
- virDomainFree(ddom);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -2284,7 +2284,7 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish2_args *args,
remote_domain_migrate_finish2_ret *ret)
{
- virDomainPtr ddom = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -2292,23 +2292,23 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(ddom = virDomainMigrateFinish2(conn, args->dname,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags,
- args->retcode)))
+ if (!(dom = virDomainMigrateFinish2(conn, args->dname,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags,
+ args->retcode)))
goto cleanup;
- make_nonnull_domain(&ret->ddom, ddom);
+ make_nonnull_domain(&ret->ddom, dom);
rv = 0;
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (ddom)
- virDomainFree(ddom);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -7439,7 +7439,7 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
remote_domain_is_active_args *args,
remote_domain_is_active_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -7447,10 +7447,10 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- if ((ret->active = virDomainIsActive(domain)) < 0)
+ if ((ret->active = virDomainIsActive(dom)) < 0)
goto cleanup;
rv = 0;
@@ -7458,8 +7458,8 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -7471,7 +7471,7 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
remote_domain_is_persistent_args *args,
remote_domain_is_persistent_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -7479,10 +7479,10 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- if ((ret->persistent = virDomainIsPersistent(domain)) < 0)
+ if ((ret->persistent = virDomainIsPersistent(dom)) < 0)
goto cleanup;
rv = 0;
@@ -7490,8 +7490,8 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -7503,7 +7503,7 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
remote_domain_is_updated_args *args,
remote_domain_is_updated_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -7511,10 +7511,10 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
- if ((ret->updated = virDomainIsUpdated(domain)) < 0)
+ if ((ret->updated = virDomainIsUpdated(dom)) < 0)
goto cleanup;
rv = 0;
@@ -7522,8 +7522,8 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -7567,7 +7567,7 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
remote_network_is_active_args *args,
remote_network_is_active_ret *ret)
{
- virNetworkPtr network = NULL;
+ virNetworkPtr net = NULL;
int rv = -1;
if (!conn) {
@@ -7575,10 +7575,10 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- if (!(network = get_nonnull_network(conn, args->net)))
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
- if ((ret->active = virNetworkIsActive(network)) < 0)
+ if ((ret->active = virNetworkIsActive(net)) < 0)
goto cleanup;
rv = 0;
@@ -7586,8 +7586,8 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (network)
- virNetworkFree(network);
+ if (net)
+ virNetworkFree(net);
return rv;
}
@@ -7599,7 +7599,7 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
remote_network_is_persistent_args *args,
remote_network_is_persistent_ret *ret)
{
- virNetworkPtr network = NULL;
+ virNetworkPtr net = NULL;
int rv = -1;
if (!conn) {
@@ -7607,10 +7607,10 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
goto cleanup;
}
- if (!(network = get_nonnull_network(conn, args->net)))
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
- if ((ret->persistent = virNetworkIsPersistent(network)) < 0)
+ if ((ret->persistent = virNetworkIsPersistent(net)) < 0)
goto cleanup;
rv = 0;
@@ -7618,8 +7618,8 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (network)
- virNetworkFree(network);
+ if (net)
+ virNetworkFree(net);
return rv;
}
@@ -7937,7 +7937,7 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_create_xml_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -7945,10 +7945,10 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- if (!(snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags)))
+ if (!(snapshot = virDomainSnapshotCreateXML(dom, args->xml_desc, args->flags)))
goto cleanup;
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -7960,8 +7960,8 @@ cleanup:
remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -7974,7 +7974,7 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_snapshot_dump_xml_args *args,
remote_domain_snapshot_dump_xml_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
virDomainSnapshotPtr snapshot = NULL;
int rv = -1;
@@ -7983,10 +7983,10 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
+ if (!(dom = get_nonnull_domain(conn, args->snap.domain)))
goto cleanup;
- if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
+ if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
goto cleanup;
/* remoteDispatchClientRequest will free this. */
@@ -8000,8 +8000,8 @@ cleanup:
remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8014,7 +8014,7 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_snapshot_num_args *args,
remote_domain_snapshot_num_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -8022,10 +8022,10 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- if ((ret->num = virDomainSnapshotNum(domain, args->flags)) < 0)
+ if ((ret->num = virDomainSnapshotNum(dom, args->flags)) < 0)
goto cleanup;
rv = 0;
@@ -8033,8 +8033,8 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8047,7 +8047,7 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_snapshot_list_names_args *args,
remote_domain_snapshot_list_names_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
int len;
@@ -8062,7 +8062,7 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
/* Allocate return buffer. */
@@ -8071,7 +8071,7 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
goto cleanup;
}
- len = virDomainSnapshotListNames(domain,
+ len = virDomainSnapshotListNames(dom,
ret->names.names_val,
args->nameslen,
args->flags);
@@ -8086,8 +8086,8 @@ cleanup:
remoteDispatchError(rerr);
VIR_FREE(ret->names.names_val);
}
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8101,7 +8101,7 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
remote_domain_snapshot_lookup_by_name_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -8109,10 +8109,10 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- if (!(snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags)))
+ if (!(snapshot = virDomainSnapshotLookupByName(dom, args->name, args->flags)))
goto cleanup;
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8124,8 +8124,8 @@ cleanup:
remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8138,7 +8138,7 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
remote_domain_has_current_snapshot_args *args,
remote_domain_has_current_snapshot_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int result;
int rv = -1;
@@ -8147,10 +8147,10 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- result = virDomainHasCurrentSnapshot(domain, args->flags);
+ result = virDomainHasCurrentSnapshot(dom, args->flags);
if (result < 0)
goto cleanup;
@@ -8161,8 +8161,8 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8176,7 +8176,7 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
remote_domain_snapshot_current_ret *ret)
{
virDomainSnapshotPtr snapshot;
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -8184,10 +8184,10 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- if (!(snapshot = virDomainSnapshotCurrent(domain, args->flags)))
+ if (!(snapshot = virDomainSnapshotCurrent(dom, args->flags)))
goto cleanup;
make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8199,8 +8199,8 @@ cleanup:
remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8213,7 +8213,7 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
remote_domain_revert_to_snapshot_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
virDomainSnapshotPtr snapshot = NULL;
int rv = -1;
@@ -8222,10 +8222,10 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
+ if (!(dom = get_nonnull_domain(conn, args->snap.domain)))
goto cleanup;
- if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
+ if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
goto cleanup;
if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
@@ -8238,8 +8238,8 @@ cleanup:
remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8252,7 +8252,7 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_snapshot_delete_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
virDomainSnapshotPtr snapshot = NULL;
int rv = -1;
@@ -8261,10 +8261,10 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
+ if (!(dom = get_nonnull_domain(conn, args->snap.domain)))
goto cleanup;
- if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
+ if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
goto cleanup;
if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
@@ -8277,8 +8277,8 @@ cleanup:
remoteDispatchError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8658,7 +8658,7 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
qemu_monitor_command_args *args,
qemu_monitor_command_ret *ret)
{
- virDomainPtr domain = NULL;
+ virDomainPtr dom = NULL;
int rv = -1;
if (!conn) {
@@ -8666,10 +8666,10 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(domain = get_nonnull_domain(conn, args->domain)))
+ if (!(dom = get_nonnull_domain(conn, args->domain)))
goto cleanup;
- if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
+ if (virDomainQemuMonitorCommand(dom, args->cmd, &ret->result,
args->flags) < 0)
goto cleanup;
@@ -8678,8 +8678,8 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
cleanup:
if (rv < 0)
remoteDispatchError(rerr);
- if (domain)
- virDomainFree(domain);
+ if (dom)
+ virDomainFree(dom);
return rv;
}
@@ -8793,9 +8793,9 @@ get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
}
static virDomainSnapshotPtr
-get_nonnull_domain_snapshot(virDomainPtr domain, remote_nonnull_domain_snapshot snapshot)
+get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot)
{
- return virGetDomainSnapshot(domain, snapshot.name);
+ return virGetDomainSnapshot(dom, snapshot.name);
}
/* Make remote_nonnull_domain and remote_nonnull_network. */
--
1.7.4.2
2
1
[libvirt] [PATCH] Remove C99 variable declare in PHYP network driver
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
Move the virInterfacePtr declaration to the top of the
function to avoid jump uninitialized variable warnings
* src/phyp/phyp_driver.c: Fix var declaration
---
src/phyp/phyp_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
Pushed to fix the broken build...
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index b5145db..a1b6819 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3587,6 +3587,7 @@ phypInterfaceLookupByName(virConnectPtr conn, const char *name)
int slot = 0;
int lpar_id = 0;
char mac[PHYP_MAC_SIZE];
+ virInterfacePtr result = NULL;
/*Getting the slot number for the interface */
virBufferAddLit(&buf, "lshwres ");
@@ -3667,7 +3668,7 @@ phypInterfaceLookupByName(virConnectPtr conn, const char *name)
memcpy(mac, ret, PHYP_MAC_SIZE-1);
- virInterfacePtr result = virGetInterface(conn, name, ret);
+ result = virGetInterface(conn, name, ret);
VIR_FREE(cmd);
VIR_FREE(ret);
--
1.7.4.2
2
1
13 Apr '11
When I edit the domain's config file like this:
=====================
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/test3.img'/>
<target dev='sdb' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='10'/>
</disk>
=====================
Note, the unit is wrong, but libvirt does not check it.
When I start the vm with the wrong config file, libvirtd will be blocked because
qemu quited unexpectedly. This bug does not happen every time, and it only happened
once on my box.
So I try to use gdb and add sleep() to trigger this bug. I have posted two patches
to fix 2 bugs. But there is still another bug, and I have no good way to fix it.
I add sleep() in qemuDomainObjExitMonitorWithDriver():
==============================
int qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
int refs;
int debug = 0;
refs = qemuMonitorUnref(priv->mon);
if (refs > 0)
qemuMonitorUnlock(priv->mon);
/* Note: qemu may quited unexpectedly here, and the monitor will be freed.
* If it happened, priv->mon will be null.
*/
if (debug)
sleep(100);
qemuDriverLock(driver);
virDomainObjLock(obj);
if (refs == 0) {
priv->mon = NULL;
}
}
==============================
Steps to reproduce this bug:
1. use gdb to attach libvirtd, and set a breakpoint in the function
qemuConnectMonitor()
2. start a vm
3. let the libvirtd to run until qemuMonitorSetCapabilities() returns.
4. kill the qemu process
5. step into qemuDomainObjExitMonitorWithDriver(), and set debug to 1
Now, qemuDomainObjExitMonitorWithDriver() will sleep 100s to make sure
qemuProcessHandleMonitorEOF() is done before qemuProcessHandleMonitorEOF()
returns.
priv->mon will be null after qemuDomainObjExitMonitorWithDriver() returns.
So we must not use it. Unfortunately we still use it, and it will cause
libvirtd crashed.
My first fix is that qemuDomainObjExitMonitorWithDriver() returns -1, and
the caller checks the return value, then do some cleanup and return error.
Unfortunately we may use priv->mon when doing some cleanup. The only way
to avoid it is that add some local variable and set it when qemu quited
unexpectedly. Avoid to use priv->mon in cleanup codes
Is there some simply way to fix this bug.
3
6
13 Apr '11
Bug https://bugzilla.redhat.com/show_bug.cgi?id=689374 reported libvirtd
crash during error dispatch.
The reason is that libvirtd uses remoteDispatchConnError() with non-NULL
conn parameter which means that virConnGetLastError() is used instead of
its thread safe replacement virGetLastError().
So when several libvirtd threads are reporting errors at the same time,
the errors can get mixed or corrupted or in case of bad luck libvirtd
itself crashes.
Since Daniel B. is going to rewrite this code from scratch on top of his
RPC infrastructure, I tried to come up with a minimal fix. Thus,
remoteDispatchConnError() now just ignores its conn argument and always
calls virGetLastError(). However, several callers had to be touched as
well, since no libvirt API is allowed to be called before dispatching
the error. Doing so would reset the error and we would have nothing to
dispatch. As a result of that, the code is not very nice but that
doesn't really make daemon/remote.c worse than it is now :-) And it will
all die soon, which is good.
The bug report also contains a reproducer in C which detects both mixed
up error messages and libvirtd crash. Before this patch, I was able to
crash libvirtd in about 20 seconds up to 3 minutes depending on number
of CPU cores (more is better) and luck.
---
daemon/dispatch.c | 8 +--
daemon/remote.c | 238 +++++++++++++++++++++++++++-------------------------
2 files changed, 126 insertions(+), 120 deletions(-)
diff --git a/daemon/dispatch.c b/daemon/dispatch.c
index dc3b48a..4814017 100644
--- a/daemon/dispatch.c
+++ b/daemon/dispatch.c
@@ -113,14 +113,10 @@ void remoteDispatchOOMError (remote_error *rerr)
void remoteDispatchConnError (remote_error *rerr,
- virConnectPtr conn)
+ virConnectPtr conn ATTRIBUTE_UNUSED)
{
- virErrorPtr verr;
+ virErrorPtr verr = virGetLastError();
- if (conn)
- verr = virConnGetLastError(conn);
- else
- verr = virGetLastError();
if (verr)
remoteDispatchCopyError(rerr, verr);
else
diff --git a/daemon/remote.c b/daemon/remote.c
index a8fef4d..4b42ed2 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -757,8 +757,8 @@ remoteDispatchDomainGetSchedulerType (struct qemud_server *server ATTRIBUTE_UNUS
type = virDomainGetSchedulerType (dom, &nparams);
if (type == NULL) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -801,9 +801,9 @@ remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUT
r = virDomainGetSchedulerParameters (dom, params, &nparams);
if (r == -1) {
+ remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -908,12 +908,13 @@ remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUT
}
r = virDomainSetSchedulerParameters (dom, params, nparams);
- virDomainFree(dom);
VIR_FREE(params);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
+ virDomainFree(dom);
return 0;
}
@@ -939,8 +940,8 @@ remoteDispatchDomainBlockStats (struct qemud_server *server ATTRIBUTE_UNUSED,
path = args->path;
if (virDomainBlockStats (dom, path, &stats, sizeof stats) == -1) {
- virDomainFree (dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree (dom);
return -1;
}
virDomainFree (dom);
@@ -975,8 +976,8 @@ remoteDispatchDomainInterfaceStats (struct qemud_server *server ATTRIBUTE_UNUSED
path = args->path;
if (virDomainInterfaceStats (dom, path, &stats, sizeof stats) == -1) {
- virDomainFree (dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree (dom);
return -1;
}
virDomainFree (dom);
@@ -1026,12 +1027,13 @@ remoteDispatchDomainMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
}
nr_stats = virDomainMemoryStats (dom, stats, args->maxStats, 0);
- virDomainFree (dom);
if (nr_stats == -1) {
VIR_FREE(stats);
remoteDispatchConnError(rerr, conn);
+ virDomainFree (dom);
return -1;
}
+ virDomainFree (dom);
/* Allocate return buffer */
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
@@ -1092,8 +1094,8 @@ remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
if (virDomainBlockPeek (dom, path, offset, size,
ret->buffer.buffer_val, flags) == -1) {
/* free (ret->buffer.buffer_val); - caller frees */
- virDomainFree (dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree (dom);
return -1;
}
virDomainFree (dom);
@@ -1141,8 +1143,8 @@ remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
if (virDomainMemoryPeek (dom, offset, size,
ret->buffer.buffer_val, flags) == -1) {
/* free (ret->buffer.buffer_val); - caller frees */
- virDomainFree (dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree (dom);
return -1;
}
virDomainFree (dom);
@@ -1168,8 +1170,8 @@ remoteDispatchDomainAttachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainAttachDevice (dom, args->xml) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1194,8 +1196,8 @@ remoteDispatchDomainAttachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNU
}
if (virDomainAttachDeviceFlags (dom, args->xml, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1220,8 +1222,8 @@ remoteDispatchDomainUpdateDeviceFlags (struct qemud_server *server ATTRIBUTE_UNU
}
if (virDomainUpdateDeviceFlags (dom, args->xml, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1246,8 +1248,8 @@ remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainCreate (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1272,8 +1274,8 @@ remoteDispatchDomainCreateWithFlags (struct qemud_server *server ATTRIBUTE_UNUSE
}
if (virDomainCreateWithFlags (dom, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -1346,8 +1348,8 @@ remoteDispatchDomainDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainDestroy (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1372,8 +1374,8 @@ remoteDispatchDomainDetachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainDetachDevice (dom, args->xml) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -1399,8 +1401,8 @@ remoteDispatchDomainDetachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNU
}
if (virDomainDetachDeviceFlags (dom, args->xml, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -1428,8 +1430,8 @@ remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->xml = virDomainGetXMLDesc (dom, args->flags);
if (!ret->xml) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1497,8 +1499,8 @@ remoteDispatchDomainGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainGetAutostart (dom, &ret->autostart) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1524,8 +1526,8 @@ remoteDispatchDomainGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainGetInfo (dom, &info) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -1559,8 +1561,8 @@ remoteDispatchDomainGetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
ret->memory = virDomainGetMaxMemory (dom);
if (ret->memory == 0) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1586,8 +1588,8 @@ remoteDispatchDomainGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
ret->num = virDomainGetMaxVcpus (dom);
if (ret->num == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1614,8 +1616,8 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
memset(&seclabel, 0, sizeof seclabel);
if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -1686,8 +1688,8 @@ remoteDispatchDomainGetOsType (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this */
ret->type = virDomainGetOSType (dom);
if (ret->type == NULL) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1737,10 +1739,10 @@ remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
info, args->maxinfo,
cpumaps, args->maplen);
if (info_len == -1) {
+ remoteDispatchConnError(rerr, conn);
VIR_FREE(info);
VIR_FREE(cpumaps);
virDomainFree(dom);
- remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -1794,8 +1796,8 @@ remoteDispatchDomainGetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
ret->num = virDomainGetVcpusFlags (dom, args->flags);
if (ret->num == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -1877,11 +1879,12 @@ remoteDispatchDomainMigratePerform (struct qemud_server *server ATTRIBUTE_UNUSED
args->cookie.cookie_len,
args->uri,
args->flags, dname, args->resource);
- virDomainFree (dom);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
+ virDomainFree (dom);
return -1;
}
+ virDomainFree (dom);
return 0;
}
@@ -2013,8 +2016,8 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
args->flags, dname, args->resource,
args->dom_xml);
if (r == -1) {
- remoteFreeClientStream(client, stream);
remoteDispatchConnError(rerr, conn);
+ remoteFreeClientStream(client, stream);
return -1;
}
@@ -2175,8 +2178,8 @@ remoteDispatchDomainPinVcpu (struct qemud_server *server ATTRIBUTE_UNUSED,
(unsigned char *) args->cpumap.cpumap_val,
args->cpumap.cpumap_len);
if (rv == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2201,8 +2204,8 @@ remoteDispatchDomainReboot (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainReboot (dom, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2245,8 +2248,8 @@ remoteDispatchDomainResume (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainResume (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2271,8 +2274,8 @@ remoteDispatchDomainSave (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSave (dom, args->to) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2297,8 +2300,8 @@ remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainCoreDump (dom, args->to, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2323,8 +2326,8 @@ remoteDispatchDomainSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSetAutostart (dom, args->autostart) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2349,8 +2352,8 @@ remoteDispatchDomainSetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSetMaxMemory (dom, args->memory) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2375,8 +2378,8 @@ remoteDispatchDomainSetMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSetMemory (dom, args->memory) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2401,8 +2404,8 @@ remoteDispatchDomainSetMemoryFlags (struct qemud_server *server ATTRIBUTE_UNUSED
}
if (virDomainSetMemoryFlags (dom, args->memory, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2491,12 +2494,13 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
}
r = virDomainSetMemoryParameters(dom, params, nparams, flags);
- virDomainFree(dom);
VIR_FREE(params);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
+ virDomainFree(dom);
return 0;
}
@@ -2541,9 +2545,9 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
if (r == -1) {
+ remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
return -1;
}
/* In this case, we need to send back the number of parameters
@@ -2701,12 +2705,13 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
}
r = virDomainSetBlkioParameters(dom, params, nparams, flags);
- virDomainFree(dom);
VIR_FREE(params);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
+ virDomainFree(dom);
return 0;
}
@@ -2751,9 +2756,9 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
if (r == -1) {
+ remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
VIR_FREE(params);
- remoteDispatchConnError(rerr, conn);
return -1;
}
/* In this case, we need to send back the number of parameters
@@ -2847,8 +2852,8 @@ remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSetVcpus (dom, args->nvcpus) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2873,8 +2878,8 @@ remoteDispatchDomainSetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSetVcpusFlags (dom, args->nvcpus, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2899,8 +2904,8 @@ remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainShutdown (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2925,8 +2930,8 @@ remoteDispatchDomainSuspend (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainSuspend (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -2951,8 +2956,8 @@ remoteDispatchDomainUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainUndefine (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -3044,8 +3049,8 @@ remoteDispatchDomainManagedSave (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainManagedSave (dom, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -3071,8 +3076,8 @@ remoteDispatchDomainHasManagedSaveImage (struct qemud_server *server ATTRIBUTE_U
ret->ret = virDomainHasManagedSaveImage (dom, args->flags);
if (ret->ret == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -3097,8 +3102,8 @@ remoteDispatchDomainManagedSaveRemove (struct qemud_server *server ATTRIBUTE_UNU
}
if (virDomainManagedSaveRemove (dom, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
virDomainFree(dom);
@@ -3157,8 +3162,8 @@ remoteDispatchNetworkCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNetworkCreate (net) == -1) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3227,8 +3232,8 @@ remoteDispatchNetworkDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNetworkDestroy (net) == -1) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3255,8 +3260,8 @@ remoteDispatchNetworkDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->xml = virNetworkGetXMLDesc (net, args->flags);
if (!ret->xml) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3281,8 +3286,8 @@ remoteDispatchNetworkGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNetworkGetAutostart (net, &ret->autostart) == -1) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3309,8 +3314,8 @@ remoteDispatchNetworkGetBridgeName (struct qemud_server *server ATTRIBUTE_UNUSED
/* remoteDispatchClientRequest will free this. */
ret->name = virNetworkGetBridgeName (net);
if (!ret->name) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3379,8 +3384,8 @@ remoteDispatchNetworkSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNetworkSetAutostart (net, args->autostart) == -1) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3405,8 +3410,8 @@ remoteDispatchNetworkUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNetworkUndefine (net) == -1) {
- virNetworkFree(net);
remoteDispatchConnError(rerr, conn);
+ virNetworkFree(net);
return -1;
}
virNetworkFree(net);
@@ -3642,8 +3647,8 @@ remoteDispatchInterfaceGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->xml = virInterfaceGetXMLDesc (iface, args->flags);
if (!ret->xml) {
- virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
+ virInterfaceFree(iface);
return -1;
}
virInterfaceFree(iface);
@@ -3690,8 +3695,8 @@ remoteDispatchInterfaceUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virInterfaceUndefine (iface) == -1) {
- virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
+ virInterfaceFree(iface);
return -1;
}
virInterfaceFree(iface);
@@ -3716,8 +3721,8 @@ remoteDispatchInterfaceCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virInterfaceCreate (iface, args->flags) == -1) {
- virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
+ virInterfaceFree(iface);
return -1;
}
virInterfaceFree(iface);
@@ -3742,8 +3747,8 @@ remoteDispatchInterfaceDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virInterfaceDestroy (iface, args->flags) == -1) {
- virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
+ virInterfaceFree(iface);
return -1;
}
virInterfaceFree(iface);
@@ -4656,8 +4661,8 @@ remoteDispatchStoragePoolCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolCreate (pool, args->flags) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4726,8 +4731,8 @@ remoteDispatchStoragePoolBuild (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolBuild (pool, args->flags) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4753,8 +4758,8 @@ remoteDispatchStoragePoolDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolDestroy (pool) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4779,8 +4784,8 @@ remoteDispatchStoragePoolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolDelete (pool, args->flags) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4805,8 +4810,8 @@ remoteDispatchStoragePoolRefresh (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolRefresh (pool, args->flags) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4832,8 +4837,8 @@ remoteDispatchStoragePoolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolGetInfo (pool, &info) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
@@ -4867,8 +4872,8 @@ remoteDispatchStoragePoolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->xml = virStoragePoolGetXMLDesc (pool, args->flags);
if (!ret->xml) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4893,8 +4898,8 @@ remoteDispatchStoragePoolGetAutostart (struct qemud_server *server ATTRIBUTE_UNU
}
if (virStoragePoolGetAutostart (pool, &ret->autostart) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -4965,11 +4970,12 @@ remoteDispatchStoragePoolLookupByVolume (struct qemud_server *server ATTRIBUTE_U
}
pool = virStoragePoolLookupByVolume (vol);
- virStorageVolFree(vol);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
+ virStorageVolFree(vol);
return -1;
}
+ virStorageVolFree(vol);
make_nonnull_storage_pool (&ret->pool, pool);
virStoragePoolFree(pool);
@@ -4994,8 +5000,8 @@ remoteDispatchStoragePoolSetAutostart (struct qemud_server *server ATTRIBUTE_UNU
}
if (virStoragePoolSetAutostart (pool, args->autostart) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -5020,8 +5026,8 @@ remoteDispatchStoragePoolUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStoragePoolUndefine (pool) == -1) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
virStoragePoolFree(pool);
@@ -5163,11 +5169,12 @@ remoteDispatchStorageVolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
}
vol = virStorageVolCreateXML (pool, args->xml, args->flags);
- virStoragePoolFree(pool);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
+ virStoragePoolFree(pool);
make_nonnull_storage_vol (&ret->vol, vol);
virStorageVolFree(vol);
@@ -5194,19 +5201,21 @@ remoteDispatchStorageVolCreateXmlFrom (struct qemud_server *server ATTRIBUTE_UNU
clonevol = get_nonnull_storage_vol (conn, args->clonevol);
if (clonevol == NULL) {
- virStoragePoolFree(pool);
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
newvol = virStorageVolCreateXMLFrom (pool, args->xml, clonevol,
args->flags);
- virStorageVolFree(clonevol);
- virStoragePoolFree(pool);
if (newvol == NULL) {
remoteDispatchConnError(rerr, conn);
+ virStorageVolFree(clonevol);
+ virStoragePoolFree(pool);
return -1;
}
+ virStorageVolFree(clonevol);
+ virStoragePoolFree(pool);
make_nonnull_storage_vol (&ret->vol, newvol);
virStorageVolFree(newvol);
@@ -5231,8 +5240,8 @@ remoteDispatchStorageVolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStorageVolDelete (vol, args->flags) == -1) {
- virStorageVolFree(vol);
remoteDispatchConnError(rerr, conn);
+ virStorageVolFree(vol);
return -1;
}
virStorageVolFree(vol);
@@ -5290,8 +5299,8 @@ remoteDispatchStorageVolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virStorageVolGetInfo (vol, &info) == -1) {
- virStorageVolFree(vol);
remoteDispatchConnError(rerr, conn);
+ virStorageVolFree(vol);
return -1;
}
@@ -5324,8 +5333,8 @@ remoteDispatchStorageVolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->xml = virStorageVolGetXMLDesc (vol, args->flags);
if (!ret->xml) {
- virStorageVolFree(vol);
remoteDispatchConnError(rerr, conn);
+ virStorageVolFree(vol);
return -1;
}
virStorageVolFree(vol);
@@ -5353,8 +5362,8 @@ remoteDispatchStorageVolGetPath (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->name = virStorageVolGetPath (vol);
if (!ret->name) {
- virStorageVolFree(vol);
remoteDispatchConnError(rerr, conn);
+ virStorageVolFree(vol);
return -1;
}
virStorageVolFree(vol);
@@ -5381,11 +5390,12 @@ remoteDispatchStorageVolLookupByName (struct qemud_server *server ATTRIBUTE_UNUS
}
vol = virStorageVolLookupByName (pool, args->name);
- virStoragePoolFree(pool);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
+ virStoragePoolFree(pool);
return -1;
}
+ virStoragePoolFree(pool);
make_nonnull_storage_vol (&ret->vol, vol);
virStorageVolFree(vol);
@@ -5622,8 +5632,8 @@ remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
ret->num = virNodeDeviceNumOfCaps(dev);
if (ret->num < 0) {
- virNodeDeviceFree(dev);
remoteDispatchConnError(rerr, conn);
+ virNodeDeviceFree(dev);
return -1;
}
@@ -5668,8 +5678,8 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
virNodeDeviceListCaps (dev, ret->names.names_val,
args->maxnames);
if (ret->names.names_len == -1) {
- virNodeDeviceFree(dev);
remoteDispatchConnError(rerr, conn);
+ virNodeDeviceFree(dev);
VIR_FREE(ret->names.names_val);
return -1;
}
@@ -5698,8 +5708,8 @@ remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNodeDeviceDettach(dev) == -1) {
- virNodeDeviceFree(dev);
remoteDispatchConnError(rerr, conn);
+ virNodeDeviceFree(dev);
return -1;
}
@@ -5727,8 +5737,8 @@ remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNodeDeviceReAttach(dev) == -1) {
- virNodeDeviceFree(dev);
remoteDispatchConnError(rerr, conn);
+ virNodeDeviceFree(dev);
return -1;
}
@@ -5756,8 +5766,8 @@ remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNodeDeviceReset(dev) == -1) {
- virNodeDeviceFree(dev);
remoteDispatchConnError(rerr, conn);
+ virNodeDeviceFree(dev);
return -1;
}
@@ -5808,8 +5818,8 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNodeDeviceDestroy(dev) == -1) {
- virNodeDeviceFree(dev);
remoteDispatchConnError(rerr, conn);
+ virNodeDeviceFree(dev);
return -1;
}
@@ -6189,8 +6199,8 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
ret->active = virDomainIsActive(domain);
if (ret->active < 0) {
- virDomainFree(domain);
remoteDispatchConnError(err, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6217,8 +6227,8 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
ret->persistent = virDomainIsPersistent(domain);
if (ret->persistent < 0) {
- virDomainFree(domain);
remoteDispatchConnError(err, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6245,8 +6255,8 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
ret->updated = virDomainIsUpdated(domain);
if (ret->updated < 0) {
- virDomainFree(domain);
remoteDispatchConnError(err, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6273,8 +6283,8 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
ret->active = virInterfaceIsActive(iface);
if (ret->active < 0) {
- virInterfaceFree(iface);
remoteDispatchConnError(err, conn);
+ virInterfaceFree(iface);
return -1;
}
@@ -6301,8 +6311,8 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
ret->active = virNetworkIsActive(network);
if (ret->active < 0) {
- virNetworkFree(network);
remoteDispatchConnError(err, conn);
+ virNetworkFree(network);
return -1;
}
@@ -6329,8 +6339,8 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
ret->persistent = virNetworkIsPersistent(network);
if (ret->persistent < 0) {
- virNetworkFree(network);
remoteDispatchConnError(err, conn);
+ virNetworkFree(network);
return -1;
}
@@ -6357,8 +6367,8 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
ret->active = virStoragePoolIsActive(pool);
if (ret->active < 0) {
- virStoragePoolFree(pool);
remoteDispatchConnError(err, conn);
+ virStoragePoolFree(pool);
return -1;
}
@@ -6385,8 +6395,8 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
ret->persistent = virStoragePoolIsPersistent(pool);
if (ret->persistent < 0) {
- virStoragePoolFree(pool);
remoteDispatchConnError(err, conn);
+ virStoragePoolFree(pool);
return -1;
}
@@ -6481,8 +6491,8 @@ remoteDispatchDomainGetJobInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainGetJobInfo (dom, &info) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -6523,8 +6533,8 @@ remoteDispatchDomainAbortJob (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainAbortJob (dom) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -6552,8 +6562,8 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
}
if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -6610,8 +6620,8 @@ remoteDispatchDomainSnapshotCreateXml (struct qemud_server *server ATTRIBUTE_UNU
snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
if (snapshot == NULL) {
- virDomainFree(domain);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6652,12 +6662,12 @@ remoteDispatchDomainSnapshotDumpXml (struct qemud_server *server ATTRIBUTE_UNUSE
rc = 0;
cleanup:
+ if (rc < 0)
+ remoteDispatchConnError(rerr, conn);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
return rc;
}
@@ -6681,8 +6691,8 @@ remoteDispatchDomainSnapshotNum (struct qemud_server *server ATTRIBUTE_UNUSED,
ret->num = virDomainSnapshotNum(domain, args->flags);
if (ret->num == -1) {
- virDomainFree(domain);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6726,9 +6736,9 @@ remoteDispatchDomainSnapshotListNames (struct qemud_server *server ATTRIBUTE_UNU
args->nameslen,
args->flags);
if (ret->names.names_len == -1) {
+ remoteDispatchConnError(rerr, conn);
virDomainFree(domain);
VIR_FREE(ret->names.names_val);
- remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6757,8 +6767,8 @@ remoteDispatchDomainSnapshotLookupByName (struct qemud_server *server ATTRIBUTE_
snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
if (snapshot == NULL) {
- virDomainFree(domain);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6790,8 +6800,8 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
result = virDomainHasCurrentSnapshot(domain, args->flags);
if (result < 0) {
- virDomainFree(domain);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6822,8 +6832,8 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
snapshot = virDomainSnapshotCurrent(domain, args->flags);
if (snapshot == NULL) {
- virDomainFree(domain);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(domain);
return -1;
}
@@ -6862,12 +6872,12 @@ remoteDispatchDomainRevertToSnapshot (struct qemud_server *server ATTRIBUTE_UNUS
rc = 0;
cleanup:
+ if (rc < 0)
+ remoteDispatchConnError(rerr, conn);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
return rc;
}
@@ -6899,12 +6909,12 @@ remoteDispatchDomainSnapshotDelete (struct qemud_server *server ATTRIBUTE_UNUSED
rc = 0;
cleanup:
+ if (rc < 0)
+ remoteDispatchConnError(rerr, conn);
if (snapshot)
virDomainSnapshotFree(snapshot);
if (domain)
virDomainFree(domain);
- if (rc < 0)
- remoteDispatchConnError(rerr, conn);
return rc;
}
@@ -7069,8 +7079,8 @@ remoteDispatchNwfilterUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virNWFilterUndefine (nwfilter) == -1) {
- virNWFilterFree(nwfilter);
remoteDispatchConnError(rerr, conn);
+ virNWFilterFree(nwfilter);
return -1;
}
virNWFilterFree(nwfilter);
@@ -7132,8 +7142,8 @@ remoteDispatchNwfilterGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
/* remoteDispatchClientRequest will free this. */
ret->xml = virNWFilterGetXMLDesc (nwfilter, args->flags);
if (!ret->xml) {
- virNWFilterFree(nwfilter);
remoteDispatchConnError(rerr, conn);
+ virNWFilterFree(nwfilter);
return -1;
}
virNWFilterFree(nwfilter);
@@ -7180,8 +7190,8 @@ remoteDispatchDomainGetBlockInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
if (virDomainGetBlockInfo (dom, args->path, &info, args->flags) == -1) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
return -1;
}
@@ -7213,8 +7223,8 @@ qemuDispatchMonitorCommand (struct qemud_server *server ATTRIBUTE_UNUSED,
if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
args->flags) == -1) {
- virDomainFree(domain);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(domain);
return -1;
}
@@ -7257,15 +7267,15 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
stream->st,
args->flags);
if (r == -1) {
+ remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
remoteFreeClientStream(client, stream);
- remoteDispatchConnError(rerr, conn);
return -1;
}
if (remoteAddClientStream(client, stream, 1) < 0) {
- virDomainFree(dom);
remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
virStreamAbort(stream->st);
remoteFreeClientStream(client, stream);
return -1;
--
1.7.4.1
3
3
13 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.
---
docs/formatdomain.html.in | 12 ++
docs/schemas/domain.rng | 50 ++++++++
src/conf/domain_conf.c | 130 ++++++++++++++++++++
src/conf/domain_conf.h | 42 +++++++
src/libvirt_private.syms | 8 ++
src/qemu/qemu_command.c | 16 +++
.../qemuxml2argv-graphics-spice.args | 4 +-
.../qemuxml2argv-graphics-spice.xml | 4 +
8 files changed, 265 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..f215e7d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -322,6 +322,32 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceChannelMode,
"secure",
"insecure");
+VIR_ENUM_IMPL(virDomainGraphicsSpiceImageCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST,
+ "auto_glz",
+ "auto_lz",
+ "quic",
+ "glz",
+ "lz",
+ "off");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpiceJpegCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST,
+ "auto",
+ "never",
+ "always");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpiceZlibCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST,
+ "auto",
+ "never",
+ "always");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST,
+ "on",
+ "off");
+
VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
"subsystem",
"capabilities")
@@ -3917,6 +3943,11 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth) < 0)
goto error;
+ def->data.spice.image = VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST;
+ def->data.spice.jpeg = VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST;
+ def->data.spice.zlib = VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST;
+ def->data.spice.playback = VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST;
+
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
@@ -3954,6 +3985,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_INTERNAL_ERROR,
+ _("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_INTERNAL_ERROR,
+ _("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_INTERNAL_ERROR,
+ _("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_INTERNAL_ERROR,
+ _("unknown spice playback compression"));
+ VIR_FREE(compression);
+ goto error;
+
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.playback = compressionVal;
}
}
cur = cur->next;
@@ -7817,6 +7931,22 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
virDomainGraphicsSpiceChannelNameTypeToString(i),
virDomainGraphicsSpiceChannelModeTypeToString(mode));
}
+ if (def->data.spice.image !=
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST)
+ virBufferVSprintf(buf, " <image compression='%s'/>\n",
+ virDomainGraphicsSpiceImageCompressionTypeToString(def->data.spice.image));
+ if (def->data.spice.jpeg !=
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST)
+ virBufferVSprintf(buf, " <jpeg compression='%s'/>\n",
+ virDomainGraphicsSpiceJpegCompressionTypeToString(def->data.spice.jpeg));
+ if (def->data.spice.zlib !=
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST)
+ virBufferVSprintf(buf, " <zlib compression='%s'/>\n",
+ virDomainGraphicsSpiceZlibCompressionTypeToString(def->data.spice.zlib));
+ if (def->data.spice.playback !=
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST)
+ 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..e36f0ed 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -658,6 +658,40 @@ enum virDomainGraphicsSpiceChannelMode {
VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST
};
+enum virDomainGraphicsSpiceImageCompression {
+ 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_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_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_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 +729,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 +1461,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..6272910 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4032,6 +4032,22 @@ qemuBuildCommandLine(virConnectPtr conn,
break;
}
}
+ if (def->graphics[0]->data.spice.image !=
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST)
+ virBufferVSprintf(&opt, ",image-compression=%s",
+ virDomainGraphicsSpiceImageCompressionTypeToString(def->graphics[0]->data.spice.image));
+ if (def->graphics[0]->data.spice.jpeg !=
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST)
+ virBufferVSprintf(&opt, ",jpeg-wan-compression=%s",
+ virDomainGraphicsSpiceJpegCompressionTypeToString(def->graphics[0]->data.spice.jpeg));
+ if (def->graphics[0]->data.spice.zlib !=
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST)
+ virBufferVSprintf(&opt, ",zlib-glz-wan-compression=%s",
+ virDomainGraphicsSpiceZlibCompressionTypeToString(def->graphics[0]->data.spice.zlib));
+ if (def->graphics[0]->data.spice.playback !=
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST)
+ 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
3
2
13 Apr '11
This is a series of 3 patches to add network management support for
pHyp driver.
Eduardo Otubo (3):
PHYP: Separating UUID functions in another file
PHYP: Adding basic network functions
PHYP: create, destroy and other network functions
po/POTFILES.in | 1 +
src/Makefile.am | 3 +-
src/phyp/phyp_driver.c | 1066 +++++++++++++++++++++++++++---------------------
src/phyp/phyp_driver.h | 43 ++-
src/phyp/phyp_uuid.c | 834 +++++++++++++++++++++++++++++++++++++
src/phyp/phyp_uuid.h | 44 ++
6 files changed, 1520 insertions(+), 471 deletions(-)
create mode 100644 src/phyp/phyp_uuid.c
create mode 100644 src/phyp/phyp_uuid.h
3
25
[libvirt] [PATCH] - added mapping to Network object - added implementation of select networking functions - virsh net-list and net-info commands now work for esx
by jbarkley 13 Apr '11
by jbarkley 13 Apr '11
13 Apr '11
From: jbarkely <jbarkley(a)willo.(none)>
---
src/esx/esx_network_driver.c | 181 +++++++++++++++++++++++++++++++++++++++-
src/esx/esx_vi.c | 104 ++++++++++++++++++++++-
src/esx/esx_vi.h | 9 ++
src/esx/esx_vi_generator.input | 78 +++++++++++++++++
4 files changed, 366 insertions(+), 6 deletions(-)
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index a64bb8e..c4cc7b4 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -34,6 +34,7 @@
#include "esx_vi.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
+#include "md5.h"
#define VIR_FROM_THIS VIR_FROM_ESX
@@ -63,18 +64,190 @@ esxNetworkClose(virConnectPtr conn)
return 0;
}
+static virNetworkPtr
+esxNetworkLookupByName(virConnectPtr conn, const char *name) {
+ //esxPrivate *priv = conn->networkPrivateData;
+ esxPrivate *priv = conn->networkPrivateData;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *network = NULL;
+ virNetworkPtr virNetwork = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ unsigned char md5[MD5_DIGEST_SIZE]; /* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
+
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return NULL;
+ }
+
+ if (esxVI_LookupNetworkByName(priv->primary, name, propertyNameList,
+ &network,
+ esxVI_Occurrence_OptionalItem) < 0) {
+ goto cleanup;
+ }
+
+ if (NULL==network) {
+ // raise error
+ ESX_ERROR(VIR_ERR_NO_NETWORK, _("No network with name '%s'"), name);
+ goto cleanup;
+
+ }
+
+ char *name_candidate = NULL;
+ esxVI_GetStringValue(network, "name", &name_candidate, esxVI_Occurrence_OptionalItem);
+
+ md5_buffer(name, strlen(name), md5);
+ virNetwork = virGetNetwork(conn, name, md5);
+
+ cleanup:
+ esxVI_String_Free(&propertyNameList);
+ //esxVI_ObjectContent_Free(&network);
+// printf("virNetwork=%s\n", virNetwork->name);
+ return virNetwork;
+}
+
+static int
+esxListNetworks(virConnectPtr conn, char **const names, int nnames)
+{
+ //setup
+ bool success = false;
+ esxPrivate *priv = conn->networkPrivateData;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_ObjectContent *networkList = NULL;
+ esxVI_ObjectContent *network = NULL;
+ int count = 0;
+ int i;
+
+ //check args
+ if (names == NULL || nnames < 0) {
+ ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ if (nnames == 0) {
+ return 0;
+ }
+
+ //check connection
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return -1;
+ }
+
+ //get network(s)
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "summary.name") < 0 ||
+ esxVI_LookupNetworkList(priv->primary, propertyNameList,
+ &networkList) < 0) {
+ goto cleanup;
+ }
+
+ for (network = networkList; network != NULL;
+ network = network->_next) {
+ for (dynamicProperty = network->propSet; dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "summary.name")) {
+ if (esxVI_AnyType_ExpectType(dynamicProperty->val,
+ esxVI_Type_String) < 0) {
+ goto cleanup;
+ }
+
+ names[count] = strdup(dynamicProperty->val->string);
+
+ if (names[count] == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ++count;
+ break;
+ } else {
+ VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
+ }
+ }
+ }
+
+ success = true;
+
+ //cleanup
+ cleanup:
+ if (! success) {
+ for (i = 0; i < count; ++i) {
+ VIR_FREE(names[i]);
+ }
+
+ count = -1;
+ }
+
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&networkList);
+
+ return count;
+}
+
+static int
+esxNumOfNetworks(virConnectPtr conn)
+{
+ //setup
+ esxPrivate *priv = conn->networkPrivateData;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_ObjectContent *networkList = NULL;
+ esxVI_ObjectContent *network = NULL;
+ int count = 0;
+ int i;
+
+ //check connection
+ if (esxVI_EnsureSession(priv->primary) < 0) {
+ return -1;
+ }
+
+ //get network(s)
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "summary.name") < 0 ||
+ esxVI_LookupNetworkList(priv->primary, propertyNameList,
+ &networkList) < 0) {
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&networkList);
+
+ return -1;
+ }
+
+ for (network = networkList; network != NULL;
+ network = network->_next) {
+ for (dynamicProperty = network->propSet; dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "summary.name")) {
+ ++count;
+ break;
+ } else {
+ VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
+ }
+ }
+ }
+
+
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&networkList);
+
+ return count;
+}
+
+static int esxNumOfDefinedNetworks(virConnectPtr conn)
+{
+ printf("JB-BUG C\n");
+ return 8;
+}
static virNetworkDriver esxNetworkDriver = {
"ESX", /* name */
esxNetworkOpen, /* open */
esxNetworkClose, /* close */
- NULL, /* numOfNetworks */
- NULL, /* listNetworks */
- NULL, /* numOfDefinedNetworks */
+ esxNumOfNetworks, /* numOfNetworks */
+ esxListNetworks, /* listNetworks */
+ esxNumOfDefinedNetworks, /* numOfDefinedNetworks */
NULL, /* listDefinedNetworks */
NULL, /* networkLookupByUUID */
- NULL, /* networkLookupByName */
+ esxNetworkLookupByName, /* networkLookupByName */
NULL, /* networkCreateXML */
NULL, /* networkDefineXML */
NULL, /* networkUndefine */
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 7446ec5..509cf07 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -109,6 +109,7 @@ ESX_VI__TEMPLATE__FREE(Context,
esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToParent);
esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToVm);
esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToDatastore);
+ esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToNetwork);
esxVI_SelectionSpec_Free(&item->selectSet_computeResourceToHost);
esxVI_SelectionSpec_Free(&item->selectSet_computeResourceToParentToParent);
});
@@ -1483,6 +1484,13 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx)
return -1;
}
+ /* HostSystem -> network (Network) */
+ if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToNetwork,
+ "hostSystemToNetwork",
+ "HostSystem", "network", NULL) < 0) {
+ return -1;
+ }
+
/* Folder -> parent (Folder, Datacenter) */
if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToParentToParent,
"managedEntityToParent",
@@ -1543,9 +1551,13 @@ esxVI_EnsureSession(esxVI_Context *ctx)
* Query the session manager for the current session of this connection
* and re-login if there is no current session for this connection.
*/
+
if (esxVI_String_AppendValueToList(&propertyNameList,
- "currentSession") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->service->sessionManager,
+ "currentSession") < 0) {
+ goto cleanup;
+ }
+
+ if (esxVI_LookupObjectContentByType(ctx, ctx->service->sessionManager,
"SessionManager", propertyNameList,
&sessionManager,
esxVI_Occurrence_RequiredItem) < 0) {
@@ -1649,6 +1661,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
objectSpec->selectSet = ctx->selectSet_hostSystemToVm;
} else if (STREQ(type, "Datastore")) {
objectSpec->selectSet = ctx->selectSet_hostSystemToDatastore;
+ } else if (STREQ(type, "Network")) {
+ objectSpec->selectSet = ctx->selectSet_hostSystemToNetwork;
} else {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Invalid lookup of '%s' from '%s'"),
@@ -2474,6 +2488,92 @@ esxVI_LookupDatastoreList(esxVI_Context *ctx, esxVI_String *propertyNameList,
esxVI_Occurrence_OptionalList);
}
+int
+esxVI_LookupNetworkList(esxVI_Context *ctx,
+ esxVI_String *propertyNameList,
+ esxVI_ObjectContent **networkList)
+{
+ return esxVI_LookupObjectContentByType(ctx, ctx->hostSystem->_reference,
+ "Network", propertyNameList,
+ networkList,
+ esxVI_Occurrence_OptionalList);
+}
+
+int
+esxVI_LookupNetworkByName(esxVI_Context *ctx, const char *name,
+ esxVI_String *propertyNameList,
+ esxVI_ObjectContent **network,
+ esxVI_Occurrence occurrence)
+{
+ int result = -1;
+ esxVI_String *completePropertyNameList = NULL;
+ esxVI_ObjectContent *networkList = NULL;
+ esxVI_ObjectContent *candidate = NULL;
+ char *name_candidate = NULL;
+
+ if (network == NULL || *network != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+
+ if (esxVI_String_DeepCopyList(&completePropertyNameList,
+ propertyNameList) < 0 ||
+ esxVI_String_AppendValueToList(&completePropertyNameList, "name") < 0 ||
+ esxVI_LookupNetworkList(ctx, completePropertyNameList,
+ &networkList) < 0) {
+ goto cleanup;
+ }
+
+ for (candidate = networkList; candidate != NULL;
+ candidate = candidate->_next) {
+ VIR_FREE(name_candidate);
+
+ /*
+ if (esxVI_GetVirtualMachineIdentity(candidate, NULL, &name_candidate,
+ NULL) < 0) {
+ goto cleanup;
+ }
+ */
+ if (esxVI_GetStringValue(candidate, "name", &name_candidate,
+ esxVI_Occurrence_OptionalItem) < 0) {
+ goto cleanup;
+ }
+
+ if (STRNEQ(name, name_candidate)) {
+ continue;
+ }
+
+ if (esxVI_ObjectContent_DeepCopy(network, candidate) < 0) {
+ goto cleanup;
+ }
+
+ break;
+ }
+
+ /*
+ if (*network == NULL) {
+ if (occurrence == esxVI_Occurrence_OptionalItem) {
+ result = 0;
+
+ goto cleanup;
+ } else {
+ ESX_VI_ERROR(VIR_ERR_NO_NETWORK,
+ _("Could not find network with name '%s'"), name);
+ goto cleanup;
+ }
+ }
+ */
+
+ result = 0;
+
+ cleanup:
+ esxVI_String_Free(&completePropertyNameList);
+ esxVI_ObjectContent_Free(&networkList);
+ //VIR_FREE(name_candidate);
+
+ return result;
+}
int
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index e150dbf..cbd6068 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -165,6 +165,7 @@ struct _esxVI_Context {
esxVI_SelectionSpec *selectSet_hostSystemToParent;
esxVI_SelectionSpec *selectSet_hostSystemToVm;
esxVI_SelectionSpec *selectSet_hostSystemToDatastore;
+ esxVI_SelectionSpec *selectSet_hostSystemToNetwork;
esxVI_SelectionSpec *selectSet_computeResourceToHost;
esxVI_SelectionSpec *selectSet_computeResourceToParentToParent;
bool hasQueryVirtualDiskUuid;
@@ -367,11 +368,19 @@ int esxVI_LookupVirtualMachineByUuidAndPrepareForTask
int esxVI_LookupDatastoreList(esxVI_Context *ctx, esxVI_String *propertyNameList,
esxVI_ObjectContent **datastoreList);
+int esxVI_LookupNetworkList(esxVI_Context *ctx, esxVI_String *propertyNameList,
+ esxVI_ObjectContent **networkList);
+
int esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name,
esxVI_String *propertyNameList,
esxVI_ObjectContent **datastore,
esxVI_Occurrence occurrence);
+int esxVI_LookupNetworkByName(esxVI_Context *ctx, const char *name,
+ esxVI_String *propertyNameList,
+ esxVI_ObjectContent **network,
+ esxVI_Occurrence occurrence);
+
int esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
const char *absolutePath,
esxVI_String *propertyNameList,
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 44d1d9b..86c4b12 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -334,6 +334,84 @@ object HostNasVolume extends HostFileSystemVolume
String userName o
end
+object HostNetCapabilities
+end
+
+object HostIpRouteConfig
+end
+
+object HostDnsConfig
+end
+
+object HostIpRouteConfig
+end
+
+object HostNetworkConfig
+end
+
+object HostNetworkInfo
+end
+
+object HostNetworkSystem
+ HostNetCapabilities capabilities rl
+ HostIpRouteConfig consoleIpRuteConfig r
+ HostDnsConfig dnsConfig r
+ HostIpRouteConfig ipRouteConfig r
+ HostNetworkConfig networkConfig r
+ HostNetworkInfo networkInfo r
+end
+
+
+object HostIpRouteConfig
+end
+
+object HostVirtualNic
+end
+
+object HostDhcpService
+end
+
+object HostDnsConfig
+end
+
+object HostNatService
+end
+
+object PhysicalNic
+end
+
+object HostPortGroup
+end
+
+object HostProxySwitch
+end
+
+object HostIpRouteTableInfo
+end
+
+object HostVirtualNic
+end
+
+object HostVirtualSwitch
+end
+
+object HostNetworkInfo
+ Boolean atBootIpV6Enabled r
+ HostIpRouteConfig consoleIpRouteConfig r
+ HostVirtualNic consoleVnic rl
+ HostDhcpService dhcp rl
+ HostDnsConfig dnsConfig r
+ HostIpRouteConfig ipRouteConfig r
+ Boolean ipV6Enabled r
+ HostNatService nat rl
+ PhysicalNic pnic rl
+ HostPortGroup portgroup rl
+ HostProxySwitch proxySwitch rl
+ HostIpRouteTableInfo routeTableInfo r
+ HostVirtualNic vnic rl
+ HostVirtualSwitch vswitch rl
+end
+
object HostScsiDiskPartition
String diskName r
--
1.7.4.1
4
3
Thanks , Hahn!
I think I get your point ,libvirt or the host machine is independent from the guest OS.
but ,as I know ,on the VMware ESX server , they supply an extra tool called vmware-tools which can get more information
about the Guest OS,including the network info. How did they do this?
Now I had to write a tool to get more information about the active Guest OS using KVM hypervisor , have no idea how to
who can help me ?
Sincerely
wade
2
1
13 Apr '11
Hi all,
Currently "virsh setmem" is not allowed to use against an inactive domain.
This is yet another approach to configure inactive domain's memory size.
The approach before was closed in "virsh" command:
http://www.redhat.com/archives/libvir-list/2011-February/msg01074.html
This time a new libvirt API is introduced to achieve this.
*[PATCH 1/5] setmem: introduce a new libvirt API (virDomainSetMemoryFlags)
*[PATCH 2/5] setmem: implement the call back member for new API on each driver
*[PATCH 3/5] setmem: implement the code to address the new API in the qemu driver
*[PATCH 4/5] setmem: implement the remote protocol to address the new API
*[PATCH 5/5] setmem: add the new options to "virsh setmem" command
Best regards,
Taku Izumi
5
28
[libvirt] [PATCH 0/3] Expose the libvirtd event loop to apps as an API
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
We provide the virEventRegister() API to let applications provide
a set of callbacks to integrate with their existing event loop.
Not all apps have an existing event loop and forcing them to write
one themselves is an undue burden, which they often get wrong. We
have an event loop impl used by libvirtd that could be used by
applications. This series exposes it via two new public APIs. Apps
are free to ignore these new APIs and provide their own impl, but
this should help the common case.
4
11
[libvirt] [PATCH] Replace REMOTE_DEBUG with VIR_DEBUG in daemon dispatcher
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
The daemon dispatcher code had an obsolete macro
#define REMOTE_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)
This can be trivially removed
* daemon/remote.c: s/REMOTE_DEBUG/VIR_DEBUG/
---
daemon/remote.c | 59 +++++++++++++++++++++++++++----------------------------
1 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 2a56d91..3ecf85f 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -63,7 +63,6 @@
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_REMOTE
-#define REMOTE_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
@@ -134,7 +133,7 @@ static int remoteRelayDomainEventLifecycle(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain lifecycle event %d %d", event, detail);
+ VIR_DEBUG("Relaying domain lifecycle event %d %d", event, detail);
virMutexLock(&client->lock);
@@ -163,7 +162,7 @@ static int remoteRelayDomainEventReboot(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain reboot event %s %d", dom->name, dom->id);
+ VIR_DEBUG("Relaying domain reboot event %s %d", dom->name, dom->id);
virMutexLock(&client->lock);
@@ -192,7 +191,7 @@ static int remoteRelayDomainEventRTCChange(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain rtc change event %s %d %lld", dom->name, dom->id, offset);
+ VIR_DEBUG("Relaying domain rtc change event %s %d %lld", dom->name, dom->id, offset);
virMutexLock(&client->lock);
@@ -222,7 +221,7 @@ static int remoteRelayDomainEventWatchdog(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain watchdog event %s %d %d", dom->name, dom->id, action);
+ VIR_DEBUG("Relaying domain watchdog event %s %d %d", dom->name, dom->id, action);
virMutexLock(&client->lock);
@@ -254,7 +253,7 @@ static int remoteRelayDomainEventIOError(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain io error %s %d %s %s %d", dom->name, dom->id, srcPath, devAlias, action);
+ VIR_DEBUG("Relaying domain io error %s %d %s %s %d", dom->name, dom->id, srcPath, devAlias, action);
virMutexLock(&client->lock);
@@ -289,8 +288,8 @@ static int remoteRelayDomainEventIOErrorReason(virConnectPtr conn ATTRIBUTE_UNUS
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain io error %s %d %s %s %d %s",
- dom->name, dom->id, srcPath, devAlias, action, reason);
+ VIR_DEBUG("Relaying domain io error %s %d %s %s %d %s",
+ dom->name, dom->id, srcPath, devAlias, action, reason);
virMutexLock(&client->lock);
@@ -328,14 +327,14 @@ static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!client)
return -1;
- REMOTE_DEBUG("Relaying domain graphics event %s %d %d - %d %s %s - %d %s %s - %s", dom->name, dom->id, phase,
- local->family, local->service, local->node,
- remote->family, remote->service, remote->node,
- authScheme);
+ VIR_DEBUG("Relaying domain graphics event %s %d %d - %d %s %s - %d %s %s - %s", dom->name, dom->id, phase,
+ local->family, local->service, local->node,
+ remote->family, remote->service, remote->node,
+ authScheme);
- REMOTE_DEBUG("Subject %d", subject->nidentity);
+ VIR_DEBUG("Subject %d", subject->nidentity);
for (i = 0 ; i < subject->nidentity ; i++) {
- REMOTE_DEBUG(" %s=%s", subject->identities[i].type, subject->identities[i].name);
+ VIR_DEBUG(" %s=%s", subject->identities[i].type, subject->identities[i].name);
}
virMutexLock(&client->lock);
@@ -4309,7 +4308,7 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
virMutexLock(&client->lock);
virMutexUnlock(&server->lock);
- REMOTE_DEBUG("Initialize SASL auth %d", client->fd);
+ VIR_DEBUG("Initialize SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn != NULL) {
VIR_ERROR0(_("client tried invalid SASL init request"));
@@ -4428,7 +4427,7 @@ remoteDispatchAuthSaslInit(struct qemud_server *server,
client->saslconn = NULL;
goto authfail;
}
- REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist);
+ VIR_DEBUG("Available mechanisms for client: '%s'", mechlist);
ret->mechlist = strdup(mechlist);
if (!ret->mechlist) {
VIR_ERROR0(_("cannot allocate mechlist"));
@@ -4473,7 +4472,7 @@ remoteSASLCheckSSF(struct qemud_client *client,
return -1;
}
ssf = *(const int *)val;
- REMOTE_DEBUG("negotiated an SSF of %d", ssf);
+ VIR_DEBUG("negotiated an SSF of %d", ssf);
if (ssf < 56) { /* 56 is good for Kerberos */
VIR_ERROR(_("negotiated SSF %d was not strong enough"), ssf);
remoteDispatchAuthError(rerr);
@@ -4521,7 +4520,7 @@ remoteSASLCheckAccess(struct qemud_server *server,
client->saslconn = NULL;
return -1;
}
- REMOTE_DEBUG("SASL client username %s", (const char *)val);
+ VIR_DEBUG("SASL client username %s", (const char *)val);
client->saslUsername = strdup((const char*)val);
if (client->saslUsername == NULL) {
@@ -4572,15 +4571,15 @@ remoteDispatchAuthSaslStart(struct qemud_server *server,
virMutexLock(&client->lock);
virMutexUnlock(&server->lock);
- REMOTE_DEBUG("Start SASL auth %d", client->fd);
+ VIR_DEBUG("Start SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) {
VIR_ERROR0(_("client tried invalid SASL start request"));
goto authfail;
}
- REMOTE_DEBUG("Using SASL mechanism %s. Data %d bytes, nil: %d",
- args->mech, args->data.data_len, args->nil);
+ VIR_DEBUG("Using SASL mechanism %s. Data %d bytes, nil: %d",
+ args->mech, args->data.data_len, args->nil);
err = sasl_server_start(client->saslconn,
args->mech,
/* NB, distinction of NULL vs "" is *critical* in SASL */
@@ -4616,7 +4615,7 @@ remoteDispatchAuthSaslStart(struct qemud_server *server,
ret->nil = serverout ? 0 : 1;
ret->data.data_len = serveroutlen;
- REMOTE_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
+ VIR_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
if (err == SASL_CONTINUE) {
ret->complete = 0;
} else {
@@ -4629,7 +4628,7 @@ remoteDispatchAuthSaslStart(struct qemud_server *server,
goto authfail;
}
- REMOTE_DEBUG("Authentication successful %d", client->fd);
+ VIR_DEBUG("Authentication successful %d", client->fd);
PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
client->fd, REMOTE_AUTH_SASL, client->saslUsername);
ret->complete = 1;
@@ -4672,15 +4671,15 @@ remoteDispatchAuthSaslStep(struct qemud_server *server,
virMutexLock(&client->lock);
virMutexUnlock(&server->lock);
- REMOTE_DEBUG("Step SASL auth %d", client->fd);
+ VIR_DEBUG("Step SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) {
VIR_ERROR0(_("client tried invalid SASL start request"));
goto authfail;
}
- REMOTE_DEBUG("Using SASL Data %d bytes, nil: %d",
- args->data.data_len, args->nil);
+ VIR_DEBUG("Using SASL Data %d bytes, nil: %d",
+ args->data.data_len, args->nil);
err = sasl_server_step(client->saslconn,
/* NB, distinction of NULL vs "" is *critical* in SASL */
args->nil ? NULL : args->data.data_val,
@@ -4717,7 +4716,7 @@ remoteDispatchAuthSaslStep(struct qemud_server *server,
ret->nil = serverout ? 0 : 1;
ret->data.data_len = serveroutlen;
- REMOTE_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
+ VIR_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
if (err == SASL_CONTINUE) {
ret->complete = 0;
} else {
@@ -4730,7 +4729,7 @@ remoteDispatchAuthSaslStep(struct qemud_server *server,
goto authfail;
}
- REMOTE_DEBUG("Authentication successful %d", client->fd);
+ VIR_DEBUG("Authentication successful %d", client->fd);
PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
client->fd, REMOTE_AUTH_SASL, client->saslUsername);
ret->complete = 1;
@@ -4840,7 +4839,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
NULL
};
- REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
+ VIR_DEBUG("Start PolicyKit auth %d", client->fd);
if (client->auth != REMOTE_AUTH_POLKIT) {
VIR_ERROR0(_("client tried invalid PolicyKit init request"));
goto authfail;
@@ -4932,7 +4931,7 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
"org.libvirt.unix.monitor" :
"org.libvirt.unix.manage";
- REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
+ VIR_DEBUG("Start PolicyKit auth %d", client->fd);
if (client->auth != REMOTE_AUTH_POLKIT) {
VIR_ERROR0(_("client tried invalid PolicyKit init request"));
goto authfail;
--
1.7.4.2
2
1
[libvirt] [PATCH] Add missing checks for whether the connection is open in dispatcher
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
Many functions did not check for whether a connection was
open. Replace the macro which obscures control flow, with
explicit checks, and ensure all dispatcher code has checks.
* daemon/remote.c: Add connection checks
---
daemon/remote.c | 986 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 959 insertions(+), 27 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 8a2a71f..2a56d91 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -432,11 +432,6 @@ remoteDispatchOpen(struct qemud_server *server,
return rc;
}
-#define CHECK_CONN(client) \
- if (!client->conn) { \
- remoteDispatchFormatError(rerr, "%s", _("connection not open")); \
- return -1; \
- }
static int
remoteDispatchClose(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -464,6 +459,12 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_error *rerr,
remote_supports_feature_args *args, remote_supports_feature_ret *ret)
{
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
ret->supported = virDrvSupportsFeature(conn, args->feature);
if (ret->supported == -1) {
@@ -484,6 +485,11 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
{
const char *type;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
type = virConnectGetType(conn);
if (type == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -513,6 +519,11 @@ remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
{
unsigned long hvVer;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (virConnectGetVersion(conn, &hvVer) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -533,6 +544,11 @@ remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
{
unsigned long libVer;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (virConnectGetLibVersion(conn, &libVer) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -553,6 +569,11 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
{
char *hostname;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
hostname = virConnectGetHostname(conn);
if (hostname == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -573,7 +594,11 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_get_uri_ret *ret)
{
char *uri;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
uri = virConnectGetURI(conn);
if (uri == NULL) {
@@ -597,6 +622,11 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
unsigned int flags;
char *sysinfo;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
flags = args->flags;
sysinfo = virConnectGetSysinfo(conn, flags);
if (sysinfo == NULL) {
@@ -619,6 +649,11 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
{
char *type;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
type = args->type ? *args->type : NULL;
ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
if (ret->max_vcpus == -1) {
@@ -640,6 +675,11 @@ remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNodeInfo info;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (virNodeGetInfo(conn, &info) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -668,6 +708,11 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
{
char *caps;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
caps = virConnectGetCapabilities(conn);
if (caps == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -689,6 +734,11 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
{
int err;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
remoteDispatchFormatError(rerr,
"%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
@@ -727,6 +777,11 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
{
unsigned long long freeMem;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
freeMem = virNodeGetFreeMemory(conn);
if (freeMem == 0) {
remoteDispatchConnError(rerr, conn);
@@ -750,6 +805,11 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
char *type;
int nparams;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -782,6 +842,11 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
virSchedParameterPtr params;
int i, r, nparams;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nparams = args->nparams;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
@@ -866,6 +931,11 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
int i, r, nparams;
virSchedParameterPtr params;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nparams = args->params.params_len;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
@@ -933,6 +1003,11 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
char *path;
struct _virDomainBlockStats stats;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -969,6 +1044,11 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
char *path;
struct _virDomainInterfaceStats stats;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1008,6 +1088,11 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
struct _virDomainMemoryStat *stats;
unsigned int nr_stats, i;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
remoteDispatchFormatError(rerr, "%s",
_("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
@@ -1068,6 +1153,11 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
size_t size;
unsigned int flags;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1118,6 +1208,11 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
size_t size;
unsigned int flags;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1164,6 +1259,11 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1190,6 +1290,11 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1216,6 +1321,11 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1242,6 +1352,11 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1296,6 +1411,11 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1319,6 +1439,11 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = virDomainDefineXML(conn, args->xml);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1342,6 +1467,11 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1368,6 +1498,11 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1395,6 +1530,11 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1422,6 +1562,11 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1448,6 +1593,11 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_from_native_args *args,
remote_domain_xml_from_native_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
/* remoteDispatchClientRequest will free this. */
ret->domainXml = virConnectDomainXMLFromNative(conn,
args->nativeFormat,
@@ -1469,6 +1619,11 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_xml_to_native_args *args,
remote_domain_xml_to_native_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
/* remoteDispatchClientRequest will free this. */
ret->nativeConfig = virConnectDomainXMLToNative(conn,
args->nativeFormat,
@@ -1493,6 +1648,11 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1520,6 +1680,11 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
virDomainPtr dom;
virDomainInfo info;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1554,6 +1719,11 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1581,6 +1751,11 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1609,6 +1784,11 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
virDomainPtr dom;
virSecurityLabelPtr seclabel;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1654,6 +1834,11 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecurityModel secmodel;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
memset(&secmodel, 0, sizeof secmodel);
if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
remoteDispatchConnError(rerr, conn);
@@ -1688,6 +1873,11 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1719,6 +1909,11 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
unsigned char *cpumaps = NULL;
int info_len, i;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1797,6 +1992,11 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1829,6 +2029,11 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
char **uri_out;
char *dname;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
dname = args->dname == NULL ? NULL : *args->dname;
@@ -1875,6 +2080,11 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
virDomainPtr dom;
char *dname;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -1908,7 +2118,11 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish_ret *ret)
{
virDomainPtr ddom;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ddom = virDomainMigrateFinish(conn, args->dname,
args->cookie.cookie_val,
@@ -1940,7 +2154,11 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
char *uri_in;
char **uri_out;
char *dname;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
dname = args->dname == NULL ? NULL : *args->dname;
@@ -1980,7 +2198,11 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_migrate_finish2_ret *ret)
{
virDomainPtr ddom;
- CHECK_CONN (client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ddom = virDomainMigrateFinish2(conn, args->dname,
args->cookie.cookie_val,
@@ -2011,7 +2233,11 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
int r;
char *dname;
struct qemud_client_stream *stream;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2049,6 +2275,10 @@ remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_domains_args *args,
remote_list_defined_domains_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -2085,6 +2315,11 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = virDomainLookupByID(conn, args->id);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2107,6 +2342,11 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = virDomainLookupByName(conn, args->name);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2129,6 +2369,11 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2149,6 +2394,10 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_domains_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfDefinedDomains(conn);
if (ret->num == -1) {
@@ -2171,6 +2420,11 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
virDomainPtr dom;
int rv;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2206,6 +2460,11 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2230,6 +2489,10 @@ remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_domain_restore_args *args,
void *ret ATTRIBUTE_UNUSED)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (virDomainRestore(conn, args->from) == -1) {
remoteDispatchConnError(rerr, conn);
@@ -2250,6 +2513,11 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2276,6 +2544,11 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2302,6 +2575,11 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2328,6 +2606,11 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2354,6 +2637,11 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2380,6 +2668,11 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2406,6 +2699,11 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2438,6 +2736,11 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
virMemoryParameterPtr params;
unsigned int flags;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nparams = args->params.params_len;
flags = args->flags;
@@ -2533,6 +2836,11 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
int i, r, nparams;
unsigned int flags;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nparams = args->nparams;
flags = args->flags;
@@ -2649,6 +2957,11 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
virBlkioParameterPtr params;
unsigned int flags;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nparams = args->params.params_len;
flags = args->flags;
@@ -2744,6 +3057,11 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
int i, r, nparams;
unsigned int flags;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nparams = args->nparams;
flags = args->flags;
@@ -2854,6 +3172,11 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2880,6 +3203,11 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2906,6 +3234,11 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2932,6 +3265,11 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2958,6 +3296,11 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -2982,6 +3325,10 @@ remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_defined_networks_args *args,
remote_list_defined_networks_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -3016,6 +3363,10 @@ remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_domains_args *args,
remote_list_domains_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -3051,6 +3402,11 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3077,6 +3433,11 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3104,6 +3465,11 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3128,6 +3494,10 @@ remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_networks_args *args,
remote_list_networks_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -3164,6 +3534,11 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3190,6 +3565,11 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = virNetworkCreateXML(conn, args->xml);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3212,6 +3592,11 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = virNetworkDefineXML(conn, args->xml);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3234,6 +3619,11 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3260,6 +3650,11 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3288,6 +3683,11 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3314,6 +3714,11 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3342,6 +3747,11 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = virNetworkLookupByName(conn, args->name);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3364,6 +3774,11 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3386,8 +3801,13 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
- net = get_nonnull_network(conn, args->net);
- if (net == NULL) {
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
+ net = get_nonnull_network(conn, args->net);
+ if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -3412,6 +3832,11 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNetworkPtr net;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3436,6 +3861,10 @@ remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_networks_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfDefinedNetworks(conn);
if (ret->num == -1) {
@@ -3455,6 +3884,10 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_domains_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfDomains(conn);
if (ret->num == -1) {
@@ -3474,6 +3907,10 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_networks_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfNetworks(conn);
if (ret->num == -1) {
@@ -3495,6 +3932,10 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_interfaces_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfInterfaces(conn);
if (ret->num == -1) {
@@ -3514,6 +3955,10 @@ remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_interfaces_args *args,
remote_list_interfaces_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -3548,6 +3993,10 @@ remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_interfaces_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfDefinedInterfaces(conn);
if (ret->num == -1) {
@@ -3567,6 +4016,10 @@ remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED
remote_list_defined_interfaces_args *args,
remote_list_defined_interfaces_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -3603,6 +4056,11 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = virInterfaceLookupByName(conn, args->name);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3625,6 +4083,11 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = virInterfaceLookupByMACString(conn, args->mac);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3647,6 +4110,11 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3675,6 +4143,11 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = virInterfaceDefineXML(conn, args->xml, args->flags);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3697,6 +4170,11 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3723,6 +4201,11 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3749,6 +4232,11 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -3775,6 +4263,11 @@ remoteDispatchAuthList(struct qemud_server *server,
void *args ATTRIBUTE_UNUSED,
remote_auth_list_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
ret->types.types_len = 1;
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
remoteDispatchOOMError(rerr);
@@ -4572,6 +5065,10 @@ remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUS
remote_list_defined_storage_pools_args *args,
remote_list_defined_storage_pools_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr, "%s",
@@ -4606,6 +5103,10 @@ remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_storage_pools_args *args,
remote_list_storage_pools_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -4640,6 +5141,11 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
remote_find_storage_pool_sources_args *args,
remote_find_storage_pool_sources_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
ret->xml =
virConnectFindStoragePoolSources(conn,
args->type,
@@ -4665,6 +5171,11 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4691,6 +5202,11 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4713,6 +5229,11 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4735,6 +5256,11 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4762,6 +5288,11 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4788,6 +5319,11 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4814,6 +5350,11 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4841,6 +5382,11 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
virStoragePoolPtr pool;
virStoragePoolInfo info;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4874,6 +5420,11 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4902,6 +5453,11 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4929,6 +5485,11 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = virStoragePoolLookupByName(conn, args->name);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4951,6 +5512,11 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -4974,6 +5540,11 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
virStoragePoolPtr pool;
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5004,6 +5575,11 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5030,6 +5606,11 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5054,6 +5635,10 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_storage_pools_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfStoragePools(conn);
if (ret->num == -1) {
@@ -5073,6 +5658,10 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
void *args ATTRIBUTE_UNUSED,
remote_num_of_defined_storage_pools_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfDefinedStoragePools(conn);
if (ret->num == -1) {
@@ -5094,6 +5683,11 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
@@ -5139,6 +5733,11 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5175,6 +5774,11 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
virStoragePoolPtr pool;
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5206,6 +5810,11 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
virStoragePoolPtr pool;
virStorageVolPtr clonevol, newvol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5246,6 +5855,11 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5273,6 +5887,11 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
int retval = -1;
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5305,6 +5924,11 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
virStorageVolPtr vol;
virStorageVolInfo info;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5337,6 +5961,11 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5366,6 +5995,11 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5396,6 +6030,11 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
virStoragePoolPtr pool;
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5426,6 +6065,11 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
{
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = virStorageVolLookupByKey(conn, args->key);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5449,6 +6093,11 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
{
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = virStorageVolLookupByPath(conn, args->path);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5474,7 +6123,10 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_num_of_devices_args *args,
remote_node_num_of_devices_ret *ret)
{
- CHECK_CONN(client);
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virNodeNumOfDevices(conn,
args->cap ? *args->cap : NULL,
@@ -5497,7 +6149,10 @@ remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_list_devices_args *args,
remote_node_list_devices_ret *ret)
{
- CHECK_CONN(client);
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -5536,7 +6191,10 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5560,7 +6218,11 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_dump_xml_ret *ret)
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5591,7 +6253,11 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNodeDevicePtr dev;
const char *parent;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5635,7 +6301,11 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_num_of_caps_ret *ret)
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5665,7 +6335,11 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_device_list_caps_ret *ret)
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5712,7 +6386,11 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5741,7 +6419,11 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5770,7 +6452,11 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
void *ret ATTRIBUTE_UNUSED)
{
virNodeDevicePtr dev;
- CHECK_CONN(client);
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
@@ -5800,6 +6486,11 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNodeDevicePtr dev;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
if (dev == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5824,6 +6515,11 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNodeDevicePtr dev;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5851,6 +6547,11 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
struct qemud_client_stream *stream = NULL;
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5898,6 +6599,11 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
struct qemud_client_stream *stream = NULL;
virStorageVolPtr vol;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -5946,9 +6652,13 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
{
- CHECK_CONN(client);
int callbackID;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
remoteDispatchFormatError(rerr, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
return -1;
@@ -5977,7 +6687,10 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
void *args ATTRIBUTE_UNUSED,
remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
{
- CHECK_CONN(client);
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] == -1) {
remoteDispatchFormatError(rerr, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
@@ -6067,6 +6780,11 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_secrets_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
ret->num = virConnectNumOfSecrets(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
@@ -6085,6 +6803,11 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_secrets_args *args,
remote_list_secrets_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
remoteDispatchFormatError(rerr, "%s",
_("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
@@ -6118,6 +6841,11 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecretPtr secret;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = virSecretDefineXML(conn, args->xml, args->flags);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6142,6 +6870,11 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
size_t value_size;
unsigned char *value;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6172,6 +6905,11 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecretPtr secret;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6198,6 +6936,11 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecretPtr secret;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6220,6 +6963,11 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecretPtr secret;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6247,6 +6995,11 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecretPtr secret;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6273,6 +7026,11 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virSecretPtr secret;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
if (secret == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6295,6 +7053,11 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
{
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6323,6 +7086,11 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
{
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6351,6 +7119,11 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
{
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6379,6 +7152,11 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
{
virInterfacePtr iface;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6407,6 +7185,11 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
{
virNetworkPtr network;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6435,6 +7218,11 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
{
virNetworkPtr network;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6463,6 +7251,11 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6491,6 +7284,11 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
{
virStoragePoolPtr pool;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6518,6 +7316,11 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_is_secure_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
ret->secure = virConnectIsSecure(conn);
if (ret->secure < 0) {
@@ -6540,6 +7343,11 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
{
int result;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
result = virConnectCompareCPU(conn, args->xml, args->flags);
if (result == VIR_CPU_COMPARE_ERROR) {
remoteDispatchConnError(rerr, conn);
@@ -6562,6 +7370,11 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
{
char *cpu;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
cpu = virConnectBaselineCPU(conn,
(const char **) args->xmlCPUs.xmlCPUs_val,
args->xmlCPUs.xmlCPUs_len,
@@ -6589,6 +7402,11 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
virDomainPtr dom;
virDomainJobInfo info;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6631,6 +7449,11 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6660,6 +7483,11 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6688,6 +7516,11 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
{
virDomainPtr dom;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6717,6 +7550,11 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
virDomainSnapshotPtr snapshot;
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6751,6 +7589,11 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
virDomainSnapshotPtr snapshot = NULL;
int rc = -1;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->snap.domain);
if (domain == NULL)
goto cleanup;
@@ -6788,6 +7631,11 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6817,6 +7665,11 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
{
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) {
remoteDispatchFormatError(rerr, "%s",
_("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
@@ -6864,6 +7717,11 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
virDomainSnapshotPtr snapshot;
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6897,6 +7755,11 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
virDomainPtr domain;
int result;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6929,6 +7792,11 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
virDomainSnapshotPtr snapshot;
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -6963,6 +7831,11 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
virDomainSnapshotPtr snapshot = NULL;
int rc = -1;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->snap.domain);
if (domain == NULL)
goto cleanup;
@@ -7000,6 +7873,11 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
virDomainSnapshotPtr snapshot = NULL;
int rc = -1;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->snap.domain);
if (domain == NULL)
goto cleanup;
@@ -7034,9 +7912,13 @@ remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUS
remote_domain_events_register_any_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- CHECK_CONN(client);
int callbackID;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
@@ -7072,9 +7954,13 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
remote_domain_events_deregister_any_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- CHECK_CONN(client);
int callbackID = -1;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
args->eventID < 0) {
remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
@@ -7109,6 +7995,11 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNWFilterPtr nwfilter;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nwfilter = virNWFilterLookupByName(conn, args->name);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7131,6 +8022,11 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNWFilterPtr nwfilter;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7154,6 +8050,11 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNWFilterPtr nwfilter;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nwfilter = virNWFilterDefineXML(conn, args->xml);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7177,6 +8078,11 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNWFilterPtr nwfilter;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7201,6 +8107,10 @@ remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
remote_list_nwfilters_args *args,
remote_list_nwfilters_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
if (args->maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) {
remoteDispatchFormatError(rerr,
@@ -7238,6 +8148,11 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNWFilterPtr nwfilter;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7265,6 +8180,10 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_num_of_nwfilters_ret *ret)
{
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
ret->num = virConnectNumOfNWFilters(conn);
if (ret->num == -1) {
@@ -7288,6 +8207,11 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
virDomainPtr dom;
virDomainBlockInfo info;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7320,6 +8244,11 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virDomainPtr domain;
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
+
domain = get_nonnull_domain(conn, args->domain);
if (domain == NULL) {
remoteDispatchConnError(rerr, conn);
@@ -7352,7 +8281,10 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client_stream *stream;
virDomainPtr dom;
- CHECK_CONN (client);
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not open"));
+ return -1;
+ }
dom = get_nonnull_domain(conn, args->domain);
if (dom == NULL) {
--
1.7.4.2
2
1
[libvirt] [PATCH] Standard on error variable name in libvirtd dispatcher
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
Some dispatcher methods have a parameter
remote_error *err,
Instead of the more normal
remote_error *rerr,
* daemon/remote.c: s/err/rerr/
---
daemon/remote.c | 108 +++++++++++++++++++++++++++---------------------------
1 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index d43cfce..8a2a71f 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -6063,13 +6063,13 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
void *args ATTRIBUTE_UNUSED,
remote_num_of_secrets_ret *ret)
{
ret->num = virConnectNumOfSecrets(conn);
if (ret->num == -1) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6081,18 +6081,18 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_list_secrets_args *args,
remote_list_secrets_ret *ret)
{
if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
- remoteDispatchFormatError(err, "%s",
+ remoteDispatchFormatError(rerr, "%s",
_("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
return -1;
}
if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
- remoteDispatchOOMError(err);
+ remoteDispatchOOMError(rerr);
return -1;
}
@@ -6100,7 +6100,7 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
args->maxuuids);
if (ret->uuids.uuids_len == -1) {
VIR_FREE(ret->uuids.uuids_val);
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6112,7 +6112,7 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_define_xml_args *args,
remote_secret_define_xml_ret *ret)
{
@@ -6120,7 +6120,7 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = virSecretDefineXML(conn, args->xml, args->flags);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6134,7 +6134,7 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_get_value_args *args,
remote_secret_get_value_ret *ret)
{
@@ -6144,13 +6144,13 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
value = virSecretGetValue(secret, &value_size, args->flags);
if (value == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virSecretFree(secret);
return -1;
}
@@ -6166,7 +6166,7 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_get_xml_desc_args *args,
remote_secret_get_xml_desc_ret *ret)
{
@@ -6174,12 +6174,12 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->xml = virSecretGetXMLDesc(secret, args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virSecretFree(secret);
return -1;
}
@@ -6192,7 +6192,7 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_lookup_by_uuid_args *args,
remote_secret_lookup_by_uuid_ret *ret)
{
@@ -6200,7 +6200,7 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6214,7 +6214,7 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_set_value_args *args,
void *ret ATTRIBUTE_UNUSED)
{
@@ -6222,12 +6222,12 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
args->value.value_len, args->flags) < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virSecretFree(secret);
return -1;
}
@@ -6241,7 +6241,7 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
@@ -6249,11 +6249,11 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
if (virSecretUndefine(secret) < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virSecretFree(secret);
return -1;
}
@@ -6267,7 +6267,7 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_secret_lookup_by_usage_args *args,
remote_secret_lookup_by_usage_ret *ret)
{
@@ -6275,7 +6275,7 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
if (secret == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6289,7 +6289,7 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_domain_is_active_args *args,
remote_domain_is_active_ret *ret)
{
@@ -6297,14 +6297,14 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->active = virDomainIsActive(domain);
if (ret->active < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virDomainFree(domain);
return -1;
}
@@ -6317,7 +6317,7 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_domain_is_persistent_args *args,
remote_domain_is_persistent_ret *ret)
{
@@ -6325,14 +6325,14 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->persistent = virDomainIsPersistent(domain);
if (ret->persistent < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virDomainFree(domain);
return -1;
}
@@ -6345,7 +6345,7 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_domain_is_updated_args *args,
remote_domain_is_updated_ret *ret)
{
@@ -6353,14 +6353,14 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
domain = get_nonnull_domain(conn, args->dom);
if (domain == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->updated = virDomainIsUpdated(domain);
if (ret->updated < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virDomainFree(domain);
return -1;
}
@@ -6373,7 +6373,7 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_interface_is_active_args *args,
remote_interface_is_active_ret *ret)
{
@@ -6381,14 +6381,14 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->active = virInterfaceIsActive(iface);
if (ret->active < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virInterfaceFree(iface);
return -1;
}
@@ -6401,7 +6401,7 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_network_is_active_args *args,
remote_network_is_active_ret *ret)
{
@@ -6409,14 +6409,14 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->active = virNetworkIsActive(network);
if (ret->active < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virNetworkFree(network);
return -1;
}
@@ -6429,7 +6429,7 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_network_is_persistent_args *args,
remote_network_is_persistent_ret *ret)
{
@@ -6437,14 +6437,14 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
network = get_nonnull_network(conn, args->net);
if (network == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->persistent = virNetworkIsPersistent(network);
if (ret->persistent < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virNetworkFree(network);
return -1;
}
@@ -6457,7 +6457,7 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_storage_pool_is_active_args *args,
remote_storage_pool_is_active_ret *ret)
{
@@ -6465,14 +6465,14 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->active = virStoragePoolIsActive(pool);
if (ret->active < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
}
@@ -6485,7 +6485,7 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_storage_pool_is_persistent_args *args,
remote_storage_pool_is_persistent_ret *ret)
{
@@ -6493,14 +6493,14 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
ret->persistent = virStoragePoolIsPersistent(pool);
if (ret->persistent < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
}
@@ -6514,14 +6514,14 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
void *args ATTRIBUTE_UNUSED,
remote_is_secure_ret *ret)
{
ret->secure = virConnectIsSecure(conn);
if (ret->secure < 0) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6534,7 +6534,7 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_cpu_compare_args *args,
remote_cpu_compare_ret *ret)
{
@@ -6542,7 +6542,7 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
result = virConnectCompareCPU(conn, args->xml, args->flags);
if (result == VIR_CPU_COMPARE_ERROR) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -6556,7 +6556,7 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
+ remote_error *rerr,
remote_cpu_baseline_args *args,
remote_cpu_baseline_ret *ret)
{
@@ -6567,7 +6567,7 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
args->xmlCPUs.xmlCPUs_len,
args->flags);
if (cpu == NULL) {
- remoteDispatchConnError(err, conn);
+ remoteDispatchConnError(rerr, conn);
return -1;
}
--
1.7.4.2
2
2
[libvirt] [PATCH] Remove all whitespace before function brackets in daemon dispatcher
by Daniel P. Berrange 13 Apr '11
by Daniel P. Berrange 13 Apr '11
13 Apr '11
Alot of code in libvirtd's dispatcher used the style
dom = get_nonnull_domain (conn, args->dom);
Instead of the normal libvirt style
dom = get_nonnull_domain(conn, args->dom);
* daemon/remote.c: Remove all whitelist before function brackets
---
daemon/remote.c | 3488 +++++++++++++++++++++++++++---------------------------
1 files changed, 1744 insertions(+), 1744 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index e4aa3db..d43cfce 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -117,10 +117,10 @@ const dispatch_data const *qemuGetDispatchData(int proc)
/* Prototypes */
static void
-remoteDispatchDomainEventSend (struct qemud_client *client,
- int procnr,
- xdrproc_t proc,
- void *data);
+remoteDispatchDomainEventSend(struct qemud_client *client,
+ int procnr,
+ xdrproc_t proc,
+ void *data);
static int remoteRelayDomainEventLifecycle(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
@@ -140,13 +140,13 @@ static int remoteRelayDomainEventLifecycle(virConnectPtr conn ATTRIBUTE_UNUSED,
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
data.event = event;
data.detail = detail;
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE,
- (xdrproc_t)xdr_remote_domain_event_lifecycle_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE,
+ (xdrproc_t)xdr_remote_domain_event_lifecycle_msg, &data);
virMutexUnlock(&client->lock);
@@ -169,11 +169,11 @@ static int remoteRelayDomainEventReboot(virConnectPtr conn ATTRIBUTE_UNUSED,
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_REBOOT,
- (xdrproc_t)xdr_remote_domain_event_reboot_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_REBOOT,
+ (xdrproc_t)xdr_remote_domain_event_reboot_msg, &data);
virMutexUnlock(&client->lock);
@@ -198,12 +198,12 @@ static int remoteRelayDomainEventRTCChange(virConnectPtr conn ATTRIBUTE_UNUSED,
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
data.offset = offset;
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
- (xdrproc_t)xdr_remote_domain_event_rtc_change_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
+ (xdrproc_t)xdr_remote_domain_event_rtc_change_msg, &data);
virMutexUnlock(&client->lock);
@@ -228,12 +228,12 @@ static int remoteRelayDomainEventWatchdog(virConnectPtr conn ATTRIBUTE_UNUSED,
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
data.action = action;
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_WATCHDOG,
- (xdrproc_t)xdr_remote_domain_event_watchdog_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_WATCHDOG,
+ (xdrproc_t)xdr_remote_domain_event_watchdog_msg, &data);
virMutexUnlock(&client->lock);
@@ -260,14 +260,14 @@ static int remoteRelayDomainEventIOError(virConnectPtr conn ATTRIBUTE_UNUSED,
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
data.srcPath = (char*)srcPath;
data.devAlias = (char*)devAlias;
data.action = action;
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_IO_ERROR,
- (xdrproc_t)xdr_remote_domain_event_io_error_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_IO_ERROR,
+ (xdrproc_t)xdr_remote_domain_event_io_error_msg, &data);
virMutexUnlock(&client->lock);
@@ -296,15 +296,15 @@ static int remoteRelayDomainEventIOErrorReason(virConnectPtr conn ATTRIBUTE_UNUS
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
data.srcPath = (char*)srcPath;
data.devAlias = (char*)devAlias;
data.action = action;
data.reason = (char*)reason;
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON,
- (xdrproc_t)xdr_remote_domain_event_io_error_reason_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON,
+ (xdrproc_t)xdr_remote_domain_event_io_error_reason_msg, &data);
virMutexUnlock(&client->lock);
@@ -342,7 +342,7 @@ static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
/* build return data */
memset(&data, 0, sizeof data);
- make_nonnull_domain (&data.dom, dom);
+ make_nonnull_domain(&data.dom, dom);
data.phase = phase;
data.authScheme = (char*)authScheme;
@@ -364,9 +364,9 @@ static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
data.subject.subject_val[i].name = (char*)subject->identities[i].name;
}
- remoteDispatchDomainEventSend (client,
- REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
- (xdrproc_t)xdr_remote_domain_event_graphics_msg, &data);
+ remoteDispatchDomainEventSend(client,
+ REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
+ (xdrproc_t)xdr_remote_domain_event_graphics_msg, &data);
VIR_FREE(data.subject.subject_val);
@@ -391,19 +391,19 @@ verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
/*----- Functions. -----*/
static int
-remoteDispatchOpen (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
+remoteDispatchOpen(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ 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"));
+ remoteDispatchFormatError(rerr, "%s", _("connection already open"));
return -1;
}
@@ -421,8 +421,8 @@ remoteDispatchOpen (struct qemud_server *server,
client->conn =
flags & VIR_CONNECT_RO
- ? virConnectOpenReadOnly (name)
- : virConnectOpen (name);
+ ? virConnectOpenReadOnly(name)
+ : virConnectOpen(name);
if (client->conn == NULL)
remoteDispatchConnError(rerr, NULL);
@@ -434,17 +434,17 @@ remoteDispatchOpen (struct qemud_server *server,
#define CHECK_CONN(client) \
if (!client->conn) { \
- remoteDispatchFormatError (rerr, "%s", _("connection not open")); \
+ remoteDispatchFormatError(rerr, "%s", _("connection not open")); \
return -1; \
}
static int
-remoteDispatchClose (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr ATTRIBUTE_UNUSED,
- void *args ATTRIBUTE_UNUSED, void *ret ATTRIBUTE_UNUSED)
+remoteDispatchClose(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr ATTRIBUTE_UNUSED,
+ void *args ATTRIBUTE_UNUSED, void *ret ATTRIBUTE_UNUSED)
{
virMutexLock(&server->lock);
virMutexLock(&client->lock);
@@ -457,14 +457,14 @@ remoteDispatchClose (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchSupportsFeature (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_supports_feature_args *args, remote_supports_feature_ret *ret)
+remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_supports_feature_args *args, remote_supports_feature_ret *ret)
{
- ret->supported = virDrvSupportsFeature (conn, args->feature);
+ ret->supported = virDrvSupportsFeature(conn, args->feature);
if (ret->supported == -1) {
remoteDispatchConnError(rerr, conn);
@@ -475,16 +475,16 @@ remoteDispatchSupportsFeature (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetType (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
+remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
{
const char *type;
- type = virConnectGetType (conn);
+ type = virConnectGetType(conn);
if (type == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -493,7 +493,7 @@ remoteDispatchGetType (struct qemud_server *server ATTRIBUTE_UNUSED,
/* We have to strdup because remoteDispatchClientRequest will
* free this string after it's been serialised.
*/
- ret->type = strdup (type);
+ ret->type = strdup(type);
if (!ret->type) {
remoteDispatchOOMError(rerr);
return -1;
@@ -503,17 +503,17 @@ remoteDispatchGetType (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_get_version_ret *ret)
+remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_get_version_ret *ret)
{
unsigned long hvVer;
- if (virConnectGetVersion (conn, &hvVer) == -1) {
+ if (virConnectGetVersion(conn, &hvVer) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -523,17 +523,17 @@ remoteDispatchGetVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetLibVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_get_lib_version_ret *ret)
+remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_get_lib_version_ret *ret)
{
unsigned long libVer;
- if (virConnectGetLibVersion (conn, &libVer) == -1) {
+ if (virConnectGetLibVersion(conn, &libVer) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -543,17 +543,17 @@ remoteDispatchGetLibVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetHostname (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_get_hostname_ret *ret)
+remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_get_hostname_ret *ret)
{
char *hostname;
- hostname = virConnectGetHostname (conn);
+ hostname = virConnectGetHostname(conn);
if (hostname == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -564,18 +564,18 @@ remoteDispatchGetHostname (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetUri (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_get_uri_ret *ret)
+remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_get_uri_ret *ret)
{
char *uri;
CHECK_CONN(client);
- uri = virConnectGetURI (conn);
+ uri = virConnectGetURI(conn);
if (uri == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -586,19 +586,19 @@ remoteDispatchGetUri (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetSysinfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_get_sysinfo_args *args,
- remote_get_sysinfo_ret *ret)
+remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_get_sysinfo_args *args,
+ remote_get_sysinfo_ret *ret)
{
unsigned int flags;
char *sysinfo;
flags = args->flags;
- sysinfo = virConnectGetSysinfo (conn, flags);
+ sysinfo = virConnectGetSysinfo(conn, flags);
if (sysinfo == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -609,18 +609,18 @@ remoteDispatchGetSysinfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_get_max_vcpus_args *args,
- remote_get_max_vcpus_ret *ret)
+remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_get_max_vcpus_args *args,
+ remote_get_max_vcpus_ret *ret)
{
char *type;
type = args->type ? *args->type : NULL;
- ret->max_vcpus = virConnectGetMaxVcpus (conn, type);
+ ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
if (ret->max_vcpus == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -630,22 +630,22 @@ remoteDispatchGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNodeGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_node_get_info_ret *ret)
+remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_node_get_info_ret *ret)
{
virNodeInfo info;
- if (virNodeGetInfo (conn, &info) == -1) {
+ if (virNodeGetInfo(conn, &info) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- memcpy (ret->model, info.model, sizeof ret->model);
+ memcpy(ret->model, info.model, sizeof ret->model);
ret->memory = info.memory;
ret->cpus = info.cpus;
ret->mhz = info.mhz;
@@ -658,17 +658,17 @@ remoteDispatchNodeGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchGetCapabilities (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_get_capabilities_ret *ret)
+remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_get_capabilities_ret *ret)
{
char *caps;
- caps = virConnectGetCapabilities (conn);
+ caps = virConnectGetCapabilities(conn);
if (caps == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -679,18 +679,18 @@ remoteDispatchGetCapabilities (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_get_cells_free_memory_args *args,
- remote_node_get_cells_free_memory_ret *ret)
+remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_get_cells_free_memory_args *args,
+ remote_node_get_cells_free_memory_ret *ret)
{
int err;
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
return -1;
}
@@ -717,13 +717,13 @@ remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUS
static int
-remoteDispatchNodeGetFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_node_get_free_memory_ret *ret)
+remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_node_get_free_memory_ret *ret)
{
unsigned long long freeMem;
@@ -738,25 +738,25 @@ remoteDispatchNodeGetFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchDomainGetSchedulerType (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_scheduler_type_args *args,
- remote_domain_get_scheduler_type_ret *ret)
+remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_scheduler_type_args *args,
+ remote_domain_get_scheduler_type_ret *ret)
{
virDomainPtr dom;
char *type;
int nparams;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- type = virDomainGetSchedulerType (dom, &nparams);
+ type = virDomainGetSchedulerType(dom, &nparams);
if (type == NULL) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -770,13 +770,13 @@ remoteDispatchDomainGetSchedulerType (struct qemud_server *server ATTRIBUTE_UNUS
}
static int
-remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_scheduler_parameters_args *args,
- remote_domain_get_scheduler_parameters_ret *ret)
+remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_scheduler_parameters_args *args,
+ remote_domain_get_scheduler_parameters_ret *ret)
{
virDomainPtr dom;
virSchedParameterPtr params;
@@ -785,7 +785,7 @@ remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUT
nparams = args->nparams;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError (rerr, "%s", _("nparams too large"));
+ remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
return -1;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
@@ -793,14 +793,14 @@ remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUT
return -1;
}
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
VIR_FREE(params);
remoteDispatchConnError(rerr, conn);
return -1;
}
- r = virDomainGetSchedulerParameters (dom, params, &nparams);
+ r = virDomainGetSchedulerParameters(dom, params, &nparams);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -815,7 +815,7 @@ remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUT
for (i = 0; i < nparams; ++i) {
/* remoteDispatchClientRequest will free this: */
- ret->params.params_val[i].field = strdup (params[i].field);
+ ret->params.params_val[i].field = strdup(params[i].field);
if (ret->params.params_val[i].field == NULL)
goto oom;
@@ -834,7 +834,7 @@ remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUT
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"));
+ remoteDispatchFormatError(rerr, "%s", _("unknown type"));
goto cleanup;
}
}
@@ -854,13 +854,13 @@ cleanup:
}
static int
-remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_scheduler_parameters_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_scheduler_parameters_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
int i, r, nparams;
@@ -869,7 +869,7 @@ remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUT
nparams = args->params.params_len;
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
- remoteDispatchFormatError (rerr, "%s", _("nparams too large"));
+ remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
return -1;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
@@ -901,14 +901,14 @@ remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUT
}
}
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
VIR_FREE(params);
remoteDispatchConnError(rerr, conn);
return -1;
}
- r = virDomainSetSchedulerParameters (dom, params, nparams);
+ r = virDomainSetSchedulerParameters(dom, params, nparams);
VIR_FREE(params);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
@@ -921,31 +921,31 @@ remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUT
}
static int
-remoteDispatchDomainBlockStats (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_block_stats_args *args,
- remote_domain_block_stats_ret *ret)
+remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_block_stats_args *args,
+ remote_domain_block_stats_ret *ret)
{
virDomainPtr dom;
char *path;
struct _virDomainBlockStats stats;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
path = args->path;
- if (virDomainBlockStats (dom, path, &stats, sizeof stats) == -1) {
+ if (virDomainBlockStats(dom, path, &stats, sizeof stats) == -1) {
remoteDispatchConnError(rerr, conn);
- virDomainFree (dom);
+ virDomainFree(dom);
return -1;
}
- virDomainFree (dom);
+ virDomainFree(dom);
ret->rd_req = stats.rd_req;
ret->rd_bytes = stats.rd_bytes;
@@ -957,31 +957,31 @@ remoteDispatchDomainBlockStats (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainInterfaceStats (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_interface_stats_args *args,
- remote_domain_interface_stats_ret *ret)
+remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_interface_stats_args *args,
+ remote_domain_interface_stats_ret *ret)
{
virDomainPtr dom;
char *path;
struct _virDomainInterfaceStats stats;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
path = args->path;
- if (virDomainInterfaceStats (dom, path, &stats, sizeof stats) == -1) {
+ if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) == -1) {
remoteDispatchConnError(rerr, conn);
- virDomainFree (dom);
+ virDomainFree(dom);
return -1;
}
- virDomainFree (dom);
+ virDomainFree(dom);
ret->rx_bytes = stats.rx_bytes;
ret->rx_packets = stats.rx_packets;
@@ -996,25 +996,25 @@ remoteDispatchDomainInterfaceStats (struct qemud_server *server ATTRIBUTE_UNUSED
}
static int
-remoteDispatchDomainMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_memory_stats_args *args,
- remote_domain_memory_stats_ret *ret)
+remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_memory_stats_args *args,
+ remote_domain_memory_stats_ret *ret)
{
virDomainPtr dom;
struct _virDomainMemoryStat *stats;
unsigned int nr_stats, i;
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
- remoteDispatchFormatError (rerr, "%s",
+ remoteDispatchFormatError(rerr, "%s",
_("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
return -1;
}
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1022,19 +1022,19 @@ remoteDispatchDomainMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
/* Allocate stats array for making dispatch call */
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
- virDomainFree (dom);
+ virDomainFree(dom);
remoteDispatchOOMError(rerr);
return -1;
}
- nr_stats = virDomainMemoryStats (dom, stats, args->maxStats, 0);
+ nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
if (nr_stats == -1) {
VIR_FREE(stats);
remoteDispatchConnError(rerr, conn);
- virDomainFree (dom);
+ virDomainFree(dom);
return -1;
}
- virDomainFree (dom);
+ virDomainFree(dom);
/* Allocate return buffer */
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
@@ -1054,13 +1054,13 @@ remoteDispatchDomainMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_block_peek_args *args,
- remote_domain_block_peek_ret *ret)
+remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_block_peek_args *args,
+ remote_domain_block_peek_ret *ret)
{
virDomainPtr dom;
char *path;
@@ -1068,7 +1068,7 @@ remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
size_t size;
unsigned int flags;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1079,46 +1079,46 @@ remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags;
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
- virDomainFree (dom);
- remoteDispatchFormatError (rerr,
+ virDomainFree(dom);
+ remoteDispatchFormatError(rerr,
"%s", _("size > maximum buffer size"));
return -1;
}
ret->buffer.buffer_len = size;
- if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
- virDomainFree (dom);
+ if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
+ virDomainFree(dom);
remoteDispatchOOMError(rerr);
return -1;
}
- if (virDomainBlockPeek (dom, path, offset, size,
- ret->buffer.buffer_val, flags) == -1) {
- /* free (ret->buffer.buffer_val); - caller frees */
+ if (virDomainBlockPeek(dom, path, offset, size,
+ ret->buffer.buffer_val, flags) == -1) {
+ /* free(ret->buffer.buffer_val); - caller frees */
remoteDispatchConnError(rerr, conn);
- virDomainFree (dom);
+ virDomainFree(dom);
return -1;
}
- virDomainFree (dom);
+ virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_memory_peek_args *args,
- remote_domain_memory_peek_ret *ret)
+remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_memory_peek_args *args,
+ remote_domain_memory_peek_ret *ret)
{
virDomainPtr dom;
unsigned long long offset;
size_t size;
unsigned int flags;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1128,49 +1128,49 @@ remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags;
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
- virDomainFree (dom);
- remoteDispatchFormatError (rerr,
+ virDomainFree(dom);
+ remoteDispatchFormatError(rerr,
"%s", _("size > maximum buffer size"));
return -1;
}
ret->buffer.buffer_len = size;
- if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
- virDomainFree (dom);
+ if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
+ virDomainFree(dom);
remoteDispatchOOMError(rerr);
return -1;
}
- if (virDomainMemoryPeek (dom, offset, size,
- ret->buffer.buffer_val, flags) == -1) {
- /* free (ret->buffer.buffer_val); - caller frees */
+ if (virDomainMemoryPeek(dom, offset, size,
+ ret->buffer.buffer_val, flags) == -1) {
+ /* free(ret->buffer.buffer_val); - caller frees */
remoteDispatchConnError(rerr, conn);
- virDomainFree (dom);
+ virDomainFree(dom);
return -1;
}
- virDomainFree (dom);
+ virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainAttachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_attach_device_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_attach_device_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainAttachDevice (dom, args->xml) == -1) {
+ if (virDomainAttachDevice(dom, args->xml) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1180,23 +1180,23 @@ remoteDispatchDomainAttachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainAttachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_attach_device_flags_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_attach_device_flags_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainAttachDeviceFlags (dom, args->xml, args->flags) == -1) {
+ if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1206,23 +1206,23 @@ remoteDispatchDomainAttachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchDomainUpdateDeviceFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_update_device_flags_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_update_device_flags_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainUpdateDeviceFlags (dom, args->xml, args->flags) == -1) {
+ if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1232,23 +1232,23 @@ remoteDispatchDomainUpdateDeviceFlags (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_create_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_create_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainCreate (dom) == -1) {
+ if (virDomainCreate(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1258,97 +1258,97 @@ remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainCreateWithFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_create_with_flags_args *args,
- remote_domain_create_with_flags_ret *ret)
+remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_create_with_flags_args *args,
+ remote_domain_create_with_flags_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainCreateWithFlags (dom, args->flags) == -1) {
+ if (virDomainCreateWithFlags(dom, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
}
- make_nonnull_domain (&ret->dom, dom);
+ make_nonnull_domain(&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_create_xml_args *args,
- remote_domain_create_xml_ret *ret)
+remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_create_xml_args *args,
+ remote_domain_create_xml_ret *ret)
{
virDomainPtr dom;
- dom = virDomainCreateXML (conn, args->xml_desc, args->flags);
+ dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->dom, dom);
+ make_nonnull_domain(&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_define_xml_args *args,
- remote_domain_define_xml_ret *ret)
+remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_define_xml_args *args,
+ remote_domain_define_xml_ret *ret)
{
virDomainPtr dom;
- dom = virDomainDefineXML (conn, args->xml);
+ dom = virDomainDefineXML(conn, args->xml);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->dom, dom);
+ make_nonnull_domain(&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_destroy_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_destroy_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainDestroy (dom) == -1) {
+ if (virDomainDestroy(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1358,23 +1358,23 @@ remoteDispatchDomainDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainDetachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_detach_device_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_detach_device_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainDetachDevice (dom, args->xml) == -1) {
+ if (virDomainDetachDevice(dom, args->xml) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1385,23 +1385,23 @@ remoteDispatchDomainDetachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainDetachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_detach_device_flags_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_detach_device_flags_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainDetachDeviceFlags (dom, args->xml, args->flags) == -1) {
+ if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1412,24 +1412,24 @@ remoteDispatchDomainDetachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_dump_xml_args *args,
- remote_domain_dump_xml_ret *ret)
+remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_dump_xml_args *args,
+ remote_domain_dump_xml_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virDomainGetXMLDesc (dom, args->flags);
+ ret->xml = virDomainGetXMLDesc(dom, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -1440,19 +1440,19 @@ remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainXmlFromNative (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_xml_from_native_args *args,
- remote_domain_xml_from_native_ret *ret)
+remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_xml_from_native_args *args,
+ remote_domain_xml_from_native_ret *ret)
{
/* remoteDispatchClientRequest will free this. */
- ret->domainXml = virConnectDomainXMLFromNative (conn,
- args->nativeFormat,
- args->nativeConfig,
- args->flags);
+ ret->domainXml = virConnectDomainXMLFromNative(conn,
+ args->nativeFormat,
+ args->nativeConfig,
+ args->flags);
if (!ret->domainXml) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1461,19 +1461,19 @@ remoteDispatchDomainXmlFromNative (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainXmlToNative (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_xml_to_native_args *args,
- remote_domain_xml_to_native_ret *ret)
+remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_xml_to_native_args *args,
+ remote_domain_xml_to_native_ret *ret)
{
/* remoteDispatchClientRequest will free this. */
- ret->nativeConfig = virConnectDomainXMLToNative (conn,
- args->nativeFormat,
- args->domainXml,
- args->flags);
+ ret->nativeConfig = virConnectDomainXMLToNative(conn,
+ args->nativeFormat,
+ args->domainXml,
+ args->flags);
if (!ret->nativeConfig) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1483,23 +1483,23 @@ remoteDispatchDomainXmlToNative (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchDomainGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_autostart_args *args,
- remote_domain_get_autostart_ret *ret)
+remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_autostart_args *args,
+ remote_domain_get_autostart_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainGetAutostart (dom, &ret->autostart) == -1) {
+ if (virDomainGetAutostart(dom, &ret->autostart) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1509,24 +1509,24 @@ remoteDispatchDomainGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_info_args *args,
- remote_domain_get_info_ret *ret)
+remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_info_args *args,
+ remote_domain_get_info_ret *ret)
{
virDomainPtr dom;
virDomainInfo info;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainGetInfo (dom, &info) == -1) {
+ if (virDomainGetInfo(dom, &info) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -1544,23 +1544,23 @@ remoteDispatchDomainGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainGetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_max_memory_args *args,
- remote_domain_get_max_memory_ret *ret)
+remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_max_memory_args *args,
+ remote_domain_get_max_memory_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- ret->memory = virDomainGetMaxMemory (dom);
+ ret->memory = virDomainGetMaxMemory(dom);
if (ret->memory == 0) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -1571,23 +1571,23 @@ remoteDispatchDomainGetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_max_vcpus_args *args,
- remote_domain_get_max_vcpus_ret *ret)
+remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_max_vcpus_args *args,
+ remote_domain_get_max_vcpus_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- ret->num = virDomainGetMaxVcpus (dom);
+ ret->num = virDomainGetMaxVcpus(dom);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -1678,24 +1678,24 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainGetOsType (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_os_type_args *args,
- remote_domain_get_os_type_ret *ret)
+remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_os_type_args *args,
+ remote_domain_get_os_type_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this */
- ret->type = virDomainGetOSType (dom);
+ ret->type = virDomainGetOSType(dom);
if (ret->type == NULL) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -1706,20 +1706,20 @@ remoteDispatchDomainGetOsType (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_vcpus_args *args,
- remote_domain_get_vcpus_ret *ret)
+remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_vcpus_args *args,
+ remote_domain_get_vcpus_ret *ret)
{
virDomainPtr dom = NULL;
virVcpuInfoPtr info = NULL;
unsigned char *cpumaps = NULL;
int info_len, i;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1727,13 +1727,13 @@ remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
virDomainFree(dom);
- remoteDispatchFormatError (rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
+ remoteDispatchFormatError(rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
return -1;
}
if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
virDomainFree(dom);
- remoteDispatchFormatError (rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+ remoteDispatchFormatError(rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
return -1;
}
@@ -1744,9 +1744,9 @@ remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
goto oom;
- info_len = virDomainGetVcpus (dom,
- info, args->maxinfo,
- cpumaps, args->maplen);
+ info_len = virDomainGetVcpus(dom,
+ info, args->maxinfo,
+ cpumaps, args->maplen);
if (info_len == -1) {
remoteDispatchConnError(rerr, conn);
VIR_FREE(info);
@@ -1787,23 +1787,23 @@ oom:
}
static int
-remoteDispatchDomainGetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_vcpus_flags_args *args,
- remote_domain_get_vcpus_flags_ret *ret)
+remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_vcpus_flags_args *args,
+ remote_domain_get_vcpus_flags_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- ret->num = virDomainGetVcpusFlags (dom, args->flags);
+ ret->num = virDomainGetVcpusFlags(dom, args->flags);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -1814,13 +1814,13 @@ remoteDispatchDomainGetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_migrate_prepare_args *args,
- remote_domain_migrate_prepare_ret *ret)
+remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_migrate_prepare_args *args,
+ remote_domain_migrate_prepare_ret *ret)
{
int r;
char *cookie = NULL;
@@ -1838,9 +1838,9 @@ remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED
return -1;
}
- r = virDomainMigratePrepare (conn, &cookie, &cookielen,
- uri_in, uri_out,
- args->flags, dname, args->resource);
+ r = virDomainMigratePrepare(conn, &cookie, &cookielen,
+ uri_in, uri_out,
+ args->flags, dname, args->resource);
if (r == -1) {
VIR_FREE(uri_out);
remoteDispatchConnError(rerr, conn);
@@ -1863,19 +1863,19 @@ remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED
}
static int
-remoteDispatchDomainMigratePerform (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_migrate_perform_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_migrate_perform_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
int r;
virDomainPtr dom;
char *dname;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1883,56 +1883,56 @@ remoteDispatchDomainMigratePerform (struct qemud_server *server ATTRIBUTE_UNUSED
dname = args->dname == NULL ? NULL : *args->dname;
- r = virDomainMigratePerform (dom,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags, dname, args->resource);
+ r = virDomainMigratePerform(dom,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags, dname, args->resource);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
- virDomainFree (dom);
+ virDomainFree(dom);
return -1;
}
- virDomainFree (dom);
+ virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainMigrateFinish (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_migrate_finish_args *args,
- remote_domain_migrate_finish_ret *ret)
+remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_migrate_finish_args *args,
+ remote_domain_migrate_finish_ret *ret)
{
virDomainPtr ddom;
- CHECK_CONN (client);
+ CHECK_CONN(client);
- ddom = virDomainMigrateFinish (conn, args->dname,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags);
+ ddom = virDomainMigrateFinish(conn, args->dname,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags);
if (ddom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->ddom, ddom);
- virDomainFree (ddom);
+ make_nonnull_domain(&ret->ddom, ddom);
+ virDomainFree(ddom);
return 0;
}
static int
-remoteDispatchDomainMigratePrepare2 (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_migrate_prepare2_args *args,
- remote_domain_migrate_prepare2_ret *ret)
+remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_migrate_prepare2_args *args,
+ remote_domain_migrate_prepare2_ret *ret)
{
int r;
char *cookie = NULL;
@@ -1940,7 +1940,7 @@ remoteDispatchDomainMigratePrepare2 (struct qemud_server *server ATTRIBUTE_UNUSE
char *uri_in;
char **uri_out;
char *dname;
- CHECK_CONN (client);
+ CHECK_CONN(client);
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
dname = args->dname == NULL ? NULL : *args->dname;
@@ -1951,10 +1951,10 @@ remoteDispatchDomainMigratePrepare2 (struct qemud_server *server ATTRIBUTE_UNUSE
return -1;
}
- r = virDomainMigratePrepare2 (conn, &cookie, &cookielen,
- uri_in, uri_out,
- args->flags, dname, args->resource,
- args->dom_xml);
+ r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
+ uri_in, uri_out,
+ args->flags, dname, args->resource,
+ args->dom_xml);
if (r == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -1971,30 +1971,30 @@ remoteDispatchDomainMigratePrepare2 (struct qemud_server *server ATTRIBUTE_UNUSE
}
static int
-remoteDispatchDomainMigrateFinish2 (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_migrate_finish2_args *args,
- remote_domain_migrate_finish2_ret *ret)
+remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_migrate_finish2_args *args,
+ remote_domain_migrate_finish2_ret *ret)
{
virDomainPtr ddom;
CHECK_CONN (client);
- ddom = virDomainMigrateFinish2 (conn, args->dname,
- args->cookie.cookie_val,
- args->cookie.cookie_len,
- args->uri,
- args->flags,
- args->retcode);
+ ddom = virDomainMigrateFinish2(conn, args->dname,
+ args->cookie.cookie_val,
+ args->cookie.cookie_len,
+ args->uri,
+ args->flags,
+ args->retcode);
if (ddom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->ddom, ddom);
- virDomainFree (ddom);
+ make_nonnull_domain(&ret->ddom, ddom);
+ virDomainFree(ddom);
return 0;
}
@@ -2011,7 +2011,7 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
int r;
char *dname;
struct qemud_client_stream *stream;
- CHECK_CONN (client);
+ CHECK_CONN(client);
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2041,17 +2041,17 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
}
static int
-remoteDispatchListDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_defined_domains_args *args,
- remote_list_defined_domains_ret *ret)
+remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_defined_domains_args *args,
+ remote_list_defined_domains_ret *ret)
{
if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
return -1;
}
@@ -2063,8 +2063,8 @@ remoteDispatchListDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virConnectListDefinedDomains (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListDefinedDomains(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_val);
remoteDispatchConnError(rerr, conn);
@@ -2075,82 +2075,82 @@ remoteDispatchListDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainLookupById (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_lookup_by_id_args *args,
- remote_domain_lookup_by_id_ret *ret)
+remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_lookup_by_id_args *args,
+ remote_domain_lookup_by_id_ret *ret)
{
virDomainPtr dom;
- dom = virDomainLookupByID (conn, args->id);
+ dom = virDomainLookupByID(conn, args->id);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->dom, dom);
+ make_nonnull_domain(&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_lookup_by_name_args *args,
- remote_domain_lookup_by_name_ret *ret)
+remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_lookup_by_name_args *args,
+ remote_domain_lookup_by_name_ret *ret)
{
virDomainPtr dom;
- dom = virDomainLookupByName (conn, args->name);
+ dom = virDomainLookupByName(conn, args->name);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->dom, dom);
+ make_nonnull_domain(&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
-remoteDispatchDomainLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_lookup_by_uuid_args *args,
- remote_domain_lookup_by_uuid_ret *ret)
+remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_lookup_by_uuid_args *args,
+ remote_domain_lookup_by_uuid_ret *ret)
{
virDomainPtr dom;
- dom = virDomainLookupByUUID (conn, (unsigned char *) args->uuid);
+ dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_domain (&ret->dom, dom);
+ make_nonnull_domain(&ret->dom, dom);
virDomainFree(dom);
return 0;
}
static int
-remoteDispatchNumOfDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_defined_domains_ret *ret)
+remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_defined_domains_ret *ret)
{
- ret->num = virConnectNumOfDefinedDomains (conn);
+ ret->num = virConnectNumOfDefinedDomains(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -2160,18 +2160,18 @@ remoteDispatchNumOfDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainPinVcpu (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_pin_vcpu_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_pin_vcpu_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
int rv;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -2179,13 +2179,13 @@ remoteDispatchDomainPinVcpu (struct qemud_server *server ATTRIBUTE_UNUSED,
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
virDomainFree(dom);
- remoteDispatchFormatError (rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
+ remoteDispatchFormatError(rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
return -1;
}
- rv = virDomainPinVcpu (dom, args->vcpu,
- (unsigned char *) args->cpumap.cpumap_val,
- args->cpumap.cpumap_len);
+ rv = virDomainPinVcpu(dom, args->vcpu,
+ (unsigned char *) args->cpumap.cpumap_val,
+ args->cpumap.cpumap_len);
if (rv == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -2196,23 +2196,23 @@ remoteDispatchDomainPinVcpu (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainReboot (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_reboot_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_reboot_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainReboot (dom, args->flags) == -1) {
+ if (virDomainReboot(dom, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2222,16 +2222,16 @@ remoteDispatchDomainReboot (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainRestore (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_restore_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_restore_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
- if (virDomainRestore (conn, args->from) == -1) {
+ if (virDomainRestore(conn, args->from) == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -2240,23 +2240,23 @@ remoteDispatchDomainRestore (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainResume (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_resume_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_resume_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainResume (dom) == -1) {
+ if (virDomainResume(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2266,23 +2266,23 @@ remoteDispatchDomainResume (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSave (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_save_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_save_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSave (dom, args->to) == -1) {
+ if (virDomainSave(dom, args->to) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2292,23 +2292,23 @@ remoteDispatchDomainSave (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_core_dump_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_core_dump_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainCoreDump (dom, args->to, args->flags) == -1) {
+ if (virDomainCoreDump(dom, args->to, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2318,23 +2318,23 @@ remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_autostart_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_autostart_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSetAutostart (dom, args->autostart) == -1) {
+ if (virDomainSetAutostart(dom, args->autostart) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2344,23 +2344,23 @@ remoteDispatchDomainSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_max_memory_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_max_memory_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSetMaxMemory (dom, args->memory) == -1) {
+ if (virDomainSetMaxMemory(dom, args->memory) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2370,23 +2370,23 @@ remoteDispatchDomainSetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSetMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_memory_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_memory_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSetMemory (dom, args->memory) == -1) {
+ if (virDomainSetMemory(dom, args->memory) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2396,23 +2396,23 @@ remoteDispatchDomainSetMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSetMemoryFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_memory_flags_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_memory_flags_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSetMemoryFlags (dom, args->memory, args->flags) == -1) {
+ if (virDomainSetMemoryFlags(dom, args->memory, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2844,23 +2844,23 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
}
static int
-remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_vcpus_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_vcpus_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSetVcpus (dom, args->nvcpus) == -1) {
+ if (virDomainSetVcpus(dom, args->nvcpus) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2870,23 +2870,23 @@ remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_set_vcpus_flags_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_vcpus_flags_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSetVcpusFlags (dom, args->nvcpus, args->flags) == -1) {
+ if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2896,23 +2896,23 @@ remoteDispatchDomainSetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_shutdown_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_shutdown_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainShutdown (dom) == -1) {
+ if (virDomainShutdown(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2922,23 +2922,23 @@ remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSuspend (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_suspend_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_suspend_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainSuspend (dom) == -1) {
+ if (virDomainSuspend(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2948,23 +2948,23 @@ remoteDispatchDomainSuspend (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_undefine_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_undefine_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainUndefine (dom) == -1) {
+ if (virDomainUndefine(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -2974,17 +2974,17 @@ remoteDispatchDomainUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchListDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_defined_networks_args *args,
- remote_list_defined_networks_ret *ret)
+remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_defined_networks_args *args,
+ remote_list_defined_networks_ret *ret)
{
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
@@ -2996,8 +2996,8 @@ remoteDispatchListDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virConnectListDefinedNetworks (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListDefinedNetworks(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_val);
remoteDispatchConnError(rerr, conn);
@@ -3008,17 +3008,17 @@ remoteDispatchListDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_domains_args *args,
- remote_list_domains_ret *ret)
+remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_domains_args *args,
+ remote_list_domains_ret *ret)
{
if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
return -1;
}
@@ -3029,8 +3029,8 @@ remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
return -1;
}
- ret->ids.ids_len = virConnectListDomains (conn,
- ret->ids.ids_val, args->maxids);
+ 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);
@@ -3041,23 +3041,23 @@ remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainManagedSave (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_managed_save_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_managed_save_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainManagedSave (dom, args->flags) == -1) {
+ if (virDomainManagedSave(dom, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -3067,23 +3067,23 @@ remoteDispatchDomainManagedSave (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainHasManagedSaveImage (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_has_managed_save_image_args *args,
- remote_domain_has_managed_save_image_ret *ret)
+remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_has_managed_save_image_args *args,
+ remote_domain_has_managed_save_image_ret *ret)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- ret->ret = virDomainHasManagedSaveImage (dom, args->flags);
+ ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
if (ret->ret == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
@@ -3094,23 +3094,23 @@ remoteDispatchDomainHasManagedSaveImage (struct qemud_server *server ATTRIBUTE_U
}
static int
-remoteDispatchDomainManagedSaveRemove (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_managed_save_remove_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_managed_save_remove_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainManagedSaveRemove (dom, args->flags) == -1) {
+ if (virDomainManagedSaveRemove(dom, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -3120,17 +3120,17 @@ remoteDispatchDomainManagedSaveRemove (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchListNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_networks_args *args,
- remote_list_networks_ret *ret)
+remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_networks_args *args,
+ remote_list_networks_ret *ret)
{
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
@@ -3142,8 +3142,8 @@ remoteDispatchListNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virConnectListNetworks (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListNetworks(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_len);
remoteDispatchConnError(rerr, conn);
@@ -3154,23 +3154,23 @@ remoteDispatchListNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNetworkCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_create_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_create_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virNetworkCreate (net) == -1) {
+ if (virNetworkCreate(net) == -1) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
return -1;
@@ -3180,67 +3180,67 @@ remoteDispatchNetworkCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNetworkCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_create_xml_args *args,
- remote_network_create_xml_ret *ret)
+remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_create_xml_args *args,
+ remote_network_create_xml_ret *ret)
{
virNetworkPtr net;
- net = virNetworkCreateXML (conn, args->xml);
+ net = virNetworkCreateXML(conn, args->xml);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_network (&ret->net, net);
+ make_nonnull_network(&ret->net, net);
virNetworkFree(net);
return 0;
}
static int
-remoteDispatchNetworkDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_define_xml_args *args,
- remote_network_define_xml_ret *ret)
+remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_define_xml_args *args,
+ remote_network_define_xml_ret *ret)
{
virNetworkPtr net;
- net = virNetworkDefineXML (conn, args->xml);
+ net = virNetworkDefineXML(conn, args->xml);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_network (&ret->net, net);
+ make_nonnull_network(&ret->net, net);
virNetworkFree(net);
return 0;
}
static int
-remoteDispatchNetworkDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_destroy_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_destroy_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virNetworkDestroy (net) == -1) {
+ if (virNetworkDestroy(net) == -1) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
return -1;
@@ -3250,24 +3250,24 @@ remoteDispatchNetworkDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNetworkDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_dump_xml_args *args,
- remote_network_dump_xml_ret *ret)
+remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_dump_xml_args *args,
+ remote_network_dump_xml_ret *ret)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virNetworkGetXMLDesc (net, args->flags);
+ ret->xml = virNetworkGetXMLDesc(net, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
@@ -3278,23 +3278,23 @@ remoteDispatchNetworkDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNetworkGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_get_autostart_args *args,
- remote_network_get_autostart_ret *ret)
+remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_get_autostart_args *args,
+ remote_network_get_autostart_ret *ret)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virNetworkGetAutostart (net, &ret->autostart) == -1) {
+ if (virNetworkGetAutostart(net, &ret->autostart) == -1) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
return -1;
@@ -3304,24 +3304,24 @@ remoteDispatchNetworkGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNetworkGetBridgeName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_get_bridge_name_args *args,
- remote_network_get_bridge_name_ret *ret)
+remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_get_bridge_name_args *args,
+ remote_network_get_bridge_name_ret *ret)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->name = virNetworkGetBridgeName (net);
+ ret->name = virNetworkGetBridgeName(net);
if (!ret->name) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
@@ -3332,67 +3332,67 @@ remoteDispatchNetworkGetBridgeName (struct qemud_server *server ATTRIBUTE_UNUSED
}
static int
-remoteDispatchNetworkLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_lookup_by_name_args *args,
- remote_network_lookup_by_name_ret *ret)
+remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_lookup_by_name_args *args,
+ remote_network_lookup_by_name_ret *ret)
{
virNetworkPtr net;
- net = virNetworkLookupByName (conn, args->name);
+ net = virNetworkLookupByName(conn, args->name);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_network (&ret->net, net);
+ make_nonnull_network(&ret->net, net);
virNetworkFree(net);
return 0;
}
static int
-remoteDispatchNetworkLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_lookup_by_uuid_args *args,
- remote_network_lookup_by_uuid_ret *ret)
+remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_lookup_by_uuid_args *args,
+ remote_network_lookup_by_uuid_ret *ret)
{
virNetworkPtr net;
- net = virNetworkLookupByUUID (conn, (unsigned char *) args->uuid);
+ net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_network (&ret->net, net);
+ make_nonnull_network(&ret->net, net);
virNetworkFree(net);
return 0;
}
static int
-remoteDispatchNetworkSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_set_autostart_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_set_autostart_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virNetworkSetAutostart (net, args->autostart) == -1) {
+ if (virNetworkSetAutostart(net, args->autostart) == -1) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
return -1;
@@ -3402,23 +3402,23 @@ remoteDispatchNetworkSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNetworkUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_network_undefine_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_network_undefine_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNetworkPtr net;
- net = get_nonnull_network (conn, args->net);
+ net = get_nonnull_network(conn, args->net);
if (net == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virNetworkUndefine (net) == -1) {
+ if (virNetworkUndefine(net) == -1) {
remoteDispatchConnError(rerr, conn);
virNetworkFree(net);
return -1;
@@ -3428,16 +3428,16 @@ remoteDispatchNetworkUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNumOfDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_defined_networks_ret *ret)
+remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_defined_networks_ret *ret)
{
- ret->num = virConnectNumOfDefinedNetworks (conn);
+ ret->num = virConnectNumOfDefinedNetworks(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -3447,16 +3447,16 @@ remoteDispatchNumOfDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED
}
static int
-remoteDispatchNumOfDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_domains_ret *ret)
+remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_domains_ret *ret)
{
- ret->num = virConnectNumOfDomains (conn);
+ ret->num = virConnectNumOfDomains(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -3466,16 +3466,16 @@ remoteDispatchNumOfDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNumOfNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_networks_ret *ret)
+remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_networks_ret *ret)
{
- ret->num = virConnectNumOfNetworks (conn);
+ ret->num = virConnectNumOfNetworks(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -3487,16 +3487,16 @@ remoteDispatchNumOfNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
/*-------------------------------------------------------------*/
static int
-remoteDispatchNumOfInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_interfaces_ret *ret)
+remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_interfaces_ret *ret)
{
- ret->num = virConnectNumOfInterfaces (conn);
+ ret->num = virConnectNumOfInterfaces(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -3506,17 +3506,17 @@ remoteDispatchNumOfInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchListInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_interfaces_args *args,
- remote_list_interfaces_ret *ret)
+remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_interfaces_args *args,
+ remote_list_interfaces_ret *ret)
{
if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
return -1;
}
@@ -3528,8 +3528,8 @@ remoteDispatchListInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virConnectListInterfaces (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListInterfaces(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_len);
remoteDispatchConnError(rerr, conn);
@@ -3540,16 +3540,16 @@ remoteDispatchListInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNumOfDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_defined_interfaces_ret *ret)
+remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_defined_interfaces_ret *ret)
{
- ret->num = virConnectNumOfDefinedInterfaces (conn);
+ ret->num = virConnectNumOfDefinedInterfaces(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -3559,17 +3559,17 @@ remoteDispatchNumOfDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUS
}
static int
-remoteDispatchListDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_defined_interfaces_args *args,
- remote_list_defined_interfaces_ret *ret)
+remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_defined_interfaces_args *args,
+ remote_list_defined_interfaces_ret *ret)
{
if (args->maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
return -1;
}
@@ -3581,8 +3581,8 @@ remoteDispatchListDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUSE
}
ret->names.names_len =
- virConnectListDefinedInterfaces (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListDefinedInterfaces(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_len);
remoteDispatchConnError(rerr, conn);
@@ -3593,68 +3593,68 @@ remoteDispatchListDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUSE
}
static int
-remoteDispatchInterfaceLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_lookup_by_name_args *args,
- remote_interface_lookup_by_name_ret *ret)
+remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_lookup_by_name_args *args,
+ remote_interface_lookup_by_name_ret *ret)
{
virInterfacePtr iface;
- iface = virInterfaceLookupByName (conn, args->name);
+ iface = virInterfaceLookupByName(conn, args->name);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_interface (&ret->iface, iface);
+ make_nonnull_interface(&ret->iface, iface);
virInterfaceFree(iface);
return 0;
}
static int
-remoteDispatchInterfaceLookupByMacString (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_lookup_by_mac_string_args *args,
- remote_interface_lookup_by_mac_string_ret *ret)
+remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_lookup_by_mac_string_args *args,
+ remote_interface_lookup_by_mac_string_ret *ret)
{
virInterfacePtr iface;
- iface = virInterfaceLookupByMACString (conn, args->mac);
+ iface = virInterfaceLookupByMACString(conn, args->mac);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_interface (&ret->iface, iface);
+ make_nonnull_interface(&ret->iface, iface);
virInterfaceFree(iface);
return 0;
}
-
-static int
-remoteDispatchInterfaceGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_get_xml_desc_args *args,
- remote_interface_get_xml_desc_ret *ret)
+
+static int
+remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_get_xml_desc_args *args,
+ remote_interface_get_xml_desc_ret *ret)
{
virInterfacePtr iface;
- iface = get_nonnull_interface (conn, args->iface);
+ iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virInterfaceGetXMLDesc (iface, args->flags);
+ ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virInterfaceFree(iface);
@@ -3665,45 +3665,45 @@ remoteDispatchInterfaceGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchInterfaceDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_define_xml_args *args,
- remote_interface_define_xml_ret *ret)
+remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_define_xml_args *args,
+ remote_interface_define_xml_ret *ret)
{
virInterfacePtr iface;
- iface = virInterfaceDefineXML (conn, args->xml, args->flags);
+ iface = virInterfaceDefineXML(conn, args->xml, args->flags);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_interface (&ret->iface, iface);
+ make_nonnull_interface(&ret->iface, iface);
virInterfaceFree(iface);
return 0;
}
static int
-remoteDispatchInterfaceUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_undefine_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_undefine_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virInterfacePtr iface;
- iface = get_nonnull_interface (conn, args->iface);
+ iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virInterfaceUndefine (iface) == -1) {
+ if (virInterfaceUndefine(iface) == -1) {
remoteDispatchConnError(rerr, conn);
virInterfaceFree(iface);
return -1;
@@ -3713,23 +3713,23 @@ remoteDispatchInterfaceUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchInterfaceCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_create_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_create_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virInterfacePtr iface;
- iface = get_nonnull_interface (conn, args->iface);
+ iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virInterfaceCreate (iface, args->flags) == -1) {
+ if (virInterfaceCreate(iface, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virInterfaceFree(iface);
return -1;
@@ -3739,23 +3739,23 @@ remoteDispatchInterfaceCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchInterfaceDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_interface_destroy_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_interface_destroy_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virInterfacePtr iface;
- iface = get_nonnull_interface (conn, args->iface);
+ iface = get_nonnull_interface(conn, args->iface);
if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virInterfaceDestroy (iface, args->flags) == -1) {
+ if (virInterfaceDestroy(iface, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virInterfaceFree(iface);
return -1;
@@ -3767,13 +3767,13 @@ remoteDispatchInterfaceDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
/*-------------------------------------------------------------*/
static int
-remoteDispatchAuthList (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_auth_list_ret *ret)
+remoteDispatchAuthList(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_auth_list_ret *ret)
{
ret->types.types_len = 1;
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
@@ -3798,13 +3798,13 @@ remoteDispatchAuthList (struct qemud_server *server,
* XXX callbacks for stuff like password verification ?
*/
static int
-remoteDispatchAuthSaslInit (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_auth_sasl_init_ret *ret)
+remoteDispatchAuthSaslInit(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_auth_sasl_init_ret *ret)
{
const char *mechlist = NULL;
sasl_security_properties_t secprops;
@@ -3893,7 +3893,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server,
}
}
- memset (&secprops, 0, sizeof secprops);
+ memset(&secprops, 0, sizeof secprops);
if (client->type == QEMUD_SOCK_TYPE_TLS ||
client->type == QEMUD_SOCK_TYPE_UNIX) {
/* If we've got TLS or UNIX domain sock, we don't care about SSF */
@@ -3961,8 +3961,8 @@ error:
* Returns 0 if ok, -1 on error, -2 if rejected
*/
static int
-remoteSASLCheckSSF (struct qemud_client *client,
- remote_error *rerr) {
+remoteSASLCheckSSF(struct qemud_client *client,
+ remote_error *rerr) {
const void *val;
int err, ssf;
@@ -4005,9 +4005,9 @@ remoteSASLCheckSSF (struct qemud_client *client,
* Returns 0 if ok, -1 on error, -2 if rejected
*/
static int
-remoteSASLCheckAccess (struct qemud_server *server,
- struct qemud_client *client,
- remote_error *rerr) {
+remoteSASLCheckAccess(struct qemud_server *server,
+ struct qemud_client *client,
+ remote_error *rerr) {
const void *val;
int err;
char **wildcards;
@@ -4045,7 +4045,7 @@ remoteSASLCheckAccess (struct qemud_server *server,
return 0; /* No ACL, allow all */
while (*wildcards) {
- if (fnmatch (*wildcards, client->saslUsername, 0) == 0)
+ if (fnmatch(*wildcards, client->saslUsername, 0) == 0)
return 0; /* Allowed */
wildcards++;
}
@@ -4063,13 +4063,13 @@ remoteSASLCheckAccess (struct qemud_server *server,
* This starts the SASL authentication negotiation.
*/
static int
-remoteDispatchAuthSaslStart (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_auth_sasl_start_args *args,
- remote_auth_sasl_start_ret *ret)
+remoteDispatchAuthSaslStart(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_auth_sasl_start_args *args,
+ remote_auth_sasl_start_ret *ret)
{
const char *serverout;
unsigned int serveroutlen;
@@ -4163,13 +4163,13 @@ error:
static int
-remoteDispatchAuthSaslStep (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_auth_sasl_step_args *args,
- remote_auth_sasl_step_ret *ret)
+remoteDispatchAuthSaslStep(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_auth_sasl_step_args *args,
+ remote_auth_sasl_step_ret *ret)
{
const char *serverout;
unsigned int serveroutlen;
@@ -4265,13 +4265,13 @@ error:
#else /* HAVE_SASL */
static int
-remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchAuthSaslInit(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
{
VIR_ERROR0(_("client tried unsupported SASL init request"));
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
@@ -4280,13 +4280,13 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchAuthSaslStart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
- remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchAuthSaslStart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
+ remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
{
VIR_ERROR0(_("client tried unsupported SASL start request"));
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
@@ -4295,13 +4295,13 @@ remoteDispatchAuthSaslStart (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
- remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchAuthSaslStep(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
+ remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
{
VIR_ERROR0(_("client tried unsupported SASL step request"));
PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
@@ -4313,13 +4313,13 @@ remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
#if HAVE_POLKIT1
static int
-remoteDispatchAuthPolkit (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_auth_polkit_ret *ret)
+remoteDispatchAuthPolkit(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_auth_polkit_ret *ret)
{
pid_t callerPid = -1;
uid_t callerUid = -1;
@@ -4409,13 +4409,13 @@ error:
}
#elif HAVE_POLKIT0
static int
-remoteDispatchAuthPolkit (struct qemud_server *server,
- struct qemud_client *client,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_auth_polkit_ret *ret)
+remoteDispatchAuthPolkit(struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_auth_polkit_ret *ret)
{
pid_t callerPid;
uid_t callerUid;
@@ -4543,13 +4543,13 @@ error:
#else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
static int
-remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn ATTRIBUTE_UNUSED,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchAuthPolkit(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
{
VIR_ERROR0(_("client tried unsupported PolicyKit init request"));
remoteDispatchAuthError(rerr);
@@ -4564,17 +4564,17 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchListDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_defined_storage_pools_args *args,
- remote_list_defined_storage_pools_ret *ret)
+remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_defined_storage_pools_args *args,
+ remote_list_defined_storage_pools_ret *ret)
{
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr, "%s",
+ remoteDispatchFormatError(rerr, "%s",
_("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
@@ -4586,8 +4586,8 @@ remoteDispatchListDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNU
}
ret->names.names_len =
- virConnectListDefinedStoragePools (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListDefinedStoragePools(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_val);
remoteDispatchConnError(rerr, conn);
@@ -4598,17 +4598,17 @@ remoteDispatchListDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchListStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_storage_pools_args *args,
- remote_list_storage_pools_ret *ret)
+remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_storage_pools_args *args,
+ remote_list_storage_pools_ret *ret)
{
if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
return -1;
}
@@ -4620,8 +4620,8 @@ remoteDispatchListStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virConnectListStoragePools (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListStoragePools(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_val);
remoteDispatchConnError(rerr, conn);
@@ -4632,19 +4632,19 @@ remoteDispatchListStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchFindStoragePoolSources (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_find_storage_pool_sources_args *args,
- remote_find_storage_pool_sources_ret *ret)
+remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_find_storage_pool_sources_args *args,
+ remote_find_storage_pool_sources_ret *ret)
{
ret->xml =
- virConnectFindStoragePoolSources (conn,
- args->type,
- args->srcSpec ? *args->srcSpec : NULL,
- args->flags);
+ virConnectFindStoragePoolSources(conn,
+ args->type,
+ args->srcSpec ? *args->srcSpec : NULL,
+ args->flags);
if (ret->xml == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -4655,23 +4655,23 @@ remoteDispatchFindStoragePoolSources (struct qemud_server *server ATTRIBUTE_UNUS
static int
-remoteDispatchStoragePoolCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_create_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_create_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolCreate (pool, args->flags) == -1) {
+ if (virStoragePoolCreate(pool, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4681,67 +4681,67 @@ remoteDispatchStoragePoolCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStoragePoolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_create_xml_args *args,
- remote_storage_pool_create_xml_ret *ret)
+remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_create_xml_args *args,
+ remote_storage_pool_create_xml_ret *ret)
{
virStoragePoolPtr pool;
- pool = virStoragePoolCreateXML (conn, args->xml, args->flags);
+ pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_storage_pool (&ret->pool, pool);
+ make_nonnull_storage_pool(&ret->pool, pool);
virStoragePoolFree(pool);
return 0;
}
static int
-remoteDispatchStoragePoolDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_define_xml_args *args,
- remote_storage_pool_define_xml_ret *ret)
+remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_define_xml_args *args,
+ remote_storage_pool_define_xml_ret *ret)
{
virStoragePoolPtr pool;
- pool = virStoragePoolDefineXML (conn, args->xml, args->flags);
+ pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_storage_pool (&ret->pool, pool);
+ make_nonnull_storage_pool(&ret->pool, pool);
virStoragePoolFree(pool);
return 0;
}
static int
-remoteDispatchStoragePoolBuild (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_build_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_build_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolBuild (pool, args->flags) == -1) {
+ if (virStoragePoolBuild(pool, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4752,23 +4752,23 @@ remoteDispatchStoragePoolBuild (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchStoragePoolDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_destroy_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_destroy_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolDestroy (pool) == -1) {
+ if (virStoragePoolDestroy(pool) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4778,23 +4778,23 @@ remoteDispatchStoragePoolDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStoragePoolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_delete_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_delete_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolDelete (pool, args->flags) == -1) {
+ if (virStoragePoolDelete(pool, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4804,23 +4804,23 @@ remoteDispatchStoragePoolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStoragePoolRefresh (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_refresh_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_refresh_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolRefresh (pool, args->flags) == -1) {
+ if (virStoragePoolRefresh(pool, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4830,24 +4830,24 @@ remoteDispatchStoragePoolRefresh (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStoragePoolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_get_info_args *args,
- remote_storage_pool_get_info_ret *ret)
+remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_get_info_args *args,
+ remote_storage_pool_get_info_ret *ret)
{
virStoragePoolPtr pool;
virStoragePoolInfo info;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolGetInfo (pool, &info) == -1) {
+ if (virStoragePoolGetInfo(pool, &info) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4864,24 +4864,24 @@ remoteDispatchStoragePoolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStoragePoolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_dump_xml_args *args,
- remote_storage_pool_dump_xml_ret *ret)
+remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_dump_xml_args *args,
+ remote_storage_pool_dump_xml_ret *ret)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virStoragePoolGetXMLDesc (pool, args->flags);
+ ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
@@ -4892,23 +4892,23 @@ remoteDispatchStoragePoolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStoragePoolGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_get_autostart_args *args,
- remote_storage_pool_get_autostart_ret *ret)
+remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_get_autostart_args *args,
+ remote_storage_pool_get_autostart_ret *ret)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolGetAutostart (pool, &ret->autostart) == -1) {
+ if (virStoragePoolGetAutostart(pool, &ret->autostart) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -4919,68 +4919,68 @@ remoteDispatchStoragePoolGetAutostart (struct qemud_server *server ATTRIBUTE_UNU
static int
-remoteDispatchStoragePoolLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_lookup_by_name_args *args,
- remote_storage_pool_lookup_by_name_ret *ret)
+remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_lookup_by_name_args *args,
+ remote_storage_pool_lookup_by_name_ret *ret)
{
virStoragePoolPtr pool;
- pool = virStoragePoolLookupByName (conn, args->name);
+ pool = virStoragePoolLookupByName(conn, args->name);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_storage_pool (&ret->pool, pool);
+ make_nonnull_storage_pool(&ret->pool, pool);
virStoragePoolFree(pool);
return 0;
}
static int
-remoteDispatchStoragePoolLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_lookup_by_uuid_args *args,
- remote_storage_pool_lookup_by_uuid_ret *ret)
+remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_lookup_by_uuid_args *args,
+ remote_storage_pool_lookup_by_uuid_ret *ret)
{
virStoragePoolPtr pool;
- pool = virStoragePoolLookupByUUID (conn, (unsigned char *) args->uuid);
+ pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_storage_pool (&ret->pool, pool);
+ make_nonnull_storage_pool(&ret->pool, pool);
virStoragePoolFree(pool);
return 0;
}
static int
-remoteDispatchStoragePoolLookupByVolume (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_lookup_by_volume_args *args,
- remote_storage_pool_lookup_by_volume_ret *ret)
+remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_lookup_by_volume_args *args,
+ remote_storage_pool_lookup_by_volume_ret *ret)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
- vol = get_nonnull_storage_vol (conn, args->vol);
+ vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- pool = virStoragePoolLookupByVolume (vol);
+ pool = virStoragePoolLookupByVolume(vol);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
virStorageVolFree(vol);
@@ -4988,29 +4988,29 @@ remoteDispatchStoragePoolLookupByVolume (struct qemud_server *server ATTRIBUTE_U
}
virStorageVolFree(vol);
- make_nonnull_storage_pool (&ret->pool, pool);
+ make_nonnull_storage_pool(&ret->pool, pool);
virStoragePoolFree(pool);
return 0;
}
static int
-remoteDispatchStoragePoolSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_set_autostart_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_set_autostart_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolSetAutostart (pool, args->autostart) == -1) {
+ if (virStoragePoolSetAutostart(pool, args->autostart) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -5020,23 +5020,23 @@ remoteDispatchStoragePoolSetAutostart (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchStoragePoolUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_undefine_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_undefine_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStoragePoolUndefine (pool) == -1) {
+ if (virStoragePoolUndefine(pool) == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
@@ -5046,16 +5046,16 @@ remoteDispatchStoragePoolUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNumOfStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_storage_pools_ret *ret)
+remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_storage_pools_ret *ret)
{
- ret->num = virConnectNumOfStoragePools (conn);
+ ret->num = virConnectNumOfStoragePools(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -5065,16 +5065,16 @@ remoteDispatchNumOfStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchNumOfDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_defined_storage_pools_ret *ret)
+remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_defined_storage_pools_ret *ret)
{
- ret->num = virConnectNumOfDefinedStoragePools (conn);
+ ret->num = virConnectNumOfDefinedStoragePools(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -5084,23 +5084,23 @@ remoteDispatchNumOfDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UN
}
static int
-remoteDispatchStoragePoolListVolumes (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_list_volumes_args *args,
- remote_storage_pool_list_volumes_ret *ret)
+remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_list_volumes_args *args,
+ remote_storage_pool_list_volumes_ret *ret)
{
virStoragePoolPtr pool;
if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
return -1;
}
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -5114,8 +5114,8 @@ remoteDispatchStoragePoolListVolumes (struct qemud_server *server ATTRIBUTE_UNUS
}
ret->names.names_len =
- virStoragePoolListVolumes (pool,
- ret->names.names_val, args->maxnames);
+ virStoragePoolListVolumes(pool,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_val);
remoteDispatchConnError(rerr, conn);
@@ -5129,23 +5129,23 @@ remoteDispatchStoragePoolListVolumes (struct qemud_server *server ATTRIBUTE_UNUS
static int
-remoteDispatchStoragePoolNumOfVolumes (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_pool_num_of_volumes_args *args,
- remote_storage_pool_num_of_volumes_ret *ret)
+remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_pool_num_of_volumes_args *args,
+ remote_storage_pool_num_of_volumes_ret *ret)
{
virStoragePoolPtr pool;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- ret->num = virStoragePoolNumOfVolumes (pool);
+ ret->num = virStoragePoolNumOfVolumes(pool);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
@@ -5164,24 +5164,24 @@ remoteDispatchStoragePoolNumOfVolumes (struct qemud_server *server ATTRIBUTE_UNU
static int
-remoteDispatchStorageVolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_create_xml_args *args,
- remote_storage_vol_create_xml_ret *ret)
+remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_create_xml_args *args,
+ remote_storage_vol_create_xml_ret *ret)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- vol = virStorageVolCreateXML (pool, args->xml, args->flags);
+ vol = virStorageVolCreateXML(pool, args->xml, args->flags);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
@@ -5189,38 +5189,38 @@ remoteDispatchStorageVolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
}
virStoragePoolFree(pool);
- make_nonnull_storage_vol (&ret->vol, vol);
+ make_nonnull_storage_vol(&ret->vol, vol);
virStorageVolFree(vol);
return 0;
}
static int
-remoteDispatchStorageVolCreateXmlFrom (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_create_xml_from_args *args,
- remote_storage_vol_create_xml_from_ret *ret)
+remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_create_xml_from_args *args,
+ remote_storage_vol_create_xml_from_ret *ret)
{
virStoragePoolPtr pool;
virStorageVolPtr clonevol, newvol;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- clonevol = get_nonnull_storage_vol (conn, args->clonevol);
+ clonevol = get_nonnull_storage_vol(conn, args->clonevol);
if (clonevol == NULL) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
return -1;
}
- newvol = virStorageVolCreateXMLFrom (pool, args->xml, clonevol,
- args->flags);
+ newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
+ args->flags);
if (newvol == NULL) {
remoteDispatchConnError(rerr, conn);
virStorageVolFree(clonevol);
@@ -5230,29 +5230,29 @@ remoteDispatchStorageVolCreateXmlFrom (struct qemud_server *server ATTRIBUTE_UNU
virStorageVolFree(clonevol);
virStoragePoolFree(pool);
- make_nonnull_storage_vol (&ret->vol, newvol);
+ make_nonnull_storage_vol(&ret->vol, newvol);
virStorageVolFree(newvol);
return 0;
}
static int
-remoteDispatchStorageVolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_delete_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_delete_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virStorageVolPtr vol;
- vol = get_nonnull_storage_vol (conn, args->vol);
+ vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStorageVolDelete (vol, args->flags) == -1) {
+ if (virStorageVolDelete(vol, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virStorageVolFree(vol);
return -1;
@@ -5294,24 +5294,24 @@ out:
}
static int
-remoteDispatchStorageVolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_get_info_args *args,
- remote_storage_vol_get_info_ret *ret)
+remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_get_info_args *args,
+ remote_storage_vol_get_info_ret *ret)
{
virStorageVolPtr vol;
virStorageVolInfo info;
- vol = get_nonnull_storage_vol (conn, args->vol);
+ vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virStorageVolGetInfo (vol, &info) == -1) {
+ if (virStorageVolGetInfo(vol, &info) == -1) {
remoteDispatchConnError(rerr, conn);
virStorageVolFree(vol);
return -1;
@@ -5327,24 +5327,24 @@ remoteDispatchStorageVolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchStorageVolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_dump_xml_args *args,
- remote_storage_vol_dump_xml_ret *ret)
+remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_dump_xml_args *args,
+ remote_storage_vol_dump_xml_ret *ret)
{
virStorageVolPtr vol;
- vol = get_nonnull_storage_vol (conn, args->vol);
+ vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virStorageVolGetXMLDesc (vol, args->flags);
+ ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virStorageVolFree(vol);
@@ -5356,24 +5356,24 @@ remoteDispatchStorageVolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchStorageVolGetPath (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_get_path_args *args,
- remote_storage_vol_get_path_ret *ret)
+remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_get_path_args *args,
+ remote_storage_vol_get_path_ret *ret)
{
virStorageVolPtr vol;
- vol = get_nonnull_storage_vol (conn, args->vol);
+ vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->name = virStorageVolGetPath (vol);
+ ret->name = virStorageVolGetPath(vol);
if (!ret->name) {
remoteDispatchConnError(rerr, conn);
virStorageVolFree(vol);
@@ -5385,24 +5385,24 @@ remoteDispatchStorageVolGetPath (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchStorageVolLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_lookup_by_name_args *args,
- remote_storage_vol_lookup_by_name_ret *ret)
+remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_lookup_by_name_args *args,
+ remote_storage_vol_lookup_by_name_ret *ret)
{
virStoragePoolPtr pool;
virStorageVolPtr vol;
- pool = get_nonnull_storage_pool (conn, args->pool);
+ pool = get_nonnull_storage_pool(conn, args->pool);
if (pool == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- vol = virStorageVolLookupByName (pool, args->name);
+ vol = virStorageVolLookupByName(pool, args->name);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
virStoragePoolFree(pool);
@@ -5410,52 +5410,52 @@ remoteDispatchStorageVolLookupByName (struct qemud_server *server ATTRIBUTE_UNUS
}
virStoragePoolFree(pool);
- make_nonnull_storage_vol (&ret->vol, vol);
+ make_nonnull_storage_vol(&ret->vol, vol);
virStorageVolFree(vol);
return 0;
}
static int
-remoteDispatchStorageVolLookupByKey (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_lookup_by_key_args *args,
- remote_storage_vol_lookup_by_key_ret *ret)
+remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_lookup_by_key_args *args,
+ remote_storage_vol_lookup_by_key_ret *ret)
{
virStorageVolPtr vol;
- vol = virStorageVolLookupByKey (conn, args->key);
+ vol = virStorageVolLookupByKey(conn, args->key);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_storage_vol (&ret->vol, vol);
+ make_nonnull_storage_vol(&ret->vol, vol);
virStorageVolFree(vol);
return 0;
}
static int
-remoteDispatchStorageVolLookupByPath (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_storage_vol_lookup_by_path_args *args,
- remote_storage_vol_lookup_by_path_ret *ret)
+remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_storage_vol_lookup_by_path_args *args,
+ remote_storage_vol_lookup_by_path_ret *ret)
{
virStorageVolPtr vol;
- vol = virStorageVolLookupByPath (conn, args->path);
+ vol = virStorageVolLookupByPath(conn, args->path);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_storage_vol (&ret->vol, vol);
+ make_nonnull_storage_vol(&ret->vol, vol);
virStorageVolFree(vol);
return 0;
}
@@ -5466,19 +5466,19 @@ remoteDispatchStorageVolLookupByPath (struct qemud_server *server ATTRIBUTE_UNUS
**************************************************************/
static int
-remoteDispatchNodeNumOfDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_num_of_devices_args *args,
- remote_node_num_of_devices_ret *ret)
+remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_num_of_devices_args *args,
+ remote_node_num_of_devices_ret *ret)
{
CHECK_CONN(client);
- ret->num = virNodeNumOfDevices (conn,
- args->cap ? *args->cap : NULL,
- args->flags);
+ ret->num = virNodeNumOfDevices(conn,
+ args->cap ? *args->cap : NULL,
+ args->flags);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -5489,13 +5489,13 @@ remoteDispatchNodeNumOfDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeListDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_list_devices_args *args,
- remote_node_list_devices_ret *ret)
+remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_list_devices_args *args,
+ remote_node_list_devices_ret *ret)
{
CHECK_CONN(client);
@@ -5512,9 +5512,9 @@ remoteDispatchNodeListDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virNodeListDevices (conn,
- args->cap ? *args->cap : NULL,
- ret->names.names_val, args->maxnames, args->flags);
+ virNodeListDevices(conn,
+ 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);
@@ -5526,38 +5526,38 @@ remoteDispatchNodeListDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_lookup_by_name_args *args,
- remote_node_device_lookup_by_name_ret *ret)
+remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_lookup_by_name_args *args,
+ remote_node_device_lookup_by_name_ret *ret)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
- dev = virNodeDeviceLookupByName (conn, args->name);
+ dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_node_device (&ret->dev, dev);
+ make_nonnull_node_device(&ret->dev, dev);
virNodeDeviceFree(dev);
return 0;
}
static int
-remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_dump_xml_args *args,
- remote_node_device_dump_xml_ret *ret)
+remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_dump_xml_args *args,
+ remote_node_device_dump_xml_ret *ret)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
@@ -5569,7 +5569,7 @@ remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virNodeDeviceGetXMLDesc (dev, args->flags);
+ ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virNodeDeviceFree(dev);
@@ -5581,13 +5581,13 @@ remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceGetParent (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_get_parent_args *args,
- remote_node_device_get_parent_ret *ret)
+remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_get_parent_args *args,
+ remote_node_device_get_parent_ret *ret)
{
virNodeDevicePtr dev;
const char *parent;
@@ -5626,13 +5626,13 @@ remoteDispatchNodeDeviceGetParent (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_num_of_caps_args *args,
- remote_node_device_num_of_caps_ret *ret)
+remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_num_of_caps_args *args,
+ remote_node_device_num_of_caps_ret *ret)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
@@ -5656,13 +5656,13 @@ remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_list_caps_args *args,
- remote_node_device_list_caps_ret *ret)
+remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_list_caps_args *args,
+ remote_node_device_list_caps_ret *ret)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
@@ -5688,8 +5688,8 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virNodeDeviceListCaps (dev, ret->names.names_val,
- args->maxnames);
+ virNodeDeviceListCaps(dev, ret->names.names_val,
+ args->maxnames);
if (ret->names.names_len == -1) {
remoteDispatchConnError(rerr, conn);
virNodeDeviceFree(dev);
@@ -5703,13 +5703,13 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_dettach_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_dettach_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
@@ -5732,13 +5732,13 @@ remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_re_attach_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_re_attach_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
@@ -5761,13 +5761,13 @@ remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_node_device_reset_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_node_device_reset_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNodeDevicePtr dev;
CHECK_CONN(client);
@@ -5800,13 +5800,13 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
{
virNodeDevicePtr dev;
- dev = virNodeDeviceCreateXML (conn, args->xml_desc, args->flags);
+ dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
if (dev == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_node_device (&ret->dev, dev);
+ make_nonnull_node_device(&ret->dev, dev);
virNodeDeviceFree(dev);
return 0;
@@ -5898,7 +5898,7 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
struct qemud_client_stream *stream = NULL;
virStorageVolPtr vol;
- vol = get_nonnull_storage_vol (conn, args->vol);
+ vol = get_nonnull_storage_vol(conn, args->vol);
if (vol == NULL) {
remoteDispatchConnError(rerr, conn);
goto cleanup;
@@ -5938,13 +5938,13 @@ cleanup:
* Register / deregister events
***************************/
static int
-remoteDispatchDomainEventsRegister (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr ATTRIBUTE_UNUSED,
- void *args ATTRIBUTE_UNUSED,
- remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr ATTRIBUTE_UNUSED,
+ void *args ATTRIBUTE_UNUSED,
+ remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
{
CHECK_CONN(client);
int callbackID;
@@ -5969,13 +5969,13 @@ remoteDispatchDomainEventsRegister (struct qemud_server *server ATTRIBUTE_UNUSED
}
static int
-remoteDispatchDomainEventsDeregister (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr ATTRIBUTE_UNUSED,
- void *args ATTRIBUTE_UNUSED,
- remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr ATTRIBUTE_UNUSED,
+ void *args ATTRIBUTE_UNUSED,
+ remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
{
CHECK_CONN(client);
@@ -5995,10 +5995,10 @@ remoteDispatchDomainEventsDeregister (struct qemud_server *server ATTRIBUTE_UNUS
}
static void
-remoteDispatchDomainEventSend (struct qemud_client *client,
- int procnr,
- xdrproc_t proc,
- void *data)
+remoteDispatchDomainEventSend(struct qemud_client *client,
+ int procnr,
+ xdrproc_t proc,
+ void *data)
{
struct qemud_client_message *msg = NULL;
XDR xdr;
@@ -6018,13 +6018,13 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
goto error;
/* Serialise the return header and event. */
- xdrmem_create (&xdr,
- msg->buffer,
- msg->bufferLength,
- XDR_ENCODE);
+ xdrmem_create(&xdr,
+ msg->buffer,
+ msg->bufferLength,
+ XDR_ENCODE);
/* Skip over the header we just wrote */
- if (xdr_setpos (&xdr, msg->bufferOffset) == 0)
+ if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
goto xdr_error;
if (!(proc)(&xdr, data)) {
@@ -6033,11 +6033,11 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
}
/* Update length word to include payload*/
- len = msg->bufferOffset = xdr_getpos (&xdr);
- if (xdr_setpos (&xdr, 0) == 0)
+ len = msg->bufferOffset = xdr_getpos(&xdr);
+ if (xdr_setpos(&xdr, 0) == 0)
goto xdr_error;
- if (!xdr_u_int (&xdr, &len))
+ if (!xdr_u_int(&xdr, &len))
goto xdr_error;
/* Send it. */
@@ -6049,7 +6049,7 @@ remoteDispatchDomainEventSend (struct qemud_client *client,
qemudClientMessageQueuePush(&client->tx, msg);
qemudUpdateClientEvent(client);
- xdr_destroy (&xdr);
+ xdr_destroy(&xdr);
return;
xdr_error:
@@ -6059,17 +6059,17 @@ error:
}
static int
-remoteDispatchNumOfSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_secrets_ret *ret)
+remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_secrets_ret *ret)
{
- ret->num = virConnectNumOfSecrets (conn);
+ ret->num = virConnectNumOfSecrets(conn);
if (ret->num == -1) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
@@ -6077,30 +6077,30 @@ remoteDispatchNumOfSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchListSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_list_secrets_args *args,
- remote_list_secrets_ret *ret)
+remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_list_secrets_args *args,
+ remote_list_secrets_ret *ret)
{
if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
- remoteDispatchFormatError (err, "%s",
+ remoteDispatchFormatError(err, "%s",
_("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
return -1;
}
- if (VIR_ALLOC_N (ret->uuids.uuids_val, args->maxuuids) < 0) {
- remoteDispatchOOMError (err);
+ if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
+ remoteDispatchOOMError(err);
return -1;
}
- ret->uuids.uuids_len = virConnectListSecrets (conn, ret->uuids.uuids_val,
- args->maxuuids);
+ 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 (err, conn);
+ VIR_FREE(ret->uuids.uuids_val);
+ remoteDispatchConnError(err, conn);
return -1;
}
@@ -6108,49 +6108,49 @@ remoteDispatchListSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchSecretDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_define_xml_args *args,
- remote_secret_define_xml_ret *ret)
+remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_define_xml_args *args,
+ remote_secret_define_xml_ret *ret)
{
virSecretPtr secret;
- secret = virSecretDefineXML (conn, args->xml, args->flags);
+ secret = virSecretDefineXML(conn, args->xml, args->flags);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- make_nonnull_secret (&ret->secret, secret);
- virSecretFree (secret);
+ make_nonnull_secret(&ret->secret, secret);
+ virSecretFree(secret);
return 0;
}
static int
-remoteDispatchSecretGetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_get_value_args *args,
- remote_secret_get_value_ret *ret)
+remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_get_value_args *args,
+ remote_secret_get_value_ret *ret)
{
virSecretPtr secret;
size_t value_size;
unsigned char *value;
- secret = get_nonnull_secret (conn, args->secret);
+ secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- value = virSecretGetValue (secret, &value_size, args->flags);
+ value = virSecretGetValue(secret, &value_size, args->flags);
if (value == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
virSecretFree(secret);
return -1;
}
@@ -6162,24 +6162,24 @@ remoteDispatchSecretGetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchSecretGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_get_xml_desc_args *args,
- remote_secret_get_xml_desc_ret *ret)
+remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_get_xml_desc_args *args,
+ remote_secret_get_xml_desc_ret *ret)
{
virSecretPtr secret;
- secret = get_nonnull_secret (conn, args->secret);
+ secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- ret->xml = virSecretGetXMLDesc (secret, args->flags);
+ ret->xml = virSecretGetXMLDesc(secret, args->flags);
if (ret->xml == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
virSecretFree(secret);
return -1;
}
@@ -6188,46 +6188,46 @@ remoteDispatchSecretGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchSecretLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_lookup_by_uuid_args *args,
- remote_secret_lookup_by_uuid_ret *ret)
+remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_lookup_by_uuid_args *args,
+ remote_secret_lookup_by_uuid_ret *ret)
{
virSecretPtr secret;
- secret = virSecretLookupByUUID (conn, (unsigned char *)args->uuid);
+ secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- make_nonnull_secret (&ret->secret, secret);
- virSecretFree (secret);
+ make_nonnull_secret(&ret->secret, secret);
+ virSecretFree(secret);
return 0;
}
static int
-remoteDispatchSecretSetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_set_value_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_set_value_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virSecretPtr secret;
- secret = get_nonnull_secret (conn, args->secret);
+ secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- if (virSecretSetValue (secret, (const unsigned char *)args->value.value_val,
- args->value.value_len, args->flags) < 0) {
- remoteDispatchConnError (err, conn);
+ if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
+ args->value.value_len, args->flags) < 0) {
+ remoteDispatchConnError(err, conn);
virSecretFree(secret);
return -1;
}
@@ -6237,23 +6237,23 @@ remoteDispatchSecretSetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchSecretUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_undefine_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_undefine_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virSecretPtr secret;
- secret = get_nonnull_secret (conn, args->secret);
+ secret = get_nonnull_secret(conn, args->secret);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- if (virSecretUndefine (secret) < 0) {
- remoteDispatchConnError (err, conn);
+ if (virSecretUndefine(secret) < 0) {
+ remoteDispatchConnError(err, conn);
virSecretFree(secret);
return -1;
}
@@ -6263,24 +6263,24 @@ remoteDispatchSecretUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchSecretLookupByUsage (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *err,
- remote_secret_lookup_by_usage_args *args,
- remote_secret_lookup_by_usage_ret *ret)
+remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *err,
+ remote_secret_lookup_by_usage_args *args,
+ remote_secret_lookup_by_usage_ret *ret)
{
virSecretPtr secret;
- secret = virSecretLookupByUsage (conn, args->usageType, args->usageID);
+ secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
if (secret == NULL) {
- remoteDispatchConnError (err, conn);
+ remoteDispatchConnError(err, conn);
return -1;
}
- make_nonnull_secret (&ret->secret, secret);
- virSecretFree (secret);
+ make_nonnull_secret(&ret->secret, secret);
+ virSecretFree(secret);
return 0;
}
@@ -6578,24 +6578,24 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchDomainGetJobInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_job_info_args *args,
- remote_domain_get_job_info_ret *ret)
+remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_job_info_args *args,
+ remote_domain_get_job_info_ret *ret)
{
virDomainPtr dom;
virDomainJobInfo info;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainGetJobInfo (dom, &info) == -1) {
+ if (virDomainGetJobInfo(dom, &info) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -6621,23 +6621,23 @@ remoteDispatchDomainGetJobInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchDomainAbortJob (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_abort_job_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_abort_job_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr dom;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainAbortJob (dom) == -1) {
+ if (virDomainAbortJob(dom) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -6706,13 +6706,13 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchDomainSnapshotCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_snapshot_create_xml_args *args,
- remote_domain_snapshot_create_xml_ret *ret)
+remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_snapshot_create_xml_args *args,
+ remote_domain_snapshot_create_xml_ret *ret)
{
virDomainSnapshotPtr snapshot;
virDomainPtr domain;
@@ -6739,13 +6739,13 @@ remoteDispatchDomainSnapshotCreateXml (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchDomainSnapshotDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_snapshot_dump_xml_args *args,
- remote_domain_snapshot_dump_xml_ret *ret)
+remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_snapshot_dump_xml_args *args,
+ remote_domain_snapshot_dump_xml_ret *ret)
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -6778,13 +6778,13 @@ cleanup:
}
static int
-remoteDispatchDomainSnapshotNum (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_snapshot_num_args *args,
- remote_domain_snapshot_num_ret *ret)
+remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_snapshot_num_args *args,
+ remote_domain_snapshot_num_ret *ret)
{
virDomainPtr domain;
@@ -6807,18 +6807,18 @@ remoteDispatchDomainSnapshotNum (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchDomainSnapshotListNames (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_snapshot_list_names_args *args,
- remote_domain_snapshot_list_names_ret *ret)
+remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_snapshot_list_names_args *args,
+ remote_domain_snapshot_list_names_ret *ret)
{
virDomainPtr domain;
if (args->nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) {
- remoteDispatchFormatError (rerr, "%s",
+ remoteDispatchFormatError(rerr, "%s",
_("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
return -1;
}
@@ -6853,13 +6853,13 @@ remoteDispatchDomainSnapshotListNames (struct qemud_server *server ATTRIBUTE_UNU
}
static int
-remoteDispatchDomainSnapshotLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_snapshot_lookup_by_name_args *args,
- remote_domain_snapshot_lookup_by_name_ret *ret)
+remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_snapshot_lookup_by_name_args *args,
+ remote_domain_snapshot_lookup_by_name_ret *ret)
{
virDomainSnapshotPtr snapshot;
virDomainPtr domain;
@@ -6877,7 +6877,7 @@ remoteDispatchDomainSnapshotLookupByName (struct qemud_server *server ATTRIBUTE_
return -1;
}
- make_nonnull_domain_snapshot (&ret->snap, snapshot);
+ make_nonnull_domain_snapshot(&ret->snap, snapshot);
virDomainSnapshotFree(snapshot);
virDomainFree(domain);
@@ -6951,13 +6951,13 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
}
static int
-remoteDispatchDomainRevertToSnapshot (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_revert_to_snapshot_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_revert_to_snapshot_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -6988,13 +6988,13 @@ cleanup:
}
static int
-remoteDispatchDomainSnapshotDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_snapshot_delete_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_snapshot_delete_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virDomainPtr domain = NULL;
virDomainSnapshotPtr snapshot = NULL;
@@ -7026,13 +7026,13 @@ cleanup:
static int
-remoteDispatchDomainEventsRegisterAny (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr ATTRIBUTE_UNUSED,
- remote_domain_events_register_any_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr ATTRIBUTE_UNUSED,
+ remote_domain_events_register_any_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
CHECK_CONN(client);
int callbackID;
@@ -7064,13 +7064,13 @@ remoteDispatchDomainEventsRegisterAny (struct qemud_server *server ATTRIBUTE_UNU
static int
-remoteDispatchDomainEventsDeregisterAny (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr ATTRIBUTE_UNUSED,
- remote_domain_events_deregister_any_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr ATTRIBUTE_UNUSED,
+ remote_domain_events_deregister_any_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
CHECK_CONN(client);
int callbackID = -1;
@@ -7099,91 +7099,91 @@ remoteDispatchDomainEventsDeregisterAny (struct qemud_server *server ATTRIBUTE_U
static int
-remoteDispatchNwfilterLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_nwfilter_lookup_by_name_args *args,
- remote_nwfilter_lookup_by_name_ret *ret)
+remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_nwfilter_lookup_by_name_args *args,
+ remote_nwfilter_lookup_by_name_ret *ret)
{
virNWFilterPtr nwfilter;
- nwfilter = virNWFilterLookupByName (conn, args->name);
+ nwfilter = virNWFilterLookupByName(conn, args->name);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_nwfilter (&ret->nwfilter, nwfilter);
+ make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
virNWFilterFree(nwfilter);
return 0;
}
static int
-remoteDispatchNwfilterLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_nwfilter_lookup_by_uuid_args *args,
- remote_nwfilter_lookup_by_uuid_ret *ret)
+remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_nwfilter_lookup_by_uuid_args *args,
+ remote_nwfilter_lookup_by_uuid_ret *ret)
{
virNWFilterPtr nwfilter;
- nwfilter = virNWFilterLookupByUUID (conn, (unsigned char *) args->uuid);
+ nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_nwfilter (&ret->nwfilter, nwfilter);
+ make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
virNWFilterFree(nwfilter);
return 0;
}
static int
-remoteDispatchNwfilterDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_nwfilter_define_xml_args *args,
- remote_nwfilter_define_xml_ret *ret)
+remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_nwfilter_define_xml_args *args,
+ remote_nwfilter_define_xml_ret *ret)
{
virNWFilterPtr nwfilter;
- nwfilter = virNWFilterDefineXML (conn, args->xml);
+ nwfilter = virNWFilterDefineXML(conn, args->xml);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_nwfilter (&ret->nwfilter, nwfilter);
+ make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
virNWFilterFree(nwfilter);
return 0;
}
static int
-remoteDispatchNwfilterUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_nwfilter_undefine_args *args,
- void *ret ATTRIBUTE_UNUSED)
+remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_nwfilter_undefine_args *args,
+ void *ret ATTRIBUTE_UNUSED)
{
virNWFilterPtr nwfilter;
- nwfilter = get_nonnull_nwfilter (conn, args->nwfilter);
+ nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virNWFilterUndefine (nwfilter) == -1) {
+ if (virNWFilterUndefine(nwfilter) == -1) {
remoteDispatchConnError(rerr, conn);
virNWFilterFree(nwfilter);
return -1;
@@ -7193,17 +7193,17 @@ remoteDispatchNwfilterUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-remoteDispatchListNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_list_nwfilters_args *args,
- remote_list_nwfilters_ret *ret)
+remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_list_nwfilters_args *args,
+ remote_list_nwfilters_ret *ret)
{
if (args->maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) {
- remoteDispatchFormatError (rerr,
+ remoteDispatchFormatError(rerr,
"%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
return -1;
}
@@ -7215,8 +7215,8 @@ remoteDispatchListNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
}
ret->names.names_len =
- virConnectListNWFilters (conn,
- ret->names.names_val, args->maxnames);
+ virConnectListNWFilters(conn,
+ ret->names.names_val, args->maxnames);
if (ret->names.names_len == -1) {
VIR_FREE(ret->names.names_len);
remoteDispatchConnError(rerr, conn);
@@ -7228,24 +7228,24 @@ remoteDispatchListNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNwfilterGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_nwfilter_get_xml_desc_args *args,
- remote_nwfilter_get_xml_desc_ret *ret)
+remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_nwfilter_get_xml_desc_args *args,
+ remote_nwfilter_get_xml_desc_ret *ret)
{
virNWFilterPtr nwfilter;
- nwfilter = get_nonnull_nwfilter (conn, args->nwfilter);
+ nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
if (nwfilter == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virNWFilterGetXMLDesc (nwfilter, args->flags);
+ ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
if (!ret->xml) {
remoteDispatchConnError(rerr, conn);
virNWFilterFree(nwfilter);
@@ -7257,16 +7257,16 @@ remoteDispatchNwfilterGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchNumOfNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- void *args ATTRIBUTE_UNUSED,
- remote_num_of_nwfilters_ret *ret)
+remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_num_of_nwfilters_ret *ret)
{
- ret->num = virConnectNumOfNWFilters (conn);
+ ret->num = virConnectNumOfNWFilters(conn);
if (ret->num == -1) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -7277,24 +7277,24 @@ remoteDispatchNumOfNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
static int
-remoteDispatchDomainGetBlockInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- remote_domain_get_block_info_args *args,
- remote_domain_get_block_info_ret *ret)
+remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_get_block_info_args *args,
+ remote_domain_get_block_info_ret *ret)
{
virDomainPtr dom;
virDomainBlockInfo info;
- dom = get_nonnull_domain (conn, args->dom);
+ dom = get_nonnull_domain(conn, args->dom);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virDomainGetBlockInfo (dom, args->path, &info, args->flags) == -1) {
+ if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) == -1) {
remoteDispatchConnError(rerr, conn);
virDomainFree(dom);
return -1;
@@ -7310,13 +7310,13 @@ remoteDispatchDomainGetBlockInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
}
static int
-qemuDispatchMonitorCommand (struct qemud_server *server ATTRIBUTE_UNUSED,
- struct qemud_client *client ATTRIBUTE_UNUSED,
- virConnectPtr conn,
- remote_message_header *hdr ATTRIBUTE_UNUSED,
- remote_error *rerr,
- qemu_monitor_command_args *args,
- qemu_monitor_command_ret *ret)
+qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ qemu_monitor_command_args *args,
+ qemu_monitor_command_ret *ret)
{
virDomainPtr domain;
@@ -7354,7 +7354,7 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
CHECK_CONN (client);
- dom = get_nonnull_domain (conn, args->domain);
+ dom = get_nonnull_domain(conn, args->domain);
if (dom == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
@@ -7400,10 +7400,10 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
* NB. If these return NULL then the caller must return an error.
*/
static virDomainPtr
-get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain)
+get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain)
{
virDomainPtr dom;
- dom = virGetDomain (conn, domain.name, BAD_CAST domain.uuid);
+ dom = virGetDomain(conn, domain.name, BAD_CAST domain.uuid);
/* Should we believe the domain.id sent by the client? Maybe
* this should be a check rather than an assignment? XXX
*/
@@ -7412,111 +7412,111 @@ get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain)
}
static virNetworkPtr
-get_nonnull_network (virConnectPtr conn, remote_nonnull_network network)
+get_nonnull_network(virConnectPtr conn, remote_nonnull_network network)
{
- return virGetNetwork (conn, network.name, BAD_CAST network.uuid);
+ return virGetNetwork(conn, network.name, BAD_CAST network.uuid);
}
static virInterfacePtr
-get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface)
+get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface)
{
- return virGetInterface (conn, iface.name, iface.mac);
+ return virGetInterface(conn, iface.name, iface.mac);
}
static virStoragePoolPtr
-get_nonnull_storage_pool (virConnectPtr conn, remote_nonnull_storage_pool pool)
+get_nonnull_storage_pool(virConnectPtr conn, remote_nonnull_storage_pool pool)
{
- return virGetStoragePool (conn, pool.name, BAD_CAST pool.uuid);
+ return virGetStoragePool(conn, pool.name, BAD_CAST pool.uuid);
}
static virStorageVolPtr
-get_nonnull_storage_vol (virConnectPtr conn, remote_nonnull_storage_vol vol)
+get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol)
{
virStorageVolPtr ret;
- ret = virGetStorageVol (conn, vol.pool, vol.name, vol.key);
+ ret = virGetStorageVol(conn, vol.pool, vol.name, vol.key);
return ret;
}
static virSecretPtr
-get_nonnull_secret (virConnectPtr conn, remote_nonnull_secret secret)
+get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret)
{
- return virGetSecret (conn, BAD_CAST secret.uuid, secret.usageType, secret.usageID);
+ return virGetSecret(conn, BAD_CAST secret.uuid, secret.usageType, secret.usageID);
}
static virNWFilterPtr
-get_nonnull_nwfilter (virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
+get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
{
- return virGetNWFilter (conn, nwfilter.name, BAD_CAST nwfilter.uuid);
+ return virGetNWFilter(conn, nwfilter.name, BAD_CAST nwfilter.uuid);
}
static virDomainSnapshotPtr
-get_nonnull_domain_snapshot (virDomainPtr domain, remote_nonnull_domain_snapshot snapshot)
+get_nonnull_domain_snapshot(virDomainPtr domain, remote_nonnull_domain_snapshot snapshot)
{
return virGetDomainSnapshot(domain, snapshot.name);
}
/* Make remote_nonnull_domain and remote_nonnull_network. */
static void
-make_nonnull_domain (remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
+make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
{
dom_dst->id = dom_src->id;
- dom_dst->name = strdup (dom_src->name);
- memcpy (dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
+ dom_dst->name = strdup(dom_src->name);
+ memcpy(dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
}
static void
-make_nonnull_network (remote_nonnull_network *net_dst, virNetworkPtr net_src)
+make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src)
{
- net_dst->name = strdup (net_src->name);
- memcpy (net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
+ net_dst->name = strdup(net_src->name);
+ memcpy(net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
}
static void
-make_nonnull_interface (remote_nonnull_interface *interface_dst,
- virInterfacePtr interface_src)
+make_nonnull_interface(remote_nonnull_interface *interface_dst,
+ virInterfacePtr interface_src)
{
- interface_dst->name = strdup (interface_src->name);
- interface_dst->mac = strdup (interface_src->mac);
+ interface_dst->name = strdup(interface_src->name);
+ interface_dst->mac = strdup(interface_src->mac);
}
static void
-make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
+make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
{
- pool_dst->name = strdup (pool_src->name);
- memcpy (pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
+ pool_dst->name = strdup(pool_src->name);
+ memcpy(pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
}
static void
-make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
+make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
{
- vol_dst->pool = strdup (vol_src->pool);
- vol_dst->name = strdup (vol_src->name);
- vol_dst->key = strdup (vol_src->key);
+ vol_dst->pool = strdup(vol_src->pool);
+ vol_dst->name = strdup(vol_src->name);
+ vol_dst->key = strdup(vol_src->key);
}
static void
-make_nonnull_node_device (remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
+make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
{
dev_dst->name = strdup(dev_src->name);
}
static void
-make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
+make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
{
- memcpy (secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN);
+ memcpy(secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN);
secret_dst->usageType = secret_src->usageType;
- secret_dst->usageID = strdup (secret_src->usageID);
+ secret_dst->usageID = strdup(secret_src->usageID);
}
static void
-make_nonnull_nwfilter (remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
+make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
{
- nwfilter_dst->name = strdup (nwfilter_src->name);
- memcpy (nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
+ nwfilter_dst->name = strdup(nwfilter_src->name);
+ memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
}
static void
-make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
+make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
{
snapshot_dst->name = strdup(snapshot_src->name);
make_nonnull_domain(&snapshot_dst->domain, snapshot_src->domain);
--
1.7.4.2
2
1
13 Apr '11
Hi Michal,
The following commit introduced a regression:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=79c3fe4d1681cd94598d2bd42e…
Now, defining a guest with XML like
<serial type='pty'/>
<serial type='null'/>
<serial type='stdio'/>
Will allocate <target port='0'/> to all 3. The reason is that
target.port is never set to -1 unless the user specified some <target>
XML. A simple fix is:
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3265,6 +3265,8 @@ virDomainChrDefParseXML(virCapsPtr caps,
return NULL;
}
+ def->target.port = -1;
+
type = virXMLPropString(node, "type");
if (type == NULL) {
def->source.type = VIR_DOMAIN_CHR_TYPE_PTY;
But that doesn't solve the problem for users who are building ChrDef's
by hand, like when converting between formats as xen and vmware drivers
do. I didn't look at those users so they may be safe, but the interface
should be improved. Maybe add a ChrDefNew function that sets the -1 default.
Additionally we should add a qemuxml2xml test for this to prevent
against future regressions.
Thanks,
Cole
2
7
Hi all:
To my surprise, it seems that passing null to php as a string parameter,
will set the pointer which retrive it to an empty string "" , but not NULL.
get_xml_from_xpath() doesn't work correctly since an empty string is
passed as the xpath argument, and libxml will complain "Invalid expression"
I know seldom about xpath, I'm not sure if it is the correct way to fix it.
BTW, what xpath shall I pass to get the entire xml?
---
src/libvirt-php.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index ce9d0b9..2a77423 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -1205,6 +1205,11 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal)
int ret = 0, i;
char *value, key[8] = { 0 };
+ if ((xpath == NULL) || (xml == NULL))
+ {
+ return NULL;
+ }
+
xp = xmlCreateDocParserCtxt( (xmlChar *)xml );
if (!xp) {
if (retVal)
@@ -1691,6 +1696,10 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc)
int retval = -1;
GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&xpath,&xpath_len,&flags);
+ if (xpath_len < 1)
+ {
+ xpath = NULL;
+ }
xml=virDomainGetXMLDesc(domain->domain,flags);
if (xml==NULL) {
@@ -3123,6 +3132,10 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc)
int retval = -1;
GET_VOLUME_FROM_ARGS("rs|l",&zvolume,&xpath,&xpath_len,&flags);
+ if (xpath_len < 1)
+ {
+ xpath = NULL;
+ }
xml=virStorageVolGetXMLDesc(volume->volume,flags);
if (xml==NULL) {
@@ -3338,6 +3351,10 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc)
int retval = -1;
GET_STORAGEPOOL_FROM_ARGS("rs|l", &zpool, &xpath, &xpath_len, &flags);
+ if (xpath_len < 1)
+ {
+ xpath = NULL;
+ }
xml = virStoragePoolGetXMLDesc (pool->pool, flags);
if (xml == NULL)
@@ -4136,6 +4153,10 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc)
int retval = -1;
GET_NODEDEV_FROM_ARGS("r|s",&znodedev,&xpath,&xpath_len);
+ if (xpath_len < 1)
+ {
+ xpath = NULL;
+ }
xml=virNodeDeviceGetXMLDesc(nodedev->device, 0);
if ( xml == NULL ) {
@@ -4576,6 +4597,10 @@ PHP_FUNCTION(libvirt_network_get_xml_desc)
int retval = -1;
GET_NETWORK_FROM_ARGS("r|s",&znetwork,&xpath,&xpath_len);
+ if (xpath_len < 1)
+ {
+ xpath = NULL;
+ }
xml=virNetworkGetXMLDesc(network->network, 0);
--
1.7.3.4
2
3
[libvirt] [PATCH] virsh: Add --name and --description options to snapshot-create
by Matthias Bolte 13 Apr '11
by Matthias Bolte 13 Apr '11
13 Apr '11
This options are shortcuts to set name and description of a snapshot.
Suggested by Elias Probst
---
I'm not sure if this is be best approach. In case of the vol-* commands there
is vol-create that takes and XML file and vol-create-as that takes a set of
arguments.
So, should there actually be a snapshot-create-as to takes --name and
--description options?
Matthias
tools/virsh.c | 39 ++++++++++++++++++++++++++++++++++++---
tools/virsh.pod | 6 ++++--
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 2e35021..2ddb2f7 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10214,6 +10214,8 @@ static const vshCmdInfo info_snapshot_create[] = {
static const vshCmdOptDef opts_snapshot_create[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"xmlfile", VSH_OT_DATA, 0, N_("domain snapshot XML")},
+ {"name", VSH_OT_DATA, 0, N_("snapshot name")},
+ {"description", VSH_OT_DATA, 0, N_("snapshot description")},
{NULL, 0, 0, NULL}
};
@@ -10223,6 +10225,8 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom = NULL;
int ret = FALSE;
const char *from = NULL;
+ const char *suggested_name = NULL;
+ const char *description = NULL;
char *buffer = NULL;
virDomainSnapshotPtr snapshot = NULL;
xmlDocPtr xml = NULL;
@@ -10237,9 +10241,38 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
if (dom == NULL)
goto cleanup;
- if (vshCommandOptString(cmd, "xmlfile", &from) <= 0)
- buffer = vshStrdup(ctl, "<domainsnapshot/>");
- else {
+ if (vshCommandOptString(cmd, "xmlfile", &from) <= 0) {
+ if (vshCommandOptString(cmd, "name", &suggested_name) < 0 ||
+ vshCommandOptString(cmd, "description", &description) < 0) {
+ goto cleanup;
+ }
+
+ if (suggested_name != NULL || description != NULL) {
+ virBuffer tmp = VIR_BUFFER_INITIALIZER;
+
+ virBufferAddLit(&tmp, "<domainsnapshot>\n");
+
+ if (suggested_name != NULL)
+ virBufferEscapeString(&tmp, " <name>%s</name>\n",
+ suggested_name);
+
+ if (description != NULL)
+ virBufferEscapeString(&tmp, " <description>%s</description>\n",
+ description);
+
+ virBufferAddLit(&tmp, "</domainsnapshot>");
+
+ if (virBufferError(&tmp)) {
+ virBufferFreeAndReset(&tmp);
+ vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
+ goto cleanup;
+ }
+
+ buffer = virBufferContentAndReset(&tmp);
+ } else {
+ buffer = vshStrdup(ctl, "<domainsnapshot/>");
+ }
+ } else {
if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
/* we have to report the error here because during cleanup
* we'll run through virDomainFree(), which loses the
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 9c42008..aa238d9 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1223,12 +1223,14 @@ used to represent properties of snapshots.
=over 4
-=item B<snapshot-create> I<domain> I<xmlfile>
+=item B<snapshot-create> I<domain> I<xmlfile> optional I<name> I<description>
Create a snapshot for domain I<domain> with the properties specified in
I<xmlfile>. The only properties settable for a domain snapshot are the
<name> and <description>; the rest of the fields are ignored, and
-automatically filled in by libvirt. If I<xmlfile> is completely omitted,
+automatically filled in by libvirt. The values for <name> and <description>
+can also be specified using I<name> and I<description> when I<xmlfile> is
+ommited. If I<xmlfile>, I<name> and I<description> are completely omitted,
then libvirt will choose a value for all fields.
=item B<snapshot-current> I<domain>
--
1.7.0.4
3
2
I think keeping with the monthly schedule for new release is a good
thing considering the current amount of changes and patches being
pushed. So if we plan 0.9.1 by the month end, this means entering freeze
around the week-end of the 23rd, i.e. in 10 days, a rough estimate is
that the new release would embed 200-250 commits which is plenty enough :-)
Opinions ?
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
1
0
12 Apr '11
When we take out completed calls from queue we might end up
in circular pointer. We don't want pointer to previous item
point to element taken out.
---
src/remote/remote_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 9310ddf..ec10010 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -10672,8 +10672,9 @@ remoteIOEventLoop(virConnectPtr conn,
*/
VIR_DEBUG("Waking up sleep %d %p %p", tmp->proc_nr, tmp, priv->waitDispatch);
virCondSignal(&tmp->cond);
+ } else {
+ prev = tmp;
}
- prev = tmp;
tmp = tmp->next;
}
--
1.7.4.2
3
2
Jim recently improved gnulib to catch various grammar errors
during 'make syntax-check'.
* .gnulib: Update to latest, for syntax-check improvements.
* include/libvirt/libvirt.h.in (virConnectAuthCallbackPtr): Use
cannot rather than two words.
* src/driver.c: Likewise.
* src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): Likewise.
* src/remote/remote_driver.c (initialize_gnutls): Likewise.
* src/util/pci.c (pciBindDeviceToStub): Likewise.
* src/storage/storage_backend.c (virStorageBackendCreateQemuImg):
Likewise.
(virStorageBackendUpdateVolTargetInfoFD): Avoid doubled word.
* docs/formatdomain.html.in: Likewise.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_can_not)
(exclude_file_name_regexp--sc_prohibit_doubled_word): Exclude
existing translation problems.
---
* .gnulib 4a1579d...ca6143b (40):
> autoupdate
> maint.mk: prohibit doubled words
> maint: fix doubled-word typo in comments
> maint: remove doubled word: s/it it/it/
> maint.mk: remove useless semicolon and backslash
> stdint test: Fix compilation failure on OSF/1 with DTK compiler.
> autoupdate
> maint: remove doubled words in comments, e.g., s/a a/a/
> test-chown.h: correct a cast
> fix typo in ChangeLog entry
> getaddrinfo: Fix test for sa_len member.
> maint: change "can not" to "cannot"
> maint: change "a a" to "a"
> maint.mk: prohibit \<the the\>
> maint: fix "the the" in comment
> maint: change "can not" to "cannot"
> maint.mk: prohibit use of "can not"
> careadlinkat: Guard against misuse of careadlinkatcwd.
> careadlinkat: Use common coding style.
> careadlinkat: Clarify specification.
> areadlinkat: Avoid link error on many platforms.
> allocator, careadlinkat: Fix double-inclusion guard.
> relocatable-prog-wrapper: Update after module 'areadlink' changed.
> relocatable-prog-wrapper: Update after module 'areadlink' changed.
> strftime: silence gnulib-tool warning
> verify: Fix syntax error with GCC 4.6 in C++ mode.
> autoupdate
> allocator: New module.
> * lib/stdlib.in.h (malloc, realloc): Limit this change to a smaller scope.
> * lib/realloc.c (_GL_USE_STDLIB_ALLOC, malloc, realloc): Likewise.
> * lib/malloc.c (_GL_USE_STDLIB_ALLOC, malloc): Likewise.
> * lib/relocwrapper.c (_GL_USE_STDLIB_ALLOC, malloc): Likewise.
> * lib/relocatable.c (_GL_USE_STDLIB_ALLOC, malloc): Likewise.
> * lib/canonicalize-lgpl.c (_GL_USE_STDLIB_ALLOC, malloc): Likewise.
> * lib/setenv.c (_GL_USE_STDLIB_ALLOC, malloc, realloc): Likewise.
> * lib/progreloc.c (_GL_USE_STDLIB_ALLOC, malloc): Likewise.
> * lib/malloca.c (_GL_USE_STDLIB_ALLOC, malloc): Likewise.
> * lib/careadlinkat.c (_GL_USE_STDLIB_ALLOC): Define.
> stdlib: let modules use system malloc, realloc
> careadlinkat: rename members to avoid problem
.gnulib | 2 +-
cfg.mk | 4 ++++
docs/formatdomain.html.in | 2 +-
include/libvirt/libvirt.h.in | 2 +-
src/driver.c | 4 ++--
src/driver.h | 2 +-
src/qemu/qemu_process.c | 2 +-
src/remote/remote_driver.c | 2 +-
src/storage/storage_backend.c | 4 ++--
src/util/pci.c | 6 +++---
10 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/.gnulib b/.gnulib
index 4a1579d..ca6143b 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 4a1579d7560659ef5723325726eda14490a967f6
+Subproject commit ca6143b425589c3a64bd28efd7af14463f96d576
diff --git a/cfg.mk b/cfg.mk
index 4ed0d96..94db937 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -573,9 +573,13 @@ exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
exclude_file_name_regexp--sc_prohibit_asprintf = \
^(bootstrap.conf$$|po/|src/util/util\.c$$|examples/domain-events/events-c/event-test\.c$$)
+exclude_file_name_regexp--sc_prohibit_can_not = ^po/
+
exclude_file_name_regexp--sc_prohibit_close = \
(\.py$$|^docs/|(src/util/files\.c|src/libvirt\.c)$$)
+exclude_file_name_regexp--sc_prohibit_doubled_word = ^po/
+
exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \
(^docs/api_extension/|^tests/qemuhelpdata/|\.(gif|ico|png)$$)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 574fee5..3c4c656 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -774,7 +774,7 @@
<span class="since">Since 0.0.3; "device" attribute since 0.1.4;
"network" attribute since 0.8.7</span></dd>
<dt><code>source</code></dt>
- <dd>If the disk <code>type</code> is "file", then the
+ <dd>If the disk <code>type</code> is "file", then
the <code>file</code> attribute specifies the fully-qualified
path to the file holding the disk. If the disk
<code>type</code> is "block", then the <code>dev</code>
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 04b7fbf..5783303 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -505,7 +505,7 @@ typedef virConnectCredential *virConnectCredentialPtr;
* When authentication requires one or more interactions, this callback
* is invoked. For each interaction supplied, data must be gathered
* from the user and filled in to the 'result' and 'resultlen' fields.
- * If an interaction can not be filled, fill in NULL and 0.
+ * If an interaction cannot be filled, fill in NULL and 0.
*
* Returns 0 if all interactions were filled, or -1 upon error
*/
diff --git a/src/driver.c b/src/driver.c
index f882ea1..579c2b3 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -1,7 +1,7 @@
/*
* driver.c: Helpers for loading drivers
*
- * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,7 @@
#define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
-/* Make sure ... INTERNAL_CALL can not be set by the caller */
+/* Make sure ... INTERNAL_CALL cannot be set by the caller */
verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL &
VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
diff --git a/src/driver.h b/src/driver.h
index e5f91ca..a8b79e6 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1063,7 +1063,7 @@ struct _virDeviceMonitor {
enum {
/* This getValue call is inside libvirt, override the "private" flag.
- This flag can not be set by outside callers. */
+ This flag cannot be set by outside callers. */
VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 16
};
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9ada24d..7295f9e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2326,7 +2326,7 @@ int qemuProcessStart(virConnectPtr conn,
ret = virCommandRun(cmd, NULL);
VIR_FREE(pidfile);
- /* wait for qemu process to to show up */
+ /* wait for qemu process to show up */
if (ret == 0) {
if (virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 9310ddf..5cb4f4c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1223,7 +1223,7 @@ initialize_gnutls(char *pkipath, int flags)
goto out_of_memory;
/* Use default location as long as one of CA certificate,
- * client key, and client certificate can not be found in
+ * client key, and client certificate cannot be found in
* $HOME/.pki/libvirt, we don't want to make user confused
* with one file is here, the other is there.
*/
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 8af2878..97a7e4b 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -703,7 +703,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
(!inputBackingPath ||
STRNEQ(inputBackingPath, vol->backingStore.path))) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("a different backing store can not "
+ "%s", _("a different backing store cannot "
"be specified."));
return -1;
}
@@ -1188,7 +1188,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
*capacity = sb.st_size;
} else {
off_t end;
- /* XXX this is POSIX compliant, but doesn't work for for CHAR files,
+ /* XXX this is POSIX compliant, but doesn't work for CHAR files,
* only BLOCK. There is a Linux specific ioctl() for getting
* size of both CHAR / BLOCK devices we should check for in
* configure
diff --git a/src/util/pci.c b/src/util/pci.c
index 248afd3..ff950d1 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1073,7 +1073,7 @@ remove_id:
* ID table so that 'drivers_probe' works below.
*/
if (pciDriverFile(&path, driver, "remove_id") < 0) {
- /* We do not remove PCI ID from pci-stub, and we can not reprobe it */
+ /* We do not remove PCI ID from pci-stub, and we cannot reprobe it */
if (dev->reprobe) {
VIR_WARN("Could not remove PCI ID '%s' from %s, and the device "
"cannot be probed again.", dev->id, driver);
@@ -1087,7 +1087,7 @@ remove_id:
_("Failed to remove PCI ID '%s' from %s"),
dev->id, driver);
- /* remove PCI ID from pci-stub failed, and we can not reprobe it */
+ /* remove PCI ID from pci-stub failed, and we cannot reprobe it */
if (dev->reprobe) {
VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device "
"cannot be probed again.", dev->id, driver);
--
1.7.4.2
2
2
Hi all:
This patch fixed some memory leaks
Lyre (2):
Fix memory leak when connection failed
Fix memory leak when releasing connection & domain
src/libvirt-php.c | 36 +++++++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 9 deletions(-)
--
1.7.3.4
C
2
3
This patch series are based on Dave Allan's previous posts:
https://www.redhat.com/archives/libvir-list/2010-June/msg00040.html
I rebased them and make changes per last feedback from Eric, and
also other some small changes.
<QUOTE>
The following patches add the ability to format filesystem pools when
the appropriate flags are passed to pool build. As before, I have
implemented two new flags:
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE causes the build to probe for an
existing pool of the requested type. The build operation formats the
filesystem if it does not find an existing filesystem of that type.
VIR_STORAGE_POOL_BUILD_OVERWRITE causes the build to format unconditionally.
These patches incorporate all the feedback received on earlier versions.
The incremental is pretty unhelpful, so these are complete replacement patches.
Dave
</QUOTE>
1
5
11 Apr '11
Hello,
when a domain is migrated to another host and than back again, snapshots of
this domain are no longer shown.
I think that is because qemuDomainSnapshotLoad() is only called once from
qemudStartup() during startup, but not after migration (or re-definition of a
previously deleted domain, e.g. offline-migration)
No patch yet, but this is tracked at our German bugzilla at
<https://forge.univention.org/bugzilla/show_bug.cgi?id=22072>
Sincerely
Philipp Hahn
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
2
1
11 Apr '11
Hi all,
This patchset enables us to configure inactive domain's maximum memory
size.
v1 -> v2:
- recreate based on 0.9.0
- fix some typo
*[PATCH 1/3] maxmem: introduces VIR_DOMAIN_MEM_MAXIMUM flag
*[PATCH 2/3] maxmem: implement virDomainSetMaxMemory API of the qemu driver
*[PATCH 3/3] setmaxmem: add the new options to "virsh setmaxmem" command
Best regards,
Taku Izumi
4
10
Hi all,
I notice that the current IPv6 auto address implementation doesn't pass
down any DNS details to the guest machine - which means that an 'IPv6
only' guest that works automatically is currently just out of reach.
Support for handing out these details depends upon the version of
'radvd' that is installed on the host server. RHEL5's standard version
has no support for DNS options. 6.0 has 1.6 installed which can hand out
the DNS address, but you need 1.7 before DNS search lists from RFC6106
are supported.
The data for these options is available in the network definition and it
appears at first glance to be reasonably straightforward to add them.
What do you think would be the best way to implement this? Is there a
mechanism within libvirt already that checks versions of subsiduary
programs and runs slightly different code accordingly?
Or are there other plans in the pipeline?
Rgs
Neil Wilson
2
1
Based on a smaller patch developed by Moritoshi Oshiro:
https://bugzilla.redhat.com/show_bug.cgi?id=693963
* tools/virsh.pod (freecell): Mention all, and clarify that
optional cellno requires --cellno.
---
I think this is the first case where virsh.pod is trying to convey
mutually exclusive options; does the resulting layout look
reasonable?
tools/virsh.pod | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index f4bd294..2e98d5b 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -314,10 +314,11 @@ crashed.
=back
-=item B<freecell> optional I<cellno>
+=item B<freecell> optional { I<--cellno> B<cellno> | I<--all> }
Prints the available amount of memory on the machine or within a
-NUMA cell if I<cellno> is provided.
+NUMA cell if I<cellno> is provided. If I<--all> is provided instead
+of I<--cellno>, then show the information on all NUMA cells.
=item B<cpu-baseline> I<FILE>
--
1.7.4
2
2
Hi all,
some time ago bug
https://bugs.launchpad.net/ubuntu/maverick/+source/qemu-kvm/+bug/584048
was fixed in libvirt. It's the one where when a VM is started or stopped
which has a lower macaddr than what the bridge currently has, the bridge
changes macaddr and networking pauses. The fix was to make sure that a
macaddr assigned by libvirt will start with 'fe:' making it higher than
the physical interface.
But this doesn't help when virbr0 isn't associated with any physical
nic, as in the common NAT case!
Is there anything we can do to help that case?
thanks,
-serge
2
1
[libvirt] [PATCH] docs: remove "returns" word from beginning of lines
by Jean-Baptiste Rouault 11 Apr '11
by Jean-Baptiste Rouault 11 Apr '11
11 Apr '11
Move "returns" keyword from beginning of API doc lines
when it does not describe return values.
Maybe the API doc extractor could be changed to look for
"returns: " to avoid such confusion.
---
src/libvirt.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 85dfc58..344e921 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10097,8 +10097,8 @@ error:
*
* The virDomainPtr object handle passed into the callback upon delivery
* of an event is only valid for the duration of execution of the callback.
- * If the callback wishes to keep the domain object after the callback
- * returns, it shall take a reference to it, by calling virDomainRef.
+ * If the callback wishes to keep the domain object after the callback returns,
+ * it shall take a reference to it, by calling virDomainRef.
* The reference can be released once the object is no longer required
* by calling virDomainFree.
*
@@ -12727,8 +12727,8 @@ error:
*
* The virDomainPtr object handle passed into the callback upon delivery
* of an event is only valid for the duration of execution of the callback.
- * If the callback wishes to keep the domain object after the callback
- * returns, it shall take a reference to it, by calling virDomainRef.
+ * If the callback wishes to keep the domain object after the callback returns,
+ * it shall take a reference to it, by calling virDomainRef.
* The reference can be released once the object is no longer required
* by calling virDomainFree.
*
--
1.7.0.4
3
2
[libvirt] [PATCH v2] xen: Remove PATH_MAX sized stack allocation from block stats code
by Matthias Bolte 10 Apr '11
by Matthias Bolte 10 Apr '11
10 Apr '11
---
src/xen/block_stats.c | 51 +++++++++++++++++++++++++------------------------
1 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index e7c80c9..1918257 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -113,34 +113,35 @@ read_stat (const char *path)
}
static int64_t
-read_bd_stat (int device, int domid, const char *str)
+read_bd_stat(int device, int domid, const char *str)
{
- char path[PATH_MAX];
+ static const char *paths[] = {
+ "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
+ "/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
+ "/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
+ "/sys/devices/xen-backend/tap-%d-%d/statistics/%s"
+ };
+
+ int i;
+ char *path;
int64_t r;
- snprintf (path, sizeof path,
- "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- if (r >= 0) return r;
-
- snprintf (path, sizeof path,
- "/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- if (r >= 0) return r;
-
- snprintf (path, sizeof path,
- "/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- if (r >= 0) return r;
-
- snprintf (path, sizeof path,
- "/sys/devices/xen-backend/tap-%d-%d/statistics/%s",
- domid, device, str);
- r = read_stat (path);
- return r;
+ for (i = 0; i < ARRAY_CARDINALITY(paths); ++i) {
+ if (virAsprintf(&path, paths[i], domid, device, str) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ r = read_stat(path);
+
+ VIR_FREE(path);
+
+ if (r >= 0) {
+ return r;
+ }
+ }
+
+ return -1;
}
/* In Xenstore, /local/domain/0/backend/vbd/<domid>/<device>/state,
--
1.7.0.4
2
2
[libvirt] [PATCH 1/3] Don't use virSetCloseExec in event loop on Win32
by Daniel P. Berrange 08 Apr '11
by Daniel P. Berrange 08 Apr '11
08 Apr '11
The virSetCloseExec API returns -1 on Win32 since it cannot
possibly work. Avoid calling it from the event loop since
is not required in this case.
* src/util/event_poll.c: Remove virSetCloseExec
---
src/util/event_poll.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/util/event_poll.c b/src/util/event_poll.c
index 91000e2..90788a4 100644
--- a/src/util/event_poll.c
+++ b/src/util/event_poll.c
@@ -658,10 +658,12 @@ int virEventPollInit(void)
}
if (pipe(eventLoop.wakeupfd) < 0 ||
- virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
- virSetNonBlock(eventLoop.wakeupfd[1]) < 0 ||
+#ifndef WIN32
virSetCloseExec(eventLoop.wakeupfd[0]) < 0 ||
- virSetCloseExec(eventLoop.wakeupfd[1]) < 0) {
+ virSetCloseExec(eventLoop.wakeupfd[1]) < 0 ||
+#endif
+ virSetNonBlock(eventLoop.wakeupfd[0]) < 0 ||
+ virSetNonBlock(eventLoop.wakeupfd[1]) < 0) {
virReportSystemError(errno, "%s",
_("Unable to setup wakeup pipe"));
return -1;
--
1.7.4
3
10