[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 7/8] Extend RPC server to allow FD passing



From: "Daniel P. Berrange" <berrange redhat com>

The RPC server classes are extended to allow FDs to be received
from clients with calls. THere is not currently any way for a
procedure to pass FDs back to the client with replies

* daemon/remote.c, src/rpc/gendispatch.pl: Change virNetMessageHeaderPtr
  param to virNetMessagePtr in dispatcher impls
* src/rpc/virnetserver.c, src/rpc/virnetserverclient.c,
  src/rpc/virnetserverprogram.c, src/rpc/virnetserverprogram.h:
  Extend to support FD passing
---
 daemon/remote.c               |   86 ++++++++++++++++++++--------------------
 src/libvirt_private.syms      |    1 +
 src/rpc/gendispatch.pl        |   12 +++---
 src/rpc/virnetserver.c        |    3 +-
 src/rpc/virnetserverclient.c  |   24 +++++++++++
 src/rpc/virnetserverprogram.c |   29 ++++++++++++-
 src/rpc/virnetserverprogram.h |    2 +-
 7 files changed, 103 insertions(+), 54 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 550bed4..2507e91 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -535,7 +535,7 @@ int remoteClientInitHook(virNetServerPtr srv ATTRIBUTE_UNUSED,
 static int
 remoteDispatchOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
                    virNetServerClientPtr client,
-                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
                    virNetMessageErrorPtr rerr,
                    struct remote_open_args *args)
 {
@@ -582,7 +582,7 @@ cleanup:
 static int
 remoteDispatchClose(virNetServerPtr server ATTRIBUTE_UNUSED,
                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                     virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED)
 {
     virNetServerClientDelayedClose(client);
@@ -593,7 +593,7 @@ remoteDispatchClose(virNetServerPtr server ATTRIBUTE_UNUSED,
 static int
 remoteDispatchDomainGetSchedulerType(virNetServerPtr server ATTRIBUTE_UNUSED,
                                      virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                     virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                     virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                      virNetMessageErrorPtr rerr,
                                      remote_domain_get_scheduler_type_args *args,
                                      remote_domain_get_scheduler_type_ret *ret)
@@ -768,7 +768,7 @@ cleanup:
 static int
 remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
                                            virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                           virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                            virNetMessageErrorPtr rerr,
                                            remote_domain_get_scheduler_parameters_args *args,
                                            remote_domain_get_scheduler_parameters_ret *ret)
@@ -821,7 +821,7 @@ no_memory:
 static int
 remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
                                                 virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                                virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                                virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                                 virNetMessageErrorPtr rerr,
                                                 remote_domain_get_scheduler_parameters_flags_args *args,
                                                 remote_domain_get_scheduler_parameters_flags_ret *ret)
@@ -875,7 +875,7 @@ no_memory:
 static int
 remoteDispatchDomainMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
                                 virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                 virNetMessageErrorPtr rerr,
                                 remote_domain_memory_stats_args *args,
                                 remote_domain_memory_stats_ret *ret)
@@ -937,7 +937,7 @@ cleanup:
 static int
 remoteDispatchDomainBlockPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
                               virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                              virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                              virNetMessagePtr msg ATTRIBUTE_UNUSED,
                               virNetMessageErrorPtr rerr,
                               remote_domain_block_peek_args *args,
                               remote_domain_block_peek_ret *ret)
@@ -994,7 +994,7 @@ cleanup:
 static int
 remoteDispatchDomainBlockStatsFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                     virNetMessageErrorPtr rerr,
                                     remote_domain_block_stats_flags_args *args,
                                     remote_domain_block_stats_flags_ret *ret)
@@ -1065,7 +1065,7 @@ cleanup:
 static int
 remoteDispatchDomainMemoryPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
                                virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                               virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                               virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                virNetMessageErrorPtr rerr,
                                remote_domain_memory_peek_args *args,
                                remote_domain_memory_peek_ret *ret)
@@ -1120,7 +1120,7 @@ cleanup:
 static int
 remoteDispatchDomainGetSecurityLabel(virNetServerPtr server ATTRIBUTE_UNUSED,
                                      virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                     virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                     virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                      virNetMessageErrorPtr rerr,
                                      remote_domain_get_security_label_args *args,
                                      remote_domain_get_security_label_ret *ret)
@@ -1169,7 +1169,7 @@ cleanup:
 static int
 remoteDispatchNodeGetSecurityModel(virNetServerPtr server ATTRIBUTE_UNUSED,
                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                    virNetMessageErrorPtr rerr,
                                    remote_node_get_security_model_ret *ret)
 {
@@ -1212,7 +1212,7 @@ cleanup:
 static int
 remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                    virNetMessageErrorPtr rerr,
                                    remote_domain_get_vcpu_pin_info_args *args,
                                    remote_domain_get_vcpu_pin_info_ret *ret)
@@ -1282,7 +1282,7 @@ no_memory:
 static int
 remoteDispatchDomainGetVcpus(virNetServerPtr server ATTRIBUTE_UNUSED,
                              virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                             virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                             virNetMessagePtr msg ATTRIBUTE_UNUSED,
                              virNetMessageErrorPtr rerr,
                              remote_domain_get_vcpus_args *args,
                              remote_domain_get_vcpus_ret *ret)
@@ -1367,7 +1367,7 @@ no_memory:
 static int
 remoteDispatchDomainMigratePrepare(virNetServerPtr server ATTRIBUTE_UNUSED,
                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                    virNetMessageErrorPtr rerr,
                                    remote_domain_migrate_prepare_args *args,
                                    remote_domain_migrate_prepare_ret *ret)
@@ -1424,7 +1424,7 @@ cleanup:
 static int
 remoteDispatchDomainMigratePrepare2(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                     virNetMessageErrorPtr rerr,
                                     remote_domain_migrate_prepare2_args *args,
                                     remote_domain_migrate_prepare2_ret *ret)
@@ -1476,7 +1476,7 @@ cleanup:
 static int
 remoteDispatchDomainGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
                                         virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                        virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                        virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                         virNetMessageErrorPtr rerr,
                                         remote_domain_get_memory_parameters_args *args,
                                         remote_domain_get_memory_parameters_ret *ret)
@@ -1539,7 +1539,7 @@ cleanup:
 static int
 remoteDispatchDomainGetBlkioParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
                                        virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                       virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                       virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                        virNetMessageErrorPtr rerr,
                                        remote_domain_get_blkio_parameters_args *args,
                                        remote_domain_get_blkio_parameters_ret *ret)
@@ -1602,7 +1602,7 @@ cleanup:
 static int
 remoteDispatchNodeGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED,
                               virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                              virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                              virNetMessagePtr msg ATTRIBUTE_UNUSED,
                               virNetMessageErrorPtr rerr,
                               remote_node_get_cpu_stats_args *args,
                               remote_node_get_cpu_stats_ret *ret)
@@ -1680,7 +1680,7 @@ no_memory:
 static int
 remoteDispatchNodeGetMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
                                  virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                 virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                 virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                  virNetMessageErrorPtr rerr,
                                  remote_node_get_memory_stats_args *args,
                                  remote_node_get_memory_stats_ret *ret)
@@ -1758,7 +1758,7 @@ no_memory:
 static int
 remoteDispatchDomainGetBlockJobInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                     virNetMessageErrorPtr rerr,
                                     remote_domain_get_block_job_info_args *args,
                                     remote_domain_get_block_job_info_ret *ret)
@@ -1802,7 +1802,7 @@ cleanup:
 static int
 remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED,
                        virNetServerClientPtr client,
-                       virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                       virNetMessagePtr msg ATTRIBUTE_UNUSED,
                        virNetMessageErrorPtr rerr,
                        remote_auth_list_ret *ret)
 {
@@ -1872,7 +1872,7 @@ cleanup:
 static int
 remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED,
                            virNetServerClientPtr client,
-                           virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
                            virNetMessageErrorPtr rerr,
                            remote_auth_sasl_init_ret *ret)
 {
@@ -1996,7 +1996,7 @@ error:
 static int
 remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED,
                             virNetServerClientPtr client,
-                            virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                            virNetMessagePtr msg ATTRIBUTE_UNUSED,
                             virNetMessageErrorPtr rerr,
                             remote_auth_sasl_start_args *args,
                             remote_auth_sasl_start_ret *ret)
@@ -2094,7 +2094,7 @@ error:
 static int
 remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED,
                            virNetServerClientPtr client,
-                           virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
                            virNetMessageErrorPtr rerr,
                            remote_auth_sasl_step_args *args,
                            remote_auth_sasl_step_ret *ret)
@@ -2191,7 +2191,7 @@ error:
 static int
 remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED,
                            virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                           virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
                            virNetMessageErrorPtr rerr,
                            remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
 {
@@ -2204,7 +2204,7 @@ remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED,
 static int
 remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED,
                             virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                            virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                            virNetMessagePtr msg ATTRIBUTE_UNUSED,
                             virNetMessageErrorPtr rerr,
                             remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
                             remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
@@ -2218,7 +2218,7 @@ remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED,
 static int
 remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED,
                            virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                           virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
                            virNetMessageErrorPtr rerr,
                            remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
                            remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
@@ -2237,7 +2237,7 @@ remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED,
 static int
 remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
                          virNetServerClientPtr client,
-                         virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                         virNetMessagePtr msg ATTRIBUTE_UNUSED,
                          virNetMessageErrorPtr rerr,
                          remote_auth_polkit_ret *ret)
 {
@@ -2337,7 +2337,7 @@ authdeny:
 static int
 remoteDispatchAuthPolkit(virNetServerPtr server,
                          virNetServerClientPtr client,
-                         virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                         virNetMessagePtr msg ATTRIBUTE_UNUSED,
                          virNetMessageErrorPtr rerr,
                          remote_auth_polkit_ret *ret)
 {
@@ -2476,7 +2476,7 @@ authdeny:
 static int
 remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
                          virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                         virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                         virNetMessagePtr msg ATTRIBUTE_UNUSED,
                          virNetMessageErrorPtr rerr,
                          remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
 {
@@ -2496,7 +2496,7 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
 static int
 remoteDispatchNodeDeviceGetParent(virNetServerPtr server ATTRIBUTE_UNUSED,
                                   virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                  virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                  virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                   virNetMessageErrorPtr rerr,
                                   remote_node_device_get_parent_args *args,
                                   remote_node_device_get_parent_ret *ret)
@@ -2551,7 +2551,7 @@ cleanup:
 static int
 remoteDispatchDomainEventsRegister(virNetServerPtr server ATTRIBUTE_UNUSED,
                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                    virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
                                    remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
 {
@@ -2593,7 +2593,7 @@ cleanup:
 static int
 remoteDispatchDomainEventsDeregister(virNetServerPtr server ATTRIBUTE_UNUSED,
                                      virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                     virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                     virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                      virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
                                      remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
 {
@@ -2667,7 +2667,7 @@ cleanup:
 static int
 remoteDispatchSecretGetValue(virNetServerPtr server ATTRIBUTE_UNUSED,
                              virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                             virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                             virNetMessagePtr msg ATTRIBUTE_UNUSED,
                              virNetMessageErrorPtr rerr,
                              remote_secret_get_value_args *args,
                              remote_secret_get_value_ret *ret)
@@ -2706,7 +2706,7 @@ cleanup:
 static int
 remoteDispatchDomainGetState(virNetServerPtr server ATTRIBUTE_UNUSED,
                              virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                             virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                             virNetMessagePtr msg ATTRIBUTE_UNUSED,
                              virNetMessageErrorPtr rerr,
                              remote_domain_get_state_args *args,
                              remote_domain_get_state_ret *ret)
@@ -2740,7 +2740,7 @@ cleanup:
 static int
 remoteDispatchDomainEventsRegisterAny(virNetServerPtr server ATTRIBUTE_UNUSED,
                                       virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                      virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                      virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                       virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
                                       remote_domain_events_register_any_args *args)
 {
@@ -2789,7 +2789,7 @@ cleanup:
 static int
 remoteDispatchDomainEventsDeregisterAny(virNetServerPtr server ATTRIBUTE_UNUSED,
                                         virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                        virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                        virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                         virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
                                         remote_domain_events_deregister_any_args *args)
 {
@@ -2834,7 +2834,7 @@ cleanup:
 static int
 qemuDispatchMonitorCommand(virNetServerPtr server ATTRIBUTE_UNUSED,
                            virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                           virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
                            virNetMessageErrorPtr rerr,
                            qemu_monitor_command_args *args,
                            qemu_monitor_command_ret *ret)
@@ -2870,7 +2870,7 @@ cleanup:
 static int
 remoteDispatchDomainMigrateBegin3(virNetServerPtr server ATTRIBUTE_UNUSED,
                                   virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                  virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                  virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                   virNetMessageErrorPtr rerr,
                                   remote_domain_migrate_begin3_args *args,
                                   remote_domain_migrate_begin3_ret *ret)
@@ -2922,7 +2922,7 @@ cleanup:
 static int
 remoteDispatchDomainMigratePrepare3(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                     virNetMessageErrorPtr rerr,
                                     remote_domain_migrate_prepare3_args *args,
                                     remote_domain_migrate_prepare3_ret *ret)
@@ -2980,7 +2980,7 @@ cleanup:
 static int
 remoteDispatchDomainMigratePerform3(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                     virNetMessageErrorPtr rerr,
                                     remote_domain_migrate_perform3_args *args,
                                     remote_domain_migrate_perform3_ret *ret)
@@ -3036,7 +3036,7 @@ cleanup:
 static int
 remoteDispatchDomainMigrateFinish3(virNetServerPtr server ATTRIBUTE_UNUSED,
                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                    virNetMessageErrorPtr rerr,
                                    remote_domain_migrate_finish3_args *args,
                                    remote_domain_migrate_finish3_ret *ret)
@@ -3090,7 +3090,7 @@ cleanup:
 static int
 remoteDispatchDomainMigrateConfirm3(virNetServerPtr server ATTRIBUTE_UNUSED,
                                     virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                    virNetMessagePtr msg ATTRIBUTE_UNUSED,
                                     virNetMessageErrorPtr rerr,
                                     remote_domain_migrate_confirm3_args *args)
 {
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fd107e7..3411a2e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1184,6 +1184,7 @@ virNetMessageEncodeHeader;
 virNetMessageEncodePayload;
 virNetMessageEncodeNumFDs;
 virNetMessageDecodeNumFDs;
+virNetMessageDupFD;
 virNetMessageFree;
 virNetMessageNew;
 virNetMessageQueuePush;
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index b7ac3c8..56af258 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -298,7 +298,7 @@ elsif ($opt_b) {
 	print "static int ${name}(\n";
 	print "    virNetServerPtr server,\n";
 	print "    virNetServerClientPtr client,\n";
-	print "    virNetMessageHeaderPtr hdr,\n";
+	print "    virNetMessagePtr msg,\n";
 	print "    virNetMessageErrorPtr rerr";
 	if ($argtype ne "void") {
 	    print ",\n    $argtype *args";
@@ -315,13 +315,13 @@ elsif ($opt_b) {
 	print "static int ${name}Helper(\n";
 	print "    virNetServerPtr server,\n";
 	print "    virNetServerClientPtr client,\n";
-	print "    virNetMessageHeaderPtr hdr,\n";
+	print "    virNetMessagePtr msg,\n";
 	print "    virNetMessageErrorPtr rerr,\n";
 	print "    void *args$argann,\n";
 	print "    void *ret$retann)\n";
 	print "{\n";
-	print "  VIR_DEBUG(\"server=%p client=%p hdr=%p rerr=%p args=%p ret=%p\", server, client, hdr, rerr, args, ret);\n";
-	print "  return $name(server, client, hdr, rerr";
+	print "  VIR_DEBUG(\"server=%p client=%p msg=%p rerr=%p args=%p ret=%p\", server, client, msg, rerr, args, ret);\n";
+	print "  return $name(server, client, msg, rerr";
 	if ($argtype ne "void") {
 	    print ", args";
 	}
@@ -750,7 +750,7 @@ elsif ($opt_b) {
 	print "static int $name(\n";
 	print "    virNetServerPtr server ATTRIBUTE_UNUSED,\n";
 	print "    virNetServerClientPtr client,\n";
-	print "    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,\n";
+	print "    virNetMessagePtr msg ATTRIBUTE_UNUSED,\n";
 	print "    virNetMessageErrorPtr rerr";
         if ($argtype ne "void") {
 	    print ",\n    $argtype *args";
@@ -809,7 +809,7 @@ elsif ($opt_b) {
             print "    if (!(st = virStreamNew(priv->conn, VIR_STREAM_NONBLOCK)))\n";
             print "        goto cleanup;\n";
             print "\n";
-            print "    if (!(stream = daemonCreateClientStream(client, st, remoteProgram, hdr)))\n";
+            print "    if (!(stream = daemonCreateClientStream(client, st, remoteProgram, &msg->header)))\n";
             print "        goto cleanup;\n";
             print "\n";
         }
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index f739743..6533b5a 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -138,7 +138,8 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
          * message types are not expecting replies, so we
          * must just log it & drop them
          */
-        if (job->msg->header.type == VIR_NET_CALL) {
+        if (job->msg->header.type == VIR_NET_CALL ||
+            job->msg->header.type == VIR_NET_CALL_WITH_FDS) {
             if (virNetServerProgramUnknownError(job->client,
                                                 job->msg,
                                                 &job->msg->header) < 0)
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 05077d6..1256f0f 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -770,6 +770,7 @@ readmore:
         /* Grab the completed message */
         virNetMessagePtr msg = virNetMessageQueueServe(&client->rx);
         virNetServerClientFilterPtr filter;
+        size_t i;
 
         /* Decode the header so we can use it for routing decisions */
         if (virNetMessageDecodeHeader(msg) < 0) {
@@ -778,6 +779,20 @@ readmore:
             return;
         }
 
+        if (msg->header.type == VIR_NET_CALL_WITH_FDS &&
+            virNetMessageDecodeNumFDs(msg) < 0) {
+            virNetMessageFree(msg);
+            client->wantClose = true;
+            return;
+        }
+        for (i = 0 ; i < msg->nfds ; i++) {
+            if ((msg->fds[i] = virNetSocketRecvFD(client->sock)) < 0) {
+                virNetMessageFree(msg);
+                client->wantClose = true;
+                return;
+            }
+        }
+
         PROBE(RPC_SERVER_CLIENT_MSG_RX,
               "client=%p len=%zu prog=%u vers=%u proc=%u type=%u status=%u serial=%u",
               client, msg->bufferLength,
@@ -883,6 +898,15 @@ virNetServerClientDispatchWrite(virNetServerClientPtr client)
 
         if (client->tx->bufferOffset == client->tx->bufferLength) {
             virNetMessagePtr msg;
+            size_t i;
+
+            for (i = 0 ; i < client->tx->nfds ; i++) {
+                if (virNetSocketSendFD(client->sock, client->tx->fds[i]) < 0) {
+                    client->wantClose = true;
+                    return;
+                }
+            }
+
 #if HAVE_SASL
             /* Completed this 'tx' operation, so now read for all
              * future rx/tx to be under a SASL SSF layer
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 47b7ded..bbd2d65 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -29,6 +29,7 @@
 #include "memory.h"
 #include "virterror_internal.h"
 #include "logging.h"
+#include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 #define virNetError(code, ...)                                    \
@@ -284,6 +285,7 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
 
     switch (msg->header.type) {
     case VIR_NET_CALL:
+    case VIR_NET_CALL_WITH_FDS:
         ret = virNetServerProgramDispatchCall(prog, server, client, msg);
         break;
 
@@ -314,7 +316,8 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
     return ret;
 
 error:
-    if (msg->header.type == VIR_NET_CALL) {
+    if (msg->header.type == VIR_NET_CALL ||
+        msg->header.type == VIR_NET_CALL_WITH_FDS) {
         ret = virNetServerProgramSendReplyError(prog, client, msg, &rerr, &msg->header);
     } else {
         /* Send a dummy reply to free up 'msg' & unblock client rx */
@@ -355,6 +358,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
     int rv = -1;
     virNetServerProgramProcPtr dispatcher;
     virNetMessageError rerr;
+    size_t i;
 
     memset(&rerr, 0, sizeof(rerr));
 
@@ -409,7 +413,20 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
      *
      *   'args and 'ret'
      */
-    rv = (dispatcher->func)(server, client, &msg->header, &rerr, arg, ret);
+    rv = (dispatcher->func)(server, client, msg, &rerr, arg, ret);
+
+    /*
+     * Clear out the FDs we got from the client, we don't
+     * want to send them back !
+     *
+     * XXX we don't have a way to let dispatcher->func
+     * return any FDs. Fortunately we don't need this
+     * capability just yet
+     */
+    for (i = 0 ; i < msg->nfds ; i++)
+        VIR_FORCE_CLOSE(msg->fds[i]);
+    VIR_FREE(msg->fds);
+    msg->nfds = 0;
 
     xdr_free(dispatcher->arg_filter, arg);
 
@@ -421,7 +438,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
     /*msg->header.prog = msg->header.prog;*/
     /*msg->header.vers = msg->header.vers;*/
     /*msg->header.proc = msg->header.proc;*/
-    msg->header.type = VIR_NET_REPLY;
+    msg->header.type = msg->nfds ? VIR_NET_REPLY_WITH_FDS : VIR_NET_REPLY;
     /*msg->header.serial = msg->header.serial;*/
     msg->header.status = VIR_NET_OK;
 
@@ -430,6 +447,12 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
         goto error;
     }
 
+    if (msg->nfds &&
+        virNetMessageEncodeNumFDs(msg) < 0) {
+        xdr_free(dispatcher->ret_filter, ret);
+        goto error;
+    }
+
     if (virNetMessageEncodePayload(msg, dispatcher->ret_filter, ret) < 0) {
         xdr_free(dispatcher->ret_filter, ret);
         goto error;
diff --git a/src/rpc/virnetserverprogram.h b/src/rpc/virnetserverprogram.h
index 9dabf92..aa9f3cf 100644
--- a/src/rpc/virnetserverprogram.h
+++ b/src/rpc/virnetserverprogram.h
@@ -41,7 +41,7 @@ typedef virNetServerProgramProc *virNetServerProgramProcPtr;
 
 typedef int (*virNetServerProgramDispatchFunc)(virNetServerPtr server,
                                                virNetServerClientPtr client,
-                                               virNetMessageHeaderPtr hdr,
+                                               virNetMessagePtr msg,
                                                virNetMessageErrorPtr rerr,
                                                void *args,
                                                void *ret);
-- 
1.7.6.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]