2007-06-11 11:47:01 +00:00
|
|
|
/*
|
|
|
|
* remote.c: code handling remote requests (from remote_internal.c)
|
|
|
|
*
|
2009-02-05 16:28:15 +00:00
|
|
|
* Copyright (C) 2007, 2008, 2009 Red Hat, Inc.
|
2007-06-11 11:47:01 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Richard W.M. Jones <rjones@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2007-12-05 15:34:05 +00:00
|
|
|
#include <fnmatch.h>
|
2009-02-05 16:28:30 +00:00
|
|
|
#include "virterror_internal.h"
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2007-12-05 18:21:27 +00:00
|
|
|
#ifdef HAVE_POLKIT
|
|
|
|
#include <polkit/polkit.h>
|
|
|
|
#include <polkit-dbus/polkit-dbus.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "libvirt_internal.h"
|
|
|
|
#include "datatypes.h"
|
Standardize use of header files, making internal.h primary.
* qemud/internal.h, qemud/qemud.h: Rename this file so it
doesn't conflict with src/internal.h.
* HACKING: Document how header files should be used.
* qemud/Makefile.am: Add src/ directory to includes.
* qemud/event.c, qemud/mdns.c, qemud/qemud.c, qemud/remote.c,
qemud/remote_protocol.c, qemud/remote_protocol.h,
qemud/remote_protocol.x, src/buf.c, src/libvirt.c,
src/nodeinfo.c, src/qemu_conf.c, src/qemu_driver.c,
src/stats_linux.c, src/storage_backend.c, src/storage_backend_fs.c,
src/storage_backend_iscsi.c, src/storage_backend_logical.c,
src/storage_conf.c, src/storage_driver.c, src/util.c,
src/util.h, src/virsh.c, src/virterror.c, src/xend_internal.c,
src/xml.c, tests/reconnect.c, tests/xmlrpctest.c,
tests/qparamtest.c: Standardize use of header files.
* docs/*, po/*: Rebuild docs.
2008-05-23 08:24:41 +00:00
|
|
|
#include "qemud.h"
|
2008-06-06 10:52:01 +00:00
|
|
|
#include "memory.h"
|
2009-05-19 13:15:50 +00:00
|
|
|
#include "util.h"
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2009-05-19 13:15:50 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_REMOTE
|
2008-12-22 12:55:47 +00:00
|
|
|
#define REMOTE_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
static void remoteDispatchFormatError (remote_error *rerr,
|
|
|
|
const char *fmt, ...)
|
|
|
|
ATTRIBUTE_FORMAT(printf, 2, 3);
|
2007-06-11 11:47:01 +00:00
|
|
|
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
|
|
|
|
static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
|
2009-05-20 14:26:49 +00:00
|
|
|
static virInterfacePtr get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface interface);
|
2008-02-20 15:22:35 +00:00
|
|
|
static virStoragePoolPtr get_nonnull_storage_pool (virConnectPtr conn, remote_nonnull_storage_pool pool);
|
|
|
|
static virStorageVolPtr get_nonnull_storage_vol (virConnectPtr conn, remote_nonnull_storage_vol vol);
|
2007-06-11 11:47:01 +00:00
|
|
|
static void make_nonnull_domain (remote_nonnull_domain *dom_dst, virDomainPtr dom_src);
|
|
|
|
static void make_nonnull_network (remote_nonnull_network *net_dst, virNetworkPtr net_src);
|
2009-05-20 14:26:49 +00:00
|
|
|
static void make_nonnull_interface (remote_nonnull_interface *interface_dst, virInterfacePtr interface_src);
|
2008-02-20 15:22:35 +00:00
|
|
|
static void make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src);
|
|
|
|
static void make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src);
|
2008-11-21 12:31:04 +00:00
|
|
|
static void make_nonnull_node_device (remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
#include "remote_dispatch_prototypes.h"
|
|
|
|
|
2008-12-04 22:03:24 +00:00
|
|
|
typedef union {
|
|
|
|
#include "remote_dispatch_args.h"
|
|
|
|
} dispatch_args;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
#include "remote_dispatch_ret.h"
|
|
|
|
} dispatch_ret;
|
|
|
|
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
/**
|
|
|
|
* When the RPC handler is called:
|
|
|
|
*
|
|
|
|
* - Server object is unlocked
|
|
|
|
* - Client object is unlocked
|
|
|
|
*
|
|
|
|
* Both must be locked before use. Server lock must
|
|
|
|
* be held before attempting to lock client.
|
|
|
|
*
|
|
|
|
* Without any locking, it is safe to use:
|
|
|
|
*
|
|
|
|
* 'conn', 'rerr', 'args and 'ret'
|
|
|
|
*/
|
2007-12-05 15:34:05 +00:00
|
|
|
typedef int (*dispatch_fn) (struct qemud_server *server,
|
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *err,
|
2008-12-04 22:03:24 +00:00
|
|
|
dispatch_args *args,
|
|
|
|
dispatch_ret *ret);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
dispatch_fn fn;
|
|
|
|
xdrproc_t args_filter;
|
|
|
|
xdrproc_t ret_filter;
|
|
|
|
} dispatch_data;
|
|
|
|
|
|
|
|
static const dispatch_data const dispatch_table[] = {
|
|
|
|
#include "remote_dispatch_table.h"
|
|
|
|
};
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
/* Prototypes */
|
|
|
|
static void
|
|
|
|
remoteDispatchDomainEventSend (struct qemud_client *client,
|
2009-01-20 19:25:15 +00:00
|
|
|
struct qemud_client_message *msg,
|
2008-10-23 13:18:18 +00:00
|
|
|
virDomainPtr dom,
|
2008-11-17 16:43:00 +00:00
|
|
|
int event,
|
|
|
|
int detail);
|
2008-10-23 13:18:18 +00:00
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
|
|
|
|
/* Convert a libvirt virError object into wire format */
|
|
|
|
static void
|
|
|
|
remoteDispatchCopyError (remote_error *rerr,
|
|
|
|
virErrorPtr verr)
|
|
|
|
{
|
|
|
|
rerr->code = verr->code;
|
|
|
|
rerr->domain = verr->domain;
|
|
|
|
rerr->message = verr->message ? malloc(sizeof(char*)) : NULL;
|
|
|
|
if (rerr->message) *rerr->message = strdup(verr->message);
|
|
|
|
rerr->level = verr->level;
|
|
|
|
rerr->str1 = verr->str1 ? malloc(sizeof(char*)) : NULL;
|
|
|
|
if (rerr->str1) *rerr->str1 = strdup(verr->str1);
|
|
|
|
rerr->str2 = verr->str2 ? malloc(sizeof(char*)) : NULL;
|
|
|
|
if (rerr->str2) *rerr->str2 = strdup(verr->str2);
|
|
|
|
rerr->str3 = verr->str3 ? malloc(sizeof(char*)) : NULL;
|
|
|
|
if (rerr->str3) *rerr->str3 = strdup(verr->str3);
|
|
|
|
rerr->int1 = verr->int1;
|
|
|
|
rerr->int2 = verr->int2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* A set of helpers for sending back errors to client
|
|
|
|
in various ways .... */
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchStringError (remote_error *rerr,
|
|
|
|
int code, const char *msg)
|
|
|
|
{
|
|
|
|
virError verr;
|
|
|
|
|
|
|
|
memset(&verr, 0, sizeof verr);
|
|
|
|
|
|
|
|
/* Construct the dummy libvirt virError. */
|
|
|
|
verr.code = code;
|
|
|
|
verr.domain = VIR_FROM_REMOTE;
|
|
|
|
verr.message = (char *)msg;
|
|
|
|
verr.level = VIR_ERR_ERROR;
|
|
|
|
verr.str1 = (char *)msg;
|
|
|
|
|
|
|
|
remoteDispatchCopyError(rerr, &verr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchAuthError (remote_error *rerr)
|
|
|
|
{
|
|
|
|
remoteDispatchStringError (rerr, VIR_ERR_AUTH_FAILED, "authentication failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchFormatError (remote_error *rerr,
|
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
char msgbuf[1024];
|
|
|
|
char *msg = msgbuf;
|
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
vsnprintf (msgbuf, sizeof msgbuf, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
remoteDispatchStringError (rerr, VIR_ERR_RPC, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchGenericError (remote_error *rerr)
|
|
|
|
{
|
|
|
|
remoteDispatchStringError(rerr,
|
|
|
|
VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"library function returned error but did not set virterror");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchOOMError (remote_error *rerr)
|
|
|
|
{
|
|
|
|
remoteDispatchStringError(rerr,
|
|
|
|
VIR_ERR_NO_MEMORY,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchConnError (remote_error *rerr,
|
|
|
|
virConnectPtr conn)
|
|
|
|
{
|
|
|
|
virErrorPtr verr;
|
|
|
|
|
|
|
|
if (conn)
|
|
|
|
verr = virConnGetLastError(conn);
|
|
|
|
else
|
|
|
|
verr = virGetLastError();
|
|
|
|
if (verr)
|
|
|
|
remoteDispatchCopyError(rerr, verr);
|
|
|
|
else
|
|
|
|
remoteDispatchGenericError(rerr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/* This function gets called from qemud when it detects an incoming
|
|
|
|
* remote protocol message. At this point, client->buffer contains
|
|
|
|
* the full call message (including length word which we skip).
|
2008-12-04 22:16:40 +00:00
|
|
|
*
|
|
|
|
* Server object is unlocked
|
|
|
|
* Client object is locked
|
2007-06-11 11:47:01 +00:00
|
|
|
*/
|
2009-01-20 19:25:15 +00:00
|
|
|
int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchClientRequest (struct qemud_server *server,
|
2009-01-20 19:25:15 +00:00
|
|
|
struct qemud_client *client,
|
|
|
|
struct qemud_client_message *msg)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
|
|
|
XDR xdr;
|
|
|
|
remote_message_header req, rep;
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error rerr;
|
2008-12-04 22:03:24 +00:00
|
|
|
dispatch_args args;
|
|
|
|
dispatch_ret ret;
|
|
|
|
const dispatch_data *data = NULL;
|
2009-01-20 19:25:15 +00:00
|
|
|
int rv = -1;
|
|
|
|
unsigned int len;
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn = NULL;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-12-04 22:03:24 +00:00
|
|
|
memset(&args, 0, sizeof args);
|
|
|
|
memset(&ret, 0, sizeof ret);
|
2008-12-04 22:12:53 +00:00
|
|
|
memset(&rerr, 0, sizeof rerr);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* Parse the header. */
|
2009-01-20 19:25:15 +00:00
|
|
|
xdrmem_create (&xdr,
|
|
|
|
msg->buffer + REMOTE_MESSAGE_HEADER_XDR_LEN,
|
|
|
|
msg->bufferLength - REMOTE_MESSAGE_HEADER_XDR_LEN,
|
|
|
|
XDR_DECODE);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
if (!xdr_remote_message_header (&xdr, &req))
|
|
|
|
goto fatal_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* Check version, etc. */
|
|
|
|
if (req.prog != REMOTE_PROGRAM) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (&rerr,
|
|
|
|
_("program mismatch (actual %x, expected %x)"),
|
|
|
|
req.prog, REMOTE_PROGRAM);
|
|
|
|
goto rpc_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
if (req.vers != REMOTE_PROTOCOL_VERSION) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (&rerr,
|
|
|
|
_("version mismatch (actual %x, expected %x)"),
|
|
|
|
req.vers, REMOTE_PROTOCOL_VERSION);
|
|
|
|
goto rpc_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
if (req.direction != REMOTE_CALL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (&rerr, _("direction (%d) != REMOTE_CALL"),
|
|
|
|
(int) req.direction);
|
|
|
|
goto rpc_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
if (req.status != REMOTE_OK) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (&rerr, _("status (%d) != REMOTE_OK"),
|
|
|
|
(int) req.status);
|
|
|
|
goto rpc_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
/* If client is marked as needing auth, don't allow any RPC ops,
|
|
|
|
* except for authentication ones
|
|
|
|
*/
|
|
|
|
if (client->auth) {
|
|
|
|
if (req.proc != REMOTE_PROC_AUTH_LIST &&
|
|
|
|
req.proc != REMOTE_PROC_AUTH_SASL_INIT &&
|
|
|
|
req.proc != REMOTE_PROC_AUTH_SASL_START &&
|
2007-12-05 18:21:27 +00:00
|
|
|
req.proc != REMOTE_PROC_AUTH_SASL_STEP &&
|
|
|
|
req.proc != REMOTE_PROC_AUTH_POLKIT
|
2007-12-05 15:24:15 +00:00
|
|
|
) {
|
2008-12-04 22:12:53 +00:00
|
|
|
/* Explicitly *NOT* calling remoteDispatchAuthError() because
|
|
|
|
we want back-compatability with libvirt clients which don't
|
|
|
|
support the VIR_ERR_AUTH_FAILED error code */
|
|
|
|
remoteDispatchFormatError (&rerr, "%s", _("authentication required"));
|
|
|
|
goto rpc_error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-04 22:03:24 +00:00
|
|
|
if (req.proc >= ARRAY_CARDINALITY(dispatch_table) ||
|
|
|
|
dispatch_table[req.proc].fn == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (&rerr, _("unknown procedure: %d"),
|
|
|
|
req.proc);
|
|
|
|
goto rpc_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 22:03:24 +00:00
|
|
|
data = &(dispatch_table[req.proc]);
|
|
|
|
|
|
|
|
/* De-serialize args off the wire */
|
|
|
|
if (!((data->args_filter)(&xdr, &args))) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (&rerr, "%s", _("parse args failed"));
|
|
|
|
goto rpc_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Call function. */
|
2008-12-04 22:16:40 +00:00
|
|
|
conn = client->conn;
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When the RPC handler is called:
|
|
|
|
*
|
|
|
|
* - Server object is unlocked
|
|
|
|
* - Client object is unlocked
|
|
|
|
*
|
|
|
|
* Without locking, it is safe to use:
|
|
|
|
*
|
|
|
|
* 'conn', 'rerr', 'args and 'ret'
|
|
|
|
*/
|
|
|
|
rv = (data->fn)(server, client, conn, &rerr, &args, &ret);
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2008-12-04 22:03:24 +00:00
|
|
|
xdr_free (data->args_filter, (char*)&args);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
rpc_error:
|
|
|
|
xdr_destroy (&xdr);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* Return header. */
|
|
|
|
rep.prog = req.prog;
|
|
|
|
rep.vers = req.vers;
|
|
|
|
rep.proc = req.proc;
|
|
|
|
rep.direction = REMOTE_REPLY;
|
|
|
|
rep.serial = req.serial;
|
2008-12-04 22:12:53 +00:00
|
|
|
rep.status = rv < 0 ? REMOTE_ERROR : REMOTE_OK;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* Serialise the return header. */
|
2009-01-20 19:25:15 +00:00
|
|
|
xdrmem_create (&xdr, msg->buffer, sizeof msg->buffer, XDR_ENCODE);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
len = 0; /* We'll come back and write this later. */
|
2009-01-20 19:25:15 +00:00
|
|
|
if (!xdr_u_int (&xdr, &len)) {
|
2008-12-04 22:03:24 +00:00
|
|
|
if (rv == 0) xdr_free (data->ret_filter, (char*)&ret);
|
2008-12-04 22:12:53 +00:00
|
|
|
goto fatal_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!xdr_remote_message_header (&xdr, &rep)) {
|
2008-12-04 22:03:24 +00:00
|
|
|
if (rv == 0) xdr_free (data->ret_filter, (char*)&ret);
|
2008-12-04 22:12:53 +00:00
|
|
|
goto fatal_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If OK, serialise return structure, if error serialise error. */
|
2008-12-04 22:12:53 +00:00
|
|
|
if (rv >= 0) {
|
|
|
|
if (!((data->ret_filter) (&xdr, &ret)))
|
|
|
|
goto fatal_error;
|
2008-12-04 22:03:24 +00:00
|
|
|
xdr_free (data->ret_filter, (char*)&ret);
|
2007-06-11 11:47:01 +00:00
|
|
|
} else /* error */ {
|
2008-12-04 22:12:53 +00:00
|
|
|
/* Error was NULL so synthesize an error. */
|
|
|
|
if (rerr.code == 0)
|
|
|
|
remoteDispatchGenericError(&rerr);
|
|
|
|
if (!xdr_remote_error (&xdr, &rerr))
|
|
|
|
goto fatal_error;
|
2009-01-30 16:48:02 +00:00
|
|
|
xdr_free((xdrproc_t)xdr_remote_error, (char *)&rerr);
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the length word. */
|
|
|
|
len = xdr_getpos (&xdr);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (xdr_setpos (&xdr, 0) == 0)
|
|
|
|
goto fatal_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
if (!xdr_u_int (&xdr, &len))
|
2008-12-04 22:12:53 +00:00
|
|
|
goto fatal_error;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
xdr_destroy (&xdr);
|
2009-01-20 19:25:15 +00:00
|
|
|
|
|
|
|
msg->bufferLength = len;
|
|
|
|
msg->bufferOffset = 0;
|
|
|
|
|
|
|
|
return 0;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
fatal_error:
|
|
|
|
/* Seriously bad stuff happened, so we'll kill off this client
|
|
|
|
and not send back any RPC error */
|
2007-06-11 11:47:01 +00:00
|
|
|
xdr_destroy (&xdr);
|
2009-01-20 19:25:15 +00:00
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
int remoteRelayDomainEvent (virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-11-17 16:43:00 +00:00
|
|
|
virDomainPtr dom,
|
|
|
|
int event,
|
|
|
|
int detail,
|
|
|
|
void *opaque)
|
2008-10-23 13:18:18 +00:00
|
|
|
{
|
|
|
|
struct qemud_client *client = opaque;
|
2008-11-17 16:43:00 +00:00
|
|
|
REMOTE_DEBUG("Relaying domain event %d %d", event, detail);
|
2008-10-23 13:18:18 +00:00
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
if (client) {
|
|
|
|
struct qemud_client_message *ev;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(ev) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
|
|
|
|
remoteDispatchDomainEventSend (client, ev, dom, event, detail);
|
|
|
|
|
|
|
|
if (qemudRegisterClientEvent(client->server, client, 1) < 0)
|
|
|
|
qemudDispatchClientFailure(client);
|
|
|
|
|
|
|
|
virMutexUnlock(&client->lock);
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/*----- Functions. -----*/
|
|
|
|
|
|
|
|
static int
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchOpen (struct qemud_server *server,
|
2008-12-04 22:12:53 +00:00
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
struct remote_open_args *args, void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
const char *name;
|
2008-12-04 22:16:40 +00:00
|
|
|
int flags, rc;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* Already opened? */
|
2008-12-04 22:16:40 +00:00
|
|
|
if (conn) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("connection already open"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
name = args->name ? *args->name : NULL;
|
|
|
|
|
|
|
|
/* If this connection arrived on a readonly socket, force
|
|
|
|
* the connection to be readonly.
|
|
|
|
*/
|
|
|
|
flags = args->flags;
|
|
|
|
if (client->readonly) flags |= VIR_CONNECT_RO;
|
|
|
|
|
|
|
|
client->conn =
|
|
|
|
flags & VIR_CONNECT_RO
|
|
|
|
? virConnectOpenReadOnly (name)
|
|
|
|
: virConnectOpen (name);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
if (client->conn == NULL)
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchConnError(rerr, NULL);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
rc = client->conn ? 0 : -1;
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return rc;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
#define CHECK_CONN(client) \
|
|
|
|
if (!client->conn) { \
|
|
|
|
remoteDispatchFormatError (rerr, "%s", _("connection not open")); \
|
|
|
|
return -1; \
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchClose (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
remote_error *rerr ATTRIBUTE_UNUSED,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED, void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
client->closing = 1;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:12:53 +00:00
|
|
|
return 0;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-08-21 09:03:55 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchSupportsFeature (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-08-21 09:03:55 +00:00
|
|
|
remote_supports_feature_args *args, remote_supports_feature_ret *ret)
|
|
|
|
{
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->supported = virDrvSupportsFeature (conn, args->feature);
|
2008-12-04 22:12:53 +00:00
|
|
|
|
|
|
|
if (ret->supported == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-08-21 09:03:55 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchGetType (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED, remote_get_type_ret *ret)
|
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
type = virConnectGetType (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (type == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* We have to strdup because remoteDispatchClientRequest will
|
|
|
|
* free this string after it's been serialised.
|
|
|
|
*/
|
|
|
|
ret->type = strdup (type);
|
|
|
|
if (!ret->type) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("out of memory in strdup"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchGetVersion (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_get_version_ret *ret)
|
|
|
|
{
|
|
|
|
unsigned long hvVer;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
if (virConnectGetVersion (conn, &hvVer) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2008-12-04 22:12:53 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
ret->hv_ver = hvVer;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-26 11:42:46 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchGetHostname (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-26 11:42:46 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_get_hostname_ret *ret)
|
|
|
|
{
|
|
|
|
char *hostname;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
hostname = virConnectGetHostname (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (hostname == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-26 11:42:46 +00:00
|
|
|
|
|
|
|
ret->hostname = hostname;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchGetUri (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-17 11:44:51 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_get_uri_ret *ret)
|
|
|
|
{
|
|
|
|
char *uri;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
uri = virConnectGetURI (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (uri == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-17 11:44:51 +00:00
|
|
|
|
|
|
|
ret->uri = uri;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_get_max_vcpus_args *args,
|
|
|
|
remote_get_max_vcpus_ret *ret)
|
|
|
|
{
|
|
|
|
char *type;
|
|
|
|
|
|
|
|
type = args->type ? *args->type : NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->max_vcpus = virConnectGetMaxVcpus (conn, type);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->max_vcpus == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNodeGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_node_get_info_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeInfo info;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
if (virNodeGetInfo (conn, &info) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2008-12-04 22:12:53 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
memcpy (ret->model, info.model, sizeof ret->model);
|
|
|
|
ret->memory = info.memory;
|
|
|
|
ret->cpus = info.cpus;
|
|
|
|
ret->mhz = info.mhz;
|
|
|
|
ret->nodes = info.nodes;
|
|
|
|
ret->sockets = info.sockets;
|
|
|
|
ret->cores = info.cores;
|
|
|
|
ret->threads = info.threads;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchGetCapabilities (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_get_capabilities_ret *ret)
|
|
|
|
{
|
|
|
|
char *caps;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
caps = virConnectGetCapabilities (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (caps == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
ret->capabilities = caps;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-22 15:20:25 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-05-22 15:20:25 +00:00
|
|
|
remote_node_get_cells_free_memory_args *args,
|
|
|
|
remote_node_get_cells_free_memory_ret *ret)
|
|
|
|
{
|
2009-04-03 12:45:05 +00:00
|
|
|
int err;
|
2008-05-22 15:20:25 +00:00
|
|
|
|
|
|
|
if (args->maxCells > REMOTE_NODE_MAX_CELLS) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxCells > REMOTE_NODE_MAX_CELLS"));
|
|
|
|
return -1;
|
2008-05-22 15:20:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->freeMems.freeMems_val, args->maxCells) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2008-05-22 15:20:25 +00:00
|
|
|
|
2009-04-03 12:45:05 +00:00
|
|
|
err = virNodeGetCellsFreeMemory(conn,
|
|
|
|
(unsigned long long *)ret->freeMems.freeMems_val,
|
|
|
|
args->startCell,
|
|
|
|
args->maxCells);
|
|
|
|
if (err <= 0) {
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(ret->freeMems.freeMems_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-05-22 15:20:25 +00:00
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2009-04-03 12:45:05 +00:00
|
|
|
ret->freeMems.freeMems_len = err;
|
2008-05-22 15:20:25 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeGetFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-05-22 15:20:25 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_node_get_free_memory_ret *ret)
|
|
|
|
{
|
|
|
|
unsigned long long freeMem;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
freeMem = virNodeGetFreeMemory(conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (freeMem == 0) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-05-22 15:20:25 +00:00
|
|
|
ret->freeMem = freeMem;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-22 13:16:10 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetSchedulerType (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-22 13:16:10 +00:00
|
|
|
remote_domain_get_scheduler_type_args *args,
|
|
|
|
remote_domain_get_scheduler_type_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
char *type;
|
|
|
|
int nparams;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-22 13:16:10 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type = virDomainGetSchedulerType (dom, &nparams);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (type == NULL) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-22 13:16:10 +00:00
|
|
|
|
|
|
|
ret->type = type;
|
|
|
|
ret->nparams = nparams;
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-22 13:16:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetSchedulerParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-22 13:16:10 +00:00
|
|
|
remote_domain_get_scheduler_parameters_args *args,
|
|
|
|
remote_domain_get_scheduler_parameters_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
virSchedParameterPtr params;
|
|
|
|
int i, r, nparams;
|
|
|
|
|
|
|
|
nparams = args->nparams;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("nparams too large"));
|
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(params, nparams) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-22 13:16:10 +00:00
|
|
|
if (dom == NULL) {
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(params);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r = virDomainGetSchedulerParameters (dom, params, &nparams);
|
|
|
|
if (r == -1) {
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(params);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-22 13:16:10 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Serialise the scheduler parameters. */
|
|
|
|
ret->params.params_len = nparams;
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
|
|
|
|
goto oom;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < nparams; ++i) {
|
|
|
|
// remoteDispatchClientRequest will free this:
|
|
|
|
ret->params.params_val[i].field = strdup (params[i].field);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->params.params_val[i].field == NULL)
|
|
|
|
goto oom;
|
|
|
|
|
2007-06-22 13:16:10 +00:00
|
|
|
ret->params.params_val[i].value.type = params[i].type;
|
|
|
|
switch (params[i].type) {
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_INT:
|
|
|
|
ret->params.params_val[i].value.remote_sched_param_value_u.i = params[i].value.i; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
|
|
|
ret->params.params_val[i].value.remote_sched_param_value_u.ui = params[i].value.ui; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
|
|
|
ret->params.params_val[i].value.remote_sched_param_value_u.l = params[i].value.l; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
|
|
|
ret->params.params_val[i].value.remote_sched_param_value_u.ul = params[i].value.ul; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
|
|
|
ret->params.params_val[i].value.remote_sched_param_value_u.d = params[i].value.d; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
|
|
|
ret->params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
|
|
|
|
default:
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("unknown type"));
|
2008-06-06 10:52:01 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(params);
|
2007-06-22 13:16:10 +00:00
|
|
|
|
|
|
|
return 0;
|
2008-06-06 10:52:01 +00:00
|
|
|
|
|
|
|
oom:
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
2008-06-06 10:52:01 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainFree(dom);
|
|
|
|
for (i = 0 ; i < nparams ; i++)
|
|
|
|
VIR_FREE(ret->params.params_val[i].field);
|
|
|
|
VIR_FREE(params);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSetSchedulerParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-22 13:16:10 +00:00
|
|
|
remote_domain_set_scheduler_parameters_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
int i, r, nparams;
|
|
|
|
virSchedParameterPtr params;
|
|
|
|
|
|
|
|
nparams = args->params.params_len;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("nparams too large"));
|
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(params, nparams)) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Deserialise parameters. */
|
|
|
|
for (i = 0; i < nparams; ++i) {
|
|
|
|
strncpy (params[i].field, args->params.params_val[i].field,
|
|
|
|
VIR_DOMAIN_SCHED_FIELD_LENGTH);
|
|
|
|
params[i].field[VIR_DOMAIN_SCHED_FIELD_LENGTH-1] = '\0';
|
|
|
|
params[i].type = args->params.params_val[i].value.type;
|
|
|
|
switch (params[i].type) {
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_INT:
|
|
|
|
params[i].value.i = args->params.params_val[i].value.remote_sched_param_value_u.i; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
|
|
|
params[i].value.ui = args->params.params_val[i].value.remote_sched_param_value_u.ui; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
|
|
|
params[i].value.l = args->params.params_val[i].value.remote_sched_param_value_u.l; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
|
|
|
params[i].value.ul = args->params.params_val[i].value.remote_sched_param_value_u.ul; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
|
|
|
params[i].value.d = args->params.params_val[i].value.remote_sched_param_value_u.d; break;
|
|
|
|
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
|
|
|
params[i].value.b = args->params.params_val[i].value.remote_sched_param_value_u.b; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-22 13:16:10 +00:00
|
|
|
if (dom == NULL) {
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(params);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r = virDomainSetSchedulerParameters (dom, params, nparams);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(params);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (r == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-22 13:16:10 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-21 10:08:12 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainBlockStats (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-08-21 10:08:12 +00:00
|
|
|
remote_domain_block_stats_args *args,
|
|
|
|
remote_domain_block_stats_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
char *path;
|
|
|
|
struct _virDomainBlockStats stats;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-08-21 10:08:12 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-08-21 10:08:12 +00:00
|
|
|
}
|
|
|
|
path = args->path;
|
|
|
|
|
2008-05-22 15:12:25 +00:00
|
|
|
if (virDomainBlockStats (dom, path, &stats, sizeof stats) == -1) {
|
|
|
|
virDomainFree (dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-08-21 10:08:12 +00:00
|
|
|
return -1;
|
2008-05-22 15:12:25 +00:00
|
|
|
}
|
|
|
|
virDomainFree (dom);
|
2007-08-21 10:08:12 +00:00
|
|
|
|
|
|
|
ret->rd_req = stats.rd_req;
|
|
|
|
ret->rd_bytes = stats.rd_bytes;
|
|
|
|
ret->wr_req = stats.wr_req;
|
|
|
|
ret->wr_bytes = stats.wr_bytes;
|
|
|
|
ret->errs = stats.errs;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainInterfaceStats (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-08-21 10:08:12 +00:00
|
|
|
remote_domain_interface_stats_args *args,
|
|
|
|
remote_domain_interface_stats_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
char *path;
|
|
|
|
struct _virDomainInterfaceStats stats;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-08-21 10:08:12 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-08-21 10:08:12 +00:00
|
|
|
}
|
|
|
|
path = args->path;
|
|
|
|
|
2008-05-22 15:12:25 +00:00
|
|
|
if (virDomainInterfaceStats (dom, path, &stats, sizeof stats) == -1) {
|
|
|
|
virDomainFree (dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-08-21 10:08:12 +00:00
|
|
|
return -1;
|
2008-05-22 15:12:25 +00:00
|
|
|
}
|
|
|
|
virDomainFree (dom);
|
2007-08-21 10:08:12 +00:00
|
|
|
|
|
|
|
ret->rx_bytes = stats.rx_bytes;
|
|
|
|
ret->rx_packets = stats.rx_packets;
|
|
|
|
ret->rx_errs = stats.rx_errs;
|
|
|
|
ret->rx_drop = stats.rx_drop;
|
|
|
|
ret->tx_bytes = stats.tx_bytes;
|
|
|
|
ret->tx_packets = stats.tx_packets;
|
|
|
|
ret->tx_errs = stats.tx_errs;
|
|
|
|
ret->tx_drop = stats.tx_drop;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-05 21:12:26 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-06-05 21:12:26 +00:00
|
|
|
remote_domain_block_peek_args *args,
|
|
|
|
remote_domain_block_peek_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
char *path;
|
|
|
|
unsigned long long offset;
|
|
|
|
size_t size;
|
|
|
|
unsigned int flags;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2008-06-05 21:12:26 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
path = args->path;
|
|
|
|
offset = args->offset;
|
|
|
|
size = args->size;
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
|
2008-06-06 10:52:01 +00:00
|
|
|
virDomainFree (dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("size > maximum buffer size"));
|
|
|
|
return -1;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->buffer.buffer_len = size;
|
2009-02-05 16:28:30 +00:00
|
|
|
if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
|
|
|
|
char ebuf[1024];
|
2008-06-06 10:52:01 +00:00
|
|
|
virDomainFree (dom);
|
2009-02-05 16:28:30 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s",
|
|
|
|
virStrerror(errno, ebuf, sizeof ebuf));
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainBlockPeek (dom, path, offset, size,
|
|
|
|
ret->buffer.buffer_val, flags) == -1) {
|
|
|
|
/* free (ret->buffer.buffer_val); - caller frees */
|
|
|
|
virDomainFree (dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-05 21:12:26 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virDomainFree (dom);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 10:43:28 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-06-10 10:43:28 +00:00
|
|
|
remote_domain_memory_peek_args *args,
|
|
|
|
remote_domain_memory_peek_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
unsigned long long offset;
|
|
|
|
size_t size;
|
|
|
|
unsigned int flags;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2008-06-10 10:43:28 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
offset = args->offset;
|
|
|
|
size = args->size;
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
|
2009-02-05 16:28:30 +00:00
|
|
|
virDomainFree (dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("size > maximum buffer size"));
|
|
|
|
return -1;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->buffer.buffer_len = size;
|
|
|
|
if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
2008-06-10 10:43:28 +00:00
|
|
|
virDomainFree (dom);
|
2009-02-05 16:28:30 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s",
|
|
|
|
virStrerror(errno, ebuf, sizeof ebuf));
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainMemoryPeek (dom, offset, size,
|
|
|
|
ret->buffer.buffer_val, flags) == -1) {
|
|
|
|
/* free (ret->buffer.buffer_val); - caller frees */
|
|
|
|
virDomainFree (dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-10 10:43:28 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virDomainFree (dom);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainAttachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_attach_device_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainAttachDevice (dom, args->xml) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_create_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainCreate (dom) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-10-10 09:32:27 +00:00
|
|
|
remoteDispatchDomainCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_domain_create_xml_args *args,
|
|
|
|
remote_domain_create_xml_ret *ret)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = virDomainCreateXML (conn, args->xml_desc, args->flags);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->dom, dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_define_xml_args *args,
|
|
|
|
remote_domain_define_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = virDomainDefineXML (conn, args->xml);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->dom, dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_destroy_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2008-05-21 20:53:30 +00:00
|
|
|
if (virDomainDestroy (dom) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2008-05-21 20:53:30 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainDetachDevice (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_detach_device_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainDetachDevice (dom, args->xml) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_dump_xml_args *args,
|
|
|
|
remote_domain_dump_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->xml = virDomainGetXMLDesc (dom, args->flags);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (!ret->xml) {
|
2008-12-04 22:12:53 +00:00
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-21 13:50:56 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainXmlFromNative (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_domain_xml_from_native_args *args,
|
|
|
|
remote_domain_xml_from_native_ret *ret)
|
|
|
|
{
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->domainXml = virConnectDomainXMLFromNative (conn,
|
|
|
|
args->nativeFormat,
|
|
|
|
args->nativeConfig,
|
|
|
|
args->flags);
|
|
|
|
if (!ret->domainXml) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainXmlToNative (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_domain_xml_to_native_args *args,
|
|
|
|
remote_domain_xml_to_native_ret *ret)
|
|
|
|
{
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->nativeConfig = virConnectDomainXMLToNative (conn,
|
|
|
|
args->nativeFormat,
|
|
|
|
args->domainXml,
|
|
|
|
args->flags);
|
|
|
|
if (!ret->nativeConfig) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_get_autostart_args *args,
|
|
|
|
remote_domain_get_autostart_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainGetAutostart (dom, &ret->autostart) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_get_info_args *args,
|
|
|
|
remote_domain_get_info_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainInfo info;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainGetInfo (dom, &info) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
ret->state = info.state;
|
|
|
|
ret->max_mem = info.maxMem;
|
|
|
|
ret->memory = info.memory;
|
|
|
|
ret->nr_virt_cpu = info.nrVirtCpu;
|
|
|
|
ret->cpu_time = info.cpuTime;
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_get_max_memory_args *args,
|
|
|
|
remote_domain_get_max_memory_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->memory = virDomainGetMaxMemory (dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (ret->memory == 0) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetMaxVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_get_max_vcpus_args *args,
|
|
|
|
remote_domain_get_max_vcpus_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->num = virDomainGetMaxVcpus (dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (ret->num == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-03 09:27:02 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_domain_get_security_label_args *args,
|
|
|
|
remote_domain_get_security_label_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
virSecurityLabel seclabel;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, args->dom);
|
|
|
|
if (dom == NULL) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&seclabel, 0, sizeof seclabel);
|
|
|
|
if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
|
|
|
|
virDomainFree(dom);
|
|
|
|
remoteDispatchFormatError(rerr, "%s", _("unable to get security label"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->label.label_len = strlen(seclabel.label) + 1;
|
|
|
|
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
|
|
|
|
virDomainFree(dom);
|
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
strcpy(ret->label.label_val, seclabel.label);
|
|
|
|
ret->enforcing = seclabel.enforcing;
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_node_get_security_model_ret *ret)
|
|
|
|
{
|
|
|
|
virSecurityModel secmodel;
|
|
|
|
|
|
|
|
memset(&secmodel, 0, sizeof secmodel);
|
|
|
|
if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
|
|
|
|
remoteDispatchFormatError(rerr, "%s", _("unable to get security model"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->model.model_len = strlen(secmodel.model) + 1;
|
|
|
|
if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
|
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
strcpy(ret->model.model_val, secmodel.model);
|
|
|
|
|
|
|
|
ret->doi.doi_len = strlen(secmodel.doi) + 1;
|
|
|
|
if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
|
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
strcpy(ret->doi.doi_val, secmodel.doi);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetOsType (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_get_os_type_args *args,
|
|
|
|
remote_domain_get_os_type_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this */
|
|
|
|
ret->type = virDomainGetOSType (dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (ret->type == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_get_vcpus_args *args,
|
|
|
|
remote_domain_get_vcpus_ret *ret)
|
|
|
|
{
|
2008-06-06 10:52:01 +00:00
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virVcpuInfoPtr info = NULL;
|
|
|
|
unsigned char *cpumaps = NULL;
|
2007-06-11 11:47:01 +00:00
|
|
|
int info_len, i;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-06-25 08:23:10 +00:00
|
|
|
if (args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate buffers to take the results. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(info, args->maxinfo) < 0)
|
|
|
|
goto oom;
|
2009-03-16 10:33:01 +00:00
|
|
|
if (args->maplen > 0 &&
|
|
|
|
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
|
2008-06-06 10:52:01 +00:00
|
|
|
goto oom;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
info_len = virDomainGetVcpus (dom,
|
|
|
|
info, args->maxinfo,
|
|
|
|
cpumaps, args->maplen);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (info_len == -1) {
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(info);
|
|
|
|
VIR_FREE(cpumaps);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
/* Allocate the return buffer for info. */
|
|
|
|
ret->info.info_len = info_len;
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
|
|
|
|
goto oom;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < info_len; ++i) {
|
|
|
|
ret->info.info_val[i].number = info[i].number;
|
|
|
|
ret->info.info_val[i].state = info[i].state;
|
|
|
|
ret->info.info_val[i].cpu_time = info[i].cpuTime;
|
|
|
|
ret->info.info_val[i].cpu = info[i].cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't need to allocate/copy the cpumaps if we make the reasonable
|
|
|
|
* assumption that unsigned char and char are the same size.
|
|
|
|
* Note that remoteDispatchClientRequest will free.
|
|
|
|
*/
|
2007-06-25 08:23:10 +00:00
|
|
|
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
|
2007-06-11 11:47:01 +00:00
|
|
|
ret->cpumaps.cpumaps_val = (char *) cpumaps;
|
|
|
|
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(info);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
2008-06-06 10:52:01 +00:00
|
|
|
|
|
|
|
oom:
|
|
|
|
VIR_FREE(info);
|
|
|
|
VIR_FREE(cpumaps);
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-08-21 09:31:12 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainMigratePrepare (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-08-21 09:31:12 +00:00
|
|
|
remote_domain_migrate_prepare_args *args,
|
|
|
|
remote_domain_migrate_prepare_ret *ret)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
char *cookie = NULL;
|
|
|
|
int cookielen = 0;
|
|
|
|
char *uri_in;
|
|
|
|
char **uri_out;
|
|
|
|
char *dname;
|
|
|
|
|
|
|
|
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
|
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
|
|
|
|
|
|
|
/* Wacky world of XDR ... */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC(uri_out) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2007-08-21 09:31:12 +00:00
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
r = virDomainMigratePrepare (conn, &cookie, &cookielen,
|
2008-11-17 11:03:25 +00:00
|
|
|
uri_in, uri_out,
|
|
|
|
args->flags, dname, args->resource);
|
2008-05-22 15:12:25 +00:00
|
|
|
if (r == -1) {
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(uri_out);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-05-22 15:12:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-08-21 09:31:12 +00:00
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free cookie, uri_out and
|
|
|
|
* the string if there is one.
|
|
|
|
*/
|
|
|
|
ret->cookie.cookie_len = cookielen;
|
|
|
|
ret->cookie.cookie_val = cookie;
|
2008-05-22 15:12:25 +00:00
|
|
|
if (*uri_out == NULL) {
|
|
|
|
ret->uri_out = NULL;
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(uri_out);
|
2008-05-22 15:12:25 +00:00
|
|
|
} else {
|
|
|
|
ret->uri_out = uri_out;
|
|
|
|
}
|
2007-08-21 09:31:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainMigratePerform (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-08-21 09:31:12 +00:00
|
|
|
remote_domain_migrate_perform_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
virDomainPtr dom;
|
|
|
|
char *dname;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-08-21 09:31:12 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-08-21 09:31:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
|
|
|
|
2008-11-17 11:03:25 +00:00
|
|
|
r = virDomainMigratePerform (dom,
|
|
|
|
args->cookie.cookie_val,
|
|
|
|
args->cookie.cookie_len,
|
|
|
|
args->uri,
|
|
|
|
args->flags, dname, args->resource);
|
2008-05-22 15:12:25 +00:00
|
|
|
virDomainFree (dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (r == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-08-21 09:31:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainMigrateFinish (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-08-21 09:31:12 +00:00
|
|
|
remote_domain_migrate_finish_args *args,
|
|
|
|
remote_domain_migrate_finish_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr ddom;
|
|
|
|
CHECK_CONN (client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ddom = virDomainMigrateFinish (conn, args->dname,
|
2008-11-17 11:03:25 +00:00
|
|
|
args->cookie.cookie_val,
|
|
|
|
args->cookie.cookie_len,
|
|
|
|
args->uri,
|
|
|
|
args->flags);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ddom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-08-21 09:31:12 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->ddom, ddom);
|
2008-05-22 15:12:25 +00:00
|
|
|
virDomainFree (ddom);
|
2007-08-21 09:31:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-14 08:42:47 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainMigratePrepare2 (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-14 08:42:47 +00:00
|
|
|
remote_domain_migrate_prepare2_args *args,
|
|
|
|
remote_domain_migrate_prepare2_ret *ret)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
char *cookie = NULL;
|
|
|
|
int cookielen = 0;
|
|
|
|
char *uri_in;
|
|
|
|
char **uri_out;
|
|
|
|
char *dname;
|
|
|
|
CHECK_CONN (client);
|
|
|
|
|
|
|
|
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
|
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
|
|
|
|
|
|
|
/* Wacky world of XDR ... */
|
|
|
|
if (VIR_ALLOC(uri_out) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-11-14 08:42:47 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
r = virDomainMigratePrepare2 (conn, &cookie, &cookielen,
|
2008-11-17 11:03:25 +00:00
|
|
|
uri_in, uri_out,
|
|
|
|
args->flags, dname, args->resource,
|
|
|
|
args->dom_xml);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (r == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-14 08:42:47 +00:00
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free cookie, uri_out and
|
|
|
|
* the string if there is one.
|
|
|
|
*/
|
|
|
|
ret->cookie.cookie_len = cookielen;
|
|
|
|
ret->cookie.cookie_val = cookie;
|
|
|
|
ret->uri_out = *uri_out == NULL ? NULL : uri_out;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainMigrateFinish2 (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-14 08:42:47 +00:00
|
|
|
remote_domain_migrate_finish2_args *args,
|
|
|
|
remote_domain_migrate_finish2_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr ddom;
|
|
|
|
CHECK_CONN (client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ddom = virDomainMigrateFinish2 (conn, args->dname,
|
2008-11-17 11:03:25 +00:00
|
|
|
args->cookie.cookie_val,
|
|
|
|
args->cookie.cookie_len,
|
|
|
|
args->uri,
|
|
|
|
args->flags,
|
|
|
|
args->retcode);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ddom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-14 08:42:47 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->ddom, ddom);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchListDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_list_defined_domains_args *args,
|
|
|
|
remote_list_defined_domains_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
ret->names.names_len =
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectListDefinedDomains (conn,
|
2007-06-11 11:47:01 +00:00
|
|
|
ret->names.names_val, args->maxnames);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainLookupById (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_lookup_by_id_args *args,
|
|
|
|
remote_domain_lookup_by_id_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = virDomainLookupByID (conn, args->id);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->dom, dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_lookup_by_name_args *args,
|
|
|
|
remote_domain_lookup_by_name_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = virDomainLookupByName (conn, args->name);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->dom, dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_lookup_by_uuid_args *args,
|
|
|
|
remote_domain_lookup_by_uuid_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = virDomainLookupByUUID (conn, (unsigned char *) args->uuid);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&ret->dom, dom);
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNumOfDefinedDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_defined_domains_ret *ret)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virConnectNumOfDefinedDomains (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainPinVcpu (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_pin_vcpu_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
int rv;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
|
2007-07-24 14:21:03 +00:00
|
|
|
virDomainFree(dom);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s", _("cpumap_len > REMOTE_CPUMAP_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rv = virDomainPinVcpu (dom, args->vcpu,
|
|
|
|
(unsigned char *) args->cpumap.cpumap_val,
|
|
|
|
args->cpumap.cpumap_len);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (rv == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainReboot (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_reboot_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainReboot (dom, args->flags) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainRestore (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_restore_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
if (virDomainRestore (conn, args->from) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2008-12-04 22:12:53 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainResume (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_resume_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainResume (dom) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSave (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_save_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainSave (dom, args->to) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_core_dump_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainCoreDump (dom, args->to, args->flags) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_set_autostart_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainSetAutostart (dom, args->autostart) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSetMaxMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_set_max_memory_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainSetMaxMemory (dom, args->memory) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSetMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_set_memory_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainSetMemory (dom, args->memory) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_set_vcpus_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainSetVcpus (dom, args->nvcpus) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainShutdown (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_shutdown_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainShutdown (dom) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainSuspend (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_suspend_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainSuspend (dom) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchDomainUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_domain_undefine_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dom = get_nonnull_domain (conn, args->dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (dom == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virDomainUndefine (dom) == -1) {
|
|
|
|
virDomainFree(dom);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virDomainFree(dom);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchListDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_list_defined_networks_args *args,
|
|
|
|
remote_list_defined_networks_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
ret->names.names_len =
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectListDefinedNetworks (conn,
|
2007-06-11 11:47:01 +00:00
|
|
|
ret->names.names_val, args->maxnames);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchListDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_list_domains_args *args,
|
|
|
|
remote_list_domains_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->ids.ids_val, args->maxids) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->ids.ids_len = virConnectListDomains (conn,
|
2007-06-11 11:47:01 +00:00
|
|
|
ret->ids.ids_val, args->maxids);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->ids.ids_len == -1) {
|
|
|
|
VIR_FREE(ret->ids.ids_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchListNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_list_networks_args *args,
|
|
|
|
remote_list_networks_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
ret->names.names_len =
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectListNetworks (conn,
|
2007-06-11 11:47:01 +00:00
|
|
|
ret->names.names_val, args->maxnames);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_len);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_create_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virNetworkCreate (net) == -1) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_create_xml_args *args,
|
|
|
|
remote_network_create_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = virNetworkCreateXML (conn, args->xml);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_network (&ret->net, net);
|
2007-07-24 14:21:03 +00:00
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_define_xml_args *args,
|
|
|
|
remote_network_define_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = virNetworkDefineXML (conn, args->xml);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_network (&ret->net, net);
|
2007-07-24 14:21:03 +00:00
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_destroy_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virNetworkDestroy (net) == -1) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_dump_xml_args *args,
|
|
|
|
remote_network_dump_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->xml = virNetworkGetXMLDesc (net, args->flags);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (!ret->xml) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_get_autostart_args *args,
|
|
|
|
remote_network_get_autostart_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virNetworkGetAutostart (net, &ret->autostart) == -1) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkGetBridgeName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_get_bridge_name_args *args,
|
|
|
|
remote_network_get_bridge_name_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->name = virNetworkGetBridgeName (net);
|
2007-07-24 14:21:03 +00:00
|
|
|
if (!ret->name) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-07-24 14:21:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_lookup_by_name_args *args,
|
|
|
|
remote_network_lookup_by_name_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = virNetworkLookupByName (conn, args->name);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_network (&ret->net, net);
|
2007-07-24 14:21:03 +00:00
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_lookup_by_uuid_args *args,
|
|
|
|
remote_network_lookup_by_uuid_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = virNetworkLookupByUUID (conn, (unsigned char *) args->uuid);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
make_nonnull_network (&ret->net, net);
|
2007-07-24 14:21:03 +00:00
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_set_autostart_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virNetworkSetAutostart (net, args->autostart) == -1) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNetworkUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
remote_network_undefine_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNetworkPtr net;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
net = get_nonnull_network (conn, args->net);
|
2007-06-11 11:47:01 +00:00
|
|
|
if (net == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 14:21:03 +00:00
|
|
|
if (virNetworkUndefine (net) == -1) {
|
|
|
|
virNetworkFree(net);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2007-06-11 11:47:01 +00:00
|
|
|
return -1;
|
2007-07-24 14:21:03 +00:00
|
|
|
}
|
|
|
|
virNetworkFree(net);
|
2007-06-11 11:47:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNumOfDefinedNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_defined_networks_ret *ret)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virConnectNumOfDefinedNetworks (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNumOfDomains (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_domains_ret *ret)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virConnectNumOfDomains (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchNumOfNetworks (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-06-11 11:47:01 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_networks_ret *ret)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virConnectNumOfNetworks (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
/*-------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
remoteDispatchNumOfInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_interfaces_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
ret->num = virConnectNumOfInterfaces (conn);
|
|
|
|
if (ret->num == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchListInterfaces (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_list_interfaces_args *args,
|
|
|
|
remote_list_interfaces_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_INTERFACE_NAME_LIST_MAX) {
|
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_INTERFACE_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->names.names_len =
|
|
|
|
virConnectListInterfaces (conn,
|
|
|
|
ret->names.names_val, args->maxnames);
|
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_len);
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_lookup_by_name_args *args,
|
|
|
|
remote_interface_lookup_by_name_ret *ret)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = virInterfaceLookupByName (conn, args->name);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
make_nonnull_interface (&ret->iface, iface);
|
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceLookupByMacString (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_lookup_by_mac_string_args *args,
|
|
|
|
remote_interface_lookup_by_mac_string_ret *ret)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = virInterfaceLookupByMACString (conn, args->mac);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
make_nonnull_interface (&ret->iface, iface);
|
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceGetXmlDesc (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_get_xml_desc_args *args,
|
|
|
|
remote_interface_get_xml_desc_ret *ret)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = get_nonnull_interface (conn, args->iface);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
2009-05-29 14:29:22 +00:00
|
|
|
ret->xml = virInterfaceGetXMLDesc (iface, args->flags);
|
2009-05-20 14:26:49 +00:00
|
|
|
if (!ret->xml) {
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_define_xml_args *args,
|
|
|
|
remote_interface_define_xml_ret *ret)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = virInterfaceDefineXML (conn, args->xml, args->flags);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
make_nonnull_interface (&ret->iface, iface);
|
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_undefine_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = get_nonnull_interface (conn, args->iface);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
if (virInterfaceUndefine (iface) == -1) {
|
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_create_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = get_nonnull_interface (conn, args->iface);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
if (virInterfaceCreate (iface, args->flags) == -1) {
|
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchInterfaceDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_interface_destroy_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfacePtr iface;
|
2009-05-20 14:26:49 +00:00
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
iface = get_nonnull_interface (conn, args->iface);
|
|
|
|
if (iface == NULL) {
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:29:22 +00:00
|
|
|
if (virInterfaceDestroy (iface, args->flags) == -1) {
|
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
2009-05-29 14:29:22 +00:00
|
|
|
virInterfaceFree(iface);
|
2009-05-20 14:26:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------*/
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
static int
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchAuthList (struct qemud_server *server,
|
2007-12-05 15:34:05 +00:00
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_list_ret *ret)
|
|
|
|
{
|
|
|
|
ret->types.types_len = 1;
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
ret->types.types_val[0] = client->auth;
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_SASL
|
|
|
|
/*
|
|
|
|
* NB, keep in sync with similar method in src/remote_internal.c
|
|
|
|
*/
|
2008-12-04 22:12:53 +00:00
|
|
|
static char *addrToString(remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
struct sockaddr_storage *sa, socklen_t salen) {
|
|
|
|
char host[1024], port[20];
|
|
|
|
char *addr;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if ((err = getnameinfo((struct sockaddr *)sa, salen,
|
|
|
|
host, sizeof(host),
|
|
|
|
port, sizeof(port),
|
|
|
|
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr,
|
|
|
|
_("Cannot resolve address %d: %s"),
|
|
|
|
err, gai_strerror(err));
|
2007-12-05 15:24:15 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-19 13:15:50 +00:00
|
|
|
if (virAsprintf(&addr, "%s;%s", host, port) == -1) {
|
|
|
|
virReportOOMError(NULL);
|
2007-12-05 15:24:15 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initializes the SASL session in prepare for authentication
|
2008-05-15 06:12:32 +00:00
|
|
|
* and gives the client a list of allowed mechanisms to choose
|
2007-12-05 15:24:15 +00:00
|
|
|
*
|
|
|
|
* XXX callbacks for stuff like password verification ?
|
|
|
|
*/
|
|
|
|
static int
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchAuthSaslInit (struct qemud_server *server,
|
2007-12-05 15:34:05 +00:00
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_sasl_init_ret *ret)
|
|
|
|
{
|
|
|
|
const char *mechlist = NULL;
|
2007-12-05 15:27:08 +00:00
|
|
|
sasl_security_properties_t secprops;
|
2007-12-05 15:24:15 +00:00
|
|
|
int err;
|
|
|
|
struct sockaddr_storage sa;
|
|
|
|
socklen_t salen;
|
|
|
|
char *localAddr, *remoteAddr;
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
REMOTE_DEBUG("Initialize SASL auth %d", client->fd);
|
|
|
|
if (client->auth != REMOTE_AUTH_SASL ||
|
|
|
|
client->saslconn != NULL) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried invalid SASL init request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get local address in form IPADDR:PORT */
|
|
|
|
salen = sizeof(sa);
|
|
|
|
if (getsockname(client->fd, (struct sockaddr*)&sa, &salen) < 0) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr,
|
2009-02-05 16:28:15 +00:00
|
|
|
_("failed to get sock address: %s"),
|
2009-02-05 16:28:30 +00:00
|
|
|
virStrerror(errno, ebuf, sizeof ebuf));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
2008-12-04 22:12:53 +00:00
|
|
|
if ((localAddr = addrToString(rerr, &sa, salen)) == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get remote address in form IPADDR:PORT */
|
|
|
|
salen = sizeof(sa);
|
|
|
|
if (getpeername(client->fd, (struct sockaddr*)&sa, &salen) < 0) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
2009-02-05 16:28:15 +00:00
|
|
|
remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
|
2009-02-05 16:28:30 +00:00
|
|
|
virStrerror(errno, ebuf, sizeof ebuf));
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(localAddr);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
2008-12-04 22:12:53 +00:00
|
|
|
if ((remoteAddr = addrToString(rerr, &sa, salen)) == NULL) {
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(localAddr);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = sasl_server_new("libvirt",
|
|
|
|
NULL, /* FQDN - just delegates to gethostname */
|
|
|
|
NULL, /* User realm */
|
|
|
|
localAddr,
|
|
|
|
remoteAddr,
|
|
|
|
NULL, /* XXX Callbacks */
|
|
|
|
SASL_SUCCESS_DATA,
|
|
|
|
&client->saslconn);
|
2008-06-06 10:52:01 +00:00
|
|
|
VIR_FREE(localAddr);
|
|
|
|
VIR_FREE(remoteAddr);
|
2007-12-05 15:24:15 +00:00
|
|
|
if (err != SASL_OK) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("sasl context setup failed %d (%s)"),
|
|
|
|
err, sasl_errstring(err, NULL, NULL));
|
2007-12-05 15:24:15 +00:00
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 15:27:08 +00:00
|
|
|
/* Inform SASL that we've got an external SSF layer from TLS */
|
|
|
|
if (client->type == QEMUD_SOCK_TYPE_TLS) {
|
|
|
|
gnutls_cipher_algorithm_t cipher;
|
|
|
|
sasl_ssf_t ssf;
|
|
|
|
|
|
|
|
cipher = gnutls_cipher_get(client->tlssession);
|
|
|
|
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
|
2009-06-11 15:34:37 +00:00
|
|
|
VIR_ERROR0(_("cannot get TLS cipher size"));
|
2007-12-05 15:27:08 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
|
|
|
ssf *= 8; /* tls key size is bytes, sasl wants bits */
|
|
|
|
|
|
|
|
err = sasl_setprop(client->saslconn, SASL_SSF_EXTERNAL, &ssf);
|
|
|
|
if (err != SASL_OK) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("cannot set SASL external SSF %d (%s)"),
|
|
|
|
err, sasl_errstring(err, NULL, NULL));
|
2007-12-05 15:27:08 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (&secprops, 0, sizeof secprops);
|
|
|
|
if (client->type == QEMUD_SOCK_TYPE_TLS ||
|
|
|
|
client->type == QEMUD_SOCK_TYPE_UNIX) {
|
|
|
|
/* If we've got TLS or UNIX domain sock, we don't care about SSF */
|
|
|
|
secprops.min_ssf = 0;
|
|
|
|
secprops.max_ssf = 0;
|
|
|
|
secprops.maxbufsize = 8192;
|
|
|
|
secprops.security_flags = 0;
|
|
|
|
} else {
|
|
|
|
/* Plain TCP, better get an SSF layer */
|
|
|
|
secprops.min_ssf = 56; /* Good enough to require kerberos */
|
|
|
|
secprops.max_ssf = 100000; /* Arbitrary big number */
|
|
|
|
secprops.maxbufsize = 8192;
|
|
|
|
/* Forbid any anonymous or trivially crackable auth */
|
|
|
|
secprops.security_flags =
|
|
|
|
SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = sasl_setprop(client->saslconn, SASL_SEC_PROPS, &secprops);
|
|
|
|
if (err != SASL_OK) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("cannot set SASL security props %d (%s)"),
|
|
|
|
err, sasl_errstring(err, NULL, NULL));
|
2007-12-05 15:27:08 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
err = sasl_listmech(client->saslconn,
|
|
|
|
NULL, /* Don't need to set user */
|
|
|
|
"", /* Prefix */
|
|
|
|
",", /* Separator */
|
|
|
|
"", /* Suffix */
|
|
|
|
&mechlist,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (err != SASL_OK) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("cannot list SASL mechanisms %d (%s)"),
|
|
|
|
err, sasl_errdetail(client->saslconn));
|
2007-12-05 15:24:15 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist);
|
|
|
|
ret->mechlist = strdup(mechlist);
|
|
|
|
if (!ret->mechlist) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("cannot allocate mechlist"));
|
2007-12-05 15:24:15 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
|
|
|
remoteDispatchAuthError(rerr);
|
|
|
|
error:
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-29 12:53:10 +00:00
|
|
|
/* We asked for an SSF layer, so sanity check that we actually
|
2007-12-05 15:27:08 +00:00
|
|
|
* got what we asked for */
|
|
|
|
static int
|
|
|
|
remoteSASLCheckSSF (struct qemud_client *client,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr) {
|
2007-12-05 15:27:08 +00:00
|
|
|
const void *val;
|
|
|
|
int err, ssf;
|
|
|
|
|
|
|
|
if (client->type == QEMUD_SOCK_TYPE_TLS ||
|
|
|
|
client->type == QEMUD_SOCK_TYPE_UNIX)
|
|
|
|
return 0; /* TLS or UNIX domain sockets trivially OK */
|
|
|
|
|
|
|
|
err = sasl_getprop(client->saslconn, SASL_SSF, &val);
|
|
|
|
if (err != SASL_OK) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("cannot query SASL ssf on connection %d (%s)"),
|
|
|
|
err, sasl_errstring(err, NULL, NULL));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:27:08 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ssf = *(const int *)val;
|
|
|
|
REMOTE_DEBUG("negotiated an SSF of %d", ssf);
|
|
|
|
if (ssf < 56) { /* 56 is good for Kerberos */
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("negotiated SSF %d was not strong enough"), ssf);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:27:08 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only setup for read initially, because we're about to send an RPC
|
|
|
|
* reply which must be in plain text. When the next incoming RPC
|
|
|
|
* arrives, we'll switch on writes too
|
|
|
|
*
|
|
|
|
* cf qemudClientReadSASL in qemud.c
|
|
|
|
*/
|
|
|
|
client->saslSSF = QEMUD_SASL_SSF_READ;
|
|
|
|
|
|
|
|
/* We have a SSF !*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-05 15:34:05 +00:00
|
|
|
static int
|
|
|
|
remoteSASLCheckAccess (struct qemud_server *server,
|
|
|
|
struct qemud_client *client,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr) {
|
2007-12-05 15:34:05 +00:00
|
|
|
const void *val;
|
|
|
|
int err;
|
|
|
|
char **wildcards;
|
|
|
|
|
|
|
|
err = sasl_getprop(client->saslconn, SASL_USERNAME, &val);
|
|
|
|
if (err != SASL_OK) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("cannot query SASL username on connection %d (%s)"),
|
|
|
|
err, sasl_errstring(err, NULL, NULL));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:34:05 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (val == NULL) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("no client username was found"));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:34:05 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
REMOTE_DEBUG("SASL client username %s", (const char *)val);
|
|
|
|
|
|
|
|
client->saslUsername = strdup((const char*)val);
|
|
|
|
if (client->saslUsername == NULL) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("out of memory copying username"));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:34:05 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the list is not set, allow any DN. */
|
|
|
|
wildcards = server->saslUsernameWhitelist;
|
|
|
|
if (!wildcards)
|
|
|
|
return 0; /* No ACL, allow all */
|
|
|
|
|
|
|
|
while (*wildcards) {
|
|
|
|
if (fnmatch (*wildcards, client->saslUsername, 0) == 0)
|
|
|
|
return 0; /* Allowed */
|
|
|
|
wildcards++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Denied */
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("SASL client %s not allowed in whitelist"), client->saslUsername);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:34:05 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
/*
|
|
|
|
* This starts the SASL authentication negotiation.
|
|
|
|
*/
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchAuthSaslStart (struct qemud_server *server,
|
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
remote_auth_sasl_start_args *args,
|
|
|
|
remote_auth_sasl_start_ret *ret)
|
|
|
|
{
|
|
|
|
const char *serverout;
|
|
|
|
unsigned int serveroutlen;
|
|
|
|
int err;
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
REMOTE_DEBUG("Start SASL auth %d", client->fd);
|
|
|
|
if (client->auth != REMOTE_AUTH_SASL ||
|
|
|
|
client->saslconn == NULL) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried invalid SASL start request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
REMOTE_DEBUG("Using SASL mechanism %s. Data %d bytes, nil: %d",
|
|
|
|
args->mech, args->data.data_len, args->nil);
|
|
|
|
err = sasl_server_start(client->saslconn,
|
|
|
|
args->mech,
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
args->nil ? NULL : args->data.data_val,
|
|
|
|
args->data.data_len,
|
|
|
|
&serverout,
|
|
|
|
&serveroutlen);
|
|
|
|
if (err != SASL_OK &&
|
|
|
|
err != SASL_CONTINUE) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("sasl start failed %d (%s)"),
|
|
|
|
err, sasl_errdetail(client->saslconn));
|
2007-12-05 15:24:15 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("sasl start reply data too long %d"), serveroutlen);
|
2007-12-05 15:24:15 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
if (serverout) {
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
memcpy(ret->data.data_val, serverout, serveroutlen);
|
|
|
|
} else {
|
|
|
|
ret->data.data_val = NULL;
|
|
|
|
}
|
|
|
|
ret->nil = serverout ? 0 : 1;
|
|
|
|
ret->data.data_len = serveroutlen;
|
|
|
|
|
|
|
|
REMOTE_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
|
|
|
|
if (err == SASL_CONTINUE) {
|
|
|
|
ret->complete = 0;
|
|
|
|
} else {
|
2008-12-04 22:12:53 +00:00
|
|
|
if (remoteSASLCheckSSF(client, rerr) < 0)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2007-12-05 15:34:05 +00:00
|
|
|
/* Check username whitelist ACL */
|
2008-12-04 22:12:53 +00:00
|
|
|
if (remoteSASLCheckAccess(server, client, rerr) < 0)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
REMOTE_DEBUG("Authentication successful %d", client->fd);
|
|
|
|
ret->complete = 1;
|
|
|
|
client->auth = REMOTE_AUTH_NONE;
|
|
|
|
}
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
|
|
|
remoteDispatchAuthError(rerr);
|
|
|
|
error:
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchAuthSaslStep (struct qemud_server *server,
|
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
remote_auth_sasl_step_args *args,
|
|
|
|
remote_auth_sasl_step_ret *ret)
|
|
|
|
{
|
|
|
|
const char *serverout;
|
|
|
|
unsigned int serveroutlen;
|
|
|
|
int err;
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
REMOTE_DEBUG("Step SASL auth %d", client->fd);
|
|
|
|
if (client->auth != REMOTE_AUTH_SASL ||
|
|
|
|
client->saslconn == NULL) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried invalid SASL start request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
REMOTE_DEBUG("Using SASL Data %d bytes, nil: %d",
|
|
|
|
args->data.data_len, args->nil);
|
|
|
|
err = sasl_server_step(client->saslconn,
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
args->nil ? NULL : args->data.data_val,
|
|
|
|
args->data.data_len,
|
|
|
|
&serverout,
|
|
|
|
&serveroutlen);
|
|
|
|
if (err != SASL_OK &&
|
|
|
|
err != SASL_CONTINUE) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("sasl step failed %d (%s)"),
|
|
|
|
err, sasl_errdetail(client->saslconn));
|
2007-12-05 15:24:15 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("sasl step reply data too long %d"),
|
|
|
|
serveroutlen);
|
2007-12-05 15:24:15 +00:00
|
|
|
sasl_dispose(&client->saslconn);
|
|
|
|
client->saslconn = NULL;
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
if (serverout) {
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
memcpy(ret->data.data_val, serverout, serveroutlen);
|
|
|
|
} else {
|
|
|
|
ret->data.data_val = NULL;
|
|
|
|
}
|
|
|
|
ret->nil = serverout ? 0 : 1;
|
|
|
|
ret->data.data_len = serveroutlen;
|
|
|
|
|
|
|
|
REMOTE_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
|
|
|
|
if (err == SASL_CONTINUE) {
|
|
|
|
ret->complete = 0;
|
|
|
|
} else {
|
2008-12-04 22:12:53 +00:00
|
|
|
if (remoteSASLCheckSSF(client, rerr) < 0)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2007-12-05 15:34:05 +00:00
|
|
|
/* Check username whitelist ACL */
|
2008-12-04 22:12:53 +00:00
|
|
|
if (remoteSASLCheckAccess(server, client, rerr) < 0)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto error;
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
REMOTE_DEBUG("Authentication successful %d", client->fd);
|
|
|
|
ret->complete = 1;
|
|
|
|
client->auth = REMOTE_AUTH_NONE;
|
|
|
|
}
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
|
|
|
remoteDispatchAuthError(rerr);
|
|
|
|
error:
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else /* HAVE_SASL */
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried unsupported SASL init request"));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchAuthSaslStart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried unsupported SASL start request"));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-12-05 15:34:05 +00:00
|
|
|
remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 15:24:15 +00:00
|
|
|
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried unsupported SASL step request"));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_SASL */
|
|
|
|
|
|
|
|
|
2007-12-05 18:21:27 +00:00
|
|
|
#if HAVE_POLKIT
|
|
|
|
static int
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchAuthPolkit (struct qemud_server *server,
|
2007-12-05 18:21:27 +00:00
|
|
|
struct qemud_client *client,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2007-12-05 18:21:27 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_polkit_ret *ret)
|
|
|
|
{
|
|
|
|
pid_t callerPid;
|
|
|
|
uid_t callerUid;
|
2008-04-04 15:09:19 +00:00
|
|
|
PolKitCaller *pkcaller = NULL;
|
|
|
|
PolKitAction *pkaction = NULL;
|
|
|
|
PolKitContext *pkcontext = NULL;
|
|
|
|
PolKitError *pkerr = NULL;
|
|
|
|
PolKitResult pkresult;
|
|
|
|
DBusError err;
|
2008-12-04 22:16:40 +00:00
|
|
|
const char *action;
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&server->lock);
|
|
|
|
virMutexLock(&client->lock);
|
|
|
|
virMutexUnlock(&server->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
action = client->readonly ?
|
2008-04-04 15:09:19 +00:00
|
|
|
"org.libvirt.unix.monitor" :
|
|
|
|
"org.libvirt.unix.manage";
|
2007-12-05 18:21:27 +00:00
|
|
|
|
|
|
|
REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
|
|
|
|
if (client->auth != REMOTE_AUTH_POLKIT) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried invalid PolicyKit init request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qemudGetSocketIdentity(client->fd, &callerUid, &callerPid) < 0) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("cannot get peer socket identity"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_INFO(_("Checking PID %d running as %d"), callerPid, callerUid);
|
2008-04-04 15:09:19 +00:00
|
|
|
dbus_error_init(&err);
|
|
|
|
if (!(pkcaller = polkit_caller_new_from_pid(server->sysbus,
|
|
|
|
callerPid, &err))) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("Failed to lookup policy kit caller: %s"), err.message);
|
2008-04-04 15:09:19 +00:00
|
|
|
dbus_error_free(&err);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
2007-12-05 18:21:27 +00:00
|
|
|
|
2008-04-04 15:09:19 +00:00
|
|
|
if (!(pkaction = polkit_action_new())) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
|
|
|
VIR_ERROR(_("Failed to create polkit action %s\n"),
|
|
|
|
virStrerror(errno, ebuf, sizeof ebuf));
|
2008-04-04 15:09:19 +00:00
|
|
|
polkit_caller_unref(pkcaller);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
|
|
|
polkit_action_set_action_id(pkaction, action);
|
|
|
|
|
|
|
|
if (!(pkcontext = polkit_context_new()) ||
|
|
|
|
!polkit_context_init(pkcontext, &pkerr)) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("Failed to create polkit context %s\n"),
|
|
|
|
(pkerr ? polkit_error_get_error_message(pkerr)
|
2009-02-05 16:28:30 +00:00
|
|
|
: virStrerror(errno, ebuf, sizeof ebuf)));
|
2008-04-04 15:09:19 +00:00
|
|
|
if (pkerr)
|
|
|
|
polkit_error_free(pkerr);
|
|
|
|
polkit_caller_unref(pkcaller);
|
|
|
|
polkit_action_unref(pkaction);
|
|
|
|
dbus_error_free(&err);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
2007-12-05 18:21:27 +00:00
|
|
|
|
2008-02-20 16:54:35 +00:00
|
|
|
#if HAVE_POLKIT_CONTEXT_IS_CALLER_AUTHORIZED
|
2008-04-04 15:09:19 +00:00
|
|
|
pkresult = polkit_context_is_caller_authorized(pkcontext,
|
|
|
|
pkaction,
|
|
|
|
pkcaller,
|
|
|
|
0,
|
|
|
|
&pkerr);
|
|
|
|
if (pkerr && polkit_error_is_set(pkerr)) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("Policy kit failed to check authorization %d %s"),
|
|
|
|
polkit_error_get_error_code(pkerr),
|
|
|
|
polkit_error_get_error_message(pkerr));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
2008-02-20 16:54:35 +00:00
|
|
|
#else
|
2008-04-04 15:09:19 +00:00
|
|
|
pkresult = polkit_context_can_caller_do_action(pkcontext,
|
|
|
|
pkaction,
|
|
|
|
pkcaller);
|
2008-02-20 16:54:35 +00:00
|
|
|
#endif
|
2008-04-04 15:09:19 +00:00
|
|
|
polkit_context_unref(pkcontext);
|
|
|
|
polkit_caller_unref(pkcaller);
|
|
|
|
polkit_action_unref(pkaction);
|
|
|
|
if (pkresult != POLKIT_RESULT_YES) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("Policy kit denied action %s from pid %d, uid %d, result: %s\n"),
|
|
|
|
action, callerPid, callerUid,
|
|
|
|
polkit_result_to_string_representation(pkresult));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_INFO(_("Policy allowed action %s from pid %d, uid %d, result %s"),
|
2008-04-04 15:09:19 +00:00
|
|
|
action, callerPid, callerUid,
|
|
|
|
polkit_result_to_string_representation(pkresult));
|
|
|
|
ret->complete = 1;
|
|
|
|
client->auth = REMOTE_AUTH_NONE;
|
2007-12-05 18:21:27 +00:00
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2007-12-05 18:21:27 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
|
|
|
remoteDispatchAuthError(rerr);
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&client->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return -1;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else /* HAVE_POLKIT */
|
|
|
|
|
|
|
|
static int
|
2007-12-05 20:45:37 +00:00
|
|
|
remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
2008-12-18 12:00:45 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
|
2007-12-05 18:21:27 +00:00
|
|
|
{
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR0(_("client tried unsupported PolicyKit init request"));
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchAuthError(rerr);
|
2007-12-05 18:21:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_POLKIT */
|
|
|
|
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* STORAGE POOL APIS
|
|
|
|
***************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchListDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_list_defined_storage_pools_args *args,
|
|
|
|
remote_list_defined_storage_pools_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
|
2008-12-22 12:55:47 +00:00
|
|
|
remoteDispatchFormatError (rerr, "%s",
|
|
|
|
_("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
ret->names.names_len =
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectListDefinedStoragePools (conn,
|
2008-06-06 10:52:01 +00:00
|
|
|
ret->names.names_val, args->maxnames);
|
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchListStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_list_storage_pools_args *args,
|
|
|
|
remote_list_storage_pools_ret *ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
ret->names.names_len =
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectListStoragePools (conn,
|
2008-02-20 15:22:35 +00:00
|
|
|
ret->names.names_val, args->maxnames);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchFindStoragePoolSources (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-08-27 20:05:58 +00:00
|
|
|
remote_find_storage_pool_sources_args *args,
|
|
|
|
remote_find_storage_pool_sources_ret *ret)
|
|
|
|
{
|
|
|
|
ret->xml =
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectFindStoragePoolSources (conn,
|
2008-08-27 20:05:58 +00:00
|
|
|
args->type,
|
|
|
|
args->srcSpec ? *args->srcSpec : NULL,
|
|
|
|
args->flags);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->xml == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-08-27 20:05:58 +00:00
|
|
|
return -1;
|
2008-12-04 22:12:53 +00:00
|
|
|
}
|
2008-08-27 20:05:58 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 15:22:35 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_create_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolCreate (pool, args->flags) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_create_xml_args *args,
|
|
|
|
remote_storage_pool_create_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = virStoragePoolCreateXML (conn, args->xml, args->flags);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_pool (&ret->pool, pool);
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolDefineXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_define_xml_args *args,
|
|
|
|
remote_storage_pool_define_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = virStoragePoolDefineXML (conn, args->xml, args->flags);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_pool (&ret->pool, pool);
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolBuild (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
|
|
|
remote_storage_pool_build_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
2008-02-20 15:22:35 +00:00
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolBuild (pool, args->flags) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolDestroy (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_destroy_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolDestroy (pool) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_delete_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolDelete (pool, args->flags) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolRefresh (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_refresh_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolRefresh (pool, args->flags) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_get_info_args *args,
|
|
|
|
remote_storage_pool_get_info_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
virStoragePoolInfo info;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolGetInfo (pool, &info) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->state = info.state;
|
|
|
|
ret->capacity = info.capacity;
|
|
|
|
ret->allocation = info.allocation;
|
|
|
|
ret->available = info.available;
|
|
|
|
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_dump_xml_args *args,
|
|
|
|
remote_storage_pool_dump_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->xml = virStoragePoolGetXMLDesc (pool, args->flags);
|
|
|
|
if (!ret->xml) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolGetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_get_autostart_args *args,
|
|
|
|
remote_storage_pool_get_autostart_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolGetAutostart (pool, &ret->autostart) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_lookup_by_name_args *args,
|
|
|
|
remote_storage_pool_lookup_by_name_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = virStoragePoolLookupByName (conn, args->name);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_pool (&ret->pool, pool);
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolLookupByUuid (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_lookup_by_uuid_args *args,
|
|
|
|
remote_storage_pool_lookup_by_uuid_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = virStoragePoolLookupByUUID (conn, (unsigned char *) args->uuid);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_pool (&ret->pool, pool);
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolLookupByVolume (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_lookup_by_volume_args *args,
|
|
|
|
remote_storage_pool_lookup_by_volume_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = get_nonnull_storage_vol (conn, args->vol);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
pool = virStoragePoolLookupByVolume (vol);
|
|
|
|
virStorageVolFree(vol);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_pool (&ret->pool, pool);
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_set_autostart_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolSetAutostart (pool, args->autostart) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolUndefine (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_undefine_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolUndefine (pool) == -1) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStoragePoolFree(pool);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNumOfStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_storage_pools_ret *ret)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virConnectNumOfStoragePools (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNumOfDefinedStoragePools (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_num_of_defined_storage_pools_ret *ret)
|
|
|
|
{
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virConnectNumOfDefinedStoragePools (conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolListVolumes (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_list_volumes_args *args,
|
|
|
|
remote_storage_pool_list_volumes_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError (rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-06-06 10:52:01 +00:00
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
ret->names.names_len =
|
|
|
|
virStoragePoolListVolumes (pool,
|
|
|
|
ret->names.names_val, args->maxnames);
|
|
|
|
virStoragePoolFree(pool);
|
2008-06-06 10:52:01 +00:00
|
|
|
if (ret->names.names_len == -1) {
|
|
|
|
VIR_FREE(ret->names.names_val);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-06-06 10:52:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolNumOfVolumes (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_pool_num_of_volumes_args *args,
|
|
|
|
remote_storage_pool_num_of_volumes_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->num = virStoragePoolNumOfVolumes (pool);
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* STORAGE VOL APIS
|
|
|
|
***************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_create_xml_args *args,
|
|
|
|
remote_storage_vol_create_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolCreateXML (pool, args->xml, args->flags);
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_vol (&ret->vol, vol);
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-12 20:13:52 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolCreateXmlFrom (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_storage_vol_create_xml_from_args *args,
|
|
|
|
remote_storage_vol_create_xml_from_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
virStorageVolPtr clonevol, newvol;
|
|
|
|
|
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
|
|
|
if (pool == NULL) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
clonevol = get_nonnull_storage_vol (conn, args->clonevol);
|
|
|
|
if (clonevol == NULL) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
newvol = virStorageVolCreateXMLFrom (pool, args->xml, clonevol,
|
|
|
|
args->flags);
|
|
|
|
if (newvol == NULL) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_storage_vol (&ret->vol, newvol);
|
|
|
|
virStorageVolFree(newvol);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_delete_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = get_nonnull_storage_vol (conn, args->vol);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStorageVolDelete (vol, args->flags) == -1) {
|
|
|
|
virStorageVolFree(vol);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolGetInfo (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_get_info_args *args,
|
|
|
|
remote_storage_vol_get_info_ret *ret)
|
|
|
|
{
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
virStorageVolInfo info;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = get_nonnull_storage_vol (conn, args->vol);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStorageVolGetInfo (vol, &info) == -1) {
|
|
|
|
virStorageVolFree(vol);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->type = info.type;
|
|
|
|
ret->capacity = info.capacity;
|
|
|
|
ret->allocation = info.allocation;
|
|
|
|
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_dump_xml_args *args,
|
|
|
|
remote_storage_vol_dump_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = get_nonnull_storage_vol (conn, args->vol);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->xml = virStorageVolGetXMLDesc (vol, args->flags);
|
|
|
|
if (!ret->xml) {
|
|
|
|
virStorageVolFree(vol);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolGetPath (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_get_path_args *args,
|
|
|
|
remote_storage_vol_get_path_ret *ret)
|
|
|
|
{
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = get_nonnull_storage_vol (conn, args->vol);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->name = virStorageVolGetPath (vol);
|
|
|
|
if (!ret->name) {
|
|
|
|
virStorageVolFree(vol);
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-02-20 15:22:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_lookup_by_name_args *args,
|
|
|
|
remote_storage_vol_lookup_by_name_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr pool;
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
pool = get_nonnull_storage_pool (conn, args->pool);
|
2008-02-20 15:22:35 +00:00
|
|
|
if (pool == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolLookupByName (pool, args->name);
|
|
|
|
virStoragePoolFree(pool);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_vol (&ret->vol, vol);
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolLookupByKey (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_lookup_by_key_args *args,
|
|
|
|
remote_storage_vol_lookup_by_key_ret *ret)
|
|
|
|
{
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = virStorageVolLookupByKey (conn, args->key);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_vol (&ret->vol, vol);
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchStorageVolLookupByPath (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-02-20 15:22:35 +00:00
|
|
|
remote_storage_vol_lookup_by_path_args *args,
|
|
|
|
remote_storage_vol_lookup_by_path_ret *ret)
|
|
|
|
{
|
|
|
|
virStorageVolPtr vol;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
vol = virStorageVolLookupByPath (conn, args->path);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (vol == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
make_nonnull_storage_vol (&ret->vol, vol);
|
|
|
|
virStorageVolFree(vol);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-21 12:31:04 +00:00
|
|
|
/***************************************************************
|
|
|
|
* NODE INFO APIS
|
|
|
|
**************************************************************/
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeNumOfDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_num_of_devices_args *args,
|
|
|
|
remote_node_num_of_devices_ret *ret)
|
|
|
|
{
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
ret->num = virNodeNumOfDevices (conn,
|
2008-11-21 12:31:04 +00:00
|
|
|
args->cap ? *args->cap : NULL,
|
|
|
|
args->flags);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-21 12:31:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeListDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_list_devices_args *args,
|
|
|
|
remote_node_list_devices_ret *ret)
|
|
|
|
{
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->names.names_len =
|
2008-12-04 22:16:40 +00:00
|
|
|
virNodeListDevices (conn,
|
2008-11-21 12:31:04 +00:00
|
|
|
args->cap ? *args->cap : NULL,
|
|
|
|
ret->names.names_val, args->maxnames, args->flags);
|
|
|
|
if (ret->names.names_len == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-11-21 12:31:04 +00:00
|
|
|
VIR_FREE(ret->names.names_val);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceLookupByName (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_device_lookup_by_name_args *args,
|
|
|
|
remote_node_device_lookup_by_name_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dev = virNodeDeviceLookupByName (conn, args->name);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (dev == NULL) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-21 12:31:04 +00:00
|
|
|
|
|
|
|
make_nonnull_node_device (&ret->dev, dev);
|
|
|
|
virNodeDeviceFree(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_device_dump_xml_args *args,
|
|
|
|
remote_node_device_dump_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
2008-11-21 12:31:04 +00:00
|
|
|
if (dev == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
ret->xml = virNodeDeviceGetXMLDesc (dev, args->flags);
|
|
|
|
if (!ret->xml) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-11-21 12:31:04 +00:00
|
|
|
virNodeDeviceFree(dev);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
virNodeDeviceFree(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceGetParent (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_device_get_parent_args *args,
|
|
|
|
remote_node_device_get_parent_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
const char *parent;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
2008-11-21 12:31:04 +00:00
|
|
|
if (dev == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
parent = virNodeDeviceGetParent(dev);
|
|
|
|
|
|
|
|
if (parent == NULL) {
|
|
|
|
ret->parent = NULL;
|
|
|
|
} else {
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
char **parent_p;
|
|
|
|
if (VIR_ALLOC(parent_p) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
*parent_p = strdup(parent);
|
|
|
|
if (*parent_p == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
ret->parent = parent_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
virNodeDeviceFree(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_device_num_of_caps_args *args,
|
|
|
|
remote_node_device_num_of_caps_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
2008-11-21 12:31:04 +00:00
|
|
|
if (dev == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->num = virNodeDeviceNumOfCaps(dev);
|
2008-12-04 22:12:53 +00:00
|
|
|
if (ret->num < 0) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-12-04 22:12:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-21 12:31:04 +00:00
|
|
|
|
|
|
|
virNodeDeviceFree(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr,
|
2008-11-21 12:31:04 +00:00
|
|
|
remote_node_device_list_caps_args *args,
|
|
|
|
remote_node_device_list_caps_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
2008-11-21 12:31:04 +00:00
|
|
|
if (dev == NULL) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr,
|
|
|
|
"%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate return buffer. */
|
|
|
|
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchOOMError(rerr);
|
|
|
|
return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->names.names_len =
|
|
|
|
virNodeDeviceListCaps (dev, ret->names.names_val,
|
|
|
|
args->maxnames);
|
|
|
|
if (ret->names.names_len == -1) {
|
2008-12-04 22:16:40 +00:00
|
|
|
remoteDispatchConnError(rerr, conn);
|
2008-11-21 12:31:04 +00:00
|
|
|
VIR_FREE(ret->names.names_val);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-02 16:30:59 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_node_device_dettach_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
|
|
|
if (dev == NULL) {
|
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virNodeDeviceDettach(dev) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_node_device_re_attach_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
|
|
|
if (dev == NULL) {
|
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virNodeDeviceReAttach(dev) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_node_device_reset_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
|
|
|
if (dev == NULL) {
|
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virNodeDeviceReset(dev) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-24 13:11:23 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_node_device_create_xml_args *args,
|
|
|
|
remote_node_device_create_xml_ret *ret)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
|
|
|
|
dev = virNodeDeviceCreateXML (conn, args->xml_desc, args->flags);
|
|
|
|
if (dev == NULL) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_node_device (&ret->dev, dev);
|
|
|
|
virNodeDeviceFree(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
|
|
|
remote_error *rerr,
|
|
|
|
remote_node_device_destroy_args *args,
|
|
|
|
void *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virNodeDevicePtr dev;
|
|
|
|
|
|
|
|
dev = virNodeDeviceLookupByName(conn, args->name);
|
|
|
|
if (dev == NULL) {
|
|
|
|
remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virNodeDeviceDestroy(dev) == -1) {
|
|
|
|
remoteDispatchConnError(rerr, conn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
/**************************
|
|
|
|
* Async Events
|
|
|
|
**************************/
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainEvent (struct qemud_server *server ATTRIBUTE_UNUSED,
|
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr ATTRIBUTE_UNUSED,
|
2008-10-23 13:18:18 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_domain_event_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* This call gets dispatched from a client call.
|
|
|
|
* This does not make sense, as this should not be intiated
|
|
|
|
* from the client side in generated code.
|
|
|
|
*/
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchFormatError(rerr, "%s", _("unexpected async event method call"));
|
|
|
|
return -1;
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************
|
|
|
|
* Register / deregister events
|
|
|
|
***************************/
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainEventsRegister (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr ATTRIBUTE_UNUSED,
|
2008-10-23 13:18:18 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
|
|
|
/* Register event delivery callback */
|
|
|
|
REMOTE_DEBUG("%s","Registering to relay remote events");
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectDomainEventRegister(conn, remoteRelayDomainEvent, client, NULL);
|
2008-10-23 13:18:18 +00:00
|
|
|
|
|
|
|
if(ret)
|
|
|
|
ret->cb_registered = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainEventsDeregister (struct qemud_server *server ATTRIBUTE_UNUSED,
|
2008-12-04 22:16:40 +00:00
|
|
|
struct qemud_client *client ATTRIBUTE_UNUSED,
|
|
|
|
virConnectPtr conn,
|
2008-12-04 22:12:53 +00:00
|
|
|
remote_error *rerr ATTRIBUTE_UNUSED,
|
2008-10-23 13:18:18 +00:00
|
|
|
void *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
CHECK_CONN(client);
|
|
|
|
|
|
|
|
/* Deregister event delivery callback */
|
|
|
|
REMOTE_DEBUG("%s","Deregistering to relay remote events");
|
2008-12-04 22:16:40 +00:00
|
|
|
virConnectDomainEventDeregister(conn, remoteRelayDomainEvent);
|
2008-10-23 13:18:18 +00:00
|
|
|
|
|
|
|
if(ret)
|
|
|
|
ret->cb_registered = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDispatchDomainEventSend (struct qemud_client *client,
|
2009-01-20 19:25:15 +00:00
|
|
|
struct qemud_client_message *msg,
|
2008-11-17 16:43:00 +00:00
|
|
|
virDomainPtr dom,
|
|
|
|
int event,
|
|
|
|
int detail)
|
2008-10-23 13:18:18 +00:00
|
|
|
{
|
|
|
|
remote_message_header rep;
|
|
|
|
XDR xdr;
|
2009-01-20 19:25:15 +00:00
|
|
|
unsigned int len;
|
2008-10-23 13:18:18 +00:00
|
|
|
remote_domain_event_ret data;
|
|
|
|
|
2008-12-04 22:12:53 +00:00
|
|
|
if (!client)
|
2008-10-23 13:18:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
rep.prog = REMOTE_PROGRAM;
|
|
|
|
rep.vers = REMOTE_PROTOCOL_VERSION;
|
|
|
|
rep.proc = REMOTE_PROC_DOMAIN_EVENT;
|
|
|
|
rep.direction = REMOTE_MESSAGE;
|
|
|
|
rep.serial = 1;
|
|
|
|
rep.status = REMOTE_OK;
|
|
|
|
|
|
|
|
/* Serialise the return header and event. */
|
2009-01-20 19:25:15 +00:00
|
|
|
xdrmem_create (&xdr, msg->buffer, sizeof msg->buffer, XDR_ENCODE);
|
2008-10-23 13:18:18 +00:00
|
|
|
|
|
|
|
len = 0; /* We'll come back and write this later. */
|
2009-01-20 19:25:15 +00:00
|
|
|
if (!xdr_u_int (&xdr, &len)) {
|
|
|
|
/*remoteDispatchError (client, NULL, "%s", _("xdr_u_int failed (1)"));*/
|
2008-10-23 13:18:18 +00:00
|
|
|
xdr_destroy (&xdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!xdr_remote_message_header (&xdr, &rep)) {
|
|
|
|
xdr_destroy (&xdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* build return data */
|
|
|
|
make_nonnull_domain (&data.dom, dom);
|
2008-11-17 16:43:00 +00:00
|
|
|
data.event = event;
|
|
|
|
data.detail = detail;
|
2008-10-23 13:18:18 +00:00
|
|
|
|
|
|
|
if (!xdr_remote_domain_event_ret(&xdr, &data)) {
|
2008-12-04 22:12:53 +00:00
|
|
|
/*remoteDispatchError (client, NULL, "%s", _("serialise return struct"));*/
|
2008-10-23 13:18:18 +00:00
|
|
|
xdr_destroy (&xdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = xdr_getpos (&xdr);
|
|
|
|
if (xdr_setpos (&xdr, 0) == 0) {
|
2008-12-04 22:12:53 +00:00
|
|
|
/*remoteDispatchError (client, NULL, "%s", _("xdr_setpos failed"));*/
|
2008-10-23 13:18:18 +00:00
|
|
|
xdr_destroy (&xdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
if (!xdr_u_int (&xdr, &len)) {
|
|
|
|
/*remoteDispatchError (client, NULL, "%s", _("xdr_u_int failed (2)"));*/
|
2008-10-23 13:18:18 +00:00
|
|
|
xdr_destroy (&xdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xdr_destroy (&xdr);
|
|
|
|
|
|
|
|
/* Send it. */
|
2009-01-20 19:25:15 +00:00
|
|
|
msg->async = 1;
|
|
|
|
msg->bufferLength = len;
|
|
|
|
msg->bufferOffset = 0;
|
|
|
|
qemudClientMessageQueuePush(&client->tx, msg);
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
2008-11-21 12:31:04 +00:00
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/*----- Helpers. -----*/
|
|
|
|
|
|
|
|
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
|
|
|
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
|
|
|
|
* virDomainPtr or virNetworkPtr cannot be NULL.
|
|
|
|
*
|
|
|
|
* NB. If these return NULL then the caller must return an error.
|
|
|
|
*/
|
|
|
|
static virDomainPtr
|
|
|
|
get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
dom = virGetDomain (conn, domain.name, BAD_CAST domain.uuid);
|
|
|
|
/* Should we believe the domain.id sent by the client? Maybe
|
|
|
|
* this should be a check rather than an assignment? XXX
|
|
|
|
*/
|
|
|
|
if (dom) dom->id = domain.id;
|
|
|
|
return dom;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virNetworkPtr
|
|
|
|
get_nonnull_network (virConnectPtr conn, remote_nonnull_network network)
|
|
|
|
{
|
|
|
|
return virGetNetwork (conn, network.name, BAD_CAST network.uuid);
|
|
|
|
}
|
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
static virInterfacePtr
|
2009-05-29 14:29:22 +00:00
|
|
|
get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface)
|
2009-05-20 14:26:49 +00:00
|
|
|
{
|
2009-05-29 14:29:22 +00:00
|
|
|
return virGetInterface (conn, iface.name, iface.mac);
|
2009-05-20 14:26:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:22:35 +00:00
|
|
|
static virStoragePoolPtr
|
|
|
|
get_nonnull_storage_pool (virConnectPtr conn, remote_nonnull_storage_pool pool)
|
|
|
|
{
|
|
|
|
return virGetStoragePool (conn, pool.name, BAD_CAST pool.uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
get_nonnull_storage_vol (virConnectPtr conn, remote_nonnull_storage_vol vol)
|
|
|
|
{
|
|
|
|
virStorageVolPtr ret;
|
|
|
|
ret = virGetStorageVol (conn, vol.pool, vol.name, vol.key);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/* Make remote_nonnull_domain and remote_nonnull_network. */
|
|
|
|
static void
|
|
|
|
make_nonnull_domain (remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
|
|
|
|
{
|
|
|
|
dom_dst->id = dom_src->id;
|
|
|
|
dom_dst->name = strdup (dom_src->name);
|
|
|
|
memcpy (dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
make_nonnull_network (remote_nonnull_network *net_dst, virNetworkPtr net_src)
|
|
|
|
{
|
|
|
|
net_dst->name = strdup (net_src->name);
|
|
|
|
memcpy (net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
|
|
|
|
}
|
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
static void
|
|
|
|
make_nonnull_interface (remote_nonnull_interface *interface_dst,
|
|
|
|
virInterfacePtr interface_src)
|
|
|
|
{
|
|
|
|
interface_dst->name = strdup (interface_src->name);
|
|
|
|
interface_dst->mac = strdup (interface_src->mac);
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:22:35 +00:00
|
|
|
static void
|
|
|
|
make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
|
|
|
|
{
|
|
|
|
pool_dst->name = strdup (pool_src->name);
|
|
|
|
memcpy (pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
|
|
|
|
{
|
|
|
|
vol_dst->pool = strdup (vol_src->pool);
|
|
|
|
vol_dst->name = strdup (vol_src->name);
|
|
|
|
vol_dst->key = strdup (vol_src->key);
|
|
|
|
}
|
2008-11-21 12:31:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
make_nonnull_node_device (remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
|
|
|
|
{
|
|
|
|
dev_dst->name = strdup(dev_src->name);
|
|
|
|
}
|