Commit Graph

189 Commits

Author SHA1 Message Date
Matthias Bolte
9de503f957 remote generator, client: Handle functions with simple return values 2011-05-06 20:27:18 +02:00
Matthias Bolte
f68bb4edb3 remote generator, client: Handle simple remote driver functions
Rename remoteSecretListSecrets to remoteListSecrets to match the normal
naming pattern.
2011-05-06 20:26:21 +02:00
Matthias Bolte
6384104bcc remote generator, daemon: Handle functions with multiple return values
Once again rename members in the XDR definitions to avoid special case
code in the generator.
2011-05-06 20:08:36 +02:00
Matthias Bolte
705519d8e9 remote: Rename 'nameslen' to the common 'maxnames'
Avoids special case handling in the remote generator.
2011-05-06 20:08:25 +02:00
Matthias Bolte
37cb0882b5 remote: Replace 'domain' with 'dom' in the XDR protocol
This simplifies the remote protocol code generator.

Also rename 'ret' to 'result' to resolve a naming conflict in the
generator.
2011-05-06 20:05:00 +02:00
Doug Goldstein
db36449fd6 remote: check actual access to the cert
Instead of calling stat(), check that we'll actually be able to access
and read the file.

Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
2011-05-06 10:38:14 -06:00
Doug Goldstein
1945d74cc3 virsh: improve TLS certificate error messages
Print the name of the CA cert, certificate, and key file that resulted
in the failure so that the user has an idea what to troubleshoot.

Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
2011-05-05 17:16:58 -06:00
Matthias Bolte
60d769a13a Remove virConnectPtr from virRaiseErrorFull
And from all related macros and functions.
2011-04-17 07:22:23 +02:00
Michal Privoznik
50e4b9195d Fix possible infinite loop in remote driver
When we take out completed calls from queue we might end up
in circular pointer. We don't want pointer to previous item
point to element taken out.
2011-04-12 09:18:40 -06:00
Eric Blake
99fa30804b maint: fix grammar errors
Jim Meyering recently improved gnulib to catch various grammar
errors during 'make syntax-check'.

* .gnulib: Update to latest, for syntax-check improvements.
* include/libvirt/libvirt.h.in (virConnectAuthCallbackPtr): Use
cannot rather than two words.
* src/driver.c: Likewise.
* src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): Likewise.
* src/remote/remote_driver.c (initialize_gnutls): Likewise.
* src/util/pci.c (pciBindDeviceToStub): Likewise.
* src/storage/storage_backend.c (virStorageBackendCreateQemuImg):
Likewise.
(virStorageBackendUpdateVolTargetInfoFD): Avoid doubled word.
* docs/formatdomain.html.in: Likewise.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_can_not)
(exclude_file_name_regexp--sc_prohibit_doubled_word): Exclude
existing translation problems.
2011-04-12 09:06:14 -06:00
Matthias Bolte
0e27b8a856 sasl: Remove stack allocated 8kb temporary buffers
Move the buffers to the heap allocated client/private data structs.
2011-04-05 08:55:27 +02:00
Eric Blake
0d166c6b7c build: detect potentential uninitialized variables
Even with -Wuninitialized (which is part of autobuild.sh
--enable-compile-warnings=error), gcc does NOT catch this
use of an uninitialized variable:

{
  if (cond)
    goto error;
  int a = 1;
error:
  printf("%d", a);
}

which prints 0 (supposing the stack started life wiped) if
cond was true.  Clang will catch it, but we don't use clang
as often.  Using gcc -Wjump-misses-init catches it, but also
gives false positives:

{
  if (cond)
    goto error;
  int a = 1;
  return a;
error:
  return 0;
}

Here, a was never used in the scope of the error block, so
declaring it after goto is technically fine (and clang agrees).
However, given that our HACKING already documents a preference
to C89 decl-before-statement, the false positive warning is
enough of a prod to comply with HACKING.

[Personally, I'd _really_ rather use C99 decl-after-statement
to minimize scope, but until gcc can efficiently and reliably
catch scoping and uninitialized usage bugs, I'll settle with
the compromise of enforcing a coding standard that happens to
reject false positives if it can also detect real bugs.]

* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add -Wjump-misses-init.
* src/util/util.c (__virExec): Adjust offenders.
* src/conf/domain_conf.c (virDomainTimerDefParseXML): Likewise.
* src/remote/remote_driver.c (doRemoteOpen): Likewise.
* src/phyp/phyp_driver.c (phypGetLparNAME, phypGetLparProfile)
(phypGetVIOSFreeSCSIAdapter, phypVolumeGetKey)
(phypGetStoragePoolDevice)
(phypVolumeGetPhysicalVolumeByStoragePool)
(phypVolumeGetPath): Likewise.
* src/vbox/vbox_tmpl.c (vboxNetworkUndefineDestroy)
(vboxNetworkCreate, vboxNetworkDumpXML)
(vboxNetworkDefineCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject)
(xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/security/security_selinux.c (SELinuxGenNewContext):
Likewise.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetPtyPaths):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainShutdown)
(qemudDomainBlockStats, qemudDomainMemoryPeek): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendCreateIfaceIQN): Likewise.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
2011-04-04 11:26:29 -06:00
Daniel P. Berrange
230a5d8b4a Remote protocol support for storage vol upload/download APIs
* daemon/remote.c, src/remote/remote_driver.c: Implementation
  of storage vol upload/download APIs
* src/remote/remote_protocol.x: Wire protocol definition for
  upload/download
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_table.h, src/remote/remote_protocol.h,
  src/remote/remote_protocol.c: Re-generate
2011-03-29 12:17:52 +01:00
Matthias Bolte
4cb5044dcb remote: Don't leak gnutls session on negotiation error 2011-03-26 16:43:44 +01:00
Eric Blake
391c397e48 maint: prohibit access(,X_OK)
This simplifies several callers that were repeating checks already
guaranteed by util.c, and makes other callers more robust to now
reject directories.  remote_driver.c was over-strict - access(,R_OK)
is only needed to execute a script file; a binary only needs
access(,X_OK) (besides, it's unusual to see a file with x but not
r permissions, whether script or binary).

* cfg.mk (sc_prohibit_access_xok): New syntax-check rule.
(exclude_file_name_regexp--sc_prohibit_access_xok): Exempt one use.
* src/network/bridge_driver.c (networkStartRadvd): Fix offenders.
* src/qemu/qemu_capabilities.c (qemuCapsProbeMachineTypes)
(qemuCapsInitGuest, qemuCapsInit, qemuCapsExtractVersionInfo):
Likewise.
* src/remote/remote_driver.c (remoteFindDaemonPath): Likewise.
* src/uml/uml_driver.c (umlStartVMDaemon): Likewise.
* src/util/hooks.c (virHookCheck): Likewise.
2011-03-24 15:18:44 -06:00
Daniel P. Berrange
118dd7d06e Wire up virDomainMigrateSetSpeed for the remote RPC driver
* src/remote/remote_protocol.x: Define wire protocol
* daemon/remote.c, src/remote/remote_driver.c: Add new
  functions for virDomainMigrateSetSpeed API
* src/remote/remote_protocol.c, src/remote/remote_protocol.h,
  daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_table.h: Re-generate files
2011-03-22 15:53:08 +00:00
Daniel P. Berrange
cb4aba9b6a Add public API for setting migration speed on the fly
It is possible to set a migration speed limit when starting
migration. This new API allows the speed limit to be changed
on the fly to adjust to changing conditions

* src/driver.h, src/libvirt.c, src/libvirt_public.syms,
  include/libvirt/libvirt.h.in: Add virDomainMigrateSetMaxSpeed
* src/esx/esx_driver.c, src/lxc/lxc_driver.c,
  src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/vmware/vmware_driver.c, src/xen/xen_driver.c,
  src/libxl/libxl_driver.c: Stub new API
2011-03-22 15:53:08 +00:00
Wen Congyang
3c2b210a3c do not report OOM error when prepareCall() failed
We have reported error in the function prepareCall(), and
the error is not only OOM error. So we should not report
OOM error in the function call() when prepareCall() failed.
2011-03-21 09:28:25 -06:00
Daniel P. Berrange
635523f74a Fix delayed event delivery when SASL is active
When SASL is active, it was possible that we read and decoded
more data off the wire than we initially wanted. The loop
processing this data terminated after only one message to
avoid delaying the calling thread, but this could delay
event delivery. As long as there is decoded SASL data in
memory, we must process it, before returning to the poll()
event loop.

This is a counterpart to the same kind of issue solved in

  commit 68d2c3482f

in a different area of the code

* src/remote/remote_driver.c: Process all pending SASL data
2011-03-18 16:47:46 +00:00
Matthias Bolte
55fb386671 remote: Add missing virCondDestroy calls
The virCond of the remote_thread_call struct was leaked in some
places. This results in leaking the underlying mutex. Which in turn
leaks a handle on Windows.

Reported by Aliaksandr Chabatar and Ihar Smertsin.
2011-03-17 17:51:33 +01:00
Gui Jianfeng
5f4a48cbdf remote-protocol: implement new BlkioParameters API
Remote protocol implementation of virDomainSetBlkioParameters and virDomainGetBlkioParameters.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
2011-03-10 17:54:12 -07:00
Gui Jianfeng
d55aa8694e libvirt: implements virDomain{Get,Set}BlkioParameters
Implements virDomainSetBlkioParameters and virDomainGetBlkioParameters and initialization

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
2011-03-10 17:53:33 -07:00
Taku Izumi
55141abf9d setmem: implement the remote protocol to address the new API
This patch implements the remote protocol to address the new API.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2011-03-10 15:02:58 -07:00
Taku Izumi
e8340a8b79 setmem: introduce a new libvirt API (virDomainSetMemoryFlags)
This patch introduces a new libvirt API (virDomainSetMemoryFlags) and
a flag (virDomainMemoryModFlags).

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2011-03-10 15:02:58 -07:00
Phil Petty
5a81401235 fixes for several memory leaks
Signed-off-by: Eric Blake <eblake@redhat.com>
2011-03-04 09:52:12 -07:00
Daniel P. Berrange
6a8ef183be add additional event debug points
Followup to commit 2222bd24
2011-03-01 16:54:20 -07:00
Eric Blake
994e7567b6 maint: kill all remaining uses of old DEBUG macro
Done mechanically with:
$ git grep -l '\bDEBUG0\? *(' | xargs -L1 sed -i 's/\bDEBUG0\? *(/VIR_&/'

followed by manual deletion of qemudDebug in daemon/libvirtd.c, along
with a single 'make syntax-check' fallout in the same file, and the
actual deletion in src/util/logging.h.

* src/util/logging.h (DEBUG, DEBUG0): Delete.
* daemon/libvirtd.h (qemudDebug): Likewise.
* global: Change remaining clients over to VIR_DEBUG counterpart.
2011-02-21 08:46:52 -07:00
Daniel P. Berrange
2222bd2459 Add a little more debugging for async events
To make it easier to investigate problems with async event
delivery, add two more debugging lines

* daemon/remote.c: Debug when an event is queued for dispatch
* src/remote/remote_driver.c: Debug when an event is received
  for processing
2011-02-09 16:45:05 +00:00
Eric Blake
5c8dedddcc sysinfo: implement the remote protocol
Done by editing the first three files, then running
'make -C src rpcgen', then editing src/remote_protocol-structs
to match.

* daemon/remote.c (remoteDispatchGetSysinfo): New function.
* src/remote/remote_driver.c (remoteGetSysinfo, remote_driver):
Client side serialization.
* src/remote/remote_protocol.x (remote_get_sysinfo_args)
(remote_get_sysinfo_ret): New types.
(REMOTE_PROC_GET_SYSINFO): New enum value.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_ret.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.
2011-02-08 19:29:46 -07:00
Eric Blake
dec13a5a15 sysinfo: define internal driver API
* src/driver.h (virDrvGetSysinfo): New typedef.
(_virDriver): New callback member.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/vmware/vmware_driver.c (vmwareDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
2011-02-08 19:25:30 -07:00
Daniel Veillard
3028f51c38 Fix compilation when building without sasl
Use of saslDecoded field need to be guarded by #if HAVE_SASL/endif
* src/remote/remote_driver.c: fix remoteIOEventLoop accordingly
2011-02-03 22:13:24 +08:00
Daniel P. Berrange
68d2c3482f Don't sleep in poll() if there is existing SASL decoded data
In the SASL codepath we typically read far more data off the
wire than we immediately need. When using a connection from a
single thread this isn't a problem, since only our reply will
be pending (or an event we can handle directly). When using a
connection from multiple threads though, we may read the data
from replies from other threads. If those replies occur after
our own reply, they'll not be processed. The other thread will
then go into poll() and wait for its reply which has already
been received and decoded. The solution is to set poll() timeout
to 0 if there is pending SASL data.

* src/remote/remote_driver.c: Don't sleep in poll() if SASL
  data exists
2011-02-02 10:59:55 +00:00
Matthias Bolte
dc52cab126 Prefer C style comments over C++ ones
Pure cosmetic change.
2011-01-29 00:59:45 +01:00
Osier Yang
31242565ae remote: Add extra parameter pkipath for URI
This new parameter allows user specifies where the client
cerficate, client key, CA certificate of x509 is, instead of
hardcoding it. If 'pkipath' is not specified, and the user
is not root, try to find files in $HOME/.pki/libvirt, as long
as one of client cerficate, client key, CA certificate can
not be found, use default global location (LIBVIRT_CACERT,
LIBVIRT_CLIENTCERT, LIBVIRT_CLIENTKEY, see
src/remote/remote_driver.h)

Example of use:

[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
error: Cannot access CA certificate '/tmp/pki/client/cacert.pem': No such file
or directory
error: failed to connect to the hypervisor
[root@Osier client]# ls -l
total 24
-rwxrwxr-x. 1 root root 6424 Jan 24 21:35 a.out
-rw-r--r--. 1 root root 1245 Jan 23 19:04 clientcert.pem
-rw-r--r--. 1 root root  132 Jan 23 19:04 client.info
-rw-r--r--. 1 root root 1679 Jan 23 19:04 clientkey.pem

[root@Osier client]# cp /tmp/cacert.pem .
[root@Osier client]# virsh -c qemu+tls://10.66.93.111/system?pkipath=/tmp/pki/client
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
'quit' to quit

virsh #

* src/remote/remote_driver.c: adds support for the new pkipath URI parameter
2011-01-27 16:34:54 +08:00
Cole Robinson
1dd5c7f2df remote: Don't lose track of events when callbacks are slow
After the remote driver runs an event callback, it unconditionally disables the
loop timer, thinking it just flushed every queued event. This doesn't work
correctly though if an event is queued while a callback is running.

The events actually aren't being lost, it's just that the event loop didn't
think there was anything that needed to be dispatched. So all those 'lost
events' should actually get re-triggered if you manually kick the loop by
generating a new event (like creating a new guest).

The solution is to disable the dispatch timer _before_ we invoke any event
callbacks. Events queued while a callback is running will properly reenable the
timer.

More info at https://bugzilla.redhat.com/show_bug.cgi?id=624252
2011-01-10 14:44:03 -05:00
Eric Blake
2deb32ae02 virterror: avoid API breakage with vmware
Fix glitch in commit cddd2a06 (thankfully post-0.8.6, so no
released version has the glitch).

Document and try to workaround glitch in commit 46e9b0f (in 0.8.0),
which invalidated 6 virErrorNumber values dating as far back as 0.7.1.

My audit did not find any other glitches until pre-0.1.0 days.  I'm
not sure how to add a syntax-check off the top of my head, but
hopefully the explicit numbering will make people think twice about
renumbering in the future.

* include/libvirt/virterror.h (virErrorDomain): Avoid inserting
new values in the middle, and add explicit numbering to help avoid
this in the future.
(virErrorNumber): Add explicit numbering, and document the snafu.
* src/remote/remote_driver.c (remoteIO): Compensate for the snafu.
2010-12-22 09:09:04 -07:00
Eric Blake
65c0f17acd build: update gnulib for pipe on mingw
* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import pipe-posix and waitpid
for mingw.
* src/remote/remote_driver.c (pipe) [WIN32]: Drop dead macro.
* daemon/event.c (pipe) [WIN32]: Drop dead function.
2010-12-13 16:09:50 -07:00
Osier Yang
313215e15f implement the remote protocol
* daemon/remote.c
* daemon/remote_dispatch_args.h
* daemon/remote_dispatch_prototypes.h
* daemon/remote_dispatch_ret.h
* daemon/remote_dispatch_table.h
* src/remote/remote_driver.c
* src/remote/remote_protocol.c
* src/remote/remote_protocol.h
* src/remote/remote_protocol.x
* src/remote_protocol-structs
2010-11-23 15:04:42 -07:00
Osier Yang
37a02efd71 define internal driver API
* src/driver.h (new typedef, new callback member for "_virDriver")
* src/esx/esx_driver.c
* src/lxc/lxc_driver.c
* src/opennebula/one_driver.c
* src/openvz/openvz_driver.c
* src/phyp/phyp_driver.c
* src/qemu/qemu_driver.c
* src/remote/remote_driver.c
* src/test/test_driver.c
* src/uml/uml_driver.c
* src/vbox/vbox_tmpl.c
* src/xen/xen_driver.c
* src/xenapi/xenapi_driver.c
2010-11-23 15:04:41 -07:00
Matthias Bolte
9abe1e4358 remote: Fix TLS transport on Windows
gnulib wraps Windows' SOCKET handle based send() and recv() functions
into file descriptor based ones that are used in libvirt.

Even though GnuTLS is using gnulib too, it explicitly doesn't use
gnulib's replacement functions on Windows. By default GnuTLS uses the
SOCKET handle based send() and recv(). This makes gnutls_handshake()
fail internally with a WSAENOTSOCK error because libvirt passes a
file descriptor; GnuTLS needs the SOCKET handle.

To avoid this mismatch make sure that GnuTLS uses gnulib's replacment
functions, by setting custom pull() and push() functions for GnuTLS.
2010-11-23 18:31:42 +01:00
Laine Stump
45dc5a142f remote_driver.c: fix non-literal format strings w/o args 2010-11-11 12:05:21 -05:00
Daniel P. Berrange
4ef40df13d Lower logging level in remote driver streams
Now that bi-directional, non-blocking streams are supported
in the remote driver, some of the VIR_WARN statements need
to be reduced to VIR_DEBUG.

* src/remote/remote_driver.c: Lower logging level
2010-11-11 16:02:52 +00:00
Daniel P. Berrange
73d8b03cda Remote driver client and server for virDomainOpenConsole
This provides an implementation of the virDomainOpenConsole
API for the remote driver client and server.

* daemon/remote.c: Server side impl
* src/remote/remote_driver.c: Client impl
* src/remote/remote_protocol.x: Wire definition
2010-11-11 16:02:46 +00:00
Daniel P. Berrange
88a9b382c6 Introduce a virDomainOpenConsole API
To enable virsh console (or equivalent) to be used remotely
it is necessary to provide remote access to the /dev/pts/XXX
pseudo-TTY associated with the console/serial/parallel device
in the guest. The virStream API provide a bi-directional I/O
stream capability that can be used for this purpose. This
patch thus introduces a virDomainOpenConsole API that uses
the stream APIs.

* src/libvirt.c, src/libvirt_public.syms,
  include/libvirt/libvirt.h.in, src/driver.h: Define the
  new virDomainOpenConsole API
* src/esx/esx_driver.c, src/lxc/lxc_driver.c,
  src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub
  API entry point
2010-11-11 16:02:41 +00:00
Daniel P. Berrange
5126926548 Support callbacks on virStream APIs in remote driver client
The current remote driver code for streams only supports
blocking I/O mode. This is fine for the usage with migration
but is a problem for more general use cases, in particular
bi-directional streams.

This adds supported for the stream callbacks and non-blocking
I/O. with the minor caveat is that it doesn't actually do
non-blocking I/O for sending stream data, only receiving it.
A future patch will try to do non-blocking sends, but this is
quite tricky to get right.

* src/remote/remote_driver.c: Allow non-blocking I/O for
  streams and support callbacks
2010-11-11 16:02:35 +00:00
Stefan Berger
60ae1c34ad bye to close(), welcome to VIR_(FORCE_)CLOSE()
Using automated replacement with sed and editing I have now replaced all
occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
course. Some replacements were straight forward, others I needed to pay
attention. I hope I payed attention in all the right places... Please
have a look. This should have at least solved one more double-close
error.
2010-11-09 15:48:48 -05:00
Daniel P. Berrange
a75cf152a5 Change calling conventions in remote driver client internals
The remoteIO() method has wierd calling conventions, where
it is passed a pre-allocated 'struct remote_call *' but
then free()s it itself, instead of letting the caller free().
This fixes those weird semantics

* src/remote/remote_driver.c: Sanitize semantics of remoteIO
  method wrt to memory release
2010-11-02 14:50:32 +00:00
Daniel P. Berrange
640c5f1984 Remove both addrToString methods
The addrToString functionality is now available via the
virSocketFormatAddrFull method.

* daemon/remote.c, src/remote/remote_driver.c: Remove
  addrToString methods
2010-10-22 11:27:29 +01:00
Daniel P. Berrange
9e42b40a95 Remove useless code in error path of getnameinfo()
If getnameinfo() with NI_NUMERICHOST set fails, there are no
grounds to expect inet_ntop to succeed, since these calls
are functionally equivalent. Remove useless inet_ntop code
in the getnameinfo() error path.

* daemon/remote.c, src/remote/remote_driver.c: Remove
  calls to inet_ntop
2010-10-22 11:15:14 +01:00
Eric Blake
eb826444f9 vcpu: implement the remote protocol
Done by editing the first three files, then running
'make -C src rpcgen', then editing src/remote_protocol-structs
to match.

* daemon/remote.c (remoteDispatchDomainSetVcpusFlags)
(remoteDispatchDomainGetVcpusFlags): New functions.
* src/remote/remote_driver.c (remoteDomainSetVcpusFlags)
(remoteDomainGetVcpusFlags, remote_driver): Client side
serialization.
* src/remote/remote_protocol.x
(remote_domain_set_vcpus_flags_args)
(remote_domain_get_vcpus_flags_args)
(remote_domain_get_vcpus_flags_ret)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS): Define wire format.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.
2010-10-19 10:02:33 -06:00
Eric Blake
dd255d6405 vcpu: define internal driver API
* src/driver.h (virDrvDomainSetVcpusFlags)
(virDrvDomainGetVcpusFlags): New typedefs.
(_virDriver): New callback members.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
2010-10-19 10:00:47 -06:00
Nikunj A. Dadhania
f928f43b7b Remote protocol implementation of virDomainSet/GetMemoryParameters 2010-10-12 19:26:10 +02:00
Nikunj A. Dadhania
0cd7823271 Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API
Public api to set/get memory tunables supported by the hypervisors.

dv:
* some cleanups in libvirt.c
* adding extra checks in libvirt.c new entry points

v4:
* Move exporting public API to this patch
* Add unsigned int flags to the public api for future extensions

v3:
* Add domainGetMemoryParamters and NULL in all the driver interface

v2:
* Initialize domainSetMemoryParameters to NULL in all the driver
  interface structure.
2010-10-12 19:26:09 +02:00
Daniel P. Berrange
3a73eaeb61 Make SASL work over UNIX domain sockets
The addrToString methods were not coping with UNIX domain sockets
which have no normal host+port address. Hardcode special handling
for these so that SASL routines can work over UNIX sockets. Also
fix up SSF logic in remote client so that it presumes that a UNIX
socket is secure

* daemon/remote.c: Fix addrToString for UNIX sockets.
* src/remote/remote_driver.c: Fix addrToString for UNIX sockets
  and fix SSF logic to work for TLS + UNIX sockets in the same
  manner
2010-09-22 17:52:25 +01:00
Daniel Berrange
9f45fabda2 remote: Fix incorrect use of private data field
NodeDeviceCreateXML and NodeDeviceDestroy methods added for NPIV were
using the wrong privateData field for the remote driver. This doesn't
impact KVM, since the remote driver handles everything, thus
privateData == devMonPrivateData. It does impact Xen though, because
the remote driver only handles a subset of methods and thus
privateData != devMonPrivateData.
2010-08-18 17:32:31 +02:00
Chris Lalancette
337d201ef2 Qemu remote protocol.
Since we are adding a new "per-hypervisor" protocol, we
make it so that the qemu remote protocol uses a new
PROTOCOL and PROGRAM number.  This allows us to easily
distinguish it from the normal REMOTE protocol.

This necessitates changing the proc in remote_message_header
from a "remote_procedure" to an "unsigned", which should
be the same size (and thus preserve the on-wire protocol).

Changes since v1:
 - Fixed up a couple of script problems in remote_generate_stubs.pl
 - Switch an int flag to a bool in dispatch.c

Changes since v2:
 - None

Changes since v3:
 - Change unsigned proc to signed proc, to conform to spec

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:33 -04:00
Chris Lalancette
21adf03c2d Qemu Monitor API entry point.
Add the library entry point for the new virDomainQemuMonitorCommand()
entry point.  Because this is not part of the "normal" libvirt API,
it gets its own header file, library file, and will eventually
get its own over-the-wire protocol later in the series.

Changes since v1:
 - Go back to using the virDriver table for qemuDomainMonitorCommand, due to
   linking issues
 - Added versioning information to the libvirt-qemu.so

Changes since v2:
 - None

Changes since v3:
 - Add LGPL header to libvirt-qemu.c
 - Make virLibConnError and virLibDomainError macros instead of function calls

Changes since v4:
 - Move exported symbols to libvirt_qemu.syms

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:14 -04:00
Daniel P. Berrange
8d4f024221 Fix incorrect use of private data in remote driver
The remote driver is using the wrong privateData field in
a couple of functions. THis is harmless for stateful
drivers like QEMU/UML/LXC, but will crash with Xen

* src/remote/remote_driver.c: Fix use of privateData field
2010-07-23 05:16:18 -04:00
Eric Blake
6c83e7ca6f remote: protocol implementation for virDomainCreateWithFlags
Define the wire format for the new virDomainCreateWithFlags
API, and implement client and server side of marshaling code.

* daemon/remote.c (remoteDispatchDomainCreateWithFlags): Add
server side dispatch for virDomainCreateWithFlags.
* src/remote/remote_driver.c (remoteDomainCreateWithFlags)
(remote_driver): Client side serialization.
* src/remote/remote_protocol.x
(remote_domain_create_with_flags_args)
(remote_domain_create_with_flags_ret)
(REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS): Define wire format.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.
2010-06-15 09:37:04 -06:00
Eric Blake
460ca88b98 libvirt: introduce domainCreateWithFlags API
Persistent domain creation needs the same features as transient
domains, but virDomainCreate lacks the flags argument present in
virDomainCreateXML.  virDomainCreateFlags is already claimed as
a public enum, so we have to break convention and expose
virDomainCreateWithFlags.

* include/libvirt/libvirt.h.in (virDomainCreateWithFlags): Add.
* src/driver.h (virDrvDomainCreateWithFlags): Internal API.
* src/libvirt.c (virDomainCreateWithFlags): Glue public API to
driver API.
* src/libvirt_public.syms (LIBVIRT_0.8.2): Expose public API.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
2010-06-15 07:32:41 -06:00
Jiri Denemark
272d5a9653 Fix potential NULL dereference in remoteDomainMigratePrepare2 2010-05-18 20:53:31 +02:00
Jiri Denemark
6ef9d9da5e Remove watches before calling REMOTE_PROC_CLOSE
First calling REMOTE_PROC_CLOSE and then removing watches might lead to
a hang as HANGUP event can be triggered before the watches are actually
removed but after virConnectPtr is already freed. As a result of that
remoteDomainEventFired() would try to lock uninitialized mutex, which
would hang for ever.
2010-05-12 16:07:08 +02:00
Eric Blake
e8a1a730fe build: update gnulib
* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import netdb.
* src/esx/esx_util.c (AI_ADDRCONFIG): Rely on gnulib.
* src/remote/remote_driver.c (AI_ADDRCONFIG): Likewise.
* tools/virsh.c (WEXITSTATUS, O_SYNC): Likewise.
2010-05-11 10:03:48 -06:00
Daniel P. Berrange
36a03bd2ee Add env variable for debugging gnutls usage
Allow debugging of GNUTLS interactions by setting

  LIBVIRT_GNUTLS_DEBUG=10 LIBVIRT_DEBUG=1 virsh

* src/remote/remote_driver.c: Use LIBVIRT_GNUTLS_DEBUG to
  enable gnutls debugging
2010-05-11 15:54:38 +01:00
Eric Blake
8acaeb730b build: use gnulib's sys/wait.h
* configure.ac: Drop sys/wait.h check.
* src/libvirt.c (includes): Use header unconditionally.
* src/remote/remote_driver.c (includes): Likewise.
* src/storage/storage_backend.c (includes): Likewise.
* src/util/ebtables.c (includes): Likewise.
* src/util/hooks.c (includes): Likewise.
* src/util/iptables.c (includes): Likewise.
* src/util/util.c (includes): Likewise.
2010-05-06 14:35:38 -06:00
Eric Blake
9017b9bcaf build: rely on gnulib's pthread module
Gnulib can guarantee that pthread.h exists, but for now, it is a dummy
header with no support for most pthread_* functions.  Modify our
use of pthread to use function checks, rather than header checks,
to determine how much pthread support is present.

* bootstrap.conf (gnulib_modules): Add pthread.
* configure.ac: Drop all pthread.h checks.  Optimize function
checks.  Add check for pthread functions.
* src/Makefile.am (libvirt_lxc_LDADD): Ensure proper link.
* src/remote/remote_driver.c (remoteIOEventLoop): Depend on
pthread_sigmask, now that gnulib guarantees pthread.h.
* src/util/util.c (virFork): Likewise.
* src/util/threads.c (threads-pthread.c): Depend on
pthread_mutexattr_init, as a witness of full pthread support.
* src/util/threads.h (threads-pthread.h): Likewise.
2010-05-06 14:35:37 -06:00
Daniel P. Berrange
34dcbbb470 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-04-30 15:52:59 +01:00
Daniel P. Berrange
84a3269a15 Remote protocol impl for virDomainGetBlockInfo
* daemon/remote.c: Server side dispatcher
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h: Update
  with new API
* src/remote/remote_driver.c: Client side dispatcher
* src/remote/remote_protocol.c, src/remote/remote_protocol.h: Update
* src/remote/remote_protocol.x: Define new wire protocol
2010-04-29 17:20:24 +01:00
Daniel P. Berrange
46bad5121f Internal driver API infrastructure for virDomainGetBlockInfo
This defines the internal driver API and stubs out each driver

* src/driver.h: Define virDrvDomainGetBlockInfo signature
* src/libvirt.c, src/libvirt_public.syms: Glue public API to drivers
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub out driver
2010-04-29 17:20:24 +01:00
Eric Blake
3022375da3 addrToString: give better error message
The user probably doesn't care what the gai error numbers are, as
much as what the failed conversion IP address was.

* src/remote/remote_driver.c (addrToString): Mention which address
could not be converted.
* daemon/remote.c (addrToString): Likewise.
2010-04-22 14:46:55 -06:00
Eric Blake
8f342c6f9a build: avoid compiler warning
According to GCC, ATTRIBUTE_UNUSED means that an attribute _might_
be unused, not _must_ be unused.  Therefore, it is easier to
blindly mark a variable, than to try and do preprocessor limiting
of when we know it is unused.

* src/remote/remote_driver.c (remoteAuthenticate): Mark attribute
as potentially unused.
Reported by Gustovo Morozowski.
2010-04-20 13:44:31 -06:00
Matthias Bolte
cad913060c Mark in_open parameter of remoteAuthenticate as unused when it's unused
Otherwise compiling with -Werror will fail.
2010-04-20 20:35:23 +02:00
Eric Blake
ec724071e9 remote: react to failures on wakeupFD
* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Report
failures on pipe used for wakeup.
Reported by Chris Lalancette.
2010-04-15 11:40:08 -06:00
Eric Blake
f9f6c34c5c util: ensure safe{read,write,zero} return is checked
Based on a warning from coverity.  The safe* functions
guarantee complete transactions on success, but don't guarantee
freedom from failure.

* src/util/util.h (saferead, safewrite, safezero): Add
ATTRIBUTE_RETURN_CHECK.
* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Ignore
some failures.
(remoteIOReadBuffer): Adjust error messages on read failure.
* daemon/event.c (virEventHandleWakeup): Ignore read failure.
2010-04-15 11:40:08 -06:00
Chris Lalancette
f5926b54c0 Remove some debugging leftovers.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:23 -04:00
Matthias Bolte
ddf877cd9e remote: Replace some virRaiseError with remoteError 2010-04-09 02:23:40 +02:00
Matthias Bolte
9455323530 remote: Remove virConnectPtr from error/errorf
Also unify error/errorf to remoteError and update cfg.mk accordingly.
2010-04-09 01:56:27 +02:00
Eric Blake
dd1a186f77 maint: s/initialis/initializ/
git grep found 12 of the former but 100 of the latter in src/.

* src/remote/remote_driver.c (initialise_gnutls): Rename...
(initialize_gnutls): ...to this.
(doRemoteOpen): Adjust caller.
* src/xen/xen_driver.c (xenUnifiedOpen): Adjust output string.
* src/util/network.c: Adjust comments.
Suggested by Matthias Bolte.
2010-04-07 09:48:07 -06:00
Matthias Bolte
49411f029a Remove unnecessary trailing \n in log messages 2010-04-06 01:41:58 +02:00
Chris Lalancette
2f992d4be4 Snapshot API framework.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:34 -04:00
Daniel Veillard
7a3da17a58 Implement remote protocol for managed save
* src/remote/remote_protocol.x src/remote/remote_protocol.h
  src/remote/remote_protocol.c src/remote/remote_driver.c: add the entry
  points in the remote driver
* daemon/remote.c daemon/remote_dispatch_args.h
  daemon/remote_dispatch_prototypes.h daemon/remote_dispatch_table.h:
  and implement the daemon counterpart
2010-04-04 11:36:33 +02:00
Daniel Veillard
15c647a91e Add managed save API entry points
virDomainManagedSave() is to be run on a running domain. Once the call
complete, as in virDomainSave() the domain is stopped upon completion,
but there is no restore counterpart as any order to start the domain
from the API would load the state from the managed file, similary if
the domain is autostarted when libvirtd starts.
Once a domain has restarted his managed save image is destroyed,
basically managed save image can only exist for a stopped domain,
for a running domain that would be by definition outdated data.

* include/libvirt/libvirt.h.in src/libvirt.c src/libvirt_public.syms:
  adds the new entry points virDomainManagedSave(),
  virDomainHasManagedSaveImage() and virDomainManagedSaveRemove()
* src/driver.h src/esx/esx_driver.c src/lxc/lxc_driver.c
  src/opennebula/one_driver.c  src/openvz/openvz_driver.c
  src/phyp/phyp_driver.c src/qemu/qemu_driver.c src/vbox/vbox_tmpl.c
  src/remote/remote_driver.c src/test/test_driver.c src/uml/uml_driver.c
  src/xen/xen_driver.c: add corresponding new internal drivers entry
  points
2010-04-04 11:07:48 +02:00
Stefan Berger
965466c1ee Definition of the wire format, RPC client & server
This patch adds the definition of the wire format for RPC calls
and implementation of the RPC client & server code

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:16 +00:00
Daniel P. Berrange
ee9083aba5 Remote protocol impl for virDomainUpdateDeviceFlags
This defines the wire format for the new virDomainUpdateDeviceFlags()
API, and implements the server & client side of the marshalling code.

* daemon/remote.c: Server side dispatch for virDomainUpdateDeviceFlags
* src/remote/remote_driver.c: Client side serialization for
  virDomainUpdateDeviceFlags
* src/remote/remote_protocol.x: Define wire format for
  virDomainUpdateDeviceFlags
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_table.h, src/remote/remote_protocol.c,
  src/remote/remote_protocol.h: Re-generate code
2010-03-26 14:17:34 +00:00
Daniel P. Berrange
46a2ea3689 Introduce a new virDomainUpdateDeviceFlags public API
The current virDomainAttachDevice API can be (ab)used to change
the media of an existing CDROM/Floppy device. Going forward there
will be more devices that can be configured on the fly and overloading
virDomainAttachDevice for this is not too pleasant. This patch adds
a new virDomainUpdateDeviceFlags() explicitly just for modifying
existing devices.

* include/libvirt/libvirt.h.in: Add virDomainUpdateDeviceFlags
* src/driver.h: Internal API for virDomainUpdateDeviceFlags
* src/libvirt.c, src/libvirt_public.syms: Glue public API to
  driver API
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Add
  stubs for new driver entry point
2010-03-26 14:13:28 +00:00
Daniel P. Berrange
987e31edc9 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-26 13:53:20 +00:00
Daniel P. Berrange
71d793faaf 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-26 13:53:11 +00:00
Daniel P. Berrange
c5728cd618 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-26 13:53:01 +00:00
Daniel P. Berrange
32e6ac9c26 Add support for an explicit RTC change event
This introduces a new event type

   VIR_DOMAIN_EVENT_ID_RTC_CHANGE

This event includes the new UTC offset measured in seconds.
Thus there is a new callback definition for this event type

 typedef void (*virConnectDomainEventRTCChangeCallback)(virConnectPtr conn,
                                                        virDomainPtr dom,
                                                        long long utcoffset,
                                                        void *opaque);

If the guest XML configuration for the <clock> is set to
offset='variable', then the XML will automatically be
updated with the new UTC offset value. This ensures that
during migration/save/restore the new offset is preserved.

* daemon/remote.c: Dispatch RTC change events to client
* examples/domain-events/events-c/event-test.c: Watch for
  RTC change events
* include/libvirt/libvirt.h.in: Define new RTC change event ID
  and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle RTC change events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for RTC changes and emit a libvirt RTC change event
* src/remote/remote_driver.c: Receive and dispatch RTC change
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  RTC change events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for RTC_CHANGE event
  from QEMU monitor
2010-03-26 13:52:50 +00:00
Daniel P. Berrange
8613273458 Add support for an explicit guest reboot event
The reboot event is not a normal lifecycle event, since the
virtual machine on the host does not change state. Rather the
guest OS is resetting the virtual CPUs. ie, the QEMU process
does not restart. Thus, this does not belong in the current
lifecycle events callback.

This introduces a new event type

    VIR_DOMAIN_EVENT_ID_REBOOT

It takes no parameters, besides the virDomainPtr, so it can
use the generic callback signature.

* daemon/remote.c: Dispatch reboot events to client
* examples/domain-events/events-c/event-test.c: Watch for
  reboot events
* include/libvirt/libvirt.h.in: Define new reboot event ID
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle reboot events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for reboots and emit a libvirt reboot event
* src/remote/remote_driver.c: Receive and dispatch reboot
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  reboot events
2010-03-26 13:52:43 +00:00
Daniel P. Berrange
d51638d0ad Rename domain lifecycle event message
To avoid confusion, rename the current REMOTE_PROC_DOMAIN_EVENT
message to REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE. This does not
cause ABI problems, since the names are only relevant at the source
code level. On the wire they encoding is a plain integer whose
value does not change

* src/remote/remote_protocol.x: Rename REMOTE_PROC_DOMAIN_EVENT
  to REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE.
* daemon/remote.c, src/remote/remote_driver.c: Update code for
  renamed event
2010-03-26 13:52:39 +00:00
Daniel P. Berrange
097e07a63a 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-26 13:52:29 +00:00
Daniel P. Berrange
747c536370 Refactor domain events to handle multiple event types
The internal domain events APIs are designed to handle the lifecycle
events. This needs to be refactored to allow arbitrary new event
types to be handled.

 * The signature of virDomainEventDispatchFunc changes to use
   virConnectDomainEventGenericCallback instead of the lifecycle
   event specific virConnectDomainEventCallback
 * Every registered callback gains a unique ID to allow its
   removal based on ID, instead of function pointer
 * Every registered callback gains an 'eventID' to allow callbacks
   for different types of events to be distinguished
 * virDomainEventDispatch is adapted to filter out callbacks
   whose eventID does not match the eventID of the event being
   dispatched
 * virDomainEventDispatch is adapted to filter based on the
   domain name and uuid, if this filter is set for a callback.
 * virDomainEvent type/detail fields are moved into a union to
   allow different data fields for other types of events to be
   added later

* src/conf/domain_event.h, src/conf/domain_event.c: Refactor
  to allow handling of different types of events
* src/lxc/lxc_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/xen/xen_driver.c: Change dispatch function signature
  to use virConnectDomainEventGenericCallback
2010-03-26 13:52:14 +00:00
Daniel P. Berrange
4445723811 Introduce a new public API for domain events
The current API for domain events has a number of problems

 - Only allows for domain lifecycle change events
 - Does not allow the same callback to be registered multiple times
 - Does not allow filtering of events to a specific domain

This introduces a new more general purpose domain events API

  typedef enum {
     VIR_DOMAIN_EVENT_ID_LIFECYCLE = 0,       /* virConnectDomainEventCallback */
      ...more events later..
  }

  int virConnectDomainEventRegisterAny(virConnectPtr conn,
                                       virDomainPtr dom, /* Optional, to filter */
                                       int eventID,
                                       virConnectDomainEventGenericCallback cb,
                                       void *opaque,
                                       virFreeCallback freecb);

  int virConnectDomainEventDeregisterAny(virConnectPtr conn,
                                         int callbackID);

Since different event types can received different data in the callback,
the API is defined with a generic callback. Specific events will each
have a custom signature for their callback. Thus when registering an
event it is neccessary to cast the callback to the generic signature

eg

  int myDomainEventCallback(virConnectPtr conn,
                            virDomainPtr dom,
                            int event,
                            int detail,
                            void *opaque)
  {
    ...
  }

  virConnectDomainEventRegisterAny(conn, NULL,
                                   VIR_DOMAIN_EVENT_ID_LIFECYCLE,
                                   VIR_DOMAIN_EVENT_CALLBACK(myDomainEventCallback)
                                   NULL, NULL);

The VIR_DOMAIN_EVENT_CALLBACK() macro simply does a "bad" cast
to the generic signature

* include/libvirt/libvirt.h.in: Define new APIs for registering
  domain events
* src/driver.h: Internal driver entry points for new events APIs
* src/libvirt.c: Wire up public API to driver API for events APIs
* src/libvirt_public.syms: Export new APIs
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c,
  src/xenapi/xenapi_driver.c: Stub out new API entries
2010-03-26 13:52:03 +00:00
Matthias Bolte
7233dc170f Add HAVE_PTHREAD_H guard for pthread_sigmask
Correctly disable pthread related code if pthread is not avialable,
in order to get it compile with MinGW on Windows.
2010-03-23 02:13:19 +01:00
Jiri Denemark
0ab6423579 Implement virDomainMigrateSetMaxDowntime in remote driver 2010-03-19 22:45:55 +01:00
Jiri Denemark
7f7849c996 Internal driver API for virDomainMigrateSetMaxDowntime 2010-03-19 22:20:42 +01:00
David Allan
3fdb9ba760 Implement remote bits for vol wiping 2010-03-19 14:43:02 -04:00
Eric Blake
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
Eric Blake
2e56fb2bcc build: consistently use C99 varargs macros
Prior to this patch, there was an inconsistent mix between GNU and C99.

For consistency, and potential portability to other compilers, stick
with the C99 vararg macro syntax.

* src/conf/cpu_conf.c (virCPUReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/conf/domain_conf.c (virDomainReportError): Likewise.
* src/conf/domain_event.c (eventReportError): Likewise.
* src/conf/interface_conf.c (virInterfaceReportError): Likewise.
* src/conf/network_conf.c (virNetworkReportError): Likewise.
* src/conf/node_device_conf.h (virNodeDeviceReportError): Likewise.
* src/conf/secret_conf.h (virSecretReportError): Likewise.
* src/conf/storage_conf.h (virStorageReportError): Likewise.
* src/esx/esx_device_monitor.c (ESX_ERROR): Use C99 rather than
  GNU vararg macro syntax.
* src/esx/esx_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_interface_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_network_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_secret_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_storage_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_util.c (ESX_ERROR): Likewise.
* src/esx/esx_vi.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vi_methods.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vi_types.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vmx.c (ESX_ERROR): Likewise.
* src/util/hostusb.c (usbReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/util/json.c (virJSONError): Likewise.
* src/util/macvtap.c (ReportError): Likewise.
* src/util/pci.c (pciReportError): Likewise.
* src/util/stats_linux.c (virStatsError): Likewise.
* src/util/util.c (virUtilError): Likewise.
* src/util/xml.c (virXMLError): Likewise.
* src/xen/proxy_internal.c (virProxyError): Use C99 rather than
  GNU vararg macro syntax.
* src/xen/sexpr.c (virSexprError): Likewise.
* src/xen/xen_driver.c (xenUnifiedError): Likewise.
* src/xen/xen_hypervisor.c (virXenError): Likewise.
* src/xen/xen_inotify.c (virXenInotifyError): Likewise.
* src/xen/xend_internal.c (virXendError): Likewise.
* src/xen/xm_internal.c (xenXMError): Likewise.
* src/xen/xs_internal.c (virXenStoreError): Likewise.
* src/cpu/cpu.h (virCPUReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/datatypes.c (virLibConnError): Likewise.
* src/interface/netcf_driver.c (interfaceReportError): Likewise.
* src/libvirt.c (virLibStreamError): Likewise.
* src/lxc/lxc_conf.h (lxcError): Likewise.
* src/network/bridge_driver.c (networkReportError): Likewise.
* src/nodeinfo.c (nodeReportError): Likewise.
* src/opennebula/one_conf.h (oneError): Likewise.
* src/openvz/openvz_conf.h (openvzError): Likewise.
* src/phyp/phyp_driver.c (PHYP_ERROR): Likewise.
* src/qemu/qemu_conf.h (qemuReportError): Likewise.
* src/remote/remote_driver.c (errorf): Likewise.
* src/security/security_driver.h (virSecurityReportError): Likewise.
* src/test/test_driver.c (testError): Likewise.
* src/uml/uml_conf.h (umlReportError): Likewise.
* src/vbox/vbox_driver.c (vboxError): Likewise.
* src/vbox/vbox_tmpl.c (vboxError): Likewise.
2010-03-08 13:32:27 +01:00