~ubuntu-branches/ubuntu/oneiric/libvirt/oneiric-updates

« back to all changes in this revision

Viewing changes to daemon/remote.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2011-05-11 12:29:51 UTC
  • mfrom: (1.2.10) (3.4.30 sid)
  • Revision ID: package-import@ubuntu.com-20110511122951-ku5fk1tv37o5aymm
Tags: 0.9.1-1ubuntu1
* Resynchronize and merge from Debian unstable (LP: #794378). Remaining
  changes:
  - debian/control:
    * set X-Python-Version to 2.7, as 2.6 is not in oneiric.
    * set ubuntu maintainer
    * Build-Depends:
      - remove [linux-any] from all dependencies
      - remove [!linux-any] deps
      - swap libxen to libxen3, qemu to qemu-kvm, and open-iscsi to
        open-iscsi-utils in Build-Depends
      - remove virtualbox-ose Build-Depends
      - add parted and libapparmor-dev Build-Depends
    * convert Vcs-Git to Xs-Debian-Vcs-Git
    * libvirt-bin Depends: move netcat-openbsd, bridge-utils, dnsmasq-base
      (>= 2.46-1), and iptables from Recommends to Depends
    * libvirt-bin Recommends: move qemu to Suggests
    * libvirt-bin Suggests: add apparmor
    * libvirt0 Recommands: move lvm2 to Suggests
  - keep debian/libvirt-bin.apport
  - keep debian/libvirt-bin.cron.daily
  - debian/libvirt-bin.dirs:
    * add apparmor, cron.daily, and apport dirs
  - debian/libvirt-bin.examples:
    * add debian/libvirt-suspendonreboot
  - debian/libvirt-bin.install:
    * add /etc/apparmor.d files
    * add apport hook
  - debian/libvirt-bin.manpages:
    * add debian/libvirt-migrate-qemu-disks.1
  - debian/libvirt-bin.postinst:
    * replace libvirt groupname with libvirtd
    * add each admin user to libvirtd group
    * call apparmor_parser on usr.sbin.libvirtd and
      usr.lib.libvirt.virt-aa-helper
    * call 'libvirt-migrate-qemu-disks -a' after
      libvirt-bin has started if migrating from
      older than 0.8.3-1ubuntu1
  - debian/libvirt-bin.postrm:
    * replace libvirt groupname with libvirtd
    * remove usr.sbin.libvirtd and
      usr.lib.libvirt.virt-aa-helper
  - keep added files under debian/:
    * libvirt-bin.upstart
    * libvirt-migrate-qemu-disks
    * libvirt-migrate-qemu-disks.1
    * libvirt-suspendonreboot
    * apparmor profiles
  - debian/README.Debian:
    * add 'Apparmor Profile' section
    * add 'Disk migration' section
  - debian/rules:
    * move include of debhelper.mk to top of file so DEB_HOST_ARCH_OS
      is defined.
    * don't build with vbox since virtualbox-ose is in universe
      - remove WITH_VBOX, add explicit --without-vbox
    * add --with-apparmor to DEB_CONFIGURE_EXTRA_FLAGS
    * set DEB_DH_INSTALLINIT_ARGS to '--upstart-only'
    * remove unneeded binary-install/libvirt-bin:: and clean::
      sections (they only deal with sysvinit stuff)
    * add build/libvirt-bin:: section to install
      - apparmor files
      - apport hooks
      - libvirt-migrate-qemu-disks
* debian/patches/series:
  - don't apply Disable-CHECKSUM-rule.patch: our iptables can do this
  - don't apply Debian-specific Debianize-libvirt-guests.patch (sysvinit only)
  - don't apply Disable qemu-disable-network.diff.patch
* debian/patches:
  - drop 9007-fix-daemon-conf-ftbfs.patch (looks like it may be fixed)
  - drop patches applied upstream:
    * 9022-drop-booton-when-kernel-specified.patch
    * 9023-fix-lxc-console-hangup.patch
    * 9024-fix-broken-commandtest.patch
    * 9025-Pass-virSecurityManagerPtr-to-virSecurityDAC-Set-Res.patch
    * 9026-security-avoid-memory-leak.patch
    * 9027-CVE-2011-1146.patch
  - keep patches:
    * 9000-delayed_iff_up_bridge.patch
    * 9001-dont_clobber_existing_bridges.patch
    * 9002-better_default_uri_virsh.patch
    * 9003-better-default-arch.patch
    * 9004-libvirtd-group-name.patch
    * 9005-increase-unix-socket-timeout.patch
    * 9006-default-config-test-case.patch
    * 9011-move-ebtables-script.patch (refreshed)
    * 9014-skip-nodeinfotest.patch (modified to make it apply)
    * 9020-lp545795.patch (modified to make it still apply)
    * 9021-fix-uint64_t.patch
    * 9022-allows-lxc-containers-with-lxcguest.patch (renamed, modified
      to make it still apply, and added DEP-3 tags).
  - new patches:
    * 9023-disable-test-poll.patch - don't run broken test-poll

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
#include "uuid.h"
61
61
#include "network.h"
62
62
#include "libvirt/libvirt-qemu.h"
 
63
#include "command.h"
63
64
 
64
65
#define VIR_FROM_THIS VIR_FROM_REMOTE
65
 
#define REMOTE_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
66
 
 
67
 
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
68
 
static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
69
 
static virInterfacePtr get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface);
70
 
static virStoragePoolPtr get_nonnull_storage_pool (virConnectPtr conn, remote_nonnull_storage_pool pool);
71
 
static virStorageVolPtr get_nonnull_storage_vol (virConnectPtr conn, remote_nonnull_storage_vol vol);
72
 
static virSecretPtr get_nonnull_secret (virConnectPtr conn, remote_nonnull_secret secret);
73
 
static virNWFilterPtr get_nonnull_nwfilter (virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
74
 
static virDomainSnapshotPtr get_nonnull_domain_snapshot (virDomainPtr domain, remote_nonnull_domain_snapshot snapshot);
75
 
static void make_nonnull_domain (remote_nonnull_domain *dom_dst, virDomainPtr dom_src);
76
 
static void make_nonnull_network (remote_nonnull_network *net_dst, virNetworkPtr net_src);
77
 
static void make_nonnull_interface (remote_nonnull_interface *interface_dst, virInterfacePtr interface_src);
78
 
static void make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src);
79
 
static void make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src);
80
 
static void make_nonnull_node_device (remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src);
81
 
static void make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
82
 
static void make_nonnull_nwfilter (remote_nonnull_nwfilter *net_dst, virNWFilterPtr nwfilter_src);
83
 
static void make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
 
66
 
 
67
#define virNetError(code, ...)                                    \
 
68
    virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,           \
 
69
                         __FUNCTION__, __LINE__, __VA_ARGS__)
 
70
 
 
71
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
 
72
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
 
73
static virInterfacePtr get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface);
 
74
static virStoragePoolPtr get_nonnull_storage_pool(virConnectPtr conn, remote_nonnull_storage_pool pool);
 
75
static virStorageVolPtr get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol);
 
76
static virSecretPtr get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret);
 
77
static virNWFilterPtr get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
 
78
static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot);
 
79
static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src);
 
80
static void make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src);
 
81
static void make_nonnull_interface(remote_nonnull_interface *interface_dst, virInterfacePtr interface_src);
 
82
static void make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src);
 
83
static void make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src);
 
84
static void make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src);
 
85
static void make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
 
86
static void make_nonnull_nwfilter(remote_nonnull_nwfilter *net_dst, virNWFilterPtr nwfilter_src);
 
87
static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
84
88
 
85
89
 
86
90
#include "remote_dispatch_prototypes.h"
116
120
 
117
121
/* Prototypes */
118
122
static void
119
 
remoteDispatchDomainEventSend (struct qemud_client *client,
120
 
                               int procnr,
121
 
                               xdrproc_t proc,
122
 
                               void *data);
 
123
remoteDispatchDomainEventSend(struct qemud_client *client,
 
124
                              int procnr,
 
125
                              xdrproc_t proc,
 
126
                              void *data);
123
127
 
124
128
static int remoteRelayDomainEventLifecycle(virConnectPtr conn ATTRIBUTE_UNUSED,
125
129
                                           virDomainPtr dom,
133
137
    if (!client)
134
138
        return -1;
135
139
 
136
 
    REMOTE_DEBUG("Relaying domain lifecycle event %d %d", event, detail);
 
140
    VIR_DEBUG("Relaying domain lifecycle event %d %d", event, detail);
137
141
 
138
142
    virMutexLock(&client->lock);
139
143
 
140
144
    /* build return data */
141
145
    memset(&data, 0, sizeof data);
142
 
    make_nonnull_domain (&data.dom, dom);
 
146
    make_nonnull_domain(&data.dom, dom);
143
147
    data.event = event;
144
148
    data.detail = detail;
145
149
 
146
 
    remoteDispatchDomainEventSend (client,
147
 
                                   REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE,
148
 
                                   (xdrproc_t)xdr_remote_domain_event_lifecycle_msg, &data);
 
150
    remoteDispatchDomainEventSend(client,
 
151
                                  REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE,
 
152
                                  (xdrproc_t)xdr_remote_domain_event_lifecycle_msg, &data);
149
153
 
150
154
    virMutexUnlock(&client->lock);
151
155
 
162
166
    if (!client)
163
167
        return -1;
164
168
 
165
 
    REMOTE_DEBUG("Relaying domain reboot event %s %d", dom->name, dom->id);
 
169
    VIR_DEBUG("Relaying domain reboot event %s %d", dom->name, dom->id);
166
170
 
167
171
    virMutexLock(&client->lock);
168
172
 
169
173
    /* build return data */
170
174
    memset(&data, 0, sizeof data);
171
 
    make_nonnull_domain (&data.dom, dom);
 
175
    make_nonnull_domain(&data.dom, dom);
172
176
 
173
 
    remoteDispatchDomainEventSend (client,
174
 
                                   REMOTE_PROC_DOMAIN_EVENT_REBOOT,
175
 
                                   (xdrproc_t)xdr_remote_domain_event_reboot_msg, &data);
 
177
    remoteDispatchDomainEventSend(client,
 
178
                                  REMOTE_PROC_DOMAIN_EVENT_REBOOT,
 
179
                                  (xdrproc_t)xdr_remote_domain_event_reboot_msg, &data);
176
180
 
177
181
    virMutexUnlock(&client->lock);
178
182
 
191
195
    if (!client)
192
196
        return -1;
193
197
 
194
 
    REMOTE_DEBUG("Relaying domain rtc change event %s %d %lld", dom->name, dom->id, offset);
 
198
    VIR_DEBUG("Relaying domain rtc change event %s %d %lld", dom->name, dom->id, offset);
195
199
 
196
200
    virMutexLock(&client->lock);
197
201
 
198
202
    /* build return data */
199
203
    memset(&data, 0, sizeof data);
200
 
    make_nonnull_domain (&data.dom, dom);
 
204
    make_nonnull_domain(&data.dom, dom);
201
205
    data.offset = offset;
202
206
 
203
 
    remoteDispatchDomainEventSend (client,
204
 
                                   REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
205
 
                                   (xdrproc_t)xdr_remote_domain_event_rtc_change_msg, &data);
 
207
    remoteDispatchDomainEventSend(client,
 
208
                                  REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
 
209
                                  (xdrproc_t)xdr_remote_domain_event_rtc_change_msg, &data);
206
210
 
207
211
    virMutexUnlock(&client->lock);
208
212
 
221
225
    if (!client)
222
226
        return -1;
223
227
 
224
 
    REMOTE_DEBUG("Relaying domain watchdog event %s %d %d", dom->name, dom->id, action);
 
228
    VIR_DEBUG("Relaying domain watchdog event %s %d %d", dom->name, dom->id, action);
225
229
 
226
230
    virMutexLock(&client->lock);
227
231
 
228
232
    /* build return data */
229
233
    memset(&data, 0, sizeof data);
230
 
    make_nonnull_domain (&data.dom, dom);
 
234
    make_nonnull_domain(&data.dom, dom);
231
235
    data.action = action;
232
236
 
233
 
    remoteDispatchDomainEventSend (client,
234
 
                                   REMOTE_PROC_DOMAIN_EVENT_WATCHDOG,
235
 
                                   (xdrproc_t)xdr_remote_domain_event_watchdog_msg, &data);
 
237
    remoteDispatchDomainEventSend(client,
 
238
                                  REMOTE_PROC_DOMAIN_EVENT_WATCHDOG,
 
239
                                  (xdrproc_t)xdr_remote_domain_event_watchdog_msg, &data);
236
240
 
237
241
    virMutexUnlock(&client->lock);
238
242
 
253
257
    if (!client)
254
258
        return -1;
255
259
 
256
 
    REMOTE_DEBUG("Relaying domain io error %s %d %s %s %d", dom->name, dom->id, srcPath, devAlias, action);
 
260
    VIR_DEBUG("Relaying domain io error %s %d %s %s %d", dom->name, dom->id, srcPath, devAlias, action);
257
261
 
258
262
    virMutexLock(&client->lock);
259
263
 
260
264
    /* build return data */
261
265
    memset(&data, 0, sizeof data);
262
 
    make_nonnull_domain (&data.dom, dom);
 
266
    make_nonnull_domain(&data.dom, dom);
263
267
    data.srcPath = (char*)srcPath;
264
268
    data.devAlias = (char*)devAlias;
265
269
    data.action = action;
266
270
 
267
 
    remoteDispatchDomainEventSend (client,
268
 
                                   REMOTE_PROC_DOMAIN_EVENT_IO_ERROR,
269
 
                                   (xdrproc_t)xdr_remote_domain_event_io_error_msg, &data);
 
271
    remoteDispatchDomainEventSend(client,
 
272
                                  REMOTE_PROC_DOMAIN_EVENT_IO_ERROR,
 
273
                                  (xdrproc_t)xdr_remote_domain_event_io_error_msg, &data);
270
274
 
271
275
    virMutexUnlock(&client->lock);
272
276
 
288
292
    if (!client)
289
293
        return -1;
290
294
 
291
 
    REMOTE_DEBUG("Relaying domain io error %s %d %s %s %d %s",
292
 
                 dom->name, dom->id, srcPath, devAlias, action, reason);
 
295
    VIR_DEBUG("Relaying domain io error %s %d %s %s %d %s",
 
296
              dom->name, dom->id, srcPath, devAlias, action, reason);
293
297
 
294
298
    virMutexLock(&client->lock);
295
299
 
296
300
    /* build return data */
297
301
    memset(&data, 0, sizeof data);
298
 
    make_nonnull_domain (&data.dom, dom);
 
302
    make_nonnull_domain(&data.dom, dom);
299
303
    data.srcPath = (char*)srcPath;
300
304
    data.devAlias = (char*)devAlias;
301
305
    data.action = action;
302
306
    data.reason = (char*)reason;
303
307
 
304
 
    remoteDispatchDomainEventSend (client,
305
 
                                   REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON,
306
 
                                   (xdrproc_t)xdr_remote_domain_event_io_error_reason_msg, &data);
 
308
    remoteDispatchDomainEventSend(client,
 
309
                                  REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON,
 
310
                                  (xdrproc_t)xdr_remote_domain_event_io_error_reason_msg, &data);
307
311
 
308
312
    virMutexUnlock(&client->lock);
309
313
 
327
331
    if (!client)
328
332
        return -1;
329
333
 
330
 
    REMOTE_DEBUG("Relaying domain graphics event %s %d %d - %d %s %s  - %d %s %s - %s", dom->name, dom->id, phase,
331
 
                 local->family, local->service, local->node,
332
 
                 remote->family, remote->service, remote->node,
333
 
                 authScheme);
 
334
    VIR_DEBUG("Relaying domain graphics event %s %d %d - %d %s %s  - %d %s %s - %s", dom->name, dom->id, phase,
 
335
              local->family, local->service, local->node,
 
336
              remote->family, remote->service, remote->node,
 
337
              authScheme);
334
338
 
335
 
    REMOTE_DEBUG("Subject %d", subject->nidentity);
 
339
    VIR_DEBUG("Subject %d", subject->nidentity);
336
340
    for (i = 0 ; i < subject->nidentity ; i++) {
337
 
        REMOTE_DEBUG("  %s=%s", subject->identities[i].type, subject->identities[i].name);
 
341
        VIR_DEBUG("  %s=%s", subject->identities[i].type, subject->identities[i].name);
338
342
    }
339
343
 
340
344
    virMutexLock(&client->lock);
341
345
 
342
346
    /* build return data */
343
347
    memset(&data, 0, sizeof data);
344
 
    make_nonnull_domain (&data.dom, dom);
 
348
    make_nonnull_domain(&data.dom, dom);
345
349
    data.phase = phase;
346
350
    data.authScheme = (char*)authScheme;
347
351
 
363
367
        data.subject.subject_val[i].name = (char*)subject->identities[i].name;
364
368
    }
365
369
 
366
 
    remoteDispatchDomainEventSend (client,
367
 
                                   REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
368
 
                                   (xdrproc_t)xdr_remote_domain_event_graphics_msg, &data);
 
370
    remoteDispatchDomainEventSend(client,
 
371
                                  REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
 
372
                                  (xdrproc_t)xdr_remote_domain_event_graphics_msg, &data);
369
373
 
370
374
    VIR_FREE(data.subject.subject_val);
371
375
 
390
394
/*----- Functions. -----*/
391
395
 
392
396
static int
393
 
remoteDispatchOpen (struct qemud_server *server,
394
 
                    struct qemud_client *client,
395
 
                    virConnectPtr conn,
396
 
                    remote_message_header *hdr ATTRIBUTE_UNUSED,
397
 
                    remote_error *rerr,
398
 
                    struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
 
397
remoteDispatchOpen(struct qemud_server *server,
 
398
                   struct qemud_client *client,
 
399
                   virConnectPtr conn,
 
400
                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
401
                   remote_error *rerr,
 
402
                   struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
399
403
{
400
404
    const char *name;
401
 
    int flags, rc;
402
 
 
403
 
    /* Already opened? */
 
405
    int flags;
 
406
    int rv = -1;
 
407
 
 
408
    virMutexLock(&server->lock);
 
409
    virMutexLock(&client->lock);
 
410
    virMutexUnlock(&server->lock);
 
411
 
404
412
    if (conn) {
405
 
        remoteDispatchFormatError (rerr, "%s", _("connection already open"));
406
 
        return -1;
 
413
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection already open"));
 
414
        goto cleanup;
407
415
    }
408
416
 
409
 
    virMutexLock(&server->lock);
410
 
    virMutexLock(&client->lock);
411
 
    virMutexUnlock(&server->lock);
412
 
 
413
417
    name = args->name ? *args->name : NULL;
414
418
 
415
419
    /* If this connection arrived on a readonly socket, force
420
424
 
421
425
    client->conn =
422
426
        flags & VIR_CONNECT_RO
423
 
        ? virConnectOpenReadOnly (name)
424
 
        : virConnectOpen (name);
 
427
        ? virConnectOpenReadOnly(name)
 
428
        : virConnectOpen(name);
425
429
 
426
430
    if (client->conn == NULL)
427
 
        remoteDispatchConnError(rerr, NULL);
428
 
 
429
 
    rc = client->conn ? 0 : -1;
 
431
        goto cleanup;
 
432
 
 
433
    rv = 0;
 
434
 
 
435
cleanup:
 
436
    if (rv < 0)
 
437
        remoteDispatchError(rerr);
430
438
    virMutexUnlock(&client->lock);
431
 
    return rc;
 
439
    return rv;
432
440
}
433
441
 
434
 
#define CHECK_CONN(client)                                              \
435
 
    if (!client->conn) {                                                \
436
 
        remoteDispatchFormatError (rerr, "%s", _("connection not open")); \
437
 
        return -1;                                                      \
438
 
    }
439
442
 
440
443
static int
441
 
remoteDispatchClose (struct qemud_server *server ATTRIBUTE_UNUSED,
442
 
                     struct qemud_client *client ATTRIBUTE_UNUSED,
443
 
                     virConnectPtr conn ATTRIBUTE_UNUSED,
444
 
                     remote_message_header *hdr ATTRIBUTE_UNUSED,
445
 
                     remote_error *rerr ATTRIBUTE_UNUSED,
446
 
                     void *args ATTRIBUTE_UNUSED, void *ret ATTRIBUTE_UNUSED)
 
444
remoteDispatchClose(struct qemud_server *server ATTRIBUTE_UNUSED,
 
445
                    struct qemud_client *client ATTRIBUTE_UNUSED,
 
446
                    virConnectPtr conn ATTRIBUTE_UNUSED,
 
447
                    remote_message_header *hdr ATTRIBUTE_UNUSED,
 
448
                    remote_error *rerr ATTRIBUTE_UNUSED,
 
449
                    void *args ATTRIBUTE_UNUSED, void *ret ATTRIBUTE_UNUSED)
447
450
{
448
451
    virMutexLock(&server->lock);
449
452
    virMutexLock(&client->lock);
456
459
}
457
460
 
458
461
static int
459
 
remoteDispatchSupportsFeature (struct qemud_server *server ATTRIBUTE_UNUSED,
460
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
461
 
                               virConnectPtr conn,
462
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
463
 
                               remote_error *rerr,
464
 
                               remote_supports_feature_args *args, remote_supports_feature_ret *ret)
 
462
remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
 
463
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
464
                              virConnectPtr conn,
 
465
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
466
                              remote_error *rerr,
 
467
                              remote_supports_feature_args *args, remote_supports_feature_ret *ret)
465
468
{
466
 
    ret->supported = virDrvSupportsFeature (conn, args->feature);
 
469
    int rv = -1;
467
470
 
468
 
    if (ret->supported == -1) {
469
 
        remoteDispatchConnError(rerr, conn);
470
 
        return -1;
 
471
    if (!conn) {
 
472
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
473
        goto cleanup;
471
474
    }
472
475
 
473
 
    return 0;
 
476
    if ((ret->supported = virDrvSupportsFeature(conn, args->feature)) < 0)
 
477
        goto cleanup;
 
478
 
 
479
    rv = 0;
 
480
 
 
481
cleanup:
 
482
    if (rv < 0)
 
483
        remoteDispatchError(rerr);
 
484
    return rv;
474
485
}
475
486
 
476
487
static int
477
 
remoteDispatchGetType (struct qemud_server *server ATTRIBUTE_UNUSED,
478
 
                       struct qemud_client *client ATTRIBUTE_UNUSED,
479
 
                       virConnectPtr conn,
480
 
                       remote_message_header *hdr ATTRIBUTE_UNUSED,
481
 
                       remote_error *rerr,
482
 
                       void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
 
488
remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
 
489
                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
490
                      virConnectPtr conn,
 
491
                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
492
                      remote_error *rerr,
 
493
                      void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
483
494
{
484
495
    const char *type;
 
496
    int rv = -1;
485
497
 
486
 
    type = virConnectGetType (conn);
487
 
    if (type == NULL) {
488
 
        remoteDispatchConnError(rerr, conn);
489
 
        return -1;
 
498
    if (!conn) {
 
499
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
500
        goto cleanup;
490
501
    }
491
502
 
 
503
    if (!(type = virConnectGetType(conn)))
 
504
        goto cleanup;
 
505
 
492
506
    /* We have to strdup because remoteDispatchClientRequest will
493
507
     * free this string after it's been serialised.
494
508
     */
495
 
    ret->type = strdup (type);
496
 
    if (!ret->type) {
497
 
        remoteDispatchOOMError(rerr);
498
 
        return -1;
 
509
    if (!(ret->type = strdup(type))) {
 
510
        virReportOOMError();
 
511
        goto cleanup;
499
512
    }
500
513
 
501
 
    return 0;
 
514
    rv = 0;
 
515
 
 
516
cleanup:
 
517
    if (rv < 0)
 
518
        remoteDispatchError(rerr);
 
519
    return rv;
502
520
}
503
521
 
504
522
static int
505
 
remoteDispatchGetVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
506
 
                          struct qemud_client *client ATTRIBUTE_UNUSED,
507
 
                          virConnectPtr conn,
508
 
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
509
 
                          remote_error *rerr,
510
 
                          void *args ATTRIBUTE_UNUSED,
511
 
                          remote_get_version_ret *ret)
 
523
remoteDispatchGetVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
 
524
                         struct qemud_client *client ATTRIBUTE_UNUSED,
 
525
                         virConnectPtr conn,
 
526
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
527
                         remote_error *rerr,
 
528
                         void *args ATTRIBUTE_UNUSED,
 
529
                         remote_get_version_ret *ret)
512
530
{
513
531
    unsigned long hvVer;
 
532
    int rv = -1;
514
533
 
515
 
    if (virConnectGetVersion (conn, &hvVer) == -1) {
516
 
        remoteDispatchConnError(rerr, conn);
517
 
        return -1;
 
534
    if (!conn) {
 
535
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
536
        goto cleanup;
518
537
    }
519
538
 
 
539
    if (virConnectGetVersion(conn, &hvVer) < 0)
 
540
        goto cleanup;
 
541
 
520
542
    ret->hv_ver = hvVer;
521
 
    return 0;
 
543
    rv = 0;
 
544
 
 
545
cleanup:
 
546
    if (rv < 0)
 
547
        remoteDispatchError(rerr);
 
548
    return rv;
522
549
}
523
550
 
524
551
static int
525
 
remoteDispatchGetLibVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
526
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
527
 
                             virConnectPtr conn,
528
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
529
 
                             remote_error *rerr,
530
 
                             void *args ATTRIBUTE_UNUSED,
531
 
                             remote_get_lib_version_ret *ret)
 
552
remoteDispatchGetLibVersion(struct qemud_server *server ATTRIBUTE_UNUSED,
 
553
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
554
                            virConnectPtr conn,
 
555
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
556
                            remote_error *rerr,
 
557
                            void *args ATTRIBUTE_UNUSED,
 
558
                            remote_get_lib_version_ret *ret)
532
559
{
533
560
    unsigned long libVer;
 
561
    int rv = -1;
534
562
 
535
 
    if (virConnectGetLibVersion (conn, &libVer) == -1) {
536
 
        remoteDispatchConnError(rerr, conn);
537
 
        return -1;
 
563
    if (!conn) {
 
564
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
565
        goto cleanup;
538
566
    }
539
567
 
 
568
    if (virConnectGetLibVersion(conn, &libVer) < 0)
 
569
        goto cleanup;
 
570
 
540
571
    ret->lib_ver = libVer;
541
 
    return 0;
 
572
    rv = 0;
 
573
 
 
574
cleanup:
 
575
    if (rv < 0)
 
576
        remoteDispatchError(rerr);
 
577
    return rv;
542
578
}
543
579
 
544
580
static int
545
 
remoteDispatchGetHostname (struct qemud_server *server ATTRIBUTE_UNUSED,
546
 
                           struct qemud_client *client ATTRIBUTE_UNUSED,
547
 
                           virConnectPtr conn,
548
 
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
549
 
                           remote_error *rerr,
550
 
                           void *args ATTRIBUTE_UNUSED,
551
 
                           remote_get_hostname_ret *ret)
 
581
remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
 
582
                          struct qemud_client *client ATTRIBUTE_UNUSED,
 
583
                          virConnectPtr conn,
 
584
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
 
585
                          remote_error *rerr,
 
586
                          void *args ATTRIBUTE_UNUSED,
 
587
                          remote_get_hostname_ret *ret)
552
588
{
553
589
    char *hostname;
 
590
    int rv = -1;
554
591
 
555
 
    hostname = virConnectGetHostname (conn);
556
 
    if (hostname == NULL) {
557
 
        remoteDispatchConnError(rerr, conn);
558
 
        return -1;
 
592
    if (!conn) {
 
593
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
594
        goto cleanup;
559
595
    }
560
596
 
 
597
    if (!(hostname = virConnectGetHostname(conn)))
 
598
        goto cleanup;
 
599
 
561
600
    ret->hostname = hostname;
562
 
    return 0;
 
601
    rv = 0;
 
602
 
 
603
cleanup:
 
604
    if (rv < 0)
 
605
        remoteDispatchError(rerr);
 
606
    return rv;
563
607
}
564
608
 
565
609
static int
566
 
remoteDispatchGetUri (struct qemud_server *server ATTRIBUTE_UNUSED,
567
 
                      struct qemud_client *client ATTRIBUTE_UNUSED,
568
 
                      virConnectPtr conn,
569
 
                      remote_message_header *hdr ATTRIBUTE_UNUSED,
570
 
                      remote_error *rerr,
571
 
                      void *args ATTRIBUTE_UNUSED,
572
 
                      remote_get_uri_ret *ret)
 
610
remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
 
611
                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
612
                     virConnectPtr conn,
 
613
                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
614
                     remote_error *rerr,
 
615
                     void *args ATTRIBUTE_UNUSED,
 
616
                     remote_get_uri_ret *ret)
573
617
{
574
618
    char *uri;
575
 
    CHECK_CONN(client);
 
619
    int rv = -1;
576
620
 
577
 
    uri = virConnectGetURI (conn);
578
 
    if (uri == NULL) {
579
 
        remoteDispatchConnError(rerr, conn);
580
 
        return -1;
 
621
    if (!conn) {
 
622
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
623
        goto cleanup;
581
624
    }
582
625
 
 
626
    if (!(uri = virConnectGetURI(conn)))
 
627
        goto cleanup;
 
628
 
583
629
    ret->uri = uri;
584
 
    return 0;
 
630
    rv = 0;
 
631
 
 
632
cleanup:
 
633
    if (rv < 0)
 
634
        remoteDispatchError(rerr);
 
635
    return rv;
585
636
}
586
637
 
587
638
static int
588
 
remoteDispatchGetSysinfo (struct qemud_server *server ATTRIBUTE_UNUSED,
589
 
                          struct qemud_client *client ATTRIBUTE_UNUSED,
590
 
                          virConnectPtr conn,
591
 
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
592
 
                          remote_error *rerr,
593
 
                          remote_get_sysinfo_args *args,
594
 
                          remote_get_sysinfo_ret *ret)
 
639
remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
640
                         struct qemud_client *client ATTRIBUTE_UNUSED,
 
641
                         virConnectPtr conn,
 
642
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
643
                         remote_error *rerr,
 
644
                         remote_get_sysinfo_args *args,
 
645
                         remote_get_sysinfo_ret *ret)
595
646
{
596
647
    unsigned int flags;
597
648
    char *sysinfo;
 
649
    int rv = -1;
 
650
 
 
651
    if (!conn) {
 
652
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
653
        goto cleanup;
 
654
    }
598
655
 
599
656
    flags = args->flags;
600
 
    sysinfo = virConnectGetSysinfo (conn, flags);
601
 
    if (sysinfo == NULL) {
602
 
        remoteDispatchConnError(rerr, conn);
603
 
        return -1;
604
 
    }
 
657
    if (!(sysinfo = virConnectGetSysinfo(conn, flags)))
 
658
        goto cleanup;
605
659
 
606
660
    ret->sysinfo = sysinfo;
607
 
    return 0;
 
661
    rv = 0;
 
662
 
 
663
cleanup:
 
664
    if (rv < 0)
 
665
        remoteDispatchError(rerr);
 
666
    return rv;
608
667
}
609
668
 
610
669
static int
611
 
remoteDispatchGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
612
 
                           struct qemud_client *client ATTRIBUTE_UNUSED,
613
 
                           virConnectPtr conn,
614
 
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
615
 
                           remote_error *rerr,
616
 
                           remote_get_max_vcpus_args *args,
617
 
                           remote_get_max_vcpus_ret *ret)
 
670
remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
 
671
                          struct qemud_client *client ATTRIBUTE_UNUSED,
 
672
                          virConnectPtr conn,
 
673
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
 
674
                          remote_error *rerr,
 
675
                          remote_get_max_vcpus_args *args,
 
676
                          remote_get_max_vcpus_ret *ret)
618
677
{
619
678
    char *type;
 
679
    int rv = -1;
 
680
 
 
681
    if (!conn) {
 
682
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
683
        goto cleanup;
 
684
    }
620
685
 
621
686
    type = args->type ? *args->type : NULL;
622
 
    ret->max_vcpus = virConnectGetMaxVcpus (conn, type);
623
 
    if (ret->max_vcpus == -1) {
624
 
        remoteDispatchConnError(rerr, conn);
625
 
        return -1;
626
 
    }
627
 
 
628
 
    return 0;
 
687
    if ((ret->max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
 
688
        goto cleanup;
 
689
 
 
690
    rv = 0;
 
691
 
 
692
cleanup:
 
693
    if (rv < 0)
 
694
        remoteDispatchError(rerr);
 
695
    return rv;
629
696
}
630
697
 
631
698
static int
632
 
remoteDispatchNodeGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
633
 
                           struct qemud_client *client ATTRIBUTE_UNUSED,
634
 
                           virConnectPtr conn,
635
 
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
636
 
                           remote_error *rerr,
637
 
                           void *args ATTRIBUTE_UNUSED,
638
 
                           remote_node_get_info_ret *ret)
 
699
remoteDispatchNodeGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
700
                          struct qemud_client *client ATTRIBUTE_UNUSED,
 
701
                          virConnectPtr conn,
 
702
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
 
703
                          remote_error *rerr,
 
704
                          void *args ATTRIBUTE_UNUSED,
 
705
                          remote_node_get_info_ret *ret)
639
706
{
640
707
    virNodeInfo info;
 
708
    int rv = -1;
641
709
 
642
 
    if (virNodeGetInfo (conn, &info) == -1) {
643
 
        remoteDispatchConnError(rerr, conn);
644
 
        return -1;
 
710
    if (!conn) {
 
711
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
712
        goto cleanup;
645
713
    }
646
714
 
647
 
    memcpy (ret->model, info.model, sizeof ret->model);
 
715
    if (virNodeGetInfo(conn, &info) < 0)
 
716
        goto cleanup;
 
717
 
 
718
    memcpy(ret->model, info.model, sizeof ret->model);
648
719
    ret->memory = info.memory;
649
720
    ret->cpus = info.cpus;
650
721
    ret->mhz = info.mhz;
653
724
    ret->cores = info.cores;
654
725
    ret->threads = info.threads;
655
726
 
656
 
    return 0;
 
727
    rv = 0;
 
728
 
 
729
cleanup:
 
730
    if (rv < 0)
 
731
        remoteDispatchError(rerr);
 
732
    return rv;
657
733
}
658
734
 
659
735
static int
660
 
remoteDispatchGetCapabilities (struct qemud_server *server ATTRIBUTE_UNUSED,
661
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
662
 
                               virConnectPtr conn,
663
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
664
 
                               remote_error *rerr,
665
 
                               void *args ATTRIBUTE_UNUSED,
666
 
                               remote_get_capabilities_ret *ret)
 
736
remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
 
737
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
738
                              virConnectPtr conn,
 
739
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
740
                              remote_error *rerr,
 
741
                              void *args ATTRIBUTE_UNUSED,
 
742
                              remote_get_capabilities_ret *ret)
667
743
{
668
744
    char *caps;
 
745
    int rv = -1;
669
746
 
670
 
    caps = virConnectGetCapabilities (conn);
671
 
    if (caps == NULL) {
672
 
        remoteDispatchConnError(rerr, conn);
673
 
        return -1;
 
747
    if (!conn) {
 
748
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
749
        goto cleanup;
674
750
    }
675
751
 
 
752
    if (!(caps = virConnectGetCapabilities(conn)))
 
753
        goto cleanup;
 
754
 
676
755
    ret->capabilities = caps;
677
 
    return 0;
 
756
    rv = 0;
 
757
 
 
758
cleanup:
 
759
    if (rv < 0)
 
760
        remoteDispatchError(rerr);
 
761
    return rv;
678
762
}
679
763
 
680
764
static int
681
 
remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
682
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
683
 
                                      virConnectPtr conn,
684
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
685
 
                                      remote_error *rerr,
686
 
                                      remote_node_get_cells_free_memory_args *args,
687
 
                                      remote_node_get_cells_free_memory_ret *ret)
 
765
remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
 
766
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
767
                                     virConnectPtr conn,
 
768
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
769
                                     remote_error *rerr,
 
770
                                     remote_node_get_cells_free_memory_args *args,
 
771
                                     remote_node_get_cells_free_memory_ret *ret)
688
772
{
689
 
    int err;
 
773
    int len;
 
774
    int rv = -1;
 
775
 
 
776
    if (!conn) {
 
777
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
778
        goto cleanup;
 
779
    }
690
780
 
691
781
    if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
692
 
        remoteDispatchFormatError (rerr,
693
 
                                   "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
694
 
        return -1;
 
782
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
783
                    "%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
 
784
        goto cleanup;
695
785
    }
696
786
 
697
787
    /* Allocate return buffer. */
698
788
    if (VIR_ALLOC_N(ret->freeMems.freeMems_val, args->maxCells) < 0) {
699
 
        remoteDispatchOOMError(rerr);
700
 
        return -1;
 
789
        virReportOOMError();
 
790
        goto cleanup;
701
791
    }
702
792
 
703
 
    err = virNodeGetCellsFreeMemory(conn,
 
793
    len = virNodeGetCellsFreeMemory(conn,
704
794
                                    (unsigned long long *)ret->freeMems.freeMems_val,
705
795
                                    args->startCell,
706
796
                                    args->maxCells);
707
 
    if (err <= 0) {
 
797
    if (len <= 0)
 
798
        goto cleanup;
 
799
    ret->freeMems.freeMems_len = len;
 
800
 
 
801
    rv = 0;
 
802
 
 
803
cleanup:
 
804
    if (rv < 0) {
 
805
        remoteDispatchError(rerr);
708
806
        VIR_FREE(ret->freeMems.freeMems_val);
709
 
        remoteDispatchConnError(rerr, conn);
710
 
        return -1;
711
807
    }
712
 
    ret->freeMems.freeMems_len = err;
713
 
 
714
 
    return 0;
 
808
    return rv;
715
809
}
716
810
 
717
811
 
718
812
static int
719
 
remoteDispatchNodeGetFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
720
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
721
 
                                 virConnectPtr conn,
722
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
723
 
                                 remote_error *rerr,
724
 
                                 void *args ATTRIBUTE_UNUSED,
725
 
                                 remote_node_get_free_memory_ret *ret)
 
813
remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
 
814
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
815
                                virConnectPtr conn,
 
816
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
817
                                remote_error *rerr,
 
818
                                void *args ATTRIBUTE_UNUSED,
 
819
                                remote_node_get_free_memory_ret *ret)
726
820
{
727
821
    unsigned long long freeMem;
 
822
    int rv = -1;
728
823
 
729
 
    freeMem = virNodeGetFreeMemory(conn);
730
 
    if (freeMem == 0) {
731
 
        remoteDispatchConnError(rerr, conn);
732
 
        return -1;
 
824
    if (!conn) {
 
825
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
826
        goto cleanup;
733
827
    }
 
828
 
 
829
    if ((freeMem = virNodeGetFreeMemory(conn)) == 0)
 
830
        goto cleanup;
734
831
    ret->freeMem = freeMem;
735
 
    return 0;
 
832
    rv = 0;
 
833
 
 
834
cleanup:
 
835
    if (rv < 0)
 
836
        remoteDispatchError(rerr);
 
837
    return rv;
736
838
}
737
839
 
738
840
 
739
841
static int
740
 
remoteDispatchDomainGetSchedulerType (struct qemud_server *server ATTRIBUTE_UNUSED,
741
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
742
 
                                      virConnectPtr conn,
743
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
744
 
                                      remote_error *rerr,
745
 
                                      remote_domain_get_scheduler_type_args *args,
746
 
                                      remote_domain_get_scheduler_type_ret *ret)
 
842
remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSED,
 
843
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
844
                                     virConnectPtr conn,
 
845
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
846
                                     remote_error *rerr,
 
847
                                     remote_domain_get_scheduler_type_args *args,
 
848
                                     remote_domain_get_scheduler_type_ret *ret)
747
849
{
748
 
    virDomainPtr dom;
 
850
    virDomainPtr dom = NULL;
749
851
    char *type;
750
852
    int nparams;
751
 
 
752
 
    dom = get_nonnull_domain (conn, args->dom);
753
 
    if (dom == NULL) {
754
 
        remoteDispatchConnError(rerr, conn);
755
 
        return -1;
756
 
    }
757
 
 
758
 
    type = virDomainGetSchedulerType (dom, &nparams);
759
 
    if (type == NULL) {
760
 
        virDomainFree(dom);
761
 
        remoteDispatchConnError(rerr, conn);
762
 
        return -1;
763
 
    }
 
853
    int rv = -1;
 
854
 
 
855
    if (!conn) {
 
856
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
857
        goto cleanup;
 
858
    }
 
859
 
 
860
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
861
        goto cleanup;
 
862
 
 
863
    if (!(type = virDomainGetSchedulerType(dom, &nparams)))
 
864
        goto cleanup;
764
865
 
765
866
    ret->type = type;
766
867
    ret->nparams = nparams;
767
 
    virDomainFree(dom);
768
 
    return 0;
 
868
    rv = 0;
 
869
 
 
870
cleanup:
 
871
    if (rv < 0)
 
872
        remoteDispatchError(rerr);
 
873
    if (dom)
 
874
        virDomainFree(dom);
 
875
    return rv;
769
876
}
770
877
 
771
878
static int
772
 
remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
773
 
                                            struct qemud_client *client ATTRIBUTE_UNUSED,
774
 
                                            virConnectPtr conn,
775
 
                                            remote_message_header *hdr ATTRIBUTE_UNUSED,
776
 
                                            remote_error *rerr,
777
 
                                            remote_domain_get_scheduler_parameters_args *args,
778
 
                                            remote_domain_get_scheduler_parameters_ret *ret)
 
879
remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE_UNUSED,
 
880
                                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
881
                                           virConnectPtr conn,
 
882
                                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
883
                                           remote_error *rerr,
 
884
                                           remote_domain_get_scheduler_parameters_args *args,
 
885
                                           remote_domain_get_scheduler_parameters_ret *ret)
779
886
{
780
 
    virDomainPtr dom;
781
 
    virSchedParameterPtr params;
782
 
    int i, r, nparams;
 
887
    virDomainPtr dom = NULL;
 
888
    virSchedParameterPtr params = NULL;
 
889
    int i;
 
890
    int nparams = args->nparams;
 
891
    int rv = -1;
783
892
 
784
 
    nparams = args->nparams;
 
893
    if (!conn) {
 
894
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
895
        goto cleanup;
 
896
    }
785
897
 
786
898
    if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
787
 
        remoteDispatchFormatError (rerr, "%s", _("nparams too large"));
788
 
        return -1;
789
 
    }
790
 
    if (VIR_ALLOC_N(params, nparams) < 0) {
791
 
        remoteDispatchOOMError(rerr);
792
 
        return -1;
793
 
    }
794
 
 
795
 
    dom = get_nonnull_domain (conn, args->dom);
796
 
    if (dom == NULL) {
797
 
        VIR_FREE(params);
798
 
        remoteDispatchConnError(rerr, conn);
799
 
        return -1;
800
 
    }
801
 
 
802
 
    r = virDomainGetSchedulerParameters (dom, params, &nparams);
803
 
    if (r == -1) {
804
 
        virDomainFree(dom);
805
 
        VIR_FREE(params);
806
 
        remoteDispatchConnError(rerr, conn);
807
 
        return -1;
808
 
    }
 
899
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
 
900
        goto cleanup;
 
901
    }
 
902
    if (VIR_ALLOC_N(params, nparams) < 0)
 
903
        goto no_memory;
 
904
 
 
905
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
906
        goto cleanup;
 
907
 
 
908
    if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0)
 
909
        goto cleanup;
809
910
 
810
911
    /* Serialise the scheduler parameters. */
811
912
    ret->params.params_len = nparams;
812
913
    if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
813
 
        goto oom;
 
914
        goto no_memory;
814
915
 
815
916
    for (i = 0; i < nparams; ++i) {
816
917
        /* remoteDispatchClientRequest will free this: */
817
 
        ret->params.params_val[i].field = strdup (params[i].field);
 
918
        ret->params.params_val[i].field = strdup(params[i].field);
818
919
        if (ret->params.params_val[i].field == NULL)
819
 
            goto oom;
 
920
            goto no_memory;
820
921
 
821
922
        ret->params.params_val[i].value.type = params[i].type;
822
923
        switch (params[i].type) {
833
934
        case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
834
935
            ret->params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
835
936
        default:
836
 
            remoteDispatchFormatError (rerr, "%s", _("unknown type"));
 
937
            virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
837
938
            goto cleanup;
838
939
        }
839
940
    }
840
 
    virDomainFree(dom);
841
 
    VIR_FREE(params);
842
 
 
843
 
    return 0;
844
 
 
845
 
oom:
846
 
    remoteDispatchOOMError(rerr);
 
941
 
 
942
    rv = 0;
 
943
 
847
944
cleanup:
848
 
    virDomainFree(dom);
849
 
    for (i = 0 ; i < nparams ; i++)
850
 
        VIR_FREE(ret->params.params_val[i].field);
 
945
    if (rv < 0) {
 
946
        remoteDispatchError(rerr);
 
947
        if (ret->params.params_val) {
 
948
            for (i = 0 ; i < nparams ; i++)
 
949
                VIR_FREE(ret->params.params_val[i].field);
 
950
            VIR_FREE(ret->params.params_val);
 
951
        }
 
952
    }
 
953
    if (dom)
 
954
        virDomainFree(dom);
851
955
    VIR_FREE(params);
852
 
    return -1;
 
956
    return rv;
 
957
 
 
958
no_memory:
 
959
    virReportOOMError();
 
960
    goto cleanup;
853
961
}
854
962
 
855
963
static int
856
 
remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
857
 
                                            struct qemud_client *client ATTRIBUTE_UNUSED,
858
 
                                            virConnectPtr conn,
859
 
                                            remote_message_header *hdr ATTRIBUTE_UNUSED,
860
 
                                            remote_error *rerr,
861
 
                                            remote_domain_set_scheduler_parameters_args *args,
862
 
                                            void *ret ATTRIBUTE_UNUSED)
 
964
remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE_UNUSED,
 
965
                                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
966
                                           virConnectPtr conn,
 
967
                                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
968
                                           remote_error *rerr,
 
969
                                           remote_domain_set_scheduler_parameters_args *args,
 
970
                                           void *ret ATTRIBUTE_UNUSED)
863
971
{
864
 
    virDomainPtr dom;
865
 
    int i, r, nparams;
866
 
    virSchedParameterPtr params;
 
972
    virDomainPtr dom = NULL;
 
973
    virSchedParameterPtr params = NULL;
 
974
    int i, nparams;
 
975
    int rv = -1;
 
976
 
 
977
    if (!conn) {
 
978
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
979
        goto cleanup;
 
980
    }
867
981
 
868
982
    nparams = args->params.params_len;
869
983
 
870
984
    if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
871
 
        remoteDispatchFormatError (rerr, "%s", _("nparams too large"));
872
 
        return -1;
 
985
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
 
986
        goto cleanup;
873
987
    }
874
988
    if (VIR_ALLOC_N(params, nparams) < 0) {
875
 
        remoteDispatchOOMError(rerr);
876
 
        return -1;
 
989
        virReportOOMError();
 
990
        goto cleanup;
877
991
    }
878
992
 
879
993
    /* Deserialise parameters. */
880
994
    for (i = 0; i < nparams; ++i) {
881
995
        if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
882
 
            remoteDispatchFormatError(rerr, _("Field %s too big for destination"),
 
996
            virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
883
997
                                      args->params.params_val[i].field);
884
 
            return -1;
 
998
            goto cleanup;
885
999
        }
886
1000
        params[i].type = args->params.params_val[i].value.type;
887
1001
        switch (params[i].type) {
900
1014
        }
901
1015
    }
902
1016
 
903
 
    dom = get_nonnull_domain (conn, args->dom);
904
 
    if (dom == NULL) {
905
 
        VIR_FREE(params);
906
 
        remoteDispatchConnError(rerr, conn);
907
 
        return -1;
908
 
    }
909
 
 
910
 
    r = virDomainSetSchedulerParameters (dom, params, nparams);
911
 
    virDomainFree(dom);
 
1017
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1018
        goto cleanup;
 
1019
 
 
1020
    if (virDomainSetSchedulerParameters(dom, params, nparams) < 0)
 
1021
        goto cleanup;
 
1022
 
 
1023
    rv = 0;
 
1024
 
 
1025
cleanup:
 
1026
    if (rv < 0)
 
1027
        remoteDispatchError(rerr);
 
1028
    if (dom)
 
1029
        virDomainFree(dom);
912
1030
    VIR_FREE(params);
913
 
    if (r == -1) {
914
 
        remoteDispatchConnError(rerr, conn);
915
 
        return -1;
916
 
    }
917
 
 
918
 
    return 0;
 
1031
    return rv;
919
1032
}
920
1033
 
921
1034
static int
922
 
remoteDispatchDomainBlockStats (struct qemud_server *server ATTRIBUTE_UNUSED,
923
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
924
 
                                virConnectPtr conn,
925
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
926
 
                                remote_error *rerr,
927
 
                                remote_domain_block_stats_args *args,
928
 
                                remote_domain_block_stats_ret *ret)
 
1035
remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1036
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
1037
                               virConnectPtr conn,
 
1038
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1039
                               remote_error *rerr,
 
1040
                               remote_domain_block_stats_args *args,
 
1041
                               remote_domain_block_stats_ret *ret)
929
1042
{
930
 
    virDomainPtr dom;
 
1043
    virDomainPtr dom = NULL;
931
1044
    char *path;
932
1045
    struct _virDomainBlockStats stats;
 
1046
    int rv = -1;
933
1047
 
934
 
    dom = get_nonnull_domain (conn, args->dom);
935
 
    if (dom == NULL) {
936
 
        remoteDispatchConnError(rerr, conn);
937
 
        return -1;
 
1048
    if (!conn) {
 
1049
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1050
        goto cleanup;
938
1051
    }
 
1052
 
 
1053
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1054
        goto cleanup;
939
1055
    path = args->path;
940
1056
 
941
 
    if (virDomainBlockStats (dom, path, &stats, sizeof stats) == -1) {
942
 
        virDomainFree (dom);
943
 
        remoteDispatchConnError(rerr, conn);
944
 
        return -1;
945
 
    }
946
 
    virDomainFree (dom);
 
1057
    if (virDomainBlockStats(dom, path, &stats, sizeof stats) < 0)
 
1058
        goto cleanup;
947
1059
 
948
1060
    ret->rd_req = stats.rd_req;
949
1061
    ret->rd_bytes = stats.rd_bytes;
951
1063
    ret->wr_bytes = stats.wr_bytes;
952
1064
    ret->errs = stats.errs;
953
1065
 
954
 
    return 0;
 
1066
    rv = 0;
 
1067
 
 
1068
cleanup:
 
1069
    if (rv < 0)
 
1070
        remoteDispatchError(rerr);
 
1071
    if (dom)
 
1072
        virDomainFree(dom);
 
1073
    return rv;
955
1074
}
956
1075
 
957
1076
static int
958
 
remoteDispatchDomainInterfaceStats (struct qemud_server *server ATTRIBUTE_UNUSED,
959
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
960
 
                                    virConnectPtr conn,
961
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
962
 
                                    remote_error *rerr,
963
 
                                    remote_domain_interface_stats_args *args,
964
 
                                    remote_domain_interface_stats_ret *ret)
 
1077
remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1078
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
1079
                                   virConnectPtr conn,
 
1080
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1081
                                   remote_error *rerr,
 
1082
                                   remote_domain_interface_stats_args *args,
 
1083
                                   remote_domain_interface_stats_ret *ret)
965
1084
{
966
 
    virDomainPtr dom;
 
1085
    virDomainPtr dom = NULL;
967
1086
    char *path;
968
1087
    struct _virDomainInterfaceStats stats;
 
1088
    int rv = -1;
969
1089
 
970
 
    dom = get_nonnull_domain (conn, args->dom);
971
 
    if (dom == NULL) {
972
 
        remoteDispatchConnError(rerr, conn);
973
 
        return -1;
 
1090
    if (!conn) {
 
1091
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1092
        goto cleanup;
974
1093
    }
 
1094
 
 
1095
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1096
        goto cleanup;
975
1097
    path = args->path;
976
1098
 
977
 
    if (virDomainInterfaceStats (dom, path, &stats, sizeof stats) == -1) {
978
 
        virDomainFree (dom);
979
 
        remoteDispatchConnError(rerr, conn);
980
 
        return -1;
981
 
    }
982
 
    virDomainFree (dom);
 
1099
    if (virDomainInterfaceStats(dom, path, &stats, sizeof stats) < 0)
 
1100
        goto cleanup;
983
1101
 
984
1102
    ret->rx_bytes = stats.rx_bytes;
985
1103
    ret->rx_packets = stats.rx_packets;
990
1108
    ret->tx_errs = stats.tx_errs;
991
1109
    ret->tx_drop = stats.tx_drop;
992
1110
 
993
 
    return 0;
 
1111
    rv = 0;
 
1112
 
 
1113
cleanup:
 
1114
    if (rv < 0)
 
1115
        remoteDispatchError(rerr);
 
1116
    if (dom)
 
1117
        virDomainFree(dom);
 
1118
    return rv;
994
1119
}
995
1120
 
996
1121
static int
997
 
remoteDispatchDomainMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
998
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
999
 
                                 virConnectPtr conn,
1000
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
1001
 
                                 remote_error *rerr,
1002
 
                                 remote_domain_memory_stats_args *args,
1003
 
                                 remote_domain_memory_stats_ret *ret)
 
1122
remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1123
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
1124
                                virConnectPtr conn,
 
1125
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1126
                                remote_error *rerr,
 
1127
                                remote_domain_memory_stats_args *args,
 
1128
                                remote_domain_memory_stats_ret *ret)
1004
1129
{
1005
 
    virDomainPtr dom;
 
1130
    virDomainPtr dom = NULL;
1006
1131
    struct _virDomainMemoryStat *stats;
1007
 
    unsigned int nr_stats, i;
 
1132
    int nr_stats, i;
 
1133
    int rv = -1;
 
1134
 
 
1135
    if (!conn) {
 
1136
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1137
        goto cleanup;
 
1138
    }
1008
1139
 
1009
1140
    if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
1010
 
        remoteDispatchFormatError (rerr, "%s",
1011
 
                               _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
1012
 
        return -1;
 
1141
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
 
1142
                    _("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
 
1143
        goto cleanup;
1013
1144
    }
1014
1145
 
1015
 
    dom = get_nonnull_domain (conn, args->dom);
1016
 
    if (dom == NULL) {
1017
 
        remoteDispatchConnError(rerr, conn);
1018
 
        return -1;
1019
 
    }
 
1146
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1147
        goto cleanup;
1020
1148
 
1021
1149
    /* Allocate stats array for making dispatch call */
1022
1150
    if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
1023
 
        virDomainFree (dom);
1024
 
        remoteDispatchOOMError(rerr);
1025
 
        return -1;
 
1151
        virReportOOMError();
 
1152
        goto cleanup;
1026
1153
    }
1027
1154
 
1028
 
    nr_stats = virDomainMemoryStats (dom, stats, args->maxStats, 0);
1029
 
    virDomainFree (dom);
1030
 
    if (nr_stats == -1) {
1031
 
        VIR_FREE(stats);
1032
 
        remoteDispatchConnError(rerr, conn);
1033
 
        return -1;
1034
 
    }
 
1155
    nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, 0);
 
1156
    if (nr_stats < 0)
 
1157
        goto cleanup;
1035
1158
 
1036
1159
    /* Allocate return buffer */
1037
1160
    if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
1038
 
        VIR_FREE(stats);
1039
 
        remoteDispatchOOMError(rerr);
1040
 
        return -1;
 
1161
        virReportOOMError();
 
1162
        goto cleanup;
1041
1163
    }
1042
1164
 
1043
1165
    /* Copy the stats into the xdr return structure */
1046
1168
        ret->stats.stats_val[i].val = stats[i].val;
1047
1169
    }
1048
1170
    ret->stats.stats_len = nr_stats;
 
1171
    rv = 0;
 
1172
 
 
1173
cleanup:
 
1174
    if (rv < 0)
 
1175
        remoteDispatchError(rerr);
 
1176
    if (dom)
 
1177
        virDomainFree(dom);
1049
1178
    VIR_FREE(stats);
1050
 
    return 0;
 
1179
    return rv;
1051
1180
}
1052
1181
 
1053
1182
static int
1054
 
remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
1055
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
1056
 
                               virConnectPtr conn,
1057
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
1058
 
                               remote_error *rerr,
1059
 
                               remote_domain_block_peek_args *args,
1060
 
                               remote_domain_block_peek_ret *ret)
 
1183
remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1184
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
1185
                              virConnectPtr conn,
 
1186
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1187
                              remote_error *rerr,
 
1188
                              remote_domain_block_peek_args *args,
 
1189
                              remote_domain_block_peek_ret *ret)
1061
1190
{
1062
 
    virDomainPtr dom;
 
1191
    virDomainPtr dom = NULL;
1063
1192
    char *path;
1064
1193
    unsigned long long offset;
1065
1194
    size_t size;
1066
1195
    unsigned int flags;
 
1196
    int rv = -1;
1067
1197
 
1068
 
    dom = get_nonnull_domain (conn, args->dom);
1069
 
    if (dom == NULL) {
1070
 
        remoteDispatchConnError(rerr, conn);
1071
 
        return -1;
 
1198
    if (!conn) {
 
1199
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1200
        goto cleanup;
1072
1201
    }
 
1202
 
 
1203
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1204
        goto cleanup;
1073
1205
    path = args->path;
1074
1206
    offset = args->offset;
1075
1207
    size = args->size;
1076
1208
    flags = args->flags;
1077
1209
 
1078
1210
    if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
1079
 
        virDomainFree (dom);
1080
 
        remoteDispatchFormatError (rerr,
1081
 
                                   "%s", _("size > maximum buffer size"));
1082
 
        return -1;
 
1211
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
1212
                    "%s", _("size > maximum buffer size"));
 
1213
        goto cleanup;
1083
1214
    }
1084
1215
 
1085
1216
    ret->buffer.buffer_len = size;
1086
 
    if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
1087
 
        virDomainFree (dom);
1088
 
        remoteDispatchOOMError(rerr);
1089
 
        return -1;
1090
 
    }
1091
 
 
1092
 
    if (virDomainBlockPeek (dom, path, offset, size,
1093
 
                            ret->buffer.buffer_val, flags) == -1) {
1094
 
        /* free (ret->buffer.buffer_val); - caller frees */
1095
 
        virDomainFree (dom);
1096
 
        remoteDispatchConnError(rerr, conn);
1097
 
        return -1;
1098
 
    }
1099
 
    virDomainFree (dom);
1100
 
 
1101
 
    return 0;
 
1217
    if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
 
1218
        virReportOOMError();
 
1219
        goto cleanup;
 
1220
    }
 
1221
 
 
1222
    if (virDomainBlockPeek(dom, path, offset, size,
 
1223
                           ret->buffer.buffer_val, flags) < 0)
 
1224
        goto cleanup;
 
1225
 
 
1226
    rv = 0;
 
1227
 
 
1228
cleanup:
 
1229
    if (rv < 0) {
 
1230
        remoteDispatchError(rerr);
 
1231
        VIR_FREE(ret->buffer.buffer_val);
 
1232
    }
 
1233
    if (dom)
 
1234
        virDomainFree(dom);
 
1235
    return rv;
1102
1236
}
1103
1237
 
1104
1238
static int
1105
 
remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
1106
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
1107
 
                                virConnectPtr conn,
1108
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
1109
 
                                remote_error *rerr,
1110
 
                                remote_domain_memory_peek_args *args,
1111
 
                                remote_domain_memory_peek_ret *ret)
 
1239
remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1240
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
1241
                               virConnectPtr conn,
 
1242
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1243
                               remote_error *rerr,
 
1244
                               remote_domain_memory_peek_args *args,
 
1245
                               remote_domain_memory_peek_ret *ret)
1112
1246
{
1113
 
    virDomainPtr dom;
 
1247
    virDomainPtr dom = NULL;
1114
1248
    unsigned long long offset;
1115
1249
    size_t size;
1116
1250
    unsigned int flags;
 
1251
    int rv = -1;
1117
1252
 
1118
 
    dom = get_nonnull_domain (conn, args->dom);
1119
 
    if (dom == NULL) {
1120
 
        remoteDispatchConnError(rerr, conn);
1121
 
        return -1;
 
1253
    if (!conn) {
 
1254
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1255
        goto cleanup;
1122
1256
    }
 
1257
 
 
1258
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1259
        goto cleanup;
1123
1260
    offset = args->offset;
1124
1261
    size = args->size;
1125
1262
    flags = args->flags;
1126
1263
 
1127
1264
    if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
1128
 
        virDomainFree (dom);
1129
 
        remoteDispatchFormatError (rerr,
1130
 
                                   "%s", _("size > maximum buffer size"));
1131
 
        return -1;
 
1265
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
1266
                    "%s", _("size > maximum buffer size"));
 
1267
        goto cleanup;
1132
1268
    }
1133
1269
 
1134
1270
    ret->buffer.buffer_len = size;
1135
 
    if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
1136
 
        virDomainFree (dom);
1137
 
        remoteDispatchOOMError(rerr);
1138
 
        return -1;
1139
 
    }
1140
 
 
1141
 
    if (virDomainMemoryPeek (dom, offset, size,
1142
 
                             ret->buffer.buffer_val, flags) == -1) {
1143
 
        /* free (ret->buffer.buffer_val); - caller frees */
1144
 
        virDomainFree (dom);
1145
 
        remoteDispatchConnError(rerr, conn);
1146
 
        return -1;
1147
 
    }
1148
 
    virDomainFree (dom);
1149
 
 
1150
 
    return 0;
1151
 
}
1152
 
 
1153
 
static int
1154
 
remoteDispatchDomainAttachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
1155
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
1156
 
                                  virConnectPtr conn,
1157
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
1158
 
                                  remote_error *rerr,
1159
 
                                  remote_domain_attach_device_args *args,
1160
 
                                  void *ret ATTRIBUTE_UNUSED)
1161
 
{
1162
 
    virDomainPtr dom;
1163
 
 
1164
 
    dom = get_nonnull_domain (conn, args->dom);
1165
 
    if (dom == NULL) {
1166
 
        remoteDispatchConnError(rerr, conn);
1167
 
        return -1;
1168
 
    }
1169
 
 
1170
 
    if (virDomainAttachDevice (dom, args->xml) == -1) {
1171
 
        virDomainFree(dom);
1172
 
        remoteDispatchConnError(rerr, conn);
1173
 
        return -1;
1174
 
    }
1175
 
    virDomainFree(dom);
1176
 
    return 0;
1177
 
}
1178
 
 
1179
 
static int
1180
 
remoteDispatchDomainAttachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
1181
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
1182
 
                                       virConnectPtr conn,
1183
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
1184
 
                                       remote_error *rerr,
1185
 
                                       remote_domain_attach_device_flags_args *args,
1186
 
                                       void *ret ATTRIBUTE_UNUSED)
1187
 
{
1188
 
    virDomainPtr dom;
1189
 
 
1190
 
    dom = get_nonnull_domain (conn, args->dom);
1191
 
    if (dom == NULL) {
1192
 
        remoteDispatchConnError(rerr, conn);
1193
 
        return -1;
1194
 
    }
1195
 
 
1196
 
    if (virDomainAttachDeviceFlags (dom, args->xml, args->flags) == -1) {
1197
 
        virDomainFree(dom);
1198
 
        remoteDispatchConnError(rerr, conn);
1199
 
        return -1;
1200
 
    }
1201
 
    virDomainFree(dom);
1202
 
    return 0;
1203
 
}
1204
 
 
1205
 
static int
1206
 
remoteDispatchDomainUpdateDeviceFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
1207
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
1208
 
                                       virConnectPtr conn,
1209
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
1210
 
                                       remote_error *rerr,
1211
 
                                       remote_domain_update_device_flags_args *args,
1212
 
                                       void *ret ATTRIBUTE_UNUSED)
1213
 
{
1214
 
    virDomainPtr dom;
1215
 
 
1216
 
    dom = get_nonnull_domain (conn, args->dom);
1217
 
    if (dom == NULL) {
1218
 
        remoteDispatchConnError(rerr, conn);
1219
 
        return -1;
1220
 
    }
1221
 
 
1222
 
    if (virDomainUpdateDeviceFlags (dom, args->xml, args->flags) == -1) {
1223
 
        virDomainFree(dom);
1224
 
        remoteDispatchConnError(rerr, conn);
1225
 
        return -1;
1226
 
    }
1227
 
    virDomainFree(dom);
1228
 
    return 0;
1229
 
}
1230
 
 
1231
 
static int
1232
 
remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
 
1271
    if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
 
1272
        virReportOOMError();
 
1273
        goto cleanup;
 
1274
    }
 
1275
 
 
1276
    if (virDomainMemoryPeek(dom, offset, size,
 
1277
                            ret->buffer.buffer_val, flags) < 0)
 
1278
        goto cleanup;
 
1279
    if (dom)
 
1280
        virDomainFree(dom);
 
1281
 
 
1282
    rv = 0;
 
1283
 
 
1284
cleanup:
 
1285
    if (rv < 0) {
 
1286
        remoteDispatchError(rerr);
 
1287
        VIR_FREE(ret->buffer.buffer_val);
 
1288
    }
 
1289
    if (dom)
 
1290
        virDomainFree(dom);
 
1291
    return rv;
 
1292
}
 
1293
 
 
1294
static int
 
1295
remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1296
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
1297
                                 virConnectPtr conn,
 
1298
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1299
                                 remote_error *rerr,
 
1300
                                 remote_domain_attach_device_args *args,
 
1301
                                 void *ret ATTRIBUTE_UNUSED)
 
1302
{
 
1303
    virDomainPtr dom = NULL;
 
1304
    int rv = -1;
 
1305
 
 
1306
    if (!conn) {
 
1307
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1308
        goto cleanup;
 
1309
    }
 
1310
 
 
1311
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1312
        goto cleanup;
 
1313
 
 
1314
    if (virDomainAttachDevice(dom, args->xml) < 0)
 
1315
        goto cleanup;
 
1316
 
 
1317
    rv = 0;
 
1318
 
 
1319
cleanup:
 
1320
    if (rv < 0)
 
1321
        remoteDispatchError(rerr);
 
1322
    if (dom)
 
1323
        virDomainFree(dom);
 
1324
    return rv;
 
1325
}
 
1326
 
 
1327
static int
 
1328
remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1329
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
1330
                                      virConnectPtr conn,
 
1331
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1332
                                      remote_error *rerr,
 
1333
                                      remote_domain_attach_device_flags_args *args,
 
1334
                                      void *ret ATTRIBUTE_UNUSED)
 
1335
{
 
1336
    virDomainPtr dom = NULL;
 
1337
    int rv = -1;
 
1338
 
 
1339
    if (!conn) {
 
1340
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1341
        goto cleanup;
 
1342
    }
 
1343
 
 
1344
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1345
        goto cleanup;
 
1346
 
 
1347
    if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) < 0)
 
1348
        goto cleanup;
 
1349
 
 
1350
    rv = 0;
 
1351
 
 
1352
cleanup:
 
1353
    if (rv < 0)
 
1354
        remoteDispatchError(rerr);
 
1355
    if (dom)
 
1356
        virDomainFree(dom);
 
1357
    return rv;
 
1358
}
 
1359
 
 
1360
static int
 
1361
remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1362
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
1363
                                      virConnectPtr conn,
 
1364
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1365
                                      remote_error *rerr,
 
1366
                                      remote_domain_update_device_flags_args *args,
 
1367
                                      void *ret ATTRIBUTE_UNUSED)
 
1368
{
 
1369
    virDomainPtr dom = NULL;
 
1370
    int rv = -1;
 
1371
 
 
1372
    if (!conn) {
 
1373
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1374
        goto cleanup;
 
1375
    }
 
1376
 
 
1377
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1378
        goto cleanup;
 
1379
 
 
1380
    if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0)
 
1381
        goto cleanup;
 
1382
 
 
1383
    rv = 0;
 
1384
 
 
1385
cleanup:
 
1386
    if (rv < 0)
 
1387
        remoteDispatchError(rerr);
 
1388
    if (dom)
 
1389
        virDomainFree(dom);
 
1390
    return rv;
 
1391
}
 
1392
 
 
1393
static int
 
1394
remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1395
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
1396
                           virConnectPtr conn,
 
1397
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1398
                           remote_error *rerr,
 
1399
                           remote_domain_create_args *args,
 
1400
                           void *ret ATTRIBUTE_UNUSED)
 
1401
{
 
1402
    virDomainPtr dom = NULL;
 
1403
    int rv = -1;
 
1404
 
 
1405
    if (!conn) {
 
1406
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1407
        goto cleanup;
 
1408
    }
 
1409
 
 
1410
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1411
        goto cleanup;
 
1412
 
 
1413
    if (virDomainCreate(dom) < 0)
 
1414
        goto cleanup;
 
1415
 
 
1416
    rv = 0;
 
1417
 
 
1418
cleanup:
 
1419
    if (rv < 0)
 
1420
        remoteDispatchError(rerr);
 
1421
    if (dom)
 
1422
        virDomainFree(dom);
 
1423
    return rv;
 
1424
}
 
1425
 
 
1426
static int
 
1427
remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1428
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
 
1429
                                    virConnectPtr conn,
 
1430
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1431
                                    remote_error *rerr,
 
1432
                                    remote_domain_create_with_flags_args *args,
 
1433
                                    remote_domain_create_with_flags_ret *ret)
 
1434
{
 
1435
    int rv = -1;
 
1436
    virDomainPtr dom = NULL;
 
1437
 
 
1438
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1439
        goto cleanup;
 
1440
 
 
1441
    if (virDomainCreateWithFlags(dom, args->flags) < 0)
 
1442
        goto cleanup;
 
1443
 
 
1444
    make_nonnull_domain(&ret->dom, dom);
 
1445
 
 
1446
    rv = 0;
 
1447
 
 
1448
cleanup:
 
1449
    if (rv < 0)
 
1450
        remoteDispatchError(rerr);
 
1451
    if (dom)
 
1452
        virDomainFree(dom);
 
1453
    return rv;
 
1454
}
 
1455
 
 
1456
static int
 
1457
remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1458
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
1459
                              virConnectPtr conn,
 
1460
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1461
                              remote_error *rerr,
 
1462
                              remote_domain_create_xml_args *args,
 
1463
                              remote_domain_create_xml_ret *ret)
 
1464
{
 
1465
    virDomainPtr dom = NULL;
 
1466
    int rv = -1;
 
1467
 
 
1468
    if (!conn) {
 
1469
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1470
        goto cleanup;
 
1471
    }
 
1472
 
 
1473
    if (!(dom = virDomainCreateXML(conn, args->xml_desc, args->flags)))
 
1474
        goto cleanup;
 
1475
 
 
1476
    make_nonnull_domain(&ret->dom, dom);
 
1477
 
 
1478
    rv = 0;
 
1479
 
 
1480
cleanup:
 
1481
    if (rv < 0)
 
1482
        remoteDispatchError(rerr);
 
1483
    if (dom)
 
1484
        virDomainFree(dom);
 
1485
    return rv;
 
1486
}
 
1487
 
 
1488
static int
 
1489
remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1490
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
1491
                              virConnectPtr conn,
 
1492
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1493
                              remote_error *rerr,
 
1494
                              remote_domain_define_xml_args *args,
 
1495
                              remote_domain_define_xml_ret *ret)
 
1496
{
 
1497
    virDomainPtr dom = NULL;
 
1498
    int rv = -1;
 
1499
 
 
1500
    if (!conn) {
 
1501
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1502
        goto cleanup;
 
1503
    }
 
1504
 
 
1505
    if (!(dom = virDomainDefineXML(conn, args->xml)))
 
1506
        goto cleanup;
 
1507
 
 
1508
    make_nonnull_domain(&ret->dom, dom);
 
1509
 
 
1510
    rv = 0;
 
1511
 
 
1512
cleanup:
 
1513
    if (rv < 0)
 
1514
        remoteDispatchError(rerr);
 
1515
    if (dom)
 
1516
        virDomainFree(dom);
 
1517
    return rv;
 
1518
}
 
1519
 
 
1520
static int
 
1521
remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
1233
1522
                            struct qemud_client *client ATTRIBUTE_UNUSED,
1234
1523
                            virConnectPtr conn,
1235
1524
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
1236
1525
                            remote_error *rerr,
1237
 
                            remote_domain_create_args *args,
 
1526
                            remote_domain_destroy_args *args,
1238
1527
                            void *ret ATTRIBUTE_UNUSED)
1239
1528
{
1240
 
    virDomainPtr dom;
1241
 
 
1242
 
    dom = get_nonnull_domain (conn, args->dom);
1243
 
    if (dom == NULL) {
1244
 
        remoteDispatchConnError(rerr, conn);
1245
 
        return -1;
1246
 
    }
1247
 
 
1248
 
    if (virDomainCreate (dom) == -1) {
1249
 
        virDomainFree(dom);
1250
 
        remoteDispatchConnError(rerr, conn);
1251
 
        return -1;
1252
 
    }
1253
 
    virDomainFree(dom);
1254
 
    return 0;
1255
 
}
1256
 
 
1257
 
static int
1258
 
remoteDispatchDomainCreateWithFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
1259
 
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
1260
 
                                     virConnectPtr conn,
1261
 
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
1262
 
                                     remote_error *rerr,
1263
 
                                     remote_domain_create_with_flags_args *args,
1264
 
                                     remote_domain_create_with_flags_ret *ret)
1265
 
{
1266
 
    virDomainPtr dom;
1267
 
 
1268
 
    dom = get_nonnull_domain (conn, args->dom);
1269
 
    if (dom == NULL) {
1270
 
        remoteDispatchConnError(rerr, conn);
1271
 
        return -1;
1272
 
    }
1273
 
 
1274
 
    if (virDomainCreateWithFlags (dom, args->flags) == -1) {
1275
 
        virDomainFree(dom);
1276
 
        remoteDispatchConnError(rerr, conn);
1277
 
        return -1;
1278
 
    }
1279
 
 
1280
 
    make_nonnull_domain (&ret->dom, dom);
1281
 
    virDomainFree(dom);
1282
 
    return 0;
1283
 
}
1284
 
 
1285
 
static int
1286
 
remoteDispatchDomainCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
1287
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
1288
 
                               virConnectPtr conn,
1289
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
1290
 
                               remote_error *rerr,
1291
 
                               remote_domain_create_xml_args *args,
1292
 
                               remote_domain_create_xml_ret *ret)
1293
 
{
1294
 
    virDomainPtr dom;
1295
 
 
1296
 
    dom = virDomainCreateXML (conn, args->xml_desc, args->flags);
1297
 
    if (dom == NULL) {
1298
 
        remoteDispatchConnError(rerr, conn);
1299
 
        return -1;
1300
 
    }
1301
 
 
1302
 
    make_nonnull_domain (&ret->dom, dom);
1303
 
    virDomainFree(dom);
1304
 
 
1305
 
    return 0;
1306
 
}
1307
 
 
1308
 
static int
1309
 
remoteDispatchDomainDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
1310
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
1311
 
                               virConnectPtr conn,
1312
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
1313
 
                               remote_error *rerr,
1314
 
                               remote_domain_define_xml_args *args,
1315
 
                               remote_domain_define_xml_ret *ret)
1316
 
{
1317
 
    virDomainPtr dom;
1318
 
 
1319
 
    dom = virDomainDefineXML (conn, args->xml);
1320
 
    if (dom == NULL) {
1321
 
        remoteDispatchConnError(rerr, conn);
1322
 
        return -1;
1323
 
    }
1324
 
 
1325
 
    make_nonnull_domain (&ret->dom, dom);
1326
 
    virDomainFree(dom);
1327
 
 
1328
 
    return 0;
1329
 
}
1330
 
 
1331
 
static int
1332
 
remoteDispatchDomainDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
1333
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
1334
 
                             virConnectPtr conn,
1335
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
1336
 
                             remote_error *rerr,
1337
 
                             remote_domain_destroy_args *args,
1338
 
                             void *ret ATTRIBUTE_UNUSED)
1339
 
{
1340
 
    virDomainPtr dom;
1341
 
 
1342
 
    dom = get_nonnull_domain (conn, args->dom);
1343
 
    if (dom == NULL) {
1344
 
        remoteDispatchConnError(rerr, conn);
1345
 
        return -1;
1346
 
    }
1347
 
 
1348
 
    if (virDomainDestroy (dom) == -1) {
1349
 
        virDomainFree(dom);
1350
 
        remoteDispatchConnError(rerr, conn);
1351
 
        return -1;
1352
 
    }
1353
 
    virDomainFree(dom);
1354
 
    return 0;
1355
 
}
1356
 
 
1357
 
static int
1358
 
remoteDispatchDomainDetachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
1359
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
1360
 
                                  virConnectPtr conn,
1361
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
1362
 
                                  remote_error *rerr,
1363
 
                                  remote_domain_detach_device_args *args,
1364
 
                                  void *ret ATTRIBUTE_UNUSED)
1365
 
{
1366
 
    virDomainPtr dom;
1367
 
 
1368
 
    dom = get_nonnull_domain (conn, args->dom);
1369
 
    if (dom == NULL) {
1370
 
        remoteDispatchConnError(rerr, conn);
1371
 
        return -1;
1372
 
    }
1373
 
 
1374
 
    if (virDomainDetachDevice (dom, args->xml) == -1) {
1375
 
        virDomainFree(dom);
1376
 
        remoteDispatchConnError(rerr, conn);
1377
 
        return -1;
1378
 
    }
1379
 
 
1380
 
    virDomainFree(dom);
1381
 
    return 0;
1382
 
}
1383
 
 
1384
 
static int
1385
 
remoteDispatchDomainDetachDeviceFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
1386
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
1387
 
                                       virConnectPtr conn,
1388
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
1389
 
                                       remote_error *rerr,
1390
 
                                       remote_domain_detach_device_flags_args *args,
1391
 
                                       void *ret ATTRIBUTE_UNUSED)
1392
 
{
1393
 
    virDomainPtr dom;
1394
 
 
1395
 
    dom = get_nonnull_domain (conn, args->dom);
1396
 
    if (dom == NULL) {
1397
 
        remoteDispatchConnError(rerr, conn);
1398
 
        return -1;
1399
 
    }
1400
 
 
1401
 
    if (virDomainDetachDeviceFlags (dom, args->xml, args->flags) == -1) {
1402
 
        virDomainFree(dom);
1403
 
        remoteDispatchConnError(rerr, conn);
1404
 
        return -1;
1405
 
    }
1406
 
 
1407
 
    virDomainFree(dom);
1408
 
    return 0;
1409
 
}
1410
 
 
1411
 
static int
1412
 
remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
1413
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
1414
 
                             virConnectPtr conn,
1415
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
1416
 
                             remote_error *rerr,
1417
 
                             remote_domain_dump_xml_args *args,
1418
 
                             remote_domain_dump_xml_ret *ret)
1419
 
{
1420
 
    virDomainPtr dom;
1421
 
 
1422
 
    dom = get_nonnull_domain (conn, args->dom);
1423
 
    if (dom == NULL) {
1424
 
        remoteDispatchConnError(rerr, conn);
1425
 
        return -1;
1426
 
    }
1427
 
 
1428
 
    /* remoteDispatchClientRequest will free this. */
1429
 
    ret->xml = virDomainGetXMLDesc (dom, args->flags);
1430
 
    if (!ret->xml) {
1431
 
        virDomainFree(dom);
1432
 
        remoteDispatchConnError(rerr, conn);
1433
 
        return -1;
1434
 
    }
1435
 
    virDomainFree(dom);
1436
 
    return 0;
1437
 
}
1438
 
 
1439
 
static int
1440
 
remoteDispatchDomainXmlFromNative (struct qemud_server *server ATTRIBUTE_UNUSED,
1441
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
1442
 
                                   virConnectPtr conn,
1443
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
1444
 
                                   remote_error *rerr,
1445
 
                                   remote_domain_xml_from_native_args *args,
1446
 
                                   remote_domain_xml_from_native_ret *ret)
1447
 
{
1448
 
    /* remoteDispatchClientRequest will free this. */
1449
 
    ret->domainXml = virConnectDomainXMLFromNative (conn,
1450
 
                                                    args->nativeFormat,
1451
 
                                                    args->nativeConfig,
1452
 
                                                    args->flags);
1453
 
    if (!ret->domainXml) {
1454
 
        remoteDispatchConnError(rerr, conn);
1455
 
        return -1;
1456
 
    }
1457
 
    return 0;
1458
 
}
1459
 
 
1460
 
static int
1461
 
remoteDispatchDomainXmlToNative (struct qemud_server *server ATTRIBUTE_UNUSED,
1462
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
1463
 
                                 virConnectPtr conn,
1464
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
1465
 
                                 remote_error *rerr,
1466
 
                                 remote_domain_xml_to_native_args *args,
1467
 
                                 remote_domain_xml_to_native_ret *ret)
1468
 
{
1469
 
    /* remoteDispatchClientRequest will free this. */
1470
 
    ret->nativeConfig = virConnectDomainXMLToNative (conn,
1471
 
                                                     args->nativeFormat,
1472
 
                                                     args->domainXml,
1473
 
                                                     args->flags);
1474
 
    if (!ret->nativeConfig) {
1475
 
        remoteDispatchConnError(rerr, conn);
1476
 
        return -1;
1477
 
    }
1478
 
    return 0;
1479
 
}
1480
 
 
1481
 
 
1482
 
static int
1483
 
remoteDispatchDomainGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
1484
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
1485
 
                                  virConnectPtr conn,
1486
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
1487
 
                                  remote_error *rerr,
1488
 
                                  remote_domain_get_autostart_args *args,
1489
 
                                  remote_domain_get_autostart_ret *ret)
1490
 
{
1491
 
    virDomainPtr dom;
1492
 
 
1493
 
    dom = get_nonnull_domain (conn, args->dom);
1494
 
    if (dom == NULL) {
1495
 
        remoteDispatchConnError(rerr, conn);
1496
 
        return -1;
1497
 
    }
1498
 
 
1499
 
    if (virDomainGetAutostart (dom, &ret->autostart) == -1) {
1500
 
        virDomainFree(dom);
1501
 
        remoteDispatchConnError(rerr, conn);
1502
 
        return -1;
1503
 
    }
1504
 
    virDomainFree(dom);
1505
 
    return 0;
1506
 
}
1507
 
 
1508
 
static int
1509
 
remoteDispatchDomainGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
1510
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
1511
 
                             virConnectPtr conn,
1512
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
1513
 
                             remote_error *rerr,
1514
 
                             remote_domain_get_info_args *args,
1515
 
                             remote_domain_get_info_ret *ret)
1516
 
{
1517
 
    virDomainPtr dom;
 
1529
    virDomainPtr dom = NULL;
 
1530
    int rv = -1;
 
1531
 
 
1532
    if (!conn) {
 
1533
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1534
        goto cleanup;
 
1535
    }
 
1536
 
 
1537
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1538
        goto cleanup;
 
1539
 
 
1540
    if (virDomainDestroy(dom) < 0)
 
1541
        goto cleanup;
 
1542
 
 
1543
    rv = 0;
 
1544
 
 
1545
cleanup:
 
1546
    if (rv < 0)
 
1547
        remoteDispatchError(rerr);
 
1548
    if (dom)
 
1549
        virDomainFree(dom);
 
1550
    return rv;
 
1551
}
 
1552
 
 
1553
static int
 
1554
remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1555
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
1556
                                 virConnectPtr conn,
 
1557
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1558
                                 remote_error *rerr,
 
1559
                                 remote_domain_detach_device_args *args,
 
1560
                                 void *ret ATTRIBUTE_UNUSED)
 
1561
{
 
1562
    virDomainPtr dom = NULL;
 
1563
    int rv = -1;
 
1564
 
 
1565
    if (!conn) {
 
1566
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1567
        goto cleanup;
 
1568
    }
 
1569
 
 
1570
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1571
        goto cleanup;
 
1572
 
 
1573
    if (virDomainDetachDevice(dom, args->xml) < 0)
 
1574
        goto cleanup;
 
1575
 
 
1576
    rv = 0;
 
1577
 
 
1578
cleanup:
 
1579
    if (rv < 0)
 
1580
        remoteDispatchError(rerr);
 
1581
    if (dom)
 
1582
        virDomainFree(dom);
 
1583
    return rv;
 
1584
}
 
1585
 
 
1586
static int
 
1587
remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1588
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
1589
                                      virConnectPtr conn,
 
1590
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1591
                                      remote_error *rerr,
 
1592
                                      remote_domain_detach_device_flags_args *args,
 
1593
                                      void *ret ATTRIBUTE_UNUSED)
 
1594
{
 
1595
    virDomainPtr dom = NULL;
 
1596
    int rv = -1;
 
1597
 
 
1598
    if (!conn) {
 
1599
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1600
        goto cleanup;
 
1601
    }
 
1602
 
 
1603
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1604
        goto cleanup;
 
1605
 
 
1606
    if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) < 0)
 
1607
        goto cleanup;
 
1608
 
 
1609
    rv = 0;
 
1610
 
 
1611
cleanup:
 
1612
    if (rv < 0)
 
1613
        remoteDispatchError(rerr);
 
1614
    if (dom)
 
1615
        virDomainFree(dom);
 
1616
    return rv;
 
1617
}
 
1618
 
 
1619
static int
 
1620
remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1621
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
1622
                            virConnectPtr conn,
 
1623
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1624
                            remote_error *rerr,
 
1625
                            remote_domain_dump_xml_args *args,
 
1626
                            remote_domain_dump_xml_ret *ret)
 
1627
{
 
1628
    virDomainPtr dom = NULL;
 
1629
    int rv = -1;
 
1630
 
 
1631
    if (!conn) {
 
1632
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1633
        goto cleanup;
 
1634
    }
 
1635
 
 
1636
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1637
        goto cleanup;
 
1638
 
 
1639
    /* remoteDispatchClientRequest will free this. */
 
1640
    if (!(ret->xml = virDomainGetXMLDesc(dom, args->flags)))
 
1641
        goto cleanup;
 
1642
 
 
1643
    rv = 0;
 
1644
 
 
1645
cleanup:
 
1646
    if (rv < 0)
 
1647
        remoteDispatchError(rerr);
 
1648
    if (dom)
 
1649
        virDomainFree(dom);
 
1650
    return rv;
 
1651
}
 
1652
 
 
1653
static int
 
1654
remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1655
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
1656
                                  virConnectPtr conn,
 
1657
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1658
                                  remote_error *rerr,
 
1659
                                  remote_domain_xml_from_native_args *args,
 
1660
                                  remote_domain_xml_from_native_ret *ret)
 
1661
{
 
1662
    int rv = -1;
 
1663
 
 
1664
    if (!conn) {
 
1665
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1666
        goto cleanup;
 
1667
    }
 
1668
 
 
1669
    /* remoteDispatchClientRequest will free this. */
 
1670
    if (!(ret->domainXml = virConnectDomainXMLFromNative(conn,
 
1671
                                                         args->nativeFormat,
 
1672
                                                         args->nativeConfig,
 
1673
                                                         args->flags)))
 
1674
        goto cleanup;
 
1675
 
 
1676
    rv = 0;
 
1677
 
 
1678
cleanup:
 
1679
    if (rv < 0)
 
1680
        remoteDispatchError(rerr);
 
1681
    return rv;
 
1682
}
 
1683
 
 
1684
static int
 
1685
remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1686
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
1687
                                virConnectPtr conn,
 
1688
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1689
                                remote_error *rerr,
 
1690
                                remote_domain_xml_to_native_args *args,
 
1691
                                remote_domain_xml_to_native_ret *ret)
 
1692
{
 
1693
    int rv = -1;
 
1694
 
 
1695
    if (!conn) {
 
1696
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1697
        goto cleanup;
 
1698
    }
 
1699
 
 
1700
    /* remoteDispatchClientRequest will free this. */
 
1701
    if (!(ret->nativeConfig = virConnectDomainXMLToNative(conn,
 
1702
                                                          args->nativeFormat,
 
1703
                                                          args->domainXml,
 
1704
                                                          args->flags)))
 
1705
        goto cleanup;
 
1706
 
 
1707
    rv = 0;
 
1708
 
 
1709
cleanup:
 
1710
    if (rv < 0)
 
1711
        remoteDispatchError(rerr);
 
1712
    return rv;
 
1713
}
 
1714
 
 
1715
 
 
1716
static int
 
1717
remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1718
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
1719
                                 virConnectPtr conn,
 
1720
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1721
                                 remote_error *rerr,
 
1722
                                 remote_domain_get_autostart_args *args,
 
1723
                                 remote_domain_get_autostart_ret *ret)
 
1724
{
 
1725
    virDomainPtr dom = NULL;
 
1726
    int rv = -1;
 
1727
 
 
1728
    if (!conn) {
 
1729
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1730
        goto cleanup;
 
1731
    }
 
1732
 
 
1733
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1734
        goto cleanup;
 
1735
 
 
1736
    if (virDomainGetAutostart(dom, &ret->autostart) < 0)
 
1737
        goto cleanup;
 
1738
 
 
1739
    rv = 0;
 
1740
 
 
1741
cleanup:
 
1742
    if (rv < 0)
 
1743
        remoteDispatchError(rerr);
 
1744
    if (dom)
 
1745
        virDomainFree(dom);
 
1746
    return rv;
 
1747
}
 
1748
 
 
1749
static int
 
1750
remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1751
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
1752
                            virConnectPtr conn,
 
1753
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1754
                            remote_error *rerr,
 
1755
                            remote_domain_get_info_args *args,
 
1756
                            remote_domain_get_info_ret *ret)
 
1757
{
 
1758
    virDomainPtr dom = NULL;
1518
1759
    virDomainInfo info;
1519
 
 
1520
 
    dom = get_nonnull_domain (conn, args->dom);
1521
 
    if (dom == NULL) {
1522
 
        remoteDispatchConnError(rerr, conn);
1523
 
        return -1;
1524
 
    }
1525
 
 
1526
 
    if (virDomainGetInfo (dom, &info) == -1) {
1527
 
        virDomainFree(dom);
1528
 
        remoteDispatchConnError(rerr, conn);
1529
 
        return -1;
1530
 
    }
 
1760
    int rv = -1;
 
1761
 
 
1762
    if (!conn) {
 
1763
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1764
        goto cleanup;
 
1765
    }
 
1766
 
 
1767
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1768
        goto cleanup;
 
1769
 
 
1770
    if (virDomainGetInfo(dom, &info) < 0)
 
1771
        goto cleanup;
1531
1772
 
1532
1773
    ret->state = info.state;
1533
1774
    ret->max_mem = info.maxMem;
1535
1776
    ret->nr_virt_cpu = info.nrVirtCpu;
1536
1777
    ret->cpu_time = info.cpuTime;
1537
1778
 
1538
 
    virDomainFree(dom);
1539
 
 
1540
 
    return 0;
1541
 
}
1542
 
 
1543
 
static int
1544
 
remoteDispatchDomainGetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
1545
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
1546
 
                                  virConnectPtr conn,
1547
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
1548
 
                                  remote_error *rerr,
1549
 
                                  remote_domain_get_max_memory_args *args,
1550
 
                                  remote_domain_get_max_memory_ret *ret)
1551
 
{
1552
 
    virDomainPtr dom;
1553
 
 
1554
 
    dom = get_nonnull_domain (conn, args->dom);
1555
 
    if (dom == NULL) {
1556
 
        remoteDispatchConnError(rerr, conn);
1557
 
        return -1;
1558
 
    }
1559
 
 
1560
 
    ret->memory = virDomainGetMaxMemory (dom);
1561
 
    if (ret->memory == 0) {
 
1779
    rv = 0;
 
1780
 
 
1781
cleanup:
 
1782
    if (rv < 0)
 
1783
        remoteDispatchError(rerr);
 
1784
    if (dom)
1562
1785
        virDomainFree(dom);
1563
 
        remoteDispatchConnError(rerr, conn);
1564
 
        return -1;
1565
 
    }
1566
 
    virDomainFree(dom);
1567
 
    return 0;
 
1786
    return rv;
1568
1787
}
1569
1788
 
1570
1789
static int
1571
 
remoteDispatchDomainGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
 
1790
remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
1572
1791
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
1573
1792
                                 virConnectPtr conn,
1574
1793
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
1575
1794
                                 remote_error *rerr,
1576
 
                                 remote_domain_get_max_vcpus_args *args,
1577
 
                                 remote_domain_get_max_vcpus_ret *ret)
1578
 
{
1579
 
    virDomainPtr dom;
1580
 
 
1581
 
    dom = get_nonnull_domain (conn, args->dom);
1582
 
    if (dom == NULL) {
1583
 
        remoteDispatchConnError(rerr, conn);
1584
 
        return -1;
1585
 
    }
1586
 
 
1587
 
    ret->num = virDomainGetMaxVcpus (dom);
1588
 
    if (ret->num == -1) {
1589
 
        virDomainFree(dom);
1590
 
        remoteDispatchConnError(rerr, conn);
1591
 
        return -1;
1592
 
    }
1593
 
    virDomainFree(dom);
1594
 
    return 0;
 
1795
                                 remote_domain_get_max_memory_args *args,
 
1796
                                 remote_domain_get_max_memory_ret *ret)
 
1797
{
 
1798
    virDomainPtr dom = NULL;
 
1799
    int rv = -1;
 
1800
 
 
1801
    if (!conn) {
 
1802
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1803
        goto cleanup;
 
1804
    }
 
1805
 
 
1806
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1807
        goto cleanup;
 
1808
 
 
1809
    if ((ret->memory = virDomainGetMaxMemory(dom)) == 0)
 
1810
        goto cleanup;
 
1811
 
 
1812
    rv = 0;
 
1813
 
 
1814
cleanup:
 
1815
    if (rv < 0)
 
1816
        remoteDispatchError(rerr);
 
1817
    if (dom)
 
1818
        virDomainFree(dom);
 
1819
    return rv;
 
1820
}
 
1821
 
 
1822
static int
 
1823
remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1824
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
1825
                                virConnectPtr conn,
 
1826
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1827
                                remote_error *rerr,
 
1828
                                remote_domain_get_max_vcpus_args *args,
 
1829
                                remote_domain_get_max_vcpus_ret *ret)
 
1830
{
 
1831
    virDomainPtr dom = NULL;
 
1832
    int rv = -1;
 
1833
 
 
1834
    if (!conn) {
 
1835
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1836
        goto cleanup;
 
1837
    }
 
1838
 
 
1839
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1840
        goto cleanup;
 
1841
 
 
1842
    if ((ret->num = virDomainGetMaxVcpus(dom)) < 0)
 
1843
        goto cleanup;
 
1844
 
 
1845
    rv = 0;
 
1846
 
 
1847
cleanup:
 
1848
    if (rv < 0)
 
1849
        remoteDispatchError(rerr);
 
1850
    if (dom)
 
1851
        virDomainFree(dom);
 
1852
    return rv;
1595
1853
}
1596
1854
 
1597
1855
static int
1603
1861
                                     remote_domain_get_security_label_args *args,
1604
1862
                                     remote_domain_get_security_label_ret *ret)
1605
1863
{
1606
 
    virDomainPtr dom;
1607
 
    virSecurityLabel seclabel;
1608
 
 
1609
 
    dom = get_nonnull_domain(conn, args->dom);
1610
 
    if (dom == NULL) {
1611
 
        remoteDispatchConnError(rerr, conn);
1612
 
        return -1;
1613
 
    }
1614
 
 
1615
 
    memset(&seclabel, 0, sizeof seclabel);
1616
 
    if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
1617
 
        virDomainFree(dom);
1618
 
        remoteDispatchConnError(rerr, conn);
1619
 
        return -1;
1620
 
    }
1621
 
 
1622
 
    ret->label.label_len = strlen(seclabel.label) + 1;
 
1864
    virDomainPtr dom = NULL;
 
1865
    virSecurityLabelPtr seclabel = NULL;
 
1866
    int rv = -1;
 
1867
 
 
1868
    if (!conn) {
 
1869
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1870
        goto cleanup;
 
1871
    }
 
1872
 
 
1873
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1874
        goto cleanup;
 
1875
 
 
1876
    if (VIR_ALLOC(seclabel) < 0) {
 
1877
        virReportOOMError();
 
1878
        goto cleanup;
 
1879
    }
 
1880
 
 
1881
    if (virDomainGetSecurityLabel(dom, seclabel) < 0)
 
1882
        goto cleanup;
 
1883
 
 
1884
    ret->label.label_len = strlen(seclabel->label) + 1;
1623
1885
    if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
 
1886
        virReportOOMError();
 
1887
        goto cleanup;
 
1888
    }
 
1889
    strcpy(ret->label.label_val, seclabel->label);
 
1890
    ret->enforcing = seclabel->enforcing;
 
1891
 
 
1892
    rv = 0;
 
1893
 
 
1894
cleanup:
 
1895
    if (rv < 0)
 
1896
        remoteDispatchError(rerr);
 
1897
    if (dom)
1624
1898
        virDomainFree(dom);
1625
 
        remoteDispatchOOMError(rerr);
1626
 
        return -1;
1627
 
    }
1628
 
    strcpy(ret->label.label_val, seclabel.label);
1629
 
    ret->enforcing = seclabel.enforcing;
1630
 
    virDomainFree(dom);
1631
 
 
1632
 
    return 0;
 
1899
    VIR_FREE(seclabel);
 
1900
    return rv;
1633
1901
}
1634
1902
 
1635
1903
static int
1642
1910
                                   remote_node_get_security_model_ret *ret)
1643
1911
{
1644
1912
    virSecurityModel secmodel;
 
1913
    int rv = -1;
 
1914
 
 
1915
    if (!conn) {
 
1916
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1917
        goto cleanup;
 
1918
    }
1645
1919
 
1646
1920
    memset(&secmodel, 0, sizeof secmodel);
1647
 
    if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
1648
 
        remoteDispatchConnError(rerr, conn);
1649
 
        return -1;
1650
 
    }
 
1921
    if (virNodeGetSecurityModel(conn, &secmodel) < 0)
 
1922
        goto cleanup;
1651
1923
 
1652
1924
    ret->model.model_len = strlen(secmodel.model) + 1;
1653
1925
    if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
1654
 
        remoteDispatchOOMError(rerr);
1655
 
        return -1;
 
1926
        virReportOOMError();
 
1927
        goto cleanup;
1656
1928
    }
1657
1929
    strcpy(ret->model.model_val, secmodel.model);
1658
1930
 
1659
1931
    ret->doi.doi_len = strlen(secmodel.doi) + 1;
1660
1932
    if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
1661
 
        remoteDispatchOOMError(rerr);
1662
 
        return -1;
 
1933
        virReportOOMError();
 
1934
        goto cleanup;
1663
1935
    }
1664
1936
    strcpy(ret->doi.doi_val, secmodel.doi);
1665
1937
 
1666
 
    return 0;
 
1938
    rv = 0;
 
1939
 
 
1940
cleanup:
 
1941
    if (rv < 0)
 
1942
        remoteDispatchError(rerr);
 
1943
    return rv;
1667
1944
}
1668
1945
 
1669
1946
static int
1670
 
remoteDispatchDomainGetOsType (struct qemud_server *server ATTRIBUTE_UNUSED,
1671
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
1672
 
                               virConnectPtr conn,
1673
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
1674
 
                               remote_error *rerr,
1675
 
                               remote_domain_get_os_type_args *args,
1676
 
                               remote_domain_get_os_type_ret *ret)
 
1947
remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1948
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
1949
                              virConnectPtr conn,
 
1950
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1951
                              remote_error *rerr,
 
1952
                              remote_domain_get_os_type_args *args,
 
1953
                              remote_domain_get_os_type_ret *ret)
1677
1954
{
1678
 
    virDomainPtr dom;
 
1955
    virDomainPtr dom = NULL;
 
1956
    int rv = -1;
1679
1957
 
1680
 
    dom = get_nonnull_domain (conn, args->dom);
1681
 
    if (dom == NULL) {
1682
 
        remoteDispatchConnError(rerr, conn);
1683
 
        return -1;
 
1958
    if (!conn) {
 
1959
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1960
        goto cleanup;
1684
1961
    }
1685
1962
 
 
1963
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
1964
        goto cleanup;
 
1965
 
1686
1966
    /* remoteDispatchClientRequest will free this */
1687
 
    ret->type = virDomainGetOSType (dom);
1688
 
    if (ret->type == NULL) {
 
1967
    if (!(ret->type = virDomainGetOSType(dom)))
 
1968
        goto cleanup;
 
1969
 
 
1970
    rv = 0;
 
1971
 
 
1972
cleanup:
 
1973
    if (rv < 0)
 
1974
        remoteDispatchError(rerr);
 
1975
    if (dom)
1689
1976
        virDomainFree(dom);
1690
 
        remoteDispatchConnError(rerr, conn);
1691
 
        return -1;
1692
 
    }
1693
 
    virDomainFree(dom);
1694
 
    return 0;
 
1977
    return rv;
1695
1978
}
1696
1979
 
1697
1980
static int
1698
 
remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
1699
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
1700
 
                              virConnectPtr conn,
1701
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
1702
 
                              remote_error *rerr,
1703
 
                              remote_domain_get_vcpus_args *args,
1704
 
                              remote_domain_get_vcpus_ret *ret)
 
1981
remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
 
1982
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
1983
                             virConnectPtr conn,
 
1984
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
1985
                             remote_error *rerr,
 
1986
                             remote_domain_get_vcpus_args *args,
 
1987
                             remote_domain_get_vcpus_ret *ret)
1705
1988
{
1706
1989
    virDomainPtr dom = NULL;
1707
1990
    virVcpuInfoPtr info = NULL;
1708
1991
    unsigned char *cpumaps = NULL;
1709
1992
    int info_len, i;
 
1993
    int rv = -1;
1710
1994
 
1711
 
    dom = get_nonnull_domain (conn, args->dom);
1712
 
    if (dom == NULL) {
1713
 
        remoteDispatchConnError(rerr, conn);
1714
 
        return -1;
 
1995
    if (!conn) {
 
1996
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
1997
        goto cleanup;
1715
1998
    }
1716
1999
 
 
2000
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2001
        goto cleanup;
 
2002
 
1717
2003
    if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
1718
 
        virDomainFree(dom);
1719
 
        remoteDispatchFormatError (rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
1720
 
        return -1;
 
2004
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
 
2005
        goto cleanup;
1721
2006
    }
1722
2007
 
1723
2008
    if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
1724
 
        virDomainFree(dom);
1725
 
        remoteDispatchFormatError (rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
1726
 
        return -1;
 
2009
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
 
2010
        goto cleanup;
1727
2011
    }
1728
2012
 
1729
2013
    /* Allocate buffers to take the results. */
1730
2014
    if (VIR_ALLOC_N(info, args->maxinfo) < 0)
1731
 
        goto oom;
 
2015
        goto no_memory;
1732
2016
    if (args->maplen > 0 &&
1733
2017
        VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
1734
 
        goto oom;
 
2018
        goto no_memory;
1735
2019
 
1736
 
    info_len = virDomainGetVcpus (dom,
1737
 
                                  info, args->maxinfo,
1738
 
                                  cpumaps, args->maplen);
1739
 
    if (info_len == -1) {
1740
 
        VIR_FREE(info);
1741
 
        VIR_FREE(cpumaps);
1742
 
        virDomainFree(dom);
1743
 
        remoteDispatchConnError(rerr, conn);
1744
 
        return -1;
1745
 
    }
 
2020
    if ((info_len = virDomainGetVcpus(dom,
 
2021
                                      info, args->maxinfo,
 
2022
                                      cpumaps, args->maplen)) < 0)
 
2023
        goto cleanup;
1746
2024
 
1747
2025
    /* Allocate the return buffer for info. */
1748
2026
    ret->info.info_len = info_len;
1749
2027
    if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
1750
 
        goto oom;
 
2028
        goto no_memory;
1751
2029
 
1752
2030
    for (i = 0; i < info_len; ++i) {
1753
2031
        ret->info.info_val[i].number = info[i].number;
1762
2040
     */
1763
2041
    ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
1764
2042
    ret->cpumaps.cpumaps_val = (char *) cpumaps;
1765
 
 
1766
 
    VIR_FREE(info);
1767
 
    virDomainFree(dom);
1768
 
    return 0;
1769
 
 
1770
 
oom:
1771
 
    VIR_FREE(info);
 
2043
    cpumaps = NULL;
 
2044
 
 
2045
    rv = 0;
 
2046
 
 
2047
cleanup:
 
2048
    if (rv < 0) {
 
2049
        remoteDispatchError(rerr);
 
2050
        VIR_FREE(ret->info.info_val);
 
2051
    }
1772
2052
    VIR_FREE(cpumaps);
1773
 
    virDomainFree(dom);
1774
 
    remoteDispatchOOMError(rerr);
1775
 
    return -1;
1776
 
}
1777
 
 
1778
 
static int
1779
 
remoteDispatchDomainGetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
 
2053
    VIR_FREE(info);
 
2054
    if (dom)
 
2055
        virDomainFree(dom);
 
2056
    return rv;
 
2057
 
 
2058
no_memory:
 
2059
    virReportOOMError();
 
2060
    goto cleanup;
 
2061
}
 
2062
 
 
2063
static int
 
2064
remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2065
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
2066
                                  virConnectPtr conn,
 
2067
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2068
                                  remote_error *rerr,
 
2069
                                  remote_domain_get_vcpus_flags_args *args,
 
2070
                                  remote_domain_get_vcpus_flags_ret *ret)
 
2071
{
 
2072
    virDomainPtr dom = NULL;
 
2073
    int rv = -1;
 
2074
 
 
2075
    if (!conn) {
 
2076
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2077
        goto cleanup;
 
2078
    }
 
2079
 
 
2080
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2081
        goto cleanup;
 
2082
 
 
2083
    if ((ret->num = virDomainGetVcpusFlags(dom, args->flags)) < 0)
 
2084
        goto cleanup;
 
2085
 
 
2086
    rv = 0;
 
2087
 
 
2088
cleanup:
 
2089
    if (rv < 0)
 
2090
        remoteDispatchError(rerr);
 
2091
    if (dom)
 
2092
        virDomainFree(dom);
 
2093
    return rv;
 
2094
}
 
2095
 
 
2096
static int
 
2097
remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
1780
2098
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
1781
2099
                                   virConnectPtr conn,
1782
2100
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
1783
2101
                                   remote_error *rerr,
1784
 
                                   remote_domain_get_vcpus_flags_args *args,
1785
 
                                   remote_domain_get_vcpus_flags_ret *ret)
1786
 
{
1787
 
    virDomainPtr dom;
1788
 
 
1789
 
    dom = get_nonnull_domain (conn, args->dom);
1790
 
    if (dom == NULL) {
1791
 
        remoteDispatchConnError(rerr, conn);
1792
 
        return -1;
1793
 
    }
1794
 
 
1795
 
    ret->num = virDomainGetVcpusFlags (dom, args->flags);
1796
 
    if (ret->num == -1) {
1797
 
        virDomainFree(dom);
1798
 
        remoteDispatchConnError(rerr, conn);
1799
 
        return -1;
1800
 
    }
1801
 
    virDomainFree(dom);
1802
 
    return 0;
1803
 
}
1804
 
 
1805
 
static int
1806
 
remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED,
1807
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
1808
 
                                    virConnectPtr conn,
1809
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
1810
 
                                    remote_error *rerr,
1811
 
                                    remote_domain_migrate_prepare_args *args,
1812
 
                                    remote_domain_migrate_prepare_ret *ret)
1813
 
{
1814
 
    int r;
 
2102
                                   remote_domain_migrate_prepare_args *args,
 
2103
                                   remote_domain_migrate_prepare_ret *ret)
 
2104
{
1815
2105
    char *cookie = NULL;
1816
2106
    int cookielen = 0;
1817
2107
    char *uri_in;
1818
2108
    char **uri_out;
1819
2109
    char *dname;
 
2110
    int rv = -1;
 
2111
 
 
2112
    if (!conn) {
 
2113
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2114
        goto cleanup;
 
2115
    }
1820
2116
 
1821
2117
    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
1822
2118
    dname = args->dname == NULL ? NULL : *args->dname;
1823
2119
 
1824
2120
    /* Wacky world of XDR ... */
1825
2121
    if (VIR_ALLOC(uri_out) < 0) {
1826
 
        remoteDispatchOOMError(rerr);
1827
 
        return -1;
 
2122
        virReportOOMError();
 
2123
        goto cleanup;
1828
2124
    }
1829
2125
 
1830
 
    r = virDomainMigratePrepare (conn, &cookie, &cookielen,
1831
 
                                 uri_in, uri_out,
1832
 
                                 args->flags, dname, args->resource);
1833
 
    if (r == -1) {
1834
 
        VIR_FREE(uri_out);
1835
 
        remoteDispatchConnError(rerr, conn);
1836
 
        return -1;
1837
 
    }
 
2126
    if (virDomainMigratePrepare(conn, &cookie, &cookielen,
 
2127
                                uri_in, uri_out,
 
2128
                                args->flags, dname, args->resource) < 0)
 
2129
        goto cleanup;
1838
2130
 
1839
2131
    /* remoteDispatchClientRequest will free cookie, uri_out and
1840
2132
     * the string if there is one.
1843
2135
    ret->cookie.cookie_val = cookie;
1844
2136
    if (*uri_out == NULL) {
1845
2137
        ret->uri_out = NULL;
1846
 
        VIR_FREE(uri_out);
1847
2138
    } else {
1848
2139
        ret->uri_out = uri_out;
1849
 
    }
1850
 
 
1851
 
    return 0;
1852
 
}
1853
 
 
1854
 
static int
1855
 
remoteDispatchDomainMigratePerform (struct qemud_server *server ATTRIBUTE_UNUSED,
 
2140
        uri_out = NULL;
 
2141
    }
 
2142
 
 
2143
    rv = 0;
 
2144
 
 
2145
cleanup:
 
2146
    if (rv < 0)
 
2147
        remoteDispatchError(rerr);
 
2148
    VIR_FREE(uri_out);
 
2149
    return rv;
 
2150
}
 
2151
 
 
2152
static int
 
2153
remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2154
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
2155
                                   virConnectPtr conn,
 
2156
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2157
                                   remote_error *rerr,
 
2158
                                   remote_domain_migrate_perform_args *args,
 
2159
                                   void *ret ATTRIBUTE_UNUSED)
 
2160
{
 
2161
    virDomainPtr dom = NULL;
 
2162
    char *dname;
 
2163
    int rv = -1;
 
2164
 
 
2165
    if (!conn) {
 
2166
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2167
        goto cleanup;
 
2168
    }
 
2169
 
 
2170
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2171
        goto cleanup;
 
2172
 
 
2173
    dname = args->dname == NULL ? NULL : *args->dname;
 
2174
 
 
2175
    if (virDomainMigratePerform(dom,
 
2176
                                args->cookie.cookie_val,
 
2177
                                args->cookie.cookie_len,
 
2178
                                args->uri,
 
2179
                                args->flags, dname, args->resource) < 0)
 
2180
        goto cleanup;
 
2181
 
 
2182
    rv = 0;
 
2183
 
 
2184
cleanup:
 
2185
    if (rv < 0)
 
2186
        remoteDispatchError(rerr);
 
2187
    if (dom)
 
2188
        virDomainFree(dom);
 
2189
    return rv;
 
2190
}
 
2191
 
 
2192
static int
 
2193
remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2194
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
2195
                                  virConnectPtr conn,
 
2196
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2197
                                  remote_error *rerr,
 
2198
                                  remote_domain_migrate_finish_args *args,
 
2199
                                  remote_domain_migrate_finish_ret *ret)
 
2200
{
 
2201
    virDomainPtr dom = NULL;
 
2202
    int rv = -1;
 
2203
 
 
2204
    if (!conn) {
 
2205
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2206
        goto cleanup;
 
2207
    }
 
2208
 
 
2209
    if (!(dom = virDomainMigrateFinish(conn, args->dname,
 
2210
                                       args->cookie.cookie_val,
 
2211
                                       args->cookie.cookie_len,
 
2212
                                       args->uri,
 
2213
                                       args->flags)))
 
2214
        goto cleanup;
 
2215
 
 
2216
    make_nonnull_domain(&ret->ddom, dom);
 
2217
    rv = 0;
 
2218
 
 
2219
cleanup:
 
2220
    if (rv < 0)
 
2221
        remoteDispatchError(rerr);
 
2222
    if (dom)
 
2223
        virDomainFree(dom);
 
2224
    return rv;
 
2225
}
 
2226
 
 
2227
static int
 
2228
remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED,
1856
2229
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
1857
2230
                                    virConnectPtr conn,
1858
2231
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
1859
2232
                                    remote_error *rerr,
1860
 
                                    remote_domain_migrate_perform_args *args,
1861
 
                                    void *ret ATTRIBUTE_UNUSED)
1862
 
{
1863
 
    int r;
1864
 
    virDomainPtr dom;
1865
 
    char *dname;
1866
 
 
1867
 
    dom = get_nonnull_domain (conn, args->dom);
1868
 
    if (dom == NULL) {
1869
 
        remoteDispatchConnError(rerr, conn);
1870
 
        return -1;
1871
 
    }
1872
 
 
1873
 
    dname = args->dname == NULL ? NULL : *args->dname;
1874
 
 
1875
 
    r = virDomainMigratePerform (dom,
1876
 
                                 args->cookie.cookie_val,
1877
 
                                 args->cookie.cookie_len,
1878
 
                                 args->uri,
1879
 
                                 args->flags, dname, args->resource);
1880
 
    virDomainFree (dom);
1881
 
    if (r == -1) {
1882
 
        remoteDispatchConnError(rerr, conn);
1883
 
        return -1;
1884
 
    }
1885
 
 
1886
 
    return 0;
1887
 
}
1888
 
 
1889
 
static int
1890
 
remoteDispatchDomainMigrateFinish (struct qemud_server *server ATTRIBUTE_UNUSED,
1891
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
1892
 
                                   virConnectPtr conn,
1893
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
1894
 
                                   remote_error *rerr,
1895
 
                                   remote_domain_migrate_finish_args *args,
1896
 
                                   remote_domain_migrate_finish_ret *ret)
1897
 
{
1898
 
    virDomainPtr ddom;
1899
 
    CHECK_CONN (client);
1900
 
 
1901
 
    ddom = virDomainMigrateFinish (conn, args->dname,
1902
 
                                   args->cookie.cookie_val,
1903
 
                                   args->cookie.cookie_len,
1904
 
                                   args->uri,
1905
 
                                   args->flags);
1906
 
    if (ddom == NULL) {
1907
 
        remoteDispatchConnError(rerr, conn);
1908
 
        return -1;
1909
 
    }
1910
 
 
1911
 
    make_nonnull_domain (&ret->ddom, ddom);
1912
 
    virDomainFree (ddom);
1913
 
    return 0;
1914
 
}
1915
 
 
1916
 
static int
1917
 
remoteDispatchDomainMigratePrepare2 (struct qemud_server *server ATTRIBUTE_UNUSED,
1918
 
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
1919
 
                                     virConnectPtr conn,
1920
 
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
1921
 
                                     remote_error *rerr,
1922
 
                                     remote_domain_migrate_prepare2_args *args,
1923
 
                                     remote_domain_migrate_prepare2_ret *ret)
1924
 
{
1925
 
    int r;
 
2233
                                    remote_domain_migrate_prepare2_args *args,
 
2234
                                    remote_domain_migrate_prepare2_ret *ret)
 
2235
{
1926
2236
    char *cookie = NULL;
1927
2237
    int cookielen = 0;
1928
2238
    char *uri_in;
1929
2239
    char **uri_out;
1930
2240
    char *dname;
1931
 
    CHECK_CONN (client);
 
2241
    int rv = -1;
 
2242
 
 
2243
    if (!conn) {
 
2244
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2245
        goto cleanup;
 
2246
    }
1932
2247
 
1933
2248
    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
1934
2249
    dname = args->dname == NULL ? NULL : *args->dname;
1935
2250
 
1936
2251
    /* Wacky world of XDR ... */
1937
2252
    if (VIR_ALLOC(uri_out) < 0) {
1938
 
        remoteDispatchOOMError(rerr);
1939
 
        return -1;
 
2253
        virReportOOMError();
 
2254
        goto cleanup;
1940
2255
    }
1941
2256
 
1942
 
    r = virDomainMigratePrepare2 (conn, &cookie, &cookielen,
1943
 
                                  uri_in, uri_out,
1944
 
                                  args->flags, dname, args->resource,
1945
 
                                  args->dom_xml);
1946
 
    if (r == -1) {
1947
 
        remoteDispatchConnError(rerr, conn);
1948
 
        return -1;
1949
 
    }
 
2257
    if (virDomainMigratePrepare2(conn, &cookie, &cookielen,
 
2258
                                 uri_in, uri_out,
 
2259
                                 args->flags, dname, args->resource,
 
2260
                                 args->dom_xml) < 0)
 
2261
        goto cleanup;
1950
2262
 
1951
2263
    /* remoteDispatchClientRequest will free cookie, uri_out and
1952
2264
     * the string if there is one.
1955
2267
    ret->cookie.cookie_val = cookie;
1956
2268
    ret->uri_out = *uri_out == NULL ? NULL : uri_out;
1957
2269
 
1958
 
    return 0;
 
2270
    rv = 0;
 
2271
 
 
2272
cleanup:
 
2273
    if (rv < 0)
 
2274
        remoteDispatchError(rerr);
 
2275
    return rv;
1959
2276
}
1960
2277
 
1961
2278
static int
1962
 
remoteDispatchDomainMigrateFinish2 (struct qemud_server *server ATTRIBUTE_UNUSED,
1963
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
1964
 
                                    virConnectPtr conn,
1965
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
1966
 
                                    remote_error *rerr,
1967
 
                                    remote_domain_migrate_finish2_args *args,
1968
 
                                    remote_domain_migrate_finish2_ret *ret)
 
2279
remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2280
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
2281
                                   virConnectPtr conn,
 
2282
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2283
                                   remote_error *rerr,
 
2284
                                   remote_domain_migrate_finish2_args *args,
 
2285
                                   remote_domain_migrate_finish2_ret *ret)
1969
2286
{
1970
 
    virDomainPtr ddom;
1971
 
    CHECK_CONN (client);
 
2287
    virDomainPtr dom = NULL;
 
2288
    int rv = -1;
1972
2289
 
1973
 
    ddom = virDomainMigrateFinish2 (conn, args->dname,
1974
 
                                    args->cookie.cookie_val,
1975
 
                                    args->cookie.cookie_len,
1976
 
                                    args->uri,
1977
 
                                    args->flags,
1978
 
                                    args->retcode);
1979
 
    if (ddom == NULL) {
1980
 
        remoteDispatchConnError(rerr, conn);
1981
 
        return -1;
 
2290
    if (!conn) {
 
2291
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2292
        goto cleanup;
1982
2293
    }
1983
2294
 
1984
 
    make_nonnull_domain (&ret->ddom, ddom);
1985
 
    virDomainFree (ddom);
1986
 
 
1987
 
    return 0;
 
2295
    if (!(dom = virDomainMigrateFinish2(conn, args->dname,
 
2296
                                        args->cookie.cookie_val,
 
2297
                                        args->cookie.cookie_len,
 
2298
                                        args->uri,
 
2299
                                        args->flags,
 
2300
                                        args->retcode)))
 
2301
        goto cleanup;
 
2302
 
 
2303
    make_nonnull_domain(&ret->ddom, dom);
 
2304
 
 
2305
    rv = 0;
 
2306
 
 
2307
cleanup:
 
2308
    if (rv < 0)
 
2309
        remoteDispatchError(rerr);
 
2310
    if (dom)
 
2311
        virDomainFree(dom);
 
2312
    return rv;
1988
2313
}
1989
2314
 
1990
2315
static int
1996
2321
                                         remote_domain_migrate_prepare_tunnel_args *args,
1997
2322
                                         void *ret ATTRIBUTE_UNUSED)
1998
2323
{
1999
 
    int r;
2000
2324
    char *dname;
2001
 
    struct qemud_client_stream *stream;
2002
 
    CHECK_CONN (client);
 
2325
    struct qemud_client_stream *stream = NULL;
 
2326
    int rv = -1;
 
2327
 
 
2328
    if (!conn) {
 
2329
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2330
        goto cleanup;
 
2331
    }
2003
2332
 
2004
2333
    dname = args->dname == NULL ? NULL : *args->dname;
2005
2334
 
2006
 
    stream = remoteCreateClientStream(conn, hdr);
2007
 
    if (!stream) {
2008
 
        remoteDispatchOOMError(rerr);
2009
 
        return -1;
 
2335
    if (!(stream = remoteCreateClientStream(conn, hdr))) {
 
2336
        virReportOOMError();
 
2337
        goto cleanup;
2010
2338
    }
2011
2339
 
2012
 
    r = virDomainMigratePrepareTunnel(conn, stream->st,
 
2340
    if (virDomainMigratePrepareTunnel(conn, stream->st,
2013
2341
                                      args->flags, dname, args->resource,
2014
 
                                      args->dom_xml);
2015
 
    if (r == -1) {
2016
 
        remoteFreeClientStream(client, stream);
2017
 
        remoteDispatchConnError(rerr, conn);
2018
 
        return -1;
2019
 
    }
2020
 
 
2021
 
    if (remoteAddClientStream(client, stream, 0) < 0) {
2022
 
        remoteDispatchConnError(rerr, conn);
2023
 
        virStreamAbort(stream->st);
2024
 
        remoteFreeClientStream(client, stream);
2025
 
        return -1;
2026
 
    }
2027
 
 
2028
 
    return 0;
 
2342
                                      args->dom_xml) < 0)
 
2343
        goto cleanup;
 
2344
 
 
2345
    if (remoteAddClientStream(client, stream, 0) < 0)
 
2346
        goto cleanup;
 
2347
 
 
2348
    rv = 0;
 
2349
 
 
2350
cleanup:
 
2351
    if (rv < 0) {
 
2352
        remoteDispatchError(rerr);
 
2353
        if (stream) {
 
2354
            virStreamAbort(stream->st);
 
2355
            remoteFreeClientStream(client, stream);
 
2356
        }
 
2357
    }
 
2358
    return rv;
2029
2359
}
2030
2360
 
2031
2361
static int
2032
 
remoteDispatchListDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
2033
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
2034
 
                                  virConnectPtr conn,
2035
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
2036
 
                                  remote_error *rerr,
2037
 
                                  remote_list_defined_domains_args *args,
2038
 
                                  remote_list_defined_domains_ret *ret)
 
2362
remoteDispatchListDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2363
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
2364
                                 virConnectPtr conn,
 
2365
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2366
                                 remote_error *rerr,
 
2367
                                 remote_list_defined_domains_args *args,
 
2368
                                 remote_list_defined_domains_ret *ret)
2039
2369
{
 
2370
    int rv = -1;
 
2371
    int len;
 
2372
 
 
2373
    if (!conn) {
 
2374
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2375
        goto cleanup;
 
2376
    }
2040
2377
 
2041
2378
    if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
2042
 
        remoteDispatchFormatError (rerr,
2043
 
                                   "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
2044
 
        return -1;
 
2379
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
2380
                    "%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
 
2381
        goto cleanup;
2045
2382
    }
2046
2383
 
2047
2384
    /* Allocate return buffer. */
2048
2385
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
2049
 
        remoteDispatchOOMError(rerr);
2050
 
        return -1;
 
2386
        virReportOOMError();
 
2387
        goto cleanup;
2051
2388
    }
2052
2389
 
2053
 
    ret->names.names_len =
2054
 
        virConnectListDefinedDomains (conn,
2055
 
                                      ret->names.names_val, args->maxnames);
2056
 
    if (ret->names.names_len == -1) {
 
2390
    len = virConnectListDefinedDomains(conn,
 
2391
                                       ret->names.names_val, args->maxnames);
 
2392
    if (len < 0)
 
2393
        goto cleanup;
 
2394
    ret->names.names_len = len;
 
2395
 
 
2396
    rv = 0;
 
2397
 
 
2398
cleanup:
 
2399
    if (rv < 0) {
 
2400
        remoteDispatchError(rerr);
2057
2401
        VIR_FREE(ret->names.names_val);
2058
 
        remoteDispatchConnError(rerr, conn);
2059
 
        return -1;
2060
 
    }
2061
 
 
2062
 
    return 0;
2063
 
}
2064
 
 
2065
 
static int
2066
 
remoteDispatchDomainLookupById (struct qemud_server *server ATTRIBUTE_UNUSED,
2067
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
2068
 
                                virConnectPtr conn,
2069
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
2070
 
                                remote_error *rerr,
2071
 
                                remote_domain_lookup_by_id_args *args,
2072
 
                                remote_domain_lookup_by_id_ret *ret)
2073
 
{
2074
 
    virDomainPtr dom;
2075
 
 
2076
 
    dom = virDomainLookupByID (conn, args->id);
2077
 
    if (dom == NULL) {
2078
 
        remoteDispatchConnError(rerr, conn);
2079
 
        return -1;
2080
 
    }
2081
 
 
2082
 
    make_nonnull_domain (&ret->dom, dom);
2083
 
    virDomainFree(dom);
2084
 
    return 0;
2085
 
}
2086
 
 
2087
 
static int
2088
 
remoteDispatchDomainLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
2089
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
2090
 
                                  virConnectPtr conn,
2091
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
2092
 
                                  remote_error *rerr,
2093
 
                                  remote_domain_lookup_by_name_args *args,
2094
 
                                  remote_domain_lookup_by_name_ret *ret)
2095
 
{
2096
 
    virDomainPtr dom;
2097
 
 
2098
 
    dom = virDomainLookupByName (conn, args->name);
2099
 
    if (dom == NULL) {
2100
 
        remoteDispatchConnError(rerr, conn);
2101
 
        return -1;
2102
 
    }
2103
 
 
2104
 
    make_nonnull_domain (&ret->dom, dom);
2105
 
    virDomainFree(dom);
2106
 
    return 0;
2107
 
}
2108
 
 
2109
 
static int
2110
 
remoteDispatchDomainLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
2111
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
2112
 
                                  virConnectPtr conn,
2113
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
2114
 
                                  remote_error *rerr,
2115
 
                                  remote_domain_lookup_by_uuid_args *args,
2116
 
                                  remote_domain_lookup_by_uuid_ret *ret)
2117
 
{
2118
 
    virDomainPtr dom;
2119
 
 
2120
 
    dom = virDomainLookupByUUID (conn, (unsigned char *) args->uuid);
2121
 
    if (dom == NULL) {
2122
 
        remoteDispatchConnError(rerr, conn);
2123
 
        return -1;
2124
 
    }
2125
 
 
2126
 
    make_nonnull_domain (&ret->dom, dom);
2127
 
    virDomainFree(dom);
2128
 
    return 0;
2129
 
}
2130
 
 
2131
 
static int
2132
 
remoteDispatchNumOfDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
2133
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
2134
 
                                   virConnectPtr conn,
2135
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
2136
 
                                   remote_error *rerr,
2137
 
                                   void *args ATTRIBUTE_UNUSED,
2138
 
                                   remote_num_of_defined_domains_ret *ret)
2139
 
{
2140
 
 
2141
 
    ret->num = virConnectNumOfDefinedDomains (conn);
2142
 
    if (ret->num == -1) {
2143
 
        remoteDispatchConnError(rerr, conn);
2144
 
        return -1;
2145
 
    }
2146
 
 
2147
 
    return 0;
2148
 
}
2149
 
 
2150
 
static int
2151
 
remoteDispatchDomainPinVcpu (struct qemud_server *server ATTRIBUTE_UNUSED,
2152
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
2153
 
                             virConnectPtr conn,
2154
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
2155
 
                             remote_error *rerr,
2156
 
                             remote_domain_pin_vcpu_args *args,
2157
 
                             void *ret ATTRIBUTE_UNUSED)
2158
 
{
2159
 
    virDomainPtr dom;
2160
 
    int rv;
2161
 
 
2162
 
    dom = get_nonnull_domain (conn, args->dom);
2163
 
    if (dom == NULL) {
2164
 
        remoteDispatchConnError(rerr, conn);
2165
 
        return -1;
2166
 
    }
 
2402
    }
 
2403
    return rv;
 
2404
}
 
2405
 
 
2406
static int
 
2407
remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2408
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
2409
                               virConnectPtr conn,
 
2410
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2411
                               remote_error *rerr,
 
2412
                               remote_domain_lookup_by_id_args *args,
 
2413
                               remote_domain_lookup_by_id_ret *ret)
 
2414
{
 
2415
    virDomainPtr dom = NULL;
 
2416
    int rv = -1;
 
2417
 
 
2418
    if (!conn) {
 
2419
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2420
        goto cleanup;
 
2421
    }
 
2422
 
 
2423
    if (!(dom = virDomainLookupByID(conn, args->id)))
 
2424
        goto cleanup;
 
2425
 
 
2426
    make_nonnull_domain(&ret->dom, dom);
 
2427
 
 
2428
    rv = 0;
 
2429
 
 
2430
cleanup:
 
2431
    if (rv < 0)
 
2432
        remoteDispatchError(rerr);
 
2433
    if (dom)
 
2434
        virDomainFree(dom);
 
2435
    return rv;
 
2436
}
 
2437
 
 
2438
static int
 
2439
remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2440
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
2441
                                 virConnectPtr conn,
 
2442
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2443
                                 remote_error *rerr,
 
2444
                                 remote_domain_lookup_by_name_args *args,
 
2445
                                 remote_domain_lookup_by_name_ret *ret)
 
2446
{
 
2447
    virDomainPtr dom = NULL;
 
2448
    int rv = -1;
 
2449
 
 
2450
    if (!conn) {
 
2451
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2452
        goto cleanup;
 
2453
    }
 
2454
 
 
2455
    if (!(dom = virDomainLookupByName(conn, args->name)))
 
2456
        goto cleanup;
 
2457
 
 
2458
    make_nonnull_domain(&ret->dom, dom);
 
2459
 
 
2460
    rv = 0;
 
2461
 
 
2462
cleanup:
 
2463
    if (rv < 0)
 
2464
        remoteDispatchError(rerr);
 
2465
    if (dom)
 
2466
        virDomainFree(dom);
 
2467
    return rv;
 
2468
}
 
2469
 
 
2470
static int
 
2471
remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2472
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
2473
                                 virConnectPtr conn,
 
2474
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2475
                                 remote_error *rerr,
 
2476
                                 remote_domain_lookup_by_uuid_args *args,
 
2477
                                 remote_domain_lookup_by_uuid_ret *ret)
 
2478
{
 
2479
    virDomainPtr dom = NULL;
 
2480
    int rv = -1;
 
2481
 
 
2482
    if (!conn) {
 
2483
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2484
        goto cleanup;
 
2485
    }
 
2486
 
 
2487
    if (!(dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid)))
 
2488
        goto cleanup;
 
2489
 
 
2490
    make_nonnull_domain(&ret->dom, dom);
 
2491
 
 
2492
    rv = 0;
 
2493
 
 
2494
cleanup:
 
2495
    if (rv < 0)
 
2496
        remoteDispatchError(rerr);
 
2497
    if (dom)
 
2498
        virDomainFree(dom);
 
2499
    return rv;
 
2500
}
 
2501
 
 
2502
static int
 
2503
remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2504
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
2505
                                  virConnectPtr conn,
 
2506
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2507
                                  remote_error *rerr,
 
2508
                                  void *args ATTRIBUTE_UNUSED,
 
2509
                                  remote_num_of_defined_domains_ret *ret)
 
2510
{
 
2511
    int rv = -1;
 
2512
 
 
2513
    if (!conn) {
 
2514
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2515
        goto cleanup;
 
2516
    }
 
2517
 
 
2518
    if ((ret->num = virConnectNumOfDefinedDomains(conn)) < 0)
 
2519
        goto cleanup;
 
2520
 
 
2521
    rv = 0;
 
2522
 
 
2523
cleanup:
 
2524
    if (rv < 0)
 
2525
        remoteDispatchError(rerr);
 
2526
    return rv;
 
2527
}
 
2528
 
 
2529
static int
 
2530
remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2531
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
2532
                            virConnectPtr conn,
 
2533
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2534
                            remote_error *rerr,
 
2535
                            remote_domain_pin_vcpu_args *args,
 
2536
                            void *ret ATTRIBUTE_UNUSED)
 
2537
{
 
2538
    virDomainPtr dom = NULL;
 
2539
    int rv = -1;
 
2540
 
 
2541
    if (!conn) {
 
2542
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2543
        goto cleanup;
 
2544
    }
 
2545
 
 
2546
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2547
        goto cleanup;
2167
2548
 
2168
2549
    if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
2169
 
        virDomainFree(dom);
2170
 
        remoteDispatchFormatError (rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
2171
 
        return -1;
2172
 
    }
2173
 
 
2174
 
    rv = virDomainPinVcpu (dom, args->vcpu,
2175
 
                           (unsigned char *) args->cpumap.cpumap_val,
2176
 
                           args->cpumap.cpumap_len);
2177
 
    if (rv == -1) {
2178
 
        virDomainFree(dom);
2179
 
        remoteDispatchConnError(rerr, conn);
2180
 
        return -1;
2181
 
    }
2182
 
    virDomainFree(dom);
2183
 
    return 0;
2184
 
}
2185
 
 
2186
 
static int
2187
 
remoteDispatchDomainReboot (struct qemud_server *server ATTRIBUTE_UNUSED,
 
2550
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
 
2551
        goto cleanup;
 
2552
    }
 
2553
 
 
2554
    if (virDomainPinVcpu(dom, args->vcpu,
 
2555
                         (unsigned char *) args->cpumap.cpumap_val,
 
2556
                         args->cpumap.cpumap_len) < 0)
 
2557
        goto cleanup;
 
2558
 
 
2559
    rv = 0;
 
2560
 
 
2561
cleanup:
 
2562
    if (rv < 0)
 
2563
        remoteDispatchError(rerr);
 
2564
    if (dom)
 
2565
        virDomainFree(dom);
 
2566
    return rv;
 
2567
}
 
2568
 
 
2569
static int
 
2570
remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2571
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
2572
                           virConnectPtr conn,
 
2573
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2574
                           remote_error *rerr,
 
2575
                           remote_domain_reboot_args *args,
 
2576
                           void *ret ATTRIBUTE_UNUSED)
 
2577
{
 
2578
    virDomainPtr dom = NULL;
 
2579
    int rv = -1;
 
2580
 
 
2581
    if (!conn) {
 
2582
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2583
        goto cleanup;
 
2584
    }
 
2585
 
 
2586
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2587
        goto cleanup;
 
2588
 
 
2589
    if (virDomainReboot(dom, args->flags) < 0)
 
2590
        goto cleanup;
 
2591
 
 
2592
    rv = 0;
 
2593
 
 
2594
cleanup:
 
2595
    if (rv < 0)
 
2596
        remoteDispatchError(rerr);
 
2597
    if (dom)
 
2598
        virDomainFree(dom);
 
2599
    return rv;
 
2600
}
 
2601
 
 
2602
static int
 
2603
remoteDispatchDomainRestore(struct qemud_server *server ATTRIBUTE_UNUSED,
2188
2604
                            struct qemud_client *client ATTRIBUTE_UNUSED,
2189
2605
                            virConnectPtr conn,
2190
2606
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
2191
2607
                            remote_error *rerr,
2192
 
                            remote_domain_reboot_args *args,
 
2608
                            remote_domain_restore_args *args,
2193
2609
                            void *ret ATTRIBUTE_UNUSED)
2194
2610
{
2195
 
    virDomainPtr dom;
2196
 
 
2197
 
    dom = get_nonnull_domain (conn, args->dom);
2198
 
    if (dom == NULL) {
2199
 
        remoteDispatchConnError(rerr, conn);
2200
 
        return -1;
2201
 
    }
2202
 
 
2203
 
    if (virDomainReboot (dom, args->flags) == -1) {
2204
 
        virDomainFree(dom);
2205
 
        remoteDispatchConnError(rerr, conn);
2206
 
        return -1;
2207
 
    }
2208
 
    virDomainFree(dom);
2209
 
    return 0;
2210
 
}
2211
 
 
2212
 
static int
2213
 
remoteDispatchDomainRestore (struct qemud_server *server ATTRIBUTE_UNUSED,
 
2611
    int rv = -1;
 
2612
 
 
2613
    if (!conn) {
 
2614
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2615
        goto cleanup;
 
2616
    }
 
2617
 
 
2618
    if (virDomainRestore(conn, args->from) < 0)
 
2619
        goto cleanup;
 
2620
 
 
2621
    rv = 0;
 
2622
 
 
2623
cleanup:
 
2624
    if (rv < 0)
 
2625
        remoteDispatchError(rerr);
 
2626
    return rv;
 
2627
}
 
2628
 
 
2629
static int
 
2630
remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2631
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
2632
                           virConnectPtr conn,
 
2633
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2634
                           remote_error *rerr,
 
2635
                           remote_domain_resume_args *args,
 
2636
                           void *ret ATTRIBUTE_UNUSED)
 
2637
{
 
2638
    virDomainPtr dom = NULL;
 
2639
    int rv = -1;
 
2640
 
 
2641
    if (!conn) {
 
2642
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2643
        goto cleanup;
 
2644
    }
 
2645
 
 
2646
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2647
        goto cleanup;
 
2648
 
 
2649
    if (virDomainResume(dom) < 0)
 
2650
        goto cleanup;
 
2651
 
 
2652
    rv = 0;
 
2653
 
 
2654
cleanup:
 
2655
    if (rv < 0)
 
2656
        remoteDispatchError(rerr);
 
2657
    if (dom)
 
2658
        virDomainFree(dom);
 
2659
    return rv;
 
2660
}
 
2661
 
 
2662
static int
 
2663
remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2664
                         struct qemud_client *client ATTRIBUTE_UNUSED,
 
2665
                         virConnectPtr conn,
 
2666
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2667
                         remote_error *rerr,
 
2668
                         remote_domain_save_args *args,
 
2669
                         void *ret ATTRIBUTE_UNUSED)
 
2670
{
 
2671
    virDomainPtr dom = NULL;
 
2672
    int rv = -1;
 
2673
 
 
2674
    if (!conn) {
 
2675
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2676
        goto cleanup;
 
2677
    }
 
2678
 
 
2679
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2680
        goto cleanup;
 
2681
 
 
2682
    if (virDomainSave(dom, args->to) < 0)
 
2683
        goto cleanup;
 
2684
 
 
2685
    rv = 0;
 
2686
 
 
2687
cleanup:
 
2688
    if (rv < 0)
 
2689
        remoteDispatchError(rerr);
 
2690
    if (dom)
 
2691
        virDomainFree(dom);
 
2692
    return rv;
 
2693
}
 
2694
 
 
2695
static int
 
2696
remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
2214
2697
                             struct qemud_client *client ATTRIBUTE_UNUSED,
2215
2698
                             virConnectPtr conn,
2216
2699
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
2217
2700
                             remote_error *rerr,
2218
 
                             remote_domain_restore_args *args,
 
2701
                             remote_domain_core_dump_args *args,
2219
2702
                             void *ret ATTRIBUTE_UNUSED)
2220
2703
{
2221
 
 
2222
 
    if (virDomainRestore (conn, args->from) == -1) {
2223
 
        remoteDispatchConnError(rerr, conn);
2224
 
        return -1;
2225
 
    }
2226
 
 
2227
 
    return 0;
2228
 
}
2229
 
 
2230
 
static int
2231
 
remoteDispatchDomainResume (struct qemud_server *server ATTRIBUTE_UNUSED,
2232
 
                            struct qemud_client *client ATTRIBUTE_UNUSED,
2233
 
                            virConnectPtr conn,
2234
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
2235
 
                            remote_error *rerr,
2236
 
                            remote_domain_resume_args *args,
2237
 
                            void *ret ATTRIBUTE_UNUSED)
2238
 
{
2239
 
    virDomainPtr dom;
2240
 
 
2241
 
    dom = get_nonnull_domain (conn, args->dom);
2242
 
    if (dom == NULL) {
2243
 
        remoteDispatchConnError(rerr, conn);
2244
 
        return -1;
2245
 
    }
2246
 
 
2247
 
    if (virDomainResume (dom) == -1) {
2248
 
        virDomainFree(dom);
2249
 
        remoteDispatchConnError(rerr, conn);
2250
 
        return -1;
2251
 
    }
2252
 
    virDomainFree(dom);
2253
 
    return 0;
2254
 
}
2255
 
 
2256
 
static int
2257
 
remoteDispatchDomainSave (struct qemud_server *server ATTRIBUTE_UNUSED,
2258
 
                          struct qemud_client *client ATTRIBUTE_UNUSED,
2259
 
                          virConnectPtr conn,
2260
 
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
2261
 
                          remote_error *rerr,
2262
 
                          remote_domain_save_args *args,
2263
 
                          void *ret ATTRIBUTE_UNUSED)
2264
 
{
2265
 
    virDomainPtr dom;
2266
 
 
2267
 
    dom = get_nonnull_domain (conn, args->dom);
2268
 
    if (dom == NULL) {
2269
 
        remoteDispatchConnError(rerr, conn);
2270
 
        return -1;
2271
 
    }
2272
 
 
2273
 
    if (virDomainSave (dom, args->to) == -1) {
2274
 
        virDomainFree(dom);
2275
 
        remoteDispatchConnError(rerr, conn);
2276
 
        return -1;
2277
 
    }
2278
 
    virDomainFree(dom);
2279
 
    return 0;
2280
 
}
2281
 
 
2282
 
static int
2283
 
remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
 
2704
    virDomainPtr dom = NULL;
 
2705
    int rv = -1;
 
2706
 
 
2707
    if (!conn) {
 
2708
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2709
        goto cleanup;
 
2710
    }
 
2711
 
 
2712
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2713
        goto cleanup;
 
2714
 
 
2715
    if (virDomainCoreDump(dom, args->to, args->flags) < 0)
 
2716
        goto cleanup;
 
2717
 
 
2718
    rv = 0;
 
2719
 
 
2720
cleanup:
 
2721
    if (rv < 0)
 
2722
        remoteDispatchError(rerr);
 
2723
    if (dom)
 
2724
        virDomainFree(dom);
 
2725
    return rv;
 
2726
}
 
2727
 
 
2728
static int
 
2729
remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2730
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
2731
                                 virConnectPtr conn,
 
2732
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2733
                                 remote_error *rerr,
 
2734
                                 remote_domain_set_autostart_args *args,
 
2735
                                 void *ret ATTRIBUTE_UNUSED)
 
2736
{
 
2737
    virDomainPtr dom = NULL;
 
2738
    int rv = -1;
 
2739
 
 
2740
    if (!conn) {
 
2741
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2742
        goto cleanup;
 
2743
    }
 
2744
 
 
2745
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2746
        goto cleanup;
 
2747
 
 
2748
    if (virDomainSetAutostart(dom, args->autostart) < 0)
 
2749
        goto cleanup;
 
2750
 
 
2751
    rv = 0;
 
2752
 
 
2753
cleanup:
 
2754
    if (rv < 0)
 
2755
        remoteDispatchError(rerr);
 
2756
    if (dom)
 
2757
        virDomainFree(dom);
 
2758
    return rv;
 
2759
}
 
2760
 
 
2761
static int
 
2762
remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2763
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
2764
                                 virConnectPtr conn,
 
2765
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2766
                                 remote_error *rerr,
 
2767
                                 remote_domain_set_max_memory_args *args,
 
2768
                                 void *ret ATTRIBUTE_UNUSED)
 
2769
{
 
2770
    virDomainPtr dom = NULL;
 
2771
    int rv = -1;
 
2772
 
 
2773
    if (!conn) {
 
2774
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2775
        goto cleanup;
 
2776
    }
 
2777
 
 
2778
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2779
        goto cleanup;
 
2780
 
 
2781
    if (virDomainSetMaxMemory(dom, args->memory) < 0)
 
2782
        goto cleanup;
 
2783
 
 
2784
    rv = 0;
 
2785
 
 
2786
cleanup:
 
2787
    if (rv < 0)
 
2788
        remoteDispatchError(rerr);
 
2789
    if (dom)
 
2790
        virDomainFree(dom);
 
2791
    return rv;
 
2792
}
 
2793
 
 
2794
static int
 
2795
remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
2284
2796
                              struct qemud_client *client ATTRIBUTE_UNUSED,
2285
2797
                              virConnectPtr conn,
2286
2798
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
2287
2799
                              remote_error *rerr,
2288
 
                              remote_domain_core_dump_args *args,
 
2800
                              remote_domain_set_memory_args *args,
2289
2801
                              void *ret ATTRIBUTE_UNUSED)
2290
2802
{
2291
 
    virDomainPtr dom;
2292
 
 
2293
 
    dom = get_nonnull_domain (conn, args->dom);
2294
 
    if (dom == NULL) {
2295
 
        remoteDispatchConnError(rerr, conn);
2296
 
        return -1;
2297
 
    }
2298
 
 
2299
 
    if (virDomainCoreDump (dom, args->to, args->flags) == -1) {
2300
 
        virDomainFree(dom);
2301
 
        remoteDispatchConnError(rerr, conn);
2302
 
        return -1;
2303
 
    }
2304
 
    virDomainFree(dom);
2305
 
    return 0;
2306
 
}
2307
 
 
2308
 
static int
2309
 
remoteDispatchDomainSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
2310
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
2311
 
                                  virConnectPtr conn,
2312
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
2313
 
                                  remote_error *rerr,
2314
 
                                  remote_domain_set_autostart_args *args,
2315
 
                                  void *ret ATTRIBUTE_UNUSED)
2316
 
{
2317
 
    virDomainPtr dom;
2318
 
 
2319
 
    dom = get_nonnull_domain (conn, args->dom);
2320
 
    if (dom == NULL) {
2321
 
        remoteDispatchConnError(rerr, conn);
2322
 
        return -1;
2323
 
    }
2324
 
 
2325
 
    if (virDomainSetAutostart (dom, args->autostart) == -1) {
2326
 
        virDomainFree(dom);
2327
 
        remoteDispatchConnError(rerr, conn);
2328
 
        return -1;
2329
 
    }
2330
 
    virDomainFree(dom);
2331
 
    return 0;
2332
 
}
2333
 
 
2334
 
static int
2335
 
remoteDispatchDomainSetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
2336
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
2337
 
                                  virConnectPtr conn,
2338
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
2339
 
                                  remote_error *rerr,
2340
 
                                  remote_domain_set_max_memory_args *args,
2341
 
                                  void *ret ATTRIBUTE_UNUSED)
2342
 
{
2343
 
    virDomainPtr dom;
2344
 
 
2345
 
    dom = get_nonnull_domain (conn, args->dom);
2346
 
    if (dom == NULL) {
2347
 
        remoteDispatchConnError(rerr, conn);
2348
 
        return -1;
2349
 
    }
2350
 
 
2351
 
    if (virDomainSetMaxMemory (dom, args->memory) == -1) {
2352
 
        virDomainFree(dom);
2353
 
        remoteDispatchConnError(rerr, conn);
2354
 
        return -1;
2355
 
    }
2356
 
    virDomainFree(dom);
2357
 
    return 0;
2358
 
}
2359
 
 
2360
 
static int
2361
 
remoteDispatchDomainSetMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
2362
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
2363
 
                               virConnectPtr conn,
2364
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
2365
 
                               remote_error *rerr,
2366
 
                               remote_domain_set_memory_args *args,
2367
 
                               void *ret ATTRIBUTE_UNUSED)
2368
 
{
2369
 
    virDomainPtr dom;
2370
 
 
2371
 
    dom = get_nonnull_domain (conn, args->dom);
2372
 
    if (dom == NULL) {
2373
 
        remoteDispatchConnError(rerr, conn);
2374
 
        return -1;
2375
 
    }
2376
 
 
2377
 
    if (virDomainSetMemory (dom, args->memory) == -1) {
2378
 
        virDomainFree(dom);
2379
 
        remoteDispatchConnError(rerr, conn);
2380
 
        return -1;
2381
 
    }
2382
 
    virDomainFree(dom);
2383
 
    return 0;
 
2803
    virDomainPtr dom = NULL;
 
2804
    int rv = -1;
 
2805
 
 
2806
    if (!conn) {
 
2807
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2808
        goto cleanup;
 
2809
    }
 
2810
 
 
2811
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2812
        goto cleanup;
 
2813
 
 
2814
    if (virDomainSetMemory(dom, args->memory) < 0)
 
2815
        goto cleanup;
 
2816
 
 
2817
    rv = 0;
 
2818
 
 
2819
cleanup:
 
2820
    if (rv < 0)
 
2821
        remoteDispatchError(rerr);
 
2822
    if (dom)
 
2823
        virDomainFree(dom);
 
2824
    return rv;
 
2825
}
 
2826
 
 
2827
static int
 
2828
remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
2829
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
2830
                                   virConnectPtr conn,
 
2831
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
2832
                                   remote_error *rerr,
 
2833
                                   remote_domain_set_memory_flags_args *args,
 
2834
                                   void *ret ATTRIBUTE_UNUSED)
 
2835
{
 
2836
    virDomainPtr dom = NULL;
 
2837
    int rv = -1;
 
2838
 
 
2839
    if (!conn) {
 
2840
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2841
        goto cleanup;
 
2842
    }
 
2843
 
 
2844
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2845
        goto cleanup;
 
2846
 
 
2847
    if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0)
 
2848
        goto cleanup;
 
2849
 
 
2850
    rv = 0;
 
2851
 
 
2852
cleanup:
 
2853
    if (rv < 0)
 
2854
        remoteDispatchError(rerr);
 
2855
    if (dom)
 
2856
        virDomainFree(dom);
 
2857
    return rv;
2384
2858
}
2385
2859
 
2386
2860
static int
2395
2869
                                        remote_domain_set_memory_parameters_args
2396
2870
                                        * args, void *ret ATTRIBUTE_UNUSED)
2397
2871
{
2398
 
    virDomainPtr dom;
2399
 
    int i, r, nparams;
2400
 
    virMemoryParameterPtr params;
 
2872
    virDomainPtr dom = NULL;
 
2873
    virMemoryParameterPtr params = NULL;
 
2874
    int i, nparams;
2401
2875
    unsigned int flags;
 
2876
    int rv = -1;
 
2877
 
 
2878
    if (!conn) {
 
2879
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2880
        goto cleanup;
 
2881
    }
2402
2882
 
2403
2883
    nparams = args->params.params_len;
2404
2884
    flags = args->flags;
2405
2885
 
2406
2886
    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
2407
 
        remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
2408
 
        return -1;
 
2887
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
 
2888
        goto cleanup;
2409
2889
    }
2410
2890
    if (VIR_ALLOC_N(params, nparams) < 0) {
2411
 
        remoteDispatchOOMError(rerr);
2412
 
        return -1;
 
2891
        virReportOOMError();
 
2892
        goto cleanup;
2413
2893
    }
2414
2894
 
2415
2895
    /* Deserialise parameters. */
2416
2896
    for (i = 0; i < nparams; ++i) {
2417
2897
        if (virStrcpyStatic
2418
2898
            (params[i].field, args->params.params_val[i].field) == NULL) {
2419
 
            remoteDispatchFormatError(rerr,
2420
 
                                      _
2421
 
                                      ("Field %s too big for destination"),
2422
 
                                      args->params.params_val[i].field);
2423
 
            return -1;
 
2899
            virNetError(VIR_ERR_INTERNAL_ERROR,
 
2900
                        _("Field %s too big for destination"),
 
2901
                        args->params.params_val[i].field);
 
2902
            goto cleanup;
2424
2903
        }
2425
2904
        params[i].type = args->params.params_val[i].value.type;
2426
2905
        switch (params[i].type) {
2457
2936
        }
2458
2937
    }
2459
2938
 
2460
 
    dom = get_nonnull_domain(conn, args->dom);
2461
 
    if (dom == NULL) {
2462
 
        VIR_FREE(params);
2463
 
        remoteDispatchConnError(rerr, conn);
2464
 
        return -1;
2465
 
    }
2466
 
 
2467
 
    r = virDomainSetMemoryParameters(dom, params, nparams, flags);
2468
 
    virDomainFree(dom);
 
2939
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2940
        goto cleanup;
 
2941
 
 
2942
    if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0)
 
2943
        goto cleanup;
 
2944
 
 
2945
    rv = 0;
 
2946
 
 
2947
cleanup:
 
2948
    if (rv < 0)
 
2949
        remoteDispatchError(rerr);
2469
2950
    VIR_FREE(params);
2470
 
    if (r == -1) {
2471
 
        remoteDispatchConnError(rerr, conn);
2472
 
        return -1;
2473
 
    }
2474
 
 
2475
 
    return 0;
 
2951
    if (dom)
 
2952
        virDomainFree(dom);
 
2953
    return rv;
2476
2954
}
2477
2955
 
2478
2956
static int
2489
2967
                                        remote_domain_get_memory_parameters_ret
2490
2968
                                        * ret)
2491
2969
{
2492
 
    virDomainPtr dom;
2493
 
    virMemoryParameterPtr params;
2494
 
    int i, r, nparams;
 
2970
    virDomainPtr dom = NULL;
 
2971
    virMemoryParameterPtr params = NULL;
 
2972
    int i;
 
2973
    int nparams = args->nparams;
2495
2974
    unsigned int flags;
2496
 
 
2497
 
    nparams = args->nparams;
 
2975
    int rv = -1;
 
2976
 
 
2977
    if (!conn) {
 
2978
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
2979
        goto cleanup;
 
2980
    }
 
2981
 
2498
2982
    flags = args->flags;
2499
2983
 
2500
2984
    if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
2501
 
        remoteDispatchFormatError(rerr, "%s", _("nparams too large"));
2502
 
        return -1;
 
2985
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
 
2986
        goto cleanup;
2503
2987
    }
2504
2988
    if (VIR_ALLOC_N(params, nparams) < 0) {
2505
 
        remoteDispatchOOMError(rerr);
2506
 
        return -1;
2507
 
    }
2508
 
 
2509
 
    dom = get_nonnull_domain(conn, args->dom);
2510
 
    if (dom == NULL) {
2511
 
        VIR_FREE(params);
2512
 
        remoteDispatchConnError(rerr, conn);
2513
 
        return -1;
2514
 
    }
2515
 
 
2516
 
    r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
2517
 
    if (r == -1) {
2518
 
        virDomainFree(dom);
2519
 
        VIR_FREE(params);
2520
 
        remoteDispatchConnError(rerr, conn);
2521
 
        return -1;
2522
 
    }
 
2989
        virReportOOMError();
 
2990
        goto cleanup;
 
2991
    }
 
2992
 
 
2993
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
2994
        goto cleanup;
 
2995
 
 
2996
    if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
 
2997
        goto cleanup;
 
2998
 
2523
2999
    /* In this case, we need to send back the number of parameters
2524
3000
     * supported
2525
3001
     */
2531
3007
    /* Serialise the memory parameters. */
2532
3008
    ret->params.params_len = nparams;
2533
3009
    if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
2534
 
        goto oom;
 
3010
        goto no_memory;
2535
3011
 
2536
3012
    for (i = 0; i < nparams; ++i) {
2537
3013
        /* remoteDispatchClientRequest will free this: */
2538
3014
        ret->params.params_val[i].field = strdup(params[i].field);
2539
3015
        if (ret->params.params_val[i].field == NULL)
2540
 
            goto oom;
 
3016
            goto no_memory;
2541
3017
 
2542
3018
        ret->params.params_val[i].value.type = params[i].type;
2543
3019
        switch (params[i].type) {
2572
3048
                    params[i].value.b;
2573
3049
                break;
2574
3050
            default:
2575
 
                remoteDispatchFormatError(rerr, "%s", _("unknown type"));
2576
 
                goto cleanup;
2577
 
        }
2578
 
    }
2579
 
 
2580
 
  success:
2581
 
    virDomainFree(dom);
2582
 
    VIR_FREE(params);
2583
 
 
2584
 
    return 0;
2585
 
 
2586
 
  oom:
2587
 
    remoteDispatchOOMError(rerr);
2588
 
  cleanup:
2589
 
    virDomainFree(dom);
2590
 
    for (i = 0; i < nparams; i++)
2591
 
        VIR_FREE(ret->params.params_val[i].field);
2592
 
    VIR_FREE(params);
2593
 
    return -1;
2594
 
}
2595
 
 
2596
 
static int
2597
 
remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
2598
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
2599
 
                              virConnectPtr conn,
2600
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
2601
 
                              remote_error *rerr,
2602
 
                              remote_domain_set_vcpus_args *args,
2603
 
                              void *ret ATTRIBUTE_UNUSED)
2604
 
{
2605
 
    virDomainPtr dom;
2606
 
 
2607
 
    dom = get_nonnull_domain (conn, args->dom);
2608
 
    if (dom == NULL) {
2609
 
        remoteDispatchConnError(rerr, conn);
2610
 
        return -1;
2611
 
    }
2612
 
 
2613
 
    if (virDomainSetVcpus (dom, args->nvcpus) == -1) {
2614
 
        virDomainFree(dom);
2615
 
        remoteDispatchConnError(rerr, conn);
2616
 
        return -1;
2617
 
    }
2618
 
    virDomainFree(dom);
2619
 
    return 0;
2620
 
}
2621
 
 
2622
 
static int
2623
 
remoteDispatchDomainSetVcpusFlags (struct qemud_server *server ATTRIBUTE_UNUSED,
2624
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
2625
 
                                   virConnectPtr conn,
2626
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
2627
 
                                   remote_error *rerr,
2628
 
                                   remote_domain_set_vcpus_flags_args *args,
2629
 
                                   void *ret ATTRIBUTE_UNUSED)
2630
 
{
2631
 
    virDomainPtr dom;
2632
 
 
2633
 
    dom = get_nonnull_domain (conn, args->dom);
2634
 
    if (dom == NULL) {
2635
 
        remoteDispatchConnError(rerr, conn);
2636
 
        return -1;
2637
 
    }
2638
 
 
2639
 
    if (virDomainSetVcpusFlags (dom, args->nvcpus, args->flags) == -1) {
2640
 
        virDomainFree(dom);
2641
 
        remoteDispatchConnError(rerr, conn);
2642
 
        return -1;
2643
 
    }
2644
 
    virDomainFree(dom);
2645
 
    return 0;
2646
 
}
2647
 
 
2648
 
static int
2649
 
remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
2650
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
2651
 
                              virConnectPtr conn,
2652
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
2653
 
                              remote_error *rerr,
2654
 
                              remote_domain_shutdown_args *args,
2655
 
                              void *ret ATTRIBUTE_UNUSED)
2656
 
{
2657
 
    virDomainPtr dom;
2658
 
 
2659
 
    dom = get_nonnull_domain (conn, args->dom);
2660
 
    if (dom == NULL) {
2661
 
        remoteDispatchConnError(rerr, conn);
2662
 
        return -1;
2663
 
    }
2664
 
 
2665
 
    if (virDomainShutdown (dom) == -1) {
2666
 
        virDomainFree(dom);
2667
 
        remoteDispatchConnError(rerr, conn);
2668
 
        return -1;
2669
 
    }
2670
 
    virDomainFree(dom);
2671
 
    return 0;
2672
 
}
2673
 
 
2674
 
static int
2675
 
remoteDispatchDomainSuspend (struct qemud_server *server ATTRIBUTE_UNUSED,
2676
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
2677
 
                             virConnectPtr conn,
2678
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
2679
 
                             remote_error *rerr,
2680
 
                             remote_domain_suspend_args *args,
2681
 
                             void *ret ATTRIBUTE_UNUSED)
2682
 
{
2683
 
    virDomainPtr dom;
2684
 
 
2685
 
    dom = get_nonnull_domain (conn, args->dom);
2686
 
    if (dom == NULL) {
2687
 
        remoteDispatchConnError(rerr, conn);
2688
 
        return -1;
2689
 
    }
2690
 
 
2691
 
    if (virDomainSuspend (dom) == -1) {
2692
 
        virDomainFree(dom);
2693
 
        remoteDispatchConnError(rerr, conn);
2694
 
        return -1;
2695
 
    }
2696
 
    virDomainFree(dom);
2697
 
    return 0;
2698
 
}
2699
 
 
2700
 
static int
2701
 
remoteDispatchDomainUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
2702
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
2703
 
                              virConnectPtr conn,
2704
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
2705
 
                              remote_error *rerr,
2706
 
                              remote_domain_undefine_args *args,
2707
 
                              void *ret ATTRIBUTE_UNUSED)
2708
 
{
2709
 
    virDomainPtr dom;
2710
 
 
2711
 
    dom = get_nonnull_domain (conn, args->dom);
2712
 
    if (dom == NULL) {
2713
 
        remoteDispatchConnError(rerr, conn);
2714
 
        return -1;
2715
 
    }
2716
 
 
2717
 
    if (virDomainUndefine (dom) == -1) {
2718
 
        virDomainFree(dom);
2719
 
        remoteDispatchConnError(rerr, conn);
2720
 
        return -1;
2721
 
    }
2722
 
    virDomainFree(dom);
2723
 
    return 0;
2724
 
}
2725
 
 
2726
 
static int
2727
 
remoteDispatchListDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
2728
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
2729
 
                                   virConnectPtr conn,
2730
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
2731
 
                                   remote_error *rerr,
2732
 
                                   remote_list_defined_networks_args *args,
2733
 
                                   remote_list_defined_networks_ret *ret)
2734
 
{
 
3051
                virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
 
3052
                goto cleanup;
 
3053
        }
 
3054
    }
 
3055
 
 
3056
success:
 
3057
    rv = 0;
 
3058
 
 
3059
cleanup:
 
3060
    if (rv < 0) {
 
3061
        remoteDispatchError(rerr);
 
3062
        if (ret->params.params_val) {
 
3063
            for (i = 0; i < nparams; i++)
 
3064
                VIR_FREE(ret->params.params_val[i].field);
 
3065
            VIR_FREE(ret->params.params_val);
 
3066
        }
 
3067
    }
 
3068
    if (dom)
 
3069
        virDomainFree(dom);
 
3070
    VIR_FREE(params);
 
3071
    return rv;
 
3072
 
 
3073
no_memory:
 
3074
    virReportOOMError();
 
3075
    goto cleanup;
 
3076
}
 
3077
 
 
3078
static int
 
3079
remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
 
3080
                                        ATTRIBUTE_UNUSED,
 
3081
                                        struct qemud_client *client
 
3082
                                        ATTRIBUTE_UNUSED,
 
3083
                                        virConnectPtr conn,
 
3084
                                        remote_message_header *
 
3085
                                        hdr ATTRIBUTE_UNUSED,
 
3086
                                        remote_error * rerr,
 
3087
                                        remote_domain_set_blkio_parameters_args
 
3088
                                        * args, void *ret ATTRIBUTE_UNUSED)
 
3089
{
 
3090
    virDomainPtr dom = NULL;
 
3091
    virBlkioParameterPtr params = NULL;
 
3092
    int i, nparams;
 
3093
    unsigned int flags;
 
3094
    int rv = -1;
 
3095
 
 
3096
    if (!conn) {
 
3097
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3098
        goto cleanup;
 
3099
    }
 
3100
 
 
3101
    nparams = args->params.params_len;
 
3102
    flags = args->flags;
 
3103
 
 
3104
    if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
 
3105
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
 
3106
        goto cleanup;
 
3107
    }
 
3108
    if (VIR_ALLOC_N(params, nparams) < 0) {
 
3109
        virReportOOMError();
 
3110
        goto cleanup;
 
3111
    }
 
3112
 
 
3113
    /* Deserialise parameters. */
 
3114
    for (i = 0; i < nparams; ++i) {
 
3115
        if (virStrcpyStatic
 
3116
            (params[i].field, args->params.params_val[i].field) == NULL) {
 
3117
            virNetError(VIR_ERR_INTERNAL_ERROR,
 
3118
                        _("Field %s too big for destination"),
 
3119
                        args->params.params_val[i].field);
 
3120
            goto cleanup;
 
3121
        }
 
3122
        params[i].type = args->params.params_val[i].value.type;
 
3123
        switch (params[i].type) {
 
3124
            case VIR_DOMAIN_BLKIO_PARAM_INT:
 
3125
                params[i].value.i =
 
3126
                    args->params.params_val[i].value.
 
3127
                    remote_blkio_param_value_u.i;
 
3128
                break;
 
3129
            case VIR_DOMAIN_BLKIO_PARAM_UINT:
 
3130
                params[i].value.ui =
 
3131
                    args->params.params_val[i].value.
 
3132
                    remote_blkio_param_value_u.ui;
 
3133
                break;
 
3134
            case VIR_DOMAIN_BLKIO_PARAM_LLONG:
 
3135
                params[i].value.l =
 
3136
                    args->params.params_val[i].value.
 
3137
                    remote_blkio_param_value_u.l;
 
3138
                break;
 
3139
            case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
 
3140
                params[i].value.ul =
 
3141
                    args->params.params_val[i].value.
 
3142
                    remote_blkio_param_value_u.ul;
 
3143
                break;
 
3144
            case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
 
3145
                params[i].value.d =
 
3146
                    args->params.params_val[i].value.
 
3147
                    remote_blkio_param_value_u.d;
 
3148
                break;
 
3149
            case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
 
3150
                params[i].value.b =
 
3151
                    args->params.params_val[i].value.
 
3152
                    remote_blkio_param_value_u.b;
 
3153
                break;
 
3154
        }
 
3155
    }
 
3156
 
 
3157
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3158
        goto cleanup;
 
3159
 
 
3160
    if (virDomainSetBlkioParameters(dom, params, nparams, flags) < 0)
 
3161
        goto cleanup;
 
3162
 
 
3163
    rv = 0;
 
3164
 
 
3165
cleanup:
 
3166
    if (rv < 0)
 
3167
        remoteDispatchError(rerr);
 
3168
    VIR_FREE(params);
 
3169
    if (dom)
 
3170
        virDomainFree(dom);
 
3171
    return rv;
 
3172
}
 
3173
 
 
3174
static int
 
3175
remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
 
3176
                                        ATTRIBUTE_UNUSED,
 
3177
                                        struct qemud_client *client
 
3178
                                        ATTRIBUTE_UNUSED,
 
3179
                                        virConnectPtr conn,
 
3180
                                        remote_message_header *
 
3181
                                        hdr ATTRIBUTE_UNUSED,
 
3182
                                        remote_error * rerr,
 
3183
                                        remote_domain_get_blkio_parameters_args
 
3184
                                        * args,
 
3185
                                        remote_domain_get_blkio_parameters_ret
 
3186
                                        * ret)
 
3187
{
 
3188
    virDomainPtr dom = NULL;
 
3189
    virBlkioParameterPtr params = NULL;
 
3190
    int i;
 
3191
    int nparams = args->nparams;
 
3192
    unsigned int flags;
 
3193
    int rv = -1;
 
3194
 
 
3195
    if (!conn) {
 
3196
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3197
        goto cleanup;
 
3198
    }
 
3199
 
 
3200
    flags = args->flags;
 
3201
 
 
3202
    if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
 
3203
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
 
3204
        goto cleanup;
 
3205
    }
 
3206
    if (VIR_ALLOC_N(params, nparams) < 0) {
 
3207
        virReportOOMError();
 
3208
        goto cleanup;
 
3209
    }
 
3210
 
 
3211
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3212
        goto cleanup;
 
3213
 
 
3214
    if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
 
3215
        goto cleanup;
 
3216
 
 
3217
    /* In this case, we need to send back the number of parameters
 
3218
     * supported
 
3219
     */
 
3220
    if (args->nparams == 0) {
 
3221
        ret->nparams = nparams;
 
3222
        goto success;
 
3223
    }
 
3224
 
 
3225
    /* Serialise the blkio parameters. */
 
3226
    ret->params.params_len = nparams;
 
3227
    if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
 
3228
        goto no_memory;
 
3229
 
 
3230
    for (i = 0; i < nparams; ++i) {
 
3231
        // remoteDispatchClientRequest will free this:
 
3232
        ret->params.params_val[i].field = strdup(params[i].field);
 
3233
        if (ret->params.params_val[i].field == NULL)
 
3234
            goto no_memory;
 
3235
 
 
3236
        ret->params.params_val[i].value.type = params[i].type;
 
3237
        switch (params[i].type) {
 
3238
            case VIR_DOMAIN_BLKIO_PARAM_INT:
 
3239
                ret->params.params_val[i].
 
3240
                    value.remote_blkio_param_value_u.i =
 
3241
                    params[i].value.i;
 
3242
                break;
 
3243
            case VIR_DOMAIN_BLKIO_PARAM_UINT:
 
3244
                ret->params.params_val[i].
 
3245
                    value.remote_blkio_param_value_u.ui =
 
3246
                    params[i].value.ui;
 
3247
                break;
 
3248
            case VIR_DOMAIN_BLKIO_PARAM_LLONG:
 
3249
                ret->params.params_val[i].
 
3250
                    value.remote_blkio_param_value_u.l =
 
3251
                    params[i].value.l;
 
3252
                break;
 
3253
            case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
 
3254
                ret->params.params_val[i].
 
3255
                    value.remote_blkio_param_value_u.ul =
 
3256
                    params[i].value.ul;
 
3257
                break;
 
3258
            case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
 
3259
                ret->params.params_val[i].
 
3260
                    value.remote_blkio_param_value_u.d =
 
3261
                    params[i].value.d;
 
3262
                break;
 
3263
            case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
 
3264
                ret->params.params_val[i].
 
3265
                    value.remote_blkio_param_value_u.b =
 
3266
                    params[i].value.b;
 
3267
                break;
 
3268
            default:
 
3269
                virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
 
3270
                goto cleanup;
 
3271
        }
 
3272
    }
 
3273
 
 
3274
success:
 
3275
    rv = 0;
 
3276
 
 
3277
cleanup:
 
3278
    if (rv < 0) {
 
3279
        remoteDispatchError(rerr);
 
3280
        if (ret->params.params_val) {
 
3281
            for (i = 0; i < nparams; i++)
 
3282
                VIR_FREE(ret->params.params_val[i].field);
 
3283
            VIR_FREE(ret->params.params_val);
 
3284
        }
 
3285
    }
 
3286
    VIR_FREE(params);
 
3287
    if (dom)
 
3288
        virDomainFree(dom);
 
3289
    return rv;
 
3290
 
 
3291
no_memory:
 
3292
    virReportOOMError();
 
3293
    goto cleanup;
 
3294
}
 
3295
 
 
3296
static int
 
3297
remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3298
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
3299
                             virConnectPtr conn,
 
3300
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3301
                             remote_error *rerr,
 
3302
                             remote_domain_set_vcpus_args *args,
 
3303
                             void *ret ATTRIBUTE_UNUSED)
 
3304
{
 
3305
    virDomainPtr dom = NULL;
 
3306
    int rv = -1;
 
3307
 
 
3308
    if (!conn) {
 
3309
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3310
        goto cleanup;
 
3311
    }
 
3312
 
 
3313
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3314
        goto cleanup;
 
3315
 
 
3316
    if (virDomainSetVcpus(dom, args->nvcpus) < 0)
 
3317
        goto cleanup;
 
3318
 
 
3319
    rv = 0;
 
3320
 
 
3321
cleanup:
 
3322
    if (rv < 0)
 
3323
        remoteDispatchError(rerr);
 
3324
    if (dom)
 
3325
        virDomainFree(dom);
 
3326
    return rv;
 
3327
}
 
3328
 
 
3329
static int
 
3330
remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3331
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
3332
                                  virConnectPtr conn,
 
3333
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3334
                                  remote_error *rerr,
 
3335
                                  remote_domain_set_vcpus_flags_args *args,
 
3336
                                  void *ret ATTRIBUTE_UNUSED)
 
3337
{
 
3338
    virDomainPtr dom = NULL;
 
3339
    int rv = -1;
 
3340
 
 
3341
    if (!conn) {
 
3342
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3343
        goto cleanup;
 
3344
    }
 
3345
 
 
3346
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3347
        goto cleanup;
 
3348
 
 
3349
    if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0)
 
3350
        goto cleanup;
 
3351
 
 
3352
    rv = 0;
 
3353
 
 
3354
cleanup:
 
3355
    if (rv < 0)
 
3356
        remoteDispatchError(rerr);
 
3357
    if (dom)
 
3358
        virDomainFree(dom);
 
3359
    return rv;
 
3360
}
 
3361
 
 
3362
static int
 
3363
remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3364
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
3365
                             virConnectPtr conn,
 
3366
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3367
                             remote_error *rerr,
 
3368
                             remote_domain_shutdown_args *args,
 
3369
                             void *ret ATTRIBUTE_UNUSED)
 
3370
{
 
3371
    virDomainPtr dom = NULL;
 
3372
    int rv = -1;
 
3373
 
 
3374
    if (!conn) {
 
3375
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3376
        goto cleanup;
 
3377
    }
 
3378
 
 
3379
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3380
        goto cleanup;
 
3381
 
 
3382
    if (virDomainShutdown(dom) < 0)
 
3383
        goto cleanup;
 
3384
 
 
3385
    rv = 0;
 
3386
 
 
3387
cleanup:
 
3388
    if (rv < 0)
 
3389
        remoteDispatchError(rerr);
 
3390
    if (dom)
 
3391
        virDomainFree(dom);
 
3392
    return rv;
 
3393
}
 
3394
 
 
3395
static int
 
3396
remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3397
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
3398
                            virConnectPtr conn,
 
3399
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3400
                            remote_error *rerr,
 
3401
                            remote_domain_suspend_args *args,
 
3402
                            void *ret ATTRIBUTE_UNUSED)
 
3403
{
 
3404
    virDomainPtr dom = NULL;
 
3405
    int rv = -1;
 
3406
 
 
3407
    if (!conn) {
 
3408
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3409
        goto cleanup;
 
3410
    }
 
3411
 
 
3412
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3413
        goto cleanup;
 
3414
 
 
3415
    if (virDomainSuspend(dom) < 0)
 
3416
        goto cleanup;
 
3417
 
 
3418
    rv = 0;
 
3419
 
 
3420
cleanup:
 
3421
    if (rv < 0)
 
3422
        remoteDispatchError(rerr);
 
3423
    if (dom)
 
3424
        virDomainFree(dom);
 
3425
    return rv;
 
3426
}
 
3427
 
 
3428
static int
 
3429
remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3430
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
3431
                             virConnectPtr conn,
 
3432
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3433
                             remote_error *rerr,
 
3434
                             remote_domain_undefine_args *args,
 
3435
                             void *ret ATTRIBUTE_UNUSED)
 
3436
{
 
3437
    virDomainPtr dom = NULL;
 
3438
    int rv = -1;
 
3439
 
 
3440
    if (!conn) {
 
3441
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3442
        goto cleanup;
 
3443
    }
 
3444
 
 
3445
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3446
        goto cleanup;
 
3447
 
 
3448
    if (virDomainUndefine(dom) < 0)
 
3449
        goto cleanup;
 
3450
 
 
3451
    rv = 0;
 
3452
 
 
3453
cleanup:
 
3454
    if (rv < 0)
 
3455
        remoteDispatchError(rerr);
 
3456
    if (dom)
 
3457
        virDomainFree(dom);
 
3458
    return rv;
 
3459
}
 
3460
 
 
3461
static int
 
3462
remoteDispatchListDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3463
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
3464
                                  virConnectPtr conn,
 
3465
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3466
                                  remote_error *rerr,
 
3467
                                  remote_list_defined_networks_args *args,
 
3468
                                  remote_list_defined_networks_ret *ret)
 
3469
{
 
3470
    int rv = -1;
 
3471
    int len;
 
3472
 
 
3473
    if (!conn) {
 
3474
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3475
        goto cleanup;
 
3476
    }
2735
3477
 
2736
3478
    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
2737
 
        remoteDispatchFormatError (rerr,
2738
 
                                   "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
2739
 
        return -1;
 
3479
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
3480
                    "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
 
3481
        goto cleanup;
2740
3482
    }
2741
3483
 
2742
3484
    /* Allocate return buffer. */
2743
3485
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
2744
 
        remoteDispatchOOMError(rerr);
2745
 
        return -1;
 
3486
        virReportOOMError();
 
3487
        goto cleanup;
2746
3488
    }
2747
3489
 
2748
 
    ret->names.names_len =
2749
 
        virConnectListDefinedNetworks (conn,
2750
 
                                       ret->names.names_val, args->maxnames);
2751
 
    if (ret->names.names_len == -1) {
 
3490
    len = virConnectListDefinedNetworks(conn,
 
3491
                                      ret->names.names_val, args->maxnames);
 
3492
    if (len < 0)
 
3493
        goto cleanup;
 
3494
    ret->names.names_len = len;
 
3495
 
 
3496
    rv = 0;
 
3497
 
 
3498
cleanup:
 
3499
    if (rv < 0) {
 
3500
        remoteDispatchError(rerr);
2752
3501
        VIR_FREE(ret->names.names_val);
2753
 
        remoteDispatchConnError(rerr, conn);
2754
 
        return -1;
2755
3502
    }
2756
 
 
2757
 
    return 0;
 
3503
    return rv;
2758
3504
}
2759
3505
 
2760
3506
static int
2761
 
remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
2762
 
                           struct qemud_client *client ATTRIBUTE_UNUSED,
2763
 
                           virConnectPtr conn,
2764
 
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
2765
 
                           remote_error *rerr,
2766
 
                           remote_list_domains_args *args,
2767
 
                           remote_list_domains_ret *ret)
 
3507
remoteDispatchListDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3508
                          struct qemud_client *client ATTRIBUTE_UNUSED,
 
3509
                          virConnectPtr conn,
 
3510
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3511
                          remote_error *rerr,
 
3512
                          remote_list_domains_args *args,
 
3513
                          remote_list_domains_ret *ret)
2768
3514
{
 
3515
    int rv = -1;
 
3516
    int len;
 
3517
 
 
3518
    if (!conn) {
 
3519
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3520
        goto cleanup;
 
3521
    }
2769
3522
 
2770
3523
    if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
2771
 
        remoteDispatchFormatError (rerr,
2772
 
                                   "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
2773
 
        return -1;
 
3524
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
3525
                    "%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
 
3526
        goto cleanup;
2774
3527
    }
2775
3528
 
2776
3529
    /* Allocate return buffer. */
2777
3530
    if (VIR_ALLOC_N(ret->ids.ids_val, args->maxids) < 0) {
2778
 
        remoteDispatchOOMError(rerr);
2779
 
        return -1;
 
3531
        virReportOOMError();
 
3532
        goto cleanup;
2780
3533
    }
2781
3534
 
2782
 
    ret->ids.ids_len = virConnectListDomains (conn,
2783
 
                                              ret->ids.ids_val, args->maxids);
2784
 
    if (ret->ids.ids_len == -1) {
 
3535
    len = virConnectListDomains(conn,
 
3536
                                ret->ids.ids_val, args->maxids);
 
3537
    if (len < 0)
 
3538
        goto cleanup;
 
3539
    ret->ids.ids_len = len;
 
3540
 
 
3541
    rv = 0;
 
3542
 
 
3543
cleanup:
 
3544
    if (rv < 0) {
 
3545
        remoteDispatchError(rerr);
2785
3546
        VIR_FREE(ret->ids.ids_val);
2786
 
        remoteDispatchConnError(rerr, conn);
2787
 
        return -1;
2788
 
    }
2789
 
 
2790
 
    return 0;
2791
 
}
2792
 
 
2793
 
static int
2794
 
remoteDispatchDomainManagedSave (struct qemud_server *server ATTRIBUTE_UNUSED,
2795
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
2796
 
                                 virConnectPtr conn,
2797
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
2798
 
                                 remote_error *rerr,
2799
 
                                 remote_domain_managed_save_args *args,
2800
 
                                 void *ret ATTRIBUTE_UNUSED)
2801
 
{
2802
 
    virDomainPtr dom;
2803
 
 
2804
 
    dom = get_nonnull_domain (conn, args->dom);
2805
 
    if (dom == NULL) {
2806
 
        remoteDispatchConnError(rerr, conn);
2807
 
        return -1;
2808
 
    }
2809
 
 
2810
 
    if (virDomainManagedSave (dom, args->flags) == -1) {
2811
 
        virDomainFree(dom);
2812
 
        remoteDispatchConnError(rerr, conn);
2813
 
        return -1;
2814
 
    }
2815
 
    virDomainFree(dom);
2816
 
    return 0;
2817
 
}
2818
 
 
2819
 
static int
2820
 
remoteDispatchDomainHasManagedSaveImage (struct qemud_server *server ATTRIBUTE_UNUSED,
2821
 
                                         struct qemud_client *client ATTRIBUTE_UNUSED,
2822
 
                                         virConnectPtr conn,
2823
 
                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
2824
 
                                         remote_error *rerr,
2825
 
                                         remote_domain_has_managed_save_image_args *args,
2826
 
                                         remote_domain_has_managed_save_image_ret *ret)
2827
 
{
2828
 
    virDomainPtr dom;
2829
 
 
2830
 
    dom = get_nonnull_domain (conn, args->dom);
2831
 
    if (dom == NULL) {
2832
 
        remoteDispatchConnError(rerr, conn);
2833
 
        return -1;
2834
 
    }
2835
 
 
2836
 
    ret->ret = virDomainHasManagedSaveImage (dom, args->flags);
2837
 
    if (ret->ret == -1) {
2838
 
        virDomainFree(dom);
2839
 
        remoteDispatchConnError(rerr, conn);
2840
 
        return -1;
2841
 
    }
2842
 
    virDomainFree(dom);
2843
 
    return 0;
2844
 
}
2845
 
 
2846
 
static int
2847
 
remoteDispatchDomainManagedSaveRemove (struct qemud_server *server ATTRIBUTE_UNUSED,
2848
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
2849
 
                                       virConnectPtr conn,
2850
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
2851
 
                                       remote_error *rerr,
2852
 
                                       remote_domain_managed_save_remove_args *args,
2853
 
                                       void *ret ATTRIBUTE_UNUSED)
2854
 
{
2855
 
    virDomainPtr dom;
2856
 
 
2857
 
    dom = get_nonnull_domain (conn, args->dom);
2858
 
    if (dom == NULL) {
2859
 
        remoteDispatchConnError(rerr, conn);
2860
 
        return -1;
2861
 
    }
2862
 
 
2863
 
    if (virDomainManagedSaveRemove (dom, args->flags) == -1) {
2864
 
        virDomainFree(dom);
2865
 
        remoteDispatchConnError(rerr, conn);
2866
 
        return -1;
2867
 
    }
2868
 
    virDomainFree(dom);
2869
 
    return 0;
2870
 
}
2871
 
 
2872
 
static int
2873
 
remoteDispatchListNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
2874
 
                            struct qemud_client *client ATTRIBUTE_UNUSED,
2875
 
                            virConnectPtr conn,
2876
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
2877
 
                            remote_error *rerr,
2878
 
                            remote_list_networks_args *args,
2879
 
                            remote_list_networks_ret *ret)
2880
 
{
 
3547
    }
 
3548
    return rv;
 
3549
}
 
3550
 
 
3551
static int
 
3552
remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3553
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
3554
                                virConnectPtr conn,
 
3555
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3556
                                remote_error *rerr,
 
3557
                                remote_domain_managed_save_args *args,
 
3558
                                void *ret ATTRIBUTE_UNUSED)
 
3559
{
 
3560
    virDomainPtr dom = NULL;
 
3561
    int rv = -1;
 
3562
 
 
3563
    if (!conn) {
 
3564
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3565
        goto cleanup;
 
3566
    }
 
3567
 
 
3568
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3569
        goto cleanup;
 
3570
 
 
3571
    if (virDomainManagedSave(dom, args->flags) < 0)
 
3572
        goto cleanup;
 
3573
 
 
3574
    rv = 0;
 
3575
 
 
3576
cleanup:
 
3577
    if (rv < 0)
 
3578
        remoteDispatchError(rerr);
 
3579
    if (dom)
 
3580
        virDomainFree(dom);
 
3581
    return rv;
 
3582
}
 
3583
 
 
3584
static int
 
3585
remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3586
                                        struct qemud_client *client ATTRIBUTE_UNUSED,
 
3587
                                        virConnectPtr conn,
 
3588
                                        remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3589
                                        remote_error *rerr,
 
3590
                                        remote_domain_has_managed_save_image_args *args,
 
3591
                                        remote_domain_has_managed_save_image_ret *ret)
 
3592
{
 
3593
    virDomainPtr dom = NULL;
 
3594
    int rv = -1;
 
3595
 
 
3596
    if (!conn) {
 
3597
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3598
        goto cleanup;
 
3599
    }
 
3600
 
 
3601
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3602
        goto cleanup;
 
3603
 
 
3604
    if ((ret->ret = virDomainHasManagedSaveImage(dom, args->flags)) < 0)
 
3605
        goto cleanup;
 
3606
 
 
3607
    rv = 0;
 
3608
 
 
3609
cleanup:
 
3610
    if (rv < 0)
 
3611
        remoteDispatchError(rerr);
 
3612
    if (dom)
 
3613
        virDomainFree(dom);
 
3614
    return rv;
 
3615
}
 
3616
 
 
3617
static int
 
3618
remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3619
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
3620
                                      virConnectPtr conn,
 
3621
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3622
                                      remote_error *rerr,
 
3623
                                      remote_domain_managed_save_remove_args *args,
 
3624
                                      void *ret ATTRIBUTE_UNUSED)
 
3625
{
 
3626
    virDomainPtr dom = NULL;
 
3627
    int rv = -1;
 
3628
 
 
3629
    if (!conn) {
 
3630
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3631
        goto cleanup;
 
3632
    }
 
3633
 
 
3634
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
3635
        goto cleanup;
 
3636
 
 
3637
    if (virDomainManagedSaveRemove(dom, args->flags) < 0)
 
3638
        goto cleanup;
 
3639
 
 
3640
    rv = 0;
 
3641
 
 
3642
cleanup:
 
3643
    if (rv < 0)
 
3644
        remoteDispatchError(rerr);
 
3645
    if (dom)
 
3646
        virDomainFree(dom);
 
3647
    return rv;
 
3648
}
 
3649
 
 
3650
static int
 
3651
remoteDispatchListNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3652
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
3653
                           virConnectPtr conn,
 
3654
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3655
                           remote_error *rerr,
 
3656
                           remote_list_networks_args *args,
 
3657
                           remote_list_networks_ret *ret)
 
3658
{
 
3659
    int rv = -1;
 
3660
    int len;
 
3661
 
 
3662
    if (!conn) {
 
3663
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3664
        goto cleanup;
 
3665
    }
2881
3666
 
2882
3667
    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
2883
 
        remoteDispatchFormatError (rerr,
2884
 
                                   "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
2885
 
        return -1;
 
3668
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
3669
                    "%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
 
3670
        goto cleanup;
2886
3671
    }
2887
3672
 
2888
3673
    /* Allocate return buffer. */
2889
3674
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
2890
 
        remoteDispatchOOMError(rerr);
2891
 
        return -1;
2892
 
    }
2893
 
 
2894
 
    ret->names.names_len =
2895
 
        virConnectListNetworks (conn,
2896
 
                                ret->names.names_val, args->maxnames);
2897
 
    if (ret->names.names_len == -1) {
2898
 
        VIR_FREE(ret->names.names_len);
2899
 
        remoteDispatchConnError(rerr, conn);
2900
 
        return -1;
2901
 
    }
2902
 
 
2903
 
    return 0;
2904
 
}
2905
 
 
2906
 
static int
2907
 
remoteDispatchNetworkCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
 
3675
        virReportOOMError();
 
3676
        goto cleanup;
 
3677
    }
 
3678
 
 
3679
    len = virConnectListNetworks(conn,
 
3680
                                 ret->names.names_val, args->maxnames);
 
3681
    if (len < 0)
 
3682
        goto cleanup;
 
3683
    ret->names.names_len = len;
 
3684
 
 
3685
    rv = 0;
 
3686
 
 
3687
cleanup:
 
3688
    if (rv < 0) {
 
3689
        remoteDispatchError(rerr);
 
3690
        VIR_FREE(ret->names.names_val);
 
3691
    }
 
3692
    return rv;
 
3693
}
 
3694
 
 
3695
static int
 
3696
remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3697
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
3698
                            virConnectPtr conn,
 
3699
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3700
                            remote_error *rerr,
 
3701
                            remote_network_create_args *args,
 
3702
                            void *ret ATTRIBUTE_UNUSED)
 
3703
{
 
3704
    virNetworkPtr net = NULL;
 
3705
    int rv = -1;
 
3706
 
 
3707
    if (!conn) {
 
3708
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3709
        goto cleanup;
 
3710
    }
 
3711
 
 
3712
    if (!(net = get_nonnull_network(conn, args->net)))
 
3713
        goto cleanup;
 
3714
 
 
3715
    if (virNetworkCreate(net) < 0)
 
3716
        goto cleanup;
 
3717
 
 
3718
    rv = 0;
 
3719
 
 
3720
cleanup:
 
3721
    if (rv < 0)
 
3722
        remoteDispatchError(rerr);
 
3723
    if (net)
 
3724
        virNetworkFree(net);
 
3725
    return rv;
 
3726
}
 
3727
 
 
3728
static int
 
3729
remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3730
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
3731
                               virConnectPtr conn,
 
3732
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3733
                               remote_error *rerr,
 
3734
                               remote_network_create_xml_args *args,
 
3735
                               remote_network_create_xml_ret *ret)
 
3736
{
 
3737
    virNetworkPtr net = NULL;
 
3738
    int rv = -1;
 
3739
 
 
3740
    if (!conn) {
 
3741
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3742
        goto cleanup;
 
3743
    }
 
3744
 
 
3745
    if (!(net = virNetworkCreateXML(conn, args->xml)))
 
3746
        goto cleanup;
 
3747
 
 
3748
    make_nonnull_network(&ret->net, net);
 
3749
 
 
3750
    rv = 0;
 
3751
 
 
3752
cleanup:
 
3753
    if (rv < 0)
 
3754
        remoteDispatchError(rerr);
 
3755
    if (net)
 
3756
        virNetworkFree(net);
 
3757
    return rv;
 
3758
}
 
3759
 
 
3760
static int
 
3761
remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3762
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
3763
                               virConnectPtr conn,
 
3764
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3765
                               remote_error *rerr,
 
3766
                               remote_network_define_xml_args *args,
 
3767
                               remote_network_define_xml_ret *ret)
 
3768
{
 
3769
    virNetworkPtr net = NULL;
 
3770
    int rv = -1;
 
3771
 
 
3772
    if (!conn) {
 
3773
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3774
        goto cleanup;
 
3775
    }
 
3776
 
 
3777
    if (!(net = virNetworkDefineXML(conn, args->xml)))
 
3778
        goto cleanup;
 
3779
 
 
3780
    make_nonnull_network(&ret->net, net);
 
3781
 
 
3782
    rv = 0;
 
3783
 
 
3784
cleanup:
 
3785
    if (rv < 0)
 
3786
        remoteDispatchError(rerr);
 
3787
    if (net)
 
3788
        virNetworkFree(net);
 
3789
    return rv;
 
3790
}
 
3791
 
 
3792
static int
 
3793
remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
2908
3794
                             struct qemud_client *client ATTRIBUTE_UNUSED,
2909
3795
                             virConnectPtr conn,
2910
3796
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
2911
3797
                             remote_error *rerr,
2912
 
                             remote_network_create_args *args,
 
3798
                             remote_network_destroy_args *args,
2913
3799
                             void *ret ATTRIBUTE_UNUSED)
2914
3800
{
2915
 
    virNetworkPtr net;
2916
 
 
2917
 
    net = get_nonnull_network (conn, args->net);
2918
 
    if (net == NULL) {
2919
 
        remoteDispatchConnError(rerr, conn);
2920
 
        return -1;
2921
 
    }
2922
 
 
2923
 
    if (virNetworkCreate (net) == -1) {
2924
 
        virNetworkFree(net);
2925
 
        remoteDispatchConnError(rerr, conn);
2926
 
        return -1;
2927
 
    }
2928
 
    virNetworkFree(net);
2929
 
    return 0;
2930
 
}
2931
 
 
2932
 
static int
2933
 
remoteDispatchNetworkCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
2934
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
2935
 
                                virConnectPtr conn,
2936
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
2937
 
                                remote_error *rerr,
2938
 
                                remote_network_create_xml_args *args,
2939
 
                                remote_network_create_xml_ret *ret)
2940
 
{
2941
 
    virNetworkPtr net;
2942
 
 
2943
 
    net = virNetworkCreateXML (conn, args->xml);
2944
 
    if (net == NULL) {
2945
 
        remoteDispatchConnError(rerr, conn);
2946
 
        return -1;
2947
 
    }
2948
 
 
2949
 
    make_nonnull_network (&ret->net, net);
2950
 
    virNetworkFree(net);
2951
 
    return 0;
2952
 
}
2953
 
 
2954
 
static int
2955
 
remoteDispatchNetworkDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
2956
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
2957
 
                                virConnectPtr conn,
2958
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
2959
 
                                remote_error *rerr,
2960
 
                                remote_network_define_xml_args *args,
2961
 
                                remote_network_define_xml_ret *ret)
2962
 
{
2963
 
    virNetworkPtr net;
2964
 
 
2965
 
    net = virNetworkDefineXML (conn, args->xml);
2966
 
    if (net == NULL) {
2967
 
        remoteDispatchConnError(rerr, conn);
2968
 
        return -1;
2969
 
    }
2970
 
 
2971
 
    make_nonnull_network (&ret->net, net);
2972
 
    virNetworkFree(net);
2973
 
    return 0;
2974
 
}
2975
 
 
2976
 
static int
2977
 
remoteDispatchNetworkDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
 
3801
    virNetworkPtr net = NULL;
 
3802
    int rv = -1;
 
3803
 
 
3804
    if (!conn) {
 
3805
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3806
        goto cleanup;
 
3807
    }
 
3808
 
 
3809
    if (!(net = get_nonnull_network(conn, args->net)))
 
3810
        goto cleanup;
 
3811
 
 
3812
    if (virNetworkDestroy(net) < 0)
 
3813
        goto cleanup;
 
3814
 
 
3815
    rv = 0;
 
3816
 
 
3817
cleanup:
 
3818
    if (rv < 0)
 
3819
        remoteDispatchError(rerr);
 
3820
    if (net)
 
3821
        virNetworkFree(net);
 
3822
    return rv;
 
3823
}
 
3824
 
 
3825
static int
 
3826
remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3827
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
3828
                             virConnectPtr conn,
 
3829
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3830
                             remote_error *rerr,
 
3831
                             remote_network_dump_xml_args *args,
 
3832
                             remote_network_dump_xml_ret *ret)
 
3833
{
 
3834
    virNetworkPtr net = NULL;
 
3835
    int rv = -1;
 
3836
 
 
3837
    if (!conn) {
 
3838
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3839
        goto cleanup;
 
3840
    }
 
3841
 
 
3842
    if (!(net = get_nonnull_network(conn, args->net)))
 
3843
        goto cleanup;
 
3844
 
 
3845
    /* remoteDispatchClientRequest will free this. */
 
3846
    if (!(ret->xml = virNetworkGetXMLDesc(net, args->flags)))
 
3847
        goto cleanup;
 
3848
 
 
3849
    rv = 0;
 
3850
 
 
3851
cleanup:
 
3852
    if (rv < 0)
 
3853
        remoteDispatchError(rerr);
 
3854
    if (net)
 
3855
        virNetworkFree(net);
 
3856
    return rv;
 
3857
}
 
3858
 
 
3859
static int
 
3860
remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3861
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
3862
                                  virConnectPtr conn,
 
3863
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3864
                                  remote_error *rerr,
 
3865
                                  remote_network_get_autostart_args *args,
 
3866
                                  remote_network_get_autostart_ret *ret)
 
3867
{
 
3868
    virNetworkPtr net = NULL;
 
3869
    int rv = -1;
 
3870
 
 
3871
    if (!conn) {
 
3872
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3873
        goto cleanup;
 
3874
    }
 
3875
 
 
3876
    if (!(net = get_nonnull_network(conn, args->net)))
 
3877
        goto cleanup;
 
3878
 
 
3879
    if (virNetworkGetAutostart(net, &ret->autostart) < 0)
 
3880
        goto cleanup;
 
3881
 
 
3882
    rv = 0;
 
3883
 
 
3884
cleanup:
 
3885
    if (rv < 0)
 
3886
        remoteDispatchError(rerr);
 
3887
    if (net)
 
3888
        virNetworkFree(net);
 
3889
    return rv;
 
3890
}
 
3891
 
 
3892
static int
 
3893
remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3894
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
3895
                                   virConnectPtr conn,
 
3896
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3897
                                   remote_error *rerr,
 
3898
                                   remote_network_get_bridge_name_args *args,
 
3899
                                   remote_network_get_bridge_name_ret *ret)
 
3900
{
 
3901
    virNetworkPtr net = NULL;
 
3902
    int rv = -1;
 
3903
 
 
3904
    if (!conn) {
 
3905
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3906
        goto cleanup;
 
3907
    }
 
3908
 
 
3909
    if (!(net = get_nonnull_network(conn, args->net)))
 
3910
        goto cleanup;
 
3911
 
 
3912
    /* remoteDispatchClientRequest will free this. */
 
3913
    if (!(ret->name = virNetworkGetBridgeName(net)))
 
3914
        goto cleanup;
 
3915
 
 
3916
    rv = 0;
 
3917
 
 
3918
cleanup:
 
3919
    if (rv < 0)
 
3920
        remoteDispatchError(rerr);
 
3921
    if (net)
 
3922
        virNetworkFree(net);
 
3923
    return rv;
 
3924
}
 
3925
 
 
3926
static int
 
3927
remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3928
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
3929
                                  virConnectPtr conn,
 
3930
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3931
                                  remote_error *rerr,
 
3932
                                  remote_network_lookup_by_name_args *args,
 
3933
                                  remote_network_lookup_by_name_ret *ret)
 
3934
{
 
3935
    virNetworkPtr net = NULL;
 
3936
    int rv = -1;
 
3937
 
 
3938
    if (!conn) {
 
3939
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3940
        goto cleanup;
 
3941
    }
 
3942
 
 
3943
    if (!(net = virNetworkLookupByName(conn, args->name)))
 
3944
        goto cleanup;
 
3945
 
 
3946
    make_nonnull_network(&ret->net, net);
 
3947
 
 
3948
    rv = 0;
 
3949
 
 
3950
cleanup:
 
3951
    if (rv < 0)
 
3952
        remoteDispatchError(rerr);
 
3953
    if (net)
 
3954
        virNetworkFree(net);
 
3955
    return rv;
 
3956
}
 
3957
 
 
3958
static int
 
3959
remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3960
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
3961
                                  virConnectPtr conn,
 
3962
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3963
                                  remote_error *rerr,
 
3964
                                  remote_network_lookup_by_uuid_args *args,
 
3965
                                  remote_network_lookup_by_uuid_ret *ret)
 
3966
{
 
3967
    virNetworkPtr net = NULL;
 
3968
    int rv = -1;
 
3969
 
 
3970
    if (!conn) {
 
3971
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
3972
        goto cleanup;
 
3973
    }
 
3974
 
 
3975
    if (!(net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid)))
 
3976
        goto cleanup;
 
3977
 
 
3978
    make_nonnull_network(&ret->net, net);
 
3979
 
 
3980
    rv = 0;
 
3981
 
 
3982
cleanup:
 
3983
    if (rv < 0)
 
3984
        remoteDispatchError(rerr);
 
3985
    if (net)
 
3986
        virNetworkFree(net);
 
3987
    return rv;
 
3988
}
 
3989
 
 
3990
static int
 
3991
remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
 
3992
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
3993
                                  virConnectPtr conn,
 
3994
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
3995
                                  remote_error *rerr,
 
3996
                                  remote_network_set_autostart_args *args,
 
3997
                                  void *ret ATTRIBUTE_UNUSED)
 
3998
{
 
3999
    virNetworkPtr net = NULL;
 
4000
    int rv = -1;
 
4001
 
 
4002
    if (!conn) {
 
4003
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4004
        goto cleanup;
 
4005
    }
 
4006
 
 
4007
    if (!(net = get_nonnull_network(conn, args->net)))
 
4008
        goto cleanup;
 
4009
 
 
4010
    if (virNetworkSetAutostart(net, args->autostart) < 0)
 
4011
        goto cleanup;
 
4012
 
 
4013
    rv = 0;
 
4014
 
 
4015
cleanup:
 
4016
    if (rv < 0)
 
4017
        remoteDispatchError(rerr);
 
4018
    if (net)
 
4019
        virNetworkFree(net);
 
4020
    return rv;
 
4021
}
 
4022
 
 
4023
static int
 
4024
remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
2978
4025
                              struct qemud_client *client ATTRIBUTE_UNUSED,
2979
4026
                              virConnectPtr conn,
2980
4027
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
2981
4028
                              remote_error *rerr,
2982
 
                              remote_network_destroy_args *args,
 
4029
                              remote_network_undefine_args *args,
2983
4030
                              void *ret ATTRIBUTE_UNUSED)
2984
4031
{
2985
 
    virNetworkPtr net;
2986
 
 
2987
 
    net = get_nonnull_network (conn, args->net);
2988
 
    if (net == NULL) {
2989
 
        remoteDispatchConnError(rerr, conn);
2990
 
        return -1;
2991
 
    }
2992
 
 
2993
 
    if (virNetworkDestroy (net) == -1) {
2994
 
        virNetworkFree(net);
2995
 
        remoteDispatchConnError(rerr, conn);
2996
 
        return -1;
2997
 
    }
2998
 
    virNetworkFree(net);
2999
 
    return 0;
3000
 
}
3001
 
 
3002
 
static int
3003
 
remoteDispatchNetworkDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
3004
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
3005
 
                              virConnectPtr conn,
3006
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
3007
 
                              remote_error *rerr,
3008
 
                              remote_network_dump_xml_args *args,
3009
 
                              remote_network_dump_xml_ret *ret)
3010
 
{
3011
 
    virNetworkPtr net;
3012
 
 
3013
 
    net = get_nonnull_network (conn, args->net);
3014
 
    if (net == NULL) {
3015
 
        remoteDispatchConnError(rerr, conn);
3016
 
        return -1;
3017
 
    }
3018
 
 
3019
 
    /* remoteDispatchClientRequest will free this. */
3020
 
    ret->xml = virNetworkGetXMLDesc (net, args->flags);
3021
 
    if (!ret->xml) {
3022
 
        virNetworkFree(net);
3023
 
        remoteDispatchConnError(rerr, conn);
3024
 
        return -1;
3025
 
    }
3026
 
    virNetworkFree(net);
3027
 
    return 0;
3028
 
}
3029
 
 
3030
 
static int
3031
 
remoteDispatchNetworkGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
3032
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
3033
 
                                   virConnectPtr conn,
3034
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
3035
 
                                   remote_error *rerr,
3036
 
                                   remote_network_get_autostart_args *args,
3037
 
                                   remote_network_get_autostart_ret *ret)
3038
 
{
3039
 
    virNetworkPtr net;
3040
 
 
3041
 
    net = get_nonnull_network (conn, args->net);
3042
 
    if (net == NULL) {
3043
 
        remoteDispatchConnError(rerr, conn);
3044
 
        return -1;
3045
 
    }
3046
 
 
3047
 
    if (virNetworkGetAutostart (net, &ret->autostart) == -1) {
3048
 
        virNetworkFree(net);
3049
 
        remoteDispatchConnError(rerr, conn);
3050
 
        return -1;
3051
 
    }
3052
 
    virNetworkFree(net);
3053
 
    return 0;
3054
 
}
3055
 
 
3056
 
static int
3057
 
remoteDispatchNetworkGetBridgeName (struct qemud_server *server ATTRIBUTE_UNUSED,
3058
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
3059
 
                                    virConnectPtr conn,
3060
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
3061
 
                                    remote_error *rerr,
3062
 
                                    remote_network_get_bridge_name_args *args,
3063
 
                                    remote_network_get_bridge_name_ret *ret)
3064
 
{
3065
 
    virNetworkPtr net;
3066
 
 
3067
 
    net = get_nonnull_network (conn, args->net);
3068
 
    if (net == NULL) {
3069
 
        remoteDispatchConnError(rerr, conn);
3070
 
        return -1;
3071
 
    }
3072
 
 
3073
 
    /* remoteDispatchClientRequest will free this. */
3074
 
    ret->name = virNetworkGetBridgeName (net);
3075
 
    if (!ret->name) {
3076
 
        virNetworkFree(net);
3077
 
        remoteDispatchConnError(rerr, conn);
3078
 
        return -1;
3079
 
    }
3080
 
    virNetworkFree(net);
3081
 
    return 0;
3082
 
}
3083
 
 
3084
 
static int
3085
 
remoteDispatchNetworkLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
3086
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
3087
 
                                   virConnectPtr conn,
3088
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
3089
 
                                   remote_error *rerr,
3090
 
                                   remote_network_lookup_by_name_args *args,
3091
 
                                   remote_network_lookup_by_name_ret *ret)
3092
 
{
3093
 
    virNetworkPtr net;
3094
 
 
3095
 
    net = virNetworkLookupByName (conn, args->name);
3096
 
    if (net == NULL) {
3097
 
        remoteDispatchConnError(rerr, conn);
3098
 
        return -1;
3099
 
    }
3100
 
 
3101
 
    make_nonnull_network (&ret->net, net);
3102
 
    virNetworkFree(net);
3103
 
    return 0;
3104
 
}
3105
 
 
3106
 
static int
3107
 
remoteDispatchNetworkLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
3108
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
3109
 
                                   virConnectPtr conn,
3110
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
3111
 
                                   remote_error *rerr,
3112
 
                                   remote_network_lookup_by_uuid_args *args,
3113
 
                                   remote_network_lookup_by_uuid_ret *ret)
3114
 
{
3115
 
    virNetworkPtr net;
3116
 
 
3117
 
    net = virNetworkLookupByUUID (conn, (unsigned char *) args->uuid);
3118
 
    if (net == NULL) {
3119
 
        remoteDispatchConnError(rerr, conn);
3120
 
        return -1;
3121
 
    }
3122
 
 
3123
 
    make_nonnull_network (&ret->net, net);
3124
 
    virNetworkFree(net);
3125
 
    return 0;
3126
 
}
3127
 
 
3128
 
static int
3129
 
remoteDispatchNetworkSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
3130
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
3131
 
                                   virConnectPtr conn,
3132
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
3133
 
                                   remote_error *rerr,
3134
 
                                   remote_network_set_autostart_args *args,
3135
 
                                   void *ret ATTRIBUTE_UNUSED)
3136
 
{
3137
 
    virNetworkPtr net;
3138
 
 
3139
 
    net = get_nonnull_network (conn, args->net);
3140
 
    if (net == NULL) {
3141
 
        remoteDispatchConnError(rerr, conn);
3142
 
        return -1;
3143
 
    }
3144
 
 
3145
 
    if (virNetworkSetAutostart (net, args->autostart) == -1) {
3146
 
        virNetworkFree(net);
3147
 
        remoteDispatchConnError(rerr, conn);
3148
 
        return -1;
3149
 
    }
3150
 
    virNetworkFree(net);
3151
 
    return 0;
3152
 
}
3153
 
 
3154
 
static int
3155
 
remoteDispatchNetworkUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
3156
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
3157
 
                               virConnectPtr conn,
3158
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
3159
 
                               remote_error *rerr,
3160
 
                               remote_network_undefine_args *args,
3161
 
                               void *ret ATTRIBUTE_UNUSED)
3162
 
{
3163
 
    virNetworkPtr net;
3164
 
 
3165
 
    net = get_nonnull_network (conn, args->net);
3166
 
    if (net == NULL) {
3167
 
        remoteDispatchConnError(rerr, conn);
3168
 
        return -1;
3169
 
    }
3170
 
 
3171
 
    if (virNetworkUndefine (net) == -1) {
3172
 
        virNetworkFree(net);
3173
 
        remoteDispatchConnError(rerr, conn);
3174
 
        return -1;
3175
 
    }
3176
 
    virNetworkFree(net);
3177
 
    return 0;
3178
 
}
3179
 
 
3180
 
static int
3181
 
remoteDispatchNumOfDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
3182
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
3183
 
                                    virConnectPtr conn,
3184
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
3185
 
                                    remote_error *rerr,
3186
 
                                    void *args ATTRIBUTE_UNUSED,
3187
 
                                    remote_num_of_defined_networks_ret *ret)
3188
 
{
3189
 
 
3190
 
    ret->num = virConnectNumOfDefinedNetworks (conn);
3191
 
    if (ret->num == -1) {
3192
 
        remoteDispatchConnError(rerr, conn);
3193
 
        return -1;
3194
 
    }
3195
 
 
3196
 
    return 0;
3197
 
}
3198
 
 
3199
 
static int
3200
 
remoteDispatchNumOfDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
 
4032
    virNetworkPtr net = NULL;
 
4033
    int rv = -1;
 
4034
 
 
4035
    if (!conn) {
 
4036
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4037
        goto cleanup;
 
4038
    }
 
4039
 
 
4040
    if (!(net = get_nonnull_network(conn, args->net)))
 
4041
        goto cleanup;
 
4042
 
 
4043
    if (virNetworkUndefine(net) < 0)
 
4044
        goto cleanup;
 
4045
 
 
4046
    rv = 0;
 
4047
 
 
4048
cleanup:
 
4049
    if (rv < 0)
 
4050
        remoteDispatchError(rerr);
 
4051
    if (net)
 
4052
        virNetworkFree(net);
 
4053
    return rv;
 
4054
}
 
4055
 
 
4056
static int
 
4057
remoteDispatchNumOfDefinedNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4058
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
4059
                                   virConnectPtr conn,
 
4060
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4061
                                   remote_error *rerr,
 
4062
                                   void *args ATTRIBUTE_UNUSED,
 
4063
                                   remote_num_of_defined_networks_ret *ret)
 
4064
{
 
4065
    int rv = -1;
 
4066
    int len;
 
4067
 
 
4068
    if (!conn) {
 
4069
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4070
        goto cleanup;
 
4071
    }
 
4072
 
 
4073
    len = virConnectNumOfDefinedNetworks(conn);
 
4074
    if (len < 0)
 
4075
        goto cleanup;
 
4076
    ret->num = len;
 
4077
 
 
4078
    rv = 0;
 
4079
 
 
4080
cleanup:
 
4081
    if (rv < 0)
 
4082
        remoteDispatchError(rerr);
 
4083
    return rv;
 
4084
}
 
4085
 
 
4086
static int
 
4087
remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4088
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
4089
                           virConnectPtr conn,
 
4090
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4091
                           remote_error *rerr,
 
4092
                           void *args ATTRIBUTE_UNUSED,
 
4093
                           remote_num_of_domains_ret *ret)
 
4094
{
 
4095
    int rv = -1;
 
4096
 
 
4097
    if (!conn) {
 
4098
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4099
        goto cleanup;
 
4100
    }
 
4101
 
 
4102
    if ((ret->num = virConnectNumOfDomains(conn)) < 0)
 
4103
        goto cleanup;
 
4104
 
 
4105
    rv = 0;
 
4106
 
 
4107
cleanup:
 
4108
    if (rv < 0)
 
4109
        remoteDispatchError(rerr);
 
4110
    return rv;
 
4111
}
 
4112
 
 
4113
static int
 
4114
remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
3201
4115
                            struct qemud_client *client ATTRIBUTE_UNUSED,
3202
4116
                            virConnectPtr conn,
3203
4117
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
3204
4118
                            remote_error *rerr,
3205
4119
                            void *args ATTRIBUTE_UNUSED,
3206
 
                            remote_num_of_domains_ret *ret)
3207
 
{
3208
 
 
3209
 
    ret->num = virConnectNumOfDomains (conn);
3210
 
    if (ret->num == -1) {
3211
 
        remoteDispatchConnError(rerr, conn);
3212
 
        return -1;
3213
 
    }
3214
 
 
3215
 
    return 0;
3216
 
}
3217
 
 
3218
 
static int
3219
 
remoteDispatchNumOfNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
3220
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
3221
 
                             virConnectPtr conn,
3222
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
3223
 
                             remote_error *rerr,
3224
 
                             void *args ATTRIBUTE_UNUSED,
3225
 
                             remote_num_of_networks_ret *ret)
3226
 
{
3227
 
 
3228
 
    ret->num = virConnectNumOfNetworks (conn);
3229
 
    if (ret->num == -1) {
3230
 
        remoteDispatchConnError(rerr, conn);
3231
 
        return -1;
3232
 
    }
3233
 
 
3234
 
    return 0;
 
4120
                            remote_num_of_networks_ret *ret)
 
4121
{
 
4122
    int rv = -1;
 
4123
 
 
4124
    if (!conn) {
 
4125
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4126
        goto cleanup;
 
4127
    }
 
4128
 
 
4129
    if ((ret->num = virConnectNumOfNetworks(conn)) < 0)
 
4130
        goto cleanup;
 
4131
 
 
4132
    rv = 0;
 
4133
 
 
4134
cleanup:
 
4135
    if (rv < 0)
 
4136
        remoteDispatchError(rerr);
 
4137
    return rv;
3235
4138
}
3236
4139
 
3237
4140
 
3238
4141
/*-------------------------------------------------------------*/
3239
4142
static int
3240
 
remoteDispatchNumOfInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
3241
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
3242
 
                               virConnectPtr conn,
3243
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
3244
 
                               remote_error *rerr,
3245
 
                               void *args ATTRIBUTE_UNUSED,
3246
 
                               remote_num_of_interfaces_ret *ret)
3247
 
{
3248
 
 
3249
 
    ret->num = virConnectNumOfInterfaces (conn);
3250
 
    if (ret->num == -1) {
3251
 
        remoteDispatchConnError(rerr, conn);
3252
 
        return -1;
3253
 
    }
3254
 
 
3255
 
    return 0;
3256
 
}
3257
 
 
3258
 
static int
3259
 
remoteDispatchListInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
 
4143
remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
3260
4144
                              struct qemud_client *client ATTRIBUTE_UNUSED,
3261
4145
                              virConnectPtr conn,
3262
4146
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
3263
4147
                              remote_error *rerr,
3264
 
                              remote_list_interfaces_args *args,
3265
 
                              remote_list_interfaces_ret *ret)
3266
 
{
 
4148
                              void *args ATTRIBUTE_UNUSED,
 
4149
                              remote_num_of_interfaces_ret *ret)
 
4150
{
 
4151
    int rv = -1;
 
4152
 
 
4153
    if (!conn) {
 
4154
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4155
        goto cleanup;
 
4156
    }
 
4157
 
 
4158
    if ((ret->num = virConnectNumOfInterfaces(conn)) < 0)
 
4159
        goto cleanup;
 
4160
 
 
4161
    rv = 0;
 
4162
 
 
4163
cleanup:
 
4164
    if (rv < 0)
 
4165
        remoteDispatchError(rerr);
 
4166
    return rv;
 
4167
}
 
4168
 
 
4169
static int
 
4170
remoteDispatchListInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4171
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
4172
                             virConnectPtr conn,
 
4173
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4174
                             remote_error *rerr,
 
4175
                             remote_list_interfaces_args *args,
 
4176
                             remote_list_interfaces_ret *ret)
 
4177
{
 
4178
    int rv = -1;
 
4179
    int len;
 
4180
 
 
4181
    if (!conn) {
 
4182
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4183
        goto cleanup;
 
4184
    }
3267
4185
 
3268
4186
    if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
3269
 
        remoteDispatchFormatError (rerr,
3270
 
                                   "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
3271
 
        return -1;
 
4187
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
4188
                    "%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
 
4189
        goto cleanup;
3272
4190
    }
3273
4191
 
3274
4192
    /* Allocate return buffer. */
3275
4193
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
3276
 
        remoteDispatchOOMError(rerr);
3277
 
        return -1;
3278
 
    }
3279
 
 
3280
 
    ret->names.names_len =
3281
 
        virConnectListInterfaces (conn,
3282
 
                                  ret->names.names_val, args->maxnames);
3283
 
    if (ret->names.names_len == -1) {
3284
 
        VIR_FREE(ret->names.names_len);
3285
 
        remoteDispatchConnError(rerr, conn);
3286
 
        return -1;
3287
 
    }
3288
 
 
3289
 
    return 0;
3290
 
}
3291
 
 
3292
 
static int
3293
 
remoteDispatchNumOfDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
3294
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
3295
 
                                      virConnectPtr conn,
3296
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
3297
 
                                      remote_error *rerr,
3298
 
                                      void *args ATTRIBUTE_UNUSED,
3299
 
                                      remote_num_of_defined_interfaces_ret *ret)
3300
 
{
3301
 
 
3302
 
    ret->num = virConnectNumOfDefinedInterfaces (conn);
3303
 
    if (ret->num == -1) {
3304
 
        remoteDispatchConnError(rerr, conn);
3305
 
        return -1;
3306
 
    }
3307
 
 
3308
 
    return 0;
3309
 
}
3310
 
 
3311
 
static int
3312
 
remoteDispatchListDefinedInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
 
4194
        virReportOOMError();
 
4195
        goto cleanup;
 
4196
    }
 
4197
 
 
4198
    len = virConnectListInterfaces(conn,
 
4199
                                   ret->names.names_val, args->maxnames);
 
4200
    if (len < 0)
 
4201
        goto cleanup;
 
4202
    ret->names.names_len = len;
 
4203
 
 
4204
    rv = 0;
 
4205
 
 
4206
cleanup:
 
4207
    if (rv < 0) {
 
4208
        remoteDispatchError(rerr);
 
4209
        VIR_FREE(ret->names.names_val);
 
4210
    }
 
4211
    return rv;
 
4212
}
 
4213
 
 
4214
static int
 
4215
remoteDispatchNumOfDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
3313
4216
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
3314
4217
                                     virConnectPtr conn,
3315
4218
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
3316
4219
                                     remote_error *rerr,
3317
 
                                     remote_list_defined_interfaces_args *args,
3318
 
                                     remote_list_defined_interfaces_ret *ret)
3319
 
{
 
4220
                                     void *args ATTRIBUTE_UNUSED,
 
4221
                                     remote_num_of_defined_interfaces_ret *ret)
 
4222
{
 
4223
    int rv = -1;
 
4224
    int len;
 
4225
 
 
4226
    if (!conn) {
 
4227
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4228
        goto cleanup;
 
4229
    }
 
4230
 
 
4231
    len = virConnectNumOfDefinedInterfaces(conn);
 
4232
    if (len < 0)
 
4233
        goto cleanup;
 
4234
    ret->num = len;
 
4235
 
 
4236
    rv = 0;
 
4237
 
 
4238
cleanup:
 
4239
    if (rv < 0)
 
4240
        remoteDispatchError(rerr);
 
4241
    return rv;
 
4242
}
 
4243
 
 
4244
static int
 
4245
remoteDispatchListDefinedInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4246
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
 
4247
                                    virConnectPtr conn,
 
4248
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4249
                                    remote_error *rerr,
 
4250
                                    remote_list_defined_interfaces_args *args,
 
4251
                                    remote_list_defined_interfaces_ret *ret)
 
4252
{
 
4253
    int rv = -1;
 
4254
    int len;
 
4255
 
 
4256
    if (!conn) {
 
4257
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4258
        goto cleanup;
 
4259
    }
3320
4260
 
3321
4261
    if (args->maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX) {
3322
 
        remoteDispatchFormatError (rerr,
3323
 
                                   "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
3324
 
        return -1;
 
4262
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
4263
                    "%s", _("maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX"));
 
4264
        goto cleanup;
3325
4265
    }
3326
4266
 
3327
4267
    /* Allocate return buffer. */
3328
4268
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
3329
 
        remoteDispatchOOMError(rerr);
3330
 
        return -1;
3331
 
    }
3332
 
 
3333
 
    ret->names.names_len =
3334
 
        virConnectListDefinedInterfaces (conn,
3335
 
                                         ret->names.names_val, args->maxnames);
3336
 
    if (ret->names.names_len == -1) {
3337
 
        VIR_FREE(ret->names.names_len);
3338
 
        remoteDispatchConnError(rerr, conn);
3339
 
        return -1;
3340
 
    }
3341
 
 
3342
 
    return 0;
3343
 
}
3344
 
 
3345
 
static int
3346
 
remoteDispatchInterfaceLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
3347
 
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
3348
 
                                     virConnectPtr conn,
3349
 
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
3350
 
                                     remote_error *rerr,
3351
 
                                     remote_interface_lookup_by_name_args *args,
3352
 
                                     remote_interface_lookup_by_name_ret *ret)
3353
 
{
3354
 
    virInterfacePtr iface;
3355
 
 
3356
 
    iface = virInterfaceLookupByName (conn, args->name);
3357
 
    if (iface == NULL) {
3358
 
        remoteDispatchConnError(rerr, conn);
3359
 
        return -1;
3360
 
    }
3361
 
 
3362
 
    make_nonnull_interface (&ret->iface, iface);
3363
 
    virInterfaceFree(iface);
3364
 
    return 0;
3365
 
}
3366
 
 
3367
 
static int
3368
 
remoteDispatchInterfaceLookupByMacString (struct qemud_server *server ATTRIBUTE_UNUSED,
3369
 
                                          struct qemud_client *client ATTRIBUTE_UNUSED,
3370
 
                                          virConnectPtr conn,
3371
 
                                          remote_message_header *hdr ATTRIBUTE_UNUSED,
3372
 
                                          remote_error *rerr,
3373
 
                                          remote_interface_lookup_by_mac_string_args *args,
3374
 
                                          remote_interface_lookup_by_mac_string_ret *ret)
3375
 
{
3376
 
    virInterfacePtr iface;
3377
 
 
3378
 
    iface = virInterfaceLookupByMACString (conn, args->mac);
3379
 
    if (iface == NULL) {
3380
 
        remoteDispatchConnError(rerr, conn);
3381
 
        return -1;
3382
 
    }
3383
 
 
3384
 
    make_nonnull_interface (&ret->iface, iface);
3385
 
    virInterfaceFree(iface);
3386
 
    return 0;
3387
 
}
3388
 
 
3389
 
static int
3390
 
remoteDispatchInterfaceGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
3391
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
3392
 
                                   virConnectPtr conn,
3393
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
3394
 
                                   remote_error *rerr,
3395
 
                                   remote_interface_get_xml_desc_args *args,
3396
 
                                   remote_interface_get_xml_desc_ret *ret)
3397
 
{
3398
 
    virInterfacePtr iface;
3399
 
 
3400
 
    iface = get_nonnull_interface (conn, args->iface);
3401
 
    if (iface == NULL) {
3402
 
        remoteDispatchConnError(rerr, conn);
3403
 
        return -1;
3404
 
    }
3405
 
 
3406
 
    /* remoteDispatchClientRequest will free this. */
3407
 
    ret->xml = virInterfaceGetXMLDesc (iface, args->flags);
3408
 
    if (!ret->xml) {
3409
 
        virInterfaceFree(iface);
3410
 
        remoteDispatchConnError(rerr, conn);
3411
 
        return -1;
3412
 
    }
3413
 
    virInterfaceFree(iface);
3414
 
    return 0;
3415
 
}
3416
 
 
3417
 
static int
3418
 
remoteDispatchInterfaceDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
 
4269
        virReportOOMError();
 
4270
        goto cleanup;
 
4271
    }
 
4272
 
 
4273
    len = virConnectListDefinedInterfaces(conn,
 
4274
                                          ret->names.names_val, args->maxnames);
 
4275
    if (len < 0)
 
4276
        goto cleanup;
 
4277
    ret->names.names_len = len;
 
4278
 
 
4279
    rv = 0;
 
4280
 
 
4281
cleanup:
 
4282
    if (rv < 0) {
 
4283
        remoteDispatchError(rerr);
 
4284
        VIR_FREE(ret->names.names_val);
 
4285
    }
 
4286
    return rv;
 
4287
}
 
4288
 
 
4289
static int
 
4290
remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4291
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
 
4292
                                    virConnectPtr conn,
 
4293
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4294
                                    remote_error *rerr,
 
4295
                                    remote_interface_lookup_by_name_args *args,
 
4296
                                    remote_interface_lookup_by_name_ret *ret)
 
4297
{
 
4298
    virInterfacePtr iface = NULL;
 
4299
    int rv = -1;
 
4300
 
 
4301
    if (!conn) {
 
4302
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4303
        goto cleanup;
 
4304
    }
 
4305
 
 
4306
    if (!(iface = virInterfaceLookupByName(conn, args->name)))
 
4307
        goto cleanup;
 
4308
 
 
4309
    make_nonnull_interface(&ret->iface, iface);
 
4310
 
 
4311
    rv = 0;
 
4312
 
 
4313
cleanup:
 
4314
    if (rv < 0)
 
4315
        remoteDispatchError(rerr);
 
4316
    if (iface)
 
4317
        virInterfaceFree(iface);
 
4318
    return rv;
 
4319
}
 
4320
 
 
4321
static int
 
4322
remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4323
                                         struct qemud_client *client ATTRIBUTE_UNUSED,
 
4324
                                         virConnectPtr conn,
 
4325
                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4326
                                         remote_error *rerr,
 
4327
                                         remote_interface_lookup_by_mac_string_args *args,
 
4328
                                         remote_interface_lookup_by_mac_string_ret *ret)
 
4329
{
 
4330
    virInterfacePtr iface = NULL;
 
4331
    int rv = -1;
 
4332
 
 
4333
    if (!conn) {
 
4334
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4335
        goto cleanup;
 
4336
    }
 
4337
 
 
4338
    if (!(iface = virInterfaceLookupByMACString(conn, args->mac)))
 
4339
        goto cleanup;
 
4340
 
 
4341
    make_nonnull_interface(&ret->iface, iface);
 
4342
 
 
4343
    rv = 0;
 
4344
 
 
4345
cleanup:
 
4346
    if (rv < 0)
 
4347
        remoteDispatchError(rerr);
 
4348
    if (iface)
 
4349
        virInterfaceFree(iface);
 
4350
    return rv;
 
4351
}
 
4352
 
 
4353
static int
 
4354
remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
3419
4355
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
3420
4356
                                  virConnectPtr conn,
3421
4357
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
3422
4358
                                  remote_error *rerr,
3423
 
                                  remote_interface_define_xml_args *args,
3424
 
                                  remote_interface_define_xml_ret *ret)
 
4359
                                  remote_interface_get_xml_desc_args *args,
 
4360
                                  remote_interface_get_xml_desc_ret *ret)
3425
4361
{
3426
 
    virInterfacePtr iface;
 
4362
    virInterfacePtr iface = NULL;
 
4363
    int rv = -1;
3427
4364
 
3428
 
    iface = virInterfaceDefineXML (conn, args->xml, args->flags);
3429
 
    if (iface == NULL) {
3430
 
        remoteDispatchConnError(rerr, conn);
3431
 
        return -1;
 
4365
    if (!conn) {
 
4366
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4367
        goto cleanup;
3432
4368
    }
3433
4369
 
3434
 
    make_nonnull_interface (&ret->iface, iface);
3435
 
    virInterfaceFree(iface);
3436
 
    return 0;
 
4370
    if (!(iface = get_nonnull_interface(conn, args->iface)))
 
4371
        goto cleanup;
 
4372
 
 
4373
    /* remoteDispatchClientRequest will free this. */
 
4374
    if (!(ret->xml = virInterfaceGetXMLDesc(iface, args->flags)))
 
4375
        goto cleanup;
 
4376
 
 
4377
    rv = 0;
 
4378
 
 
4379
cleanup:
 
4380
    if (rv < 0)
 
4381
        remoteDispatchError(rerr);
 
4382
    if (iface)
 
4383
        virInterfaceFree(iface);
 
4384
    return rv;
3437
4385
}
3438
4386
 
3439
4387
static int
3440
 
remoteDispatchInterfaceUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
 
4388
remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
3441
4389
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
3442
4390
                                 virConnectPtr conn,
3443
4391
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
3444
4392
                                 remote_error *rerr,
3445
 
                                 remote_interface_undefine_args *args,
3446
 
                                 void *ret ATTRIBUTE_UNUSED)
3447
 
{
3448
 
    virInterfacePtr iface;
3449
 
 
3450
 
    iface = get_nonnull_interface (conn, args->iface);
3451
 
    if (iface == NULL) {
3452
 
        remoteDispatchConnError(rerr, conn);
3453
 
        return -1;
3454
 
    }
3455
 
 
3456
 
    if (virInterfaceUndefine (iface) == -1) {
3457
 
        virInterfaceFree(iface);
3458
 
        remoteDispatchConnError(rerr, conn);
3459
 
        return -1;
3460
 
    }
3461
 
    virInterfaceFree(iface);
3462
 
    return 0;
3463
 
}
3464
 
 
3465
 
static int
3466
 
remoteDispatchInterfaceCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
 
4393
                                 remote_interface_define_xml_args *args,
 
4394
                                 remote_interface_define_xml_ret *ret)
 
4395
{
 
4396
    virInterfacePtr iface = NULL;
 
4397
    int rv = -1;
 
4398
 
 
4399
    if (!conn) {
 
4400
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4401
        goto cleanup;
 
4402
    }
 
4403
 
 
4404
    if (!(iface = virInterfaceDefineXML(conn, args->xml, args->flags)))
 
4405
        goto cleanup;
 
4406
 
 
4407
    make_nonnull_interface(&ret->iface, iface);
 
4408
 
 
4409
    rv = 0;
 
4410
 
 
4411
cleanup:
 
4412
    if (rv < 0)
 
4413
        remoteDispatchError(rerr);
 
4414
    if (iface)
 
4415
        virInterfaceFree(iface);
 
4416
    return rv;
 
4417
}
 
4418
 
 
4419
static int
 
4420
remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4421
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
4422
                                virConnectPtr conn,
 
4423
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4424
                                remote_error *rerr,
 
4425
                                remote_interface_undefine_args *args,
 
4426
                                void *ret ATTRIBUTE_UNUSED)
 
4427
{
 
4428
    virInterfacePtr iface = NULL;
 
4429
    int rv = -1;
 
4430
 
 
4431
    if (!conn) {
 
4432
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4433
        goto cleanup;
 
4434
    }
 
4435
 
 
4436
    if (!(iface = get_nonnull_interface(conn, args->iface)))
 
4437
        goto cleanup;
 
4438
 
 
4439
    if (virInterfaceUndefine(iface) < 0)
 
4440
        goto cleanup;
 
4441
 
 
4442
    rv = 0;
 
4443
 
 
4444
cleanup:
 
4445
    if (rv < 0)
 
4446
        remoteDispatchError(rerr);
 
4447
    if (iface)
 
4448
        virInterfaceFree(iface);
 
4449
    return rv;
 
4450
}
 
4451
 
 
4452
static int
 
4453
remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
 
4454
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
4455
                              virConnectPtr conn,
 
4456
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4457
                              remote_error *rerr,
 
4458
                              remote_interface_create_args *args,
 
4459
                              void *ret ATTRIBUTE_UNUSED)
 
4460
{
 
4461
    virInterfacePtr iface = NULL;
 
4462
    int rv = -1;
 
4463
 
 
4464
    if (!conn) {
 
4465
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4466
        goto cleanup;
 
4467
    }
 
4468
 
 
4469
    if (!(iface = get_nonnull_interface(conn, args->iface)))
 
4470
        goto cleanup;
 
4471
 
 
4472
    if (virInterfaceCreate(iface, args->flags) < 0)
 
4473
        goto cleanup;
 
4474
 
 
4475
    rv = 0;
 
4476
 
 
4477
cleanup:
 
4478
    if (rv < 0)
 
4479
        remoteDispatchError(rerr);
 
4480
    if (iface)
 
4481
        virInterfaceFree(iface);
 
4482
    return rv;
 
4483
}
 
4484
 
 
4485
static int
 
4486
remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
3467
4487
                               struct qemud_client *client ATTRIBUTE_UNUSED,
3468
4488
                               virConnectPtr conn,
3469
4489
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
3470
4490
                               remote_error *rerr,
3471
 
                               remote_interface_create_args *args,
 
4491
                               remote_interface_destroy_args *args,
3472
4492
                               void *ret ATTRIBUTE_UNUSED)
3473
4493
{
3474
 
    virInterfacePtr iface;
3475
 
 
3476
 
    iface = get_nonnull_interface (conn, args->iface);
3477
 
    if (iface == NULL) {
3478
 
        remoteDispatchConnError(rerr, conn);
3479
 
        return -1;
3480
 
    }
3481
 
 
3482
 
    if (virInterfaceCreate (iface, args->flags) == -1) {
3483
 
        virInterfaceFree(iface);
3484
 
        remoteDispatchConnError(rerr, conn);
3485
 
        return -1;
3486
 
    }
3487
 
    virInterfaceFree(iface);
3488
 
    return 0;
3489
 
}
3490
 
 
3491
 
static int
3492
 
remoteDispatchInterfaceDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
3493
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
3494
 
                                virConnectPtr conn,
3495
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
3496
 
                                remote_error *rerr,
3497
 
                                remote_interface_destroy_args *args,
3498
 
                                void *ret ATTRIBUTE_UNUSED)
3499
 
{
3500
 
    virInterfacePtr iface;
3501
 
 
3502
 
    iface = get_nonnull_interface (conn, args->iface);
3503
 
    if (iface == NULL) {
3504
 
        remoteDispatchConnError(rerr, conn);
3505
 
        return -1;
3506
 
    }
3507
 
 
3508
 
    if (virInterfaceDestroy (iface, args->flags) == -1) {
3509
 
        virInterfaceFree(iface);
3510
 
        remoteDispatchConnError(rerr, conn);
3511
 
        return -1;
3512
 
    }
3513
 
    virInterfaceFree(iface);
3514
 
    return 0;
 
4494
    virInterfacePtr iface = NULL;
 
4495
    int rv = -1;
 
4496
 
 
4497
    if (!conn) {
 
4498
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
4499
        goto cleanup;
 
4500
    }
 
4501
 
 
4502
    if (!(iface = get_nonnull_interface(conn, args->iface)))
 
4503
        goto cleanup;
 
4504
 
 
4505
    if (virInterfaceDestroy(iface, args->flags) < 0)
 
4506
        goto cleanup;
 
4507
 
 
4508
    rv = 0;
 
4509
 
 
4510
cleanup:
 
4511
    if (rv < 0)
 
4512
        remoteDispatchError(rerr);
 
4513
    if (iface)
 
4514
        virInterfaceFree(iface);
 
4515
    return rv;
3515
4516
}
3516
4517
 
3517
4518
/*-------------------------------------------------------------*/
3518
4519
 
3519
4520
static int
3520
 
remoteDispatchAuthList (struct qemud_server *server,
3521
 
                        struct qemud_client *client,
3522
 
                        virConnectPtr conn ATTRIBUTE_UNUSED,
3523
 
                        remote_message_header *hdr ATTRIBUTE_UNUSED,
3524
 
                        remote_error *rerr,
3525
 
                        void *args ATTRIBUTE_UNUSED,
3526
 
                        remote_auth_list_ret *ret)
 
4521
remoteDispatchAuthList(struct qemud_server *server,
 
4522
                       struct qemud_client *client,
 
4523
                       virConnectPtr conn ATTRIBUTE_UNUSED,
 
4524
                       remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4525
                       remote_error *rerr,
 
4526
                       void *args ATTRIBUTE_UNUSED,
 
4527
                       remote_auth_list_ret *ret)
3527
4528
{
 
4529
    int rv = -1;
 
4530
 
3528
4531
    ret->types.types_len = 1;
3529
4532
    if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
3530
 
        remoteDispatchOOMError(rerr);
3531
 
        return -1;
 
4533
        virReportOOMError();
 
4534
        goto cleanup;
3532
4535
    }
3533
4536
    virMutexLock(&server->lock);
3534
4537
    virMutexLock(&client->lock);
3536
4539
    ret->types.types_val[0] = client->auth;
3537
4540
    virMutexUnlock(&client->lock);
3538
4541
 
3539
 
    return 0;
 
4542
    rv = 0;
 
4543
 
 
4544
cleanup:
 
4545
    if (rv < 0)
 
4546
        remoteDispatchError(rerr);
 
4547
    return rv;
3540
4548
}
3541
4549
 
3542
4550
 
3548
4556
 * XXX callbacks for stuff like password verification ?
3549
4557
 */
3550
4558
static int
3551
 
remoteDispatchAuthSaslInit (struct qemud_server *server,
3552
 
                            struct qemud_client *client,
3553
 
                            virConnectPtr conn,
3554
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
3555
 
                            remote_error *rerr,
3556
 
                            void *args ATTRIBUTE_UNUSED,
3557
 
                            remote_auth_sasl_init_ret *ret)
 
4559
remoteDispatchAuthSaslInit(struct qemud_server *server,
 
4560
                           struct qemud_client *client,
 
4561
                           virConnectPtr conn ATTRIBUTE_UNUSED,
 
4562
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4563
                           remote_error *rerr,
 
4564
                           void *args ATTRIBUTE_UNUSED,
 
4565
                           remote_auth_sasl_init_ret *ret)
3558
4566
{
3559
4567
    const char *mechlist = NULL;
3560
4568
    sasl_security_properties_t secprops;
3566
4574
    virMutexLock(&client->lock);
3567
4575
    virMutexUnlock(&server->lock);
3568
4576
 
3569
 
    REMOTE_DEBUG("Initialize SASL auth %d", client->fd);
 
4577
    VIR_DEBUG("Initialize SASL auth %d", client->fd);
3570
4578
    if (client->auth != REMOTE_AUTH_SASL ||
3571
4579
        client->saslconn != NULL) {
3572
4580
        VIR_ERROR0(_("client tried invalid SASL init request"));
3577
4585
    sa.len = sizeof(sa.data.stor);
3578
4586
    if (getsockname(client->fd, &sa.data.sa, &sa.len) < 0) {
3579
4587
        char ebuf[1024];
3580
 
        remoteDispatchFormatError(rerr,
3581
 
                                  _("failed to get sock address: %s"),
3582
 
                                  virStrerror(errno, ebuf, sizeof ebuf));
3583
 
        goto error;
3584
 
    }
3585
 
    if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
3586
 
        remoteDispatchConnError(rerr, conn);
3587
 
        goto error;
3588
 
    }
 
4588
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
4589
                    _("failed to get sock address: %s"),
 
4590
                    virStrerror(errno, ebuf, sizeof ebuf));
 
4591
        goto error;
 
4592
    }
 
4593
    if ((localAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL)
 
4594
        goto error;
3589
4595
 
3590
4596
    /* Get remote address in form  IPADDR:PORT */
3591
4597
    sa.len = sizeof(sa.data.stor);
3592
4598
    if (getpeername(client->fd, &sa.data.sa, &sa.len) < 0) {
3593
4599
        char ebuf[1024];
3594
 
        remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
3595
 
                                  virStrerror(errno, ebuf, sizeof ebuf));
 
4600
        virNetError(VIR_ERR_INTERNAL_ERROR, _("failed to get peer address: %s"),
 
4601
                    virStrerror(errno, ebuf, sizeof ebuf));
3596
4602
        VIR_FREE(localAddr);
3597
4603
        goto error;
3598
4604
    }
3599
4605
    if ((remoteAddr = virSocketFormatAddrFull(&sa, true, ";")) == NULL) {
3600
4606
        VIR_FREE(localAddr);
3601
 
        remoteDispatchConnError(rerr, conn);
3602
4607
        goto error;
3603
4608
    }
3604
4609
 
3643
4648
        }
3644
4649
    }
3645
4650
 
3646
 
    memset (&secprops, 0, sizeof secprops);
 
4651
    memset(&secprops, 0, sizeof secprops);
3647
4652
    if (client->type == QEMUD_SOCK_TYPE_TLS ||
3648
4653
        client->type == QEMUD_SOCK_TYPE_UNIX) {
3649
4654
        /* If we've got TLS or UNIX domain sock, we don't care about SSF */
3685
4690
        client->saslconn = NULL;
3686
4691
        goto authfail;
3687
4692
    }
3688
 
    REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist);
 
4693
    VIR_DEBUG("Available mechanisms for client: '%s'", mechlist);
3689
4694
    ret->mechlist = strdup(mechlist);
3690
4695
    if (!ret->mechlist) {
3691
4696
        VIR_ERROR0(_("cannot allocate mechlist"));
3711
4716
 * Returns 0 if ok, -1 on error, -2 if rejected
3712
4717
 */
3713
4718
static int
3714
 
remoteSASLCheckSSF (struct qemud_client *client,
3715
 
                    remote_error *rerr) {
 
4719
remoteSASLCheckSSF(struct qemud_client *client,
 
4720
                   remote_error *rerr) {
3716
4721
    const void *val;
3717
4722
    int err, ssf;
3718
4723
 
3730
4735
        return -1;
3731
4736
    }
3732
4737
    ssf = *(const int *)val;
3733
 
    REMOTE_DEBUG("negotiated an SSF of %d", ssf);
 
4738
    VIR_DEBUG("negotiated an SSF of %d", ssf);
3734
4739
    if (ssf < 56) { /* 56 is good for Kerberos */
3735
4740
        VIR_ERROR(_("negotiated SSF %d was not strong enough"), ssf);
3736
4741
        remoteDispatchAuthError(rerr);
3755
4760
 * Returns 0 if ok, -1 on error, -2 if rejected
3756
4761
 */
3757
4762
static int
3758
 
remoteSASLCheckAccess (struct qemud_server *server,
3759
 
                       struct qemud_client *client,
3760
 
                       remote_error *rerr) {
 
4763
remoteSASLCheckAccess(struct qemud_server *server,
 
4764
                      struct qemud_client *client,
 
4765
                      remote_error *rerr) {
3761
4766
    const void *val;
3762
4767
    int err;
3763
4768
    char **wildcards;
3778
4783
        client->saslconn = NULL;
3779
4784
        return -1;
3780
4785
    }
3781
 
    REMOTE_DEBUG("SASL client username %s", (const char *)val);
 
4786
    VIR_DEBUG("SASL client username %s", (const char *)val);
3782
4787
 
3783
4788
    client->saslUsername = strdup((const char*)val);
3784
4789
    if (client->saslUsername == NULL) {
3795
4800
        return 0; /* No ACL, allow all */
3796
4801
 
3797
4802
    while (*wildcards) {
3798
 
        if (fnmatch (*wildcards, client->saslUsername, 0) == 0)
 
4803
        if (fnmatch(*wildcards, client->saslUsername, 0) == 0)
3799
4804
            return 0; /* Allowed */
3800
4805
        wildcards++;
3801
4806
    }
3813
4818
 * This starts the SASL authentication negotiation.
3814
4819
 */
3815
4820
static int
3816
 
remoteDispatchAuthSaslStart (struct qemud_server *server,
3817
 
                             struct qemud_client *client,
3818
 
                             virConnectPtr conn ATTRIBUTE_UNUSED,
3819
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
3820
 
                             remote_error *rerr,
3821
 
                             remote_auth_sasl_start_args *args,
3822
 
                             remote_auth_sasl_start_ret *ret)
 
4821
remoteDispatchAuthSaslStart(struct qemud_server *server,
 
4822
                            struct qemud_client *client,
 
4823
                            virConnectPtr conn ATTRIBUTE_UNUSED,
 
4824
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4825
                            remote_error *rerr,
 
4826
                            remote_auth_sasl_start_args *args,
 
4827
                            remote_auth_sasl_start_ret *ret)
3823
4828
{
3824
4829
    const char *serverout;
3825
4830
    unsigned int serveroutlen;
3829
4834
    virMutexLock(&client->lock);
3830
4835
    virMutexUnlock(&server->lock);
3831
4836
 
3832
 
    REMOTE_DEBUG("Start SASL auth %d", client->fd);
 
4837
    VIR_DEBUG("Start SASL auth %d", client->fd);
3833
4838
    if (client->auth != REMOTE_AUTH_SASL ||
3834
4839
        client->saslconn == NULL) {
3835
4840
        VIR_ERROR0(_("client tried invalid SASL start request"));
3836
4841
        goto authfail;
3837
4842
    }
3838
4843
 
3839
 
    REMOTE_DEBUG("Using SASL mechanism %s. Data %d bytes, nil: %d",
3840
 
                 args->mech, args->data.data_len, args->nil);
 
4844
    VIR_DEBUG("Using SASL mechanism %s. Data %d bytes, nil: %d",
 
4845
              args->mech, args->data.data_len, args->nil);
3841
4846
    err = sasl_server_start(client->saslconn,
3842
4847
                            args->mech,
3843
4848
                            /* NB, distinction of NULL vs "" is *critical* in SASL */
3863
4868
    /* NB, distinction of NULL vs "" is *critical* in SASL */
3864
4869
    if (serverout) {
3865
4870
        if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
3866
 
            remoteDispatchOOMError(rerr);
 
4871
            virReportOOMError();
 
4872
            remoteDispatchError(rerr);
3867
4873
            goto error;
3868
4874
        }
3869
4875
        memcpy(ret->data.data_val, serverout, serveroutlen);
3873
4879
    ret->nil = serverout ? 0 : 1;
3874
4880
    ret->data.data_len = serveroutlen;
3875
4881
 
3876
 
    REMOTE_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
 
4882
    VIR_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
3877
4883
    if (err == SASL_CONTINUE) {
3878
4884
        ret->complete = 0;
3879
4885
    } else {
3886
4892
                goto authfail;
3887
4893
        }
3888
4894
 
3889
 
        REMOTE_DEBUG("Authentication successful %d", client->fd);
 
4895
        VIR_DEBUG("Authentication successful %d", client->fd);
3890
4896
        PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
3891
4897
              client->fd, REMOTE_AUTH_SASL, client->saslUsername);
3892
4898
        ret->complete = 1;
3913
4919
 
3914
4920
 
3915
4921
static int
3916
 
remoteDispatchAuthSaslStep (struct qemud_server *server,
3917
 
                            struct qemud_client *client,
3918
 
                            virConnectPtr conn ATTRIBUTE_UNUSED,
3919
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
3920
 
                            remote_error *rerr,
3921
 
                            remote_auth_sasl_step_args *args,
3922
 
                            remote_auth_sasl_step_ret *ret)
 
4922
remoteDispatchAuthSaslStep(struct qemud_server *server,
 
4923
                           struct qemud_client *client,
 
4924
                           virConnectPtr conn ATTRIBUTE_UNUSED,
 
4925
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
4926
                           remote_error *rerr,
 
4927
                           remote_auth_sasl_step_args *args,
 
4928
                           remote_auth_sasl_step_ret *ret)
3923
4929
{
3924
4930
    const char *serverout;
3925
4931
    unsigned int serveroutlen;
3929
4935
    virMutexLock(&client->lock);
3930
4936
    virMutexUnlock(&server->lock);
3931
4937
 
3932
 
    REMOTE_DEBUG("Step SASL auth %d", client->fd);
 
4938
    VIR_DEBUG("Step SASL auth %d", client->fd);
3933
4939
    if (client->auth != REMOTE_AUTH_SASL ||
3934
4940
        client->saslconn == NULL) {
3935
4941
        VIR_ERROR0(_("client tried invalid SASL start request"));
3936
4942
        goto authfail;
3937
4943
    }
3938
4944
 
3939
 
    REMOTE_DEBUG("Using SASL Data %d bytes, nil: %d",
3940
 
                 args->data.data_len, args->nil);
 
4945
    VIR_DEBUG("Using SASL Data %d bytes, nil: %d",
 
4946
              args->data.data_len, args->nil);
3941
4947
    err = sasl_server_step(client->saslconn,
3942
4948
                           /* NB, distinction of NULL vs "" is *critical* in SASL */
3943
4949
                           args->nil ? NULL : args->data.data_val,
3964
4970
    /* NB, distinction of NULL vs "" is *critical* in SASL */
3965
4971
    if (serverout) {
3966
4972
        if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
3967
 
            remoteDispatchOOMError(rerr);
 
4973
            virReportOOMError();
 
4974
            remoteDispatchError(rerr);
3968
4975
            goto error;
3969
4976
        }
3970
4977
        memcpy(ret->data.data_val, serverout, serveroutlen);
3974
4981
    ret->nil = serverout ? 0 : 1;
3975
4982
    ret->data.data_len = serveroutlen;
3976
4983
 
3977
 
    REMOTE_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
 
4984
    VIR_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
3978
4985
    if (err == SASL_CONTINUE) {
3979
4986
        ret->complete = 0;
3980
4987
    } else {
3987
4994
                goto authfail;
3988
4995
        }
3989
4996
 
3990
 
        REMOTE_DEBUG("Authentication successful %d", client->fd);
 
4997
        VIR_DEBUG("Authentication successful %d", client->fd);
3991
4998
        PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
3992
4999
              client->fd, REMOTE_AUTH_SASL, client->saslUsername);
3993
5000
        ret->complete = 1;
4015
5022
 
4016
5023
#else /* HAVE_SASL */
4017
5024
static int
4018
 
remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
4019
 
                            struct qemud_client *client ATTRIBUTE_UNUSED,
4020
 
                            virConnectPtr conn ATTRIBUTE_UNUSED,
4021
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
4022
 
                            remote_error *rerr,
4023
 
                            void *args ATTRIBUTE_UNUSED,
4024
 
                            remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
 
5025
remoteDispatchAuthSaslInit(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5026
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
5027
                           virConnectPtr conn ATTRIBUTE_UNUSED,
 
5028
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5029
                           remote_error *rerr,
 
5030
                           void *args ATTRIBUTE_UNUSED,
 
5031
                           remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
4025
5032
{
4026
5033
    VIR_ERROR0(_("client tried unsupported SASL init request"));
4027
5034
    PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
4030
5037
}
4031
5038
 
4032
5039
static int
4033
 
remoteDispatchAuthSaslStart (struct qemud_server *server ATTRIBUTE_UNUSED,
4034
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
4035
 
                             virConnectPtr conn ATTRIBUTE_UNUSED,
4036
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
4037
 
                             remote_error *rerr,
4038
 
                             remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
4039
 
                             remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
 
5040
remoteDispatchAuthSaslStart(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5041
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
5042
                            virConnectPtr conn ATTRIBUTE_UNUSED,
 
5043
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5044
                            remote_error *rerr,
 
5045
                            remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
 
5046
                            remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
4040
5047
{
4041
5048
    VIR_ERROR0(_("client tried unsupported SASL start request"));
4042
5049
    PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
4045
5052
}
4046
5053
 
4047
5054
static int
4048
 
remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
4049
 
                            struct qemud_client *client ATTRIBUTE_UNUSED,
4050
 
                            virConnectPtr conn ATTRIBUTE_UNUSED,
4051
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
4052
 
                            remote_error *rerr,
4053
 
                            remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
4054
 
                            remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
 
5055
remoteDispatchAuthSaslStep(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5056
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
5057
                           virConnectPtr conn ATTRIBUTE_UNUSED,
 
5058
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5059
                           remote_error *rerr,
 
5060
                           remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
 
5061
                           remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
4055
5062
{
4056
5063
    VIR_ERROR0(_("client tried unsupported SASL step request"));
4057
5064
    PROBE(CLIENT_AUTH_FAIL, "fd=%d, auth=%d", client->fd, REMOTE_AUTH_SASL);
4063
5070
 
4064
5071
#if HAVE_POLKIT1
4065
5072
static int
4066
 
remoteDispatchAuthPolkit (struct qemud_server *server,
4067
 
                          struct qemud_client *client,
4068
 
                          virConnectPtr conn ATTRIBUTE_UNUSED,
4069
 
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
4070
 
                          remote_error *rerr,
4071
 
                          void *args ATTRIBUTE_UNUSED,
4072
 
                          remote_auth_polkit_ret *ret)
 
5073
remoteDispatchAuthPolkit(struct qemud_server *server,
 
5074
                         struct qemud_client *client,
 
5075
                         virConnectPtr conn ATTRIBUTE_UNUSED,
 
5076
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5077
                         remote_error *rerr,
 
5078
                         void *args ATTRIBUTE_UNUSED,
 
5079
                         remote_auth_polkit_ret *ret)
4073
5080
{
4074
5081
    pid_t callerPid = -1;
4075
5082
    uid_t callerUid = -1;
4097
5104
      NULL
4098
5105
    };
4099
5106
 
4100
 
    REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
 
5107
    VIR_DEBUG("Start PolicyKit auth %d", client->fd);
4101
5108
    if (client->auth != REMOTE_AUTH_POLKIT) {
4102
5109
        VIR_ERROR0(_("client tried invalid PolicyKit init request"));
4103
5110
        goto authfail;
4127
5134
        goto authfail;
4128
5135
    }
4129
5136
    if (status != 0) {
4130
 
        VIR_ERROR(_("Policy kit denied action %s from pid %d, uid %d, result: %d"),
4131
 
                  action, callerPid, callerUid, status);
 
5137
        char *tmp = virCommandTranslateStatus(status);
 
5138
        VIR_ERROR(_("Policy kit denied action %s from pid %d, uid %d: %s"),
 
5139
                  action, callerPid, callerUid, NULLSTR(tmp));
 
5140
        VIR_FREE(tmp);
4132
5141
        goto authdeny;
4133
5142
    }
4134
5143
    PROBE(CLIENT_AUTH_ALLOW, "fd=%d, auth=%d, username=%s",
4157
5166
}
4158
5167
#elif HAVE_POLKIT0
4159
5168
static int
4160
 
remoteDispatchAuthPolkit (struct qemud_server *server,
4161
 
                          struct qemud_client *client,
4162
 
                          virConnectPtr conn ATTRIBUTE_UNUSED,
4163
 
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
4164
 
                          remote_error *rerr,
4165
 
                          void *args ATTRIBUTE_UNUSED,
4166
 
                          remote_auth_polkit_ret *ret)
 
5169
remoteDispatchAuthPolkit(struct qemud_server *server,
 
5170
                         struct qemud_client *client,
 
5171
                         virConnectPtr conn ATTRIBUTE_UNUSED,
 
5172
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5173
                         remote_error *rerr,
 
5174
                         void *args ATTRIBUTE_UNUSED,
 
5175
                         remote_auth_polkit_ret *ret)
4167
5176
{
4168
5177
    pid_t callerPid;
4169
5178
    uid_t callerUid;
4187
5196
        "org.libvirt.unix.monitor" :
4188
5197
        "org.libvirt.unix.manage";
4189
5198
 
4190
 
    REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
 
5199
    VIR_DEBUG("Start PolicyKit auth %d", client->fd);
4191
5200
    if (client->auth != REMOTE_AUTH_POLKIT) {
4192
5201
        VIR_ERROR0(_("client tried invalid PolicyKit init request"));
4193
5202
        goto authfail;
4291
5300
#else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
4292
5301
 
4293
5302
static int
4294
 
remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
4295
 
                          struct qemud_client *client ATTRIBUTE_UNUSED,
4296
 
                          virConnectPtr conn ATTRIBUTE_UNUSED,
4297
 
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
4298
 
                          remote_error *rerr,
4299
 
                          void *args ATTRIBUTE_UNUSED,
4300
 
                          remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
 
5303
remoteDispatchAuthPolkit(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5304
                         struct qemud_client *client ATTRIBUTE_UNUSED,
 
5305
                         virConnectPtr conn ATTRIBUTE_UNUSED,
 
5306
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5307
                         remote_error *rerr,
 
5308
                         void *args ATTRIBUTE_UNUSED,
 
5309
                         remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
4301
5310
{
4302
5311
    VIR_ERROR0(_("client tried unsupported PolicyKit init request"));
4303
5312
    remoteDispatchAuthError(rerr);
4312
5321
 
4313
5322
 
4314
5323
static int
4315
 
remoteDispatchListDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
4316
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4317
 
                                       virConnectPtr conn,
4318
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4319
 
                                       remote_error *rerr,
4320
 
                                       remote_list_defined_storage_pools_args *args,
4321
 
                                       remote_list_defined_storage_pools_ret *ret)
 
5324
remoteDispatchListDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5325
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
5326
                                      virConnectPtr conn,
 
5327
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5328
                                      remote_error *rerr,
 
5329
                                      remote_list_defined_storage_pools_args *args,
 
5330
                                      remote_list_defined_storage_pools_ret *ret)
4322
5331
{
 
5332
    int rv = -1;
 
5333
    int len;
 
5334
 
 
5335
    if (!conn) {
 
5336
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5337
        goto cleanup;
 
5338
    }
4323
5339
 
4324
5340
    if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
4325
 
        remoteDispatchFormatError (rerr, "%s",
4326
 
                            _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
4327
 
        return -1;
 
5341
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
 
5342
                    _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
 
5343
        goto cleanup;
4328
5344
    }
4329
5345
 
4330
5346
    /* Allocate return buffer. */
4331
5347
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
4332
 
        remoteDispatchOOMError(rerr);
4333
 
        return -1;
 
5348
        virReportOOMError();
 
5349
        goto cleanup;
4334
5350
    }
4335
5351
 
4336
 
    ret->names.names_len =
4337
 
        virConnectListDefinedStoragePools (conn,
4338
 
                                           ret->names.names_val, args->maxnames);
4339
 
    if (ret->names.names_len == -1) {
 
5352
    len = virConnectListDefinedStoragePools(conn,
 
5353
                                            ret->names.names_val, args->maxnames);
 
5354
    if (len < 0)
 
5355
        goto cleanup;
 
5356
    ret->names.names_len = len;
 
5357
 
 
5358
    rv = 0;
 
5359
 
 
5360
cleanup:
 
5361
    if (rv < 0) {
 
5362
        remoteDispatchError(rerr);
4340
5363
        VIR_FREE(ret->names.names_val);
4341
 
        remoteDispatchConnError(rerr, conn);
4342
 
        return -1;
4343
5364
    }
4344
 
 
4345
 
    return 0;
 
5365
    return rv;
4346
5366
}
4347
5367
 
4348
5368
static int
4349
 
remoteDispatchListStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
4350
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
4351
 
                                virConnectPtr conn,
4352
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
4353
 
                                remote_error *rerr,
4354
 
                                remote_list_storage_pools_args *args,
4355
 
                                remote_list_storage_pools_ret *ret)
 
5369
remoteDispatchListStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5370
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
5371
                               virConnectPtr conn,
 
5372
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5373
                               remote_error *rerr,
 
5374
                               remote_list_storage_pools_args *args,
 
5375
                               remote_list_storage_pools_ret *ret)
4356
5376
{
 
5377
    int rv = -1;
 
5378
    int len;
 
5379
 
 
5380
    if (!conn) {
 
5381
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5382
        goto cleanup;
 
5383
    }
4357
5384
 
4358
5385
    if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
4359
 
        remoteDispatchFormatError (rerr,
4360
 
                                   "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
4361
 
        return -1;
 
5386
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
5387
                    "%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
 
5388
        goto cleanup;
4362
5389
    }
4363
5390
 
4364
5391
    /* Allocate return buffer. */
4365
5392
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
4366
 
        remoteDispatchOOMError(rerr);
4367
 
        return -1;
 
5393
        virReportOOMError();
 
5394
        goto cleanup;
4368
5395
    }
4369
5396
 
4370
 
    ret->names.names_len =
4371
 
        virConnectListStoragePools (conn,
4372
 
                                ret->names.names_val, args->maxnames);
4373
 
    if (ret->names.names_len == -1) {
 
5397
    len = virConnectListStoragePools(conn,
 
5398
                                     ret->names.names_val, args->maxnames);
 
5399
    if (len < 0)
 
5400
        goto cleanup;
 
5401
    ret->names.names_len = len;
 
5402
 
 
5403
    rv = 0;
 
5404
 
 
5405
cleanup:
 
5406
    if (rv < 0) {
 
5407
        remoteDispatchError(rerr);
4374
5408
        VIR_FREE(ret->names.names_val);
4375
 
        remoteDispatchConnError(rerr, conn);
4376
 
        return -1;
4377
 
    }
4378
 
 
4379
 
    return 0;
4380
 
}
4381
 
 
4382
 
static int
4383
 
remoteDispatchFindStoragePoolSources (struct qemud_server *server ATTRIBUTE_UNUSED,
4384
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
4385
 
                                      virConnectPtr conn,
4386
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
4387
 
                                      remote_error *rerr,
4388
 
                                      remote_find_storage_pool_sources_args *args,
4389
 
                                      remote_find_storage_pool_sources_ret *ret)
4390
 
{
4391
 
    ret->xml =
4392
 
        virConnectFindStoragePoolSources (conn,
4393
 
                                          args->type,
4394
 
                                          args->srcSpec ? *args->srcSpec : NULL,
4395
 
                                          args->flags);
4396
 
    if (ret->xml == NULL) {
4397
 
        remoteDispatchConnError(rerr, conn);
4398
 
        return -1;
4399
 
    }
4400
 
 
4401
 
    return 0;
4402
 
}
4403
 
 
4404
 
 
4405
 
static int
4406
 
remoteDispatchStoragePoolCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
4407
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
4408
 
                                 virConnectPtr conn,
4409
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
4410
 
                                 remote_error *rerr,
4411
 
                                 remote_storage_pool_create_args *args,
4412
 
                                 void *ret ATTRIBUTE_UNUSED)
4413
 
{
4414
 
    virStoragePoolPtr pool;
4415
 
 
4416
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4417
 
    if (pool == NULL) {
4418
 
        remoteDispatchConnError(rerr, conn);
4419
 
        return -1;
4420
 
    }
4421
 
 
4422
 
    if (virStoragePoolCreate (pool, args->flags) == -1) {
4423
 
        virStoragePoolFree(pool);
4424
 
        remoteDispatchConnError(rerr, conn);
4425
 
        return -1;
4426
 
    }
4427
 
    virStoragePoolFree(pool);
4428
 
    return 0;
4429
 
}
4430
 
 
4431
 
static int
4432
 
remoteDispatchStoragePoolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
4433
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
4434
 
                                    virConnectPtr conn,
4435
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
4436
 
                                    remote_error *rerr,
4437
 
                                    remote_storage_pool_create_xml_args *args,
4438
 
                                    remote_storage_pool_create_xml_ret *ret)
4439
 
{
4440
 
    virStoragePoolPtr pool;
4441
 
 
4442
 
    pool = virStoragePoolCreateXML (conn, args->xml, args->flags);
4443
 
    if (pool == NULL) {
4444
 
        remoteDispatchConnError(rerr, conn);
4445
 
        return -1;
4446
 
    }
4447
 
 
4448
 
    make_nonnull_storage_pool (&ret->pool, pool);
4449
 
    virStoragePoolFree(pool);
4450
 
    return 0;
4451
 
}
4452
 
 
4453
 
static int
4454
 
remoteDispatchStoragePoolDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
4455
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
4456
 
                                    virConnectPtr conn,
4457
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
4458
 
                                    remote_error *rerr,
4459
 
                                    remote_storage_pool_define_xml_args *args,
4460
 
                                    remote_storage_pool_define_xml_ret *ret)
4461
 
{
4462
 
    virStoragePoolPtr pool;
4463
 
 
4464
 
    pool = virStoragePoolDefineXML (conn, args->xml, args->flags);
4465
 
    if (pool == NULL) {
4466
 
        remoteDispatchConnError(rerr, conn);
4467
 
        return -1;
4468
 
    }
4469
 
 
4470
 
    make_nonnull_storage_pool (&ret->pool, pool);
4471
 
    virStoragePoolFree(pool);
4472
 
    return 0;
4473
 
}
4474
 
 
4475
 
static int
4476
 
remoteDispatchStoragePoolBuild (struct qemud_server *server ATTRIBUTE_UNUSED,
4477
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
4478
 
                                virConnectPtr conn,
4479
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
4480
 
                                remote_error *rerr,
4481
 
                                remote_storage_pool_build_args *args,
4482
 
                                void *ret ATTRIBUTE_UNUSED)
4483
 
{
4484
 
    virStoragePoolPtr pool;
4485
 
 
4486
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4487
 
    if (pool == NULL) {
4488
 
        remoteDispatchConnError(rerr, conn);
4489
 
        return -1;
4490
 
    }
4491
 
 
4492
 
    if (virStoragePoolBuild (pool, args->flags) == -1) {
4493
 
        virStoragePoolFree(pool);
4494
 
        remoteDispatchConnError(rerr, conn);
4495
 
        return -1;
4496
 
    }
4497
 
    virStoragePoolFree(pool);
4498
 
    return 0;
4499
 
}
4500
 
 
4501
 
 
4502
 
static int
4503
 
remoteDispatchStoragePoolDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
4504
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
4505
 
                                  virConnectPtr conn,
4506
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
4507
 
                                  remote_error *rerr,
4508
 
                                  remote_storage_pool_destroy_args *args,
4509
 
                                  void *ret ATTRIBUTE_UNUSED)
4510
 
{
4511
 
    virStoragePoolPtr pool;
4512
 
 
4513
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4514
 
    if (pool == NULL) {
4515
 
        remoteDispatchConnError(rerr, conn);
4516
 
        return -1;
4517
 
    }
4518
 
 
4519
 
    if (virStoragePoolDestroy (pool) == -1) {
4520
 
        virStoragePoolFree(pool);
4521
 
        remoteDispatchConnError(rerr, conn);
4522
 
        return -1;
4523
 
    }
4524
 
    virStoragePoolFree(pool);
4525
 
    return 0;
4526
 
}
4527
 
 
4528
 
static int
4529
 
remoteDispatchStoragePoolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
4530
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
4531
 
                                 virConnectPtr conn,
4532
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
4533
 
                                 remote_error *rerr,
4534
 
                                 remote_storage_pool_delete_args *args,
4535
 
                                 void *ret ATTRIBUTE_UNUSED)
4536
 
{
4537
 
    virStoragePoolPtr pool;
4538
 
 
4539
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4540
 
    if (pool == NULL) {
4541
 
        remoteDispatchConnError(rerr, conn);
4542
 
        return -1;
4543
 
    }
4544
 
 
4545
 
    if (virStoragePoolDelete (pool, args->flags) == -1) {
4546
 
        virStoragePoolFree(pool);
4547
 
        remoteDispatchConnError(rerr, conn);
4548
 
        return -1;
4549
 
    }
4550
 
    virStoragePoolFree(pool);
4551
 
    return 0;
4552
 
}
4553
 
 
4554
 
static int
4555
 
remoteDispatchStoragePoolRefresh (struct qemud_server *server ATTRIBUTE_UNUSED,
4556
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
4557
 
                                  virConnectPtr conn,
4558
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
4559
 
                                  remote_error *rerr,
4560
 
                                  remote_storage_pool_refresh_args *args,
4561
 
                                  void *ret ATTRIBUTE_UNUSED)
4562
 
{
4563
 
    virStoragePoolPtr pool;
4564
 
 
4565
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4566
 
    if (pool == NULL) {
4567
 
        remoteDispatchConnError(rerr, conn);
4568
 
        return -1;
4569
 
    }
4570
 
 
4571
 
    if (virStoragePoolRefresh (pool, args->flags) == -1) {
4572
 
        virStoragePoolFree(pool);
4573
 
        remoteDispatchConnError(rerr, conn);
4574
 
        return -1;
4575
 
    }
4576
 
    virStoragePoolFree(pool);
4577
 
    return 0;
4578
 
}
4579
 
 
4580
 
static int
4581
 
remoteDispatchStoragePoolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
4582
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
4583
 
                                  virConnectPtr conn,
4584
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
4585
 
                                  remote_error *rerr,
4586
 
                                  remote_storage_pool_get_info_args *args,
4587
 
                                  remote_storage_pool_get_info_ret *ret)
4588
 
{
4589
 
    virStoragePoolPtr pool;
 
5409
    }
 
5410
    return rv;
 
5411
}
 
5412
 
 
5413
static int
 
5414
remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5415
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
5416
                                     virConnectPtr conn,
 
5417
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5418
                                     remote_error *rerr,
 
5419
                                     remote_find_storage_pool_sources_args *args,
 
5420
                                     remote_find_storage_pool_sources_ret *ret)
 
5421
{
 
5422
    int rv = -1;
 
5423
 
 
5424
    if (!conn) {
 
5425
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5426
        goto cleanup;
 
5427
    }
 
5428
 
 
5429
    if (!(ret->xml =
 
5430
          virConnectFindStoragePoolSources(conn,
 
5431
                                           args->type,
 
5432
                                           args->srcSpec ? *args->srcSpec : NULL,
 
5433
                                           args->flags)))
 
5434
        goto cleanup;
 
5435
 
 
5436
    rv = 0;
 
5437
 
 
5438
cleanup:
 
5439
    if (rv < 0)
 
5440
        remoteDispatchError(rerr);
 
5441
    return rv;
 
5442
}
 
5443
 
 
5444
 
 
5445
static int
 
5446
remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5447
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
5448
                                virConnectPtr conn,
 
5449
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5450
                                remote_error *rerr,
 
5451
                                remote_storage_pool_create_args *args,
 
5452
                                void *ret ATTRIBUTE_UNUSED)
 
5453
{
 
5454
    virStoragePoolPtr pool = NULL;
 
5455
    int rv = -1;
 
5456
 
 
5457
    if (!conn) {
 
5458
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5459
        goto cleanup;
 
5460
    }
 
5461
 
 
5462
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5463
        goto cleanup;
 
5464
 
 
5465
    if (virStoragePoolCreate(pool, args->flags) < 0)
 
5466
        goto cleanup;
 
5467
 
 
5468
    rv = 0;
 
5469
 
 
5470
cleanup:
 
5471
    if (rv < 0)
 
5472
        remoteDispatchError(rerr);
 
5473
    if (pool)
 
5474
        virStoragePoolFree(pool);
 
5475
    return rv;
 
5476
}
 
5477
 
 
5478
static int
 
5479
remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5480
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
5481
                                   virConnectPtr conn,
 
5482
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5483
                                   remote_error *rerr,
 
5484
                                   remote_storage_pool_create_xml_args *args,
 
5485
                                   remote_storage_pool_create_xml_ret *ret)
 
5486
{
 
5487
    virStoragePoolPtr pool = NULL;
 
5488
    int rv = -1;
 
5489
 
 
5490
    if (!conn) {
 
5491
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5492
        goto cleanup;
 
5493
    }
 
5494
 
 
5495
    if (!(pool = virStoragePoolCreateXML(conn, args->xml, args->flags)))
 
5496
        goto cleanup;
 
5497
 
 
5498
    make_nonnull_storage_pool(&ret->pool, pool);
 
5499
 
 
5500
    rv = 0;
 
5501
 
 
5502
cleanup:
 
5503
    if (rv < 0)
 
5504
        remoteDispatchError(rerr);
 
5505
    if (pool)
 
5506
        virStoragePoolFree(pool);
 
5507
    return rv;
 
5508
}
 
5509
 
 
5510
static int
 
5511
remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5512
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
5513
                                   virConnectPtr conn,
 
5514
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5515
                                   remote_error *rerr,
 
5516
                                   remote_storage_pool_define_xml_args *args,
 
5517
                                   remote_storage_pool_define_xml_ret *ret)
 
5518
{
 
5519
    virStoragePoolPtr pool = NULL;
 
5520
    int rv = -1;
 
5521
 
 
5522
    if (!conn) {
 
5523
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5524
        goto cleanup;
 
5525
    }
 
5526
 
 
5527
    if (!(pool = virStoragePoolDefineXML(conn, args->xml, args->flags)))
 
5528
        goto cleanup;
 
5529
 
 
5530
    make_nonnull_storage_pool(&ret->pool, pool);
 
5531
 
 
5532
    rv = 0;
 
5533
 
 
5534
cleanup:
 
5535
    if (rv < 0)
 
5536
        remoteDispatchError(rerr);
 
5537
    if (pool)
 
5538
        virStoragePoolFree(pool);
 
5539
    return rv;
 
5540
}
 
5541
 
 
5542
static int
 
5543
remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5544
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
5545
                               virConnectPtr conn,
 
5546
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5547
                               remote_error *rerr,
 
5548
                               remote_storage_pool_build_args *args,
 
5549
                               void *ret ATTRIBUTE_UNUSED)
 
5550
{
 
5551
    virStoragePoolPtr pool = NULL;
 
5552
    int rv = -1;
 
5553
 
 
5554
    if (!conn) {
 
5555
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5556
        goto cleanup;
 
5557
    }
 
5558
 
 
5559
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5560
        goto cleanup;
 
5561
 
 
5562
    if (virStoragePoolBuild(pool, args->flags) < 0)
 
5563
        goto cleanup;
 
5564
 
 
5565
    rv = 0;
 
5566
 
 
5567
cleanup:
 
5568
    if (rv < 0)
 
5569
        remoteDispatchError(rerr);
 
5570
    if (pool)
 
5571
        virStoragePoolFree(pool);
 
5572
    return rv;
 
5573
}
 
5574
 
 
5575
 
 
5576
static int
 
5577
remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5578
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
5579
                                 virConnectPtr conn,
 
5580
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5581
                                 remote_error *rerr,
 
5582
                                 remote_storage_pool_destroy_args *args,
 
5583
                                 void *ret ATTRIBUTE_UNUSED)
 
5584
{
 
5585
    virStoragePoolPtr pool = NULL;
 
5586
    int rv = -1;
 
5587
 
 
5588
    if (!conn) {
 
5589
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5590
        goto cleanup;
 
5591
    }
 
5592
 
 
5593
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5594
        goto cleanup;
 
5595
 
 
5596
    if (virStoragePoolDestroy(pool) < 0)
 
5597
        goto cleanup;
 
5598
 
 
5599
    rv = 0;
 
5600
 
 
5601
cleanup:
 
5602
    if (rv < 0)
 
5603
        remoteDispatchError(rerr);
 
5604
    if (pool)
 
5605
        virStoragePoolFree(pool);
 
5606
    return rv;
 
5607
}
 
5608
 
 
5609
static int
 
5610
remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5611
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
5612
                                virConnectPtr conn,
 
5613
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5614
                                remote_error *rerr,
 
5615
                                remote_storage_pool_delete_args *args,
 
5616
                                void *ret ATTRIBUTE_UNUSED)
 
5617
{
 
5618
    virStoragePoolPtr pool = NULL;
 
5619
    int rv = -1;
 
5620
 
 
5621
    if (!conn) {
 
5622
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5623
        goto cleanup;
 
5624
    }
 
5625
 
 
5626
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5627
        goto cleanup;
 
5628
 
 
5629
    if (virStoragePoolDelete(pool, args->flags) < 0)
 
5630
        goto cleanup;
 
5631
 
 
5632
    rv = 0;
 
5633
 
 
5634
cleanup:
 
5635
    if (rv < 0)
 
5636
        remoteDispatchError(rerr);
 
5637
    if (pool)
 
5638
        virStoragePoolFree(pool);
 
5639
    return rv;
 
5640
}
 
5641
 
 
5642
static int
 
5643
remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5644
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
5645
                                 virConnectPtr conn,
 
5646
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5647
                                 remote_error *rerr,
 
5648
                                 remote_storage_pool_refresh_args *args,
 
5649
                                 void *ret ATTRIBUTE_UNUSED)
 
5650
{
 
5651
    virStoragePoolPtr pool = NULL;
 
5652
    int rv = -1;
 
5653
 
 
5654
    if (!conn) {
 
5655
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5656
        goto cleanup;
 
5657
    }
 
5658
 
 
5659
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5660
        goto cleanup;
 
5661
 
 
5662
    if (virStoragePoolRefresh(pool, args->flags) < 0)
 
5663
        goto cleanup;
 
5664
 
 
5665
    rv = 0;
 
5666
 
 
5667
cleanup:
 
5668
    if (rv < 0)
 
5669
        remoteDispatchError(rerr);
 
5670
    if (pool)
 
5671
        virStoragePoolFree(pool);
 
5672
    return rv;
 
5673
}
 
5674
 
 
5675
static int
 
5676
remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5677
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
5678
                                 virConnectPtr conn,
 
5679
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5680
                                 remote_error *rerr,
 
5681
                                 remote_storage_pool_get_info_args *args,
 
5682
                                 remote_storage_pool_get_info_ret *ret)
 
5683
{
 
5684
    virStoragePoolPtr pool = NULL;
4590
5685
    virStoragePoolInfo info;
4591
 
 
4592
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4593
 
    if (pool == NULL) {
4594
 
        remoteDispatchConnError(rerr, conn);
4595
 
        return -1;
4596
 
    }
4597
 
 
4598
 
    if (virStoragePoolGetInfo (pool, &info) == -1) {
4599
 
        virStoragePoolFree(pool);
4600
 
        remoteDispatchConnError(rerr, conn);
4601
 
        return -1;
4602
 
    }
 
5686
    int rv = -1;
 
5687
 
 
5688
    if (!conn) {
 
5689
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5690
        goto cleanup;
 
5691
    }
 
5692
 
 
5693
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5694
        goto cleanup;
 
5695
 
 
5696
    if (virStoragePoolGetInfo(pool, &info) < 0)
 
5697
        goto cleanup;
4603
5698
 
4604
5699
    ret->state = info.state;
4605
5700
    ret->capacity = info.capacity;
4606
5701
    ret->allocation = info.allocation;
4607
5702
    ret->available = info.available;
4608
5703
 
4609
 
    virStoragePoolFree(pool);
4610
 
 
4611
 
    return 0;
4612
 
}
4613
 
 
4614
 
static int
4615
 
remoteDispatchStoragePoolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
4616
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
4617
 
                                  virConnectPtr conn,
4618
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
4619
 
                                  remote_error *rerr,
4620
 
                                  remote_storage_pool_dump_xml_args *args,
4621
 
                                  remote_storage_pool_dump_xml_ret *ret)
4622
 
{
4623
 
    virStoragePoolPtr pool;
4624
 
 
4625
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4626
 
    if (pool == NULL) {
4627
 
        remoteDispatchConnError(rerr, conn);
4628
 
        return -1;
4629
 
    }
4630
 
 
4631
 
    /* remoteDispatchClientRequest will free this. */
4632
 
    ret->xml = virStoragePoolGetXMLDesc (pool, args->flags);
4633
 
    if (!ret->xml) {
4634
 
        virStoragePoolFree(pool);
4635
 
        remoteDispatchConnError(rerr, conn);
4636
 
        return -1;
4637
 
    }
4638
 
    virStoragePoolFree(pool);
4639
 
    return 0;
4640
 
}
4641
 
 
4642
 
static int
4643
 
remoteDispatchStoragePoolGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
4644
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4645
 
                                       virConnectPtr conn,
4646
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4647
 
                                       remote_error *rerr,
4648
 
                                       remote_storage_pool_get_autostart_args *args,
4649
 
                                       remote_storage_pool_get_autostart_ret *ret)
4650
 
{
4651
 
    virStoragePoolPtr pool;
4652
 
 
4653
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4654
 
    if (pool == NULL) {
4655
 
        remoteDispatchConnError(rerr, conn);
4656
 
        return -1;
4657
 
    }
4658
 
 
4659
 
    if (virStoragePoolGetAutostart (pool, &ret->autostart) == -1) {
4660
 
        virStoragePoolFree(pool);
4661
 
        remoteDispatchConnError(rerr, conn);
4662
 
        return -1;
4663
 
    }
4664
 
    virStoragePoolFree(pool);
4665
 
    return 0;
4666
 
}
4667
 
 
4668
 
 
4669
 
static int
4670
 
remoteDispatchStoragePoolLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
4671
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4672
 
                                       virConnectPtr conn,
4673
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4674
 
                                       remote_error *rerr,
4675
 
                                       remote_storage_pool_lookup_by_name_args *args,
4676
 
                                       remote_storage_pool_lookup_by_name_ret *ret)
4677
 
{
4678
 
    virStoragePoolPtr pool;
4679
 
 
4680
 
    pool = virStoragePoolLookupByName (conn, args->name);
4681
 
    if (pool == NULL) {
4682
 
        remoteDispatchConnError(rerr, conn);
4683
 
        return -1;
4684
 
    }
4685
 
 
4686
 
    make_nonnull_storage_pool (&ret->pool, pool);
4687
 
    virStoragePoolFree(pool);
4688
 
    return 0;
4689
 
}
4690
 
 
4691
 
static int
4692
 
remoteDispatchStoragePoolLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
4693
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4694
 
                                       virConnectPtr conn,
4695
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4696
 
                                       remote_error *rerr,
4697
 
                                       remote_storage_pool_lookup_by_uuid_args *args,
4698
 
                                       remote_storage_pool_lookup_by_uuid_ret *ret)
4699
 
{
4700
 
    virStoragePoolPtr pool;
4701
 
 
4702
 
    pool = virStoragePoolLookupByUUID (conn, (unsigned char *) args->uuid);
4703
 
    if (pool == NULL) {
4704
 
        remoteDispatchConnError(rerr, conn);
4705
 
        return -1;
4706
 
    }
4707
 
 
4708
 
    make_nonnull_storage_pool (&ret->pool, pool);
4709
 
    virStoragePoolFree(pool);
4710
 
    return 0;
4711
 
}
4712
 
 
4713
 
static int
4714
 
remoteDispatchStoragePoolLookupByVolume (struct qemud_server *server ATTRIBUTE_UNUSED,
4715
 
                                         struct qemud_client *client ATTRIBUTE_UNUSED,
4716
 
                                         virConnectPtr conn,
4717
 
                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
4718
 
                                         remote_error *rerr,
4719
 
                                         remote_storage_pool_lookup_by_volume_args *args,
4720
 
                                         remote_storage_pool_lookup_by_volume_ret *ret)
4721
 
{
4722
 
    virStoragePoolPtr pool;
4723
 
    virStorageVolPtr vol;
4724
 
 
4725
 
    vol = get_nonnull_storage_vol (conn, args->vol);
4726
 
    if (vol == NULL) {
4727
 
        remoteDispatchConnError(rerr, conn);
4728
 
        return -1;
4729
 
    }
4730
 
 
4731
 
    pool = virStoragePoolLookupByVolume (vol);
4732
 
    virStorageVolFree(vol);
4733
 
    if (pool == NULL) {
4734
 
        remoteDispatchConnError(rerr, conn);
4735
 
        return -1;
4736
 
    }
4737
 
 
4738
 
    make_nonnull_storage_pool (&ret->pool, pool);
4739
 
    virStoragePoolFree(pool);
4740
 
    return 0;
4741
 
}
4742
 
 
4743
 
static int
4744
 
remoteDispatchStoragePoolSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
4745
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4746
 
                                       virConnectPtr conn,
4747
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4748
 
                                       remote_error *rerr,
4749
 
                                       remote_storage_pool_set_autostart_args *args,
4750
 
                                       void *ret ATTRIBUTE_UNUSED)
4751
 
{
4752
 
    virStoragePoolPtr pool;
4753
 
 
4754
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4755
 
    if (pool == NULL) {
4756
 
        remoteDispatchConnError(rerr, conn);
4757
 
        return -1;
4758
 
    }
4759
 
 
4760
 
    if (virStoragePoolSetAutostart (pool, args->autostart) == -1) {
4761
 
        virStoragePoolFree(pool);
4762
 
        remoteDispatchConnError(rerr, conn);
4763
 
        return -1;
4764
 
    }
4765
 
    virStoragePoolFree(pool);
4766
 
    return 0;
4767
 
}
4768
 
 
4769
 
static int
4770
 
remoteDispatchStoragePoolUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
4771
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
4772
 
                                   virConnectPtr conn,
4773
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
4774
 
                                   remote_error *rerr,
4775
 
                                   remote_storage_pool_undefine_args *args,
4776
 
                                   void *ret ATTRIBUTE_UNUSED)
4777
 
{
4778
 
    virStoragePoolPtr pool;
4779
 
 
4780
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4781
 
    if (pool == NULL) {
4782
 
        remoteDispatchConnError(rerr, conn);
4783
 
        return -1;
4784
 
    }
4785
 
 
4786
 
    if (virStoragePoolUndefine (pool) == -1) {
4787
 
        virStoragePoolFree(pool);
4788
 
        remoteDispatchConnError(rerr, conn);
4789
 
        return -1;
4790
 
    }
4791
 
    virStoragePoolFree(pool);
4792
 
    return 0;
4793
 
}
4794
 
 
4795
 
static int
4796
 
remoteDispatchNumOfStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
 
5704
    rv = 0;
 
5705
 
 
5706
cleanup:
 
5707
    if (rv < 0)
 
5708
        remoteDispatchError(rerr);
 
5709
    if (pool)
 
5710
        virStoragePoolFree(pool);
 
5711
    return rv;
 
5712
}
 
5713
 
 
5714
static int
 
5715
remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
4797
5716
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
4798
5717
                                 virConnectPtr conn,
4799
5718
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
4800
5719
                                 remote_error *rerr,
4801
 
                                 void *args ATTRIBUTE_UNUSED,
4802
 
                                 remote_num_of_storage_pools_ret *ret)
4803
 
{
4804
 
 
4805
 
    ret->num = virConnectNumOfStoragePools (conn);
4806
 
    if (ret->num == -1) {
4807
 
        remoteDispatchConnError(rerr, conn);
4808
 
        return -1;
4809
 
    }
4810
 
 
4811
 
    return 0;
4812
 
}
4813
 
 
4814
 
static int
4815
 
remoteDispatchNumOfDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
 
5720
                                 remote_storage_pool_dump_xml_args *args,
 
5721
                                 remote_storage_pool_dump_xml_ret *ret)
 
5722
{
 
5723
    virStoragePoolPtr pool = NULL;
 
5724
    int rv = -1;
 
5725
 
 
5726
    if (!conn) {
 
5727
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5728
        goto cleanup;
 
5729
    }
 
5730
 
 
5731
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5732
        goto cleanup;
 
5733
 
 
5734
    /* remoteDispatchClientRequest will free this. */
 
5735
    if (!(ret->xml = virStoragePoolGetXMLDesc(pool, args->flags)))
 
5736
        goto cleanup;
 
5737
 
 
5738
    rv = 0;
 
5739
 
 
5740
cleanup:
 
5741
    if (rv < 0)
 
5742
        remoteDispatchError(rerr);
 
5743
    if (pool)
 
5744
        virStoragePoolFree(pool);
 
5745
    return rv;
 
5746
}
 
5747
 
 
5748
static int
 
5749
remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5750
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
5751
                                      virConnectPtr conn,
 
5752
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5753
                                      remote_error *rerr,
 
5754
                                      remote_storage_pool_get_autostart_args *args,
 
5755
                                      remote_storage_pool_get_autostart_ret *ret)
 
5756
{
 
5757
    virStoragePoolPtr pool = NULL;
 
5758
    int rv = -1;
 
5759
 
 
5760
    if (!conn) {
 
5761
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5762
        goto cleanup;
 
5763
    }
 
5764
 
 
5765
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5766
        goto cleanup;
 
5767
 
 
5768
    if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0)
 
5769
        goto cleanup;
 
5770
 
 
5771
    rv = 0;
 
5772
 
 
5773
cleanup:
 
5774
    if (rv < 0)
 
5775
        remoteDispatchError(rerr);
 
5776
    if (pool)
 
5777
        virStoragePoolFree(pool);
 
5778
    return rv;
 
5779
}
 
5780
 
 
5781
 
 
5782
static int
 
5783
remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5784
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
5785
                                      virConnectPtr conn,
 
5786
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5787
                                      remote_error *rerr,
 
5788
                                      remote_storage_pool_lookup_by_name_args *args,
 
5789
                                      remote_storage_pool_lookup_by_name_ret *ret)
 
5790
{
 
5791
    virStoragePoolPtr pool = NULL;
 
5792
    int rv = -1;
 
5793
 
 
5794
    if (!conn) {
 
5795
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5796
        goto cleanup;
 
5797
    }
 
5798
 
 
5799
    if (!(pool = virStoragePoolLookupByName(conn, args->name)))
 
5800
        goto cleanup;
 
5801
 
 
5802
    make_nonnull_storage_pool(&ret->pool, pool);
 
5803
 
 
5804
    rv = 0;
 
5805
 
 
5806
cleanup:
 
5807
    if (rv < 0)
 
5808
        remoteDispatchError(rerr);
 
5809
    if (pool)
 
5810
        virStoragePoolFree(pool);
 
5811
    return rv;
 
5812
}
 
5813
 
 
5814
static int
 
5815
remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5816
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
5817
                                      virConnectPtr conn,
 
5818
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5819
                                      remote_error *rerr,
 
5820
                                      remote_storage_pool_lookup_by_uuid_args *args,
 
5821
                                      remote_storage_pool_lookup_by_uuid_ret *ret)
 
5822
{
 
5823
    virStoragePoolPtr pool = NULL;
 
5824
    int rv = -1;
 
5825
 
 
5826
    if (!conn) {
 
5827
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5828
        goto cleanup;
 
5829
    }
 
5830
 
 
5831
    if (!(pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid)))
 
5832
        goto cleanup;
 
5833
 
 
5834
    make_nonnull_storage_pool(&ret->pool, pool);
 
5835
 
 
5836
    rv = 0;
 
5837
 
 
5838
cleanup:
 
5839
    if (rv < 0)
 
5840
        remoteDispatchError(rerr);
 
5841
    if (pool)
 
5842
        virStoragePoolFree(pool);
 
5843
    return rv;
 
5844
}
 
5845
 
 
5846
static int
 
5847
remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UNUSED,
4816
5848
                                        struct qemud_client *client ATTRIBUTE_UNUSED,
4817
5849
                                        virConnectPtr conn,
4818
5850
                                        remote_message_header *hdr ATTRIBUTE_UNUSED,
4819
5851
                                        remote_error *rerr,
4820
 
                                        void *args ATTRIBUTE_UNUSED,
4821
 
                                        remote_num_of_defined_storage_pools_ret *ret)
 
5852
                                        remote_storage_pool_lookup_by_volume_args *args,
 
5853
                                        remote_storage_pool_lookup_by_volume_ret *ret)
4822
5854
{
 
5855
    virStoragePoolPtr pool = NULL;
 
5856
    virStorageVolPtr vol = NULL;
 
5857
    int rv = -1;
4823
5858
 
4824
 
    ret->num = virConnectNumOfDefinedStoragePools (conn);
4825
 
    if (ret->num == -1) {
4826
 
        remoteDispatchConnError(rerr, conn);
4827
 
        return -1;
 
5859
    if (!conn) {
 
5860
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5861
        goto cleanup;
4828
5862
    }
4829
5863
 
4830
 
    return 0;
 
5864
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
5865
        goto cleanup;
 
5866
 
 
5867
    if (!(pool = virStoragePoolLookupByVolume(vol)))
 
5868
        goto cleanup;
 
5869
 
 
5870
    make_nonnull_storage_pool(&ret->pool, pool);
 
5871
 
 
5872
    rv = 0;
 
5873
 
 
5874
cleanup:
 
5875
    if (rv < 0)
 
5876
        remoteDispatchError(rerr);
 
5877
    if (vol)
 
5878
        virStorageVolFree(vol);
 
5879
    if (pool)
 
5880
        virStoragePoolFree(pool);
 
5881
    return rv;
4831
5882
}
4832
5883
 
4833
5884
static int
4834
 
remoteDispatchStoragePoolListVolumes (struct qemud_server *server ATTRIBUTE_UNUSED,
 
5885
remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
4835
5886
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
4836
5887
                                      virConnectPtr conn,
4837
5888
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
4838
5889
                                      remote_error *rerr,
4839
 
                                      remote_storage_pool_list_volumes_args *args,
4840
 
                                      remote_storage_pool_list_volumes_ret *ret)
4841
 
{
4842
 
    virStoragePoolPtr pool;
 
5890
                                      remote_storage_pool_set_autostart_args *args,
 
5891
                                      void *ret ATTRIBUTE_UNUSED)
 
5892
{
 
5893
    virStoragePoolPtr pool = NULL;
 
5894
    int rv = -1;
 
5895
 
 
5896
    if (!conn) {
 
5897
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5898
        goto cleanup;
 
5899
    }
 
5900
 
 
5901
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5902
        goto cleanup;
 
5903
 
 
5904
    if (virStoragePoolSetAutostart(pool, args->autostart) < 0)
 
5905
        goto cleanup;
 
5906
 
 
5907
    rv = 0;
 
5908
 
 
5909
cleanup:
 
5910
    if (rv < 0)
 
5911
        remoteDispatchError(rerr);
 
5912
    if (pool)
 
5913
        virStoragePoolFree(pool);
 
5914
    return rv;
 
5915
}
 
5916
 
 
5917
static int
 
5918
remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5919
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
5920
                                  virConnectPtr conn,
 
5921
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5922
                                  remote_error *rerr,
 
5923
                                  remote_storage_pool_undefine_args *args,
 
5924
                                  void *ret ATTRIBUTE_UNUSED)
 
5925
{
 
5926
    virStoragePoolPtr pool = NULL;
 
5927
    int rv = -1;
 
5928
 
 
5929
    if (!conn) {
 
5930
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5931
        goto cleanup;
 
5932
    }
 
5933
 
 
5934
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
5935
        goto cleanup;
 
5936
 
 
5937
    if (virStoragePoolUndefine(pool) < 0)
 
5938
        goto cleanup;
 
5939
 
 
5940
    rv = 0;
 
5941
 
 
5942
cleanup:
 
5943
    if (rv < 0)
 
5944
        remoteDispatchError(rerr);
 
5945
    if (pool)
 
5946
        virStoragePoolFree(pool);
 
5947
    return rv;
 
5948
}
 
5949
 
 
5950
static int
 
5951
remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5952
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
5953
                                virConnectPtr conn,
 
5954
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5955
                                remote_error *rerr,
 
5956
                                void *args ATTRIBUTE_UNUSED,
 
5957
                                remote_num_of_storage_pools_ret *ret)
 
5958
{
 
5959
    int rv = -1;
 
5960
 
 
5961
    if (!conn) {
 
5962
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5963
        goto cleanup;
 
5964
    }
 
5965
 
 
5966
    if ((ret->num = virConnectNumOfStoragePools(conn)) < 0)
 
5967
        goto cleanup;
 
5968
 
 
5969
    rv = 0;
 
5970
 
 
5971
cleanup:
 
5972
    if (rv < 0)
 
5973
        remoteDispatchError(rerr);
 
5974
    return rv;
 
5975
}
 
5976
 
 
5977
static int
 
5978
remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
 
5979
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
 
5980
                                       virConnectPtr conn,
 
5981
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
 
5982
                                       remote_error *rerr,
 
5983
                                       void *args ATTRIBUTE_UNUSED,
 
5984
                                       remote_num_of_defined_storage_pools_ret *ret)
 
5985
{
 
5986
    int rv = -1;
 
5987
 
 
5988
    if (!conn) {
 
5989
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
5990
        goto cleanup;
 
5991
    }
 
5992
 
 
5993
    if ((ret->num = virConnectNumOfDefinedStoragePools(conn)) < 0)
 
5994
        goto cleanup;
 
5995
 
 
5996
    rv = 0;
 
5997
 
 
5998
cleanup:
 
5999
    if (rv < 0)
 
6000
        remoteDispatchError(rerr);
 
6001
    return rv;
 
6002
}
 
6003
 
 
6004
static int
 
6005
remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6006
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
6007
                                     virConnectPtr conn,
 
6008
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6009
                                     remote_error *rerr,
 
6010
                                     remote_storage_pool_list_volumes_args *args,
 
6011
                                     remote_storage_pool_list_volumes_ret *ret)
 
6012
{
 
6013
    virStoragePoolPtr pool = NULL;
 
6014
    int rv = -1;
 
6015
    int len;
 
6016
 
 
6017
    if (!conn) {
 
6018
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6019
        goto cleanup;
 
6020
    }
4843
6021
 
4844
6022
    if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
4845
 
        remoteDispatchFormatError (rerr,
4846
 
                                   "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
4847
 
        return -1;
 
6023
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
6024
                    "%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
 
6025
        goto cleanup;
4848
6026
    }
4849
6027
 
4850
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4851
 
    if (pool == NULL) {
4852
 
        remoteDispatchConnError(rerr, conn);
4853
 
        return -1;
4854
 
    }
 
6028
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
6029
        goto cleanup;
4855
6030
 
4856
6031
    /* Allocate return buffer. */
4857
6032
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
4858
 
        virStoragePoolFree(pool);
4859
 
        remoteDispatchOOMError(rerr);
4860
 
        return -1;
 
6033
        virReportOOMError();
 
6034
        goto cleanup;
4861
6035
    }
4862
6036
 
4863
 
    ret->names.names_len =
4864
 
        virStoragePoolListVolumes (pool,
4865
 
                                   ret->names.names_val, args->maxnames);
4866
 
    virStoragePoolFree(pool);
4867
 
    if (ret->names.names_len == -1) {
 
6037
    len = virStoragePoolListVolumes(pool,
 
6038
                                    ret->names.names_val, args->maxnames);
 
6039
    if (len < 0)
 
6040
        goto cleanup;
 
6041
    ret->names.names_len = len;
 
6042
 
 
6043
    rv = 0;
 
6044
 
 
6045
cleanup:
 
6046
    if (rv < 0) {
 
6047
        remoteDispatchError(rerr);
4868
6048
        VIR_FREE(ret->names.names_val);
4869
 
        remoteDispatchConnError(rerr, conn);
4870
 
        return -1;
4871
6049
    }
4872
 
 
4873
 
    return 0;
 
6050
    if (pool)
 
6051
        virStoragePoolFree(pool);
 
6052
    return rv;
4874
6053
}
4875
6054
 
4876
6055
 
4877
6056
static int
4878
 
remoteDispatchStoragePoolNumOfVolumes (struct qemud_server *server ATTRIBUTE_UNUSED,
4879
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4880
 
                                       virConnectPtr conn,
4881
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4882
 
                                       remote_error *rerr,
4883
 
                                       remote_storage_pool_num_of_volumes_args *args,
4884
 
                                       remote_storage_pool_num_of_volumes_ret *ret)
 
6057
remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6058
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
6059
                                      virConnectPtr conn,
 
6060
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6061
                                      remote_error *rerr,
 
6062
                                      remote_storage_pool_num_of_volumes_args *args,
 
6063
                                      remote_storage_pool_num_of_volumes_ret *ret)
4885
6064
{
4886
 
    virStoragePoolPtr pool;
4887
 
 
4888
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4889
 
    if (pool == NULL) {
4890
 
        remoteDispatchConnError(rerr, conn);
4891
 
        return -1;
4892
 
    }
4893
 
 
4894
 
    ret->num = virStoragePoolNumOfVolumes (pool);
4895
 
    virStoragePoolFree(pool);
4896
 
    if (ret->num == -1) {
4897
 
        remoteDispatchConnError(rerr, conn);
4898
 
        return -1;
4899
 
    }
4900
 
 
4901
 
    return 0;
 
6065
    virStoragePoolPtr pool = NULL;
 
6066
    int rv = -1;
 
6067
 
 
6068
    if (!conn) {
 
6069
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6070
        goto cleanup;
 
6071
    }
 
6072
 
 
6073
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
6074
        goto cleanup;
 
6075
 
 
6076
    if ((ret->num = virStoragePoolNumOfVolumes(pool)) < 0)
 
6077
        goto cleanup;
 
6078
 
 
6079
    rv = 0;
 
6080
 
 
6081
cleanup:
 
6082
    if (rv < 0)
 
6083
        remoteDispatchError(rerr);
 
6084
    if (pool)
 
6085
        virStoragePoolFree(pool);
 
6086
    return rv;
4902
6087
}
4903
6088
 
4904
6089
 
4909
6094
 
4910
6095
 
4911
6096
static int
4912
 
remoteDispatchStorageVolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
4913
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
4914
 
                                   virConnectPtr conn,
4915
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
4916
 
                                   remote_error *rerr,
4917
 
                                   remote_storage_vol_create_xml_args *args,
4918
 
                                   remote_storage_vol_create_xml_ret *ret)
4919
 
{
4920
 
    virStoragePoolPtr pool;
4921
 
    virStorageVolPtr vol;
4922
 
 
4923
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4924
 
    if (pool == NULL) {
4925
 
        remoteDispatchConnError(rerr, conn);
4926
 
        return -1;
4927
 
    }
4928
 
 
4929
 
    vol = virStorageVolCreateXML (pool, args->xml, args->flags);
4930
 
    virStoragePoolFree(pool);
4931
 
    if (vol == NULL) {
4932
 
        remoteDispatchConnError(rerr, conn);
4933
 
        return -1;
4934
 
    }
4935
 
 
4936
 
    make_nonnull_storage_vol (&ret->vol, vol);
4937
 
    virStorageVolFree(vol);
4938
 
    return 0;
4939
 
}
4940
 
 
4941
 
static int
4942
 
remoteDispatchStorageVolCreateXmlFrom (struct qemud_server *server ATTRIBUTE_UNUSED,
4943
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
4944
 
                                       virConnectPtr conn,
4945
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
4946
 
                                       remote_error *rerr,
4947
 
                                       remote_storage_vol_create_xml_from_args *args,
4948
 
                                       remote_storage_vol_create_xml_from_ret *ret)
4949
 
{
4950
 
    virStoragePoolPtr pool;
4951
 
    virStorageVolPtr clonevol, newvol;
4952
 
 
4953
 
    pool = get_nonnull_storage_pool (conn, args->pool);
4954
 
    if (pool == NULL) {
4955
 
        remoteDispatchConnError(rerr, conn);
4956
 
        return -1;
4957
 
    }
4958
 
 
4959
 
    clonevol = get_nonnull_storage_vol (conn, args->clonevol);
4960
 
    if (clonevol == NULL) {
4961
 
        virStoragePoolFree(pool);
4962
 
        remoteDispatchConnError(rerr, conn);
4963
 
        return -1;
4964
 
    }
4965
 
 
4966
 
    newvol = virStorageVolCreateXMLFrom (pool, args->xml, clonevol,
4967
 
                                         args->flags);
4968
 
    virStorageVolFree(clonevol);
4969
 
    virStoragePoolFree(pool);
4970
 
    if (newvol == NULL) {
4971
 
        remoteDispatchConnError(rerr, conn);
4972
 
        return -1;
4973
 
    }
4974
 
 
4975
 
    make_nonnull_storage_vol (&ret->vol, newvol);
4976
 
    virStorageVolFree(newvol);
4977
 
    return 0;
4978
 
}
4979
 
 
4980
 
static int
4981
 
remoteDispatchStorageVolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
4982
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
4983
 
                                virConnectPtr conn,
4984
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
4985
 
                                remote_error *rerr,
4986
 
                                remote_storage_vol_delete_args *args,
4987
 
                                void *ret ATTRIBUTE_UNUSED)
4988
 
{
4989
 
    virStorageVolPtr vol;
4990
 
 
4991
 
    vol = get_nonnull_storage_vol (conn, args->vol);
4992
 
    if (vol == NULL) {
4993
 
        remoteDispatchConnError(rerr, conn);
4994
 
        return -1;
4995
 
    }
4996
 
 
4997
 
    if (virStorageVolDelete (vol, args->flags) == -1) {
4998
 
        virStorageVolFree(vol);
4999
 
        remoteDispatchConnError(rerr, conn);
5000
 
        return -1;
5001
 
    }
5002
 
    virStorageVolFree(vol);
5003
 
    return 0;
 
6097
remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6098
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
6099
                                  virConnectPtr conn,
 
6100
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6101
                                  remote_error *rerr,
 
6102
                                  remote_storage_vol_create_xml_args *args,
 
6103
                                  remote_storage_vol_create_xml_ret *ret)
 
6104
{
 
6105
    virStoragePoolPtr pool = NULL;
 
6106
    virStorageVolPtr vol = NULL;
 
6107
    int rv = -1;
 
6108
 
 
6109
    if (!conn) {
 
6110
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6111
        goto cleanup;
 
6112
    }
 
6113
 
 
6114
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
6115
        goto cleanup;
 
6116
 
 
6117
    if (!(vol = virStorageVolCreateXML(pool, args->xml, args->flags)))
 
6118
        goto cleanup;
 
6119
 
 
6120
    make_nonnull_storage_vol(&ret->vol, vol);
 
6121
    rv = 0;
 
6122
 
 
6123
cleanup:
 
6124
    if (rv < 0)
 
6125
        remoteDispatchError(rerr);
 
6126
    if (pool)
 
6127
        virStoragePoolFree(pool);
 
6128
    if (vol)
 
6129
        virStorageVolFree(vol);
 
6130
    return rv;
 
6131
}
 
6132
 
 
6133
static int
 
6134
remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6135
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
6136
                                      virConnectPtr conn,
 
6137
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6138
                                      remote_error *rerr,
 
6139
                                      remote_storage_vol_create_xml_from_args *args,
 
6140
                                      remote_storage_vol_create_xml_from_ret *ret)
 
6141
{
 
6142
    virStoragePoolPtr pool = NULL;
 
6143
    virStorageVolPtr clonevol = NULL;
 
6144
    virStorageVolPtr newvol = NULL;
 
6145
    int rv = -1;
 
6146
 
 
6147
    if (!conn) {
 
6148
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6149
        goto cleanup;
 
6150
    }
 
6151
 
 
6152
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
6153
        goto cleanup;
 
6154
 
 
6155
    if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol)))
 
6156
        goto cleanup;
 
6157
 
 
6158
    if (!(newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
 
6159
                                              args->flags)))
 
6160
        goto cleanup;
 
6161
 
 
6162
    make_nonnull_storage_vol(&ret->vol, newvol);
 
6163
    rv = 0;
 
6164
 
 
6165
cleanup:
 
6166
    if (rv < 0)
 
6167
        remoteDispatchError(rerr);
 
6168
    if (newvol)
 
6169
        virStorageVolFree(newvol);
 
6170
    if (clonevol)
 
6171
        virStorageVolFree(clonevol);
 
6172
    if (pool)
 
6173
        virStoragePoolFree(pool);
 
6174
    return rv;
 
6175
}
 
6176
 
 
6177
static int
 
6178
remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6179
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
6180
                               virConnectPtr conn,
 
6181
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6182
                               remote_error *rerr,
 
6183
                               remote_storage_vol_delete_args *args,
 
6184
                               void *ret ATTRIBUTE_UNUSED)
 
6185
{
 
6186
    virStorageVolPtr vol = NULL;
 
6187
    int rv = -1;
 
6188
 
 
6189
    if (!conn) {
 
6190
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6191
        goto cleanup;
 
6192
    }
 
6193
 
 
6194
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6195
        goto cleanup;
 
6196
 
 
6197
    if (virStorageVolDelete(vol, args->flags) < 0)
 
6198
        goto cleanup;
 
6199
 
 
6200
    rv = 0;
 
6201
 
 
6202
cleanup:
 
6203
    if (rv < 0)
 
6204
        remoteDispatchError(rerr);
 
6205
    if (vol)
 
6206
        virStorageVolFree(vol);
 
6207
    return rv;
5004
6208
}
5005
6209
 
5006
6210
static int
5012
6216
                             remote_storage_vol_wipe_args *args,
5013
6217
                             void *ret ATTRIBUTE_UNUSED)
5014
6218
{
5015
 
    int retval = -1;
5016
 
    virStorageVolPtr vol;
5017
 
 
5018
 
    vol = get_nonnull_storage_vol(conn, args->vol);
5019
 
    if (vol == NULL) {
5020
 
        remoteDispatchConnError(rerr, conn);
5021
 
        goto out;
5022
 
    }
5023
 
 
5024
 
    if (virStorageVolWipe(vol, args->flags) == -1) {
5025
 
        remoteDispatchConnError(rerr, conn);
5026
 
        goto out;
5027
 
    }
5028
 
 
5029
 
    retval = 0;
5030
 
 
5031
 
out:
5032
 
    if (vol != NULL) {
 
6219
    virStorageVolPtr vol = NULL;
 
6220
    int rv = -1;
 
6221
 
 
6222
    if (!conn) {
 
6223
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6224
        goto cleanup;
 
6225
    }
 
6226
 
 
6227
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6228
        goto cleanup;
 
6229
 
 
6230
    if (virStorageVolWipe(vol, args->flags) < 0)
 
6231
        goto cleanup;
 
6232
 
 
6233
    rv = 0;
 
6234
 
 
6235
cleanup:
 
6236
    if (rv < 0)
 
6237
        remoteDispatchError(rerr);
 
6238
    if (vol)
5033
6239
        virStorageVolFree(vol);
5034
 
    }
5035
 
    return retval;
 
6240
    return rv;
5036
6241
}
5037
6242
 
5038
6243
static int
5039
 
remoteDispatchStorageVolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
5040
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
5041
 
                                 virConnectPtr conn,
5042
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
5043
 
                                 remote_error *rerr,
5044
 
                                 remote_storage_vol_get_info_args *args,
5045
 
                                 remote_storage_vol_get_info_ret *ret)
 
6244
remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6245
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
6246
                                virConnectPtr conn,
 
6247
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6248
                                remote_error *rerr,
 
6249
                                remote_storage_vol_get_info_args *args,
 
6250
                                remote_storage_vol_get_info_ret *ret)
5046
6251
{
5047
 
    virStorageVolPtr vol;
 
6252
    virStorageVolPtr vol = NULL;
5048
6253
    virStorageVolInfo info;
5049
 
 
5050
 
    vol = get_nonnull_storage_vol (conn, args->vol);
5051
 
    if (vol == NULL) {
5052
 
        remoteDispatchConnError(rerr, conn);
5053
 
        return -1;
5054
 
    }
5055
 
 
5056
 
    if (virStorageVolGetInfo (vol, &info) == -1) {
5057
 
        virStorageVolFree(vol);
5058
 
        remoteDispatchConnError(rerr, conn);
5059
 
        return -1;
5060
 
    }
 
6254
    int rv = -1;
 
6255
 
 
6256
    if (!conn) {
 
6257
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6258
        goto cleanup;
 
6259
    }
 
6260
 
 
6261
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6262
        goto cleanup;
 
6263
 
 
6264
    if (virStorageVolGetInfo(vol, &info) < 0)
 
6265
        goto cleanup;
5061
6266
 
5062
6267
    ret->type = info.type;
5063
6268
    ret->capacity = info.capacity;
5064
6269
    ret->allocation = info.allocation;
5065
6270
 
5066
 
    virStorageVolFree(vol);
5067
 
 
5068
 
    return 0;
5069
 
}
5070
 
 
5071
 
static int
5072
 
remoteDispatchStorageVolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
5073
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
5074
 
                                 virConnectPtr conn,
5075
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
5076
 
                                 remote_error *rerr,
5077
 
                                 remote_storage_vol_dump_xml_args *args,
5078
 
                                 remote_storage_vol_dump_xml_ret *ret)
5079
 
{
5080
 
    virStorageVolPtr vol;
5081
 
 
5082
 
    vol = get_nonnull_storage_vol (conn, args->vol);
5083
 
    if (vol == NULL) {
5084
 
        remoteDispatchConnError(rerr, conn);
5085
 
        return -1;
5086
 
    }
5087
 
 
5088
 
    /* remoteDispatchClientRequest will free this. */
5089
 
    ret->xml = virStorageVolGetXMLDesc (vol, args->flags);
5090
 
    if (!ret->xml) {
5091
 
        virStorageVolFree(vol);
5092
 
        remoteDispatchConnError(rerr, conn);
5093
 
        return -1;
5094
 
    }
5095
 
    virStorageVolFree(vol);
5096
 
    return 0;
5097
 
}
5098
 
 
5099
 
 
5100
 
static int
5101
 
remoteDispatchStorageVolGetPath (struct qemud_server *server ATTRIBUTE_UNUSED,
5102
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
5103
 
                                 virConnectPtr conn,
5104
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
5105
 
                                 remote_error *rerr,
5106
 
                                 remote_storage_vol_get_path_args *args,
5107
 
                                 remote_storage_vol_get_path_ret *ret)
5108
 
{
5109
 
    virStorageVolPtr vol;
5110
 
 
5111
 
    vol = get_nonnull_storage_vol (conn, args->vol);
5112
 
    if (vol == NULL) {
5113
 
        remoteDispatchConnError(rerr, conn);
5114
 
        return -1;
5115
 
    }
5116
 
 
5117
 
    /* remoteDispatchClientRequest will free this. */
5118
 
    ret->name = virStorageVolGetPath (vol);
5119
 
    if (!ret->name) {
5120
 
        virStorageVolFree(vol);
5121
 
        remoteDispatchConnError(rerr, conn);
5122
 
        return -1;
5123
 
    }
5124
 
    virStorageVolFree(vol);
5125
 
    return 0;
5126
 
}
5127
 
 
5128
 
 
5129
 
static int
5130
 
remoteDispatchStorageVolLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
5131
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
5132
 
                                      virConnectPtr conn,
5133
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
5134
 
                                      remote_error *rerr,
5135
 
                                      remote_storage_vol_lookup_by_name_args *args,
5136
 
                                      remote_storage_vol_lookup_by_name_ret *ret)
5137
 
{
5138
 
    virStoragePoolPtr pool;
5139
 
    virStorageVolPtr vol;
5140
 
 
5141
 
    pool = get_nonnull_storage_pool (conn, args->pool);
5142
 
    if (pool == NULL) {
5143
 
        remoteDispatchConnError(rerr, conn);
5144
 
        return -1;
5145
 
    }
5146
 
 
5147
 
    vol = virStorageVolLookupByName (pool, args->name);
5148
 
    virStoragePoolFree(pool);
5149
 
    if (vol == NULL) {
5150
 
        remoteDispatchConnError(rerr, conn);
5151
 
        return -1;
5152
 
    }
5153
 
 
5154
 
    make_nonnull_storage_vol (&ret->vol, vol);
5155
 
    virStorageVolFree(vol);
5156
 
    return 0;
5157
 
}
5158
 
 
5159
 
static int
5160
 
remoteDispatchStorageVolLookupByKey (struct qemud_server *server ATTRIBUTE_UNUSED,
5161
 
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
5162
 
                                     virConnectPtr conn,
5163
 
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
5164
 
                                     remote_error *rerr,
5165
 
                                     remote_storage_vol_lookup_by_key_args *args,
5166
 
                                     remote_storage_vol_lookup_by_key_ret *ret)
5167
 
{
5168
 
    virStorageVolPtr vol;
5169
 
 
5170
 
    vol = virStorageVolLookupByKey (conn, args->key);
5171
 
    if (vol == NULL) {
5172
 
        remoteDispatchConnError(rerr, conn);
5173
 
        return -1;
5174
 
    }
5175
 
 
5176
 
    make_nonnull_storage_vol (&ret->vol, vol);
5177
 
    virStorageVolFree(vol);
5178
 
    return 0;
5179
 
}
5180
 
 
5181
 
 
5182
 
static int
5183
 
remoteDispatchStorageVolLookupByPath (struct qemud_server *server ATTRIBUTE_UNUSED,
5184
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
5185
 
                                      virConnectPtr conn,
5186
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
5187
 
                                      remote_error *rerr,
5188
 
                                      remote_storage_vol_lookup_by_path_args *args,
5189
 
                                      remote_storage_vol_lookup_by_path_ret *ret)
5190
 
{
5191
 
    virStorageVolPtr vol;
5192
 
 
5193
 
    vol = virStorageVolLookupByPath (conn, args->path);
5194
 
    if (vol == NULL) {
5195
 
        remoteDispatchConnError(rerr, conn);
5196
 
        return -1;
5197
 
    }
5198
 
 
5199
 
    make_nonnull_storage_vol (&ret->vol, vol);
5200
 
    virStorageVolFree(vol);
5201
 
    return 0;
 
6271
    rv = 0;
 
6272
 
 
6273
cleanup:
 
6274
    if (rv < 0)
 
6275
        remoteDispatchError(rerr);
 
6276
    if (vol)
 
6277
        virStorageVolFree(vol);
 
6278
    return rv;
 
6279
}
 
6280
 
 
6281
static int
 
6282
remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6283
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
6284
                                virConnectPtr conn,
 
6285
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6286
                                remote_error *rerr,
 
6287
                                remote_storage_vol_dump_xml_args *args,
 
6288
                                remote_storage_vol_dump_xml_ret *ret)
 
6289
{
 
6290
    virStorageVolPtr vol = NULL;
 
6291
    int rv = -1;
 
6292
 
 
6293
    if (!conn) {
 
6294
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6295
        goto cleanup;
 
6296
    }
 
6297
 
 
6298
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6299
        goto cleanup;
 
6300
 
 
6301
    /* remoteDispatchClientRequest will free this. */
 
6302
    if (!(ret->xml = virStorageVolGetXMLDesc(vol, args->flags)))
 
6303
        goto cleanup;
 
6304
 
 
6305
    rv = 0;
 
6306
 
 
6307
cleanup:
 
6308
    if (rv < 0)
 
6309
        remoteDispatchError(rerr);
 
6310
    if (vol)
 
6311
        virStorageVolFree(vol);
 
6312
    return rv;
 
6313
}
 
6314
 
 
6315
 
 
6316
static int
 
6317
remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6318
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
6319
                                virConnectPtr conn,
 
6320
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6321
                                remote_error *rerr,
 
6322
                                remote_storage_vol_get_path_args *args,
 
6323
                                remote_storage_vol_get_path_ret *ret)
 
6324
{
 
6325
    virStorageVolPtr vol = NULL;
 
6326
    int rv = -1;
 
6327
 
 
6328
    if (!conn) {
 
6329
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6330
        goto cleanup;
 
6331
    }
 
6332
 
 
6333
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6334
        goto cleanup;
 
6335
 
 
6336
    /* remoteDispatchClientRequest will free this. */
 
6337
    if (!(ret->name = virStorageVolGetPath(vol)))
 
6338
        goto cleanup;
 
6339
 
 
6340
    rv = 0;
 
6341
 
 
6342
cleanup:
 
6343
    if (rv < 0)
 
6344
        remoteDispatchError(rerr);
 
6345
    if (vol)
 
6346
        virStorageVolFree(vol);
 
6347
    return rv;
 
6348
}
 
6349
 
 
6350
 
 
6351
static int
 
6352
remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6353
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
6354
                                     virConnectPtr conn,
 
6355
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6356
                                     remote_error *rerr,
 
6357
                                     remote_storage_vol_lookup_by_name_args *args,
 
6358
                                     remote_storage_vol_lookup_by_name_ret *ret)
 
6359
{
 
6360
    virStoragePoolPtr pool = NULL;
 
6361
    virStorageVolPtr vol = NULL;
 
6362
    int rv = -1;
 
6363
 
 
6364
    if (!conn) {
 
6365
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6366
        goto cleanup;
 
6367
    }
 
6368
 
 
6369
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
6370
        goto cleanup;
 
6371
 
 
6372
    if (!(vol = virStorageVolLookupByName(pool, args->name)))
 
6373
        goto cleanup;
 
6374
 
 
6375
    make_nonnull_storage_vol(&ret->vol, vol);
 
6376
 
 
6377
    rv = 0;
 
6378
 
 
6379
cleanup:
 
6380
    if (rv < 0)
 
6381
        remoteDispatchError(rerr);
 
6382
    if (pool)
 
6383
        virStoragePoolFree(pool);
 
6384
    if (vol)
 
6385
        virStorageVolFree(vol);
 
6386
    return rv;
 
6387
}
 
6388
 
 
6389
static int
 
6390
remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6391
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
 
6392
                                    virConnectPtr conn,
 
6393
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6394
                                    remote_error *rerr,
 
6395
                                    remote_storage_vol_lookup_by_key_args *args,
 
6396
                                    remote_storage_vol_lookup_by_key_ret *ret)
 
6397
{
 
6398
    virStorageVolPtr vol = NULL;
 
6399
    int rv = -1;
 
6400
 
 
6401
    if (!conn) {
 
6402
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6403
        goto cleanup;
 
6404
    }
 
6405
 
 
6406
    if (!(vol = virStorageVolLookupByKey(conn, args->key)))
 
6407
        goto cleanup;
 
6408
 
 
6409
    make_nonnull_storage_vol(&ret->vol, vol);
 
6410
 
 
6411
    rv = 0;
 
6412
 
 
6413
cleanup:
 
6414
    if (rv < 0)
 
6415
        remoteDispatchError(rerr);
 
6416
    if (vol)
 
6417
        virStorageVolFree(vol);
 
6418
    return rv;
 
6419
}
 
6420
 
 
6421
 
 
6422
static int
 
6423
remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6424
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
6425
                                     virConnectPtr conn,
 
6426
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6427
                                     remote_error *rerr,
 
6428
                                     remote_storage_vol_lookup_by_path_args *args,
 
6429
                                     remote_storage_vol_lookup_by_path_ret *ret)
 
6430
{
 
6431
    virStorageVolPtr vol = NULL;
 
6432
    int rv = -1;
 
6433
 
 
6434
    if (!conn) {
 
6435
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6436
        goto cleanup;
 
6437
    }
 
6438
 
 
6439
    if (!(vol = virStorageVolLookupByPath(conn, args->path)))
 
6440
        goto cleanup;
 
6441
 
 
6442
    make_nonnull_storage_vol(&ret->vol, vol);
 
6443
 
 
6444
    rv = 0;
 
6445
 
 
6446
cleanup:
 
6447
    if (rv < 0)
 
6448
        remoteDispatchError(rerr);
 
6449
    if (vol)
 
6450
        virStorageVolFree(vol);
 
6451
    return rv;
5202
6452
}
5203
6453
 
5204
6454
 
5207
6457
 **************************************************************/
5208
6458
 
5209
6459
static int
5210
 
remoteDispatchNodeNumOfDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
5211
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
5212
 
                                virConnectPtr conn,
5213
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
5214
 
                                remote_error *rerr,
5215
 
                                remote_node_num_of_devices_args *args,
5216
 
                                remote_node_num_of_devices_ret *ret)
5217
 
{
5218
 
    CHECK_CONN(client);
5219
 
 
5220
 
    ret->num = virNodeNumOfDevices (conn,
5221
 
                                    args->cap ? *args->cap : NULL,
5222
 
                                    args->flags);
5223
 
    if (ret->num == -1) {
5224
 
        remoteDispatchConnError(rerr, conn);
5225
 
        return -1;
5226
 
    }
5227
 
 
5228
 
    return 0;
5229
 
}
5230
 
 
5231
 
 
5232
 
static int
5233
 
remoteDispatchNodeListDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
 
6460
remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
5234
6461
                               struct qemud_client *client ATTRIBUTE_UNUSED,
5235
6462
                               virConnectPtr conn,
5236
6463
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
5237
6464
                               remote_error *rerr,
5238
 
                               remote_node_list_devices_args *args,
5239
 
                               remote_node_list_devices_ret *ret)
5240
 
{
5241
 
    CHECK_CONN(client);
 
6465
                               remote_node_num_of_devices_args *args,
 
6466
                               remote_node_num_of_devices_ret *ret)
 
6467
{
 
6468
    int rv = -1;
 
6469
 
 
6470
    if (!conn) {
 
6471
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6472
        goto cleanup;
 
6473
    }
 
6474
 
 
6475
    if ((ret->num = virNodeNumOfDevices(conn,
 
6476
                                        args->cap ? *args->cap : NULL,
 
6477
                                        args->flags)) < 0)
 
6478
        goto cleanup;
 
6479
 
 
6480
    rv = 0;
 
6481
 
 
6482
cleanup:
 
6483
    if (rv < 0)
 
6484
        remoteDispatchError(rerr);
 
6485
    return rv;
 
6486
}
 
6487
 
 
6488
 
 
6489
static int
 
6490
remoteDispatchNodeListDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6491
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
6492
                              virConnectPtr conn,
 
6493
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6494
                              remote_error *rerr,
 
6495
                              remote_node_list_devices_args *args,
 
6496
                              remote_node_list_devices_ret *ret)
 
6497
{
 
6498
    int rv = -1;
 
6499
    int len;
 
6500
 
 
6501
    if (!conn) {
 
6502
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6503
        goto cleanup;
 
6504
    }
5242
6505
 
5243
6506
    if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
5244
 
        remoteDispatchFormatError(rerr,
5245
 
                                  "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
5246
 
        return -1;
 
6507
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
6508
                    "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
 
6509
        goto cleanup;
5247
6510
    }
5248
6511
 
5249
6512
    /* Allocate return buffer. */
5250
6513
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
5251
 
        remoteDispatchOOMError(rerr);
5252
 
        return -1;
 
6514
        virReportOOMError();
 
6515
        goto cleanup;
5253
6516
    }
5254
6517
 
5255
 
    ret->names.names_len =
5256
 
        virNodeListDevices (conn,
5257
 
                            args->cap ? *args->cap : NULL,
5258
 
                            ret->names.names_val, args->maxnames, args->flags);
5259
 
    if (ret->names.names_len == -1) {
5260
 
        remoteDispatchConnError(rerr, conn);
 
6518
    len = virNodeListDevices(conn,
 
6519
                             args->cap ? *args->cap : NULL,
 
6520
                             ret->names.names_val, args->maxnames, args->flags);
 
6521
    if (len < 0)
 
6522
        goto cleanup;
 
6523
    ret->names.names_len = len;
 
6524
 
 
6525
    rv = 0;
 
6526
 
 
6527
cleanup:
 
6528
    if (rv < 0) {
 
6529
        remoteDispatchError(rerr);
5261
6530
        VIR_FREE(ret->names.names_val);
5262
 
        return -1;
5263
 
    }
5264
 
 
5265
 
    return 0;
5266
 
}
5267
 
 
5268
 
 
5269
 
static int
5270
 
remoteDispatchNodeDeviceLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
5271
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
5272
 
                                      virConnectPtr conn,
5273
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
5274
 
                                      remote_error *rerr,
5275
 
                                      remote_node_device_lookup_by_name_args *args,
5276
 
                                      remote_node_device_lookup_by_name_ret *ret)
5277
 
{
5278
 
    virNodeDevicePtr dev;
5279
 
 
5280
 
    CHECK_CONN(client);
5281
 
 
5282
 
    dev = virNodeDeviceLookupByName (conn, args->name);
5283
 
    if (dev == NULL) {
5284
 
        remoteDispatchConnError(rerr, conn);
5285
 
        return -1;
5286
 
    }
5287
 
 
5288
 
    make_nonnull_node_device (&ret->dev, dev);
5289
 
    virNodeDeviceFree(dev);
5290
 
    return 0;
5291
 
}
5292
 
 
5293
 
 
5294
 
static int
5295
 
remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
5296
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
5297
 
                                 virConnectPtr conn,
5298
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
5299
 
                                 remote_error *rerr,
5300
 
                                 remote_node_device_dump_xml_args *args,
5301
 
                                 remote_node_device_dump_xml_ret *ret)
5302
 
{
5303
 
    virNodeDevicePtr dev;
5304
 
    CHECK_CONN(client);
5305
 
 
5306
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5307
 
    if (dev == NULL) {
5308
 
        remoteDispatchConnError(rerr, conn);
5309
 
        return -1;
5310
 
    }
 
6531
    }
 
6532
    return rv;
 
6533
}
 
6534
 
 
6535
 
 
6536
static int
 
6537
remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6538
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
6539
                                     virConnectPtr conn,
 
6540
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6541
                                     remote_error *rerr,
 
6542
                                     remote_node_device_lookup_by_name_args *args,
 
6543
                                     remote_node_device_lookup_by_name_ret *ret)
 
6544
{
 
6545
    virNodeDevicePtr dev = NULL;
 
6546
    int rv = -1;
 
6547
 
 
6548
    if (!conn) {
 
6549
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6550
        goto cleanup;
 
6551
    }
 
6552
 
 
6553
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6554
        goto cleanup;
 
6555
 
 
6556
    make_nonnull_node_device(&ret->dev, dev);
 
6557
 
 
6558
    rv = 0;
 
6559
 
 
6560
cleanup:
 
6561
    if (rv < 0)
 
6562
        remoteDispatchError(rerr);
 
6563
    if (dev)
 
6564
        virNodeDeviceFree(dev);
 
6565
    return rv;
 
6566
}
 
6567
 
 
6568
 
 
6569
static int
 
6570
remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6571
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
6572
                                virConnectPtr conn,
 
6573
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6574
                                remote_error *rerr,
 
6575
                                remote_node_device_dump_xml_args *args,
 
6576
                                remote_node_device_dump_xml_ret *ret)
 
6577
{
 
6578
    virNodeDevicePtr dev = NULL;
 
6579
    int rv = -1;
 
6580
 
 
6581
    if (!conn) {
 
6582
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6583
        goto cleanup;
 
6584
    }
 
6585
 
 
6586
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6587
        goto cleanup;
5311
6588
 
5312
6589
    /* remoteDispatchClientRequest will free this. */
5313
 
    ret->xml = virNodeDeviceGetXMLDesc (dev, args->flags);
5314
 
    if (!ret->xml) {
5315
 
        remoteDispatchConnError(rerr, conn);
 
6590
    if (!(ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags)))
 
6591
        goto cleanup;
 
6592
 
 
6593
    rv = 0;
 
6594
 
 
6595
cleanup:
 
6596
    if (rv < 0)
 
6597
        remoteDispatchError(rerr);
 
6598
    if (dev)
5316
6599
        virNodeDeviceFree(dev);
5317
 
        return -1;
5318
 
    }
5319
 
    virNodeDeviceFree(dev);
5320
 
    return 0;
 
6600
    return rv;
5321
6601
}
5322
6602
 
5323
6603
 
5324
6604
static int
5325
 
remoteDispatchNodeDeviceGetParent (struct qemud_server *server ATTRIBUTE_UNUSED,
5326
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
5327
 
                                   virConnectPtr conn,
5328
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
5329
 
                                   remote_error *rerr,
5330
 
                                   remote_node_device_get_parent_args *args,
5331
 
                                   remote_node_device_get_parent_ret *ret)
 
6605
remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6606
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
 
6607
                                  virConnectPtr conn,
 
6608
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6609
                                  remote_error *rerr,
 
6610
                                  remote_node_device_get_parent_args *args,
 
6611
                                  remote_node_device_get_parent_ret *ret)
5332
6612
{
5333
 
    virNodeDevicePtr dev;
5334
 
    const char *parent;
5335
 
    CHECK_CONN(client);
 
6613
    virNodeDevicePtr dev = NULL;
 
6614
    const char *parent = NULL;
 
6615
    int rv = -1;
5336
6616
 
5337
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5338
 
    if (dev == NULL) {
5339
 
        remoteDispatchConnError(rerr, conn);
5340
 
        return -1;
 
6617
    if (!conn) {
 
6618
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6619
        goto cleanup;
5341
6620
    }
5342
6621
 
 
6622
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6623
        goto cleanup;
 
6624
 
5343
6625
    parent = virNodeDeviceGetParent(dev);
5344
6626
 
5345
6627
    if (parent == NULL) {
5348
6630
        /* remoteDispatchClientRequest will free this. */
5349
6631
        char **parent_p;
5350
6632
        if (VIR_ALLOC(parent_p) < 0) {
5351
 
            virNodeDeviceFree(dev);
5352
 
            remoteDispatchOOMError(rerr);
5353
 
            return -1;
 
6633
            virReportOOMError();
 
6634
            goto cleanup;
5354
6635
        }
5355
 
        *parent_p = strdup(parent);
5356
 
        if (*parent_p == NULL) {
5357
 
            virNodeDeviceFree(dev);
5358
 
            remoteDispatchOOMError(rerr);
5359
 
            return -1;
 
6636
        if (!(*parent_p = strdup(parent))) {
 
6637
            VIR_FREE(parent_p);
 
6638
            virReportOOMError();
 
6639
            goto cleanup;
5360
6640
        }
5361
6641
        ret->parent = parent_p;
5362
6642
    }
5363
6643
 
5364
 
    virNodeDeviceFree(dev);
5365
 
    return 0;
5366
 
}
5367
 
 
5368
 
 
5369
 
static int
5370
 
remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
5371
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
5372
 
                                   virConnectPtr conn,
5373
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
5374
 
                                   remote_error *rerr,
5375
 
                                   remote_node_device_num_of_caps_args *args,
5376
 
                                   remote_node_device_num_of_caps_ret *ret)
5377
 
{
5378
 
    virNodeDevicePtr dev;
5379
 
    CHECK_CONN(client);
5380
 
 
5381
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5382
 
    if (dev == NULL) {
5383
 
        remoteDispatchConnError(rerr, conn);
5384
 
        return -1;
5385
 
    }
5386
 
 
5387
 
    ret->num = virNodeDeviceNumOfCaps(dev);
5388
 
    if (ret->num < 0) {
 
6644
    rv = 0;
 
6645
 
 
6646
cleanup:
 
6647
    if (rv < 0)
 
6648
        remoteDispatchError(rerr);
 
6649
    if (dev)
5389
6650
        virNodeDeviceFree(dev);
5390
 
        remoteDispatchConnError(rerr, conn);
5391
 
        return -1;
5392
 
    }
5393
 
 
5394
 
    virNodeDeviceFree(dev);
5395
 
    return 0;
 
6651
    return rv;
5396
6652
}
5397
6653
 
5398
6654
 
5399
6655
static int
5400
 
remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
 
6656
remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
5401
6657
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
5402
6658
                                  virConnectPtr conn,
5403
6659
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
5404
6660
                                  remote_error *rerr,
5405
 
                                  remote_node_device_list_caps_args *args,
5406
 
                                  remote_node_device_list_caps_ret *ret)
5407
 
{
5408
 
    virNodeDevicePtr dev;
5409
 
    CHECK_CONN(client);
5410
 
 
5411
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5412
 
    if (dev == NULL) {
5413
 
        remoteDispatchConnError(rerr, conn);
5414
 
        return -1;
5415
 
    }
 
6661
                                  remote_node_device_num_of_caps_args *args,
 
6662
                                  remote_node_device_num_of_caps_ret *ret)
 
6663
{
 
6664
    virNodeDevicePtr dev = NULL;
 
6665
    int rv = -1;
 
6666
 
 
6667
    if (!conn) {
 
6668
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6669
        goto cleanup;
 
6670
    }
 
6671
 
 
6672
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6673
        goto cleanup;
 
6674
 
 
6675
    if ((ret->num = virNodeDeviceNumOfCaps(dev)) < 0)
 
6676
        goto cleanup;
 
6677
 
 
6678
    rv = 0;
 
6679
 
 
6680
cleanup:
 
6681
    if (rv < 0)
 
6682
        remoteDispatchError(rerr);
 
6683
    if (dev)
 
6684
        virNodeDeviceFree(dev);
 
6685
    return rv;
 
6686
}
 
6687
 
 
6688
 
 
6689
static int
 
6690
remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6691
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
6692
                                 virConnectPtr conn,
 
6693
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6694
                                 remote_error *rerr,
 
6695
                                 remote_node_device_list_caps_args *args,
 
6696
                                 remote_node_device_list_caps_ret *ret)
 
6697
{
 
6698
    virNodeDevicePtr dev = NULL;
 
6699
    int rv = -1;
 
6700
    int len;
 
6701
 
 
6702
    if (!conn) {
 
6703
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6704
        goto cleanup;
 
6705
    }
 
6706
 
 
6707
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6708
        goto cleanup;
5416
6709
 
5417
6710
    if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
5418
 
        virNodeDeviceFree(dev);
5419
 
        remoteDispatchFormatError(rerr,
5420
 
                                  "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
5421
 
        return -1;
 
6711
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
6712
                    "%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
 
6713
        goto cleanup;
5422
6714
    }
5423
6715
 
5424
6716
    /* Allocate return buffer. */
5425
6717
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
5426
 
        virNodeDeviceFree(dev);
5427
 
        remoteDispatchOOMError(rerr);
5428
 
        return -1;
 
6718
        virReportOOMError();
 
6719
        goto cleanup;
5429
6720
    }
5430
6721
 
5431
 
    ret->names.names_len =
5432
 
        virNodeDeviceListCaps (dev, ret->names.names_val,
5433
 
                               args->maxnames);
5434
 
    if (ret->names.names_len == -1) {
5435
 
        virNodeDeviceFree(dev);
5436
 
        remoteDispatchConnError(rerr, conn);
 
6722
    len = virNodeDeviceListCaps(dev, ret->names.names_val,
 
6723
                                args->maxnames);
 
6724
    if (len < 0)
 
6725
        goto cleanup;
 
6726
    ret->names.names_len = len;
 
6727
 
 
6728
    rv = 0;
 
6729
 
 
6730
cleanup:
 
6731
    if (rv < 0) {
 
6732
        remoteDispatchError(rerr);
5437
6733
        VIR_FREE(ret->names.names_val);
5438
 
        return -1;
5439
 
    }
5440
 
 
5441
 
    virNodeDeviceFree(dev);
5442
 
    return 0;
5443
 
}
5444
 
 
5445
 
 
5446
 
static int
5447
 
remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
 
6734
    }
 
6735
    if (dev)
 
6736
        virNodeDeviceFree(dev);
 
6737
    return rv;
 
6738
}
 
6739
 
 
6740
 
 
6741
static int
 
6742
remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6743
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
6744
                                virConnectPtr conn,
 
6745
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6746
                                remote_error *rerr,
 
6747
                                remote_node_device_dettach_args *args,
 
6748
                                void *ret ATTRIBUTE_UNUSED)
 
6749
{
 
6750
    virNodeDevicePtr dev = NULL;
 
6751
    int rv = -1;
 
6752
 
 
6753
    if (!conn) {
 
6754
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6755
        goto cleanup;
 
6756
    }
 
6757
 
 
6758
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6759
        goto cleanup;
 
6760
 
 
6761
    if (virNodeDeviceDettach(dev) < 0)
 
6762
        goto cleanup;
 
6763
 
 
6764
    rv = 0;
 
6765
 
 
6766
cleanup:
 
6767
    if (rv < 0)
 
6768
        remoteDispatchError(rerr);
 
6769
    if (dev)
 
6770
        virNodeDeviceFree(dev);
 
6771
    return rv;
 
6772
}
 
6773
 
 
6774
 
 
6775
static int
 
6776
remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
5448
6777
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
5449
6778
                                 virConnectPtr conn,
5450
6779
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
5451
6780
                                 remote_error *rerr,
5452
 
                                 remote_node_device_dettach_args *args,
 
6781
                                 remote_node_device_re_attach_args *args,
5453
6782
                                 void *ret ATTRIBUTE_UNUSED)
5454
6783
{
5455
 
    virNodeDevicePtr dev;
5456
 
    CHECK_CONN(client);
5457
 
 
5458
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5459
 
    if (dev == NULL) {
5460
 
        remoteDispatchConnError(rerr, conn);
5461
 
        return -1;
5462
 
    }
5463
 
 
5464
 
    if (virNodeDeviceDettach(dev) == -1) {
5465
 
        virNodeDeviceFree(dev);
5466
 
        remoteDispatchConnError(rerr, conn);
5467
 
        return -1;
5468
 
    }
5469
 
 
5470
 
    virNodeDeviceFree(dev);
5471
 
    return 0;
5472
 
}
5473
 
 
5474
 
 
5475
 
static int
5476
 
remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
5477
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
5478
 
                                  virConnectPtr conn,
5479
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
5480
 
                                  remote_error *rerr,
5481
 
                                  remote_node_device_re_attach_args *args,
5482
 
                                  void *ret ATTRIBUTE_UNUSED)
5483
 
{
5484
 
    virNodeDevicePtr dev;
5485
 
    CHECK_CONN(client);
5486
 
 
5487
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5488
 
    if (dev == NULL) {
5489
 
        remoteDispatchConnError(rerr, conn);
5490
 
        return -1;
5491
 
    }
5492
 
 
5493
 
    if (virNodeDeviceReAttach(dev) == -1) {
5494
 
        virNodeDeviceFree(dev);
5495
 
        remoteDispatchConnError(rerr, conn);
5496
 
        return -1;
5497
 
    }
5498
 
 
5499
 
    virNodeDeviceFree(dev);
5500
 
    return 0;
5501
 
}
5502
 
 
5503
 
 
5504
 
static int
5505
 
remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
5506
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
5507
 
                               virConnectPtr conn,
5508
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
5509
 
                               remote_error *rerr,
5510
 
                               remote_node_device_reset_args *args,
5511
 
                               void *ret ATTRIBUTE_UNUSED)
5512
 
{
5513
 
    virNodeDevicePtr dev;
5514
 
    CHECK_CONN(client);
5515
 
 
5516
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5517
 
    if (dev == NULL) {
5518
 
        remoteDispatchConnError(rerr, conn);
5519
 
        return -1;
5520
 
    }
5521
 
 
5522
 
    if (virNodeDeviceReset(dev) == -1) {
5523
 
        virNodeDeviceFree(dev);
5524
 
        remoteDispatchConnError(rerr, conn);
5525
 
        return -1;
5526
 
    }
5527
 
 
5528
 
    virNodeDeviceFree(dev);
5529
 
    return 0;
 
6784
    virNodeDevicePtr dev = NULL;
 
6785
    int rv = -1;
 
6786
 
 
6787
    if (!conn) {
 
6788
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6789
        goto cleanup;
 
6790
    }
 
6791
 
 
6792
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6793
        goto cleanup;
 
6794
 
 
6795
    if (virNodeDeviceReAttach(dev) < 0)
 
6796
        goto cleanup;
 
6797
 
 
6798
    rv = 0;
 
6799
 
 
6800
cleanup:
 
6801
    if (rv < 0)
 
6802
        remoteDispatchError(rerr);
 
6803
    if (dev)
 
6804
        virNodeDeviceFree(dev);
 
6805
    return rv;
 
6806
}
 
6807
 
 
6808
 
 
6809
static int
 
6810
remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6811
                              struct qemud_client *client ATTRIBUTE_UNUSED,
 
6812
                              virConnectPtr conn,
 
6813
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
 
6814
                              remote_error *rerr,
 
6815
                              remote_node_device_reset_args *args,
 
6816
                              void *ret ATTRIBUTE_UNUSED)
 
6817
{
 
6818
    virNodeDevicePtr dev = NULL;
 
6819
    int rv = -1;
 
6820
 
 
6821
    if (!conn) {
 
6822
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6823
        goto cleanup;
 
6824
    }
 
6825
 
 
6826
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6827
        goto cleanup;
 
6828
 
 
6829
    if (virNodeDeviceReset(dev) < 0)
 
6830
        goto cleanup;
 
6831
 
 
6832
    rv = 0;
 
6833
 
 
6834
cleanup:
 
6835
    if (rv < 0)
 
6836
        remoteDispatchError(rerr);
 
6837
    if (dev)
 
6838
        virNodeDeviceFree(dev);
 
6839
    return rv;
5530
6840
}
5531
6841
 
5532
6842
 
5539
6849
                                  remote_node_device_create_xml_args *args,
5540
6850
                                  remote_node_device_create_xml_ret *ret)
5541
6851
{
5542
 
    virNodeDevicePtr dev;
 
6852
    virNodeDevicePtr dev = NULL;
 
6853
    int rv = -1;
5543
6854
 
5544
 
    dev = virNodeDeviceCreateXML (conn, args->xml_desc, args->flags);
5545
 
    if (dev == NULL) {
5546
 
        remoteDispatchConnError(rerr, conn);
5547
 
        return -1;
 
6855
    if (!conn) {
 
6856
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6857
        goto cleanup;
5548
6858
    }
5549
6859
 
5550
 
    make_nonnull_node_device (&ret->dev, dev);
5551
 
    virNodeDeviceFree(dev);
5552
 
 
5553
 
    return 0;
 
6860
    if (!(dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags)))
 
6861
        goto cleanup;
 
6862
 
 
6863
    make_nonnull_node_device(&ret->dev, dev);
 
6864
 
 
6865
    rv = 0;
 
6866
 
 
6867
cleanup:
 
6868
    if (rv < 0)
 
6869
        remoteDispatchError(rerr);
 
6870
    if (dev)
 
6871
        virNodeDeviceFree(dev);
 
6872
    return rv;
5554
6873
}
5555
6874
 
5556
6875
 
5563
6882
                                remote_node_device_destroy_args *args,
5564
6883
                                void *ret ATTRIBUTE_UNUSED)
5565
6884
{
5566
 
    virNodeDevicePtr dev;
 
6885
    virNodeDevicePtr dev = NULL;
 
6886
    int rv = -1;
5567
6887
 
5568
 
    dev = virNodeDeviceLookupByName(conn, args->name);
5569
 
    if (dev == NULL) {
5570
 
        remoteDispatchConnError(rerr, conn);
5571
 
        return -1;
 
6888
    if (!conn) {
 
6889
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6890
        goto cleanup;
5572
6891
    }
5573
6892
 
5574
 
    if (virNodeDeviceDestroy(dev) == -1) {
 
6893
    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
 
6894
        goto cleanup;
 
6895
 
 
6896
    if (virNodeDeviceDestroy(dev) < 0)
 
6897
        goto cleanup;
 
6898
 
 
6899
    rv = 0;
 
6900
 
 
6901
cleanup:
 
6902
    if (rv < 0)
 
6903
        remoteDispatchError(rerr);
 
6904
    if (dev)
5575
6905
        virNodeDeviceFree(dev);
5576
 
        remoteDispatchConnError(rerr, conn);
5577
 
        return -1;
5578
 
    }
5579
 
 
5580
 
    virNodeDeviceFree(dev);
5581
 
    return 0;
5582
 
}
5583
 
 
 
6906
    return rv;
 
6907
}
 
6908
 
 
6909
static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6910
                                          struct qemud_client *client,
 
6911
                                          virConnectPtr conn,
 
6912
                                          remote_message_header *hdr,
 
6913
                                          remote_error *rerr,
 
6914
                                          remote_storage_vol_upload_args *args,
 
6915
                                          void *ret ATTRIBUTE_UNUSED)
 
6916
{
 
6917
    struct qemud_client_stream *stream = NULL;
 
6918
    virStorageVolPtr vol = NULL;
 
6919
    int rv = -1;
 
6920
 
 
6921
    if (!conn) {
 
6922
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6923
        goto cleanup;
 
6924
    }
 
6925
 
 
6926
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6927
        goto cleanup;
 
6928
 
 
6929
    if (!(stream = remoteCreateClientStream(conn, hdr)))
 
6930
        goto cleanup;
 
6931
 
 
6932
    if (virStorageVolUpload(vol, stream->st,
 
6933
                            args->offset, args->length,
 
6934
                            args->flags) < 0)
 
6935
        goto cleanup;
 
6936
 
 
6937
    if (remoteAddClientStream(client, stream, 0) < 0)
 
6938
        goto cleanup;
 
6939
 
 
6940
    rv = 0;
 
6941
 
 
6942
cleanup:
 
6943
    if (rv < 0)
 
6944
        remoteDispatchError(rerr);
 
6945
    if (vol)
 
6946
        virStorageVolFree(vol);
 
6947
    if (stream && rv != 0) {
 
6948
        virStreamAbort(stream->st);
 
6949
        remoteFreeClientStream(client, stream);
 
6950
    }
 
6951
    return rv;
 
6952
}
 
6953
 
 
6954
static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUTE_UNUSED,
 
6955
                                            struct qemud_client *client,
 
6956
                                            virConnectPtr conn,
 
6957
                                            remote_message_header *hdr,
 
6958
                                            remote_error *rerr,
 
6959
                                            remote_storage_vol_download_args *args,
 
6960
                                            void *ret ATTRIBUTE_UNUSED)
 
6961
{
 
6962
    struct qemud_client_stream *stream = NULL;
 
6963
    virStorageVolPtr vol = NULL;
 
6964
    int rv = -1;
 
6965
 
 
6966
    if (!conn) {
 
6967
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
6968
        goto cleanup;
 
6969
    }
 
6970
 
 
6971
    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
 
6972
        goto cleanup;
 
6973
 
 
6974
    if (!(stream = remoteCreateClientStream(conn, hdr)))
 
6975
        goto cleanup;
 
6976
 
 
6977
    if (virStorageVolDownload(vol, stream->st,
 
6978
                              args->offset, args->length,
 
6979
                              args->flags) < 0)
 
6980
        goto cleanup;
 
6981
 
 
6982
    if (remoteAddClientStream(client, stream, 1) < 0)
 
6983
        goto cleanup;
 
6984
 
 
6985
    rv = 0;
 
6986
 
 
6987
cleanup:
 
6988
    if (rv < 0)
 
6989
        remoteDispatchError(rerr);
 
6990
    if (vol)
 
6991
        virStorageVolFree(vol);
 
6992
    if (stream && rv != 0) {
 
6993
        virStreamAbort(stream->st);
 
6994
        remoteFreeClientStream(client, stream);
 
6995
    }
 
6996
    return rv;
 
6997
}
5584
6998
 
5585
6999
 
5586
7000
/***************************
5587
7001
 * Register / deregister events
5588
7002
 ***************************/
5589
7003
static int
5590
 
remoteDispatchDomainEventsRegister (struct qemud_server *server ATTRIBUTE_UNUSED,
5591
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
5592
 
                                    virConnectPtr conn,
5593
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
5594
 
                                    remote_error *rerr ATTRIBUTE_UNUSED,
5595
 
                                    void *args ATTRIBUTE_UNUSED,
5596
 
                                    remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
 
7004
remoteDispatchDomainEventsRegister(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7005
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
7006
                                   virConnectPtr conn,
 
7007
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7008
                                   remote_error *rerr ATTRIBUTE_UNUSED,
 
7009
                                   void *args ATTRIBUTE_UNUSED,
 
7010
                                   remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
5597
7011
{
5598
 
    CHECK_CONN(client);
5599
7012
    int callbackID;
 
7013
    int rv = -1;
 
7014
 
 
7015
    if (!conn) {
 
7016
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7017
        goto cleanup;
 
7018
    }
5600
7019
 
5601
7020
    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
5602
 
        remoteDispatchFormatError(rerr, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
5603
 
        return -1;
 
7021
        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
 
7022
        goto cleanup;
5604
7023
    }
5605
7024
 
5606
7025
    if ((callbackID = virConnectDomainEventRegisterAny(conn,
5607
7026
                                                       NULL,
5608
7027
                                                       VIR_DOMAIN_EVENT_ID_LIFECYCLE,
5609
7028
                                                       VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
5610
 
                                                       client, NULL)) < 0) {
5611
 
        remoteDispatchConnError(rerr, conn);
5612
 
        return -1;
5613
 
    }
 
7029
                                                       client, NULL)) < 0)
 
7030
        goto cleanup;
5614
7031
 
5615
7032
    client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
5616
7033
 
5617
 
    return 0;
 
7034
    rv = 0;
 
7035
 
 
7036
cleanup:
 
7037
    if (rv < 0)
 
7038
        remoteDispatchError(rerr);
 
7039
    return rv;
5618
7040
}
5619
7041
 
5620
7042
static int
5621
 
remoteDispatchDomainEventsDeregister (struct qemud_server *server ATTRIBUTE_UNUSED,
5622
 
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
5623
 
                                      virConnectPtr conn,
5624
 
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
5625
 
                                      remote_error *rerr ATTRIBUTE_UNUSED,
5626
 
                                      void *args ATTRIBUTE_UNUSED,
5627
 
                                      remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
 
7043
remoteDispatchDomainEventsDeregister(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7044
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
7045
                                     virConnectPtr conn,
 
7046
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7047
                                     remote_error *rerr ATTRIBUTE_UNUSED,
 
7048
                                     void *args ATTRIBUTE_UNUSED,
 
7049
                                     remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
5628
7050
{
5629
 
    CHECK_CONN(client);
5630
 
 
5631
 
    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] == -1) {
5632
 
        remoteDispatchFormatError(rerr, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
5633
 
        return -1;
 
7051
    int rv = -1;
 
7052
 
 
7053
    if (!conn) {
 
7054
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7055
        goto cleanup;
 
7056
    }
 
7057
 
 
7058
    if (client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] < 0) {
 
7059
        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
 
7060
        goto cleanup;
5634
7061
    }
5635
7062
 
5636
7063
    if (virConnectDomainEventDeregisterAny(conn,
5637
 
                                           client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0) {
5638
 
        remoteDispatchConnError(rerr, conn);
5639
 
        return -1;
5640
 
    }
 
7064
                                           client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0)
 
7065
        goto cleanup;
5641
7066
 
5642
7067
    client->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
5643
 
    return 0;
 
7068
    rv = 0;
 
7069
 
 
7070
cleanup:
 
7071
    if (rv < 0)
 
7072
        remoteDispatchError(rerr);
 
7073
    return rv;
5644
7074
}
5645
7075
 
5646
7076
static void
5647
 
remoteDispatchDomainEventSend (struct qemud_client *client,
5648
 
                               int procnr,
5649
 
                               xdrproc_t proc,
5650
 
                               void *data)
 
7077
remoteDispatchDomainEventSend(struct qemud_client *client,
 
7078
                              int procnr,
 
7079
                              xdrproc_t proc,
 
7080
                              void *data)
5651
7081
{
5652
7082
    struct qemud_client_message *msg = NULL;
5653
7083
    XDR xdr;
5664
7094
    msg->hdr.status = REMOTE_OK;
5665
7095
 
5666
7096
    if (remoteEncodeClientMessageHeader(msg) < 0)
5667
 
        goto error;
 
7097
        goto cleanup;
5668
7098
 
5669
7099
    /* Serialise the return header and event. */
5670
 
    xdrmem_create (&xdr,
5671
 
                   msg->buffer,
5672
 
                   msg->bufferLength,
5673
 
                   XDR_ENCODE);
 
7100
    xdrmem_create(&xdr,
 
7101
                  msg->buffer,
 
7102
                  msg->bufferLength,
 
7103
                  XDR_ENCODE);
5674
7104
 
5675
7105
    /* Skip over the header we just wrote */
5676
 
    if (xdr_setpos (&xdr, msg->bufferOffset) == 0)
5677
 
        goto xdr_error;
 
7106
    if (xdr_setpos(&xdr, msg->bufferOffset) == 0)
 
7107
        goto xdr_cleanup;
5678
7108
 
5679
7109
    if (!(proc)(&xdr, data)) {
5680
7110
        VIR_WARN("Failed to serialize domain event %d", procnr);
5681
 
        goto xdr_error;
 
7111
        goto xdr_cleanup;
5682
7112
    }
5683
7113
 
5684
7114
    /* Update length word to include payload*/
5685
 
    len = msg->bufferOffset = xdr_getpos (&xdr);
5686
 
    if (xdr_setpos (&xdr, 0) == 0)
5687
 
        goto xdr_error;
 
7115
    len = msg->bufferOffset = xdr_getpos(&xdr);
 
7116
    if (xdr_setpos(&xdr, 0) == 0)
 
7117
        goto xdr_cleanup;
5688
7118
 
5689
 
    if (!xdr_u_int (&xdr, &len))
5690
 
        goto xdr_error;
 
7119
    if (!xdr_u_int(&xdr, &len))
 
7120
        goto xdr_cleanup;
5691
7121
 
5692
7122
    /* Send it. */
5693
7123
    msg->async = 1;
5698
7128
    qemudClientMessageQueuePush(&client->tx, msg);
5699
7129
    qemudUpdateClientEvent(client);
5700
7130
 
5701
 
    xdr_destroy (&xdr);
 
7131
    xdr_destroy(&xdr);
5702
7132
    return;
5703
7133
 
5704
 
xdr_error:
 
7134
xdr_cleanup:
5705
7135
    xdr_destroy(&xdr);
5706
 
error:
 
7136
cleanup:
5707
7137
    VIR_FREE(msg);
5708
7138
}
5709
7139
 
5710
7140
static int
5711
 
remoteDispatchNumOfSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
5712
 
                            struct qemud_client *client ATTRIBUTE_UNUSED,
5713
 
                            virConnectPtr conn,
5714
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
5715
 
                            remote_error *err,
5716
 
                            void *args ATTRIBUTE_UNUSED,
5717
 
                            remote_num_of_secrets_ret *ret)
5718
 
{
5719
 
    ret->num = virConnectNumOfSecrets (conn);
5720
 
    if (ret->num == -1) {
5721
 
        remoteDispatchConnError (err, conn);
5722
 
        return -1;
5723
 
    }
5724
 
 
5725
 
    return 0;
5726
 
}
5727
 
 
5728
 
static int
5729
 
remoteDispatchListSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
 
7141
remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
5730
7142
                           struct qemud_client *client ATTRIBUTE_UNUSED,
5731
7143
                           virConnectPtr conn,
5732
7144
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
5733
 
                           remote_error *err,
5734
 
                           remote_list_secrets_args *args,
5735
 
                           remote_list_secrets_ret *ret)
5736
 
{
 
7145
                           remote_error *rerr,
 
7146
                           void *args ATTRIBUTE_UNUSED,
 
7147
                           remote_num_of_secrets_ret *ret)
 
7148
{
 
7149
    int rv = -1;
 
7150
 
 
7151
    if (!conn) {
 
7152
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7153
        goto cleanup;
 
7154
    }
 
7155
 
 
7156
    if ((ret->num = virConnectNumOfSecrets(conn)) < 0)
 
7157
        goto cleanup;
 
7158
 
 
7159
    rv = 0;
 
7160
 
 
7161
cleanup:
 
7162
    if (rv < 0)
 
7163
        remoteDispatchError(rerr);
 
7164
    return rv;
 
7165
}
 
7166
 
 
7167
static int
 
7168
remoteDispatchListSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7169
                          struct qemud_client *client ATTRIBUTE_UNUSED,
 
7170
                          virConnectPtr conn,
 
7171
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7172
                          remote_error *rerr,
 
7173
                          remote_list_secrets_args *args,
 
7174
                          remote_list_secrets_ret *ret)
 
7175
{
 
7176
    int rv = -1;
 
7177
    int len;
 
7178
 
 
7179
    if (!conn) {
 
7180
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7181
        goto cleanup;
 
7182
    }
 
7183
 
5737
7184
    if (args->maxuuids > REMOTE_SECRET_UUID_LIST_MAX) {
5738
 
        remoteDispatchFormatError (err, "%s",
5739
 
                                   _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
5740
 
        return -1;
5741
 
    }
5742
 
 
5743
 
    if (VIR_ALLOC_N (ret->uuids.uuids_val, args->maxuuids) < 0) {
5744
 
        remoteDispatchOOMError (err);
5745
 
        return -1;
5746
 
    }
5747
 
 
5748
 
    ret->uuids.uuids_len = virConnectListSecrets (conn, ret->uuids.uuids_val,
5749
 
                                                  args->maxuuids);
5750
 
    if (ret->uuids.uuids_len == -1) {
5751
 
        VIR_FREE (ret->uuids.uuids_val);
5752
 
        remoteDispatchConnError (err, conn);
5753
 
        return -1;
5754
 
    }
5755
 
 
5756
 
    return 0;
5757
 
}
5758
 
 
5759
 
static int
5760
 
remoteDispatchSecretDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
5761
 
                               struct qemud_client *client ATTRIBUTE_UNUSED,
5762
 
                               virConnectPtr conn,
5763
 
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
5764
 
                               remote_error *err,
5765
 
                               remote_secret_define_xml_args *args,
5766
 
                               remote_secret_define_xml_ret *ret)
5767
 
{
5768
 
    virSecretPtr secret;
5769
 
 
5770
 
    secret = virSecretDefineXML (conn, args->xml, args->flags);
5771
 
    if (secret == NULL) {
5772
 
        remoteDispatchConnError (err, conn);
5773
 
        return -1;
5774
 
    }
5775
 
 
5776
 
    make_nonnull_secret (&ret->secret, secret);
5777
 
    virSecretFree (secret);
5778
 
    return 0;
5779
 
}
5780
 
 
5781
 
static int
5782
 
remoteDispatchSecretGetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
 
7185
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
 
7186
                    _("maxuuids > REMOTE_SECRET_UUID_LIST_MAX"));
 
7187
        goto cleanup;
 
7188
    }
 
7189
 
 
7190
    if (VIR_ALLOC_N(ret->uuids.uuids_val, args->maxuuids) < 0) {
 
7191
        virReportOOMError();
 
7192
        goto cleanup;
 
7193
    }
 
7194
 
 
7195
    len = virConnectListSecrets(conn, ret->uuids.uuids_val,
 
7196
                                args->maxuuids);
 
7197
    if (len < 0)
 
7198
        goto cleanup;
 
7199
    ret->uuids.uuids_len = len;
 
7200
 
 
7201
    rv = 0;
 
7202
 
 
7203
cleanup:
 
7204
    if (rv < 0) {
 
7205
        remoteDispatchError(rerr);
 
7206
        VIR_FREE(ret->uuids.uuids_val);
 
7207
    }
 
7208
    return rv;
 
7209
}
 
7210
 
 
7211
static int
 
7212
remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
5783
7213
                              struct qemud_client *client ATTRIBUTE_UNUSED,
5784
7214
                              virConnectPtr conn,
5785
7215
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
5786
 
                              remote_error *err,
5787
 
                              remote_secret_get_value_args *args,
5788
 
                              remote_secret_get_value_ret *ret)
5789
 
{
5790
 
    virSecretPtr secret;
 
7216
                              remote_error *rerr,
 
7217
                              remote_secret_define_xml_args *args,
 
7218
                              remote_secret_define_xml_ret *ret)
 
7219
{
 
7220
    virSecretPtr secret = NULL;
 
7221
    int rv = -1;
 
7222
 
 
7223
    if (!conn) {
 
7224
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7225
        goto cleanup;
 
7226
    }
 
7227
 
 
7228
    if (!(secret = virSecretDefineXML(conn, args->xml, args->flags)))
 
7229
        goto cleanup;
 
7230
 
 
7231
    make_nonnull_secret(&ret->secret, secret);
 
7232
    rv = 0;
 
7233
 
 
7234
cleanup:
 
7235
    if (rv < 0)
 
7236
        remoteDispatchError(rerr);
 
7237
    if (secret)
 
7238
        virSecretFree(secret);
 
7239
    return rv;
 
7240
}
 
7241
 
 
7242
static int
 
7243
remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7244
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
7245
                             virConnectPtr conn,
 
7246
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7247
                             remote_error *rerr,
 
7248
                             remote_secret_get_value_args *args,
 
7249
                             remote_secret_get_value_ret *ret)
 
7250
{
 
7251
    virSecretPtr secret = NULL;
5791
7252
    size_t value_size;
5792
7253
    unsigned char *value;
5793
 
 
5794
 
    secret = get_nonnull_secret (conn, args->secret);
5795
 
    if (secret == NULL) {
5796
 
        remoteDispatchConnError (err, conn);
5797
 
        return -1;
5798
 
    }
5799
 
 
5800
 
    value = virSecretGetValue (secret, &value_size, args->flags);
5801
 
    if (value == NULL) {
5802
 
        remoteDispatchConnError (err, conn);
5803
 
        virSecretFree(secret);
5804
 
        return -1;
5805
 
    }
 
7254
    int rv = -1;
 
7255
 
 
7256
    if (!conn) {
 
7257
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7258
        goto cleanup;
 
7259
    }
 
7260
 
 
7261
    if (!(secret = get_nonnull_secret(conn, args->secret)))
 
7262
        goto cleanup;
 
7263
 
 
7264
    if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
 
7265
        goto cleanup;
5806
7266
 
5807
7267
    ret->value.value_len = value_size;
5808
7268
    ret->value.value_val = (char *)value;
5809
 
    virSecretFree(secret);
5810
 
    return 0;
5811
 
}
5812
 
 
5813
 
static int
5814
 
remoteDispatchSecretGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
5815
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
5816
 
                                virConnectPtr conn,
5817
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
5818
 
                                remote_error *err,
5819
 
                                remote_secret_get_xml_desc_args *args,
5820
 
                                remote_secret_get_xml_desc_ret *ret)
5821
 
{
5822
 
    virSecretPtr secret;
5823
 
 
5824
 
    secret = get_nonnull_secret (conn, args->secret);
5825
 
    if (secret == NULL) {
5826
 
        remoteDispatchConnError (err, conn);
5827
 
        return -1;
5828
 
    }
5829
 
    ret->xml = virSecretGetXMLDesc (secret, args->flags);
5830
 
    if (ret->xml == NULL) {
5831
 
        remoteDispatchConnError (err, conn);
5832
 
        virSecretFree(secret);
5833
 
        return -1;
5834
 
    }
5835
 
    virSecretFree(secret);
5836
 
    return 0;
5837
 
}
5838
 
 
5839
 
static int
5840
 
remoteDispatchSecretLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
 
7269
 
 
7270
    rv = 0;
 
7271
 
 
7272
cleanup:
 
7273
    if (rv < 0)
 
7274
        remoteDispatchError(rerr);
 
7275
    if (secret)
 
7276
        virSecretFree(secret);
 
7277
    return rv;
 
7278
}
 
7279
 
 
7280
static int
 
7281
remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7282
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
7283
                               virConnectPtr conn,
 
7284
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7285
                               remote_error *rerr,
 
7286
                               remote_secret_get_xml_desc_args *args,
 
7287
                               remote_secret_get_xml_desc_ret *ret)
 
7288
{
 
7289
    virSecretPtr secret = NULL;
 
7290
    int rv = -1;
 
7291
 
 
7292
    if (!conn) {
 
7293
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7294
        goto cleanup;
 
7295
    }
 
7296
 
 
7297
    if (!(secret = get_nonnull_secret(conn, args->secret)))
 
7298
        goto cleanup;
 
7299
    if (!(ret->xml = virSecretGetXMLDesc(secret, args->flags)))
 
7300
        goto cleanup;
 
7301
 
 
7302
    rv = 0;
 
7303
 
 
7304
cleanup:
 
7305
    if (rv < 0)
 
7306
        remoteDispatchError(rerr);
 
7307
    if (secret)
 
7308
        virSecretFree(secret);
 
7309
    return rv;
 
7310
}
 
7311
 
 
7312
static int
 
7313
remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7314
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
7315
                                 virConnectPtr conn,
 
7316
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7317
                                 remote_error *rerr,
 
7318
                                 remote_secret_lookup_by_uuid_args *args,
 
7319
                                 remote_secret_lookup_by_uuid_ret *ret)
 
7320
{
 
7321
    virSecretPtr secret = NULL;
 
7322
    int rv = -1;
 
7323
 
 
7324
    if (!conn) {
 
7325
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7326
        goto cleanup;
 
7327
    }
 
7328
 
 
7329
    if (!(secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid)))
 
7330
        goto cleanup;
 
7331
 
 
7332
    make_nonnull_secret(&ret->secret, secret);
 
7333
 
 
7334
    rv = 0;
 
7335
 
 
7336
cleanup:
 
7337
    if (rv < 0)
 
7338
        remoteDispatchError(rerr);
 
7339
    if (secret)
 
7340
        virSecretFree(secret);
 
7341
    return rv;
 
7342
}
 
7343
 
 
7344
static int
 
7345
remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7346
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
7347
                             virConnectPtr conn,
 
7348
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7349
                             remote_error *rerr,
 
7350
                             remote_secret_set_value_args *args,
 
7351
                             void *ret ATTRIBUTE_UNUSED)
 
7352
{
 
7353
    virSecretPtr secret = NULL;
 
7354
    int rv = -1;
 
7355
 
 
7356
    if (!conn) {
 
7357
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7358
        goto cleanup;
 
7359
    }
 
7360
 
 
7361
    if (!(secret = get_nonnull_secret(conn, args->secret)))
 
7362
        goto cleanup;
 
7363
    if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
 
7364
                          args->value.value_len, args->flags) < 0)
 
7365
        goto cleanup;
 
7366
 
 
7367
    rv = 0;
 
7368
 
 
7369
cleanup:
 
7370
    if (rv < 0)
 
7371
        remoteDispatchError(rerr);
 
7372
    if (secret)
 
7373
        virSecretFree(secret);
 
7374
    return rv;
 
7375
}
 
7376
 
 
7377
static int
 
7378
remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7379
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
7380
                             virConnectPtr conn,
 
7381
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7382
                             remote_error *rerr,
 
7383
                             remote_secret_undefine_args *args,
 
7384
                             void *ret ATTRIBUTE_UNUSED)
 
7385
{
 
7386
    virSecretPtr secret = NULL;
 
7387
    int rv = -1;
 
7388
 
 
7389
    if (!conn) {
 
7390
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7391
        goto cleanup;
 
7392
    }
 
7393
 
 
7394
    if (!(secret = get_nonnull_secret(conn, args->secret)))
 
7395
        goto cleanup;
 
7396
    if (virSecretUndefine(secret) < 0)
 
7397
        goto cleanup;
 
7398
 
 
7399
    rv = 0;
 
7400
 
 
7401
cleanup:
 
7402
    if (rv < 0)
 
7403
        remoteDispatchError(rerr);
 
7404
    if (secret)
 
7405
        virSecretFree(secret);
 
7406
    return rv;
 
7407
}
 
7408
 
 
7409
static int
 
7410
remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
5841
7411
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
5842
7412
                                  virConnectPtr conn,
5843
7413
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
5844
 
                                  remote_error *err,
5845
 
                                  remote_secret_lookup_by_uuid_args *args,
5846
 
                                  remote_secret_lookup_by_uuid_ret *ret)
5847
 
{
5848
 
    virSecretPtr secret;
5849
 
 
5850
 
    secret = virSecretLookupByUUID (conn, (unsigned char *)args->uuid);
5851
 
    if (secret == NULL) {
5852
 
        remoteDispatchConnError (err, conn);
5853
 
        return -1;
5854
 
    }
5855
 
 
5856
 
    make_nonnull_secret (&ret->secret, secret);
5857
 
    virSecretFree (secret);
5858
 
    return 0;
5859
 
}
5860
 
 
5861
 
static int
5862
 
remoteDispatchSecretSetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
5863
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
5864
 
                              virConnectPtr conn,
5865
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
5866
 
                              remote_error *err,
5867
 
                              remote_secret_set_value_args *args,
5868
 
                              void *ret ATTRIBUTE_UNUSED)
5869
 
{
5870
 
    virSecretPtr secret;
5871
 
 
5872
 
    secret = get_nonnull_secret (conn, args->secret);
5873
 
    if (secret == NULL) {
5874
 
        remoteDispatchConnError (err, conn);
5875
 
        return -1;
5876
 
    }
5877
 
    if (virSecretSetValue (secret, (const unsigned char *)args->value.value_val,
5878
 
                           args->value.value_len, args->flags) < 0) {
5879
 
        remoteDispatchConnError (err, conn);
5880
 
        virSecretFree(secret);
5881
 
        return -1;
5882
 
    }
5883
 
 
5884
 
    virSecretFree(secret);
5885
 
    return 0;
5886
 
}
5887
 
 
5888
 
static int
5889
 
remoteDispatchSecretUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
5890
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
5891
 
                              virConnectPtr conn,
5892
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
5893
 
                              remote_error *err,
5894
 
                              remote_secret_undefine_args *args,
5895
 
                              void *ret ATTRIBUTE_UNUSED)
5896
 
{
5897
 
    virSecretPtr secret;
5898
 
 
5899
 
    secret = get_nonnull_secret (conn, args->secret);
5900
 
    if (secret == NULL) {
5901
 
        remoteDispatchConnError (err, conn);
5902
 
        return -1;
5903
 
    }
5904
 
    if (virSecretUndefine (secret) < 0) {
5905
 
        remoteDispatchConnError (err, conn);
5906
 
        virSecretFree(secret);
5907
 
        return -1;
5908
 
    }
5909
 
 
5910
 
    virSecretFree(secret);
5911
 
    return 0;
5912
 
}
5913
 
 
5914
 
static int
5915
 
remoteDispatchSecretLookupByUsage (struct qemud_server *server ATTRIBUTE_UNUSED,
5916
 
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
5917
 
                                   virConnectPtr conn,
5918
 
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
5919
 
                                   remote_error *err,
5920
 
                                   remote_secret_lookup_by_usage_args *args,
5921
 
                                   remote_secret_lookup_by_usage_ret *ret)
5922
 
{
5923
 
    virSecretPtr secret;
5924
 
 
5925
 
    secret = virSecretLookupByUsage (conn, args->usageType, args->usageID);
5926
 
    if (secret == NULL) {
5927
 
        remoteDispatchConnError (err, conn);
5928
 
        return -1;
5929
 
    }
5930
 
 
5931
 
    make_nonnull_secret (&ret->secret, secret);
5932
 
    virSecretFree (secret);
5933
 
    return 0;
 
7414
                                  remote_error *rerr,
 
7415
                                  remote_secret_lookup_by_usage_args *args,
 
7416
                                  remote_secret_lookup_by_usage_ret *ret)
 
7417
{
 
7418
    virSecretPtr secret = NULL;
 
7419
    int rv = -1;
 
7420
 
 
7421
    if (!conn) {
 
7422
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7423
        goto cleanup;
 
7424
    }
 
7425
 
 
7426
    if (!(secret = virSecretLookupByUsage(conn, args->usageType, args->usageID)))
 
7427
        goto cleanup;
 
7428
 
 
7429
    make_nonnull_secret(&ret->secret, secret);
 
7430
 
 
7431
    rv = 0;
 
7432
 
 
7433
cleanup:
 
7434
    if (rv < 0)
 
7435
        remoteDispatchError(rerr);
 
7436
    if (secret)
 
7437
        virSecretFree(secret);
 
7438
    return rv;
5934
7439
}
5935
7440
 
5936
7441
 
5938
7443
                                        struct qemud_client *client ATTRIBUTE_UNUSED,
5939
7444
                                        virConnectPtr conn,
5940
7445
                                        remote_message_header *hdr ATTRIBUTE_UNUSED,
5941
 
                                        remote_error *err,
 
7446
                                        remote_error *rerr,
5942
7447
                                        remote_domain_is_active_args *args,
5943
7448
                                        remote_domain_is_active_ret *ret)
5944
7449
{
5945
 
    virDomainPtr domain;
5946
 
 
5947
 
    domain = get_nonnull_domain(conn, args->dom);
5948
 
    if (domain == NULL) {
5949
 
        remoteDispatchConnError(err, conn);
5950
 
        return -1;
5951
 
    }
5952
 
 
5953
 
    ret->active = virDomainIsActive(domain);
5954
 
 
5955
 
    if (ret->active < 0) {
5956
 
        virDomainFree(domain);
5957
 
        remoteDispatchConnError(err, conn);
5958
 
        return -1;
5959
 
    }
5960
 
 
5961
 
    virDomainFree(domain);
5962
 
    return 0;
 
7450
    virDomainPtr dom = NULL;
 
7451
    int rv = -1;
 
7452
 
 
7453
    if (!conn) {
 
7454
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7455
        goto cleanup;
 
7456
    }
 
7457
 
 
7458
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7459
        goto cleanup;
 
7460
 
 
7461
    if ((ret->active = virDomainIsActive(dom)) < 0)
 
7462
        goto cleanup;
 
7463
 
 
7464
    rv = 0;
 
7465
 
 
7466
cleanup:
 
7467
    if (rv < 0)
 
7468
        remoteDispatchError(rerr);
 
7469
    if (dom)
 
7470
        virDomainFree(dom);
 
7471
    return rv;
5963
7472
}
5964
7473
 
5965
7474
static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
5966
7475
                                            struct qemud_client *client ATTRIBUTE_UNUSED,
5967
7476
                                            virConnectPtr conn,
5968
7477
                                            remote_message_header *hdr ATTRIBUTE_UNUSED,
5969
 
                                            remote_error *err,
 
7478
                                            remote_error *rerr,
5970
7479
                                            remote_domain_is_persistent_args *args,
5971
7480
                                            remote_domain_is_persistent_ret *ret)
5972
7481
{
5973
 
    virDomainPtr domain;
5974
 
 
5975
 
    domain = get_nonnull_domain(conn, args->dom);
5976
 
    if (domain == NULL) {
5977
 
        remoteDispatchConnError(err, conn);
5978
 
        return -1;
5979
 
    }
5980
 
 
5981
 
    ret->persistent = virDomainIsPersistent(domain);
5982
 
 
5983
 
    if (ret->persistent < 0) {
5984
 
        virDomainFree(domain);
5985
 
        remoteDispatchConnError(err, conn);
5986
 
        return -1;
5987
 
    }
5988
 
 
5989
 
    virDomainFree(domain);
5990
 
    return 0;
 
7482
    virDomainPtr dom = NULL;
 
7483
    int rv = -1;
 
7484
 
 
7485
    if (!conn) {
 
7486
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7487
        goto cleanup;
 
7488
    }
 
7489
 
 
7490
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7491
        goto cleanup;
 
7492
 
 
7493
    if ((ret->persistent = virDomainIsPersistent(dom)) < 0)
 
7494
        goto cleanup;
 
7495
 
 
7496
    rv = 0;
 
7497
 
 
7498
cleanup:
 
7499
    if (rv < 0)
 
7500
        remoteDispatchError(rerr);
 
7501
    if (dom)
 
7502
        virDomainFree(dom);
 
7503
    return rv;
5991
7504
}
5992
7505
 
5993
7506
static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_UNUSED,
5994
7507
                                            struct qemud_client *client ATTRIBUTE_UNUSED,
5995
7508
                                            virConnectPtr conn,
5996
7509
                                            remote_message_header *hdr ATTRIBUTE_UNUSED,
5997
 
                                            remote_error *err,
 
7510
                                            remote_error *rerr,
5998
7511
                                            remote_domain_is_updated_args *args,
5999
7512
                                            remote_domain_is_updated_ret *ret)
6000
7513
{
6001
 
    virDomainPtr domain;
6002
 
 
6003
 
    domain = get_nonnull_domain(conn, args->dom);
6004
 
    if (domain == NULL) {
6005
 
        remoteDispatchConnError(err, conn);
6006
 
        return -1;
6007
 
    }
6008
 
 
6009
 
    ret->updated = virDomainIsUpdated(domain);
6010
 
 
6011
 
    if (ret->updated < 0) {
6012
 
        virDomainFree(domain);
6013
 
        remoteDispatchConnError(err, conn);
6014
 
        return -1;
6015
 
    }
6016
 
 
6017
 
    virDomainFree(domain);
6018
 
    return 0;
 
7514
    virDomainPtr dom = NULL;
 
7515
    int rv = -1;
 
7516
 
 
7517
    if (!conn) {
 
7518
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7519
        goto cleanup;
 
7520
    }
 
7521
 
 
7522
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7523
        goto cleanup;
 
7524
 
 
7525
    if ((ret->updated = virDomainIsUpdated(dom)) < 0)
 
7526
        goto cleanup;
 
7527
 
 
7528
    rv = 0;
 
7529
 
 
7530
cleanup:
 
7531
    if (rv < 0)
 
7532
        remoteDispatchError(rerr);
 
7533
    if (dom)
 
7534
        virDomainFree(dom);
 
7535
    return rv;
6019
7536
}
6020
7537
 
6021
7538
static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
6022
7539
                                           struct qemud_client *client ATTRIBUTE_UNUSED,
6023
7540
                                           virConnectPtr conn,
6024
7541
                                           remote_message_header *hdr ATTRIBUTE_UNUSED,
6025
 
                                           remote_error *err,
 
7542
                                           remote_error *rerr,
6026
7543
                                           remote_interface_is_active_args *args,
6027
7544
                                           remote_interface_is_active_ret *ret)
6028
7545
{
6029
 
    virInterfacePtr iface;
 
7546
    virInterfacePtr iface = NULL;
 
7547
    int rv = -1;
6030
7548
 
6031
 
    iface = get_nonnull_interface(conn, args->iface);
6032
 
    if (iface == NULL) {
6033
 
        remoteDispatchConnError(err, conn);
6034
 
        return -1;
 
7549
    if (!conn) {
 
7550
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7551
        goto cleanup;
6035
7552
    }
6036
7553
 
6037
 
    ret->active = virInterfaceIsActive(iface);
6038
 
 
6039
 
    if (ret->active < 0) {
 
7554
    if (!(iface = get_nonnull_interface(conn, args->iface)))
 
7555
        goto cleanup;
 
7556
 
 
7557
    if ((ret->active = virInterfaceIsActive(iface)) < 0)
 
7558
        goto cleanup;
 
7559
 
 
7560
    rv = 0;
 
7561
 
 
7562
cleanup:
 
7563
    if (rv < 0)
 
7564
        remoteDispatchError(rerr);
 
7565
    if (iface)
6040
7566
        virInterfaceFree(iface);
6041
 
        remoteDispatchConnError(err, conn);
6042
 
        return -1;
6043
 
    }
6044
 
 
6045
 
    virInterfaceFree(iface);
6046
 
    return 0;
 
7567
    return rv;
6047
7568
}
6048
7569
 
6049
7570
static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
6050
7571
                                         struct qemud_client *client ATTRIBUTE_UNUSED,
6051
7572
                                         virConnectPtr conn,
6052
7573
                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
6053
 
                                         remote_error *err,
 
7574
                                         remote_error *rerr,
6054
7575
                                         remote_network_is_active_args *args,
6055
7576
                                         remote_network_is_active_ret *ret)
6056
7577
{
6057
 
    virNetworkPtr network;
6058
 
 
6059
 
    network = get_nonnull_network(conn, args->net);
6060
 
    if (network == NULL) {
6061
 
        remoteDispatchConnError(err, conn);
6062
 
        return -1;
6063
 
    }
6064
 
 
6065
 
    ret->active = virNetworkIsActive(network);
6066
 
 
6067
 
    if (ret->active < 0) {
6068
 
        virNetworkFree(network);
6069
 
        remoteDispatchConnError(err, conn);
6070
 
        return -1;
6071
 
    }
6072
 
 
6073
 
    virNetworkFree(network);
6074
 
    return 0;
 
7578
    virNetworkPtr net = NULL;
 
7579
    int rv = -1;
 
7580
 
 
7581
    if (!conn) {
 
7582
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7583
        goto cleanup;
 
7584
    }
 
7585
 
 
7586
    if (!(net = get_nonnull_network(conn, args->net)))
 
7587
        goto cleanup;
 
7588
 
 
7589
    if ((ret->active = virNetworkIsActive(net)) < 0)
 
7590
        goto cleanup;
 
7591
 
 
7592
    rv = 0;
 
7593
 
 
7594
cleanup:
 
7595
    if (rv < 0)
 
7596
        remoteDispatchError(rerr);
 
7597
    if (net)
 
7598
        virNetworkFree(net);
 
7599
    return rv;
6075
7600
}
6076
7601
 
6077
7602
static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
6078
7603
                                             struct qemud_client *client ATTRIBUTE_UNUSED,
6079
7604
                                             virConnectPtr conn,
6080
7605
                                             remote_message_header *hdr ATTRIBUTE_UNUSED,
6081
 
                                             remote_error *err,
 
7606
                                             remote_error *rerr,
6082
7607
                                             remote_network_is_persistent_args *args,
6083
7608
                                             remote_network_is_persistent_ret *ret)
6084
7609
{
6085
 
    virNetworkPtr network;
6086
 
 
6087
 
    network = get_nonnull_network(conn, args->net);
6088
 
    if (network == NULL) {
6089
 
        remoteDispatchConnError(err, conn);
6090
 
        return -1;
6091
 
    }
6092
 
 
6093
 
    ret->persistent = virNetworkIsPersistent(network);
6094
 
 
6095
 
    if (ret->persistent < 0) {
6096
 
        virNetworkFree(network);
6097
 
        remoteDispatchConnError(err, conn);
6098
 
        return -1;
6099
 
    }
6100
 
 
6101
 
    virNetworkFree(network);
6102
 
    return 0;
 
7610
    virNetworkPtr net = NULL;
 
7611
    int rv = -1;
 
7612
 
 
7613
    if (!conn) {
 
7614
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7615
        goto cleanup;
 
7616
    }
 
7617
 
 
7618
    if (!(net = get_nonnull_network(conn, args->net)))
 
7619
        goto cleanup;
 
7620
 
 
7621
    if ((ret->persistent = virNetworkIsPersistent(net)) < 0)
 
7622
        goto cleanup;
 
7623
 
 
7624
    rv = 0;
 
7625
 
 
7626
cleanup:
 
7627
    if (rv < 0)
 
7628
        remoteDispatchError(rerr);
 
7629
    if (net)
 
7630
        virNetworkFree(net);
 
7631
    return rv;
6103
7632
}
6104
7633
 
6105
7634
static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBUTE_UNUSED,
6106
7635
                                             struct qemud_client *client ATTRIBUTE_UNUSED,
6107
7636
                                             virConnectPtr conn,
6108
7637
                                             remote_message_header *hdr ATTRIBUTE_UNUSED,
6109
 
                                             remote_error *err,
 
7638
                                             remote_error *rerr,
6110
7639
                                             remote_storage_pool_is_active_args *args,
6111
7640
                                             remote_storage_pool_is_active_ret *ret)
6112
7641
{
6113
 
    virStoragePoolPtr pool;
 
7642
    virStoragePoolPtr pool = NULL;
 
7643
    int rv = -1;
6114
7644
 
6115
 
    pool = get_nonnull_storage_pool(conn, args->pool);
6116
 
    if (pool == NULL) {
6117
 
        remoteDispatchConnError(err, conn);
6118
 
        return -1;
 
7645
    if (!conn) {
 
7646
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7647
        goto cleanup;
6119
7648
    }
6120
7649
 
6121
 
    ret->active = virStoragePoolIsActive(pool);
6122
 
 
6123
 
    if (ret->active < 0) {
 
7650
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
7651
        goto cleanup;
 
7652
 
 
7653
    if ((ret->active = virStoragePoolIsActive(pool)) < 0)
 
7654
        goto cleanup;
 
7655
 
 
7656
    rv = 0;
 
7657
 
 
7658
cleanup:
 
7659
    if (rv < 0)
 
7660
        remoteDispatchError(rerr);
 
7661
    if (pool)
6124
7662
        virStoragePoolFree(pool);
6125
 
        remoteDispatchConnError(err, conn);
6126
 
        return -1;
6127
 
    }
6128
 
 
6129
 
    virStoragePoolFree(pool);
6130
 
    return 0;
 
7663
    return rv;
6131
7664
}
6132
7665
 
6133
7666
static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATTRIBUTE_UNUSED,
6134
7667
                                                 struct qemud_client *client ATTRIBUTE_UNUSED,
6135
7668
                                                 virConnectPtr conn,
6136
7669
                                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
6137
 
                                                 remote_error *err,
 
7670
                                                 remote_error *rerr,
6138
7671
                                                 remote_storage_pool_is_persistent_args *args,
6139
7672
                                                 remote_storage_pool_is_persistent_ret *ret)
6140
7673
{
6141
 
    virStoragePoolPtr pool;
 
7674
    virStoragePoolPtr pool = NULL;
 
7675
    int rv = -1;
6142
7676
 
6143
 
    pool = get_nonnull_storage_pool(conn, args->pool);
6144
 
    if (pool == NULL) {
6145
 
        remoteDispatchConnError(err, conn);
6146
 
        return -1;
 
7677
    if (!conn) {
 
7678
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7679
        goto cleanup;
6147
7680
    }
6148
7681
 
6149
 
    ret->persistent = virStoragePoolIsPersistent(pool);
6150
 
 
6151
 
    if (ret->persistent < 0) {
 
7682
    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
 
7683
        goto cleanup;
 
7684
 
 
7685
    if ((ret->persistent = virStoragePoolIsPersistent(pool)) < 0)
 
7686
        goto cleanup;
 
7687
 
 
7688
    rv = 0;
 
7689
 
 
7690
cleanup:
 
7691
    if (rv < 0)
 
7692
        remoteDispatchError(rerr);
 
7693
    if (pool)
6152
7694
        virStoragePoolFree(pool);
6153
 
        remoteDispatchConnError(err, conn);
6154
 
        return -1;
6155
 
    }
6156
 
 
6157
 
    virStoragePoolFree(pool);
6158
 
    return 0;
 
7695
    return rv;
6159
7696
}
6160
7697
 
6161
7698
 
6163
7700
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
6164
7701
                                  virConnectPtr conn,
6165
7702
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
6166
 
                                  remote_error *err,
 
7703
                                  remote_error *rerr,
6167
7704
                                  void *args ATTRIBUTE_UNUSED,
6168
7705
                                  remote_is_secure_ret *ret)
6169
7706
{
6170
 
    ret->secure = virConnectIsSecure(conn);
 
7707
    int rv = -1;
6171
7708
 
6172
 
    if (ret->secure < 0) {
6173
 
        remoteDispatchConnError(err, conn);
6174
 
        return -1;
 
7709
    if (!conn) {
 
7710
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7711
        goto cleanup;
6175
7712
    }
6176
7713
 
6177
 
    return 0;
 
7714
    if ((ret->secure = virConnectIsSecure(conn)) < 0)
 
7715
        goto cleanup;
 
7716
 
 
7717
    rv = 0;
 
7718
 
 
7719
cleanup:
 
7720
    if (rv < 0)
 
7721
        remoteDispatchError(rerr);
 
7722
    return rv;
6178
7723
}
6179
7724
 
6180
7725
 
6183
7728
                         struct qemud_client *client ATTRIBUTE_UNUSED,
6184
7729
                         virConnectPtr conn,
6185
7730
                         remote_message_header *hdr ATTRIBUTE_UNUSED,
6186
 
                         remote_error *err,
 
7731
                         remote_error *rerr,
6187
7732
                         remote_cpu_compare_args *args,
6188
7733
                         remote_cpu_compare_ret *ret)
6189
7734
{
6190
7735
    int result;
 
7736
    int rv = -1;
6191
7737
 
6192
 
    result = virConnectCompareCPU(conn, args->xml, args->flags);
6193
 
    if (result == VIR_CPU_COMPARE_ERROR) {
6194
 
        remoteDispatchConnError(err, conn);
6195
 
        return -1;
 
7738
    if (!conn) {
 
7739
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7740
        goto cleanup;
6196
7741
    }
6197
7742
 
 
7743
    if ((result = virConnectCompareCPU(conn, args->xml, args->flags)) == VIR_CPU_COMPARE_ERROR)
 
7744
        goto cleanup;
 
7745
 
6198
7746
    ret->result = result;
6199
 
    return 0;
 
7747
    rv = 0;
 
7748
 
 
7749
cleanup:
 
7750
    if (rv < 0)
 
7751
        remoteDispatchError(rerr);
 
7752
    return rv;
6200
7753
}
6201
7754
 
6202
7755
 
6205
7758
                          struct qemud_client *client ATTRIBUTE_UNUSED,
6206
7759
                          virConnectPtr conn,
6207
7760
                          remote_message_header *hdr ATTRIBUTE_UNUSED,
6208
 
                          remote_error *err,
 
7761
                          remote_error *rerr,
6209
7762
                          remote_cpu_baseline_args *args,
6210
7763
                          remote_cpu_baseline_ret *ret)
6211
7764
{
6212
7765
    char *cpu;
 
7766
    int rv = -1;
6213
7767
 
6214
 
    cpu = virConnectBaselineCPU(conn,
6215
 
                                (const char **) args->xmlCPUs.xmlCPUs_val,
6216
 
                                args->xmlCPUs.xmlCPUs_len,
6217
 
                                args->flags);
6218
 
    if (cpu == NULL) {
6219
 
        remoteDispatchConnError(err, conn);
6220
 
        return -1;
 
7768
    if (!conn) {
 
7769
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7770
        goto cleanup;
6221
7771
    }
6222
7772
 
 
7773
    if (!(cpu = virConnectBaselineCPU(conn,
 
7774
                                      (const char **) args->xmlCPUs.xmlCPUs_val,
 
7775
                                      args->xmlCPUs.xmlCPUs_len,
 
7776
                                      args->flags)))
 
7777
        goto cleanup;
 
7778
 
6223
7779
    ret->cpu = cpu;
6224
7780
 
6225
 
    return 0;
 
7781
    rv = 0;
 
7782
 
 
7783
cleanup:
 
7784
    if (rv < 0)
 
7785
        remoteDispatchError(rerr);
 
7786
    return rv;
6226
7787
}
6227
7788
 
6228
7789
 
6229
7790
static int
6230
 
remoteDispatchDomainGetJobInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
6231
 
                                struct qemud_client *client ATTRIBUTE_UNUSED,
6232
 
                                virConnectPtr conn,
6233
 
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
6234
 
                                remote_error *rerr,
6235
 
                                remote_domain_get_job_info_args *args,
6236
 
                                remote_domain_get_job_info_ret *ret)
 
7791
remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7792
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
7793
                               virConnectPtr conn,
 
7794
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7795
                               remote_error *rerr,
 
7796
                               remote_domain_get_job_info_args *args,
 
7797
                               remote_domain_get_job_info_ret *ret)
6237
7798
{
6238
 
    virDomainPtr dom;
 
7799
    virDomainPtr dom = NULL;
6239
7800
    virDomainJobInfo info;
6240
 
 
6241
 
    dom = get_nonnull_domain (conn, args->dom);
6242
 
    if (dom == NULL) {
6243
 
        remoteDispatchConnError(rerr, conn);
6244
 
        return -1;
6245
 
    }
6246
 
 
6247
 
    if (virDomainGetJobInfo (dom, &info) == -1) {
6248
 
        virDomainFree(dom);
6249
 
        remoteDispatchConnError(rerr, conn);
6250
 
        return -1;
6251
 
    }
 
7801
    int rv = -1;
 
7802
 
 
7803
    if (!conn) {
 
7804
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7805
        goto cleanup;
 
7806
    }
 
7807
 
 
7808
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7809
        goto cleanup;
 
7810
 
 
7811
    if (virDomainGetJobInfo(dom, &info) < 0)
 
7812
        goto cleanup;
6252
7813
 
6253
7814
    ret->type = info.type;
6254
7815
    ret->timeElapsed = info.timeElapsed;
6263
7824
    ret->fileProcessed = info.fileProcessed;
6264
7825
    ret->fileRemaining = info.fileRemaining;
6265
7826
 
6266
 
    virDomainFree(dom);
 
7827
    rv = 0;
6267
7828
 
6268
 
    return 0;
 
7829
cleanup:
 
7830
    if (rv < 0)
 
7831
        remoteDispatchError(rerr);
 
7832
    if (dom)
 
7833
        virDomainFree(dom);
 
7834
    return rv;
6269
7835
}
6270
7836
 
6271
7837
 
6272
7838
static int
6273
 
remoteDispatchDomainAbortJob (struct qemud_server *server ATTRIBUTE_UNUSED,
6274
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
6275
 
                              virConnectPtr conn,
6276
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
6277
 
                              remote_error *rerr,
6278
 
                              remote_domain_abort_job_args *args,
6279
 
                              void *ret ATTRIBUTE_UNUSED)
 
7839
remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7840
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
7841
                             virConnectPtr conn,
 
7842
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7843
                             remote_error *rerr,
 
7844
                             remote_domain_abort_job_args *args,
 
7845
                             void *ret ATTRIBUTE_UNUSED)
6280
7846
{
6281
 
    virDomainPtr dom;
 
7847
    virDomainPtr dom = NULL;
 
7848
    int rv = -1;
6282
7849
 
6283
 
    dom = get_nonnull_domain (conn, args->dom);
6284
 
    if (dom == NULL) {
6285
 
        remoteDispatchConnError(rerr, conn);
6286
 
        return -1;
 
7850
    if (!conn) {
 
7851
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7852
        goto cleanup;
6287
7853
    }
6288
7854
 
6289
 
    if (virDomainAbortJob (dom) == -1) {
 
7855
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7856
        goto cleanup;
 
7857
 
 
7858
    if (virDomainAbortJob(dom) < 0)
 
7859
        goto cleanup;
 
7860
 
 
7861
    rv = 0;
 
7862
 
 
7863
cleanup:
 
7864
    if (rv < 0)
 
7865
        remoteDispatchError(rerr);
 
7866
    if (dom)
6290
7867
        virDomainFree(dom);
6291
 
        remoteDispatchConnError(rerr, conn);
6292
 
        return -1;
6293
 
    }
6294
 
 
6295
 
    virDomainFree(dom);
6296
 
 
6297
 
    return 0;
 
7868
    return rv;
6298
7869
}
6299
7870
 
6300
7871
 
6307
7878
                                          remote_domain_migrate_set_max_downtime_args *args,
6308
7879
                                          void *ret ATTRIBUTE_UNUSED)
6309
7880
{
6310
 
    virDomainPtr dom;
 
7881
    virDomainPtr dom = NULL;
 
7882
    int rv = -1;
6311
7883
 
6312
 
    dom = get_nonnull_domain(conn, args->dom);
6313
 
    if (dom == NULL) {
6314
 
        remoteDispatchConnError(rerr, conn);
6315
 
        return -1;
 
7884
    if (!conn) {
 
7885
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7886
        goto cleanup;
6316
7887
    }
6317
7888
 
6318
 
    if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) == -1) {
 
7889
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7890
        goto cleanup;
 
7891
 
 
7892
    if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0)
 
7893
        goto cleanup;
 
7894
 
 
7895
    rv = 0;
 
7896
 
 
7897
cleanup:
 
7898
    if (rv < 0)
 
7899
        remoteDispatchError(rerr);
 
7900
    if (dom)
6319
7901
        virDomainFree(dom);
6320
 
        remoteDispatchConnError(rerr, conn);
6321
 
        return -1;
6322
 
    }
6323
 
 
6324
 
    virDomainFree(dom);
6325
 
 
6326
 
    return 0;
 
7902
    return rv;
6327
7903
}
6328
7904
 
6329
7905
static int
6330
 
remoteDispatchDomainSnapshotCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
 
7906
remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNUSED,
6331
7907
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
6332
7908
                                       virConnectPtr conn,
6333
7909
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
6334
7910
                                       remote_error *rerr,
6335
 
                                       remote_domain_snapshot_create_xml_args *args,
6336
 
                                       remote_domain_snapshot_create_xml_ret *ret)
6337
 
{
6338
 
    virDomainSnapshotPtr snapshot;
6339
 
    virDomainPtr domain;
6340
 
 
6341
 
    domain = get_nonnull_domain(conn, args->domain);
6342
 
    if (domain == NULL) {
6343
 
        remoteDispatchConnError(rerr, conn);
6344
 
        return -1;
6345
 
    }
6346
 
 
6347
 
    snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
6348
 
    if (snapshot == NULL) {
6349
 
        virDomainFree(domain);
6350
 
        remoteDispatchConnError(rerr, conn);
6351
 
        return -1;
6352
 
    }
 
7911
                                       remote_domain_migrate_set_max_speed_args *args,
 
7912
                                       void *ret ATTRIBUTE_UNUSED)
 
7913
{
 
7914
    virDomainPtr dom = NULL;
 
7915
    int rv = -1;
 
7916
 
 
7917
    if (!conn) {
 
7918
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7919
        goto cleanup;
 
7920
    }
 
7921
 
 
7922
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
7923
        goto cleanup;
 
7924
 
 
7925
    if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0)
 
7926
        goto cleanup;
 
7927
 
 
7928
    rv = 0;
 
7929
 
 
7930
cleanup:
 
7931
    if (rv < 0)
 
7932
        remoteDispatchError(rerr);
 
7933
    if (dom)
 
7934
        virDomainFree(dom);
 
7935
    return rv;
 
7936
}
 
7937
 
 
7938
static int
 
7939
remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7940
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
7941
                                      virConnectPtr conn,
 
7942
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7943
                                      remote_error *rerr,
 
7944
                                      remote_domain_snapshot_create_xml_args *args,
 
7945
                                      remote_domain_snapshot_create_xml_ret *ret)
 
7946
{
 
7947
    virDomainSnapshotPtr snapshot = NULL;
 
7948
    virDomainPtr dom = NULL;
 
7949
    int rv = -1;
 
7950
 
 
7951
    if (!conn) {
 
7952
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7953
        goto cleanup;
 
7954
    }
 
7955
 
 
7956
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
7957
        goto cleanup;
 
7958
 
 
7959
    if (!(snapshot = virDomainSnapshotCreateXML(dom, args->xml_desc, args->flags)))
 
7960
        goto cleanup;
6353
7961
 
6354
7962
    make_nonnull_domain_snapshot(&ret->snap, snapshot);
6355
7963
 
6356
 
    virDomainSnapshotFree(snapshot);
6357
 
    virDomainFree(domain);
 
7964
    rv = 0;
6358
7965
 
6359
 
    return 0;
 
7966
cleanup:
 
7967
    if (rv < 0)
 
7968
        remoteDispatchError(rerr);
 
7969
    if (snapshot)
 
7970
        virDomainSnapshotFree(snapshot);
 
7971
    if (dom)
 
7972
        virDomainFree(dom);
 
7973
    return rv;
6360
7974
}
6361
7975
 
6362
7976
static int
6363
 
remoteDispatchDomainSnapshotDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
6364
 
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
6365
 
                                     virConnectPtr conn,
6366
 
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
6367
 
                                     remote_error *rerr,
6368
 
                                     remote_domain_snapshot_dump_xml_args *args,
6369
 
                                     remote_domain_snapshot_dump_xml_ret *ret)
 
7977
remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
 
7978
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
 
7979
                                    virConnectPtr conn,
 
7980
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
 
7981
                                    remote_error *rerr,
 
7982
                                    remote_domain_snapshot_dump_xml_args *args,
 
7983
                                    remote_domain_snapshot_dump_xml_ret *ret)
6370
7984
{
6371
 
    virDomainPtr domain = NULL;
 
7985
    virDomainPtr dom = NULL;
6372
7986
    virDomainSnapshotPtr snapshot = NULL;
6373
 
    int rc = -1;
6374
 
 
6375
 
    domain = get_nonnull_domain(conn, args->snap.domain);
6376
 
    if (domain == NULL)
6377
 
        goto cleanup;
6378
 
 
6379
 
    snapshot = get_nonnull_domain_snapshot(domain, args->snap);
6380
 
    if (snapshot == NULL)
 
7987
    int rv = -1;
 
7988
 
 
7989
    if (!conn) {
 
7990
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
7991
        goto cleanup;
 
7992
    }
 
7993
 
 
7994
    if (!(dom = get_nonnull_domain(conn, args->snap.domain)))
 
7995
        goto cleanup;
 
7996
 
 
7997
    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
6381
7998
        goto cleanup;
6382
7999
 
6383
8000
    /* remoteDispatchClientRequest will free this. */
6384
 
    ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags);
6385
 
    if (!ret->xml)
 
8001
    if (!(ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags)))
6386
8002
        goto cleanup;
6387
8003
 
6388
 
    rc = 0;
 
8004
    rv = 0;
6389
8005
 
6390
8006
cleanup:
 
8007
    if (rv < 0)
 
8008
        remoteDispatchError(rerr);
6391
8009
    if (snapshot)
6392
8010
        virDomainSnapshotFree(snapshot);
6393
 
    if (domain)
6394
 
        virDomainFree(domain);
6395
 
    if (rc < 0)
6396
 
        remoteDispatchConnError(rerr, conn);
6397
 
 
6398
 
    return rc;
6399
 
}
6400
 
 
6401
 
static int
6402
 
remoteDispatchDomainSnapshotNum (struct qemud_server *server ATTRIBUTE_UNUSED,
6403
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
6404
 
                                 virConnectPtr conn,
6405
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
6406
 
                                 remote_error *rerr,
6407
 
                                 remote_domain_snapshot_num_args *args,
6408
 
                                 remote_domain_snapshot_num_ret *ret)
6409
 
{
6410
 
    virDomainPtr domain;
6411
 
 
6412
 
    domain = get_nonnull_domain(conn, args->domain);
6413
 
    if (domain == NULL) {
6414
 
        remoteDispatchConnError(rerr, conn);
6415
 
        return -1;
6416
 
    }
6417
 
 
6418
 
    ret->num = virDomainSnapshotNum(domain, args->flags);
6419
 
    if (ret->num == -1) {
6420
 
        virDomainFree(domain);
6421
 
        remoteDispatchConnError(rerr, conn);
6422
 
        return -1;
6423
 
    }
6424
 
 
6425
 
    virDomainFree(domain);
6426
 
 
6427
 
    return 0;
6428
 
}
6429
 
 
6430
 
static int
6431
 
remoteDispatchDomainSnapshotListNames (struct qemud_server *server ATTRIBUTE_UNUSED,
6432
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
6433
 
                                       virConnectPtr conn,
6434
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
6435
 
                                       remote_error *rerr,
6436
 
                                       remote_domain_snapshot_list_names_args *args,
6437
 
                                       remote_domain_snapshot_list_names_ret *ret)
6438
 
{
6439
 
    virDomainPtr domain;
 
8011
    if (dom)
 
8012
        virDomainFree(dom);
 
8013
    return rv;
 
8014
}
 
8015
 
 
8016
static int
 
8017
remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8018
                                struct qemud_client *client ATTRIBUTE_UNUSED,
 
8019
                                virConnectPtr conn,
 
8020
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8021
                                remote_error *rerr,
 
8022
                                remote_domain_snapshot_num_args *args,
 
8023
                                remote_domain_snapshot_num_ret *ret)
 
8024
{
 
8025
    virDomainPtr dom = NULL;
 
8026
    int rv = -1;
 
8027
 
 
8028
    if (!conn) {
 
8029
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8030
        goto cleanup;
 
8031
    }
 
8032
 
 
8033
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8034
        goto cleanup;
 
8035
 
 
8036
    if ((ret->num = virDomainSnapshotNum(dom, args->flags)) < 0)
 
8037
        goto cleanup;
 
8038
 
 
8039
    rv = 0;
 
8040
 
 
8041
cleanup:
 
8042
    if (rv < 0)
 
8043
        remoteDispatchError(rerr);
 
8044
    if (dom)
 
8045
        virDomainFree(dom);
 
8046
    return rv;
 
8047
}
 
8048
 
 
8049
static int
 
8050
remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8051
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
 
8052
                                      virConnectPtr conn,
 
8053
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8054
                                      remote_error *rerr,
 
8055
                                      remote_domain_snapshot_list_names_args *args,
 
8056
                                      remote_domain_snapshot_list_names_ret *ret)
 
8057
{
 
8058
    virDomainPtr dom = NULL;
 
8059
    int rv = -1;
 
8060
    int len;
 
8061
 
 
8062
    if (!conn) {
 
8063
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8064
        goto cleanup;
 
8065
    }
6440
8066
 
6441
8067
    if (args->nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX) {
6442
 
        remoteDispatchFormatError (rerr, "%s",
6443
 
                                   _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
6444
 
        return -1;
 
8068
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
 
8069
                    _("nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX"));
 
8070
        goto cleanup;
6445
8071
    }
6446
8072
 
6447
 
    domain = get_nonnull_domain(conn, args->domain);
6448
 
    if (domain == NULL) {
6449
 
        remoteDispatchConnError(rerr, conn);
6450
 
        return -1;
6451
 
    }
 
8073
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8074
        goto cleanup;
6452
8075
 
6453
8076
    /* Allocate return buffer. */
6454
8077
    if (VIR_ALLOC_N(ret->names.names_val, args->nameslen) < 0) {
6455
 
        virDomainFree(domain);
6456
 
        remoteDispatchOOMError(rerr);
6457
 
        return -1;
 
8078
        virReportOOMError();
 
8079
        goto cleanup;
6458
8080
    }
6459
8081
 
6460
 
    ret->names.names_len = virDomainSnapshotListNames(domain,
6461
 
                                                      ret->names.names_val,
6462
 
                                                      args->nameslen,
6463
 
                                                      args->flags);
6464
 
    if (ret->names.names_len == -1) {
6465
 
        virDomainFree(domain);
 
8082
    len = virDomainSnapshotListNames(dom,
 
8083
                                     ret->names.names_val,
 
8084
                                     args->nameslen,
 
8085
                                     args->flags);
 
8086
    if (len < 0)
 
8087
        goto cleanup;
 
8088
    ret->names.names_len = len;
 
8089
 
 
8090
    rv = 0;
 
8091
 
 
8092
cleanup:
 
8093
    if (rv < 0) {
 
8094
        remoteDispatchError(rerr);
6466
8095
        VIR_FREE(ret->names.names_val);
6467
 
        remoteDispatchConnError(rerr, conn);
6468
 
        return -1;
6469
8096
    }
6470
 
 
6471
 
    virDomainFree(domain);
6472
 
 
6473
 
    return 0;
 
8097
    if (dom)
 
8098
        virDomainFree(dom);
 
8099
    return rv;
6474
8100
}
6475
8101
 
6476
8102
static int
6477
 
remoteDispatchDomainSnapshotLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
6478
 
                                          struct qemud_client *client ATTRIBUTE_UNUSED,
6479
 
                                          virConnectPtr conn,
6480
 
                                          remote_message_header *hdr ATTRIBUTE_UNUSED,
6481
 
                                          remote_error *rerr,
6482
 
                                          remote_domain_snapshot_lookup_by_name_args *args,
6483
 
                                          remote_domain_snapshot_lookup_by_name_ret *ret)
 
8103
remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8104
                                         struct qemud_client *client ATTRIBUTE_UNUSED,
 
8105
                                         virConnectPtr conn,
 
8106
                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8107
                                         remote_error *rerr,
 
8108
                                         remote_domain_snapshot_lookup_by_name_args *args,
 
8109
                                         remote_domain_snapshot_lookup_by_name_ret *ret)
6484
8110
{
6485
 
    virDomainSnapshotPtr snapshot;
6486
 
    virDomainPtr domain;
6487
 
 
6488
 
    domain = get_nonnull_domain(conn, args->domain);
6489
 
    if (domain == NULL) {
6490
 
        remoteDispatchConnError(rerr, conn);
6491
 
        return -1;
6492
 
    }
6493
 
 
6494
 
    snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
6495
 
    if (snapshot == NULL) {
6496
 
        virDomainFree(domain);
6497
 
        remoteDispatchConnError(rerr, conn);
6498
 
        return -1;
6499
 
    }
6500
 
 
6501
 
    make_nonnull_domain_snapshot (&ret->snap, snapshot);
6502
 
 
6503
 
    virDomainSnapshotFree(snapshot);
6504
 
    virDomainFree(domain);
6505
 
 
6506
 
    return 0;
 
8111
    virDomainSnapshotPtr snapshot = NULL;
 
8112
    virDomainPtr dom = NULL;
 
8113
    int rv = -1;
 
8114
 
 
8115
    if (!conn) {
 
8116
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8117
        goto cleanup;
 
8118
    }
 
8119
 
 
8120
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8121
        goto cleanup;
 
8122
 
 
8123
    if (!(snapshot = virDomainSnapshotLookupByName(dom, args->name, args->flags)))
 
8124
        goto cleanup;
 
8125
 
 
8126
    make_nonnull_domain_snapshot(&ret->snap, snapshot);
 
8127
 
 
8128
    rv = 0;
 
8129
 
 
8130
cleanup:
 
8131
    if (rv < 0)
 
8132
        remoteDispatchError(rerr);
 
8133
    if (snapshot)
 
8134
        virDomainSnapshotFree(snapshot);
 
8135
    if (dom)
 
8136
        virDomainFree(dom);
 
8137
    return rv;
6507
8138
}
6508
8139
 
6509
8140
static int
6515
8146
                                       remote_domain_has_current_snapshot_args *args,
6516
8147
                                       remote_domain_has_current_snapshot_ret *ret)
6517
8148
{
6518
 
    virDomainPtr domain;
 
8149
    virDomainPtr dom = NULL;
6519
8150
    int result;
6520
 
 
6521
 
    domain = get_nonnull_domain(conn, args->domain);
6522
 
    if (domain == NULL) {
6523
 
        remoteDispatchConnError(rerr, conn);
6524
 
        return -1;
6525
 
    }
6526
 
 
6527
 
    result = virDomainHasCurrentSnapshot(domain, args->flags);
6528
 
    if (result < 0) {
6529
 
        virDomainFree(domain);
6530
 
        remoteDispatchConnError(rerr, conn);
6531
 
        return -1;
6532
 
    }
 
8151
    int rv = -1;
 
8152
 
 
8153
    if (!conn) {
 
8154
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8155
        goto cleanup;
 
8156
    }
 
8157
 
 
8158
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8159
        goto cleanup;
 
8160
 
 
8161
    result = virDomainHasCurrentSnapshot(dom, args->flags);
 
8162
    if (result < 0)
 
8163
        goto cleanup;
6533
8164
 
6534
8165
    ret->result = result;
6535
8166
 
6536
 
    virDomainFree(domain);
 
8167
    rv = 0;
6537
8168
 
6538
 
    return 0;
 
8169
cleanup:
 
8170
    if (rv < 0)
 
8171
        remoteDispatchError(rerr);
 
8172
    if (dom)
 
8173
        virDomainFree(dom);
 
8174
    return rv;
6539
8175
}
6540
8176
 
6541
8177
static int
6547
8183
                                    remote_domain_snapshot_current_args *args,
6548
8184
                                    remote_domain_snapshot_current_ret *ret)
6549
8185
{
6550
 
    virDomainSnapshotPtr snapshot;
6551
 
    virDomainPtr domain;
6552
 
 
6553
 
    domain = get_nonnull_domain(conn, args->domain);
6554
 
    if (domain == NULL) {
6555
 
        remoteDispatchConnError(rerr, conn);
6556
 
        return -1;
6557
 
    }
6558
 
 
6559
 
    snapshot = virDomainSnapshotCurrent(domain, args->flags);
6560
 
    if (snapshot == NULL) {
6561
 
        virDomainFree(domain);
6562
 
        remoteDispatchConnError(rerr, conn);
6563
 
        return -1;
6564
 
    }
 
8186
    virDomainSnapshotPtr snapshot = NULL;
 
8187
    virDomainPtr dom = NULL;
 
8188
    int rv = -1;
 
8189
 
 
8190
    if (!conn) {
 
8191
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8192
        goto cleanup;
 
8193
    }
 
8194
 
 
8195
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8196
        goto cleanup;
 
8197
 
 
8198
    if (!(snapshot = virDomainSnapshotCurrent(dom, args->flags)))
 
8199
        goto cleanup;
6565
8200
 
6566
8201
    make_nonnull_domain_snapshot(&ret->snap, snapshot);
6567
8202
 
6568
 
    virDomainSnapshotFree(snapshot);
6569
 
    virDomainFree(domain);
6570
 
 
6571
 
    return 0;
6572
 
}
6573
 
 
6574
 
static int
6575
 
remoteDispatchDomainRevertToSnapshot (struct qemud_server *server ATTRIBUTE_UNUSED,
 
8203
    rv = 0;
 
8204
 
 
8205
cleanup:
 
8206
    if (rv < 0)
 
8207
        remoteDispatchError(rerr);
 
8208
    if (snapshot)
 
8209
        virDomainSnapshotFree(snapshot);
 
8210
    if (dom)
 
8211
        virDomainFree(dom);
 
8212
    return rv;
 
8213
}
 
8214
 
 
8215
static int
 
8216
remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8217
                                     struct qemud_client *client ATTRIBUTE_UNUSED,
 
8218
                                     virConnectPtr conn,
 
8219
                                     remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8220
                                     remote_error *rerr,
 
8221
                                     remote_domain_revert_to_snapshot_args *args,
 
8222
                                     void *ret ATTRIBUTE_UNUSED)
 
8223
{
 
8224
    virDomainPtr dom = NULL;
 
8225
    virDomainSnapshotPtr snapshot = NULL;
 
8226
    int rv = -1;
 
8227
 
 
8228
    if (!conn) {
 
8229
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8230
        goto cleanup;
 
8231
    }
 
8232
 
 
8233
    if (!(dom = get_nonnull_domain(conn, args->snap.domain)))
 
8234
        goto cleanup;
 
8235
 
 
8236
    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
 
8237
        goto cleanup;
 
8238
 
 
8239
    if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
 
8240
        goto cleanup;
 
8241
 
 
8242
    rv = 0;
 
8243
 
 
8244
cleanup:
 
8245
    if (rv < 0)
 
8246
        remoteDispatchError(rerr);
 
8247
    if (snapshot)
 
8248
        virDomainSnapshotFree(snapshot);
 
8249
    if (dom)
 
8250
        virDomainFree(dom);
 
8251
    return rv;
 
8252
}
 
8253
 
 
8254
static int
 
8255
remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8256
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
8257
                                   virConnectPtr conn,
 
8258
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8259
                                   remote_error *rerr,
 
8260
                                   remote_domain_snapshot_delete_args *args,
 
8261
                                   void *ret ATTRIBUTE_UNUSED)
 
8262
{
 
8263
    virDomainPtr dom = NULL;
 
8264
    virDomainSnapshotPtr snapshot = NULL;
 
8265
    int rv = -1;
 
8266
 
 
8267
    if (!conn) {
 
8268
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8269
        goto cleanup;
 
8270
    }
 
8271
 
 
8272
    if (!(dom = get_nonnull_domain(conn, args->snap.domain)))
 
8273
        goto cleanup;
 
8274
 
 
8275
    if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snap)))
 
8276
        goto cleanup;
 
8277
 
 
8278
    if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
 
8279
        goto cleanup;
 
8280
 
 
8281
    rv = 0;
 
8282
 
 
8283
cleanup:
 
8284
    if (rv < 0)
 
8285
        remoteDispatchError(rerr);
 
8286
    if (snapshot)
 
8287
        virDomainSnapshotFree(snapshot);
 
8288
    if (dom)
 
8289
        virDomainFree(dom);
 
8290
    return rv;
 
8291
}
 
8292
 
 
8293
 
 
8294
static int
 
8295
remoteDispatchDomainEventsRegisterAny(struct qemud_server *server ATTRIBUTE_UNUSED,
6576
8296
                                      struct qemud_client *client ATTRIBUTE_UNUSED,
6577
8297
                                      virConnectPtr conn,
6578
8298
                                      remote_message_header *hdr ATTRIBUTE_UNUSED,
6579
 
                                      remote_error *rerr,
6580
 
                                      remote_domain_revert_to_snapshot_args *args,
 
8299
                                      remote_error *rerr ATTRIBUTE_UNUSED,
 
8300
                                      remote_domain_events_register_any_args *args,
6581
8301
                                      void *ret ATTRIBUTE_UNUSED)
6582
8302
{
6583
 
    virDomainPtr domain = NULL;
6584
 
    virDomainSnapshotPtr snapshot = NULL;
6585
 
    int rc = -1;
6586
 
 
6587
 
    domain = get_nonnull_domain(conn, args->snap.domain);
6588
 
    if (domain == NULL)
6589
 
        goto cleanup;
6590
 
 
6591
 
    snapshot = get_nonnull_domain_snapshot(domain, args->snap);
6592
 
    if (snapshot == NULL)
6593
 
        goto cleanup;
6594
 
 
6595
 
    if (virDomainRevertToSnapshot(snapshot, args->flags) == -1)
6596
 
        goto cleanup;
6597
 
 
6598
 
    rc = 0;
6599
 
 
6600
 
cleanup:
6601
 
    if (snapshot)
6602
 
        virDomainSnapshotFree(snapshot);
6603
 
    if (domain)
6604
 
        virDomainFree(domain);
6605
 
    if (rc < 0)
6606
 
        remoteDispatchConnError(rerr, conn);
6607
 
 
6608
 
    return rc;
6609
 
}
6610
 
 
6611
 
static int
6612
 
remoteDispatchDomainSnapshotDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
6613
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
6614
 
                                    virConnectPtr conn,
6615
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
6616
 
                                    remote_error *rerr,
6617
 
                                    remote_domain_snapshot_delete_args *args,
6618
 
                                    void *ret ATTRIBUTE_UNUSED)
6619
 
{
6620
 
    virDomainPtr domain = NULL;
6621
 
    virDomainSnapshotPtr snapshot = NULL;
6622
 
    int rc = -1;
6623
 
 
6624
 
    domain = get_nonnull_domain(conn, args->snap.domain);
6625
 
    if (domain == NULL)
6626
 
        goto cleanup;
6627
 
 
6628
 
    snapshot = get_nonnull_domain_snapshot(domain, args->snap);
6629
 
    if (snapshot == NULL)
6630
 
        goto cleanup;
6631
 
 
6632
 
    if (virDomainSnapshotDelete(snapshot, args->flags) == -1)
6633
 
        goto cleanup;
6634
 
 
6635
 
    rc = 0;
6636
 
 
6637
 
cleanup:
6638
 
    if (snapshot)
6639
 
        virDomainSnapshotFree(snapshot);
6640
 
    if (domain)
6641
 
        virDomainFree(domain);
6642
 
    if (rc < 0)
6643
 
        remoteDispatchConnError(rerr, conn);
6644
 
 
6645
 
    return rc;
6646
 
}
6647
 
 
6648
 
 
6649
 
static int
6650
 
remoteDispatchDomainEventsRegisterAny (struct qemud_server *server ATTRIBUTE_UNUSED,
6651
 
                                       struct qemud_client *client ATTRIBUTE_UNUSED,
6652
 
                                       virConnectPtr conn,
6653
 
                                       remote_message_header *hdr ATTRIBUTE_UNUSED,
6654
 
                                       remote_error *rerr ATTRIBUTE_UNUSED,
6655
 
                                       remote_domain_events_register_any_args *args,
6656
 
                                       void *ret ATTRIBUTE_UNUSED)
6657
 
{
6658
 
    CHECK_CONN(client);
6659
8303
    int callbackID;
 
8304
    int rv = -1;
 
8305
 
 
8306
    if (!conn) {
 
8307
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8308
        goto cleanup;
 
8309
    }
6660
8310
 
6661
8311
    if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
6662
8312
        args->eventID < 0) {
6663
 
        remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
6664
 
        return -1;
 
8313
        virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
 
8314
        goto cleanup;
6665
8315
    }
6666
8316
 
6667
8317
    if (client->domainEventCallbackID[args->eventID] != -1)  {
6668
 
        remoteDispatchFormatError(rerr, _("domain event %d already registered"), args->eventID);
6669
 
        return -1;
 
8318
        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), args->eventID);
 
8319
        goto cleanup;
6670
8320
    }
6671
8321
 
6672
8322
    if ((callbackID = virConnectDomainEventRegisterAny(conn,
6673
8323
                                                       NULL,
6674
8324
                                                       args->eventID,
6675
8325
                                                       domainEventCallbacks[args->eventID],
6676
 
                                                       client, NULL)) < 0) {
6677
 
        remoteDispatchConnError(rerr, conn);
6678
 
        return -1;
6679
 
    }
 
8326
                                                       client, NULL)) < 0)
 
8327
        goto cleanup;
6680
8328
 
6681
8329
    client->domainEventCallbackID[args->eventID] = callbackID;
6682
8330
 
6683
 
    return 0;
 
8331
    rv = 0;
 
8332
 
 
8333
cleanup:
 
8334
    if (rv < 0)
 
8335
        remoteDispatchError(rerr);
 
8336
    return rv;
6684
8337
}
6685
8338
 
6686
8339
 
6687
8340
static int
6688
 
remoteDispatchDomainEventsDeregisterAny (struct qemud_server *server ATTRIBUTE_UNUSED,
6689
 
                                         struct qemud_client *client ATTRIBUTE_UNUSED,
6690
 
                                         virConnectPtr conn,
6691
 
                                         remote_message_header *hdr ATTRIBUTE_UNUSED,
6692
 
                                         remote_error *rerr ATTRIBUTE_UNUSED,
6693
 
                                         remote_domain_events_deregister_any_args *args,
6694
 
                                         void *ret ATTRIBUTE_UNUSED)
 
8341
remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8342
                                        struct qemud_client *client ATTRIBUTE_UNUSED,
 
8343
                                        virConnectPtr conn,
 
8344
                                        remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8345
                                        remote_error *rerr ATTRIBUTE_UNUSED,
 
8346
                                        remote_domain_events_deregister_any_args *args,
 
8347
                                        void *ret ATTRIBUTE_UNUSED)
6695
8348
{
6696
 
    CHECK_CONN(client);
6697
8349
    int callbackID = -1;
 
8350
    int rv = -1;
 
8351
 
 
8352
    if (!conn) {
 
8353
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8354
        goto cleanup;
 
8355
    }
6698
8356
 
6699
8357
    if (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
6700
8358
        args->eventID < 0) {
6701
 
        remoteDispatchFormatError(rerr, _("unsupported event ID %d"), args->eventID);
6702
 
        return -1;
6703
 
    }
6704
 
 
6705
 
    callbackID = client->domainEventCallbackID[args->eventID];
6706
 
    if (callbackID < 0) {
6707
 
        remoteDispatchFormatError(rerr, _("domain event %d not registered"), args->eventID);
6708
 
        return -1;
6709
 
    }
6710
 
 
6711
 
    if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0) {
6712
 
        remoteDispatchConnError(rerr, conn);
6713
 
        return -1;
6714
 
    }
 
8359
        virNetError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
 
8360
        goto cleanup;
 
8361
    }
 
8362
 
 
8363
    if ((callbackID = client->domainEventCallbackID[args->eventID]) < 0) {
 
8364
        virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
 
8365
        goto cleanup;
 
8366
    }
 
8367
 
 
8368
    if (virConnectDomainEventDeregisterAny(conn, callbackID) < 0)
 
8369
        goto cleanup;
6715
8370
 
6716
8371
    client->domainEventCallbackID[args->eventID] = -1;
6717
 
    return 0;
6718
 
}
6719
 
 
6720
 
 
6721
 
 
6722
 
static int
6723
 
remoteDispatchNwfilterLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
6724
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
6725
 
                                    virConnectPtr conn,
6726
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
6727
 
                                    remote_error *rerr,
6728
 
                                    remote_nwfilter_lookup_by_name_args *args,
6729
 
                                    remote_nwfilter_lookup_by_name_ret *ret)
6730
 
{
6731
 
    virNWFilterPtr nwfilter;
6732
 
 
6733
 
    nwfilter = virNWFilterLookupByName (conn, args->name);
6734
 
    if (nwfilter == NULL) {
6735
 
        remoteDispatchConnError(rerr, conn);
6736
 
        return -1;
6737
 
    }
6738
 
 
6739
 
    make_nonnull_nwfilter (&ret->nwfilter, nwfilter);
6740
 
    virNWFilterFree(nwfilter);
6741
 
    return 0;
6742
 
}
6743
 
 
6744
 
static int
6745
 
remoteDispatchNwfilterLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
6746
 
                                    struct qemud_client *client ATTRIBUTE_UNUSED,
6747
 
                                    virConnectPtr conn,
6748
 
                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
6749
 
                                    remote_error *rerr,
6750
 
                                    remote_nwfilter_lookup_by_uuid_args *args,
6751
 
                                    remote_nwfilter_lookup_by_uuid_ret *ret)
6752
 
{
6753
 
    virNWFilterPtr nwfilter;
6754
 
 
6755
 
    nwfilter = virNWFilterLookupByUUID (conn, (unsigned char *) args->uuid);
6756
 
    if (nwfilter == NULL) {
6757
 
        remoteDispatchConnError(rerr, conn);
6758
 
        return -1;
6759
 
    }
6760
 
 
6761
 
    make_nonnull_nwfilter (&ret->nwfilter, nwfilter);
6762
 
    virNWFilterFree(nwfilter);
6763
 
    return 0;
6764
 
}
6765
 
 
6766
 
 
6767
 
static int
6768
 
remoteDispatchNwfilterDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
6769
 
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
6770
 
                                 virConnectPtr conn,
6771
 
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
6772
 
                                 remote_error *rerr,
6773
 
                                 remote_nwfilter_define_xml_args *args,
6774
 
                                 remote_nwfilter_define_xml_ret *ret)
6775
 
{
6776
 
    virNWFilterPtr nwfilter;
6777
 
 
6778
 
    nwfilter = virNWFilterDefineXML (conn, args->xml);
6779
 
    if (nwfilter == NULL) {
6780
 
        remoteDispatchConnError(rerr, conn);
6781
 
        return -1;
6782
 
    }
6783
 
 
6784
 
    make_nonnull_nwfilter (&ret->nwfilter, nwfilter);
6785
 
    virNWFilterFree(nwfilter);
6786
 
    return 0;
6787
 
}
6788
 
 
6789
 
 
6790
 
static int
6791
 
remoteDispatchNwfilterUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
 
8372
    rv = 0;
 
8373
 
 
8374
cleanup:
 
8375
    if (rv < 0)
 
8376
        remoteDispatchError(rerr);
 
8377
    return rv;
 
8378
}
 
8379
 
 
8380
 
 
8381
 
 
8382
static int
 
8383
remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8384
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
8385
                                   virConnectPtr conn,
 
8386
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8387
                                   remote_error *rerr,
 
8388
                                   remote_nwfilter_lookup_by_name_args *args,
 
8389
                                   remote_nwfilter_lookup_by_name_ret *ret)
 
8390
{
 
8391
    virNWFilterPtr nwfilter = NULL;
 
8392
    int rv = -1;
 
8393
 
 
8394
    if (!conn) {
 
8395
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8396
        goto cleanup;
 
8397
    }
 
8398
 
 
8399
    if (!(nwfilter = virNWFilterLookupByName(conn, args->name)))
 
8400
        goto cleanup;
 
8401
 
 
8402
    make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
 
8403
 
 
8404
    rv = 0;
 
8405
 
 
8406
cleanup:
 
8407
    if (rv < 0)
 
8408
        remoteDispatchError(rerr);
 
8409
    if (nwfilter)
 
8410
        virNWFilterFree(nwfilter);
 
8411
    return rv;
 
8412
}
 
8413
 
 
8414
static int
 
8415
remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8416
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
 
8417
                                   virConnectPtr conn,
 
8418
                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8419
                                   remote_error *rerr,
 
8420
                                   remote_nwfilter_lookup_by_uuid_args *args,
 
8421
                                   remote_nwfilter_lookup_by_uuid_ret *ret)
 
8422
{
 
8423
    virNWFilterPtr nwfilter = NULL;
 
8424
    int rv = -1;
 
8425
 
 
8426
    if (!conn) {
 
8427
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8428
        goto cleanup;
 
8429
    }
 
8430
 
 
8431
    if (!(nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid)))
 
8432
        goto cleanup;
 
8433
 
 
8434
    make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
 
8435
 
 
8436
    rv = 0;
 
8437
 
 
8438
cleanup:
 
8439
    if (rv < 0)
 
8440
        remoteDispatchError(rerr);
 
8441
    if (nwfilter)
 
8442
        virNWFilterFree(nwfilter);
 
8443
    return rv;
 
8444
}
 
8445
 
 
8446
 
 
8447
static int
 
8448
remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
6792
8449
                                struct qemud_client *client ATTRIBUTE_UNUSED,
6793
8450
                                virConnectPtr conn,
6794
8451
                                remote_message_header *hdr ATTRIBUTE_UNUSED,
6795
8452
                                remote_error *rerr,
6796
 
                                remote_nwfilter_undefine_args *args,
6797
 
                                void *ret ATTRIBUTE_UNUSED)
6798
 
{
6799
 
    virNWFilterPtr nwfilter;
6800
 
 
6801
 
    nwfilter = get_nonnull_nwfilter (conn, args->nwfilter);
6802
 
    if (nwfilter == NULL) {
6803
 
        remoteDispatchConnError(rerr, conn);
6804
 
        return -1;
6805
 
    }
6806
 
 
6807
 
    if (virNWFilterUndefine (nwfilter) == -1) {
6808
 
        virNWFilterFree(nwfilter);
6809
 
        remoteDispatchConnError(rerr, conn);
6810
 
        return -1;
6811
 
    }
6812
 
    virNWFilterFree(nwfilter);
6813
 
    return 0;
6814
 
}
6815
 
 
6816
 
static int
6817
 
remoteDispatchListNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
6818
 
                             struct qemud_client *client ATTRIBUTE_UNUSED,
6819
 
                             virConnectPtr conn,
6820
 
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
6821
 
                             remote_error *rerr,
6822
 
                             remote_list_nwfilters_args *args,
6823
 
                             remote_list_nwfilters_ret *ret)
6824
 
{
 
8453
                                remote_nwfilter_define_xml_args *args,
 
8454
                                remote_nwfilter_define_xml_ret *ret)
 
8455
{
 
8456
    virNWFilterPtr nwfilter = NULL;
 
8457
    int rv = -1;
 
8458
 
 
8459
    if (!conn) {
 
8460
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8461
        goto cleanup;
 
8462
    }
 
8463
 
 
8464
    if (!(nwfilter = virNWFilterDefineXML(conn, args->xml)))
 
8465
        goto cleanup;
 
8466
 
 
8467
    make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
 
8468
 
 
8469
    rv = 0;
 
8470
 
 
8471
cleanup:
 
8472
    if (rv < 0)
 
8473
        remoteDispatchError(rerr);
 
8474
    if (nwfilter)
 
8475
        virNWFilterFree(nwfilter);
 
8476
    return rv;
 
8477
}
 
8478
 
 
8479
 
 
8480
static int
 
8481
remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8482
                               struct qemud_client *client ATTRIBUTE_UNUSED,
 
8483
                               virConnectPtr conn,
 
8484
                               remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8485
                               remote_error *rerr,
 
8486
                               remote_nwfilter_undefine_args *args,
 
8487
                               void *ret ATTRIBUTE_UNUSED)
 
8488
{
 
8489
    virNWFilterPtr nwfilter = NULL;
 
8490
    int rv = -1;
 
8491
 
 
8492
    if (!conn) {
 
8493
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8494
        goto cleanup;
 
8495
    }
 
8496
 
 
8497
    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
 
8498
        goto cleanup;
 
8499
 
 
8500
    if (virNWFilterUndefine(nwfilter) < 0)
 
8501
        goto cleanup;
 
8502
 
 
8503
    rv = 0;
 
8504
 
 
8505
cleanup:
 
8506
    if (rv < 0)
 
8507
        remoteDispatchError(rerr);
 
8508
    if (nwfilter)
 
8509
        virNWFilterFree(nwfilter);
 
8510
    return rv;
 
8511
}
 
8512
 
 
8513
static int
 
8514
remoteDispatchListNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8515
                            struct qemud_client *client ATTRIBUTE_UNUSED,
 
8516
                            virConnectPtr conn,
 
8517
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8518
                            remote_error *rerr,
 
8519
                            remote_list_nwfilters_args *args,
 
8520
                            remote_list_nwfilters_ret *ret)
 
8521
{
 
8522
    int rv = -1;
 
8523
    int len;
 
8524
 
 
8525
    if (!conn) {
 
8526
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8527
        goto cleanup;
 
8528
    }
6825
8529
 
6826
8530
    if (args->maxnames > REMOTE_NWFILTER_NAME_LIST_MAX) {
6827
 
        remoteDispatchFormatError (rerr,
6828
 
                                   "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
6829
 
        return -1;
 
8531
        virNetError(VIR_ERR_INTERNAL_ERROR,
 
8532
                    "%s", _("maxnames > REMOTE_NWFILTER_NAME_LIST_MAX"));
 
8533
        goto cleanup;
6830
8534
    }
6831
8535
 
6832
8536
    /* Allocate return buffer. */
6833
8537
    if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
6834
 
        remoteDispatchOOMError(rerr);
6835
 
        return -1;
6836
 
    }
6837
 
 
6838
 
    ret->names.names_len =
6839
 
        virConnectListNWFilters (conn,
6840
 
                                 ret->names.names_val, args->maxnames);
6841
 
    if (ret->names.names_len == -1) {
6842
 
        VIR_FREE(ret->names.names_len);
6843
 
        remoteDispatchConnError(rerr, conn);
6844
 
        return -1;
6845
 
    }
6846
 
 
6847
 
    return 0;
 
8538
        virReportOOMError();
 
8539
        goto cleanup;
 
8540
    }
 
8541
 
 
8542
    len = virConnectListNWFilters(conn,
 
8543
                                  ret->names.names_val, args->maxnames);
 
8544
    if (len < 0)
 
8545
        goto cleanup;
 
8546
    ret->names.names_len = len;
 
8547
 
 
8548
    rv = 0;
 
8549
 
 
8550
cleanup:
 
8551
    if (rv < 0) {
 
8552
        remoteDispatchError(rerr);
 
8553
        VIR_FREE(ret->names.names_val);
 
8554
    }
 
8555
    return rv;
6848
8556
}
6849
8557
 
6850
8558
 
6851
8559
static int
6852
 
remoteDispatchNwfilterGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
6853
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
6854
 
                              virConnectPtr conn,
6855
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
6856
 
                              remote_error *rerr,
6857
 
                              remote_nwfilter_get_xml_desc_args *args,
6858
 
                              remote_nwfilter_get_xml_desc_ret *ret)
 
8560
remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8561
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
8562
                                 virConnectPtr conn,
 
8563
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8564
                                 remote_error *rerr,
 
8565
                                 remote_nwfilter_get_xml_desc_args *args,
 
8566
                                 remote_nwfilter_get_xml_desc_ret *ret)
6859
8567
{
6860
 
    virNWFilterPtr nwfilter;
 
8568
    virNWFilterPtr nwfilter = NULL;
 
8569
    int rv = -1;
6861
8570
 
6862
 
    nwfilter = get_nonnull_nwfilter (conn, args->nwfilter);
6863
 
    if (nwfilter == NULL) {
6864
 
        remoteDispatchConnError(rerr, conn);
6865
 
        return -1;
 
8571
    if (!conn) {
 
8572
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8573
        goto cleanup;
6866
8574
    }
6867
8575
 
 
8576
    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
 
8577
        goto cleanup;
 
8578
 
6868
8579
    /* remoteDispatchClientRequest will free this. */
6869
 
    ret->xml = virNWFilterGetXMLDesc (nwfilter, args->flags);
6870
 
    if (!ret->xml) {
 
8580
    if (!(ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags)))
 
8581
        goto cleanup;
 
8582
 
 
8583
    rv = 0;
 
8584
 
 
8585
cleanup:
 
8586
    if (rv < 0)
 
8587
        remoteDispatchError(rerr);
 
8588
    if (nwfilter)
6871
8589
        virNWFilterFree(nwfilter);
6872
 
        remoteDispatchConnError(rerr, conn);
6873
 
        return -1;
6874
 
    }
6875
 
    virNWFilterFree(nwfilter);
6876
 
    return 0;
6877
 
}
6878
 
 
6879
 
 
6880
 
static int
6881
 
remoteDispatchNumOfNwfilters (struct qemud_server *server ATTRIBUTE_UNUSED,
6882
 
                              struct qemud_client *client ATTRIBUTE_UNUSED,
6883
 
                              virConnectPtr conn,
6884
 
                              remote_message_header *hdr ATTRIBUTE_UNUSED,
6885
 
                              remote_error *rerr,
6886
 
                              void *args ATTRIBUTE_UNUSED,
6887
 
                              remote_num_of_nwfilters_ret *ret)
6888
 
{
6889
 
 
6890
 
    ret->num = virConnectNumOfNWFilters (conn);
6891
 
    if (ret->num == -1) {
6892
 
        remoteDispatchConnError(rerr, conn);
6893
 
        return -1;
6894
 
    }
6895
 
 
6896
 
    return 0;
6897
 
}
6898
 
 
6899
 
 
6900
 
static int
6901
 
remoteDispatchDomainGetBlockInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
6902
 
                                  struct qemud_client *client ATTRIBUTE_UNUSED,
6903
 
                                  virConnectPtr conn,
6904
 
                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
6905
 
                                  remote_error *rerr,
6906
 
                                  remote_domain_get_block_info_args *args,
6907
 
                                  remote_domain_get_block_info_ret *ret)
6908
 
{
6909
 
    virDomainPtr dom;
 
8590
    return rv;
 
8591
}
 
8592
 
 
8593
 
 
8594
static int
 
8595
remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8596
                             struct qemud_client *client ATTRIBUTE_UNUSED,
 
8597
                             virConnectPtr conn,
 
8598
                             remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8599
                             remote_error *rerr,
 
8600
                             void *args ATTRIBUTE_UNUSED,
 
8601
                             remote_num_of_nwfilters_ret *ret)
 
8602
{
 
8603
    int rv = -1;
 
8604
 
 
8605
    if (!conn) {
 
8606
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8607
        goto cleanup;
 
8608
    }
 
8609
 
 
8610
    if ((ret->num = virConnectNumOfNWFilters(conn)) < 0)
 
8611
        goto cleanup;
 
8612
 
 
8613
    rv = 0;
 
8614
 
 
8615
cleanup:
 
8616
    if (rv < 0)
 
8617
        remoteDispatchError(rerr);
 
8618
    return rv;
 
8619
}
 
8620
 
 
8621
 
 
8622
static int
 
8623
remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8624
                                 struct qemud_client *client ATTRIBUTE_UNUSED,
 
8625
                                 virConnectPtr conn,
 
8626
                                 remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8627
                                 remote_error *rerr,
 
8628
                                 remote_domain_get_block_info_args *args,
 
8629
                                 remote_domain_get_block_info_ret *ret)
 
8630
{
 
8631
    virDomainPtr dom = NULL;
6910
8632
    virDomainBlockInfo info;
6911
 
 
6912
 
    dom = get_nonnull_domain (conn, args->dom);
6913
 
    if (dom == NULL) {
6914
 
        remoteDispatchConnError(rerr, conn);
6915
 
        return -1;
6916
 
    }
6917
 
 
6918
 
    if (virDomainGetBlockInfo (dom, args->path, &info, args->flags) == -1) {
6919
 
        virDomainFree(dom);
6920
 
        remoteDispatchConnError(rerr, conn);
6921
 
        return -1;
6922
 
    }
 
8633
    int rv = -1;
 
8634
 
 
8635
    if (!conn) {
 
8636
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8637
        goto cleanup;
 
8638
    }
 
8639
 
 
8640
    if (!(dom = get_nonnull_domain(conn, args->dom)))
 
8641
        goto cleanup;
 
8642
 
 
8643
    if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) < 0)
 
8644
        goto cleanup;
6923
8645
 
6924
8646
    ret->capacity = info.capacity;
6925
8647
    ret->allocation = info.allocation;
6926
8648
    ret->physical = info.physical;
6927
8649
 
6928
 
    virDomainFree(dom);
 
8650
    rv = 0;
6929
8651
 
6930
 
    return 0;
 
8652
cleanup:
 
8653
    if (rv < 0)
 
8654
        remoteDispatchError(rerr);
 
8655
    if (dom)
 
8656
        virDomainFree(dom);
 
8657
    return rv;
6931
8658
}
6932
8659
 
6933
8660
static int
6934
 
qemuDispatchMonitorCommand (struct qemud_server *server ATTRIBUTE_UNUSED,
6935
 
                            struct qemud_client *client ATTRIBUTE_UNUSED,
6936
 
                            virConnectPtr conn,
6937
 
                            remote_message_header *hdr ATTRIBUTE_UNUSED,
6938
 
                            remote_error *rerr,
6939
 
                            qemu_monitor_command_args *args,
6940
 
                            qemu_monitor_command_ret *ret)
 
8661
qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
 
8662
                           struct qemud_client *client ATTRIBUTE_UNUSED,
 
8663
                           virConnectPtr conn,
 
8664
                           remote_message_header *hdr ATTRIBUTE_UNUSED,
 
8665
                           remote_error *rerr,
 
8666
                           qemu_monitor_command_args *args,
 
8667
                           qemu_monitor_command_ret *ret)
6941
8668
{
6942
 
    virDomainPtr domain;
6943
 
 
6944
 
    domain = get_nonnull_domain(conn, args->domain);
6945
 
    if (domain == NULL) {
6946
 
        remoteDispatchConnError(rerr, conn);
6947
 
        return -1;
6948
 
    }
6949
 
 
6950
 
    if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
6951
 
                                    args->flags) == -1) {
6952
 
        virDomainFree(domain);
6953
 
        remoteDispatchConnError(rerr, conn);
6954
 
        return -1;
6955
 
    }
6956
 
 
6957
 
    virDomainFree(domain);
6958
 
 
6959
 
    return 0;
 
8669
    virDomainPtr dom = NULL;
 
8670
    int rv = -1;
 
8671
 
 
8672
    if (!conn) {
 
8673
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8674
        goto cleanup;
 
8675
    }
 
8676
 
 
8677
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8678
        goto cleanup;
 
8679
 
 
8680
    if (virDomainQemuMonitorCommand(dom, args->cmd, &ret->result,
 
8681
                                    args->flags) < 0)
 
8682
        goto cleanup;
 
8683
 
 
8684
    rv = 0;
 
8685
 
 
8686
cleanup:
 
8687
    if (rv < 0)
 
8688
        remoteDispatchError(rerr);
 
8689
    if (dom)
 
8690
        virDomainFree(dom);
 
8691
    return rv;
6960
8692
}
6961
8693
 
6962
8694
 
6969
8701
                                remote_domain_open_console_args *args,
6970
8702
                                void *ret ATTRIBUTE_UNUSED)
6971
8703
{
6972
 
    int r;
6973
 
    struct qemud_client_stream *stream;
6974
 
    virDomainPtr dom;
6975
 
 
6976
 
    CHECK_CONN (client);
6977
 
 
6978
 
    dom = get_nonnull_domain (conn, args->domain);
6979
 
    if (dom == NULL) {
6980
 
        remoteDispatchConnError(rerr, conn);
6981
 
        return -1;
6982
 
    }
6983
 
 
6984
 
    stream = remoteCreateClientStream(conn, hdr);
6985
 
    if (!stream) {
6986
 
        virDomainFree(dom);
6987
 
        remoteDispatchOOMError(rerr);
6988
 
        return -1;
6989
 
    }
6990
 
 
6991
 
    r = virDomainOpenConsole(dom,
 
8704
    struct qemud_client_stream *stream = NULL;
 
8705
    virDomainPtr dom = NULL;
 
8706
    int rv = -1;
 
8707
 
 
8708
    if (!conn) {
 
8709
        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 
8710
        goto cleanup;
 
8711
    }
 
8712
 
 
8713
    if (!(dom = get_nonnull_domain(conn, args->domain)))
 
8714
        goto cleanup;
 
8715
 
 
8716
    if (!(stream = remoteCreateClientStream(conn, hdr))) {
 
8717
        virReportOOMError();
 
8718
        goto cleanup;
 
8719
    }
 
8720
 
 
8721
    if (virDomainOpenConsole(dom,
6992
8722
                             args->devname ? *args->devname : NULL,
6993
8723
                             stream->st,
6994
 
                             args->flags);
6995
 
    if (r == -1) {
6996
 
        virDomainFree(dom);
6997
 
        remoteFreeClientStream(client, stream);
6998
 
        remoteDispatchConnError(rerr, conn);
6999
 
        return -1;
7000
 
    }
7001
 
 
7002
 
    if (remoteAddClientStream(client, stream, 1) < 0) {
7003
 
        virDomainFree(dom);
7004
 
        remoteDispatchConnError(rerr, conn);
 
8724
                             args->flags) < 0)
 
8725
        goto cleanup;
 
8726
 
 
8727
    if (remoteAddClientStream(client, stream, 1) < 0)
 
8728
        goto cleanup;
 
8729
 
 
8730
    rv = 0;
 
8731
 
 
8732
cleanup:
 
8733
    if (rv < 0)
 
8734
        remoteDispatchError(rerr);
 
8735
    if (stream && rv < 0) {
7005
8736
        virStreamAbort(stream->st);
7006
8737
        remoteFreeClientStream(client, stream);
7007
 
        return -1;
7008
8738
    }
7009
 
 
7010
 
    virDomainFree(dom);
7011
 
    return 0;
 
8739
    if (dom)
 
8740
        virDomainFree(dom);
 
8741
    return rv;
7012
8742
}
7013
8743
 
7014
8744
 
7021
8751
 * NB. If these return NULL then the caller must return an error.
7022
8752
 */
7023
8753
static virDomainPtr
7024
 
get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain)
 
8754
get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain)
7025
8755
{
7026
8756
    virDomainPtr dom;
7027
 
    dom = virGetDomain (conn, domain.name, BAD_CAST domain.uuid);
 
8757
    dom = virGetDomain(conn, domain.name, BAD_CAST domain.uuid);
7028
8758
    /* Should we believe the domain.id sent by the client?  Maybe
7029
8759
     * this should be a check rather than an assignment? XXX
7030
8760
     */
7033
8763
}
7034
8764
 
7035
8765
static virNetworkPtr
7036
 
get_nonnull_network (virConnectPtr conn, remote_nonnull_network network)
 
8766
get_nonnull_network(virConnectPtr conn, remote_nonnull_network network)
7037
8767
{
7038
 
    return virGetNetwork (conn, network.name, BAD_CAST network.uuid);
 
8768
    return virGetNetwork(conn, network.name, BAD_CAST network.uuid);
7039
8769
}
7040
8770
 
7041
8771
static virInterfacePtr
7042
 
get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface)
 
8772
get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface)
7043
8773
{
7044
 
    return virGetInterface (conn, iface.name, iface.mac);
 
8774
    return virGetInterface(conn, iface.name, iface.mac);
7045
8775
}
7046
8776
 
7047
8777
static virStoragePoolPtr
7048
 
get_nonnull_storage_pool (virConnectPtr conn, remote_nonnull_storage_pool pool)
 
8778
get_nonnull_storage_pool(virConnectPtr conn, remote_nonnull_storage_pool pool)
7049
8779
{
7050
 
    return virGetStoragePool (conn, pool.name, BAD_CAST pool.uuid);
 
8780
    return virGetStoragePool(conn, pool.name, BAD_CAST pool.uuid);
7051
8781
}
7052
8782
 
7053
8783
static virStorageVolPtr
7054
 
get_nonnull_storage_vol (virConnectPtr conn, remote_nonnull_storage_vol vol)
 
8784
get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol)
7055
8785
{
7056
8786
    virStorageVolPtr ret;
7057
 
    ret = virGetStorageVol (conn, vol.pool, vol.name, vol.key);
 
8787
    ret = virGetStorageVol(conn, vol.pool, vol.name, vol.key);
7058
8788
    return ret;
7059
8789
}
7060
8790
 
7061
8791
static virSecretPtr
7062
 
get_nonnull_secret (virConnectPtr conn, remote_nonnull_secret secret)
 
8792
get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret)
7063
8793
{
7064
 
    return virGetSecret (conn, BAD_CAST secret.uuid, secret.usageType, secret.usageID);
 
8794
    return virGetSecret(conn, BAD_CAST secret.uuid, secret.usageType, secret.usageID);
7065
8795
}
7066
8796
 
7067
8797
static virNWFilterPtr
7068
 
get_nonnull_nwfilter (virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
 
8798
get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
7069
8799
{
7070
 
    return virGetNWFilter (conn, nwfilter.name, BAD_CAST nwfilter.uuid);
 
8800
    return virGetNWFilter(conn, nwfilter.name, BAD_CAST nwfilter.uuid);
7071
8801
}
7072
8802
 
7073
8803
static virDomainSnapshotPtr
7074
 
get_nonnull_domain_snapshot (virDomainPtr domain, remote_nonnull_domain_snapshot snapshot)
 
8804
get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot)
7075
8805
{
7076
 
    return virGetDomainSnapshot(domain, snapshot.name);
 
8806
    return virGetDomainSnapshot(dom, snapshot.name);
7077
8807
}
7078
8808
 
7079
8809
/* Make remote_nonnull_domain and remote_nonnull_network. */
7080
8810
static void
7081
 
make_nonnull_domain (remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
 
8811
make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
7082
8812
{
7083
8813
    dom_dst->id = dom_src->id;
7084
 
    dom_dst->name = strdup (dom_src->name);
7085
 
    memcpy (dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
7086
 
}
7087
 
 
7088
 
static void
7089
 
make_nonnull_network (remote_nonnull_network *net_dst, virNetworkPtr net_src)
7090
 
{
7091
 
    net_dst->name = strdup (net_src->name);
7092
 
    memcpy (net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
7093
 
}
7094
 
 
7095
 
static void
7096
 
make_nonnull_interface (remote_nonnull_interface *interface_dst,
7097
 
                        virInterfacePtr interface_src)
7098
 
{
7099
 
    interface_dst->name = strdup (interface_src->name);
7100
 
    interface_dst->mac = strdup (interface_src->mac);
7101
 
}
7102
 
 
7103
 
static void
7104
 
make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
7105
 
{
7106
 
    pool_dst->name = strdup (pool_src->name);
7107
 
    memcpy (pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
7108
 
}
7109
 
 
7110
 
static void
7111
 
make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
7112
 
{
7113
 
    vol_dst->pool = strdup (vol_src->pool);
7114
 
    vol_dst->name = strdup (vol_src->name);
7115
 
    vol_dst->key = strdup (vol_src->key);
7116
 
}
7117
 
 
7118
 
static void
7119
 
make_nonnull_node_device (remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
 
8814
    dom_dst->name = strdup(dom_src->name);
 
8815
    memcpy(dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
 
8816
}
 
8817
 
 
8818
static void
 
8819
make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src)
 
8820
{
 
8821
    net_dst->name = strdup(net_src->name);
 
8822
    memcpy(net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
 
8823
}
 
8824
 
 
8825
static void
 
8826
make_nonnull_interface(remote_nonnull_interface *interface_dst,
 
8827
                       virInterfacePtr interface_src)
 
8828
{
 
8829
    interface_dst->name = strdup(interface_src->name);
 
8830
    interface_dst->mac = strdup(interface_src->mac);
 
8831
}
 
8832
 
 
8833
static void
 
8834
make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
 
8835
{
 
8836
    pool_dst->name = strdup(pool_src->name);
 
8837
    memcpy(pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
 
8838
}
 
8839
 
 
8840
static void
 
8841
make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
 
8842
{
 
8843
    vol_dst->pool = strdup(vol_src->pool);
 
8844
    vol_dst->name = strdup(vol_src->name);
 
8845
    vol_dst->key = strdup(vol_src->key);
 
8846
}
 
8847
 
 
8848
static void
 
8849
make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
7120
8850
{
7121
8851
    dev_dst->name = strdup(dev_src->name);
7122
8852
}
7123
8853
 
7124
8854
static void
7125
 
make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
 
8855
make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
7126
8856
{
7127
 
    memcpy (secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN);
 
8857
    memcpy(secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN);
7128
8858
    secret_dst->usageType = secret_src->usageType;
7129
 
    secret_dst->usageID = strdup (secret_src->usageID);
 
8859
    secret_dst->usageID = strdup(secret_src->usageID);
7130
8860
}
7131
8861
 
7132
8862
static void
7133
 
make_nonnull_nwfilter (remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
 
8863
make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
7134
8864
{
7135
 
    nwfilter_dst->name = strdup (nwfilter_src->name);
7136
 
    memcpy (nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
 
8865
    nwfilter_dst->name = strdup(nwfilter_src->name);
 
8866
    memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
7137
8867
}
7138
8868
 
7139
8869
static void
7140
 
make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
 
8870
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
7141
8871
{
7142
8872
    snapshot_dst->name = strdup(snapshot_src->name);
7143
8873
    make_nonnull_domain(&snapshot_dst->domain, snapshot_src->domain);