]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 years agoAdd several fields to node device capabilities
David Allan [Thu, 12 Nov 2009 21:39:40 +0000 (22:39 +0100)]
Add several fields to node device capabilities

* src/conf/node_device_conf.h src/conf/node_device_conf.c: add the new
  fields in the structure as well as parsing and serialization

15 years agoAdd virConnectGetLibvirtVersion API
Cole Robinson [Thu, 12 Nov 2009 15:53:26 +0000 (10:53 -0500)]
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.

15 years agoImplement finer grained migration control for Xen
Maximilian Wilhelm [Thu, 12 Nov 2009 15:04:43 +0000 (16:04 +0100)]
Implement finer grained migration control for Xen

* src/xen/xen_driver.c: Add support for VIR_MIGRATE_PERSIST_DEST flag
* src/xen/xend_internal.c: Add support for VIR_MIGRATE_UNDEFINE_SOURCE flag
* include/libvirt/virterror.h, src/util/virterror.c: Add new errorcode
  VIR_ERR_MIGRATE_PERSIST_FAILED

15 years agoSupport for SATA Disks in virDomainDiskBus
pritesh [Thu, 12 Nov 2009 14:45:18 +0000 (15:45 +0100)]
Support for SATA Disks in virDomainDiskBus

* src/conf/domain_conf.h src/conf/domain_conf.c: add the new entry in
  the enum and lists of virDomainDiskBus
* src/qemu/qemu_conf.c: same for virDomainDiskQEMUBus

15 years agoLXC implement missing DomainInterfaceStats API
Ryota Ozaki [Thu, 12 Nov 2009 13:55:44 +0000 (14:55 +0100)]
LXC implement missing DomainInterfaceStats API

* src/lxc/lxc_driver.c: add lxcDomainInterfaceStats implementing
  virDomainInterfaceStats()

15 years agoFilter out stale domains from xenstore listing
Daniel P. Berrange [Fri, 9 Oct 2009 09:32:37 +0000 (10:32 +0100)]
Filter out stale domains from xenstore listing

The xenstore database sometimes has stale domain IDs which are not
present in the hypervisor anymore. Filter these out to avoid causing
confusion

* src/xen/xs_internal.c: Filter domain IDs against HV's list
* src/xen/xen_hypervisor.h, src/xen/xen_hypervisor.c: Add new
  xenHypervisorHasDomain() method for checking ID validity

15 years agoFix logic in xenUnifiedNumOfDomains to match xenUnifiedListDomains
Jonas Eriksson [Fri, 9 Oct 2009 09:23:23 +0000 (10:23 +0100)]
Fix logic in xenUnifiedNumOfDomains to match xenUnifiedListDomains

The xenUnifiedNumOfDomains and xenUnifiedListDomains methods work
together as a pair, so it is critical they both apply the same
logic. With the current mis-matched logic it is possible to sometimes
get into a state when you miss certain active guests.

* src/xen/xen_driver.c: Change xenUnifiedNumOfDomains ordering to
  match xenUnifiedListDomains.

15 years agoDisable IPv6 socket auto-binding to IPv4 socket
Daniel P. Berrange [Wed, 11 Nov 2009 15:19:50 +0000 (15:19 +0000)]
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

15 years agoExclude numactl on s390[x]
Daniel P. Berrange [Wed, 11 Nov 2009 18:07:34 +0000 (18:07 +0000)]
Exclude numactl on s390[x]

The numactl package is not applicable for s390[x] arches, so do
not enable it as a build dep.

* libvirt.spec.in: Exclude numactl on s390[x]

15 years agoFix error handling in qemuMonitorOpen
Ryota Ozaki [Thu, 12 Nov 2009 10:33:30 +0000 (11:33 +0100)]
Fix error handling in qemuMonitorOpen

* src/qemu/qemu_monitor.c: add error check for qemuMonitorOpenXXX
  returned file descriptor

15 years agoFix save and restore with non-privileged guests and SELinux
Daniel P. Berrange [Wed, 11 Nov 2009 12:07:00 +0000 (12:07 +0000)]
Fix save and restore with non-privileged guests and SELinux

When running qemu:///system instance, libvirtd runs as root,
but QEMU may optionally be configured to run non-root. When
then saving a guest to a state file, the file is initially
created as root, and thus QEMU cannot write to it. It is also
missing labelling required to allow access via SELinux.

* src/qemu/qemu_driver.c: Set ownership on save image before
  running migrate command in virDomainSave impl. Call out to
  security driver to set save image labelling
* src/security/security_driver.h: Add driver APIs for setting
  and restoring saved state file labelling
* src/security/security_selinux.c: Implement saved state file
  labelling for SELinux

15 years agodisable mac_filter config switch by default
Gerhard Stenzel [Wed, 11 Nov 2009 12:02:57 +0000 (13:02 +0100)]
disable mac_filter config switch by default

* src/qemu/qemu.conf:  disables the mac_filter config switch by default
  to match existing convention, also document the option

15 years agoPrevent initializing ebtables if disabled in qemu.conf
Ryota Ozaki [Wed, 11 Nov 2009 11:59:54 +0000 (12:59 +0100)]
Prevent initializing ebtables if disabled in qemu.conf

* src/qemu/qemu_conf.c: don't initialize ebtables if
  disabled

15 years agophyp: too much timeout when polling socket
Eduardo Otubo [Wed, 11 Nov 2009 10:53:16 +0000 (11:53 +0100)]
phyp: too much timeout when polling socket

* src/phyp/phyp_driver.c: a 10s timeout on socket availability was way
  too long, reduced to 1ms

15 years agoFix warning on make due to missing cast (int)
Ryota Ozaki [Wed, 11 Nov 2009 10:30:01 +0000 (11:30 +0100)]
Fix warning on make due to missing cast (int)

* src/qemu/qemu_monitor.c src/qemu/qemu_monitor_text.c: cast size_t to
  int when passing to '%d'

15 years agophyp: Reorder keyboard_interactive label in openSSHSession()
Eduardo Otubo [Wed, 11 Nov 2009 01:45:51 +0000 (02:45 +0100)]
phyp: Reorder keyboard_interactive label in openSSHSession()

Finish changes intended to be part of commit
6c70802374d1cb9316769fea750a6c2c198901ff

15 years agoImplmentation of new APIs to checking state/persistence of objects
Daniel P. Berrange [Tue, 20 Oct 2009 14:12:03 +0000 (15:12 +0100)]
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

15 years agoNew APIs for checking some object properties
Daniel P. Berrange [Wed, 21 Oct 2009 10:49:05 +0000 (11:49 +0100)]
New APIs for checking some object properties

Introduce a number of new APIs to  expose some boolean properties
of objects, which cannot otherwise reliably determined, nor are
aspects of the XML configuration.

 * virDomainIsActive: Checking virDomainGetID is not reliable
   since it is not possible to distinguish between error condition
   and inactive domain for ID of -1.
 * virDomainIsPersistent: Check whether a persistent config exists
   for the domain

 * virNetworkIsActive: Check whether the network is active
 * virNetworkIsPersistent: Check whether a persistent config exists
   for the network

 * virStoragePoolIsActive: Check whether the storage pool is active
 * virStoragePoolIsPersistent: Check whether a persistent config exists
   for the storage pool

 * virInterfaceIsActive: Check whether the host interface is active

 * virConnectIsSecure: whether the communication channel to the
   hypervisor is secure
 * virConnectIsEncrypted: whether any network based commnunication
   channels are encrypted

NB, a channel can be secure, even if not encrypted, eg if it does
not involve the network, like a UNIX socket, or pipe.

 * include/libvirt/libvirt.h.in: Define public API
 * src/driver.h: Define internal driver API
 * src/libvirt.c: Implement public API entry point
 * src/libvirt_public.syms: Export API symbols
 * src/esx/esx_driver.c, src/lxc/lxc_driver.c,
   src/interface/netcf_driver.c, src/network/bridge_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: Stub out driver tables

15 years agoVarious fixes following a code review part 2
Daniel Veillard [Tue, 10 Nov 2009 13:40:22 +0000 (14:40 +0100)]
Various fixes following a code review part 2

* daemon/libvirtd.c tools/virsh.c: Steve Grubb <sgrubb@redhat.com> found
  a few more issues

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