Commit Graph

83 Commits

Author SHA1 Message Date
Daniel Veillard
1216398da9 Fix LSB compliance of init script
https://bugzilla.redhat.com/show_bug.cgi?id=538701

* daemon/libvirtd.init.in: daemon/libvirtd.init.in were not mentionned
  in the usage message and if a missing or wrong argument is given it
  should return 2, not 1
2010-03-18 13:30:16 +01:00
Cole Robinson
0ef58c3155 .gitignore: Ignore generated daemon/libvirtd.logrotate 2010-03-17 12:27:41 -04:00
Daniel Veillard
89bf843a6d Change logrotate to be per-hypervisor logs
Having a single logrotate configuration file for all hypervisors
did not work as logrotate would get confused if an hypervisor not
supported on that platform was still listed. Simplest is to split
the logrotate as separate per hypervisor files and change the
spec file to only install the ones compiled in.
* daemon/libvirtd.lxc.logrotate.in daemon/libvirtd.qemu.logrotate.in
  daemon/libvirtd.uml.logrotate.in: copy and split the original
  daemon/libvirtd.logrotate.in file
* daemon/Makefile.am: update to support the different files and
  cleanup in sed suggested by Eric Blake
* libvirt.spec.in: only install the relevant logrotate configs
* daemon/.gitignore: update logrotate generated list
2010-03-10 11:27:02 +01: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
Daniel P. Berrange
b1a7ebfdec Remote driver implementation for the virDomainAbortJob APi
This defines the wire protocol for the new API

* src/remote/remote_protocol.x: Wire protocol definition
* src/remote/remote_driver.c,daemon/remote.c: Client and server
  side implementation
* 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 from remote_protocol.x
2010-03-02 16:23:31 +00:00
Daniel P. Berrange
b85a53405c Remote driver implmentation of job info API
* src/remote/remote_protocol.x: Define wire protocol format
  for virDomainGetJobInfo API
* src/remote/remote_driver.c, daemon/remote.c: Implement client
  and server marshalling code for virDomainGetJobInfo()
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h,
  src/remote/remote_protocol.c, src/remote/remote_protocol.h: Rebuild
  files from src/remote/remote_protocol.x
2010-03-02 16:22:31 +00:00
Eric Blake
66d70a8f66 libvirtd: avoid false-positive NULL-deref warning from clang
* daemon/libvirtd.c (qemudWorker): Rewrite loop to silence a
warning.
2010-03-02 09:02:40 +01:00
Jim Meyering
7ca954cf26 libvirtd: do not ignore failure to set group ID in privileged mode
* daemon/libvirtd.c (qemudListenUnix): Diagnose and fail upon
failure to set or restore group-ID.
2010-02-26 17:12:00 +01:00
Cole Robinson
b39c2068e4 libvirtd: Better initscript error reporting
From time to time I bork my install, and hate it when the initscript
returns no info. This patch removes the sanity check, which lets
the shell give us 'command not found' or 'permission denied' errors.
2010-02-25 11:43:57 -05:00
Cole Robinson
67b2eb1042 remote: Improve daemon startup error reporting
If I toggle enable_tcp in libvirtd.conf and add --listen in
/etc/init.d/libvirtd, I get the unhelpful error:

Starting libvirtd daemon: error: Unable to initialize network sockets.

Running without --daemon provides much more useful info:

sudo libvirtd --listen
11:29:26.117: error : remoteCheckCertFile:270 : Cannot access CA certificate '/etc/pki/CA/cacert.pem': No such file or directory

The daemon architecture makes it difficult to report this useful
info if daemonized, so point users to /var/log/messages and
dropping the --daemon flag if they want more info.
2010-02-25 11:43:57 -05:00
Jiri Denemark
a3d22efd77 Wire protocol format and dispatcher for virConnectBaselineCPU 2010-02-12 14:27:20 +01:00
Daniel P. Berrange
5dee786d7b Re-generate remote protocol files for new APIs
Re-generate remote protocol files for changes in commit
daeb6f6b40

* 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 files
2010-02-09 12:09:05 +00:00
Matthias Bolte
f972dc2d5c Remove conn parameter from util functions
It was used for error reporting only.
2010-02-09 01:04:54 +01:00
Matthias Bolte
8ce5e2c1ab Remove conn parameter from virReportOOMError 2010-02-09 01:04:54 +01:00
Jim Fehlig
ce039c3ea5 Server side dispatcher
Server side dispatcher for Domain{Attach,Detach}DeviceFlags.
2010-02-08 10:49:43 -07:00
Jim Meyering
c37ff6a1ec libvirtd.c: avoid closing a negative socket file descriptor
* daemon/libvirtd.c (qemudListenUnix): Close socket only if non-negative.
2010-02-02 12:07:27 +01:00
Daniel P. Berrange
50b6c95d62 Make all bitfields unsigned ints to avoid unexpected values in casts
The 'int virInterfaceIsActive()' method was directly returning the
value of the 'int active:1' bitfield in virIntefaceDefPtr. A bitfield
with a signed integer, will hold the values 0 and -1, not 0 and +1
as might be expected. This meant that virInterfaceIsActive() was
always returning -1 when the interface was active, not +1 & thus all
callers thought an error had occurred. To protect against this kind
of mistake again, change all bitfields to be unsigned ints

* daemon/libvirtd.h, src/conf/domain_conf.h, src/conf/interface_conf.h,
  src/conf/network_conf.h: Change bitfields to unsigned int.
2010-01-20 16:33:02 +00:00
Jiri Denemark
4bc3bd7b18 Remove superfluous new lines from messages
I noticed some debug messages are printed with an empty lines after
them. This patch removes these empty lines from all invocations of the
following macros:
    VIR_DEBUG
    VIR_DEBUG0
    VIR_ERROR
    VIR_ERROR0
    VIR_INFO
    VIR_WARN
    VIR_WARN0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 17:30:41 +01:00
Cole Robinson
438fa79358 daemon: Don't blindly unregister domain events
The daemon will attempt to unregister domain events on client disconnect,
even if no events were ever registered. This raises an unneeded error.

Track in the qemu_client structure if events have been registered, and
check this when performing cleanup.
2010-01-13 14:24:13 -05:00
Cole Robinson
2d4d657695 daemon: Fix various error reporting issues
Many node device calls weren't properly relaying error messages, and
domain event registeration was not checking for error.
2010-01-13 14:24:13 -05:00
Matthias Bolte
a26d2628c0 The secret driver is stateful, link it directly to libvirtd
All other stateful drivers are linked directly to libvirtd
instead of libvirt.so. Link the secret driver to libvirtd too.

* daemon/Makefile.am: link the secret driver to libvirtd
* daemon/libvirtd.c: add #ifdef WITH_SECRETS blocks
* src/Makefile.am: don't link the secret driver to libvirt.so
* src/libvirt_private.syms: remove the secretRegister symbol
2009-12-23 15:01:09 +01:00
Adam Litke
841d50358f Add domainMemoryStats support to remote driver
Use a dynamically sized xdr_array to pass memory stats on the wire.  This
supports the addition of future memory stats and reduces the message size
since only supported statistics are returned.

* src/remote/remote_protocol.x: provide defines for the new entry point
* src/remote/remote_driver.c daemon/remote.c: implement the client and
  server side
* daemon/remote_dispatch_args.h daemon/remote_dispatch_prototypes.h
  daemon/remote_dispatch_ret.h daemon/remote_dispatch_table.h
  src/remote/remote_protocol.c src/remote/remote_protocol.h: generated
  stubs
2009-12-20 13:43:19 +01:00
Jiri Denemark
3a2881fa60 CPU flags wire protocol format and server side
* src/remote/remote_protocol.x: update with new entry point
* daemon/remote.c: add the new server dispatcher
* daemon/remote_dispatch_args.h daemon/remote_dispatch_prototypes.h
  daemon/remote_dispatch_ret.h daemon/remote_dispatch_table.h
  src/remote/remote_protocol.c src/remote/remote_protocol.h: regenerated
2009-12-18 15:49:34 +01:00
Jim Meyering
2e5efc3d6e avoid calling exit with a constant; use EXIT_* instead
This appeases a new gnulib-provided "syntax-check".
* daemon/libvirtd.c (main): Use EXIT_FAILURE, not 1.
* proxy/libvirt_proxy.c (main): Likewise, and EXIT_SUCCESS, not 0.
* tests/conftest.c (main): Likewise.
* tests/reconnect.c (main): Likewise.
* tests/testutils.h (EXIT_AM_SKIP): Define.
* tests/nodeinfotest.c (mymain): Use EXIT_AM_SKIP, not 77.
* tests/qemuargv2xmltest.c: Likewise.
* tests/qemuxml2xmltest.c: Likewise.
* tests/virshtest.c (mymain): Likewise.
2009-12-15 17:46:04 +01:00
Jim Meyering
63a499d3f3 libvirtd: avoid a NULL dereference on error path
* daemon/libvirtd.c (qemudDispatchServer): Since "client" may be
NULL in the "cleanup:" block, free client->rx only when it's not.
2009-12-15 07:53:27 +01:00
Matthias Bolte
e2692e25de Fix reference leak in remoteDispatchStorageVolCreateXmlFrom 2009-12-11 16:36:45 +01:00
Matthias Bolte
1b9d074493 Add virBufferFreeAndReset() and replace free()
Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
Update documentation and replace all remaining calls to free() with
calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
and virReportOOMError() in OOM error cases.
2009-12-10 00:00:50 +01:00
Daniel P. Berrange
32f021f266 Fix event test timer checks on kernels with HZ=100
On kernels with HZ=100, the resolution of sleeps in poll() is
quite bad. Doing a precise check on the expiry time vs the
current time will thus often thing the timer has not expired
even though we're within 10ms of the expected expiry time. This
then causes another pointless sleep in poll() for <10ms. Timers
do not need to have such precise expiration, so we treat a timer
as expired if it is within 20ms of the expected expiry time. This
also fixes the eventtest.c test suite on kernels with HZ=100

* daemon/event.c: Add 20ms fuzz when checking for timer expiry
2009-12-02 11:53:42 +00:00
Wolfgang Mauerer
4060131927 Fix help message
The configuration file setting is overriden by -f or --config, but
not with -c

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
2009-11-26 18:51:51 +00:00
Daniel P. Berrange
4be6e024c7 Fix cleanup when state driver init fails
* daemon/libvirtd.c: Fix incorrect goto label causing cleanup to
  be missed when state driver init fails
2009-11-13 15:10:54 +00:00
Daniel P. Berrange
ce62916b6e Fix initscript to check daemon pidfile
The libvirtd initscript could get confused between the system and
session instances of the daemon. To avoid this it is neccessary
to check the pidfile explicitly.

* daemon/libvirtd.init.in: Always check the pidfile of the system
  daemon to avoid confusion with the session daemons
2009-11-13 10:37:11 +00:00
David Allan
3ad6dcf3dc Implement a node device backend using libudev
* configure.in: add new --with-udev, disabled by default, and requiring
  libudev > 145
* src/node_device/node_device_udev.c src/node_device/node_device_udev.h:
  the new node device backend
* src/node_device/node_device_linux_sysfs.c: moved node_device_hal_linux.c
  to a better file name
* src/conf/node_device_conf.c src/conf/node_device_conf.h: add a couple
  of fields in node device definitions, and an API to look them up,
  remove a couple of unused fields from previous patch.
* src/node_device/node_device_driver.c src/node_device/node_device_driver.h:
  plug the new driver
* po/POTFILES.in src/Makefile.am src/libvirt_private.syms: add the new
  files and symbols
* src/util/util.h src/util/util.c: add a new convenience macro
  virBuildPath and virBuildPathInternal() function
2009-11-12 22:48:24 +01:00
Cole Robinson
ce4c0bf5a2 Add virConnectGetLibvirtVersion API
There is currently no way to determine the libvirt version of a remote
libvirtd we are connected to. This is a useful piece of data to enable
feature detection.
2009-11-12 10:53:26 -05:00
Daniel P. Berrange
730fd3b022 Disable IPv6 socket auto-binding to IPv4 socket
Sometimes getaddrinfo returns IPv4 addresses before IPv6 addresses.
IPv6 sockets default to attempting to bind to IPv4 addresses too.
So if the IPv4 address is activated first, then binding to IPv6
will unneccessarily fail.

* daemon/libvirtd.c: Bind to IPv6 and IPv4 addresses separately
2009-11-12 11:17:39 +00:00
Daniel P. Berrange
cabc2cc98f 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-11-10 17:00:27 +00:00
Daniel Veillard
117aa0d874 Various fixes following a code review part 2
* daemon/libvirtd.c tools/virsh.c: Steve Grubb <sgrubb@redhat.com> found
  a few more issues
2009-11-10 17:48:13 +01:00
Matthias Bolte
790f0b3057 Add missing OOM error checks, reports and cleanups 2009-11-09 23:17:45 +01:00
Cole Robinson
517761fd96 Improve error reporting for virConnectGetHostname calls
All drivers have copy + pasted inadequate error reporting which wraps
util.c:virGetHostname. Move all error reporting to this function, and improve
what we report.

Changes from v1:
  Drop the driver wrappers around virGetHostname. This means we still need
  to keep the new conn argument to virGetHostname, but I think it's worth
  it.
2009-11-03 16:46:54 -05:00
Daniel P. Berrange
075bb5f1aa Move libvirtd event loop into background thread
The virStateInitialize() call for starting up stateful drivers
may require that the event loop is running already. This it is
neccessary to start the event loop before this call. At the
same time, network clients must not be processed until afte
virStateInitialize has completed.

The qemudListenUnix() and remoteListenTCP() methods must
therefore not register file handle watches, merely open the
network sockets & listen() on them. This means clients can
connected and are queued, pending completion of initialization

The qemudRunLoop() method is moved into a background thread
that is started early to allow access to the event loop during
driver initialization. The main process thread leader pretty
much does nothing once the daemon is running, merely waits
for the event loop thread to quit

* daemon/libvirtd.c, daemon/libvirtd.h: Move event loop into
  a background thread
* daemon/THREADING.txt: Rewrite docs to better reflect reality
2009-11-03 14:45:43 -05:00
Matthew Booth
958c366b21 Fix --with-init-script configure option
* configure.in daemon/Makefile.am: the --with-init-script configure
  option was broken, and always defaulted based on the existence of
  /etc/redhat-release. This was a systematic typo based on
  mixed use of init-script and init-scripts.
2009-11-02 17:57:05 +01:00
Daniel P. Berrange
4296cea2b2 Don't let parent of daemon exit until basic initialization is done
The daemonizing code lets the parent exit almost immediately. This
means that it may think it has successfully started even when
important failures occur like not being able to acquire the PID
file. It also means network sockets are not yet open.

To address this when daemonizing the parent passes an open pipe
file descriptor to the child. The child does its basic initialization
and then writes a status code to the pipe indicating either success,
or failure. This ensures that when daemonizing, the parent does not
exit until the pidfile is acquired & basic network sockets are open.

Initialization of the libvirt drivers is still done asynchronously
since this may take a very long time.

* daemon/libvirtd.c: Force parent to stay around until basic config
  file, pidfile & network socket init is completed
2009-11-02 11:41:35 -05:00
Daniel P. Berrange
a71f79c37e Pull signal setup code out into separate method
* daemon/libvirtd.c: Introduce a daemonSetupSignals() method
  and put all signal handling code there
* daemon/libvirtd.h: Add sigread/sigwrite to qemud_server type
2009-11-02 11:41:35 -05:00
Daniel P. Berrange
4ab7995871 Fix duplicating logging of errors in libvirtd
The libvirt default error handling callback will print all errors
to stderr. The libvirtd default logging callback will do the same.
Set a no-op error handling callback in libvirtd to prevent this
duplication

* daemon/libvirtd.c: Register a no-op error handling function
2009-11-02 11:22:02 -05:00
Daniel P. Berrange
5f67253813 Fix initialization order bugs
virInitialize must be the first libvirt function called to ensure
threads, error handling & random number generator are all setup.

Move UNIX socket directory permissions change to place of use
2009-11-02 11:21:22 -05:00
Daniel P. Berrange
0264e1678c Misc cleanup to network socket init
* daemon/libvirtd.c: Change qemudNetworkInit() so that it doesn't try
to free its argument, leaving the caller todo cleanup as is normal
practice. Add missing policykit cleanup to qemudCleanup, and remove
server watch if set. Remove duplicated call to listen() on TCP sockets
2009-11-02 11:15:01 -05:00
Daniel P. Berrange
46992453b9 Annotate many methods with ATTRIBUTE_RETURN_CHECK & fix problems
Nearly all of the methods in src/util/util.h have error codes that
must be checked by the caller to correct detect & report failure.
Add ATTRIBUTE_RETURN_CHECK to ensure compile time validation of
this

* daemon/libvirtd.c: Add explicit check on return value of virAsprintf
* src/conf/domain_conf.c: Add missing check on virParseMacAddr return
  value status & report error
* src/network/bridge_driver.c: Add missing OOM check on virAsprintf
  and report error
* src/qemu/qemu_conf.c: Add missing check on virParseMacAddr return
  value status & report error
* src/security/security_selinux.c: Remove call to virRandomInitialize
  that's done in libvirt.c already
* src/storage/storage_backend_logical.c: Add check & log on virRun
  return status
* src/util/util.c: Add missing checks on virAsprintf/Run status
* src/util/util.h: Annotate all methods with ATTRIBUTE_RETURN_CHECK
  if they return an error status code
* src/vbox/vbox_tmpl.c: Add missing check on virParseMacAddr
* src/xen/xm_internal.c: Add missing checks on virAsprintf
* tests/qemuargv2xmltest.c: Remove bogus call to virRandomInitialize()
2009-11-02 11:09:03 -05:00
Dan Kenigsberg
0b74bc622c Fix some typos in comments 2009-10-27 00:02:46 +01:00
Chris Lalancette
b2af10cd49 Replace a gethostname by virGetHostname in libvirtd.c
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-10-26 10:33:20 +01:00
Chris Lalancette
43a9249c95 Add a default log_level to qemudSetLogging to remove a build warning.
(original patch from Charles Duffy)

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-10-26 10:31:16 +01:00
Chris Lalancette
2ff5cffe6e Better error message when libvirtd fails to start.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-10-26 10:30:49 +01:00