]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 years agoVarious fixes following a code review
Daniel Veillard [Tue, 10 Nov 2009 11:56:11 +0000 (12:56 +0100)]
Various fixes following a code review

* src/libvirt.c src/lxc/lxc_conf.c src/lxc/lxc_container.c
  src/lxc/lxc_controller.c src/node_device/node_device_hal.c
  src/openvz/openvz_conf.c src/qemu/qemu_driver.c
  src/qemu/qemu_monitor_text.c src/remote/remote_driver.c
  src/storage/storage_backend_disk.c src/storage/storage_driver.c
  src/util/logging.c src/xen/sexpr.c src/xen/xend_internal.c
  src/xen/xm_internal.c: Steve Grubb <sgrubb@redhat.com> sent a code
  review and those are the fixes correcting the problems

15 years agoAllow timeouts waiting for QEMU job lock
Daniel P. Berrange [Tue, 3 Nov 2009 18:34:20 +0000 (13:34 -0500)]
Allow timeouts waiting for QEMU job lock

Some monitor commands may take a very long time to complete. It is
not desirable to block other incoming API calls forever. With this
change, if an existing API call is holding the job lock, additional
API calls will not wait forever. They will time out after a short
period of time, allowing application to retry later.

* include/libvirt/virterror.h, src/util/virterror.c: Add new
  VIR_ERR_OPERATION_TIMEOUT error code
* src/qemu/qemu_driver.c: Change to a timed condition variable
  wait for acquiring the monitor job lock

15 years agoRelease driver and domain lock when running monitor commands
Daniel P. Berrange [Tue, 3 Nov 2009 18:26:32 +0000 (13:26 -0500)]
Release driver and domain lock when running monitor commands

QEMU monitor commands may sleep for a prolonged period of time.
If the virDomainObjPtr or qemu driver lock is held this will
needlessly block execution of many other API calls. it also
prevents asynchronous monitor events from being dispatched
while a monitor command is executing, because deadlock will
ensure.

To resolve this, it is neccessary to release all locks while
executing a monitor command. This change introduces a flag
indicating that a monitor job is active, and a condition
variable to synchronize access to this flag. This ensures that
only a single thread can be making a state change or executing
a monitor command at a time, while still allowing other API
calls to be completed without blocking

* src/qemu/qemu_driver.c: Release driver and domain lock when
  running monitor commands. Re-add locking to disk passphrase
  callback
* src/qemu/THREADS.txt: Document threading rules

15 years agoFully asynchronous monitor I/O processing
Daniel P. Berrange [Wed, 14 Oct 2009 17:40:51 +0000 (18:40 +0100)]
Fully asynchronous monitor I/O processing

Change the QEMU monitor file handle watch to poll for both
read & write events, as well as EOF. All I/O to/from the
QEMU monitor FD is now done in the event callback thread.

When the QEMU driver needs to send a command, it puts the
data to be sent into a qemuMonitorMessagePtr object instance,
queues it for dispatch, and then goes to sleep on a condition
variable. The event thread sends all the data, and then waits
for the reply to arrive, putting the response / error data
back into the qemuMonitorMessagePtr and notifying the condition
variable.

There is a temporary hack in the disk passphrase callback to
avoid acquiring the domain lock.  This avoids a deadlock in
the command processing, since the domain lock is still held
when running monitor commands. The next commit will remove
the locking when running commands & thus allow re-introduction
of locking the disk passphrase callback

* src/qemu/qemu_driver.c: Temporarily don't acquire lock in
  disk passphrase callback. To be reverted in next commit
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Remove
  raw I/O functions, and a generic qemuMonitorSend() for
  invoking a command
* src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Remove all low level I/O, and use the new qemuMonitorSend()
  API. Provide a qemuMonitorTextIOProcess() method for detecting
  command/reply/prompt boundaries in the monitor data stream

15 years agophyp: ssh authentication with public key fixed
Eduardo Otubo [Tue, 10 Nov 2009 12:15:34 +0000 (13:15 +0100)]
phyp: ssh authentication with public key fixed

Use ssh keyfiles from the current user's home directory instead of trying
to use keyfiles from a hardcoded /home/user directory. Fallback to
username/password authentication if keyfiles are not available or keyfile
authentication failed.

15 years agoAdd reference counting on virDomainObjPtr objects
Daniel P. Berrange [Thu, 15 Oct 2009 11:30:26 +0000 (12:30 +0100)]
Add reference counting on virDomainObjPtr objects

Add reference counting on the virDomainObjPtr objects. With the
forthcoming asynchronous QEMU monitor, it will be neccessary to
release the lock on virDomainObjPtr while waiting for a monitor
command response. It is neccessary to ensure one thread can't
delete a virDomainObjPtr while another is waiting. By introducing
reference counting threads can make sure objects they are using
are not accidentally deleted while unlocked.

* src/conf/domain_conf.h, src/conf/domain_conf.c: Add
  virDomainObjRef/Unref APIs, remove virDomainObjFree
* src/openvz/openvz_conf.c: replace call to virDomainObjFree
  with virDomainObjUnref

15 years agoLocking of the qemuMonitorPtr object
Daniel P. Berrange [Tue, 13 Oct 2009 14:27:58 +0000 (15:27 +0100)]
Locking of the qemuMonitorPtr object

In preparation of the monitor I/O process becoming fully asynchronous,
it is neccessary to ensure all access to internals of the qemuMonitorPtr
object is protected by a mutex lock.

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add mutex for locking
  monitor.
* src/qemu/qemu_driver.c: Add locking around all monitor commands

15 years agoWrap text mode monitor APIs, pass qemuMonitorPtr directly to APIs
Daniel P. Berrange [Fri, 9 Oct 2009 20:13:06 +0000 (21:13 +0100)]
Wrap text mode monitor APIs, pass qemuMonitorPtr directly to APIs

Change the QEMU driver to not directly invoke the text mode monitor
APIs. Instead add a generic wrapper layer, which will eventually
invoke either the text or JSON protocol code as needed. Pass an
qemuMonitorPtr object into the monitor APIs instead of virDomainObjPtr
to complete the de-coupling of the monitor impl from virDomainObj
data structures

* src/qemu/qemu_conf.h: Remove qemuDomainObjPrivate definition
* src/qemu/qemu_driver.c: Add qemuDomainObjPrivate definition.
  Pass qemuMonitorPtr into all monitor APIs instead of the
  virDomainObjPtr instance.
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add thin
  wrappers for all qemuMonitorXXX command APIs, calling into
  qemu_monitor_text.c/h
* src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Rename qemuMonitor -> qemuMonitorText & update to accept
  qemuMonitorPtr instead of virDomainObjPtr

15 years agoMove encryption lookup back into qemu driver file
Daniel P. Berrange [Fri, 9 Oct 2009 19:34:24 +0000 (20:34 +0100)]
Move encryption lookup back into qemu driver file

Decouple the monitor code from the virDomainDefPtr structure
by moving the disk encryption lookup code back into the
qemu_driver.c file. Instead provide a function callback to
the monitor code which can be invoked to retrieve encryption
data as required.

* src/qemu/qemu_driver.c: Add findDomainDiskEncryption,
  and findVolumeQcowPassphrase. Pass address of the method
  findVolumeQcowPassphrase into qemuMonitorOpen()
* src/qemu/qemu_monitor.c: Associate a disk
  encryption function callback with the qemuMonitorPtr
  object.
* src/qemu/qemu_monitor_text.c: Remove findDomainDiskEncryption
  and findVolumeQcowPassphrase.

15 years agoMake use of private data structure for monitor state
Daniel P. Berrange [Fri, 9 Oct 2009 19:13:29 +0000 (20:13 +0100)]
Make use of private data structure for monitor state

Introduce a new qemuDomainObjPrivate object which is used to store
the private QEMU specific data associated with each virDomainObjPtr
instance. This contains a single member, an instance of the new
qemuMonitorPtr object which encapsulates the QEMU monitor state.
The internals of the latter are private to the qemu_monitor* files,
not to be shown to qemu_driver.c

* src/qemu/qemu_conf.h: Definition of qemuDomainObjPrivate.
* src/qemu/qemu_driver.c: Register a functions for creating
  and freeing qemuDomainObjPrivate instances with the domain
  capabilities. Remove the qemudDispatchVMEvent() watch since
  I/O watches are now handled by the monitor code itself. Pass
  a new qemuHandleMonitorEOF() callback into qemuMonitorOpen
  to allow notification when the monitor quits.
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Introduce
  the 'qemuMonitor' object. Temporarily add new APIs
  qemuMonitorWrite, qemuMonitorRead, qemuMonitorWaitForInput
  to allow text based monitor impl to perform I/O.
* src/qemu/qemu_monitor_text.c: Call APIs for reading/writing
  to monitor instead of accessing the file handle directly.

15 years agoMove code for low level QEMU monitor interaction into separate file
Daniel P. Berrange [Fri, 9 Oct 2009 18:07:55 +0000 (19:07 +0100)]
Move code for low level QEMU monitor interaction into separate file

The qemu_driver.c code should not contain any code that interacts
with the QEMU monitor at a low level. A previous commit moved all
the command invocations out. This change moves out the code which
actually opens the monitor device.

* src/qemu/qemu_driver.c: Remove qemudOpenMonitor & methods called
  from it.
* src/Makefile.am: Add qemu_monitor.{c,h}
* src/qemu/qemu_monitor.h: Add qemuMonitorOpen()
* src/qemu/qemu_monitor.c: All code for opening the monitor

15 years agoAdd a new timed condition variable wait API
Daniel P. Berrange [Tue, 3 Nov 2009 18:40:15 +0000 (13:40 -0500)]
Add a new timed condition variable wait API

* src/util/threads.h, src/util/threads-pthread.c,
  src/libvirt_private.syms: Add virCondWaitUntil()

15 years agoFix errno handling for pthreads wrappers
Daniel P. Berrange [Wed, 28 Oct 2009 19:54:07 +0000 (19:54 +0000)]
Fix errno handling for pthreads wrappers

* src/util/threads-pthread.c: pthreads APIs do not set errno, instead
  the return value is the positive errno. Set errno based on the return
  value in the wrappers

15 years agoMake pciDeviceList struct opaque
Daniel P. Berrange [Tue, 27 Oct 2009 17:30:16 +0000 (17:30 +0000)]
Make pciDeviceList struct opaque

* src/util/pci.c, src/util/pci.h: Make the pciDeviceList struct
  opaque to callers of the API. Add accessor methods for managing
  devices in the list
* src/qemu/qemu_driver.c: Update to use APIs instead of directly
  accessing pciDeviceList fields

15 years agoAdd missing OOM error checks, reports and cleanups
Matthias Bolte [Sun, 8 Nov 2009 21:08:54 +0000 (22:08 +0100)]
Add missing OOM error checks, reports and cleanups

15 years agoAdd documentation for <channel> domain element
Matthew Booth [Mon, 9 Nov 2009 14:38:20 +0000 (15:38 +0100)]
Add documentation for <channel> domain element

* src/formatdomain.html.in: Add <channel> element documentation

15 years agoSeparate character device doc guest and host parts
Matthew Booth [Mon, 9 Nov 2009 14:35:21 +0000 (15:35 +0100)]
Separate character device doc guest and host parts

* docs/formatdomain.html.in: refactors the existing character device
  documentation to make it explicit which directives configure the guest
  interface, and which configure the host interface.

15 years agoRemoves the ebtablesSaveRules() function
Gerhard Stenzel [Mon, 9 Nov 2009 14:30:15 +0000 (15:30 +0100)]
Removes the ebtablesSaveRules() function

As it was basically unimplemented and more confusing than useful
at the moment.
* src/libvirt_private.syms: remove from internal symbols list
* src/qemu/qemu_bridge_filter.c src/util/ebtables.c: remove code and
  one use of the unimplemented function

15 years agoopennebula: Fix potential memory/mutex leak in state driver startup
Matthias Bolte [Mon, 2 Nov 2009 23:54:09 +0000 (00:54 +0100)]
opennebula: Fix potential memory/mutex leak in state driver startup

In case of an error the domains hash and the driver mutex may leak.

* src/opennebula/one_driver.c: free/destroy domains hash and driver
  mutex in error cases

15 years agoAdd a Python example that lists active ESX domains
Matthias Bolte [Sat, 7 Nov 2009 23:42:19 +0000 (00:42 +0100)]
Add a Python example that lists active ESX domains

It also demonstrates how to use the libvirt.openAuth() method.

* examples/python/Makefile.am: add esxlist.py to EXTRA_DIST
* examples/python/README: add some notes about esxlist.py
* examples/python/esxlist.py: the new example

15 years agophyp: Use actual error code instead of 0
Matthias Bolte [Fri, 6 Nov 2009 02:19:22 +0000 (03:19 +0100)]
phyp: Use actual error code instead of 0

15 years agophyp: Don't use VIR_ALLOC if a stack variable is good enough
Matthias Bolte [Fri, 6 Nov 2009 02:07:26 +0000 (03:07 +0100)]
phyp: Don't use VIR_ALLOC if a stack variable is good enough

15 years agophyp: Fix several UUID table related problems
Matthias Bolte [Fri, 6 Nov 2009 01:59:35 +0000 (02:59 +0100)]
phyp: Fix several UUID table related problems

- Make reading ID from file working for IDs > 127
- Fix inverse error check for writing ID to file
- Use feof() to distinguish EOF from real error of fread()
- Don't interpret libssh2 error codes as number of bytes

15 years agophyp: Check for exit_status < 0 before parsing the result
Matthias Bolte [Fri, 6 Nov 2009 01:33:20 +0000 (02:33 +0100)]
phyp: Check for exit_status < 0 before parsing the result

15 years agophyp: memcpy/memmove/memset can't fail, so don't check for error
Matthias Bolte [Fri, 6 Nov 2009 01:28:05 +0000 (02:28 +0100)]
phyp: memcpy/memmove/memset can't fail, so don't check for error

Also reset UUID to all 0 instead of all 48 (== '0') in phypUUIDTable_RemLpar()

15 years agophyp: Make generic domain listing functions return -1 in case of error
Matthias Bolte [Fri, 6 Nov 2009 01:15:19 +0000 (02:15 +0100)]
phyp: Make generic domain listing functions return -1 in case of error

phypNumDomainsGeneric() and phypListDomainsGeneric() return 0 in case
of an error. This makes it impossible to distinguish between an actual
error and no domains being defined on the hypervisor. It also turn the
no domains situation into an error. Return -1 in case of an error to
fix this problem.

15 years agophyp: Break potential infinite loops
Matthias Bolte [Fri, 6 Nov 2009 00:53:24 +0000 (01:53 +0100)]
phyp: Break potential infinite loops

15 years agophyp: Fix memory/session leaks and potential invalid frees
Matthias Bolte [Thu, 5 Nov 2009 23:19:16 +0000 (00:19 +0100)]
phyp: Fix memory/session leaks and potential invalid frees

15 years agoFix configure check for libssh2
Matthias Bolte [Thu, 5 Nov 2009 22:38:07 +0000 (23:38 +0100)]
Fix configure check for libssh2

* configure.in: add -L$libssh2_path to LIBS for the AC_TRY_LINK check

15 years ago524280 pass max lease option to dnsmasq
Daniel Veillard [Fri, 6 Nov 2009 16:53:45 +0000 (17:53 +0100)]
524280 pass max lease option to dnsmasq

* src/network/bridge_driver.c: when exec'ing dnsmaq, if there are
  DHCP ranges defined, then compute and pass the --dhcp-lease-max
  deriving the maximum number of leases

15 years agoStore the range size when adding a DHCP range
Daniel Veillard [Fri, 6 Nov 2009 16:50:54 +0000 (17:50 +0100)]
Store the range size when adding a DHCP range

* src/conf/network_conf.h: extend the structure to store the range
* src/conf/network_conf.c: before adding a range parse the IP addresses
  do some checking and keep the size

15 years agoRepair getIPv4Addr after the ntohl conversion
Daniel Veillard [Fri, 6 Nov 2009 16:47:45 +0000 (17:47 +0100)]
Repair getIPv4Addr after the ntohl conversion

* src/util/network.c: getIPv4Addr() got broken when the input
  network address value got converted from network to host byte order

15 years agoqemu: Allow cpu pinning for all logical CPUs, not just physical
Cole Robinson [Thu, 5 Nov 2009 15:21:33 +0000 (10:21 -0500)]
qemu: Allow cpu pinning for all logical CPUs, not just physical

This is what virsh already expects when printing output, and what
'man cpuset' claims to support.

15 years agoqemu: Use same create/define overwrite logic for migration prepare.
Cole Robinson [Mon, 2 Nov 2009 19:10:36 +0000 (14:10 -0500)]
qemu: Use same create/define overwrite logic for migration prepare.

15 years agoqemu: Break out function to check if we can create/define/restore
Cole Robinson [Mon, 2 Nov 2009 18:37:38 +0000 (13:37 -0500)]
qemu: Break out function to check if we can create/define/restore

Use this function in the qemu, uml, lxc, and test drivers.

15 years agoCleanup whitespace in docs
Matthew Booth [Fri, 6 Nov 2009 15:04:19 +0000 (16:04 +0100)]
Cleanup whitespace in docs

This patch is the result of running the following command in the docs
directory: sed -i 's/\t/        /g; s/\s*$//' *.html.in

* docs/*.html.in:convert tabs into 8 spaces and remove trailing whitespace

15 years agoUse virBuffer when building QEMU char dev command line
Matthew Booth [Fri, 6 Nov 2009 13:44:25 +0000 (14:44 +0100)]
Use virBuffer when building QEMU char dev command line

* src/qemu/qemu_conf.c: Update qemudBuildCommandLineChrDevStr to use a
  virBuffer

15 years agoCleanup virBuffer usage in qemdBuildCommandLine
Matthew Booth [Fri, 6 Nov 2009 11:19:21 +0000 (12:19 +0100)]
Cleanup virBuffer usage in qemdBuildCommandLine

* src/qemu_qemu_conf.c: Cleanup usage of virBuffer in qemudBuildCommandLine

15 years agoAdd sentinel attribute for NULL terminated arg lists
Paolo Bonzini [Fri, 6 Nov 2009 09:39:13 +0000 (10:39 +0100)]
Add sentinel attribute for NULL terminated arg lists

* src/internal.h (ATTRIBUTE_SENTINEL): New, it's a ggc feature and
  protected as such
* src/util/buf.c (virBufferStrcat): Use it.
* src/util/ebtables.c (ebtablesAddRemoveRule): Use it.
* src/util/iptables.c (iptableAddRemoveRule: Use it.
* src/util/qparams.h (new_qparam_set, append_qparams): Use it.
* docs/apibuild.py: avoid breaking the API generator with that new
  internal keyword macro

15 years agotest: Update inactive guest config on shutdown
Cole Robinson [Tue, 3 Nov 2009 21:42:02 +0000 (16:42 -0500)]
test: Update inactive guest config on shutdown

This matches the expected behavior of state drivers such as QEMU.

15 years agotest: Add testDomainShutdownState helper
Cole Robinson [Tue, 3 Nov 2009 17:06:00 +0000 (12:06 -0500)]
test: Add testDomainShutdownState helper

Performs changes needed when stopping a VM (which are currently duplicated
in several places, and forgotten in others).

15 years agoFix some cut-and-paste error in migration code
Paolo Bonzini [Thu, 5 Nov 2009 17:06:31 +0000 (18:06 +0100)]
Fix some cut-and-paste error in migration code

* src/qemu/qemu_driver.c: in qemudDomainMigratePerform call
  doPeer2PeerMigrate for VIR_MIGRATE_PEER2PEER.

15 years agoProperly convert port numbers to/from network byte order
Matthew Booth [Thu, 5 Nov 2009 16:56:08 +0000 (17:56 +0100)]
Properly convert port numbers to/from network byte order

* src/util/network.c: Add htons and ntohs in virSocket(Get|Set)Port

15 years agoPOWER add create() and destroy() support
Eduardo Otubo [Thu, 5 Nov 2009 16:18:07 +0000 (17:18 +0100)]
POWER add create() and destroy() support

* src/phyp/phyp_driver.[ch]: add new entry points and a number of
  cleanups

15 years agoEnsure guestfwd address is IPv4 and various cleanups
Matthew Booth [Thu, 5 Nov 2009 15:04:34 +0000 (16:04 +0100)]
Ensure guestfwd address is IPv4 and various cleanups

* include/libvirt/virterror.h src/util/virterror.c: add a new error
  VIR_ERR_CONFIG_UNSUPPORTED for valid but unsupported configuration options
* src/conf/domain_conf.c: Throw an error if guestfwd address isn't IPv4
  and cleanup a number of parsing return error values.

15 years agoForgot test case on previous commit
Daniel Veillard [Thu, 5 Nov 2009 14:45:53 +0000 (15:45 +0100)]
Forgot test case on previous commit

15 years agoSupport for <channel> in domain and QEmu backend
Matthew Booth [Thu, 5 Nov 2009 14:31:03 +0000 (15:31 +0100)]
Support for <channel> in domain and QEmu backend

allows the following to be specified in a domain:
<channel type='pipe'>
  <source path='/tmp/guestfwd'/>
  <target type='guestfwd' address='10.0.2.1' port='4600'/>
</channel>

* proxy/Makefile.am: add network.c as dep of domain_conf.c
* docs/schemas/domain.rng src/conf/domain_conf.[ch]: extend the domain
  schemas and the parsing/serialization side for the new construct

QEmu support will add the following on the qemu command line:
 -chardev pipe,id=channel0,path=/tmp/guestfwd
 -net user,guestfwd=tcp:10.0.2.1:4600-chardev:channel0

* src/qemu/qemu_conf.c: Add argument output for channel
* tests/qemuxml2(argv|xml)test.c: Add test for <channel> domain syntax

15 years agoDetect availability of QEMU -chardev CLI option
Matthew Booth [Thu, 5 Nov 2009 13:41:24 +0000 (14:41 +0100)]
Detect availability of QEMU -chardev CLI option

* src/qemu/qemu_conf.h: defines a new QEMUD_CMD_FLAG_CHARDEV flag
* src/qemu/qemu_conf.c: parse the output for -chardev and set flag
  appropriately

15 years agoAllow character devices to have different target types
Matthew Booth [Thu, 5 Nov 2009 13:19:14 +0000 (14:19 +0100)]
Allow character devices to have different target types

A character device's target (it's interface in the guest) had only a
single property: port. This patch is in preparation for adding targets
which require other properties.
Since this changes the conf type for character devices this affects
a number of drivers:

* src/conf/domain_conf.[ch] src/esx/esx_vmx.c src/qemu/qemu_conf.c
  src/qemu/qemu_driver.c src/uml/uml_conf.c src/uml/uml_driver.c
  src/vbox/vbox_tmpl.c src/xen/xend_internal.c src/xen/xm_internal.c:
  target properties are moved into a union in virDomainChrDef, and a
  targetType field is added to identify which union member should be
  used. All current code which touches a virDomainChrDef is updated both
  to use the new union field, and to populate targetType if necessary.

15 years agoLXC allow container to have ethN interfaces
Ryota Ozaki [Thu, 5 Nov 2009 13:11:30 +0000 (14:11 +0100)]
LXC allow container to have ethN interfaces

Current implementation of lxc driver creates vethN named
interface(s) in the host and passes as it is to a container.
The reason why it doesn't use ethN is due to the limitation
that one namespace cannot have multiple iterfaces that have
an identical name so that we give up creating ethN named
interface in the host for the container.

However, we should be able to allow the container to have
ethN by changing the name after clone(CLONE_NEWNET).

* src/lxc/lxc_container.c src/lxc/veth.c src/lxc/veth.h: do the clone
  and then renames interfaces eth0 ... ethN to keep the interface names
  familiar in the domain

15 years agoLXC cleanup deep indentation in lxcDomainSetAutostart
Ryota Ozaki [Thu, 5 Nov 2009 12:41:14 +0000 (13:41 +0100)]
LXC cleanup deep indentation in lxcDomainSetAutostart

* src/lxc/lxc_driver.c: refactor lxcDomainSetAutostart() to avoid deep
  indentation of the code

15 years agoLXC messages cleanup and fix lxcError
Ryota Ozaki [Thu, 5 Nov 2009 12:39:09 +0000 (13:39 +0100)]
LXC messages cleanup and fix lxcError

* src/lxc/lxc_container.c src/lxc/lxc_controller.c src/lxc/lxc_driver.c
  src/lxc/veth.c: most of cleanups are just capitalizing their messages
  though, some fixes wrong error messages and awkward indentations, and
  improves error messages.

15 years agoLXC fix wrong or out-of-date function descriptions
Ryota Ozaki [Thu, 5 Nov 2009 12:35:13 +0000 (13:35 +0100)]
LXC fix wrong or out-of-date function descriptions

* src/lxc/lxc_container.c src/lxc/lxc_controller.c src/lxc/lxc_driver.c
  src/lxc/veth.c: fix broken function comments

15 years agodocs: <clock> property is 'offset', not 'sync'
Cole Robinson [Wed, 4 Nov 2009 18:26:28 +0000 (13:26 -0500)]
docs: <clock> property is 'offset', not 'sync'

15 years agoadd MAC address based port filtering to qemu
Gerhard Stenzel [Tue, 3 Nov 2009 22:41:23 +0000 (23:41 +0100)]
add MAC address based port filtering to qemu

* src/qemu/qemu.conf src/qemu/qemu_conf.c src/qemu/qemu_conf.h: there is
  a new config type option for mac filtering
* src/qemu/qemu_bridge_filter.[ch]: new module for the ebtable entry points
* src/qemu/qemu_driver.c: plug the MAC filtering at the right places
  in the domain life cycle
* src/Makefile.am po/POTFILES.in: add the new module

15 years agoNew ebtables module wrapper
Gerhard Stenzel [Tue, 3 Nov 2009 22:11:01 +0000 (23:11 +0100)]
New ebtables module wrapper

* configure.in: look for ebtables binary location if present
* src/Makefile.am: add the new module
* src/util/ebtables.[ch]: new module and internal APIs around
  the ebtables binary
* src/libvirt_private.syms: export the symbols only internally

15 years agotest: Implement virDomainPinVcpu
Cole Robinson [Tue, 27 Oct 2009 22:25:38 +0000 (18:25 -0400)]
test: Implement virDomainPinVcpu

15 years agotest: Implement virDomainGetVcpus
Cole Robinson [Wed, 21 Oct 2009 19:04:14 +0000 (15:04 -0400)]
test: Implement virDomainGetVcpus

15 years agotest: Update vcpu runtime info in SetVcpus
Cole Robinson [Tue, 27 Oct 2009 22:02:14 +0000 (18:02 -0400)]
test: Update vcpu runtime info in SetVcpus

15 years agotest: Use privateData to track running VM vcpu state
Cole Robinson [Tue, 27 Oct 2009 18:06:30 +0000 (14:06 -0400)]
test: Use privateData to track running VM vcpu state

15 years agotest: Break out wrapper for setting up started domain state.
Cole Robinson [Tue, 27 Oct 2009 17:15:44 +0000 (13:15 -0400)]
test: Break out wrapper for setting up started domain state.

This should be a no op for now, but we will use this function to set up
transient state in the future.

15 years agotest: Fixes for SetVcpus
Cole Robinson [Tue, 27 Oct 2009 22:00:02 +0000 (18:00 -0400)]
test: Fixes for SetVcpus

- Implement DomainGetMaxVCPUs
- Use GetMaxVCPUs to validate requested CPU amount
- Deny the 'hotplug' for a running domain.

15 years agoqemu: Remove compiled out localhost migration support
Cole Robinson [Mon, 2 Nov 2009 18:49:44 +0000 (13:49 -0500)]
qemu: Remove compiled out localhost migration support

Pretty sure this would deadlock now that we have proper locking, so
remove the code.

15 years agostorage: conf: Fix memory leak in encryption parsing
Cole Robinson [Wed, 28 Oct 2009 18:22:45 +0000 (14:22 -0400)]
storage: conf: Fix memory leak in encryption parsing

15 years agoVarious error reporting fixes
Cole Robinson [Tue, 27 Oct 2009 16:20:22 +0000 (12:20 -0400)]
Various error reporting fixes

- Don't duplicate SystemError
- Use proper error code in domain_conf
- Fix a broken error call in qemu_conf
- Don't use VIR_ERR_ERROR in security driver (isn't a valid code in this case)

15 years agoImprove error reporting for virConnectGetHostname calls
Cole Robinson [Fri, 23 Oct 2009 17:01:22 +0000 (13:01 -0400)]
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.

15 years agoFix improper error return in virInterfaceDefParseProtoIPvX
Laine Stump [Tue, 3 Nov 2009 20:01:32 +0000 (21:01 +0100)]
Fix improper error return in virInterfaceDefParseProtoIPvX

* src/conf/interface_conf.c: the code was erronously returning -1
  in the two functions if <dhcp> is not provided

15 years agoMake monitor type (miimon/arpmon) optional in bond xml
Laine Stump [Tue, 3 Nov 2009 19:15:38 +0000 (20:15 +0100)]
Make monitor type (miimon/arpmon) optional in bond xml

* src/conf/interface_conf.c: lack of one of these in the live xml output
  was causing the parse in virInterfaceDefParseBond() to fail

15 years agoFix virInterfaceIpDefPtr leak during virInterfaceIpDefFree
Laine Stump [Tue, 3 Nov 2009 19:02:52 +0000 (20:02 +0100)]
Fix virInterfaceIpDefPtr leak during virInterfaceIpDefFree

* src/conf/interface_conf.c: forgot to free the structure itself

15 years agoSupport for IPv6 / multiple addresses per interfaces
Laine Stump [Wed, 28 Oct 2009 13:13:18 +0000 (14:13 +0100)]
Support for IPv6 / multiple addresses per interfaces

This patch updates the xml parsing and formatting, and the associated
virInterfaceDef data structure to support IPv6, along the way adding
support for multiple protocols per interface, and multiple IP
addresses per protocol.
* src/conf/interface_conf.[ch]: update the structures, code for parsing
  and serialization

15 years agoSupport reporting live interface IP/netmask
Laine Stump [Wed, 28 Oct 2009 09:40:54 +0000 (10:40 +0100)]
Support reporting live interface IP/netmask

This patch adds the flag VIR_INTERFACE_XML_INACTIVE to
virInterfaceGetXMLDesc's flags. When it is*not* set (the default), the
live interface info will be returned in the XML (in particular, the IP
address(es) and netmask(s) will be retrieved by querying the interface
directly, rather than  reporting what's in the config file). The
backend of this is in netcf's ncf_if_xml_state() function.

* configure.in libvirt.spec.in: requires netcf >= 0.1.3
* include/libvirt/libvirt.h.in: adds flag VIR_INTERFACE_XML_INACTIVE
* src/conf/interface_conf.c src/interface/netcf_driver.c src/libvirt.c:
  update the parsing and backend routines accordingly
* tools/virsh.c: change interface edit to inactive definition and
  adds the inactive flag for interface dump

15 years agoMake startmode optional in toplevel interface definition
Laine Stump [Wed, 28 Oct 2009 08:55:33 +0000 (09:55 +0100)]
Make startmode optional in toplevel interface definition

The minimal XML returned from ncf_if_xml_state() doesn't contain this
attribute (which makes no sense in the case of reporting current
status of the interface), and it was preventing it from passing
through the parse/format step.

* src/conf/interface_conf.[ch]: add a new virInterfaceStartMode value
  and modify loading/saving accordingly

15 years agoMove libvirtd event loop into background thread
Daniel P. Berrange [Fri, 16 Oct 2009 15:34:37 +0000 (16:34 +0100)]
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

15 years agogive up python interpreter lock before calling cb
Dan Kenigsberg [Tue, 3 Nov 2009 17:42:16 +0000 (18:42 +0100)]
give up python interpreter lock before calling cb

suggested by danpb on irc, patch by danken fixed for proper C syntax

* python/libvirt-override.c: on event callback release the python
  interpreter lock and take it again when coming back so that the
  callback can reinvoke libvirt.

15 years agoAllow NULL mac address in virGetInterface
Laine Stump [Tue, 3 Nov 2009 15:42:53 +0000 (16:42 +0100)]
Allow NULL mac address in virGetInterface

There are places where an interface will not have a mac address, and netcf
returns this as a NULL pointer rather than a pointer to an empty string.
Rather than checking for this all over the place in libvirt, just save it
in the virInterface object as an empty string.

* src/datatypes.c: allow NULL mac in virGetInterface()

15 years agoFix compilation problems
Daniel Veillard [Tue, 3 Nov 2009 15:24:46 +0000 (16:24 +0100)]
Fix compilation problems

introduced on commit 9231aa7d9563745c64e4f69afabca65d28bfae25
* src/qemu/qemu_driver.c: in qemudRemoveDomainStatus fix a reference
  to an undefined variable buf and free up an allocated string

15 years agoFix up NLS warnings.
Chris Lalancette [Tue, 3 Nov 2009 12:30:47 +0000 (13:30 +0100)]
Fix up NLS warnings.

When building with --disable-nls, I got a few messages like this:

storage/storage_backend.c: In function 'virStorageBackendCreateQemuImg':
storage/storage_backend.c:571: warning: format not a string literal and no format arguments

Fix these up.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoRemove redundant virFileDeletePID() call
Chris Lalancette [Sat, 22 Aug 2009 21:56:33 +0000 (23:56 +0200)]
Remove redundant virFileDeletePID() call

qemudShutdownVMDaemon() calls qemudRemoveDomainStatus(), which
then calls virFileDeletePID().  qemudShutdownVMDaemon() then
unnecessarily calls virFileDeletePID() again.  Remove this second
usage of it, and also slightly refactor qemudRemoveDomainStatus()
to VIR_WARN appropriate error messages.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix return value in virStateInitialize impl for LXC
Daniel P. Berrange [Mon, 2 Nov 2009 23:18:19 +0000 (18:18 -0500)]
Fix return value in virStateInitialize impl for LXC

The LXC driver was mistakenly returning -1 for lxcStartup()
in scenarios that are not an error. This caused the libvirtd
to quit for unprivileged users. This fixes the return code
of LXC driver, and also adds a "name" field to the virStateDriver
struct and logging to make it easier to find these problems
in the future

* src/driver.h: Add a 'name' field to state driver to allow
  easy identification during failures
* src/libvirt.c: Log name of failed driver for virStateInit
  failures
* src/lxc/lxc_driver.c: Don't return a failure code for
  lxcStartup() if LXC is not available on this host, simply
  disable the driver.
* src/network/bridge_driver.c, src/node_device/node_device_devkit.c,
  src/node_device/node_device_hal.c, src/opennebula/one_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/secret/secret_driver.c, src/storage/storage_driver.c,
  src/uml/uml_driver.c, src/xen/xen_driver.c: Fill in name
  field in virStateDriver struct

15 years agoESX: Fix memory leak in list handling functions.
Matthias Bolte [Thu, 22 Oct 2009 07:47:51 +0000 (09:47 +0200)]
ESX: Fix memory leak in list handling functions.

If an error occurs between the allocation of an item and appending it
to the list, the item leaks. Free such orphaned items in error cases.

* src/esx/esx_vi.c: free orphaned items in error cases

15 years agoESX: Don't automatically follow redirects.
Matthias Bolte [Wed, 21 Oct 2009 18:25:22 +0000 (20:25 +0200)]
ESX: Don't automatically follow redirects.

The default transport for the VI API is HTTPS. If the server redirects
from HTTPS to HTTP the driver would silently follow that redirection.
The user assumes to communicate with the server over a secure transport
but isn't.

This patch disables automatical redirection following. The driver reports
an error if the server tries to redirect.

* src/esx/esx_vi.c: refactor the call to curl_easy_perform() into a
  function and do error handling there, disable automatical redirection
  following for curl
* src/esx/esx_vi.h: change the type of responseCode to int

15 years agoESX: Unify naming of VI API utility and convenience functions.
Matthias Bolte [Sun, 18 Oct 2009 19:31:46 +0000 (21:31 +0200)]
ESX: Unify naming of VI API utility and convenience functions.

Unified function naming scheme:
- 'lookup' functions query the ESX or vCenter for information
- 'get' functions return information from a local object

* src/esx/esx_driver.c, src/esx/esx_vi.[ch]: unify function naming

15 years agoESX: Change disk selection for datastore detection.
Matthias Bolte [Sun, 18 Oct 2009 19:21:46 +0000 (21:21 +0200)]
ESX: Change disk selection for datastore detection.

In order to register a new virtual machine the ESX driver needs to upload
a VMX file to a datastore. Try to put this file beside the main VMDK file
of the virtual machine. Change the disk selection for datastore detection
to choose the first file-based harddisk instead of just the first disk.
The first disk may be a CDROM disk and ISO images are normaly not located
in the virtual machine's directory.

* src/esx/esx_driver.c: change disk selection for datastore detection

15 years agoESX: Fallback to the preliminary name if the datastore cannot be found.
Matthias Bolte [Fri, 16 Oct 2009 23:42:05 +0000 (01:42 +0200)]
ESX: Fallback to the preliminary name if the datastore cannot be found.

This allows to use domain-xml-from-native with VMX files that reference
unavailable datastores.

* src/esx/esx_vmx.c: fallback to the preliminary name if the datastore
  cannot be found

15 years agoRename internal APis
Daniel P. Berrange [Tue, 20 Oct 2009 14:51:03 +0000 (15:51 +0100)]
Rename internal APis

Rename virDomainIsActive to virDomainObjIsActive, and
virInterfaceIsActive to virInterfaceObjIsActive and finally
virNetworkIsActive to virNetworkObjIsActive.

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/conf/interface_conf.h, src/conf/network_conf.c,
  src/conf/network_conf.h, src/lxc/lxc_driver.c,
  src/network/bridge_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c: Update for
  renamed APIs.

15 years agoFix --with-init-script configure option
Matthew Booth [Mon, 2 Nov 2009 16:55:40 +0000 (17:55 +0100)]
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.

15 years agoDon't let parent of daemon exit until basic initialization is done
Daniel P. Berrange [Fri, 16 Oct 2009 11:14:54 +0000 (12:14 +0100)]
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

15 years agoPull signal setup code out into separate method
Daniel P. Berrange [Fri, 16 Oct 2009 10:48:50 +0000 (11:48 +0100)]
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

15 years agoSet KMEMSIZE for OpenVZ domains being defined
Yuji NISHIDA [Mon, 2 Nov 2009 16:39:46 +0000 (17:39 +0100)]
Set KMEMSIZE for OpenVZ domains being defined

* src/openvz/openvz_driver.c: add a new openvzDomainSetMemoryInternal()
  function, used to initialize the KMEMSIZE parameter of a container.

15 years agoFix duplicating logging of errors in libvirtd
Daniel P. Berrange [Mon, 19 Oct 2009 17:28:28 +0000 (18:28 +0100)]
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

15 years agoFix initialization order bugs
Daniel P. Berrange [Fri, 16 Oct 2009 10:29:01 +0000 (11:29 +0100)]
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

15 years agoMisc cleanup to network socket init
Daniel P. Berrange [Fri, 16 Oct 2009 10:24:01 +0000 (11:24 +0100)]
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

15 years agoAnnotate many methods with ATTRIBUTE_RETURN_CHECK & fix problems
Daniel P. Berrange [Fri, 16 Oct 2009 10:09:13 +0000 (11:09 +0100)]
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()

15 years agoAllow for a driver specific private data blob in virDomainObjPtr
Daniel P. Berrange [Tue, 6 Oct 2009 11:50:58 +0000 (12:50 +0100)]
Allow for a driver specific private data blob in virDomainObjPtr

The virDomainObjPtr object stores state about a running domain.
This object is shared across all drivers so it is not appropriate
to include driver specific state here. This patch adds the ability
to request a blob of private data per domain object instance. The
driver must provide a allocator & deallocator for this purpose

THis patch abuses the virCapabilitiesPtr structure for storing the
allocator/deallocator callbacks, since it is already being abused
for other internal things relating to parsing. This should be moved
out into a separate object at some point.

* src/conf/capabilities.h: Add privateDataAllocFunc and
  privateDataFreeFunc fields
* src/conf/domain_conf.c: Invoke the driver allocators / deallocators
  when creating/freeing virDomainObjPtr instances.
* src/conf/domain_conf.h: Pass virCapsPtr into virDomainAssignDef
  to allow access to the driver specific allocator function
* src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/qemu/qemu_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c: Update for
  change in virDomainAssignDef contract

15 years agoDon't use private struct member names of in6_addr
Matthias Bolte [Mon, 2 Nov 2009 14:45:05 +0000 (15:45 +0100)]
Don't use private struct member names of in6_addr

__in6_u.__u6_addr16 is the private name for this struct member,
s6_addr16 is the public one
* src/util/network.c: dont use the private field, but the public one.

15 years agoMore network utility functions
Matthew Booth [Mon, 2 Nov 2009 14:42:47 +0000 (15:42 +0100)]
More network utility functions

* src/util/network.[ch] Add functions for address->text and get/set
  port number
* src/libvirt_private.syms: add new entry points

15 years agoFix typo in network.c function comments
Matthew Booth [Fri, 30 Oct 2009 15:39:57 +0000 (16:39 +0100)]
Fix typo in network.c function comments

* src/util/network.c: fix a few typo

15 years agoAdd symbols from new network.h module
Daniel Veillard [Fri, 30 Oct 2009 15:36:04 +0000 (16:36 +0100)]
Add symbols from new network.h module

* src/libvirt_private.syms: keep all symbols from network.h private

15 years agoSet of new network related utilities
Daniel Veillard [Thu, 22 Oct 2009 14:34:43 +0000 (16:34 +0200)]
Set of new network related utilities

* src/util/network.h src/util/network.c: utilities to parse network
  addresses, check netmask and compute ranges

15 years agoFix configure detection of device mapper
Pritesh Kothari [Fri, 30 Oct 2009 13:44:50 +0000 (14:44 +0100)]
Fix configure detection of device mapper

* configure.in: the PKG_CHECK_MODULES() for it would not work on
  Ubuntu and SuSE, so add a direct check fallback