The driver dispatch methods access the priv->conn variables directly.
In future we want to dynamically open the connections for the secondary
driver. Thus we want the methods to call a method to get the connection
handle instead of assuming the private variable is non-NULL.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/remote/remote_daemon_dispatch.c | 782 ++++++++++------------------
1 file changed, 289 insertions(+), 493 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index ecce0b0112..b677bd44ee 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -2147,15 +2147,12 @@ remoteDispatchDomainGetSchedulerType(virNetServerPtr server
ATTRIBUTE_UNUSED,
char *type;
int nparams;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (!(type = virDomainGetSchedulerType(dom, &nparams)))
@@ -2184,13 +2181,10 @@ remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server
ATTRIBUTE_UNUS
virTypedParameterPtr params = NULL;
int nparams = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too
large"));
@@ -2200,7 +2194,7 @@ remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server
ATTRIBUTE_UNUS
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0)
@@ -2234,13 +2228,10 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr
server ATTRIBUTE
virTypedParameterPtr params = NULL;
int nparams = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too
large"));
@@ -2250,7 +2241,7 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr
server ATTRIBUTE
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetSchedulerParametersFlags(dom, params, &nparams,
@@ -2286,13 +2277,10 @@ remoteDispatchDomainMemoryStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nr_stats;
size_t i;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2300,7 +2288,7 @@ remoteDispatchDomainMemoryStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
/* Allocate stats array for making dispatch call */
@@ -2345,15 +2333,12 @@ remoteDispatchDomainBlockPeek(virNetServerPtr server
ATTRIBUTE_UNUSED,
size_t size;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
path = args->path;
offset = args->offset;
@@ -2399,15 +2384,12 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
flags = args->flags;
@@ -2461,15 +2443,12 @@ remoteDispatchDomainMemoryPeek(virNetServerPtr server
ATTRIBUTE_UNUSED,
size_t size;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
offset = args->offset;
size = args->size;
@@ -2511,15 +2490,12 @@ remoteDispatchDomainGetSecurityLabel(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
virSecurityLabelPtr seclabel = NULL;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (VIR_ALLOC(seclabel) < 0)
@@ -2556,15 +2532,12 @@ remoteDispatchDomainGetSecurityLabelList(virNetServerPtr server
ATTRIBUTE_UNUSED
virSecurityLabelPtr seclabels = NULL;
int len, rv = -1;
size_t i;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if ((len = virDomainGetSecurityLabelList(dom, &seclabels)) < 0) {
@@ -2610,16 +2583,13 @@ remoteDispatchNodeGetSecurityModel(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
virSecurityModel secmodel;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
memset(&secmodel, 0, sizeof(secmodel));
- if (virNodeGetSecurityModel(priv->conn, &secmodel) < 0)
+ if (virNodeGetSecurityModel(conn, &secmodel) < 0)
goto cleanup;
ret->model.model_len = strlen(secmodel.model) + 1;
@@ -2652,15 +2622,12 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr server
ATTRIBUTE_UNUSED,
unsigned char *cpumaps = NULL;
int num;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (args->ncpumaps > REMOTE_VCPUINFO_MAX) {
@@ -2714,15 +2681,12 @@ remoteDispatchDomainPinEmulator(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
virDomainPtr dom = NULL;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainPinEmulator(dom,
@@ -2753,15 +2717,12 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServerPtr server
ATTRIBUTE_UNUSED,
unsigned char *cpumaps = NULL;
int r;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
/* Allocate buffers to take the results */
@@ -2804,15 +2765,12 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server
ATTRIBUTE_UNUSED,
int info_len;
size_t i;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
@@ -2881,18 +2839,16 @@ remoteDispatchDomainGetIOThreadInfo(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
size_t i;
- struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
virDomainIOThreadInfoPtr *info = NULL;
virDomainPtr dom = NULL;
remote_domain_iothread_info *dst;
int ninfo = 0;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if ((ninfo = virDomainGetIOThreadInfo(dom, &info, args->flags)) < 0)
@@ -2957,13 +2913,10 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr server
ATTRIBUTE_UNUSED,
char **uri_out;
char *dname;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
dname = args->dname == NULL ? NULL : *args->dname;
@@ -2972,7 +2925,7 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr server
ATTRIBUTE_UNUSED,
if (VIR_ALLOC(uri_out) < 0)
goto cleanup;
- if (virDomainMigratePrepare(priv->conn, &cookie, &cookielen,
+ if (virDomainMigratePrepare(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource) < 0)
goto cleanup;
@@ -3012,13 +2965,10 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr server
ATTRIBUTE_UNUSED,
char **uri_out;
char *dname;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
dname = args->dname == NULL ? NULL : *args->dname;
@@ -3027,7 +2977,7 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr server
ATTRIBUTE_UNUSED,
if (VIR_ALLOC(uri_out) < 0)
goto cleanup;
- if (virDomainMigratePrepare2(priv->conn, &cookie, &cookielen,
+ if (virDomainMigratePrepare2(conn, &cookie, &cookielen,
uri_in, uri_out,
args->flags, dname, args->resource,
args->dom_xml) < 0)
@@ -3063,13 +3013,10 @@ remoteDispatchDomainGetMemoryParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -3081,7 +3028,7 @@ remoteDispatchDomainGetMemoryParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
@@ -3125,13 +3072,10 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -3143,7 +3087,7 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetNumaParameters(dom, params, &nparams, flags) < 0)
@@ -3187,13 +3131,10 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -3205,7 +3146,7 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
@@ -3250,13 +3191,10 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -3268,7 +3206,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, flags) < 0)
+ if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, flags) < 0)
goto cleanup;
/* In this case, we need to send back the number of stats
@@ -3322,13 +3260,10 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -3340,7 +3275,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, flags) <
0)
+ if (virNodeGetMemoryStats(conn, cellNum, params, &nparams, flags) < 0)
goto cleanup;
/* In this case, we need to send back the number of parameters
@@ -3392,15 +3327,12 @@ remoteDispatchDomainGetLaunchSecurityInfo(virNetServerPtr server
ATTRIBUTE_UNUSE
virTypedParameterPtr params = NULL;
int nparams = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetLaunchSecurityInfo(dom, ¶ms, &nparams, args->flags)
< 0)
@@ -3439,15 +3371,12 @@ remoteDispatchDomainGetPerfEvents(virNetServerPtr server
ATTRIBUTE_UNUSED,
virTypedParameterPtr params = NULL;
int nparams = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetPerfEvents(dom, ¶ms, &nparams, args->flags) < 0)
@@ -3485,15 +3414,12 @@ remoteDispatchDomainGetBlockJobInfo(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
virDomainBlockJobInfo tmp;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
rv = virDomainGetBlockJobInfo(dom, args->path, &tmp, args->flags);
@@ -3526,13 +3452,10 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr server
ATTRIBUTE_UNUSED,
int rv = -1;
virTypedParameterPtr params = NULL;
int nparams = 0;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->nparams > REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too
large"));
@@ -3543,7 +3466,7 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetBlockIoTune(dom, args->disk ? *args->disk : NULL,
@@ -4103,15 +4026,12 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server
ATTRIBUTE_UNUSED,
virNodeDevicePtr dev = NULL;
const char *parent = NULL;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetNodeDevConn(client);
- if (!priv->nodedevConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dev = virNodeDeviceLookupByName(priv->nodedevConn, args->name)))
+ if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
goto cleanup;
parent = virNodeDeviceGetParent(dev);
@@ -4143,15 +4063,14 @@ remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server
ATTRIBUTE_UNUS
int rv = -1;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (virConnectRegisterCloseCallback(priv->conn,
+ if (virConnectRegisterCloseCallback(conn,
remoteRelayConnectionClosedEvent,
client, NULL) < 0)
goto cleanup;
@@ -4175,15 +4094,14 @@ remoteDispatchConnectUnregisterCloseCallback(virNetServerPtr
server ATTRIBUTE_UN
int rv = -1;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (virConnectUnregisterCloseCallback(priv->conn,
+ if (virConnectUnregisterCloseCallback(conn,
remoteRelayConnectionClosedEvent) < 0)
goto cleanup;
@@ -4210,14 +4128,13 @@ remoteDispatchConnectDomainEventRegister(virNetServerPtr server
ATTRIBUTE_UNUSED
daemonClientEventCallbackPtr ref;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
/* If we call register first, we could append a complete callback
* to our array, but on OOM append failure, we'd have to then hope
* deregister works to undo our register. So instead we append an
@@ -4238,7 +4155,7 @@ remoteDispatchConnectDomainEventRegister(virNetServerPtr server
ATTRIBUTE_UNUSED
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectDomainEventRegisterAny(priv->conn,
+ if ((callbackID = virConnectDomainEventRegisterAny(conn,
NULL,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
@@ -4274,14 +4191,13 @@ remoteDispatchConnectDomainEventDeregister(virNetServerPtr server
ATTRIBUTE_UNUS
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->ndomainEventCallbacks; i++) {
if (priv->domainEventCallbacks[i]->eventID ==
VIR_DOMAIN_EVENT_ID_LIFECYCLE) {
callbackID = priv->domainEventCallbacks[i]->callbackID;
@@ -4296,7 +4212,7 @@ remoteDispatchConnectDomainEventDeregister(virNetServerPtr server
ATTRIBUTE_UNUS
goto cleanup;
}
- if (virConnectDomainEventDeregisterAny(priv->conn, callbackID) < 0)
+ if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->domainEventCallbacks, i,
@@ -4360,15 +4276,12 @@ remoteDispatchSecretGetValue(virNetServerPtr server
ATTRIBUTE_UNUSED,
size_t value_size;
unsigned char *value;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetSecretConn(client);
- if (!priv->secretConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(secret = get_nonnull_secret(priv->secretConn, args->secret)))
+ if (!(secret = get_nonnull_secret(conn, args->secret)))
goto cleanup;
if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
@@ -4396,15 +4309,12 @@ remoteDispatchDomainGetState(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
virDomainPtr dom = NULL;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetState(dom, &ret->state, &ret->reason, args->flags)
< 0)
@@ -4438,14 +4348,13 @@ remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server
ATTRIBUTE_UNU
daemonClientEventCallbackPtr ref;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
/* We intentionally do not use VIR_DOMAIN_EVENT_ID_LAST here; any
* new domain events added after this point should only use the
* modern callback style of RPC. */
@@ -4474,7 +4383,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server
ATTRIBUTE_UNU
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectDomainEventRegisterAny(priv->conn,
+ if ((callbackID = virConnectDomainEventRegisterAny(conn,
NULL,
args->eventID,
domainEventCallbacks[args->eventID],
@@ -4514,16 +4423,15 @@
remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr server ATTRI
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
virDomainPtr dom = NULL;
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
if (args->dom &&
- !(dom = get_nonnull_domain(priv->conn, *args->dom)))
+ !(dom = get_nonnull_domain(conn, *args->dom)))
goto cleanup;
if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST || args->eventID < 0) {
@@ -4549,7 +4457,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr
server ATTRI
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectDomainEventRegisterAny(priv->conn,
+ if ((callbackID = virConnectDomainEventRegisterAny(conn,
dom,
args->eventID,
domainEventCallbacks[args->eventID],
@@ -4588,14 +4496,13 @@ remoteDispatchConnectDomainEventDeregisterAny(virNetServerPtr
server ATTRIBUTE_U
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
/* We intentionally do not use VIR_DOMAIN_EVENT_ID_LAST here; any
* new domain events added after this point should only use the
* modern callback style of RPC. */
@@ -4618,7 +4525,7 @@ remoteDispatchConnectDomainEventDeregisterAny(virNetServerPtr server
ATTRIBUTE_U
goto cleanup;
}
- if (virConnectDomainEventDeregisterAny(priv->conn, callbackID) < 0)
+ if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->domainEventCallbacks, i,
@@ -4645,14 +4552,13 @@
remoteDispatchConnectDomainEventCallbackDeregisterAny(virNetServerPtr server ATT
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->ndomainEventCallbacks; i++) {
if (priv->domainEventCallbacks[i]->callbackID == args->callbackID)
break;
@@ -4664,7 +4570,7 @@
remoteDispatchConnectDomainEventCallbackDeregisterAny(virNetServerPtr server ATT
goto cleanup;
}
- if (virConnectDomainEventDeregisterAny(priv->conn, args->callbackID) < 0)
+ if (virConnectDomainEventDeregisterAny(conn, args->callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->domainEventCallbacks, i,
@@ -4690,15 +4596,12 @@ qemuDispatchDomainMonitorCommand(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
virDomainPtr dom = NULL;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainQemuMonitorCommand(dom, args->cmd, &ret->result,
@@ -4730,15 +4633,12 @@ remoteDispatchDomainMigrateBegin3(virNetServerPtr server
ATTRIBUTE_UNUSED,
char *cookieout = NULL;
int cookieoutlen = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
xmlin = args->xmlin == NULL ? NULL : *args->xmlin;
@@ -4780,13 +4680,10 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr server
ATTRIBUTE_UNUSED,
char **uri_out;
char *dname;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
dname = args->dname == NULL ? NULL : *args->dname;
@@ -4795,7 +4692,7 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr server
ATTRIBUTE_UNUSED,
if (VIR_ALLOC(uri_out) < 0)
goto cleanup;
- if (virDomainMigratePrepare3(priv->conn,
+ if (virDomainMigratePrepare3(conn,
args->cookie_in.cookie_in_val,
args->cookie_in.cookie_in_len,
&cookieout, &cookieoutlen,
@@ -4838,15 +4735,12 @@ remoteDispatchDomainMigratePerform3(virNetServerPtr server
ATTRIBUTE_UNUSED,
char *cookieout = NULL;
int cookieoutlen = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
xmlin = args->xmlin == NULL ? NULL : *args->xmlin;
@@ -4891,18 +4785,15 @@ remoteDispatchDomainMigrateFinish3(virNetServerPtr server
ATTRIBUTE_UNUSED,
char *uri;
char *dconnuri;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
uri = args->uri == NULL ? NULL : *args->uri;
dconnuri = args->dconnuri == NULL ? NULL : *args->dconnuri;
- if (!(dom = virDomainMigrateFinish3(priv->conn, args->dname,
+ if (!(dom = virDomainMigrateFinish3(conn, args->dname,
args->cookie_in.cookie_in_val,
args->cookie_in.cookie_in_len,
&cookieout, &cookieoutlen,
@@ -4940,15 +4831,12 @@ remoteDispatchDomainMigrateConfirm3(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
virDomainPtr dom = NULL;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainMigrateConfirm3(dom,
@@ -4976,8 +4864,7 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr
server ATTRIBUTE
{
int rv = -1;
int supported = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = NULL;
/* This feature is checked before opening the connection, thus we must
* check it first.
@@ -4989,10 +4876,10 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr
server ATTRIBUTE
goto done;
}
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ conn = remoteGetHypervisorConn(client);
+
+ if (!conn)
goto cleanup;
- }
switch ((virDrvFeature) args->feature) {
case VIR_DRV_FEATURE_FD_PASSING:
@@ -5012,7 +4899,7 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr
server ATTRIBUTE
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
default:
- if ((supported = virConnectSupportsFeature(priv->conn, args->feature)) <
0)
+ if ((supported = virConnectSupportsFeature(conn, args->feature)) < 0)
goto cleanup;
break;
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
@@ -5041,15 +4928,12 @@ remoteDispatchDomainOpenGraphics(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
int rv = -1;
int fd = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if ((fd = virNetMessageDupFD(msg, 0)) < 0)
@@ -5082,15 +4966,12 @@ remoteDispatchDomainOpenGraphicsFd(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
int rv = -1;
int fd = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if ((fd = virDomainOpenGraphicsFD(dom,
@@ -5129,13 +5010,10 @@ remoteDispatchDomainGetInterfaceParameters(virNetServerPtr server
ATTRIBUTE_UNUS
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -5147,7 +5025,7 @@ remoteDispatchDomainGetInterfaceParameters(virNetServerPtr server
ATTRIBUTE_UNUS
goto cleanup;
nparams = args->nparams;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetInterfaceParameters(dom, device, params, &nparams, flags) <
0)
@@ -5187,16 +5065,13 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
remote_domain_get_cpu_stats_ret *ret)
{
virDomainPtr dom = NULL;
- struct daemonClientPrivate *priv;
virTypedParameterPtr params = NULL;
int rv = -1;
int percpu_len = 0;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- priv = virNetServerClientGetPrivateData(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->nparams > REMOTE_NODE_CPU_STATS_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too
large"));
@@ -5211,7 +5086,7 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0)
goto cleanup;
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
percpu_len = virDomainGetCPUStats(dom, params, args->nparams,
@@ -5261,15 +5136,12 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
virDomainDiskErrorPtr errors = NULL;
int len = 0;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (args->maxerrors > REMOTE_DOMAIN_DISK_ERRORS_MAX) {
@@ -5321,15 +5193,12 @@ remoteDispatchNodeGetSevInfo(virNetServerPtr server
ATTRIBUTE_UNUSED,
virTypedParameterPtr params = NULL;
int nparams = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (virNodeGetSEVInfo(priv->conn, ¶ms, &nparams, args->flags) <
0)
+ if (virNodeGetSEVInfo(conn, ¶ms, &nparams, args->flags) < 0)
goto cleanup;
if (nparams > REMOTE_NODE_SEV_INFO_MAX) {
@@ -5366,13 +5235,10 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
int nparams = 0;
unsigned int flags;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
@@ -5384,7 +5250,7 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
nparams = args->nparams;
- if (virNodeGetMemoryParameters(priv->conn, params, &nparams, flags) < 0)
+ if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0)
goto cleanup;
/* In this case, we need to send back the number of parameters
@@ -5424,17 +5290,14 @@ remoteDispatchNodeGetCPUMap(virNetServerPtr server
ATTRIBUTE_UNUSED,
unsigned int flags;
int cpunum;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
flags = args->flags;
- cpunum = virNodeGetCPUMap(priv->conn, args->need_map ? &cpumap : NULL,
+ cpunum = virNodeGetCPUMap(conn, args->need_map ? &cpumap : NULL,
args->need_online ? &online : NULL, flags);
if (cpunum < 0)
goto cleanup;
@@ -5466,19 +5329,16 @@ lxcDispatchDomainOpenNamespace(virNetServerPtr server
ATTRIBUTE_UNUSED,
lxc_domain_open_namespace_args *args)
{
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
int *fdlist = NULL;
int ret;
virDomainPtr dom = NULL;
size_t i;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
ret = virDomainLxcOpenNamespace(dom,
@@ -5520,15 +5380,12 @@ remoteDispatchDomainGetJobStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
virTypedParameterPtr params = NULL;
int nparams = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetJobStats(dom, &ret->type, ¶ms,
@@ -5573,13 +5430,10 @@ remoteDispatchDomainMigrateBegin3Params(virNetServerPtr server
ATTRIBUTE_UNUSED,
char *cookieout = NULL;
int cookieoutlen = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) {
virReportError(VIR_ERR_RPC,
@@ -5588,7 +5442,7 @@ remoteDispatchDomainMigrateBegin3Params(virNetServerPtr server
ATTRIBUTE_UNUSED,
goto cleanup;
}
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virTypedParamsDeserialize((virTypedParameterRemotePtr)
args->params.params_val,
@@ -5629,13 +5483,10 @@ remoteDispatchDomainMigratePrepare3Params(virNetServerPtr server
ATTRIBUTE_UNUSE
int cookieoutlen = 0;
char **uri_out;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) {
virReportError(VIR_ERR_RPC,
@@ -5653,7 +5504,7 @@ remoteDispatchDomainMigratePrepare3Params(virNetServerPtr server
ATTRIBUTE_UNUSE
if (VIR_ALLOC(uri_out) < 0)
goto cleanup;
- if (virDomainMigratePrepare3Params(priv->conn, params, nparams,
+ if (virDomainMigratePrepare3Params(conn, params, nparams,
args->cookie_in.cookie_in_val,
args->cookie_in.cookie_in_len,
&cookieout, &cookieoutlen,
@@ -5688,15 +5539,12 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virNetServerPtr
server ATTRIBUTE
char *cookieout = NULL;
int cookieoutlen = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
virStreamPtr st = NULL;
daemonClientStreamPtr stream = NULL;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) {
virReportError(VIR_ERR_RPC,
@@ -5710,12 +5558,12 @@ remoteDispatchDomainMigratePrepareTunnel3Params(virNetServerPtr
server ATTRIBUTE
0, ¶ms, &nparams) < 0)
goto cleanup;
- if (!(st = virStreamNew(priv->conn, VIR_STREAM_NONBLOCK)) ||
+ if (!(st = virStreamNew(conn, VIR_STREAM_NONBLOCK)) ||
!(stream = daemonCreateClientStream(client, st, remoteProgram,
&msg->header, false)))
goto cleanup;
- if (virDomainMigratePrepareTunnel3Params(priv->conn, st, params, nparams,
+ if (virDomainMigratePrepareTunnel3Params(conn, st, params, nparams,
args->cookie_in.cookie_in_val,
args->cookie_in.cookie_in_len,
&cookieout, &cookieoutlen,
@@ -5760,13 +5608,10 @@ remoteDispatchDomainMigratePerform3Params(virNetServerPtr server
ATTRIBUTE_UNUSE
int cookieoutlen = 0;
char *dconnuri;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) {
virReportError(VIR_ERR_RPC,
@@ -5775,7 +5620,7 @@ remoteDispatchDomainMigratePerform3Params(virNetServerPtr server
ATTRIBUTE_UNUSE
goto cleanup;
}
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virTypedParamsDeserialize((virTypedParameterRemotePtr)
args->params.params_val,
@@ -5820,13 +5665,10 @@ remoteDispatchDomainMigrateFinish3Params(virNetServerPtr server
ATTRIBUTE_UNUSED
char *cookieout = NULL;
int cookieoutlen = 0;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) {
virReportError(VIR_ERR_RPC,
@@ -5840,7 +5682,7 @@ remoteDispatchDomainMigrateFinish3Params(virNetServerPtr server
ATTRIBUTE_UNUSED
0, ¶ms, &nparams) < 0)
goto cleanup;
- dom = virDomainMigrateFinish3Params(priv->conn, params, nparams,
+ dom = virDomainMigrateFinish3Params(conn, params, nparams,
args->cookie_in.cookie_in_val,
args->cookie_in.cookie_in_len,
&cookieout, &cookieoutlen,
@@ -5878,13 +5720,10 @@ remoteDispatchDomainMigrateConfirm3Params(virNetServerPtr server
ATTRIBUTE_UNUSE
int nparams = 0;
virDomainPtr dom = NULL;
int rv = -1;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->params.params_len > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) {
virReportError(VIR_ERR_RPC,
@@ -5893,7 +5732,7 @@ remoteDispatchDomainMigrateConfirm3Params(virNetServerPtr server
ATTRIBUTE_UNUSE
goto cleanup;
}
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virTypedParamsDeserialize((virTypedParameterRemotePtr)
args->params.params_val,
@@ -5928,15 +5767,12 @@ remoteDispatchConnectGetCPUModelNames(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int len, rv = -1;
char **models = NULL;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- len = virConnectGetCPUModelNames(priv->conn, args->arch,
+ len = virConnectGetCPUModelNames(conn, args->arch,
args->need_results ? &models : NULL,
args->flags);
if (len < 0)
@@ -5980,16 +5816,13 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
virDomainPtr dom = NULL;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
int *files = NULL;
unsigned int nfiles = 0;
size_t i;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (VIR_ALLOC_N(files, msg->nfds) < 0)
goto cleanup;
@@ -5999,7 +5832,7 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPtr server
ATTRIBUTE_UNUSED,
nfiles++;
}
- if ((dom = virDomainCreateXMLWithFiles(priv->conn, args->xml_desc,
+ if ((dom = virDomainCreateXMLWithFiles(conn, args->xml_desc,
nfiles, files,
args->flags)) == NULL)
goto cleanup;
@@ -6029,16 +5862,13 @@ static int remoteDispatchDomainCreateWithFiles(virNetServerPtr
server ATTRIBUTE_
{
int rv = -1;
virDomainPtr dom = NULL;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
int *files = NULL;
unsigned int nfiles = 0;
size_t i;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (VIR_ALLOC_N(files, msg->nfds) < 0)
goto cleanup;
@@ -6048,7 +5878,7 @@ static int remoteDispatchDomainCreateWithFiles(virNetServerPtr
server ATTRIBUTE_
nfiles++;
}
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainCreateWithFiles(dom,
@@ -6084,19 +5914,18 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr
server ATTRIBUTE_UN
int rv = -1;
daemonClientEventCallbackPtr callback = NULL;
daemonClientEventCallbackPtr ref;
+ virNetworkPtr net = NULL;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
- virNetworkPtr net = NULL;
-
- if (!priv->networkConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetNetworkConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
if (args->net &&
- !(net = get_nonnull_network(priv->networkConn, *args->net)))
+ !(net = get_nonnull_network(conn, *args->net)))
goto cleanup;
if (args->eventID >= VIR_NETWORK_EVENT_ID_LAST || args->eventID < 0) {
@@ -6122,7 +5951,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server
ATTRIBUTE_UN
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectNetworkEventRegisterAny(priv->networkConn,
+ if ((callbackID = virConnectNetworkEventRegisterAny(conn,
net,
args->eventID,
networkEventCallbacks[args->eventID],
@@ -6160,14 +5989,13 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr
server ATTRIBUTE_
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->networkConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetNetworkConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->nnetworkEventCallbacks; i++) {
if (priv->networkEventCallbacks[i]->callbackID == args->callbackID)
break;
@@ -6179,7 +6007,7 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr
server ATTRIBUTE_
goto cleanup;
}
- if (virConnectNetworkEventDeregisterAny(priv->networkConn, args->callbackID)
< 0)
+ if (virConnectNetworkEventDeregisterAny(conn, args->callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->networkEventCallbacks, i,
@@ -6209,16 +6037,15 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr
server ATTRIBUT
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
virStoragePoolPtr pool = NULL;
-
- if (!priv->storageConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetStorageConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
if (args->pool &&
- !(pool = get_nonnull_storage_pool(priv->storageConn, *args->pool)))
+ !(pool = get_nonnull_storage_pool(conn, *args->pool)))
goto cleanup;
if (args->eventID >= VIR_STORAGE_POOL_EVENT_ID_LAST || args->eventID < 0)
{
@@ -6244,7 +6071,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr
server ATTRIBUT
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectStoragePoolEventRegisterAny(priv->storageConn,
+ if ((callbackID = virConnectStoragePoolEventRegisterAny(conn,
pool,
args->eventID,
storageEventCallbacks[args->eventID],
@@ -6281,14 +6108,13 @@ remoteDispatchConnectStoragePoolEventDeregisterAny(virNetServerPtr
server ATTRIB
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->storageConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetStorageConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->nstorageEventCallbacks; i++) {
if (priv->storageEventCallbacks[i]->callbackID == args->callbackID)
break;
@@ -6300,7 +6126,7 @@ remoteDispatchConnectStoragePoolEventDeregisterAny(virNetServerPtr
server ATTRIB
goto cleanup;
}
- if (virConnectStoragePoolEventDeregisterAny(priv->storageConn,
args->callbackID) < 0)
+ if (virConnectStoragePoolEventDeregisterAny(conn, args->callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->storageEventCallbacks, i,
@@ -6330,16 +6156,15 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr
server ATTRIBUTE
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
virNodeDevicePtr dev = NULL;
-
- if (!priv->nodedevConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetNodeDevConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
if (args->dev &&
- !(dev = get_nonnull_node_device(priv->nodedevConn, *args->dev)))
+ !(dev = get_nonnull_node_device(conn, *args->dev)))
goto cleanup;
if (args->eventID >= VIR_NODE_DEVICE_EVENT_ID_LAST || args->eventID < 0)
{
@@ -6365,7 +6190,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr
server ATTRIBUTE
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectNodeDeviceEventRegisterAny(priv->nodedevConn,
+ if ((callbackID = virConnectNodeDeviceEventRegisterAny(conn,
dev,
args->eventID,
nodeDeviceEventCallbacks[args->eventID],
@@ -6402,14 +6227,13 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(virNetServerPtr
server ATTRIBU
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->nodedevConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetNodeDevConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->nnodeDeviceEventCallbacks; i++) {
if (priv->nodeDeviceEventCallbacks[i]->callbackID == args->callbackID)
break;
@@ -6421,7 +6245,7 @@ remoteDispatchConnectNodeDeviceEventDeregisterAny(virNetServerPtr
server ATTRIBU
goto cleanup;
}
- if (virConnectNodeDeviceEventDeregisterAny(priv->nodedevConn, args->callbackID)
< 0)
+ if (virConnectNodeDeviceEventDeregisterAny(conn, args->callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->nodeDeviceEventCallbacks, i,
@@ -6451,16 +6275,15 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server
ATTRIBUTE_UNU
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
virSecretPtr secret = NULL;
-
- if (!priv->secretConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetSecretConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
if (args->secret &&
- !(secret = get_nonnull_secret(priv->secretConn, *args->secret)))
+ !(secret = get_nonnull_secret(conn, *args->secret)))
goto cleanup;
if (args->eventID >= VIR_SECRET_EVENT_ID_LAST || args->eventID < 0) {
@@ -6486,7 +6309,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server
ATTRIBUTE_UNU
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectSecretEventRegisterAny(priv->secretConn,
+ if ((callbackID = virConnectSecretEventRegisterAny(conn,
secret,
args->eventID,
secretEventCallbacks[args->eventID],
@@ -6523,14 +6346,13 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr
server ATTRIBUTE_U
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->secretConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetSecretConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->nsecretEventCallbacks; i++) {
if (priv->secretEventCallbacks[i]->callbackID == args->callbackID)
break;
@@ -6542,7 +6364,7 @@ remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr server
ATTRIBUTE_U
goto cleanup;
}
- if (virConnectSecretEventDeregisterAny(priv->secretConn, args->callbackID) <
0)
+ if (virConnectSecretEventDeregisterAny(conn, args->callbackID) < 0)
goto cleanup;
VIR_DELETE_ELEMENT(priv->secretEventCallbacks, i,
@@ -6573,16 +6395,15 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr
server ATTRIBUTE_U
virNetServerClientGetPrivateData(client);
virDomainPtr dom = NULL;
const char *event = args->event ? *args->event : NULL;
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
if (args->dom &&
- !(dom = get_nonnull_domain(priv->conn, *args->dom)))
+ !(dom = get_nonnull_domain(conn, *args->dom)))
goto cleanup;
/* If we call register first, we could append a complete callback
@@ -6602,7 +6423,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr server
ATTRIBUTE_U
callback) < 0)
goto cleanup;
- if ((callbackID = virConnectDomainQemuMonitorEventRegister(priv->conn,
+ if ((callbackID = virConnectDomainQemuMonitorEventRegister(conn,
dom,
event,
remoteRelayDomainQemuMonitorEvent,
@@ -6641,14 +6462,13 @@ qemuDispatchConnectDomainMonitorEventDeregister(virNetServerPtr
server ATTRIBUTE
size_t i;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
-
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
- goto cleanup;
- }
+ virConnectPtr conn = remoteGetHypervisorConn(client);
virMutexLock(&priv->lock);
+ if (!conn)
+ goto cleanup;
+
for (i = 0; i < priv->nqemuEventCallbacks; i++) {
if (priv->qemuEventCallbacks[i]->callbackID == args->callbackID)
break;
@@ -6660,7 +6480,7 @@ qemuDispatchConnectDomainMonitorEventDeregister(virNetServerPtr
server ATTRIBUTE
goto cleanup;
}
- if (virConnectDomainQemuMonitorEventDeregister(priv->conn,
+ if (virConnectDomainQemuMonitorEventDeregister(conn,
args->callbackID) < 0)
goto cleanup;
@@ -6688,15 +6508,12 @@ remoteDispatchDomainGetTime(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
long long seconds;
unsigned int nseconds;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if (virDomainGetTime(dom, &seconds, &nseconds, args->flags) < 0)
@@ -6724,13 +6541,10 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
int len;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->pages.pages_len * args->cellCount > REMOTE_NODE_MAX_CELLS) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -6743,7 +6557,7 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server
ATTRIBUTE_UNUSED,
args->pages.pages_len * args->cellCount) < 0)
goto cleanup;
- if ((len = virNodeGetFreePages(priv->conn,
+ if ((len = virNodeGetFreePages(conn,
args->pages.pages_len,
args->pages.pages_val,
args->startCell,
@@ -6837,17 +6651,15 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
size_t i;
- struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
virNetworkDHCPLeasePtr *leases = NULL;
virNetworkPtr net = NULL;
int nleases = 0;
+ virConnectPtr conn = remoteGetNetworkConn(client);
- if (!priv->networkConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(net = get_nonnull_network(priv->networkConn, args->net)))
+ if (!(net = get_nonnull_network(conn, args->net)))
goto cleanup;
if ((nleases = virNetworkGetDHCPLeases(net,
@@ -6905,22 +6717,20 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
size_t i;
- struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
virDomainStatsRecordPtr *retStats = NULL;
int nrecords = 0;
virDomainPtr *doms = NULL;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
if (args->doms.doms_len) {
if (VIR_ALLOC_N(doms, args->doms.doms_len + 1) < 0)
goto cleanup;
for (i = 0; i < args->doms.doms_len; i++) {
- if (!(doms[i] = get_nonnull_domain(priv->conn,
args->doms.doms_val[i])))
+ if (!(doms[i] = get_nonnull_domain(conn, args->doms.doms_val[i])))
goto cleanup;
}
@@ -6930,7 +6740,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPtr server
ATTRIBUTE_UNUSED,
args->flags)) < 0)
goto cleanup;
} else {
- if ((nrecords = virConnectGetAllDomainStats(priv->conn,
+ if ((nrecords = virConnectGetAllDomainStats(conn,
args->stats,
&retStats,
args->flags)) < 0)
@@ -6992,15 +6802,12 @@ remoteDispatchNodeAllocPages(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
int len;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if ((len = virNodeAllocPages(priv->conn,
+ if ((len = virNodeAllocPages(conn,
args->pageSizes.pageSizes_len,
args->pageSizes.pageSizes_val,
(unsigned long long *)
args->pageCounts.pageCounts_val,
@@ -7029,19 +6836,17 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server
ATTRIBUTE_UNUSED,
{
int rv = -1;
size_t i, j;
- struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
virDomainFSInfoPtr *info = NULL;
virDomainPtr dom = NULL;
remote_domain_fsinfo *dst;
int ninfo = 0;
size_t ndisk;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if ((ninfo = virDomainGetFSInfo(dom, &info, args->flags)) < 0)
@@ -7226,15 +7031,12 @@ remoteDispatchDomainInterfaceAddresses(virNetServerPtr server
ATTRIBUTE_UNUSED,
virDomainPtr dom = NULL;
virDomainInterfacePtr *ifaces = NULL;
int ifaces_count = 0;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetHypervisorConn(client);
- if (!priv->conn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
goto cleanup;
if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, args->source,
args->flags)) < 0)
@@ -7272,15 +7074,12 @@ remoteDispatchStorageVolGetInfoFlags(virNetServerPtr server
ATTRIBUTE_UNUSED,
int rv = -1;
virStorageVolPtr vol = NULL;
virStorageVolInfo tmp;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetStorageConn(client);
- if (!priv->storageConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(vol = get_nonnull_storage_vol(priv->storageConn, args->vol)))
+ if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
goto cleanup;
if (virStorageVolGetInfoFlags(vol, &tmp, args->flags) < 0)
@@ -7311,15 +7110,12 @@ remoteDispatchNetworkPortGetParameters(virNetServerPtr server
ATTRIBUTE_UNUSED,
virNetworkPortPtr port = NULL;
virTypedParameterPtr params = NULL;
int nparams = 0;
- struct daemonClientPrivate *priv =
- virNetServerClientGetPrivateData(client);
+ virConnectPtr conn = remoteGetNetworkConn(client);
- if (!priv->networkConn) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ if (!conn)
goto cleanup;
- }
- if (!(port = get_nonnull_network_port(priv->networkConn, args->port)))
+ if (!(port = get_nonnull_network_port(conn, args->port)))
goto cleanup;
if (virNetworkPortGetParameters(port, ¶ms, &nparams, args->flags) <
0)
--
2.21.0