]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agodomain.rng vs. formatdomain.html#elementsUSB
Philipp Hahn [Tue, 1 Mar 2011 10:23:20 +0000 (11:23 +0100)]
domain.rng vs. formatdomain.html#elementsUSB

The Relax-NG schema for domains regarding <hostdev> doesn't match what's
implemented in src/conf/domain_conf.c#virDomainHostdevDefFormat(): The
implementation only requires @type, but the schema currently either
required none or all three attributes (@mode, @type, and @managed) to be
defined together, because they are declared in the same
<optional)-section. (@managed is currently even undocumented on
<http://libvirt.org/formatdomain.html#elementsUSB>).

Thus the following minimal <hostdev>-example fails to validate:
<domain type='test'>
        <name>N</name>
        <memory>4096</memory>
        <bootloader>/bin/false</bootloader>
        <os>
                <type arch='x86_64' machine='xenpv'>linux</type>
        </os>
        <devices>
                <hostdev type='pci'>
                        <source>
                                <address bus='0x06' slot='0x00' function='0x0'/>
                        </source>
                </hostdev>
        </devices>
</domain>

The schema is changed to match the current implementation:
1. @mode is optional (which defaults to 'subsystem')
2. @type is required
3. @managed is optional (which defaults to 'no')

The documentation is updated to mention @managed.

Signed-off-by: Philipp Hahn <hahn@univention.de>
14 years agoqemu: fix -global argument usage
Eric Blake [Fri, 11 Mar 2011 16:59:32 +0000 (09:59 -0700)]
qemu: fix -global argument usage

* src/qemu/qemu_command.c (qemuBuildCommandLine): Pass two
separate arguments, and fix indentation.

14 years agodocs: fix missing </p>
Eric Blake [Fri, 11 Mar 2011 17:08:24 +0000 (10:08 -0700)]
docs: fix missing </p>

* docs/formatdomain.html.in: Fix typo in last patch.
Reported by Matthias Bolte.

14 years agoIgnore backing file errors in FS storage pool
Philipp Hahn [Tue, 1 Mar 2011 15:48:20 +0000 (16:48 +0100)]
Ignore backing file errors in FS storage pool

Currently a single storage volume with a broken backing file will disable the
whole storage pool. This can happen when the backing file is on some
unavailable network storage or if the backing volume is deleted, while the
storage volumes using it remain.
Since the storage pool can not be re-activated, re-creating the missing
or deleting the now useless volumes using libvirt only is not possible.

Fixing this is a little bit tricky:
1. virStorageBackendProbeTarget() only detects the missing backing file,
   if the backing file format is not explicitly specified. If the
   backing file is created using
   kvm-img create -f qcow2 -o backing_fmt=qcow2,backing_file=... ...
   no error is detected at this stage.
   The new return code -3 signals that the backing file could not be
   opened.
2. The backingStore.format must be >= 0, since values < 0 would break
   virStorageVolTargetDefFormat() when dumping the XML data such as
       <format type='...'/>
   Because of this the format is faked as VIR_STORAGE_FILE_RAW.
3. virStorageBackendUpdateVolTargetInfo() always opens the backing file
   and thus always detects a missing backing file.
   Since it "only" updates the capacity, allocation, owner, group, mode
   and SELinux label, just ignore errors at this stage, print an error
   message and continue.
4. Using vol-dump on a broken volume still doesn't work, but at least
   vol-destroy and pool-refresh do work now.

To reproduce:
  dir=$(mktemp -d)
  virsh pool-create-as tmp dir '' '' '' '' "$dir"
  virsh vol-create-as --format qcow2 tmp back 1G
  virsh vol-create-as --format qcow2 --backing-vol-format qcow2 --backing-vol back tmp cow 1G
  virsh vol-delete --pool tmp back
  virsh pool-refresh tmp
After the last step, the pool will be gone (because it was not persistent). As
long as the now broken image stays in the directory, you will not be able to
re-create or re-start the pool.

Signed-off-by: Philipp Hahn <hahn@univention.de>
14 years agodocumenting the 802.1Qbg parameters of a 'direct' interface
Gerhard Stenzel [Fri, 11 Mar 2011 09:47:57 +0000 (10:47 +0100)]
documenting the 802.1Qbg parameters of a 'direct' interface

This patchs adds documentation about the 802.1Qbg related parameters
of the virtualport element in a 'direct' interface definition.

Signed-off-by: Gerhard Stenzel <gerhard.stenzel@de.ibm.com>
14 years agoremote-protocol: implement new BlkioParameters API
Gui Jianfeng [Tue, 22 Feb 2011 05:34:28 +0000 (13:34 +0800)]
remote-protocol: implement new BlkioParameters API

Remote protocol implementation of virDomainSetBlkioParameters and virDomainGetBlkioParameters.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agovirsh: Adding blkiotune command to virsh tool
Gui Jianfeng [Tue, 22 Feb 2011 05:33:24 +0000 (13:33 +0800)]
virsh: Adding blkiotune command to virsh tool

Adding blkiotune command to virsh tool

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agoqemu: implement new BlkioParameters API
Gui Jianfeng [Tue, 22 Feb 2011 05:32:38 +0000 (13:32 +0800)]
qemu: implement new BlkioParameters API

Implement domainSetBlkioParameters and domainGetBlkioParameters for QEmu

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agolibvirt: implements virDomain{Get,Set}BlkioParameters
Gui Jianfeng [Tue, 22 Feb 2011 05:31:57 +0000 (13:31 +0800)]
libvirt: implements virDomain{Get,Set}BlkioParameters

Implements virDomainSetBlkioParameters and virDomainGetBlkioParameters and initialization

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agolibvirt: add virDomain{Get,Set}BlkioParameters
Gui Jianfeng [Tue, 22 Feb 2011 05:30:33 +0000 (13:30 +0800)]
libvirt: add virDomain{Get,Set}BlkioParameters

Add virDomainSetBlkioParameters virDomainGetBlkioParameters

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agosetmem: add the new options to "virsh setmem" command
Taku Izumi [Wed, 2 Mar 2011 08:13:39 +0000 (17:13 +0900)]
setmem: add the new options to "virsh setmem" command

This patch adds the new options (--live and --config)  to "virsh setmem" command.
The behavior of above options is the same as that of "virsh setvcpus" and so on.
That is, when the --config option is specified, a modification is effective for
the persistent domain. Moreover we can modify the memory size of inactive domains
as well as that of active domains.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
14 years agosetmem: implement the remote protocol to address the new API
Taku Izumi [Wed, 2 Mar 2011 08:13:24 +0000 (17:13 +0900)]
setmem: implement the remote protocol to address the new API

This patch implements the remote protocol to address the new API.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
14 years agosetmem: implement the code to address the new API in the qemu driver
Taku Izumi [Wed, 2 Mar 2011 08:13:09 +0000 (17:13 +0900)]
setmem: implement the code to address the new API in the qemu driver

This patch implements the code to address the new API
in the qemu driver.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
14 years agosetmem: introduce a new libvirt API (virDomainSetMemoryFlags)
Taku Izumi [Wed, 2 Mar 2011 08:07:48 +0000 (17:07 +0900)]
setmem: introduce a new libvirt API (virDomainSetMemoryFlags)

This patch introduces a new libvirt API (virDomainSetMemoryFlags) and
a flag (virDomainMemoryModFlags).

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
14 years agoMake sure we reset the umask on the error path
Guido Günther [Wed, 9 Mar 2011 13:19:56 +0000 (14:19 +0100)]
Make sure we reset the umask on the error path

14 years agoaudit: audit use of /dev/net/tun, /dev/tapN, /dev/vhost-net
Eric Blake [Tue, 8 Mar 2011 18:00:59 +0000 (11:00 -0700)]
audit: audit use of /dev/net/tun, /dev/tapN, /dev/vhost-net

Opening raw network devices with the intent of passing those fds to
qemu is worth an audit point.  This makes a multi-part audit: first,
we audit the device(s) that libvirt opens on behalf of the MAC address
of a to-be-created interface (which can independently succeed or
fail), then we audit whether qemu actually started the network device
with the same MAC (so searching backwards for successful audits with
the same MAC will show which fd(s) qemu is actually using).  Note that
it is possible for the fd to be successfully opened but no attempt
made to pass the fd to qemu (for example, because intermediate
nwfilter operations failed) - no interface start audit will occur in
that case; so the audit for a successful opened fd does not imply
rights given to qemu unless there is a followup audit about the
attempt to start a new interface.

Likewise, when a network device is hot-unplugged, there is only one
audit message about the MAC being discontinued; again, searching back
to the earlier device open audits will show which fds that qemu quits
using (and yes, I checked via /proc/<qemu-pid>/fd that qemu _does_
close out the fds associated with an interface on hot-unplug).  The
code would require much more refactoring to be able to definitively
state which device(s) were discontinued at that point, since we
currently don't record anywhere in the XML whether /dev/vhost-net was
opened for a given interface.

* src/qemu/qemu_audit.h (qemuAuditNetDevice): New prototype.
* src/qemu/qemu_audit.c (qemuAuditNetDevice): New function.
* src/qemu/qemu_command.h (qemuNetworkIfaceConnect)
(qemuPhysIfaceConnect, qemuOpenVhostNet): Adjust prototype.
* src/qemu/qemu_command.c (qemuNetworkIfaceConnect)
(qemuPhysIfaceConnect, qemuOpenVhostNet): Add audit points and
adjust parameters.
(qemuBuildCommandLine): Adjust caller.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.

14 years agoqemu: don't request cgroup ACL access for /dev/net/tun
Eric Blake [Wed, 9 Mar 2011 22:05:00 +0000 (15:05 -0700)]
qemu: don't request cgroup ACL access for /dev/net/tun

Since libvirt always passes /dev/net/tun to qemu via fd, we should
never trigger the cases where qemu tries to directly open the
device.  Therefore, it is safer to deny the cgroup device ACL.

* src/qemu/qemu_cgroup.c (defaultDeviceACL): Remove /dev/net/tun.
* src/qemu/qemu.conf (cgroup_device_acl): Reflect this change.

14 years agoqemu: support vhost in attach-interface
Eric Blake [Wed, 9 Mar 2011 04:43:33 +0000 (21:43 -0700)]
qemu: support vhost in attach-interface

* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Honor vhost
designations, similar to qemu_command code paths.
* src/qemu/qemu_command.h (qemuOpenVhostNet): New prototype.
* src/qemu/qemu_command.c (qemuOpenVhostNet): Export.

14 years agoqemu: Stop guest CPUs before creating a snapshot
Jiri Denemark [Thu, 24 Feb 2011 15:46:44 +0000 (16:46 +0100)]
qemu: Stop guest CPUs before creating a snapshot

14 years agoqemu: Refactor qemuDomainSnapshotCreateXML
Jiri Denemark [Fri, 25 Feb 2011 09:29:57 +0000 (10:29 +0100)]
qemu: Refactor qemuDomainSnapshotCreateXML

14 years agoqemu: Escape snapshot name passed to {save,load,del}vm
Jiri Denemark [Wed, 9 Mar 2011 20:47:06 +0000 (21:47 +0100)]
qemu: Escape snapshot name passed to {save,load,del}vm

14 years agoqemu: Fallback to HMP for snapshot commands
Jiri Denemark [Wed, 23 Feb 2011 11:12:11 +0000 (12:12 +0100)]
qemu: Fallback to HMP for snapshot commands

qemu driver in libvirt gained support for creating domain snapshots
almost a year ago in libvirt 0.8.0. Since then we enabled QMP support
for qemu >= 0.13.0 but QMP equivalents of {save,load,del}vm commands are
not implemented in current qemu (0.14.0) so the domain snapshot support
is not very useful.

This patch detects when the appropriate QMP command is not implemented
and tries to use human-monitor-command (aka HMP passthrough) to run
it's HMP equivalent.

14 years agoqemu: Rename qemuMonitorCommandWithHandler as qemuMonitorText*
Jiri Denemark [Thu, 10 Mar 2011 08:37:08 +0000 (09:37 +0100)]
qemu: Rename qemuMonitorCommandWithHandler as qemuMonitorText*

To make it more obvious that it is only used for text monitor. The
naming also matches the style of qemuMonitorTextCommandWithFd.

14 years agoqemu: Rename qemuMonitorCommand{,WithFd} as qemuMonitorHMP*
Jiri Denemark [Thu, 10 Mar 2011 08:33:01 +0000 (09:33 +0100)]
qemu: Rename qemuMonitorCommand{,WithFd} as qemuMonitorHMP*

So that it's obvious that they are supposed to be used with HMP commands.

14 years agoqemu: Setup infrastructure for HMP passthrough
Jiri Denemark [Wed, 9 Mar 2011 20:24:04 +0000 (21:24 +0100)]
qemu: Setup infrastructure for HMP passthrough

JSON monitor command implementation can now just directly call text
monitor implementation and it will be automatically encapsulated into
QMP's human-monitor-command.

14 years agoqemu: Fix warnings in event handlers
Jiri Denemark [Tue, 8 Mar 2011 13:42:05 +0000 (14:42 +0100)]
qemu: Fix warnings in event handlers

Some qemu monitor event handlers were issuing inadequate warning when
virDomainSaveStatus() failed. They copied the message from I/O error
handler without customizing it to provide better information on why
virDomainSaveStatus() was called.

14 years agostorage: Update qemu-img flag checking
Osier Yang [Thu, 10 Mar 2011 07:02:28 +0000 (15:02 +0800)]
storage: Update qemu-img flag checking

For newer qemu-img, the help string for "backing file format" is
"[-F backing_fmt]".

Fix the wrong logic error by commit e997c268.

* src/storage/storage_backend.c

14 years agoqemu: Replace deprecated option of qemu-img
Osier Yang [Thu, 10 Mar 2011 02:05:14 +0000 (10:05 +0800)]
qemu: Replace deprecated option of qemu-img

qemu-img silently disable "-e", so we can't use it for volume
encryption anymore, change it into "-o encryption=on" if qemu
supports "-o" option.

14 years agoaudit: also audit cgroup ACL permissions
Eric Blake [Wed, 9 Mar 2011 03:06:26 +0000 (20:06 -0700)]
audit: also audit cgroup ACL permissions

* src/qemu/qemu_audit.h (qemuAuditCgroupMajor)
(qemuAuditCgroupPath): Add parameter.
* src/qemu/qemu_audit.c (qemuAuditCgroupMajor)
(qemuAuditCgroupPath): Add 'acl=rwm' to cgroup audit entries.
* src/qemu/qemu_cgroup.c: Update clients.
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Likewise.

14 years agocgroup: allow fine-tuning of device ACL permissions
Eric Blake [Wed, 9 Mar 2011 03:13:18 +0000 (20:13 -0700)]
cgroup: allow fine-tuning of device ACL permissions

Adding audit points showed that we were granting too much privilege
to qemu; it should not need any mknod rights to recreate any
devices.  On the other hand, lxc should have all device privileges.
The solution is adding a flag parameter.

This also lets us restrict write access to read-only disks.

* src/util/cgroup.h (virCgroup*Device*): Adjust prototypes.
* src/util/cgroup.c (virCgroupAllowDevice)
(virCgroupAllowDeviceMajor, virCgroupAllowDevicePath)
(virCgroupDenyDevice, virCgroupDenyDeviceMajor)
(virCgroupDenyDevicePath): Add parameter.
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update clients.
* src/lxc/lxc_controller.c (lxcSetContainerResources): Likewise.
* src/qemu/qemu_cgroup.c: Likewise.
(qemuSetupDiskPathAllow): Also, honor read-only disks.

14 years agoaudit: rename remaining qemu audit functions
Eric Blake [Tue, 8 Mar 2011 21:28:51 +0000 (14:28 -0700)]
audit: rename remaining qemu audit functions

Also add ATTRIBUTE_NONNULL markers.

* src/qemu/qemu_audit.h: The pattern qemuDomainXXXAudit is
inconsistent; prefer qemuAuditXXX instead.
* src/qemu/qemu_audit.c: Reflect the renames.
* src/qemu/qemu_driver.c: Likewise.
* src/qemu/qemu_hotplug.c: Likewise.
* src/qemu/qemu_migration.c: Likewise.
* src/qemu/qemu_process.c: Likewise.

14 years agoaudit: also audit cgroup controller path
Eric Blake [Mon, 7 Mar 2011 23:41:40 +0000 (16:41 -0700)]
audit: also audit cgroup controller path

Although the cgroup device ACL controller path can be worked out
by researching the code, it is more efficient to include that
information directly in the audit message.

* src/util/cgroup.h (virCgroupPathOfController): New prototype.
* src/util/cgroup.c (virCgroupPathOfController): Export.
* src/libvirt_private.syms: Likewise.
* src/qemu/qemu_audit.c (qemuAuditCgroup): Use it.

14 years agoaudit: split cgroup audit types to allow more information
Eric Blake [Mon, 7 Mar 2011 23:17:26 +0000 (16:17 -0700)]
audit: split cgroup audit types to allow more information

Device names can be manipulated, so it is better to also log
the major/minor device number corresponding to the cgroup ACL
changes that libvirt made.  This required some refactoring
of the relatively new qemu cgroup audit code.

Also, qemuSetupChardevCgroup was only auditing on failure, not success.

* src/qemu/qemu_audit.h (qemuDomainCgroupAudit): Delete.
(qemuAuditCgroup, qemuAuditCgroupMajor, qemuAuditCgroupPath): New
prototypes.
* src/qemu/qemu_audit.c (qemuDomainCgroupAudit): Rename...
(qemuAuditCgroup): ...and drop a parameter.
(qemuAuditCgroupMajor, qemuAuditCgroupPath): New functions, to
allow listing device major/minor in audit.
(qemuAuditGetRdev): New helper function.
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Adjust callers.
* src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
(qemuSetupHostUsbDeviceCgroup, qemuSetupCgroup)
(qemuTeardownDiskPathDeny): Likewise.
(qemuSetupChardevCgroup): Likewise, fixing missing audit.

14 years agoaudit: tweak audit messages to match conventions
Eric Blake [Sat, 26 Feb 2011 00:28:21 +0000 (17:28 -0700)]
audit: tweak audit messages to match conventions

* src/qemu/qemu_audit.c (qemuDomainHostdevAudit): Avoid use of
"type", which has a pre-defined meaning.
(qemuDomainCgroupAudit): Likewise, as well as "item".

14 years agodocs: silence warnings about generated API docs
Eric Blake [Wed, 9 Mar 2011 03:42:19 +0000 (20:42 -0700)]
docs: silence warnings about generated API docs

I noticed these while testing 'make dist'.

Parsing ./../src/util/event.c
Function comment for virEventRegisterDefaultImpl lacks description of return value
Function comment for virEventRunDefaultImpl lacks description of return value
Parsing ./../src/util/virterror.c
Missing comment for function virSetErrorLogPriorityFunc

* src/util/event.c (virEventRegisterDefaultImpl)
(virEventRunDefaultImpl): Document return types.
* src/util/virterror.c (virSetErrorLogPriorityFunc): Provide docs.

14 years agodocs: document <driver name='vhost'/> for interfaces
Eric Blake [Tue, 8 Mar 2011 23:35:17 +0000 (16:35 -0700)]
docs: document <driver name='vhost'/> for interfaces

* docs/formatdomain.html.in: Document virtio backend selection.

14 years agoMake sure the rundir is accessible by the user
Guido Günther [Wed, 9 Mar 2011 13:15:48 +0000 (14:15 +0100)]
Make sure the rundir is accessible by the user

otherwise the user might not have enough permissions to access the
socket if root's umask is 077.

http://bugs.debian.org/614210

14 years agoDon't overwrite virRun error messages
Cole Robinson [Tue, 8 Mar 2011 18:46:29 +0000 (13:46 -0500)]
Don't overwrite virRun error messages

virRun gives pretty useful error output, let's not overwrite it unless there
is a good reason. Some places were providing more information about what
the commands were _attempting_ to do, however that's usually less useful from
a debugging POV than what actually happened.

14 years agolibvirtd: Remove indirect linking
Guido Günther [Tue, 8 Mar 2011 20:44:14 +0000 (21:44 +0100)]
libvirtd: Remove indirect linking

as described at
http://wiki.debian.org/ToolChain/DSOLinking
https://fedoraproject.org/wiki/UnderstandingDSOLinkChange

otherwise the build fails on current Debian unstable with:

CCLD   libvirtd
/usr/bin/ld: ../src/.libs/libvirt_driver_lxc.a(libvirt_driver_lxc_la-lxc_container.o): undefined reference to symbol 'capng_apply'
/usr/bin/ld: note: 'capng_apply' is defined in DSO //usr/lib/libcap-ng.so.0 so try adding it to the linker command line

CCLD   libvirtd
/usr/bin/ld: ../src/.libs/libvirt_driver_storage.a(libvirt_driver_storage_la-storage_backend.o): undefined reference to symbol 'fgetfilecon'
/usr/bin/ld: note: 'fgetfilecon' is defined in DSO //lib/libselinux.so.1 so try adding it to the linker command line
//lib/libselinux.so.1: could not read symbols: Invalid operation

and similar errors.

14 years agoFix a wrong error message thrown to user
Hu Tao [Wed, 9 Mar 2011 12:09:25 +0000 (20:09 +0800)]
Fix a wrong error message thrown to user

* src/qemu/qemu_driver.c: qemuDomainUpdateDeviceFlags() is not disk
  specific as the message suggests

14 years agobuild: avoid compiler warning on cygwin
Eric Blake [Wed, 9 Mar 2011 04:47:49 +0000 (21:47 -0700)]
build: avoid compiler warning on cygwin

On cygwin:

  CC       libvirt_driver_security_la-security_dac.lo
security/security_dac.c: In function 'virSecurityDACSetProcessLabel':
security/security_dac.c:618: warning: format '%d' expects type 'int', but argument 7 has type 'uid_t' [-Wformat]

We've done this before (see src/util/util.c).

* src/security/security_dac.c (virSecurityDACSetProcessLabel): On
cygwin, uid_t is a 32-bit long.

14 years agobuild: fix build on cygwin
Eric Blake [Wed, 9 Mar 2011 04:43:26 +0000 (21:43 -0700)]
build: fix build on cygwin

On cygwin:

  CC        libvirt_util_la-cgroup.lo
util/cgroup.c: In function 'virCgroupKillRecursiveInternal':
util/cgroup.c:1458: warning: implicit declaration of function 'virCgroupNew' [-Wimplicit-function-declaration]

* src/util/cgroup.c (virCgroupKill): Don't build on platforms
where virCgroupNew is unsupported.

14 years agobuild: fix building error when building without libvirtd
Wen Congyang [Wed, 9 Mar 2011 03:18:36 +0000 (11:18 +0800)]
build: fix building error when building without libvirtd

When building libvirt without libvirtd, I receive the following errors:
make[1]: Leaving directory `/home/wency/source/test/libvirt/src'
 (cd daemon && make  top_distdir=../libvirt-0.8.8 distdir=../libvirt-0.8.8/daemon \
     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)
make[1]: Entering directory `/home/wency/source/test/libvirt/daemon'
make[1]: *** No rule to make target `libvirtd.8.in', needed by `distdir'.  Stop.

This bug was caused by commit 6db98a2d.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
14 years agodocs: correct range of default NAT subnet
Eric Blake [Tue, 8 Mar 2011 23:15:47 +0000 (16:15 -0700)]
docs: correct range of default NAT subnet

* docs/formatdomain.html.in: Fix typo.

14 years agovirsh: Remove indirect link against libxml2
Guido Günther [Tue, 8 Mar 2011 18:24:28 +0000 (19:24 +0100)]
virsh: Remove indirect link against libxml2

as described at
http://wiki.debian.org/ToolChain/DSOLinking
https://fedoraproject.org/wiki/UnderstandingDSOLinkChange

otherwise the build fails on current Debian unstable with:

CCLD   virsh
/usr/bin/ld: virsh-virsh.o: undefined reference to symbol 'xmlSaveTree@@LIBXML2_2.6.8'
/usr/bin/ld: note: 'xmlSaveTree@@LIBXML2_2.6.8' is defined in DSO //usr/lib/libxml2.so.2 so try adding it to the linker command line
//usr/lib/libxml2.so.2: could not read symbols: Invalid operation

14 years agovirsh: Change option parsing functions to return tri-state information
Michal Privoznik [Tue, 8 Mar 2011 16:29:31 +0000 (17:29 +0100)]
virsh: Change option parsing functions to return tri-state information

This is needed to detect situations when optional argument was
specified with non-integer value: '--int-opt foo'. To keep functions
uniform vshCommandOptString function was also changed, because it
returns tri-state value as well. Given result pointer is updated only
in case of success. If parsing fails, result is not updated at all.

14 years agovirsh: change vshCommandOptString return type and fix const-correctness
Michal Privoznik [Tue, 8 Mar 2011 16:29:30 +0000 (17:29 +0100)]
virsh: change vshCommandOptString return type and fix const-correctness

This function should return pointer to const, because we don't want
to change command option value. Therefore we can ensure const-correctness.

14 years agodocs/formatdomain: Add release info for disk <driver> attributes
Cole Robinson [Tue, 8 Mar 2011 18:02:43 +0000 (13:02 -0500)]
docs/formatdomain: Add release info for disk <driver> attributes

14 years agoFix build on cygwin
Daniel Veillard [Tue, 8 Mar 2011 08:01:25 +0000 (16:01 +0800)]
Fix build on cygwin

Apparently some signals found on Unix are not exposed, this led
to a compilation failure
* src/util/logging.c: make code related to each signal dependant
  upon the definition of that signal

14 years agosupport to detach USB disk
Wen Congyang [Mon, 7 Mar 2011 03:36:48 +0000 (11:36 +0800)]
support to detach USB disk

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
14 years agorename qemuDomainDetachSCSIDiskDevice to qemuDomainDetachDiskDevice
Wen Congyang [Mon, 7 Mar 2011 03:31:48 +0000 (11:31 +0800)]
rename qemuDomainDetachSCSIDiskDevice to qemuDomainDetachDiskDevice

The way to detach a USB disk is the same as that to detach a SCSI
disk. Rename this function and we can use it to detach a USB disk.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
14 years agoqemu_hotplug: Reword error if spice password change not available
Cole Robinson [Mon, 7 Mar 2011 18:09:35 +0000 (13:09 -0500)]
qemu_hotplug: Reword error if spice password change not available

Currently it sounds like spice is completely unsupported, which is
confusing.

14 years agounlock eventLoop before calling callback function
Wen Congyang [Mon, 7 Mar 2011 06:06:49 +0000 (14:06 +0800)]
unlock eventLoop before calling callback function

When I use newest libvirt to save a domain, libvirtd will be deadlock.
Here is the output of gdb:
(gdb) thread 3
[Switching to thread 3 (Thread 0x7f972a1fc710 (LWP 30265))]#0  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
    at qemu/qemu_driver.c:2074
    ret=0x7f972a1fbbe0) at remote.c:2273
(gdb) thread 7
[Switching to thread 7 (Thread 0x7f9730bcd710 (LWP 30261))]#0  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
(gdb) p *(virMutexPtr)0x6fdd60
$2 = {lock = {__data = {__lock = 2, __count = 0, __owner = 30261, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\065v\000\000\001", '\000' <repeats 26 times>, __align = 2}}
(gdb) p *(virMutexPtr)0x1a63ac0
$3 = {lock = {__data = {__lock = 2, __count = 0, __owner = 30265, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\071v\000\000\001", '\000' <repeats 26 times>, __align = 2}}
(gdb) info threads
  7 Thread 0x7f9730bcd710 (LWP 30261)  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
  6 Thread 0x7f972bfff710 (LWP 30262)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  5 Thread 0x7f972b5fe710 (LWP 30263)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  4 Thread 0x7f972abfd710 (LWP 30264)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
* 3 Thread 0x7f972a1fc710 (LWP 30265)  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
  2 Thread 0x7f97297fb710 (LWP 30266)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  1 Thread 0x7f9737aac800 (LWP 30260)  0x000000351fe0803d in pthread_join () from /lib64/libpthread.so.0

The reason is that we will try to lock some object in callback function, and we may call event API with locking the same object.
In the function virEventDispatchHandles(), we unlock eventLoop before calling callback function. I think we should
do the same thing in the function virEventCleanupTimeouts() and virEventCleanupHandles().

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
14 years agoExpose event loop implementation as a public API
Daniel P. Berrange [Wed, 2 Mar 2011 16:59:54 +0000 (16:59 +0000)]
Expose event loop implementation as a public API

Not all applications have an existing event loop they need
to integrate with. Forcing them to implement the libvirt
event loop integration APIs is an undue burden. This just
exposes our simple poll() based implementation for apps
to use. So instead of calling

   virEventRegister(....callbacks...)

The app would call

   virEventRegisterDefaultImpl()

And then have a thread somewhere calling

    static bool quit = false;
    ....
    while (!quit)
      virEventRunDefaultImpl()

* daemon/libvirtd.c, tools/console.c,
  tools/virsh.c: Convert to public event loop APIs
* include/libvirt/libvirt.h.in, src/libvirt_private.syms: Add
  virEventRegisterDefaultImpl and virEventRunDefaultImpl
* src/util/event.c: Implement virEventRegisterDefaultImpl
  and virEventRunDefaultImpl using poll() event loop
* src/util/event_poll.c: Add full error reporting
* src/util/virterror.c, include/libvirt/virterror.h: Add
  VIR_FROM_EVENTS

14 years agoMove event code out of the daemon/ into src/util/
Daniel P. Berrange [Thu, 24 Feb 2011 17:58:04 +0000 (17:58 +0000)]
Move event code out of the daemon/ into src/util/

The event loop implementation is used by more than just the
daemon, so move it into the shared area.

* daemon/event.c, src/util/event_poll.c: Renamed
* daemon/event.h, src/util/event_poll.h: Renamed
* tools/Makefile.am, tools/console.c, tools/virsh.c: Update
  to use new virEventPoll APIs
* daemon/mdns.c, daemon/mdns.c, daemon/Makefile.am: Update
  to use new virEventPoll APIs

14 years agoConvert daemon/virsh over to use primary event APIs, rather than impl
Daniel P. Berrange [Wed, 2 Mar 2011 15:08:31 +0000 (15:08 +0000)]
Convert daemon/virsh over to use primary event APIs, rather than impl

The daemon code calls virEventAddHandleImpl directly instead
of calling the wrapper virEventAddHandle.

* tools/console.c, daemon/libvirtd.c, daemon/mdns.c: Convert to
  use primary event APIs

14 years agoCleaning up some of the logging code
Daniel Veillard [Mon, 7 Mar 2011 13:23:53 +0000 (21:23 +0800)]
Cleaning up some of the logging code

* src/util/logging.c: fix virLogDumpAllFD() to avoid snprintf, simplify
  the code and provide more useful signal descriptions. Also remove an
  unused variable.

14 years agoqemu: Support vram for video of qxl type
Osier Yang [Sun, 6 Mar 2011 14:00:27 +0000 (22:00 +0800)]
qemu: Support vram for video of qxl type

For qemu names the primary vga as "qxl-vga":

  1) if vram is specified for 2nd qxl device:

    -vga qxl -global qxl-vga.vram_size=$SIZE \
    -device qxl,id=video1,vram_size=$SIZE,...

  2) if vram is not specified for 2nd qxl device, (use the default
     set by global):

    -vga qxl -global qxl-vga.vram_size=$SIZE \
    -device qxl,id=video1,...

For qemu names all qxl devices as "qxl":

  1) if vram is specified for 2nd qxl device:

    -vga qxl -global qxl.vram_size=$SIZE \
    -device qxl,id=video1,vram_size=$SIZE ...

  2) if vram is not specified for 2nd qxl device:

    -vga qxl -global qxl-vga.vram_size=$SIZE \
    -device qxl,id=video1,...

"-global" is the only way to define vram_size for the primary qxl
device, regardless of how qemu names it, (It's not good a good
way, as original idea of "-global" is to set a global default for
a driver property, but to specify vram for first qxl device, we
have to use it).

For other qxl devices, as they are represented by "-device", could
specify it directly and seperately for each, and it overrides the
default set by "-global" if specified.

v1 - v2:
  * modify "virDomainVideoDefaultRAM" so that it returns 16M as the
    default vram_size for qxl device.

  * vram_size * 1024 (qemu accepts bytes for vram_size).

  * apply default vram_size for qxl device for which vram_size is
    not specified.

  * modify "graphics-spice" tests (more sensiable vram_size)

  * Add an argument of virDomainDefPtr type for qemuBuildVideoDevStr,
    to use virDomainVideoDefaultRAM in qemuBuildVideoDevStr).

v2 - v3:
  * Modify default video memory size for qxl device from 16M to 24M

  * Update codes to be consistent with changes on qemu_capabilities.*

14 years agofixes for several memory leaks
Phil Petty [Fri, 4 Mar 2011 16:52:12 +0000 (09:52 -0700)]
fixes for several memory leaks

Signed-off-by: Eric Blake <eblake@redhat.com>
14 years agoDump the debug buffer to libvirtd.log on fatal signal
Daniel Veillard [Thu, 3 Mar 2011 09:41:44 +0000 (17:41 +0800)]
Dump the debug buffer to libvirtd.log on fatal signal

In case of imminent crash or upon request (signal USR2),
dump the logging buffer to the libvirtd.log file for
post-mortem analysis
* daemon/libvirtd.c: create a sig_fatal() handler connected to
  SIGFPE SIGSEGV SIGILL SIGABRT SIGBUS and SIGUSR2, just dumping
  the log buffer using virLogEmergencyDumpAll

14 years agoAdd an an internal API for emergency dump of debug buffer
Daniel Veillard [Thu, 3 Mar 2011 08:32:18 +0000 (16:32 +0800)]
Add an an internal API for emergency dump of debug buffer

virLogEmergencyDumpAll() allows to dump the content of the
debug buffer from within a signal handler. It saves to all
log file or stderr if none is found
* src/util/logging.h src/util/logging.c: add the new API
  and cleanup the old virLogDump code
* src/libvirt_private.syms: exports it as a private symbol

14 years agoFix a counter bug in the log buffer
Daniel Veillard [Thu, 3 Mar 2011 07:45:52 +0000 (15:45 +0800)]
Fix a counter bug in the log buffer

* src/util/logging.c: the start pointer need to wrap around too

14 years agoAdd logrotate support for libvirtd.log
Daniel Veillard [Thu, 3 Mar 2011 07:26:22 +0000 (15:26 +0800)]
Add logrotate support for libvirtd.log

As the file may grow quite a bit especially with debug turned on.
* daemon/libvirtd.logrotate.in daemon/Makefile.am libvirt.spec.in:
  add new logrotate file for the daemon log

14 years agoChange default log policy to libvirtd.log instead of syslog
Daniel Veillard [Thu, 3 Mar 2011 06:48:06 +0000 (14:48 +0800)]
Change default log policy to libvirtd.log instead of syslog

Syslog is not the best place to go search for libvirt error
logs, change it to a default file output libvirtd.log, but
still keep standard error if not run as a daemon.
Depending on whether it's run as root or user, the log is saved
in the local state dir or in $HOME/.libvirt.
* daemon/libvirtd.c: change default logging to go to libvirtd.log

14 years agoForce all logs to go to the round robbin memory buffer
Daniel Veillard [Wed, 2 Mar 2011 12:26:02 +0000 (20:26 +0800)]
Force all logs to go to the round robbin memory buffer

Initially only the log actually written out by libvirt were
saved on the memory buffer, this patch forces all informations
including info and debug to be saved in memory too. This is
useful to get full data in case of crash.

14 years agoqemu: avoid corruption of domain hashtable and misuse of freed domains
Laine Stump [Thu, 3 Mar 2011 18:21:07 +0000 (13:21 -0500)]
qemu: avoid corruption of domain hashtable and misuse of freed domains

This was also found while investigating

   https://bugzilla.redhat.com/show_bug.cgi?id=670848

An EOF on a domain's monitor socket results in an event being queued
to handle the EOF. The handler calls qemuProcessHandleMonitorEOF. If
it is a transient domain, this leads to a call to
virDomainRemoveInactive, which removes the domain from the driver's
hashtable and unref's it. Nowhere in this code is the qemu driver lock
acquired.

However, all modifications to the driver's domain hashtable *must* be
done while holding the driver lock, otherwise the hashtable can become
corrupt, and (even more likely) another thread could call a different
hashtable function and acquire a pointer to the domain that is in the
process of being destroyed.

To prevent such a disaster, qemuProcessHandleMonitorEOF must get the
qemu driver lock *before* it gets the DomainObj's lock, and hold it
until it is finished with the DomainObj. This guarantees that nobody
else modifies the hashtable at the same time, and that anyone who had
already gotten the DomainObj from the hashtable prior to this call has
finished with it before we remove/destroy it.

14 years agoqemu: Add missing lock of virDomainObj before calling virDomainUnref
Laine Stump [Thu, 3 Mar 2011 16:54:08 +0000 (11:54 -0500)]
qemu: Add missing lock of virDomainObj before calling virDomainUnref

This was found while researching the root cause of:

https://bugzilla.redhat.com/show_bug.cgi?id=670848

virDomainUnref should only be called with the lock held for the
virDomainObj in question. However, when a transient qemu domain gets
EOF on its monitor socket, it queues an event which frees the monitor,
which unref's the virDomainObj without first locking it. If another
thread has already locked the virDomainObj, the modification of the
refcount could potentially be corrupted. In an extreme case, it could
also be potentially unlocked by virDomainObjFree, thus left open to
modification by anyone else who would have otherwise waited for the
lock (not to mention the fact that they would be accessing freed
data!).

The solution is to have qemuMonitorFree lock the domain object right
before unrefing it. Since the caller to qemuMonitorFree doesn't expect
this lock to be held, if the refcount doesn't go all the way to 0,
qemuMonitorFree must unlock it after the unref.

14 years agoAUTHORS: adjust to preferred spelling
KAMEZAWA Hiroyuki [Thu, 3 Mar 2011 04:52:14 +0000 (13:52 +0900)]
AUTHORS: adjust to preferred spelling

maybe sounds strange but I've used this signature for years.
see http://en.wikipedia.org/wiki/Family_name

14 years agoesx: Escape password for XML
Matthias Bolte [Thu, 3 Mar 2011 21:11:24 +0000 (22:11 +0100)]
esx: Escape password for XML

Passwords are allowed to contain <, >, &, ', " characters.
Those need to be replaced by the corresponding entities.

Reported by Hereward Cooper.

14 years agoutil: correct retry path in virFileOperation
Eric Blake [Wed, 2 Mar 2011 23:25:57 +0000 (16:25 -0700)]
util: correct retry path in virFileOperation

In virFileOperation, the parent does a fallback to a non-fork
attempt if it detects that the child returned EACCES.  However,
the child was calling _exit(-EACCES), which does _not_ appear
as EACCES in the parent.

* src/util/util.c (virFileOperation): Correctly pass EACCES from
child to parent.

14 years agoPass virSecurityManagerPtr to virSecurityDAC{Set, Restore}ChardevCallback
Soren Hansen [Thu, 3 Mar 2011 14:47:48 +0000 (15:47 +0100)]
Pass virSecurityManagerPtr to virSecurityDAC{Set, Restore}ChardevCallback

virSecurityDAC{Set,Restore}ChardevCallback expect virSecurityManagerPtr,
but are passed virDomainObjPtr instead. This makes
virSecurityDACSetChardevLabel set a wrong uid/gid on chardevs. This
patch fixes this behaviour.

Signed-off-by: Soren Hansen <soren@linux2go.dk>
14 years agomaint: update to latest gnulib
Eric Blake [Fri, 25 Feb 2011 22:30:01 +0000 (15:30 -0700)]
maint: update to latest gnulib

* .gnulib: Update to latest, for syntax-check improvement.
* .x-sc_prohibit_empty_lines_at_EOF: Add more exemptions.

14 years agomaint: avoid long lines in more tests
Eric Blake [Fri, 25 Feb 2011 22:20:58 +0000 (15:20 -0700)]
maint: avoid long lines in more tests

* tests/xml2sexprdata/*.sexpr: Add backslash-newlines.
* tests/sexpr2xmldata/*.sexpr: Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args: Likewise.

14 years agoutil: Allow removing hash entries in virHashForEach
Jiri Denemark [Thu, 3 Mar 2011 13:10:51 +0000 (14:10 +0100)]
util: Allow removing hash entries in virHashForEach

This fixes a possible crash of libvirtd during its startup. When qemu
driver reconnects to running domains, it iterates over all domain
objects in a hash. When reconnecting to an associated qemu monitor
fails and the domain is transient, it's immediately removed from the
hash. Despite the fact that it's explicitly forbidden to do so. If
libvirtd is lucky enough, virHashForEach will access random memory when
the callback finishes and the deamon will crash.

Since it's trivial to fix virHashForEach to allow removal of hash
entries while iterating through them, I went this way instead of fixing
qemuReconnectDomain callback (and possibly others) to avoid deleting the
entries.

14 years agoAttempt to improve an error message
Daniel P. Berrange [Fri, 18 Feb 2011 15:52:20 +0000 (15:52 +0000)]
Attempt to improve an error message

Replace the 'Unknown failure' error message with something a
little bit more descriptive.

* src/util/virterror.c: Improve error message

14 years agoqemu: avoid double close on domain restore
Eric Blake [Wed, 2 Mar 2011 03:59:38 +0000 (20:59 -0700)]
qemu: avoid double close on domain restore

qemudDomainSaveImageStartVM was evil - it closed the incoming fd
argument on some, but not all, code paths, without informing the
caller about that action.  No wonder that this resulted in
double-closes: https://bugzilla.redhat.com/show_bug.cgi?id=672725

* src/qemu/qemu_driver.c (qemudDomainSaveImageStartVM): Alter
signature, to avoid double-close.
(qemudDomainRestore, qemudDomainObjRestore): Update callers.

14 years agoadd additional event debug points
Daniel P. Berrange [Tue, 1 Mar 2011 23:53:32 +0000 (16:53 -0700)]
add additional event debug points

Followup to commit 2222bd24

14 years agoqemu: only request sound cgroup ACL when required
Eric Blake [Fri, 25 Feb 2011 18:55:44 +0000 (11:55 -0700)]
qemu: only request sound cgroup ACL when required

When a SPICE or VNC graphics controller is present, and sound is
piggybacked over a channel to the graphics device rather than
directly accessing host hardware, then there is no need to grant
host hardware access to that qemu process.

* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Prevent sound with
spice, and with vnc when vnc_allow_host_audio is 0.
Reported by Daniel Berrange.

14 years agoAdd check for kill() to fix build of cgroups on win32
Daniel P. Berrange [Mon, 28 Feb 2011 14:13:58 +0000 (14:13 +0000)]
Add check for kill() to fix build of cgroups on win32

The kill() function doesn't exist on Win32, so it needs to be
checked for at build time & code disabled in cgroups

* configure.ac: Check for kill()
* src/util/cgroup.c: Stub out virCGroupKill* functions
  when kill() isn't available

14 years agoAdd support for multiple serial ports into the Xen driver
Michal Novotny [Fri, 25 Feb 2011 14:41:12 +0000 (15:41 +0100)]
Add support for multiple serial ports into the Xen driver

this is the patch to add support for multiple serial ports to the
libvirt Xen driver. It support both old style (serial = "pty") and
new style (serial = [ "/dev/ttyS0", "/dev/ttyS1" ]) definition and
tests for xml2sexpr, sexpr2xml and xmconfig have been added as well.

Written and tested on RHEL-5 Xen dom0 and working as designed but
the Xen version have to have patch for RHBZ #614004 but this patch
is for upstream version of libvirt.

Also, this patch is addressing issue described in RHBZ #670789.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
14 years agoFix port value parsing for serial and parallel ports
Michal Novotny [Fri, 25 Feb 2011 14:41:11 +0000 (15:41 +0100)]
Fix port value parsing for serial and parallel ports

this is the patch to fix the virDomainChrDefParseTargetXML() functionality
to parse the target port from XML if available. This is necessary for
multiple serial port support which is the second part of this patch.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
14 years agoAdd APIs for killing off processes inside a cgroup
Daniel P. Berrange [Tue, 22 Feb 2011 17:33:59 +0000 (17:33 +0000)]
Add APIs for killing off processes inside a cgroup

The virCgroupKill method kills all PIDs found in a cgroup

The virCgroupKillRecursively method does this recursively
for child cgroups.

The virCgroupKillPainfully method does a recursive kill
several times in a row until everything has really died

14 years agoAllow hash tables to use generic pointers as keys
Daniel P. Berrange [Tue, 22 Feb 2011 15:11:59 +0000 (15:11 +0000)]
Allow hash tables to use generic pointers as keys

Relax the restriction that the hash table key must be a string
by allowing an arbitrary hash code generator + comparison func
to be provided

* util/hash.c, util/hash.h: Allow any pointer as a key
* internal.h: Include stdbool.h as standard.
* conf/domain_conf.c, conf/domain_conf.c,
  conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
  nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
  qemu/qemu_command.c, qemu/qemu_driver.c,
  qemu/qemu_process.c, uml/uml_driver.c,
  xen/xm_internal.c: s/char */void */ in hash callbacks

14 years agoRemove deallocator parameter from hash functions
Daniel P. Berrange [Tue, 22 Feb 2011 15:11:59 +0000 (15:11 +0000)]
Remove deallocator parameter from hash functions

Since the deallocator is passed into the constructor of
a hash table it is not desirable to pass it into each
function again. Remove it from all functions, but provide
a virHashSteal to allow a item to be removed from a hash
table without deleteing it.

* src/util/hash.c, src/util/hash.h: Remove deallocator
  param from all functions. Add virHashSteal
* src/libvirt_private.syms: Add virHashSteal
* src/conf/domain_conf.c, src/conf/nwfilter_params.c,
  src/nwfilter/nwfilter_learnipaddr.c,
  src/qemu/qemu_command.c, src/xen/xm_internal.c: Update
  for changed hash API

14 years agoMake commandtest more robust wrt its execution environment
Daniel P. Berrange [Thu, 24 Feb 2011 12:12:27 +0000 (12:12 +0000)]
Make commandtest more robust wrt its execution environment

When executed from cron, commandtest would fail to correctly
identify daemon processes. Set session ID and process group
IDs at startup to ensure we have a consistent environment to
run in.

* tests/commandtest.c: Call setsid() and setpgid()

14 years agoFix spelling mistake: seek
Philipp Hahn [Thu, 24 Feb 2011 07:06:03 +0000 (08:06 +0100)]
Fix spelling mistake: seek

Replace wrong "set" by correct "seek" in error message.

Signed-off-by: Philipp Hahn <hahn@univention.de>
14 years agoaudit: audit qemu pci and usb device passthrough
Eric Blake [Wed, 23 Feb 2011 23:15:23 +0000 (16:15 -0700)]
audit: audit qemu pci and usb device passthrough

* src/qemu/qemu_audit.h (qemuDomainHostdevAudit): New prototype.
* src/qemu/qemu_audit.c (qemuDomainHostdevAudit): New function.
(qemuDomainStartAudit): Call as appropriate.
* src/qemu/qemu_hotplug.c (qemuDomainAttachHostPciDevice)
(qemuDomainAttachHostUsbDevice, qemuDomainDetachHostPciDevice)
(qemuDomainDetachHostUsbDevice): Likewise.

14 years agoaudit: audit qemu memory and vcpu adjusments
Eric Blake [Tue, 22 Feb 2011 00:02:17 +0000 (17:02 -0700)]
audit: audit qemu memory and vcpu adjusments

* src/qemu/qemu_audit.h (qemuDomainMemoryAudit)
(qemuDomainVcpuAudit): New prototypes.
* src/qemu/qemu_audit.c (qemuDomainResourceAudit)
(qemuDomainMemoryAudit, qemuDomainVcpuAudit): New functions.
(qemuDomainStartAudit): Call as appropriate.
* src/qemu/qemu_driver.c (qemudDomainSetMemory)
(qemudDomainHotplugVcpus): Likewise.

14 years agoaudit: add qemu hooks for auditing cgroup events
Eric Blake [Wed, 16 Feb 2011 02:35:43 +0000 (19:35 -0700)]
audit: add qemu hooks for auditing cgroup events

* src/qemu/qemu_audit.h (qemuDomainCgroupAudit): New prototype.
* src/qemu/qemu_audit.c (qemuDomainCgroupAudit): Implement it.
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Add audit.
* src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
(qemuSetupChardevCgroup, qemuSetupHostUsbDeviceCgroup)
(qemuSetupCgroup, qemuTeardownDiskPathDeny): Likewise.

14 years agoaudit: prepare qemu for listing vm in cgroup audits
Eric Blake [Wed, 16 Feb 2011 02:18:40 +0000 (19:18 -0700)]
audit: prepare qemu for listing vm in cgroup audits

* src/qemu/qemu_cgroup.h (struct qemuCgroupData): New helper type.
(qemuSetupDiskPathAllow, qemuSetupChardevCgroup)
(qemuTeardownDiskPathDeny): Drop unneeded prototypes.
(qemuSetupDiskCgroup, qemuTeardownDiskCgroup): Adjust prototype.
* src/qemu/qemu_cgroup.c
(qemuSetupDiskPathAllow, qemuSetupChardevCgroup)
(qemuTeardownDiskPathDeny): Mark static and use new type.
(qemuSetupHostUsbDeviceCgroup): Use new type.
(qemuSetupDiskCgroup): Alter signature.
(qemuSetupCgroup): Adjust caller.
* src/qemu/qemu_hotplug.c (qemuDomainAttachHostUsbDevice)
(qemuDomainDetachPciDiskDevice, qemuDomainDetachSCSIDiskDevice):
Likewise.
* src/qemu/qemu_driver.c (qemudDomainAttachDevice)
(qemuDomainUpdateDeviceFlags): Likewise.

14 years agocgroup: determine when skipping non-devices
Eric Blake [Thu, 17 Feb 2011 00:05:54 +0000 (17:05 -0700)]
cgroup: determine when skipping non-devices

* src/util/cgroup.c (virCgroupAllowDevicePath)
(virCgroupDenyDevicePath): Don't fail with EINVAL for
non-devices.
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update caller.
* src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
(qemuSetupChardevCgroup, qemuSetupHostUsbDeviceCgroup)
(qemuSetupCgroup, qemuTeardownDiskPathDeny): Likewise.

14 years agovirExec: avoid uninitialized memory usage
Eric Blake [Mon, 21 Feb 2011 21:27:04 +0000 (14:27 -0700)]
virExec: avoid uninitialized memory usage

valgrind warns:

==21079== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s)
==21079==    at 0x329840F63E: __libc_sigaction (sigaction.c:67)
==21079==    by 0x4E5A8E7: __virExec (util.c:661)

Regression introduced in commit ab07533e.  Technically, sa_mask
shouldn't affect operation if sa_flags selects sa_handler, and
sa_handler selects SIG_IGN, but better safe than sorry.

* src/util/util.c (__virExec): Supply missing sigemptyset.

14 years agoAllow 32-on-64 execution for LXC guests
Daniel P. Berrange [Wed, 23 Feb 2011 17:17:53 +0000 (17:17 +0000)]
Allow 32-on-64 execution for LXC guests

Using the 'personality(2)' system call, we can make a container
on an x86_64 host appear to be i686. Likewise for most other
Linux 64bit arches.

* src/lxc/lxc_conf.c: Fill in 32bit capabilities for x86_64 hosts
* src/lxc/lxc_container.h, src/lxc/lxc_container.c: Add API to
  check if an arch has a 32bit alternative
* src/lxc/lxc_controller.c: Set the process personality when
  starting guest

14 years agoPut <stdbool.h> into internal.h so it is available everywhere
Daniel P. Berrange [Wed, 23 Feb 2011 11:37:03 +0000 (11:37 +0000)]
Put <stdbool.h> into internal.h so it is available everywhere

Remove the <stdbool.h> header from all source files / headers
and just put it into internal.h

* src/internal.h: Add <stdbool.h>

14 years agoqemu: Switch over command line capabilities to virBitmap
Jiri Denemark [Tue, 8 Feb 2011 14:22:39 +0000 (15:22 +0100)]
qemu: Switch over command line capabilities to virBitmap

This is done for two reasons:
- we are getting very close to 64 flags which is the maximum we can use
  with unsigned long long
- by using LL constants in enum we already violates C99 constraint that
  enum values have to fit into int

14 years agoqemu: Rename qemud\?CmdFlags to qemuCaps
Jiri Denemark [Tue, 8 Feb 2011 14:28:53 +0000 (15:28 +0100)]
qemu: Rename qemud\?CmdFlags to qemuCaps

The new name complies more with the fact that it contains a set of
qemuCapsFlags.

14 years agoqemu: Use helper functions for handling cmd line capabilities
Jiri Denemark [Tue, 8 Feb 2011 14:08:12 +0000 (15:08 +0100)]
qemu: Use helper functions for handling cmd line capabilities

Three new functions (qemuCapsSet, qemuCapsClear, and qemuCapsGet) were
introduced replacing direct bit operations.

14 years agoqemu: Rename QEMUD_CMD_FLAG_* to QEMU_CAPS_*
Jiri Denemark [Mon, 7 Feb 2011 14:54:08 +0000 (15:54 +0100)]
qemu: Rename QEMUD_CMD_FLAG_* to QEMU_CAPS_*

The new names comply more with the fact that they are all members of
enum qemuCapsFlags.

14 years agoutil: Add API for converting virBitmap into printable string
Jiri Denemark [Wed, 9 Feb 2011 12:14:51 +0000 (13:14 +0100)]
util: Add API for converting virBitmap into printable string

14 years agoutil: Use unsigned long as a base type for virBitmap
Jiri Denemark [Thu, 10 Feb 2011 10:11:15 +0000 (11:11 +0100)]
util: Use unsigned long as a base type for virBitmap