]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 years agoesx: Fix memory leak in esxVI_HostCpuIdInfo_Free()
Matthias Bolte [Sat, 14 Nov 2009 21:45:38 +0000 (22:45 +0100)]
esx: Fix memory leak in esxVI_HostCpuIdInfo_Free()

15 years agoesx: Fix MAC address formatting
Matthias Bolte [Sat, 14 Nov 2009 18:51:05 +0000 (19:51 +0100)]
esx: Fix MAC address formatting

VMware uses two MAC address prefixes: 00:0c:29 and 00:50:56. The 00:0c:29
prefix is used for ESX server generated addresses. The 00:50:56 prefix is
split into two parts. MAC addresses above 00:50:56:3f:ff:ff are generated
by a vCenter. The rest of the 00:50:56 prefix can be assigned manually.
Any MAC address within the 00:0c:29 and 00:50:56 prefix can be specified
in a domain XML config and the driver will handle the details internally.

* src/esx/esx_vmx.c: fix MAC address formatting
* tests/xml2vmxdata/*: update test files accordingly

15 years agoesx: Handle 'vmxnet3' in esxVMX_FormatEthernet()
Matthias Bolte [Fri, 13 Nov 2009 21:55:25 +0000 (22:55 +0100)]
esx: Handle 'vmxnet3' in esxVMX_FormatEthernet()

In commit 3c80fac2588cbc9e5ee7e7069e1ca4468f2359d3 'vmxnet3' handling
was added to esxVMX_ParseEthernet(), but not to the inverse function
esxVMX_FormatEthernet().

15 years agoesx: Add documentation to the website
Matthias Bolte [Fri, 13 Nov 2009 21:43:10 +0000 (22:43 +0100)]
esx: Add documentation to the website

* docs/drivers.html.in: list the ESX driver
* docs/drvesx.html.in: the new ESX driver documentation
* docs/hvsupport.html.in: add the ESX driver to the matrix
* docs/index.html.in, docs/sitemap.html.in: list the ESX driver
* src/esx/esx_driver.c: fix and cleanup some comments

15 years agoChange DTD references to use public instead of system identifier
Matthias Bolte [Fri, 13 Nov 2009 22:19:09 +0000 (23:19 +0100)]
Change DTD references to use public instead of system identifier

Debian's /etc/xml/catalog doesn't contain system identifiers, so use
public identifiers instead.

* docs/Makefile.am: use public instead of system identifier
* docs/site.xsl: use matching public identifier

15 years agoFix compilation of libvirt against xen-unstable
Jim Fehlig [Sun, 15 Nov 2009 08:40:36 +0000 (09:40 +0100)]
Fix compilation of libvirt against xen-unstable

* src/xen/xen_hypervisor.c: xen-unstable changeset 19788 removed
  MAX_VIRT_CPUS from public headers, breaking compilation of libvirt
  on -unstable.  Its semanitc was retained with XEN_LEGACY_MAX_VCPUS.
  Ensure MAX_VIRT_CPUS is defined accordingly.

15 years agoFix probing for libpciaccess
Daniel P. Berrange [Fri, 13 Nov 2009 12:12:09 +0000 (12:12 +0000)]
Fix probing for libpciaccess

If 'with_udev=check' then missing pciaccess should not be a fatal
error. It should merely disable the udev driver.

* configure.in: Fix pciaccess check to be non-fatal

15 years agoRemove obsolte devicekit checks
Daniel P. Berrange [Fri, 13 Nov 2009 12:12:09 +0000 (12:12 +0000)]
Remove obsolte devicekit checks

Device kit support was removed, but the configure.ac checks were
left in place. A number of the XXX_REQUIRED=X.Y.Z variables were
not declared in the correct location (ie top of the file)

* configure.in: Remove device kit checks & move mis-placed variables
  to correct location

15 years agoFix incorrect reference counting logic in qemu monitor open
Daniel P. Berrange [Fri, 13 Nov 2009 11:43:09 +0000 (11:43 +0000)]
Fix incorrect reference counting logic in qemu monitor open

The QEMU monitor open method would not take a reference on
the virDomainObjPtr until it had successfully opened the
monitor. The cleanup code upon failure to open though would
call qemuMonitorClose() which would in turn decrement the
reference count. This caused the virDoaminObjPtr to be mistakenly
freed and then the whole driver crashes

* src/qemu/qemu_monitor.c: Fix reference counting in
  qemuMonitorOpen

15 years agoDon't return fatal error in HAL driver init if HAL isn't running
Daniel P. Berrange [Fri, 13 Nov 2009 10:36:01 +0000 (10:36 +0000)]
Don't return fatal error in HAL driver init if HAL isn't running

The HAL driver returns a fatal error code in the case where HAL
is not running. This causes the entire libvirtd daemon to quit
which isn't desirable. Instead it should simply disable the HAL
driver

* src/node_device/node_device_hal.c: Quietly disable HAL if it is
  not running

15 years agoFix cleanup when state driver init fails
Daniel P. Berrange [Fri, 13 Nov 2009 10:34:47 +0000 (10:34 +0000)]
Fix cleanup when state driver init fails

* daemon/libvirtd.c: Fix incorrect goto label causing cleanup to
  be missed when state driver init fails

15 years agoSmall guestfwd code cleanup
Matthew Booth [Fri, 13 Nov 2009 15:05:27 +0000 (16:05 +0100)]
Small guestfwd code cleanup

* src/qemu/qemu_conf.c: Remove and inline qemudBuildCommandLineChrDevTargetStr

15 years agoSmall indentation cleanup of domain schema
Matthew Booth [Fri, 13 Nov 2009 15:03:43 +0000 (16:03 +0100)]
Small indentation cleanup of domain schema

15 years agoAppArmor code cleanups
Jamie Strandboge [Fri, 13 Nov 2009 14:27:43 +0000 (15:27 +0100)]
AppArmor code cleanups

* src/security/security_apparmor.c: a few code cleanups following a
  review on the list

15 years agoAppArmor handling of accesses to readonly files
Jamie Strandboge [Fri, 13 Nov 2009 14:25:30 +0000 (15:25 +0100)]
AppArmor handling of accesses to readonly files

Fixes https://launchpad.net/bugs/453335

* src/security/virt-aa-helper.c: suppress confusing and misleading
  apparmor denied message when kvm/qemu tries to open a libvirt specified
  readonly file (such as a cdrom) with write permissions. libvirt uses
  the readonly attribute for the security driver only, and has no way
  of telling kvm/qemu that the device should be opened readonly

15 years agoAppArmor require absolute paths
Jamie Strandboge [Fri, 13 Nov 2009 14:22:20 +0000 (15:22 +0100)]
AppArmor require absolute paths

Fixes https://launchpad.net/bugs/460271

* src/security/virt-aa-helper.c: require absolute path for dynamic added
  files. This is required by AppArmor and conveniently prevents adding
  tcp consoles to the profile

15 years agoAppArmor updates of examples
Jamie Strandboge [Fri, 13 Nov 2009 14:19:05 +0000 (15:19 +0100)]
AppArmor updates of examples

* examples/apparmor/libvirt-qemu: adds pulseaudio, alsa and preliminary
  save/restore to the example apparmor abstraction
* examples/apparmor/usr.sbin.libvirtd: allows libvirtd access to inet
  dgram, inet6 dgram, inet6 stream and /usr/lib/libvirt/*

15 years agoCheck that domain is running when starting console
Daniel P. Berrange [Thu, 12 Nov 2009 14:14:23 +0000 (14:14 +0000)]
Check that domain is running when starting console

The 'virsh console' command did not check if the domain was
already running before attempting to fetch the XML and extract
the console PTY path. This caused a slightly unhelpful / misleading
error message for the user. The explicit check ensures the user
gets an explicit 'domain is not running' message.

* tools/virsh.c: Validate that state != VIR_DOMAIN_SHUTOFF in
  virsh console command

15 years agoFix incorrect variable passed to LXC event callback
Daniel P. Berrange [Thu, 12 Nov 2009 14:13:33 +0000 (14:13 +0000)]
Fix incorrect variable passed to LXC event callback

The wrong variable was being passed in with the LXC event callback
resulting in a later deadlock or crash

* src/lxc/lxc_driver.c: Pass 'vm' instead of 'driver' to event
  callback

15 years agoFix check for existance of cgroups at creation
Daniel P. Berrange [Thu, 12 Nov 2009 14:11:43 +0000 (14:11 +0000)]
Fix check for existance of cgroups at creation

In the scenario where the cgroups were mounted but the
particular group did not exist, and the caller had not
requested auto-creation, the code would fail to return
an error condition. This caused the lxc_controller to
think the cgroup existed, and it then later failed when
attempting to use it

* src/util/cgroup.c: Raise an error if the cgroup path does not
  exist

15 years agoFix race condition in HAL driver startup
Daniel P. Berrange [Thu, 12 Nov 2009 14:10:45 +0000 (14:10 +0000)]
Fix race condition in HAL driver startup

There is a race condition in HAL driver startup where the callback
can get triggered before we have finished startup. This then causes
a deadlock in the driver.

* src/node_device/node_device_hal.c: RElease driver lock before
  registering DBus callbacks

15 years agoFix formatting of XML for an inactive guest
Daniel P. Berrange [Thu, 12 Nov 2009 14:08:43 +0000 (14:08 +0000)]
Fix formatting of XML for an inactive guest

If the virDomainDefPtr object has an 'id' of -1, then forcably
set the VIR_DOMAIN_XML_INACTIVE flag to ensure generated XML
does not include any cruft from the previously running guest
such as console PTY path, or VNC port.

* src/conf/domain_conf.c: Set VIR_DOMAIN_XML_INACTIVE if
  def->id is -1. Replace checks for def->id == -1 with
  check against flags & VIR_DOMAIN_XML_INACTIVE.

15 years agoRemove capng_lock() call when spawning LXC container init process
Daniel P. Berrange [Thu, 12 Nov 2009 11:03:23 +0000 (11:03 +0000)]
Remove capng_lock() call when spawning LXC container init process

The capng_lock() call sets the SECURE_NO_SETUID_FIXUP and SECURE_NOROOT
bits on the process. This prevents the kernel granting capabilities to
processes with an effective UID of 0, or with setuid programs. This is
not actually what we want in the container init process. It should be
allowed to run setuid processes & keep capabilities when root. All that
is required is masking a handful of dangerous capabilities from the
bounding set.

* src/lxc/lxc_container.c: Remove bogus capng_lock() call.

15 years agoFix initscript to check daemon pidfile
Daniel P. Berrange [Thu, 12 Nov 2009 19:31:48 +0000 (19:31 +0000)]
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

15 years agoFix virt-aa-helper when host and os.type arch differ
Jamie Strandboge [Fri, 13 Nov 2009 10:04:23 +0000 (11:04 +0100)]
Fix virt-aa-helper when host and os.type arch differ

* src/security/virt-aa-helper.c: get_definition() now calls the new
  caps_mockup() function which will parse the XML for os.type,
  os.type.arch and then sets the wordsize.  These attributes are needed
  only to get a valid virCapsPtr for virDomainDefParseString(). The -H
  and -b options are now removed from virt-aa-helper (they weren't used
  yet anyway).
* tests/virt-aa-helper-test: extend and fixes tests, chmod'ed 755

15 years agoAdd translation of PCI vendor and product IDs
David Allan [Thu, 12 Nov 2009 22:22:00 +0000 (23:22 +0100)]
Add translation of PCI vendor and product IDs

uses libpciaccess to provide human readable names for PCI vendor and
device IDs
* configure.in: add a requirement for libpciaccess >= 0.10.0
* src/Makefile.am: add the associated compilation flags and link
* src/node_device/node_device_udev.c: lookup the libpciaccess for
  vendor name and product name based on their ids

15 years agoRemove DevKit node device backend
David Allan [Thu, 12 Nov 2009 22:09:24 +0000 (23:09 +0100)]
Remove DevKit node device backend

* configure.in src/Makefile.am: remove the configuration check and
  build instructions
* src/node_device/node_device_devkit.c: removed the module
* src/node_device/node_device_driver.c src/node_device/node_device_driver.h:
  removed references to the old backend

15 years agoAdd scsi_target device type
David Allan [Thu, 12 Nov 2009 22:03:47 +0000 (23:03 +0100)]
Add scsi_target device type

* src/conf/node_device_conf.h src/conf/node_device_conf.c: add specific
  support for SCSI target in node device capabilities
* src/node_device/node_device_udev.c: add some extra detection code
  when handling udev output

15 years agoImplement a node device backend using libudev
David Allan [Thu, 12 Nov 2009 21:48:24 +0000 (22:48 +0100)]
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

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.