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

[libvirt] [PATCH 07/22] remote generator, daemon: Handle functions with optional arguments



---
 daemon/remote.c                 |  130 -------------------------------------
 daemon/remote_dispatch_bodies.c |  136 +++++++++++++++++++++++++++++++++++++-
 daemon/remote_generator.pl      |   21 +++++--
 3 files changed, 148 insertions(+), 139 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 2b0e0dc..0c7173a 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -494,35 +494,6 @@ cleanup:
 }
 
 static int
-remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
-                          struct qemud_client *client ATTRIBUTE_UNUSED,
-                          virConnectPtr conn,
-                          remote_message_header *hdr ATTRIBUTE_UNUSED,
-                          remote_error *rerr,
-                          remote_get_max_vcpus_args *args,
-                          remote_get_max_vcpus_ret *ret)
-{
-    char *type;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    type = args->type ? *args->type : NULL;
-    if ((ret->max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
 remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
                           struct qemud_client *client ATTRIBUTE_UNUSED,
                           virConnectPtr conn,
@@ -1358,46 +1329,6 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                   struct qemud_client *client ATTRIBUTE_UNUSED,
-                                   virConnectPtr conn,
-                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                   remote_error *rerr,
-                                   remote_domain_migrate_perform_args *args,
-                                   void *ret ATTRIBUTE_UNUSED)
-{
-    virDomainPtr dom = NULL;
-    char *dname;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
-        goto cleanup;
-
-    dname = args->dname == NULL ? NULL : *args->dname;
-
-    if (virDomainMigratePerform(dom,
-                                args->cookie.cookie_val,
-                                args->cookie.cookie_len,
-                                args->uri,
-                                args->flags, dname, args->resource) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
 remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED,
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
                                     virConnectPtr conn,
@@ -3134,37 +3065,6 @@ cleanup:
 }
 
 static int
-remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                     struct qemud_client *client ATTRIBUTE_UNUSED,
-                                     virConnectPtr conn,
-                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                     remote_error *rerr,
-                                     remote_find_storage_pool_sources_args *args,
-                                     remote_find_storage_pool_sources_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(ret->xml =
-          virConnectFindStoragePoolSources(conn,
-                                           args->type,
-                                           args->srcSpec ? *args->srcSpec : NULL,
-                                           args->flags)))
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
 remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
                                  virConnectPtr conn,
@@ -3302,36 +3202,6 @@ cleanup:
  **************************************************************/
 
 static int
-remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
-                               struct qemud_client *client ATTRIBUTE_UNUSED,
-                               virConnectPtr conn,
-                               remote_message_header *hdr ATTRIBUTE_UNUSED,
-                               remote_error *rerr,
-                               remote_node_num_of_devices_args *args,
-                               remote_node_num_of_devices_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virNodeNumOfDevices(conn,
-                                        args->cap ? *args->cap : NULL,
-                                        args->flags)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-
-static int
 remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
                               struct qemud_client *client ATTRIBUTE_UNUSED,
                               virConnectPtr conn,
diff --git a/daemon/remote_dispatch_bodies.c b/daemon/remote_dispatch_bodies.c
index bd7cddd..77b7db4 100644
--- a/daemon/remote_dispatch_bodies.c
+++ b/daemon/remote_dispatch_bodies.c
@@ -1016,7 +1016,42 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainMigratePerform has to be implemented manually */
+static int
+remoteDispatchDomainMigratePerform(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_domain_migrate_perform_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virDomainPtr dom = NULL;
+    char *dname;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    dname = args->dname ? *args->dname : NULL;
+
+    if (virDomainMigratePerform(dom, args->cookie.cookie_val, args->cookie.cookie_len, args->uri, args->flags, dname, args->resource) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
 
 /* remoteDispatchDomainMigratePrepare has to be implemented manually */
 
@@ -1906,7 +1941,38 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchFindStoragePoolSources has to be implemented manually */
+static int
+remoteDispatchFindStoragePoolSources(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_find_storage_pool_sources_args *args,
+    remote_find_storage_pool_sources_ret *ret)
+{
+    int rv = -1;
+    char *srcSpec;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    srcSpec = args->srcSpec ? *args->srcSpec : NULL;
+
+    if ((xml = virConnectFindStoragePoolSources(conn, args->type, srcSpec, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
 
 static int
 remoteDispatchGetCapabilities(
@@ -1998,7 +2064,38 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchGetMaxVcpus has to be implemented manually */
+static int
+remoteDispatchGetMaxVcpus(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_get_max_vcpus_args *args,
+    remote_get_max_vcpus_ret *ret)
+{
+    int rv = -1;
+    char *type;
+    int max_vcpus;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    type = args->type ? *args->type : NULL;
+
+    if ((max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
+        goto cleanup;
+
+    ret->max_vcpus = max_vcpus;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
 
 static int
 remoteDispatchGetSysinfo(
@@ -3170,7 +3267,38 @@ cleanup:
 
 /* remoteDispatchNodeListDevices has to be implemented manually */
 
-/* remoteDispatchNodeNumOfDevices has to be implemented manually */
+static int
+remoteDispatchNodeNumOfDevices(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_node_num_of_devices_args *args,
+    remote_node_num_of_devices_ret *ret)
+{
+    int rv = -1;
+    char *cap;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    cap = args->cap ? *args->cap : NULL;
+
+    if ((num = virNodeNumOfDevices(conn, cap, args->flags)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
 
 static int
 remoteDispatchNumOfDefinedDomains(
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index 1b83d52..b3cb9b5 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -241,7 +241,6 @@ elsif ($opt_b) {
         @ungeneratable = ("Close",
                           "DomainEventsDeregisterAny",
                           "DomainEventsRegisterAny",
-                          "DomainMigratePerform",
                           "DomainMigratePrepareTunnel",
                           "DomainOpenConsole",
                           "DomainPinVcpu",
@@ -280,8 +279,6 @@ elsif ($opt_b) {
                           "DomainMigratePrepare",
                           "DomainMigratePrepare2",
                           "DomainSnapshotListNames",
-                          "FindStoragePoolSources",
-                          "GetMaxVcpus",
                           "GetType",
                           "ListDefinedDomains",
                           "ListDefinedInterfaces",
@@ -299,7 +296,6 @@ elsif ($opt_b) {
                           "NodeGetInfo",
                           "NodeGetSecurityModel",
                           "NodeListDevices",
-                          "NodeNumOfDevices",
                           "SecretGetValue",
                           "StoragePoolGetInfo",
                           "StoragePoolListVolumes",
@@ -347,6 +343,7 @@ elsif ($opt_b) {
 
         my $has_node_device = 0;
         my @vars_list = ();
+        my @optionals_list = ();
         my @getters_list = ();
         my @args_list = ();
         my @ret_list = ();
@@ -469,6 +466,10 @@ elsif ($opt_b) {
 
                     if ($1 eq "remote_uuid") {
                         push(@args_list, "(unsigned char *) args->$2");
+                    } elsif ($1 eq "remote_string") {
+                        push(@vars_list, "char *$2");
+                        push(@optionals_list, "$2");
+                        push(@args_list, "$2");
                     } else {
                         push(@args_list, "args->$2");
                     }
@@ -618,6 +619,14 @@ elsif ($opt_b) {
             print "\n";
         }
 
+        foreach my $optional (@optionals_list) {
+            print "    $optional = args->$optional ? *args->$optional : NULL;\n";
+        }
+
+        if (@optionals_list) {
+            print "\n";
+        }
+
         if ($calls{$_}->{ret} eq "void") {
             print "    if (vir$calls{$_}->{ProcName}(";
             print join(', ', @args_list);
@@ -637,8 +646,10 @@ elsif ($opt_b) {
             }
 
             if ($calls{$_}->{ProcName} eq "GetSysinfo" or
+                $calls{$_}->{ProcName} eq "GetMaxVcpus" or
                 $calls{$_}->{ProcName} eq "DomainXMLFromNative" or
-                $calls{$_}->{ProcName} eq "DomainXMLToNative") {
+                $calls{$_}->{ProcName} eq "DomainXMLToNative" or
+                $calls{$_}->{ProcName} eq "FindStoragePoolSources") {
                 $prefix = "Connect"
             } elsif ($calls{$_}->{ProcName} eq "SupportsFeature") {
                 $prefix = "Drv"
-- 
1.7.0.4


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