On Fri, Nov 01, 2019 at 06:35:48PM +0100, Marc Hartmayer wrote: > Use virNetServerGetProgram() to determine the virNetServerProgram > instead of using hard coded global variables. This allows us to remove > the global variables @remoteProgram and @qemuProgram as they're now no > longer necessary. > > Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx> > --- > src/libvirt_remote.syms | 1 + > src/remote/remote_daemon.c | 4 +- > src/remote/remote_daemon.h | 2 - > src/remote/remote_daemon_dispatch.c | 118 +++++++++++++++++++++------- > src/rpc/gendispatch.pl | 6 ++ > src/rpc/virnetserver.c | 22 ++++++ > src/rpc/virnetserver.h | 2 + > 7 files changed, 122 insertions(+), 33 deletions(-) > > diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms > index 0493467f4603..a6883f373608 100644 > --- a/src/libvirt_remote.syms > +++ b/src/libvirt_remote.syms > @@ -124,6 +124,7 @@ virNetServerGetCurrentUnauthClients; > virNetServerGetMaxClients; > virNetServerGetMaxUnauthClients; > virNetServerGetName; > +virNetServerGetProgram; > virNetServerGetThreadPoolParameters; > virNetServerHasClients; > virNetServerNeedsAuth; > diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c > index 7e63e180344d..c8ac224d52e9 100644 > --- a/src/remote/remote_daemon.c > +++ b/src/remote/remote_daemon.c > @@ -73,8 +73,6 @@ VIR_LOG_INIT("daemon." DAEMON_NAME); > #if WITH_SASL > virNetSASLContextPtr saslCtxt = NULL; > #endif > -virNetServerProgramPtr remoteProgram = NULL; > -virNetServerProgramPtr qemuProgram = NULL; > > volatile bool driversInitialized = false; > > @@ -1007,6 +1005,8 @@ int main(int argc, char **argv) { > virNetServerPtr srv = NULL; > virNetServerPtr srvAdm = NULL; > virNetServerProgramPtr adminProgram = NULL; > + virNetServerProgramPtr qemuProgram = NULL; > + virNetServerProgramPtr remoteProgram = NULL; > virNetServerProgramPtr lxcProgram = NULL; > char *remote_config_file = NULL; > int statuswrite = -1; > diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h > index a2d9af403619..a3d6a220f868 100644 > --- a/src/remote/remote_daemon.h > +++ b/src/remote/remote_daemon.h > @@ -97,5 +97,3 @@ struct daemonClientPrivate { > #if WITH_SASL > extern virNetSASLContextPtr saslCtxt; > #endif > -extern virNetServerProgramPtr remoteProgram; > -extern virNetServerProgramPtr qemuProgram; > diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c > index 70f1f7d815e8..8756bd1a222d 100644 > --- a/src/remote/remote_daemon_dispatch.c > +++ b/src/remote/remote_daemon_dispatch.c > @@ -4170,9 +4170,9 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server G_GNUC_UNUSED, > } > > static int > -remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server G_GNUC_UNUSED, > +remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server, > virNetServerClientPtr client, > - virNetMessagePtr msg G_GNUC_UNUSED, > + virNetMessagePtr msg, > virNetMessageErrorPtr rerr) > { > int rv = -1; > @@ -4180,6 +4180,12 @@ remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server G_GNUC_UNUSED, > struct daemonClientPrivate *priv = > virNetServerClientGetPrivateData(client); > virConnectPtr conn = remoteGetHypervisorConn(client); > + virNetServerProgramPtr program; > + > + if (!(program = virNetServerGetProgram(server, msg))) { > + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no matching program found")); > + goto cleanup; > + } This doesn't look right. If the function fails we will jump to cleanup where we will try to unlock &priv->lock. This has to happen after we acquire that lock. Pavel
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list