2007-06-11 11:47:01 +00:00
|
|
|
/*
|
2009-07-10 11:20:03 +00:00
|
|
|
* remote.c: handlers for RPC method calls
|
2007-06-11 11:47:01 +00:00
|
|
|
*
|
2012-01-02 21:35:12 +00:00
|
|
|
* Copyright (C) 2007-2012 Red Hat, Inc.
|
2007-06-11 11:47:01 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
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:47:01 +00:00
|
|
|
*
|
|
|
|
* Author: Richard W.M. Jones <rjones@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2009-02-05 16:28:30 +00:00
|
|
|
#include "virterror_internal.h"
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2009-08-06 12:54:08 +00:00
|
|
|
#if HAVE_POLKIT0
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <polkit/polkit.h>
|
|
|
|
# include <polkit-dbus/polkit-dbus.h>
|
2007-12-05 18:21:27 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-10 11:20:03 +00:00
|
|
|
#include "remote.h"
|
2011-05-16 17:13:11 +00:00
|
|
|
#include "libvirtd.h"
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "libvirt_internal.h"
|
|
|
|
#include "datatypes.h"
|
2008-06-06 10:52:01 +00:00
|
|
|
#include "memory.h"
|
2011-05-16 17:13:11 +00:00
|
|
|
#include "logging.h"
|
2009-05-19 13:15:50 +00:00
|
|
|
#include "util.h"
|
2009-09-30 10:51:54 +00:00
|
|
|
#include "stream.h"
|
2010-10-12 11:22:03 +00:00
|
|
|
#include "uuid.h"
|
2010-04-17 02:09:25 +00:00
|
|
|
#include "libvirt/libvirt-qemu.h"
|
2011-03-22 17:55:45 +00:00
|
|
|
#include "command.h"
|
2011-06-24 18:16:05 +00:00
|
|
|
#include "intprops.h"
|
2011-05-16 17:13:11 +00:00
|
|
|
#include "virnetserverservice.h"
|
2011-07-07 21:12:26 +00:00
|
|
|
#include "virnetserver.h"
|
2011-10-21 11:49:23 +00:00
|
|
|
#include "virfile.h"
|
2012-01-02 22:03:19 +00:00
|
|
|
#include "virtypedparam.h"
|
2012-04-19 14:34:35 +00:00
|
|
|
#include "virdbus.h"
|
2011-05-16 17:13:11 +00:00
|
|
|
#include "remote_protocol.h"
|
|
|
|
#include "qemu_protocol.h"
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2011-05-30 10:58:57 +00:00
|
|
|
#if SIZEOF_LONG < 8
|
2012-03-02 23:58:05 +00:00
|
|
|
# define HYPER_TO_TYPE(_type, _to, _from) \
|
|
|
|
do { \
|
|
|
|
if ((_from) != (_type)(_from)) { \
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_OVERFLOW, \
|
|
|
|
_("conversion from hyper to %s overflowed"), \
|
|
|
|
#_type); \
|
2012-03-02 23:58:05 +00:00
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
(_to) = (_from); \
|
2011-05-30 10:58:57 +00:00
|
|
|
} 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
|
|
|
|
|
2011-04-12 16:34:30 +00:00
|
|
|
static virDomainPtr get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain);
|
|
|
|
static virNetworkPtr get_nonnull_network(virConnectPtr conn, remote_nonnull_network network);
|
|
|
|
static virInterfacePtr get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface);
|
|
|
|
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);
|
|
|
|
static virSecretPtr get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret);
|
|
|
|
static virNWFilterPtr get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
|
2011-04-13 18:10:03 +00:00
|
|
|
static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot);
|
2011-04-12 16:34:30 +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);
|
|
|
|
static void make_nonnull_interface(remote_nonnull_interface *interface_dst, virInterfacePtr interface_src);
|
|
|
|
static void make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src);
|
|
|
|
static void make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src);
|
|
|
|
static void make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src);
|
|
|
|
static void make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
|
|
|
|
static void make_nonnull_nwfilter(remote_nonnull_nwfilter *net_dst, virNWFilterPtr nwfilter_src);
|
|
|
|
static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
static virTypedParameterPtr
|
|
|
|
remoteDeserializeTypedParameters(remote_typed_param *args_params_val,
|
|
|
|
u_int args_params_len,
|
|
|
|
int limit,
|
|
|
|
int *nparams);
|
2008-12-04 22:03:24 +00:00
|
|
|
|
2012-01-31 06:42:31 +00:00
|
|
|
static int
|
|
|
|
remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
|
|
|
|
int nerrors,
|
|
|
|
remote_domain_disk_error **ret_errors_val,
|
|
|
|
u_int *ret_errors_len);
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
#include "remote_dispatch.h"
|
|
|
|
#include "qemu_dispatch.h"
|
2010-04-17 02:09:25 +00:00
|
|
|
|
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
/* Prototypes */
|
|
|
|
static void
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(virNetServerClientPtr client,
|
|
|
|
virNetServerProgramPtr program,
|
2011-04-12 16:34:30 +00:00
|
|
|
int procnr,
|
|
|
|
xdrproc_t proc,
|
|
|
|
void *data);
|
2007-12-05 15:24:15 +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 remoteRelayDomainEventLifecycle(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int event,
|
|
|
|
int detail,
|
|
|
|
void *opaque)
|
2008-10-23 13:18:18 +00:00
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = opaque;
|
2010-03-19 14:28:23 +00:00
|
|
|
remote_domain_event_lifecycle_msg data;
|
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
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain lifecycle event %d %d", event, detail);
|
2009-07-10 11:48:50 +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
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain(&data.dom, 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
|
|
|
data.event = event;
|
|
|
|
data.detail = detail;
|
2009-01-20 19:25:15 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_lifecycle_msg, &data);
|
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
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2010-03-18 15:25:38 +00:00
|
|
|
static int remoteRelayDomainEventReboot(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = opaque;
|
2010-03-18 15:25:38 +00:00
|
|
|
remote_domain_event_reboot_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain reboot event %s %d", dom->name, dom->id);
|
2010-03-18 15:25:38 +00:00
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain(&data.dom, dom);
|
2010-03-18 15:25:38 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_REBOOT,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_reboot_msg, &data);
|
2010-03-18 15:25:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2010-03-18 18:28:15 +00:00
|
|
|
static int remoteRelayDomainEventRTCChange(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
long long offset,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = opaque;
|
2010-03-18 18:28:15 +00:00
|
|
|
remote_domain_event_rtc_change_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain rtc change event %s %d %lld", dom->name, dom->id, offset);
|
2010-03-18 18:28:15 +00:00
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain(&data.dom, dom);
|
2010-03-18 18:28:15 +00:00
|
|
|
data.offset = offset;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_rtc_change_msg, &data);
|
2010-03-18 18:28:15 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
static int remoteRelayDomainEventWatchdog(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int action,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = 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
|
|
|
remote_domain_event_watchdog_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain watchdog event %s %d %d", dom->name, dom->id, 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
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain(&data.dom, 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
|
|
|
data.action = action;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_WATCHDOG,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_watchdog_msg, &data);
|
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
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
static int remoteRelayDomainEventIOError(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
const char *srcPath,
|
|
|
|
const char *devAlias,
|
|
|
|
int action,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = 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
|
|
|
remote_domain_event_io_error_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain io error %s %d %s %s %d", dom->name, dom->id, srcPath, devAlias, 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
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-09-20 03:51:50 +00:00
|
|
|
data.srcPath = strdup(srcPath);
|
|
|
|
if (data.srcPath == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
data.devAlias = strdup(devAlias);
|
|
|
|
if (data.devAlias == NULL)
|
|
|
|
goto mem_error;
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain(&data.dom, 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
|
|
|
data.action = action;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_io_error_msg, &data);
|
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
|
|
|
|
|
|
|
return 0;
|
2011-09-20 03:51:50 +00:00
|
|
|
mem_error:
|
|
|
|
virReportOOMError();
|
2011-09-20 18:11:32 +00:00
|
|
|
VIR_FREE(data.srcPath);
|
|
|
|
VIR_FREE(data.devAlias);
|
2011-09-20 03:51:50 +00:00
|
|
|
return -1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
static int remoteRelayDomainEventIOErrorReason(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
const char *srcPath,
|
|
|
|
const char *devAlias,
|
|
|
|
int action,
|
|
|
|
const char *reason,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = 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
|
|
|
remote_domain_event_io_error_reason_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain io error %s %d %s %s %d %s",
|
|
|
|
dom->name, dom->id, srcPath, devAlias, action, 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
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-09-20 03:51:50 +00:00
|
|
|
data.srcPath = strdup(srcPath);
|
|
|
|
if (data.srcPath == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
data.devAlias = strdup(devAlias);
|
|
|
|
if (data.devAlias == NULL)
|
|
|
|
goto mem_error;
|
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
|
|
|
data.action = action;
|
2011-09-20 03:51:50 +00:00
|
|
|
data.reason = strdup(reason);
|
|
|
|
if (data.reason == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
|
|
|
|
make_nonnull_domain(&data.dom, 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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_io_error_reason_msg, &data);
|
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
|
|
|
|
|
|
|
return 0;
|
2011-09-20 03:51:50 +00:00
|
|
|
|
|
|
|
mem_error:
|
|
|
|
virReportOOMError();
|
2011-09-20 18:11:32 +00:00
|
|
|
VIR_FREE(data.srcPath);
|
|
|
|
VIR_FREE(data.devAlias);
|
|
|
|
VIR_FREE(data.reason);
|
2011-09-20 03:51:50 +00:00
|
|
|
return -1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int phase,
|
|
|
|
virDomainEventGraphicsAddressPtr local,
|
|
|
|
virDomainEventGraphicsAddressPtr remote,
|
|
|
|
const char *authScheme,
|
|
|
|
virDomainEventGraphicsSubjectPtr subject,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = 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
|
|
|
remote_domain_event_graphics_msg data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Relaying domain graphics event %s %d %d - %d %s %s - %d %s %s - %s", dom->name, dom->id, phase,
|
|
|
|
local->family, local->service, local->node,
|
|
|
|
remote->family, remote->service, remote->node,
|
|
|
|
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
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Subject %d", subject->nidentity);
|
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++) {
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG(" %s=%s", subject->identities[i].type, subject->identities[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
|
|
|
}
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
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
|
|
|
data.phase = phase;
|
|
|
|
data.local.family = local->family;
|
|
|
|
data.remote.family = remote->family;
|
2011-09-20 03:51:50 +00:00
|
|
|
data.authScheme = strdup(authScheme);
|
|
|
|
if (data.authScheme == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
|
|
|
|
data.local.node = strdup(local->node);
|
|
|
|
if (data.local.node == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
data.local.service = strdup(local->service);
|
|
|
|
if (data.local.service == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
|
|
|
|
data.remote.node = strdup(remote->node);
|
|
|
|
if (data.remote.node == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
data.remote.service = strdup(remote->service);
|
|
|
|
if (data.remote.service == NULL)
|
|
|
|
goto mem_error;
|
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
|
|
|
|
|
|
|
data.subject.subject_len = subject->nidentity;
|
2011-09-20 03:51:50 +00:00
|
|
|
if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < 0)
|
|
|
|
goto mem_error;
|
|
|
|
|
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 < data.subject.subject_len ; i++) {
|
2011-09-20 03:51:50 +00:00
|
|
|
data.subject.subject_val[i].type = strdup(subject->identities[i].type);
|
|
|
|
if (data.subject.subject_val[i].type == NULL)
|
|
|
|
goto mem_error;
|
|
|
|
data.subject.subject_val[i].name = strdup(subject->identities[i].name);
|
|
|
|
if (data.subject.subject_val[i].name == NULL)
|
|
|
|
goto mem_error;
|
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
|
|
|
}
|
2011-09-20 03:51:50 +00:00
|
|
|
make_nonnull_domain(&data.dom, 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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-04-12 16:34:30 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_GRAPHICS,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_graphics_msg, &data);
|
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
|
|
|
|
|
|
|
return 0;
|
2011-09-20 03:51:50 +00:00
|
|
|
|
|
|
|
mem_error:
|
|
|
|
virReportOOMError();
|
2011-09-20 18:11:32 +00:00
|
|
|
VIR_FREE(data.authScheme);
|
|
|
|
VIR_FREE(data.local.node);
|
|
|
|
VIR_FREE(data.local.service);
|
|
|
|
VIR_FREE(data.remote.node);
|
|
|
|
VIR_FREE(data.remote.service);
|
2011-09-20 03:51:50 +00:00
|
|
|
if (data.subject.subject_val != NULL) {
|
|
|
|
for (i = 0 ; i < data.subject.subject_len ; i++) {
|
2011-09-20 18:11:32 +00:00
|
|
|
VIR_FREE(data.subject.subject_val[i].type);
|
|
|
|
VIR_FREE(data.subject.subject_val[i].name);
|
2011-09-20 03:51:50 +00:00
|
|
|
}
|
2011-09-20 18:11:32 +00:00
|
|
|
VIR_FREE(data.subject.subject_val);
|
2011-09-20 03:51:50 +00:00
|
|
|
}
|
|
|
|
return -1;
|
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
|
|
|
}
|
|
|
|
|
2011-07-22 05:57:42 +00:00
|
|
|
static int remoteRelayDomainEventBlockJob(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
const char *path,
|
|
|
|
int type,
|
|
|
|
int status,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
virNetServerClientPtr client = opaque;
|
|
|
|
remote_domain_event_block_job_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain block job event %s %d %s %i, %i",
|
|
|
|
dom->name, dom->id, path, type, status);
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-09-20 03:51:50 +00:00
|
|
|
data.path = strdup(path);
|
|
|
|
if (data.path == NULL)
|
|
|
|
goto mem_error;
|
2011-07-22 05:57:42 +00:00
|
|
|
data.type = type;
|
|
|
|
data.status = status;
|
2011-09-20 03:51:50 +00:00
|
|
|
make_nonnull_domain(&data.dom, dom);
|
2011-07-22 05:57:42 +00:00
|
|
|
|
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
|
|
|
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_block_job_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
2011-09-20 03:51:50 +00:00
|
|
|
|
|
|
|
mem_error:
|
|
|
|
virReportOOMError();
|
2011-09-20 18:11:32 +00:00
|
|
|
VIR_FREE(data.path);
|
2011-09-20 03:51:50 +00:00
|
|
|
return -1;
|
2011-07-22 05:57:42 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-05-29 12:21:53 +00:00
|
|
|
static int remoteRelayDomainEventControlError(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
void *opaque)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client = opaque;
|
2011-05-29 12:21:53 +00:00
|
|
|
remote_domain_event_control_error_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain control error %s %d", dom->name, dom->id);
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-05-29 12:21:53 +00:00
|
|
|
make_nonnull_domain(&data.dom, dom);
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
2011-05-29 12:21:53 +00:00
|
|
|
REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_control_error_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-18 14:15:42 +00:00
|
|
|
static int remoteRelayDomainEventDiskChange(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
const char *oldSrcPath,
|
|
|
|
const char *newSrcPath,
|
|
|
|
const char *devAlias,
|
|
|
|
int reason,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
virNetServerClientPtr client = opaque;
|
|
|
|
remote_domain_event_disk_change_msg data;
|
|
|
|
char **oldSrcPath_p = NULL, **newSrcPath_p = NULL;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain %s %d disk change %s %s %s %d",
|
|
|
|
dom->name, dom->id, oldSrcPath, newSrcPath, devAlias, reason);
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2011-10-18 14:15:42 +00:00
|
|
|
if (oldSrcPath &&
|
|
|
|
((VIR_ALLOC(oldSrcPath_p) < 0) ||
|
|
|
|
!(*oldSrcPath_p = strdup(oldSrcPath))))
|
|
|
|
goto mem_error;
|
|
|
|
|
|
|
|
if (newSrcPath &&
|
|
|
|
((VIR_ALLOC(newSrcPath_p) < 0) ||
|
|
|
|
!(*newSrcPath_p = strdup(newSrcPath))))
|
|
|
|
goto mem_error;
|
|
|
|
|
|
|
|
data.oldSrcPath = oldSrcPath_p;
|
|
|
|
data.newSrcPath = newSrcPath_p;
|
|
|
|
if (!(data.devAlias = strdup(devAlias)))
|
|
|
|
goto mem_error;
|
|
|
|
data.reason = reason;
|
|
|
|
|
|
|
|
make_nonnull_domain(&data.dom, dom);
|
|
|
|
|
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
|
|
|
REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_disk_change_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
mem_error:
|
2011-10-26 09:12:45 +00:00
|
|
|
VIR_FREE(oldSrcPath_p);
|
|
|
|
VIR_FREE(newSrcPath_p);
|
2011-10-18 14:15:42 +00:00
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-23 13:44:50 +00:00
|
|
|
static int remoteRelayDomainEventTrayChange(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
const char *devAlias,
|
|
|
|
int reason,
|
|
|
|
void *opaque) {
|
|
|
|
virNetServerClientPtr client = opaque;
|
|
|
|
remote_domain_event_tray_change_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain %s %d tray change devAlias: %s reason: %d",
|
|
|
|
dom->name, dom->id, devAlias, reason);
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2012-03-23 13:44:50 +00:00
|
|
|
|
|
|
|
if (!(data.devAlias = strdup(devAlias))) {
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
data.reason = reason;
|
|
|
|
|
|
|
|
make_nonnull_domain(&data.dom, dom);
|
|
|
|
|
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
|
|
|
REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_tray_change_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-23 14:43:14 +00:00
|
|
|
static int remoteRelayDomainEventPMWakeup(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
2012-09-06 14:56:08 +00:00
|
|
|
int reason ATTRIBUTE_UNUSED,
|
2012-03-23 14:43:14 +00:00
|
|
|
void *opaque) {
|
|
|
|
virNetServerClientPtr client = opaque;
|
|
|
|
remote_domain_event_pmwakeup_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain %s %d system pmwakeup", dom->name, dom->id);
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2012-03-23 14:43:14 +00:00
|
|
|
make_nonnull_domain(&data.dom, dom);
|
|
|
|
|
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
|
|
|
REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_pmwakeup_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-23 14:50:36 +00:00
|
|
|
static int remoteRelayDomainEventPMSuspend(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
2012-09-06 14:56:08 +00:00
|
|
|
int reason ATTRIBUTE_UNUSED,
|
2012-03-23 14:50:36 +00:00
|
|
|
void *opaque) {
|
|
|
|
virNetServerClientPtr client = opaque;
|
|
|
|
remote_domain_event_pmsuspend_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain %s %d system pmsuspend", dom->name, dom->id);
|
|
|
|
|
|
|
|
/* build return data */
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&data, 0, sizeof(data));
|
2012-03-23 14:50:36 +00:00
|
|
|
make_nonnull_domain(&data.dom, dom);
|
|
|
|
|
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
|
|
|
REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_pmsuspend_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-13 09:05:17 +00:00
|
|
|
static int
|
|
|
|
remoteRelayDomainEventBalloonChange(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
unsigned long long actual,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
virNetServerClientPtr client = opaque;
|
|
|
|
remote_domain_event_balloon_change_msg data;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
VIR_DEBUG("Relaying domain balloon change event %s %d %lld", dom->name, dom->id, actual);
|
|
|
|
|
|
|
|
/* build return data */
|
|
|
|
memset(&data, 0, sizeof(data));
|
|
|
|
make_nonnull_domain(&data.dom, dom);
|
|
|
|
data.actual = actual;
|
|
|
|
|
|
|
|
remoteDispatchDomainEventSend(client, remoteProgram,
|
|
|
|
REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE,
|
|
|
|
(xdrproc_t)xdr_remote_domain_event_balloon_change_msg, &data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-18 15:25:38 +00:00
|
|
|
static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
|
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
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
|
2010-03-18 15:25:38 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventReboot),
|
2010-03-18 18:28:15 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventRTCChange),
|
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
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventWatchdog),
|
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
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventIOError),
|
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
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventGraphics),
|
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
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventIOErrorReason),
|
2011-05-29 12:21:53 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventControlError),
|
2011-07-22 05:57:42 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockJob),
|
2011-10-18 14:15:42 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventDiskChange),
|
2012-03-23 13:44:50 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventTrayChange),
|
2012-03-23 14:43:14 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMWakeup),
|
2012-03-23 14:50:36 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMSuspend),
|
2012-07-13 09:05:17 +00:00
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBalloonChange),
|
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
|
|
|
};
|
|
|
|
|
|
|
|
verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
/*
|
|
|
|
* You must hold lock for at least the client
|
|
|
|
* We don't free stuff here, merely disconnect the client's
|
|
|
|
* network socket & resources.
|
|
|
|
* We keep the libvirt connection open until any async
|
|
|
|
* jobs have finished, then clean it up elsewhere
|
|
|
|
*/
|
2012-08-09 11:31:34 +00:00
|
|
|
void remoteClientFreeFunc(void *data)
|
2011-05-16 17:13:11 +00:00
|
|
|
{
|
|
|
|
struct daemonClientPrivate *priv = data;
|
|
|
|
|
|
|
|
/* Deregister event delivery callback */
|
|
|
|
if (priv->conn) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++) {
|
|
|
|
if (priv->domainEventCallbackID[i] != -1) {
|
|
|
|
VIR_DEBUG("Deregistering to relay remote events %d", i);
|
|
|
|
virConnectDomainEventDeregisterAny(priv->conn,
|
|
|
|
priv->domainEventCallbackID[i]);
|
|
|
|
}
|
|
|
|
priv->domainEventCallbackID[i] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virConnectClose(priv->conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FREE(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-14 22:44:45 +00:00
|
|
|
static void remoteClientCloseFunc(virNetServerClientPtr client)
|
|
|
|
{
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
daemonRemoveAllClientStreams(priv->streams);
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
|
2012-08-09 11:31:34 +00:00
|
|
|
void *remoteClientInitHook(virNetServerClientPtr client,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
2011-05-16 17:13:11 +00:00
|
|
|
{
|
|
|
|
struct daemonClientPrivate *priv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(priv) < 0) {
|
|
|
|
virReportOOMError();
|
2012-08-09 11:31:34 +00:00
|
|
|
return NULL;
|
2011-05-16 17:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virMutexInit(&priv->lock) < 0) {
|
|
|
|
VIR_FREE(priv);
|
|
|
|
virReportOOMError();
|
2012-08-09 11:31:34 +00:00
|
|
|
return NULL;
|
2011-05-16 17:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++)
|
|
|
|
priv->domainEventCallbackID[i] = -1;
|
|
|
|
|
2011-08-14 22:44:45 +00:00
|
|
|
virNetServerClientSetCloseHook(client, remoteClientCloseFunc);
|
2012-08-09 11:31:34 +00:00
|
|
|
return priv;
|
2011-05-16 17:13:11 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/*----- Functions. -----*/
|
|
|
|
|
|
|
|
static int
|
2011-08-24 13:33:34 +00:00
|
|
|
remoteDispatchOpen(virNetServerPtr server,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
struct remote_open_args *args)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
|
|
|
const char *name;
|
2011-07-07 17:53:04 +00:00
|
|
|
unsigned int flags;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("priv=%p conn=%p", priv, priv->conn);
|
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
/* Already opened? */
|
|
|
|
if (priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection already open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-08-24 13:33:34 +00:00
|
|
|
if (virNetServerKeepAliveRequired(server) && !priv->keepalive_supported) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
|
_("keepalive support is required to connect"));
|
2011-08-24 13:33:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
name = args->name ? *args->name : NULL;
|
|
|
|
|
|
|
|
/* If this connection arrived on a readonly socket, force
|
|
|
|
* the connection to be readonly.
|
|
|
|
*/
|
|
|
|
flags = args->flags;
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNetServerClientGetReadonly(client))
|
|
|
|
flags |= VIR_CONNECT_RO;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->conn =
|
2007-06-11 11:47:01 +00:00
|
|
|
flags & VIR_CONNECT_RO
|
2011-04-12 16:34:30 +00:00
|
|
|
? virConnectOpenReadOnly(name)
|
|
|
|
: virConnectOpen(name);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (priv->conn == NULL)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
2008-12-04 22:12:53 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchClose(virNetServerPtr server ATTRIBUTE_UNUSED,
|
2011-07-08 11:54:29 +00:00
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
2011-07-08 11:54:29 +00:00
|
|
|
virNetServerClientDelayedClose(client);
|
2008-12-04 22:12:53 +00:00
|
|
|
return 0;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
|
2007-06-22 13:16:10 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetSchedulerType(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_domain_get_scheduler_type_args *args,
|
|
|
|
remote_domain_get_scheduler_type_ret *ret)
|
2007-06-22 13:16:10 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2007-06-22 13:16:10 +00:00
|
|
|
char *type;
|
|
|
|
int nparams;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-04-13 17:50:40 +00:00
|
|
|
if (!(type = virDomainGetSchedulerType(dom, &nparams)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
|
|
|
ret->type = type;
|
|
|
|
ret->nparams = nparams;
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
2011-10-12 09:26:34 +00:00
|
|
|
/* Helper to serialize typed parameters. This also filters out any string
|
|
|
|
* parameters that must not be returned to older clients. */
|
2011-05-17 20:58:40 +00:00
|
|
|
static int
|
|
|
|
remoteSerializeTypedParameters(virTypedParameterPtr params,
|
|
|
|
int nparams,
|
2011-05-30 18:12:18 +00:00
|
|
|
remote_typed_param **ret_params_val,
|
2011-10-12 09:26:34 +00:00
|
|
|
u_int *ret_params_len,
|
|
|
|
unsigned int flags)
|
2011-05-17 20:58:40 +00:00
|
|
|
{
|
|
|
|
int i;
|
2011-10-12 09:26:34 +00:00
|
|
|
int j;
|
2011-05-17 20:58:40 +00:00
|
|
|
int rv = -1;
|
|
|
|
remote_typed_param *val;
|
|
|
|
|
|
|
|
*ret_params_len = nparams;
|
|
|
|
if (VIR_ALLOC_N(val, nparams) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-10-12 09:26:34 +00:00
|
|
|
for (i = 0, j = 0; i < nparams; ++i) {
|
2012-01-28 06:21:31 +00:00
|
|
|
/* virDomainGetCPUStats can return a sparse array; also, we
|
|
|
|
* can't pass back strings to older clients. */
|
|
|
|
if (!params[i].type ||
|
|
|
|
(!(flags & VIR_TYPED_PARAM_STRING_OKAY) &&
|
|
|
|
params[i].type == VIR_TYPED_PARAM_STRING)) {
|
2011-10-12 09:26:34 +00:00
|
|
|
--*ret_params_len;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
/* remoteDispatchClientRequest will free this: */
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].field = strdup(params[i].field);
|
|
|
|
if (val[j].field == NULL) {
|
2011-05-17 20:58:40 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.type = params[i].type;
|
2011-11-16 08:38:11 +00:00
|
|
|
switch (params[i].type) {
|
2011-05-17 20:58:40 +00:00
|
|
|
case VIR_TYPED_PARAM_INT:
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.remote_typed_param_value_u.i = params[i].value.i;
|
2011-05-17 20:58:40 +00:00
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_UINT:
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.remote_typed_param_value_u.ui = params[i].value.ui;
|
2011-05-17 20:58:40 +00:00
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_LLONG:
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.remote_typed_param_value_u.l = params[i].value.l;
|
2011-05-17 20:58:40 +00:00
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_ULLONG:
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.remote_typed_param_value_u.ul = params[i].value.ul;
|
2011-05-17 20:58:40 +00:00
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_DOUBLE:
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.remote_typed_param_value_u.d = params[i].value.d;
|
2011-05-17 20:58:40 +00:00
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_BOOLEAN:
|
2011-10-12 09:26:34 +00:00
|
|
|
val[j].value.remote_typed_param_value_u.b = params[i].value.b;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_STRING:
|
|
|
|
val[j].value.remote_typed_param_value_u.s =
|
|
|
|
strdup(params[i].value.s);
|
|
|
|
if (val[j].value.remote_typed_param_value_u.s == NULL) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2011-05-17 20:58:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"),
|
|
|
|
params[i].type);
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2011-10-12 09:26:34 +00:00
|
|
|
j++;
|
2011-05-17 20:58:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*ret_params_val = val;
|
|
|
|
val = NULL;
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (val) {
|
2011-10-12 09:26:34 +00:00
|
|
|
for (i = 0; i < nparams; i++) {
|
2011-05-17 20:58:40 +00:00
|
|
|
VIR_FREE(val[i].field);
|
2011-12-20 15:22:25 +00:00
|
|
|
if (val[i].value.type == VIR_TYPED_PARAM_STRING)
|
2011-10-12 09:26:34 +00:00
|
|
|
VIR_FREE(val[i].value.remote_typed_param_value_u.s);
|
|
|
|
}
|
2011-05-17 20:58:40 +00:00
|
|
|
VIR_FREE(val);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper to deserialize typed parameters. */
|
|
|
|
static virTypedParameterPtr
|
2011-05-30 18:12:18 +00:00
|
|
|
remoteDeserializeTypedParameters(remote_typed_param *args_params_val,
|
|
|
|
u_int args_params_len,
|
2011-05-17 20:58:40 +00:00
|
|
|
int limit,
|
|
|
|
int *nparams)
|
|
|
|
{
|
2011-10-12 09:26:34 +00:00
|
|
|
int i = 0;
|
2011-05-17 20:58:40 +00:00
|
|
|
int rv = -1;
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
|
|
|
|
/* Check the length of the returned list carefully. */
|
|
|
|
if (args_params_len > limit) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (VIR_ALLOC_N(params, args_params_len) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nparams = args_params_len;
|
|
|
|
|
|
|
|
/* Deserialise the result. */
|
|
|
|
for (i = 0; i < args_params_len; ++i) {
|
|
|
|
if (virStrcpyStatic(params[i].field,
|
|
|
|
args_params_val[i].field) == NULL) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Parameter %s too big for destination"),
|
|
|
|
args_params_val[i].field);
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
params[i].type = args_params_val[i].value.type;
|
|
|
|
switch (params[i].type) {
|
|
|
|
case VIR_TYPED_PARAM_INT:
|
|
|
|
params[i].value.i =
|
|
|
|
args_params_val[i].value.remote_typed_param_value_u.i;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_UINT:
|
|
|
|
params[i].value.ui =
|
|
|
|
args_params_val[i].value.remote_typed_param_value_u.ui;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_LLONG:
|
|
|
|
params[i].value.l =
|
|
|
|
args_params_val[i].value.remote_typed_param_value_u.l;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_ULLONG:
|
|
|
|
params[i].value.ul =
|
|
|
|
args_params_val[i].value.remote_typed_param_value_u.ul;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_DOUBLE:
|
|
|
|
params[i].value.d =
|
|
|
|
args_params_val[i].value.remote_typed_param_value_u.d;
|
|
|
|
break;
|
|
|
|
case VIR_TYPED_PARAM_BOOLEAN:
|
|
|
|
params[i].value.b =
|
|
|
|
args_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(args_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 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown parameter type: %d"),
|
|
|
|
params[i].type);
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2011-10-12 09:26:34 +00:00
|
|
|
if (rv < 0) {
|
2012-01-31 03:20:40 +00:00
|
|
|
virTypedParameterArrayClear(params, i);
|
2011-05-17 20:58:40 +00:00
|
|
|
VIR_FREE(params);
|
2011-10-12 09:26:34 +00:00
|
|
|
}
|
2011-05-17 20:58:40 +00:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
2007-06-22 13:16:10 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_domain_get_scheduler_parameters_args *args,
|
|
|
|
remote_domain_get_scheduler_parameters_ret *ret)
|
2007-06-22 13:16:10 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2011-05-26 17:39:04 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
2011-05-03 17:24:23 +00:00
|
|
|
int nparams = args->nparams;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2007-06-22 13:16:10 +00:00
|
|
|
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto no_memory;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-04-13 17:50:40 +00:00
|
|
|
if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
2011-05-30 18:12:18 +00:00
|
|
|
&ret->params.params_val,
|
2011-10-12 09:26:34 +00:00
|
|
|
&ret->params.params_len,
|
|
|
|
0) < 0)
|
2011-05-17 21:45:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-12-20 15:22:25 +00:00
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
2011-05-17 21:45:03 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2012-05-20 14:26:36 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchConnectListAllDomains(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_connect_list_all_domains_args *args,
|
|
|
|
remote_connect_list_all_domains_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr *doms = NULL;
|
|
|
|
int ndomains = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2012-05-20 14:26:36 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ndomains = virConnectListAllDomains(priv->conn,
|
|
|
|
args->need_results ? &doms : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (doms && ndomains) {
|
|
|
|
if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->domains.domains_len = ndomains;
|
|
|
|
|
|
|
|
for (i = 0; i < ndomains; i++)
|
|
|
|
make_nonnull_domain(ret->domains.domains_val + i, doms[i]);
|
|
|
|
} else {
|
|
|
|
ret->domains.domains_len = 0;
|
|
|
|
ret->domains.domains_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = ndomains;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (doms) {
|
|
|
|
for (i = 0; i < ndomains; i++)
|
|
|
|
virDomainFree(doms[i]);
|
|
|
|
VIR_FREE(doms);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-05-17 21:45:03 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-05-17 21:45:03 +00:00
|
|
|
remote_domain_get_scheduler_parameters_flags_args *args,
|
|
|
|
remote_domain_get_scheduler_parameters_flags_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-05-17 21:45:03 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-05-17 21:45:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-05-17 21:45:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0)
|
2011-05-17 21:45:03 +00:00
|
|
|
goto no_memory;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-05-17 21:45:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainGetSchedulerParametersFlags(dom, params, &nparams,
|
|
|
|
args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
2011-05-30 18:12:18 +00:00
|
|
|
&ret->params.params_val,
|
2011-10-12 09:26:34 +00:00
|
|
|
&ret->params.params_len,
|
|
|
|
args->flags) < 0)
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
2008-06-06 10:52:01 +00:00
|
|
|
|
|
|
|
cleanup:
|
2011-05-17 20:58:40 +00:00
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-12-20 15:22:25 +00:00
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
2011-04-13 15:21:35 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2007-06-22 13:16:10 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 12:43:19 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_domain_memory_stats_args *args,
|
|
|
|
remote_domain_memory_stats_ret *ret)
|
2009-12-20 12:43:19 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2009-12-20 12:43:19 +00:00
|
|
|
struct _virDomainMemoryStat *stats;
|
2011-04-13 17:13:37 +00:00
|
|
|
int nr_stats, i;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2009-12-20 12:43:19 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 12:43:19 +00:00
|
|
|
if (args->maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2009-12-20 12:43:19 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2009-12-20 12:43:19 +00:00
|
|
|
|
|
|
|
/* Allocate stats array for making dispatch call */
|
|
|
|
if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2010-06-12 15:13:33 +00:00
|
|
|
}
|
2009-12-20 12:43:19 +00:00
|
|
|
|
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
|
|
|
nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, args->flags);
|
2011-04-13 17:23:00 +00:00
|
|
|
if (nr_stats < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2009-12-20 12:43:19 +00:00
|
|
|
|
|
|
|
/* Allocate return buffer */
|
|
|
|
if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2009-12-20 12:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the stats into the xdr return structure */
|
|
|
|
for (i = 0; i < nr_stats; i++) {
|
|
|
|
ret->stats.stats_val[i].tag = stats[i].tag;
|
|
|
|
ret->stats.stats_val[i].val = stats[i].val;
|
|
|
|
}
|
|
|
|
ret->stats.stats_len = nr_stats;
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
2009-12-20 12:43:19 +00:00
|
|
|
VIR_FREE(stats);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2009-12-20 12:43:19 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 21:12:26 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainBlockPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_domain_block_peek_args *args,
|
|
|
|
remote_domain_block_peek_ret *ret)
|
2008-06-05 21:12:26 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2008-06-05 21:12:26 +00:00
|
|
|
char *path;
|
|
|
|
unsigned long long offset;
|
|
|
|
size_t size;
|
|
|
|
unsigned int flags;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2008-06-05 21:12:26 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2008-06-05 21:12:26 +00:00
|
|
|
path = args->path;
|
|
|
|
offset = args->offset;
|
|
|
|
size = args->size;
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("size > maximum buffer size"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->buffer.buffer_len = size;
|
2011-04-12 16:34:30 +00:00
|
|
|
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2011-04-12 16:34:30 +00:00
|
|
|
if (virDomainBlockPeek(dom, path, offset, size,
|
2011-04-13 17:23:00 +00:00
|
|
|
ret->buffer.buffer_val, flags) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2008-06-05 21:12:26 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
VIR_FREE(ret->buffer.buffer_val);
|
|
|
|
}
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
2008-06-05 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 08:20:03 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainBlockStatsFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-09-05 08:20:03 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_block_stats_flags_args *args,
|
|
|
|
remote_domain_block_stats_flags_ret *ret)
|
|
|
|
{
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
const char *path = args->path;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
unsigned int flags;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-09-05 08:20:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-09-05 08:20:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
|
2011-09-05 08:20:03 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Serialise the block stats. */
|
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
|
|
|
&ret->params.params_val,
|
2011-10-12 09:26:34 +00:00
|
|
|
&ret->params.params_len,
|
|
|
|
args->flags) < 0)
|
2011-09-05 08:20:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2011-12-20 15:22:25 +00:00
|
|
|
if (rv < 0)
|
2011-09-05 08:20:03 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-12-20 15:22:25 +00:00
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
2011-09-18 16:36:10 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
2011-09-05 08:20:03 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-06-10 10:43:28 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMemoryPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_domain_memory_peek_args *args,
|
|
|
|
remote_domain_memory_peek_ret *ret)
|
2008-06-10 10:43:28 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2008-06-10 10:43:28 +00:00
|
|
|
unsigned long long offset;
|
|
|
|
size_t size;
|
|
|
|
unsigned int flags;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2008-06-10 10:43:28 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2008-06-10 10:43:28 +00:00
|
|
|
offset = args->offset;
|
|
|
|
size = args->size;
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("size > maximum buffer size"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret->buffer.buffer_len = size;
|
2011-04-12 16:34:30 +00:00
|
|
|
if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
2011-04-12 16:34:30 +00:00
|
|
|
if (virDomainMemoryPeek(dom, offset, size,
|
2011-04-13 17:23:00 +00:00
|
|
|
ret->buffer.buffer_val, flags) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2008-06-10 10:43:28 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
VIR_FREE(ret->buffer.buffer_val);
|
|
|
|
}
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
2008-06-10 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
2009-05-21 13:50:56 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetSecurityLabel(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_domain_get_security_label_args *args,
|
|
|
|
remote_domain_get_security_label_ret *ret)
|
2009-05-21 13:50:56 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virSecurityLabelPtr seclabel = NULL;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-04-13 15:21:35 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-22 15:09:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(seclabel) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainGetSecurityLabel(dom, seclabel) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret->label.label_len = strlen(seclabel->label) + 1;
|
|
|
|
if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
|
|
|
|
virReportOOMError();
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
|
|
|
strcpy(ret->label.label_val, seclabel->label);
|
|
|
|
ret->enforcing = seclabel->enforcing;
|
2011-04-13 17:50:40 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-22 15:09:33 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
VIR_FREE(seclabel);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2009-05-21 13:50:56 +00:00
|
|
|
}
|
|
|
|
|
2012-08-15 22:10:39 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetSecurityLabelList(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_security_label_list_args *args,
|
|
|
|
remote_domain_get_security_label_list_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virSecurityLabelPtr seclabels = NULL;
|
|
|
|
int i, len, rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((len = virDomainGetSecurityLabelList(dom, &seclabels)) < 0) {
|
|
|
|
ret->ret = len;
|
|
|
|
ret->labels.labels_len = 0;
|
|
|
|
ret->labels.labels_val = NULL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(ret->labels.labels_val, len) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
size_t label_len = strlen(seclabels[i].label) + 1;
|
|
|
|
remote_domain_get_security_label_ret *cur = &ret->labels.labels_val[i];
|
|
|
|
if (VIR_ALLOC_N(cur->label.label_val, label_len) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (virStrcpy(cur->label.label_val, seclabels[i].label, label_len) == NULL) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("failed to copy security label"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
cur->label.label_len = label_len;
|
|
|
|
cur->enforcing = seclabels[i].enforcing;
|
|
|
|
}
|
|
|
|
ret->labels.labels_len = ret->ret = len;
|
|
|
|
|
|
|
|
done:
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
VIR_FREE(seclabels);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-05-21 13:50:56 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchNodeGetSecurityModel(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_node_get_security_model_ret *ret)
|
2009-05-21 13:50:56 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
virSecurityModel secmodel;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-04-13 15:21:35 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memset(&secmodel, 0, sizeof(secmodel));
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNodeGetSecurityModel(priv->conn, &secmodel) < 0)
|
2011-04-22 15:09:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret->model.model_len = strlen(secmodel.model) + 1;
|
|
|
|
if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
strcpy(ret->model.model_val, secmodel.model);
|
|
|
|
|
|
|
|
ret->doi.doi_len = strlen(secmodel.doi) + 1;
|
|
|
|
if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
|
|
|
|
virReportOOMError();
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
|
|
|
strcpy(ret->doi.doi_val, secmodel.doi);
|
2011-04-13 17:50:40 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2009-05-21 13:50:56 +00:00
|
|
|
}
|
|
|
|
|
2011-06-24 09:00:22 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
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
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
unsigned char *cpumaps = NULL;
|
|
|
|
int num;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-06-24 09:00:22 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-06-24 09:00:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-06-24 09:00:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (args->ncpumaps > REMOTE_VCPUINFO_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("ncpumaps > REMOTE_VCPUINFO_MAX"));
|
2011-06-24 09:00:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (INT_MULTIPLY_OVERFLOW(args->ncpumaps, args->maplen) ||
|
|
|
|
args->ncpumaps * args->maplen > REMOTE_CPUMAPS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
|
2011-06-24 09:00:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate buffers to take the results. */
|
|
|
|
if (args->maplen > 0 &&
|
|
|
|
VIR_ALLOC_N(cpumaps, args->ncpumaps * args->maplen) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
2011-06-24 23:09:46 +00:00
|
|
|
if ((num = virDomainGetVcpuPinInfo(dom,
|
2011-06-24 09:00:22 +00:00
|
|
|
args->ncpumaps,
|
|
|
|
cpumaps,
|
|
|
|
args->maplen,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret->num = num;
|
|
|
|
/* Don't need to allocate/copy the cpumaps if we make the reasonable
|
|
|
|
* assumption that unsigned char and char are the same size.
|
|
|
|
* Note that remoteDispatchClientRequest will free.
|
|
|
|
*/
|
|
|
|
ret->cpumaps.cpumaps_len = args->ncpumaps * args->maplen;
|
|
|
|
ret->cpumaps.cpumaps_val = (char *) cpumaps;
|
2012-08-21 09:18:38 +00:00
|
|
|
cpumaps = NULL;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
VIR_FREE(cpumaps);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainPinEmulator(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_pin_emulator_args *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainPinEmulator(dom,
|
|
|
|
(unsigned char *) args->cpumap.cpumap_val,
|
|
|
|
args->cpumap.cpumap_len,
|
|
|
|
args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetEmulatorPinInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_emulator_pin_info_args *args,
|
|
|
|
remote_domain_get_emulator_pin_info_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
unsigned char *cpumaps = NULL;
|
|
|
|
int r;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Allocate buffers to take the results */
|
|
|
|
if (args->maplen > 0 &&
|
|
|
|
VIR_ALLOC_N(cpumaps, args->maplen) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
if ((r = virDomainGetEmulatorPinInfo(dom,
|
|
|
|
cpumaps,
|
|
|
|
args->maplen,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret->ret = r;
|
|
|
|
ret->cpumaps.cpumaps_len = args->maplen;
|
|
|
|
ret->cpumaps.cpumaps_val = (char *) cpumaps;
|
2011-06-24 09:00:22 +00:00
|
|
|
cpumaps = NULL;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-06-24 09:00:22 +00:00
|
|
|
VIR_FREE(cpumaps);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetVcpus(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_domain_get_vcpus_args *args,
|
|
|
|
remote_domain_get_vcpus_ret *ret)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2011-04-22 15:09:33 +00:00
|
|
|
virVcpuInfoPtr info = NULL;
|
|
|
|
unsigned char *cpumaps = NULL;
|
|
|
|
int info_len, i;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
2011-04-13 15:21:35 +00:00
|
|
|
|
2011-06-24 18:16:05 +00:00
|
|
|
if (INT_MULTIPLY_OVERFLOW(args->maxinfo, args->maplen) ||
|
|
|
|
args->maxinfo * args->maplen > REMOTE_CPUMAPS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
|
2011-04-22 15:09:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate buffers to take the results. */
|
|
|
|
if (VIR_ALLOC_N(info, args->maxinfo) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
if (args->maplen > 0 &&
|
|
|
|
VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
if ((info_len = virDomainGetVcpus(dom,
|
|
|
|
info, args->maxinfo,
|
|
|
|
cpumaps, args->maplen)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Allocate the return buffer for info. */
|
|
|
|
ret->info.info_len = info_len;
|
|
|
|
if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
for (i = 0; i < info_len; ++i) {
|
|
|
|
ret->info.info_val[i].number = info[i].number;
|
|
|
|
ret->info.info_val[i].state = info[i].state;
|
|
|
|
ret->info.info_val[i].cpu_time = info[i].cpuTime;
|
|
|
|
ret->info.info_val[i].cpu = info[i].cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't need to allocate/copy the cpumaps if we make the reasonable
|
|
|
|
* assumption that unsigned char and char are the same size.
|
|
|
|
* Note that remoteDispatchClientRequest will free.
|
|
|
|
*/
|
|
|
|
ret->cpumaps.cpumaps_len = args->maxinfo * args->maplen;
|
|
|
|
ret->cpumaps.cpumaps_val = (char *) cpumaps;
|
|
|
|
cpumaps = NULL;
|
|
|
|
|
|
|
|
rv = 0;
|
2011-04-13 15:21:35 +00:00
|
|
|
|
|
|
|
cleanup:
|
2011-04-22 15:09:33 +00:00
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-22 15:09:33 +00:00
|
|
|
VIR_FREE(ret->info.info_val);
|
|
|
|
}
|
|
|
|
VIR_FREE(cpumaps);
|
|
|
|
VIR_FREE(info);
|
2011-04-13 15:21:35 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
2011-04-22 15:09:33 +00:00
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigratePrepare(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_domain_migrate_prepare_args *args,
|
|
|
|
remote_domain_migrate_prepare_ret *ret)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
char *cookie = NULL;
|
|
|
|
int cookielen = 0;
|
|
|
|
char *uri_in;
|
|
|
|
char **uri_out;
|
|
|
|
char *dname;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
|
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
|
|
|
|
|
|
|
/* Wacky world of XDR ... */
|
|
|
|
if (VIR_ALLOC(uri_out) < 0) {
|
|
|
|
virReportOOMError();
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virDomainMigratePrepare(priv->conn, &cookie, &cookielen,
|
2011-04-22 15:09:33 +00:00
|
|
|
uri_in, uri_out,
|
|
|
|
args->flags, dname, args->resource) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
/* remoteDispatchClientRequest will free cookie, uri_out and
|
|
|
|
* the string if there is one.
|
|
|
|
*/
|
|
|
|
ret->cookie.cookie_len = cookielen;
|
|
|
|
ret->cookie.cookie_val = cookie;
|
|
|
|
if (*uri_out == NULL) {
|
|
|
|
ret->uri_out = NULL;
|
|
|
|
} else {
|
|
|
|
ret->uri_out = uri_out;
|
|
|
|
uri_out = NULL;
|
|
|
|
}
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
2007-07-24 14:21:03 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-22 15:09:33 +00:00
|
|
|
VIR_FREE(uri_out);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 09:27:02 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigratePrepare2(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_domain_migrate_prepare2_args *args,
|
|
|
|
remote_domain_migrate_prepare2_ret *ret)
|
2009-03-03 09:27:02 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
char *cookie = NULL;
|
|
|
|
int cookielen = 0;
|
|
|
|
char *uri_in;
|
|
|
|
char **uri_out;
|
|
|
|
char *dname;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2009-03-03 09:27:02 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
|
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
2009-03-03 09:27:02 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
/* Wacky world of XDR ... */
|
|
|
|
if (VIR_ALLOC(uri_out) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2011-04-03 09:21:25 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virDomainMigratePrepare2(priv->conn, &cookie, &cookielen,
|
2011-04-22 15:09:33 +00:00
|
|
|
uri_in, uri_out,
|
|
|
|
args->flags, dname, args->resource,
|
|
|
|
args->dom_xml) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2009-03-03 09:27:02 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
/* remoteDispatchClientRequest will free cookie, uri_out and
|
|
|
|
* the string if there is one.
|
|
|
|
*/
|
|
|
|
ret->cookie.cookie_len = cookielen;
|
|
|
|
ret->cookie.cookie_val = cookie;
|
|
|
|
ret->uri_out = *uri_out == NULL ? NULL : uri_out;
|
2009-03-03 09:27:02 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2009-03-03 09:27:02 +00:00
|
|
|
}
|
|
|
|
|
2009-09-30 10:51:54 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_memory_parameters_args *args,
|
|
|
|
remote_domain_get_memory_parameters_ret *ret)
|
2009-09-30 10:51:54 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2011-05-26 17:39:04 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
2011-04-22 15:09:33 +00:00
|
|
|
int nparams = args->nparams;
|
|
|
|
unsigned int flags;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-04-12 16:33:49 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
2009-09-30 10:51:54 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
flags = args->flags;
|
2009-09-30 10:51:54 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-04-22 15:09:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2009-09-30 10:51:54 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2009-09-30 10:51:54 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2009-09-30 10:51:54 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
2011-04-13 15:21:35 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
2011-05-30 18:12:18 +00:00
|
|
|
&ret->params.params_val,
|
2011-10-12 09:26:34 +00:00
|
|
|
&ret->params.params_len,
|
|
|
|
args->flags) < 0)
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
2007-06-11 11:47:01 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
success:
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2011-05-17 20:58:40 +00:00
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-12-20 15:22:25 +00:00
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
2011-04-13 15:21:35 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2011-12-20 08:35:01 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetNumaParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_numa_parameters_args *args,
|
|
|
|
remote_domain_get_numa_parameters_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
unsigned int flags;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-12-20 08:35:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_NUMA_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-12-20 08:35:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
|
2011-12-20 08:35:01 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainGetNumaParameters(dom, params, &nparams, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
|
|
|
&ret->params.params_val,
|
|
|
|
&ret->params.params_len,
|
|
|
|
flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-10-12 17:23:04 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetBlkioParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_blkio_parameters_args *args,
|
|
|
|
remote_domain_get_blkio_parameters_ret *ret)
|
2010-10-12 17:23:04 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2011-05-26 17:39:04 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
2011-05-03 17:24:23 +00:00
|
|
|
int nparams = args->nparams;
|
2010-10-12 17:23:04 +00:00
|
|
|
unsigned int flags;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2010-10-12 17:23:04 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 17:23:04 +00:00
|
|
|
flags = args->flags;
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2010-10-12 17:23:04 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-13 17:50:40 +00:00
|
|
|
|
2010-10-12 17:23:04 +00:00
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
2011-05-17 20:58:40 +00:00
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
2011-05-30 18:12:18 +00:00
|
|
|
&ret->params.params_val,
|
2011-10-12 09:26:34 +00:00
|
|
|
&ret->params.params_len,
|
|
|
|
args->flags) < 0)
|
2011-05-17 20:58:40 +00:00
|
|
|
goto cleanup;
|
2011-02-22 05:34:28 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
success:
|
|
|
|
rv = 0;
|
2011-02-22 05:34:28 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
cleanup:
|
2011-05-17 20:58:40 +00:00
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-10-12 09:26:34 +00:00
|
|
|
virTypedParameterArrayClear(params, nparams);
|
2011-04-22 15:09:33 +00:00
|
|
|
VIR_FREE(params);
|
2011-04-13 15:21:35 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
2011-02-22 05:34:28 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 01:01:12 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchNodeGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_node_get_cpu_stats_args *args,
|
|
|
|
remote_node_get_cpu_stats_ret *ret)
|
2011-06-07 01:01:12 +00:00
|
|
|
{
|
2011-06-15 10:39:57 +00:00
|
|
|
virNodeCPUStatsPtr params = NULL;
|
2011-06-07 01:01:12 +00:00
|
|
|
int i;
|
|
|
|
int cpuNum = args->cpuNum;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
unsigned int flags;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-06-07 01:01:12 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-06-07 01:01:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_NODE_CPU_STATS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-06-07 01:01:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (VIR_ALLOC_N(params, nparams) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, flags) < 0)
|
2011-06-07 01:01:12 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* In this case, we need to send back the number of stats
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Serialise the memory parameters. */
|
|
|
|
ret->params.params_len = nparams;
|
|
|
|
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
for (i = 0; i < nparams; ++i) {
|
|
|
|
/* remoteDispatchClientRequest will free this: */
|
|
|
|
ret->params.params_val[i].field = strdup(params[i].field);
|
|
|
|
if (ret->params.params_val[i].field == NULL)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
ret->params.params_val[i].value = params[i].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
|
2011-06-07 01:05:40 +00:00
|
|
|
cleanup:
|
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-06-07 01:05:40 +00:00
|
|
|
if (ret->params.params_val) {
|
|
|
|
for (i = 0; i < nparams; i++)
|
|
|
|
VIR_FREE(ret->params.params_val[i].field);
|
|
|
|
VIR_FREE(ret->params.params_val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VIR_FREE(params);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchNodeGetMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_node_get_memory_stats_args *args,
|
|
|
|
remote_node_get_memory_stats_ret *ret)
|
2011-06-07 01:05:40 +00:00
|
|
|
{
|
2011-06-15 10:39:57 +00:00
|
|
|
virNodeMemoryStatsPtr params = NULL;
|
2011-06-07 01:05:40 +00:00
|
|
|
int i;
|
|
|
|
int cellNum = args->cellNum;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
unsigned int flags;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-06-07 01:05:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-06-07 01:05:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_NODE_MEMORY_STATS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-06-07 01:05:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (VIR_ALLOC_N(params, nparams) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, flags) < 0)
|
2011-06-07 01:05:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Serialise the memory parameters. */
|
|
|
|
ret->params.params_len = nparams;
|
|
|
|
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
for (i = 0; i < nparams; ++i) {
|
|
|
|
/* remoteDispatchClientRequest will free this: */
|
|
|
|
ret->params.params_val[i].field = strdup(params[i].field);
|
|
|
|
if (ret->params.params_val[i].field == NULL)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
ret->params.params_val[i].value = params[i].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
|
2011-06-07 01:01:12 +00:00
|
|
|
cleanup:
|
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-06-07 01:01:12 +00:00
|
|
|
if (ret->params.params_val) {
|
|
|
|
for (i = 0; i < nparams; i++)
|
|
|
|
VIR_FREE(ret->params.params_val[i].field);
|
|
|
|
VIR_FREE(ret->params.params_val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VIR_FREE(params);
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-07-22 05:31:16 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetBlockJobInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-07-22 05:31:16 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_block_job_info_args *args,
|
|
|
|
remote_domain_get_block_job_info_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virDomainBlockJobInfo tmp;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-07-22 05:31:16 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = virDomainGetBlockJobInfo(dom, args->path, &tmp, args->flags);
|
|
|
|
if (rv <= 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret->type = tmp.type;
|
|
|
|
ret->bandwidth = tmp.bandwidth;
|
|
|
|
ret->cur = tmp.cur;
|
|
|
|
ret->end = tmp.end;
|
|
|
|
ret->found = 1;
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-11-15 09:02:44 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetBlockIoTune(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr hdr ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_block_io_tune_args *args,
|
|
|
|
remote_domain_get_block_io_tune_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int rv = -1;
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-11-15 09:02:44 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-11-15 09:02:44 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
|
2011-11-15 09:02:44 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainGetBlockIoTune(dom, args->disk ? *args->disk : NULL,
|
|
|
|
params, &nparams, args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Serialise the block I/O tuning parameters. */
|
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
|
|
|
&ret->params.params_val,
|
|
|
|
&ret->params.params_len,
|
|
|
|
args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
2011-07-22 05:31:16 +00:00
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
/*-------------------------------------------------------------*/
|
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_auth_list_ret *ret)
|
2007-12-05 15:24:15 +00:00
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
int auth = virNetServerClientGetAuth(client);
|
|
|
|
uid_t callerUid;
|
2011-12-16 00:18:22 +00:00
|
|
|
gid_t callerGid;
|
2011-05-16 17:13:11 +00:00
|
|
|
pid_t callerPid;
|
|
|
|
|
|
|
|
/* If the client is root then we want to bypass the
|
|
|
|
* policykit auth to avoid root being denied if
|
|
|
|
* some piece of polkit isn't present/running
|
|
|
|
*/
|
|
|
|
if (auth == VIR_NET_SERVER_SERVICE_AUTH_POLKIT) {
|
2012-01-26 00:49:48 +00:00
|
|
|
if (virNetServerClientGetUNIXIdentity(client, &callerUid, &callerGid,
|
|
|
|
&callerPid) < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
/* Don't do anything on error - it'll be validated at next
|
|
|
|
* phase of auth anyway */
|
|
|
|
virResetLastError();
|
|
|
|
} else if (callerUid == 0) {
|
2012-01-26 00:49:48 +00:00
|
|
|
char *ident;
|
|
|
|
if (virAsprintf(&ident, "pid:%lld,uid:%d",
|
2012-02-15 17:01:50 +00:00
|
|
|
(long long) callerPid, callerUid) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2011-05-16 17:13:11 +00:00
|
|
|
}
|
2012-02-15 17:01:50 +00:00
|
|
|
VIR_INFO("Bypass polkit auth for privileged client %s", ident);
|
|
|
|
if (virNetServerClientSetIdentity(client, ident) < 0)
|
|
|
|
virResetLastError();
|
|
|
|
else
|
|
|
|
auth = VIR_NET_SERVER_SERVICE_AUTH_NONE;
|
|
|
|
VIR_FREE(ident);
|
2011-05-16 17:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-13 15:21:35 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
ret->types.types_len = 1;
|
2008-06-06 10:52:01 +00:00
|
|
|
if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
|
2011-04-13 15:21:35 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
2011-05-16 17:13:11 +00:00
|
|
|
|
|
|
|
switch (auth) {
|
|
|
|
case VIR_NET_SERVER_SERVICE_AUTH_NONE:
|
|
|
|
ret->types.types_val[0] = REMOTE_AUTH_NONE;
|
|
|
|
break;
|
|
|
|
case VIR_NET_SERVER_SERVICE_AUTH_POLKIT:
|
|
|
|
ret->types.types_val[0] = REMOTE_AUTH_POLKIT;
|
|
|
|
break;
|
|
|
|
case VIR_NET_SERVER_SERVICE_AUTH_SASL:
|
|
|
|
ret->types.types_val[0] = REMOTE_AUTH_SASL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret->types.types_val[0] = REMOTE_AUTH_NONE;
|
|
|
|
}
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-30 17:18:08 +00:00
|
|
|
#ifdef HAVE_SASL
|
2007-12-05 15:24:15 +00:00
|
|
|
/*
|
|
|
|
* Initializes the SASL session in prepare for authentication
|
2008-05-15 06:12:32 +00:00
|
|
|
* and gives the client a list of allowed mechanisms to choose
|
2007-12-05 15:24:15 +00:00
|
|
|
*/
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_auth_sasl_init_ret *ret)
|
2007-12-05 15:24:15 +00:00
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetSASLSessionPtr sasl = NULL;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Initialize SASL auth %d", virNetServerClientGetFD(client));
|
|
|
|
if (virNetServerClientGetAuth(client) != VIR_NET_SERVER_SERVICE_AUTH_SASL ||
|
|
|
|
priv->sasl != NULL) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("client tried invalid SASL init request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
sasl = virNetSASLSessionNewServer(saslCtxt,
|
|
|
|
"libvirt",
|
|
|
|
virNetServerClientLocalAddrString(client),
|
|
|
|
virNetServerClientRemoteAddrString(client));
|
|
|
|
if (!sasl)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2007-12-05 15:27:08 +00:00
|
|
|
/* Inform SASL that we've got an external SSF layer from TLS */
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNetServerClientHasTLSSession(client)) {
|
|
|
|
int ssf;
|
|
|
|
|
|
|
|
if ((ssf = virNetServerClientGetTLSKeySize(client)) < 0)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2011-05-16 17:13:11 +00:00
|
|
|
|
|
|
|
ssf *= 8; /* key size is bytes, sasl wants bits */
|
|
|
|
|
|
|
|
VIR_DEBUG("Setting external SSF %d", ssf);
|
|
|
|
if (virNetSASLSessionExtKeySize(sasl, ssf) < 0)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNetServerClientIsSecure(client))
|
2007-12-05 15:27:08 +00:00
|
|
|
/* If we've got TLS or UNIX domain sock, we don't care about SSF */
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetSASLSessionSecProps(sasl, 0, 0, true);
|
|
|
|
else
|
2007-12-05 15:27:08 +00:00
|
|
|
/* Plain TCP, better get an SSF layer */
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetSASLSessionSecProps(sasl,
|
|
|
|
56, /* Good enough to require kerberos */
|
|
|
|
100000, /* Arbitrary big number */
|
|
|
|
false); /* No anonymous */
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(ret->mechlist = virNetSASLSessionListMechanisms(sasl)))
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Available mechanisms for client: '%s'", ret->mechlist);
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->sasl = sasl;
|
|
|
|
virMutexUnlock(&priv->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
2011-05-16 17:13:11 +00:00
|
|
|
virResetLastError();
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_FAIL,
|
|
|
|
"client=%p auth=%d",
|
|
|
|
client, REMOTE_AUTH_SASL);
|
2012-07-11 13:35:49 +00:00
|
|
|
virObjectUnref(sasl);
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexUnlock(&priv->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
/*
|
2010-09-14 16:50:25 +00:00
|
|
|
* Returns 0 if ok, -1 on error, -2 if rejected
|
|
|
|
*/
|
2007-12-05 15:27:08 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteSASLFinish(virNetServerClientPtr client)
|
|
|
|
{
|
|
|
|
const char *identity;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
int ssf;
|
|
|
|
|
|
|
|
/* TLS or UNIX domain sockets trivially OK */
|
|
|
|
if (!virNetServerClientIsSecure(client)) {
|
|
|
|
if ((ssf = virNetSASLSessionGetKeySize(priv->sasl)) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
VIR_DEBUG("negotiated an SSF of %d", ssf);
|
|
|
|
if (ssf < 56) { /* 56 is good for Kerberos */
|
|
|
|
VIR_ERROR(_("negotiated SSF %d was not strong enough"), ssf);
|
|
|
|
return -2;
|
|
|
|
}
|
2007-12-05 15:27:08 +00:00
|
|
|
}
|
2011-05-16 17:13:11 +00:00
|
|
|
|
|
|
|
if (!(identity = virNetSASLSessionGetIdentity(priv->sasl)))
|
2010-09-14 16:50:25 +00:00
|
|
|
return -2;
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!virNetSASLContextCheckIdentity(saslCtxt, identity))
|
|
|
|
return -2;
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNetServerClientSetIdentity(client, identity) < 0)
|
|
|
|
goto error;
|
2007-12-05 15:27:08 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientSetSASLSession(client, priv->sasl);
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Authentication successful %d", virNetServerClientGetFD(client));
|
2011-06-28 22:33:09 +00:00
|
|
|
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_ALLOW,
|
|
|
|
"client=%p auth=%d identity=%s",
|
|
|
|
client, REMOTE_AUTH_SASL, identity);
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2012-07-11 13:35:49 +00:00
|
|
|
virObjectUnref(priv->sasl);
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->sasl = NULL;
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
return 0;
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
error:
|
|
|
|
return -1;
|
|
|
|
}
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
/*
|
|
|
|
* This starts the SASL authentication negotiation.
|
|
|
|
*/
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_auth_sasl_start_args *args,
|
|
|
|
remote_auth_sasl_start_ret *ret)
|
2007-12-05 15:24:15 +00:00
|
|
|
{
|
|
|
|
const char *serverout;
|
2011-05-16 17:13:11 +00:00
|
|
|
size_t serveroutlen;
|
2007-12-05 15:24:15 +00:00
|
|
|
int err;
|
2011-05-16 17:13:11 +00:00
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-06-28 22:33:09 +00:00
|
|
|
const char *identity;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Start SASL auth %d", virNetServerClientGetFD(client));
|
|
|
|
if (virNetServerClientGetAuth(client) != VIR_NET_SERVER_SERVICE_AUTH_SASL ||
|
|
|
|
priv->sasl == NULL) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("client tried invalid SASL start request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("Using SASL mechanism %s. Data %d bytes, nil: %d",
|
|
|
|
args->mech, args->data.data_len, args->nil);
|
2011-05-16 17:13:11 +00:00
|
|
|
err = virNetSASLSessionServerStart(priv->sasl,
|
|
|
|
args->mech,
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
args->nil ? NULL : args->data.data_val,
|
|
|
|
args->data.data_len,
|
|
|
|
&serverout,
|
|
|
|
&serveroutlen);
|
|
|
|
if (err != VIR_NET_SASL_COMPLETE &&
|
|
|
|
err != VIR_NET_SASL_CONTINUE)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2011-05-16 17:13:11 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_ERROR(_("sasl start reply data too long %d"), (int)serveroutlen);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
if (serverout) {
|
2011-05-16 17:13:11 +00:00
|
|
|
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0)
|
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
memcpy(ret->data.data_val, serverout, serveroutlen);
|
|
|
|
} else {
|
|
|
|
ret->data.data_val = NULL;
|
|
|
|
}
|
|
|
|
ret->nil = serverout ? 0 : 1;
|
|
|
|
ret->data.data_len = serveroutlen;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
|
2011-05-16 17:13:11 +00:00
|
|
|
if (err == VIR_NET_SASL_CONTINUE) {
|
2007-12-05 15:24:15 +00:00
|
|
|
ret->complete = 0;
|
|
|
|
} else {
|
2007-12-05 15:34:05 +00:00
|
|
|
/* Check username whitelist ACL */
|
2011-05-16 17:13:11 +00:00
|
|
|
if ((err = remoteSASLFinish(client)) < 0) {
|
2010-09-14 16:50:25 +00:00
|
|
|
if (err == -2)
|
|
|
|
goto authdeny;
|
|
|
|
else
|
|
|
|
goto authfail;
|
|
|
|
}
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
ret->complete = 1;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexUnlock(&priv->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_FAIL,
|
|
|
|
"client=%p auth=%d",
|
|
|
|
client, REMOTE_AUTH_SASL);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
authdeny:
|
2011-06-28 22:33:09 +00:00
|
|
|
identity = virNetSASLSessionGetIdentity(priv->sasl);
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_DENY,
|
|
|
|
"client=%p auth=%d identity=%s",
|
|
|
|
client, REMOTE_AUTH_SASL, identity);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto error;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
error:
|
2012-07-11 13:35:49 +00:00
|
|
|
virObjectUnref(priv->sasl);
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->sasl = NULL;
|
|
|
|
virResetLastError();
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-05-16 17:13:11 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
return -1;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_auth_sasl_step_args *args,
|
|
|
|
remote_auth_sasl_step_ret *ret)
|
2007-12-05 15:24:15 +00:00
|
|
|
{
|
|
|
|
const char *serverout;
|
2011-05-16 17:13:11 +00:00
|
|
|
size_t serveroutlen;
|
2007-12-05 15:24:15 +00:00
|
|
|
int err;
|
2011-05-16 17:13:11 +00:00
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-06-28 22:33:09 +00:00
|
|
|
const char *identity;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
|
|
|
|
VIR_DEBUG("Step SASL auth %d", virNetServerClientGetFD(client));
|
|
|
|
if (virNetServerClientGetAuth(client) != VIR_NET_SERVER_SERVICE_AUTH_SASL ||
|
|
|
|
priv->sasl == NULL) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("client tried invalid SASL start request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Step using SASL Data %d bytes, nil: %d",
|
2011-04-13 15:10:01 +00:00
|
|
|
args->data.data_len, args->nil);
|
2011-05-16 17:13:11 +00:00
|
|
|
err = virNetSASLSessionServerStep(priv->sasl,
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
args->nil ? NULL : args->data.data_val,
|
|
|
|
args->data.data_len,
|
|
|
|
&serverout,
|
|
|
|
&serveroutlen);
|
|
|
|
if (err != VIR_NET_SASL_COMPLETE &&
|
|
|
|
err != VIR_NET_SASL_CONTINUE)
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
if (serveroutlen > REMOTE_AUTH_SASL_DATA_MAX) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("sasl step reply data too long %d"),
|
2011-05-16 17:13:11 +00:00
|
|
|
(int)serveroutlen);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NB, distinction of NULL vs "" is *critical* in SASL */
|
|
|
|
if (serverout) {
|
2011-05-16 17:13:11 +00:00
|
|
|
if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0)
|
|
|
|
goto authfail;
|
2007-12-05 15:24:15 +00:00
|
|
|
memcpy(ret->data.data_val, serverout, serveroutlen);
|
|
|
|
} else {
|
|
|
|
ret->data.data_val = NULL;
|
|
|
|
}
|
|
|
|
ret->nil = serverout ? 0 : 1;
|
|
|
|
ret->data.data_len = serveroutlen;
|
|
|
|
|
2011-04-13 15:10:01 +00:00
|
|
|
VIR_DEBUG("SASL return data %d bytes, nil; %d", ret->data.data_len, ret->nil);
|
2011-05-16 17:13:11 +00:00
|
|
|
if (err == VIR_NET_SASL_CONTINUE) {
|
2007-12-05 15:24:15 +00:00
|
|
|
ret->complete = 0;
|
|
|
|
} else {
|
2007-12-05 15:34:05 +00:00
|
|
|
/* Check username whitelist ACL */
|
2011-05-16 17:13:11 +00:00
|
|
|
if ((err = remoteSASLFinish(client)) < 0) {
|
2010-09-14 16:50:25 +00:00
|
|
|
if (err == -2)
|
|
|
|
goto authdeny;
|
|
|
|
else
|
|
|
|
goto authfail;
|
|
|
|
}
|
2007-12-05 15:34:05 +00:00
|
|
|
|
2007-12-05 15:24:15 +00:00
|
|
|
ret->complete = 1;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexUnlock(&priv->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return 0;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
|
|
|
authfail:
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_FAIL,
|
|
|
|
"client=%p auth=%d",
|
|
|
|
client, REMOTE_AUTH_SASL);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
authdeny:
|
2011-06-28 22:33:09 +00:00
|
|
|
identity = virNetSASLSessionGetIdentity(priv->sasl);
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_DENY,
|
|
|
|
"client=%p auth=%d identity=%s",
|
|
|
|
client, REMOTE_AUTH_SASL, identity);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto error;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
error:
|
2012-07-11 13:35:49 +00:00
|
|
|
virObjectUnref(priv->sasl);
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->sasl = NULL;
|
|
|
|
virResetLastError();
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-05-16 17:13:11 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2007-12-05 15:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-06-30 17:18:08 +00:00
|
|
|
#else
|
|
|
|
static int
|
|
|
|
remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-06-30 17:18:08 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
VIR_WARN("Client tried unsupported SASL auth");
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-06-30 17:18:08 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
static int
|
|
|
|
remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-06-30 17:18:08 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
VIR_WARN("Client tried unsupported SASL auth");
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-06-30 17:18:08 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
static int
|
|
|
|
remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-06-30 17:18:08 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
|
|
|
|
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
VIR_WARN("Client tried unsupported SASL auth");
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-06-30 17:18:08 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-05 15:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-08-06 12:54:08 +00:00
|
|
|
#if HAVE_POLKIT1
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_auth_polkit_ret *ret)
|
2009-08-06 12:54:08 +00:00
|
|
|
{
|
2010-09-14 16:50:25 +00:00
|
|
|
pid_t callerPid = -1;
|
2011-12-16 00:18:22 +00:00
|
|
|
gid_t callerGid = -1;
|
2010-09-14 16:50:25 +00:00
|
|
|
uid_t callerUid = -1;
|
2009-08-06 12:54:08 +00:00
|
|
|
const char *action;
|
|
|
|
int status = -1;
|
2012-01-26 00:34:50 +00:00
|
|
|
char *ident = NULL;
|
2012-01-27 18:06:49 +00:00
|
|
|
bool authdismissed = 0;
|
2012-01-27 22:40:20 +00:00
|
|
|
char *pkout = NULL;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2012-01-26 00:34:50 +00:00
|
|
|
virCommandPtr cmd = NULL;
|
2010-09-14 16:50:25 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
action = virNetServerClientGetReadonly(client) ?
|
2009-08-06 12:54:08 +00:00
|
|
|
"org.libvirt.unix.monitor" :
|
|
|
|
"org.libvirt.unix.manage";
|
|
|
|
|
2012-01-26 00:34:50 +00:00
|
|
|
cmd = virCommandNewArgList(PKCHECK_PATH, "--action-id", action, NULL);
|
2012-01-27 18:06:49 +00:00
|
|
|
virCommandSetOutputBuffer(cmd, &pkout);
|
2012-01-27 22:40:20 +00:00
|
|
|
virCommandSetErrorBuffer(cmd, &pkout);
|
2009-08-06 12:54:08 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Start PolicyKit auth %d", virNetServerClientGetFD(client));
|
|
|
|
if (virNetServerClientGetAuth(client) != VIR_NET_SERVER_SERVICE_AUTH_POLKIT) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("client tried invalid PolicyKit init request"));
|
2009-08-06 12:54:08 +00:00
|
|
|
goto authfail;
|
|
|
|
}
|
|
|
|
|
2012-01-26 00:34:50 +00:00
|
|
|
if (virNetServerClientGetUNIXIdentity(client, &callerUid, &callerGid,
|
|
|
|
&callerPid) < 0) {
|
2009-08-06 12:54:08 +00:00
|
|
|
goto authfail;
|
|
|
|
}
|
|
|
|
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_INFO("Checking PID %lld running as %d",
|
|
|
|
(long long) callerPid, callerUid);
|
2009-08-06 12:54:08 +00:00
|
|
|
|
2012-01-26 00:34:50 +00:00
|
|
|
virCommandAddArg(cmd, "--process");
|
2012-01-26 00:49:48 +00:00
|
|
|
virCommandAddArgFormat(cmd, "%lld", (long long) callerPid);
|
2012-01-26 00:34:50 +00:00
|
|
|
virCommandAddArg(cmd, "--allow-user-interaction");
|
2009-08-06 12:54:08 +00:00
|
|
|
|
2012-01-26 00:49:48 +00:00
|
|
|
if (virAsprintf(&ident, "pid:%lld,uid:%d",
|
|
|
|
(long long) callerPid, callerUid) < 0) {
|
2012-01-26 00:34:50 +00:00
|
|
|
virReportOOMError();
|
2010-09-14 16:50:25 +00:00
|
|
|
goto authfail;
|
|
|
|
}
|
|
|
|
|
2012-01-26 00:34:50 +00:00
|
|
|
if (virCommandRun(cmd, &status) < 0)
|
2009-08-25 16:18:27 +00:00
|
|
|
goto authfail;
|
2012-01-26 00:34:50 +00:00
|
|
|
|
2012-01-27 18:06:49 +00:00
|
|
|
authdismissed = (pkout && strstr(pkout, "dismissed=true"));
|
2009-08-06 12:54:08 +00:00
|
|
|
if (status != 0) {
|
2011-03-22 17:55:45 +00:00
|
|
|
char *tmp = virCommandTranslateStatus(status);
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_ERROR(_("Policy kit denied action %s from pid %lld, uid %d: %s"),
|
|
|
|
action, (long long) callerPid, callerUid, NULLSTR(tmp));
|
2011-03-22 17:55:45 +00:00
|
|
|
VIR_FREE(tmp);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto authdeny;
|
2009-08-06 12:54:08 +00:00
|
|
|
}
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_ALLOW,
|
|
|
|
"client=%p auth=%d identity=%s",
|
|
|
|
client, REMOTE_AUTH_POLKIT, ident);
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_INFO("Policy allowed action %s from pid %lld, uid %d",
|
|
|
|
action, (long long) callerPid, callerUid);
|
2009-08-06 12:54:08 +00:00
|
|
|
ret->complete = 1;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientSetIdentity(client, ident);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2012-01-26 00:34:50 +00:00
|
|
|
virCommandFree(cmd);
|
2012-02-14 22:51:01 +00:00
|
|
|
VIR_FREE(pkout);
|
2012-01-26 00:34:50 +00:00
|
|
|
VIR_FREE(ident);
|
2011-05-16 17:13:11 +00:00
|
|
|
|
2009-08-06 12:54:08 +00:00
|
|
|
return 0;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
error:
|
2012-01-26 00:34:50 +00:00
|
|
|
virCommandFree(cmd);
|
|
|
|
VIR_FREE(ident);
|
2011-05-16 17:13:11 +00:00
|
|
|
virResetLastError();
|
2012-01-27 22:01:21 +00:00
|
|
|
|
2012-01-27 18:06:49 +00:00
|
|
|
if (authdismissed) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_CANCELLED, "%s",
|
|
|
|
_("authentication cancelled by user"));
|
2012-01-27 18:06:49 +00:00
|
|
|
} else {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
pkout && *pkout ? pkout : _("authentication failed"));
|
2012-01-27 18:06:49 +00:00
|
|
|
}
|
2012-01-27 22:01:21 +00:00
|
|
|
|
|
|
|
VIR_FREE(pkout);
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
|
|
|
return -1;
|
|
|
|
|
2009-08-06 12:54:08 +00:00
|
|
|
authfail:
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_FAIL,
|
|
|
|
"client=%p auth=%d",
|
|
|
|
client, REMOTE_AUTH_POLKIT);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
authdeny:
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_DENY,
|
|
|
|
"client=%p auth=%d identity=%s",
|
2012-01-26 00:34:50 +00:00
|
|
|
client, REMOTE_AUTH_POLKIT, ident);
|
2010-09-14 16:50:25 +00:00
|
|
|
goto error;
|
2009-08-06 12:54:08 +00:00
|
|
|
}
|
|
|
|
#elif HAVE_POLKIT0
|
2007-12-05 18:21:27 +00:00
|
|
|
static int
|
2012-05-21 15:23:41 +00:00
|
|
|
remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetServerClientPtr client,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
remote_auth_polkit_ret *ret)
|
2007-12-05 18:21:27 +00:00
|
|
|
{
|
|
|
|
pid_t callerPid;
|
2011-12-16 00:18:22 +00:00
|
|
|
gid_t callerGid;
|
2007-12-05 18:21:27 +00:00
|
|
|
uid_t callerUid;
|
2008-04-04 15:09:19 +00:00
|
|
|
PolKitCaller *pkcaller = NULL;
|
|
|
|
PolKitAction *pkaction = NULL;
|
|
|
|
PolKitContext *pkcontext = NULL;
|
|
|
|
PolKitError *pkerr = NULL;
|
|
|
|
PolKitResult pkresult;
|
|
|
|
DBusError err;
|
2008-12-04 22:16:40 +00:00
|
|
|
const char *action;
|
2012-01-26 00:49:48 +00:00
|
|
|
char *ident = NULL;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2012-04-19 14:34:35 +00:00
|
|
|
DBusConnection *sysbus;
|
2010-09-14 16:50:25 +00:00
|
|
|
|
2011-07-07 21:12:26 +00:00
|
|
|
virMutexLock(&priv->lock);
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2011-07-07 21:12:26 +00:00
|
|
|
action = virNetServerClientGetReadonly(client) ?
|
2008-04-04 15:09:19 +00:00
|
|
|
"org.libvirt.unix.monitor" :
|
|
|
|
"org.libvirt.unix.manage";
|
2007-12-05 18:21:27 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Start PolicyKit auth %d", virNetServerClientGetFD(client));
|
2011-07-07 21:12:26 +00:00
|
|
|
if (virNetServerClientGetAuth(client) != VIR_NET_SERVER_SERVICE_AUTH_POLKIT) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("client tried invalid PolicyKit init request"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-26 00:49:48 +00:00
|
|
|
if (virNetServerClientGetUNIXIdentity(client, &callerUid, &callerGid,
|
|
|
|
&callerPid) < 0) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("cannot get peer socket identity"));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-26 00:49:48 +00:00
|
|
|
if (virAsprintf(&ident, "pid:%lld,uid:%d",
|
|
|
|
(long long) callerPid, callerUid) < 0) {
|
|
|
|
virReportOOMError();
|
2010-09-14 16:50:25 +00:00
|
|
|
goto authfail;
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:34:35 +00:00
|
|
|
if (!(sysbus = virDBusGetSystemBus()))
|
|
|
|
goto authfail;
|
|
|
|
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_INFO("Checking PID %lld running as %d",
|
|
|
|
(long long) callerPid, callerUid);
|
2008-04-04 15:09:19 +00:00
|
|
|
dbus_error_init(&err);
|
2012-04-19 14:34:35 +00:00
|
|
|
if (!(pkcaller = polkit_caller_new_from_pid(sysbus,
|
2008-04-04 15:09:19 +00:00
|
|
|
callerPid, &err))) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("Failed to lookup policy kit caller: %s"), err.message);
|
2008-04-04 15:09:19 +00:00
|
|
|
dbus_error_free(&err);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
2007-12-05 18:21:27 +00:00
|
|
|
|
2008-04-04 15:09:19 +00:00
|
|
|
if (!(pkaction = polkit_action_new())) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
2010-01-19 13:17:20 +00:00
|
|
|
VIR_ERROR(_("Failed to create polkit action %s"),
|
2012-03-29 09:52:04 +00:00
|
|
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
2008-04-04 15:09:19 +00:00
|
|
|
polkit_caller_unref(pkcaller);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
|
|
|
polkit_action_set_action_id(pkaction, action);
|
|
|
|
|
|
|
|
if (!(pkcontext = polkit_context_new()) ||
|
|
|
|
!polkit_context_init(pkcontext, &pkerr)) {
|
2009-02-05 16:28:30 +00:00
|
|
|
char ebuf[1024];
|
2010-01-19 13:17:20 +00:00
|
|
|
VIR_ERROR(_("Failed to create polkit context %s"),
|
2009-01-06 18:32:03 +00:00
|
|
|
(pkerr ? polkit_error_get_error_message(pkerr)
|
2012-03-29 09:52:04 +00:00
|
|
|
: virStrerror(errno, ebuf, sizeof(ebuf))));
|
2008-04-04 15:09:19 +00:00
|
|
|
if (pkerr)
|
|
|
|
polkit_error_free(pkerr);
|
|
|
|
polkit_caller_unref(pkcaller);
|
|
|
|
polkit_action_unref(pkaction);
|
|
|
|
dbus_error_free(&err);
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
2007-12-05 18:21:27 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# if HAVE_POLKIT_CONTEXT_IS_CALLER_AUTHORIZED
|
2008-04-04 15:09:19 +00:00
|
|
|
pkresult = polkit_context_is_caller_authorized(pkcontext,
|
|
|
|
pkaction,
|
|
|
|
pkcaller,
|
|
|
|
0,
|
|
|
|
&pkerr);
|
|
|
|
if (pkerr && polkit_error_is_set(pkerr)) {
|
2009-01-06 18:32:03 +00:00
|
|
|
VIR_ERROR(_("Policy kit failed to check authorization %d %s"),
|
|
|
|
polkit_error_get_error_code(pkerr),
|
|
|
|
polkit_error_get_error_message(pkerr));
|
2008-12-04 22:16:40 +00:00
|
|
|
goto authfail;
|
2008-04-04 15:09:19 +00:00
|
|
|
}
|
2010-03-09 18:22:22 +00:00
|
|
|
# else
|
2008-04-04 15:09:19 +00:00
|
|
|
pkresult = polkit_context_can_caller_do_action(pkcontext,
|
|
|
|
pkaction,
|
|
|
|
pkcaller);
|
2010-03-09 18:22:22 +00:00
|
|
|
# endif
|
2008-04-04 15:09:19 +00:00
|
|
|
polkit_context_unref(pkcontext);
|
|
|
|
polkit_caller_unref(pkcaller);
|
|
|
|
polkit_action_unref(pkaction);
|
|
|
|
if (pkresult != POLKIT_RESULT_YES) {
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_ERROR(_("Policy kit denied action %s from pid %lld, uid %d, result: %s"),
|
|
|
|
action, (long long) callerPid, callerUid,
|
2009-01-06 18:32:03 +00:00
|
|
|
polkit_result_to_string_representation(pkresult));
|
2010-09-14 16:50:25 +00:00
|
|
|
goto authdeny;
|
2007-12-05 18:21:27 +00:00
|
|
|
}
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_ALLOW,
|
|
|
|
"client=%p auth=%d identity=%s",
|
|
|
|
client, REMOTE_AUTH_POLKIT, ident);
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_INFO("Policy allowed action %s from pid %lld, uid %d, result %s",
|
|
|
|
action, (long long) callerPid, callerUid,
|
2011-04-22 15:09:33 +00:00
|
|
|
polkit_result_to_string_representation(pkresult));
|
|
|
|
ret->complete = 1;
|
2011-07-07 21:12:26 +00:00
|
|
|
virNetServerClientSetIdentity(client, ident);
|
2011-04-12 16:33:49 +00:00
|
|
|
|
2011-07-07 21:12:26 +00:00
|
|
|
virMutexUnlock(&priv->lock);
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_FREE(ident);
|
2011-04-22 15:09:33 +00:00
|
|
|
return 0;
|
2008-02-20 15:22:35 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
error:
|
2012-01-26 00:49:48 +00:00
|
|
|
VIR_FREE(ident);
|
2011-05-16 17:13:11 +00:00
|
|
|
virResetLastError();
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-07-07 21:12:26 +00:00
|
|
|
virMutexUnlock(&priv->lock);
|
2011-05-16 17:13:11 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
authfail:
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_FAIL,
|
|
|
|
"client=%p auth=%d",
|
|
|
|
client, REMOTE_AUTH_POLKIT);
|
2011-04-22 15:09:33 +00:00
|
|
|
goto error;
|
2011-04-13 15:21:35 +00:00
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
authdeny:
|
Rewrite all the DTrace/SystemTAP probing
The libvirtd daemon had a few crude system tap probes. Some of
these were broken during the RPC rewrite. The new modular RPC
code is structured in a way that allows much more effective
tracing. Instead of trying to hook up the original probes,
define a new set of probes for the RPC and event code.
The master probes file is now src/probes.d. This contains
probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
probes for the poll event loop.
The src/dtrace2systemtap.pl script can convert the probes.d
file into a libvirt_probes.stp file to make use from systemtap
much simpler.
The src/rpc/gensystemtap.pl script can generate a set of
systemtap functions for translating RPC enum values into
printable strings. This works for all RPC header enums (program,
type, status, procedure) and also the authentication enum
The PROBE macro will automatically generate a VIR_DEBUG
statement, so any place with a PROBE can remove any existing
manual DEBUG statements.
* daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
* daemon/libvirtd.h: Remove probe macros
* daemon/Makefile.am: Remove all probe buildings/install
* daemon/remote.c: Update authentication probes
* src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
to generate STP files
* src/internal.h: Add probe macros
* src/probes.d: Master list of probes
* src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
src/util/event_poll.c: Insert probe points, removing any
DEBUG statements that duplicate the info
2011-09-30 13:40:23 +00:00
|
|
|
PROBE(RPC_SERVER_CLIENT_AUTH_DENY,
|
|
|
|
"client=%p auth=%d identity=%s",
|
|
|
|
client, REMOTE_AUTH_POLKIT, ident);
|
2011-04-22 15:09:33 +00:00
|
|
|
goto error;
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
#else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
|
2008-02-20 15:22:35 +00:00
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
|
2011-06-28 19:09:05 +00:00
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
|
2008-02-20 15:22:35 +00:00
|
|
|
{
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_ERROR(_("client tried unsupported PolicyKit init request"));
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_AUTH_FAILED, "%s",
|
|
|
|
_("authentication failed"));
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-22 15:09:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_POLKIT1 */
|
2011-04-13 15:21:35 +00:00
|
|
|
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
/***************************************************************
|
|
|
|
* NODE INFO APIS
|
|
|
|
**************************************************************/
|
2008-11-21 12:31:04 +00:00
|
|
|
|
2009-07-28 02:01:00 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchNodeDeviceGetParent(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_node_device_get_parent_args *args,
|
|
|
|
remote_node_device_get_parent_ret *ret)
|
2009-07-28 02:01:00 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
virNodeDevicePtr dev = NULL;
|
|
|
|
const char *parent = NULL;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2009-07-28 02:01:00 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dev = virNodeDeviceLookupByName(priv->conn, args->name)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
parent = virNodeDeviceGetParent(dev);
|
|
|
|
|
|
|
|
if (parent == NULL) {
|
|
|
|
ret->parent = NULL;
|
|
|
|
} else {
|
|
|
|
/* remoteDispatchClientRequest will free this. */
|
|
|
|
char **parent_p;
|
|
|
|
if (VIR_ALLOC(parent_p) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (!(*parent_p = strdup(parent))) {
|
|
|
|
VIR_FREE(parent_p);
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
ret->parent = parent_p;
|
|
|
|
}
|
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-22 15:09:33 +00:00
|
|
|
if (dev)
|
|
|
|
virNodeDeviceFree(dev);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2009-07-28 02:01:00 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
|
|
|
|
/***************************
|
|
|
|
* Register / deregister events
|
|
|
|
***************************/
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventsRegister(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_domain_events_register_ret *ret ATTRIBUTE_UNUSED)
|
2010-11-15 03:23:34 +00:00
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
int callbackID;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2010-11-15 03:23:34 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
|
|
|
|
if (priv->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] != -1) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
}
|
2010-11-15 03:23:34 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if ((callbackID = virConnectDomainEventRegisterAny(priv->conn,
|
2011-04-22 15:09:33 +00:00
|
|
|
NULL,
|
|
|
|
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
|
|
|
|
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
|
|
|
|
client, NULL)) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2010-11-15 03:23:34 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = callbackID;
|
2011-04-22 15:09:33 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2010-11-15 03:23:34 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventsDeregister(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_domain_events_deregister_ret *ret ATTRIBUTE_UNUSED)
|
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
|
|
|
{
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
|
|
|
|
if (priv->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] < 0) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), VIR_DOMAIN_EVENT_ID_LIFECYCLE);
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virConnectDomainEventDeregisterAny(priv->conn,
|
|
|
|
priv->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE]) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LIFECYCLE] = -1;
|
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2011-04-22 15:09:33 +00:00
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2011-04-22 15:09:33 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventSend(virNetServerClientPtr client,
|
|
|
|
virNetServerProgramPtr program,
|
2011-04-22 15:09:33 +00:00
|
|
|
int procnr,
|
|
|
|
xdrproc_t proc,
|
|
|
|
void *data)
|
|
|
|
{
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessagePtr msg;
|
2011-04-22 15:09:33 +00:00
|
|
|
|
Fix tracking of RPC messages wrt streams
Commit 2c85644b0b51fbe5b6244e6773531af29933a727 attempted to
fix a problem with tracking RPC messages from streams by doing
- if (msg->header.type == VIR_NET_REPLY) {
+ if (msg->header.type == VIR_NET_REPLY ||
+ (msg->header.type == VIR_NET_STREAM &&
+ msg->header.status != VIR_NET_CONTINUE)) {
client->nrequests--;
In other words any stream packet, with status NET_OK or NET_ERROR
would cause nrequests to be decremented. This is great if the
packet from from a synchronous virStreamFinish or virStreamAbort
API call, but wildly wrong if from a server initiated abort.
The latter resulted in 'nrequests' being decremented below zero.
This then causes all I/O for that client to be stopped.
Instead of trying to infer whether we need to decrement the
nrequests field, from the message type/status, introduce an
explicit 'bool tracked' field to mark whether the virNetMessagePtr
object is subject to tracking.
Also add a virNetMessageClear function to allow a message
contents to be cleared out, without adversely impacting the
'tracked' field as a naive memset() would do
* src/rpc/virnetmessage.c, src/rpc/virnetmessage.h: Add
a 'bool tracked' field and virNetMessageClear() API
* daemon/remote.c, daemon/stream.c, src/rpc/virnetclientprogram.c,
src/rpc/virnetclientstream.c, src/rpc/virnetserverclient.c,
src/rpc/virnetserverprogram.c: Switch over to use
virNetMessageClear() and pass in the 'bool tracked' value
when creating messages.
2011-08-31 16:42:58 +00:00
|
|
|
if (!(msg = virNetMessageNew(false)))
|
2011-08-31 15:50:09 +00:00
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
msg->header.prog = virNetServerProgramGetID(program);
|
|
|
|
msg->header.vers = virNetServerProgramGetVersion(program);
|
|
|
|
msg->header.proc = procnr;
|
|
|
|
msg->header.type = VIR_NET_MESSAGE;
|
|
|
|
msg->header.serial = 1;
|
|
|
|
msg->header.status = VIR_NET_OK;
|
2011-04-22 15:09:33 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNetMessageEncodeHeader(msg) < 0)
|
2011-04-22 15:09:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virNetMessageEncodePayload(msg, proc, data) < 0)
|
|
|
|
goto cleanup;
|
2011-04-22 15:09:33 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
VIR_DEBUG("Queue event %d %zu", procnr, msg->bufferLength);
|
|
|
|
virNetServerClientSendMessage(client, msg);
|
2011-04-22 15:09:33 +00:00
|
|
|
|
2011-08-31 15:50:09 +00:00
|
|
|
xdr_free(proc, data);
|
2011-04-22 15:09:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
cleanup:
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageFree(msg);
|
2011-08-31 15:50:09 +00:00
|
|
|
xdr_free(proc, data);
|
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
|
|
|
}
|
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchSecretGetValue(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-22 15:09:33 +00:00
|
|
|
remote_secret_get_value_args *args,
|
|
|
|
remote_secret_get_value_ret *ret)
|
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
|
|
|
{
|
2011-04-22 15:09:33 +00:00
|
|
|
virSecretPtr secret = NULL;
|
|
|
|
size_t value_size;
|
|
|
|
unsigned char *value;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(secret = get_nonnull_secret(priv->conn, args->secret)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
|
2011-04-22 15:09:33 +00:00
|
|
|
ret->value.value_len = value_size;
|
|
|
|
ret->value.value_val = (char *)value;
|
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-22 15:09:33 +00:00
|
|
|
if (secret)
|
|
|
|
virSecretFree(secret);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
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
|
|
|
}
|
|
|
|
|
2011-04-26 14:47:22 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainGetState(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-26 14:47:22 +00:00
|
|
|
remote_domain_get_state_args *args,
|
|
|
|
remote_domain_get_state_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-04-26 14:47:22 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-26 14:47:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-26 14:47:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainGetState(dom, &ret->state, &ret->reason, args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-26 14:47:22 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
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
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventsRegisterAny(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
|
|
|
|
remote_domain_events_register_any_args *args)
|
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
|
|
|
{
|
|
|
|
int callbackID;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
|
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 (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
|
|
|
|
args->eventID < 0) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (priv->domainEventCallbackID[args->eventID] != -1) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("domain event %d already registered"), args->eventID);
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if ((callbackID = virConnectDomainEventRegisterAny(priv->conn,
|
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
|
|
|
NULL,
|
|
|
|
args->eventID,
|
|
|
|
domainEventCallbacks[args->eventID],
|
2011-04-13 17:23:00 +00:00
|
|
|
client, NULL)) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->domainEventCallbackID[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
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
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
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainEventsDeregisterAny(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
|
|
|
|
remote_domain_events_deregister_any_args *args)
|
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
|
|
|
{
|
|
|
|
int callbackID = -1;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
|
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 (args->eventID >= VIR_DOMAIN_EVENT_ID_LAST ||
|
|
|
|
args->eventID < 0) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported event ID %d"), args->eventID);
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
callbackID = priv->domainEventCallbackID[args->eventID];
|
|
|
|
if (callbackID < 0) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virConnectDomainEventDeregisterAny(priv->conn, callbackID) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
priv->domainEventCallbackID[args->eventID] = -1;
|
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virMutexUnlock(&priv->lock);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
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-04-17 02:09:25 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
qemuDispatchMonitorCommand(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-04-12 16:34:30 +00:00
|
|
|
qemu_monitor_command_args *args,
|
|
|
|
qemu_monitor_command_ret *ret)
|
2010-04-17 02:09:25 +00:00
|
|
|
{
|
2011-04-13 18:10:03 +00:00
|
|
|
virDomainPtr dom = NULL;
|
2011-04-13 15:21:35 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2010-04-17 02:09:25 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2011-04-12 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2010-04-17 02:09:25 +00:00
|
|
|
|
2011-04-13 18:10:03 +00:00
|
|
|
if (virDomainQemuMonitorCommand(dom, args->cmd, &ret->result,
|
2011-04-13 17:23:00 +00:00
|
|
|
args->flags) < 0)
|
2011-04-13 15:21:35 +00:00
|
|
|
goto cleanup;
|
2010-04-17 02:09:25 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
rv = 0;
|
2010-04-17 02:09:25 +00:00
|
|
|
|
2011-04-13 15:21:35 +00:00
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-04-13 18:10:03 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
2011-04-13 15:21:35 +00:00
|
|
|
return rv;
|
2010-04-17 02:09:25 +00:00
|
|
|
}
|
|
|
|
|
2010-04-27 19:29:15 +00:00
|
|
|
|
2011-02-01 14:23:40 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigrateBegin3(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-02-01 14:23:40 +00:00
|
|
|
remote_domain_migrate_begin3_args *args,
|
|
|
|
remote_domain_migrate_begin3_ret *ret)
|
|
|
|
{
|
|
|
|
char *xml = NULL;
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
char *dname;
|
2011-05-18 09:26:30 +00:00
|
|
|
char *xmlin;
|
2011-02-01 14:23:40 +00:00
|
|
|
char *cookieout = NULL;
|
|
|
|
int cookieoutlen = 0;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2011-05-18 09:26:30 +00:00
|
|
|
xmlin = args->xmlin == NULL ? NULL : *args->xmlin;
|
2011-02-01 14:23:40 +00:00
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
|
|
|
|
2011-05-18 09:26:30 +00:00
|
|
|
if (!(xml = virDomainMigrateBegin3(dom, xmlin,
|
2011-02-01 14:23:40 +00:00
|
|
|
&cookieout, &cookieoutlen,
|
|
|
|
args->flags, dname, args->resource)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free cookie and
|
|
|
|
* the xml string if there is one.
|
|
|
|
*/
|
|
|
|
ret->cookie_out.cookie_out_len = cookieoutlen;
|
|
|
|
ret->cookie_out.cookie_out_val = cookieout;
|
|
|
|
ret->xml = xml;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-02-01 14:23:40 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigratePrepare3(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-02-01 14:23:40 +00:00
|
|
|
remote_domain_migrate_prepare3_args *args,
|
|
|
|
remote_domain_migrate_prepare3_ret *ret)
|
|
|
|
{
|
|
|
|
char *cookieout = NULL;
|
|
|
|
int cookieoutlen = 0;
|
|
|
|
char *uri_in;
|
|
|
|
char **uri_out;
|
|
|
|
char *dname;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
|
|
|
|
dname = args->dname == NULL ? NULL : *args->dname;
|
|
|
|
|
|
|
|
/* Wacky world of XDR ... */
|
|
|
|
if (VIR_ALLOC(uri_out) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (virDomainMigratePrepare3(priv->conn,
|
2011-02-01 14:23:40 +00:00
|
|
|
args->cookie_in.cookie_in_val,
|
|
|
|
args->cookie_in.cookie_in_len,
|
|
|
|
&cookieout, &cookieoutlen,
|
|
|
|
uri_in, uri_out,
|
|
|
|
args->flags, dname, args->resource,
|
|
|
|
args->dom_xml) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free cookie, uri_out and
|
|
|
|
* the string if there is one.
|
|
|
|
*/
|
|
|
|
ret->cookie_out.cookie_out_len = cookieoutlen;
|
|
|
|
ret->cookie_out.cookie_out_val = cookieout;
|
|
|
|
ret->uri_out = *uri_out == NULL ? NULL : uri_out;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-02-01 14:23:40 +00:00
|
|
|
VIR_FREE(uri_out);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
|
2011-02-01 14:23:40 +00:00
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigratePerform3(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-02-01 14:23:40 +00:00
|
|
|
remote_domain_migrate_perform3_args *args,
|
|
|
|
remote_domain_migrate_perform3_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
2011-05-18 09:26:30 +00:00
|
|
|
char *xmlin;
|
2011-02-01 14:23:40 +00:00
|
|
|
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
|
|
|
char *uri;
|
|
|
|
char *dconnuri;
|
2011-02-01 14:23:40 +00:00
|
|
|
char *cookieout = NULL;
|
|
|
|
int cookieoutlen = 0;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2011-05-18 09:26:30 +00:00
|
|
|
xmlin = args->xmlin == NULL ? NULL : *args->xmlin;
|
2011-02-01 14:23:40 +00:00
|
|
|
dname = args->dname == NULL ? NULL : *args->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
|
|
|
uri = args->uri == NULL ? NULL : *args->uri;
|
|
|
|
dconnuri = args->dconnuri == NULL ? NULL : *args->dconnuri;
|
2011-02-01 14:23:40 +00:00
|
|
|
|
2011-05-18 09:26:30 +00:00
|
|
|
if (virDomainMigratePerform3(dom, xmlin,
|
2011-02-01 14:23:40 +00:00
|
|
|
args->cookie_in.cookie_in_val,
|
|
|
|
args->cookie_in.cookie_in_len,
|
|
|
|
&cookieout, &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
|
|
|
dconnuri, uri,
|
2011-02-01 14:23:40 +00:00
|
|
|
args->flags, dname, args->resource) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free cookie
|
|
|
|
*/
|
|
|
|
ret->cookie_out.cookie_out_len = cookieoutlen;
|
|
|
|
ret->cookie_out.cookie_out_val = cookieout;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-02-01 14:23:40 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigrateFinish3(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
2011-02-01 14:23:40 +00:00
|
|
|
remote_domain_migrate_finish3_args *args,
|
|
|
|
remote_domain_migrate_finish3_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
char *cookieout = NULL;
|
|
|
|
int cookieoutlen = 0;
|
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
|
|
|
char *uri;
|
|
|
|
char *dconnuri;
|
2011-02-01 14:23:40 +00:00
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
uri = args->uri == NULL ? NULL : *args->uri;
|
|
|
|
dconnuri = args->dconnuri == NULL ? NULL : *args->dconnuri;
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = virDomainMigrateFinish3(priv->conn, args->dname,
|
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
|
|
|
args->cookie_in.cookie_in_val,
|
|
|
|
args->cookie_in.cookie_in_len,
|
|
|
|
&cookieout, &cookieoutlen,
|
|
|
|
dconnuri, uri,
|
|
|
|
args->flags,
|
|
|
|
args->cancelled)))
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
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
|
|
|
make_nonnull_domain(&ret->dom, dom);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
|
|
|
/* remoteDispatchClientRequest will free cookie
|
|
|
|
*/
|
|
|
|
ret->cookie_out.cookie_out_len = cookieoutlen;
|
|
|
|
ret->cookie_out.cookie_out_val = cookieout;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0) {
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-02-01 14:23:40 +00:00
|
|
|
VIR_FREE(cookieout);
|
|
|
|
}
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2011-05-16 17:13:11 +00:00
|
|
|
remoteDispatchDomainMigrateConfirm3(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
2011-10-21 11:12:28 +00:00
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_migrate_confirm3_args *args)
|
2011-02-01 14:23:40 +00:00
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int rv = -1;
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
2011-02-01 14:23:40 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
2011-02-01 14:23:40 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainMigrateConfirm3(dom,
|
|
|
|
args->cookie_in.cookie_in_val,
|
|
|
|
args->cookie_in.cookie_in_len,
|
|
|
|
args->flags, args->cancelled) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
2011-02-01 14:23:40 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-21 11:12:28 +00:00
|
|
|
static int remoteDispatchSupportsFeature(
|
|
|
|
virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_supports_feature_args *args,
|
|
|
|
remote_supports_feature_ret *ret)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int supported;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
2011-08-24 13:33:34 +00:00
|
|
|
/* This feature is checked before opening the connection, thus we must
|
|
|
|
* check it first.
|
|
|
|
*/
|
|
|
|
if (args->feature == VIR_DRV_FEATURE_PROGRAM_KEEPALIVE) {
|
|
|
|
if (virNetServerClientStartKeepAlive(client) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
supported = 1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2011-10-21 11:12:28 +00:00
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-10-21 11:12:28 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (args->feature) {
|
|
|
|
case VIR_DRV_FEATURE_FD_PASSING:
|
|
|
|
supported = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if ((supported = virDrvSupportsFeature(priv->conn, args->feature)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-24 13:33:34 +00:00
|
|
|
done:
|
2011-10-21 11:12:28 +00:00
|
|
|
ret->supported = supported;
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-21 11:49:23 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainOpenGraphics(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr msg,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_open_graphics_args *args)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int rv = -1;
|
|
|
|
int fd = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-10-21 11:49:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((fd = virNetMessageDupFD(msg, 0)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainOpenGraphics(dom,
|
|
|
|
args->idx,
|
|
|
|
fd,
|
|
|
|
args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FORCE_CLOSE(fd);
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-12-29 07:33:18 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetInterfaceParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_interface_parameters_args *args,
|
|
|
|
remote_domain_get_interface_parameters_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
const char *device = args->device;
|
|
|
|
int nparams = args->nparams;
|
|
|
|
unsigned int flags;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2011-12-29 07:33:18 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = args->flags;
|
|
|
|
|
|
|
|
if (nparams > REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2011-12-29 07:33:18 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-07-30 10:14:54 +00:00
|
|
|
if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
|
2011-12-29 07:33:18 +00:00
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virDomainGetInterfaceParameters(dom, device, params, &nparams, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* In this case, we need to send back the number of parameters
|
|
|
|
* supported
|
|
|
|
*/
|
|
|
|
if (args->nparams == 0) {
|
|
|
|
ret->nparams = nparams;
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (remoteSerializeTypedParameters(params, nparams,
|
|
|
|
&ret->params.params_val,
|
|
|
|
&ret->params.params_len,
|
|
|
|
flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2012-01-02 21:35:12 +00:00
|
|
|
virTypedParameterArrayClear(params, nparams);
|
|
|
|
VIR_FREE(params);
|
2011-12-29 07:33:18 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
2011-10-21 11:49:23 +00:00
|
|
|
|
2012-01-28 06:21:31 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessagePtr hdr ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_cpu_stats_args *args,
|
|
|
|
remote_domain_get_cpu_stats_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
struct daemonClientPrivate *priv;
|
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int rv = -1;
|
|
|
|
int percpu_len = 0;
|
|
|
|
|
|
|
|
priv = virNetServerClientGetPrivateData(client);
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2012-01-28 06:21:31 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args->nparams > REMOTE_NODE_CPU_STATS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
2012-01-28 06:21:31 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (args->ncpus > REMOTE_DOMAIN_GET_CPU_STATS_NCPUS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("ncpus too large"));
|
2012-01-28 06:21:31 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args->nparams > 0 &&
|
|
|
|
VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
percpu_len = virDomainGetCPUStats(dom, params, args->nparams,
|
|
|
|
args->start_cpu, args->ncpus,
|
|
|
|
args->flags);
|
|
|
|
if (percpu_len < 0)
|
|
|
|
goto cleanup;
|
|
|
|
/* If nparams == 0, the function returns a single value */
|
|
|
|
if (args->nparams == 0)
|
|
|
|
goto success;
|
|
|
|
|
|
|
|
if (remoteSerializeTypedParameters(params, args->nparams * args->ncpus,
|
|
|
|
&ret->params.params_val,
|
|
|
|
&ret->params.params_len,
|
|
|
|
args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
success:
|
|
|
|
rv = 0;
|
|
|
|
ret->nparams = percpu_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
|
|
|
if (args->nparams && !(args->flags & VIR_TYPED_PARAM_STRING_OKAY)) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < percpu_len; i++) {
|
|
|
|
if (params[i].type == VIR_TYPED_PARAM_STRING)
|
|
|
|
ret->nparams--;
|
|
|
|
}
|
|
|
|
}
|
2012-01-28 06:21:31 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virTypedParameterArrayClear(params, args->ncpus * args->nparams);
|
|
|
|
VIR_FREE(params);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-01-31 06:42:31 +00:00
|
|
|
static int remoteDispatchDomainGetDiskErrors(
|
|
|
|
virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_get_disk_errors_args *args,
|
|
|
|
remote_domain_get_disk_errors_ret *ret)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virDomainDiskErrorPtr errors = NULL;
|
2012-02-01 15:10:46 +00:00
|
|
|
int len = 0;
|
2012-01-31 06:42:31 +00:00
|
|
|
struct daemonClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2012-01-31 06:42:31 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (args->maxerrors > REMOTE_DOMAIN_DISK_ERRORS_MAX) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("maxerrors too large"));
|
2012-01-31 06:42:31 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args->maxerrors &&
|
|
|
|
VIR_ALLOC_N(errors, args->maxerrors) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((len = virDomainGetDiskErrors(dom, errors,
|
|
|
|
args->maxerrors,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret->nerrors = len;
|
|
|
|
if (errors &&
|
|
|
|
remoteSerializeDomainDiskErrors(errors, len,
|
|
|
|
&ret->errors.errors_val,
|
|
|
|
&ret->errors.errors_len) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
if (errors) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
VIR_FREE(errors[i].disk);
|
|
|
|
}
|
|
|
|
VIR_FREE(errors);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-06-10 03:24:57 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchDomainListAllSnapshots(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_list_all_snapshots_args *args,
|
|
|
|
remote_domain_list_all_snapshots_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainSnapshotPtr *snaps = NULL;
|
|
|
|
int nsnaps = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2012-06-10 03:24:57 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((nsnaps = virDomainListAllSnapshots(dom,
|
|
|
|
args->need_results ? &snaps : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (snaps && nsnaps) {
|
|
|
|
if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->snapshots.snapshots_len = nsnaps;
|
|
|
|
|
|
|
|
for (i = 0; i < nsnaps; i++)
|
|
|
|
make_nonnull_domain_snapshot(ret->snapshots.snapshots_val + i,
|
|
|
|
snaps[i]);
|
|
|
|
} else {
|
|
|
|
ret->snapshots.snapshots_len = 0;
|
|
|
|
ret->snapshots.snapshots_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = nsnaps;
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
if (snaps) {
|
|
|
|
for (i = 0; i < nsnaps; i++)
|
|
|
|
virDomainSnapshotFree(snaps[i]);
|
|
|
|
VIR_FREE(snaps);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
remoteDispatchDomainSnapshotListAllChildren(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_domain_snapshot_list_all_children_args *args,
|
|
|
|
remote_domain_snapshot_list_all_children_ret *ret)
|
|
|
|
{
|
|
|
|
virDomainSnapshotPtr *snaps = NULL;
|
|
|
|
int nsnaps = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
virDomainSnapshotPtr snapshot = NULL;
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
2012-07-18 18:30:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
2012-06-10 03:24:57 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = get_nonnull_domain(priv->conn, args->snapshot.dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(snapshot = get_nonnull_domain_snapshot(dom, args->snapshot)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((nsnaps = virDomainSnapshotListAllChildren(snapshot,
|
|
|
|
args->need_results ? &snaps : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (snaps && nsnaps) {
|
|
|
|
if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->snapshots.snapshots_len = nsnaps;
|
|
|
|
|
|
|
|
for (i = 0; i < nsnaps; i++)
|
|
|
|
make_nonnull_domain_snapshot(ret->snapshots.snapshots_val + i,
|
|
|
|
snaps[i]);
|
|
|
|
} else {
|
|
|
|
ret->snapshots.snapshots_len = 0;
|
|
|
|
ret->snapshots.snapshots_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = nsnaps;
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (snapshot)
|
|
|
|
virDomainSnapshotFree(snapshot);
|
|
|
|
if (dom)
|
|
|
|
virDomainFree(dom);
|
|
|
|
if (snaps) {
|
|
|
|
for (i = 0; i < nsnaps; i++)
|
|
|
|
virDomainSnapshotFree(snaps[i]);
|
|
|
|
VIR_FREE(snaps);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:16:26 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_connect_list_all_storage_pools_args *args,
|
|
|
|
remote_connect_list_all_storage_pools_ret *ret)
|
|
|
|
{
|
|
|
|
virStoragePoolPtr *pools = NULL;
|
|
|
|
int npools = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((npools = virConnectListAllStoragePools(priv->conn,
|
|
|
|
args->need_results ? &pools : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (pools && npools) {
|
|
|
|
if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->pools.pools_len = npools;
|
|
|
|
|
|
|
|
for (i = 0; i < npools; i++)
|
|
|
|
make_nonnull_storage_pool(ret->pools.pools_val + i, pools[i]);
|
|
|
|
} else {
|
|
|
|
ret->pools.pools_len = 0;
|
|
|
|
ret->pools.pools_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = npools;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (pools) {
|
|
|
|
for (i = 0; i < npools; i++)
|
|
|
|
virStoragePoolFree(pools[i]);
|
|
|
|
VIR_FREE(pools);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:32:54 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_storage_pool_list_all_volumes_args *args,
|
|
|
|
remote_storage_pool_list_all_volumes_ret *ret)
|
|
|
|
{
|
|
|
|
virStorageVolPtr *vols = NULL;
|
|
|
|
virStoragePoolPtr pool = NULL;
|
|
|
|
int nvols = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pool = get_nonnull_storage_pool(priv->conn, args->pool)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((nvols = virStoragePoolListAllVolumes(pool,
|
|
|
|
args->need_results ? &vols : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (vols && nvols) {
|
|
|
|
if (VIR_ALLOC_N(ret->vols.vols_val, nvols) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->vols.vols_len = nvols;
|
|
|
|
|
|
|
|
for (i = 0; i < nvols; i++)
|
|
|
|
make_nonnull_storage_vol(ret->vols.vols_val + i, vols[i]);
|
|
|
|
} else {
|
|
|
|
ret->vols.vols_len = 0;
|
|
|
|
ret->vols.vols_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = nvols;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (vols) {
|
|
|
|
for (i = 0; i < nvols; i++)
|
|
|
|
virStorageVolFree(vols[i]);
|
|
|
|
VIR_FREE(vols);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:55:16 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchConnectListAllNetworks(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_connect_list_all_networks_args *args,
|
|
|
|
remote_connect_list_all_networks_ret *ret)
|
|
|
|
{
|
|
|
|
virNetworkPtr *nets = NULL;
|
|
|
|
int nnets = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((nnets = virConnectListAllNetworks(priv->conn,
|
|
|
|
args->need_results ? &nets : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (nets && nnets) {
|
|
|
|
if (VIR_ALLOC_N(ret->nets.nets_val, nnets) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->nets.nets_len = nnets;
|
|
|
|
|
|
|
|
for (i = 0; i < nnets; i++)
|
|
|
|
make_nonnull_network(ret->nets.nets_val + i, nets[i]);
|
|
|
|
} else {
|
|
|
|
ret->nets.nets_len = 0;
|
|
|
|
ret->nets.nets_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = nnets;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (nets) {
|
|
|
|
for (i = 0; i < nnets; i++)
|
|
|
|
virNetworkFree(nets[i]);
|
|
|
|
VIR_FREE(nets);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-09-04 16:10:16 +00:00
|
|
|
static int
|
|
|
|
remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED,
|
|
|
|
virNetServerClientPtr client,
|
|
|
|
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
remote_connect_list_all_interfaces_args *args,
|
|
|
|
remote_connect_list_all_interfaces_ret *ret)
|
|
|
|
{
|
|
|
|
virInterfacePtr *ifaces = NULL;
|
|
|
|
int nifaces = 0;
|
|
|
|
int i;
|
|
|
|
int rv = -1;
|
|
|
|
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!priv->conn) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((nifaces = virConnectListAllInterfaces(priv->conn,
|
|
|
|
args->need_results ? &ifaces : NULL,
|
|
|
|
args->flags)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (ifaces && nifaces) {
|
|
|
|
if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ifaces.ifaces_len = nifaces;
|
|
|
|
|
|
|
|
for (i = 0; i < nifaces; i++)
|
|
|
|
make_nonnull_interface(ret->ifaces.ifaces_val + i, ifaces[i]);
|
|
|
|
} else {
|
|
|
|
ret->ifaces.ifaces_len = 0;
|
|
|
|
ret->ifaces.ifaces_val = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ret = nifaces;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
if (ifaces) {
|
|
|
|
for (i = 0; i < nifaces; i++)
|
|
|
|
virInterfaceFree(ifaces[i]);
|
|
|
|
VIR_FREE(ifaces);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:55:16 +00:00
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/*----- Helpers. -----*/
|
|
|
|
|
|
|
|
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
|
|
|
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
|
|
|
|
* virDomainPtr or virNetworkPtr cannot be NULL.
|
|
|
|
*
|
|
|
|
* NB. If these return NULL then the caller must return an error.
|
|
|
|
*/
|
|
|
|
static virDomainPtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_domain(virConnectPtr conn, remote_nonnull_domain domain)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
|
|
|
virDomainPtr dom;
|
2011-04-12 16:34:30 +00:00
|
|
|
dom = virGetDomain(conn, domain.name, BAD_CAST domain.uuid);
|
2007-06-11 11:47:01 +00:00
|
|
|
/* Should we believe the domain.id sent by the client? Maybe
|
|
|
|
* this should be a check rather than an assignment? XXX
|
|
|
|
*/
|
|
|
|
if (dom) dom->id = domain.id;
|
|
|
|
return dom;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virNetworkPtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_network(virConnectPtr conn, remote_nonnull_network network)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
return virGetNetwork(conn, network.name, BAD_CAST network.uuid);
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
static virInterfacePtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_interface(virConnectPtr conn, remote_nonnull_interface iface)
|
2009-05-20 14:26:49 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
return virGetInterface(conn, iface.name, iface.mac);
|
2009-05-20 14:26:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:22:35 +00:00
|
|
|
static virStoragePoolPtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_storage_pool(virConnectPtr conn, remote_nonnull_storage_pool pool)
|
2008-02-20 15:22:35 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
return virGetStoragePool(conn, pool.name, BAD_CAST pool.uuid);
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol)
|
2008-02-20 15:22:35 +00:00
|
|
|
{
|
|
|
|
virStorageVolPtr ret;
|
2011-04-12 16:34:30 +00:00
|
|
|
ret = virGetStorageVol(conn, vol.pool, vol.name, vol.key);
|
2008-02-20 15:22:35 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-07-28 02:01:00 +00:00
|
|
|
static virSecretPtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret)
|
2009-07-28 02:01:00 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
return virGetSecret(conn, BAD_CAST secret.uuid, secret.usageType, secret.usageID);
|
2009-07-28 02:01:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 17:46:03 +00:00
|
|
|
static virNWFilterPtr
|
2011-04-12 16:34:30 +00:00
|
|
|
get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter)
|
2010-03-25 17:46:03 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
return virGetNWFilter(conn, nwfilter.name, BAD_CAST nwfilter.uuid);
|
2010-03-25 17:46:03 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 20:33:13 +00:00
|
|
|
static virDomainSnapshotPtr
|
2011-04-13 18:10:03 +00:00
|
|
|
get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot)
|
2010-03-31 20:33:13 +00:00
|
|
|
{
|
2011-04-13 18:10:03 +00:00
|
|
|
return virGetDomainSnapshot(dom, snapshot.name);
|
2010-03-31 20:33:13 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 11:47:01 +00:00
|
|
|
/* Make remote_nonnull_domain and remote_nonnull_network. */
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
|
|
|
dom_dst->id = dom_src->id;
|
2011-04-12 16:34:30 +00:00
|
|
|
dom_dst->name = strdup(dom_src->name);
|
|
|
|
memcpy(dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src)
|
2007-06-11 11:47:01 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
net_dst->name = strdup(net_src->name);
|
|
|
|
memcpy(net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
|
2007-06-11 11:47:01 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 14:26:49 +00:00
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_interface(remote_nonnull_interface *interface_dst,
|
|
|
|
virInterfacePtr interface_src)
|
2009-05-20 14:26:49 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
interface_dst->name = strdup(interface_src->name);
|
|
|
|
interface_dst->mac = strdup(interface_src->mac);
|
2009-05-20 14:26:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:22:35 +00:00
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
|
2008-02-20 15:22:35 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
pool_dst->name = strdup(pool_src->name);
|
|
|
|
memcpy(pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
|
2008-02-20 15:22:35 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
vol_dst->pool = strdup(vol_src->pool);
|
|
|
|
vol_dst->name = strdup(vol_src->name);
|
|
|
|
vol_dst->key = strdup(vol_src->key);
|
2008-02-20 15:22:35 +00:00
|
|
|
}
|
2008-11-21 12:31:04 +00:00
|
|
|
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
|
2008-11-21 12:31:04 +00:00
|
|
|
{
|
|
|
|
dev_dst->name = strdup(dev_src->name);
|
|
|
|
}
|
2009-07-28 02:01:00 +00:00
|
|
|
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
|
2009-07-28 02:01:00 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +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;
|
2011-04-12 16:34:30 +00:00
|
|
|
secret_dst->usageID = strdup(secret_src->usageID);
|
2009-07-28 02:01:00 +00:00
|
|
|
}
|
2010-03-25 17:46:03 +00:00
|
|
|
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
|
2010-03-25 17:46:03 +00:00
|
|
|
{
|
2011-04-12 16:34:30 +00:00
|
|
|
nwfilter_dst->name = strdup(nwfilter_src->name);
|
|
|
|
memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
|
2010-03-25 17:46:03 +00:00
|
|
|
}
|
2010-03-31 20:33:13 +00:00
|
|
|
|
|
|
|
static void
|
2011-04-12 16:34:30 +00:00
|
|
|
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
|
2010-03-31 20:33:13 +00:00
|
|
|
{
|
|
|
|
snapshot_dst->name = strdup(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
|
|
|
}
|
2012-01-31 06:42:31 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
|
|
|
|
int nerrors,
|
|
|
|
remote_domain_disk_error **ret_errors_val,
|
|
|
|
u_int *ret_errors_len)
|
|
|
|
{
|
|
|
|
remote_domain_disk_error *val = NULL;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(val, nerrors) < 0)
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
for (i = 0; i < nerrors; i++) {
|
|
|
|
if (!(val[i].disk = strdup(errors[i].disk)))
|
|
|
|
goto no_memory;
|
|
|
|
val[i].error = errors[i].error;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret_errors_len = nerrors;
|
|
|
|
*ret_errors_val = val;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
if (val) {
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
VIR_FREE(val[j].disk);
|
|
|
|
VIR_FREE(val);
|
|
|
|
}
|
|
|
|
virReportOOMError();
|
|
|
|
return -1;
|
|
|
|
}
|