mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
rpc: pass virNetServer to post-exec restart callback in typesafe manner
The virNetServer class is passing a pointer to itself to the virNetServerClient as a 'void *' pointer. This is presumably due to fact that the virnetserverclient.h file doesn't see the virNetServerPtr typedef. The typedef is easily movable though, which lets us get typesafe parameter passing, removing the confusion of passing two distinct 'void *' pointers to one method. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
2c76fa91d3
commit
b41780e47a
@ -540,12 +540,12 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(client = virNetServerClientNewPostExecRestart(child,
|
||||
if (!(client = virNetServerClientNewPostExecRestart(srv,
|
||||
child,
|
||||
clientPrivNewPostExecRestart,
|
||||
clientPrivPreExecRestart,
|
||||
clientPrivFree,
|
||||
clientPrivOpaque,
|
||||
srv)))
|
||||
clientPrivOpaque)))
|
||||
goto error;
|
||||
|
||||
if (virNetServerAddClient(srv, client) < 0) {
|
||||
|
@ -479,12 +479,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
|
||||
}
|
||||
|
||||
|
||||
virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr object,
|
||||
virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
|
||||
virJSONValuePtr object,
|
||||
virNetServerClientPrivNewPostExecRestart privNew,
|
||||
virNetServerClientPrivPreExecRestart privPreExecRestart,
|
||||
virFreeCallback privFree,
|
||||
void *privOpaque,
|
||||
void *opaque)
|
||||
void *privOpaque)
|
||||
{
|
||||
virJSONValuePtr child;
|
||||
virNetServerClientPtr client = NULL;
|
||||
@ -540,12 +540,12 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr objec
|
||||
|
||||
if (!virJSONValueObjectHasKey(object, "id")) {
|
||||
/* no ID found in, a new one must be generated */
|
||||
id = virNetServerNextClientID((virNetServerPtr) opaque);
|
||||
id = virNetServerNextClientID(srv);
|
||||
} else {
|
||||
if (virJSONValueObjectGetNumberUlong(object, "id", &id) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Malformed id field in JSON state document"));
|
||||
return NULL;
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Malformed id field in JSON state document"));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,9 @@
|
||||
# include "virobject.h"
|
||||
# include "virjson.h"
|
||||
|
||||
typedef struct _virNetServer virNetServer;
|
||||
typedef virNetServer *virNetServerPtr;
|
||||
|
||||
typedef struct _virNetServerClient virNetServerClient;
|
||||
typedef virNetServerClient *virNetServerClientPtr;
|
||||
|
||||
@ -71,12 +74,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
|
||||
virFreeCallback privFree,
|
||||
void *privOpaque);
|
||||
|
||||
virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr object,
|
||||
virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
|
||||
virJSONValuePtr object,
|
||||
virNetServerClientPrivNewPostExecRestart privNew,
|
||||
virNetServerClientPrivPreExecRestart privPreExecRestart,
|
||||
virFreeCallback privFree,
|
||||
void *privOpaque,
|
||||
void *opaque);
|
||||
void *privOpaque);
|
||||
|
||||
virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr client);
|
||||
|
||||
|
@ -31,9 +31,6 @@
|
||||
typedef struct _virNetDaemon virNetDaemon;
|
||||
typedef virNetDaemon *virNetDaemonPtr;
|
||||
|
||||
typedef struct _virNetServer virNetServer;
|
||||
typedef virNetServer *virNetServerPtr;
|
||||
|
||||
typedef struct _virNetServerService virNetServerService;
|
||||
typedef virNetServerService *virNetServerServicePtr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user