2007-06-11 11:43:41 +00:00
|
|
|
/*
|
2011-07-20 03:01:45 +00:00
|
|
|
* remote_driver.c: driver to provide access to libvirtd running
|
2007-06-11 11:43:41 +00:00
|
|
|
* on a remote machine
|
|
|
|
*
|
2012-01-28 06:21:31 +00:00
|
|
|
* Copyright (C) 2007-2012 Red Hat, Inc.
|
2007-06-11 11:43:41 +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
|
2012-07-21 10:06:23 +00:00
|
|
|
* License along with this library; If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2007-06-11 11:43:41 +00:00
|
|
|
*
|
|
|
|
* Author: Richard Jones <rjones@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2008-01-29 18:15:54 +00:00
|
|
|
#include <config.h>
|
2007-08-07 14:29:45 +00:00
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <assert.h>
|
2007-12-07 14:56:37 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
#include "virnetclient.h"
|
|
|
|
#include "virnetclientprogram.h"
|
|
|
|
#include "virnetclientstream.h"
|
2008-11-04 22:30:33 +00:00
|
|
|
#include "virterror_internal.h"
|
2008-11-06 16:36:07 +00:00
|
|
|
#include "logging.h"
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "datatypes.h"
|
2008-11-04 23:33:57 +00:00
|
|
|
#include "domain_event.h"
|
2007-06-11 11:43:41 +00:00
|
|
|
#include "driver.h"
|
2007-12-17 10:07:56 +00:00
|
|
|
#include "buf.h"
|
2009-09-15 17:47:05 +00:00
|
|
|
#include "remote_driver.h"
|
2007-06-11 11:43:41 +00:00
|
|
|
#include "remote_protocol.h"
|
2010-04-17 02:09:25 +00:00
|
|
|
#include "qemu_protocol.h"
|
2008-06-06 11:09:57 +00:00
|
|
|
#include "memory.h"
|
2008-08-29 07:11:15 +00:00
|
|
|
#include "util.h"
|
2011-07-19 18:32:58 +00:00
|
|
|
#include "virfile.h"
|
2011-05-06 15:23:57 +00:00
|
|
|
#include "command.h"
|
2011-06-24 18:16:05 +00:00
|
|
|
#include "intprops.h"
|
2012-01-31 03:20:40 +00:00
|
|
|
#include "virtypedparam.h"
|
2012-02-24 18:48:55 +00:00
|
|
|
#include "viruri.h"
|
2012-03-20 11:11:10 +00:00
|
|
|
#include "virauth.h"
|
|
|
|
#include "virauthconfig.h"
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_REMOTE
|
|
|
|
|
2011-05-30 10:58:57 +00:00
|
|
|
#if SIZEOF_LONG < 8
|
|
|
|
# define HYPER_TO_TYPE(_type, _to, _from) \
|
|
|
|
do { \
|
|
|
|
if ((_from) != (_type)(_from)) { \
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
_("conversion from hyper to %s overflowed"), #_type); \
|
2011-05-30 10:58:57 +00:00
|
|
|
goto done; \
|
|
|
|
} \
|
|
|
|
(_to) = (_from); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
# define HYPER_TO_LONG(_to, _from) HYPER_TO_TYPE(long, _to, _from)
|
|
|
|
# define HYPER_TO_ULONG(_to, _from) HYPER_TO_TYPE(unsigned long, _to, _from)
|
|
|
|
#else
|
|
|
|
# define HYPER_TO_LONG(_to, _from) (_to) = (_from)
|
|
|
|
# define HYPER_TO_ULONG(_to, _from) (_to) = (_from)
|
|
|
|
#endif
|
|
|
|
|
2007-10-27 01:23:28 +00:00
|
|
|
static int inside_daemon = 0;
|
2011-09-22 12:59:06 +00:00
|
|
|
static virDriverPtr remoteDriver = NULL;
|
2007-10-27 01:23:28 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
struct private_data {
|
|
|
|
virMutex lock;
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientPtr client;
|
|
|
|
virNetClientProgramPtr remoteProgram;
|
|
|
|
virNetClientProgramPtr qemuProgram;
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
int counter; /* Serial number for RPC */
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetTLSContextPtr tls;
|
2009-01-20 11:41:24 +00:00
|
|
|
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
int is_secure; /* Secure if TLS or SASL or UNIX sockets */
|
2007-06-11 11:43:41 +00:00
|
|
|
char *type; /* Cached return from remoteType. */
|
2008-02-20 15:23:36 +00:00
|
|
|
int localUses; /* Ref count for private data */
|
2007-12-05 15:24:15 +00:00
|
|
|
char *hostname; /* Original hostname */
|
2011-09-22 12:59:06 +00:00
|
|
|
bool serverKeepAlive; /* Does server support keepalive protocol? */
|
2009-01-20 16:36:34 +00:00
|
|
|
|
2011-05-13 15:00:10 +00:00
|
|
|
virDomainEventStatePtr domainEventState;
|
2007-06-11 11:43:41 +00:00
|
|
|
};
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
enum {
|
2010-12-01 16:46:36 +00:00
|
|
|
REMOTE_CALL_QEMU = (1 << 0),
|
2007-12-05 15:24:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
static void remoteDriverLock(struct private_data *driver)
|
|
|
|
{
|
|
|
|
virMutexLock(&driver->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void remoteDriverUnlock(struct private_data *driver)
|
|
|
|
{
|
|
|
|
virMutexUnlock(&driver->lock);
|
|
|
|
}
|
|
|
|
|
2011-10-21 11:49:23 +00:00
|
|
|
static int call(virConnectPtr conn, struct private_data *priv,
|
|
|
|
unsigned int flags, int proc_nr,
|
|
|
|
xdrproc_t args_filter, char *args,
|
|
|
|
xdrproc_t ret_filter, char *ret);
|
|
|
|
static int callWithFD(virConnectPtr conn, struct private_data *priv,
|
|
|
|
unsigned int flags, int fd, int proc_nr,
|
|
|
|
xdrproc_t args_filter, char *args,
|
|
|
|
xdrproc_t ret_filter, char *ret);
|
2010-12-01 16:46:36 +00:00
|
|
|
static int remoteAuthenticate (virConnectPtr conn, struct private_data *priv,
|
2007-12-05 18:55:04 +00:00
|
|
|
virConnectAuthPtr auth, const char *authtype);
|
2007-12-05 15:24:15 +00:00
|
|
|
#if HAVE_SASL
|
2010-12-01 16:46:36 +00:00
|
|
|
static int remoteAuthSASL (virConnectPtr conn, struct private_data *priv,
|
2007-12-05 18:55:04 +00:00
|
|
|
virConnectAuthPtr auth, const char *mech);
|
2007-12-05 15:24:15 +00:00
|
|
|
#endif
|
2007-12-05 18:21:27 +00:00
|
|
|
#if HAVE_POLKIT
|
2010-12-01 16:46:36 +00:00
|
|
|
static int remoteAuthPolkit (virConnectPtr conn, struct private_data *priv,
|
2007-12-05 18:55:04 +00:00
|
|
|
virConnectAuthPtr auth);
|
2007-12-05 18:21:27 +00:00
|
|
|
#endif /* HAVE_POLKIT */
|
2010-04-03 12:55:42 +00:00
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
|
|
|
|
static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
|
2010-03-25 17:46:03 +00:00
|
|
|
static virNWFilterPtr get_nonnull_nwfilter (virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
|
2009-05-29 14:29:22 +00:00
|
|
|
static virInterfacePtr get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface);
|
2008-02-20 15:23:36 +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);
|
2008-11-21 12:31:04 +00:00
|
|
|
static virNodeDevicePtr get_nonnull_node_device (virConnectPtr conn, remote_nonnull_node_device dev);
|
2009-07-28 02:46:01 +00:00
|
|
|
static virSecretPtr get_nonnull_secret (virConnectPtr conn, remote_nonnull_secret secret);
|
2010-03-31 20:33:13 +00:00
|
|
|
static virDomainSnapshotPtr get_nonnull_domain_snapshot (virDomainPtr domain, remote_nonnull_domain_snapshot snapshot);
|
2007-06-11 11:43:41 +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:23:36 +00:00
|
|
|
static void make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr vol_src);
|
|
|
|
static void make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src);
|
2009-07-28 02:46:01 +00:00
|
|
|
static void make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
|
2010-03-25 17:46:03 +00:00
|
|
|
static void make_nonnull_nwfilter (remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src);
|
2010-03-31 20:33:13 +00:00
|
|
|
static void make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
|
2010-12-01 16:46:36 +00:00
|
|
|
static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event);
|
2007-06-11 11:43:41 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* Helper functions for remoteOpen. */
|
|
|
|
static char *get_transport_from_scheme (char *scheme);
|
|
|
|
|
2008-06-26 09:37:51 +00:00
|
|
|
#ifdef WITH_LIBVIRTD
|
2007-10-27 01:23:28 +00:00
|
|
|
static int
|
2009-06-12 13:20:13 +00:00
|
|
|
remoteStartup(int privileged ATTRIBUTE_UNUSED)
|
2007-10-27 01:23:28 +00:00
|
|
|
{
|
|
|
|
/* Mark that we're inside the daemon so we can avoid
|
|
|
|
* re-entering ourselves
|
|
|
|
*/
|
|
|
|
inside_daemon = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-06-26 09:37:51 +00:00
|
|
|
#endif
|
2007-10-27 01:23:28 +00:00
|
|
|
|
2008-10-28 17:47:40 +00:00
|
|
|
#ifndef WIN32
|
2007-07-04 03:59:13 +00:00
|
|
|
/**
|
2010-12-01 16:46:36 +00:00
|
|
|
* remoteFindDaemonPath:
|
2007-07-04 03:59:13 +00:00
|
|
|
*
|
|
|
|
* Tries to find the path to the libvirtd binary.
|
2008-02-05 19:27:37 +00:00
|
|
|
*
|
2007-07-04 03:59:13 +00:00
|
|
|
* Returns path on success or NULL in case of error.
|
|
|
|
*/
|
|
|
|
static const char *
|
|
|
|
remoteFindDaemonPath(void)
|
|
|
|
{
|
|
|
|
static const char *serverPaths[] = {
|
|
|
|
SBINDIR "/libvirtd",
|
|
|
|
SBINDIR "/libvirtd_dbg",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
const char *customDaemon = getenv("LIBVIRTD_PATH");
|
|
|
|
|
|
|
|
if (customDaemon)
|
2012-03-22 11:33:35 +00:00
|
|
|
return customDaemon;
|
2007-07-04 03:59:13 +00:00
|
|
|
|
|
|
|
for (i = 0; serverPaths[i]; i++) {
|
2011-03-18 20:41:13 +00:00
|
|
|
if (virFileIsExecutable(serverPaths[i])) {
|
2007-07-04 03:59:13 +00:00
|
|
|
return serverPaths[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-12-01 16:46:36 +00:00
|
|
|
#endif
|
2007-07-04 03:59:13 +00:00
|
|
|
|
2011-05-06 15:23:57 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventReboot(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventRTCChange(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventWatchdog(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventIOError(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventIOErrorReason(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventGraphics(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventControlError(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
|
2011-07-22 05:57:42 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventBlockJob(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
|
2011-10-18 14:15:42 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventDiskChange(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
|
2012-03-23 13:44:50 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventTrayChange(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
|
2012-03-23 14:43:14 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventPMWakeup(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
|
|
|
|
2012-03-23 14:50:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventPMSuspend(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
2012-07-13 09:05:17 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventBalloonChange(virNetClientProgramPtr prog,
|
|
|
|
virNetClientPtr client,
|
|
|
|
void *evdata, void *opaque);
|
2012-03-23 14:50:36 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static virNetClientProgramEvent remoteDomainEvents[] = {
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
|
|
|
|
remoteDomainBuildEventRTCChange,
|
|
|
|
sizeof(remote_domain_event_rtc_change_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_rtc_change_msg },
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_REBOOT,
|
|
|
|
remoteDomainBuildEventReboot,
|
|
|
|
sizeof(remote_domain_event_reboot_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_reboot_msg },
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE,
|
|
|
|
remoteDomainBuildEventLifecycle,
|
|
|
|
sizeof(remote_domain_event_lifecycle_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_lifecycle_msg },
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_WATCHDOG,
|
|
|
|
remoteDomainBuildEventWatchdog,
|
|
|
|
sizeof(remote_domain_event_watchdog_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_watchdog_msg},
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_IO_ERROR,
|
|
|
|
remoteDomainBuildEventIOError,
|
|
|
|
sizeof(remote_domain_event_io_error_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_io_error_msg },
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON,
|
|
|
|
remoteDomainBuildEventIOErrorReason,
|
|
|
|
sizeof(remote_domain_event_io_error_reason_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_io_error_reason_msg },
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
|
|
|
|
remoteDomainBuildEventGraphics,
|
|
|
|
sizeof(remote_domain_event_graphics_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_graphics_msg },
|
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR,
|
|
|
|
remoteDomainBuildEventControlError,
|
|
|
|
sizeof(remote_domain_event_control_error_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_control_error_msg },
|
2011-07-22 05:57:42 +00:00
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB,
|
|
|
|
remoteDomainBuildEventBlockJob,
|
|
|
|
sizeof(remote_domain_event_block_job_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_block_job_msg },
|
2011-10-18 14:15:42 +00:00
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE,
|
|
|
|
remoteDomainBuildEventDiskChange,
|
|
|
|
sizeof(remote_domain_event_disk_change_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_disk_change_msg },
|
2012-03-23 13:44:50 +00:00
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE,
|
|
|
|
remoteDomainBuildEventTrayChange,
|
|
|
|
sizeof(remote_domain_event_tray_change_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_tray_change_msg },
|
2012-03-23 14:43:14 +00:00
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP,
|
|
|
|
remoteDomainBuildEventPMWakeup,
|
|
|
|
sizeof(remote_domain_event_pmwakeup_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_pmwakeup_msg },
|
2012-03-23 14:50:36 +00:00
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND,
|
|
|
|
remoteDomainBuildEventPMSuspend,
|
|
|
|
sizeof(remote_domain_event_pmsuspend_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_pmsuspend_msg },
|
2012-07-13 09:05:17 +00:00
|
|
|
{ REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE,
|
|
|
|
remoteDomainBuildEventBalloonChange,
|
|
|
|
sizeof(remote_domain_event_balloon_change_msg),
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_balloon_change_msg },
|
2010-12-01 16:46:36 +00:00
|
|
|
};
|
2007-07-04 03:59:13 +00:00
|
|
|
|
2007-09-12 10:33:48 +00:00
|
|
|
enum virDrvOpenRemoteFlags {
|
2007-07-04 03:59:13 +00:00
|
|
|
VIR_DRV_OPEN_REMOTE_RO = (1 << 0),
|
2009-06-12 12:06:15 +00:00
|
|
|
VIR_DRV_OPEN_REMOTE_USER = (1 << 1), /* Use the per-user socket path */
|
|
|
|
VIR_DRV_OPEN_REMOTE_AUTOSTART = (1 << 2), /* Autostart a per-user daemon */
|
2007-09-12 10:33:48 +00:00
|
|
|
};
|
2007-07-04 03:59:13 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
|
2012-07-19 14:58:38 +00:00
|
|
|
static void remoteClientCloseFunc(virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
int reason,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
|
|
|
|
virMutexLock(&conn->lock);
|
|
|
|
if (conn->closeCallback) {
|
|
|
|
virConnectCloseFunc closeCallback = conn->closeCallback;
|
|
|
|
void *closeOpaque = conn->closeOpaque;
|
|
|
|
virFreeCallback closeFreeCallback = conn->closeFreeCallback;
|
|
|
|
unsigned closeUnregisterCount = conn->closeUnregisterCount;
|
|
|
|
|
|
|
|
VIR_DEBUG("Triggering connection close callback %p reason=%d",
|
|
|
|
conn->closeCallback, reason);
|
|
|
|
conn->closeDispatch = true;
|
|
|
|
virMutexUnlock(&conn->lock);
|
|
|
|
closeCallback(conn, reason, closeOpaque);
|
|
|
|
virMutexLock(&conn->lock);
|
|
|
|
conn->closeDispatch = false;
|
|
|
|
if (conn->closeUnregisterCount != closeUnregisterCount)
|
|
|
|
closeFreeCallback(closeOpaque);
|
|
|
|
}
|
|
|
|
virMutexUnlock(&conn->lock);
|
|
|
|
}
|
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
/* helper macro to ease extraction of arguments from the URI */
|
|
|
|
#define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \
|
|
|
|
if (STRCASEEQ(var->name, ARG_NAME)) { \
|
|
|
|
VIR_FREE(ARG_VAR); \
|
|
|
|
if (!(ARG_VAR = strdup(var->value))) \
|
|
|
|
goto no_memory; \
|
|
|
|
var->ignore = 1; \
|
|
|
|
continue; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EXTRACT_URI_ARG_BOOL(ARG_NAME, ARG_VAR) \
|
|
|
|
if (STRCASEEQ(var->name, ARG_NAME)) { \
|
|
|
|
int tmp; \
|
|
|
|
if (virStrToLong_i(var->value, NULL, 10, &tmp) < 0) { \
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG, \
|
|
|
|
_("Failed to parse value of URI component %s"), \
|
|
|
|
var->name); \
|
|
|
|
goto failed; \
|
|
|
|
} \
|
|
|
|
ARG_VAR = tmp == 0; \
|
|
|
|
var->ignore = 1; \
|
|
|
|
continue; \
|
|
|
|
}
|
2009-06-12 12:06:15 +00:00
|
|
|
/*
|
|
|
|
* URIs that this driver needs to handle:
|
|
|
|
*
|
|
|
|
* The easy answer:
|
|
|
|
* - Everything that no one else has yet claimed, but nothing if
|
|
|
|
* we're inside the libvirtd daemon
|
|
|
|
*
|
|
|
|
* The hard answer:
|
|
|
|
* - Plain paths (///var/lib/xen/xend-socket) -> UNIX domain socket
|
|
|
|
* - xxx://servername/ -> TLS connection
|
|
|
|
* - xxx+tls://servername/ -> TLS connection
|
|
|
|
* - xxx+tls:/// -> TLS connection to localhost
|
|
|
|
* - xxx+tcp://servername/ -> TCP connection
|
|
|
|
* - xxx+tcp:/// -> TCP connection to localhost
|
|
|
|
* - xxx+unix:/// -> UNIX domain socket
|
|
|
|
* - xxx:/// -> UNIX domain socket
|
|
|
|
*/
|
2007-07-04 03:59:13 +00:00
|
|
|
static int
|
2012-07-17 12:25:34 +00:00
|
|
|
doRemoteOpen(virConnectPtr conn,
|
|
|
|
struct private_data *priv,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2007-06-11 11:43:41 +00:00
|
|
|
{
|
2008-11-17 11:44:51 +00:00
|
|
|
char *transport_str = NULL;
|
2009-06-12 12:06:15 +00:00
|
|
|
enum {
|
|
|
|
trans_tls,
|
|
|
|
trans_unix,
|
|
|
|
trans_ssh,
|
|
|
|
trans_ext,
|
|
|
|
trans_tcp,
|
|
|
|
} transport;
|
2011-12-07 10:39:14 +00:00
|
|
|
#ifndef WIN32
|
2011-12-06 21:46:22 +00:00
|
|
|
const char *daemonPath;
|
2011-12-07 10:39:14 +00:00
|
|
|
#endif
|
2008-11-17 11:44:51 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
/* We handle *ALL* URIs here. The caller has rejected any
|
2009-06-12 12:06:15 +00:00
|
|
|
* URIs we don't care about */
|
2008-11-17 11:44:51 +00:00
|
|
|
|
2009-06-12 12:06:15 +00:00
|
|
|
if (conn->uri) {
|
|
|
|
if (!conn->uri->scheme) {
|
|
|
|
/* This is the ///var/lib/xen/xend-socket local path style */
|
2011-10-13 10:49:45 +00:00
|
|
|
if (!conn->uri->path)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
if (conn->uri->path[0] != '/')
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
transport = trans_unix;
|
2009-06-12 12:06:15 +00:00
|
|
|
} else {
|
2012-07-17 12:25:34 +00:00
|
|
|
transport_str = get_transport_from_scheme(conn->uri->scheme);
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-06-12 12:06:15 +00:00
|
|
|
if (!transport_str) {
|
|
|
|
if (conn->uri->server)
|
|
|
|
transport = trans_tls;
|
|
|
|
else
|
|
|
|
transport = trans_unix;
|
|
|
|
} else {
|
2012-07-17 12:25:34 +00:00
|
|
|
if (STRCASEEQ(transport_str, "tls"))
|
2009-06-12 12:06:15 +00:00
|
|
|
transport = trans_tls;
|
2012-07-17 12:25:34 +00:00
|
|
|
else if (STRCASEEQ(transport_str, "unix")) {
|
2011-08-22 13:48:52 +00:00
|
|
|
if (conn->uri->server) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("using unix socket and remote "
|
|
|
|
"server '%s' is not supported."),
|
|
|
|
conn->uri->server);
|
2011-08-22 13:48:52 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
} else {
|
|
|
|
transport = trans_unix;
|
|
|
|
}
|
2012-07-17 12:25:34 +00:00
|
|
|
} else if (STRCASEEQ(transport_str, "ssh"))
|
2009-06-12 12:06:15 +00:00
|
|
|
transport = trans_ssh;
|
2012-07-17 12:25:34 +00:00
|
|
|
else if (STRCASEEQ(transport_str, "ext"))
|
2009-06-12 12:06:15 +00:00
|
|
|
transport = trans_ext;
|
2012-07-17 12:25:34 +00:00
|
|
|
else if (STRCASEEQ(transport_str, "tcp"))
|
2009-06-12 12:06:15 +00:00
|
|
|
transport = trans_tcp;
|
|
|
|
else {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
|
_("remote_open: transport in URL not recognised "
|
|
|
|
"(should be tls|unix|ssh|ext|tcp)"));
|
2009-06-12 12:06:15 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* No URI, then must be probing so use UNIX socket */
|
|
|
|
transport = trans_unix;
|
2007-07-04 03:59:13 +00:00
|
|
|
}
|
2007-06-26 23:48:46 +00:00
|
|
|
|
2010-04-07 15:12:02 +00:00
|
|
|
/* Local variables which we will initialize. These can
|
2007-06-26 11:42:46 +00:00
|
|
|
* get freed in the failed: path.
|
|
|
|
*/
|
2009-01-31 13:49:11 +00:00
|
|
|
char *name = NULL, *command = NULL, *sockname = NULL, *netcat = NULL;
|
|
|
|
char *port = NULL, *authtype = NULL, *username = NULL;
|
2011-11-04 20:10:54 +00:00
|
|
|
bool sanity = true, verify = true, tty ATTRIBUTE_UNUSED = true;
|
2011-07-19 17:52:21 +00:00
|
|
|
char *pkipath = NULL, *keyfile = NULL;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2007-06-26 11:42:46 +00:00
|
|
|
/* Return code from this function, and the private data. */
|
|
|
|
int retcode = VIR_DRV_OPEN_ERROR;
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Remote server defaults to "localhost" if not specified. */
|
2008-11-17 11:44:51 +00:00
|
|
|
if (conn->uri && conn->uri->port != 0) {
|
2012-07-17 12:25:34 +00:00
|
|
|
if (virAsprintf(&port, "%d", conn->uri->port) < 0)
|
|
|
|
goto no_memory;
|
2007-06-11 11:43:41 +00:00
|
|
|
} else if (transport == trans_tls) {
|
2012-07-17 12:25:34 +00:00
|
|
|
if (!(port = strdup(LIBVIRTD_TLS_PORT)))
|
|
|
|
goto no_memory;
|
2007-06-11 11:43:41 +00:00
|
|
|
} else if (transport == trans_tcp) {
|
2012-07-17 12:25:34 +00:00
|
|
|
if (!(port = strdup(LIBVIRTD_TCP_PORT)))
|
|
|
|
goto no_memory;
|
|
|
|
} /* Port not used for unix, ext., default for ssh */
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
if (conn->uri && conn->uri->server)
|
|
|
|
priv->hostname = strdup(conn->uri->server);
|
|
|
|
else
|
|
|
|
priv->hostname = strdup("localhost");
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2008-08-21 10:14:54 +00:00
|
|
|
if (!priv->hostname)
|
2012-07-17 12:25:34 +00:00
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
if (conn->uri && conn->uri->user &&
|
|
|
|
!(username = strdup (conn->uri->user)))
|
|
|
|
goto no_memory;
|
2007-09-25 13:54:17 +00:00
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Get the variables from the query string.
|
|
|
|
* Then we need to reconstruct the query string (because
|
|
|
|
* feasibly it might contain variables needed by the real driver,
|
|
|
|
* although that won't be the case for now).
|
|
|
|
*/
|
2007-12-17 10:07:56 +00:00
|
|
|
int i;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
if (conn->uri) {
|
2012-03-20 14:11:10 +00:00
|
|
|
for (i = 0; i < conn->uri->paramsCount ; i++) {
|
|
|
|
virURIParamPtr var = &conn->uri->params[i];
|
2012-07-17 12:25:34 +00:00
|
|
|
EXTRACT_URI_ARG_STR("name", name);
|
|
|
|
EXTRACT_URI_ARG_STR("command", command);
|
|
|
|
EXTRACT_URI_ARG_STR("socket", sockname);
|
|
|
|
EXTRACT_URI_ARG_STR("auth", authtype);
|
|
|
|
EXTRACT_URI_ARG_STR("netcat", netcat);
|
|
|
|
EXTRACT_URI_ARG_STR("keyfile", keyfile);
|
|
|
|
EXTRACT_URI_ARG_STR("pkipath", pkipath);
|
|
|
|
|
|
|
|
EXTRACT_URI_ARG_BOOL("no_sanity", sanity);
|
|
|
|
EXTRACT_URI_ARG_BOOL("no_verify", verify);
|
|
|
|
EXTRACT_URI_ARG_BOOL("no_tty", tty);
|
|
|
|
|
|
|
|
if (STRCASEEQ(var->name, "authfile")) {
|
2012-03-20 11:11:10 +00:00
|
|
|
/* Strip this param, used by virauth.c */
|
|
|
|
var->ignore = 1;
|
2012-07-17 12:25:34 +00:00
|
|
|
continue;
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
}
|
2012-07-17 12:25:34 +00:00
|
|
|
|
|
|
|
VIR_DEBUG("passing through variable '%s' ('%s') to remote end",
|
|
|
|
var->name, var->value);
|
2008-11-17 11:44:51 +00:00
|
|
|
}
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
/* Construct the original name. */
|
|
|
|
if (!name) {
|
2009-06-12 12:06:15 +00:00
|
|
|
if (conn->uri->scheme &&
|
|
|
|
(STREQ(conn->uri->scheme, "remote") ||
|
|
|
|
STRPREFIX(conn->uri->scheme, "remote+"))) {
|
2008-11-28 12:03:20 +00:00
|
|
|
/* Allow remote serve to probe */
|
Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.
* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
src/xen/xend_internal.c, tests/viruritest.c: Remove error
reporting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-20 12:16:54 +00:00
|
|
|
if (!(name = strdup("")))
|
2012-07-17 12:25:34 +00:00
|
|
|
goto no_memory;
|
2008-11-28 12:03:20 +00:00
|
|
|
} else {
|
2012-02-24 18:48:55 +00:00
|
|
|
virURI tmpuri = {
|
2008-11-28 12:03:20 +00:00
|
|
|
.scheme = conn->uri->scheme,
|
2012-03-23 14:27:03 +00:00
|
|
|
.query = virURIFormatParams(conn->uri),
|
2008-11-28 12:03:20 +00:00
|
|
|
.path = conn->uri->path,
|
|
|
|
.fragment = conn->uri->fragment,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Evil, blank out transport scheme temporarily */
|
|
|
|
if (transport_str) {
|
2012-07-17 12:25:34 +00:00
|
|
|
assert(transport_str[-1] == '+');
|
2008-11-28 12:03:20 +00:00
|
|
|
transport_str[-1] = '\0';
|
|
|
|
}
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2012-02-24 18:48:55 +00:00
|
|
|
name = virURIFormat(&tmpuri);
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2008-11-28 12:03:20 +00:00
|
|
|
VIR_FREE(tmpuri.query);
|
|
|
|
|
|
|
|
/* Restore transport scheme */
|
|
|
|
if (transport_str)
|
|
|
|
transport_str[-1] = '+';
|
Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.
* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
src/xen/xend_internal.c, tests/viruritest.c: Remove error
reporting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-20 12:16:54 +00:00
|
|
|
|
|
|
|
if (!name)
|
|
|
|
goto failed;
|
2008-11-28 12:03:20 +00:00
|
|
|
}
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
2008-11-17 11:44:51 +00:00
|
|
|
} else {
|
|
|
|
/* Probe URI server side */
|
Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.
* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
src/xen/xend_internal.c, tests/viruritest.c: Remove error
reporting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-20 12:16:54 +00:00
|
|
|
if (!(name = strdup("")))
|
2012-07-17 12:25:34 +00:00
|
|
|
goto no_memory;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("proceeding with name = %s", name);
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
/* For ext transport, command is required. */
|
|
|
|
if (transport == trans_ext && !command) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
|
_("remote_open: for 'ext' transport, command is required"));
|
2008-11-17 11:44:51 +00:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Connecting with transport %d", transport);
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Connect to the remote service. */
|
|
|
|
switch (transport) {
|
|
|
|
case trans_tls:
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->tls = virNetTLSContextNewClientPath(pkipath,
|
|
|
|
geteuid() != 0 ? true : false,
|
2011-07-21 10:13:11 +00:00
|
|
|
sanity, verify);
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!priv->tls)
|
|
|
|
goto failed;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
priv->is_secure = 1;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
|
|
|
/*FALLTHROUGH*/
|
2010-12-01 16:46:36 +00:00
|
|
|
case trans_tcp:
|
|
|
|
priv->client = virNetClientNewTCP(priv->hostname, port);
|
|
|
|
if (!priv->client)
|
2007-06-11 11:43:41 +00:00
|
|
|
goto failed;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (priv->tls) {
|
|
|
|
VIR_DEBUG("Starting TLS session");
|
|
|
|
if (virNetClientSetTLSSession(priv->client, priv->tls) < 0)
|
|
|
|
goto failed;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2007-12-07 14:56:37 +00:00
|
|
|
#ifndef WIN32
|
2010-12-01 16:46:36 +00:00
|
|
|
case trans_unix:
|
2007-06-11 11:43:41 +00:00
|
|
|
if (!sockname) {
|
2007-07-04 03:59:13 +00:00
|
|
|
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
|
2012-05-24 12:29:42 +00:00
|
|
|
char *userdir = virGetUserRuntimeDirectory();
|
2008-02-05 19:27:37 +00:00
|
|
|
|
2009-01-22 19:41:48 +00:00
|
|
|
if (!userdir)
|
2007-06-26 23:48:46 +00:00
|
|
|
goto failed;
|
2008-02-05 19:27:37 +00:00
|
|
|
|
2012-05-03 12:40:32 +00:00
|
|
|
if (virAsprintf(&sockname, "%s/" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
|
2009-01-22 19:41:48 +00:00
|
|
|
VIR_FREE(userdir);
|
2012-07-17 12:25:34 +00:00
|
|
|
goto no_memory;
|
2009-01-22 19:41:48 +00:00
|
|
|
}
|
|
|
|
VIR_FREE(userdir);
|
2007-06-26 23:48:46 +00:00
|
|
|
} else {
|
2007-07-04 03:59:13 +00:00
|
|
|
if (flags & VIR_DRV_OPEN_REMOTE_RO)
|
2010-12-01 16:46:36 +00:00
|
|
|
sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET_RO);
|
2007-06-26 23:48:46 +00:00
|
|
|
else
|
2010-12-01 16:46:36 +00:00
|
|
|
sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET);
|
2008-08-21 10:14:54 +00:00
|
|
|
if (sockname == NULL)
|
2012-07-17 12:25:34 +00:00
|
|
|
goto no_memory;
|
2007-06-26 23:48:46 +00:00
|
|
|
}
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Proceeding with sockname %s", sockname);
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2011-12-06 21:46:22 +00:00
|
|
|
if (!(daemonPath = remoteFindDaemonPath())) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Unable to locate libvirtd daemon in $PATH"));
|
2011-12-06 21:46:22 +00:00
|
|
|
goto failed;
|
|
|
|
}
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(priv->client = virNetClientNewUNIX(sockname,
|
|
|
|
flags & VIR_DRV_OPEN_REMOTE_AUTOSTART,
|
2011-12-06 21:46:22 +00:00
|
|
|
daemonPath)))
|
2009-08-03 12:37:44 +00:00
|
|
|
goto failed;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
priv->is_secure = 1;
|
2007-06-11 11:43:41 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
case trans_ssh:
|
2012-07-17 12:25:34 +00:00
|
|
|
if (!command && !(command = strdup("ssh")))
|
|
|
|
goto no_memory;
|
2007-11-14 16:29:08 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!sockname) {
|
|
|
|
if (flags & VIR_DRV_OPEN_REMOTE_RO)
|
|
|
|
sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET_RO);
|
|
|
|
else
|
|
|
|
sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET);
|
2012-07-17 12:25:34 +00:00
|
|
|
if (!sockname)
|
|
|
|
goto no_memory;
|
2010-12-01 16:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(priv->client = virNetClientNewSSH(priv->hostname,
|
|
|
|
port,
|
|
|
|
command,
|
|
|
|
username,
|
2011-07-21 10:13:11 +00:00
|
|
|
!tty,
|
|
|
|
!verify,
|
2010-12-01 16:46:36 +00:00
|
|
|
netcat ? netcat : "nc",
|
2011-07-19 17:52:21 +00:00
|
|
|
keyfile,
|
2010-12-01 16:46:36 +00:00
|
|
|
sockname)))
|
|
|
|
goto failed;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
|
|
|
priv->is_secure = 1;
|
2010-12-01 16:46:36 +00:00
|
|
|
break;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
|
|
|
case trans_ext: {
|
2010-12-01 16:46:36 +00:00
|
|
|
char const *cmd_argv[] = { command, NULL };
|
|
|
|
if (!(priv->client = virNetClientNewExternal(cmd_argv)))
|
2007-06-11 11:43:41 +00:00
|
|
|
goto failed;
|
|
|
|
|
2011-07-20 22:53:31 +00:00
|
|
|
/* Do not set 'is_secure' flag since we can't guarantee
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
* an external program is secure, and this flag must be
|
|
|
|
* pessimistic */
|
2010-12-01 16:46:36 +00:00
|
|
|
} break;
|
|
|
|
|
2007-12-07 14:56:37 +00:00
|
|
|
#else /* WIN32 */
|
|
|
|
|
|
|
|
case trans_unix:
|
|
|
|
case trans_ssh:
|
|
|
|
case trans_ext:
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
|
_("transport methods unix, ssh and ext are not supported "
|
|
|
|
"under Windows"));
|
2009-01-15 20:13:12 +00:00
|
|
|
goto failed;
|
2007-12-07 14:56:37 +00:00
|
|
|
|
|
|
|
#endif /* WIN32 */
|
2007-06-11 11:43:41 +00:00
|
|
|
} /* switch (transport) */
|
|
|
|
|
2012-07-19 14:58:38 +00:00
|
|
|
|
|
|
|
virNetClientSetCloseCallback(priv->client,
|
|
|
|
remoteClientCloseFunc,
|
|
|
|
conn, NULL);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(priv->remoteProgram = virNetClientProgramNew(REMOTE_PROGRAM,
|
|
|
|
REMOTE_PROTOCOL_VERSION,
|
|
|
|
remoteDomainEvents,
|
|
|
|
ARRAY_CARDINALITY(remoteDomainEvents),
|
|
|
|
conn)))
|
2009-01-20 16:36:34 +00:00
|
|
|
goto failed;
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(priv->qemuProgram = virNetClientProgramNew(QEMU_PROGRAM,
|
|
|
|
QEMU_PROTOCOL_VERSION,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL)))
|
2010-02-11 22:39:38 +00:00
|
|
|
goto failed;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientAddProgram(priv->client, priv->remoteProgram) < 0 ||
|
|
|
|
virNetClientAddProgram(priv->client, priv->qemuProgram) < 0)
|
2009-01-20 16:36:34 +00:00
|
|
|
goto failed;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
/* Try and authenticate with server */
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Trying authentication");
|
|
|
|
if (remoteAuthenticate(conn, priv, auth, authtype) == -1)
|
2007-12-05 15:24:15 +00:00
|
|
|
goto failed;
|
|
|
|
|
2011-09-22 12:59:06 +00:00
|
|
|
if (virNetClientKeepAliveIsSupported(priv->client)) {
|
|
|
|
remote_supports_feature_args args =
|
|
|
|
{ VIR_DRV_FEATURE_PROGRAM_KEEPALIVE };
|
|
|
|
remote_supports_feature_ret ret = { 0 };
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = call(conn, priv, 0, REMOTE_PROC_SUPPORTS_FEATURE,
|
|
|
|
(xdrproc_t)xdr_remote_supports_feature_args, (char *) &args,
|
|
|
|
(xdrproc_t)xdr_remote_supports_feature_ret, (char *) &ret);
|
|
|
|
|
2011-12-04 14:26:23 +00:00
|
|
|
if (rc != -1 && ret.supported) {
|
2011-09-22 12:59:06 +00:00
|
|
|
priv->serverKeepAlive = true;
|
|
|
|
} else {
|
|
|
|
VIR_INFO("Disabling keepalive protocol since it is not supported"
|
|
|
|
" by the server");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Finally we can call the remote side's open function. */
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
{
|
|
|
|
remote_open_args args = { &name, flags };
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Trying to open URI %s", name);
|
2012-07-17 12:25:34 +00:00
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_OPEN,
|
|
|
|
(xdrproc_t) xdr_remote_open_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:
{
if (cond)
goto error;
int a = 1;
error:
printf("%d", a);
}
which prints 0 (supposing the stack started life wiped) if
cond was true. Clang will catch it, but we don't use clang
as often. Using gcc -Wjump-misses-init catches it, but also
gives false positives:
{
if (cond)
goto error;
int a = 1;
return a;
error:
return 0;
}
Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.
[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-01 15:41:45 +00:00
|
|
|
goto failed;
|
|
|
|
}
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
/* Now try and find out what URI the daemon used */
|
|
|
|
if (conn->uri == NULL) {
|
|
|
|
remote_get_uri_ret uriret;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Trying to query remote URI");
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&uriret, 0, sizeof(uriret));
|
|
|
|
if (call(conn, priv, 0,
|
|
|
|
REMOTE_PROC_GET_URI,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_remote_get_uri_ret, (char *) &uriret) < 0)
|
2008-11-17 11:44:51 +00:00
|
|
|
goto failed;
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("Auto-probed URI is %s", uriret.uri);
|
2012-02-24 18:48:55 +00:00
|
|
|
conn->uri = virURIParse(uriret.uri);
|
2008-11-17 11:44:51 +00:00
|
|
|
VIR_FREE(uriret.uri);
|
Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.
* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
src/xen/xend_internal.c, tests/viruritest.c: Remove error
reporting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-20 12:16:54 +00:00
|
|
|
if (!conn->uri)
|
2008-11-17 11:44:51 +00:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:25:58 +00:00
|
|
|
if (!(priv->domainEventState = virDomainEventStateNew()))
|
2011-05-13 15:00:10 +00:00
|
|
|
goto failed;
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Successful. */
|
|
|
|
retcode = VIR_DRV_OPEN_SUCCESS;
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
cleanup:
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Free up the URL and strings. */
|
2009-01-31 13:49:11 +00:00
|
|
|
VIR_FREE(name);
|
|
|
|
VIR_FREE(command);
|
|
|
|
VIR_FREE(sockname);
|
|
|
|
VIR_FREE(authtype);
|
|
|
|
VIR_FREE(netcat);
|
2011-07-19 17:52:21 +00:00
|
|
|
VIR_FREE(keyfile);
|
2009-01-31 13:49:11 +00:00
|
|
|
VIR_FREE(username);
|
|
|
|
VIR_FREE(port);
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
VIR_FREE(pkipath);
|
2007-06-11 11:43:41 +00:00
|
|
|
|
|
|
|
return retcode;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
no_memory:
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
failed:
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(priv->remoteProgram);
|
|
|
|
virObjectUnref(priv->qemuProgram);
|
2011-07-19 13:13:32 +00:00
|
|
|
virNetClientClose(priv->client);
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(priv->client);
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->client = NULL;
|
2009-03-17 11:00:56 +00:00
|
|
|
|
2009-01-31 13:49:11 +00:00
|
|
|
VIR_FREE(priv->hostname);
|
2007-12-05 15:24:15 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
2012-07-17 12:25:34 +00:00
|
|
|
#undef EXTRACT_URI_ARG_STR
|
|
|
|
#undef EXTRACT_URI_ARG_BOOL
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-29 23:01:37 +00:00
|
|
|
static struct private_data *
|
2010-04-03 12:55:42 +00:00
|
|
|
remoteAllocPrivateData(void)
|
2007-07-04 03:59:13 +00:00
|
|
|
{
|
2007-10-27 01:23:28 +00:00
|
|
|
struct private_data *priv;
|
2008-06-06 11:09:57 +00:00
|
|
|
if (VIR_ALLOC(priv) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2009-01-29 23:01:37 +00:00
|
|
|
return NULL;
|
2007-07-04 03:59:13 +00:00
|
|
|
}
|
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
if (virMutexInit(&priv->lock) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("cannot initialize mutex"));
|
2009-01-20 11:41:24 +00:00
|
|
|
VIR_FREE(priv);
|
2009-01-29 23:01:37 +00:00
|
|
|
return NULL;
|
2009-01-20 11:41:24 +00:00
|
|
|
}
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses = 1;
|
2009-01-29 23:01:37 +00:00
|
|
|
|
|
|
|
return priv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteOpenSecondaryDriver(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth,
|
2011-07-08 18:57:08 +00:00
|
|
|
unsigned int flags,
|
2009-01-29 23:01:37 +00:00
|
|
|
struct private_data **priv)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int rflags = 0;
|
|
|
|
|
2010-04-03 12:55:42 +00:00
|
|
|
if (!((*priv) = remoteAllocPrivateData()))
|
2009-01-29 23:01:37 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
|
|
|
|
if (flags & VIR_CONNECT_RO)
|
|
|
|
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
|
|
|
|
|
|
|
ret = doRemoteOpen(conn, *priv, auth, rflags);
|
|
|
|
if (ret != VIR_DRV_OPEN_SUCCESS) {
|
|
|
|
remoteDriverUnlock(*priv);
|
|
|
|
VIR_FREE(*priv);
|
|
|
|
} else {
|
|
|
|
(*priv)->localUses = 1;
|
|
|
|
remoteDriverUnlock(*priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDrvOpenStatus
|
|
|
|
remoteOpen (virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth,
|
2011-07-06 20:40:19 +00:00
|
|
|
unsigned int flags)
|
2009-01-29 23:01:37 +00:00
|
|
|
{
|
|
|
|
struct private_data *priv;
|
|
|
|
int ret, rflags = 0;
|
2009-07-06 17:43:21 +00:00
|
|
|
const char *autostart = getenv("LIBVIRT_AUTOSTART");
|
2009-01-29 23:01:37 +00:00
|
|
|
|
2009-09-04 08:28:27 +00:00
|
|
|
if (inside_daemon && (!conn->uri || (conn->uri && !conn->uri->server)))
|
2009-01-29 23:01:37 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2010-04-03 12:55:42 +00:00
|
|
|
if (!(priv = remoteAllocPrivateData()))
|
2009-01-29 23:01:37 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2009-01-20 11:41:24 +00:00
|
|
|
|
2007-12-05 18:28:05 +00:00
|
|
|
if (flags & VIR_CONNECT_RO)
|
2007-07-04 03:59:13 +00:00
|
|
|
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
/*
|
|
|
|
* If no servername is given, and no +XXX
|
|
|
|
* transport is listed, or transport is unix,
|
|
|
|
* and path is /session, and uid is unprivileged
|
|
|
|
* then auto-spawn a daemon.
|
|
|
|
*/
|
|
|
|
if (conn->uri &&
|
|
|
|
!conn->uri->server &&
|
|
|
|
conn->uri->path &&
|
2008-11-20 14:33:59 +00:00
|
|
|
conn->uri->scheme &&
|
2008-11-17 11:44:51 +00:00
|
|
|
((strchr(conn->uri->scheme, '+') == 0)||
|
|
|
|
(strstr(conn->uri->scheme, "+unix") != NULL)) &&
|
2009-07-10 12:14:23 +00:00
|
|
|
(STREQ(conn->uri->path, "/session") ||
|
|
|
|
STRPREFIX(conn->uri->scheme, "test+")) &&
|
2008-11-17 11:44:51 +00:00
|
|
|
getuid() > 0) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Auto-spawn user daemon instance");
|
2008-11-17 11:44:51 +00:00
|
|
|
rflags |= VIR_DRV_OPEN_REMOTE_USER;
|
2009-07-06 17:43:21 +00:00
|
|
|
if (!autostart ||
|
|
|
|
STRNEQ(autostart, "0"))
|
|
|
|
rflags |= VIR_DRV_OPEN_REMOTE_AUTOSTART;
|
2008-11-17 11:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-01-22 17:49:41 +00:00
|
|
|
* If URI is NULL, then do a UNIX connection possibly auto-spawning
|
|
|
|
* unprivileged server and probe remote server for URI. On Solaris,
|
|
|
|
* this isn't supported, but we may be privileged enough to connect
|
|
|
|
* to the UNIX socket anyway.
|
2008-11-17 11:44:51 +00:00
|
|
|
*/
|
|
|
|
if (!conn->uri) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Auto-probe remote URI");
|
2009-01-22 17:49:41 +00:00
|
|
|
#ifndef __sun
|
2008-11-17 11:44:51 +00:00
|
|
|
if (getuid() > 0) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Auto-spawn user daemon instance");
|
2008-11-17 11:44:51 +00:00
|
|
|
rflags |= VIR_DRV_OPEN_REMOTE_USER;
|
2009-07-06 17:43:21 +00:00
|
|
|
if (!autostart ||
|
|
|
|
STRNEQ(autostart, "0"))
|
|
|
|
rflags |= VIR_DRV_OPEN_REMOTE_AUTOSTART;
|
2008-11-17 11:44:51 +00:00
|
|
|
}
|
2009-01-22 17:49:41 +00:00
|
|
|
#endif
|
2008-03-27 09:34:06 +00:00
|
|
|
}
|
2007-07-04 03:59:13 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
ret = doRemoteOpen(conn, priv, auth, rflags);
|
2007-07-04 03:59:13 +00:00
|
|
|
if (ret != VIR_DRV_OPEN_SUCCESS) {
|
|
|
|
conn->privateData = NULL;
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(priv);
|
2007-07-04 03:59:13 +00:00
|
|
|
} else {
|
|
|
|
conn->privateData = priv;
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2007-07-04 03:59:13 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/* In a string "driver+transport" return a pointer to "transport". */
|
|
|
|
static char *
|
2012-07-17 12:25:34 +00:00
|
|
|
get_transport_from_scheme(char *scheme)
|
2007-06-11 11:43:41 +00:00
|
|
|
{
|
2012-07-17 12:25:34 +00:00
|
|
|
char *p = strchr(scheme, '+');
|
|
|
|
return p ? p + 1 : NULL;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2007-07-12 15:17:08 +00:00
|
|
|
|
|
|
|
static int
|
2012-07-17 12:25:34 +00:00
|
|
|
doRemoteClose(virConnectPtr conn, struct private_data *priv)
|
2007-07-12 15:17:08 +00:00
|
|
|
{
|
2011-07-08 11:41:06 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_CLOSE,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
2011-07-08 11:41:06 +00:00
|
|
|
ret = -1;
|
2007-07-12 15:17:08 +00:00
|
|
|
|
2012-07-11 13:35:48 +00:00
|
|
|
virObjectUnref(priv->tls);
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->tls = NULL;
|
2011-07-19 13:13:32 +00:00
|
|
|
virNetClientClose(priv->client);
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(priv->client);
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->client = NULL;
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(priv->remoteProgram);
|
|
|
|
virObjectUnref(priv->qemuProgram);
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->remoteProgram = priv->qemuProgram = NULL;
|
|
|
|
|
|
|
|
/* Free hostname copy */
|
|
|
|
VIR_FREE(priv->hostname);
|
|
|
|
|
|
|
|
/* See comment for remoteType. */
|
|
|
|
VIR_FREE(priv->type);
|
|
|
|
|
|
|
|
virDomainEventStateFree(priv->domainEventState);
|
|
|
|
priv->domainEventState = NULL;
|
2007-07-12 15:17:08 +00:00
|
|
|
|
2011-07-08 11:41:06 +00:00
|
|
|
return ret;
|
2010-05-07 12:42:11 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
static int
|
2012-07-17 12:25:34 +00:00
|
|
|
remoteClose(virConnectPtr conn)
|
2007-06-11 11:43:41 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
int ret = 0;
|
|
|
|
struct private_data *priv = conn->privateData;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
|
|
|
if (!priv->localUses) {
|
|
|
|
ret = doRemoteClose(conn, priv);
|
|
|
|
conn->privateData = NULL;
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
virMutexDestroy(&priv->lock);
|
|
|
|
VIR_FREE (priv);
|
2010-05-07 12:42:11 +00:00
|
|
|
}
|
2010-12-01 16:46:36 +00:00
|
|
|
if (priv)
|
|
|
|
remoteDriverUnlock(priv);
|
2010-05-07 12:42:11 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2007-07-12 15:17:08 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
/* Unfortunately this function is defined to return a static string.
|
|
|
|
* Since the remote end always answers with the same type (for a
|
|
|
|
* single connection anyway) we cache the type in the connection's
|
|
|
|
* private data, and free it when we close the connection.
|
|
|
|
*
|
|
|
|
* See also:
|
|
|
|
* http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html
|
|
|
|
*/
|
|
|
|
static const char *
|
2012-07-17 12:25:34 +00:00
|
|
|
remoteType(virConnectPtr conn)
|
2010-12-01 16:46:36 +00:00
|
|
|
{
|
|
|
|
char *rv = NULL;
|
|
|
|
remote_get_type_ret ret;
|
|
|
|
struct private_data *priv = conn->privateData;
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteDriverLock(priv);
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
/* Cached? */
|
|
|
|
if (priv->type) {
|
|
|
|
rv = priv->type;
|
|
|
|
goto done;
|
|
|
|
}
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_GET_TYPE,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_remote_get_type_ret, (char *) &ret) == -1)
|
2010-12-01 16:46:36 +00:00
|
|
|
goto done;
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
/* Stash. */
|
|
|
|
rv = priv->type = ret.type;
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static int remoteIsSecure(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_is_secure_ret ret;
|
|
|
|
remoteDriverLock(priv);
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_IS_SECURE,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_remote_is_secure_ret, (char *) &ret) == -1)
|
2010-12-01 16:46:36 +00:00
|
|
|
goto done;
|
2011-05-06 15:00:53 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
/* We claim to be secure, if the remote driver
|
|
|
|
* transport itself is secure, and the remote
|
|
|
|
* HV connection is secure
|
|
|
|
*
|
|
|
|
* ie, we don't want to claim to be secure if the
|
|
|
|
* remote driver is used to connect to a XenD
|
|
|
|
* driver using unencrypted HTTP:/// access
|
|
|
|
*/
|
|
|
|
rv = priv->is_secure && ret.secure ? 1 : 0;
|
2011-05-06 15:00:53 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static int remoteIsEncrypted(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int encrypted = 0;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_is_secure_ret ret;
|
|
|
|
remoteDriverLock(priv);
|
remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)
Example of use:
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root 132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem
[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 08:34:54 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_IS_SECURE,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_remote_is_secure_ret, (char *) &ret) == -1)
|
2010-12-01 16:46:36 +00:00
|
|
|
goto done;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientIsEncrypted(priv->client))
|
|
|
|
encrypted = 1;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
|
|
|
/* We claim to be encrypted, if the remote driver
|
|
|
|
* transport itself is encrypted, and the remote
|
|
|
|
* HV connection is secure.
|
|
|
|
*
|
|
|
|
* Yes, we really don't check the remote 'encrypted'
|
|
|
|
* option, since it will almost always be false,
|
|
|
|
* even if secure (eg UNIX sockets).
|
|
|
|
*/
|
|
|
|
rv = encrypted && ret.secure ? 1 : 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-06-07 01:01:12 +00:00
|
|
|
static int
|
2012-07-17 12:25:34 +00:00
|
|
|
remoteNodeGetCPUStats(virConnectPtr conn,
|
|
|
|
int cpuNum,
|
|
|
|
virNodeCPUStatsPtr params, int *nparams,
|
|
|
|
unsigned int flags)
|
2011-06-07 01:01:12 +00:00
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_node_get_cpu_stats_args args;
|
|
|
|
remote_node_get_cpu_stats_ret ret;
|
|
|
|
int i = -1;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.cpuNum = cpuNum;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_CPU_STATS,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_cpu_stats_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_cpu_stats_ret,
|
|
|
|
(char *) &ret) == -1)
|
2011-06-07 01:01:12 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Check the length of the returned list carefully. */
|
|
|
|
if (ret.params.params_len > REMOTE_NODE_CPU_STATS_MAX ||
|
|
|
|
ret.params.params_len > *nparams) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("remoteNodeGetCPUStats: "
|
|
|
|
"returned number of stats exceeds limit"));
|
2011-06-07 01:01:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
/* Handle the case when the caller does not know the number of stats
|
|
|
|
* and is asking for the number of stats supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nparams = ret.params.params_len;
|
|
|
|
|
|
|
|
/* Deserialise the result. */
|
|
|
|
for (i = 0; i < *nparams; ++i) {
|
|
|
|
if (virStrcpyStatic(params[i].field, ret.params.params_val[i].field) == NULL) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Stats %s too big for destination"),
|
|
|
|
ret.params.params_val[i].field);
|
2011-06-07 01:01:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
params[i].value = ret.params.params_val[i].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2012-07-17 12:25:34 +00:00
|
|
|
xdr_free((xdrproc_t) xdr_remote_node_get_cpu_stats_ret, (char *) &ret);
|
2011-06-07 01:01:12 +00:00
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-06-07 01:05:40 +00:00
|
|
|
static int
|
2012-07-17 12:25:34 +00:00
|
|
|
remoteNodeGetMemoryStats(virConnectPtr conn,
|
|
|
|
int cellNum,
|
|
|
|
virNodeMemoryStatsPtr params,
|
|
|
|
int *nparams,
|
|
|
|
unsigned int flags)
|
2011-06-07 01:05:40 +00:00
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_node_get_memory_stats_args args;
|
|
|
|
remote_node_get_memory_stats_ret ret;
|
|
|
|
int i = -1;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.cellNum = cellNum;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2012-07-17 12:25:34 +00:00
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_MEMORY_STATS,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_memory_stats_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_memory_stats_ret, (char *) &ret) == -1)
|
2011-06-07 01:05:40 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Check the length of the returned list carefully. */
|
|
|
|
if (ret.params.params_len > REMOTE_NODE_MEMORY_STATS_MAX ||
|
|
|
|
ret.params.params_len > *nparams) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("remoteNodeGetMemoryStats: "
|
|
|
|
"returned number of stats exceeds limit"));
|
2011-06-07 01:05:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
/* Handle the case when the caller does not know the number of stats
|
|
|
|
* and is asking for the number of stats supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nparams = ret.params.params_len;
|
|
|
|
|
|
|
|
/* Deserialise the result. */
|
|
|
|
for (i = 0; i < *nparams; ++i) {
|
|
|
|
if (virStrcpyStatic(params[i].field, ret.params.params_val[i].field) == NULL) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Stats %s too big for destination"),
|
|
|
|
ret.params.params_val[i].field);
|
2011-06-07 01:05:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
params[i].value = ret.params.params_val[i].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2012-07-17 12:25:34 +00:00
|
|
|
xdr_free((xdrproc_t) xdr_remote_node_get_memory_stats_ret, (char *) &ret);
|
2011-06-07 01:05:40 +00:00
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-05-22 15:20:25 +00:00
|
|
|
static int
|
|
|
|
remoteNodeGetCellsFreeMemory(virConnectPtr conn,
|
2012-07-17 12:25:34 +00:00
|
|
|
unsigned long long *freeMems,
|
|
|
|
int startCell,
|
|
|
|
int maxCells)
|
2008-05-22 15:20:25 +00:00
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2008-05-22 15:20:25 +00:00
|
|
|
remote_node_get_cells_free_memory_args args;
|
|
|
|
remote_node_get_cells_free_memory_ret ret;
|
|
|
|
int i;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = conn->privateData;
|
2008-05-22 15:20:25 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2008-05-22 15:20:25 +00:00
|
|
|
if (maxCells > REMOTE_NODE_MAX_CELLS) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("too many NUMA cells: %d > %d"),
|
|
|
|
maxCells, REMOTE_NODE_MAX_CELLS);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-05-22 15:20:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
args.startCell = startCell;
|
2011-05-21 07:52:19 +00:00
|
|
|
args.maxcells = maxCells;
|
2008-05-22 15:20:25 +00:00
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_CELLS_FREE_MEMORY,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_cells_free_memory_args, (char *)&args,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_cells_free_memory_ret, (char *)&ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-05-22 15:20:25 +00:00
|
|
|
|
2011-05-21 07:52:19 +00:00
|
|
|
for (i = 0 ; i < ret.cells.cells_len ; i++)
|
|
|
|
freeMems[i] = ret.cells.cells_val[i];
|
2008-05-22 15:20:25 +00:00
|
|
|
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_node_get_cells_free_memory_ret, (char *) &ret);
|
|
|
|
|
2011-05-21 07:52:19 +00:00
|
|
|
rv = ret.cells.cells_len;
|
2009-01-15 20:07:10 +00:00
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2008-05-22 15:20:25 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
static int
|
2012-07-17 12:25:34 +00:00
|
|
|
remoteListDomains(virConnectPtr conn, int *ids, int maxids)
|
2007-06-11 11:43:41 +00:00
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2007-06-11 11:43:41 +00:00
|
|
|
int i;
|
|
|
|
remote_list_domains_args args;
|
|
|
|
remote_list_domains_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = conn->privateData;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
if (maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("too many remote domain IDs: %d > %d"),
|
|
|
|
maxids, REMOTE_DOMAIN_ID_LIST_MAX);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
args.maxids = maxids;
|
|
|
|
|
2012-07-17 12:25:34 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn, priv, 0, REMOTE_PROC_LIST_DOMAINS,
|
|
|
|
(xdrproc_t) xdr_remote_list_domains_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
|
|
|
if (ret.ids.ids_len > maxids) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("too many remote domain IDs: %d > %d"),
|
|
|
|
ret.ids.ids_len, maxids);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ret.ids.ids_len; ++i)
|
|
|
|
ids[i] = ret.ids.ids_val[i];
|
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = ret.ids.ids_len;
|
|
|
|
|
|
|
|
cleanup:
|
2012-07-17 12:25:34 +00:00
|
|
|
xdr_free((xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret);
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2012-05-20 14:26:36 +00:00
|
|
|
static int
|
|
|
|
remoteConnectListAllDomains(virConnectPtr conn,
|
|
|
|
virDomainPtr **domains,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int i;
|
|
|
|
virDomainPtr *doms = NULL;
|
|
|
|
remote_connect_list_all_domains_args args;
|
|
|
|
remote_connect_list_all_domains_ret ret;
|
|
|
|
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.need_results = !!domains;
|
|
|
|
args.flags = flags;
|
|
|
|
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call(conn,
|
|
|
|
priv,
|
|
|
|
0,
|
|
|
|
REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS,
|
|
|
|
(xdrproc_t) xdr_remote_connect_list_all_domains_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_connect_list_all_domains_ret,
|
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (domains) {
|
|
|
|
if (VIR_ALLOC_N(doms, ret.domains.domains_len + 1) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ret.domains.domains_len; i++) {
|
|
|
|
doms[i] = get_nonnull_domain(conn, ret.domains.domains_val[i]);
|
|
|
|
if (!doms[i]) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*domains = doms;
|
|
|
|
doms = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ret.ret;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (doms) {
|
|
|
|
for (i = 0; i < ret.domains.domains_len; i++)
|
|
|
|
if (doms[i])
|
|
|
|
virDomainFree(doms[i]);
|
|
|
|
VIR_FREE(doms);
|
|
|
|
}
|
|
|
|
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_connect_list_all_domains_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-07-27 18:32:25 +00:00
|
|
|
/* Helper to free typed parameters. */
|
|
|
|
static void
|
|
|
|
remoteFreeTypedParameters(remote_typed_param *args_params_val,
|
|
|
|
u_int args_params_len)
|
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
if (args_params_val == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-10-12 09:26:34 +00:00
|
|
|
for (i = 0; i < args_params_len; i++) {
|
2011-07-27 18:32:25 +00:00
|
|
|
VIR_FREE(args_params_val[i].field);
|
2011-10-12 09:26:34 +00:00
|
|
|
if (args_params_val[i].value.type == VIR_TYPED_PARAM_STRING)
|
|
|
|
VIR_FREE(args_params_val[i].value.remote_typed_param_value_u.s);
|
|
|
|
}
|
2011-07-27 18:32:25 +00:00
|
|
|
|
|
|
|
VIR_FREE(args_params_val);
|
|
|
|
}
|
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
/* Helper to serialize typed parameters. */
|
2010-10-12 17:23:04 +00:00
|
|
|
static int
|
2011-05-17 20:58:40 +00:00
|
|
|
remoteSerializeTypedParameters(virTypedParameterPtr params,
|
|
|
|
int nparams,
|
2011-05-30 18:12:18 +00:00
|
|
|
remote_typed_param **args_params_val,
|
|
|
|
u_int *args_params_len)
|
2010-10-12 17:23:04 +00:00
|
|
|
{
|
2011-05-17 20:58:40 +00:00
|
|
|
int i;
|
2010-10-12 17:23:04 +00:00
|
|
|
int rv = -1;
|
2011-05-17 20:58:40 +00:00
|
|
|
remote_typed_param *val;
|
2010-10-12 17:23:04 +00:00
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
*args_params_len = nparams;
|
|
|
|
if (VIR_ALLOC_N(val, nparams) < 0) {
|
2010-10-12 17:23:04 +00:00
|
|
|
virReportOOMError();
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nparams; ++i) {
|
2011-01-28 21:38:06 +00:00
|
|
|
/* call() will free this: */
|
2011-05-17 20:58:40 +00:00
|
|
|
val[i].field = strdup (params[i].field);
|
|
|
|
if (val[i].field == NULL) {
|
2010-10-12 17:23:04 +00:00
|
|
|
virReportOOMError();
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
}
|
2011-05-17 20:58:40 +00:00
|
|
|
val[i].value.type = params[i].type;
|
2010-10-12 17:23:04 +00:00
|
|
|
switch (params[i].type) {
|
2011-05-17 20:58:40 +00:00
|
|
|
case VIR_TYPED_PARAM_INT:
|
|
|
|
val[i].value.remote_typed_param_value_u.i = params[i].value.i;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_UINT:
|
|
|
|
val[i].value.remote_typed_param_value_u.ui = params[i].value.ui;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_LLONG:
|
|
|
|
val[i].value.remote_typed_param_value_u.l = params[i].value.l;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_ULLONG:
|
|
|
|
val[i].value.remote_typed_param_value_u.ul = params[i].value.ul;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_DOUBLE:
|
|
|
|
val[i].value.remote_typed_param_value_u.d = params[i].value.d;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_BOOLEAN:
|
|
|
|
val[i].value.remote_typed_param_value_u.b = params[i].value.b;
|
|
|
|
break;
|
2011-10-12 09:26:34 +00:00
|
|
|
case VIR_TYPED_PARAM_STRING:
|
|
|
|
val[i].value.remote_typed_param_value_u.s = strdup(params[i].value.s);
|
|
|
|
if (val[i].value.remote_typed_param_value_u.s == NULL) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
2010-10-12 17:23:04 +00:00
|
|
|
default:
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"),
|
|
|
|
params[i].type);
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
*args_params_val = val;
|
|
|
|
val = NULL;
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2011-07-27 18:32:25 +00:00
|
|
|
remoteFreeTypedParameters(val, nparams);
|
2011-05-17 20:58:40 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper to deserialize typed parameters. */
|
|
|
|
static int
|
2011-05-30 18:12:18 +00:00
|
|
|
remoteDeserializeTypedParameters(remote_typed_param *ret_params_val,
|
|
|
|
u_int ret_params_len,
|
2011-05-17 20:58:40 +00:00
|
|
|
int limit,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams)
|
|
|
|
{
|
2011-10-12 09:26:34 +00:00
|
|
|
int i = 0;
|
2011-05-17 20:58:40 +00:00
|
|
|
int rv = -1;
|
|
|
|
|
|
|
|
/* Check the length of the returned list carefully. */
|
|
|
|
if (ret_params_len > limit || ret_params_len > *nparams) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("returned number of parameters exceeds limit"));
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nparams = ret_params_len;
|
|
|
|
|
|
|
|
/* Deserialise the result. */
|
|
|
|
for (i = 0; i < ret_params_len; ++i) {
|
|
|
|
if (virStrcpyStatic(params[i].field,
|
|
|
|
ret_params_val[i].field) == NULL) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Parameter %s too big for destination"),
|
|
|
|
ret_params_val[i].field);
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
params[i].type = ret_params_val[i].value.type;
|
|
|
|
switch (params[i].type) {
|
|
|
|
case VIR_TYPED_PARAM_INT:
|
|
|
|
params[i].value.i =
|
|
|
|
ret_params_val[i].value.remote_typed_param_value_u.i;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_UINT:
|
|
|
|
params[i].value.ui =
|
|
|
|
ret_params_val[i].value.remote_typed_param_value_u.ui;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_LLONG:
|
|
|
|
params[i].value.l =
|
|
|
|
ret_params_val[i].value.remote_typed_param_value_u.l;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_ULLONG:
|
|
|
|
params[i].value.ul =
|
|
|
|
ret_params_val[i].value.remote_typed_param_value_u.ul;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_DOUBLE:
|
|
|
|
params[i].value.d =
|
|
|
|
ret_params_val[i].value.remote_typed_param_value_u.d;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_BOOLEAN:
|
|
|
|
params[i].value.b =
|
|
|
|
ret_params_val[i].value.remote_typed_param_value_u.b;
|
|
|
|
break;
|
2011-10-12 09:26:34 +00:00
|
|
|
case VIR_TYPED_PARAM_STRING:
|
|
|
|
params[i].value.s =
|
|
|
|
strdup(ret_params_val[i].value.remote_typed_param_value_u.s);
|
|
|
|
if (params[i].value.s == NULL) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
2011-05-17 20:58:40 +00:00
|
|
|
default:
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"),
|
|
|
|
params[i].type);
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2012-01-31 03:20:40 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virTypedParameterArrayClear(params, i);
|
2011-05-17 20:58:40 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-01-31 06:42:31 +00:00
|
|
|
static int
|
|
|
|
remoteDeserializeDomainDiskErrors(remote_domain_disk_error *ret_errors_val,
|
|
|
|
u_int ret_errors_len,
|
|
|
|
int limit,
|
|
|
|
virDomainDiskErrorPtr errors,
|
|
|
|
int maxerrors)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
if (ret_errors_len > limit || ret_errors_len > maxerrors) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("returned number of disk errors exceeds limit"));
|
2012-01-31 06:42:31 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ret_errors_len; i++) {
|
|
|
|
if (!(errors[i].disk = strdup(ret_errors_val[i].disk))) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
errors[i].error = ret_errors_val[i].error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
VIR_FREE(errors[i].disk);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-09-05 08:20:03 +00:00
|
|
|
static int
|
|
|
|
remoteDomainBlockStatsFlags(virDomainPtr domain,
|
|
|
|
const char *path,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_block_stats_flags_args args;
|
|
|
|
remote_domain_block_stats_flags_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.path = (char *) path;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-09-05 08:20:03 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_STATS_FLAGS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_block_stats_flags_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_block_stats_flags_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Check the length of the returned list carefully. */
|
|
|
|
if (ret.params.params_len > REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX ||
|
|
|
|
ret.params.params_len > *nparams) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("remoteDomainBlockStatsFlags: "
|
|
|
|
"returned number of stats exceeds limit"));
|
2011-09-05 08:20:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of stats
|
|
|
|
* and is asking for the number of stats supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nparams = ret.params.params_len;
|
|
|
|
|
|
|
|
/* Deserialise the result. */
|
|
|
|
if (remoteDeserializeTypedParameters(ret.params.params_val,
|
|
|
|
ret.params.params_len,
|
|
|
|
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
|
|
|
|
params,
|
|
|
|
nparams) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_block_stats_flags_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-10-12 17:23:04 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetMemoryParameters (virDomainPtr domain,
|
2011-05-26 17:39:04 +00:00
|
|
|
virTypedParameterPtr params, int *nparams,
|
2010-10-12 17:23:04 +00:00
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_memory_parameters_args args;
|
|
|
|
remote_domain_get_memory_parameters_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2010-10-12 17:23:04 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_MEMORY_PARAMETERS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_memory_parameters_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_memory_parameters_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of parameters
|
|
|
|
* and is asking for the number of parameters supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-30 18:12:18 +00:00
|
|
|
if (remoteDeserializeTypedParameters(ret.params.params_val,
|
|
|
|
ret.params.params_len,
|
2011-05-17 20:58:40 +00:00
|
|
|
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
|
|
|
|
params,
|
|
|
|
nparams) < 0)
|
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_memory_parameters_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-12-20 08:35:01 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetNumaParameters (virDomainPtr domain,
|
|
|
|
virTypedParameterPtr params, int *nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_numa_parameters_args args;
|
|
|
|
remote_domain_get_numa_parameters_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-12-20 08:35:01 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_NUMA_PARAMETERS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_numa_parameters_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_numa_parameters_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of parameters
|
|
|
|
* and is asking for the number of parameters supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remoteDeserializeTypedParameters(ret.params.params_val,
|
|
|
|
ret.params.params_len,
|
|
|
|
REMOTE_DOMAIN_NUMA_PARAMETERS_MAX,
|
|
|
|
params,
|
|
|
|
nparams) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_numa_parameters_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-02-22 05:34:28 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetBlkioParameters (virDomainPtr domain,
|
2011-05-26 17:39:04 +00:00
|
|
|
virTypedParameterPtr params, int *nparams,
|
|
|
|
unsigned int flags)
|
2011-02-22 05:34:28 +00:00
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_blkio_parameters_args args;
|
|
|
|
remote_domain_get_blkio_parameters_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-02-22 05:34:28 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_blkio_parameters_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_blkio_parameters_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of parameters
|
|
|
|
* and is asking for the number of parameters supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-30 18:12:18 +00:00
|
|
|
if (remoteDeserializeTypedParameters(ret.params.params_val,
|
|
|
|
ret.params.params_len,
|
2011-05-17 20:58:40 +00:00
|
|
|
REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX,
|
|
|
|
params,
|
|
|
|
nparams) < 0)
|
|
|
|
goto cleanup;
|
2011-02-22 05:34:28 +00:00
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_blkio_parameters_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-06-24 09:00:22 +00:00
|
|
|
static int
|
2011-06-24 23:09:46 +00:00
|
|
|
remoteDomainGetVcpuPinInfo (virDomainPtr domain,
|
2011-06-24 09:00:22 +00:00
|
|
|
int ncpumaps,
|
|
|
|
unsigned char *cpumaps,
|
|
|
|
int maplen,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int i;
|
2011-06-24 23:09:46 +00:00
|
|
|
remote_domain_get_vcpu_pin_info_args args;
|
|
|
|
remote_domain_get_vcpu_pin_info_ret ret;
|
2011-06-24 09:00:22 +00:00
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
if (ncpumaps > REMOTE_VCPUINFO_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("vCPU count exceeds maximum: %d > %d"),
|
|
|
|
ncpumaps, REMOTE_VCPUINFO_MAX);
|
2011-06-24 09:00:22 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (INT_MULTIPLY_OVERFLOW(ncpumaps, maplen) ||
|
|
|
|
ncpumaps * maplen > REMOTE_CPUMAPS_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("vCPU map buffer length exceeds maximum: %d > %d"),
|
|
|
|
ncpumaps * maplen, REMOTE_CPUMAPS_MAX);
|
2011-06-24 09:00:22 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.ncpumaps = ncpumaps;
|
|
|
|
args.maplen = maplen;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-06-24 09:00:22 +00:00
|
|
|
|
2011-06-24 23:09:46 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_VCPU_PIN_INFO,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_vcpu_pin_info_args,
|
2011-06-24 09:00:22 +00:00
|
|
|
(char *) &args,
|
2011-06-24 23:09:46 +00:00
|
|
|
(xdrproc_t) xdr_remote_domain_get_vcpu_pin_info_ret,
|
2011-06-24 09:00:22 +00:00
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (ret.num > ncpumaps) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("host reports too many vCPUs: %d > %d"),
|
|
|
|
ret.num, ncpumaps);
|
2011-06-24 09:00:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.cpumaps.cpumaps_len > ncpumaps * maplen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("host reports map buffer length exceeds maximum: %d > %d"),
|
|
|
|
ret.cpumaps.cpumaps_len, ncpumaps * maplen);
|
2011-06-24 09:00:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (cpumaps, 0, ncpumaps * maplen);
|
|
|
|
|
|
|
|
for (i = 0; i < ret.cpumaps.cpumaps_len; ++i)
|
|
|
|
cpumaps[i] = ret.cpumaps.cpumaps_val[i];
|
|
|
|
|
|
|
|
rv = ret.num;
|
|
|
|
|
|
|
|
cleanup:
|
2011-06-24 23:09:46 +00:00
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpu_pin_info_ret, (char *) &ret);
|
2011-06-24 09:00:22 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetVcpus (virDomainPtr domain,
|
|
|
|
virVcpuInfoPtr info,
|
|
|
|
int maxinfo,
|
|
|
|
unsigned char *cpumaps,
|
|
|
|
int maplen)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2007-06-11 11:43:41 +00:00
|
|
|
int i;
|
|
|
|
remote_domain_get_vcpus_args args;
|
|
|
|
remote_domain_get_vcpus_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = domain->conn->privateData;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
if (maxinfo > REMOTE_VCPUINFO_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("vCPU count exceeds maximum: %d > %d"),
|
|
|
|
maxinfo, REMOTE_VCPUINFO_MAX);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
2011-06-24 18:16:05 +00:00
|
|
|
if (INT_MULTIPLY_OVERFLOW(maxinfo, maplen) ||
|
|
|
|
maxinfo * maplen > REMOTE_CPUMAPS_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("vCPU map buffer length exceeds maximum: %d > %d"),
|
|
|
|
maxinfo * maplen, REMOTE_CPUMAPS_MAX);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.maxinfo = maxinfo;
|
|
|
|
args.maplen = maplen;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2007-06-11 11:43:41 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_VCPUS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_vcpus_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
|
|
|
if (ret.info.info_len > maxinfo) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("host reports too many vCPUs: %d > %d"),
|
|
|
|
ret.info.info_len, maxinfo);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
2007-06-25 08:23:10 +00:00
|
|
|
if (ret.cpumaps.cpumaps_len > maxinfo * maplen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("host reports map buffer length exceeds maximum: %d > %d"),
|
|
|
|
ret.cpumaps.cpumaps_len, maxinfo * maplen);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (info, 0, sizeof(virVcpuInfo) * maxinfo);
|
2007-06-25 08:23:10 +00:00
|
|
|
memset (cpumaps, 0, maxinfo * maplen);
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
for (i = 0; i < ret.info.info_len; ++i) {
|
|
|
|
info[i].number = ret.info.info_val[i].number;
|
|
|
|
info[i].state = ret.info.info_val[i].state;
|
|
|
|
info[i].cpuTime = ret.info.info_val[i].cpu_time;
|
|
|
|
info[i].cpu = ret.info.info_val[i].cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ret.cpumaps.cpumaps_len; ++i)
|
|
|
|
cpumaps[i] = ret.cpumaps.cpumaps_val[i];
|
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = ret.info.info_len;
|
|
|
|
|
|
|
|
cleanup:
|
2007-06-11 11:43:41 +00:00
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
|
2009-01-15 20:07:10 +00:00
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 09:27:02 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetSecurityLabel (virDomainPtr domain, virSecurityLabelPtr seclabel)
|
|
|
|
{
|
|
|
|
remote_domain_get_security_label_args args;
|
|
|
|
remote_domain_get_security_label_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
2009-03-03 19:33:34 +00:00
|
|
|
int rv = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
2009-03-03 09:27:02 +00:00
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
|
|
|
memset (seclabel, 0, sizeof(*seclabel));
|
2009-06-25 09:37:22 +00:00
|
|
|
|
2009-03-03 09:27:02 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_security_label_args, (char *)&args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret) == -1) {
|
2009-03-03 19:33:34 +00:00
|
|
|
goto done;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.label.label_val != NULL) {
|
2012-03-29 09:52:04 +00:00
|
|
|
if (strlen (ret.label.label_val) >= sizeof(seclabel->label)) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("security label exceeds maximum: %zu"),
|
|
|
|
sizeof(seclabel->label) - 1);
|
2011-07-11 05:14:45 +00:00
|
|
|
goto cleanup;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
strcpy (seclabel->label, ret.label.label_val);
|
|
|
|
seclabel->enforcing = ret.enforcing;
|
|
|
|
}
|
|
|
|
|
2009-03-03 19:33:34 +00:00
|
|
|
rv = 0;
|
|
|
|
|
2011-07-11 05:14:45 +00:00
|
|
|
cleanup:
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret);
|
|
|
|
|
2009-03-03 19:33:34 +00:00
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 14:47:22 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetState(virDomainPtr domain,
|
|
|
|
int *state,
|
|
|
|
int *reason,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_state_args args;
|
|
|
|
remote_domain_get_state_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain(&args.dom, domain);
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
2011-04-26 14:47:22 +00:00
|
|
|
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_STATE,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_state_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_state_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
*state = ret.state;
|
|
|
|
if (reason)
|
|
|
|
*reason = ret.reason;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-03-03 09:27:02 +00:00
|
|
|
static int
|
|
|
|
remoteNodeGetSecurityModel (virConnectPtr conn, virSecurityModelPtr secmodel)
|
|
|
|
{
|
|
|
|
remote_node_get_security_model_ret ret;
|
|
|
|
struct private_data *priv = conn->privateData;
|
2009-03-03 19:33:34 +00:00
|
|
|
int rv = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
2009-03-03 09:27:02 +00:00
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
|
|
|
memset (secmodel, 0, sizeof(*secmodel));
|
2009-06-25 09:37:22 +00:00
|
|
|
|
2009-03-03 09:27:02 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_SECURITY_MODEL,
|
|
|
|
(xdrproc_t) xdr_void, NULL,
|
|
|
|
(xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret) == -1) {
|
2009-03-03 19:33:34 +00:00
|
|
|
goto done;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.model.model_val != NULL) {
|
2012-03-29 09:52:04 +00:00
|
|
|
if (strlen (ret.model.model_val) >= sizeof(secmodel->model)) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("security model exceeds maximum: %zu"),
|
|
|
|
sizeof(secmodel->model) - 1);
|
2011-07-11 05:14:45 +00:00
|
|
|
goto cleanup;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
strcpy (secmodel->model, ret.model.model_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.doi.doi_val != NULL) {
|
2012-03-29 09:52:04 +00:00
|
|
|
if (strlen (ret.doi.doi_val) >= sizeof(secmodel->doi)) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("security doi exceeds maximum: %zu"),
|
|
|
|
sizeof(secmodel->doi) - 1);
|
2011-07-11 05:14:45 +00:00
|
|
|
goto cleanup;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
strcpy (secmodel->doi, ret.doi.doi_val);
|
|
|
|
}
|
2009-03-03 19:33:34 +00:00
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2011-07-11 05:14:45 +00:00
|
|
|
cleanup:
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret);
|
|
|
|
|
2009-03-03 19:33:34 +00:00
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
2007-08-21 09:31:12 +00:00
|
|
|
static int
|
|
|
|
remoteDomainMigratePrepare (virConnectPtr dconn,
|
|
|
|
char **cookie, int *cookielen,
|
|
|
|
const char *uri_in, char **uri_out,
|
|
|
|
unsigned long flags, const char *dname,
|
|
|
|
unsigned long resource)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2007-08-21 09:31:12 +00:00
|
|
|
remote_domain_migrate_prepare_args args;
|
|
|
|
remote_domain_migrate_prepare_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = dconn->privateData;
|
2007-08-21 09:31:12 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2007-08-21 09:31:12 +00:00
|
|
|
args.uri_in = uri_in == NULL ? NULL : (char **) &uri_in;
|
|
|
|
args.flags = flags;
|
|
|
|
args.dname = dname == NULL ? NULL : (char **) &dname;
|
|
|
|
args.resource = resource;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2007-08-21 09:31:12 +00:00
|
|
|
if (call (dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare_ret, (char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-08-21 09:31:12 +00:00
|
|
|
|
|
|
|
if (ret.cookie.cookie_len > 0) {
|
|
|
|
*cookie = ret.cookie.cookie_val; /* Caller frees. */
|
|
|
|
*cookielen = ret.cookie.cookie_len;
|
|
|
|
}
|
|
|
|
if (ret.uri_out)
|
|
|
|
*uri_out = *ret.uri_out; /* Caller frees. */
|
|
|
|
|
2012-03-16 11:37:05 +00:00
|
|
|
VIR_FREE(ret.uri_out);
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2007-08-21 09:31:12 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 08:42:47 +00:00
|
|
|
static int
|
|
|
|
remoteDomainMigratePrepare2 (virConnectPtr dconn,
|
|
|
|
char **cookie, int *cookielen,
|
|
|
|
const char *uri_in, char **uri_out,
|
|
|
|
unsigned long flags, const char *dname,
|
|
|
|
unsigned long resource,
|
|
|
|
const char *dom_xml)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2008-11-14 08:42:47 +00:00
|
|
|
remote_domain_migrate_prepare2_args args;
|
|
|
|
remote_domain_migrate_prepare2_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = dconn->privateData;
|
2008-11-14 08:42:47 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2008-11-14 08:42:47 +00:00
|
|
|
args.uri_in = uri_in == NULL ? NULL : (char **) &uri_in;
|
|
|
|
args.flags = flags;
|
|
|
|
args.dname = dname == NULL ? NULL : (char **) &dname;
|
|
|
|
args.resource = resource;
|
|
|
|
args.dom_xml = (char *) dom_xml;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2008-11-14 08:42:47 +00:00
|
|
|
if (call (dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE2,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare2_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare2_ret, (char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-11-14 08:42:47 +00:00
|
|
|
|
|
|
|
if (ret.cookie.cookie_len > 0) {
|
2010-05-12 14:52:06 +00:00
|
|
|
if (!cookie || !cookielen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores cookie or cookielen"));
|
2010-05-12 14:52:06 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2008-11-14 08:42:47 +00:00
|
|
|
*cookie = ret.cookie.cookie_val; /* Caller frees. */
|
|
|
|
*cookielen = ret.cookie.cookie_len;
|
|
|
|
}
|
2010-05-12 14:52:06 +00:00
|
|
|
if (ret.uri_out) {
|
|
|
|
if (!uri_out) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores uri_out"));
|
2010-05-12 14:52:06 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2008-11-14 08:42:47 +00:00
|
|
|
*uri_out = *ret.uri_out; /* Caller frees. */
|
2010-05-12 14:52:06 +00:00
|
|
|
}
|
2008-11-14 08:42:47 +00:00
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
2012-03-16 11:37:05 +00:00
|
|
|
VIR_FREE(ret.uri_out);
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2010-05-12 14:52:06 +00:00
|
|
|
error:
|
|
|
|
if (ret.cookie.cookie_len)
|
|
|
|
VIR_FREE(ret.cookie.cookie_val);
|
|
|
|
if (ret.uri_out)
|
|
|
|
VIR_FREE(*ret.uri_out);
|
|
|
|
goto done;
|
2008-11-14 08:42:47 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
static int
|
|
|
|
remoteDomainCreate (virDomainPtr domain)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2007-06-11 11:43:41 +00:00
|
|
|
remote_domain_create_args args;
|
2009-04-19 15:21:54 +00:00
|
|
|
remote_domain_lookup_by_uuid_args args2;
|
|
|
|
remote_domain_lookup_by_uuid_ret ret2;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = domain->conn->privateData;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
|
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE,
|
|
|
|
(xdrproc_t) xdr_remote_domain_create_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-04-19 15:21:54 +00:00
|
|
|
/* Need to do a lookup figure out ID of newly started guest, because
|
|
|
|
* bug in design of REMOTE_PROC_DOMAIN_CREATE means we aren't getting
|
|
|
|
* it returned.
|
|
|
|
*/
|
|
|
|
memcpy (args2.uuid, domain->uuid, VIR_UUID_BUFLEN);
|
2012-03-30 11:44:28 +00:00
|
|
|
memset (&ret2, 0, sizeof(ret2));
|
2009-04-19 15:21:54 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_LOOKUP_BY_UUID,
|
|
|
|
(xdrproc_t) xdr_remote_domain_lookup_by_uuid_args, (char *) &args2,
|
|
|
|
(xdrproc_t) xdr_remote_domain_lookup_by_uuid_ret, (char *) &ret2) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
domain->id = ret2.dom.id;
|
|
|
|
xdr_free ((xdrproc_t) &xdr_remote_domain_lookup_by_uuid_ret, (char *) &ret2);
|
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2011-04-23 10:53:57 +00:00
|
|
|
static char *
|
|
|
|
remoteDomainGetSchedulerType (virDomainPtr domain, int *nparams)
|
2007-06-11 11:43:41 +00:00
|
|
|
{
|
2011-04-23 10:53:57 +00:00
|
|
|
char *rv = NULL;
|
|
|
|
remote_domain_get_scheduler_type_args args;
|
|
|
|
remote_domain_get_scheduler_type_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = domain->conn->privateData;
|
2007-06-11 11:43:41 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-04-23 10:53:57 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SCHEDULER_TYPE,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_scheduler_type_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_scheduler_type_ret, (char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
|
|
|
if (nparams) *nparams = ret.nparams;
|
|
|
|
|
|
|
|
/* Caller frees this. */
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = ret.type;
|
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 12:43:19 +00:00
|
|
|
static int
|
|
|
|
remoteDomainMemoryStats (virDomainPtr domain,
|
|
|
|
struct _virDomainMemoryStat *stats,
|
libvirt: do not mix internal flags into public API
There were two API in driver.c that were silently masking flags
bits prior to calling out to the drivers, and several others
that were explicitly masking flags bits. This is not
forward-compatible - if we ever have that many flags in the
future, then talking to an old server that masks out the
flags would be indistinguishable from talking to a new server
that can honor the flag. In general, libvirt.c should forward
_all_ flags on to drivers, and only the drivers should reject
unknown flags.
In the case of virDrvSecretGetValue, the solution is to separate
the internal driver callback function to have two parameters
instead of one, with only one parameter affected by the public
API. In the case of virDomainGetXMLDesc, it turns out that
no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
the dumpxml path in the first place; that internal flag was
only used in saving and restoring state files, which happened
to be in functions internal to a single file, so there is no
mixing of the internal flag with a public flags argument.
Additionally, virDomainMemoryStats passed a flags argument
over RPC, but not to the driver.
* src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
(VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
(virDrvSecretGetValue): Separate out internal flags.
(virDrvDomainMemoryStats): Provide missing flags argument.
* src/driver.c (verify): Drop unused check.
* src/conf/domain_conf.h (virDomainObjParseFile): Delete
declaration.
(virDomainXMLInternalFlags): Move...
* src/conf/domain_conf.c: ...here. Delete redundant include.
(virDomainObjParseFile): Make static.
* src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
clients.
(virDomainMemoryPeek, virInterfaceGetXMLDesc)
(virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
(virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
(virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
Don't mask unknown flags.
* src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
unknown flags.
* src/secret/secret_driver.c (secretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue)
(remoteDomainMemoryStats): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
* daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.
2011-07-13 21:31:56 +00:00
|
|
|
unsigned int nr_stats,
|
|
|
|
unsigned int flags)
|
2009-12-20 12:43:19 +00:00
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_memory_stats_args args;
|
|
|
|
remote_domain_memory_stats_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
if (nr_stats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("too many memory stats requested: %d > %d"), nr_stats,
|
|
|
|
REMOTE_DOMAIN_MEMORY_STATS_MAX);
|
2009-12-20 12:43:19 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
args.maxStats = nr_stats;
|
libvirt: do not mix internal flags into public API
There were two API in driver.c that were silently masking flags
bits prior to calling out to the drivers, and several others
that were explicitly masking flags bits. This is not
forward-compatible - if we ever have that many flags in the
future, then talking to an old server that masks out the
flags would be indistinguishable from talking to a new server
that can honor the flag. In general, libvirt.c should forward
_all_ flags on to drivers, and only the drivers should reject
unknown flags.
In the case of virDrvSecretGetValue, the solution is to separate
the internal driver callback function to have two parameters
instead of one, with only one parameter affected by the public
API. In the case of virDomainGetXMLDesc, it turns out that
no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
the dumpxml path in the first place; that internal flag was
only used in saving and restoring state files, which happened
to be in functions internal to a single file, so there is no
mixing of the internal flag with a public flags argument.
Additionally, virDomainMemoryStats passed a flags argument
over RPC, but not to the driver.
* src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
(VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
(virDrvSecretGetValue): Separate out internal flags.
(virDrvDomainMemoryStats): Provide missing flags argument.
* src/driver.c (verify): Drop unused check.
* src/conf/domain_conf.h (virDomainObjParseFile): Delete
declaration.
(virDomainXMLInternalFlags): Move...
* src/conf/domain_conf.c: ...here. Delete redundant include.
(virDomainObjParseFile): Make static.
* src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
clients.
(virDomainMemoryPeek, virInterfaceGetXMLDesc)
(virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
(virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
(virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
Don't mask unknown flags.
* src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
unknown flags.
* src/secret/secret_driver.c (secretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue)
(remoteDomainMemoryStats): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
* daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.
2011-07-13 21:31:56 +00:00
|
|
|
args.flags = flags;
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2009-12-20 12:43:19 +00:00
|
|
|
|
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MEMORY_STATS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_memory_stats_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_memory_stats_ret,
|
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
for (i = 0; i < ret.stats.stats_len; i++) {
|
|
|
|
stats[i].tag = ret.stats.stats_val[i].tag;
|
|
|
|
stats[i].val = ret.stats.stats_val[i].val;
|
|
|
|
}
|
|
|
|
rv = ret.stats.stats_len;
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_domain_memory_stats_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-06-05 21:12:26 +00:00
|
|
|
static int
|
|
|
|
remoteDomainBlockPeek (virDomainPtr domain,
|
|
|
|
const char *path,
|
|
|
|
unsigned long long offset,
|
|
|
|
size_t size,
|
|
|
|
void *buffer,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2008-06-05 21:12:26 +00:00
|
|
|
remote_domain_block_peek_args args;
|
|
|
|
remote_domain_block_peek_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = domain->conn->privateData;
|
2008-06-05 21:12:26 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2008-06-05 21:12:26 +00:00
|
|
|
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("block peek request too large for remote protocol, %zi > %d"),
|
|
|
|
size, REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.path = (char *) path;
|
|
|
|
args.offset = offset;
|
|
|
|
args.size = size;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2008-06-05 21:12:26 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_PEEK,
|
|
|
|
(xdrproc_t) xdr_remote_domain_block_peek_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_block_peek_ret,
|
|
|
|
(char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-06-05 21:12:26 +00:00
|
|
|
|
|
|
|
if (ret.buffer.buffer_len != size) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("returned buffer is not same size as requested"));
|
2009-01-15 20:07:10 +00:00
|
|
|
goto cleanup;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (buffer, ret.buffer.buffer_val, size);
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2009-12-09 23:00:50 +00:00
|
|
|
VIR_FREE(ret.buffer.buffer_val);
|
2008-06-05 21:12:26 +00:00
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 10:43:28 +00:00
|
|
|
static int
|
|
|
|
remoteDomainMemoryPeek (virDomainPtr domain,
|
|
|
|
unsigned long long offset,
|
|
|
|
size_t size,
|
|
|
|
void *buffer,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2008-06-10 10:43:28 +00:00
|
|
|
remote_domain_memory_peek_args args;
|
|
|
|
remote_domain_memory_peek_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = domain->conn->privateData;
|
2008-06-10 10:43:28 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2008-06-10 10:43:28 +00:00
|
|
|
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("memory peek request too large for remote protocol, %zi > %d"),
|
|
|
|
size, REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX);
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.offset = offset;
|
|
|
|
args.size = size;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2008-06-10 10:43:28 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MEMORY_PEEK,
|
|
|
|
(xdrproc_t) xdr_remote_domain_memory_peek_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_memory_peek_ret,
|
|
|
|
(char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-06-10 10:43:28 +00:00
|
|
|
|
|
|
|
if (ret.buffer.buffer_len != size) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("returned buffer is not same size as requested"));
|
2009-01-15 20:07:10 +00:00
|
|
|
goto cleanup;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (buffer, ret.buffer.buffer_val, size);
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2009-12-09 23:00:50 +00:00
|
|
|
VIR_FREE(ret.buffer.buffer_val);
|
2008-06-10 10:43:28 +00:00
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
2011-07-22 05:31:16 +00:00
|
|
|
static int remoteDomainGetBlockJobInfo(virDomainPtr domain,
|
|
|
|
const char *path,
|
|
|
|
virDomainBlockJobInfoPtr info,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_block_job_info_args args;
|
|
|
|
remote_domain_get_block_job_info_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain(&args.dom, domain);
|
|
|
|
args.path = (char *)path;
|
|
|
|
args.flags = flags;
|
|
|
|
|
|
|
|
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_JOB_INFO,
|
|
|
|
(xdrproc_t)xdr_remote_domain_get_block_job_info_args,
|
|
|
|
(char *)&args,
|
|
|
|
(xdrproc_t)xdr_remote_domain_get_block_job_info_ret,
|
|
|
|
(char *)&ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (ret.found) {
|
|
|
|
info->type = ret.type;
|
|
|
|
info->bandwidth = ret.bandwidth;
|
|
|
|
info->cur = ret.cur;
|
|
|
|
info->end = ret.end;
|
|
|
|
rv = 1;
|
|
|
|
} else {
|
|
|
|
rv = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-11-15 09:02:44 +00:00
|
|
|
static int remoteDomainGetBlockIoTune(virDomainPtr domain,
|
|
|
|
const char *disk,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_block_io_tune_args args;
|
|
|
|
remote_domain_get_block_io_tune_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain(&args.dom, domain);
|
|
|
|
args.disk = disk ? (char **)&disk : NULL;
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.flags = flags;
|
|
|
|
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
|
|
|
|
|
|
|
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_block_io_tune_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_block_io_tune_ret,
|
|
|
|
(char *) &ret) == -1) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of parameters
|
|
|
|
* and is asking for the number of parameters supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remoteDeserializeTypedParameters(ret.params.params_val,
|
|
|
|
ret.params.params_len,
|
|
|
|
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
|
|
|
|
params,
|
|
|
|
nparams) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_block_io_tune_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-01-28 06:21:31 +00:00
|
|
|
static int remoteDomainGetCPUStats(virDomainPtr domain,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
unsigned int nparams,
|
|
|
|
int start_cpu,
|
|
|
|
unsigned int ncpus,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
remote_domain_get_cpu_stats_args args;
|
|
|
|
remote_domain_get_cpu_stats_ret ret;
|
|
|
|
int rv = -1;
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
if (nparams > REMOTE_NODE_CPU_STATS_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("nparams count exceeds maximum: %u > %u"),
|
|
|
|
nparams, REMOTE_NODE_CPU_STATS_MAX);
|
2012-01-28 06:21:31 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (ncpus > REMOTE_DOMAIN_GET_CPU_STATS_NCPUS_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC,
|
|
|
|
_("ncpus count exceeds maximum: %u > %u"),
|
|
|
|
ncpus, REMOTE_DOMAIN_GET_CPU_STATS_NCPUS_MAX);
|
2012-01-28 06:21:31 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
make_nonnull_domain(&args.dom, domain);
|
|
|
|
args.nparams = nparams;
|
|
|
|
args.start_cpu = start_cpu;
|
|
|
|
args.ncpus = ncpus;
|
|
|
|
args.flags = flags;
|
|
|
|
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
|
|
|
if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_CPU_STATS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_cpu_stats_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_cpu_stats_ret,
|
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Check the length of the returned list carefully. */
|
|
|
|
if (ret.params.params_len > nparams * ncpus ||
|
|
|
|
(ret.params.params_len &&
|
rpc: allow truncated return for virDomainGetCPUStats
The RPC code assumed that the array returned by the driver would be
fully populated; that is, ncpus on entry resulted in ncpus * return
value on exit. However, while we don't support holes in the middle
of ncpus, we do want to permit the case of ncpus on entry being
longer than the array returned by the driver (that is, it should be
safe for the caller to pass ncpus=128 on entry, and the driver will
stop populating the array when it hits max_id).
Additionally, a successful return implies that the caller will then
use virTypedParamArrayClear on the entire array; for this to not
free uninitialized memory, the driver must ensure that all skipped
entries are explicitly zeroed (the RPC driver did this, but not
the qemu driver).
There are now three cases:
server 0.9.10 and client 0.9.10 or newer: No impact - there were no
hypervisor drivers that supported cpu stats
server 0.9.11 or newer and client 0.9.10: if the client calls with
ncpus beyond the max, then the rpc call will fail on the client side
and disconnect the client, but the server is no worse for the wear
server 0.9.11 or newer and client 0.9.11: the server can return a
truncated array and the client will do just fine
I reproduced the problem by using a host with 2 CPUs, and doing:
virsh cpu-stats $dom --start 1 --count 2
* daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver
to omit tail of array.
* src/remote/remote_driver.c (remoteDomainGetCPUStats):
Accommodate driver that omits tail of array.
* src/libvirt.c (virDomainGetCPUStats): Document this.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Clear all
unpopulated entries.
2012-03-07 04:36:53 +00:00
|
|
|
((ret.params.params_len % ret.nparams) || ret.nparams > nparams))) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s",
|
|
|
|
_("remoteDomainGetCPUStats: "
|
|
|
|
"returned number of stats exceeds limit"));
|
2012-01-28 06:21:31 +00:00
|
|
|
memset(params, 0, sizeof(*params) * nparams * ncpus);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of stats
|
|
|
|
* and is asking for the number of stats supported
|
|
|
|
*/
|
|
|
|
if (nparams == 0) {
|
|
|
|
rv = ret.nparams;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The remote side did not send back any zero entries, so we have
|
rpc: allow truncated return for virDomainGetCPUStats
The RPC code assumed that the array returned by the driver would be
fully populated; that is, ncpus on entry resulted in ncpus * return
value on exit. However, while we don't support holes in the middle
of ncpus, we do want to permit the case of ncpus on entry being
longer than the array returned by the driver (that is, it should be
safe for the caller to pass ncpus=128 on entry, and the driver will
stop populating the array when it hits max_id).
Additionally, a successful return implies that the caller will then
use virTypedParamArrayClear on the entire array; for this to not
free uninitialized memory, the driver must ensure that all skipped
entries are explicitly zeroed (the RPC driver did this, but not
the qemu driver).
There are now three cases:
server 0.9.10 and client 0.9.10 or newer: No impact - there were no
hypervisor drivers that supported cpu stats
server 0.9.11 or newer and client 0.9.10: if the client calls with
ncpus beyond the max, then the rpc call will fail on the client side
and disconnect the client, but the server is no worse for the wear
server 0.9.11 or newer and client 0.9.11: the server can return a
truncated array and the client will do just fine
I reproduced the problem by using a host with 2 CPUs, and doing:
virsh cpu-stats $dom --start 1 --count 2
* daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver
to omit tail of array.
* src/remote/remote_driver.c (remoteDomainGetCPUStats):
Accommodate driver that omits tail of array.
* src/libvirt.c (virDomainGetCPUStats): Document this.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Clear all
unpopulated entries.
2012-03-07 04:36:53 +00:00
|
|
|
* to expand things back into a possibly sparse array, where the
|
|
|
|
* tail of the array may be omitted.
|
2012-01-28 06:21:31 +00:00
|
|
|
*/
|
|
|
|
memset(params, 0, sizeof(*params) * nparams * ncpus);
|
rpc: allow truncated return for virDomainGetCPUStats
The RPC code assumed that the array returned by the driver would be
fully populated; that is, ncpus on entry resulted in ncpus * return
value on exit. However, while we don't support holes in the middle
of ncpus, we do want to permit the case of ncpus on entry being
longer than the array returned by the driver (that is, it should be
safe for the caller to pass ncpus=128 on entry, and the driver will
stop populating the array when it hits max_id).
Additionally, a successful return implies that the caller will then
use virTypedParamArrayClear on the entire array; for this to not
free uninitialized memory, the driver must ensure that all skipped
entries are explicitly zeroed (the RPC driver did this, but not
the qemu driver).
There are now three cases:
server 0.9.10 and client 0.9.10 or newer: No impact - there were no
hypervisor drivers that supported cpu stats
server 0.9.11 or newer and client 0.9.10: if the client calls with
ncpus beyond the max, then the rpc call will fail on the client side
and disconnect the client, but the server is no worse for the wear
server 0.9.11 or newer and client 0.9.11: the server can return a
truncated array and the client will do just fine
I reproduced the problem by using a host with 2 CPUs, and doing:
virsh cpu-stats $dom --start 1 --count 2
* daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver
to omit tail of array.
* src/remote/remote_driver.c (remoteDomainGetCPUStats):
Accommodate driver that omits tail of array.
* src/libvirt.c (virDomainGetCPUStats): Document this.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Clear all
unpopulated entries.
2012-03-07 04:36:53 +00:00
|
|
|
ncpus = ret.params.params_len / ret.nparams;
|
2012-01-28 06:21:31 +00:00
|
|
|
for (cpu = 0; cpu < ncpus; cpu++) {
|
|
|
|
int tmp = nparams;
|
|
|
|
remote_typed_param *stride = &ret.params.params_val[cpu * ret.nparams];
|
|
|
|
|
|
|
|
if (remoteDeserializeTypedParameters(stride, ret.nparams,
|
|
|
|
REMOTE_NODE_CPU_STATS_MAX,
|
|
|
|
¶ms[cpu * nparams],
|
|
|
|
&tmp) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ret.nparams;
|
|
|
|
cleanup:
|
2012-01-31 03:20:40 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virTypedParameterArrayClear(params, nparams * ncpus);
|
2012-01-28 06:21:31 +00:00
|
|
|
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_cpu_stats_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2009-09-02 10:22:14 +00:00
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-04-23 20:07:44 +00:00
|
|
|
remoteGenericOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
2011-07-06 20:40:19 +00:00
|
|
|
unsigned int flags, void **genericPrivateData)
|
2007-06-11 11:43:41 +00:00
|
|
|
{
|
2007-10-27 01:23:28 +00:00
|
|
|
if (inside_daemon)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2009-09-02 10:22:14 +00:00
|
|
|
if (conn->driver &&
|
2008-02-20 15:23:36 +00:00
|
|
|
STREQ (conn->driver->name, "remote")) {
|
2009-01-20 11:41:24 +00:00
|
|
|
struct private_data *priv;
|
|
|
|
|
2011-04-23 20:07:44 +00:00
|
|
|
/* If we're here, the remote driver is already
|
2007-07-04 03:59:13 +00:00
|
|
|
* in use due to a) a QEMU uri, or b) a remote
|
2011-04-23 20:07:44 +00:00
|
|
|
* URI. So we can re-use existing connection */
|
2009-01-20 11:41:24 +00:00
|
|
|
priv = conn->privateData;
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses++;
|
2011-04-23 20:07:44 +00:00
|
|
|
*genericPrivateData = priv;
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
} else if (conn->networkDriver &&
|
|
|
|
STREQ (conn->networkDriver->name, "remote")) {
|
|
|
|
struct private_data *priv = conn->networkPrivateData;
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
*genericPrivateData = priv;
|
|
|
|
priv->localUses++;
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2007-06-11 11:43:41 +00:00
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
2007-07-04 03:59:13 +00:00
|
|
|
} else {
|
|
|
|
/* Using a non-remote driver, so we need to open a
|
|
|
|
* new connection for network APIs, forcing it to
|
2007-07-27 23:23:00 +00:00
|
|
|
* use the UNIX transport. This handles Xen driver
|
2011-04-23 20:07:44 +00:00
|
|
|
* which doesn't have its own impl of the network APIs. */
|
2008-06-06 11:09:57 +00:00
|
|
|
struct private_data *priv;
|
2011-06-02 21:45:31 +00:00
|
|
|
int ret = remoteOpenSecondaryDriver(conn, auth, flags, &priv);
|
|
|
|
*genericPrivateData = priv;
|
2007-07-04 03:59:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-04-23 20:07:44 +00:00
|
|
|
remoteGenericClose(virConnectPtr conn, void **genericPrivateData)
|
2007-07-04 03:59:13 +00:00
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = 0;
|
2011-04-23 20:07:44 +00:00
|
|
|
struct private_data *priv = *genericPrivateData;
|
2009-01-15 20:04:44 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
|
|
|
if (!priv->localUses) {
|
|
|
|
rv = doRemoteClose(conn, priv);
|
2011-04-23 20:07:44 +00:00
|
|
|
*genericPrivateData = NULL;
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
virMutexDestroy(&priv->lock);
|
|
|
|
VIR_FREE(priv);
|
2007-07-04 03:59:13 +00:00
|
|
|
}
|
2009-01-20 11:41:24 +00:00
|
|
|
if (priv)
|
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2007-06-11 11:43:41 +00:00
|
|
|
}
|
|
|
|
|
2011-04-23 20:07:44 +00:00
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-07-06 20:40:19 +00:00
|
|
|
remoteNetworkOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
unsigned int flags)
|
2011-04-23 20:07:44 +00:00
|
|
|
{
|
|
|
|
return remoteGenericOpen(conn, auth, flags, &conn->networkPrivateData);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteNetworkClose(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
return remoteGenericClose(conn, &conn->networkPrivateData);
|
|
|
|
}
|
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2009-09-02 10:22:14 +00:00
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-07-06 20:40:19 +00:00
|
|
|
remoteInterfaceOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
unsigned int flags)
|
2009-05-20 14:26:49 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericOpen(conn, auth, flags, &conn->interfacePrivateData);
|
2009-05-20 14:26:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-04-23 20:07:44 +00:00
|
|
|
remoteInterfaceClose(virConnectPtr conn)
|
2009-05-20 14:26:49 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericClose(conn, &conn->interfacePrivateData);
|
2009-05-20 14:26:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:23:36 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2009-09-02 10:22:14 +00:00
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-07-06 20:40:19 +00:00
|
|
|
remoteStorageOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
unsigned int flags)
|
2008-02-20 15:23:36 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericOpen(conn, auth, flags, &conn->storagePrivateData);
|
2008-02-20 15:23:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-04-23 20:07:44 +00:00
|
|
|
remoteStorageClose(virConnectPtr conn)
|
2008-02-20 15:23:36 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericClose(conn, &conn->storagePrivateData);
|
2008-02-20 15:23:36 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
static char *
|
|
|
|
remoteFindStoragePoolSources (virConnectPtr conn,
|
|
|
|
const char *type,
|
|
|
|
const char *srcSpec,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
char *rv = NULL;
|
2008-08-27 20:05:58 +00:00
|
|
|
remote_find_storage_pool_sources_args args;
|
|
|
|
remote_find_storage_pool_sources_ret ret;
|
2009-01-15 20:04:44 +00:00
|
|
|
struct private_data *priv = conn->storagePrivateData;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
args.type = (char*)type;
|
2012-07-31 08:56:41 +00:00
|
|
|
args.srcSpec = srcSpec ? (char **)&srcSpec : NULL;
|
2008-08-27 20:05:58 +00:00
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2008-08-27 20:05:58 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_FIND_STORAGE_POOL_SOURCES,
|
|
|
|
(xdrproc_t) xdr_remote_find_storage_pool_sources_args, (char *) &args,
|
2011-04-23 17:03:14 +00:00
|
|
|
(xdrproc_t) xdr_remote_find_storage_pool_sources_ret, (char *) &ret) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-02-20 15:23:36 +00:00
|
|
|
|
2011-04-23 17:03:14 +00:00
|
|
|
rv = ret.xml;
|
|
|
|
ret.xml = NULL; /* To stop xdr_free free'ing it */
|
|
|
|
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_find_storage_pool_sources_ret, (char *) &ret);
|
2009-01-15 20:07:10 +00:00
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2011-04-23 17:03:14 +00:00
|
|
|
return rv;
|
2008-02-20 15:23:36 +00:00
|
|
|
}
|
|
|
|
|
2008-11-21 12:31:04 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2009-09-02 10:22:14 +00:00
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-07-06 20:40:19 +00:00
|
|
|
remoteDevMonOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
unsigned int flags)
|
2008-11-21 12:31:04 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericOpen(conn, auth, flags, &conn->devMonPrivateData);
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
2011-04-23 20:07:44 +00:00
|
|
|
static int
|
|
|
|
remoteDevMonClose(virConnectPtr conn)
|
2008-11-21 12:31:04 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericClose(conn, &conn->devMonPrivateData);
|
2008-11-21 12:31:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-02 16:30:59 +00:00
|
|
|
static int
|
|
|
|
remoteNodeDeviceDettach (virNodeDevicePtr dev)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_node_device_dettach_args args;
|
2010-08-09 12:16:04 +00:00
|
|
|
/* This method is unusual in that it uses the HV driver, not the devMon driver
|
|
|
|
* hence its use of privateData, instead of devMonPrivateData */
|
2009-03-02 16:30:59 +00:00
|
|
|
struct private_data *priv = dev->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.name = dev->name;
|
|
|
|
|
|
|
|
if (call (dev->conn, priv, 0, REMOTE_PROC_NODE_DEVICE_DETTACH,
|
|
|
|
(xdrproc_t) xdr_remote_node_device_dettach_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteNodeDeviceReAttach (virNodeDevicePtr dev)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_node_device_re_attach_args args;
|
2010-08-09 12:16:04 +00:00
|
|
|
/* This method is unusual in that it uses the HV driver, not the devMon driver
|
|
|
|
* hence its use of privateData, instead of devMonPrivateData */
|
2009-03-02 16:30:59 +00:00
|
|
|
struct private_data *priv = dev->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.name = dev->name;
|
|
|
|
|
|
|
|
if (call (dev->conn, priv, 0, REMOTE_PROC_NODE_DEVICE_RE_ATTACH,
|
|
|
|
(xdrproc_t) xdr_remote_node_device_re_attach_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteNodeDeviceReset (virNodeDevicePtr dev)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_node_device_reset_args args;
|
2010-08-09 12:16:04 +00:00
|
|
|
/* This method is unusual in that it uses the HV driver, not the devMon driver
|
|
|
|
* hence its use of privateData, instead of devMonPrivateData */
|
2009-03-02 16:30:59 +00:00
|
|
|
struct private_data *priv = dev->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.name = dev->name;
|
|
|
|
|
|
|
|
if (call (dev->conn, priv, 0, REMOTE_PROC_NODE_DEVICE_RESET,
|
|
|
|
(xdrproc_t) xdr_remote_node_device_reset_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-03-25 17:46:03 +00:00
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-07-06 20:40:19 +00:00
|
|
|
remoteNWFilterOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
unsigned int flags)
|
2010-03-25 17:46:03 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericOpen(conn, auth, flags, &conn->nwfilterPrivateData);
|
2010-03-25 17:46:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-04-23 20:07:44 +00:00
|
|
|
remoteNWFilterClose(virConnectPtr conn)
|
2010-03-25 17:46:03 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericClose(conn, &conn->nwfilterPrivateData);
|
2010-03-25 17:46:03 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
static int
|
2010-04-20 19:44:31 +00:00
|
|
|
remoteAuthenticate (virConnectPtr conn, struct private_data *priv,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
2007-12-06 12:05:35 +00:00
|
|
|
const char *authtype)
|
2007-12-05 15:24:15 +00:00
|
|
|
{
|
|
|
|
struct remote_auth_list_ret ret;
|
2007-12-05 18:55:04 +00:00
|
|
|
int err, type = REMOTE_AUTH_NONE;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
2010-12-01 16:46:36 +00:00
|
|
|
err = call (conn, priv, 0,
|
2007-12-05 15:24:15 +00:00
|
|
|
REMOTE_PROC_AUTH_LIST,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_remote_auth_list_ret, (char *) &ret);
|
2010-12-01 16:46:36 +00:00
|
|
|
if (err < 0) {
|
|
|
|
virErrorPtr verr = virGetLastError();
|
|
|
|
if (verr && verr->code == VIR_ERR_NO_SUPPORT) {
|
|
|
|
/* Missing RPC - old server - ignore */
|
|
|
|
virResetLastError();
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
2010-12-01 16:46:36 +00:00
|
|
|
}
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
if (ret.types.types_len == 0)
|
|
|
|
return 0;
|
|
|
|
|
2007-12-05 18:55:04 +00:00
|
|
|
if (authtype) {
|
|
|
|
int want, i;
|
|
|
|
if (STRCASEEQ(authtype, "sasl") ||
|
|
|
|
STRCASEEQLEN(authtype, "sasl.", 5)) {
|
|
|
|
want = REMOTE_AUTH_SASL;
|
|
|
|
} else if (STRCASEEQ(authtype, "polkit")) {
|
|
|
|
want = REMOTE_AUTH_POLKIT;
|
|
|
|
} else {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
|
_("unknown authentication type %s"), authtype);
|
2007-12-05 18:55:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
for (i = 0 ; i < ret.types.types_len ; i++) {
|
|
|
|
if (ret.types.types_val[i] == want)
|
|
|
|
type = want;
|
|
|
|
}
|
|
|
|
if (type == REMOTE_AUTH_NONE) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
|
_("requested authentication type %s rejected"),
|
|
|
|
authtype);
|
2007-12-05 18:55:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
type = ret.types.types_val[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
2007-12-05 15:24:15 +00:00
|
|
|
#if HAVE_SASL
|
2007-12-05 18:55:04 +00:00
|
|
|
case REMOTE_AUTH_SASL: {
|
|
|
|
const char *mech = NULL;
|
|
|
|
if (authtype &&
|
|
|
|
STRCASEEQLEN(authtype, "sasl.", 5))
|
|
|
|
mech = authtype + 5;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (remoteAuthSASL(conn, priv, auth, mech) < 0) {
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(ret.types.types_val);
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
2007-12-05 18:55:04 +00:00
|
|
|
}
|
2007-12-05 15:24:15 +00:00
|
|
|
#endif
|
|
|
|
|
2007-12-05 18:21:27 +00:00
|
|
|
#if HAVE_POLKIT
|
|
|
|
case REMOTE_AUTH_POLKIT:
|
2010-12-01 16:46:36 +00:00
|
|
|
if (remoteAuthPolkit(conn, priv, auth) < 0) {
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(ret.types.types_val);
|
2007-12-05 18:21:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
case REMOTE_AUTH_NONE:
|
|
|
|
/* Nothing todo, hurrah ! */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
|
_("unsupported authentication type %d"),
|
|
|
|
ret.types.types_val[0]);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(ret.types.types_val);
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(ret.types.types_val);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_SASL
|
2007-12-05 18:55:04 +00:00
|
|
|
static int remoteAuthCredVir2SASL(int vircred)
|
|
|
|
{
|
|
|
|
switch (vircred) {
|
|
|
|
case VIR_CRED_USERNAME:
|
|
|
|
return SASL_CB_USER;
|
|
|
|
|
|
|
|
case VIR_CRED_AUTHNAME:
|
|
|
|
return SASL_CB_AUTHNAME;
|
|
|
|
|
|
|
|
case VIR_CRED_LANGUAGE:
|
|
|
|
return SASL_CB_LANGUAGE;
|
|
|
|
|
|
|
|
case VIR_CRED_CNONCE:
|
|
|
|
return SASL_CB_CNONCE;
|
|
|
|
|
|
|
|
case VIR_CRED_PASSPHRASE:
|
|
|
|
return SASL_CB_PASS;
|
|
|
|
|
|
|
|
case VIR_CRED_ECHOPROMPT:
|
|
|
|
return SASL_CB_ECHOPROMPT;
|
|
|
|
|
|
|
|
case VIR_CRED_NOECHOPROMPT:
|
|
|
|
return SASL_CB_NOECHOPROMPT;
|
|
|
|
|
|
|
|
case VIR_CRED_REALM:
|
|
|
|
return SASL_CB_GETREALM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int remoteAuthCredSASL2Vir(int vircred)
|
|
|
|
{
|
|
|
|
switch (vircred) {
|
|
|
|
case SASL_CB_USER:
|
|
|
|
return VIR_CRED_USERNAME;
|
|
|
|
|
|
|
|
case SASL_CB_AUTHNAME:
|
|
|
|
return VIR_CRED_AUTHNAME;
|
|
|
|
|
|
|
|
case SASL_CB_LANGUAGE:
|
|
|
|
return VIR_CRED_LANGUAGE;
|
|
|
|
|
|
|
|
case SASL_CB_CNONCE:
|
|
|
|
return VIR_CRED_CNONCE;
|
|
|
|
|
|
|
|
case SASL_CB_PASS:
|
|
|
|
return VIR_CRED_PASSPHRASE;
|
|
|
|
|
|
|
|
case SASL_CB_ECHOPROMPT:
|
|
|
|
return VIR_CRED_ECHOPROMPT;
|
|
|
|
|
|
|
|
case SASL_CB_NOECHOPROMPT:
|
|
|
|
return VIR_CRED_NOECHOPROMPT;
|
|
|
|
|
|
|
|
case SASL_CB_GETREALM:
|
|
|
|
return VIR_CRED_REALM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @param credtype array of credential types client supports
|
|
|
|
* @param ncredtype size of credtype array
|
|
|
|
* @return the SASL callback structure, or NULL on error
|
|
|
|
*
|
|
|
|
* Build up the SASL callback structure. We register one callback for
|
|
|
|
* each credential type that the libvirt client indicated they support.
|
|
|
|
* We explicitly leav the callback function pointer at NULL though,
|
|
|
|
* because we don't actually want to get SASL callbacks triggered.
|
|
|
|
* Instead, we want the start/step functions to return SASL_INTERACT.
|
|
|
|
* This lets us give the libvirt client a list of all required
|
|
|
|
* credentials in one go, rather than triggering the callback one
|
|
|
|
* credential at a time,
|
|
|
|
*/
|
|
|
|
static sasl_callback_t *remoteAuthMakeCallbacks(int *credtype, int ncredtype)
|
|
|
|
{
|
2008-06-06 11:09:57 +00:00
|
|
|
sasl_callback_t *cbs;
|
2007-12-05 18:55:04 +00:00
|
|
|
int i, n;
|
2008-06-06 11:09:57 +00:00
|
|
|
if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) {
|
2007-12-05 18:55:04 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, n = 0 ; i < ncredtype ; i++) {
|
|
|
|
int id = remoteAuthCredVir2SASL(credtype[i]);
|
|
|
|
if (id != 0)
|
|
|
|
cbs[n++].id = id;
|
|
|
|
/* Don't fill proc or context fields of sasl_callback_t
|
|
|
|
* because we want to use interactions instead */
|
|
|
|
}
|
|
|
|
cbs[n].id = 0;
|
|
|
|
return cbs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @param interact SASL interactions required
|
|
|
|
* @param cred populated with libvirt credential metadata
|
|
|
|
* @return the size of the cred array returned
|
2007-12-05 15:24:15 +00:00
|
|
|
*
|
2007-12-05 18:55:04 +00:00
|
|
|
* Builds up an array of libvirt credential structs, populating
|
|
|
|
* with data from the SASL interaction struct. These two structs
|
|
|
|
* are basically a 1-to-1 copy of each other.
|
|
|
|
*/
|
|
|
|
static int remoteAuthMakeCredentials(sasl_interact_t *interact,
|
2012-03-19 17:26:21 +00:00
|
|
|
virConnectCredentialPtr *cred,
|
|
|
|
size_t *ncred)
|
2007-12-05 18:55:04 +00:00
|
|
|
{
|
|
|
|
int ninteract;
|
|
|
|
if (!cred)
|
|
|
|
return -1;
|
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
for (ninteract = 0, *ncred = 0 ; interact[ninteract].id != 0 ; ninteract++) {
|
|
|
|
if (interact[ninteract].result)
|
|
|
|
continue;
|
|
|
|
(*ncred)++;
|
|
|
|
}
|
2007-12-05 18:55:04 +00:00
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
if (VIR_ALLOC_N(*cred, *ncred) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
return -1;
|
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
for (ninteract = 0, *ncred = 0 ; interact[ninteract].id != 0 ; ninteract++) {
|
|
|
|
if (interact[ninteract].result)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(*cred)[*ncred].type = remoteAuthCredSASL2Vir(interact[ninteract].id);
|
|
|
|
if (!(*cred)[*ncred].type) {
|
|
|
|
*ncred = 0;
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(*cred);
|
2007-12-05 18:55:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2012-03-20 11:11:10 +00:00
|
|
|
if (interact[*ncred].challenge)
|
|
|
|
(*cred)[*ncred].challenge = interact[ninteract].challenge;
|
|
|
|
(*cred)[*ncred].prompt = interact[ninteract].prompt;
|
|
|
|
if (interact[*ncred].defresult)
|
|
|
|
(*cred)[*ncred].defresult = interact[ninteract].defresult;
|
|
|
|
(*cred)[*ncred].result = NULL;
|
|
|
|
|
|
|
|
(*ncred)++;
|
2007-12-05 18:55:04 +00:00
|
|
|
}
|
|
|
|
|
2012-03-19 17:26:21 +00:00
|
|
|
return 0;
|
2007-12-05 18:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @param cred the populated libvirt credentials
|
|
|
|
* @param interact the SASL interactions to fill in results for
|
|
|
|
*
|
|
|
|
* Fills the SASL interactions with the result from the libvirt
|
|
|
|
* callbacks
|
|
|
|
*/
|
|
|
|
static void remoteAuthFillInteract(virConnectCredentialPtr cred,
|
|
|
|
sasl_interact_t *interact)
|
|
|
|
{
|
2012-03-20 11:11:10 +00:00
|
|
|
int ninteract, ncred;
|
|
|
|
for (ninteract = 0, ncred = 0 ; interact[ninteract].id != 0 ; ninteract++) {
|
|
|
|
if (interact[ninteract].result)
|
|
|
|
continue;
|
|
|
|
interact[ninteract].result = cred[ncred].result;
|
|
|
|
interact[ninteract].len = cred[ncred].resultlen;
|
|
|
|
ncred++;
|
2007-12-05 18:55:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-19 17:26:21 +00:00
|
|
|
struct remoteAuthInteractState {
|
|
|
|
sasl_interact_t *interact;
|
|
|
|
virConnectCredentialPtr cred;
|
|
|
|
size_t ncred;
|
2012-03-20 11:11:10 +00:00
|
|
|
virAuthConfigPtr config;
|
2012-03-19 17:26:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
|
|
|
|
static int remoteAuthFillFromConfig(virConnectPtr conn,
|
|
|
|
struct remoteAuthInteractState *state)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
int ninteract;
|
|
|
|
const char *credname;
|
|
|
|
char *path = NULL;
|
|
|
|
|
|
|
|
VIR_DEBUG("Trying to fill auth parameters from config file");
|
|
|
|
|
|
|
|
if (!state->config) {
|
|
|
|
if (virAuthGetConfigFilePath(conn, &path) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
if (path == NULL) {
|
|
|
|
ret = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(state->config = virAuthConfigNew(path)))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ninteract = 0 ; state->interact[ninteract].id != 0 ; ninteract++) {
|
|
|
|
const char *value = NULL;
|
|
|
|
|
|
|
|
switch (state->interact[ninteract].id) {
|
|
|
|
case SASL_CB_USER:
|
|
|
|
credname = "username";
|
|
|
|
break;
|
|
|
|
case SASL_CB_AUTHNAME:
|
|
|
|
credname = "authname";
|
|
|
|
break;
|
|
|
|
case SASL_CB_PASS:
|
|
|
|
credname = "password";
|
|
|
|
break;
|
|
|
|
case SASL_CB_GETREALM:
|
|
|
|
credname = "realm";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
credname = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virAuthConfigLookup(state->config,
|
|
|
|
"libvirt",
|
|
|
|
conn->uri->server,
|
|
|
|
credname,
|
|
|
|
&value) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
state->interact[ninteract].result = value;
|
|
|
|
state->interact[ninteract].len = strlen(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(path);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void remoteAuthInteractStateClear(struct remoteAuthInteractState *state,
|
|
|
|
bool final)
|
2012-03-19 17:26:21 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
if (!state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0 ; i < state->ncred ; i++)
|
|
|
|
VIR_FREE(state->cred[i].result);
|
|
|
|
VIR_FREE(state->cred);
|
|
|
|
state->ncred = 0;
|
2012-03-20 11:11:10 +00:00
|
|
|
|
|
|
|
if (final)
|
|
|
|
virAuthConfigFree(state->config);
|
2012-03-19 17:26:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
static int remoteAuthInteract(virConnectPtr conn,
|
|
|
|
struct remoteAuthInteractState *state,
|
2012-03-19 17:26:21 +00:00
|
|
|
virConnectAuthPtr auth)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
VIR_DEBUG("Starting SASL interaction");
|
|
|
|
remoteAuthInteractStateClear(state, false);
|
|
|
|
|
|
|
|
if (remoteAuthFillFromConfig(conn, state) < 0)
|
|
|
|
goto cleanup;
|
2012-03-19 17:26:21 +00:00
|
|
|
|
|
|
|
if (remoteAuthMakeCredentials(state->interact, &state->cred, &state->ncred) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("Failed to make auth credentials"));
|
2012-03-19 17:26:21 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Run the authentication callback */
|
|
|
|
if (!auth || !auth->cb) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("No authentication callback available"));
|
2012-03-19 17:26:21 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*(auth->cb))(state->cred, state->ncred, auth->cbdata) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("Failed to collect auth credentials"));
|
2012-03-19 17:26:21 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
remoteAuthFillInteract(state->cred, state->interact);
|
|
|
|
/*
|
|
|
|
* 'interact' now has pointers to strings in 'state->cred'
|
|
|
|
* so we must not free state->cred until the *next*
|
|
|
|
* sasl_start/step function is complete. Hence we
|
|
|
|
* call remoteAuthInteractStateClear() at the *start*
|
|
|
|
* of this method, rather than the end.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-05 18:55:04 +00:00
|
|
|
/* Perform the SASL authentication process
|
2007-12-05 15:24:15 +00:00
|
|
|
*/
|
|
|
|
static int
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteAuthSASL (virConnectPtr conn, struct private_data *priv,
|
2007-12-05 18:55:04 +00:00
|
|
|
virConnectAuthPtr auth, const char *wantmech)
|
2007-12-05 15:24:15 +00:00
|
|
|
{
|
|
|
|
remote_auth_sasl_init_ret iret;
|
|
|
|
remote_auth_sasl_start_args sargs;
|
|
|
|
remote_auth_sasl_start_ret sret;
|
|
|
|
remote_auth_sasl_step_args pargs;
|
|
|
|
remote_auth_sasl_step_ret pret;
|
|
|
|
const char *clientout;
|
2007-12-05 18:55:04 +00:00
|
|
|
char *serverin = NULL;
|
2010-12-01 16:46:36 +00:00
|
|
|
size_t clientoutlen, serverinlen;
|
2007-12-05 15:24:15 +00:00
|
|
|
const char *mech;
|
|
|
|
int err, complete;
|
2010-12-01 16:46:36 +00:00
|
|
|
int ssf;
|
2007-12-05 18:55:04 +00:00
|
|
|
sasl_callback_t *saslcb = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
const char *mechlist;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetSASLContextPtr saslCtxt;
|
2011-06-28 18:17:00 +00:00
|
|
|
virNetSASLSessionPtr sasl = NULL;
|
2012-03-19 17:26:21 +00:00
|
|
|
struct remoteAuthInteractState state;
|
|
|
|
|
|
|
|
memset(&state, 0, sizeof(state));
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Client initialize SASL authentication");
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(saslCtxt = virNetSASLContextNewClient()))
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2008-01-14 04:00:34 +00:00
|
|
|
if (auth) {
|
|
|
|
if ((saslcb = remoteAuthMakeCallbacks(auth->credtype, auth->ncredtype)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
} else {
|
|
|
|
saslcb = NULL;
|
|
|
|
}
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
/* Setup a handle for being a client */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(sasl = virNetSASLSessionNewClient(saslCtxt,
|
|
|
|
"libvirt",
|
|
|
|
priv->hostname,
|
|
|
|
virNetClientLocalAddrString(priv->client),
|
|
|
|
virNetClientRemoteAddrString(priv->client),
|
|
|
|
saslcb)))
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2007-12-05 15:27:08 +00:00
|
|
|
/* Initialize some connection props we care about */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (priv->tls) {
|
|
|
|
if ((ssf = virNetClientGetTLSKeySize(priv->client)) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2007-12-05 15:27:08 +00:00
|
|
|
ssf *= 8; /* key size is bytes, sasl wants bits */
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("Setting external SSF %d", ssf);
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetSASLSessionExtKeySize(sasl, ssf) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
|
|
|
|
2010-09-14 18:17:25 +00:00
|
|
|
/* If we've got a secure channel (TLS or UNIX sock), we don't care about SSF */
|
|
|
|
/* If we're not secure, then forbid any anonymous or trivially crackable auth */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetSASLSessionSecProps(sasl,
|
|
|
|
priv->is_secure ? 0 : 56, /* Equiv to DES supported by all Kerberos */
|
|
|
|
priv->is_secure ? 0 : 100000, /* Very strong ! AES == 256 */
|
|
|
|
priv->is_secure ? true : false) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
/* First call is to inquire about supported mechanisms in the server */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&iret, 0, sizeof(iret));
|
2010-12-01 16:46:36 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_AUTH_SASL_INIT,
|
2007-12-05 15:24:15 +00:00
|
|
|
(xdrproc_t) xdr_void, (char *)NULL,
|
2007-12-05 18:55:04 +00:00
|
|
|
(xdrproc_t) xdr_remote_auth_sasl_init_ret, (char *) &iret) != 0)
|
|
|
|
goto cleanup;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
|
2007-12-05 18:55:04 +00:00
|
|
|
mechlist = iret.mechlist;
|
|
|
|
if (wantmech) {
|
|
|
|
if (strstr(mechlist, wantmech) == NULL) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
|
_("SASL mechanism %s not supported by server"),
|
|
|
|
wantmech);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(iret.mechlist);
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
mechlist = wantmech;
|
|
|
|
}
|
|
|
|
restart:
|
2007-12-05 15:24:15 +00:00
|
|
|
/* Start the auth negotiation on the client end first */
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("Client start negotiation mechlist '%s'", mechlist);
|
2010-12-01 16:46:36 +00:00
|
|
|
if ((err = virNetSASLSessionClientStart(sasl,
|
|
|
|
mechlist,
|
2012-03-19 17:26:21 +00:00
|
|
|
&state.interact,
|
2010-12-01 16:46:36 +00:00
|
|
|
&clientout,
|
|
|
|
&clientoutlen,
|
|
|
|
&mech)) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Need to gather some credentials from the client */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (err == VIR_NET_SASL_INTERACT) {
|
2012-03-20 11:11:10 +00:00
|
|
|
if (remoteAuthInteract(conn, &state, auth) < 0) {
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(iret.mechlist);
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-03-19 17:26:21 +00:00
|
|
|
goto restart;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(iret.mechlist);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
if (clientoutlen > REMOTE_AUTH_SASL_DATA_MAX) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
|
_("SASL negotiation data too long: %zu bytes"),
|
|
|
|
clientoutlen);
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&sargs, 0, sizeof(sargs));
|
2007-12-05 15:24:15 +00:00
|
|
|
sargs.nil = clientout ? 0 : 1;
|
|
|
|
sargs.data.data_val = (char*)clientout;
|
|
|
|
sargs.data.data_len = clientoutlen;
|
|
|
|
sargs.mech = (char*)mech;
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Server start negotiation with mech %s. Data %zu bytes %p",
|
|
|
|
mech, clientoutlen, clientout);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
/* Now send the initial auth data to the server */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&sret, 0, sizeof(sret));
|
2010-12-01 16:46:36 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_AUTH_SASL_START,
|
2007-12-05 15:24:15 +00:00
|
|
|
(xdrproc_t) xdr_remote_auth_sasl_start_args, (char *) &sargs,
|
2007-12-05 18:55:04 +00:00
|
|
|
(xdrproc_t) xdr_remote_auth_sasl_start_ret, (char *) &sret) != 0)
|
|
|
|
goto cleanup;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
complete = sret.complete;
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
serverin = sret.nil ? NULL : sret.data.data_val;
|
|
|
|
serverinlen = sret.data.data_len;
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Client step result complete: %d. Data %zu bytes %p",
|
|
|
|
complete, serverinlen, serverin);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
/* Loop-the-loop...
|
|
|
|
* Even if the server has completed, the client must *always* do at least one step
|
2008-04-04 07:58:29 +00:00
|
|
|
* in this loop to verify the server isn't lying about something. Mutual auth */
|
2007-12-05 15:24:15 +00:00
|
|
|
for (;;) {
|
2007-12-05 18:55:04 +00:00
|
|
|
restep:
|
2010-12-01 16:46:36 +00:00
|
|
|
if ((err = virNetSASLSessionClientStep(sasl,
|
|
|
|
serverin,
|
|
|
|
serverinlen,
|
2012-03-19 17:26:21 +00:00
|
|
|
&state.interact,
|
2010-12-01 16:46:36 +00:00
|
|
|
&clientout,
|
|
|
|
&clientoutlen)) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2007-12-05 18:55:04 +00:00
|
|
|
/* Need to gather some credentials from the client */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (err == VIR_NET_SASL_INTERACT) {
|
2012-03-20 11:11:10 +00:00
|
|
|
if (remoteAuthInteract(conn, &state, auth) < 0) {
|
2012-03-19 17:26:21 +00:00
|
|
|
VIR_FREE(iret.mechlist);
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-03-19 17:26:21 +00:00
|
|
|
goto restep;
|
2007-12-05 18:55:04 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 13:08:07 +00:00
|
|
|
VIR_FREE(serverin);
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Client step result %d. Data %zu bytes %p",
|
|
|
|
err, clientoutlen, clientout);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
/* Previous server call showed completion & we're now locally complete too */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (complete && err == VIR_NET_SASL_COMPLETE)
|
2007-12-05 15:24:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Not done, prepare to talk with the server for another iteration */
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&pargs, 0, sizeof(pargs));
|
2007-12-05 15:24:15 +00:00
|
|
|
pargs.nil = clientout ? 0 : 1;
|
|
|
|
pargs.data.data_val = (char*)clientout;
|
|
|
|
pargs.data.data_len = clientoutlen;
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Server step with %zu bytes %p",
|
|
|
|
clientoutlen, clientout);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&pret, 0, sizeof(pret));
|
2010-12-01 16:46:36 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_AUTH_SASL_STEP,
|
2007-12-05 15:24:15 +00:00
|
|
|
(xdrproc_t) xdr_remote_auth_sasl_step_args, (char *) &pargs,
|
2007-12-05 18:55:04 +00:00
|
|
|
(xdrproc_t) xdr_remote_auth_sasl_step_ret, (char *) &pret) != 0)
|
|
|
|
goto cleanup;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
complete = pret.complete;
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
serverin = pret.nil ? NULL : pret.data.data_val;
|
|
|
|
serverinlen = pret.data.data_len;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
VIR_DEBUG("Client step result complete: %d. Data %zu bytes %p",
|
|
|
|
complete, serverinlen, serverin);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
/* This server call shows complete, and earlier client step was OK */
|
2010-12-01 16:46:36 +00:00
|
|
|
if (complete && err == VIR_NET_SASL_COMPLETE) {
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(serverin);
|
2007-12-05 15:24:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-14 18:17:25 +00:00
|
|
|
/* Check for suitable SSF if not already secure (TLS or UNIX sock) */
|
|
|
|
if (!priv->is_secure) {
|
2010-12-01 16:46:36 +00:00
|
|
|
if ((ssf = virNetSASLSessionGetKeySize(sasl)) < 0)
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("SASL SSF value %d", ssf);
|
2007-12-05 15:27:08 +00:00
|
|
|
if (ssf < 56) { /* 56 == DES level, good for Kerberos */
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
|
_("negotiation SSF %d was not strong enough"), ssf);
|
2007-12-05 18:55:04 +00:00
|
|
|
goto cleanup;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
priv->is_secure = 1;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
|
|
|
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("SASL authentication complete");
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientSetSASLSession(priv->client, sasl);
|
2007-12-05 18:55:04 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(serverin);
|
2007-12-05 18:55:04 +00:00
|
|
|
|
2012-03-20 11:11:10 +00:00
|
|
|
remoteAuthInteractStateClear(&state, true);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(saslcb);
|
2012-07-11 13:35:49 +00:00
|
|
|
virObjectUnref(sasl);
|
|
|
|
virObjectUnref(saslCtxt);
|
2009-01-15 20:07:10 +00:00
|
|
|
|
2007-12-05 18:55:04 +00:00
|
|
|
return ret;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
#endif /* HAVE_SASL */
|
|
|
|
|
2007-12-05 18:55:04 +00:00
|
|
|
|
|
|
|
#if HAVE_POLKIT
|
2010-03-09 18:22:22 +00:00
|
|
|
# if HAVE_POLKIT1
|
2009-08-25 16:18:27 +00:00
|
|
|
static int
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteAuthPolkit (virConnectPtr conn, struct private_data *priv,
|
2009-08-25 16:18:27 +00:00
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
remote_auth_polkit_ret ret;
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Client initialize PolicyKit-1 authentication");
|
2009-08-25 16:18:27 +00:00
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2010-12-01 16:46:36 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_AUTH_POLKIT,
|
2009-08-25 16:18:27 +00:00
|
|
|
(xdrproc_t) xdr_void, (char *)NULL,
|
|
|
|
(xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) {
|
|
|
|
return -1; /* virError already set by call */
|
|
|
|
}
|
|
|
|
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("PolicyKit-1 authentication complete");
|
2009-08-25 16:18:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-03-09 18:22:22 +00:00
|
|
|
# elif HAVE_POLKIT0
|
2007-12-05 18:55:04 +00:00
|
|
|
/* Perform the PolicyKit authentication process
|
|
|
|
*/
|
|
|
|
static int
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteAuthPolkit (virConnectPtr conn, struct private_data *priv,
|
2007-12-05 18:55:04 +00:00
|
|
|
virConnectAuthPtr auth)
|
|
|
|
{
|
|
|
|
remote_auth_polkit_ret ret;
|
2007-12-15 17:15:12 +00:00
|
|
|
int i, allowcb = 0;
|
2007-12-05 18:55:04 +00:00
|
|
|
virConnectCredential cred = {
|
|
|
|
VIR_CRED_EXTERNAL,
|
|
|
|
conn->flags & VIR_CONNECT_RO ? "org.libvirt.unix.monitor" : "org.libvirt.unix.manage",
|
|
|
|
"PolicyKit",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
};
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Client initialize PolicyKit-0 authentication");
|
2007-12-05 18:55:04 +00:00
|
|
|
|
2012-01-03 18:35:06 +00:00
|
|
|
/* Check auth first and if it succeeds we are done. */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2012-01-03 18:35:06 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_AUTH_POLKIT,
|
|
|
|
(xdrproc_t) xdr_void, (char *)NULL,
|
|
|
|
(xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Auth failed. Ask client to obtain it and check again. */
|
2008-01-02 22:48:04 +00:00
|
|
|
if (auth && auth->cb) {
|
2008-03-17 10:27:31 +00:00
|
|
|
/* Check if the necessary credential type for PolicyKit is supported */
|
2008-01-02 22:48:04 +00:00
|
|
|
for (i = 0 ; i < auth->ncredtype ; i++) {
|
|
|
|
if (auth->credtype[i] == VIR_CRED_EXTERNAL)
|
|
|
|
allowcb = 1;
|
|
|
|
}
|
2007-12-15 17:15:12 +00:00
|
|
|
|
2008-01-02 22:48:04 +00:00
|
|
|
if (allowcb) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Client run callback for PolicyKit authentication");
|
2008-01-02 22:48:04 +00:00
|
|
|
/* Run the authentication callback */
|
|
|
|
if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("Failed to collect auth credentials"));
|
2008-01-02 22:48:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-12-15 17:15:12 +00:00
|
|
|
} else {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Client auth callback does not support PolicyKit");
|
2012-01-03 18:35:06 +00:00
|
|
|
return -1;
|
2007-12-15 17:15:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("No auth callback provided");
|
2012-01-03 18:35:06 +00:00
|
|
|
return -1;
|
2007-12-05 18:55:04 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2010-12-01 16:46:36 +00:00
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_AUTH_POLKIT,
|
2007-12-05 18:55:04 +00:00
|
|
|
(xdrproc_t) xdr_void, (char *)NULL,
|
|
|
|
(xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) {
|
|
|
|
return -1; /* virError already set by call */
|
|
|
|
}
|
|
|
|
|
2012-01-03 18:35:06 +00:00
|
|
|
out:
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("PolicyKit-0 authentication complete");
|
2007-12-05 18:55:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-03-09 18:22:22 +00:00
|
|
|
# endif /* HAVE_POLKIT0 */
|
2007-12-05 18:55:04 +00:00
|
|
|
#endif /* HAVE_POLKIT */
|
2008-10-23 13:18:18 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
static int remoteDomainEventRegister(virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freecb)
|
2008-10-23 13:18:18 +00:00
|
|
|
{
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2008-10-23 13:18:18 +00:00
|
|
|
struct private_data *priv = conn->privateData;
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
int count;
|
2008-10-23 13:18:18 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if ((count = virDomainEventStateRegister(conn, priv->domainEventState,
|
|
|
|
callback, opaque, freecb)) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s", _("adding cb to list"));
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
|
|
|
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
if (count == 1) {
|
2008-10-23 13:18:18 +00:00
|
|
|
/* Tell the server when we are the first callback deregistering */
|
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_DOMAIN_EVENTS_REGISTER,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
2009-01-15 20:07:10 +00:00
|
|
|
goto done;
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
|
|
|
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
static int remoteDomainEventDeregister(virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback)
|
2008-10-23 13:18:18 +00:00
|
|
|
{
|
|
|
|
struct private_data *priv = conn->privateData;
|
2009-01-15 20:07:10 +00:00
|
|
|
int rv = -1;
|
2011-12-13 11:14:46 +00:00
|
|
|
int count;
|
2008-10-23 13:18:18 +00:00
|
|
|
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if ((count = virDomainEventStateDeregister(conn,
|
|
|
|
priv->domainEventState,
|
|
|
|
callback)) < 0)
|
2011-05-13 15:00:10 +00:00
|
|
|
goto done;
|
2009-07-28 16:45:19 +00:00
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if (count == 0) {
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
/* Tell the server when we are the last callback deregistering */
|
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_DOMAIN_EVENTS_DEREGISTER,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
|
|
|
goto done;
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 20:07:10 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
2009-01-20 11:41:24 +00:00
|
|
|
remoteDriverUnlock(priv);
|
2009-01-15 20:07:10 +00:00
|
|
|
return rv;
|
2008-10-23 13:18:18 +00:00
|
|
|
}
|
2007-12-05 18:55:04 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_lifecycle_msg *msg = evdata;
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
event = virDomainEventNewFromDom(dom, msg->event, msg->detail);
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventReboot(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
2010-03-18 15:25:38 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_reboot_msg *msg = evdata;
|
2010-03-18 15:25:38 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
2010-03-18 15:25:38 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
2010-03-18 15:25:38 +00:00
|
|
|
|
|
|
|
event = virDomainEventRebootNewFromDom(dom);
|
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
2010-03-18 15:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventRTCChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
2010-03-18 18:28:15 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_rtc_change_msg *msg = evdata;
|
2010-03-18 18:28:15 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
2010-03-18 18:28:15 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
2010-03-18 18:28:15 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
event = virDomainEventRTCChangeNewFromDom(dom, msg->offset);
|
2010-03-18 18:28:15 +00:00
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
2010-03-18 18:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventWatchdog(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_watchdog_msg *msg = evdata;
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
event = virDomainEventWatchdogNewFromDom(dom, msg->action);
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventIOError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_io_error_msg *msg = evdata;
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
|
|
|
|
event = virDomainEventIOErrorNewFromDom(dom,
|
2010-12-01 16:46:36 +00:00
|
|
|
msg->srcPath,
|
|
|
|
msg->devAlias,
|
|
|
|
msg->action);
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventIOErrorReason(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_io_error_reason_msg *msg = evdata;
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn,msg->dom);
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
|
|
|
|
event = virDomainEventIOErrorReasonNewFromDom(dom,
|
2010-12-01 16:46:36 +00:00
|
|
|
msg->srcPath,
|
|
|
|
msg->devAlias,
|
|
|
|
msg->action,
|
|
|
|
msg->reason);
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
|
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
}
|
|
|
|
|
2011-07-22 05:57:42 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventBlockJob(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_block_job_msg *msg = evdata;
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
|
|
|
if (!dom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = virDomainEventBlockJobNewFromDom(dom, msg->path, msg->type,
|
|
|
|
msg->status);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
}
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventGraphics(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_graphics_msg *msg = evdata;
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
virDomainEventGraphicsAddressPtr localAddr = NULL;
|
|
|
|
virDomainEventGraphicsAddressPtr remoteAddr = NULL;
|
|
|
|
virDomainEventGraphicsSubjectPtr subject = NULL;
|
|
|
|
int i;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
|
|
|
|
if (VIR_ALLOC(localAddr) < 0)
|
|
|
|
goto no_memory;
|
2010-12-01 16:46:36 +00:00
|
|
|
localAddr->family = msg->local.family;
|
|
|
|
if (!(localAddr->service = strdup(msg->local.service)) ||
|
|
|
|
!(localAddr->node = strdup(msg->local.node)))
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(remoteAddr) < 0)
|
|
|
|
goto no_memory;
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteAddr->family = msg->remote.family;
|
|
|
|
if (!(remoteAddr->service = strdup(msg->remote.service)) ||
|
|
|
|
!(remoteAddr->node = strdup(msg->remote.node)))
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(subject) < 0)
|
|
|
|
goto no_memory;
|
2010-12-01 16:46:36 +00:00
|
|
|
if (VIR_ALLOC_N(subject->identities, msg->subject.subject_len) < 0)
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
goto no_memory;
|
2010-12-01 16:46:36 +00:00
|
|
|
subject->nidentity = msg->subject.subject_len;
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
for (i = 0 ; i < subject->nidentity ; i++) {
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(subject->identities[i].type = strdup(msg->subject.subject_val[i].type)) ||
|
|
|
|
!(subject->identities[i].name = strdup(msg->subject.subject_val[i].name)))
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
goto no_memory;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = virDomainEventGraphicsNewFromDom(dom,
|
2010-12-01 16:46:36 +00:00
|
|
|
msg->phase,
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
localAddr,
|
|
|
|
remoteAddr,
|
2010-12-01 16:46:36 +00:00
|
|
|
msg->authScheme,
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
subject);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
return;
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
no_memory:
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
if (localAddr) {
|
|
|
|
VIR_FREE(localAddr->service);
|
|
|
|
VIR_FREE(localAddr->node);
|
|
|
|
VIR_FREE(localAddr);
|
|
|
|
}
|
|
|
|
if (remoteAddr) {
|
|
|
|
VIR_FREE(remoteAddr->service);
|
|
|
|
VIR_FREE(remoteAddr->node);
|
|
|
|
VIR_FREE(remoteAddr);
|
|
|
|
}
|
|
|
|
if (subject) {
|
|
|
|
for (i = 0 ; i < subject->nidentity ; i++) {
|
|
|
|
VIR_FREE(subject->identities[i].type);
|
|
|
|
VIR_FREE(subject->identities[i].name);
|
|
|
|
}
|
|
|
|
VIR_FREE(subject->identities);
|
|
|
|
VIR_FREE(subject);
|
|
|
|
}
|
2011-09-18 16:36:12 +00:00
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 13:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventControlError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
2011-05-29 12:21:53 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_control_error_msg *msg = evdata;
|
2011-05-29 12:21:53 +00:00
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
2011-05-29 12:21:53 +00:00
|
|
|
if (!dom)
|
2010-12-01 16:46:36 +00:00
|
|
|
return;
|
2011-05-29 12:21:53 +00:00
|
|
|
|
|
|
|
event = virDomainEventControlErrorNewFromDom(dom);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
2010-12-01 16:46:36 +00:00
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
2011-05-29 12:21:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-18 14:15:42 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventDiskChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_disk_change_msg *msg = evdata;
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
|
|
|
if (!dom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = virDomainEventDiskChangeNewFromDom(dom,
|
|
|
|
msg->oldSrcPath ? *msg->oldSrcPath : NULL,
|
|
|
|
msg->newSrcPath ? *msg->newSrcPath : NULL,
|
|
|
|
msg->devAlias,
|
|
|
|
msg->reason);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-23 13:44:50 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventTrayChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_tray_change_msg *msg = evdata;
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
|
|
|
if (!dom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = virDomainEventTrayChangeNewFromDom(dom,
|
|
|
|
msg->devAlias,
|
|
|
|
msg->reason);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
}
|
|
|
|
|
2012-03-23 14:43:14 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventPMWakeup(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_pmwakeup_msg *msg = evdata;
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
|
|
|
if (!dom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = virDomainEventPMWakeupNewFromDom(dom);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
}
|
2012-03-23 13:44:50 +00:00
|
|
|
|
2012-03-23 14:50:36 +00:00
|
|
|
static void
|
|
|
|
remoteDomainBuildEventPMSuspend(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_pmsuspend_msg *msg = evdata;
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
|
|
|
if (!dom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = virDomainEventPMSuspendNewFromDom(dom);
|
|
|
|
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
}
|
|
|
|
|
2012-07-13 09:05:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
remoteDomainBuildEventBalloonChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
|
|
|
|
virNetClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
void *evdata, void *opaque)
|
|
|
|
{
|
|
|
|
virConnectPtr conn = opaque;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_event_balloon_change_msg *msg = evdata;
|
|
|
|
virDomainPtr dom;
|
|
|
|
virDomainEventPtr event = NULL;
|
|
|
|
|
|
|
|
dom = get_nonnull_domain(conn, msg->dom);
|
|
|
|
if (!dom)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event = virDomainEventBalloonChangeNewFromDom(dom, msg->actual);
|
|
|
|
virDomainFree(dom);
|
|
|
|
|
|
|
|
remoteDomainEventQueue(priv, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-02 10:22:14 +00:00
|
|
|
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
|
2011-07-06 20:40:19 +00:00
|
|
|
remoteSecretOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
unsigned int flags)
|
2009-07-28 02:46:01 +00:00
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericOpen(conn, auth, flags, &conn->secretPrivateData);
|
2009-07-28 02:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteSecretClose (virConnectPtr conn)
|
|
|
|
{
|
2011-04-23 20:07:44 +00:00
|
|
|
return remoteGenericClose(conn, &conn->secretPrivateData);
|
2009-07-28 02:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char *
|
|
|
|
remoteSecretGetValue (virSecretPtr secret, size_t *value_size,
|
libvirt: do not mix internal flags into public API
There were two API in driver.c that were silently masking flags
bits prior to calling out to the drivers, and several others
that were explicitly masking flags bits. This is not
forward-compatible - if we ever have that many flags in the
future, then talking to an old server that masks out the
flags would be indistinguishable from talking to a new server
that can honor the flag. In general, libvirt.c should forward
_all_ flags on to drivers, and only the drivers should reject
unknown flags.
In the case of virDrvSecretGetValue, the solution is to separate
the internal driver callback function to have two parameters
instead of one, with only one parameter affected by the public
API. In the case of virDomainGetXMLDesc, it turns out that
no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
the dumpxml path in the first place; that internal flag was
only used in saving and restoring state files, which happened
to be in functions internal to a single file, so there is no
mixing of the internal flag with a public flags argument.
Additionally, virDomainMemoryStats passed a flags argument
over RPC, but not to the driver.
* src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
(VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
(virDrvSecretGetValue): Separate out internal flags.
(virDrvDomainMemoryStats): Provide missing flags argument.
* src/driver.c (verify): Drop unused check.
* src/conf/domain_conf.h (virDomainObjParseFile): Delete
declaration.
(virDomainXMLInternalFlags): Move...
* src/conf/domain_conf.c: ...here. Delete redundant include.
(virDomainObjParseFile): Make static.
* src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
clients.
(virDomainMemoryPeek, virInterfaceGetXMLDesc)
(virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
(virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
(virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
Don't mask unknown flags.
* src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
unknown flags.
* src/secret/secret_driver.c (secretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue)
(remoteDomainMemoryStats): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
* daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.
2011-07-13 21:31:56 +00:00
|
|
|
unsigned int flags, unsigned int internalFlags)
|
2009-07-28 02:46:01 +00:00
|
|
|
{
|
|
|
|
unsigned char *rv = NULL;
|
|
|
|
remote_secret_get_value_args args;
|
|
|
|
remote_secret_get_value_ret ret;
|
|
|
|
struct private_data *priv = secret->conn->secretPrivateData;
|
|
|
|
|
|
|
|
remoteDriverLock (priv);
|
|
|
|
|
libvirt: do not mix internal flags into public API
There were two API in driver.c that were silently masking flags
bits prior to calling out to the drivers, and several others
that were explicitly masking flags bits. This is not
forward-compatible - if we ever have that many flags in the
future, then talking to an old server that masks out the
flags would be indistinguishable from talking to a new server
that can honor the flag. In general, libvirt.c should forward
_all_ flags on to drivers, and only the drivers should reject
unknown flags.
In the case of virDrvSecretGetValue, the solution is to separate
the internal driver callback function to have two parameters
instead of one, with only one parameter affected by the public
API. In the case of virDomainGetXMLDesc, it turns out that
no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
the dumpxml path in the first place; that internal flag was
only used in saving and restoring state files, which happened
to be in functions internal to a single file, so there is no
mixing of the internal flag with a public flags argument.
Additionally, virDomainMemoryStats passed a flags argument
over RPC, but not to the driver.
* src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
(VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
(virDrvSecretGetValue): Separate out internal flags.
(virDrvDomainMemoryStats): Provide missing flags argument.
* src/driver.c (verify): Drop unused check.
* src/conf/domain_conf.h (virDomainObjParseFile): Delete
declaration.
(virDomainXMLInternalFlags): Move...
* src/conf/domain_conf.c: ...here. Delete redundant include.
(virDomainObjParseFile): Make static.
* src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
clients.
(virDomainMemoryPeek, virInterfaceGetXMLDesc)
(virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
(virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
(virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
Don't mask unknown flags.
* src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
unknown flags.
* src/secret/secret_driver.c (secretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue)
(remoteDomainMemoryStats): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
* daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.
2011-07-13 21:31:56 +00:00
|
|
|
/* internalFlags intentionally do not go over the wire */
|
|
|
|
if (internalFlags) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no internalFlags support"));
|
libvirt: do not mix internal flags into public API
There were two API in driver.c that were silently masking flags
bits prior to calling out to the drivers, and several others
that were explicitly masking flags bits. This is not
forward-compatible - if we ever have that many flags in the
future, then talking to an old server that masks out the
flags would be indistinguishable from talking to a new server
that can honor the flag. In general, libvirt.c should forward
_all_ flags on to drivers, and only the drivers should reject
unknown flags.
In the case of virDrvSecretGetValue, the solution is to separate
the internal driver callback function to have two parameters
instead of one, with only one parameter affected by the public
API. In the case of virDomainGetXMLDesc, it turns out that
no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
the dumpxml path in the first place; that internal flag was
only used in saving and restoring state files, which happened
to be in functions internal to a single file, so there is no
mixing of the internal flag with a public flags argument.
Additionally, virDomainMemoryStats passed a flags argument
over RPC, but not to the driver.
* src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
(VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
(virDrvSecretGetValue): Separate out internal flags.
(virDrvDomainMemoryStats): Provide missing flags argument.
* src/driver.c (verify): Drop unused check.
* src/conf/domain_conf.h (virDomainObjParseFile): Delete
declaration.
(virDomainXMLInternalFlags): Move...
* src/conf/domain_conf.c: ...here. Delete redundant include.
(virDomainObjParseFile): Make static.
* src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
clients.
(virDomainMemoryPeek, virInterfaceGetXMLDesc)
(virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
(virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
(virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
Don't mask unknown flags.
* src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
unknown flags.
* src/secret/secret_driver.c (secretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue)
(remoteDomainMemoryStats): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
* daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.
2011-07-13 21:31:56 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2009-07-28 02:46:01 +00:00
|
|
|
make_nonnull_secret (&args.secret, secret);
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2009-07-28 02:46:01 +00:00
|
|
|
if (call (secret->conn, priv, 0, REMOTE_PROC_SECRET_GET_VALUE,
|
|
|
|
(xdrproc_t) xdr_remote_secret_get_value_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_secret_get_value_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
*value_size = ret.value.value_len;
|
|
|
|
rv = (unsigned char *) ret.value.value_val; /* Caller frees. */
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock (priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
remoteStreamSend(virStreamPtr st,
|
|
|
|
const char *data,
|
|
|
|
size_t nbytes)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
|
2009-08-07 14:13:46 +00:00
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2012-07-17 14:36:23 +00:00
|
|
|
int rv;
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientStreamRaiseError(privst))
|
2012-07-17 14:36:23 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses++;
|
|
|
|
remoteDriverUnlock(priv);
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
rv = virNetClientStreamSendPacket(privst,
|
|
|
|
priv->client,
|
|
|
|
VIR_NET_CONTINUE,
|
|
|
|
data,
|
|
|
|
nbytes);
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2012-07-17 14:36:23 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
2009-08-07 14:13:46 +00:00
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteStreamRecv(virStreamPtr st,
|
|
|
|
char *data,
|
|
|
|
size_t nbytes)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("st=%p data=%p nbytes=%zu", st, data, nbytes);
|
2009-08-07 14:13:46 +00:00
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2012-07-17 14:36:23 +00:00
|
|
|
int rv;
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientStreamRaiseError(privst))
|
2012-07-17 14:36:23 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses++;
|
|
|
|
remoteDriverUnlock(priv);
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
rv = virNetClientStreamRecvPacket(privst,
|
|
|
|
priv->client,
|
|
|
|
data,
|
|
|
|
nbytes,
|
|
|
|
(st->flags & VIR_STREAM_NONBLOCK));
|
2010-07-23 12:24:37 +00:00
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("Done %d", rv);
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2012-07-17 14:36:23 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
2009-08-07 14:13:46 +00:00
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
struct remoteStreamCallbackData {
|
|
|
|
virStreamPtr st;
|
|
|
|
virStreamEventCallback cb;
|
|
|
|
void *opaque;
|
|
|
|
virFreeCallback ff;
|
|
|
|
};
|
2010-07-23 12:24:37 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void remoteStreamEventCallback(virNetClientStreamPtr stream ATTRIBUTE_UNUSED,
|
|
|
|
int events,
|
|
|
|
void *opaque)
|
2010-07-23 12:24:37 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
struct remoteStreamCallbackData *cbdata = opaque;
|
2010-07-23 12:57:14 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
(cbdata->cb)(cbdata->st, events, cbdata->opaque);
|
2010-07-23 12:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void remoteStreamCallbackFree(void *opaque)
|
2010-07-23 12:24:37 +00:00
|
|
|
{
|
2010-12-01 16:46:36 +00:00
|
|
|
struct remoteStreamCallbackData *cbdata = opaque;
|
|
|
|
|
|
|
|
if (!cbdata->cb && cbdata->ff)
|
|
|
|
(cbdata->ff)(cbdata->opaque);
|
|
|
|
|
|
|
|
virStreamFree(cbdata->st);
|
|
|
|
VIR_FREE(opaque);
|
2010-07-23 12:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
static int
|
2010-07-23 12:24:37 +00:00
|
|
|
remoteStreamEventAddCallback(virStreamPtr st,
|
|
|
|
int events,
|
|
|
|
virStreamEventCallback cb,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback ff)
|
2009-08-07 14:13:46 +00:00
|
|
|
{
|
2010-07-23 12:24:37 +00:00
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2010-07-23 12:24:37 +00:00
|
|
|
int ret = -1;
|
2010-12-01 16:46:36 +00:00
|
|
|
struct remoteStreamCallbackData *cbdata;
|
2010-07-23 12:24:37 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (VIR_ALLOC(cbdata) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
2010-07-23 12:24:37 +00:00
|
|
|
}
|
2010-12-01 16:46:36 +00:00
|
|
|
cbdata->cb = cb;
|
|
|
|
cbdata->opaque = opaque;
|
|
|
|
cbdata->ff = ff;
|
|
|
|
cbdata->st = st;
|
2010-07-23 12:24:37 +00:00
|
|
|
virStreamRef(st);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteDriverLock(priv);
|
2010-07-23 12:57:14 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if ((ret = virNetClientStreamEventAddCallback(privst,
|
|
|
|
events,
|
|
|
|
remoteStreamEventCallback,
|
|
|
|
cbdata,
|
|
|
|
remoteStreamCallbackFree)) < 0) {
|
|
|
|
VIR_FREE(cbdata);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-07-23 12:24:37 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return ret;
|
2009-08-07 14:13:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
static int
|
2010-07-23 12:24:37 +00:00
|
|
|
remoteStreamEventUpdateCallback(virStreamPtr st,
|
|
|
|
int events)
|
2009-08-07 14:13:46 +00:00
|
|
|
{
|
2010-07-23 12:24:37 +00:00
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2010-07-23 12:24:37 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
ret = virNetClientStreamEventUpdateCallback(privst, events);
|
2010-07-23 12:24:37 +00:00
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
2009-08-07 14:13:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int
|
2010-07-23 12:24:37 +00:00
|
|
|
remoteStreamEventRemoveCallback(virStreamPtr st)
|
2009-08-07 14:13:46 +00:00
|
|
|
{
|
2010-07-23 12:24:37 +00:00
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2010-07-23 12:24:37 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
ret = virNetClientStreamEventRemoveCallback(privst);
|
2010-07-23 12:24:37 +00:00
|
|
|
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return ret;
|
2009-08-07 14:13:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
static int
|
|
|
|
remoteStreamFinish(virStreamPtr st)
|
|
|
|
{
|
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2009-08-07 14:13:46 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientStreamRaiseError(privst))
|
2009-08-07 14:13:46 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2012-07-17 14:36:23 +00:00
|
|
|
priv->localUses++;
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
ret = virNetClientStreamSendPacket(privst,
|
|
|
|
priv->client,
|
|
|
|
VIR_NET_OK,
|
|
|
|
NULL,
|
|
|
|
0);
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2012-07-17 14:36:23 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
cleanup:
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientRemoveStream(priv->client, privst);
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(privst);
|
2010-12-01 16:46:36 +00:00
|
|
|
st->privateData = NULL;
|
|
|
|
st->driver = NULL;
|
2009-08-07 14:13:46 +00:00
|
|
|
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
static int
|
|
|
|
remoteStreamAbort(virStreamPtr st)
|
|
|
|
{
|
|
|
|
struct private_data *priv = st->conn->privateData;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr privst = st->privateData;
|
2009-08-07 14:13:46 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientStreamRaiseError(privst))
|
2009-08-07 14:13:46 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2012-07-17 14:36:23 +00:00
|
|
|
priv->localUses++;
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
ret = virNetClientStreamSendPacket(privst,
|
|
|
|
priv->client,
|
|
|
|
VIR_NET_ERROR,
|
|
|
|
NULL,
|
|
|
|
0);
|
2009-08-07 14:13:46 +00:00
|
|
|
|
2012-07-17 14:36:23 +00:00
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
|
|
|
|
2009-08-07 14:13:46 +00:00
|
|
|
cleanup:
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientRemoveStream(priv->client, privst);
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(privst);
|
2010-12-01 16:46:36 +00:00
|
|
|
st->privateData = NULL;
|
|
|
|
st->driver = NULL;
|
2009-08-07 14:13:46 +00:00
|
|
|
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStreamDriver remoteStreamDrv = {
|
|
|
|
.streamRecv = remoteStreamRecv,
|
|
|
|
.streamSend = remoteStreamSend,
|
|
|
|
.streamFinish = remoteStreamFinish,
|
|
|
|
.streamAbort = remoteStreamAbort,
|
|
|
|
.streamAddCallback = remoteStreamEventAddCallback,
|
|
|
|
.streamUpdateCallback = remoteStreamEventUpdateCallback,
|
|
|
|
.streamRemoveCallback = remoteStreamEventRemoveCallback,
|
|
|
|
};
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
static int remoteDomainEventRegisterAny(virConnectPtr conn,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int eventID,
|
|
|
|
virConnectDomainEventGenericCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freecb)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
remote_domain_events_register_any_args args;
|
|
|
|
int callbackID;
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
int count;
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if ((count = virDomainEventStateRegisterID(conn,
|
|
|
|
priv->domainEventState,
|
|
|
|
dom, eventID,
|
|
|
|
callback, opaque, freecb,
|
|
|
|
&callbackID)) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, "%s", _("adding cb to list"));
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
goto done;
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If this is the first callback for this eventID, we need to enable
|
|
|
|
* events on the server */
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
if (count == 1) {
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
args.eventID = eventID;
|
|
|
|
|
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_DOMAIN_EVENTS_REGISTER_ANY,
|
|
|
|
(xdrproc_t) xdr_remote_domain_events_register_any_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *)NULL) == -1) {
|
2011-12-13 11:14:46 +00:00
|
|
|
virDomainEventStateDeregisterID(conn,
|
|
|
|
priv->domainEventState,
|
|
|
|
callbackID);
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = callbackID;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int remoteDomainEventDeregisterAny(virConnectPtr conn,
|
|
|
|
int callbackID)
|
|
|
|
{
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_events_deregister_any_args args;
|
|
|
|
int eventID;
|
2011-12-13 11:14:46 +00:00
|
|
|
int count;
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if ((eventID = virDomainEventStateEventID(conn,
|
|
|
|
priv->domainEventState,
|
|
|
|
callbackID)) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("unable to find callback ID %d"), callbackID);
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if ((count = virDomainEventStateDeregisterID(conn,
|
|
|
|
priv->domainEventState,
|
|
|
|
callbackID)) < 0) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("unable to find callback ID %d"), callbackID);
|
2011-05-13 15:00:10 +00:00
|
|
|
goto done;
|
2011-12-13 11:14:46 +00:00
|
|
|
}
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
|
|
|
|
/* If that was the last callback for this eventID, we need to disable
|
|
|
|
* events on the server */
|
2011-12-13 11:14:46 +00:00
|
|
|
if (count == 0) {
|
|
|
|
args.eventID = callbackID;
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
|
|
|
|
if (call (conn, priv, 0, REMOTE_PROC_DOMAIN_EVENTS_DEREGISTER_ANY,
|
|
|
|
(xdrproc_t) xdr_remote_domain_events_deregister_any_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2010-04-17 02:09:25 +00:00
|
|
|
static int
|
|
|
|
remoteQemuDomainMonitorCommand (virDomainPtr domain, const char *cmd,
|
|
|
|
char **result, unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
qemu_monitor_command_args args;
|
|
|
|
qemu_monitor_command_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2011-04-22 13:40:31 +00:00
|
|
|
make_nonnull_domain(&args.dom, domain);
|
2010-04-17 02:09:25 +00:00
|
|
|
args.cmd = (char *)cmd;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2010-07-23 12:24:37 +00:00
|
|
|
if (call (domain->conn, priv, REMOTE_CALL_QEMU, QEMU_PROC_MONITOR_COMMAND,
|
2010-04-17 02:09:25 +00:00
|
|
|
(xdrproc_t) xdr_qemu_monitor_command_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_qemu_monitor_command_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
*result = strdup(ret.result);
|
|
|
|
if (*result == NULL) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_qemu_monitor_command_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-02-01 14:23:40 +00:00
|
|
|
|
|
|
|
static char *
|
|
|
|
remoteDomainMigrateBegin3(virDomainPtr domain,
|
2011-05-18 09:26:30 +00:00
|
|
|
const char *xmlin,
|
2011-02-01 14:23:40 +00:00
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource)
|
|
|
|
{
|
|
|
|
char *rv = NULL;
|
|
|
|
remote_domain_migrate_begin3_args args;
|
|
|
|
remote_domain_migrate_begin3_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
2011-05-18 09:26:30 +00:00
|
|
|
args.xmlin = xmlin == NULL ? NULL : (char **) &xmlin;
|
2011-02-01 14:23:40 +00:00
|
|
|
args.flags = flags;
|
|
|
|
args.dname = dname == NULL ? NULL : (char **) &dname;
|
|
|
|
args.resource = resource;
|
|
|
|
|
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_BEGIN3,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_begin3_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_begin3_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (ret.cookie_out.cookie_out_len > 0) {
|
|
|
|
if (!cookieout || !cookieoutlen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores cookieout or cookieoutlen"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
|
|
|
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ret.xml; /* caller frees */
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
error:
|
|
|
|
VIR_FREE(ret.cookie_out.cookie_out_val);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDomainMigratePrepare3(virConnectPtr dconn,
|
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
const char *uri_in,
|
|
|
|
char **uri_out,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource,
|
|
|
|
const char *dom_xml)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_migrate_prepare3_args args;
|
|
|
|
remote_domain_migrate_prepare3_ret ret;
|
|
|
|
struct private_data *priv = dconn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
|
|
|
args.cookie_in.cookie_in_val = (char *)cookiein;
|
|
|
|
args.cookie_in.cookie_in_len = cookieinlen;
|
|
|
|
args.uri_in = uri_in == NULL ? NULL : (char **) &uri_in;
|
|
|
|
args.flags = flags;
|
|
|
|
args.dname = dname == NULL ? NULL : (char **) &dname;
|
|
|
|
args.resource = resource;
|
|
|
|
args.dom_xml = (char *) dom_xml;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-02-01 14:23:40 +00:00
|
|
|
if (call (dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE3,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare3_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare3_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (ret.cookie_out.cookie_out_len > 0) {
|
|
|
|
if (!cookieout || !cookieoutlen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores cookieout or cookieoutlen"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
|
|
|
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
|
|
|
}
|
|
|
|
if (ret.uri_out) {
|
|
|
|
if (!uri_out) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores uri_out"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*uri_out = *ret.uri_out; /* Caller frees. */
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
2012-03-16 11:37:05 +00:00
|
|
|
VIR_FREE(ret.uri_out);
|
2011-02-01 14:23:40 +00:00
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
error:
|
|
|
|
VIR_FREE(ret.cookie_out.cookie_out_val);
|
|
|
|
if (ret.uri_out)
|
|
|
|
VIR_FREE(*ret.uri_out);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDomainMigratePrepareTunnel3(virConnectPtr dconn,
|
|
|
|
virStreamPtr st,
|
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource,
|
|
|
|
const char *dom_xml)
|
|
|
|
{
|
|
|
|
struct private_data *priv = dconn->privateData;
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_migrate_prepare_tunnel3_args args;
|
|
|
|
remote_domain_migrate_prepare_tunnel3_ret ret;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientStreamPtr netst;
|
2011-02-01 14:23:40 +00:00
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (!(netst = virNetClientStreamNew(priv->remoteProgram,
|
2011-06-30 15:52:13 +00:00
|
|
|
REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3,
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->counter)))
|
2011-02-01 14:23:40 +00:00
|
|
|
goto done;
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
if (virNetClientAddStream(priv->client, netst) < 0) {
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(netst);
|
2010-12-01 16:46:36 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2011-02-01 14:23:40 +00:00
|
|
|
st->driver = &remoteStreamDrv;
|
2010-12-01 16:46:36 +00:00
|
|
|
st->privateData = netst;
|
2011-02-01 14:23:40 +00:00
|
|
|
|
|
|
|
args.cookie_in.cookie_in_val = (char *)cookiein;
|
|
|
|
args.cookie_in.cookie_in_len = cookieinlen;
|
|
|
|
args.flags = flags;
|
|
|
|
args.dname = dname == NULL ? NULL : (char **) &dname;
|
|
|
|
args.resource = resource;
|
|
|
|
args.dom_xml = (char *) dom_xml;
|
|
|
|
|
|
|
|
if (call(dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel3_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel3_ret, (char *) &ret) == -1) {
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientRemoveStream(priv->client, netst);
|
2012-07-30 09:14:56 +00:00
|
|
|
virObjectUnref(netst);
|
2011-02-01 14:23:40 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.cookie_out.cookie_out_len > 0) {
|
|
|
|
if (!cookieout || !cookieoutlen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores cookieout or cookieoutlen"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
|
|
|
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
error:
|
|
|
|
VIR_FREE(ret.cookie_out.cookie_out_val);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDomainMigratePerform3(virDomainPtr dom,
|
2011-05-18 09:26:30 +00:00
|
|
|
const char *xmlin,
|
2011-02-01 14:23:40 +00:00
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
Add a second URI parameter to virDomainMigratePerform3 method
The virDomainMigratePerform3 currently has a single URI parameter
whose meaning varies. It is either
- A QEMU migration URI (normal migration)
- A libvirtd connection URI (peer2peer migration)
Unfortunately when using peer2peer migration, without also
using tunnelled migration, it is possible that both URIs are
required.
This adds a second URI parameter to the virDomainMigratePerform3
method, to cope with this scenario. Each parameter how has a fixed
meaning.
NB, there is no way to actually take advantage of this yet,
since virDomainMigrate/virDomainMigrateToURI do not have any
way to provide the 2 separate URIs
* daemon/remote.c, src/remote/remote_driver.c,
src/remote/remote_protocol.x, src/remote_protocol-structs: Add
the second URI parameter to perform3 message
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Add
the second URI parameter to Perform3 method
* src/libvirt_internal.h, src/qemu/qemu_migration.c,
src/qemu/qemu_migration.h: Update to handle URIs correctly
2011-05-18 13:18:53 +00:00
|
|
|
const char *dconnuri,
|
2011-02-01 14:23:40 +00:00
|
|
|
const char *uri,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_migrate_perform3_args args;
|
|
|
|
remote_domain_migrate_perform3_ret ret;
|
|
|
|
struct private_data *priv = dom->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
|
|
|
make_nonnull_domain(&args.dom, dom);
|
|
|
|
|
2011-05-18 09:26:30 +00:00
|
|
|
args.xmlin = xmlin == NULL ? NULL : (char **) &xmlin;
|
2011-02-01 14:23:40 +00:00
|
|
|
args.cookie_in.cookie_in_val = (char *)cookiein;
|
|
|
|
args.cookie_in.cookie_in_len = cookieinlen;
|
|
|
|
args.flags = flags;
|
|
|
|
args.dname = dname == NULL ? NULL : (char **) &dname;
|
Add a second URI parameter to virDomainMigratePerform3 method
The virDomainMigratePerform3 currently has a single URI parameter
whose meaning varies. It is either
- A QEMU migration URI (normal migration)
- A libvirtd connection URI (peer2peer migration)
Unfortunately when using peer2peer migration, without also
using tunnelled migration, it is possible that both URIs are
required.
This adds a second URI parameter to the virDomainMigratePerform3
method, to cope with this scenario. Each parameter how has a fixed
meaning.
NB, there is no way to actually take advantage of this yet,
since virDomainMigrate/virDomainMigrateToURI do not have any
way to provide the 2 separate URIs
* daemon/remote.c, src/remote/remote_driver.c,
src/remote/remote_protocol.x, src/remote_protocol-structs: Add
the second URI parameter to perform3 message
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Add
the second URI parameter to Perform3 method
* src/libvirt_internal.h, src/qemu/qemu_migration.c,
src/qemu/qemu_migration.h: Update to handle URIs correctly
2011-05-18 13:18:53 +00:00
|
|
|
args.uri = uri == NULL ? NULL : (char **) &uri;
|
|
|
|
args.dconnuri = dconnuri == NULL ? NULL : (char **) &dconnuri;
|
2011-02-01 14:23:40 +00:00
|
|
|
args.resource = resource;
|
|
|
|
|
|
|
|
if (call (dom->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PERFORM3,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_perform3_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_perform3_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (ret.cookie_out.cookie_out_len > 0) {
|
|
|
|
if (!cookieout || !cookieoutlen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores cookieout or cookieoutlen"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
|
|
|
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
error:
|
|
|
|
VIR_FREE(ret.cookie_out.cookie_out_val);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Fix the signature of virDomainMigrateFinish3 for error reporting
The current virDomainMigrateFinish3 method signature attempts to
distinguish two types of errors, by allowing return with ret== 0,
but ddomain == NULL, to indicate a failure to start the guest.
This is flawed, because when ret == 0, there is no way for the
virErrorPtr details to be sent back to the client.
Change the signature of virDomainMigrateFinish3 so it simply
returns a virDomainPtr, in the same way as virDomainMigrateFinish2
The disk locking code will protect against the only possible
failure mode this doesn't account for (loosing conenctivity to
libvirtd after Finish3 starts the CPUs, but before the client
sees the reply for Finish3).
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Change
virDomainMigrateFinish3 to return a virDomainPtr instead of int
* src/remote/remote_driver.c, src/remote/remote_protocol.x,
daemon/remote.c, src/qemu/qemu_driver.c, src/qemu/qemu_migration.c:
Update for API change
2011-05-24 12:05:33 +00:00
|
|
|
static virDomainPtr
|
2011-02-01 14:23:40 +00:00
|
|
|
remoteDomainMigrateFinish3(virConnectPtr dconn,
|
|
|
|
const char *dname,
|
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
Add a second URI parameter to virDomainMigratePerform3 method
The virDomainMigratePerform3 currently has a single URI parameter
whose meaning varies. It is either
- A QEMU migration URI (normal migration)
- A libvirtd connection URI (peer2peer migration)
Unfortunately when using peer2peer migration, without also
using tunnelled migration, it is possible that both URIs are
required.
This adds a second URI parameter to the virDomainMigratePerform3
method, to cope with this scenario. Each parameter how has a fixed
meaning.
NB, there is no way to actually take advantage of this yet,
since virDomainMigrate/virDomainMigrateToURI do not have any
way to provide the 2 separate URIs
* daemon/remote.c, src/remote/remote_driver.c,
src/remote/remote_protocol.x, src/remote_protocol-structs: Add
the second URI parameter to perform3 message
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Add
the second URI parameter to Perform3 method
* src/libvirt_internal.h, src/qemu/qemu_migration.c,
src/qemu/qemu_migration.h: Update to handle URIs correctly
2011-05-18 13:18:53 +00:00
|
|
|
const char *dconnuri,
|
2011-02-01 14:23:40 +00:00
|
|
|
const char *uri,
|
|
|
|
unsigned long flags,
|
Fix the signature of virDomainMigrateFinish3 for error reporting
The current virDomainMigrateFinish3 method signature attempts to
distinguish two types of errors, by allowing return with ret== 0,
but ddomain == NULL, to indicate a failure to start the guest.
This is flawed, because when ret == 0, there is no way for the
virErrorPtr details to be sent back to the client.
Change the signature of virDomainMigrateFinish3 so it simply
returns a virDomainPtr, in the same way as virDomainMigrateFinish2
The disk locking code will protect against the only possible
failure mode this doesn't account for (loosing conenctivity to
libvirtd after Finish3 starts the CPUs, but before the client
sees the reply for Finish3).
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Change
virDomainMigrateFinish3 to return a virDomainPtr instead of int
* src/remote/remote_driver.c, src/remote/remote_protocol.x,
daemon/remote.c, src/qemu/qemu_driver.c, src/qemu/qemu_migration.c:
Update for API change
2011-05-24 12:05:33 +00:00
|
|
|
int cancelled)
|
2011-02-01 14:23:40 +00:00
|
|
|
{
|
|
|
|
remote_domain_migrate_finish3_args args;
|
|
|
|
remote_domain_migrate_finish3_ret ret;
|
|
|
|
struct private_data *priv = dconn->privateData;
|
Fix the signature of virDomainMigrateFinish3 for error reporting
The current virDomainMigrateFinish3 method signature attempts to
distinguish two types of errors, by allowing return with ret== 0,
but ddomain == NULL, to indicate a failure to start the guest.
This is flawed, because when ret == 0, there is no way for the
virErrorPtr details to be sent back to the client.
Change the signature of virDomainMigrateFinish3 so it simply
returns a virDomainPtr, in the same way as virDomainMigrateFinish2
The disk locking code will protect against the only possible
failure mode this doesn't account for (loosing conenctivity to
libvirtd after Finish3 starts the CPUs, but before the client
sees the reply for Finish3).
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Change
virDomainMigrateFinish3 to return a virDomainPtr instead of int
* src/remote/remote_driver.c, src/remote/remote_protocol.x,
daemon/remote.c, src/qemu/qemu_driver.c, src/qemu/qemu_migration.c:
Update for API change
2011-05-24 12:05:33 +00:00
|
|
|
virDomainPtr rv = NULL;
|
2011-02-01 14:23:40 +00:00
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
|
|
|
|
args.cookie_in.cookie_in_val = (char *)cookiein;
|
|
|
|
args.cookie_in.cookie_in_len = cookieinlen;
|
|
|
|
args.dname = (char *) dname;
|
Add a second URI parameter to virDomainMigratePerform3 method
The virDomainMigratePerform3 currently has a single URI parameter
whose meaning varies. It is either
- A QEMU migration URI (normal migration)
- A libvirtd connection URI (peer2peer migration)
Unfortunately when using peer2peer migration, without also
using tunnelled migration, it is possible that both URIs are
required.
This adds a second URI parameter to the virDomainMigratePerform3
method, to cope with this scenario. Each parameter how has a fixed
meaning.
NB, there is no way to actually take advantage of this yet,
since virDomainMigrate/virDomainMigrateToURI do not have any
way to provide the 2 separate URIs
* daemon/remote.c, src/remote/remote_driver.c,
src/remote/remote_protocol.x, src/remote_protocol-structs: Add
the second URI parameter to perform3 message
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Add
the second URI parameter to Perform3 method
* src/libvirt_internal.h, src/qemu/qemu_migration.c,
src/qemu/qemu_migration.h: Update to handle URIs correctly
2011-05-18 13:18:53 +00:00
|
|
|
args.uri = uri == NULL ? NULL : (char **) &uri;
|
|
|
|
args.dconnuri = dconnuri == NULL ? NULL : (char **) &dconnuri;
|
2011-02-01 14:23:40 +00:00
|
|
|
args.flags = flags;
|
|
|
|
args.cancelled = cancelled;
|
|
|
|
|
|
|
|
if (call (dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_FINISH3,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_finish3_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_finish3_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
Fix the signature of virDomainMigrateFinish3 for error reporting
The current virDomainMigrateFinish3 method signature attempts to
distinguish two types of errors, by allowing return with ret== 0,
but ddomain == NULL, to indicate a failure to start the guest.
This is flawed, because when ret == 0, there is no way for the
virErrorPtr details to be sent back to the client.
Change the signature of virDomainMigrateFinish3 so it simply
returns a virDomainPtr, in the same way as virDomainMigrateFinish2
The disk locking code will protect against the only possible
failure mode this doesn't account for (loosing conenctivity to
libvirtd after Finish3 starts the CPUs, but before the client
sees the reply for Finish3).
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Change
virDomainMigrateFinish3 to return a virDomainPtr instead of int
* src/remote/remote_driver.c, src/remote/remote_protocol.x,
daemon/remote.c, src/qemu/qemu_driver.c, src/qemu/qemu_migration.c:
Update for API change
2011-05-24 12:05:33 +00:00
|
|
|
rv = get_nonnull_domain(dconn, ret.dom);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
|
|
|
if (ret.cookie_out.cookie_out_len > 0) {
|
|
|
|
if (!cookieout || !cookieoutlen) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("caller ignores cookieout or cookieoutlen"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
|
|
|
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
|
|
|
ret.cookie_out.cookie_out_val = NULL;
|
|
|
|
ret.cookie_out.cookie_out_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
xdr_free ((xdrproc_t) &xdr_remote_domain_migrate_finish3_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
error:
|
|
|
|
VIR_FREE(ret.cookie_out.cookie_out_val);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDomainMigrateConfirm3(virDomainPtr domain,
|
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
unsigned long flags,
|
|
|
|
int cancelled)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_migrate_confirm3_args args;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.cookie_in.cookie_in_len = cookieinlen;
|
|
|
|
args.cookie_in.cookie_in_val = (char *) cookiein;
|
|
|
|
args.flags = flags;
|
|
|
|
args.cancelled = cancelled;
|
|
|
|
|
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3,
|
|
|
|
(xdrproc_t) xdr_remote_domain_migrate_confirm3_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, (char *) NULL) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-21 11:49:23 +00:00
|
|
|
static int
|
|
|
|
remoteDomainOpenGraphics(virDomainPtr dom,
|
|
|
|
unsigned int idx,
|
|
|
|
int fd,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_open_graphics_args args;
|
|
|
|
struct private_data *priv = dom->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, dom);
|
|
|
|
args.idx = idx;
|
|
|
|
args.flags = flags;
|
|
|
|
|
|
|
|
if (callWithFD(dom->conn, priv, 0, fd, REMOTE_PROC_DOMAIN_OPEN_GRAPHICS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_open_graphics_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_void, NULL) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-22 12:59:06 +00:00
|
|
|
static int
|
|
|
|
remoteSetKeepAlive(virConnectPtr conn, int interval, unsigned int count)
|
|
|
|
{
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
if (!virNetClientKeepAliveIsSupported(priv->client)) {
|
2012-07-18 13:35:21 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("the caller doesn't support keepalive protocol;"
|
|
|
|
" perhaps it's missing event loop implementation"));
|
2011-09-22 12:59:06 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->serverKeepAlive) {
|
|
|
|
ret = 1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2012-04-24 14:38:41 +00:00
|
|
|
if (interval > 0) {
|
|
|
|
ret = virNetClientKeepAliveStart(priv->client, interval, count);
|
|
|
|
} else {
|
|
|
|
virNetClientKeepAliveStop(priv->client);
|
|
|
|
ret = 0;
|
|
|
|
}
|
2011-09-22 12:59:06 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-23 06:56:13 +00:00
|
|
|
static int
|
|
|
|
remoteIsAlive(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
struct private_data *priv = conn->privateData;
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
ret = virNetClientIsOpen(priv->client);
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-31 06:42:31 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetDiskErrors(virDomainPtr dom,
|
|
|
|
virDomainDiskErrorPtr errors,
|
|
|
|
unsigned int maxerrors,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
struct private_data *priv = dom->conn->privateData;
|
|
|
|
remote_domain_get_disk_errors_args args;
|
|
|
|
remote_domain_get_disk_errors_ret ret;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain(&args.dom, dom);
|
|
|
|
args.maxerrors = maxerrors;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&ret, 0, sizeof(ret));
|
2012-01-31 06:42:31 +00:00
|
|
|
|
|
|
|
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_DISK_ERRORS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_disk_errors_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_disk_errors_ret,
|
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (remoteDeserializeDomainDiskErrors(ret.errors.errors_val,
|
|
|
|
ret.errors.errors_len,
|
|
|
|
REMOTE_DOMAIN_DISK_ERRORS_MAX,
|
|
|
|
errors,
|
|
|
|
maxerrors) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = ret.nerrors;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_domain_get_disk_errors_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-05-06 19:54:32 +00:00
|
|
|
#include "remote_client_bodies.h"
|
|
|
|
#include "qemu_client_bodies.h"
|
2011-04-23 10:53:57 +00:00
|
|
|
|
2009-07-10 15:10:56 +00:00
|
|
|
/*
|
|
|
|
* Serial a set of arguments into a method call message,
|
|
|
|
* send that to the server and wait for reply
|
|
|
|
*/
|
|
|
|
static int
|
2011-10-21 11:49:23 +00:00
|
|
|
callWithFD(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
struct private_data *priv,
|
|
|
|
unsigned int flags,
|
|
|
|
int fd,
|
|
|
|
int proc_nr,
|
|
|
|
xdrproc_t args_filter, char *args,
|
|
|
|
xdrproc_t ret_filter, char *ret)
|
2009-07-10 15:10:56 +00:00
|
|
|
{
|
2010-07-23 11:05:46 +00:00
|
|
|
int rv;
|
2010-12-01 16:46:36 +00:00
|
|
|
virNetClientProgramPtr prog = flags & REMOTE_CALL_QEMU ? priv->qemuProgram : priv->remoteProgram;
|
|
|
|
int counter = priv->counter++;
|
|
|
|
virNetClientPtr client = priv->client;
|
2011-10-21 11:49:23 +00:00
|
|
|
int fds[] = { fd };
|
|
|
|
size_t nfds = fd == -1 ? 0 : 1;
|
2010-12-01 16:46:36 +00:00
|
|
|
priv->localUses++;
|
|
|
|
|
|
|
|
/* Unlock, so that if we get any async events/stream data
|
|
|
|
* while processing the RPC, we don't deadlock when our
|
|
|
|
* callbacks for those are invoked
|
|
|
|
*/
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
rv = virNetClientProgramCall(prog,
|
|
|
|
client,
|
|
|
|
counter,
|
|
|
|
proc_nr,
|
2011-10-21 11:49:23 +00:00
|
|
|
nfds, nfds ? fds : NULL, NULL, NULL,
|
2010-12-01 16:46:36 +00:00
|
|
|
args_filter, args,
|
|
|
|
ret_filter, ret);
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
priv->localUses--;
|
2009-07-10 15:10:56 +00:00
|
|
|
|
2010-07-23 11:05:46 +00:00
|
|
|
return rv;
|
2009-07-10 15:10:56 +00:00
|
|
|
}
|
|
|
|
|
2011-10-21 11:49:23 +00:00
|
|
|
static int
|
|
|
|
call (virConnectPtr conn,
|
|
|
|
struct private_data *priv,
|
|
|
|
unsigned int flags,
|
|
|
|
int proc_nr,
|
|
|
|
xdrproc_t args_filter, char *args,
|
|
|
|
xdrproc_t ret_filter, char *ret)
|
|
|
|
{
|
|
|
|
return callWithFD(conn, priv, flags, -1, proc_nr,
|
|
|
|
args_filter, args,
|
|
|
|
ret_filter, ret);
|
|
|
|
}
|
|
|
|
|
2009-07-10 15:10:56 +00:00
|
|
|
|
2011-12-29 07:33:18 +00:00
|
|
|
static int
|
|
|
|
remoteDomainGetInterfaceParameters (virDomainPtr domain,
|
|
|
|
const char *device,
|
|
|
|
virTypedParameterPtr params, int *nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
remote_domain_get_interface_parameters_args args;
|
|
|
|
remote_domain_get_interface_parameters_ret ret;
|
|
|
|
struct private_data *priv = domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
make_nonnull_domain (&args.dom, domain);
|
|
|
|
args.device = (char *)device;
|
|
|
|
args.nparams = *nparams;
|
|
|
|
args.flags = flags;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset (&ret, 0, sizeof(ret));
|
2011-12-29 07:33:18 +00:00
|
|
|
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_INTERFACE_PARAMETERS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_interface_parameters_args, (char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_get_interface_parameters_ret, (char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Handle the case when the caller does not know the number of parameters
|
|
|
|
* and is asking for the number of parameters supported
|
|
|
|
*/
|
|
|
|
if (*nparams == 0) {
|
|
|
|
*nparams = ret.nparams;
|
|
|
|
rv = 0;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remoteDeserializeTypedParameters(ret.params.params_val,
|
|
|
|
ret.params.params_len,
|
|
|
|
REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX,
|
|
|
|
params,
|
|
|
|
nparams) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
xdr_free ((xdrproc_t) xdr_remote_domain_get_interface_parameters_ret,
|
|
|
|
(char *) &ret);
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-06-10 03:24:57 +00:00
|
|
|
static int
|
|
|
|
remoteDomainListAllSnapshots(virDomainPtr dom,
|
|
|
|
virDomainSnapshotPtr **snapshots,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int i;
|
|
|
|
virDomainSnapshotPtr *snaps = NULL;
|
|
|
|
remote_domain_list_all_snapshots_args args;
|
|
|
|
remote_domain_list_all_snapshots_ret ret;
|
|
|
|
|
|
|
|
struct private_data *priv = dom->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
2012-07-04 08:58:39 +00:00
|
|
|
make_nonnull_domain(&args.dom, dom);
|
2012-06-10 03:24:57 +00:00
|
|
|
args.need_results = !!snapshots;
|
|
|
|
args.flags = flags;
|
|
|
|
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call (dom->conn,
|
|
|
|
priv,
|
|
|
|
0,
|
|
|
|
REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS,
|
|
|
|
(xdrproc_t) xdr_remote_domain_list_all_snapshots_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_list_all_snapshots_ret,
|
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (snapshots) {
|
|
|
|
if (VIR_ALLOC_N(snaps, ret.snapshots.snapshots_len + 1) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
for (i = 0; i < ret.snapshots.snapshots_len; i++) {
|
|
|
|
snaps[i] = get_nonnull_domain_snapshot(dom, ret.snapshots.snapshots_val[i]);
|
|
|
|
if (!snaps[i]) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*snapshots = snaps;
|
|
|
|
snaps = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ret.ret;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (snaps) {
|
|
|
|
for (i = 0; i < ret.snapshots.snapshots_len; i++)
|
|
|
|
if (snaps[i])
|
|
|
|
virDomainSnapshotFree(snaps[i]);
|
|
|
|
VIR_FREE(snaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_domain_list_all_snapshots_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDomainSnapshotListAllChildren(virDomainSnapshotPtr parent,
|
|
|
|
virDomainSnapshotPtr **snapshots,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int i;
|
|
|
|
virDomainSnapshotPtr *snaps = NULL;
|
|
|
|
remote_domain_snapshot_list_all_children_args args;
|
|
|
|
remote_domain_snapshot_list_all_children_ret ret;
|
|
|
|
|
|
|
|
struct private_data *priv = parent->domain->conn->privateData;
|
|
|
|
|
|
|
|
remoteDriverLock(priv);
|
|
|
|
|
|
|
|
args.need_results = !!snapshots;
|
|
|
|
args.flags = flags;
|
2012-08-03 09:45:12 +00:00
|
|
|
make_nonnull_domain_snapshot(&args.snapshot, parent);
|
2012-06-10 03:24:57 +00:00
|
|
|
|
|
|
|
memset(&ret, 0, sizeof(ret));
|
|
|
|
if (call (parent->domain->conn,
|
|
|
|
priv,
|
|
|
|
0,
|
|
|
|
REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN,
|
|
|
|
(xdrproc_t) xdr_remote_domain_snapshot_list_all_children_args,
|
|
|
|
(char *) &args,
|
|
|
|
(xdrproc_t) xdr_remote_domain_snapshot_list_all_children_ret,
|
|
|
|
(char *) &ret) == -1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (snapshots) {
|
|
|
|
if (VIR_ALLOC_N(snaps, ret.snapshots.snapshots_len + 1) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
for (i = 0; i < ret.snapshots.snapshots_len; i++) {
|
|
|
|
snaps[i] = get_nonnull_domain_snapshot(parent->domain, ret.snapshots.snapshots_val[i]);
|
|
|
|
if (!snaps[i]) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*snapshots = snaps;
|
|
|
|
snaps = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ret.ret;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (snaps) {
|
|
|
|
for (i = 0; i < ret.snapshots.snapshots_len; i++)
|
|
|
|
if (snaps[i])
|
|
|
|
virDomainSnapshotFree(snaps[i]);
|
|
|
|
VIR_FREE(snaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
xdr_free((xdrproc_t) xdr_remote_domain_snapshot_list_all_children_ret, (char *) &ret);
|
|
|
|
|
|
|
|
done:
|
|
|
|
remoteDriverUnlock(priv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-12-01 16:46:36 +00:00
|
|
|
static void
|
2011-05-13 15:00:10 +00:00
|
|
|
remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
|
|
|
|
{
|
|
|
|
virDomainEventStateQueue(priv->domainEventState, event);
|
|
|
|
}
|
2009-01-20 16:36:34 +00:00
|
|
|
|
2011-02-01 14:23:40 +00:00
|
|
|
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
|
|
|
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
|
|
|
|
* These can return NULL if underlying memory allocations fail,
|
|
|
|
* but if they do then virterror_internal.has been set.
|
|
|
|
*/
|
|
|
|
static virDomainPtr
|
2007-06-11 11:43:41 +00:00
|
|
|
get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain)
|
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
|
|
|
dom = virGetDomain (conn, domain.name, BAD_CAST domain.uuid);
|
|
|
|
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:23:36 +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)
|
|
|
|
{
|
|
|
|
return virGetStorageVol (conn, vol.pool, vol.name, vol.key);
|
|
|
|
}
|
|
|
|
|
2008-11-21 12:31:04 +00:00
|
|
|
static virNodeDevicePtr
|
|
|
|
get_nonnull_node_device (virConnectPtr conn, remote_nonnull_node_device dev)
|
|
|
|
{
|
|
|
|
return virGetNodeDevice(conn, dev.name);
|
|
|
|
}
|
|
|
|
|
2009-07-28 02:46:01 +00:00
|
|
|
static virSecretPtr
|
|
|
|
get_nonnull_secret (virConnectPtr conn, remote_nonnull_secret secret)
|
|
|
|
{
|
Add usage type/id as a public API property of virSecret
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in: Add
virSecretGetUsageType, virSecretGetUsageID and virLookupSecretByUsage
* python/generator.py: Mark virSecretGetUsageType, virSecretGetUsageID
as not throwing exceptions
* qemud/remote.c: Implement dispatch for virLookupSecretByUsage
* qemud/remote_protocol.x: Add usage type & ID as attributes of
remote_nonnull_secret. Add RPC calls for new public APIs
* qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h,
qemud/remote_protocol.c, qemud/remote_protocol.h: Re-generate
* src/datatypes.c, src/datatypes.h: Add usageType and usageID as
properties of virSecretPtr
* src/driver.h: Add virLookupSecretByUsage driver entry point
* src/libvirt.c: Implement virSecretGetUsageType, virSecretGetUsageID
and virLookupSecretByUsage
* src/libvirt_public.syms: Export virSecretGetUsageType, virSecretGetUsageID
and virLookupSecretByUsage
* src/remote_internal.c: Implement virLookupSecretByUsage entry
* src/secret_conf.c, src/secret_conf.h: Remove the
virSecretUsageType enum, now in public API. Make volume
path mandatory when parsing XML
* src/secret_driver.c: Enforce usage uniqueness when defining secrets.
Implement virSecretLookupByUsage api method
* src/virsh.c: Include usage for secret-list command
2009-09-11 13:06:15 +00:00
|
|
|
return virGetSecret(conn, BAD_CAST secret.uuid, secret.usageType, secret.usageID);
|
2009-07-28 02:46:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 17:46:03 +00:00
|
|
|
static virNWFilterPtr
|
|
|
|
get_nonnull_nwfilter (virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
|
|
|
|
{
|
|
|
|
return virGetNWFilter (conn, nwfilter.name, BAD_CAST nwfilter.uuid);
|
|
|
|
}
|
|
|
|
|
2010-03-31 20:33:13 +00:00
|
|
|
static virDomainSnapshotPtr
|
|
|
|
get_nonnull_domain_snapshot (virDomainPtr domain, remote_nonnull_domain_snapshot snapshot)
|
|
|
|
{
|
|
|
|
return virGetDomainSnapshot(domain, snapshot.name);
|
|
|
|
}
|
|
|
|
|
2010-03-25 17:46:03 +00:00
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/* Make remote_nonnull_domain and remote_nonnull_network. */
|
|
|
|
static void
|
|
|
|
make_nonnull_domain (remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
|
|
|
|
{
|
2007-06-21 15:38:20 +00:00
|
|
|
dom_dst->id = dom_src->id;
|
2007-06-11 11:43:41 +00:00
|
|
|
dom_dst->name = 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 = 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 = interface_src->name;
|
|
|
|
interface_dst->mac = interface_src->mac;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:23:36 +00:00
|
|
|
static void
|
|
|
|
make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
|
|
|
|
{
|
|
|
|
pool_dst->name = 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 = vol_src->pool;
|
|
|
|
vol_dst->name = vol_src->name;
|
|
|
|
vol_dst->key = vol_src->key;
|
|
|
|
}
|
|
|
|
|
2009-07-28 02:46:01 +00:00
|
|
|
static void
|
|
|
|
make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
|
|
|
|
{
|
Fix UUID handling in secrets/storage encryption APIs
Convert all the secret/storage encryption APIs / wire format to
handle UUIDs in raw format instead of non-canonical printable
format. Guarentees data format correctness.
* docs/schemas/storageencryption.rng: Make UUID mandatory for a secret
and validate fully
* docs/schemas/secret.rng: Fully validate UUID
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in, Add
virSecretLookupByUUID and virSecretGetUUID. Make
virSecretGetUUIDString follow normal API design pattern
* python/generator.py: Skip generation of virSecretGetUUID,
virSecretGetUUIDString and virSecretLookupByUUID
* python/libvir.c, python/libvirt-python-api.xml: Manual impl
of virSecretGetUUID,virSecretGetUUIDString and virSecretLookupByUUID
* qemud/remote.c: s/virSecretLookupByUUIDString/virSecretLookupByUUID/
Fix get_nonnull_secret/make_nonnull_secret to use unsigned char
* qemud/remote_protocol.x: Fix remote_nonnull_secret to use a
remote_uuid instead of remote_nonnull_string for UUID field.
Rename REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING to
REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING and make it take an
remote_uuid value
* qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h,
qemud/remote_protocol.c, qemud/remote_protocol.h: Re-generate
* src/datatypes.h, src/datatypes.c: Store UUID in raw format instead
of printable. Change virGetSecret to use raw format UUID
* src/driver.h: Rename virDrvSecretLookupByUUIDString to
virDrvSecretLookupByUUID and use raw format UUID
* src/libvirt.c: Add virSecretLookupByUUID and virSecretGetUUID
and re-implement virSecretLookupByUUIDString and
virSecretGetUUIDString in terms of those
* src/libvirt_public.syms: Add virSecretLookupByUUID and
virSecretGetUUID
* src/remote_internal.c: Rename remoteSecretLookupByUUIDString
to remoteSecretLookupByUUID. Fix typo in args for
remoteSecretDefineXML impl. Use raw UUID format for
get_nonnull_secret and make_nonnull_secret
* src/storage_encryption_conf.c, src/storage_encryption_conf.h:
Storage UUID in raw format, and require it to be present in
XML. Use UUID parser to validate.
* secret_conf.h, secret_conf.c: Generate a UUID if none is provided.
Storage UUID in raw format.
* src/secret_driver.c: Adjust to deal with raw UUIDs. Save secrets
in a filed with printable UUID, instead of base64 UUID.
* src/virsh.c: Adjust for changed public API contract of
virSecretGetUUIDString.
* src/storage_Backend.c: DOn't undefine secret we just generated
upon successful volume creation. Fix to handle raw UUIDs. Generate
a non-clashing UUID
* src/qemu_driver.c: Change to use lookupByUUID instead of
lookupByUUIDString
2009-09-10 16:44:12 +00:00
|
|
|
memcpy (secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN);
|
Add usage type/id as a public API property of virSecret
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in: Add
virSecretGetUsageType, virSecretGetUsageID and virLookupSecretByUsage
* python/generator.py: Mark virSecretGetUsageType, virSecretGetUsageID
as not throwing exceptions
* qemud/remote.c: Implement dispatch for virLookupSecretByUsage
* qemud/remote_protocol.x: Add usage type & ID as attributes of
remote_nonnull_secret. Add RPC calls for new public APIs
* qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h,
qemud/remote_protocol.c, qemud/remote_protocol.h: Re-generate
* src/datatypes.c, src/datatypes.h: Add usageType and usageID as
properties of virSecretPtr
* src/driver.h: Add virLookupSecretByUsage driver entry point
* src/libvirt.c: Implement virSecretGetUsageType, virSecretGetUsageID
and virLookupSecretByUsage
* src/libvirt_public.syms: Export virSecretGetUsageType, virSecretGetUsageID
and virLookupSecretByUsage
* src/remote_internal.c: Implement virLookupSecretByUsage entry
* src/secret_conf.c, src/secret_conf.h: Remove the
virSecretUsageType enum, now in public API. Make volume
path mandatory when parsing XML
* src/secret_driver.c: Enforce usage uniqueness when defining secrets.
Implement virSecretLookupByUsage api method
* src/virsh.c: Include usage for secret-list command
2009-09-11 13:06:15 +00:00
|
|
|
secret_dst->usageType = secret_src->usageType;
|
|
|
|
secret_dst->usageID = secret_src->usageID;
|
2009-07-28 02:46:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 17:46:03 +00:00
|
|
|
static void
|
|
|
|
make_nonnull_nwfilter (remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
|
|
|
|
{
|
|
|
|
nwfilter_dst->name = nwfilter_src->name;
|
|
|
|
memcpy (nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
|
|
|
|
}
|
|
|
|
|
2010-03-31 20:33:13 +00:00
|
|
|
static void
|
|
|
|
make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
|
|
|
|
{
|
|
|
|
snapshot_dst->name = snapshot_src->name;
|
2011-04-22 13:40:31 +00:00
|
|
|
make_nonnull_domain(&snapshot_dst->dom, snapshot_src->domain);
|
2010-03-31 20:33:13 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:43:41 +00:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
2008-11-28 12:03:20 +00:00
|
|
|
unsigned long remoteVersion(void)
|
|
|
|
{
|
|
|
|
return REMOTE_PROTOCOL_VERSION;
|
|
|
|
}
|
|
|
|
|
2009-08-17 14:05:22 +00:00
|
|
|
static virDriver remote_driver = {
|
Convert all driver struct intializers to C99 style
Change all the driver struct initializers to use the
C99 style, leaving out unused fields. This will make
it possible to add new APIs without changing every
driver. eg change:
qemudDomainResume, /* domainResume */
qemudDomainShutdown, /* domainShutdown */
NULL, /* domainReboot */
qemudDomainDestroy, /* domainDestroy */
to
.domainResume = qemudDomainResume,
.domainShutdown = qemudDomainShutdown,
.domainDestroy = qemudDomainDestroy,
And get rid of any existing C99 style initializersr which
set NULL, eg change
.listPools = vboxStorageListPools,
.numOfDefinedPools = NULL,
.listDefinedPools = NULL,
.findPoolSources = NULL,
.poolLookupByName = vboxStoragePoolLookupByName,
to
.listPools = vboxStorageListPools,
.poolLookupByName = vboxStoragePoolLookupByName,
2011-05-13 10:16:31 +00:00
|
|
|
.no = VIR_DRV_REMOTE,
|
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteOpen, /* 0.3.0 */
|
|
|
|
.close = remoteClose, /* 0.3.0 */
|
|
|
|
.supports_feature = remoteSupportsFeature, /* 0.3.0 */
|
|
|
|
.type = remoteType, /* 0.3.0 */
|
|
|
|
.version = remoteGetVersion, /* 0.3.0 */
|
|
|
|
.libvirtVersion = remoteGetLibVersion, /* 0.7.3 */
|
|
|
|
.getHostname = remoteGetHostname, /* 0.3.0 */
|
|
|
|
.getSysinfo = remoteGetSysinfo, /* 0.8.8 */
|
|
|
|
.getMaxVcpus = remoteGetMaxVcpus, /* 0.3.0 */
|
|
|
|
.nodeGetInfo = remoteNodeGetInfo, /* 0.3.0 */
|
|
|
|
.getCapabilities = remoteGetCapabilities, /* 0.3.0 */
|
|
|
|
.listDomains = remoteListDomains, /* 0.3.0 */
|
|
|
|
.numOfDomains = remoteNumOfDomains, /* 0.3.0 */
|
2012-05-20 14:26:36 +00:00
|
|
|
.listAllDomains = remoteConnectListAllDomains, /* 0.9.13 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainCreateXML = remoteDomainCreateXML, /* 0.3.0 */
|
|
|
|
.domainLookupByID = remoteDomainLookupByID, /* 0.3.0 */
|
|
|
|
.domainLookupByUUID = remoteDomainLookupByUUID, /* 0.3.0 */
|
|
|
|
.domainLookupByName = remoteDomainLookupByName, /* 0.3.0 */
|
|
|
|
.domainSuspend = remoteDomainSuspend, /* 0.3.0 */
|
|
|
|
.domainResume = remoteDomainResume, /* 0.3.0 */
|
2012-01-26 18:05:46 +00:00
|
|
|
.domainPMSuspendForDuration = remoteDomainPMSuspendForDuration, /* 0.9.10 */
|
2012-02-10 11:40:52 +00:00
|
|
|
.domainPMWakeup = remoteDomainPMWakeup, /* 0.9.11 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainShutdown = remoteDomainShutdown, /* 0.3.0 */
|
2011-10-05 17:31:55 +00:00
|
|
|
.domainShutdownFlags = remoteDomainShutdownFlags, /* 0.9.10 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainReboot = remoteDomainReboot, /* 0.3.0 */
|
2011-09-29 08:56:24 +00:00
|
|
|
.domainReset = remoteDomainReset, /* 0.9.7 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainDestroy = remoteDomainDestroy, /* 0.3.0 */
|
2011-07-20 16:33:23 +00:00
|
|
|
.domainDestroyFlags = remoteDomainDestroyFlags, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainGetOSType = remoteDomainGetOSType, /* 0.3.0 */
|
|
|
|
.domainGetMaxMemory = remoteDomainGetMaxMemory, /* 0.3.0 */
|
|
|
|
.domainSetMaxMemory = remoteDomainSetMaxMemory, /* 0.3.0 */
|
|
|
|
.domainSetMemory = remoteDomainSetMemory, /* 0.3.0 */
|
|
|
|
.domainSetMemoryFlags = remoteDomainSetMemoryFlags, /* 0.9.0 */
|
|
|
|
.domainSetMemoryParameters = remoteDomainSetMemoryParameters, /* 0.8.5 */
|
|
|
|
.domainGetMemoryParameters = remoteDomainGetMemoryParameters, /* 0.8.5 */
|
|
|
|
.domainSetBlkioParameters = remoteDomainSetBlkioParameters, /* 0.9.0 */
|
|
|
|
.domainGetBlkioParameters = remoteDomainGetBlkioParameters, /* 0.9.0 */
|
|
|
|
.domainGetInfo = remoteDomainGetInfo, /* 0.3.0 */
|
|
|
|
.domainGetState = remoteDomainGetState, /* 0.9.2 */
|
2011-05-31 15:37:00 +00:00
|
|
|
.domainGetControlInfo = remoteDomainGetControlInfo, /* 0.9.3 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainSave = remoteDomainSave, /* 0.3.0 */
|
2011-07-09 02:35:16 +00:00
|
|
|
.domainSaveFlags = remoteDomainSaveFlags, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainRestore = remoteDomainRestore, /* 0.3.0 */
|
2011-07-09 02:35:16 +00:00
|
|
|
.domainRestoreFlags = remoteDomainRestoreFlags, /* 0.9.4 */
|
2011-07-20 15:00:38 +00:00
|
|
|
.domainSaveImageGetXMLDesc = remoteDomainSaveImageGetXMLDesc, /* 0.9.4 */
|
|
|
|
.domainSaveImageDefineXML = remoteDomainSaveImageDefineXML, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainCoreDump = remoteDomainCoreDump, /* 0.3.0 */
|
|
|
|
.domainScreenshot = remoteDomainScreenshot, /* 0.9.2 */
|
|
|
|
.domainSetVcpus = remoteDomainSetVcpus, /* 0.3.0 */
|
|
|
|
.domainSetVcpusFlags = remoteDomainSetVcpusFlags, /* 0.8.5 */
|
|
|
|
.domainGetVcpusFlags = remoteDomainGetVcpusFlags, /* 0.8.5 */
|
|
|
|
.domainPinVcpu = remoteDomainPinVcpu, /* 0.3.0 */
|
2011-06-13 15:45:29 +00:00
|
|
|
.domainPinVcpuFlags = remoteDomainPinVcpuFlags, /* 0.9.3 */
|
2011-06-24 23:09:46 +00:00
|
|
|
.domainGetVcpuPinInfo = remoteDomainGetVcpuPinInfo, /* 0.9.3 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainGetVcpus = remoteDomainGetVcpus, /* 0.3.0 */
|
|
|
|
.domainGetMaxVcpus = remoteDomainGetMaxVcpus, /* 0.3.0 */
|
|
|
|
.domainGetSecurityLabel = remoteDomainGetSecurityLabel, /* 0.6.1 */
|
|
|
|
.nodeGetSecurityModel = remoteNodeGetSecurityModel, /* 0.6.1 */
|
|
|
|
.domainGetXMLDesc = remoteDomainGetXMLDesc, /* 0.3.0 */
|
|
|
|
.domainXMLFromNative = remoteDomainXMLFromNative, /* 0.6.4 */
|
|
|
|
.domainXMLToNative = remoteDomainXMLToNative, /* 0.6.4 */
|
|
|
|
.listDefinedDomains = remoteListDefinedDomains, /* 0.3.0 */
|
|
|
|
.numOfDefinedDomains = remoteNumOfDefinedDomains, /* 0.3.0 */
|
|
|
|
.domainCreate = remoteDomainCreate, /* 0.3.0 */
|
|
|
|
.domainCreateWithFlags = remoteDomainCreateWithFlags, /* 0.8.2 */
|
|
|
|
.domainDefineXML = remoteDomainDefineXML, /* 0.3.0 */
|
|
|
|
.domainUndefine = remoteDomainUndefine, /* 0.3.0 */
|
2011-07-20 03:01:45 +00:00
|
|
|
.domainUndefineFlags = remoteDomainUndefineFlags, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainAttachDevice = remoteDomainAttachDevice, /* 0.3.0 */
|
|
|
|
.domainAttachDeviceFlags = remoteDomainAttachDeviceFlags, /* 0.7.7 */
|
|
|
|
.domainDetachDevice = remoteDomainDetachDevice, /* 0.3.0 */
|
|
|
|
.domainDetachDeviceFlags = remoteDomainDetachDeviceFlags, /* 0.7.7 */
|
|
|
|
.domainUpdateDeviceFlags = remoteDomainUpdateDeviceFlags, /* 0.8.0 */
|
|
|
|
.domainGetAutostart = remoteDomainGetAutostart, /* 0.3.0 */
|
|
|
|
.domainSetAutostart = remoteDomainSetAutostart, /* 0.3.0 */
|
|
|
|
.domainGetSchedulerType = remoteDomainGetSchedulerType, /* 0.3.0 */
|
|
|
|
.domainGetSchedulerParameters = remoteDomainGetSchedulerParameters, /* 0.3.0 */
|
2011-05-17 21:45:03 +00:00
|
|
|
.domainGetSchedulerParametersFlags = remoteDomainGetSchedulerParametersFlags, /* 0.9.2 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainSetSchedulerParameters = remoteDomainSetSchedulerParameters, /* 0.3.0 */
|
2011-05-17 21:45:03 +00:00
|
|
|
.domainSetSchedulerParametersFlags = remoteDomainSetSchedulerParametersFlags, /* 0.9.2 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainMigratePrepare = remoteDomainMigratePrepare, /* 0.3.2 */
|
|
|
|
.domainMigratePerform = remoteDomainMigratePerform, /* 0.3.2 */
|
|
|
|
.domainMigrateFinish = remoteDomainMigrateFinish, /* 0.3.2 */
|
2011-11-29 13:44:36 +00:00
|
|
|
.domainBlockResize = remoteDomainBlockResize, /* 0.9.8 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainBlockStats = remoteDomainBlockStats, /* 0.3.2 */
|
2011-09-05 08:20:03 +00:00
|
|
|
.domainBlockStatsFlags = remoteDomainBlockStatsFlags, /* 0.9.5 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainInterfaceStats = remoteDomainInterfaceStats, /* 0.3.2 */
|
2011-12-29 07:33:18 +00:00
|
|
|
.domainSetInterfaceParameters = remoteDomainSetInterfaceParameters, /* 0.9.9 */
|
|
|
|
.domainGetInterfaceParameters = remoteDomainGetInterfaceParameters, /* 0.9.9 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainMemoryStats = remoteDomainMemoryStats, /* 0.7.5 */
|
|
|
|
.domainBlockPeek = remoteDomainBlockPeek, /* 0.4.2 */
|
|
|
|
.domainMemoryPeek = remoteDomainMemoryPeek, /* 0.4.2 */
|
|
|
|
.domainGetBlockInfo = remoteDomainGetBlockInfo, /* 0.8.1 */
|
2011-06-07 01:01:12 +00:00
|
|
|
.nodeGetCPUStats = remoteNodeGetCPUStats, /* 0.9.3 */
|
2011-06-07 01:05:40 +00:00
|
|
|
.nodeGetMemoryStats = remoteNodeGetMemoryStats, /* 0.9.3 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.nodeGetCellsFreeMemory = remoteNodeGetCellsFreeMemory, /* 0.3.3 */
|
|
|
|
.nodeGetFreeMemory = remoteNodeGetFreeMemory, /* 0.3.3 */
|
|
|
|
.domainEventRegister = remoteDomainEventRegister, /* 0.5.0 */
|
|
|
|
.domainEventDeregister = remoteDomainEventDeregister, /* 0.5.0 */
|
|
|
|
.domainMigratePrepare2 = remoteDomainMigratePrepare2, /* 0.5.0 */
|
|
|
|
.domainMigrateFinish2 = remoteDomainMigrateFinish2, /* 0.5.0 */
|
|
|
|
.nodeDeviceDettach = remoteNodeDeviceDettach, /* 0.6.1 */
|
|
|
|
.nodeDeviceReAttach = remoteNodeDeviceReAttach, /* 0.6.1 */
|
|
|
|
.nodeDeviceReset = remoteNodeDeviceReset, /* 0.6.1 */
|
|
|
|
.domainMigratePrepareTunnel = remoteDomainMigratePrepareTunnel, /* 0.7.2 */
|
|
|
|
.isEncrypted = remoteIsEncrypted, /* 0.7.3 */
|
|
|
|
.isSecure = remoteIsSecure, /* 0.7.3 */
|
|
|
|
.domainIsActive = remoteDomainIsActive, /* 0.7.3 */
|
|
|
|
.domainIsPersistent = remoteDomainIsPersistent, /* 0.7.3 */
|
|
|
|
.domainIsUpdated = remoteDomainIsUpdated, /* 0.8.6 */
|
|
|
|
.cpuCompare = remoteCPUCompare, /* 0.7.5 */
|
|
|
|
.cpuBaseline = remoteCPUBaseline, /* 0.7.7 */
|
|
|
|
.domainGetJobInfo = remoteDomainGetJobInfo, /* 0.7.7 */
|
|
|
|
.domainAbortJob = remoteDomainAbortJob, /* 0.7.7 */
|
|
|
|
.domainMigrateSetMaxDowntime = remoteDomainMigrateSetMaxDowntime, /* 0.8.0 */
|
|
|
|
.domainMigrateSetMaxSpeed = remoteDomainMigrateSetMaxSpeed, /* 0.9.0 */
|
2011-08-26 18:10:21 +00:00
|
|
|
.domainMigrateGetMaxSpeed = remoteDomainMigrateGetMaxSpeed, /* 0.9.5 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainEventRegisterAny = remoteDomainEventRegisterAny, /* 0.8.0 */
|
|
|
|
.domainEventDeregisterAny = remoteDomainEventDeregisterAny, /* 0.8.0 */
|
|
|
|
.domainManagedSave = remoteDomainManagedSave, /* 0.8.0 */
|
|
|
|
.domainHasManagedSaveImage = remoteDomainHasManagedSaveImage, /* 0.8.0 */
|
|
|
|
.domainManagedSaveRemove = remoteDomainManagedSaveRemove, /* 0.8.0 */
|
|
|
|
.domainSnapshotCreateXML = remoteDomainSnapshotCreateXML, /* 0.8.0 */
|
|
|
|
.domainSnapshotGetXMLDesc = remoteDomainSnapshotGetXMLDesc, /* 0.8.0 */
|
|
|
|
.domainSnapshotNum = remoteDomainSnapshotNum, /* 0.8.0 */
|
|
|
|
.domainSnapshotListNames = remoteDomainSnapshotListNames, /* 0.8.0 */
|
2012-06-10 03:24:57 +00:00
|
|
|
.domainListAllSnapshots = remoteDomainListAllSnapshots, /* 0.9.13 */
|
2011-09-29 18:06:49 +00:00
|
|
|
.domainSnapshotNumChildren = remoteDomainSnapshotNumChildren, /* 0.9.7 */
|
2012-06-10 03:24:57 +00:00
|
|
|
.domainSnapshotListAllChildren = remoteDomainSnapshotListAllChildren, /* 0.9.13 */
|
2011-09-29 18:06:49 +00:00
|
|
|
.domainSnapshotListChildrenNames = remoteDomainSnapshotListChildrenNames, /* 0.9.7 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainSnapshotLookupByName = remoteDomainSnapshotLookupByName, /* 0.8.0 */
|
|
|
|
.domainHasCurrentSnapshot = remoteDomainHasCurrentSnapshot, /* 0.8.0 */
|
2011-09-24 19:19:35 +00:00
|
|
|
.domainSnapshotGetParent = remoteDomainSnapshotGetParent, /* 0.9.7 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainSnapshotCurrent = remoteDomainSnapshotCurrent, /* 0.8.0 */
|
|
|
|
.domainRevertToSnapshot = remoteDomainRevertToSnapshot, /* 0.8.0 */
|
2012-05-24 22:47:04 +00:00
|
|
|
.domainSnapshotIsCurrent = remoteDomainSnapshotIsCurrent, /* 0.9.13 */
|
|
|
|
.domainSnapshotHasMetadata = remoteDomainSnapshotHasMetadata, /* 0.9.13 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainSnapshotDelete = remoteDomainSnapshotDelete, /* 0.8.0 */
|
|
|
|
.qemuDomainMonitorCommand = remoteQemuDomainMonitorCommand, /* 0.8.3 */
|
2011-05-05 16:31:58 +00:00
|
|
|
.qemuDomainAttach = qemuDomainAttach, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainOpenConsole = remoteDomainOpenConsole, /* 0.8.6 */
|
2011-10-21 11:49:23 +00:00
|
|
|
.domainOpenGraphics = remoteDomainOpenGraphics, /* 0.9.7 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainInjectNMI = remoteDomainInjectNMI, /* 0.9.2 */
|
2011-02-01 14:23:40 +00:00
|
|
|
.domainMigrateBegin3 = remoteDomainMigrateBegin3, /* 0.9.2 */
|
|
|
|
.domainMigratePrepare3 = remoteDomainMigratePrepare3, /* 0.9.2 */
|
|
|
|
.domainMigratePrepareTunnel3 = remoteDomainMigratePrepareTunnel3, /* 0.9.2 */
|
|
|
|
.domainMigratePerform3 = remoteDomainMigratePerform3, /* 0.9.2 */
|
|
|
|
.domainMigrateFinish3 = remoteDomainMigrateFinish3, /* 0.9.2 */
|
|
|
|
.domainMigrateConfirm3 = remoteDomainMigrateConfirm3, /* 0.9.2 */
|
2011-06-07 09:11:15 +00:00
|
|
|
.domainSendKey = remoteDomainSendKey, /* 0.9.3 */
|
2011-07-22 05:31:16 +00:00
|
|
|
.domainBlockJobAbort = remoteDomainBlockJobAbort, /* 0.9.4 */
|
|
|
|
.domainGetBlockJobInfo = remoteDomainGetBlockJobInfo, /* 0.9.4 */
|
|
|
|
.domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
|
|
|
|
.domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
|
2012-02-01 04:39:18 +00:00
|
|
|
.domainBlockRebase = remoteDomainBlockRebase, /* 0.9.10 */
|
2011-11-24 13:44:59 +00:00
|
|
|
.setKeepAlive = remoteSetKeepAlive, /* 0.9.8 */
|
|
|
|
.isAlive = remoteIsAlive, /* 0.9.8 */
|
2011-11-29 07:15:14 +00:00
|
|
|
.nodeSuspendForDuration = remoteNodeSuspendForDuration, /* 0.9.8 */
|
2011-11-15 09:02:44 +00:00
|
|
|
.domainSetBlockIoTune = remoteDomainSetBlockIoTune, /* 0.9.8 */
|
|
|
|
.domainGetBlockIoTune = remoteDomainGetBlockIoTune, /* 0.9.8 */
|
2011-12-20 08:35:01 +00:00
|
|
|
.domainSetNumaParameters = remoteDomainSetNumaParameters, /* 0.9.9 */
|
|
|
|
.domainGetNumaParameters = remoteDomainGetNumaParameters, /* 0.9.9 */
|
2012-01-28 06:21:31 +00:00
|
|
|
.domainGetCPUStats = remoteDomainGetCPUStats, /* 0.9.10 */
|
2012-01-31 06:42:31 +00:00
|
|
|
.domainGetDiskErrors = remoteDomainGetDiskErrors, /* 0.9.10 */
|
2012-02-01 13:03:50 +00:00
|
|
|
.domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
|
|
|
|
.domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
|
2012-08-01 17:00:35 +00:00
|
|
|
.domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
|
2007-06-11 11:43:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static virNetworkDriver network_driver = {
|
2007-07-27 23:23:00 +00:00
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteNetworkOpen, /* 0.3.0 */
|
|
|
|
.close = remoteNetworkClose, /* 0.3.0 */
|
|
|
|
.numOfNetworks = remoteNumOfNetworks, /* 0.3.0 */
|
|
|
|
.listNetworks = remoteListNetworks, /* 0.3.0 */
|
|
|
|
.numOfDefinedNetworks = remoteNumOfDefinedNetworks, /* 0.3.0 */
|
|
|
|
.listDefinedNetworks = remoteListDefinedNetworks, /* 0.3.0 */
|
|
|
|
.networkLookupByUUID = remoteNetworkLookupByUUID, /* 0.3.0 */
|
|
|
|
.networkLookupByName = remoteNetworkLookupByName, /* 0.3.0 */
|
|
|
|
.networkCreateXML = remoteNetworkCreateXML, /* 0.3.0 */
|
|
|
|
.networkDefineXML = remoteNetworkDefineXML, /* 0.3.0 */
|
|
|
|
.networkUndefine = remoteNetworkUndefine, /* 0.3.0 */
|
|
|
|
.networkCreate = remoteNetworkCreate, /* 0.3.0 */
|
|
|
|
.networkDestroy = remoteNetworkDestroy, /* 0.3.0 */
|
|
|
|
.networkGetXMLDesc = remoteNetworkGetXMLDesc, /* 0.3.0 */
|
|
|
|
.networkGetBridgeName = remoteNetworkGetBridgeName, /* 0.3.0 */
|
|
|
|
.networkGetAutostart = remoteNetworkGetAutostart, /* 0.3.0 */
|
|
|
|
.networkSetAutostart = remoteNetworkSetAutostart, /* 0.3.0 */
|
|
|
|
.networkIsActive = remoteNetworkIsActive, /* 0.7.3 */
|
|
|
|
.networkIsPersistent = remoteNetworkIsPersistent, /* 0.7.3 */
|
2007-06-11 11:43:41 +00:00
|
|
|
};
|
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
static virInterfaceDriver interface_driver = {
|
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteInterfaceOpen, /* 0.7.2 */
|
|
|
|
.close = remoteInterfaceClose, /* 0.7.2 */
|
|
|
|
.numOfInterfaces = remoteNumOfInterfaces, /* 0.7.2 */
|
|
|
|
.listInterfaces = remoteListInterfaces, /* 0.7.2 */
|
|
|
|
.numOfDefinedInterfaces = remoteNumOfDefinedInterfaces, /* 0.7.2 */
|
|
|
|
.listDefinedInterfaces = remoteListDefinedInterfaces, /* 0.7.2 */
|
|
|
|
.interfaceLookupByName = remoteInterfaceLookupByName, /* 0.7.2 */
|
|
|
|
.interfaceLookupByMACString = remoteInterfaceLookupByMACString, /* 0.7.2 */
|
|
|
|
.interfaceGetXMLDesc = remoteInterfaceGetXMLDesc, /* 0.7.2 */
|
|
|
|
.interfaceDefineXML = remoteInterfaceDefineXML, /* 0.7.2 */
|
|
|
|
.interfaceUndefine = remoteInterfaceUndefine, /* 0.7.2 */
|
|
|
|
.interfaceCreate = remoteInterfaceCreate, /* 0.7.2 */
|
|
|
|
.interfaceDestroy = remoteInterfaceDestroy, /* 0.7.2 */
|
|
|
|
.interfaceIsActive = remoteInterfaceIsActive, /* 0.7.3 */
|
2011-05-05 13:35:40 +00:00
|
|
|
.interfaceChangeBegin = remoteInterfaceChangeBegin, /* 0.9.2 */
|
|
|
|
.interfaceChangeCommit = remoteInterfaceChangeCommit, /* 0.9.2 */
|
|
|
|
.interfaceChangeRollback = remoteInterfaceChangeRollback, /* 0.9.2 */
|
2009-05-20 14:26:49 +00:00
|
|
|
};
|
|
|
|
|
2008-02-20 15:23:36 +00:00
|
|
|
static virStorageDriver storage_driver = {
|
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteStorageOpen, /* 0.4.1 */
|
|
|
|
.close = remoteStorageClose, /* 0.4.1 */
|
|
|
|
.numOfPools = remoteNumOfStoragePools, /* 0.4.1 */
|
|
|
|
.listPools = remoteListStoragePools, /* 0.4.1 */
|
|
|
|
.numOfDefinedPools = remoteNumOfDefinedStoragePools, /* 0.4.1 */
|
|
|
|
.listDefinedPools = remoteListDefinedStoragePools, /* 0.4.1 */
|
|
|
|
.findPoolSources = remoteFindStoragePoolSources, /* 0.4.5 */
|
|
|
|
.poolLookupByName = remoteStoragePoolLookupByName, /* 0.4.1 */
|
|
|
|
.poolLookupByUUID = remoteStoragePoolLookupByUUID, /* 0.4.1 */
|
|
|
|
.poolLookupByVolume = remoteStoragePoolLookupByVolume, /* 0.4.1 */
|
|
|
|
.poolCreateXML = remoteStoragePoolCreateXML, /* 0.4.1 */
|
|
|
|
.poolDefineXML = remoteStoragePoolDefineXML, /* 0.4.1 */
|
|
|
|
.poolBuild = remoteStoragePoolBuild, /* 0.4.1 */
|
|
|
|
.poolUndefine = remoteStoragePoolUndefine, /* 0.4.1 */
|
|
|
|
.poolCreate = remoteStoragePoolCreate, /* 0.4.1 */
|
|
|
|
.poolDestroy = remoteStoragePoolDestroy, /* 0.4.1 */
|
|
|
|
.poolDelete = remoteStoragePoolDelete, /* 0.4.1 */
|
|
|
|
.poolRefresh = remoteStoragePoolRefresh, /* 0.4.1 */
|
|
|
|
.poolGetInfo = remoteStoragePoolGetInfo, /* 0.4.1 */
|
|
|
|
.poolGetXMLDesc = remoteStoragePoolGetXMLDesc, /* 0.4.1 */
|
|
|
|
.poolGetAutostart = remoteStoragePoolGetAutostart, /* 0.4.1 */
|
|
|
|
.poolSetAutostart = remoteStoragePoolSetAutostart, /* 0.4.1 */
|
|
|
|
.poolNumOfVolumes = remoteStoragePoolNumOfVolumes, /* 0.4.1 */
|
|
|
|
.poolListVolumes = remoteStoragePoolListVolumes, /* 0.4.1 */
|
|
|
|
|
|
|
|
.volLookupByName = remoteStorageVolLookupByName, /* 0.4.1 */
|
|
|
|
.volLookupByKey = remoteStorageVolLookupByKey, /* 0.4.1 */
|
|
|
|
.volLookupByPath = remoteStorageVolLookupByPath, /* 0.4.1 */
|
|
|
|
.volCreateXML = remoteStorageVolCreateXML, /* 0.4.1 */
|
|
|
|
.volCreateXMLFrom = remoteStorageVolCreateXMLFrom, /* 0.6.4 */
|
|
|
|
.volDownload = remoteStorageVolDownload, /* 0.9.0 */
|
|
|
|
.volUpload = remoteStorageVolUpload, /* 0.9.0 */
|
|
|
|
.volDelete = remoteStorageVolDelete, /* 0.4.1 */
|
|
|
|
.volWipe = remoteStorageVolWipe, /* 0.8.0 */
|
2012-01-09 16:05:03 +00:00
|
|
|
.volWipePattern = remoteStorageVolWipePattern, /* 0.9.10 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.volGetInfo = remoteStorageVolGetInfo, /* 0.4.1 */
|
|
|
|
.volGetXMLDesc = remoteStorageVolGetXMLDesc, /* 0.4.1 */
|
|
|
|
.volGetPath = remoteStorageVolGetPath, /* 0.4.1 */
|
2012-01-27 05:29:56 +00:00
|
|
|
.volResize = remoteStorageVolResize, /* 0.9.10 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.poolIsActive = remoteStoragePoolIsActive, /* 0.7.3 */
|
|
|
|
.poolIsPersistent = remoteStoragePoolIsPersistent, /* 0.7.3 */
|
2008-02-20 15:23:36 +00:00
|
|
|
};
|
|
|
|
|
2009-07-28 02:46:01 +00:00
|
|
|
static virSecretDriver secret_driver = {
|
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteSecretOpen, /* 0.7.1 */
|
|
|
|
.close = remoteSecretClose, /* 0.7.1 */
|
|
|
|
.numOfSecrets = remoteNumOfSecrets, /* 0.7.1 */
|
|
|
|
.listSecrets = remoteListSecrets, /* 0.7.1 */
|
|
|
|
.lookupByUUID = remoteSecretLookupByUUID, /* 0.7.1 */
|
|
|
|
.lookupByUsage = remoteSecretLookupByUsage, /* 0.7.1 */
|
|
|
|
.defineXML = remoteSecretDefineXML, /* 0.7.1 */
|
|
|
|
.getXMLDesc = remoteSecretGetXMLDesc, /* 0.7.1 */
|
|
|
|
.setValue = remoteSecretSetValue, /* 0.7.1 */
|
|
|
|
.getValue = remoteSecretGetValue, /* 0.7.1 */
|
|
|
|
.undefine = remoteSecretUndefine /* 0.7.1 */
|
2009-07-28 02:46:01 +00:00
|
|
|
};
|
|
|
|
|
2008-11-21 12:31:04 +00:00
|
|
|
static virDeviceMonitor dev_monitor = {
|
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteDevMonOpen, /* 0.5.0 */
|
|
|
|
.close = remoteDevMonClose, /* 0.5.0 */
|
|
|
|
.numOfDevices = remoteNodeNumOfDevices, /* 0.5.0 */
|
|
|
|
.listDevices = remoteNodeListDevices, /* 0.5.0 */
|
|
|
|
.deviceLookupByName = remoteNodeDeviceLookupByName, /* 0.5.0 */
|
|
|
|
.deviceGetXMLDesc = remoteNodeDeviceGetXMLDesc, /* 0.5.0 */
|
|
|
|
.deviceGetParent = remoteNodeDeviceGetParent, /* 0.5.0 */
|
|
|
|
.deviceNumOfCaps = remoteNodeDeviceNumOfCaps, /* 0.5.0 */
|
|
|
|
.deviceListCaps = remoteNodeDeviceListCaps, /* 0.5.0 */
|
|
|
|
.deviceCreateXML = remoteNodeDeviceCreateXML, /* 0.6.3 */
|
|
|
|
.deviceDestroy = remoteNodeDeviceDestroy /* 0.6.3 */
|
2008-11-21 12:31:04 +00:00
|
|
|
};
|
|
|
|
|
2010-03-25 17:46:03 +00:00
|
|
|
static virNWFilterDriver nwfilter_driver = {
|
|
|
|
.name = "remote",
|
2011-05-13 13:35:01 +00:00
|
|
|
.open = remoteNWFilterOpen, /* 0.8.0 */
|
|
|
|
.close = remoteNWFilterClose, /* 0.8.0 */
|
|
|
|
.nwfilterLookupByUUID = remoteNWFilterLookupByUUID, /* 0.8.0 */
|
|
|
|
.nwfilterLookupByName = remoteNWFilterLookupByName, /* 0.8.0 */
|
|
|
|
.getXMLDesc = remoteNWFilterGetXMLDesc, /* 0.8.0 */
|
|
|
|
.defineXML = remoteNWFilterDefineXML, /* 0.8.0 */
|
|
|
|
.undefine = remoteNWFilterUndefine, /* 0.8.0 */
|
|
|
|
.numOfNWFilters = remoteNumOfNWFilters, /* 0.8.0 */
|
|
|
|
.listNWFilters = remoteListNWFilters, /* 0.8.0 */
|
2010-03-25 17:46:03 +00:00
|
|
|
};
|
|
|
|
|
2008-11-21 12:31:04 +00:00
|
|
|
|
2008-06-26 09:37:51 +00:00
|
|
|
#ifdef WITH_LIBVIRTD
|
2007-10-27 01:23:28 +00:00
|
|
|
static virStateDriver state_driver = {
|
Fix return value in virStateInitialize impl for LXC
The LXC driver was mistakenly returning -1 for lxcStartup()
in scenarios that are not an error. This caused the libvirtd
to quit for unprivileged users. This fixes the return code
of LXC driver, and also adds a "name" field to the virStateDriver
struct and logging to make it easier to find these problems
in the future
* src/driver.h: Add a 'name' field to state driver to allow
easy identification during failures
* src/libvirt.c: Log name of failed driver for virStateInit
failures
* src/lxc/lxc_driver.c: Don't return a failure code for
lxcStartup() if LXC is not available on this host, simply
disable the driver.
* src/network/bridge_driver.c, src/node_device/node_device_devkit.c,
src/node_device/node_device_hal.c, src/opennebula/one_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/secret/secret_driver.c, src/storage/storage_driver.c,
src/uml/uml_driver.c, src/xen/xen_driver.c: Fill in name
field in virStateDriver struct
2009-11-02 23:18:19 +00:00
|
|
|
.name = "Remote",
|
2008-10-06 15:40:37 +00:00
|
|
|
.initialize = remoteStartup,
|
2007-10-27 01:23:28 +00:00
|
|
|
};
|
2008-06-26 09:37:51 +00:00
|
|
|
#endif
|
2007-10-27 01:23:28 +00:00
|
|
|
|
|
|
|
|
2007-06-25 08:41:17 +00:00
|
|
|
/** remoteRegister:
|
2007-06-11 11:43:41 +00:00
|
|
|
*
|
|
|
|
* Register driver with libvirt driver system.
|
2007-06-25 08:41:17 +00:00
|
|
|
*
|
|
|
|
* Returns -1 on error.
|
2007-06-11 11:43:41 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
remoteRegister (void)
|
|
|
|
{
|
2011-09-22 12:59:06 +00:00
|
|
|
remoteDriver = &remote_driver;
|
|
|
|
|
2009-08-17 14:05:22 +00:00
|
|
|
if (virRegisterDriver (&remote_driver) == -1) return -1;
|
2007-06-11 11:43:41 +00:00
|
|
|
if (virRegisterNetworkDriver (&network_driver) == -1) return -1;
|
2009-05-20 14:26:49 +00:00
|
|
|
if (virRegisterInterfaceDriver (&interface_driver) == -1) return -1;
|
2008-02-20 15:23:36 +00:00
|
|
|
if (virRegisterStorageDriver (&storage_driver) == -1) return -1;
|
2008-11-21 12:31:04 +00:00
|
|
|
if (virRegisterDeviceMonitor (&dev_monitor) == -1) return -1;
|
2009-07-28 02:46:01 +00:00
|
|
|
if (virRegisterSecretDriver (&secret_driver) == -1) return -1;
|
2010-03-25 17:46:03 +00:00
|
|
|
if (virRegisterNWFilterDriver(&nwfilter_driver) == -1) return -1;
|
2008-06-26 09:37:51 +00:00
|
|
|
#ifdef WITH_LIBVIRTD
|
2007-10-27 01:23:28 +00:00
|
|
|
if (virRegisterStateDriver (&state_driver) == -1) return -1;
|
2008-06-26 09:37:51 +00:00
|
|
|
#endif
|
2007-06-11 11:43:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|