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

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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               |  125 +++++++++++++++++++++++++++--------------
 src/libvirt_private.syms      |    1 +
 src/remote/remote_protocol.x  |    2 +-
 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 +-
 8 files changed, 143 insertions(+), 55 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 9d70163..f0dd63f 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -586,7 +586,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)
 {
@@ -633,7 +633,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);
@@ -644,7 +644,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)
@@ -819,7 +819,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)
@@ -872,7 +872,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)
@@ -926,7 +926,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)
@@ -988,7 +988,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)
@@ -1045,7 +1045,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)
@@ -1116,7 +1116,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)
@@ -1171,7 +1171,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)
@@ -1220,7 +1220,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)
 {
@@ -1263,7 +1263,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)
@@ -1333,7 +1333,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)
@@ -1418,7 +1418,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)
@@ -1475,7 +1475,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)
@@ -1527,7 +1527,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)
@@ -1590,7 +1590,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)
@@ -1653,7 +1653,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)
@@ -1731,7 +1731,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)
@@ -1809,7 +1809,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)
@@ -1853,7 +1853,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)
 {
@@ -1923,7 +1923,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)
 {
@@ -2047,7 +2047,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)
@@ -2145,7 +2145,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)
@@ -2242,7 +2242,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)
 {
@@ -2255,7 +2255,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)
@@ -2269,7 +2269,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)
@@ -2288,7 +2288,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)
 {
@@ -2388,7 +2388,7 @@ authdeny:
 static int
 remoteDispatchAuthPolkit(virNetServerPtr server,
                          virNetServerClientPtr client,
-                         virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                         virNetMessagePtr msg ATTRIBUTE_UNUSED,
                          virNetMessageErrorPtr rerr,
                          remote_auth_polkit_ret *ret)
 {
@@ -2527,7 +2527,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)
 {
@@ -2547,7 +2547,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)
@@ -2602,7 +2602,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)
 {
@@ -2644,7 +2644,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)
 {
@@ -2718,7 +2718,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)
@@ -2757,7 +2757,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)
@@ -2791,7 +2791,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)
 {
@@ -2840,7 +2840,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)
 {
@@ -2885,7 +2885,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)
@@ -2921,7 +2921,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)
@@ -2973,7 +2973,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)
@@ -3031,7 +3031,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)
@@ -3087,7 +3087,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)
@@ -3141,7 +3141,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)
 {
@@ -3175,6 +3175,45 @@ cleanup:
 }
 
 
+static int remoteDispatchSupportsFeature(
+    virNetServerPtr server ATTRIBUTE_UNUSED,
+    virNetServerClientPtr client,
+    virNetMessagePtr msg ATTRIBUTE_UNUSED,
+    virNetMessageErrorPtr rerr,
+    remote_supports_feature_args *args,
+    remote_supports_feature_ret *ret)
+{
+    int rv = -1;
+    int supported;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    switch (args->feature) {
+    case VIR_DRV_FEATURE_FD_PASSING:
+        supported = 1;
+        break;
+
+    default:
+        if ((supported = virDrvSupportsFeature(priv->conn, args->feature)) < 0)
+            goto cleanup;
+        break;
+    }
+
+    ret->supported = supported;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    return rv;
+}
+
+
 /*----- Helpers. -----*/
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 94520eb..9e4a669 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1190,6 +1190,7 @@ virNetClientHasPassFD;
 # virnetmessage.h
 virNetMessageClear;
 virNetMessageDecodeNumFDs;
+virNetMessageDupFD;
 virNetMessageEncodeHeader;
 virNetMessageEncodePayload;
 virNetMessageEncodeNumFDs;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d135653..47b8957 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2348,7 +2348,7 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS = 57, /* skipgen autogen */
     REMOTE_PROC_DOMAIN_SET_SCHEDULER_PARAMETERS = 58, /* autogen autogen */
     REMOTE_PROC_GET_HOSTNAME = 59, /* autogen autogen priority:high */
-    REMOTE_PROC_SUPPORTS_FEATURE = 60, /* autogen autogen priority:high */
+    REMOTE_PROC_SUPPORTS_FEATURE = 60, /* skipgen autogen priority:high */
 
     REMOTE_PROC_DOMAIN_MIGRATE_PREPARE = 61, /* skipgen skipgen */
     REMOTE_PROC_DOMAIN_MIGRATE_PERFORM = 62, /* autogen autogen */
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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]