2007-06-11 15:47:01 +04:00
/*
2009-07-10 15:20:03 +04:00
* remote . c : handlers for RPC method calls
2007-06-11 15:47:01 +04:00
*
2011-02-08 01:04:17 +03:00
* Copyright ( C ) 2007 - 2011 Red Hat , Inc .
2007-06-11 15:47:01 +04:00
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*
* Author : Richard W . M . Jones < rjones @ redhat . com >
*/
# include <config.h>
# include <sys/types.h>
# include <sys/wait.h>
# include <sys/stat.h>
# include <unistd.h>
# include <fcntl.h>
# include <limits.h>
# include <sys/socket.h>
# include <sys/un.h>
# include <sys/poll.h>
# include <netinet/in.h>
# include <netdb.h>
# include <stdlib.h>
# include <pwd.h>
# include <stdio.h>
# include <stdarg.h>
# include <syslog.h>
# include <string.h>
# include <errno.h>
2007-12-05 18:34:05 +03:00
# include <fnmatch.h>
2010-04-20 20:08:56 +04:00
# include <arpa/inet.h>
2009-02-05 19:28:30 +03:00
# include "virterror_internal.h"
2007-06-11 15:47:01 +04:00
2009-08-06 16:54:08 +04:00
# if HAVE_POLKIT0
2010-03-09 21:22:22 +03:00
# include <polkit / polkit.h>
# include <polkit-dbus / polkit-dbus.h>
2007-12-05 21:21:27 +03:00
# endif
2009-07-10 15:20:03 +04:00
# include "remote.h"
# include "dispatch.h"
2008-11-05 02:22:06 +03:00
# include "libvirt_internal.h"
# include "datatypes.h"
2008-06-06 14:52:01 +04:00
# include "memory.h"
2009-05-19 17:15:50 +04:00
# include "util.h"
2009-09-30 14:51:54 +04:00
# include "stream.h"
2010-10-12 15:22:03 +04:00
# include "uuid.h"
2010-10-20 20:29:56 +04:00
# include "network.h"
2010-04-17 06:09:25 +04:00
# include "libvirt/libvirt-qemu.h"
2011-03-22 20:55:45 +03:00
# include "command.h"
2007-06-11 15:47:01 +04:00
2009-05-19 17:15:50 +04:00
# define VIR_FROM_THIS VIR_FROM_REMOTE
2007-12-05 18:24:15 +03:00
2011-04-13 19:21:35 +04:00
# define virNetError(code, ...) \
virReportErrorHelper ( VIR_FROM_THIS , code , __FILE__ , \
__FUNCTION__ , __LINE__ , __VA_ARGS__ )
2011-04-12 20:34:30 +04: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 ) ;
static virDomainSnapshotPtr get_nonnull_domain_snapshot ( virDomainPtr domain , remote_nonnull_domain_snapshot snapshot ) ;
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 15:47:01 +04:00
2008-12-05 01:03:24 +03:00
2009-07-10 15:20:03 +04:00
# include "remote_dispatch_prototypes.h"
2010-04-17 06:09:25 +04:00
# include "qemu_dispatch_prototypes.h"
2008-12-05 01:03:24 +03:00
static const dispatch_data const dispatch_table [ ] = {
# include "remote_dispatch_table.h"
} ;
2007-06-11 15:47:01 +04:00
2010-04-17 06:09:25 +04:00
static const dispatch_data const qemu_dispatch_table [ ] = {
# include "qemu_dispatch_table.h"
} ;
2009-07-10 15:20:03 +04:00
const dispatch_data const * remoteGetDispatchData ( int proc )
{
if ( proc > = ARRAY_CARDINALITY ( dispatch_table ) | |
dispatch_table [ proc ] . fn = = NULL ) {
return NULL ;
}
return & ( dispatch_table [ proc ] ) ;
}
2010-04-17 06:09:25 +04:00
const dispatch_data const * qemuGetDispatchData ( int proc )
{
if ( proc > = ARRAY_CARDINALITY ( qemu_dispatch_table ) | |
qemu_dispatch_table [ proc ] . fn = = NULL ) {
return NULL ;
}
return & ( qemu_dispatch_table [ proc ] ) ;
}
2008-10-23 17:18:18 +04:00
/* Prototypes */
static void
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( struct qemud_client * client ,
int procnr ,
xdrproc_t proc ,
void * data ) ;
2007-12-05 18:24:15 +03: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 17:56:56 +03:00
static int remoteRelayDomainEventLifecycle ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
int event ,
int detail ,
void * opaque )
2008-10-23 17:18:18 +04:00
{
struct qemud_client * client = opaque ;
2010-03-19 17:28:23 +03:00
remote_domain_event_lifecycle_msg data ;
2008-10-23 17:18:18 +04: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 17:56:56 +03:00
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Relaying domain lifecycle event %d %d " , event , detail ) ;
2009-07-10 15:48:50 +04: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 17:56:56 +03:00
virMutexLock ( & client - > lock ) ;
2009-01-20 22:25:15 +03: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 17:56:56 +03:00
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04: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 17:56:56 +03:00
data . event = event ;
data . detail = detail ;
2009-01-20 22:25:15 +03:00
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
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 17:56:56 +03:00
virMutexUnlock ( & client - > lock ) ;
2009-01-20 22:25:15 +03:00
2008-10-23 17:18:18 +04:00
return 0 ;
}
2007-12-05 18:24:15 +03:00
2010-03-18 18:25:38 +03:00
static int remoteRelayDomainEventReboot ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
void * opaque )
{
struct qemud_client * client = opaque ;
remote_domain_event_reboot_msg data ;
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Relaying domain reboot event %s %d " , dom - > name , dom - > id ) ;
2010-03-18 18:25:38 +03:00
virMutexLock ( & client - > lock ) ;
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & data . dom , dom ) ;
2010-03-18 18:25:38 +03:00
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
REMOTE_PROC_DOMAIN_EVENT_REBOOT ,
( xdrproc_t ) xdr_remote_domain_event_reboot_msg , & data ) ;
2010-03-18 18:25:38 +03:00
virMutexUnlock ( & client - > lock ) ;
return 0 ;
}
2007-12-05 18:24:15 +03:00
2010-03-18 21:28:15 +03:00
static int remoteRelayDomainEventRTCChange ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
long long offset ,
void * opaque )
{
struct qemud_client * client = opaque ;
remote_domain_event_rtc_change_msg data ;
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Relaying domain rtc change event %s %d %lld " , dom - > name , dom - > id , offset ) ;
2010-03-18 21:28:15 +03:00
virMutexLock ( & client - > lock ) ;
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & data . dom , dom ) ;
2010-03-18 21:28:15 +03:00
data . offset = offset ;
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
REMOTE_PROC_DOMAIN_EVENT_RTC_CHANGE ,
( xdrproc_t ) xdr_remote_domain_event_rtc_change_msg , & data ) ;
2010-03-18 21:28:15 +03:00
virMutexUnlock ( & client - > lock ) ;
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 22:07:48 +03:00
static int remoteRelayDomainEventWatchdog ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
int action ,
void * opaque )
{
struct qemud_client * client = opaque ;
remote_domain_event_watchdog_msg data ;
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04: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 22:07:48 +03:00
virMutexLock ( & client - > lock ) ;
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04: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 22:07:48 +03:00
data . action = action ;
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
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 22:07:48 +03:00
virMutexUnlock ( & client - > lock ) ;
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 22:37:44 +03:00
static int remoteRelayDomainEventIOError ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
const char * srcPath ,
const char * devAlias ,
int action ,
void * opaque )
{
struct qemud_client * client = opaque ;
remote_domain_event_io_error_msg data ;
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04: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 22:37:44 +03:00
virMutexLock ( & client - > lock ) ;
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04: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 22:37:44 +03:00
data . srcPath = ( char * ) srcPath ;
data . devAlias = ( char * ) devAlias ;
data . action = action ;
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
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 22:37:44 +03:00
virMutexUnlock ( & client - > lock ) ;
return 0 ;
}
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 22:37:44 +03:00
static int remoteRelayDomainEventIOErrorReason ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
const char * srcPath ,
const char * devAlias ,
int action ,
const char * reason ,
void * opaque )
{
struct qemud_client * client = opaque ;
remote_domain_event_io_error_reason_msg data ;
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04: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 22:37:44 +03:00
virMutexLock ( & client - > lock ) ;
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04:00
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 22:37:44 +03:00
data . srcPath = ( char * ) srcPath ;
data . devAlias = ( char * ) devAlias ;
data . action = action ;
data . reason = ( char * ) reason ;
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
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 22:37:44 +03:00
virMutexUnlock ( & client - > lock ) ;
return 0 ;
}
Add domain events for graphics network clients
This introduces a new event type
VIR_DOMAIN_EVENT_ID_GRAPHICS
The same event can be emitted in 3 scenarios
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
} virDomainEventGraphicsPhase;
Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop
This event comes with *a lot* of potential information
- IP address, port & address family of client
- IP address, port & address family of server
- Authentication scheme (arbitrary string)
- Authenticated subject identity. A subject may have
multiple identities with some authentication schemes.
For example, vencrypt+sasl results in a x509dname
and saslUsername identities.
This results in a very complicated callback :-(
typedef enum {
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
} virDomainEventGraphicsAddressType;
struct _virDomainEventGraphicsAddress {
int family;
const char *node;
const char *service;
};
typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;
struct _virDomainEventGraphicsSubject {
int nidentity;
struct {
const char *type;
const char *name;
} *identities;
};
typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;
typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque);
The wire protocol is similarly complex
struct remote_domain_event_graphics_address {
int family;
remote_nonnull_string node;
remote_nonnull_string service;
};
const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;
struct remote_domain_event_graphics_identity {
remote_nonnull_string type;
remote_nonnull_string name;
};
struct remote_domain_event_graphics_msg {
remote_nonnull_domain dom;
int phase;
remote_domain_event_graphics_address local;
remote_domain_event_graphics_address remote;
remote_nonnull_string authScheme;
remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
};
This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.
* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-19 16:27:45 +03:00
static int remoteRelayDomainEventGraphics ( virConnectPtr conn ATTRIBUTE_UNUSED ,
virDomainPtr dom ,
int phase ,
virDomainEventGraphicsAddressPtr local ,
virDomainEventGraphicsAddressPtr remote ,
const char * authScheme ,
virDomainEventGraphicsSubjectPtr subject ,
void * opaque )
{
struct qemud_client * client = opaque ;
remote_domain_event_graphics_msg data ;
int i ;
if ( ! client )
return - 1 ;
2011-04-13 19:10:01 +04: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 16:27:45 +03:00
2011-04-13 19:10:01 +04: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 16:27:45 +03:00
for ( i = 0 ; i < subject - > nidentity ; i + + ) {
2011-04-13 19:10:01 +04: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 16:27:45 +03:00
}
virMutexLock ( & client - > lock ) ;
/* build return data */
memset ( & data , 0 , sizeof data ) ;
2011-04-12 20:34:30 +04: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 16:27:45 +03:00
data . phase = phase ;
data . authScheme = ( char * ) authScheme ;
data . local . family = local - > family ;
data . local . node = ( char * ) local - > node ;
data . local . service = ( char * ) local - > service ;
data . remote . family = remote - > family ;
data . remote . node = ( char * ) remote - > node ;
data . remote . service = ( char * ) remote - > service ;
data . subject . subject_len = subject - > nidentity ;
if ( VIR_ALLOC_N ( data . subject . subject_val , data . subject . subject_len ) < 0 ) {
VIR_WARN0 ( " cannot allocate memory for graphics event subject " ) ;
return - 1 ;
}
for ( i = 0 ; i < data . subject . subject_len ; i + + ) {
data . subject . subject_val [ i ] . type = ( char * ) subject - > identities [ i ] . type ;
data . subject . subject_val [ i ] . name = ( char * ) subject - > identities [ i ] . name ;
}
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( client ,
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 16:27:45 +03:00
VIR_FREE ( data . subject . subject_val ) ;
virMutexUnlock ( & client - > lock ) ;
return 0 ;
}
2010-03-18 18:25:38 +03: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 17:56:56 +03:00
VIR_DOMAIN_EVENT_CALLBACK ( remoteRelayDomainEventLifecycle ) ,
2010-03-18 18:25:38 +03:00
VIR_DOMAIN_EVENT_CALLBACK ( remoteRelayDomainEventReboot ) ,
2010-03-18 21:28:15 +03: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 22:07:48 +03: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 22:37:44 +03: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 16:27:45 +03: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 22:37:44 +03:00
VIR_DOMAIN_EVENT_CALLBACK ( remoteRelayDomainEventIOErrorReason ) ,
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 17:56:56 +03:00
} ;
verify ( ARRAY_CARDINALITY ( domainEventCallbacks ) = = VIR_DOMAIN_EVENT_ID_LAST ) ;
2007-06-11 15:47:01 +04:00
/*----- Functions. -----*/
static int
2011-04-12 20:34:30 +04:00
remoteDispatchOpen ( struct qemud_server * server ,
struct qemud_client * client ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
struct remote_open_args * args , void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
const char * name ;
2011-04-13 19:21:35 +04:00
int flags ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2008-12-05 01:16:40 +03:00
2011-04-13 19:21:35 +04:00
if ( conn ) {
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection already open " ) ) ;
goto cleanup ;
}
2007-06-11 15:47:01 +04:00
name = args - > name ? * args - > name : NULL ;
/* If this connection arrived on a readonly socket, force
* the connection to be readonly .
*/
flags = args - > flags ;
if ( client - > readonly ) flags | = VIR_CONNECT_RO ;
client - > conn =
flags & VIR_CONNECT_RO
2011-04-12 20:34:30 +04:00
? virConnectOpenReadOnly ( name )
: virConnectOpen ( name ) ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( client - > conn = = NULL )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
2008-12-05 01:12:53 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2011-04-13 19:21:35 +04:00
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchClose ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ATTRIBUTE_UNUSED ,
void * args ATTRIBUTE_UNUSED , void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2007-06-11 15:47:01 +04:00
2008-12-05 01:16:40 +03:00
client - > closing = 1 ;
2007-06-11 15:47:01 +04:00
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2008-12-05 01:12:53 +03:00
return 0 ;
2007-06-11 15:47:01 +04:00
}
2007-08-21 13:03:55 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSupportsFeature ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_supports_feature_args * args , remote_supports_feature_ret * ret )
2007-08-21 13:03:55 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ( ret - > supported = virDrvSupportsFeature ( conn , args - > feature ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 13:03:55 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-08-21 13:03:55 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetType ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED , remote_get_type_ret * ret )
2007-06-11 15:47:01 +04:00
{
const char * type ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( type = virConnectGetType ( conn ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
/* We have to strdup because remoteDispatchClientRequest will
* free this string after it ' s been serialised .
*/
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > type = strdup ( type ) ) ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetVersion ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_get_version_ret * ret )
2007-06-11 15:47:01 +04:00
{
unsigned long hvVer ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:23:00 +04:00
if ( virConnectGetVersion ( conn , & hvVer ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
ret - > hv_ver = hvVer ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2009-11-12 18:53:26 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetLibVersion ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_get_lib_version_ret * ret )
2009-11-12 18:53:26 +03:00
{
unsigned long libVer ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2009-11-12 18:53:26 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:23:00 +04:00
if ( virConnectGetLibVersion ( conn , & libVer ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-11-12 18:53:26 +03:00
ret - > lib_ver = libVer ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-11-12 18:53:26 +03:00
}
2007-06-26 15:42:46 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetHostname ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_get_hostname_ret * ret )
2007-06-26 15:42:46 +04:00
{
char * hostname ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-26 15:42:46 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( hostname = virConnectGetHostname ( conn ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-26 15:42:46 +04:00
ret - > hostname = hostname ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-26 15:42:46 +04:00
}
2008-11-17 14:44:51 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetUri ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_get_uri_ret * ret )
2008-11-17 14:44:51 +03:00
{
char * uri ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-17 14:44:51 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( uri = virConnectGetURI ( conn ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-17 14:44:51 +03:00
ret - > uri = uri ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-11-17 14:44:51 +03:00
}
2011-02-08 01:04:17 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetSysinfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_get_sysinfo_args * args ,
remote_get_sysinfo_ret * ret )
2011-02-08 01:04:17 +03:00
{
unsigned int flags ;
char * sysinfo ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-02-08 01:04:17 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-02-08 01:04:17 +03:00
flags = args - > flags ;
2011-04-13 21:50:40 +04:00
if ( ! ( sysinfo = virConnectGetSysinfo ( conn , flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-02-08 01:04:17 +03:00
ret - > sysinfo = sysinfo ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2011-02-08 01:04:17 +03:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetMaxVcpus ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_get_max_vcpus_args * args ,
remote_get_max_vcpus_ret * ret )
2007-06-11 15:47:01 +04:00
{
char * type ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
type = args - > type ? * args - > type : NULL ;
2011-04-13 21:50:40 +04:00
if ( ( ret - > max_vcpus = virConnectGetMaxVcpus ( conn , type ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeGetInfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_node_get_info_ret * ret )
2007-06-11 15:47:01 +04:00
{
virNodeInfo info ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:23:00 +04:00
if ( virNodeGetInfo ( conn , & info ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
memcpy ( ret - > model , info . model , sizeof ret - > model ) ;
2007-06-11 15:47:01 +04:00
ret - > memory = info . memory ;
ret - > cpus = info . cpus ;
ret - > mhz = info . mhz ;
ret - > nodes = info . nodes ;
ret - > sockets = info . sockets ;
ret - > cores = info . cores ;
ret - > threads = info . threads ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchGetCapabilities ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_get_capabilities_ret * ret )
2007-06-11 15:47:01 +04:00
{
char * caps ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( caps = virConnectGetCapabilities ( conn ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
ret - > capabilities = caps ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2008-05-22 19:20:25 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeGetCellsFreeMemory ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_get_cells_free_memory_args * args ,
remote_node_get_cells_free_memory_ret * ret )
2008-05-22 19:20:25 +04:00
{
2011-04-13 21:50:40 +04:00
int len ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2008-05-22 19:20:25 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-05-22 19:20:25 +04:00
if ( args - > maxCells > REMOTE_NODE_MAX_CELLS ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxCells > REMOTE_NODE_MAX_CELLS " ) ) ;
goto cleanup ;
2008-05-22 19:20:25 +04:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > freeMems . freeMems_val , args - > maxCells ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2008-05-22 19:20:25 +04:00
2011-04-13 21:50:40 +04:00
len = virNodeGetCellsFreeMemory ( conn ,
2009-04-03 16:45:05 +04:00
( unsigned long long * ) ret - > freeMems . freeMems_val ,
args - > startCell ,
args - > maxCells ) ;
2011-04-13 21:50:40 +04:00
if ( len < = 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
ret - > freeMems . freeMems_len = len ;
2008-05-22 19:20:25 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > freeMems . freeMems_val ) ;
}
return rv ;
2008-05-22 19:20:25 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeGetFreeMemory ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_node_get_free_memory_ret * ret )
2008-05-22 19:20:25 +04:00
{
unsigned long long freeMem ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2008-05-22 19:20:25 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ( freeMem = virNodeGetFreeMemory ( conn ) ) = = 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-05-22 19:20:25 +04:00
ret - > freeMem = freeMem ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-05-22 19:20:25 +04:00
}
2007-06-22 17:16:10 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetSchedulerType ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_scheduler_type_args * args ,
remote_domain_get_scheduler_type_ret * ret )
2007-06-22 17:16:10 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2007-06-22 17:16:10 +04:00
char * type ;
int nparams ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-22 17:16:10 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( type = virDomainGetSchedulerType ( dom , & nparams ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
ret - > type = type ;
ret - > nparams = nparams ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-22 17:16:10 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetSchedulerParameters ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_scheduler_parameters_args * args ,
remote_domain_get_scheduler_parameters_ret * ret )
2007-06-22 17:16:10 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virSchedParameterPtr params = NULL ;
2011-04-13 21:50:40 +04:00
int i , nparams ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-22 17:16:10 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-22 17:16:10 +04:00
nparams = args - > nparams ;
if ( nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " nparams too large " ) ) ;
goto cleanup ;
2007-06-22 17:16:10 +04:00
}
2011-04-13 19:21:35 +04:00
if ( VIR_ALLOC_N ( params , nparams ) < 0 )
goto no_memory ;
2007-06-22 17:16:10 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
2011-04-13 21:50:40 +04:00
if ( virDomainGetSchedulerParameters ( dom , params , & nparams ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
/* Serialise the scheduler parameters. */
ret - > params . params_len = nparams ;
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > params . params_val , nparams ) < 0 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2007-06-22 17:16:10 +04:00
for ( i = 0 ; i < nparams ; + + i ) {
2011-01-29 00:38:06 +03:00
/* remoteDispatchClientRequest will free this: */
2011-04-12 20:34:30 +04:00
ret - > params . params_val [ i ] . field = strdup ( params [ i ] . field ) ;
2008-06-06 14:52:01 +04:00
if ( ret - > params . params_val [ i ] . field = = NULL )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2008-06-06 14:52:01 +04:00
2007-06-22 17:16:10 +04:00
ret - > params . params_val [ i ] . value . type = params [ i ] . type ;
switch ( params [ i ] . type ) {
case VIR_DOMAIN_SCHED_FIELD_INT :
ret - > params . params_val [ i ] . value . remote_sched_param_value_u . i = params [ i ] . value . i ; break ;
case VIR_DOMAIN_SCHED_FIELD_UINT :
ret - > params . params_val [ i ] . value . remote_sched_param_value_u . ui = params [ i ] . value . ui ; break ;
case VIR_DOMAIN_SCHED_FIELD_LLONG :
ret - > params . params_val [ i ] . value . remote_sched_param_value_u . l = params [ i ] . value . l ; break ;
case VIR_DOMAIN_SCHED_FIELD_ULLONG :
ret - > params . params_val [ i ] . value . remote_sched_param_value_u . ul = params [ i ] . value . ul ; break ;
case VIR_DOMAIN_SCHED_FIELD_DOUBLE :
ret - > params . params_val [ i ] . value . remote_sched_param_value_u . d = params [ i ] . value . d ; break ;
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN :
ret - > params . params_val [ i ] . value . remote_sched_param_value_u . b = params [ i ] . value . b ; break ;
default :
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " unknown type " ) ) ;
2008-06-06 14:52:01 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
}
}
2011-04-13 19:21:35 +04:00
rv = 0 ;
2008-06-06 14:52:01 +04:00
cleanup :
2011-04-13 19:21:35 +04:00
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
for ( i = 0 ; i < nparams ; i + + )
VIR_FREE ( ret - > params . params_val [ i ] . field ) ;
}
if ( dom )
virDomainFree ( dom ) ;
2008-06-06 14:52:01 +04:00
VIR_FREE ( params ) ;
2011-04-13 19:21:35 +04:00
return rv ;
no_memory :
virReportOOMError ( ) ;
goto cleanup ;
2007-06-22 17:16:10 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetSchedulerParameters ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_scheduler_parameters_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-22 17:16:10 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virSchedParameterPtr params = NULL ;
2011-04-13 21:50:40 +04:00
int i , nparams ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-22 17:16:10 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-22 17:16:10 +04:00
nparams = args - > params . params_len ;
if ( nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " nparams too large " ) ) ;
goto cleanup ;
2007-06-22 17:16:10 +04:00
}
2009-11-09 00:08:54 +03:00
if ( VIR_ALLOC_N ( params , nparams ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2007-06-22 17:16:10 +04:00
}
/* Deserialise parameters. */
for ( i = 0 ; i < nparams ; + + i ) {
2009-08-03 16:37:44 +04:00
if ( virStrcpyStatic ( params [ i ] . field , args - > params . params_val [ i ] . field ) = = NULL ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " Field %s too big for destination " ) ,
2009-08-03 16:37:44 +04:00
args - > params . params_val [ i ] . field ) ;
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-08-03 16:37:44 +04:00
}
2007-06-22 17:16:10 +04:00
params [ i ] . type = args - > params . params_val [ i ] . value . type ;
switch ( params [ i ] . type ) {
case VIR_DOMAIN_SCHED_FIELD_INT :
params [ i ] . value . i = args - > params . params_val [ i ] . value . remote_sched_param_value_u . i ; break ;
case VIR_DOMAIN_SCHED_FIELD_UINT :
params [ i ] . value . ui = args - > params . params_val [ i ] . value . remote_sched_param_value_u . ui ; break ;
case VIR_DOMAIN_SCHED_FIELD_LLONG :
params [ i ] . value . l = args - > params . params_val [ i ] . value . remote_sched_param_value_u . l ; break ;
case VIR_DOMAIN_SCHED_FIELD_ULLONG :
params [ i ] . value . ul = args - > params . params_val [ i ] . value . remote_sched_param_value_u . ul ; break ;
case VIR_DOMAIN_SCHED_FIELD_DOUBLE :
params [ i ] . value . d = args - > params . params_val [ i ] . value . remote_sched_param_value_u . d ; break ;
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN :
params [ i ] . value . b = args - > params . params_val [ i ] . value . remote_sched_param_value_u . b ; break ;
}
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
2011-04-13 21:50:40 +04:00
if ( virDomainSetSchedulerParameters ( dom , params , nparams ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-22 17:16:10 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
VIR_FREE ( params ) ;
return rv ;
2007-06-22 17:16:10 +04:00
}
2007-08-21 14:08:12 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainBlockStats ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_block_stats_args * args ,
remote_domain_block_stats_ret * ret )
2007-08-21 14:08:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2007-08-21 14:08:12 +04:00
char * path ;
struct _virDomainBlockStats stats ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-08-21 14:08:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 14:08:12 +04:00
path = args - > path ;
2011-04-13 21:23:00 +04:00
if ( virDomainBlockStats ( dom , path , & stats , sizeof stats ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 14:08:12 +04:00
ret - > rd_req = stats . rd_req ;
ret - > rd_bytes = stats . rd_bytes ;
ret - > wr_req = stats . wr_req ;
ret - > wr_bytes = stats . wr_bytes ;
ret - > errs = stats . errs ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-08-21 14:08:12 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainInterfaceStats ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_interface_stats_args * args ,
remote_domain_interface_stats_ret * ret )
2007-08-21 14:08:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2007-08-21 14:08:12 +04:00
char * path ;
struct _virDomainInterfaceStats stats ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-08-21 14:08:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 14:08:12 +04:00
path = args - > path ;
2011-04-13 21:23:00 +04:00
if ( virDomainInterfaceStats ( dom , path , & stats , sizeof stats ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 14:08:12 +04:00
ret - > rx_bytes = stats . rx_bytes ;
ret - > rx_packets = stats . rx_packets ;
ret - > rx_errs = stats . rx_errs ;
ret - > rx_drop = stats . rx_drop ;
ret - > tx_bytes = stats . tx_bytes ;
ret - > tx_packets = stats . tx_packets ;
ret - > tx_errs = stats . tx_errs ;
ret - > tx_drop = stats . tx_drop ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-08-21 14:08:12 +04:00
}
2009-12-20 15:43:19 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMemoryStats ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_memory_stats_args * args ,
remote_domain_memory_stats_ret * ret )
2009-12-20 15:43:19 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2009-12-20 15:43:19 +03:00
struct _virDomainMemoryStat * stats ;
2011-04-13 21:13:37 +04:00
int nr_stats , i ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2009-12-20 15:43:19 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-12-20 15:43:19 +03:00
if ( args - > maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " ,
_ ( " maxStats > REMOTE_DOMAIN_MEMORY_STATS_MAX " ) ) ;
goto cleanup ;
2009-12-20 15:43:19 +03:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-12-20 15:43:19 +03:00
/* Allocate stats array for making dispatch call */
if ( VIR_ALLOC_N ( stats , args - > maxStats ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2010-06-12 19:13:33 +04:00
}
2009-12-20 15:43:19 +03:00
2011-04-12 20:34:30 +04:00
nr_stats = virDomainMemoryStats ( dom , stats , args - > maxStats , 0 ) ;
2011-04-13 21:23:00 +04:00
if ( nr_stats < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-12-20 15:43:19 +03:00
/* Allocate return buffer */
if ( VIR_ALLOC_N ( ret - > stats . stats_val , args - > maxStats ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-12-20 15:43:19 +03: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 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
2009-12-20 15:43:19 +03:00
VIR_FREE ( stats ) ;
2011-04-13 19:21:35 +04:00
return rv ;
2009-12-20 15:43:19 +03:00
}
2008-06-06 01:12:26 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainBlockPeek ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_block_peek_args * args ,
remote_domain_block_peek_ret * ret )
2008-06-06 01:12:26 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2008-06-06 01:12:26 +04:00
char * path ;
unsigned long long offset ;
size_t size ;
unsigned int flags ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2008-06-06 01:12:26 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-06-06 01:12:26 +04:00
path = args - > path ;
offset = args - > offset ;
size = args - > size ;
flags = args - > flags ;
if ( size > REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " size > maximum buffer size " ) ) ;
goto cleanup ;
2008-06-06 01:12:26 +04:00
}
ret - > buffer . buffer_len = size ;
2011-04-12 20:34:30 +04:00
if ( VIR_ALLOC_N ( ret - > buffer . buffer_val , size ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 01:12:26 +04:00
}
2011-04-12 20:34:30 +04:00
if ( virDomainBlockPeek ( dom , path , offset , size ,
2011-04-13 21:23:00 +04:00
ret - > buffer . buffer_val , flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-06-06 01:12:26 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > buffer . buffer_val ) ;
}
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2008-06-06 01:12:26 +04:00
}
2008-06-10 14:43:28 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMemoryPeek ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_memory_peek_args * args ,
remote_domain_memory_peek_ret * ret )
2008-06-10 14:43:28 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2008-06-10 14:43:28 +04:00
unsigned long long offset ;
size_t size ;
unsigned int flags ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2008-06-10 14:43:28 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-06-10 14:43:28 +04:00
offset = args - > offset ;
size = args - > size ;
flags = args - > flags ;
if ( size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " size > maximum buffer size " ) ) ;
goto cleanup ;
2008-06-10 14:43:28 +04:00
}
ret - > buffer . buffer_len = size ;
2011-04-12 20:34:30 +04:00
if ( VIR_ALLOC_N ( ret - > buffer . buffer_val , size ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-10 14:43:28 +04:00
}
2011-04-12 20:34:30 +04:00
if ( virDomainMemoryPeek ( dom , offset , size ,
2011-04-13 21:23:00 +04:00
ret - > buffer . buffer_val , flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
if ( dom )
virDomainFree ( dom ) ;
2008-06-10 14:43:28 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > buffer . buffer_val ) ;
}
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2008-06-10 14:43:28 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainAttachDevice ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_attach_device_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainAttachDevice ( dom , args - > xml ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2010-01-14 04:42:28 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainAttachDeviceFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_attach_device_flags_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-01-14 04:42:28 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-01-14 04:42:28 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-01-14 04:42:28 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainAttachDeviceFlags ( dom , args - > xml , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-01-14 04:42:28 +03:00
}
2010-03-22 15:26:05 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainUpdateDeviceFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_update_device_flags_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-03-22 15:26:05 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-03-22 15:26:05 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-22 15:26:05 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainUpdateDeviceFlags ( dom , args - > xml , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-03-22 15:26:05 +03:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainCreate ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_create_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainCreate ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2010-06-10 18:53:28 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainCreateWithFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_create_with_flags_args * args ,
remote_domain_create_with_flags_ret * ret )
2010-06-10 18:53:28 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
virDomainPtr dom = NULL ;
2010-06-10 18:53:28 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-06-10 18:53:28 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainCreateWithFlags ( dom , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-06-10 18:53:28 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > dom , dom ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-06-10 18:53:28 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainCreateXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_create_xml_args * args ,
remote_domain_create_xml_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = virDomainCreateXML ( conn , args - > xml_desc , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > dom , dom ) ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainDefineXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_define_xml_args * args ,
remote_domain_define_xml_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = virDomainDefineXML ( conn , args - > xml ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > dom , dom ) ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainDestroy ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_destroy_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainDestroy ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainDetachDevice ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_detach_device_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainDetachDevice ( dom , args - > xml ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-01-14 04:42:28 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-01-14 04:42:28 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainDetachDeviceFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_detach_device_flags_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-01-14 04:42:28 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-01-14 04:42:28 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-01-14 04:42:28 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainDetachDeviceFlags ( dom , args - > xml , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainDumpXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_dump_xml_args * args ,
remote_domain_dump_xml_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virDomainGetXMLDesc ( dom , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2009-05-21 17:50:56 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainXmlFromNative ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_xml_from_native_args * args ,
remote_domain_xml_from_native_ret * ret )
2009-05-21 17:50:56 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-05-21 17:50:56 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > domainXml = virConnectDomainXMLFromNative ( conn ,
args - > nativeFormat ,
args - > nativeConfig ,
args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-05-21 17:50:56 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainXmlToNative ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_xml_to_native_args * args ,
remote_domain_xml_to_native_ret * ret )
2009-05-21 17:50:56 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-05-21 17:50:56 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > nativeConfig = virConnectDomainXMLToNative ( conn ,
args - > nativeFormat ,
args - > domainXml ,
args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-05-21 17:50:56 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetAutostart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_autostart_args * args ,
remote_domain_get_autostart_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainGetAutostart ( dom , & ret - > autostart ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetInfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_info_args * args ,
remote_domain_get_info_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2007-06-11 15:47:01 +04:00
virDomainInfo info ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainGetInfo ( dom , & info ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
ret - > state = info . state ;
ret - > max_mem = info . maxMem ;
ret - > memory = info . memory ;
ret - > nr_virt_cpu = info . nrVirtCpu ;
ret - > cpu_time = info . cpuTime ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2007-07-24 18:21:03 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetMaxMemory ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_max_memory_args * args ,
remote_domain_get_max_memory_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > memory = virDomainGetMaxMemory ( dom ) ) = = 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetMaxVcpus ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_max_vcpus_args * args ,
remote_domain_get_max_vcpus_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virDomainGetMaxVcpus ( dom ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2009-03-03 12:27:02 +03:00
static int
remoteDispatchDomainGetSecurityLabel ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
2009-09-30 14:29:20 +04:00
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2009-03-03 12:27:02 +03:00
remote_error * rerr ,
remote_domain_get_security_label_args * args ,
remote_domain_get_security_label_ret * ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virSecurityLabelPtr seclabel = NULL ;
int rv = - 1 ;
2009-03-03 12:27:02 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-03 12:27:02 +03:00
2011-04-03 13:21:25 +04:00
if ( VIR_ALLOC ( seclabel ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2011-04-03 13:21:25 +04:00
}
2011-04-13 21:23:00 +04:00
if ( virDomainGetSecurityLabel ( dom , seclabel ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-03 12:27:02 +03:00
2011-04-03 13:21:25 +04:00
ret - > label . label_len = strlen ( seclabel - > label ) + 1 ;
2009-03-03 12:27:02 +03:00
if ( VIR_ALLOC_N ( ret - > label . label_val , ret - > label . label_len ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-03-03 12:27:02 +03:00
}
2011-04-03 13:21:25 +04:00
strcpy ( ret - > label . label_val , seclabel - > label ) ;
ret - > enforcing = seclabel - > enforcing ;
2009-03-03 12:27:02 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
VIR_FREE ( seclabel ) ;
return rv ;
2009-03-03 12:27:02 +03:00
}
static int
remoteDispatchNodeGetSecurityModel ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
2009-09-30 14:29:20 +04:00
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2009-03-03 12:27:02 +03:00
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_node_get_security_model_ret * ret )
{
virSecurityModel secmodel ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2009-03-03 12:27:02 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-03-03 12:27:02 +03:00
memset ( & secmodel , 0 , sizeof secmodel ) ;
2011-04-13 21:23:00 +04:00
if ( virNodeGetSecurityModel ( conn , & secmodel ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-03 12:27:02 +03:00
ret - > model . model_len = strlen ( secmodel . model ) + 1 ;
if ( VIR_ALLOC_N ( ret - > model . model_val , ret - > model . model_len ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-03-03 12:27:02 +03:00
}
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 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-03-03 12:27:02 +03:00
}
strcpy ( ret - > doi . doi_val , secmodel . doi ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-03-03 12:27:02 +03:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetOsType ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_os_type_args * args ,
remote_domain_get_os_type_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
/* remoteDispatchClientRequest will free this */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > type = virDomainGetOSType ( dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetVcpus ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_vcpus_args * args ,
remote_domain_get_vcpus_ret * ret )
2007-06-11 15:47:01 +04:00
{
2008-06-06 14:52:01 +04:00
virDomainPtr dom = NULL ;
virVcpuInfoPtr info = NULL ;
unsigned char * cpumaps = NULL ;
2007-06-11 15:47:01 +04:00
int info_len , i ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
if ( args - > maxinfo > REMOTE_VCPUINFO_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " maxinfo > REMOTE_VCPUINFO_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
2007-06-25 12:23:10 +04:00
if ( args - > maxinfo * args - > maplen > REMOTE_CPUMAPS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " maxinfo * maplen > REMOTE_CPUMAPS_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
/* Allocate buffers to take the results. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( info , args - > maxinfo ) < 0 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2009-03-16 13:33:01 +03:00
if ( args - > maplen > 0 & &
VIR_ALLOC_N ( cpumaps , args - > maxinfo * args - > maplen ) < 0 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:50:40 +04:00
if ( ( info_len = virDomainGetVcpus ( dom ,
info , args - > maxinfo ,
cpumaps , args - > maplen ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
/* Allocate the return buffer for info. */
ret - > info . info_len = info_len ;
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > info . info_val , info_len ) < 0 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2007-06-11 15:47:01 +04:00
for ( i = 0 ; i < info_len ; + + i ) {
ret - > info . info_val [ i ] . number = info [ i ] . number ;
ret - > info . info_val [ i ] . state = info [ i ] . state ;
ret - > info . info_val [ i ] . cpu_time = info [ i ] . cpuTime ;
ret - > info . info_val [ i ] . cpu = info [ i ] . cpu ;
}
/* Don't need to allocate/copy the cpumaps if we make the reasonable
* assumption that unsigned char and char are the same size .
* Note that remoteDispatchClientRequest will free .
*/
2007-06-25 12:23:10 +04:00
ret - > cpumaps . cpumaps_len = args - > maxinfo * args - > maplen ;
2007-06-11 15:47:01 +04:00
ret - > cpumaps . cpumaps_val = ( char * ) cpumaps ;
2011-04-13 19:21:35 +04:00
cpumaps = NULL ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2008-06-06 14:52:01 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > info . info_val ) ;
}
2008-06-06 14:52:01 +04:00
VIR_FREE ( cpumaps ) ;
2011-04-13 19:21:35 +04:00
VIR_FREE ( info ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
no_memory :
virReportOOMError ( ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
2010-09-27 20:10:06 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetVcpusFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_vcpus_flags_args * args ,
remote_domain_get_vcpus_flags_ret * ret )
2010-09-27 20:10:06 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-09-27 20:10:06 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-09-27 20:10:06 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virDomainGetVcpusFlags ( dom , args - > flags ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-09-27 20:10:06 +04:00
}
2007-08-21 13:31:12 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMigratePrepare ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_prepare_args * args ,
remote_domain_migrate_prepare_ret * ret )
2007-08-21 13:31:12 +04:00
{
char * cookie = NULL ;
int cookielen = 0 ;
char * uri_in ;
char * * uri_out ;
char * dname ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-08-21 13:31:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-08-21 13:31:12 +04:00
uri_in = args - > uri_in = = NULL ? NULL : * args - > uri_in ;
dname = args - > dname = = NULL ? NULL : * args - > dname ;
/* Wacky world of XDR ... */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC ( uri_out ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2007-08-21 13:31:12 +04:00
2011-04-13 21:50:40 +04:00
if ( virDomainMigratePrepare ( conn , & cookie , & cookielen ,
2011-04-12 20:34:30 +04:00
uri_in , uri_out ,
2011-04-13 21:50:40 +04:00
args - > flags , dname , args - > resource ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 13:31:12 +04:00
/* remoteDispatchClientRequest will free cookie, uri_out and
* the string if there is one .
*/
ret - > cookie . cookie_len = cookielen ;
ret - > cookie . cookie_val = cookie ;
2008-05-22 19:12:25 +04:00
if ( * uri_out = = NULL ) {
ret - > uri_out = NULL ;
} else {
ret - > uri_out = uri_out ;
2011-04-13 19:21:35 +04:00
uri_out = NULL ;
2008-05-22 19:12:25 +04:00
}
2007-08-21 13:31:12 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
VIR_FREE ( uri_out ) ;
return rv ;
2007-08-21 13:31:12 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMigratePerform ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_perform_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-08-21 13:31:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2010-10-26 19:19:13 +04:00
char * dname ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-08-21 13:31:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 13:31:12 +04:00
dname = args - > dname = = NULL ? NULL : * args - > dname ;
2011-04-13 21:50:40 +04:00
if ( virDomainMigratePerform ( dom ,
2011-04-12 20:34:30 +04:00
args - > cookie . cookie_val ,
args - > cookie . cookie_len ,
args - > uri ,
2011-04-13 21:50:40 +04:00
args - > flags , dname , args - > resource ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 13:31:12 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-08-21 13:31:12 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMigrateFinish ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_finish_args * args ,
remote_domain_migrate_finish_ret * ret )
2007-08-21 13:31:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr ddom = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-08-21 13:31:12 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( ddom = virDomainMigrateFinish ( conn , args - > dname ,
args - > cookie . cookie_val ,
args - > cookie . cookie_len ,
args - > uri ,
args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-08-21 13:31:12 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > ddom , ddom ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( ddom )
virDomainFree ( ddom ) ;
return rv ;
2007-08-21 13:31:12 +04:00
}
2008-11-14 11:42:47 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMigratePrepare2 ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_prepare2_args * args ,
remote_domain_migrate_prepare2_ret * ret )
2008-11-14 11:42:47 +03:00
{
char * cookie = NULL ;
int cookielen = 0 ;
char * uri_in ;
char * * uri_out ;
char * dname ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-14 11:42:47 +03: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 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-11-14 11:42:47 +03:00
}
2011-04-13 21:50:40 +04:00
if ( virDomainMigratePrepare2 ( conn , & cookie , & cookielen ,
2011-04-12 20:34:30 +04:00
uri_in , uri_out ,
args - > flags , dname , args - > resource ,
2011-04-13 21:50:40 +04:00
args - > dom_xml ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-14 11:42:47 +03: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 ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-11-14 11:42:47 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainMigrateFinish2 ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_finish2_args * args ,
remote_domain_migrate_finish2_ret * ret )
2008-11-14 11:42:47 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr ddom = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-14 11:42:47 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( ddom = virDomainMigrateFinish2 ( conn , args - > dname ,
args - > cookie . cookie_val ,
args - > cookie . cookie_len ,
args - > uri ,
args - > flags ,
args - > retcode ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-14 11:42:47 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > ddom , ddom ) ;
2008-11-14 11:42:47 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( ddom )
virDomainFree ( ddom ) ;
return rv ;
2008-11-14 11:42:47 +03:00
}
2009-09-30 14:51:54 +04:00
static int
remoteDispatchDomainMigratePrepareTunnel ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ,
virConnectPtr conn ,
remote_message_header * hdr ,
remote_error * rerr ,
remote_domain_migrate_prepare_tunnel_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
char * dname ;
2011-04-13 19:21:35 +04:00
struct qemud_client_stream * stream = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-09-30 14:51:54 +04:00
dname = args - > dname = = NULL ? NULL : * args - > dname ;
2011-04-13 21:50:40 +04:00
if ( ! ( stream = remoteCreateClientStream ( conn , hdr ) ) ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-09-30 14:51:54 +04:00
}
2011-04-13 21:50:40 +04:00
if ( virDomainMigratePrepareTunnel ( conn , stream - > st ,
2009-09-30 14:51:54 +04:00
args - > flags , dname , args - > resource ,
2011-04-13 21:50:40 +04:00
args - > dom_xml ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-09-30 14:51:54 +04:00
2011-04-13 21:23:00 +04:00
if ( remoteAddClientStream ( client , stream , 0 ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-09-30 14:51:54 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
if ( stream ) {
virStreamAbort ( stream - > st ) ;
remoteFreeClientStream ( client , stream ) ;
}
}
return rv ;
2009-09-30 14:51:54 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListDefinedDomains ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_defined_domains_args * args ,
remote_list_defined_domains_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
if ( args - > maxnames > REMOTE_DOMAIN_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_DOMAIN_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:13:37 +04:00
len = virConnectListDefinedDomains ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainLookupById ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_lookup_by_id_args * args ,
remote_domain_lookup_by_id_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = virDomainLookupByID ( conn , args - > id ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > dom , dom ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_lookup_by_name_args * args ,
remote_domain_lookup_by_name_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = virDomainLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > dom , dom ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainLookupByUuid ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_lookup_by_uuid_args * args ,
remote_domain_lookup_by_uuid_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = virDomainLookupByUUID ( conn , ( unsigned char * ) args - > uuid ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( & ret - > dom , dom ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfDefinedDomains ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_defined_domains_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfDefinedDomains ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainPinVcpu ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_pin_vcpu_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
if ( args - > cpumap . cpumap_len > REMOTE_CPUMAP_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " cpumap_len > REMOTE_CPUMAP_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
2011-04-13 21:50:40 +04:00
if ( virDomainPinVcpu ( dom , args - > vcpu ,
( unsigned char * ) args - > cpumap . cpumap_val ,
args - > cpumap . cpumap_len ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainReboot ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_reboot_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainReboot ( dom , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainRestore ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_restore_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-10-12 15:22:03 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainRestore ( conn , args - > from ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainResume ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_resume_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainResume ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSave ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_save_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSave ( dom , args - > to ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainCoreDump ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_core_dump_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainCoreDump ( dom , args - > to , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetAutostart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_autostart_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSetAutostart ( dom , args - > autostart ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetMaxMemory ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_max_memory_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSetMaxMemory ( dom , args - > memory ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetMemory ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_memory_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSetMemory ( dom , args - > memory ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2011-03-02 11:13:24 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetMemoryFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_memory_flags_args * args ,
void * ret ATTRIBUTE_UNUSED )
2011-03-02 11:13:24 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2011-03-02 11:13:24 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-03-02 11:13:24 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainSetMemoryFlags ( dom , args - > memory , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2011-03-02 11:13:24 +03:00
}
2010-10-12 21:23:04 +04:00
static int
remoteDispatchDomainSetMemoryParameters ( struct qemud_server * server
ATTRIBUTE_UNUSED ,
struct qemud_client * client
ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header *
hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_memory_parameters_args
* args , void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virMemoryParameterPtr params = NULL ;
2011-04-13 21:50:40 +04:00
int i , nparams ;
2010-10-12 21:23:04 +04:00
unsigned int flags ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-10-12 21:23:04 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-10-12 21:23:04 +04:00
nparams = args - > params . params_len ;
flags = args - > flags ;
if ( nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " nparams too large " ) ) ;
goto cleanup ;
2010-10-12 21:23:04 +04:00
}
if ( VIR_ALLOC_N ( params , nparams ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2010-10-12 21:23:04 +04:00
}
/* Deserialise parameters. */
for ( i = 0 ; i < nparams ; + + i ) {
if ( virStrcpyStatic
( params [ i ] . field , args - > params . params_val [ i ] . field ) = = NULL ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
_ ( " Field %s too big for destination " ) ,
args - > params . params_val [ i ] . field ) ;
goto cleanup ;
2010-10-12 21:23:04 +04:00
}
params [ i ] . type = args - > params . params_val [ i ] . value . type ;
switch ( params [ i ] . type ) {
case VIR_DOMAIN_MEMORY_PARAM_INT :
params [ i ] . value . i =
args - > params . params_val [ i ] . value .
remote_memory_param_value_u . i ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_UINT :
params [ i ] . value . ui =
args - > params . params_val [ i ] . value .
remote_memory_param_value_u . ui ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_LLONG :
params [ i ] . value . l =
args - > params . params_val [ i ] . value .
remote_memory_param_value_u . l ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_ULLONG :
params [ i ] . value . ul =
args - > params . params_val [ i ] . value .
remote_memory_param_value_u . ul ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE :
params [ i ] . value . d =
args - > params . params_val [ i ] . value .
remote_memory_param_value_u . d ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN :
params [ i ] . value . b =
args - > params . params_val [ i ] . value .
remote_memory_param_value_u . b ;
break ;
}
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-10-12 21:23:04 +04:00
2011-04-13 21:50:40 +04:00
if ( virDomainSetMemoryParameters ( dom , params , nparams , flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-10-12 21:23:04 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
VIR_FREE ( params ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-10-12 21:23:04 +04:00
}
static int
remoteDispatchDomainGetMemoryParameters ( struct qemud_server * server
ATTRIBUTE_UNUSED ,
struct qemud_client * client
ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header *
hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_memory_parameters_args
* args ,
remote_domain_get_memory_parameters_ret
* ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virMemoryParameterPtr params = NULL ;
2011-04-13 21:50:40 +04:00
int i , nparams ;
2010-10-12 21:23:04 +04:00
unsigned int flags ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-10-12 21:23:04 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-10-12 21:23:04 +04:00
nparams = args - > nparams ;
flags = args - > flags ;
if ( nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " nparams too large " ) ) ;
goto cleanup ;
2010-10-12 21:23:04 +04:00
}
if ( VIR_ALLOC_N ( params , nparams ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2010-10-12 21:23:04 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-10-12 21:23:04 +04:00
2011-04-13 21:50:40 +04:00
if ( virDomainGetMemoryParameters ( dom , params , & nparams , flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
2010-10-12 21:23:04 +04:00
/* 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 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2010-10-12 21:23:04 +04:00
for ( i = 0 ; i < nparams ; + + i ) {
2011-01-29 00:38:06 +03:00
/* remoteDispatchClientRequest will free this: */
2010-10-12 21:23:04 +04:00
ret - > params . params_val [ i ] . field = strdup ( params [ i ] . field ) ;
if ( ret - > params . params_val [ i ] . field = = NULL )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2010-10-12 21:23:04 +04:00
ret - > params . params_val [ i ] . value . type = params [ i ] . type ;
switch ( params [ i ] . type ) {
case VIR_DOMAIN_MEMORY_PARAM_INT :
ret - > params . params_val [ i ] .
value . remote_memory_param_value_u . i =
params [ i ] . value . i ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_UINT :
ret - > params . params_val [ i ] .
value . remote_memory_param_value_u . ui =
params [ i ] . value . ui ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_LLONG :
ret - > params . params_val [ i ] .
value . remote_memory_param_value_u . l =
params [ i ] . value . l ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_ULLONG :
ret - > params . params_val [ i ] .
value . remote_memory_param_value_u . ul =
params [ i ] . value . ul ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE :
ret - > params . params_val [ i ] .
value . remote_memory_param_value_u . d =
params [ i ] . value . d ;
break ;
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN :
ret - > params . params_val [ i ] .
value . remote_memory_param_value_u . b =
params [ i ] . value . b ;
2011-02-22 08:34:28 +03:00
break ;
default :
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " unknown type " ) ) ;
2011-02-22 08:34:28 +03:00
goto cleanup ;
}
}
2011-04-13 19:21:35 +04:00
success :
rv = 0 ;
2011-02-22 08:34:28 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
for ( i = 0 ; i < nparams ; i + + )
VIR_FREE ( ret - > params . params_val [ i ] . field ) ;
VIR_FREE ( ret - > params . params_val ) ;
}
if ( dom )
virDomainFree ( dom ) ;
2011-02-22 08:34:28 +03:00
VIR_FREE ( params ) ;
2011-04-13 19:21:35 +04:00
return rv ;
no_memory :
virReportOOMError ( ) ;
goto cleanup ;
2011-02-22 08:34:28 +03:00
}
static int
remoteDispatchDomainSetBlkioParameters ( struct qemud_server * server
ATTRIBUTE_UNUSED ,
struct qemud_client * client
ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header *
hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_blkio_parameters_args
* args , void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virBlkioParameterPtr params = NULL ;
2011-04-13 21:50:40 +04:00
int i , nparams ;
2011-02-22 08:34:28 +03:00
unsigned int flags ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-02-22 08:34:28 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-02-22 08:34:28 +03:00
nparams = args - > params . params_len ;
flags = args - > flags ;
if ( nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " nparams too large " ) ) ;
goto cleanup ;
2011-02-22 08:34:28 +03:00
}
if ( VIR_ALLOC_N ( params , nparams ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2011-02-22 08:34:28 +03:00
}
/* Deserialise parameters. */
for ( i = 0 ; i < nparams ; + + i ) {
if ( virStrcpyStatic
( params [ i ] . field , args - > params . params_val [ i ] . field ) = = NULL ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
_ ( " Field %s too big for destination " ) ,
args - > params . params_val [ i ] . field ) ;
goto cleanup ;
2011-02-22 08:34:28 +03:00
}
params [ i ] . type = args - > params . params_val [ i ] . value . type ;
switch ( params [ i ] . type ) {
case VIR_DOMAIN_BLKIO_PARAM_INT :
params [ i ] . value . i =
args - > params . params_val [ i ] . value .
remote_blkio_param_value_u . i ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_UINT :
params [ i ] . value . ui =
args - > params . params_val [ i ] . value .
remote_blkio_param_value_u . ui ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_LLONG :
params [ i ] . value . l =
args - > params . params_val [ i ] . value .
remote_blkio_param_value_u . l ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_ULLONG :
params [ i ] . value . ul =
args - > params . params_val [ i ] . value .
remote_blkio_param_value_u . ul ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE :
params [ i ] . value . d =
args - > params . params_val [ i ] . value .
remote_blkio_param_value_u . d ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN :
params [ i ] . value . b =
args - > params . params_val [ i ] . value .
remote_blkio_param_value_u . b ;
break ;
}
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-02-22 08:34:28 +03:00
2011-04-13 21:50:40 +04:00
if ( virDomainSetBlkioParameters ( dom , params , nparams , flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-02-22 08:34:28 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
VIR_FREE ( params ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2011-02-22 08:34:28 +03:00
}
static int
remoteDispatchDomainGetBlkioParameters ( struct qemud_server * server
ATTRIBUTE_UNUSED ,
struct qemud_client * client
ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header *
hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_blkio_parameters_args
* args ,
remote_domain_get_blkio_parameters_ret
* ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
virBlkioParameterPtr params = NULL ;
2011-04-13 21:50:40 +04:00
int i , nparams ;
2011-02-22 08:34:28 +03:00
unsigned int flags ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-02-22 08:34:28 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-02-22 08:34:28 +03:00
nparams = args - > nparams ;
flags = args - > flags ;
if ( nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " nparams too large " ) ) ;
goto cleanup ;
2011-02-22 08:34:28 +03:00
}
if ( VIR_ALLOC_N ( params , nparams ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2011-02-22 08:34:28 +03:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-02-22 08:34:28 +03:00
2011-04-13 21:50:40 +04:00
if ( virDomainGetBlkioParameters ( dom , params , & nparams , flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
2011-02-22 08:34:28 +03:00
/* In this case, we need to send back the number of parameters
* supported
*/
if ( args - > nparams = = 0 ) {
ret - > nparams = nparams ;
goto success ;
}
/* Serialise the blkio parameters. */
ret - > params . params_len = nparams ;
if ( VIR_ALLOC_N ( ret - > params . params_val , nparams ) < 0 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2011-02-22 08:34:28 +03:00
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 )
2011-04-13 19:21:35 +04:00
goto no_memory ;
2011-02-22 08:34:28 +03:00
ret - > params . params_val [ i ] . value . type = params [ i ] . type ;
switch ( params [ i ] . type ) {
case VIR_DOMAIN_BLKIO_PARAM_INT :
ret - > params . params_val [ i ] .
value . remote_blkio_param_value_u . i =
params [ i ] . value . i ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_UINT :
ret - > params . params_val [ i ] .
value . remote_blkio_param_value_u . ui =
params [ i ] . value . ui ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_LLONG :
ret - > params . params_val [ i ] .
value . remote_blkio_param_value_u . l =
params [ i ] . value . l ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_ULLONG :
ret - > params . params_val [ i ] .
value . remote_blkio_param_value_u . ul =
params [ i ] . value . ul ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE :
ret - > params . params_val [ i ] .
value . remote_blkio_param_value_u . d =
params [ i ] . value . d ;
break ;
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN :
ret - > params . params_val [ i ] .
value . remote_blkio_param_value_u . b =
params [ i ] . value . b ;
2010-10-12 21:23:04 +04:00
break ;
default :
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " unknown type " ) ) ;
2010-10-12 21:23:04 +04:00
goto cleanup ;
}
}
2011-04-13 19:21:35 +04:00
success :
rv = 0 ;
2010-10-12 21:23:04 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
for ( i = 0 ; i < nparams ; i + + )
VIR_FREE ( ret - > params . params_val [ i ] . field ) ;
VIR_FREE ( ret - > params . params_val ) ;
}
2010-10-12 21:23:04 +04:00
VIR_FREE ( params ) ;
2011-04-13 19:21:35 +04:00
if ( dom )
virDomainFree ( dom ) ;
return rv ;
no_memory :
virReportOOMError ( ) ;
goto cleanup ;
2010-10-12 21:23:04 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetVcpus ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_vcpus_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSetVcpus ( dom , args - > nvcpus ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2010-09-27 20:10:06 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSetVcpusFlags ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_set_vcpus_flags_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-09-27 20:10:06 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-09-27 20:10:06 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-09-27 20:10:06 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSetVcpusFlags ( dom , args - > nvcpus , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-09-27 20:10:06 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainShutdown ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_shutdown_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainShutdown ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSuspend ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_suspend_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainSuspend ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainUndefine ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_undefine_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainUndefine ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListDefinedNetworks ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_defined_networks_args * args ,
remote_list_defined_networks_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
if ( args - > maxnames > REMOTE_NETWORK_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_NETWORK_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:13:37 +04:00
len = virConnectListDefinedNetworks ( conn ,
2011-04-12 20:34:30 +04:00
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListDomains ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_domains_args * args ,
remote_list_domains_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
if ( args - > maxids > REMOTE_DOMAIN_ID_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxids > REMOTE_DOMAIN_ID_LIST_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > ids . ids_val , args - > maxids ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:13:37 +04:00
len = virConnectListDomains ( conn ,
ret - > ids . ids_val , args - > maxids ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > ids . ids_len = len ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > ids . ids_val ) ;
}
return rv ;
2007-06-11 15:47:01 +04:00
}
2010-04-01 12:54:12 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainManagedSave ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_managed_save_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-04-01 12:54:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-04-01 12:54:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 12:54:12 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainManagedSave ( dom , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-04-01 12:54:12 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainHasManagedSaveImage ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_has_managed_save_image_args * args ,
remote_domain_has_managed_save_image_ret * ret )
2010-04-01 12:54:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-04-01 12:54:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 12:54:12 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > ret = virDomainHasManagedSaveImage ( dom , args - > flags ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-04-01 12:54:12 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainManagedSaveRemove ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_managed_save_remove_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-04-01 12:54:12 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-04-01 12:54:12 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 12:54:12 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainManagedSaveRemove ( dom , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-04-01 12:54:12 +04:00
}
2007-06-11 15:47:01 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListNetworks ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_networks_args * args ,
remote_list_networks_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
if ( args - > maxnames > REMOTE_NETWORK_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_NETWORK_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2007-06-11 15:47:01 +04:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:13:37 +04:00
len = virConnectListNetworks ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_len ) ;
}
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkCreate ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_create_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virNetworkCreate ( net ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkCreateXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_create_xml_args * args ,
remote_network_create_xml_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = virNetworkCreateXML ( conn , args - > xml ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_network ( & ret - > net , net ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkDefineXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_define_xml_args * args ,
remote_network_define_xml_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = virNetworkDefineXML ( conn , args - > xml ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_network ( & ret - > net , net ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkDestroy ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_destroy_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virNetworkDestroy ( net ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkDumpXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_dump_xml_args * args ,
remote_network_dump_xml_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virNetworkGetXMLDesc ( net , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkGetAutostart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_get_autostart_args * args ,
remote_network_get_autostart_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virNetworkGetAutostart ( net , & ret - > autostart ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkGetBridgeName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_get_bridge_name_args * args ,
remote_network_get_bridge_name_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > name = virNetworkGetBridgeName ( net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_lookup_by_name_args * args ,
remote_network_lookup_by_name_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = virNetworkLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_network ( & ret - > net , net ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkLookupByUuid ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_lookup_by_uuid_args * args ,
remote_network_lookup_by_uuid_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = virNetworkLookupByUUID ( conn , ( unsigned char * ) args - > uuid ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_network ( & ret - > net , net ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkSetAutostart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_set_autostart_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virNetworkSetAutostart ( net , args - > autostart ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNetworkUndefine ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_network_undefine_args * args ,
void * ret ATTRIBUTE_UNUSED )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
virNetworkPtr net = NULL ;
int rv = - 1 ;
2007-06-11 15:47:01 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( net = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 21:23:00 +04:00
if ( virNetworkUndefine ( net ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( net )
virNetworkFree ( net ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfDefinedNetworks ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_defined_networks_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:13:37 +04:00
len = virConnectNumOfDefinedNetworks ( conn ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > num = len ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfDomains ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_domains_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfDomains ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfNetworks ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_networks_ret * ret )
2007-06-11 15:47:01 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2007-06-11 15:47:01 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfNetworks ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2007-06-11 15:47:01 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-06-11 15:47:01 +04:00
}
2007-12-05 18:24:15 +03:00
2009-05-20 18:26:49 +04:00
/*-------------------------------------------------------------*/
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfInterfaces ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_interfaces_ret * ret )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-05-20 18:26:49 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfInterfaces ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListInterfaces ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_interfaces_args * args ,
remote_list_interfaces_ret * ret )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-05-20 18:26:49 +04:00
if ( args - > maxnames > REMOTE_INTERFACE_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_INTERFACE_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2009-05-20 18:26:49 +04:00
}
/* Allocate return buffer. */
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-05-20 18:26:49 +04:00
}
2011-04-13 21:13:37 +04:00
len = virConnectListInterfaces ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2009-05-20 18:26:49 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_len ) ;
}
return rv ;
2009-05-20 18:26:49 +04:00
}
2009-07-16 19:58:15 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfDefinedInterfaces ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_defined_interfaces_ret * ret )
2009-07-16 19:58:15 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-07-16 19:58:15 +04:00
2011-04-13 21:13:37 +04:00
len = virConnectNumOfDefinedInterfaces ( conn ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > num = len ;
2009-07-16 19:58:15 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-07-16 19:58:15 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListDefinedInterfaces ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_defined_interfaces_args * args ,
remote_list_defined_interfaces_ret * ret )
2009-07-16 19:58:15 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-07-16 19:58:15 +04:00
if ( args - > maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2009-07-16 19:58:15 +04:00
}
/* Allocate return buffer. */
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-07-16 19:58:15 +04:00
}
2011-04-13 21:13:37 +04:00
len = virConnectListDefinedInterfaces ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2009-07-16 19:58:15 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_len ) ;
}
return rv ;
2009-07-16 19:58:15 +04:00
}
2009-05-20 18:26:49 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchInterfaceLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_lookup_by_name_args * args ,
remote_interface_lookup_by_name_ret * ret )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = virInterfaceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_interface ( & ret - > iface , iface ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchInterfaceLookupByMacString ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_lookup_by_mac_string_args * args ,
remote_interface_lookup_by_mac_string_ret * ret )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = virInterfaceLookupByMACString ( conn , args - > mac ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_interface ( & ret - > iface , iface ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
2011-04-12 20:34:30 +04:00
static int
remoteDispatchInterfaceGetXmlDesc ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_get_xml_desc_args * args ,
remote_interface_get_xml_desc_ret * ret )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = get_nonnull_interface ( conn , args - > iface ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virInterfaceGetXMLDesc ( iface , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchInterfaceDefineXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_define_xml_args * args ,
remote_interface_define_xml_ret * ret )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = virInterfaceDefineXML ( conn , args - > xml , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_interface ( & ret - > iface , iface ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchInterfaceUndefine ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_undefine_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = get_nonnull_interface ( conn , args - > iface ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-13 21:23:00 +04:00
if ( virInterfaceUndefine ( iface ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchInterfaceCreate ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_create_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = get_nonnull_interface ( conn , args - > iface ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-13 21:23:00 +04:00
if ( virInterfaceCreate ( iface , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchInterfaceDestroy ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_interface_destroy_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-05-20 18:26:49 +04:00
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
2009-05-20 18:26:49 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = get_nonnull_interface ( conn , args - > iface ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-20 18:26:49 +04:00
2011-04-13 21:23:00 +04:00
if ( virInterfaceDestroy ( iface , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
return rv ;
2009-05-20 18:26:49 +04:00
}
/*-------------------------------------------------------------*/
2007-12-05 18:24:15 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthList ( struct qemud_server * server ,
struct qemud_client * client ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_auth_list_ret * ret )
2007-12-05 18:24:15 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2007-12-05 18:24:15 +03:00
ret - > types . types_len = 1 ;
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > types . types_val , ret - > types . types_len ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2007-12-05 18:24:15 +03:00
}
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2007-12-05 18:24:15 +03:00
ret - > types . types_val [ 0 ] = client - > auth ;
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2008-12-05 01:16:40 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2007-12-05 18:24:15 +03:00
}
# if HAVE_SASL
/*
* Initializes the SASL session in prepare for authentication
2008-05-15 10:12:32 +04:00
* and gives the client a list of allowed mechanisms to choose
2007-12-05 18:24:15 +03:00
*
* XXX callbacks for stuff like password verification ?
*/
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthSaslInit ( struct qemud_server * server ,
struct qemud_client * client ,
2011-04-13 19:21:35 +04:00
virConnectPtr conn ATTRIBUTE_UNUSED ,
2011-04-12 20:34:30 +04:00
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_auth_sasl_init_ret * ret )
2007-12-05 18:24:15 +03:00
{
const char * mechlist = NULL ;
2007-12-05 18:27:08 +03:00
sasl_security_properties_t secprops ;
2007-12-05 18:24:15 +03:00
int err ;
2010-10-20 20:29:56 +04:00
virSocketAddr sa ;
2007-12-05 18:24:15 +03:00
char * localAddr , * remoteAddr ;
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2008-12-05 01:16:40 +03:00
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Initialize SASL auth %d " , client - > fd ) ;
2007-12-05 18:24:15 +03:00
if ( client - > auth ! = REMOTE_AUTH_SASL | |
client - > saslconn ! = NULL ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried invalid SASL init request " ) ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
/* Get local address in form IPADDR:PORT */
2010-10-20 20:29:56 +04:00
sa . len = sizeof ( sa . data . stor ) ;
if ( getsockname ( client - > fd , & sa . data . sa , & sa . len ) < 0 ) {
2009-02-05 19:28:30 +03:00
char ebuf [ 1024 ] ;
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
_ ( " failed to get sock address: %s " ) ,
virStrerror ( errno , ebuf , sizeof ebuf ) ) ;
2008-12-05 01:16:40 +03:00
goto error ;
2007-12-05 18:24:15 +03:00
}
2011-04-13 19:21:35 +04:00
if ( ( localAddr = virSocketFormatAddrFull ( & sa , true , " ; " ) ) = = NULL )
2008-12-05 01:16:40 +03:00
goto error ;
2007-12-05 18:24:15 +03:00
/* Get remote address in form IPADDR:PORT */
2010-10-20 20:29:56 +04:00
sa . len = sizeof ( sa . data . stor ) ;
if ( getpeername ( client - > fd , & sa . data . sa , & sa . len ) < 0 ) {
2009-02-05 19:28:30 +03:00
char ebuf [ 1024 ] ;
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " failed to get peer address: %s " ) ,
virStrerror ( errno , ebuf , sizeof ebuf ) ) ;
2008-06-06 14:52:01 +04:00
VIR_FREE ( localAddr ) ;
2008-12-05 01:16:40 +03:00
goto error ;
2007-12-05 18:24:15 +03:00
}
2010-10-21 18:45:12 +04:00
if ( ( remoteAddr = virSocketFormatAddrFull ( & sa , true , " ; " ) ) = = NULL ) {
2008-06-06 14:52:01 +04:00
VIR_FREE ( localAddr ) ;
2008-12-05 01:16:40 +03:00
goto error ;
2007-12-05 18:24:15 +03:00
}
err = sasl_server_new ( " libvirt " ,
NULL , /* FQDN - just delegates to gethostname */
NULL , /* User realm */
localAddr ,
remoteAddr ,
NULL , /* XXX Callbacks */
SASL_SUCCESS_DATA ,
& client - > saslconn ) ;
2008-06-06 14:52:01 +04:00
VIR_FREE ( localAddr ) ;
VIR_FREE ( remoteAddr ) ;
2007-12-05 18:24:15 +03:00
if ( err ! = SASL_OK ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " sasl context setup failed %d (%s) " ) ,
err , sasl_errstring ( err , NULL , NULL ) ) ;
2007-12-05 18:24:15 +03:00
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
2007-12-05 18:27:08 +03:00
/* Inform SASL that we've got an external SSF layer from TLS */
if ( client - > type = = QEMUD_SOCK_TYPE_TLS ) {
gnutls_cipher_algorithm_t cipher ;
sasl_ssf_t ssf ;
cipher = gnutls_cipher_get ( client - > tlssession ) ;
if ( ! ( ssf = ( sasl_ssf_t ) gnutls_cipher_get_key_size ( cipher ) ) ) {
2009-06-11 19:34:37 +04:00
VIR_ERROR0 ( _ ( " cannot get TLS cipher size " ) ) ;
2007-12-05 18:27:08 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:27:08 +03:00
}
ssf * = 8 ; /* tls key size is bytes, sasl wants bits */
err = sasl_setprop ( client - > saslconn , SASL_SSF_EXTERNAL , & ssf ) ;
if ( err ! = SASL_OK ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " cannot set SASL external SSF %d (%s) " ) ,
err , sasl_errstring ( err , NULL , NULL ) ) ;
2007-12-05 18:27:08 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:27:08 +03:00
}
}
2011-04-12 20:34:30 +04:00
memset ( & secprops , 0 , sizeof secprops ) ;
2007-12-05 18:27:08 +03:00
if ( client - > type = = QEMUD_SOCK_TYPE_TLS | |
client - > type = = QEMUD_SOCK_TYPE_UNIX ) {
/* If we've got TLS or UNIX domain sock, we don't care about SSF */
secprops . min_ssf = 0 ;
secprops . max_ssf = 0 ;
secprops . maxbufsize = 8192 ;
secprops . security_flags = 0 ;
} else {
/* Plain TCP, better get an SSF layer */
secprops . min_ssf = 56 ; /* Good enough to require kerberos */
secprops . max_ssf = 100000 ; /* Arbitrary big number */
secprops . maxbufsize = 8192 ;
/* Forbid any anonymous or trivially crackable auth */
secprops . security_flags =
SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT ;
}
err = sasl_setprop ( client - > saslconn , SASL_SEC_PROPS , & secprops ) ;
if ( err ! = SASL_OK ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " cannot set SASL security props %d (%s) " ) ,
err , sasl_errstring ( err , NULL , NULL ) ) ;
2007-12-05 18:27:08 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:27:08 +03:00
}
2007-12-05 18:24:15 +03:00
err = sasl_listmech ( client - > saslconn ,
NULL , /* Don't need to set user */
" " , /* Prefix */
" , " , /* Separator */
" " , /* Suffix */
& mechlist ,
NULL ,
NULL ) ;
if ( err ! = SASL_OK ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " cannot list SASL mechanisms %d (%s) " ) ,
err , sasl_errdetail ( client - > saslconn ) ) ;
2007-12-05 18:24:15 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Available mechanisms for client: '%s' " , mechlist ) ;
2007-12-05 18:24:15 +03:00
ret - > mechlist = strdup ( mechlist ) ;
if ( ! ret - > mechlist ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " cannot allocate mechlist " ) ) ;
2007-12-05 18:24:15 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2007-12-05 18:24:15 +03:00
return 0 ;
2008-12-05 01:16:40 +03:00
authfail :
remoteDispatchAuthError ( rerr ) ;
error :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_SASL ) ;
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2008-12-05 01:16:40 +03:00
return - 1 ;
2007-12-05 18:24:15 +03:00
}
2008-02-29 15:53:10 +03:00
/* We asked for an SSF layer, so sanity check that we actually
2010-09-14 20:50:25 +04:00
* got what we asked for
* Returns 0 if ok , - 1 on error , - 2 if rejected
*/
2007-12-05 18:27:08 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteSASLCheckSSF ( struct qemud_client * client ,
remote_error * rerr ) {
2007-12-05 18:27:08 +03:00
const void * val ;
int err , ssf ;
if ( client - > type = = QEMUD_SOCK_TYPE_TLS | |
client - > type = = QEMUD_SOCK_TYPE_UNIX )
return 0 ; /* TLS or UNIX domain sockets trivially OK */
err = sasl_getprop ( client - > saslconn , SASL_SSF , & val ) ;
if ( err ! = SASL_OK ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " cannot query SASL ssf on connection %d (%s) " ) ,
err , sasl_errstring ( err , NULL , NULL ) ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:27:08 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
return - 1 ;
}
ssf = * ( const int * ) val ;
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " negotiated an SSF of %d " , ssf ) ;
2007-12-05 18:27:08 +03:00
if ( ssf < 56 ) { /* 56 is good for Kerberos */
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " negotiated SSF %d was not strong enough " ) , ssf ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:27:08 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2010-09-14 20:50:25 +04:00
return - 2 ;
2007-12-05 18:27:08 +03:00
}
/* Only setup for read initially, because we're about to send an RPC
* reply which must be in plain text . When the next incoming RPC
* arrives , we ' ll switch on writes too
*
* cf qemudClientReadSASL in qemud . c
*/
client - > saslSSF = QEMUD_SASL_SSF_READ ;
/* We have a SSF !*/
return 0 ;
}
2010-09-14 20:50:25 +04:00
/*
* Returns 0 if ok , - 1 on error , - 2 if rejected
*/
2007-12-05 18:34:05 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteSASLCheckAccess ( struct qemud_server * server ,
struct qemud_client * client ,
remote_error * rerr ) {
2007-12-05 18:34:05 +03:00
const void * val ;
int err ;
char * * wildcards ;
err = sasl_getprop ( client - > saslconn , SASL_USERNAME , & val ) ;
if ( err ! = SASL_OK ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " cannot query SASL username on connection %d (%s) " ) ,
err , sasl_errstring ( err , NULL , NULL ) ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:34:05 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
return - 1 ;
}
if ( val = = NULL ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " no client username was found " ) ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:34:05 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
return - 1 ;
}
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " SASL client username %s " , ( const char * ) val ) ;
2007-12-05 18:34:05 +03:00
client - > saslUsername = strdup ( ( const char * ) val ) ;
if ( client - > saslUsername = = NULL ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " out of memory copying username " ) ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:34:05 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
return - 1 ;
}
/* If the list is not set, allow any DN. */
wildcards = server - > saslUsernameWhitelist ;
if ( ! wildcards )
return 0 ; /* No ACL, allow all */
while ( * wildcards ) {
2011-04-12 20:34:30 +04:00
if ( fnmatch ( * wildcards , client - > saslUsername , 0 ) = = 0 )
2007-12-05 18:34:05 +03:00
return 0 ; /* Allowed */
wildcards + + ;
}
/* Denied */
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " SASL client %s not allowed in whitelist " ) , client - > saslUsername ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:34:05 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2010-09-14 20:50:25 +04:00
return - 2 ;
2007-12-05 18:34:05 +03:00
}
2007-12-05 18:24:15 +03:00
/*
* This starts the SASL authentication negotiation .
*/
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthSaslStart ( struct qemud_server * server ,
struct qemud_client * client ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_auth_sasl_start_args * args ,
remote_auth_sasl_start_ret * ret )
2007-12-05 18:24:15 +03:00
{
const char * serverout ;
unsigned int serveroutlen ;
int err ;
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2008-12-05 01:16:40 +03:00
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Start SASL auth %d " , client - > fd ) ;
2007-12-05 18:24:15 +03:00
if ( client - > auth ! = REMOTE_AUTH_SASL | |
client - > saslconn = = NULL ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried invalid SASL start request " ) ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Using SASL mechanism %s. Data %d bytes, nil: %d " ,
args - > mech , args - > data . data_len , args - > nil ) ;
2007-12-05 18:24:15 +03:00
err = sasl_server_start ( client - > saslconn ,
args - > mech ,
/* NB, distinction of NULL vs "" is *critical* in SASL */
args - > nil ? NULL : args - > data . data_val ,
args - > data . data_len ,
& serverout ,
& serveroutlen ) ;
if ( err ! = SASL_OK & &
err ! = SASL_CONTINUE ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " sasl start failed %d (%s) " ) ,
err , sasl_errdetail ( client - > saslconn ) ) ;
2007-12-05 18:24:15 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
if ( serveroutlen > REMOTE_AUTH_SASL_DATA_MAX ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " sasl start reply data too long %d " ) , serveroutlen ) ;
2007-12-05 18:24:15 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
/* NB, distinction of NULL vs "" is *critical* in SASL */
if ( serverout ) {
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > data . data_val , serveroutlen ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
remoteDispatchError ( rerr ) ;
2008-12-05 01:16:40 +03:00
goto error ;
2007-12-05 18:24:15 +03: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 19:10:01 +04:00
VIR_DEBUG ( " SASL return data %d bytes, nil; %d " , ret - > data . data_len , ret - > nil ) ;
2007-12-05 18:24:15 +03:00
if ( err = = SASL_CONTINUE ) {
ret - > complete = 0 ;
} else {
2007-12-05 18:34:05 +03:00
/* Check username whitelist ACL */
2010-09-14 20:50:25 +04:00
if ( ( err = remoteSASLCheckAccess ( server , client , rerr ) ) < 0 | |
( err = remoteSASLCheckSSF ( client , rerr ) ) < 0 ) {
if ( err = = - 2 )
goto authdeny ;
else
goto authfail ;
}
2007-12-05 18:34:05 +03:00
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Authentication successful %d " , client - > fd ) ;
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_ALLOW , " fd=%d, auth=%d, username=%s " ,
client - > fd , REMOTE_AUTH_SASL , client - > saslUsername ) ;
2007-12-05 18:24:15 +03:00
ret - > complete = 1 ;
client - > auth = REMOTE_AUTH_NONE ;
}
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2007-12-05 18:24:15 +03:00
return 0 ;
2008-12-05 01:16:40 +03:00
authfail :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_SASL ) ;
2008-12-05 01:16:40 +03:00
remoteDispatchAuthError ( rerr ) ;
2010-09-14 20:50:25 +04:00
goto error ;
authdeny :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_DENY , " fd=%d, auth=%d, username=%s " ,
client - > fd , REMOTE_AUTH_SASL , client - > saslUsername ) ;
2010-09-14 20:50:25 +04:00
goto error ;
2008-12-05 01:16:40 +03:00
error :
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2008-12-05 01:16:40 +03:00
return - 1 ;
2007-12-05 18:24:15 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthSaslStep ( struct qemud_server * server ,
struct qemud_client * client ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_auth_sasl_step_args * args ,
remote_auth_sasl_step_ret * ret )
2007-12-05 18:24:15 +03:00
{
const char * serverout ;
unsigned int serveroutlen ;
int err ;
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2008-12-05 01:16:40 +03:00
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Step SASL auth %d " , client - > fd ) ;
2007-12-05 18:24:15 +03:00
if ( client - > auth ! = REMOTE_AUTH_SASL | |
client - > saslconn = = NULL ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried invalid SASL start request " ) ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Using SASL Data %d bytes, nil: %d " ,
args - > data . data_len , args - > nil ) ;
2007-12-05 18:24:15 +03:00
err = sasl_server_step ( client - > saslconn ,
/* NB, distinction of NULL vs "" is *critical* in SASL */
args - > nil ? NULL : args - > data . data_val ,
args - > data . data_len ,
& serverout ,
& serveroutlen ) ;
if ( err ! = SASL_OK & &
err ! = SASL_CONTINUE ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " sasl step failed %d (%s) " ) ,
err , sasl_errdetail ( client - > saslconn ) ) ;
2007-12-05 18:24:15 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
if ( serveroutlen > REMOTE_AUTH_SASL_DATA_MAX ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " sasl step reply data too long %d " ) ,
serveroutlen ) ;
2007-12-05 18:24:15 +03:00
sasl_dispose ( & client - > saslconn ) ;
client - > saslconn = NULL ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 18:24:15 +03:00
}
/* NB, distinction of NULL vs "" is *critical* in SASL */
if ( serverout ) {
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > data . data_val , serveroutlen ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
remoteDispatchError ( rerr ) ;
2008-12-05 01:16:40 +03:00
goto error ;
2007-12-05 18:24:15 +03: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 19:10:01 +04:00
VIR_DEBUG ( " SASL return data %d bytes, nil; %d " , ret - > data . data_len , ret - > nil ) ;
2007-12-05 18:24:15 +03:00
if ( err = = SASL_CONTINUE ) {
ret - > complete = 0 ;
} else {
2007-12-05 18:34:05 +03:00
/* Check username whitelist ACL */
2010-09-14 20:50:25 +04:00
if ( ( err = remoteSASLCheckAccess ( server , client , rerr ) ) < 0 | |
( err = remoteSASLCheckSSF ( client , rerr ) ) < 0 ) {
if ( err = = - 2 )
goto authdeny ;
else
goto authfail ;
}
2007-12-05 18:34:05 +03:00
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Authentication successful %d " , client - > fd ) ;
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_ALLOW , " fd=%d, auth=%d, username=%s " ,
client - > fd , REMOTE_AUTH_SASL , client - > saslUsername ) ;
2007-12-05 18:24:15 +03:00
ret - > complete = 1 ;
client - > auth = REMOTE_AUTH_NONE ;
}
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2007-12-05 18:24:15 +03:00
return 0 ;
2008-12-05 01:16:40 +03:00
authfail :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_SASL ) ;
2008-12-05 01:16:40 +03:00
remoteDispatchAuthError ( rerr ) ;
2010-09-14 20:50:25 +04:00
goto error ;
authdeny :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_DENY , " fd=%d, auth=%d, username=%s " ,
client - > fd , REMOTE_AUTH_SASL , client - > saslUsername ) ;
2010-09-14 20:50:25 +04:00
goto error ;
2008-12-05 01:16:40 +03:00
error :
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2008-12-05 01:16:40 +03:00
return - 1 ;
2007-12-05 18:24:15 +03:00
}
# else /* HAVE_SASL */
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthSaslInit ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_auth_sasl_init_ret * ret ATTRIBUTE_UNUSED )
2007-12-05 18:24:15 +03:00
{
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried unsupported SASL init request " ) ) ;
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_SASL ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:24:15 +03:00
return - 1 ;
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthSaslStart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_auth_sasl_start_args * args ATTRIBUTE_UNUSED ,
remote_auth_sasl_start_ret * ret ATTRIBUTE_UNUSED )
2007-12-05 18:24:15 +03:00
{
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried unsupported SASL start request " ) ) ;
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_SASL ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:24:15 +03:00
return - 1 ;
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthSaslStep ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_auth_sasl_step_args * args ATTRIBUTE_UNUSED ,
remote_auth_sasl_step_ret * ret ATTRIBUTE_UNUSED )
2007-12-05 18:24:15 +03:00
{
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried unsupported SASL step request " ) ) ;
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_SASL ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 18:24:15 +03:00
return - 1 ;
}
# endif /* HAVE_SASL */
2009-08-06 16:54:08 +04:00
# if HAVE_POLKIT1
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthPolkit ( struct qemud_server * server ,
struct qemud_client * client ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_auth_polkit_ret * ret )
2009-08-06 16:54:08 +04:00
{
2010-09-14 20:50:25 +04:00
pid_t callerPid = - 1 ;
uid_t callerUid = - 1 ;
2009-08-06 16:54:08 +04:00
const char * action ;
int status = - 1 ;
char pidbuf [ 50 ] ;
2010-09-14 20:50:25 +04:00
char ident [ 100 ] ;
2009-08-06 16:54:08 +04:00
int rv ;
2010-09-14 20:50:25 +04:00
memset ( ident , 0 , sizeof ident ) ;
2009-08-06 16:54:08 +04:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
action = client - > readonly ?
" org.libvirt.unix.monitor " :
" org.libvirt.unix.manage " ;
const char * const pkcheck [ ] = {
PKCHECK_PATH ,
" --action-id " , action ,
" --process " , pidbuf ,
" --allow-user-interaction " ,
NULL
} ;
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Start PolicyKit auth %d " , client - > fd ) ;
2009-08-06 16:54:08 +04:00
if ( client - > auth ! = REMOTE_AUTH_POLKIT ) {
VIR_ERROR0 ( _ ( " client tried invalid PolicyKit init request " ) ) ;
goto authfail ;
}
if ( qemudGetSocketIdentity ( client - > fd , & callerUid , & callerPid ) < 0 ) {
VIR_ERROR0 ( _ ( " cannot get peer socket identity " ) ) ;
goto authfail ;
}
VIR_INFO ( _ ( " Checking PID %d running as %d " ) , callerPid , callerUid ) ;
rv = snprintf ( pidbuf , sizeof pidbuf , " %d " , callerPid ) ;
if ( rv < 0 | | rv > = sizeof pidbuf ) {
VIR_ERROR ( _ ( " Caller PID was too large %d " ) , callerPid ) ;
2009-08-25 20:18:27 +04:00
goto authfail ;
2009-08-06 16:54:08 +04:00
}
2010-09-14 20:50:25 +04:00
rv = snprintf ( ident , sizeof ident , " pid:%d,uid:%d " , callerPid , callerUid ) ;
if ( rv < 0 | | rv > = sizeof ident ) {
VIR_ERROR ( _ ( " Caller identity was too large %d:%d " ) , callerPid , callerUid ) ;
goto authfail ;
}
2010-02-05 01:41:52 +03:00
if ( virRun ( pkcheck , & status ) < 0 ) {
2009-08-06 16:54:08 +04:00
VIR_ERROR ( _ ( " Cannot invoke %s " ) , PKCHECK_PATH ) ;
2009-08-25 20:18:27 +04:00
goto authfail ;
2009-08-06 16:54:08 +04:00
}
if ( status ! = 0 ) {
2011-03-22 20:55:45 +03:00
char * tmp = virCommandTranslateStatus ( status ) ;
VIR_ERROR ( _ ( " Policy kit denied action %s from pid %d, uid %d: %s " ) ,
action , callerPid , callerUid , NULLSTR ( tmp ) ) ;
VIR_FREE ( tmp ) ;
2010-09-14 20:50:25 +04:00
goto authdeny ;
2009-08-06 16:54:08 +04:00
}
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_ALLOW , " fd=%d, auth=%d, username=%s " ,
2010-10-23 01:36:42 +04:00
client - > fd , REMOTE_AUTH_POLKIT , ( char * ) ident ) ;
2009-08-06 16:54:08 +04:00
VIR_INFO ( _ ( " Policy allowed action %s from pid %d, uid %d " ) ,
action , callerPid , callerUid ) ;
ret - > complete = 1 ;
client - > auth = REMOTE_AUTH_NONE ;
virMutexUnlock ( & client - > lock ) ;
return 0 ;
authfail :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_POLKIT ) ;
2010-09-14 20:50:25 +04:00
goto error ;
authdeny :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_DENY , " fd=%d, auth=%d, username=%s " ,
2010-10-23 01:36:42 +04:00
client - > fd , REMOTE_AUTH_POLKIT , ( char * ) ident ) ;
2010-09-14 20:50:25 +04:00
goto error ;
error :
2009-08-06 16:54:08 +04:00
remoteDispatchAuthError ( rerr ) ;
virMutexUnlock ( & client - > lock ) ;
return - 1 ;
}
# elif HAVE_POLKIT0
2007-12-05 21:21:27 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthPolkit ( struct qemud_server * server ,
struct qemud_client * client ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_auth_polkit_ret * ret )
2007-12-05 21:21:27 +03:00
{
pid_t callerPid ;
uid_t callerUid ;
2008-04-04 19:09:19 +04:00
PolKitCaller * pkcaller = NULL ;
PolKitAction * pkaction = NULL ;
PolKitContext * pkcontext = NULL ;
PolKitError * pkerr = NULL ;
PolKitResult pkresult ;
DBusError err ;
2008-12-05 01:16:40 +03:00
const char * action ;
2010-09-14 20:50:25 +04:00
char ident [ 100 ] ;
2010-11-02 02:50:32 +03:00
int rv ;
2010-09-14 20:50:25 +04:00
memset ( ident , 0 , sizeof ident ) ;
2008-12-05 01:16:40 +03:00
2009-01-15 22:56:05 +03:00
virMutexLock ( & server - > lock ) ;
virMutexLock ( & client - > lock ) ;
virMutexUnlock ( & server - > lock ) ;
2008-12-05 01:16:40 +03:00
action = client - > readonly ?
2008-04-04 19:09:19 +04:00
" org.libvirt.unix.monitor " :
" org.libvirt.unix.manage " ;
2007-12-05 21:21:27 +03:00
2011-04-13 19:10:01 +04:00
VIR_DEBUG ( " Start PolicyKit auth %d " , client - > fd ) ;
2007-12-05 21:21:27 +03:00
if ( client - > auth ! = REMOTE_AUTH_POLKIT ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried invalid PolicyKit init request " ) ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 21:21:27 +03:00
}
if ( qemudGetSocketIdentity ( client - > fd , & callerUid , & callerPid ) < 0 ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " cannot get peer socket identity " ) ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2007-12-05 21:21:27 +03:00
}
2010-09-14 20:50:25 +04:00
rv = snprintf ( ident , sizeof ident , " pid:%d,uid:%d " , callerPid , callerUid ) ;
if ( rv < 0 | | rv > = sizeof ident ) {
VIR_ERROR ( _ ( " Caller identity was too large %d:%d " ) , callerPid , callerUid ) ;
goto authfail ;
}
2009-01-06 21:32:03 +03:00
VIR_INFO ( _ ( " Checking PID %d running as %d " ) , callerPid , callerUid ) ;
2008-04-04 19:09:19 +04:00
dbus_error_init ( & err ) ;
if ( ! ( pkcaller = polkit_caller_new_from_pid ( server - > sysbus ,
callerPid , & err ) ) ) {
2009-01-06 21:32:03 +03:00
VIR_ERROR ( _ ( " Failed to lookup policy kit caller: %s " ) , err . message ) ;
2008-04-04 19:09:19 +04:00
dbus_error_free ( & err ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2008-04-04 19:09:19 +04:00
}
2007-12-05 21:21:27 +03:00
2008-04-04 19:09:19 +04:00
if ( ! ( pkaction = polkit_action_new ( ) ) ) {
2009-02-05 19:28:30 +03:00
char ebuf [ 1024 ] ;
2010-01-19 16:17:20 +03:00
VIR_ERROR ( _ ( " Failed to create polkit action %s " ) ,
2009-02-05 19:28:30 +03:00
virStrerror ( errno , ebuf , sizeof ebuf ) ) ;
2008-04-04 19:09:19 +04:00
polkit_caller_unref ( pkcaller ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2008-04-04 19:09:19 +04:00
}
polkit_action_set_action_id ( pkaction , action ) ;
if ( ! ( pkcontext = polkit_context_new ( ) ) | |
! polkit_context_init ( pkcontext , & pkerr ) ) {
2009-02-05 19:28:30 +03:00
char ebuf [ 1024 ] ;
2010-01-19 16:17:20 +03:00
VIR_ERROR ( _ ( " Failed to create polkit context %s " ) ,
2009-01-06 21:32:03 +03:00
( pkerr ? polkit_error_get_error_message ( pkerr )
2009-02-05 19:28:30 +03:00
: virStrerror ( errno , ebuf , sizeof ebuf ) ) ) ;
2008-04-04 19:09:19 +04:00
if ( pkerr )
polkit_error_free ( pkerr ) ;
polkit_caller_unref ( pkcaller ) ;
polkit_action_unref ( pkaction ) ;
dbus_error_free ( & err ) ;
2008-12-05 01:16:40 +03:00
goto authfail ;
2008-04-04 19:09:19 +04:00
}
2007-12-05 21:21:27 +03:00
2010-03-09 21:22:22 +03:00
# if HAVE_POLKIT_CONTEXT_IS_CALLER_AUTHORIZED
2008-04-04 19:09:19 +04:00
pkresult = polkit_context_is_caller_authorized ( pkcontext ,
pkaction ,
pkcaller ,
0 ,
& pkerr ) ;
if ( pkerr & & polkit_error_is_set ( pkerr ) ) {
2009-01-06 21:32:03 +03: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-05 01:16:40 +03:00
goto authfail ;
2008-04-04 19:09:19 +04:00
}
2010-03-09 21:22:22 +03:00
# else
2008-04-04 19:09:19 +04:00
pkresult = polkit_context_can_caller_do_action ( pkcontext ,
pkaction ,
pkcaller ) ;
2010-03-09 21:22:22 +03:00
# endif
2008-04-04 19:09:19 +04:00
polkit_context_unref ( pkcontext ) ;
polkit_caller_unref ( pkcaller ) ;
polkit_action_unref ( pkaction ) ;
if ( pkresult ! = POLKIT_RESULT_YES ) {
2010-01-19 16:17:20 +03:00
VIR_ERROR ( _ ( " Policy kit denied action %s from pid %d, uid %d, result: %s " ) ,
2009-01-06 21:32:03 +03:00
action , callerPid , callerUid ,
polkit_result_to_string_representation ( pkresult ) ) ;
2010-09-14 20:50:25 +04:00
goto authdeny ;
2007-12-05 21:21:27 +03:00
}
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_ALLOW , " fd=%d, auth=%d, username=%s " ,
client - > fd , REMOTE_AUTH_POLKIT , ident ) ;
2009-01-06 21:32:03 +03:00
VIR_INFO ( _ ( " Policy allowed action %s from pid %d, uid %d, result %s " ) ,
2008-04-04 19:09:19 +04:00
action , callerPid , callerUid ,
polkit_result_to_string_representation ( pkresult ) ) ;
ret - > complete = 1 ;
client - > auth = REMOTE_AUTH_NONE ;
2007-12-05 21:21:27 +03:00
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2007-12-05 21:21:27 +03:00
return 0 ;
2008-12-05 01:16:40 +03:00
authfail :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_FAIL , " fd=%d, auth=%d " , client - > fd , REMOTE_AUTH_POLKIT ) ;
2010-09-14 20:50:25 +04:00
goto error ;
authdeny :
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 20:30:32 +04:00
PROBE ( CLIENT_AUTH_DENY , " fd=%d, auth=%d, username=%s " ,
client - > fd , REMOTE_AUTH_POLKIT , ident ) ;
2010-09-14 20:50:25 +04:00
goto error ;
error :
2008-12-05 01:16:40 +03:00
remoteDispatchAuthError ( rerr ) ;
2009-01-15 22:56:05 +03:00
virMutexUnlock ( & client - > lock ) ;
2008-12-05 01:16:40 +03:00
return - 1 ;
2007-12-05 21:21:27 +03:00
}
2009-08-06 16:54:08 +04:00
# else /* !HAVE_POLKIT0 & !HAVE_POLKIT1*/
2007-12-05 21:21:27 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchAuthPolkit ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ATTRIBUTE_UNUSED ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_auth_polkit_ret * ret ATTRIBUTE_UNUSED )
2007-12-05 21:21:27 +03:00
{
2009-01-06 21:32:03 +03:00
VIR_ERROR0 ( _ ( " client tried unsupported PolicyKit init request " ) ) ;
2008-12-05 01:12:53 +03:00
remoteDispatchAuthError ( rerr ) ;
2007-12-05 21:21:27 +03:00
return - 1 ;
}
2009-08-06 16:54:08 +04:00
# endif /* HAVE_POLKIT1 */
2007-12-05 21:21:27 +03:00
2008-02-20 18:22:35 +03:00
/***************************************************************
* STORAGE POOL APIS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListDefinedStoragePools ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_defined_storage_pools_args * args ,
remote_list_defined_storage_pools_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-02-20 18:22:35 +03:00
if ( args - > maxnames > REMOTE_NETWORK_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " ,
_ ( " maxnames > REMOTE_NETWORK_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2008-02-20 18:22:35 +03:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2008-02-20 18:22:35 +03:00
2011-04-13 21:13:37 +04:00
len = virConnectListDefinedStoragePools ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListStoragePools ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_storage_pools_args * args ,
remote_list_storage_pools_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-02-20 18:22:35 +03:00
if ( args - > maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_STORAGE_POOL_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2008-02-20 18:22:35 +03:00
}
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2008-02-20 18:22:35 +03:00
2011-04-13 21:13:37 +04:00
len = virConnectListStoragePools ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
return rv ;
2008-02-20 18:22:35 +03:00
}
2008-08-28 00:05:58 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchFindStoragePoolSources ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_find_storage_pool_sources_args * args ,
remote_find_storage_pool_sources_ret * ret )
2008-08-28 00:05:58 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml =
virConnectFindStoragePoolSources ( conn ,
args - > type ,
args - > srcSpec ? * args - > srcSpec : NULL ,
args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-08-28 00:05:58 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-08-28 00:05:58 +04:00
}
2008-02-20 18:22:35 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolCreate ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_create_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolCreate ( pool , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolCreateXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_create_xml_args * args ,
remote_storage_pool_create_xml_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = virStoragePoolCreateXML ( conn , args - > xml , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_pool ( & ret - > pool , pool ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolDefineXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_define_xml_args * args ,
remote_storage_pool_define_xml_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = virStoragePoolDefineXML ( conn , args - > xml , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_pool ( & ret - > pool , pool ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolBuild ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_build_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolBuild ( pool , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolDestroy ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_destroy_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolDestroy ( pool ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolDelete ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_delete_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolDelete ( pool , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolRefresh ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_refresh_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolRefresh ( pool , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolGetInfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_get_info_args * args ,
remote_storage_pool_get_info_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
2008-02-20 18:22:35 +03:00
virStoragePoolInfo info ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolGetInfo ( pool , & info ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
ret - > state = info . state ;
ret - > capacity = info . capacity ;
ret - > allocation = info . allocation ;
ret - > available = info . available ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolDumpXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_dump_xml_args * args ,
remote_storage_pool_dump_xml_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virStoragePoolGetXMLDesc ( pool , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolGetAutostart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_get_autostart_args * args ,
remote_storage_pool_get_autostart_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolGetAutostart ( pool , & ret - > autostart ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_lookup_by_name_args * args ,
remote_storage_pool_lookup_by_name_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = virStoragePoolLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_pool ( & ret - > pool , pool ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolLookupByUuid ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_lookup_by_uuid_args * args ,
remote_storage_pool_lookup_by_uuid_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = virStoragePoolLookupByUUID ( conn , ( unsigned char * ) args - > uuid ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_pool ( & ret - > pool , pool ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolLookupByVolume ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_lookup_by_volume_args * args ,
remote_storage_pool_lookup_by_volume_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( pool = virStoragePoolLookupByVolume ( vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_pool ( & ret - > pool , pool ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolSetAutostart ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_set_autostart_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolSetAutostart ( pool , args - > autostart ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolUndefine ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_undefine_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStoragePoolUndefine ( pool ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfStoragePools ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_storage_pools_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-02-20 18:22:35 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfStoragePools ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfDefinedStoragePools ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_defined_storage_pools_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-02-20 18:22:35 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfDefinedStoragePools ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolListVolumes ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_list_volumes_args * args ,
remote_storage_pool_list_volumes_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-02-20 18:22:35 +03:00
if ( args - > maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_STORAGE_VOL_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2008-02-20 18:22:35 +03:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
/* Allocate return buffer. */
2008-06-06 14:52:01 +04:00
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-06-06 14:52:01 +04:00
}
2008-02-20 18:22:35 +03:00
2011-04-13 21:13:37 +04:00
len = virStoragePoolListVolumes ( pool ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
2008-06-06 14:52:01 +04:00
VIR_FREE ( ret - > names . names_val ) ;
}
2011-04-13 19:21:35 +04:00
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStoragePoolNumOfVolumes ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_pool_num_of_volumes_args * args ,
remote_storage_pool_num_of_volumes_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virStoragePoolNumOfVolumes ( pool ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
/***************************************************************
* STORAGE VOL APIS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolCreateXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_create_xml_args * args ,
remote_storage_vol_create_xml_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( vol = virStorageVolCreateXML ( pool , args - > xml , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_vol ( & ret - > vol , vol ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
2009-05-13 00:13:52 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolCreateXmlFrom ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_create_xml_from_args * args ,
remote_storage_vol_create_xml_from_ret * ret )
2009-05-13 00:13:52 +04:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
virStorageVolPtr clonevol = NULL ;
virStorageVolPtr newvol = NULL ;
int rv = - 1 ;
2009-05-13 00:13:52 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-13 00:13:52 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( clonevol = get_nonnull_storage_vol ( conn , args - > clonevol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-13 00:13:52 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( newvol = virStorageVolCreateXMLFrom ( pool , args - > xml , clonevol ,
args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-05-13 00:13:52 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_vol ( & ret - > vol , newvol ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( newvol )
virStorageVolFree ( newvol ) ;
if ( clonevol )
virStorageVolFree ( clonevol ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
return rv ;
2009-05-13 00:13:52 +04:00
}
2008-02-20 18:22:35 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolDelete ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_delete_args * args ,
void * ret ATTRIBUTE_UNUSED )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStorageVolDelete ( vol , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
2010-03-01 23:32:35 +03:00
static int
remoteDispatchStorageVolWipe ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_wipe_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2010-03-01 23:32:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-01 23:32:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStorageVolWipe ( vol , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-01 23:32:35 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-03-01 23:32:35 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
2010-03-01 23:32:35 +03:00
virStorageVolFree ( vol ) ;
2011-04-13 19:21:35 +04:00
return rv ;
2010-03-01 23:32:35 +03:00
}
2008-02-20 18:22:35 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolGetInfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_get_info_args * args ,
remote_storage_vol_get_info_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
2008-02-20 18:22:35 +03:00
virStorageVolInfo info ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:23:00 +04:00
if ( virStorageVolGetInfo ( vol , & info ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
ret - > type = info . type ;
ret - > capacity = info . capacity ;
ret - > allocation = info . allocation ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2008-02-20 18:22:35 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolDumpXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_dump_xml_args * args ,
remote_storage_vol_dump_xml_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virStorageVolGetXMLDesc ( vol , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolGetPath ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_get_path_args * args ,
remote_storage_vol_get_path_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > name = virStorageVolGetPath ( vol ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_lookup_by_name_args * args ,
remote_storage_vol_lookup_by_name_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( vol = virStorageVolLookupByName ( pool , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_vol ( & ret - > vol , vol ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolLookupByKey ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_lookup_by_key_args * args ,
remote_storage_vol_lookup_by_key_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = virStorageVolLookupByKey ( conn , args - > key ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_vol ( & ret - > vol , vol ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchStorageVolLookupByPath ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_storage_vol_lookup_by_path_args * args ,
remote_storage_vol_lookup_by_path_ret * ret )
2008-02-20 18:22:35 +03:00
{
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = virStorageVolLookupByPath ( conn , args - > path ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-02-20 18:22:35 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_storage_vol ( & ret - > vol , vol ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( vol )
virStorageVolFree ( vol ) ;
return rv ;
2008-02-20 18:22:35 +03:00
}
2008-11-21 15:31:04 +03:00
/***************************************************************
* NODE INFO APIS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeNumOfDevices ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_num_of_devices_args * args ,
remote_node_num_of_devices_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virNodeNumOfDevices ( conn ,
args - > cap ? * args - > cap : NULL ,
args - > flags ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-11-21 15:31:04 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeListDevices ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_list_devices_args * args ,
remote_node_list_devices_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
if ( args - > maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2008-11-21 15:31:04 +03:00
}
/* Allocate return buffer. */
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-11-21 15:31:04 +03:00
}
2011-04-13 21:13:37 +04:00
len = virNodeListDevices ( conn ,
args - > cap ? * args - > cap : NULL ,
ret - > names . names_val , args - > maxnames , args - > flags ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2008-11-21 15:31:04 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
return rv ;
2008-11-21 15:31:04 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_lookup_by_name_args * args ,
remote_node_device_lookup_by_name_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2008-11-21 15:31:04 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_node_device ( & ret - > dev , dev ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2008-11-21 15:31:04 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceDumpXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_dump_xml_args * args ,
remote_node_device_dump_xml_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virNodeDeviceGetXMLDesc ( dev , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2008-11-21 15:31:04 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceGetParent ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_get_parent_args * args ,
remote_node_device_get_parent_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
const char * parent = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
parent = virNodeDeviceGetParent ( dev ) ;
if ( parent = = NULL ) {
ret - > parent = NULL ;
} else {
/* remoteDispatchClientRequest will free this. */
char * * parent_p ;
if ( VIR_ALLOC ( parent_p ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-11-21 15:31:04 +03:00
}
2011-04-13 19:21:35 +04:00
if ( ! ( * parent_p = strdup ( parent ) ) ) {
VIR_FREE ( parent_p ) ;
virReportOOMError ( ) ;
goto cleanup ;
2008-11-21 15:31:04 +03:00
}
ret - > parent = parent_p ;
}
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2008-11-21 15:31:04 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceNumOfCaps ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_num_of_caps_args * args ,
remote_node_device_num_of_caps_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virNodeDeviceNumOfCaps ( dev ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2008-11-21 15:31:04 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceListCaps ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_list_caps_args * args ,
remote_node_device_list_caps_ret * ret )
2008-11-21 15:31:04 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-11-21 15:31:04 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-11-21 15:31:04 +03:00
if ( args - > maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2008-11-21 15:31:04 +03:00
}
/* Allocate return buffer. */
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2008-11-21 15:31:04 +03:00
}
2011-04-13 21:13:37 +04:00
len = virNodeDeviceListCaps ( dev , ret - > names . names_val ,
args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2008-11-21 15:31:04 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2008-11-21 15:31:04 +03:00
}
2009-03-02 19:30:59 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceDettach ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_dettach_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-03-02 19:30:59 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-03-02 19:30:59 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-02 19:30:59 +03:00
2011-04-13 21:23:00 +04:00
if ( virNodeDeviceDettach ( dev ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-02 19:30:59 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2009-03-02 19:30:59 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceReAttach ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_re_attach_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-03-02 19:30:59 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-03-02 19:30:59 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-02 19:30:59 +03:00
2011-04-13 21:23:00 +04:00
if ( virNodeDeviceReAttach ( dev ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-02 19:30:59 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2009-03-02 19:30:59 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNodeDeviceReset ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_node_device_reset_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-03-02 19:30:59 +03:00
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-03-02 19:30:59 +03:00
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-02 19:30:59 +03:00
2011-04-13 21:23:00 +04:00
if ( virNodeDeviceReset ( dev ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-03-02 19:30:59 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2009-03-02 19:30:59 +03:00
}
2009-04-24 17:11:23 +04:00
static int
remoteDispatchNodeDeviceCreateXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
2009-09-30 14:29:20 +04:00
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2009-04-24 17:11:23 +04:00
remote_error * rerr ,
remote_node_device_create_xml_args * args ,
remote_node_device_create_xml_ret * ret )
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2009-04-24 17:11:23 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceCreateXML ( conn , args - > xml_desc , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-04-24 17:11:23 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_node_device ( & ret - > dev , dev ) ;
2009-04-24 17:11:23 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2009-04-24 17:11:23 +04:00
}
static int
remoteDispatchNodeDeviceDestroy ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
2009-09-30 14:29:20 +04:00
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2009-04-24 17:11:23 +04:00
remote_error * rerr ,
remote_node_device_destroy_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
virNodeDevicePtr dev = NULL ;
int rv = - 1 ;
2009-04-24 17:11:23 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dev = virNodeDeviceLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-04-24 17:11:23 +04:00
2011-04-13 21:23:00 +04:00
if ( virNodeDeviceDestroy ( dev ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-04-24 17:11:23 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dev )
virNodeDeviceFree ( dev ) ;
return rv ;
2009-04-24 17:11:23 +04:00
}
2011-04-13 19:21:35 +04:00
2009-07-15 02:46:15 +04:00
static int remoteDispatchStorageVolUpload ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ,
virConnectPtr conn ,
remote_message_header * hdr ,
remote_error * rerr ,
remote_storage_vol_upload_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
struct qemud_client_stream * stream = NULL ;
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2009-07-15 02:46:15 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2009-07-15 02:46:15 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
if ( ! ( stream = remoteCreateClientStream ( conn , hdr ) ) )
2009-07-15 02:46:15 +04:00
goto cleanup ;
if ( virStorageVolUpload ( vol , stream - > st ,
args - > offset , args - > length ,
2011-04-13 21:23:00 +04:00
args - > flags ) < 0 )
2009-07-15 02:46:15 +04:00
goto cleanup ;
2011-04-13 21:23:00 +04:00
if ( remoteAddClientStream ( client , stream , 0 ) < 0 )
2009-07-15 02:46:15 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
2011-04-13 19:21:35 +04:00
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
2009-07-15 02:46:15 +04:00
if ( vol )
virStorageVolFree ( vol ) ;
2011-04-13 19:21:35 +04:00
if ( stream & & rv ! = 0 ) {
virStreamAbort ( stream - > st ) ;
2009-07-15 02:46:15 +04:00
remoteFreeClientStream ( client , stream ) ;
2011-04-13 19:21:35 +04:00
}
2009-07-15 02:46:15 +04:00
return rv ;
}
2009-04-24 17:11:23 +04:00
2009-07-15 02:46:15 +04:00
static int remoteDispatchStorageVolDownload ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ,
virConnectPtr conn ,
remote_message_header * hdr ,
remote_error * rerr ,
remote_storage_vol_download_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
struct qemud_client_stream * stream = NULL ;
2011-04-13 19:21:35 +04:00
virStorageVolPtr vol = NULL ;
int rv = - 1 ;
2009-07-15 02:46:15 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( vol = get_nonnull_storage_vol ( conn , args - > vol ) ) )
2009-07-15 02:46:15 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
if ( ! ( stream = remoteCreateClientStream ( conn , hdr ) ) )
2009-07-15 02:46:15 +04:00
goto cleanup ;
if ( virStorageVolDownload ( vol , stream - > st ,
args - > offset , args - > length ,
2011-04-13 21:23:00 +04:00
args - > flags ) < 0 )
2009-07-15 02:46:15 +04:00
goto cleanup ;
2011-04-13 21:23:00 +04:00
if ( remoteAddClientStream ( client , stream , 1 ) < 0 )
2009-07-15 02:46:15 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
2011-04-13 19:21:35 +04:00
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
2009-07-15 02:46:15 +04:00
if ( vol )
virStorageVolFree ( vol ) ;
2011-04-13 19:21:35 +04:00
if ( stream & & rv ! = 0 ) {
virStreamAbort ( stream - > st ) ;
2009-07-15 02:46:15 +04:00
remoteFreeClientStream ( client , stream ) ;
2011-04-13 19:21:35 +04:00
}
2009-07-15 02:46:15 +04:00
return rv ;
}
2009-04-24 17:11:23 +04:00
2008-10-23 17:18:18 +04:00
/***************************
* Register / deregister events
* * * * * * * * * * * * * * * * * * * * * * * * * * */
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventsRegister ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ATTRIBUTE_UNUSED ,
void * args ATTRIBUTE_UNUSED ,
remote_domain_events_register_ret * ret ATTRIBUTE_UNUSED )
2008-10-23 17:18:18 +04: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 17:56:56 +03:00
int callbackID ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 17:56:56 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04: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 17:56:56 +03:00
if ( client - > domainEventCallbackID [ VIR_DOMAIN_EVENT_ID_LIFECYCLE ] ! = - 1 ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " domain event %d already registered " ) , VIR_DOMAIN_EVENT_ID_LIFECYCLE ) ;
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 17:56:56 +03:00
}
2008-10-23 17:18:18 +04: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 17:56:56 +03:00
if ( ( callbackID = virConnectDomainEventRegisterAny ( conn ,
NULL ,
VIR_DOMAIN_EVENT_ID_LIFECYCLE ,
VIR_DOMAIN_EVENT_CALLBACK ( remoteRelayDomainEventLifecycle ) ,
2011-04-13 21:23:00 +04:00
client , NULL ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-10-23 17:18:18 +04: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 17:56:56 +03:00
client - > domainEventCallbackID [ VIR_DOMAIN_EVENT_ID_LIFECYCLE ] = callbackID ;
2010-01-13 21:21:30 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-10-23 17:18:18 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventsDeregister ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ATTRIBUTE_UNUSED ,
void * args ATTRIBUTE_UNUSED ,
remote_domain_events_deregister_ret * ret ATTRIBUTE_UNUSED )
2008-10-23 17:18:18 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2008-10-23 17:18:18 +04:00
2011-04-13 21:13:37 +04:00
if ( client - > domainEventCallbackID [ VIR_DOMAIN_EVENT_ID_LIFECYCLE ] < 0 ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " domain event %d not registered " ) , VIR_DOMAIN_EVENT_ID_LIFECYCLE ) ;
goto cleanup ;
2010-01-13 20:07:01 +03:00
}
2008-10-23 17:18:18 +04: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 17:56:56 +03:00
if ( virConnectDomainEventDeregisterAny ( conn ,
2011-04-13 21:23:00 +04:00
client - > domainEventCallbackID [ VIR_DOMAIN_EVENT_ID_LIFECYCLE ] ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-01-13 21:21:30 +03: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 17:56:56 +03:00
client - > domainEventCallbackID [ VIR_DOMAIN_EVENT_ID_LIFECYCLE ] = - 1 ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2008-10-23 17:18:18 +04:00
}
static void
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventSend ( struct qemud_client * client ,
int procnr ,
xdrproc_t proc ,
void * data )
2008-10-23 17:18:18 +04:00
{
2009-07-10 15:31:39 +04:00
struct qemud_client_message * msg = NULL ;
2008-10-23 17:18:18 +04:00
XDR xdr ;
2009-01-20 22:25:15 +03:00
unsigned int len ;
2008-10-23 17:18:18 +04:00
2009-07-10 15:31:39 +04:00
if ( VIR_ALLOC ( msg ) < 0 )
2008-10-23 17:18:18 +04:00
return ;
2009-07-10 15:31:39 +04:00
msg - > hdr . prog = REMOTE_PROGRAM ;
msg - > hdr . vers = REMOTE_PROTOCOL_VERSION ;
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 17:56:56 +03:00
msg - > hdr . proc = procnr ;
2009-07-10 16:02:08 +04:00
msg - > hdr . type = REMOTE_MESSAGE ;
2009-07-10 15:31:39 +04:00
msg - > hdr . serial = 1 ;
msg - > hdr . status = REMOTE_OK ;
2008-10-23 17:18:18 +04:00
2009-07-10 15:31:39 +04:00
if ( remoteEncodeClientMessageHeader ( msg ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2008-10-23 17:18:18 +04:00
2009-07-10 15:31:39 +04:00
/* Serialise the return header and event. */
2011-04-12 20:34:30 +04:00
xdrmem_create ( & xdr ,
msg - > buffer ,
msg - > bufferLength ,
XDR_ENCODE ) ;
2008-10-23 17:18:18 +04:00
2009-09-30 17:33:05 +04:00
/* Skip over the header we just wrote */
2011-04-12 20:34:30 +04:00
if ( xdr_setpos ( & xdr , msg - > bufferOffset ) = = 0 )
2011-04-13 19:21:35 +04:00
goto xdr_cleanup ;
2008-10-23 17:18:18 +04: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 17:56:56 +03:00
if ( ! ( proc ) ( & xdr , data ) ) {
VIR_WARN ( " Failed to serialize domain event %d " , procnr ) ;
2011-04-13 19:21:35 +04:00
goto xdr_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 17:56:56 +03:00
}
2008-10-23 17:18:18 +04:00
2009-09-30 17:33:05 +04:00
/* Update length word to include payload*/
2011-04-12 20:34:30 +04:00
len = msg - > bufferOffset = xdr_getpos ( & xdr ) ;
if ( xdr_setpos ( & xdr , 0 ) = = 0 )
2011-04-13 19:21:35 +04:00
goto xdr_cleanup ;
2008-10-23 17:18:18 +04:00
2011-04-12 20:34:30 +04:00
if ( ! xdr_u_int ( & xdr , & len ) )
2011-04-13 19:21:35 +04:00
goto xdr_cleanup ;
2008-10-23 17:18:18 +04:00
/* Send it. */
2009-01-20 22:25:15 +03:00
msg - > async = 1 ;
msg - > bufferLength = len ;
msg - > bufferOffset = 0 ;
2011-01-27 18:06:05 +03:00
VIR_DEBUG ( " Queue event %d %d " , procnr , msg - > bufferLength ) ;
2009-01-20 22:25:15 +03:00
qemudClientMessageQueuePush ( & client - > tx , msg ) ;
2009-07-10 15:48:50 +04:00
qemudUpdateClientEvent ( client ) ;
2009-07-10 15:31:39 +04:00
2011-04-12 20:34:30 +04:00
xdr_destroy ( & xdr ) ;
2009-07-10 15:31:39 +04:00
return ;
2011-04-13 19:21:35 +04:00
xdr_cleanup :
2009-07-10 15:31:39 +04:00
xdr_destroy ( & xdr ) ;
2011-04-13 19:21:35 +04:00
cleanup :
2009-07-10 15:31:39 +04:00
VIR_FREE ( msg ) ;
2008-10-23 17:18:18 +04:00
}
2008-11-21 15:31:04 +03:00
2009-07-28 06:01:00 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfSecrets ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
void * args ATTRIBUTE_UNUSED ,
remote_num_of_secrets_ret * ret )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfSecrets ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListSecrets ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_list_secrets_args * args ,
remote_list_secrets_ret * ret )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2009-07-28 06:01:00 +04:00
if ( args - > maxuuids > REMOTE_SECRET_UUID_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " ,
_ ( " maxuuids > REMOTE_SECRET_UUID_LIST_MAX " ) ) ;
goto cleanup ;
2009-07-28 06:01:00 +04:00
}
2011-04-12 20:34:30 +04:00
if ( VIR_ALLOC_N ( ret - > uuids . uuids_val , args - > maxuuids ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2009-07-28 06:01:00 +04:00
}
2011-04-13 21:13:37 +04:00
len = virConnectListSecrets ( conn , ret - > uuids . uuids_val ,
args - > maxuuids ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > uuids . uuids_len = len ;
2009-07-28 06:01:00 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > uuids . uuids_val ) ;
}
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretDefineXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_define_xml_args * args ,
remote_secret_define_xml_ret * ret )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
int rv = - 1 ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = virSecretDefineXML ( conn , args - > xml , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_secret ( & ret - > secret , secret ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretGetValue ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_get_value_args * args ,
remote_secret_get_value_ret * ret )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
2009-07-28 06:01:00 +04:00
size_t value_size ;
unsigned char * value ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = get_nonnull_secret ( conn , args - > secret ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( value = virSecretGetValue ( secret , & value_size , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
ret - > value . value_len = value_size ;
ret - > value . value_val = ( char * ) value ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretGetXmlDesc ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_get_xml_desc_args * args ,
remote_secret_get_xml_desc_ret * ret )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
int rv = - 1 ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = get_nonnull_secret ( conn , args - > secret ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virSecretGetXMLDesc ( secret , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretLookupByUuid ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_lookup_by_uuid_args * args ,
remote_secret_lookup_by_uuid_ret * ret )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
int rv = - 1 ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = virSecretLookupByUUID ( conn , ( unsigned char * ) args - > uuid ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_secret ( & ret - > secret , secret ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretSetValue ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_set_value_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
int rv = - 1 ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = get_nonnull_secret ( conn , args - > secret ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-12 20:34:30 +04:00
if ( virSecretSetValue ( secret , ( const unsigned char * ) args - > value . value_val ,
2011-04-13 21:23:00 +04:00
args - > value . value_len , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretUndefine ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_undefine_args * args ,
void * ret ATTRIBUTE_UNUSED )
2009-07-28 06:01:00 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
int rv = - 1 ;
2009-07-28 06:01:00 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = get_nonnull_secret ( conn , args - > secret ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:23:00 +04:00
if ( virSecretUndefine ( secret ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-07-28 06:01:00 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
2009-07-28 06:01:00 +04:00
}
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 17:06:15 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchSecretLookupByUsage ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2011-04-12 20:34:30 +04:00
remote_secret_lookup_by_usage_args * args ,
remote_secret_lookup_by_usage_ret * ret )
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 17:06:15 +04:00
{
2011-04-13 19:21:35 +04:00
virSecretPtr secret = NULL ;
int rv = - 1 ;
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 17:06:15 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( secret = virSecretLookupByUsage ( conn , args - > usageType , args - > usageID ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
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 17:06:15 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_secret ( & ret - > secret , secret ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( secret )
virSecretFree ( secret ) ;
return rv ;
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 17:06:15 +04:00
}
2009-07-28 06:01:00 +04: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 18:12:03 +04:00
static int remoteDispatchDomainIsActive ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_domain_is_active_args * args ,
remote_domain_is_active_ret * ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > active = virDomainIsActive ( domain ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( domain )
virDomainFree ( domain ) ;
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 18:12:03 +04:00
}
static int remoteDispatchDomainIsPersistent ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_domain_is_persistent_args * args ,
remote_domain_is_persistent_ret * ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > persistent = virDomainIsPersistent ( domain ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( domain )
virDomainFree ( domain ) ;
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 18:12:03 +04:00
}
2010-11-15 06:23:34 +03:00
static int remoteDispatchDomainIsUpdated ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2010-11-15 06:23:34 +03:00
remote_domain_is_updated_args * args ,
remote_domain_is_updated_ret * ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
int rv = - 1 ;
2010-11-15 06:23:34 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-11-15 06:23:34 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > updated = virDomainIsUpdated ( domain ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-11-15 06:23:34 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-11-15 06:23:34 +03: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 18:12:03 +04:00
static int remoteDispatchInterfaceIsActive ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_interface_is_active_args * args ,
remote_interface_is_active_ret * ret )
{
2011-04-13 19:21:35 +04:00
virInterfacePtr iface = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( iface = get_nonnull_interface ( conn , args - > iface ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > active = virInterfaceIsActive ( iface ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( iface )
virInterfaceFree ( iface ) ;
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 18:12:03 +04:00
}
static int remoteDispatchNetworkIsActive ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_network_is_active_args * args ,
remote_network_is_active_ret * ret )
{
2011-04-13 19:21:35 +04:00
virNetworkPtr network = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( network = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > active = virNetworkIsActive ( network ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( network )
virNetworkFree ( network ) ;
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 18:12:03 +04:00
}
static int remoteDispatchNetworkIsPersistent ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_network_is_persistent_args * args ,
remote_network_is_persistent_ret * ret )
{
2011-04-13 19:21:35 +04:00
virNetworkPtr network = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( network = get_nonnull_network ( conn , args - > net ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > persistent = virNetworkIsPersistent ( network ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( network )
virNetworkFree ( network ) ;
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 18:12:03 +04:00
}
static int remoteDispatchStoragePoolIsActive ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_storage_pool_is_active_args * args ,
remote_storage_pool_is_active_ret * ret )
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > active = virStoragePoolIsActive ( pool ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
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 18:12:03 +04:00
}
static int remoteDispatchStoragePoolIsPersistent ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
remote_storage_pool_is_persistent_args * args ,
remote_storage_pool_is_persistent_ret * ret )
{
2011-04-13 19:21:35 +04:00
virStoragePoolPtr pool = NULL ;
int rv = - 1 ;
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 18:12:03 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( pool = get_nonnull_storage_pool ( conn , args - > pool ) ) )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > persistent = virStoragePoolIsPersistent ( pool ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( pool )
virStoragePoolFree ( pool ) ;
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 18:12:03 +04:00
}
static int remoteDispatchIsSecure ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
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 18:12:03 +04:00
void * args ATTRIBUTE_UNUSED ,
remote_is_secure_ret * ret )
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ( ret - > secure = virConnectIsSecure ( conn ) ) < 0 )
2011-04-13 19:21:35 +04: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 18:12:03 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
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 18:12:03 +04:00
}
2009-12-18 17:49:34 +03:00
static int
remoteDispatchCpuCompare ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2009-12-18 17:49:34 +03:00
remote_cpu_compare_args * args ,
remote_cpu_compare_ret * ret )
{
int result ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2009-12-18 17:49:34 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ( result = virConnectCompareCPU ( conn , args - > xml , args - > flags ) ) = = VIR_CPU_COMPARE_ERROR )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2009-12-18 17:49:34 +03:00
ret - > result = result ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2009-12-18 17:49:34 +03:00
}
2010-02-02 16:39:05 +03:00
static int
remoteDispatchCpuBaseline ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
2011-04-13 18:49:09 +04:00
remote_error * rerr ,
2010-02-02 16:39:05 +03:00
remote_cpu_baseline_args * args ,
remote_cpu_baseline_ret * ret )
{
char * cpu ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-02-02 16:39:05 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( cpu = virConnectBaselineCPU ( conn ,
( const char * * ) args - > xmlCPUs . xmlCPUs_val ,
args - > xmlCPUs . xmlCPUs_len ,
args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-02-02 16:39:05 +03:00
ret - > cpu = cpu ;
2010-02-03 17:10:13 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2010-02-03 17:10:13 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetJobInfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_job_info_args * args ,
remote_domain_get_job_info_ret * ret )
2010-02-03 17:10:13 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2010-02-03 17:10:13 +03:00
virDomainJobInfo info ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-02-03 17:10:13 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-02-03 17:10:13 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainGetJobInfo ( dom , & info ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-02-03 17:10:13 +03:00
ret - > type = info . type ;
ret - > timeElapsed = info . timeElapsed ;
ret - > timeRemaining = info . timeRemaining ;
ret - > dataTotal = info . dataTotal ;
ret - > dataProcessed = info . dataProcessed ;
ret - > dataRemaining = info . dataRemaining ;
ret - > memTotal = info . memTotal ;
ret - > memProcessed = info . memProcessed ;
ret - > memRemaining = info . memRemaining ;
ret - > fileTotal = info . fileTotal ;
ret - > fileProcessed = info . fileProcessed ;
ret - > fileRemaining = info . fileRemaining ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-02-03 17:10:13 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-02-02 16:39:05 +03:00
}
2010-02-04 19:18:57 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainAbortJob ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_abort_job_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-02-04 19:18:57 +03:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-02-04 19:18:57 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-02-04 19:18:57 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainAbortJob ( dom ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-02-04 19:18:57 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-02-04 19:18:57 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-02-04 19:18:57 +03:00
}
2010-03-12 18:21:10 +03:00
static int
remoteDispatchDomainMigrateSetMaxDowntime ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_set_max_downtime_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-03-12 18:21:10 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-12 18:21:10 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainMigrateSetMaxDowntime ( dom , args - > downtime , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-02-17 17:26:14 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2011-02-17 17:26:14 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2011-02-17 17:26:14 +03:00
}
static int
remoteDispatchDomainMigrateSetMaxSpeed ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_migrate_set_max_speed_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
int rv = - 1 ;
2011-02-17 17:26:14 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-02-17 17:26:14 +03:00
2011-04-13 21:23:00 +04:00
if ( virDomainMigrateSetMaxSpeed ( dom , args - > bandwidth , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-12 18:21:10 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-03-12 18:21:10 +03:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-03-12 18:21:10 +03:00
}
2010-04-01 00:33:13 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSnapshotCreateXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_create_xml_args * args ,
remote_domain_snapshot_create_xml_ret * ret )
2010-04-01 00:33:13 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainSnapshotPtr snapshot = NULL ;
virDomainPtr domain = NULL ;
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( snapshot = virDomainSnapshotCreateXML ( domain , args - > xml_desc , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
make_nonnull_domain_snapshot ( & ret - > snap , snapshot ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( snapshot )
virDomainSnapshotFree ( snapshot ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSnapshotDumpXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_dump_xml_args * args ,
remote_domain_snapshot_dump_xml_ret * ret )
2010-04-01 00:33:13 +04:00
{
2010-04-23 19:57:16 +04:00
virDomainPtr domain = NULL ;
virDomainSnapshotPtr snapshot = NULL ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > snap . domain ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
if ( ! ( snapshot = get_nonnull_domain_snapshot ( domain , args - > snap ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virDomainSnapshotGetXMLDesc ( snapshot , args - > flags ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-23 19:57:16 +04:00
cleanup :
2011-04-13 19:21:35 +04:00
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
2010-04-23 19:57:16 +04:00
if ( snapshot )
2010-04-01 00:33:13 +04:00
virDomainSnapshotFree ( snapshot ) ;
2010-04-23 19:57:16 +04:00
if ( domain )
virDomainFree ( domain ) ;
2011-04-13 19:21:35 +04:00
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSnapshotNum ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_num_args * args ,
remote_domain_snapshot_num_ret * ret )
2010-04-01 00:33:13 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virDomainSnapshotNum ( domain , args - > flags ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSnapshotListNames ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_list_names_args * args ,
remote_domain_snapshot_list_names_ret * ret )
2010-04-01 00:33:13 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-04-01 00:33:13 +04:00
if ( args - > nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " ,
_ ( " nameslen > REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX " ) ) ;
goto cleanup ;
2010-04-01 00:33:13 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
/* Allocate return buffer. */
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > nameslen ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2010-04-01 00:33:13 +04:00
}
2011-04-13 21:13:37 +04:00
len = virDomainSnapshotListNames ( domain ,
ret - > names . names_val ,
args - > nameslen ,
args - > flags ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_val ) ;
}
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSnapshotLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_lookup_by_name_args * args ,
remote_domain_snapshot_lookup_by_name_ret * ret )
2010-04-01 00:33:13 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainSnapshotPtr snapshot = NULL ;
virDomainPtr domain = NULL ;
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( snapshot = virDomainSnapshotLookupByName ( domain , args - > name , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:34:30 +04:00
make_nonnull_domain_snapshot ( & ret - > snap , snapshot ) ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( snapshot )
virDomainSnapshotFree ( snapshot ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
remoteDispatchDomainHasCurrentSnapshot ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_has_current_snapshot_args * args ,
remote_domain_has_current_snapshot_ret * ret )
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
2010-04-01 00:33:13 +04:00
int result ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
result = virDomainHasCurrentSnapshot ( domain , args - > flags ) ;
2011-04-13 21:23:00 +04:00
if ( result < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
ret - > result = result ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
remoteDispatchDomainSnapshotCurrent ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_current_args * args ,
remote_domain_snapshot_current_ret * ret )
{
2011-04-13 19:21:35 +04:00
virDomainSnapshotPtr snapshot = NULL ;
virDomainPtr domain = NULL ;
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( snapshot = virDomainSnapshotCurrent ( domain , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
make_nonnull_domain_snapshot ( & ret - > snap , snapshot ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-01 00:33:13 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( snapshot )
virDomainSnapshotFree ( snapshot ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainRevertToSnapshot ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_revert_to_snapshot_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-04-01 00:33:13 +04:00
{
2010-04-23 19:57:16 +04:00
virDomainPtr domain = NULL ;
virDomainSnapshotPtr snapshot = NULL ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > snap . domain ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
if ( ! ( snapshot = get_nonnull_domain_snapshot ( domain , args - > snap ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 21:13:37 +04:00
if ( virDomainRevertToSnapshot ( snapshot , args - > flags ) < 0 )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-23 19:57:16 +04:00
cleanup :
2011-04-13 19:21:35 +04:00
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
2010-04-23 19:57:16 +04:00
if ( snapshot )
2010-04-01 00:33:13 +04:00
virDomainSnapshotFree ( snapshot ) ;
2010-04-23 19:57:16 +04:00
if ( domain )
virDomainFree ( domain ) ;
2011-04-13 19:21:35 +04:00
return rv ;
2010-04-01 00:33:13 +04:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainSnapshotDelete ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_snapshot_delete_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-04-01 00:33:13 +04:00
{
2010-04-23 19:57:16 +04:00
virDomainPtr domain = NULL ;
virDomainSnapshotPtr snapshot = NULL ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-04-01 00:33:13 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > snap . domain ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2011-04-13 21:50:40 +04:00
if ( ! ( snapshot = get_nonnull_domain_snapshot ( domain , args - > snap ) ) )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2010-04-01 00:33:13 +04:00
2011-04-13 21:13:37 +04:00
if ( virDomainSnapshotDelete ( snapshot , args - > flags ) < 0 )
2010-04-23 19:57:16 +04:00
goto cleanup ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-23 19:57:16 +04:00
cleanup :
2011-04-13 19:21:35 +04:00
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
2010-04-23 19:57:16 +04:00
if ( snapshot )
2010-04-01 00:33:13 +04:00
virDomainSnapshotFree ( snapshot ) ;
2010-04-23 19:57:16 +04:00
if ( domain )
virDomainFree ( domain ) ;
2011-04-13 19:21:35 +04:00
return rv ;
2010-04-01 00:33:13 +04:00
}
2010-03-12 18:21:10 +03: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 17:56:56 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventsRegisterAny ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ATTRIBUTE_UNUSED ,
remote_domain_events_register_any_args * args ,
void * ret ATTRIBUTE_UNUSED )
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 17:56:56 +03:00
{
int callbackID ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 17:56:56 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04: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 17:56:56 +03:00
if ( args - > eventID > = VIR_DOMAIN_EVENT_ID_LAST | |
args - > eventID < 0 ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " unsupported event ID %d " ) , args - > eventID ) ;
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 17:56:56 +03:00
}
if ( client - > domainEventCallbackID [ args - > eventID ] ! = - 1 ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " domain event %d already registered " ) , args - > eventID ) ;
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 17:56:56 +03:00
}
if ( ( callbackID = virConnectDomainEventRegisterAny ( conn ,
NULL ,
args - > eventID ,
domainEventCallbacks [ args - > eventID ] ,
2011-04-13 21:23:00 +04:00
client , NULL ) ) < 0 )
2011-04-13 19:21:35 +04: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 17:56:56 +03:00
client - > domainEventCallbackID [ args - > eventID ] = callbackID ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
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 17:56:56 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainEventsDeregisterAny ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ATTRIBUTE_UNUSED ,
remote_domain_events_deregister_any_args * args ,
void * ret ATTRIBUTE_UNUSED )
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 17:56:56 +03:00
{
int callbackID = - 1 ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 17:56:56 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04: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 17:56:56 +03:00
if ( args - > eventID > = VIR_DOMAIN_EVENT_ID_LAST | |
args - > eventID < 0 ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " unsupported event ID %d " ) , args - > eventID ) ;
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 17:56:56 +03:00
}
2011-04-13 21:50:40 +04:00
if ( ( callbackID = client - > domainEventCallbackID [ args - > eventID ] ) < 0 ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , _ ( " domain event %d not registered " ) , args - > eventID ) ;
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 17:56:56 +03:00
}
2011-04-13 21:23:00 +04:00
if ( virConnectDomainEventDeregisterAny ( conn , callbackID ) < 0 )
2011-04-13 19:21:35 +04: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 17:56:56 +03:00
client - > domainEventCallbackID [ args - > eventID ] = - 1 ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
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 17:56:56 +03:00
}
2010-03-25 20:46:03 +03:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNwfilterLookupByName ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_nwfilter_lookup_by_name_args * args ,
remote_nwfilter_lookup_by_name_ret * ret )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
virNWFilterPtr nwfilter = NULL ;
int rv = - 1 ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( nwfilter = virNWFilterLookupByName ( conn , args - > name ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_nwfilter ( & ret - > nwfilter , nwfilter ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( nwfilter )
virNWFilterFree ( nwfilter ) ;
return rv ;
2010-03-25 20:46:03 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNwfilterLookupByUuid ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_nwfilter_lookup_by_uuid_args * args ,
remote_nwfilter_lookup_by_uuid_ret * ret )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
virNWFilterPtr nwfilter = NULL ;
int rv = - 1 ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( nwfilter = virNWFilterLookupByUUID ( conn , ( unsigned char * ) args - > uuid ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_nwfilter ( & ret - > nwfilter , nwfilter ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( nwfilter )
virNWFilterFree ( nwfilter ) ;
return rv ;
2010-03-25 20:46:03 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNwfilterDefineXml ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_nwfilter_define_xml_args * args ,
remote_nwfilter_define_xml_ret * ret )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
virNWFilterPtr nwfilter = NULL ;
int rv = - 1 ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( nwfilter = virNWFilterDefineXML ( conn , args - > xml ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:34:30 +04:00
make_nonnull_nwfilter ( & ret - > nwfilter , nwfilter ) ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( nwfilter )
virNWFilterFree ( nwfilter ) ;
return rv ;
2010-03-25 20:46:03 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNwfilterUndefine ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_nwfilter_undefine_args * args ,
void * ret ATTRIBUTE_UNUSED )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
virNWFilterPtr nwfilter = NULL ;
int rv = - 1 ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( nwfilter = get_nonnull_nwfilter ( conn , args - > nwfilter ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-25 20:46:03 +03:00
2011-04-13 21:23:00 +04:00
if ( virNWFilterUndefine ( nwfilter ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( nwfilter )
virNWFilterFree ( nwfilter ) ;
return rv ;
2010-03-25 20:46:03 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchListNwfilters ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_list_nwfilters_args * args ,
remote_list_nwfilters_ret * ret )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-13 21:13:37 +04:00
int len ;
2011-04-13 19:21:35 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-03-25 20:46:03 +03:00
if ( args - > maxnames > REMOTE_NWFILTER_NAME_LIST_MAX ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR ,
" %s " , _ ( " maxnames > REMOTE_NWFILTER_NAME_LIST_MAX " ) ) ;
goto cleanup ;
2010-03-25 20:46:03 +03:00
}
/* Allocate return buffer. */
if ( VIR_ALLOC_N ( ret - > names . names_val , args - > maxnames ) < 0 ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2010-03-25 20:46:03 +03:00
}
2011-04-13 21:13:37 +04:00
len = virConnectListNWFilters ( conn ,
ret - > names . names_val , args - > maxnames ) ;
2011-04-13 21:23:00 +04:00
if ( len < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2011-04-13 21:13:37 +04:00
ret - > names . names_len = len ;
2010-03-25 20:46:03 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 ) {
remoteDispatchError ( rerr ) ;
VIR_FREE ( ret - > names . names_len ) ;
}
return rv ;
2010-03-25 20:46:03 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNwfilterGetXmlDesc ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_nwfilter_get_xml_desc_args * args ,
remote_nwfilter_get_xml_desc_ret * ret )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
virNWFilterPtr nwfilter = NULL ;
int rv = - 1 ;
2010-03-25 20:46:03 +03:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( nwfilter = get_nonnull_nwfilter ( conn , args - > nwfilter ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-25 20:46:03 +03:00
/* remoteDispatchClientRequest will free this. */
2011-04-13 21:50:40 +04:00
if ( ! ( ret - > xml = virNWFilterGetXMLDesc ( nwfilter , args - > flags ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( nwfilter )
virNWFilterFree ( nwfilter ) ;
return rv ;
2010-03-25 20:46:03 +03:00
}
static int
2011-04-12 20:34:30 +04:00
remoteDispatchNumOfNwfilters ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
void * args ATTRIBUTE_UNUSED ,
remote_num_of_nwfilters_ret * ret )
2010-03-25 20:46:03 +03:00
{
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-03-25 20:46:03 +03:00
2011-04-13 21:50:40 +04:00
if ( ( ret - > num = virConnectNumOfNWFilters ( conn ) ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-03-25 20:46:03 +03:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
return rv ;
2010-03-25 20:46:03 +03:00
}
2010-04-27 23:29:15 +04:00
static int
2011-04-12 20:34:30 +04:00
remoteDispatchDomainGetBlockInfo ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
remote_domain_get_block_info_args * args ,
remote_domain_get_block_info_ret * ret )
2010-04-27 23:29:15 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr dom = NULL ;
2010-04-27 23:29:15 +04:00
virDomainBlockInfo info ;
2011-04-13 19:21:35 +04:00
int rv = - 1 ;
2010-04-27 23:29:15 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > dom ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-27 23:29:15 +04:00
2011-04-13 21:23:00 +04:00
if ( virDomainGetBlockInfo ( dom , args - > path , & info , args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-27 23:29:15 +04:00
ret - > capacity = info . capacity ;
ret - > allocation = info . allocation ;
ret - > physical = info . physical ;
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-27 23:29:15 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-04-27 23:29:15 +04:00
}
2010-04-17 06:09:25 +04:00
static int
2011-04-12 20:34:30 +04:00
qemuDispatchMonitorCommand ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ATTRIBUTE_UNUSED ,
virConnectPtr conn ,
remote_message_header * hdr ATTRIBUTE_UNUSED ,
remote_error * rerr ,
qemu_monitor_command_args * args ,
qemu_monitor_command_ret * ret )
2010-04-17 06:09:25 +04:00
{
2011-04-13 19:21:35 +04:00
virDomainPtr domain = NULL ;
int rv = - 1 ;
2010-04-17 06:09:25 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2011-04-13 21:50:40 +04:00
if ( ! ( domain = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-17 06:09:25 +04:00
if ( virDomainQemuMonitorCommand ( domain , args - > cmd , & ret - > result ,
2011-04-13 21:23:00 +04:00
args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-04-17 06:09:25 +04:00
2011-04-13 19:21:35 +04:00
rv = 0 ;
2010-04-17 06:09:25 +04:00
2011-04-13 19:21:35 +04:00
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( domain )
virDomainFree ( domain ) ;
return rv ;
2010-04-17 06:09:25 +04:00
}
2010-04-27 23:29:15 +04:00
2010-07-23 16:57:14 +04:00
static int
remoteDispatchDomainOpenConsole ( struct qemud_server * server ATTRIBUTE_UNUSED ,
struct qemud_client * client ,
virConnectPtr conn ,
remote_message_header * hdr ,
remote_error * rerr ,
remote_domain_open_console_args * args ,
void * ret ATTRIBUTE_UNUSED )
{
2011-04-13 19:21:35 +04:00
struct qemud_client_stream * stream = NULL ;
virDomainPtr dom = NULL ;
int rv = - 1 ;
2010-07-23 16:57:14 +04:00
2011-04-12 20:33:49 +04:00
if ( ! conn ) {
2011-04-13 19:21:35 +04:00
virNetError ( VIR_ERR_INTERNAL_ERROR , " %s " , _ ( " connection not open " ) ) ;
goto cleanup ;
2011-04-12 20:33:49 +04:00
}
2010-07-23 16:57:14 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( dom = get_nonnull_domain ( conn , args - > domain ) ) )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-07-23 16:57:14 +04:00
2011-04-13 21:50:40 +04:00
if ( ! ( stream = remoteCreateClientStream ( conn , hdr ) ) ) {
2011-04-13 19:21:35 +04:00
virReportOOMError ( ) ;
goto cleanup ;
2010-07-23 16:57:14 +04:00
}
2011-04-13 21:50:40 +04:00
if ( virDomainOpenConsole ( dom ,
2010-07-23 16:57:14 +04:00
args - > devname ? * args - > devname : NULL ,
stream - > st ,
2011-04-13 21:50:40 +04:00
args - > flags ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
2010-07-23 16:57:14 +04:00
2011-04-13 21:23:00 +04:00
if ( remoteAddClientStream ( client , stream , 1 ) < 0 )
2011-04-13 19:21:35 +04:00
goto cleanup ;
rv = 0 ;
cleanup :
if ( rv < 0 )
remoteDispatchError ( rerr ) ;
if ( stream & & rv < 0 ) {
2010-07-23 16:57:14 +04:00
virStreamAbort ( stream - > st ) ;
remoteFreeClientStream ( client , stream ) ;
}
2011-04-13 19:21:35 +04:00
if ( dom )
virDomainFree ( dom ) ;
return rv ;
2010-07-23 16:57:14 +04:00
}
2007-06-11 15:47:01 +04: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 20:34:30 +04:00
get_nonnull_domain ( virConnectPtr conn , remote_nonnull_domain domain )
2007-06-11 15:47:01 +04:00
{
virDomainPtr dom ;
2011-04-12 20:34:30 +04:00
dom = virGetDomain ( conn , domain . name , BAD_CAST domain . uuid ) ;
2007-06-11 15:47:01 +04: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 20:34:30 +04:00
get_nonnull_network ( virConnectPtr conn , remote_nonnull_network network )
2007-06-11 15:47:01 +04:00
{
2011-04-12 20:34:30 +04:00
return virGetNetwork ( conn , network . name , BAD_CAST network . uuid ) ;
2007-06-11 15:47:01 +04:00
}
2009-05-20 18:26:49 +04:00
static virInterfacePtr
2011-04-12 20:34:30 +04:00
get_nonnull_interface ( virConnectPtr conn , remote_nonnull_interface iface )
2009-05-20 18:26:49 +04:00
{
2011-04-12 20:34:30 +04:00
return virGetInterface ( conn , iface . name , iface . mac ) ;
2009-05-20 18:26:49 +04:00
}
2008-02-20 18:22:35 +03:00
static virStoragePoolPtr
2011-04-12 20:34:30 +04:00
get_nonnull_storage_pool ( virConnectPtr conn , remote_nonnull_storage_pool pool )
2008-02-20 18:22:35 +03:00
{
2011-04-12 20:34:30 +04:00
return virGetStoragePool ( conn , pool . name , BAD_CAST pool . uuid ) ;
2008-02-20 18:22:35 +03:00
}
static virStorageVolPtr
2011-04-12 20:34:30 +04:00
get_nonnull_storage_vol ( virConnectPtr conn , remote_nonnull_storage_vol vol )
2008-02-20 18:22:35 +03:00
{
virStorageVolPtr ret ;
2011-04-12 20:34:30 +04:00
ret = virGetStorageVol ( conn , vol . pool , vol . name , vol . key ) ;
2008-02-20 18:22:35 +03:00
return ret ;
}
2009-07-28 06:01:00 +04:00
static virSecretPtr
2011-04-12 20:34:30 +04:00
get_nonnull_secret ( virConnectPtr conn , remote_nonnull_secret secret )
2009-07-28 06:01:00 +04:00
{
2011-04-12 20:34:30 +04:00
return virGetSecret ( conn , BAD_CAST secret . uuid , secret . usageType , secret . usageID ) ;
2009-07-28 06:01:00 +04:00
}
2010-03-25 20:46:03 +03:00
static virNWFilterPtr
2011-04-12 20:34:30 +04:00
get_nonnull_nwfilter ( virConnectPtr conn , remote_nonnull_nwfilter nwfilter )
2010-03-25 20:46:03 +03:00
{
2011-04-12 20:34:30 +04:00
return virGetNWFilter ( conn , nwfilter . name , BAD_CAST nwfilter . uuid ) ;
2010-03-25 20:46:03 +03:00
}
2010-04-01 00:33:13 +04:00
static virDomainSnapshotPtr
2011-04-12 20:34:30 +04:00
get_nonnull_domain_snapshot ( virDomainPtr domain , remote_nonnull_domain_snapshot snapshot )
2010-04-01 00:33:13 +04:00
{
return virGetDomainSnapshot ( domain , snapshot . name ) ;
}
2007-06-11 15:47:01 +04:00
/* Make remote_nonnull_domain and remote_nonnull_network. */
static void
2011-04-12 20:34:30 +04:00
make_nonnull_domain ( remote_nonnull_domain * dom_dst , virDomainPtr dom_src )
2007-06-11 15:47:01 +04:00
{
dom_dst - > id = dom_src - > id ;
2011-04-12 20:34:30 +04:00
dom_dst - > name = strdup ( dom_src - > name ) ;
memcpy ( dom_dst - > uuid , dom_src - > uuid , VIR_UUID_BUFLEN ) ;
2007-06-11 15:47:01 +04:00
}
static void
2011-04-12 20:34:30 +04:00
make_nonnull_network ( remote_nonnull_network * net_dst , virNetworkPtr net_src )
2007-06-11 15:47:01 +04:00
{
2011-04-12 20:34:30 +04:00
net_dst - > name = strdup ( net_src - > name ) ;
memcpy ( net_dst - > uuid , net_src - > uuid , VIR_UUID_BUFLEN ) ;
2007-06-11 15:47:01 +04:00
}
2009-05-20 18:26:49 +04:00
static void
2011-04-12 20:34:30 +04:00
make_nonnull_interface ( remote_nonnull_interface * interface_dst ,
virInterfacePtr interface_src )
2009-05-20 18:26:49 +04:00
{
2011-04-12 20:34:30 +04:00
interface_dst - > name = strdup ( interface_src - > name ) ;
interface_dst - > mac = strdup ( interface_src - > mac ) ;
2009-05-20 18:26:49 +04:00
}
2008-02-20 18:22:35 +03:00
static void
2011-04-12 20:34:30 +04:00
make_nonnull_storage_pool ( remote_nonnull_storage_pool * pool_dst , virStoragePoolPtr pool_src )
2008-02-20 18:22:35 +03:00
{
2011-04-12 20:34:30 +04:00
pool_dst - > name = strdup ( pool_src - > name ) ;
memcpy ( pool_dst - > uuid , pool_src - > uuid , VIR_UUID_BUFLEN ) ;
2008-02-20 18:22:35 +03:00
}
static void
2011-04-12 20:34:30 +04:00
make_nonnull_storage_vol ( remote_nonnull_storage_vol * vol_dst , virStorageVolPtr vol_src )
2008-02-20 18:22:35 +03:00
{
2011-04-12 20:34:30 +04: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 18:22:35 +03:00
}
2008-11-21 15:31:04 +03:00
static void
2011-04-12 20:34:30 +04:00
make_nonnull_node_device ( remote_nonnull_node_device * dev_dst , virNodeDevicePtr dev_src )
2008-11-21 15:31:04 +03:00
{
dev_dst - > name = strdup ( dev_src - > name ) ;
}
2009-07-28 06:01:00 +04:00
static void
2011-04-12 20:34:30 +04:00
make_nonnull_secret ( remote_nonnull_secret * secret_dst , virSecretPtr secret_src )
2009-07-28 06:01:00 +04:00
{
2011-04-12 20:34:30 +04: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 17:06:15 +04:00
secret_dst - > usageType = secret_src - > usageType ;
2011-04-12 20:34:30 +04:00
secret_dst - > usageID = strdup ( secret_src - > usageID ) ;
2009-07-28 06:01:00 +04:00
}
2010-03-25 20:46:03 +03:00
static void
2011-04-12 20:34:30 +04:00
make_nonnull_nwfilter ( remote_nonnull_nwfilter * nwfilter_dst , virNWFilterPtr nwfilter_src )
2010-03-25 20:46:03 +03:00
{
2011-04-12 20:34:30 +04:00
nwfilter_dst - > name = strdup ( nwfilter_src - > name ) ;
memcpy ( nwfilter_dst - > uuid , nwfilter_src - > uuid , VIR_UUID_BUFLEN ) ;
2010-03-25 20:46:03 +03:00
}
2010-04-01 00:33:13 +04:00
static void
2011-04-12 20:34:30 +04:00
make_nonnull_domain_snapshot ( remote_nonnull_domain_snapshot * snapshot_dst , virDomainSnapshotPtr snapshot_src )
2010-04-01 00:33:13 +04:00
{
snapshot_dst - > name = strdup ( snapshot_src - > name ) ;
make_nonnull_domain ( & snapshot_dst - > domain , snapshot_src - > domain ) ;
}