]> xenbits.xensource.com Git - libvirt.git/commitdiff
remote generator, daemon: Handle simple-return-value functions
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 22 Apr 2011 15:09:33 +0000 (17:09 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 6 May 2011 18:07:39 +0000 (20:07 +0200)
daemon/remote.c
daemon/remote_dispatch_bodies.c
daemon/remote_generator.pl

index 7a97f290420952eee076b4fd57c3d32fa468eb89..8de90e961e4154415153990eb6ec0f08e621b40d 100644 (file)
@@ -458,32 +458,6 @@ remoteDispatchClose(struct qemud_server *server ATTRIBUTE_UNUSED,
     return 0;
 }
 
-static int
-remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
-                              struct qemud_client *client ATTRIBUTE_UNUSED,
-                              virConnectPtr conn,
-                              remote_message_header *hdr ATTRIBUTE_UNUSED,
-                              remote_error *rerr,
-                              remote_supports_feature_args *args, remote_supports_feature_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->supported = virDrvSupportsFeature(conn, args->feature)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
 static int
 remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
                       struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -519,153 +493,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
-                         struct qemud_client *client ATTRIBUTE_UNUSED,
-                         virConnectPtr conn,
-                         remote_message_header *hdr ATTRIBUTE_UNUSED,
-                         remote_error *rerr,
-                         void *args ATTRIBUTE_UNUSED,
-                         remote_get_version_ret *ret)
-{
-    unsigned long hvVer;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (virConnectGetVersion(conn, &hvVer) < 0)
-        goto cleanup;
-
-    ret->hv_ver = hvVer;
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
-                            struct qemud_client *client ATTRIBUTE_UNUSED,
-                            virConnectPtr conn,
-                            remote_message_header *hdr ATTRIBUTE_UNUSED,
-                            remote_error *rerr,
-                            void *args ATTRIBUTE_UNUSED,
-                            remote_get_lib_version_ret *ret)
-{
-    unsigned long libVer;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (virConnectGetLibVersion(conn, &libVer) < 0)
-        goto cleanup;
-
-    ret->lib_ver = libVer;
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
-                          struct qemud_client *client ATTRIBUTE_UNUSED,
-                          virConnectPtr conn,
-                          remote_message_header *hdr ATTRIBUTE_UNUSED,
-                          remote_error *rerr,
-                          void *args ATTRIBUTE_UNUSED,
-                          remote_get_hostname_ret *ret)
-{
-    char *hostname;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(hostname = virConnectGetHostname(conn)))
-        goto cleanup;
-
-    ret->hostname = hostname;
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchGetURI(struct qemud_server *server ATTRIBUTE_UNUSED,
-                     struct qemud_client *client ATTRIBUTE_UNUSED,
-                     virConnectPtr conn,
-                     remote_message_header *hdr ATTRIBUTE_UNUSED,
-                     remote_error *rerr,
-                     void *args ATTRIBUTE_UNUSED,
-                     remote_get_uri_ret *ret)
-{
-    char *uri;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(uri = virConnectGetURI(conn)))
-        goto cleanup;
-
-    ret->uri = uri;
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchGetSysinfo(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_sysinfo_args *args,
-                         remote_get_sysinfo_ret *ret)
-{
-    unsigned int flags;
-    char *sysinfo;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    flags = args->flags;
-    if (!(sysinfo = virConnectGetSysinfo(conn, flags)))
-        goto cleanup;
-
-    ret->sysinfo = sysinfo;
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
 static int
 remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
                           struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -732,35 +559,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
-                              struct qemud_client *client ATTRIBUTE_UNUSED,
-                              virConnectPtr conn,
-                              remote_message_header *hdr ATTRIBUTE_UNUSED,
-                              remote_error *rerr,
-                              void *args ATTRIBUTE_UNUSED,
-                              remote_get_capabilities_ret *ret)
-{
-    char *caps;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(caps = virConnectGetCapabilities(conn)))
-        goto cleanup;
-
-    ret->capabilities = caps;
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
 static int
 remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -1386,15 +1184,16 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchDomainGetInfo(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_dump_xml_args *args,
-                            remote_domain_dump_xml_ret *ret)
+                            remote_domain_get_info_args *args,
+                            remote_domain_get_info_ret *ret)
 {
     virDomainPtr dom = NULL;
+    virDomainInfo info;
     int rv = -1;
 
     if (!conn) {
@@ -1405,10 +1204,15 @@ remoteDispatchDomainDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virDomainGetXMLDesc(dom, args->flags)))
+    if (virDomainGetInfo(dom, &info) < 0)
         goto cleanup;
 
+    ret->state = info.state;
+    ret->max_mem = info.maxMem;
+    ret->memory = info.memory;
+    ret->nr_virt_cpu = info.nrVirtCpu;
+    ret->cpu_time = info.cpuTime;
+
     rv = 0;
 
 cleanup:
@@ -1420,14 +1224,16 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainXMLFromNative(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_xml_from_native_args *args,
-                                  remote_domain_xml_from_native_ret *ret)
+remoteDispatchDomainGetSecurityLabel(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_get_security_label_args *args,
+                                     remote_domain_get_security_label_ret *ret)
 {
+    virDomainPtr dom = NULL;
+    virSecurityLabelPtr seclabel = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -1435,30 +1241,46 @@ remoteDispatchDomainXMLFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->domainXml = virConnectDomainXMLFromNative(conn,
-                                                         args->nativeFormat,
-                                                         args->nativeConfig,
-                                                         args->flags)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    if (VIR_ALLOC(seclabel) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (virDomainGetSecurityLabel(dom, seclabel) < 0)
+        goto cleanup;
+
+    ret->label.label_len = strlen(seclabel->label) + 1;
+    if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
+        virReportOOMError();
         goto cleanup;
+    }
+    strcpy(ret->label.label_val, seclabel->label);
+    ret->enforcing = seclabel->enforcing;
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    VIR_FREE(seclabel);
     return rv;
 }
 
 static int
-remoteDispatchDomainXMLToNative(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_xml_to_native_args *args,
-                                remote_domain_xml_to_native_ret *ret)
+remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr,
+                                   void *args ATTRIBUTE_UNUSED,
+                                   remote_node_get_security_model_ret *ret)
 {
+    virSecurityModel secmodel;
     int rv = -1;
 
     if (!conn) {
@@ -1466,12 +1288,23 @@ remoteDispatchDomainXMLToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->nativeConfig = virConnectDomainXMLToNative(conn,
-                                                          args->nativeFormat,
-                                                          args->domainXml,
-                                                          args->flags)))
+    memset(&secmodel, 0, sizeof secmodel);
+    if (virNodeGetSecurityModel(conn, &secmodel) < 0)
+        goto cleanup;
+
+    ret->model.model_len = strlen(secmodel.model) + 1;
+    if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+    strcpy(ret->model.model_val, secmodel.model);
+
+    ret->doi.doi_len = strlen(secmodel.doi) + 1;
+    if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
+        virReportOOMError();
         goto cleanup;
+    }
+    strcpy(ret->doi.doi_val, secmodel.doi);
 
     rv = 0;
 
@@ -1481,17 +1314,19 @@ cleanup:
     return rv;
 }
 
-
 static int
-remoteDispatchDomainGetAutostart(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_get_autostart_args *args,
-                                 remote_domain_get_autostart_ret *ret)
+remoteDispatchDomainGetVcpus(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_get_vcpus_args *args,
+                             remote_domain_get_vcpus_ret *ret)
 {
     virDomainPtr dom = NULL;
+    virVcpuInfoPtr info = NULL;
+    unsigned char *cpumaps = NULL;
+    int info_len, i;
     int rv = -1;
 
     if (!conn) {
@@ -1502,30 +1337,80 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainGetAutostart(dom, &ret->autostart) < 0)
+    if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
         goto cleanup;
+    }
 
-    rv = 0;
+    if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+        goto cleanup;
+    }
 
-cleanup:
-    if (rv < 0)
+    /* Allocate buffers to take the results. */
+    if (VIR_ALLOC_N(info, args->maxinfo) < 0)
+        goto no_memory;
+    if (args->maplen > 0 &&
+        VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
+        goto no_memory;
+
+    if ((info_len = virDomainGetVcpus(dom,
+                                      info, args->maxinfo,
+                                      cpumaps, args->maplen)) < 0)
+        goto cleanup;
+
+    /* Allocate the return buffer for info. */
+    ret->info.info_len = info_len;
+    if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
+        goto no_memory;
+
+    for (i = 0; i < info_len; ++i) {
+        ret->info.info_val[i].number = info[i].number;
+        ret->info.info_val[i].state = info[i].state;
+        ret->info.info_val[i].cpu_time = info[i].cpuTime;
+        ret->info.info_val[i].cpu = info[i].cpu;
+    }
+
+    /* Don't need to allocate/copy the cpumaps if we make the reasonable
+     * assumption that unsigned char and char are the same size.
+     * Note that remoteDispatchClientRequest will free.
+     */
+    ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
+    ret->cpumaps.cpumaps_val = (char *) cpumaps;
+    cpumaps = NULL;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0) {
         remoteDispatchError(rerr);
+        VIR_FREE(ret->info.info_val);
+    }
+    VIR_FREE(cpumaps);
+    VIR_FREE(info);
     if (dom)
         virDomainFree(dom);
     return rv;
+
+no_memory:
+    virReportOOMError();
+    goto cleanup;
 }
 
 static int
-remoteDispatchDomainGetInfo(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_get_info_args *args,
-                            remote_domain_get_info_ret *ret)
+remoteDispatchDomainMigratePrepare(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_prepare_args *args,
+                                   remote_domain_migrate_prepare_ret *ret)
 {
-    virDomainPtr dom = NULL;
-    virDomainInfo info;
+    char *cookie = NULL;
+    int cookielen = 0;
+    char *uri_in;
+    char **uri_out;
+    char *dname;
     int rv = -1;
 
     if (!conn) {
@@ -1533,38 +1418,52 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
+    dname = args->dname == NULL ? NULL : *args->dname;
+
+    /* Wacky world of XDR ... */
+    if (VIR_ALLOC(uri_out) < 0) {
+        virReportOOMError();
         goto cleanup;
+    }
 
-    if (virDomainGetInfo(dom, &info) < 0)
+    if (virDomainMigratePrepare(conn, &cookie, &cookielen,
+                                uri_in, uri_out,
+                                args->flags, dname, args->resource) < 0)
         goto cleanup;
 
-    ret->state = info.state;
-    ret->max_mem = info.maxMem;
-    ret->memory = info.memory;
-    ret->nr_virt_cpu = info.nrVirtCpu;
-    ret->cpu_time = info.cpuTime;
+    /* remoteDispatchClientRequest will free cookie, uri_out and
+     * the string if there is one.
+     */
+    ret->cookie.cookie_len = cookielen;
+    ret->cookie.cookie_val = cookie;
+    if (*uri_out == NULL) {
+        ret->uri_out = NULL;
+    } else {
+        ret->uri_out = uri_out;
+        uri_out = NULL;
+    }
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
+    VIR_FREE(uri_out);
     return rv;
 }
 
 static int
-remoteDispatchDomainGetMaxMemory(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_get_max_memory_args *args,
-                                 remote_domain_get_max_memory_ret *ret)
+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) {
@@ -1575,7 +1474,13 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if ((ret->memory = virDomainGetMaxMemory(dom)) == 0)
+    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;
@@ -1589,13 +1494,13 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainGetMaxVcpus(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_get_max_vcpus_args *args,
-                                remote_domain_get_max_vcpus_ret *ret)
+remoteDispatchDomainMigrateFinish(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_finish_args *args,
+                                  remote_domain_migrate_finish_ret *ret)
 {
     virDomainPtr dom = NULL;
     int rv = -1;
@@ -1605,12 +1510,14 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
-        goto cleanup;
-
-    if ((ret->num = virDomainGetMaxVcpus(dom)) < 0)
+    if (!(dom = virDomainMigrateFinish(conn, args->dname,
+                                       args->cookie.cookie_val,
+                                       args->cookie.cookie_len,
+                                       args->uri,
+                                       args->flags)))
         goto cleanup;
 
+    make_nonnull_domain(&ret->ddom, dom);
     rv = 0;
 
 cleanup:
@@ -1622,16 +1529,19 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainGetSecurityLabel(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_get_security_label_args *args,
-                                     remote_domain_get_security_label_ret *ret)
+remoteDispatchDomainMigratePrepare2(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_prepare2_args *args,
+                                    remote_domain_migrate_prepare2_ret *ret)
 {
-    virDomainPtr dom = NULL;
-    virSecurityLabelPtr seclabel = NULL;
+    char *cookie = NULL;
+    int cookielen = 0;
+    char *uri_in;
+    char **uri_out;
+    char *dname;
     int rv = -1;
 
     if (!conn) {
@@ -1639,46 +1549,46 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
-        goto cleanup;
+    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
+    dname = args->dname == NULL ? NULL : *args->dname;
 
-    if (VIR_ALLOC(seclabel) < 0) {
+    /* Wacky world of XDR ... */
+    if (VIR_ALLOC(uri_out) < 0) {
         virReportOOMError();
         goto cleanup;
     }
 
-    if (virDomainGetSecurityLabel(dom, seclabel) < 0)
+    if (virDomainMigratePrepare2(conn, &cookie, &cookielen,
+                                 uri_in, uri_out,
+                                 args->flags, dname, args->resource,
+                                 args->dom_xml) < 0)
         goto cleanup;
 
-    ret->label.label_len = strlen(seclabel->label) + 1;
-    if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-    strcpy(ret->label.label_val, seclabel->label);
-    ret->enforcing = seclabel->enforcing;
+    /* remoteDispatchClientRequest will free cookie, uri_out and
+     * the string if there is one.
+     */
+    ret->cookie.cookie_len = cookielen;
+    ret->cookie.cookie_val = cookie;
+    ret->uri_out = *uri_out == NULL ? NULL : uri_out;
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    VIR_FREE(seclabel);
     return rv;
 }
 
 static int
-remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
                                    virConnectPtr conn,
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
                                    remote_error *rerr,
-                                   void *args ATTRIBUTE_UNUSED,
-                                   remote_node_get_security_model_ret *ret)
+                                   remote_domain_migrate_finish2_args *args,
+                                   remote_domain_migrate_finish2_ret *ret)
 {
-    virSecurityModel secmodel;
+    virDomainPtr dom = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -1686,42 +1596,37 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    memset(&secmodel, 0, sizeof secmodel);
-    if (virNodeGetSecurityModel(conn, &secmodel) < 0)
-        goto cleanup;
-
-    ret->model.model_len = strlen(secmodel.model) + 1;
-    if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
-        virReportOOMError();
+    if (!(dom = virDomainMigrateFinish2(conn, args->dname,
+                                        args->cookie.cookie_val,
+                                        args->cookie.cookie_len,
+                                        args->uri,
+                                        args->flags,
+                                        args->retcode)))
         goto cleanup;
-    }
-    strcpy(ret->model.model_val, secmodel.model);
 
-    ret->doi.doi_len = strlen(secmodel.doi) + 1;
-    if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-    strcpy(ret->doi.doi_val, secmodel.doi);
+    make_nonnull_domain(&ret->ddom, dom);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
 static int
-remoteDispatchDomainGetOsType(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_get_os_type_args *args,
-                              remote_domain_get_os_type_ret *ret)
+remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                         struct qemud_client *client,
+                                         virConnectPtr conn,
+                                         remote_message_header *hdr,
+                                         remote_error *rerr,
+                                         remote_domain_migrate_prepare_tunnel_args *args,
+                                         void *ret ATTRIBUTE_UNUSED)
 {
-    virDomainPtr dom = NULL;
+    char *dname;
+    struct qemud_client_stream *stream = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -1729,114 +1634,87 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    dname = args->dname == NULL ? NULL : *args->dname;
+
+    if (!(stream = remoteCreateClientStream(conn, hdr))) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (virDomainMigratePrepareTunnel(conn, stream->st,
+                                      args->flags, dname, args->resource,
+                                      args->dom_xml) < 0)
         goto cleanup;
 
-    /* remoteDispatchClientRequest will free this */
-    if (!(ret->type = virDomainGetOSType(dom)))
+    if (remoteAddClientStream(client, stream, 0) < 0)
         goto cleanup;
 
     rv = 0;
 
 cleanup:
-    if (rv < 0)
+    if (rv < 0) {
         remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
+        if (stream) {
+            virStreamAbort(stream->st);
+            remoteFreeClientStream(client, stream);
+        }
+    }
     return rv;
 }
 
 static int
-remoteDispatchDomainGetVcpus(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_get_vcpus_args *args,
-                             remote_domain_get_vcpus_ret *ret)
+remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                 struct qemud_client *client ATTRIBUTE_UNUSED,
+                                 virConnectPtr conn,
+                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                 remote_error *rerr,
+                                 remote_list_defined_domains_args *args,
+                                 remote_list_defined_domains_ret *ret)
 {
-    virDomainPtr dom = NULL;
-    virVcpuInfoPtr info = NULL;
-    unsigned char *cpumaps = NULL;
-    int info_len, i;
     int rv = -1;
+    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
-        goto cleanup;
-
-    if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
+    if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR,
+                    "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
         goto cleanup;
     }
 
-    if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+    /* Allocate return buffer. */
+    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
+        virReportOOMError();
         goto cleanup;
     }
 
-    /* Allocate buffers to take the results. */
-    if (VIR_ALLOC_N(info, args->maxinfo) < 0)
-        goto no_memory;
-    if (args->maplen > 0 &&
-        VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
-        goto no_memory;
-
-    if ((info_len = virDomainGetVcpus(dom,
-                                      info, args->maxinfo,
-                                      cpumaps, args->maplen)) < 0)
+    len = virConnectListDefinedDomains(conn,
+                                       ret->names.names_val, args->maxnames);
+    if (len < 0)
         goto cleanup;
-
-    /* Allocate the return buffer for info. */
-    ret->info.info_len = info_len;
-    if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
-        goto no_memory;
-
-    for (i = 0; i < info_len; ++i) {
-        ret->info.info_val[i].number = info[i].number;
-        ret->info.info_val[i].state = info[i].state;
-        ret->info.info_val[i].cpu_time = info[i].cpuTime;
-        ret->info.info_val[i].cpu = info[i].cpu;
-    }
-
-    /* Don't need to allocate/copy the cpumaps if we make the reasonable
-     * assumption that unsigned char and char are the same size.
-     * Note that remoteDispatchClientRequest will free.
-     */
-    ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
-    ret->cpumaps.cpumaps_val = (char *) cpumaps;
-    cpumaps = NULL;
+    ret->names.names_len = len;
 
     rv = 0;
 
 cleanup:
     if (rv < 0) {
         remoteDispatchError(rerr);
-        VIR_FREE(ret->info.info_val);
+        VIR_FREE(ret->names.names_val);
     }
-    VIR_FREE(cpumaps);
-    VIR_FREE(info);
-    if (dom)
-        virDomainFree(dom);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
-remoteDispatchDomainGetVcpusFlags(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_get_vcpus_flags_args *args,
-                                  remote_domain_get_vcpus_flags_ret *ret)
+remoteDispatchDomainLookupById(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_lookup_by_id_args *args,
+                               remote_domain_lookup_by_id_ret *ret)
 {
     virDomainPtr dom = NULL;
     int rv = -1;
@@ -1846,11 +1724,10 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    if (!(dom = virDomainLookupByID(conn, args->id)))
         goto cleanup;
 
-    if ((ret->num = virDomainGetVcpusFlags(dom, args->flags)) < 0)
-        goto cleanup;
+    make_nonnull_domain(&ret->dom, dom);
 
     rv = 0;
 
@@ -1863,19 +1740,15 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainMigratePrepare(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_prepare_args *args,
-                                   remote_domain_migrate_prepare_ret *ret)
+remoteDispatchDomainLookupByName(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_lookup_by_name_args *args,
+                                 remote_domain_lookup_by_name_ret *ret)
 {
-    char *cookie = NULL;
-    int cookielen = 0;
-    char *uri_in;
-    char **uri_out;
-    char *dname;
+    virDomainPtr dom = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -1883,52 +1756,31 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
-    dname = args->dname == NULL ? NULL : *args->dname;
-
-    /* Wacky world of XDR ... */
-    if (VIR_ALLOC(uri_out) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    if (virDomainMigratePrepare(conn, &cookie, &cookielen,
-                                uri_in, uri_out,
-                                args->flags, dname, args->resource) < 0)
+    if (!(dom = virDomainLookupByName(conn, args->name)))
         goto cleanup;
 
-    /* remoteDispatchClientRequest will free cookie, uri_out and
-     * the string if there is one.
-     */
-    ret->cookie.cookie_len = cookielen;
-    ret->cookie.cookie_val = cookie;
-    if (*uri_out == NULL) {
-        ret->uri_out = NULL;
-    } else {
-        ret->uri_out = uri_out;
-        uri_out = NULL;
-    }
+    make_nonnull_domain(&ret->dom, dom);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    VIR_FREE(uri_out);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
 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)
+remoteDispatchDomainLookupByUUID(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_lookup_by_uuid_args *args,
+                                 remote_domain_lookup_by_uuid_ret *ret)
 {
     virDomainPtr dom = NULL;
-    char *dname;
     int rv = -1;
 
     if (!conn) {
@@ -1936,17 +1788,10 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    if (!(dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid)))
         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;
+    make_nonnull_domain(&ret->dom, dom);
 
     rv = 0;
 
@@ -1959,13 +1804,13 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainMigrateFinish(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_finish_args *args,
-                                  remote_domain_migrate_finish_ret *ret)
+remoteDispatchDomainPinVcpu(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_pin_vcpu_args *args,
+                            void *ret ATTRIBUTE_UNUSED)
 {
     virDomainPtr dom = NULL;
     int rv = -1;
@@ -1975,14 +1820,19 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = virDomainMigrateFinish(conn, args->dname,
-                                       args->cookie.cookie_val,
-                                       args->cookie.cookie_len,
-                                       args->uri,
-                                       args->flags)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
+        goto cleanup;
+    }
+
+    if (virDomainPinVcpu(dom, args->vcpu,
+                         (unsigned char *) args->cpumap.cpumap_val,
+                         args->cpumap.cpumap_len) < 0)
         goto cleanup;
 
-    make_nonnull_domain(&ret->ddom, dom);
     rv = 0;
 
 cleanup:
@@ -1994,19 +1844,21 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainMigratePrepare2(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_prepare2_args *args,
-                                    remote_domain_migrate_prepare2_ret *ret)
+remoteDispatchDomainSetMemoryParameters(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_set_memory_parameters_args
+                                        * args, void *ret ATTRIBUTE_UNUSED)
 {
-    char *cookie = NULL;
-    int cookielen = 0;
-    char *uri_in;
-    char **uri_out;
-    char *dname;
+    virDomainPtr dom = NULL;
+    virMemoryParameterPtr params = NULL;
+    int i, nparams;
+    unsigned int flags;
     int rv = -1;
 
     if (!conn) {
@@ -2014,84 +1866,98 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
         goto cleanup;
     }
 
-    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
-    dname = args->dname == NULL ? NULL : *args->dname;
+    nparams = args->params.params_len;
+    flags = args->flags;
 
-    /* Wacky world of XDR ... */
-    if (VIR_ALLOC(uri_out) < 0) {
-        virReportOOMError();
+    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-
-    if (virDomainMigratePrepare2(conn, &cookie, &cookielen,
-                                 uri_in, uri_out,
-                                 args->flags, dname, args->resource,
-                                 args->dom_xml) < 0)
+    if (VIR_ALLOC_N(params, nparams) < 0) {
+        virReportOOMError();
         goto cleanup;
+    }
 
-    /* remoteDispatchClientRequest will free cookie, uri_out and
-     * the string if there is one.
-     */
-    ret->cookie.cookie_len = cookielen;
-    ret->cookie.cookie_val = cookie;
-    ret->uri_out = *uri_out == NULL ? NULL : uri_out;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchDomainMigrateFinish2(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_finish2_args *args,
-                                   remote_domain_migrate_finish2_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
+    /* Deserialise parameters. */
+    for (i = 0; i < nparams; ++i) {
+        if (virStrcpyStatic
+            (params[i].field, args->params.params_val[i].field) == NULL) {
+            virNetError(VIR_ERR_INTERNAL_ERROR,
+                        _("Field %s too big for destination"),
+                        args->params.params_val[i].field);
+            goto cleanup;
+        }
+        params[i].type = args->params.params_val[i].value.type;
+        switch (params[i].type) {
+            case VIR_DOMAIN_MEMORY_PARAM_INT:
+                params[i].value.i =
+                    args->params.params_val[i].value.
+                    remote_memory_param_value_u.i;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_UINT:
+                params[i].value.ui =
+                    args->params.params_val[i].value.
+                    remote_memory_param_value_u.ui;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_LLONG:
+                params[i].value.l =
+                    args->params.params_val[i].value.
+                    remote_memory_param_value_u.l;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
+                params[i].value.ul =
+                    args->params.params_val[i].value.
+                    remote_memory_param_value_u.ul;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
+                params[i].value.d =
+                    args->params.params_val[i].value.
+                    remote_memory_param_value_u.d;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
+                params[i].value.b =
+                    args->params.params_val[i].value.
+                    remote_memory_param_value_u.b;
+                break;
+        }
     }
 
-    if (!(dom = virDomainMigrateFinish2(conn, args->dname,
-                                        args->cookie.cookie_val,
-                                        args->cookie.cookie_len,
-                                        args->uri,
-                                        args->flags,
-                                        args->retcode)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    make_nonnull_domain(&ret->ddom, dom);
+    if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0)
+        goto cleanup;
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    VIR_FREE(params);
     if (dom)
         virDomainFree(dom);
     return rv;
 }
 
 static int
-remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                         struct qemud_client *client,
-                                         virConnectPtr conn,
-                                         remote_message_header *hdr,
-                                         remote_error *rerr,
-                                         remote_domain_migrate_prepare_tunnel_args *args,
-                                         void *ret ATTRIBUTE_UNUSED)
+remoteDispatchDomainGetMemoryParameters(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_get_memory_parameters_args
+                                        * args,
+                                        remote_domain_get_memory_parameters_ret
+                                        * ret)
 {
-    char *dname;
-    struct qemud_client_stream *stream = NULL;
+    virDomainPtr dom = NULL;
+    virMemoryParameterPtr params = NULL;
+    int i;
+    int nparams = args->nparams;
+    unsigned int flags;
     int rv = -1;
 
     if (!conn) {
@@ -2099,89 +1965,118 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
         goto cleanup;
     }
 
-    dname = args->dname == NULL ? NULL : *args->dname;
+    flags = args->flags;
 
-    if (!(stream = remoteCreateClientStream(conn, hdr))) {
+    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+        goto cleanup;
+    }
+    if (VIR_ALLOC_N(params, nparams) < 0) {
         virReportOOMError();
         goto cleanup;
     }
 
-    if (virDomainMigratePrepareTunnel(conn, stream->st,
-                                      args->flags, dname, args->resource,
-                                      args->dom_xml) < 0)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (remoteAddClientStream(client, stream, 0) < 0)
+    if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
         goto cleanup;
 
-    rv = 0;
-
-cleanup:
-    if (rv < 0) {
-        remoteDispatchError(rerr);
-        if (stream) {
-            virStreamAbort(stream->st);
-            remoteFreeClientStream(client, stream);
-        }
+    /* In this case, we need to send back the number of parameters
+     * supported
+     */
+    if (args->nparams == 0) {
+        ret->nparams = nparams;
+        goto success;
     }
-    return rv;
-}
-
-static int
-remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                 struct qemud_client *client ATTRIBUTE_UNUSED,
-                                 virConnectPtr conn,
-                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                 remote_error *rerr,
-                                 remote_list_defined_domains_args *args,
-                                 remote_list_defined_domains_ret *ret)
-{
-    int rv = -1;
-    int len;
 
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
+    /* Serialise the memory parameters. */
+    ret->params.params_len = nparams;
+    if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
+        goto no_memory;
 
-    if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR,
-                    "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
-        goto cleanup;
-    }
+    for (i = 0; i < nparams; ++i) {
+        /* remoteDispatchClientRequest will free this: */
+        ret->params.params_val[i].field = strdup(params[i].field);
+        if (ret->params.params_val[i].field == NULL)
+            goto no_memory;
 
-    /* Allocate return buffer. */
-    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
-        virReportOOMError();
-        goto cleanup;
+        ret->params.params_val[i].value.type = params[i].type;
+        switch (params[i].type) {
+            case VIR_DOMAIN_MEMORY_PARAM_INT:
+                ret->params.params_val[i].
+                    value.remote_memory_param_value_u.i =
+                    params[i].value.i;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_UINT:
+                ret->params.params_val[i].
+                    value.remote_memory_param_value_u.ui =
+                    params[i].value.ui;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_LLONG:
+                ret->params.params_val[i].
+                    value.remote_memory_param_value_u.l =
+                    params[i].value.l;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
+                ret->params.params_val[i].
+                    value.remote_memory_param_value_u.ul =
+                    params[i].value.ul;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
+                ret->params.params_val[i].
+                    value.remote_memory_param_value_u.d =
+                    params[i].value.d;
+                break;
+            case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
+                ret->params.params_val[i].
+                    value.remote_memory_param_value_u.b =
+                    params[i].value.b;
+                break;
+            default:
+                virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
+                goto cleanup;
+        }
     }
 
-    len = virConnectListDefinedDomains(conn,
-                                       ret->names.names_val, args->maxnames);
-    if (len < 0)
-        goto cleanup;
-    ret->names.names_len = len;
-
+success:
     rv = 0;
 
 cleanup:
     if (rv < 0) {
         remoteDispatchError(rerr);
-        VIR_FREE(ret->names.names_val);
+        if (ret->params.params_val) {
+            for (i = 0; i < nparams; i++)
+                VIR_FREE(ret->params.params_val[i].field);
+            VIR_FREE(ret->params.params_val);
+        }
     }
+    if (dom)
+        virDomainFree(dom);
+    VIR_FREE(params);
     return rv;
+
+no_memory:
+    virReportOOMError();
+    goto cleanup;
 }
 
 static int
-remoteDispatchDomainLookupById(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_lookup_by_id_args *args,
-                               remote_domain_lookup_by_id_ret *ret)
+remoteDispatchDomainSetBlkioParameters(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_set_blkio_parameters_args
+                                        * args, void *ret ATTRIBUTE_UNUSED)
 {
     virDomainPtr dom = NULL;
+    virBlkioParameterPtr params = NULL;
+    int i, nparams;
+    unsigned int flags;
     int rv = -1;
 
     if (!conn) {
@@ -2189,186 +2084,17 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dom = virDomainLookupByID(conn, args->id)))
-        goto cleanup;
-
-    make_nonnull_domain(&ret->dom, dom);
-
-    rv = 0;
+    nparams = args->params.params_len;
+    flags = args->flags;
 
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
-remoteDispatchDomainLookupByName(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_lookup_by_name_args *args,
-                                 remote_domain_lookup_by_name_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(dom = virDomainLookupByName(conn, args->name)))
-        goto cleanup;
-
-    make_nonnull_domain(&ret->dom, dom);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
-remoteDispatchDomainLookupByUUID(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_lookup_by_uuid_args *args,
-                                 remote_domain_lookup_by_uuid_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid)))
-        goto cleanup;
-
-    make_nonnull_domain(&ret->dom, dom);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
-remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                  struct qemud_client *client ATTRIBUTE_UNUSED,
-                                  virConnectPtr conn,
-                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                  remote_error *rerr,
-                                  void *args ATTRIBUTE_UNUSED,
-                                  remote_num_of_defined_domains_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfDefinedDomains(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchDomainPinVcpu(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_pin_vcpu_args *args,
-                            void *ret ATTRIBUTE_UNUSED)
-{
-    virDomainPtr dom = NULL;
-    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;
-
-    if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
-        goto cleanup;
-    }
-
-    if (virDomainPinVcpu(dom, args->vcpu,
-                         (unsigned char *) args->cpumap.cpumap_val,
-                         args->cpumap.cpumap_len) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
-remoteDispatchDomainSetMemoryParameters(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_set_memory_parameters_args
-                                        * args, void *ret ATTRIBUTE_UNUSED)
-{
-    virDomainPtr dom = NULL;
-    virMemoryParameterPtr params = NULL;
-    int i, nparams;
-    unsigned int flags;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    nparams = args->params.params_len;
-    flags = args->flags;
-
-    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
-        goto cleanup;
-    }
-    if (VIR_ALLOC_N(params, nparams) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
+    if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+        goto cleanup;
+    }
+    if (VIR_ALLOC_N(params, nparams) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
 
     /* Deserialise parameters. */
     for (i = 0; i < nparams; ++i) {
@@ -2381,35 +2107,35 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
         }
         params[i].type = args->params.params_val[i].value.type;
         switch (params[i].type) {
-            case VIR_DOMAIN_MEMORY_PARAM_INT:
+            case VIR_DOMAIN_BLKIO_PARAM_INT:
                 params[i].value.i =
                     args->params.params_val[i].value.
-                    remote_memory_param_value_u.i;
+                    remote_blkio_param_value_u.i;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_UINT:
+            case VIR_DOMAIN_BLKIO_PARAM_UINT:
                 params[i].value.ui =
                     args->params.params_val[i].value.
-                    remote_memory_param_value_u.ui;
+                    remote_blkio_param_value_u.ui;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_LLONG:
+            case VIR_DOMAIN_BLKIO_PARAM_LLONG:
                 params[i].value.l =
                     args->params.params_val[i].value.
-                    remote_memory_param_value_u.l;
+                    remote_blkio_param_value_u.l;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
+            case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
                 params[i].value.ul =
                     args->params.params_val[i].value.
-                    remote_memory_param_value_u.ul;
+                    remote_blkio_param_value_u.ul;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
+            case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
                 params[i].value.d =
                     args->params.params_val[i].value.
-                    remote_memory_param_value_u.d;
+                    remote_blkio_param_value_u.d;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
+            case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
                 params[i].value.b =
                     args->params.params_val[i].value.
-                    remote_memory_param_value_u.b;
+                    remote_blkio_param_value_u.b;
                 break;
         }
     }
@@ -2417,7 +2143,7 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0)
+    if (virDomainSetBlkioParameters(dom, params, nparams, flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -2432,7 +2158,7 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
+remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
                                         ATTRIBUTE_UNUSED,
                                         struct qemud_client *client
                                         ATTRIBUTE_UNUSED,
@@ -2440,13 +2166,13 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
                                         remote_message_header *
                                         hdr ATTRIBUTE_UNUSED,
                                         remote_error * rerr,
-                                        remote_domain_get_memory_parameters_args
+                                        remote_domain_get_blkio_parameters_args
                                         * args,
-                                        remote_domain_get_memory_parameters_ret
+                                        remote_domain_get_blkio_parameters_ret
                                         * ret)
 {
     virDomainPtr dom = NULL;
-    virMemoryParameterPtr params = NULL;
+    virBlkioParameterPtr params = NULL;
     int i;
     int nparams = args->nparams;
     unsigned int flags;
@@ -2459,7 +2185,7 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
 
     flags = args->flags;
 
-    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
+    if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
@@ -2471,7 +2197,7 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
+    if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
         goto cleanup;
 
     /* In this case, we need to send back the number of parameters
@@ -2482,47 +2208,47 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
         goto success;
     }
 
-    /* Serialise the memory parameters. */
+    /* Serialise the blkio parameters. */
     ret->params.params_len = nparams;
     if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
         goto no_memory;
 
     for (i = 0; i < nparams; ++i) {
-        /* remoteDispatchClientRequest will free this: */
+        // remoteDispatchClientRequest will free this:
         ret->params.params_val[i].field = strdup(params[i].field);
         if (ret->params.params_val[i].field == NULL)
             goto no_memory;
 
         ret->params.params_val[i].value.type = params[i].type;
         switch (params[i].type) {
-            case VIR_DOMAIN_MEMORY_PARAM_INT:
+            case VIR_DOMAIN_BLKIO_PARAM_INT:
                 ret->params.params_val[i].
-                    value.remote_memory_param_value_u.i =
+                    value.remote_blkio_param_value_u.i =
                     params[i].value.i;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_UINT:
+            case VIR_DOMAIN_BLKIO_PARAM_UINT:
                 ret->params.params_val[i].
-                    value.remote_memory_param_value_u.ui =
+                    value.remote_blkio_param_value_u.ui =
                     params[i].value.ui;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_LLONG:
+            case VIR_DOMAIN_BLKIO_PARAM_LLONG:
                 ret->params.params_val[i].
-                    value.remote_memory_param_value_u.l =
+                    value.remote_blkio_param_value_u.l =
                     params[i].value.l;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
+            case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
                 ret->params.params_val[i].
-                    value.remote_memory_param_value_u.ul =
+                    value.remote_blkio_param_value_u.ul =
                     params[i].value.ul;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
+            case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
                 ret->params.params_val[i].
-                    value.remote_memory_param_value_u.d =
+                    value.remote_blkio_param_value_u.d =
                     params[i].value.d;
                 break;
-            case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
+            case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
                 ret->params.params_val[i].
-                    value.remote_memory_param_value_u.b =
+                    value.remote_blkio_param_value_u.b =
                     params[i].value.b;
                 break;
             default:
@@ -2543,9 +2269,9 @@ cleanup:
             VIR_FREE(ret->params.params_val);
         }
     }
+    VIR_FREE(params);
     if (dom)
         virDomainFree(dom);
-    VIR_FREE(params);
     return rv;
 
 no_memory:
@@ -2554,243 +2280,25 @@ no_memory:
 }
 
 static int
-remoteDispatchDomainSetBlkioParameters(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_set_blkio_parameters_args
-                                        * args, void *ret ATTRIBUTE_UNUSED)
+remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                  struct qemud_client *client ATTRIBUTE_UNUSED,
+                                  virConnectPtr conn,
+                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                  remote_error *rerr,
+                                  remote_list_defined_networks_args *args,
+                                  remote_list_defined_networks_ret *ret)
 {
-    virDomainPtr dom = NULL;
-    virBlkioParameterPtr params = NULL;
-    int i, nparams;
-    unsigned int flags;
     int rv = -1;
+    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    nparams = args->params.params_len;
-    flags = args->flags;
-
-    if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
-        goto cleanup;
-    }
-    if (VIR_ALLOC_N(params, nparams) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    /* Deserialise parameters. */
-    for (i = 0; i < nparams; ++i) {
-        if (virStrcpyStatic
-            (params[i].field, args->params.params_val[i].field) == NULL) {
-            virNetError(VIR_ERR_INTERNAL_ERROR,
-                        _("Field %s too big for destination"),
-                        args->params.params_val[i].field);
-            goto cleanup;
-        }
-        params[i].type = args->params.params_val[i].value.type;
-        switch (params[i].type) {
-            case VIR_DOMAIN_BLKIO_PARAM_INT:
-                params[i].value.i =
-                    args->params.params_val[i].value.
-                    remote_blkio_param_value_u.i;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_UINT:
-                params[i].value.ui =
-                    args->params.params_val[i].value.
-                    remote_blkio_param_value_u.ui;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_LLONG:
-                params[i].value.l =
-                    args->params.params_val[i].value.
-                    remote_blkio_param_value_u.l;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
-                params[i].value.ul =
-                    args->params.params_val[i].value.
-                    remote_blkio_param_value_u.ul;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
-                params[i].value.d =
-                    args->params.params_val[i].value.
-                    remote_blkio_param_value_u.d;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
-                params[i].value.b =
-                    args->params.params_val[i].value.
-                    remote_blkio_param_value_u.b;
-                break;
-        }
-    }
-
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
-        goto cleanup;
-
-    if (virDomainSetBlkioParameters(dom, params, nparams, flags) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    VIR_FREE(params);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
-remoteDispatchDomainGetBlkioParameters(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_get_blkio_parameters_args
-                                        * args,
-                                        remote_domain_get_blkio_parameters_ret
-                                        * ret)
-{
-    virDomainPtr dom = NULL;
-    virBlkioParameterPtr params = NULL;
-    int i;
-    int nparams = args->nparams;
-    unsigned int flags;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    flags = args->flags;
-
-    if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
-        goto cleanup;
-    }
-    if (VIR_ALLOC_N(params, nparams) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
-        goto cleanup;
-
-    if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
-        goto cleanup;
-
-    /* In this case, we need to send back the number of parameters
-     * supported
-     */
-    if (args->nparams == 0) {
-        ret->nparams = nparams;
-        goto success;
-    }
-
-    /* Serialise the blkio parameters. */
-    ret->params.params_len = nparams;
-    if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
-        goto no_memory;
-
-    for (i = 0; i < nparams; ++i) {
-        // remoteDispatchClientRequest will free this:
-        ret->params.params_val[i].field = strdup(params[i].field);
-        if (ret->params.params_val[i].field == NULL)
-            goto no_memory;
-
-        ret->params.params_val[i].value.type = params[i].type;
-        switch (params[i].type) {
-            case VIR_DOMAIN_BLKIO_PARAM_INT:
-                ret->params.params_val[i].
-                    value.remote_blkio_param_value_u.i =
-                    params[i].value.i;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_UINT:
-                ret->params.params_val[i].
-                    value.remote_blkio_param_value_u.ui =
-                    params[i].value.ui;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_LLONG:
-                ret->params.params_val[i].
-                    value.remote_blkio_param_value_u.l =
-                    params[i].value.l;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
-                ret->params.params_val[i].
-                    value.remote_blkio_param_value_u.ul =
-                    params[i].value.ul;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
-                ret->params.params_val[i].
-                    value.remote_blkio_param_value_u.d =
-                    params[i].value.d;
-                break;
-            case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
-                ret->params.params_val[i].
-                    value.remote_blkio_param_value_u.b =
-                    params[i].value.b;
-                break;
-            default:
-                virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
-                goto cleanup;
-        }
-    }
-
-success:
-    rv = 0;
-
-cleanup:
-    if (rv < 0) {
-        remoteDispatchError(rerr);
-        if (ret->params.params_val) {
-            for (i = 0; i < nparams; i++)
-                VIR_FREE(ret->params.params_val[i].field);
-            VIR_FREE(ret->params.params_val);
-        }
-    }
-    VIR_FREE(params);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
-}
-
-static int
-remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                  struct qemud_client *client ATTRIBUTE_UNUSED,
-                                  virConnectPtr conn,
-                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                  remote_error *rerr,
-                                  remote_list_defined_networks_args *args,
-                                  remote_list_defined_networks_ret *ret)
-{
-    int rv = -1;
-    int len;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR,
-                    "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
+    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR,
+                    "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
         goto cleanup;
     }
 
@@ -2861,39 +2369,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchDomainHasManagedSaveImage(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_has_managed_save_image_args *args,
-                                        remote_domain_has_managed_save_image_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    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;
-
-    if ((ret->result = virDomainHasManagedSaveImage(dom, args->flags)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
 static int
 remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
                            struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -3004,13 +2479,13 @@ cleanup:
 }
 
 static int
-remoteDispatchNetworkDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                             struct qemud_client *client ATTRIBUTE_UNUSED,
-                             virConnectPtr conn,
-                             remote_message_header *hdr ATTRIBUTE_UNUSED,
-                             remote_error *rerr,
-                             remote_network_dump_xml_args *args,
-                             remote_network_dump_xml_ret *ret)
+remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                  struct qemud_client *client ATTRIBUTE_UNUSED,
+                                  virConnectPtr conn,
+                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                  remote_error *rerr,
+                                  remote_network_lookup_by_name_args *args,
+                                  remote_network_lookup_by_name_ret *ret)
 {
     virNetworkPtr net = NULL;
     int rv = -1;
@@ -3020,12 +2495,10 @@ remoteDispatchNetworkDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
+    if (!(net = virNetworkLookupByName(conn, args->name)))
         goto cleanup;
 
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virNetworkGetXMLDesc(net, args->flags)))
-        goto cleanup;
+    make_nonnull_network(&ret->net, net);
 
     rv = 0;
 
@@ -3038,112 +2511,13 @@ cleanup:
 }
 
 static int
-remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchNetworkLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED,
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
                                   virConnectPtr conn,
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
                                   remote_error *rerr,
-                                  remote_network_get_autostart_args *args,
-                                  remote_network_get_autostart_ret *ret)
-{
-    virNetworkPtr net = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(net = get_nonnull_network(conn, args->net)))
-        goto cleanup;
-
-    if (virNetworkGetAutostart(net, &ret->autostart) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
-    return rv;
-}
-
-static int
-remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                   struct qemud_client *client ATTRIBUTE_UNUSED,
-                                   virConnectPtr conn,
-                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                   remote_error *rerr,
-                                   remote_network_get_bridge_name_args *args,
-                                   remote_network_get_bridge_name_ret *ret)
-{
-    virNetworkPtr net = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(net = get_nonnull_network(conn, args->net)))
-        goto cleanup;
-
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->name = virNetworkGetBridgeName(net)))
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
-    return rv;
-}
-
-static int
-remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                  struct qemud_client *client ATTRIBUTE_UNUSED,
-                                  virConnectPtr conn,
-                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                  remote_error *rerr,
-                                  remote_network_lookup_by_name_args *args,
-                                  remote_network_lookup_by_name_ret *ret)
-{
-    virNetworkPtr net = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(net = virNetworkLookupByName(conn, args->name)))
-        goto cleanup;
-
-    make_nonnull_network(&ret->net, net);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
-    return rv;
-}
-
-static int
-remoteDispatchNetworkLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                  struct qemud_client *client ATTRIBUTE_UNUSED,
-                                  virConnectPtr conn,
-                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                  remote_error *rerr,
-                                  remote_network_lookup_by_uuid_args *args,
-                                  remote_network_lookup_by_uuid_ret *ret)
+                                  remote_network_lookup_by_uuid_args *args,
+                                  remote_network_lookup_by_uuid_ret *ret)
 {
     virNetworkPtr net = NULL;
     int rv = -1;
@@ -3168,118 +2542,7 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                   struct qemud_client *client ATTRIBUTE_UNUSED,
-                                   virConnectPtr conn,
-                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                   remote_error *rerr,
-                                   void *args ATTRIBUTE_UNUSED,
-                                   remote_num_of_defined_networks_ret *ret)
-{
-    int rv = -1;
-    int len;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    len = virConnectNumOfDefinedNetworks(conn);
-    if (len < 0)
-        goto cleanup;
-    ret->num = len;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
-                           struct qemud_client *client ATTRIBUTE_UNUSED,
-                           virConnectPtr conn,
-                           remote_message_header *hdr ATTRIBUTE_UNUSED,
-                           remote_error *rerr,
-                           void *args ATTRIBUTE_UNUSED,
-                           remote_num_of_domains_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfDomains(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
-                            struct qemud_client *client ATTRIBUTE_UNUSED,
-                            virConnectPtr conn,
-                            remote_message_header *hdr ATTRIBUTE_UNUSED,
-                            remote_error *rerr,
-                            void *args ATTRIBUTE_UNUSED,
-                            remote_num_of_networks_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfNetworks(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-
 /*-------------------------------------------------------------*/
-static int
-remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
-                              struct qemud_client *client ATTRIBUTE_UNUSED,
-                              virConnectPtr conn,
-                              remote_message_header *hdr ATTRIBUTE_UNUSED,
-                              remote_error *rerr,
-                              void *args ATTRIBUTE_UNUSED,
-                              remote_num_of_interfaces_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfInterfaces(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
 
 static int
 remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -3326,36 +2589,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                     struct qemud_client *client ATTRIBUTE_UNUSED,
-                                     virConnectPtr conn,
-                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                     remote_error *rerr,
-                                     void *args ATTRIBUTE_UNUSED,
-                                     remote_num_of_defined_interfaces_ret *ret)
-{
-    int rv = -1;
-    int len;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    len = virConnectNumOfDefinedInterfaces(conn);
-    if (len < 0)
-        goto cleanup;
-    ret->num = len;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
 static int
 remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -3465,40 +2698,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchInterfaceGetXMLDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                  struct qemud_client *client ATTRIBUTE_UNUSED,
-                                  virConnectPtr conn,
-                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                  remote_error *rerr,
-                                  remote_interface_get_xml_desc_args *args,
-                                  remote_interface_get_xml_desc_ret *ret)
-{
-    virInterfacePtr iface = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(iface = get_nonnull_interface(conn, args->iface)))
-        goto cleanup;
-
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virInterfaceGetXMLDesc(iface, args->flags)))
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (iface)
-        virInterfaceFree(iface);
-    return rv;
-}
-
 static int
 remoteDispatchInterfaceDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED,
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -4290,862 +3489,151 @@ remoteDispatchAuthPolkit(struct qemud_server *server,
     PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
           client->fd, REMOTE_AUTH_POLKIT, ident);
     VIR_INFO(_("Policy allowed action %s from pid %d, uid %d, result %s"),
-             action, callerPid, callerUid,
-             polkit_result_to_string_representation(pkresult));
-    ret->complete = 1;
-    client->auth = REMOTE_AUTH_NONE;
-
-    virMutexUnlock(&client->lock);
-    return 0;
-
-authfail:
-    PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
-    goto error;
-
-authdeny:
-    PROBE(CLIENT_AUTH_DENY, "fd=%d, auth=%d, username=%s",
-          client->fd, REMOTE_AUTH_POLKIT, ident);
-    goto error;
-
-error:
-    remoteDispatchAuthError(rerr);
-    virMutexUnlock(&client->lock);
-    return -1;
-}
-
-#else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
-
-static int
-remoteDispatchAuthPolkit(struct qemud_server *server ATTRIBUTE_UNUSED,
-                         struct qemud_client *client ATTRIBUTE_UNUSED,
-                         virConnectPtr conn ATTRIBUTE_UNUSED,
-                         remote_message_header *hdr ATTRIBUTE_UNUSED,
-                         remote_error *rerr,
-                         void *args ATTRIBUTE_UNUSED,
-                         remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
-{
-    VIR_ERROR0(_("client tried unsupported PolicyKit init request"));
-    remoteDispatchAuthError(rerr);
-    return -1;
-}
-#endif /* HAVE_POLKIT1 */
-
-
-/***************************************************************
- *     STORAGE POOL APIS
- ***************************************************************/
-
-
-static int
-remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                      struct qemud_client *client ATTRIBUTE_UNUSED,
-                                      virConnectPtr conn,
-                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                      remote_error *rerr,
-                                      remote_list_defined_storage_pools_args *args,
-                                      remote_list_defined_storage_pools_ret *ret)
-{
-    int rv = -1;
-    int len;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
-                    _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
-        goto cleanup;
-    }
-
-    /* Allocate return buffer. */
-    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    len = virConnectListDefinedStoragePools(conn,
-                                            ret->names.names_val, args->maxnames);
-    if (len < 0)
-        goto cleanup;
-    ret->names.names_len = len;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0) {
-        remoteDispatchError(rerr);
-        VIR_FREE(ret->names.names_val);
-    }
-    return rv;
-}
-
-static int
-remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
-                               struct qemud_client *client ATTRIBUTE_UNUSED,
-                               virConnectPtr conn,
-                               remote_message_header *hdr ATTRIBUTE_UNUSED,
-                               remote_error *rerr,
-                               remote_list_storage_pools_args *args,
-                               remote_list_storage_pools_ret *ret)
-{
-    int rv = -1;
-    int len;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR,
-                    "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
-        goto cleanup;
-    }
-
-    /* Allocate return buffer. */
-    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    len = virConnectListStoragePools(conn,
-                                     ret->names.names_val, args->maxnames);
-    if (len < 0)
-        goto cleanup;
-    ret->names.names_len = len;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0) {
-        remoteDispatchError(rerr);
-        VIR_FREE(ret->names.names_val);
-    }
-    return rv;
-}
-
-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
-remoteDispatchStoragePoolCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                   struct qemud_client *client ATTRIBUTE_UNUSED,
-                                   virConnectPtr conn,
-                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                   remote_error *rerr,
-                                   remote_storage_pool_create_xml_args *args,
-                                   remote_storage_pool_create_xml_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = virStoragePoolCreateXML(conn, args->xml, args->flags)))
-        goto cleanup;
-
-    make_nonnull_storage_pool(&ret->pool, pool);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                   struct qemud_client *client ATTRIBUTE_UNUSED,
-                                   virConnectPtr conn,
-                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                   remote_error *rerr,
-                                   remote_storage_pool_define_xml_args *args,
-                                   remote_storage_pool_define_xml_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = virStoragePoolDefineXML(conn, args->xml, args->flags)))
-        goto cleanup;
-
-    make_nonnull_storage_pool(&ret->pool, pool);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                 struct qemud_client *client ATTRIBUTE_UNUSED,
-                                 virConnectPtr conn,
-                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                 remote_error *rerr,
-                                 remote_storage_pool_get_info_args *args,
-                                 remote_storage_pool_get_info_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    virStoragePoolInfo info;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    if (virStoragePoolGetInfo(pool, &info) < 0)
-        goto cleanup;
-
-    ret->state = info.state;
-    ret->capacity = info.capacity;
-    ret->allocation = info.allocation;
-    ret->available = info.available;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                 struct qemud_client *client ATTRIBUTE_UNUSED,
-                                 virConnectPtr conn,
-                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                 remote_error *rerr,
-                                 remote_storage_pool_dump_xml_args *args,
-                                 remote_storage_pool_dump_xml_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virStoragePoolGetXMLDesc(pool, args->flags)))
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                      struct qemud_client *client ATTRIBUTE_UNUSED,
-                                      virConnectPtr conn,
-                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                      remote_error *rerr,
-                                      remote_storage_pool_get_autostart_args *args,
-                                      remote_storage_pool_get_autostart_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-
-static int
-remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                      struct qemud_client *client ATTRIBUTE_UNUSED,
-                                      virConnectPtr conn,
-                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                      remote_error *rerr,
-                                      remote_storage_pool_lookup_by_name_args *args,
-                                      remote_storage_pool_lookup_by_name_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = virStoragePoolLookupByName(conn, args->name)))
-        goto cleanup;
-
-    make_nonnull_storage_pool(&ret->pool, pool);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                      struct qemud_client *client ATTRIBUTE_UNUSED,
-                                      virConnectPtr conn,
-                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                      remote_error *rerr,
-                                      remote_storage_pool_lookup_by_uuid_args *args,
-                                      remote_storage_pool_lookup_by_uuid_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid)))
-        goto cleanup;
-
-    make_nonnull_storage_pool(&ret->pool, pool);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                        struct qemud_client *client ATTRIBUTE_UNUSED,
-                                        virConnectPtr conn,
-                                        remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                        remote_error *rerr,
-                                        remote_storage_pool_lookup_by_volume_args *args,
-                                        remote_storage_pool_lookup_by_volume_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    virStorageVolPtr vol = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
-        goto cleanup;
-
-    if (!(pool = virStoragePoolLookupByVolume(vol)))
-        goto cleanup;
-
-    make_nonnull_storage_pool(&ret->pool, pool);
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (vol)
-        virStorageVolFree(vol);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                struct qemud_client *client ATTRIBUTE_UNUSED,
-                                virConnectPtr conn,
-                                remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                remote_error *rerr,
-                                void *args ATTRIBUTE_UNUSED,
-                                remote_num_of_storage_pools_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfStoragePools(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                       struct qemud_client *client ATTRIBUTE_UNUSED,
-                                       virConnectPtr conn,
-                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                       remote_error *rerr,
-                                       void *args ATTRIBUTE_UNUSED,
-                                       remote_num_of_defined_storage_pools_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfDefinedStoragePools(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-static int
-remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                     struct qemud_client *client ATTRIBUTE_UNUSED,
-                                     virConnectPtr conn,
-                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                     remote_error *rerr,
-                                     remote_storage_pool_list_volumes_args *args,
-                                     remote_storage_pool_list_volumes_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-    int len;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR,
-                    "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    /* Allocate return buffer. */
-    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    len = virStoragePoolListVolumes(pool,
-                                    ret->names.names_val, args->maxnames);
-    if (len < 0)
-        goto cleanup;
-    ret->names.names_len = len;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0) {
-        remoteDispatchError(rerr);
-        VIR_FREE(ret->names.names_val);
-    }
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-
-static int
-remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                      struct qemud_client *client ATTRIBUTE_UNUSED,
-                                      virConnectPtr conn,
-                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                      remote_error *rerr,
-                                      remote_storage_pool_num_of_volumes_args *args,
-                                      remote_storage_pool_num_of_volumes_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    if ((ret->num = virStoragePoolNumOfVolumes(pool)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-
-/***************************************************************
- *     STORAGE VOL APIS
- ***************************************************************/
-
-
-
-static int
-remoteDispatchStorageVolCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                  struct qemud_client *client ATTRIBUTE_UNUSED,
-                                  virConnectPtr conn,
-                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                  remote_error *rerr,
-                                  remote_storage_vol_create_xml_args *args,
-                                  remote_storage_vol_create_xml_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    virStorageVolPtr vol = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    if (!(vol = virStorageVolCreateXML(pool, args->xml, args->flags)))
-        goto cleanup;
-
-    make_nonnull_storage_vol(&ret->vol, vol);
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    if (vol)
-        virStorageVolFree(vol);
-    return rv;
-}
-
-static int
-remoteDispatchStorageVolCreateXMLFrom(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                      struct qemud_client *client ATTRIBUTE_UNUSED,
-                                      virConnectPtr conn,
-                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                      remote_error *rerr,
-                                      remote_storage_vol_create_xml_from_args *args,
-                                      remote_storage_vol_create_xml_from_ret *ret)
-{
-    virStoragePoolPtr pool = NULL;
-    virStorageVolPtr clonevol = NULL;
-    virStorageVolPtr newvol = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
-        goto cleanup;
-
-    if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol)))
-        goto cleanup;
-
-    if (!(newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
-                                              args->flags)))
-        goto cleanup;
-
-    make_nonnull_storage_vol(&ret->vol, newvol);
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (newvol)
-        virStorageVolFree(newvol);
-    if (clonevol)
-        virStorageVolFree(clonevol);
-    if (pool)
-        virStoragePoolFree(pool);
-    return rv;
-}
-
-static int
-remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                struct qemud_client *client ATTRIBUTE_UNUSED,
-                                virConnectPtr conn,
-                                remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                remote_error *rerr,
-                                remote_storage_vol_get_info_args *args,
-                                remote_storage_vol_get_info_ret *ret)
-{
-    virStorageVolPtr vol = NULL;
-    virStorageVolInfo info;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
-        goto cleanup;
-
-    if (virStorageVolGetInfo(vol, &info) < 0)
-        goto cleanup;
-
-    ret->type = info.type;
-    ret->capacity = info.capacity;
-    ret->allocation = info.allocation;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (vol)
-        virStorageVolFree(vol);
-    return rv;
-}
-
-static int
-remoteDispatchStorageVolDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                struct qemud_client *client ATTRIBUTE_UNUSED,
-                                virConnectPtr conn,
-                                remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                remote_error *rerr,
-                                remote_storage_vol_dump_xml_args *args,
-                                remote_storage_vol_dump_xml_ret *ret)
-{
-    virStorageVolPtr vol = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
+             action, callerPid, callerUid,
+             polkit_result_to_string_representation(pkresult));
+    ret->complete = 1;
+    client->auth = REMOTE_AUTH_NONE;
 
-    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
-        goto cleanup;
+    virMutexUnlock(&client->lock);
+    return 0;
 
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virStorageVolGetXMLDesc(vol, args->flags)))
-        goto cleanup;
+authfail:
+    PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_POLKIT);
+    goto error;
 
-    rv = 0;
+authdeny:
+    PROBE(CLIENT_AUTH_DENY, "fd=%d, auth=%d, username=%s",
+          client->fd, REMOTE_AUTH_POLKIT, ident);
+    goto error;
 
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (vol)
-        virStorageVolFree(vol);
-    return rv;
+error:
+    remoteDispatchAuthError(rerr);
+    virMutexUnlock(&client->lock);
+    return -1;
 }
 
+#else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
 
 static int
-remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                struct qemud_client *client ATTRIBUTE_UNUSED,
-                                virConnectPtr conn,
-                                remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                remote_error *rerr,
-                                remote_storage_vol_get_path_args *args,
-                                remote_storage_vol_get_path_ret *ret)
+remoteDispatchAuthPolkit(struct qemud_server *server ATTRIBUTE_UNUSED,
+                         struct qemud_client *client ATTRIBUTE_UNUSED,
+                         virConnectPtr conn ATTRIBUTE_UNUSED,
+                         remote_message_header *hdr ATTRIBUTE_UNUSED,
+                         remote_error *rerr,
+                         void *args ATTRIBUTE_UNUSED,
+                         remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
 {
-    virStorageVolPtr vol = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
-        goto cleanup;
-
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->name = virStorageVolGetPath(vol)))
-        goto cleanup;
+    VIR_ERROR0(_("client tried unsupported PolicyKit init request"));
+    remoteDispatchAuthError(rerr);
+    return -1;
+}
+#endif /* HAVE_POLKIT1 */
 
-    rv = 0;
 
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (vol)
-        virStorageVolFree(vol);
-    return rv;
-}
+/***************************************************************
+ *     STORAGE POOL APIS
+ ***************************************************************/
 
 
 static int
-remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                     struct qemud_client *client ATTRIBUTE_UNUSED,
-                                     virConnectPtr conn,
-                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                     remote_error *rerr,
-                                     remote_storage_vol_lookup_by_name_args *args,
-                                     remote_storage_vol_lookup_by_name_ret *ret)
+remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                      struct qemud_client *client ATTRIBUTE_UNUSED,
+                                      virConnectPtr conn,
+                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                      remote_error *rerr,
+                                      remote_list_defined_storage_pools_args *args,
+                                      remote_list_defined_storage_pools_ret *ret)
 {
-    virStoragePoolPtr pool = NULL;
-    virStorageVolPtr vol = NULL;
     int rv = -1;
+    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
+    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+                    _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
         goto cleanup;
+    }
 
-    if (!(vol = virStorageVolLookupByName(pool, args->name)))
+    /* Allocate return buffer. */
+    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
+        virReportOOMError();
         goto cleanup;
+    }
 
-    make_nonnull_storage_vol(&ret->vol, vol);
+    len = virConnectListDefinedStoragePools(conn,
+                                            ret->names.names_val, args->maxnames);
+    if (len < 0)
+        goto cleanup;
+    ret->names.names_len = len;
 
     rv = 0;
 
 cleanup:
-    if (rv < 0)
+    if (rv < 0) {
         remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
-    if (vol)
-        virStorageVolFree(vol);
+        VIR_FREE(ret->names.names_val);
+    }
     return rv;
 }
 
 static int
-remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                    struct qemud_client *client ATTRIBUTE_UNUSED,
-                                    virConnectPtr conn,
-                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                    remote_error *rerr,
-                                    remote_storage_vol_lookup_by_key_args *args,
-                                    remote_storage_vol_lookup_by_key_ret *ret)
+remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
+                               struct qemud_client *client ATTRIBUTE_UNUSED,
+                               virConnectPtr conn,
+                               remote_message_header *hdr ATTRIBUTE_UNUSED,
+                               remote_error *rerr,
+                               remote_list_storage_pools_args *args,
+                               remote_list_storage_pools_ret *ret)
 {
-    virStorageVolPtr vol = NULL;
     int rv = -1;
+    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(vol = virStorageVolLookupByKey(conn, args->key)))
+    if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR,
+                    "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
         goto cleanup;
+    }
 
-    make_nonnull_storage_vol(&ret->vol, vol);
+    /* Allocate return buffer. */
+    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    len = virConnectListStoragePools(conn,
+                                     ret->names.names_val, args->maxnames);
+    if (len < 0)
+        goto cleanup;
+    ret->names.names_len = len;
 
     rv = 0;
 
 cleanup:
-    if (rv < 0)
+    if (rv < 0) {
         remoteDispatchError(rerr);
-    if (vol)
-        virStorageVolFree(vol);
+        VIR_FREE(ret->names.names_val);
+    }
     return rv;
 }
 
-
 static int
-remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSED,
+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_storage_vol_lookup_by_path_args *args,
-                                     remote_storage_vol_lookup_by_path_ret *ret)
+                                     remote_find_storage_pool_sources_args *args,
+                                     remote_find_storage_pool_sources_ret *ret)
 {
-    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5153,35 +3641,31 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    if (!(vol = virStorageVolLookupByPath(conn, args->path)))
+    if (!(ret->xml =
+          virConnectFindStoragePoolSources(conn,
+                                           args->type,
+                                           args->srcSpec ? *args->srcSpec : NULL,
+                                           args->flags)))
         goto cleanup;
 
-    make_nonnull_storage_vol(&ret->vol, vol);
-
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (vol)
-        virStorageVolFree(vol);
     return rv;
 }
 
-
-/***************************************************************
- *     NODE INFO APIS
- **************************************************************/
-
 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)
+remoteDispatchStoragePoolCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr,
+                                   remote_storage_pool_create_xml_args *args,
+                                   remote_storage_pool_create_xml_ret *ret)
 {
+    virStoragePoolPtr pool = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5189,77 +3673,64 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if ((ret->num = virNodeNumOfDevices(conn,
-                                        args->cap ? *args->cap : NULL,
-                                        args->flags)) < 0)
+    if (!(pool = virStoragePoolCreateXML(conn, args->xml, args->flags)))
         goto cleanup;
 
+    make_nonnull_storage_pool(&ret->pool, pool);
+
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-
 static int
-remoteDispatchNodeListDevices(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_list_devices_args *args,
-                              remote_node_list_devices_ret *ret)
+remoteDispatchStoragePoolDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr,
+                                   remote_storage_pool_define_xml_args *args,
+                                   remote_storage_pool_define_xml_ret *ret)
 {
+    virStoragePoolPtr pool = NULL;
     int rv = -1;
-    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR,
-                    "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
-        goto cleanup;
-    }
-
-    /* Allocate return buffer. */
-    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
-        virReportOOMError();
+    if (!(pool = virStoragePoolDefineXML(conn, args->xml, args->flags)))
         goto cleanup;
-    }
 
-    len = virNodeListDevices(conn,
-                             args->cap ? *args->cap : NULL,
-                             ret->names.names_val, args->maxnames, args->flags);
-    if (len < 0)
-        goto cleanup;
-    ret->names.names_len = len;
+    make_nonnull_storage_pool(&ret->pool, pool);
 
     rv = 0;
 
 cleanup:
-    if (rv < 0) {
+    if (rv < 0)
         remoteDispatchError(rerr);
-        VIR_FREE(ret->names.names_val);
-    }
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-
 static int
-remoteDispatchNodeDeviceLookupByName(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_device_lookup_by_name_args *args,
-                                     remote_node_device_lookup_by_name_ret *ret)
+remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                 struct qemud_client *client ATTRIBUTE_UNUSED,
+                                 virConnectPtr conn,
+                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                 remote_error *rerr,
+                                 remote_storage_pool_get_info_args *args,
+                                 remote_storage_pool_get_info_ret *ret)
 {
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
+    virStoragePoolInfo info;
     int rv = -1;
 
     if (!conn) {
@@ -5267,32 +3738,37 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
+        goto cleanup;
+
+    if (virStoragePoolGetInfo(pool, &info) < 0)
         goto cleanup;
 
-    make_nonnull_node_device(&ret->dev, dev);
+    ret->state = info.state;
+    ret->capacity = info.capacity;
+    ret->allocation = info.allocation;
+    ret->available = info.available;
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-
 static int
-remoteDispatchNodeDeviceDumpXML(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_device_dump_xml_args *args,
-                                remote_node_device_dump_xml_ret *ret)
+remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                      struct qemud_client *client ATTRIBUTE_UNUSED,
+                                      virConnectPtr conn,
+                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                      remote_error *rerr,
+                                      remote_storage_pool_lookup_by_name_args *args,
+                                      remote_storage_pool_lookup_by_name_ret *ret)
 {
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5300,35 +3776,31 @@ remoteDispatchNodeDeviceDumpXML(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(pool = virStoragePoolLookupByName(conn, args->name)))
         goto cleanup;
 
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags)))
-        goto cleanup;
+    make_nonnull_storage_pool(&ret->pool, pool);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-
 static int
-remoteDispatchNodeDeviceGetParent(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_device_get_parent_args *args,
-                                  remote_node_device_get_parent_ret *ret)
+remoteDispatchStoragePoolLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                      struct qemud_client *client ATTRIBUTE_UNUSED,
+                                      virConnectPtr conn,
+                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                      remote_error *rerr,
+                                      remote_storage_pool_lookup_by_uuid_args *args,
+                                      remote_storage_pool_lookup_by_uuid_ret *ret)
 {
-    virNodeDevicePtr dev = NULL;
-    const char *parent = NULL;
+    virStoragePoolPtr pool = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5336,49 +3808,32 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid)))
         goto cleanup;
 
-    parent = virNodeDeviceGetParent(dev);
-
-    if (parent == NULL) {
-        ret->parent = NULL;
-    } else {
-        /* remoteDispatchClientRequest will free this. */
-        char **parent_p;
-        if (VIR_ALLOC(parent_p) < 0) {
-            virReportOOMError();
-            goto cleanup;
-        }
-        if (!(*parent_p = strdup(parent))) {
-            VIR_FREE(parent_p);
-            virReportOOMError();
-            goto cleanup;
-        }
-        ret->parent = parent_p;
-    }
+    make_nonnull_storage_pool(&ret->pool, pool);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-
 static int
-remoteDispatchNodeDeviceNumOfCaps(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_device_num_of_caps_args *args,
-                                  remote_node_device_num_of_caps_ret *ret)
+remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                        struct qemud_client *client ATTRIBUTE_UNUSED,
+                                        virConnectPtr conn,
+                                        remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                        remote_error *rerr,
+                                        remote_storage_pool_lookup_by_volume_args *args,
+                                        remote_storage_pool_lookup_by_volume_ret *ret)
 {
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
+    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5386,33 +3841,36 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
-    if ((ret->num = virNodeDeviceNumOfCaps(dev)) < 0)
+    if (!(pool = virStoragePoolLookupByVolume(vol)))
         goto cleanup;
 
+    make_nonnull_storage_pool(&ret->pool, pool);
+
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (vol)
+        virStorageVolFree(vol);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-
 static int
-remoteDispatchNodeDeviceListCaps(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_device_list_caps_args *args,
-                                 remote_node_device_list_caps_ret *ret)
+remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                     struct qemud_client *client ATTRIBUTE_UNUSED,
+                                     virConnectPtr conn,
+                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                     remote_error *rerr,
+                                     remote_storage_pool_list_volumes_args *args,
+                                     remote_storage_pool_list_volumes_ret *ret)
 {
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
     int rv = -1;
     int len;
 
@@ -5421,23 +3879,23 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
-        goto cleanup;
-
-    if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
+    if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
         virNetError(VIR_ERR_INTERNAL_ERROR,
-                    "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+                    "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
         goto cleanup;
     }
 
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
+        goto cleanup;
+
     /* Allocate return buffer. */
     if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
         virReportOOMError();
         goto cleanup;
     }
 
-    len = virNodeDeviceListCaps(dev, ret->names.names_val,
-                                args->maxnames);
+    len = virStoragePoolListVolumes(pool,
+                                    ret->names.names_val, args->maxnames);
     if (len < 0)
         goto cleanup;
     ret->names.names_len = len;
@@ -5449,21 +3907,29 @@ cleanup:
         remoteDispatchError(rerr);
         VIR_FREE(ret->names.names_val);
     }
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
+
+/***************************************************************
+ *     STORAGE VOL APIS
+ ***************************************************************/
+
+
+
 static int
-remoteDispatchNodeDeviceCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchStorageVolCreateXML(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_device_create_xml_args *args,
-                                  remote_node_device_create_xml_ret *ret)
+                                  remote_storage_vol_create_xml_args *args,
+                                  remote_storage_vol_create_xml_ret *ret)
 {
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
+    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5471,31 +3937,37 @@ remoteDispatchNodeDeviceCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    make_nonnull_node_device(&ret->dev, dev);
+    if (!(vol = virStorageVolCreateXML(pool, args->xml, args->flags)))
+        goto cleanup;
 
+    make_nonnull_storage_vol(&ret->vol, vol);
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
+    if (vol)
+        virStorageVolFree(vol);
     return rv;
 }
 
-static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                          struct qemud_client *client,
-                                          virConnectPtr conn,
-                                          remote_message_header *hdr,
-                                          remote_error *rerr,
-                                          remote_storage_vol_upload_args *args,
-                                          void *ret ATTRIBUTE_UNUSED)
+static int
+remoteDispatchStorageVolCreateXMLFrom(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                      struct qemud_client *client ATTRIBUTE_UNUSED,
+                                      virConnectPtr conn,
+                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                      remote_error *rerr,
+                                      remote_storage_vol_create_xml_from_args *args,
+                                      remote_storage_vol_create_xml_from_ret *ret)
 {
-    struct qemud_client_stream *stream = NULL;
-    virStorageVolPtr vol = NULL;
+    virStoragePoolPtr pool = NULL;
+    virStorageVolPtr clonevol = NULL;
+    virStorageVolPtr newvol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5503,19 +3975,58 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
         goto cleanup;
     }
 
-    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (!(stream = remoteCreateClientStream(conn, hdr)))
+    if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol)))
         goto cleanup;
 
-    if (virStorageVolUpload(vol, stream->st,
-                            args->offset, args->length,
-                            args->flags) < 0)
+    if (!(newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
+                                              args->flags)))
         goto cleanup;
 
-    if (remoteAddClientStream(client, stream, 0) < 0)
+    make_nonnull_storage_vol(&ret->vol, newvol);
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (newvol)
+        virStorageVolFree(newvol);
+    if (clonevol)
+        virStorageVolFree(clonevol);
+    if (pool)
+        virStoragePoolFree(pool);
+    return rv;
+}
+
+static int
+remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                struct qemud_client *client ATTRIBUTE_UNUSED,
+                                virConnectPtr conn,
+                                remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                remote_error *rerr,
+                                remote_storage_vol_get_info_args *args,
+                                remote_storage_vol_get_info_ret *ret)
+{
+    virStorageVolPtr vol = NULL;
+    virStorageVolInfo info;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
+    }
+
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
+        goto cleanup;
+
+    if (virStorageVolGetInfo(vol, &info) < 0)
+        goto cleanup;
+
+    ret->type = info.type;
+    ret->capacity = info.capacity;
+    ret->allocation = info.allocation;
 
     rv = 0;
 
@@ -5524,22 +4035,19 @@ cleanup:
         remoteDispatchError(rerr);
     if (vol)
         virStorageVolFree(vol);
-    if (stream && rv != 0) {
-        virStreamAbort(stream->st);
-        remoteFreeClientStream(client, stream);
-    }
     return rv;
 }
 
-static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                            struct qemud_client *client,
-                                            virConnectPtr conn,
-                                            remote_message_header *hdr,
-                                            remote_error *rerr,
-                                            remote_storage_vol_download_args *args,
-                                            void *ret ATTRIBUTE_UNUSED)
+static int
+remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                     struct qemud_client *client ATTRIBUTE_UNUSED,
+                                     virConnectPtr conn,
+                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                     remote_error *rerr,
+                                     remote_storage_vol_lookup_by_name_args *args,
+                                     remote_storage_vol_lookup_by_name_ret *ret)
 {
-    struct qemud_client_stream *stream = NULL;
+    virStoragePoolPtr pool = NULL;
     virStorageVolPtr vol = NULL;
     int rv = -1;
 
@@ -5548,48 +4056,36 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
         goto cleanup;
     }
 
-    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
-        goto cleanup;
-
-    if (!(stream = remoteCreateClientStream(conn, hdr)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virStorageVolDownload(vol, stream->st,
-                              args->offset, args->length,
-                              args->flags) < 0)
+    if (!(vol = virStorageVolLookupByName(pool, args->name)))
         goto cleanup;
 
-    if (remoteAddClientStream(client, stream, 1) < 0)
-        goto cleanup;
+    make_nonnull_storage_vol(&ret->vol, vol);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (pool)
+        virStoragePoolFree(pool);
     if (vol)
         virStorageVolFree(vol);
-    if (stream && rv != 0) {
-        virStreamAbort(stream->st);
-        remoteFreeClientStream(client, stream);
-    }
     return rv;
 }
 
-
-/***************************
- * Register / deregister events
- ***************************/
 static int
-remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                   struct qemud_client *client ATTRIBUTE_UNUSED,
-                                   virConnectPtr conn,
-                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                   remote_error *rerr ATTRIBUTE_UNUSED,
-                                   void *args ATTRIBUTE_UNUSED,
-                                   remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
+remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                    struct qemud_client *client ATTRIBUTE_UNUSED,
+                                    virConnectPtr conn,
+                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                    remote_error *rerr,
+                                    remote_storage_vol_lookup_by_key_args *args,
+                                    remote_storage_vol_lookup_by_key_ret *ret)
 {
-    int callbackID;
+    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5597,37 +4093,32 @@ remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
-        goto cleanup;
-    }
-
-    if ((callbackID = virConnectDomainEventRegisterAny(conn,
-                                                       NULL,
-                                                       VIR_DOMAIN_EVENT_ID_LIFECYCLE,
-                                                       VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
-                                                       client, NULL)) < 0)
+    if (!(vol = virStorageVolLookupByKey(conn, args->key)))
         goto cleanup;
 
-    client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
+    make_nonnull_storage_vol(&ret->vol, vol);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (vol)
+        virStorageVolFree(vol);
     return rv;
 }
 
+
 static int
-remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSED,
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
                                      virConnectPtr conn,
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                     remote_error *rerr ATTRIBUTE_UNUSED,
-                                     void *args ATTRIBUTE_UNUSED,
-                                     remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
+                                     remote_error *rerr,
+                                     remote_storage_vol_lookup_by_path_args *args,
+                                     remote_storage_vol_lookup_by_path_ret *ret)
 {
+    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5635,96 +4126,34 @@ remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] < 0) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
+    if (!(vol = virStorageVolLookupByPath(conn, args->path)))
         goto cleanup;
-    }
 
-    if (virConnectDomainEventDeregisterAny(conn,
-                                           client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0)
-        goto cleanup;
+    make_nonnull_storage_vol(&ret->vol, vol);
 
-    client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (vol)
+        virStorageVolFree(vol);
     return rv;
 }
 
-static void
-remoteDispatchDomainEventSend(struct qemud_client *client,
-                              int procnr,
-                              xdrproc_t proc,
-                              void *data)
-{
-    struct qemud_client_message *msg = NULL;
-    XDR xdr;
-    unsigned int len;
-
-    if (VIR_ALLOC(msg) < 0)
-        return;
-
-    msg->hdr.prog = REMOTE_PROGRAM;
-    msg->hdr.vers = REMOTE_PROTOCOL_VERSION;
-    msg->hdr.proc = procnr;
-    msg->hdr.type = REMOTE_MESSAGE;
-    msg->hdr.serial = 1;
-    msg->hdr.status = REMOTE_OK;
-
-    if (remoteEncodeClientMessageHeader(msg) < 0)
-        goto cleanup;
-
-    /* Serialise the return header and event. */
-    xdrmem_create(&xdr,
-                  msg->buffer,
-                  msg->bufferLength,
-                  XDR_ENCODE);
-
-    /* Skip over the header we just wrote */
-    if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
-        goto xdr_cleanup;
-
-    if (!(proc)(&xdr, data)) {
-        VIR_WARN("Failed to serialize domain event %d", procnr);
-        goto xdr_cleanup;
-    }
-
-    /* Update length word to include payload*/
-    len = msg->bufferOffset = xdr_getpos(&xdr);
-    if (xdr_setpos(&xdr, 0) == 0)
-        goto xdr_cleanup;
-
-    if (!xdr_u_int(&xdr, &len))
-        goto xdr_cleanup;
-
-    /* Send it. */
-    msg->async = 1;
-    msg->bufferLength = len;
-    msg->bufferOffset = 0;
-
-    VIR_DEBUG("Queue event %d %d", procnr, msg->bufferLength);
-    qemudClientMessageQueuePush(&client->tx, msg);
-    qemudUpdateClientEvent(client);
-
-    xdr_destroy(&xdr);
-    return;
 
-xdr_cleanup:
-    xdr_destroy(&xdr);
-cleanup:
-    VIR_FREE(msg);
-}
+/***************************************************************
+ *     NODE INFO APIS
+ **************************************************************/
 
 static int
-remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
-                           struct qemud_client *client ATTRIBUTE_UNUSED,
-                           virConnectPtr conn,
-                           remote_message_header *hdr ATTRIBUTE_UNUSED,
-                           remote_error *rerr,
-                           void *args ATTRIBUTE_UNUSED,
-                           remote_num_of_secrets_ret *ret)
+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;
 
@@ -5733,7 +4162,9 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if ((ret->num = virConnectNumOfSecrets(conn)) < 0)
+    if ((ret->num = virNodeNumOfDevices(conn,
+                                        args->cap ? *args->cap : NULL,
+                                        args->flags)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -5744,14 +4175,15 @@ cleanup:
     return rv;
 }
 
+
 static int
-remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
-                          struct qemud_client *client ATTRIBUTE_UNUSED,
-                          virConnectPtr conn,
-                          remote_message_header *hdr ATTRIBUTE_UNUSED,
-                          remote_error *rerr,
-                          remote_list_secrets_args *args,
-                          remote_list_secrets_ret *ret)
+remoteDispatchNodeListDevices(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_list_devices_args *args,
+                              remote_node_list_devices_ret *ret)
 {
     int rv = -1;
     int len;
@@ -5761,76 +4193,46 @@ remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
-                    _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
+    if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR,
+                    "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
         goto cleanup;
     }
 
-    if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
+    /* Allocate return buffer. */
+    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
         virReportOOMError();
         goto cleanup;
     }
 
-    len = virConnectListSecrets(conn, ret->uuids.uuids_val,
-                                args->maxuuids);
+    len = virNodeListDevices(conn,
+                             args->cap ? *args->cap : NULL,
+                             ret->names.names_val, args->maxnames, args->flags);
     if (len < 0)
         goto cleanup;
-    ret->uuids.uuids_len = len;
+    ret->names.names_len = len;
 
     rv = 0;
 
 cleanup:
     if (rv < 0) {
         remoteDispatchError(rerr);
-        VIR_FREE(ret->uuids.uuids_val);
+        VIR_FREE(ret->names.names_val);
     }
     return rv;
 }
 
-static int
-remoteDispatchSecretDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED,
-                              struct qemud_client *client ATTRIBUTE_UNUSED,
-                              virConnectPtr conn,
-                              remote_message_header *hdr ATTRIBUTE_UNUSED,
-                              remote_error *rerr,
-                              remote_secret_define_xml_args *args,
-                              remote_secret_define_xml_ret *ret)
-{
-    virSecretPtr secret = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(secret = virSecretDefineXML(conn, args->xml, args->flags)))
-        goto cleanup;
-
-    make_nonnull_secret(&ret->secret, secret);
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
-    return rv;
-}
 
 static int
-remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
-                             struct qemud_client *client ATTRIBUTE_UNUSED,
-                             virConnectPtr conn,
-                             remote_message_header *hdr ATTRIBUTE_UNUSED,
-                             remote_error *rerr,
-                             remote_secret_get_value_args *args,
-                             remote_secret_get_value_ret *ret)
+remoteDispatchNodeDeviceLookupByName(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_device_lookup_by_name_args *args,
+                                     remote_node_device_lookup_by_name_ret *ret)
 {
-    virSecretPtr secret = NULL;
-    size_t value_size;
-    unsigned char *value;
+    virNodeDevicePtr dev = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5838,35 +4240,32 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(secret = get_nonnull_secret(conn, args->secret)))
-        goto cleanup;
-
-    if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
-    ret->value.value_len = value_size;
-    ret->value.value_val = (char *)value;
+    make_nonnull_node_device(&ret->dev, dev);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
+    if (dev)
+        virNodeDeviceFree(dev);
     return rv;
 }
 
 static int
-remoteDispatchSecretGetXMLDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
-                               struct qemud_client *client ATTRIBUTE_UNUSED,
-                               virConnectPtr conn,
-                               remote_message_header *hdr ATTRIBUTE_UNUSED,
-                               remote_error *rerr,
-                               remote_secret_get_xml_desc_args *args,
-                               remote_secret_get_xml_desc_ret *ret)
+remoteDispatchNodeDeviceGetParent(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_device_get_parent_args *args,
+                                  remote_node_device_get_parent_ret *ret)
 {
-    virSecretPtr secret = NULL;
+    virNodeDevicePtr dev = NULL;
+    const char *parent = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5874,63 +4273,99 @@ remoteDispatchSecretGetXMLDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(secret = get_nonnull_secret(conn, args->secret)))
-        goto cleanup;
-    if (!(ret->xml = virSecretGetXMLDesc(secret, args->flags)))
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
+    parent = virNodeDeviceGetParent(dev);
+
+    if (parent == NULL) {
+        ret->parent = NULL;
+    } else {
+        /* remoteDispatchClientRequest will free this. */
+        char **parent_p;
+        if (VIR_ALLOC(parent_p) < 0) {
+            virReportOOMError();
+            goto cleanup;
+        }
+        if (!(*parent_p = strdup(parent))) {
+            VIR_FREE(parent_p);
+            virReportOOMError();
+            goto cleanup;
+        }
+        ret->parent = parent_p;
+    }
+
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
+    if (dev)
+        virNodeDeviceFree(dev);
     return rv;
 }
 
 static int
-remoteDispatchSecretLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
                                  virConnectPtr conn,
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
                                  remote_error *rerr,
-                                 remote_secret_lookup_by_uuid_args *args,
-                                 remote_secret_lookup_by_uuid_ret *ret)
+                                 remote_node_device_list_caps_args *args,
+                                 remote_node_device_list_caps_ret *ret)
 {
-    virSecretPtr secret = NULL;
+    virNodeDevicePtr dev = NULL;
     int rv = -1;
+    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid)))
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
-    make_nonnull_secret(&ret->secret, secret);
+    if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR,
+                    "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
+        goto cleanup;
+    }
+
+    /* Allocate return buffer. */
+    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    len = virNodeDeviceListCaps(dev, ret->names.names_val,
+                                args->maxnames);
+    if (len < 0)
+        goto cleanup;
+    ret->names.names_len = len;
 
     rv = 0;
 
 cleanup:
-    if (rv < 0)
+    if (rv < 0) {
         remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
+        VIR_FREE(ret->names.names_val);
+    }
+    if (dev)
+        virNodeDeviceFree(dev);
     return rv;
 }
 
 static int
-remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
+remoteDispatchNodeDeviceCreateXML(struct qemud_server *server ATTRIBUTE_UNUSED,
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
                                   virConnectPtr conn,
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
                                   remote_error *rerr,
-                                  remote_secret_lookup_by_usage_args *args,
-                                  remote_secret_lookup_by_usage_ret *ret)
+                                  remote_node_device_create_xml_args *args,
+                                  remote_node_device_create_xml_ret *ret)
 {
-    virSecretPtr secret = NULL;
+    virNodeDevicePtr dev = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5938,31 +4373,31 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(secret = virSecretLookupByUsage(conn, args->usageType, args->usageID)))
+    if (!(dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags)))
         goto cleanup;
 
-    make_nonnull_secret(&ret->secret, secret);
+    make_nonnull_node_device(&ret->dev, dev);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
+    if (dev)
+        virNodeDeviceFree(dev);
     return rv;
 }
 
-
-static int remoteDispatchDomainIsActive(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_is_active_args *args,
-                                        remote_domain_is_active_ret *ret)
+static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                          struct qemud_client *client,
+                                          virConnectPtr conn,
+                                          remote_message_header *hdr,
+                                          remote_error *rerr,
+                                          remote_storage_vol_upload_args *args,
+                                          void *ret ATTRIBUTE_UNUSED)
 {
-    virDomainPtr dom = NULL;
+    struct qemud_client_stream *stream = NULL;
+    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -5970,10 +4405,18 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
+        goto cleanup;
+
+    if (!(stream = remoteCreateClientStream(conn, hdr)))
         goto cleanup;
 
-    if ((ret->active = virDomainIsActive(dom)) < 0)
+    if (virStorageVolUpload(vol, stream->st,
+                            args->offset, args->length,
+                            args->flags) < 0)
+        goto cleanup;
+
+    if (remoteAddClientStream(client, stream, 0) < 0)
         goto cleanup;
 
     rv = 0;
@@ -5981,20 +4424,25 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
+    if (vol)
+        virStorageVolFree(vol);
+    if (stream && rv != 0) {
+        virStreamAbort(stream->st);
+        remoteFreeClientStream(client, stream);
+    }
     return rv;
 }
 
-static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                            struct qemud_client *client ATTRIBUTE_UNUSED,
+static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                            struct qemud_client *client,
                                             virConnectPtr conn,
-                                            remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                            remote_message_header *hdr,
                                             remote_error *rerr,
-                                            remote_domain_is_persistent_args *args,
-                                            remote_domain_is_persistent_ret *ret)
+                                            remote_storage_vol_download_args *args,
+                                            void *ret ATTRIBUTE_UNUSED)
 {
-    virDomainPtr dom = NULL;
+    struct qemud_client_stream *stream = NULL;
+    virStorageVolPtr vol = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -6002,10 +4450,18 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
-    if ((ret->persistent = virDomainIsPersistent(dom)) < 0)
+    if (!(stream = remoteCreateClientStream(conn, hdr)))
+        goto cleanup;
+
+    if (virStorageVolDownload(vol, stream->st,
+                              args->offset, args->length,
+                              args->flags) < 0)
+        goto cleanup;
+
+    if (remoteAddClientStream(client, stream, 1) < 0)
         goto cleanup;
 
     rv = 0;
@@ -6013,20 +4469,29 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
+    if (vol)
+        virStorageVolFree(vol);
+    if (stream && rv != 0) {
+        virStreamAbort(stream->st);
+        remoteFreeClientStream(client, stream);
+    }
     return rv;
 }
 
-static int remoteDispatchDomainIsUpdated(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_is_updated_args *args,
-                                            remote_domain_is_updated_ret *ret)
+
+/***************************
+ * Register / deregister events
+ ***************************/
+static int
+remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr ATTRIBUTE_UNUSED,
+                                   void *args ATTRIBUTE_UNUSED,
+                                   remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
 {
-    virDomainPtr dom = NULL;
+    int callbackID;
     int rv = -1;
 
     if (!conn) {
@@ -6034,31 +4499,37 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
         goto cleanup;
+    }
 
-    if ((ret->updated = virDomainIsUpdated(dom)) < 0)
+    if ((callbackID = virConnectDomainEventRegisterAny(conn,
+                                                       NULL,
+                                                       VIR_DOMAIN_EVENT_ID_LIFECYCLE,
+                                                       VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
+                                                       client, NULL)) < 0)
         goto cleanup;
 
+    client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
+
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
     return rv;
 }
 
-static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                           struct qemud_client *client ATTRIBUTE_UNUSED,
-                                           virConnectPtr conn,
-                                           remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                           remote_error *rerr,
-                                           remote_interface_is_active_args *args,
-                                           remote_interface_is_active_ret *ret)
+static int
+remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                     struct qemud_client *client ATTRIBUTE_UNUSED,
+                                     virConnectPtr conn,
+                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                     remote_error *rerr ATTRIBUTE_UNUSED,
+                                     void *args ATTRIBUTE_UNUSED,
+                                     remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
 {
-    virInterfacePtr iface = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -6066,63 +4537,142 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
         goto cleanup;
     }
 
-    if (!(iface = get_nonnull_interface(conn, args->iface)))
+    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] < 0) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
         goto cleanup;
+    }
 
-    if ((ret->active = virInterfaceIsActive(iface)) < 0)
+    if (virConnectDomainEventDeregisterAny(conn,
+                                           client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0)
         goto cleanup;
 
+    client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
     rv = 0;
 
 cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (iface)
-        virInterfaceFree(iface);
-    return rv;
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static void
+remoteDispatchDomainEventSend(struct qemud_client *client,
+                              int procnr,
+                              xdrproc_t proc,
+                              void *data)
+{
+    struct qemud_client_message *msg = NULL;
+    XDR xdr;
+    unsigned int len;
+
+    if (VIR_ALLOC(msg) < 0)
+        return;
+
+    msg->hdr.prog = REMOTE_PROGRAM;
+    msg->hdr.vers = REMOTE_PROTOCOL_VERSION;
+    msg->hdr.proc = procnr;
+    msg->hdr.type = REMOTE_MESSAGE;
+    msg->hdr.serial = 1;
+    msg->hdr.status = REMOTE_OK;
+
+    if (remoteEncodeClientMessageHeader(msg) < 0)
+        goto cleanup;
+
+    /* Serialise the return header and event. */
+    xdrmem_create(&xdr,
+                  msg->buffer,
+                  msg->bufferLength,
+                  XDR_ENCODE);
+
+    /* Skip over the header we just wrote */
+    if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
+        goto xdr_cleanup;
+
+    if (!(proc)(&xdr, data)) {
+        VIR_WARN("Failed to serialize domain event %d", procnr);
+        goto xdr_cleanup;
+    }
+
+    /* Update length word to include payload*/
+    len = msg->bufferOffset = xdr_getpos(&xdr);
+    if (xdr_setpos(&xdr, 0) == 0)
+        goto xdr_cleanup;
+
+    if (!xdr_u_int(&xdr, &len))
+        goto xdr_cleanup;
+
+    /* Send it. */
+    msg->async = 1;
+    msg->bufferLength = len;
+    msg->bufferOffset = 0;
+
+    VIR_DEBUG("Queue event %d %d", procnr, msg->bufferLength);
+    qemudClientMessageQueuePush(&client->tx, msg);
+    qemudUpdateClientEvent(client);
+
+    xdr_destroy(&xdr);
+    return;
+
+xdr_cleanup:
+    xdr_destroy(&xdr);
+cleanup:
+    VIR_FREE(msg);
 }
 
-static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                         struct qemud_client *client ATTRIBUTE_UNUSED,
-                                         virConnectPtr conn,
-                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                         remote_error *rerr,
-                                         remote_network_is_active_args *args,
-                                         remote_network_is_active_ret *ret)
+static int
+remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
+                          struct qemud_client *client ATTRIBUTE_UNUSED,
+                          virConnectPtr conn,
+                          remote_message_header *hdr ATTRIBUTE_UNUSED,
+                          remote_error *rerr,
+                          remote_list_secrets_args *args,
+                          remote_list_secrets_ret *ret)
 {
-    virNetworkPtr net = NULL;
     int rv = -1;
+    int len;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
+    if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
+                    _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
+        goto cleanup;
+    }
+
+    if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
+        virReportOOMError();
         goto cleanup;
+    }
 
-    if ((ret->active = virNetworkIsActive(net)) < 0)
+    len = virConnectListSecrets(conn, ret->uuids.uuids_val,
+                                args->maxuuids);
+    if (len < 0)
         goto cleanup;
+    ret->uuids.uuids_len = len;
 
     rv = 0;
 
 cleanup:
-    if (rv < 0)
+    if (rv < 0) {
         remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
+        VIR_FREE(ret->uuids.uuids_val);
+    }
     return rv;
 }
 
-static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                             struct qemud_client *client ATTRIBUTE_UNUSED,
-                                             virConnectPtr conn,
-                                             remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                             remote_error *rerr,
-                                             remote_network_is_persistent_args *args,
-                                             remote_network_is_persistent_ret *ret)
+static int
+remoteDispatchSecretDefineXML(struct qemud_server *server ATTRIBUTE_UNUSED,
+                              struct qemud_client *client ATTRIBUTE_UNUSED,
+                              virConnectPtr conn,
+                              remote_message_header *hdr ATTRIBUTE_UNUSED,
+                              remote_error *rerr,
+                              remote_secret_define_xml_args *args,
+                              remote_secret_define_xml_ret *ret)
 {
-    virNetworkPtr net = NULL;
+    virSecretPtr secret = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -6130,31 +4680,32 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
-        goto cleanup;
-
-    if ((ret->persistent = virNetworkIsPersistent(net)) < 0)
+    if (!(secret = virSecretDefineXML(conn, args->xml, args->flags)))
         goto cleanup;
 
+    make_nonnull_secret(&ret->secret, secret);
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
+    if (secret)
+        virSecretFree(secret);
     return rv;
 }
 
-static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                             struct qemud_client *client ATTRIBUTE_UNUSED,
-                                             virConnectPtr conn,
-                                             remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                             remote_error *rerr,
-                                             remote_storage_pool_is_active_args *args,
-                                             remote_storage_pool_is_active_ret *ret)
+static int
+remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
+                             struct qemud_client *client ATTRIBUTE_UNUSED,
+                             virConnectPtr conn,
+                             remote_message_header *hdr ATTRIBUTE_UNUSED,
+                             remote_error *rerr,
+                             remote_secret_get_value_args *args,
+                             remote_secret_get_value_ret *ret)
 {
-    virStoragePoolPtr pool = NULL;
+    virSecretPtr secret = NULL;
+    size_t value_size;
+    unsigned char *value;
     int rv = -1;
 
     if (!conn) {
@@ -6162,31 +4713,35 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
         goto cleanup;
     }
 
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
         goto cleanup;
 
-    if ((ret->active = virStoragePoolIsActive(pool)) < 0)
+    if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
         goto cleanup;
 
+    ret->value.value_len = value_size;
+    ret->value.value_val = (char *)value;
+
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
+    if (secret)
+        virSecretFree(secret);
     return rv;
 }
 
-static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                                 struct qemud_client *client ATTRIBUTE_UNUSED,
-                                                 virConnectPtr conn,
-                                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                                 remote_error *rerr,
-                                                 remote_storage_pool_is_persistent_args *args,
-                                                 remote_storage_pool_is_persistent_ret *ret)
+static int
+remoteDispatchSecretLookupByUUID(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                 struct qemud_client *client ATTRIBUTE_UNUSED,
+                                 virConnectPtr conn,
+                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                 remote_error *rerr,
+                                 remote_secret_lookup_by_uuid_args *args,
+                                 remote_secret_lookup_by_uuid_ret *ret)
 {
-    virStoragePoolPtr pool = NULL;
+    virSecretPtr secret = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -6194,31 +4749,31 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
         goto cleanup;
     }
 
-    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
+    if (!(secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid)))
         goto cleanup;
 
-    if ((ret->persistent = virStoragePoolIsPersistent(pool)) < 0)
-        goto cleanup;
+    make_nonnull_secret(&ret->secret, secret);
 
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (pool)
-        virStoragePoolFree(pool);
+    if (secret)
+        virSecretFree(secret);
     return rv;
 }
 
-
-static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
+static int
+remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
                                   virConnectPtr conn,
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
                                   remote_error *rerr,
-                                  void *args ATTRIBUTE_UNUSED,
-                                  remote_is_secure_ret *ret)
+                                  remote_secret_lookup_by_usage_args *args,
+                                  remote_secret_lookup_by_usage_ret *ret)
 {
+    virSecretPtr secret = NULL;
     int rv = -1;
 
     if (!conn) {
@@ -6226,18 +4781,21 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if ((ret->secure = virConnectIsSecure(conn)) < 0)
+    if (!(secret = virSecretLookupByUsage(conn, args->usageType, args->usageID)))
         goto cleanup;
 
+    make_nonnull_secret(&ret->secret, secret);
+
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (secret)
+        virSecretFree(secret);
     return rv;
 }
 
-
 static int
 remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
                          struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -6387,79 +4945,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchDomainSnapshotDumpXML(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_snapshot_dump_xml_args *args,
-                                    remote_domain_snapshot_dump_xml_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    virDomainSnapshotPtr snapshot = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(dom = get_nonnull_domain(conn, args->snap.dom)))
-        goto cleanup;
-
-    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
-        goto cleanup;
-
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags)))
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (snapshot)
-        virDomainSnapshotFree(snapshot);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
-static int
-remoteDispatchDomainSnapshotNum(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_snapshot_num_args *args,
-                                remote_domain_snapshot_num_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    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;
-
-    if ((ret->num = virDomainSnapshotNum(dom, args->flags)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
 static int
 remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUSED,
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -6551,43 +5036,6 @@ cleanup:
     return rv;
 }
 
-static int
-remoteDispatchDomainHasCurrentSnapshot(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_has_current_snapshot_args *args,
-                                       remote_domain_has_current_snapshot_ret *ret)
-{
-    virDomainPtr dom = NULL;
-    int result;
-    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;
-
-    result = virDomainHasCurrentSnapshot(dom, args->flags);
-    if (result < 0)
-        goto cleanup;
-
-    ret->result = result;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (dom)
-        virDomainFree(dom);
-    return rv;
-}
-
 static int
 remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED,
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
@@ -6856,70 +5304,6 @@ cleanup:
     return rv;
 }
 
-
-static int
-remoteDispatchNWFilterGetXMLDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
-                                 struct qemud_client *client ATTRIBUTE_UNUSED,
-                                 virConnectPtr conn,
-                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
-                                 remote_error *rerr,
-                                 remote_nwfilter_get_xml_desc_args *args,
-                                 remote_nwfilter_get_xml_desc_ret *ret)
-{
-    virNWFilterPtr nwfilter = NULL;
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
-        goto cleanup;
-
-    /* remoteDispatchClientRequest will free this. */
-    if (!(ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags)))
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    if (nwfilter)
-        virNWFilterFree(nwfilter);
-    return rv;
-}
-
-
-static int
-remoteDispatchNumOfNWFilters(struct qemud_server *server ATTRIBUTE_UNUSED,
-                             struct qemud_client *client ATTRIBUTE_UNUSED,
-                             virConnectPtr conn,
-                             remote_message_header *hdr ATTRIBUTE_UNUSED,
-                             remote_error *rerr,
-                             void *args ATTRIBUTE_UNUSED,
-                             remote_num_of_nwfilters_ret *ret)
-{
-    int rv = -1;
-
-    if (!conn) {
-        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
-        goto cleanup;
-    }
-
-    if ((ret->num = virConnectNumOfNWFilters(conn)) < 0)
-        goto cleanup;
-
-    rv = 0;
-
-cleanup:
-    if (rv < 0)
-        remoteDispatchError(rerr);
-    return rv;
-}
-
-
 static int
 remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
index 79c3221b0c68d55b1fc6a4af2b44c80fed65c929..0ae342da74769ee4e2c0031450c234bc9527c47d 100644 (file)
@@ -301,74 +301,19 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainDumpXML has to be implemented manually */
-
-/* remoteDispatchDomainEventsDeregister has to be implemented manually */
-
-/* remoteDispatchDomainEventsDeregisterAny has to be implemented manually */
-
-/* remoteDispatchDomainEventsRegister has to be implemented manually */
-
-/* remoteDispatchDomainEventsRegisterAny has to be implemented manually */
-
-/* remoteDispatchDomainGetAutostart has to be implemented manually */
-
-/* remoteDispatchDomainGetBlkioParameters has to be implemented manually */
-
-/* remoteDispatchDomainGetBlockInfo has to be implemented manually */
-
-/* remoteDispatchDomainGetInfo has to be implemented manually */
-
-/* remoteDispatchDomainGetJobInfo has to be implemented manually */
-
-/* remoteDispatchDomainGetMaxMemory has to be implemented manually */
-
-/* remoteDispatchDomainGetMaxVcpus has to be implemented manually */
-
-/* remoteDispatchDomainGetMemoryParameters has to be implemented manually */
-
-/* remoteDispatchDomainGetOsType has to be implemented manually */
-
-/* remoteDispatchDomainGetSchedulerParameters has to be implemented manually */
-
-/* remoteDispatchDomainGetSchedulerType has to be implemented manually */
-
-/* remoteDispatchDomainGetSecurityLabel has to be implemented manually */
-
-/* remoteDispatchDomainGetVcpus has to be implemented manually */
-
-/* remoteDispatchDomainGetVcpusFlags has to be implemented manually */
-
-/* remoteDispatchDomainHasCurrentSnapshot has to be implemented manually */
-
-/* remoteDispatchDomainHasManagedSaveImage has to be implemented manually */
-
-/* remoteDispatchDomainInterfaceStats has to be implemented manually */
-
-/* remoteDispatchDomainIsActive has to be implemented manually */
-
-/* remoteDispatchDomainIsPersistent has to be implemented manually */
-
-/* remoteDispatchDomainIsUpdated has to be implemented manually */
-
-/* remoteDispatchDomainLookupById has to be implemented manually */
-
-/* remoteDispatchDomainLookupByName has to be implemented manually */
-
-/* remoteDispatchDomainLookupByUUID has to be implemented manually */
-
 static int
-remoteDispatchDomainManagedSave(
+remoteDispatchDomainDumpXML(
     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_managed_save_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_dump_xml_args *args,
+    remote_domain_dump_xml_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    char *xml;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -378,9 +323,10 @@ remoteDispatchDomainManagedSave(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainManagedSave(dom, args->flags) < 0)
+    if ((xml = virDomainGetXMLDesc(dom, args->flags)) == NULL)
         goto cleanup;
 
+    ret->xml = xml;
     rv = 0;
 
 cleanup:
@@ -391,18 +337,27 @@ cleanup:
     return rv;
 }
 
+/* remoteDispatchDomainEventsDeregister has to be implemented manually */
+
+/* remoteDispatchDomainEventsDeregisterAny has to be implemented manually */
+
+/* remoteDispatchDomainEventsRegister has to be implemented manually */
+
+/* remoteDispatchDomainEventsRegisterAny has to be implemented manually */
+
 static int
-remoteDispatchDomainManagedSaveRemove(
+remoteDispatchDomainGetAutostart(
     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_managed_save_remove_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_get_autostart_args *args,
+    remote_domain_get_autostart_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    int autostart;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -412,9 +367,10 @@ remoteDispatchDomainManagedSaveRemove(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainManagedSaveRemove(dom, args->flags) < 0)
+    if (virDomainGetAutostart(dom, &autostart) < 0)
         goto cleanup;
 
+    ret->autostart = autostart;
     rv = 0;
 
 cleanup:
@@ -425,34 +381,27 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainMemoryPeek has to be implemented manually */
-
-/* remoteDispatchDomainMemoryStats has to be implemented manually */
-
-/* remoteDispatchDomainMigrateFinish has to be implemented manually */
-
-/* remoteDispatchDomainMigrateFinish2 has to be implemented manually */
-
-/* remoteDispatchDomainMigratePerform has to be implemented manually */
+/* remoteDispatchDomainGetBlkioParameters has to be implemented manually */
 
-/* remoteDispatchDomainMigratePrepare has to be implemented manually */
+/* remoteDispatchDomainGetBlockInfo has to be implemented manually */
 
-/* remoteDispatchDomainMigratePrepare2 has to be implemented manually */
+/* remoteDispatchDomainGetInfo has to be implemented manually */
 
-/* remoteDispatchDomainMigratePrepareTunnel has to be implemented manually */
+/* remoteDispatchDomainGetJobInfo has to be implemented manually */
 
 static int
-remoteDispatchDomainMigrateSetMaxDowntime(
+remoteDispatchDomainGetMaxMemory(
     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_set_max_downtime_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_get_max_memory_args *args,
+    remote_domain_get_max_memory_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    unsigned long memory;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -462,9 +411,10 @@ remoteDispatchDomainMigrateSetMaxDowntime(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0)
+    if ((memory = virDomainGetMaxMemory(dom)) == 0)
         goto cleanup;
 
+    ret->memory = memory;
     rv = 0;
 
 cleanup:
@@ -476,17 +426,18 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainMigrateSetMaxSpeed(
+remoteDispatchDomainGetMaxVcpus(
     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_set_max_speed_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_get_max_vcpus_args *args,
+    remote_domain_get_max_vcpus_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    int num;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -496,9 +447,10 @@ remoteDispatchDomainMigrateSetMaxSpeed(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0)
+    if ((num = virDomainGetMaxVcpus(dom)) < 0)
         goto cleanup;
 
+    ret->num = num;
     rv = 0;
 
 cleanup:
@@ -509,22 +461,21 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainOpenConsole has to be implemented manually */
-
-/* remoteDispatchDomainPinVcpu has to be implemented manually */
+/* remoteDispatchDomainGetMemoryParameters has to be implemented manually */
 
 static int
-remoteDispatchDomainReboot(
+remoteDispatchDomainGetOsType(
     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_reboot_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_get_os_type_args *args,
+    remote_domain_get_os_type_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    char *type;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -534,9 +485,10 @@ remoteDispatchDomainReboot(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainReboot(dom, args->flags) < 0)
+    if ((type = virDomainGetOSType(dom)) == NULL)
         goto cleanup;
 
+    ret->type = type;
     rv = 0;
 
 cleanup:
@@ -547,48 +499,63 @@ cleanup:
     return rv;
 }
 
+/* remoteDispatchDomainGetSchedulerParameters has to be implemented manually */
+
+/* remoteDispatchDomainGetSchedulerType has to be implemented manually */
+
+/* remoteDispatchDomainGetSecurityLabel has to be implemented manually */
+
+/* remoteDispatchDomainGetVcpus has to be implemented manually */
+
 static int
-remoteDispatchDomainRestore(
+remoteDispatchDomainGetVcpusFlags(
     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_restore_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_get_vcpus_flags_args *args,
+    remote_domain_get_vcpus_flags_ret *ret)
 {
     int rv = -1;
+    virDomainPtr dom = NULL;
+    int num;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
 
-    if (virDomainRestore(conn, args->from) < 0)
+    if ((num = virDomainGetVcpusFlags(dom, args->flags)) < 0)
         goto cleanup;
 
+    ret->num = num;
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
 static int
-remoteDispatchDomainResume(
+remoteDispatchDomainHasCurrentSnapshot(
     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_resume_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_has_current_snapshot_args *args,
+    remote_domain_has_current_snapshot_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    int result;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -598,9 +565,10 @@ remoteDispatchDomainResume(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainResume(dom) < 0)
+    if ((result = virDomainHasCurrentSnapshot(dom, args->flags)) < 0)
         goto cleanup;
 
+    ret->result = result;
     rv = 0;
 
 cleanup:
@@ -612,57 +580,56 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainRevertToSnapshot(
+remoteDispatchDomainHasManagedSaveImage(
     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_revert_to_snapshot_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_has_managed_save_image_args *args,
+    remote_domain_has_managed_save_image_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
-    virDomainSnapshotPtr snapshot = NULL;
+    int result;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->snap.dom)))
-        goto cleanup;
-
-    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
+    if ((result = virDomainHasManagedSaveImage(dom, args->flags)) < 0)
         goto cleanup;
 
+    ret->result = result;
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (snapshot)
-        virDomainSnapshotFree(snapshot);
     if (dom)
         virDomainFree(dom);
     return rv;
 }
 
+/* remoteDispatchDomainInterfaceStats has to be implemented manually */
+
 static int
-remoteDispatchDomainSave(
+remoteDispatchDomainIsActive(
     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_save_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_is_active_args *args,
+    remote_domain_is_active_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    int active;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -672,9 +639,10 @@ remoteDispatchDomainSave(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSave(dom, args->to) < 0)
+    if ((active = virDomainIsActive(dom)) < 0)
         goto cleanup;
 
+    ret->active = active;
     rv = 0;
 
 cleanup:
@@ -686,17 +654,18 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainSetAutostart(
+remoteDispatchDomainIsPersistent(
     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_set_autostart_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_is_persistent_args *args,
+    remote_domain_is_persistent_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    int persistent;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -706,9 +675,10 @@ remoteDispatchDomainSetAutostart(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetAutostart(dom, args->autostart) < 0)
+    if ((persistent = virDomainIsPersistent(dom)) < 0)
         goto cleanup;
 
+    ret->persistent = persistent;
     rv = 0;
 
 cleanup:
@@ -719,20 +689,19 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainSetBlkioParameters has to be implemented manually */
-
 static int
-remoteDispatchDomainSetMaxMemory(
+remoteDispatchDomainIsUpdated(
     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_set_max_memory_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_is_updated_args *args,
+    remote_domain_is_updated_ret *ret)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    int updated;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -742,9 +711,10 @@ remoteDispatchDomainSetMaxMemory(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetMaxMemory(dom, args->memory) < 0)
+    if ((updated = virDomainIsUpdated(dom)) < 0)
         goto cleanup;
 
+    ret->updated = updated;
     rv = 0;
 
 cleanup:
@@ -755,14 +725,20 @@ cleanup:
     return rv;
 }
 
+/* remoteDispatchDomainLookupById has to be implemented manually */
+
+/* remoteDispatchDomainLookupByName has to be implemented manually */
+
+/* remoteDispatchDomainLookupByUUID has to be implemented manually */
+
 static int
-remoteDispatchDomainSetMemory(
+remoteDispatchDomainManagedSave(
     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_set_memory_args *args,
+    remote_domain_managed_save_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -776,7 +752,7 @@ remoteDispatchDomainSetMemory(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetMemory(dom, args->memory) < 0)
+    if (virDomainManagedSave(dom, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -790,13 +766,13 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainSetMemoryFlags(
+remoteDispatchDomainManagedSaveRemove(
     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_set_memory_flags_args *args,
+    remote_domain_managed_save_remove_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -810,7 +786,7 @@ remoteDispatchDomainSetMemoryFlags(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0)
+    if (virDomainManagedSaveRemove(dom, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -823,18 +799,30 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainSetMemoryParameters has to be implemented manually */
+/* remoteDispatchDomainMemoryPeek has to be implemented manually */
 
-/* remoteDispatchDomainSetSchedulerParameters has to be implemented manually */
+/* remoteDispatchDomainMemoryStats has to be implemented manually */
+
+/* remoteDispatchDomainMigrateFinish has to be implemented manually */
+
+/* remoteDispatchDomainMigrateFinish2 has to be implemented manually */
+
+/* remoteDispatchDomainMigratePerform has to be implemented manually */
+
+/* remoteDispatchDomainMigratePrepare has to be implemented manually */
+
+/* remoteDispatchDomainMigratePrepare2 has to be implemented manually */
+
+/* remoteDispatchDomainMigratePrepareTunnel has to be implemented manually */
 
 static int
-remoteDispatchDomainSetVcpus(
+remoteDispatchDomainMigrateSetMaxDowntime(
     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_set_vcpus_args *args,
+    remote_domain_migrate_set_max_downtime_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -848,7 +836,7 @@ remoteDispatchDomainSetVcpus(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetVcpus(dom, args->nvcpus) < 0)
+    if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -862,13 +850,13 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainSetVcpusFlags(
+remoteDispatchDomainMigrateSetMaxSpeed(
     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_set_vcpus_flags_args *args,
+    remote_domain_migrate_set_max_speed_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -882,7 +870,7 @@ remoteDispatchDomainSetVcpusFlags(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0)
+    if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -895,14 +883,18 @@ cleanup:
     return rv;
 }
 
+/* remoteDispatchDomainOpenConsole has to be implemented manually */
+
+/* remoteDispatchDomainPinVcpu has to be implemented manually */
+
 static int
-remoteDispatchDomainShutdown(
+remoteDispatchDomainReboot(
     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_shutdown_args *args,
+    remote_domain_reboot_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -916,7 +908,7 @@ remoteDispatchDomainShutdown(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainShutdown(dom) < 0)
+    if (virDomainReboot(dom, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -929,36 +921,24 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainSnapshotCreateXML has to be implemented manually */
-
-/* remoteDispatchDomainSnapshotCurrent has to be implemented manually */
-
 static int
-remoteDispatchDomainSnapshotDelete(
+remoteDispatchDomainRestore(
     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_snapshot_delete_args *args,
+    remote_domain_restore_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virDomainPtr dom = NULL;
-    virDomainSnapshotPtr snapshot = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->snap.dom)))
-        goto cleanup;
-
-    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
-        goto cleanup;
-
-    if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
+    if (virDomainRestore(conn, args->from) < 0)
         goto cleanup;
 
     rv = 0;
@@ -966,29 +946,17 @@ remoteDispatchDomainSnapshotDelete(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (snapshot)
-        virDomainSnapshotFree(snapshot);
-    if (dom)
-        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchDomainSnapshotDumpXML has to be implemented manually */
-
-/* remoteDispatchDomainSnapshotListNames has to be implemented manually */
-
-/* remoteDispatchDomainSnapshotLookupByName has to be implemented manually */
-
-/* remoteDispatchDomainSnapshotNum has to be implemented manually */
-
 static int
-remoteDispatchDomainSuspend(
+remoteDispatchDomainResume(
     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_suspend_args *args,
+    remote_domain_resume_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -1002,7 +970,7 @@ remoteDispatchDomainSuspend(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainSuspend(dom) < 0)
+    if (virDomainResume(dom) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1016,27 +984,31 @@ cleanup:
 }
 
 static int
-remoteDispatchDomainUndefine(
+remoteDispatchDomainRevertToSnapshot(
     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_undefine_args *args,
+    remote_domain_revert_to_snapshot_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
     virDomainPtr dom = NULL;
+    virDomainSnapshotPtr snapshot = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dom = get_nonnull_domain(conn, args->dom)))
+    if (!(dom = get_nonnull_domain(conn, args->snap.dom)))
         goto cleanup;
 
-    if (virDomainUndefine(dom) < 0)
+    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
+        goto cleanup;
+
+    if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1044,19 +1016,21 @@ remoteDispatchDomainUndefine(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
+    if (snapshot)
+        virDomainSnapshotFree(snapshot);
     if (dom)
         virDomainFree(dom);
     return rv;
 }
 
 static int
-remoteDispatchDomainUpdateDeviceFlags(
+remoteDispatchDomainSave(
     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_update_device_flags_args *args,
+    remote_domain_save_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
@@ -1070,7 +1044,7 @@ remoteDispatchDomainUpdateDeviceFlags(
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0)
+    if (virDomainSave(dom, args->to) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1083,50 +1057,64 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchDomainXMLFromNative has to be implemented manually */
-
-/* remoteDispatchDomainXMLToNative has to be implemented manually */
-
-/* remoteDispatchFindStoragePoolSources has to be implemented manually */
-
-/* remoteDispatchGetCapabilities has to be implemented manually */
-
-/* remoteDispatchGetHostname has to be implemented manually */
+static int
+remoteDispatchDomainSetAutostart(
+    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_set_autostart_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virDomainPtr dom = NULL;
 
-/* remoteDispatchGetLibVersion has to be implemented manually */
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
 
-/* remoteDispatchGetMaxVcpus has to be implemented manually */
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
 
-/* remoteDispatchGetSysinfo has to be implemented manually */
+    if (virDomainSetAutostart(dom, args->autostart) < 0)
+        goto cleanup;
 
-/* remoteDispatchGetType has to be implemented manually */
+    rv = 0;
 
-/* remoteDispatchGetURI has to be implemented manually */
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
 
-/* remoteDispatchGetVersion has to be implemented manually */
+/* remoteDispatchDomainSetBlkioParameters has to be implemented manually */
 
 static int
-remoteDispatchInterfaceCreate(
+remoteDispatchDomainSetMaxMemory(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_interface_create_args *args,
+    remote_domain_set_max_memory_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virInterfacePtr iface = NULL;
+    virDomainPtr dom = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(iface = get_nonnull_interface(conn, args->iface)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virInterfaceCreate(iface, args->flags) < 0)
+    if (virDomainSetMaxMemory(dom, args->memory) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1134,35 +1122,33 @@ remoteDispatchInterfaceCreate(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (iface)
-        virInterfaceFree(iface);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchInterfaceDefineXML has to be implemented manually */
-
 static int
-remoteDispatchInterfaceDestroy(
+remoteDispatchDomainSetMemory(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_interface_destroy_args *args,
+    remote_domain_set_memory_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virInterfacePtr iface = NULL;
+    virDomainPtr dom = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(iface = get_nonnull_interface(conn, args->iface)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virInterfaceDestroy(iface, args->flags) < 0)
+    if (virDomainSetMemory(dom, args->memory) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1170,41 +1156,33 @@ remoteDispatchInterfaceDestroy(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (iface)
-        virInterfaceFree(iface);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchInterfaceGetXMLDesc has to be implemented manually */
-
-/* remoteDispatchInterfaceIsActive has to be implemented manually */
-
-/* remoteDispatchInterfaceLookupByMacString has to be implemented manually */
-
-/* remoteDispatchInterfaceLookupByName has to be implemented manually */
-
 static int
-remoteDispatchInterfaceUndefine(
+remoteDispatchDomainSetMemoryFlags(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_interface_undefine_args *args,
+    remote_domain_set_memory_flags_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virInterfacePtr iface = NULL;
+    virDomainPtr dom = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(iface = get_nonnull_interface(conn, args->iface)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virInterfaceUndefine(iface) < 0)
+    if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1212,55 +1190,71 @@ remoteDispatchInterfaceUndefine(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (iface)
-        virInterfaceFree(iface);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchIsSecure has to be implemented manually */
-
-/* remoteDispatchListDefinedDomains has to be implemented manually */
-
-/* remoteDispatchListDefinedInterfaces has to be implemented manually */
-
-/* remoteDispatchListDefinedNetworks has to be implemented manually */
+/* remoteDispatchDomainSetMemoryParameters has to be implemented manually */
 
-/* remoteDispatchListDefinedStoragePools has to be implemented manually */
+/* remoteDispatchDomainSetSchedulerParameters has to be implemented manually */
 
-/* remoteDispatchListDomains has to be implemented manually */
+static int
+remoteDispatchDomainSetVcpus(
+    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_set_vcpus_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virDomainPtr dom = NULL;
 
-/* remoteDispatchListInterfaces has to be implemented manually */
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
 
-/* remoteDispatchListNetworks has to be implemented manually */
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
 
-/* remoteDispatchListNWFilters has to be implemented manually */
+    if (virDomainSetVcpus(dom, args->nvcpus) < 0)
+        goto cleanup;
 
-/* remoteDispatchListSecrets has to be implemented manually */
+    rv = 0;
 
-/* remoteDispatchListStoragePools has to be implemented manually */
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
 
 static int
-remoteDispatchNetworkCreate(
+remoteDispatchDomainSetVcpusFlags(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_network_create_args *args,
+    remote_domain_set_vcpus_flags_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNetworkPtr net = NULL;
+    virDomainPtr dom = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virNetworkCreate(net) < 0)
+    if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1268,37 +1262,33 @@ remoteDispatchNetworkCreate(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchNetworkCreateXML has to be implemented manually */
-
-/* remoteDispatchNetworkDefineXML has to be implemented manually */
-
 static int
-remoteDispatchNetworkDestroy(
+remoteDispatchDomainShutdown(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_network_destroy_args *args,
+    remote_domain_shutdown_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNetworkPtr net = NULL;
+    virDomainPtr dom = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virNetworkDestroy(net) < 0)
+    if (virDomainShutdown(dom) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1306,117 +1296,159 @@ remoteDispatchNetworkDestroy(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchNetworkDumpXML has to be implemented manually */
+/* remoteDispatchDomainSnapshotCreateXML has to be implemented manually */
+
+/* remoteDispatchDomainSnapshotCurrent has to be implemented manually */
+
+static int
+remoteDispatchDomainSnapshotDelete(
+    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_snapshot_delete_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virDomainPtr dom = NULL;
+    virDomainSnapshotPtr snapshot = NULL;
 
-/* remoteDispatchNetworkGetAutostart has to be implemented manually */
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
 
-/* remoteDispatchNetworkGetBridgeName has to be implemented manually */
+    if (!(dom = get_nonnull_domain(conn, args->snap.dom)))
+        goto cleanup;
 
-/* remoteDispatchNetworkIsActive has to be implemented manually */
+    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
+        goto cleanup;
 
-/* remoteDispatchNetworkIsPersistent has to be implemented manually */
+    if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
+        goto cleanup;
 
-/* remoteDispatchNetworkLookupByName has to be implemented manually */
+    rv = 0;
 
-/* remoteDispatchNetworkLookupByUUID has to be implemented manually */
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (snapshot)
+        virDomainSnapshotFree(snapshot);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
 
 static int
-remoteDispatchNetworkSetAutostart(
+remoteDispatchDomainSnapshotDumpXML(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_network_set_autostart_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_snapshot_dump_xml_args *args,
+    remote_domain_snapshot_dump_xml_ret *ret)
 {
     int rv = -1;
-    virNetworkPtr net = NULL;
+    virDomainPtr dom = NULL;
+    virDomainSnapshotPtr snapshot = NULL;
+    char *xml;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
+    if (!(dom = get_nonnull_domain(conn, args->snap.dom)))
         goto cleanup;
 
-    if (virNetworkSetAutostart(net, args->autostart) < 0)
+    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
+        goto cleanup;
+
+    if ((xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags)) == NULL)
         goto cleanup;
 
+    ret->xml = xml;
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
+    if (snapshot)
+        virDomainSnapshotFree(snapshot);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
+/* remoteDispatchDomainSnapshotListNames has to be implemented manually */
+
+/* remoteDispatchDomainSnapshotLookupByName has to be implemented manually */
+
 static int
-remoteDispatchNetworkUndefine(
+remoteDispatchDomainSnapshotNum(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_network_undefine_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_domain_snapshot_num_args *args,
+    remote_domain_snapshot_num_ret *ret)
 {
     int rv = -1;
-    virNetworkPtr net = NULL;
+    virDomainPtr dom = NULL;
+    int num;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(conn, args->net)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virNetworkUndefine(net) < 0)
+    if ((num = virDomainSnapshotNum(dom, args->flags)) < 0)
         goto cleanup;
 
+    ret->num = num;
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (net)
-        virNetworkFree(net);
+    if (dom)
+        virDomainFree(dom);
     return rv;
 }
 
-/* remoteDispatchNodeDeviceCreateXML has to be implemented manually */
-
 static int
-remoteDispatchNodeDeviceDestroy(
+remoteDispatchDomainSuspend(
     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_device_destroy_args *args,
+    remote_domain_suspend_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNodeDevicePtr dev = NULL;
+    virDomainPtr dom = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (virNodeDeviceDestroy(dev) < 0)
+    if (virDomainSuspend(dom) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1424,33 +1456,1585 @@ remoteDispatchNodeDeviceDestroy(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+static int
+remoteDispatchDomainUndefine(
+    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_undefine_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virDomainPtr dom = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    if (virDomainUndefine(dom) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+static int
+remoteDispatchDomainUpdateDeviceFlags(
+    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_update_device_flags_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virDomainPtr dom = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+static int
+remoteDispatchDomainXMLFromNative(
+    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_xml_from_native_args *args,
+    remote_domain_xml_from_native_ret *ret)
+{
+    int rv = -1;
+    char *domainXml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((domainXml = virConnectDomainXMLFromNative(conn, args->nativeFormat, args->nativeConfig, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->domainXml = domainXml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchDomainXMLToNative(
+    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_xml_to_native_args *args,
+    remote_domain_xml_to_native_ret *ret)
+{
+    int rv = -1;
+    char *nativeConfig;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((nativeConfig = virConnectDomainXMLToNative(conn, args->nativeFormat, args->domainXml, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->nativeConfig = nativeConfig;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+/* remoteDispatchFindStoragePoolSources has to be implemented manually */
+
+static int
+remoteDispatchGetCapabilities(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_get_capabilities_ret *ret)
+{
+    int rv = -1;
+    char *capabilities;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((capabilities = virConnectGetCapabilities(conn)) == NULL)
+        goto cleanup;
+
+    ret->capabilities = capabilities;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchGetHostname(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_get_hostname_ret *ret)
+{
+    int rv = -1;
+    char *hostname;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((hostname = virConnectGetHostname(conn)) == NULL)
+        goto cleanup;
+
+    ret->hostname = hostname;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchGetLibVersion(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_get_lib_version_ret *ret)
+{
+    int rv = -1;
+    unsigned long lib_ver;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (virConnectGetLibVersion(conn, &lib_ver) < 0)
+        goto cleanup;
+
+    ret->lib_ver = lib_ver;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+/* remoteDispatchGetMaxVcpus has to be implemented manually */
+
+static int
+remoteDispatchGetSysinfo(
+    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_sysinfo_args *args,
+    remote_get_sysinfo_ret *ret)
+{
+    int rv = -1;
+    char *sysinfo;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((sysinfo = virConnectGetSysinfo(conn, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->sysinfo = sysinfo;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+/* remoteDispatchGetType has to be implemented manually */
+
+static int
+remoteDispatchGetURI(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_get_uri_ret *ret)
+{
+    int rv = -1;
+    char *uri;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((uri = virConnectGetURI(conn)) == NULL)
+        goto cleanup;
+
+    ret->uri = uri;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchGetVersion(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_get_version_ret *ret)
+{
+    int rv = -1;
+    unsigned long hv_ver;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (virConnectGetVersion(conn, &hv_ver) < 0)
+        goto cleanup;
+
+    ret->hv_ver = hv_ver;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchInterfaceCreate(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_interface_create_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virInterfacePtr iface = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
+        goto cleanup;
+
+    if (virInterfaceCreate(iface, args->flags) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (iface)
+        virInterfaceFree(iface);
+    return rv;
+}
+
+/* remoteDispatchInterfaceDefineXML has to be implemented manually */
+
+static int
+remoteDispatchInterfaceDestroy(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_interface_destroy_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virInterfacePtr iface = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
+        goto cleanup;
+
+    if (virInterfaceDestroy(iface, args->flags) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (iface)
+        virInterfaceFree(iface);
+    return rv;
+}
+
+static int
+remoteDispatchInterfaceGetXMLDesc(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_interface_get_xml_desc_args *args,
+    remote_interface_get_xml_desc_ret *ret)
+{
+    int rv = -1;
+    virInterfacePtr iface = NULL;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
+        goto cleanup;
+
+    if ((xml = virInterfaceGetXMLDesc(iface, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (iface)
+        virInterfaceFree(iface);
+    return rv;
+}
+
+static int
+remoteDispatchInterfaceIsActive(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_interface_is_active_args *args,
+    remote_interface_is_active_ret *ret)
+{
+    int rv = -1;
+    virInterfacePtr iface = NULL;
+    int active;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
+        goto cleanup;
+
+    if ((active = virInterfaceIsActive(iface)) < 0)
+        goto cleanup;
+
+    ret->active = active;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (iface)
+        virInterfaceFree(iface);
+    return rv;
+}
+
+/* remoteDispatchInterfaceLookupByMacString has to be implemented manually */
+
+/* remoteDispatchInterfaceLookupByName has to be implemented manually */
+
+static int
+remoteDispatchInterfaceUndefine(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_interface_undefine_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virInterfacePtr iface = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
+        goto cleanup;
+
+    if (virInterfaceUndefine(iface) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (iface)
+        virInterfaceFree(iface);
+    return rv;
+}
+
+static int
+remoteDispatchIsSecure(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_is_secure_ret *ret)
+{
+    int rv = -1;
+    int secure;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((secure = virConnectIsSecure(conn)) < 0)
+        goto cleanup;
+
+    ret->secure = secure;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+/* remoteDispatchListDefinedDomains has to be implemented manually */
+
+/* remoteDispatchListDefinedInterfaces has to be implemented manually */
+
+/* remoteDispatchListDefinedNetworks has to be implemented manually */
+
+/* remoteDispatchListDefinedStoragePools has to be implemented manually */
+
+/* remoteDispatchListDomains has to be implemented manually */
+
+/* remoteDispatchListInterfaces has to be implemented manually */
+
+/* remoteDispatchListNetworks has to be implemented manually */
+
+/* remoteDispatchListNWFilters has to be implemented manually */
+
+/* remoteDispatchListSecrets has to be implemented manually */
+
+/* remoteDispatchListStoragePools has to be implemented manually */
+
+static int
+remoteDispatchNetworkCreate(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_create_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if (virNetworkCreate(net) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+/* remoteDispatchNetworkCreateXML has to be implemented manually */
+
+/* remoteDispatchNetworkDefineXML has to be implemented manually */
+
+static int
+remoteDispatchNetworkDestroy(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_destroy_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if (virNetworkDestroy(net) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+static int
+remoteDispatchNetworkDumpXML(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_dump_xml_args *args,
+    remote_network_dump_xml_ret *ret)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if ((xml = virNetworkGetXMLDesc(net, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+static int
+remoteDispatchNetworkGetAutostart(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_get_autostart_args *args,
+    remote_network_get_autostart_ret *ret)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+    int autostart;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if (virNetworkGetAutostart(net, &autostart) < 0)
+        goto cleanup;
+
+    ret->autostart = autostart;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+static int
+remoteDispatchNetworkGetBridgeName(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_get_bridge_name_args *args,
+    remote_network_get_bridge_name_ret *ret)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+    char *name;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if ((name = virNetworkGetBridgeName(net)) == NULL)
+        goto cleanup;
+
+    ret->name = name;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+static int
+remoteDispatchNetworkIsActive(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_is_active_args *args,
+    remote_network_is_active_ret *ret)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+    int active;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if ((active = virNetworkIsActive(net)) < 0)
+        goto cleanup;
+
+    ret->active = active;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+static int
+remoteDispatchNetworkIsPersistent(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_is_persistent_args *args,
+    remote_network_is_persistent_ret *ret)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+    int persistent;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if ((persistent = virNetworkIsPersistent(net)) < 0)
+        goto cleanup;
+
+    ret->persistent = persistent;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+/* remoteDispatchNetworkLookupByName has to be implemented manually */
+
+/* remoteDispatchNetworkLookupByUUID has to be implemented manually */
+
+static int
+remoteDispatchNetworkSetAutostart(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_set_autostart_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if (virNetworkSetAutostart(net, args->autostart) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+static int
+remoteDispatchNetworkUndefine(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_network_undefine_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNetworkPtr net = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(net = get_nonnull_network(conn, args->net)))
+        goto cleanup;
+
+    if (virNetworkUndefine(net) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (net)
+        virNetworkFree(net);
+    return rv;
+}
+
+/* remoteDispatchNodeDeviceCreateXML has to be implemented manually */
+
+static int
+remoteDispatchNodeDeviceDestroy(
+    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_device_destroy_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNodeDevicePtr dev = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+        goto cleanup;
+
+    if (virNodeDeviceDestroy(dev) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dev)
+        virNodeDeviceFree(dev);
+    return rv;
+}
+
+static int
+remoteDispatchNodeDeviceDettach(
+    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_device_dettach_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNodeDevicePtr dev = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+        goto cleanup;
+
+    if (virNodeDeviceDettach(dev) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dev)
+        virNodeDeviceFree(dev);
+    return rv;
+}
+
+static int
+remoteDispatchNodeDeviceDumpXML(
+    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_device_dump_xml_args *args,
+    remote_node_device_dump_xml_ret *ret)
+{
+    int rv = -1;
+    virNodeDevicePtr dev = NULL;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+        goto cleanup;
+
+    if ((xml = virNodeDeviceGetXMLDesc(dev, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dev)
+        virNodeDeviceFree(dev);
+    return rv;
+}
+
+/* remoteDispatchNodeDeviceGetParent has to be implemented manually */
+
+/* remoteDispatchNodeDeviceListCaps has to be implemented manually */
+
+/* remoteDispatchNodeDeviceLookupByName has to be implemented manually */
+
+static int
+remoteDispatchNodeDeviceNumOfCaps(
+    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_device_num_of_caps_args *args,
+    remote_node_device_num_of_caps_ret *ret)
+{
+    int rv = -1;
+    virNodeDevicePtr dev = NULL;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+        goto cleanup;
+
+    if ((num = virNodeDeviceNumOfCaps(dev)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dev)
+        virNodeDeviceFree(dev);
+    return rv;
+}
+
+static int
+remoteDispatchNodeDeviceReAttach(
+    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_device_re_attach_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNodeDevicePtr dev = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+        goto cleanup;
+
+    if (virNodeDeviceReAttach(dev) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dev)
+        virNodeDeviceFree(dev);
+    return rv;
+}
+
+static int
+remoteDispatchNodeDeviceReset(
+    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_device_reset_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNodeDevicePtr dev = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+        goto cleanup;
+
+    if (virNodeDeviceReset(dev) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dev)
+        virNodeDeviceFree(dev);
+    return rv;
+}
+
+/* remoteDispatchNodeGetCellsFreeMemory has to be implemented manually */
+
+/* remoteDispatchNodeGetFreeMemory has to be implemented manually */
+
+/* remoteDispatchNodeGetInfo has to be implemented manually */
+
+/* remoteDispatchNodeGetSecurityModel has to be implemented manually */
+
+/* remoteDispatchNodeListDevices has to be implemented manually */
+
+/* remoteDispatchNodeNumOfDevices has to be implemented manually */
+
+static int
+remoteDispatchNumOfDefinedDomains(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_defined_domains_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfDefinedDomains(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfDefinedInterfaces(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_defined_interfaces_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfDefinedInterfaces(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfDefinedNetworks(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_defined_networks_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfDefinedNetworks(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfDefinedStoragePools(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_defined_storage_pools_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfDefinedStoragePools(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfDomains(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_domains_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfDomains(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfInterfaces(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_interfaces_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfInterfaces(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfNetworks(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_networks_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfNetworks(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfNWFilters(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_nwfilters_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfNWFilters(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfSecrets(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_secrets_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfSecrets(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+static int
+remoteDispatchNumOfStoragePools(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    void *args ATTRIBUTE_UNUSED,
+    remote_num_of_storage_pools_ret *ret)
+{
+    int rv = -1;
+    int num;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((num = virConnectNumOfStoragePools(conn)) < 0)
+        goto cleanup;
+
+    ret->num = num;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
+
+/* remoteDispatchNWFilterDefineXML has to be implemented manually */
+
+static int
+remoteDispatchNWFilterGetXMLDesc(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_nwfilter_get_xml_desc_args *args,
+    remote_nwfilter_get_xml_desc_ret *ret)
+{
+    int rv = -1;
+    virNWFilterPtr nwfilter = NULL;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
+        goto cleanup;
+
+    if ((xml = virNWFilterGetXMLDesc(nwfilter, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (nwfilter)
+        virNWFilterFree(nwfilter);
+    return rv;
+}
+
+/* remoteDispatchNWFilterLookupByName has to be implemented manually */
+
+/* remoteDispatchNWFilterLookupByUUID has to be implemented manually */
+
+static int
+remoteDispatchNWFilterUndefine(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_nwfilter_undefine_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virNWFilterPtr nwfilter = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
+        goto cleanup;
+
+    if (virNWFilterUndefine(nwfilter) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (nwfilter)
+        virNWFilterFree(nwfilter);
+    return rv;
+}
+
+/* remoteDispatchOpen has to be implemented manually */
+
+/* remoteDispatchSecretDefineXML has to be implemented manually */
+
+/* remoteDispatchSecretGetValue has to be implemented manually */
+
+static int
+remoteDispatchSecretGetXMLDesc(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_secret_get_xml_desc_args *args,
+    remote_secret_get_xml_desc_ret *ret)
+{
+    int rv = -1;
+    virSecretPtr secret = NULL;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
+        goto cleanup;
+
+    if ((xml = virSecretGetXMLDesc(secret, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (secret)
+        virSecretFree(secret);
+    return rv;
+}
+
+/* remoteDispatchSecretLookupByUsage has to be implemented manually */
+
+/* remoteDispatchSecretLookupByUUID has to be implemented manually */
+
+static int
+remoteDispatchSecretSetValue(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_secret_set_value_args *args,
+    void *ret ATTRIBUTE_UNUSED)
+{
+    int rv = -1;
+    virSecretPtr secret = NULL;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
+        goto cleanup;
+
+    if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val, args->value.value_len, args->flags) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (secret)
+        virSecretFree(secret);
     return rv;
 }
 
 static int
-remoteDispatchNodeDeviceDettach(
+remoteDispatchSecretUndefine(
     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_device_dettach_args *args,
+    remote_secret_undefine_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNodeDevicePtr dev = NULL;
+    virSecretPtr secret = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
         goto cleanup;
 
-    if (virNodeDeviceDettach(dev) < 0)
+    if (virSecretUndefine(secret) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1458,43 +3042,33 @@ remoteDispatchNodeDeviceDettach(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (secret)
+        virSecretFree(secret);
     return rv;
 }
 
-/* remoteDispatchNodeDeviceDumpXML has to be implemented manually */
-
-/* remoteDispatchNodeDeviceGetParent has to be implemented manually */
-
-/* remoteDispatchNodeDeviceListCaps has to be implemented manually */
-
-/* remoteDispatchNodeDeviceLookupByName has to be implemented manually */
-
-/* remoteDispatchNodeDeviceNumOfCaps has to be implemented manually */
-
 static int
-remoteDispatchNodeDeviceReAttach(
+remoteDispatchStoragePoolBuild(
     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_device_re_attach_args *args,
+    remote_storage_pool_build_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virNodeDeviceReAttach(dev) < 0)
+    if (virStoragePoolBuild(pool, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1502,33 +3076,33 @@ remoteDispatchNodeDeviceReAttach(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
 static int
-remoteDispatchNodeDeviceReset(
+remoteDispatchStoragePoolCreate(
     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_device_reset_args *args,
+    remote_storage_pool_create_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNodeDevicePtr dev = NULL;
+    virStoragePoolPtr pool = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virNodeDeviceReset(dev) < 0)
+    if (virStoragePoolCreate(pool, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1536,73 +3110,37 @@ remoteDispatchNodeDeviceReset(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (dev)
-        virNodeDeviceFree(dev);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-/* remoteDispatchNodeGetCellsFreeMemory has to be implemented manually */
-
-/* remoteDispatchNodeGetFreeMemory has to be implemented manually */
-
-/* remoteDispatchNodeGetInfo has to be implemented manually */
-
-/* remoteDispatchNodeGetSecurityModel has to be implemented manually */
-
-/* remoteDispatchNodeListDevices has to be implemented manually */
-
-/* remoteDispatchNodeNumOfDevices has to be implemented manually */
-
-/* remoteDispatchNumOfDefinedDomains has to be implemented manually */
-
-/* remoteDispatchNumOfDefinedInterfaces has to be implemented manually */
-
-/* remoteDispatchNumOfDefinedNetworks has to be implemented manually */
-
-/* remoteDispatchNumOfDefinedStoragePools has to be implemented manually */
-
-/* remoteDispatchNumOfDomains has to be implemented manually */
-
-/* remoteDispatchNumOfInterfaces has to be implemented manually */
-
-/* remoteDispatchNumOfNetworks has to be implemented manually */
-
-/* remoteDispatchNumOfNWFilters has to be implemented manually */
-
-/* remoteDispatchNumOfSecrets has to be implemented manually */
-
-/* remoteDispatchNumOfStoragePools has to be implemented manually */
-
-/* remoteDispatchNWFilterDefineXML has to be implemented manually */
-
-/* remoteDispatchNWFilterGetXMLDesc has to be implemented manually */
-
-/* remoteDispatchNWFilterLookupByName has to be implemented manually */
+/* remoteDispatchStoragePoolCreateXML has to be implemented manually */
 
-/* remoteDispatchNWFilterLookupByUUID has to be implemented manually */
+/* remoteDispatchStoragePoolDefineXML has to be implemented manually */
 
 static int
-remoteDispatchNWFilterUndefine(
+remoteDispatchStoragePoolDelete(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_nwfilter_undefine_args *args,
+    remote_storage_pool_delete_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virNWFilterPtr nwfilter = NULL;
+    virStoragePoolPtr pool = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virNWFilterUndefine(nwfilter) < 0)
+    if (virStoragePoolDelete(pool, args->flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1610,45 +3148,33 @@ remoteDispatchNWFilterUndefine(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (nwfilter)
-        virNWFilterFree(nwfilter);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
-/* remoteDispatchOpen has to be implemented manually */
-
-/* remoteDispatchSecretDefineXML has to be implemented manually */
-
-/* remoteDispatchSecretGetValue has to be implemented manually */
-
-/* remoteDispatchSecretGetXMLDesc has to be implemented manually */
-
-/* remoteDispatchSecretLookupByUsage has to be implemented manually */
-
-/* remoteDispatchSecretLookupByUUID has to be implemented manually */
-
 static int
-remoteDispatchSecretSetValue(
+remoteDispatchStoragePoolDestroy(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_secret_set_value_args *args,
+    remote_storage_pool_destroy_args *args,
     void *ret ATTRIBUTE_UNUSED)
 {
     int rv = -1;
-    virSecretPtr secret = NULL;
+    virStoragePoolPtr pool = NULL;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(secret = get_nonnull_secret(conn, args->secret)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val, args->value.value_len, args->flags) < 0)
+    if (virStoragePoolDestroy(pool) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1656,57 +3182,60 @@ remoteDispatchSecretSetValue(
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
 static int
-remoteDispatchSecretUndefine(
+remoteDispatchStoragePoolDumpXML(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_secret_undefine_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_storage_pool_dump_xml_args *args,
+    remote_storage_pool_dump_xml_ret *ret)
 {
     int rv = -1;
-    virSecretPtr secret = NULL;
+    virStoragePoolPtr pool = NULL;
+    char *xml;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(secret = get_nonnull_secret(conn, args->secret)))
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virSecretUndefine(secret) < 0)
+    if ((xml = virStoragePoolGetXMLDesc(pool, args->flags)) == NULL)
         goto cleanup;
 
+    ret->xml = xml;
     rv = 0;
 
 cleanup:
     if (rv < 0)
         remoteDispatchError(rerr);
-    if (secret)
-        virSecretFree(secret);
+    if (pool)
+        virStoragePoolFree(pool);
     return rv;
 }
 
 static int
-remoteDispatchStoragePoolBuild(
+remoteDispatchStoragePoolGetAutostart(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_storage_pool_build_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_storage_pool_get_autostart_args *args,
+    remote_storage_pool_get_autostart_ret *ret)
 {
     int rv = -1;
     virStoragePoolPtr pool = NULL;
+    int autostart;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -1716,9 +3245,10 @@ remoteDispatchStoragePoolBuild(
     if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virStoragePoolBuild(pool, args->flags) < 0)
+    if (virStoragePoolGetAutostart(pool, &autostart) < 0)
         goto cleanup;
 
+    ret->autostart = autostart;
     rv = 0;
 
 cleanup:
@@ -1729,18 +3259,21 @@ cleanup:
     return rv;
 }
 
+/* remoteDispatchStoragePoolGetInfo has to be implemented manually */
+
 static int
-remoteDispatchStoragePoolCreate(
+remoteDispatchStoragePoolIsActive(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_storage_pool_create_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_storage_pool_is_active_args *args,
+    remote_storage_pool_is_active_ret *ret)
 {
     int rv = -1;
     virStoragePoolPtr pool = NULL;
+    int active;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -1750,9 +3283,10 @@ remoteDispatchStoragePoolCreate(
     if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virStoragePoolCreate(pool, args->flags) < 0)
+    if ((active = virStoragePoolIsActive(pool)) < 0)
         goto cleanup;
 
+    ret->active = active;
     rv = 0;
 
 cleanup:
@@ -1763,22 +3297,19 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchStoragePoolCreateXML has to be implemented manually */
-
-/* remoteDispatchStoragePoolDefineXML has to be implemented manually */
-
 static int
-remoteDispatchStoragePoolDelete(
+remoteDispatchStoragePoolIsPersistent(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_storage_pool_delete_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_storage_pool_is_persistent_args *args,
+    remote_storage_pool_is_persistent_ret *ret)
 {
     int rv = -1;
     virStoragePoolPtr pool = NULL;
+    int persistent;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -1788,9 +3319,10 @@ remoteDispatchStoragePoolDelete(
     if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virStoragePoolDelete(pool, args->flags) < 0)
+    if ((persistent = virStoragePoolIsPersistent(pool)) < 0)
         goto cleanup;
 
+    ret->persistent = persistent;
     rv = 0;
 
 cleanup:
@@ -1801,18 +3333,27 @@ cleanup:
     return rv;
 }
 
+/* remoteDispatchStoragePoolListVolumes has to be implemented manually */
+
+/* remoteDispatchStoragePoolLookupByName has to be implemented manually */
+
+/* remoteDispatchStoragePoolLookupByUUID has to be implemented manually */
+
+/* remoteDispatchStoragePoolLookupByVolume has to be implemented manually */
+
 static int
-remoteDispatchStoragePoolDestroy(
+remoteDispatchStoragePoolNumOfVolumes(
     struct qemud_server *server ATTRIBUTE_UNUSED,
     struct qemud_client *client ATTRIBUTE_UNUSED,
     virConnectPtr conn,
     remote_message_header *hdr ATTRIBUTE_UNUSED,
     remote_error *rerr,
-    remote_storage_pool_destroy_args *args,
-    void *ret ATTRIBUTE_UNUSED)
+    remote_storage_pool_num_of_volumes_args *args,
+    remote_storage_pool_num_of_volumes_ret *ret)
 {
     int rv = -1;
     virStoragePoolPtr pool = NULL;
+    int num;
 
     if (!conn) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
@@ -1822,9 +3363,10 @@ remoteDispatchStoragePoolDestroy(
     if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    if (virStoragePoolDestroy(pool) < 0)
+    if ((num = virStoragePoolNumOfVolumes(pool)) < 0)
         goto cleanup;
 
+    ret->num = num;
     rv = 0;
 
 cleanup:
@@ -1835,26 +3377,6 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchStoragePoolDumpXML has to be implemented manually */
-
-/* remoteDispatchStoragePoolGetAutostart has to be implemented manually */
-
-/* remoteDispatchStoragePoolGetInfo has to be implemented manually */
-
-/* remoteDispatchStoragePoolIsActive has to be implemented manually */
-
-/* remoteDispatchStoragePoolIsPersistent has to be implemented manually */
-
-/* remoteDispatchStoragePoolListVolumes has to be implemented manually */
-
-/* remoteDispatchStoragePoolLookupByName has to be implemented manually */
-
-/* remoteDispatchStoragePoolLookupByUUID has to be implemented manually */
-
-/* remoteDispatchStoragePoolLookupByVolume has to be implemented manually */
-
-/* remoteDispatchStoragePoolNumOfVolumes has to be implemented manually */
-
 static int
 remoteDispatchStoragePoolRefresh(
     struct qemud_server *server ATTRIBUTE_UNUSED,
@@ -1997,11 +3519,79 @@ cleanup:
 
 /* remoteDispatchStorageVolDownload has to be implemented manually */
 
-/* remoteDispatchStorageVolDumpXML has to be implemented manually */
+static int
+remoteDispatchStorageVolDumpXML(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_storage_vol_dump_xml_args *args,
+    remote_storage_vol_dump_xml_ret *ret)
+{
+    int rv = -1;
+    virStorageVolPtr vol = NULL;
+    char *xml;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
+        goto cleanup;
+
+    if ((xml = virStorageVolGetXMLDesc(vol, args->flags)) == NULL)
+        goto cleanup;
+
+    ret->xml = xml;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (vol)
+        virStorageVolFree(vol);
+    return rv;
+}
 
 /* remoteDispatchStorageVolGetInfo has to be implemented manually */
 
-/* remoteDispatchStorageVolGetPath has to be implemented manually */
+static int
+remoteDispatchStorageVolGetPath(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_storage_vol_get_path_args *args,
+    remote_storage_vol_get_path_ret *ret)
+{
+    int rv = -1;
+    virStorageVolPtr vol = NULL;
+    char *name;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
+        goto cleanup;
+
+    if ((name = virStorageVolGetPath(vol)) == NULL)
+        goto cleanup;
+
+    ret->name = name;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (vol)
+        virStorageVolFree(vol);
+    return rv;
+}
 
 /* remoteDispatchStorageVolLookupByKey has to be implemented manually */
 
@@ -2045,4 +3635,32 @@ cleanup:
     return rv;
 }
 
-/* remoteDispatchSupportsFeature has to be implemented manually */
+static int
+remoteDispatchSupportsFeature(
+    struct qemud_server *server ATTRIBUTE_UNUSED,
+    struct qemud_client *client ATTRIBUTE_UNUSED,
+    virConnectPtr conn,
+    remote_message_header *hdr ATTRIBUTE_UNUSED,
+    remote_error *rerr,
+    remote_supports_feature_args *args,
+    remote_supports_feature_ret *ret)
+{
+    int rv = -1;
+    int supported;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if ((supported = virDrvSupportsFeature(conn, args->feature)) < 0)
+        goto cleanup;
+
+    ret->supported = supported;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    return rv;
+}
index 9af10cfce37c21c49358580fcc4254c71b050665..3fd3f970c4eac81d776617963443b57144b38db0 100755 (executable)
@@ -54,6 +54,7 @@ if ($opt_c) {
 }
 
 my $collect_args_members = 0;
+my $collect_ret_members = 0;
 my $last_name;
 
 while (<>) {
@@ -63,6 +64,12 @@ while (<>) {
         } elsif ($_ =~ m/^\s*(.*\S)\s*$/) {
             push(@{$calls{$name}->{args_members}}, $1);
         }
+    } elsif ($collect_ret_members) {
+        if (/^};/) {
+            $collect_ret_members = 0;
+        } elsif ($_ =~ m/^\s*(.*\S)\s*$/) {
+            push(@{$calls{$name}->{ret_members}}, $1);
+        }
     } elsif (/^struct ${structprefix}_(.*)_args/) {
         $name = $1;
         $ProcName = name_to_ProcName ($name);
@@ -80,6 +87,7 @@ while (<>) {
         };
 
         $collect_args_members = 1;
+        $collect_ret_members = 0;
         $last_name = $name;
     } elsif (/^struct ${structprefix}_(.*)_ret/) {
         $name = $1;
@@ -93,11 +101,14 @@ while (<>) {
                 ProcName => $ProcName,
                 UC_NAME => uc $name,
                 args => "void",
-                ret => "${structprefix}_${name}_ret"
+                ret => "${structprefix}_${name}_ret",
+                ret_members => []
             }
         }
 
         $collect_args_members = 0;
+        $collect_ret_members = 1;
+        $last_name = $name;
     } elsif (/^struct ${structprefix}_(.*)_msg/) {
         $name = $1;
         $ProcName = name_to_ProcName ($name);
@@ -110,6 +121,7 @@ while (<>) {
         };
 
         $collect_args_members = 0;
+        $collect_ret_members = 0;
     } elsif (/^\s*${procprefix}_PROC_(.*?)\s+=\s+(\d+),?$/) {
         $name = lc $1;
         $id = $2;
@@ -118,8 +130,10 @@ while (<>) {
         $calls[$id] = $calls{$name};
 
         $collect_args_members = 0;
+        $collect_ret_members = 0;
     } else {
         $collect_args_members = 0;
+        $collect_ret_members = 0;
     }
 }
 
@@ -235,7 +249,96 @@ elsif ($opt_b) {
                           "DomainSetBlkioParameters",
                           "Open",
                           "StorageVolUpload",
-                          "StorageVolDownload");
+                          "StorageVolDownload",
+
+                          "AuthList",
+                          "AuthSaslInit",
+                          "AuthSaslStart",
+                          "AuthSaslStep",
+                          "AuthPolkit",
+
+                          "CpuBaseline",
+                          "CpuCompare",
+                          "DomainBlockPeek",
+                          "DomainBlockStats",
+                          "DomainCreateWithFlags",
+                          "DomainCreateXML",
+                          "DomainDefineXML",
+                          "DomainEventsDeregister",
+                          "DomainEventsRegister",
+                          "DomainGetBlkioParameters",
+                          "DomainGetBlockInfo",
+                          "DomainGetInfo",
+                          "DomainGetJobInfo",
+                          "DomainGetMemoryParameters",
+                          "DomainGetSchedulerParameters",
+                          "DomainGetSchedulerType",
+                          "DomainGetSecurityLabel",
+                          "DomainGetVcpus",
+                          "DomainInterfaceStats",
+                          "DomainLookupById",
+                          "DomainLookupByName",
+                          "DomainLookupByUUID",
+                          "DomainMemoryPeek",
+                          "DomainMemoryStats",
+                          "DomainMigrateFinish",
+                          "DomainMigrateFinish2",
+                          "DomainMigratePrepare",
+                          "DomainMigratePrepare2",
+                          "DomainSnapshotCreateXML",
+                          "DomainSnapshotCurrent",
+                          "DomainSnapshotListNames",
+                          "DomainSnapshotLookupByName",
+                          "FindStoragePoolSources",
+                          "GetMaxVcpus",
+                          "GetType",
+                          "InterfaceLookupByMacString",
+                          "InterfaceLookupByName",
+                          "InterfaceDefineXML",
+                          "ListDefinedDomains",
+                          "ListDefinedInterfaces",
+                          "ListDefinedNetworks",
+                          "ListDefinedStoragePools",
+                          "ListDomains",
+                          "ListInterfaces",
+                          "ListNetworks",
+                          "ListNWFilters",
+                          "ListSecrets",
+                          "ListStoragePools",
+                          "NetworkLookupByName",
+                          "NetworkLookupByUUID",
+                          "NodeDeviceCreateXML",
+                          "NetworkCreateXML",
+                          "NodeDeviceGetParent",
+                          "NodeDeviceListCaps",
+                          "NodeDeviceLookupByName",
+                          "NodeGetCellsFreeMemory",
+                          "NodeGetFreeMemory",
+                          "NodeGetInfo",
+                          "NodeGetSecurityModel",
+                          "NetworkDefineXML",
+                          "NodeListDevices",
+                          "NodeNumOfDevices",
+                          "NWFilterLookupByName",
+                          "NWFilterLookupByUUID",
+                          "SecretDefineXML",
+                          "SecretGetValue",
+                          "NWFilterDefineXML",
+                          "SecretLookupByUsage",
+                          "SecretLookupByUUID",
+                          "StoragePoolCreateXML",
+                          "StoragePoolDefineXML",
+                          "StoragePoolGetInfo",
+                          "StoragePoolListVolumes",
+                          "StoragePoolLookupByName",
+                          "StoragePoolLookupByUUID",
+                          "StoragePoolLookupByVolume",
+                          "StorageVolCreateXML",
+                          "StorageVolCreateXMLFrom",
+                          "StorageVolGetInfo",
+                          "StorageVolLookupByKey",
+                          "StorageVolLookupByName",
+                          "StorageVolLookupByPath");
     } elsif ($structprefix eq "qemu") {
         @ungeneratable = ("MonitorCommand");
     }
@@ -248,8 +351,9 @@ elsif ($opt_b) {
         next if $calls{$_}->{msg};
 
         # FIXME: skip functions with explicit return value for now
-        if ($calls{$_}->{ret} ne "void" or exists($ug{$calls{$_}->{ProcName}})) {
-            print "\n/* ${structprefix}Dispatch$calls{$_}->{ProcName} has to be implemented manually */\n";
+        if (exists($ug{$calls{$_}->{ProcName}})) {
+            print "\n/* ${structprefix}Dispatch$calls{$_}->{ProcName} has " .
+                  "to be implemented manually */\n";
             next;
         }
 
@@ -282,6 +386,7 @@ elsif ($opt_b) {
         my @vars_list = ();
         my @getters_list = ();
         my @args_list = ();
+        my @ret_list = ();
         my @free_list = ();
 
         if ($calls{$_}->{args} ne "void") {
@@ -402,6 +507,49 @@ elsif ($opt_b) {
             }
         }
 
+        my $single_ret_var = "undefined";
+        my $single_ret_by_ref = 0;
+        my $single_ret_check = " == undefined";
+
+        if ($calls{$_}->{ret} ne "void") {
+            foreach my $ret_member (@{$calls{$_}->{ret_members}}) {
+                if ($ret_member =~ m/(\S+)<\S+>;/) {
+                    push(@ret_list, "ret->$1.$1_val");
+                    push(@ret_list, "ret->$1.$1_len");
+                } elsif ($ret_member =~ m/remote_nonnull_string (\S+);/) {
+                    push(@vars_list, "char *$1");
+                    push(@ret_list, "ret->$1 = $1;");
+                    $single_ret_var = $1;
+                    $single_ret_by_ref = 0;
+                    $single_ret_check = " == NULL";
+                } elsif ($ret_member =~ m/int (\S+);/) {
+                    push(@vars_list, "int $1");
+                    push(@ret_list, "ret->$1 = $1;");
+                    $single_ret_var = $1;
+
+                    if ($calls{$_}->{ProcName} eq "DomainGetAutostart" or
+                        $calls{$_}->{ProcName} eq "NetworkGetAutostart" or
+                        $calls{$_}->{ProcName} eq "StoragePoolGetAutostart") {
+                        $single_ret_by_ref = 1;
+                    } else {
+                        $single_ret_by_ref = 0;
+                        $single_ret_check = " < 0";
+                    }
+                } elsif ($ret_member =~ m/hyper (\S+);/) {
+                    push(@vars_list, "unsigned long $1");
+                    push(@ret_list, "ret->$1 = $1;");
+                    $single_ret_var = $1;
+
+                    if ($calls{$_}->{ProcName} eq "DomainGetMaxMemory") {
+                        $single_ret_by_ref = 0;
+                        $single_ret_check = " == 0";
+                    } else {
+                        $single_ret_by_ref = 1;
+                    }
+                }
+            }
+        }
+
         foreach my $var (@vars_list) {
             print "    $var;\n";
         }
@@ -415,7 +563,9 @@ elsif ($opt_b) {
 
         print join("\n", @getters_list);
 
-        print "\n";
+        if (@getters_list) {
+            print "\n";
+        }
 
         if ($calls{$_}->{ret} eq "void") {
             print "    if (vir$calls{$_}->{ProcName}(";
@@ -423,6 +573,56 @@ elsif ($opt_b) {
             print ") < 0)\n";
             print "        goto cleanup;\n";
             print "\n";
+        } elsif (scalar(@{$calls{$_}->{ret_members}}) == 1) {
+            my $prefix = "";
+            my $proc_name = $calls{$_}->{ProcName};
+
+            if (! @args_list) {
+                push(@args_list, "conn");
+                $prefix = "Connect"
+            }
+
+            if ($calls{$_}->{ProcName} eq "GetSysinfo" or
+                $calls{$_}->{ProcName} eq "DomainXMLFromNative" or
+                $calls{$_}->{ProcName} eq "DomainXMLToNative") {
+                $prefix = "Connect"
+            } elsif ($calls{$_}->{ProcName} eq "SupportsFeature") {
+                $prefix = "Drv"
+            } elsif ($calls{$_}->{ProcName} eq "DomainDumpXML") {
+                $proc_name = "DomainGetXMLDesc"
+            } elsif ($calls{$_}->{ProcName} eq "NetworkDumpXML") {
+                $proc_name = "NetworkGetXMLDesc"
+            } elsif ($calls{$_}->{ProcName} eq "StoragePoolDumpXML") {
+                $proc_name = "StoragePoolGetXMLDesc"
+            } elsif ($calls{$_}->{ProcName} eq "StorageVolDumpXML") {
+                $proc_name = "StorageVolGetXMLDesc"
+            } elsif ($calls{$_}->{ProcName} eq "NodeDeviceDumpXML") {
+                $proc_name = "NodeDeviceGetXMLDesc"
+            } elsif ($calls{$_}->{ProcName} eq "DomainSnapshotDumpXML") {
+                $proc_name = "DomainSnapshotGetXMLDesc"
+            } elsif ($calls{$_}->{ProcName} eq "DomainGetOsType") {
+                $proc_name = "DomainGetOSType"
+            }
+
+            if ($single_ret_by_ref) {
+                print "    if (vir$prefix$proc_name(";
+                print join(', ', @args_list);
+                print ", &$single_ret_var) < 0)\n";
+            } else {
+                print "    if (($single_ret_var = vir$prefix$proc_name(";
+                print join(', ', @args_list);
+                print "))$single_ret_check)\n";
+            }
+
+            print "        goto cleanup;\n";
+            print "\n";
+
+            if (@ret_list) {
+                print "    ";
+            }
+
+            print join("    \n", @ret_list);
+            print "\n";
         }
 
         print "    rv = 0;\n";
@@ -433,7 +633,10 @@ elsif ($opt_b) {
 
         print join("\n", @free_list);
 
-        print "\n";
+        if (@free_list) {
+            print "\n";
+        }
+
         print "    return rv;\n";
         print "}\n";
     }