Commit Graph

103 Commits

Author SHA1 Message Date
Richard W.M. Jones
aa6e7fb408 remote: remove bogus virDomainFree. 2011-05-20 16:12:36 +01:00
Hu Tao
bb9f1bbf4a remote: introduce remoteSetSchedulerParametersFlags
support for virDomainSetSchedulerParametersFlags of remote driver.
2011-05-17 10:38:30 -06:00
Matthias Bolte
5b77f1d5dc Fix error reporting in stream creation code
virStreamNew needs to dispatch the error that virGetStream reports
on failure.

remoteCreateClientStream can fail due to virStreamNew or due to
VIR_ALLOC. Report OOM error for VIR_ALLOC failure to report errors
in all error cases.

Remove OOM error reporting from remoteCreateClientStream callers.
2011-05-17 14:54:54 +02:00
Daniel P. Berrange
66f57a5041 Fix leak of mime type string in screenshot dispatcher
* daemon/remote.c: Free mime string
2011-05-16 20:30:17 +01:00
Daniel P. Berrange
9cd16c0aa9 Fix remote dispatcher for screenshot command
* daemon/remote.c: Update screenshot dispatcher to follow
  standard practice
2011-05-16 18:27:15 +01:00
Daniel P. Berrange
d59e14a1a2 Remote driver implementation of new migration API
* src/remote/remote_protocol.x: Define wire protocol for migration
  protocol v3
* daemon/remote.c: Server side dispatch
* src/remote/remote_driver.c: Client side serialization
* src/remote/remote_protocol.c, src/remote/remote_protocol.h,
  daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h:
  Re-generate files
* src/remote_protocol-structs: Declare new ABIs
2011-05-16 15:09:25 +01:00
Jiri Denemark
9f181ebc14 Wire protocol format and remote driver for virDomainGetState 2011-05-16 10:04:19 +02:00
Michal Privoznik
2c6efac985 screenshot: Implementing the remote protocol
* src/remote/remote_protocol.x: Wire protocol definition
* daemon/remote.c: Daemon part
* src/remote/remote_driver.c: Client part
* src/remote_protocol-structs: Add structures
2011-05-13 12:44:23 +02:00
Eric Blake
cb84580a25 maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.

* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:20:33 -06:00
Lai Jiangshan
b65f37a4a1 libvirt,logging: cleanup VIR_XXX0()
These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.

How do these coversions works? The magic is using the gcc extension of ##.
When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
avoid compile error.

example: origin				after CPP
	high_level_api("%d", a_int)	low_level_api("%d", a_int)
	high_level_api("a  string")	low_level_api("a  string")

About 400 conversions.

8 special conversions:
VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
  (for security) 6 conversions

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2011-05-11 12:41:14 -06:00
Eric Blake
d3c5104dda build: rename generated files to .h, for automake's sake
In preparation for removing generated files, it is necessary
to tell automake that the generated files must be distributed
but not directly compiled (since they are included into the
body of a larger .c file that is compiled).  Hence, even though
these files are code and not headers in the strict sense of
the word, it is easier to rename them to .h for automake's sake.

* daemon/remote_client_bodies.c: Rename to .h.
* daemon/qemu_client_bodies.c: Likewise.
* src/remote/remote_client_bodies.c: Likewise.
* src/remote/qemu_client_bodies.c: Likewise.
* daemon/Makefile.am (remote_dispatch_bodies.c)
(qemu_dispatch_bodies.c): Rename to .h.
(remote.c, EXTRA_DIST): Reflect rename.
* daemon/remote.c: Likewise.
* daemon/remote_generator.pl: Likewise.
* src/Makefile.am (remote/remote_driver.c): Likewise.
* src/remote/remote_driver.c: Likewise.
* po/POTFILES.in: Likewise.
* cfg.mk (exclude_file_name_regexp--sc_require_config_h)
(exclude_file_name_regexp--sc_require_config_h_first)
(exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF):
Likewise.
2011-05-06 15:11:36 -06: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
5641222eba remote generator, daemon: Handle the CPU functions
They require additional special cases.
2011-05-06 20:08:31 +02:00
Matthias Bolte
33148050e7 remote generator, daemon: Handle functions that return lists 2011-05-06 20:08:27 +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
9a74649cd2 remote generator, daemon: Handle functions with optional arguments 2011-05-06 20:08:23 +02:00
Matthias Bolte
0411030665 remote generator, daemon: Handle more functions
This covers functions that return single wrapped objects and don't
involve complexer code in the body.
2011-05-06 20:08:21 +02:00
Matthias Bolte
0c3cea0bd6 remote generator, daemon: Handle simple-return-value functions 2011-05-06 20:07:39 +02:00
Matthias Bolte
0fb79ff4bb remote generator, daemon: Change capitalization of some words
Again this will simplify the generator, due to less special case handling.
2011-05-06 20:05:01 +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
Matthias Bolte
aff1db9fab remote generator, daemon: Output function bodies too
This patch just covers the simple functions without explicit return
values. There is more to be handled.

The generator collects the members of the XDR argument structs and uses
this information to generate the function bodies.

Exclude the generated files from offending syntax-checks.

Suggested by Richard W.M. Jones
2011-05-06 20:04:56 +02:00
Eric Blake
85cb292681 remote: avoid null dereference on error
Clang found three instances of uninitialized use of nparams in
the cleanup path.  Unfortunately, one is a false positive: clang
couldn't see that ret->params.params_val is guaranteed to be
NULL unless allocated within a function, and that nparams is
guaranteed to be assigned prior to the allocation; hoisting the
assignment to nparams to be earlier in the function shuts up
that false positive.  But two of the reports also happened to
highlight a real bug - the error path can dereference NULL.

Regression introduced in commit 158ba873.

* daemon/remote.c (remoteDispatchDomainGetMemoryParameters)
(remoteDispatchDomainGetBlkioParameters): Don't clear fields if
array was not allocated.
(remoteDispatchDomainGetSchedulerParameters): Initialize nparams
earlier.
2011-05-04 10:55:29 -06:00
Hu Tao
3c1326385a free memory properly in cleanup patch
virsh schedinfo inactive-domain will trigger the problem.
2011-04-27 20:12:14 +08:00
Matthias Bolte
802e2df9a3 daemon: Don't try to free an unsigned int in error paths 2011-04-22 19:02:40 +02:00
Daniel P. Berrange
bf4883caff Change some variable names to follow standard in daemon dispatcher
Replace some occurrances of

  virDomainPtr domain;
  virNetworkPtr network;

With

  virDomainPtr dom;
  virNetworkPtr net;

* daemon/remote.c: Fix variable naming to follow standard
2011-04-18 15:20:33 +01:00
Daniel P. Berrange
05a6283c7a Write error check conditionals in more compact form for dispatcher
Replace cases of

     type = virConnectGetType(conn);
     if (type == NULL)
         goto cleanup;

With

     if (!(type = virConnectGetType(conn)))
         goto cleanup;

* daemon/remote.c: Write error checks in compat form
2011-04-18 15:20:33 +01:00
Daniel P. Berrange
55c71a26af Remove curly braces on all single-line conditional jumps in dispatcher
Replace all occurrances of

   if (....) {
      goto cleanup;
   }

With

   if (.....)
      goto cleanup;

to save one line of code

* daemon/remote.c: Remove curly braces on single line conditionals
2011-04-18 15:20:33 +01:00
Daniel P. Berrange
c19295e5ae Fix checking of return codes in dispatcher
The libvirt APIs reserve any negative value for indicating an
error. Thus checks

    if (virXXXX() == -1)

Should instead be

    if (virXXXX() < 0)

* daemon/remote.c: s/ == -1/ < 0/
2011-04-18 15:20:33 +01:00
Daniel P. Berrange
158ba8730e Merge all returns paths from dispatcher into single path
The dispatcher functions have numerous places where they
return to the caller. This leads to duplicated cleanup
code, often resulting in memory leaks. It makes it harder
to ensure that errors are dispatched before freeing objects,
which may overwrite the original error.

The standard pattern is now

    remoteDispatchXXX(...) {
        int rv = -1;

        ....
        if (XXX < 0)
          goto cleanup;
        ...
        if (XXXX < 0)
          goto cleanup;
        ...

        rv = 0;
    cleanup:
        if (rv < 0)
           remoteDispatchError(rerr);
        ...free all other stuff..
        return rv;
    }

* daemon/remote.c: Centralize all cleanup paths
* daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
* daemon/dispatch.c, daemon/dispatch.h: Replace
  remoteDispatchConnError with remoteDispatchError
  removing unused virConnectPtr
2011-04-18 15:20:33 +01:00
Daniel P. Berrange
d93ef4466b Replace REMOTE_DEBUG with VIR_DEBUG in daemon dispatcher
The daemon dispatcher code had an obsolete macro

  #define REMOTE_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)

This can be trivially removed

* daemon/remote.c: s/REMOTE_DEBUG/VIR_DEBUG/
2011-04-13 19:01:24 +01:00
Daniel P. Berrange
aaa6d7eb39 Add missing checks for whether the connection is open in dispatcher
Many functions did not check for whether a connection was
open. Replace the macro which obscures control flow, with
explicit checks, and ensure all dispatcher code has checks.

* daemon/remote.c: Add connection checks
2011-04-13 19:01:11 +01:00
Daniel P. Berrange
36b652138b Standard on error variable name in libvirtd dispatcher
Some dispatcher methods have a parameter

            remote_error *err,

Instead of the more normal

            remote_error *rerr,

* daemon/remote.c: s/err/rerr/
2011-04-13 19:00:46 +01:00
Daniel P. Berrange
8005048447 Remove all whitespace before function brackets in daemon dispatcher
A lot of code in libvirtd's dispatcher used the style

    dom = get_nonnull_domain (conn, args->dom);

Instead of the normal libvirt style

    dom = get_nonnull_domain(conn, args->dom);

* daemon/remote.c: Remove all whitelist before function brackets
2011-04-13 19:00:21 +01:00
Matthias Bolte
76f0ae3261 daemon: Remove 4kb stack allocation of security label 2011-04-05 09:08:58 +02: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
Jiri Denemark
55cc591fc1 daemon: Avoid resetting errors before they are reported
Commit f44bfb7 was supposed to make sure no additional libvirt API (esp.
*Free) is called before remoteDispatchConnError() is called on error.
However, the patch missed two instances.
2011-03-25 15:05:35 +01:00
Eric Blake
208a044a54 command: properly diagnose process exit via signal
Child processes don't always reach _exit(); if they die from a
signal, then any messages should still be accurate.  Most users
either expect a 0 status (thankfully, if status==0, then
WIFEXITED(status) is true and WEXITSTATUS(status)==0 for all
known platforms) or were filtering on WIFEXITED before printing
a status, but a few were missing this check.  Additionally,
nwfilter_ebiptables_driver was making an assumption that works
on Linux (where WEXITSTATUS shifts and WTERMSIG just masks)
but fails on other platforms (where WEXITSTATUS just masks and
WTERMSIG shifts).

* src/util/command.h (virCommandTranslateStatus): New helper.
* src/libvirt_private.syms (command.h): Export it.
* src/util/command.c (virCommandTranslateStatus): New function.
(virCommandWait): Use it to also diagnose status from signals.
* src/security/security_apparmor.c (load_profile): Likewise.
* src/storage/storage_backend.c
(virStorageBackendQEMUImgBackingFormat): Likewise.
* src/util/util.c (virExecDaemonize, virRunWithHook)
(virFileOperation, virDirCreate): Likewise.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesExecCLI):
Likewise.
2011-03-25 05:34:48 -06:00
Jiri Denemark
f44bfb7fb9 Make error reporting in libvirtd thread safe
Bug https://bugzilla.redhat.com/show_bug.cgi?id=689374 reported libvirtd
crash during error dispatch.

The reason is that libvirtd uses remoteDispatchConnError() with non-NULL
conn parameter which means that virConnGetLastError() is used instead of
its thread safe replacement virGetLastError().

So when several libvirtd threads are reporting errors at the same time,
the errors can get mixed or corrupted or in case of bad luck libvirtd
itself crashes.

Since Daniel B. is going to rewrite this code from scratch on top of his
RPC infrastructure, I tried to come up with a minimal fix. Thus,
remoteDispatchConnError() now just ignores its conn argument and always
calls virGetLastError(). However, several callers had to be touched as
well, since no libvirt API is allowed to be called before dispatching
the error. Doing so would reset the error and we would have nothing to
dispatch. As a result of that, the code is not very nice but that
doesn't really make daemon/remote.c worse than it is now :-) And it will
all die soon, which is good.

The bug report also contains a reproducer in C which detects both mixed
up error messages and libvirtd crash. Before this patch, I was able to
crash libvirtd in about 20 seconds up to 3 minutes depending on number
of CPU cores (more is better) and luck.
2011-03-24 09:39:50 +01: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
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
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
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
Matthias Bolte
dc52cab126 Prefer C style comments over C++ ones
Pure cosmetic change.
2011-01-29 00:59:45 +01: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
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
Jim Fehlig
98b8424ed8 Fix build with polkit 0
Commit e8066d53 broke the build with polkit0:

remote.c: In function 'remoteDispatchAuthPolkit':
remote.c:4177: error: 'rv' undeclared (first use in this function)

Add missing identifier.
2010-11-02 10:11:16 -06:00
Daniel P. Berrange
43e7e8f614 Remove all auditing hooks from libvirtd dispatch code
Revert most of commit a8b5f9bd27.
The audit hooks will be re-added directly in the QEMU driver code
in a future commit

* daemon/remote.c: Remove all audit logging hooks
* src/qemu/qemu_driver.c: Remove all audit logging hooks
2010-10-27 17:03:21 +01:00
Matthias Bolte
cbe719feb2 Fix build for SystemTap 1.0
With SystemTap 1.0 a part of the generated macros in probes.h
expands to:

volatile __typeof__(((name))) arg2 = (name);

GCC reports an 'invalid initialize' error when name has type
char[]. Therfore, add casts to char* to avoid this.
2010-10-26 13:28:32 +02:00