]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoqemu: make qemu processes to retain rawio capability
Taku Izumi [Tue, 31 Jan 2012 04:52:00 +0000 (23:52 -0500)]
qemu: make qemu processes to retain rawio capability

This patch revises qemuProcessStart() function for qemu
processes to retain CAP_SYS_RAWIO if needed.
And in case of that, add taint flag to domain.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
13 years agoutil: extend virExecWithHook()
Taku Izumi [Tue, 31 Jan 2012 04:51:00 +0000 (23:51 -0500)]
util: extend virExecWithHook()

This patch extends virExecWithHook() to receive
capability information.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
13 years agoutil: add functions to keep capabilities
Taku Izumi [Tue, 31 Jan 2012 04:50:00 +0000 (23:50 -0500)]
util: add functions to keep capabilities

This patch introduces virSetCapabilities() function and implements
virCommandAllowCap() function.

Existing virClearCapabilities() is function to clear all capabilities.
Instead virSetCapabilities() is function to set arbitrary capabilities.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
13 years agoconf: add rawio attribute to disk element of domain XML
Taku Izumi [Tue, 31 Jan 2012 04:49:00 +0000 (23:49 -0500)]
conf: add rawio attribute to disk element of domain XML

 This patch adds a new attribute "rawio" to the "disk" element
 of domain XML. Valid values of "rawio" attribute are "yes"
 and "no".
 rawio='yes' indicates the disk is desirous of CAP_SYS_RAWIO.

 If you specify the following XML:

 <disk type='block' device='lun' rawio='yes'>
  ...
 </disk>

 the domain will be granted CAP_SYS_RAWIO.
 (of course, the domain have to be executed with root privilege)

NOTE:
   - "rawio" attribute is only valid when device='lun'
   - At the moment, any other disks you won't use rawio can use rawio.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoImplement virStorageVolResize() for FS backend
Zeeshan Ali (Khattak) [Mon, 30 Jan 2012 07:40:00 +0000 (02:40 -0500)]
Implement virStorageVolResize() for FS backend

Currently only VIR_STORAGE_VOL_RESIZE_DELTA flag is supported.

13 years agoresize: slightly alter signature
Eric Blake [Mon, 30 Jan 2012 19:04:20 +0000 (12:04 -0700)]
resize: slightly alter signature

Our existing virDomainBlockResize takes an unsigned long long
argument; if that command is later taught a DELTA and SHRINK flag,
we cannot change its type without breaking API (but at least such
a change would be ABI compatible).  Meanwhile, the only time a
negative size makes sense is if both DELTA and SHRINK are used
together, but if we keep the argument unsigned, applications can
pass the positive delta amount by which they would like to shrink
the system, and have the flags imply the negative value.  So,
since this API has not yet been released, and in the interest of
consistency with existing API, we swap virStorageVolResize to
always pass an unsigned value.

* include/libvirt/libvirt.h.in (virStorageVolResize): Use unsigned
argument.
* src/libvirt.c (virStorageVolResize): Likewise.
* src/driver.h (virDrvStorageVolUpload): Adjust clients.
* src/remote/remote_protocol.x (remote_storage_vol_resize_args):
Likewise.
* src/remote_protocol-structs: Regenerate.
Suggested by Daniel P. Berrange.

13 years agoXenXs: Update documentation
Philipp Hahn [Tue, 17 Jan 2012 08:26:13 +0000 (09:26 +0100)]
XenXs: Update documentation

Fix several references to now renamed functions and parameters when the
functions were moved from src/xen/ to src/xenxs/.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoqemu: add "romfile" support to specify device boot ROM
Laine Stump [Wed, 25 Jan 2012 16:20:49 +0000 (11:20 -0500)]
qemu: add "romfile" support to specify device boot ROM

This patch addresses: https://bugzilla.redhat.com/show_bug.cgi?id=781562

Along with the "rombar" option that controls whether or not a boot rom
is made visible to the guest, qemu also has a "romfile" option that
allows specifying a binary file to present as the ROM BIOS of any
emulated or passthrough PCI device. This patch adds support for
specifying romfile to both passthrough PCI devices, and emulated
network devices that attach to the guest's PCI bus (just about
everything other than ne2k_isa).

One example of the usefulness of this option is described in the
bugzilla report: 82576 sriov network adapters don't provide a ROM BIOS
for the cards virtual functions (VF), but an image of such a ROM is
available, and with this ROM visible to the guest, it can PXE boot.

In libvirt's xml, the new option is configured like this:

   <hostdev>
     ...
     <rom file='/etc/fake/boot.bin'/>
     ...
   </hostdev

(similarly for <interface>).

13 years agoqemu: (and conf) support rombar for network devices
Laine Stump [Wed, 25 Jan 2012 00:54:12 +0000 (19:54 -0500)]
qemu: (and conf) support rombar for network devices

When support for the rombar option was added, it was only added for
PCI passthrough devices, configured with <hostdev>. The same option is
available for any network device that is attached to the guest's PCI
bus. This patch allows setting rombar for any PCI network device type.

After adding cases to test this to qemuxml2argv-hostdev-pci-rombar.*,
I decided to rename those files (to qemuxml2argv-pci-rom.*) to more
accurately reflect the additional tests, and also noticed that up to
now we've only been performing a domainschematest for that case, so I
added the "pci-rom" test to both qemuxml2argv and qemuxml2xml (and in
the process found some bugs whose fixes I squashed into previous
commits of this series).

13 years agoconf: relocate rombar and boot order parse/format
Laine Stump [Tue, 24 Jan 2012 19:11:05 +0000 (14:11 -0500)]
conf: relocate rombar and boot order parse/format

Since these two items are now in the virDomainDeviceInfo struct, it
makes sense to parse/format them in the functions written to
parse/format that structure. Not all types of devices allow them, so
two internal flags are added to indicate when it is appropriate to do
so.

I was lucky - only one test case needed to be re-ordered!

13 years agoconf: put all guest-related HostdevDef data in one object
Laine Stump [Tue, 24 Jan 2012 17:53:59 +0000 (12:53 -0500)]
conf: put all guest-related HostdevDef data in one object

To help consolidate the commonality between virDomainHostdevDef and
virDomainNetDef into as few members as possible (and because I
think it makes sense), this patch moves the rombar and bootIndex
members into the "info" member that is common to both (and to all the
other structs that use them).

It's a bit problematic that this gives rombar and bootIndex to many
device types that don't use them, but this is already the case for the
master and mastertype members of virDomainDeviceInfo, and is properly
commented as such in the definition.

Note that this opens the door to supporting rombar for other devices
that are attached to the guest PCI bus - virtio-blk-pci,
virtio-net-pci, various other network adapters - which which have that
capability in qemu, but previously had no support in libvirt.

13 years agoconf: remove duplicate call to VIR_FREE(info->alias)
Laine Stump [Wed, 25 Jan 2012 16:40:13 +0000 (11:40 -0500)]
conf: remove duplicate call to VIR_FREE(info->alias)

There is another identical call 4 lines up in the same function.

13 years agoqemu: Fix segfault in qemuMonitorTextGetBlockInfo
Hendrik Schwartke [Mon, 30 Jan 2012 12:36:46 +0000 (13:36 +0100)]
qemu: Fix segfault in qemuMonitorTextGetBlockInfo

If some error occurs then the cleanup code calls VIR_FREE(info)
without ensuring that info is initialized.

13 years agoxen: Don't add <console> to xml for dom0
Cole Robinson [Sun, 29 Jan 2012 19:10:00 +0000 (14:10 -0500)]
xen: Don't add <console> to xml for dom0

It just doesn't really make sense and confuses virt-manager

13 years agoAdd virt-host-validate.1 to Mingw32 RPM spec file list
Daniel P. Berrange [Mon, 30 Jan 2012 12:03:30 +0000 (12:03 +0000)]
Add virt-host-validate.1 to Mingw32 RPM spec file list

13 years agoremote handler for virDomainGetCPUStats()
KAMEZAWA Hiroyuki [Sat, 28 Jan 2012 06:21:31 +0000 (15:21 +0900)]
remote handler for virDomainGetCPUStats()

Unlike other users of virTypedParameter with RPC, this interface
can return zero-filled entries because the interface assumes
2 dimensional array. We compress these entries out from the
server when generating the over-the-wire contents, then reconstitute
them in the client.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agodocs: reorder public header
Eric Blake [Sat, 28 Jan 2012 14:37:55 +0000 (07:37 -0700)]
docs: reorder public header

The bottom of the public header is reserved for deprecated APIs;
it's nicer to arrange things in logical groups.

* include/libvirt/libvirt.h.in (virConnectSetKeepAlive)
(virDomainGetCPUStats): Float earlier in the file.

13 years agodocs: tweak recent suspend API additions
Eric Blake [Sat, 28 Jan 2012 14:29:10 +0000 (07:29 -0700)]
docs: tweak recent suspend API additions

* src/libvirt.c (virDomainPMSuspendForDuration): Clarify usage.

13 years agoAdd new public API virDomainGetCPUStats()
KAMEZAWA Hiroyuki [Sat, 28 Jan 2012 06:20:28 +0000 (15:20 +0900)]
Add new public API virDomainGetCPUStats()

add new API virDomainGetCPUStats() for getting cpu accounting information
per real cpus which is used by a domain.  The API is designed to allow
future extensions for additional statistics.

based on ideas by Lai Jiangshan and Eric Blake.

* src/libvirt_public.syms: add API for LIBVIRT_0.9.10
* src/libvirt.c: define virDomainGetCPUStats()
* include/libvirt/libvirt.h.in: add virDomainGetCPUStats() header
* src/driver.h: add driver API
* python/generator.py: add python API (as not implemented)

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agovirsh: Expose new virDomainPMSuspendForDuration API
Michal Privoznik [Thu, 26 Jan 2012 19:20:49 +0000 (20:20 +0100)]
virsh: Expose new virDomainPMSuspendForDuration API

under new command "dompmsuspend"

13 years agoIntroduce virDomainPMSuspendForDuration API
Michal Privoznik [Thu, 26 Jan 2012 18:05:46 +0000 (19:05 +0100)]
Introduce virDomainPMSuspendForDuration API

This API allows a domain to be put into one of S# ACPI states.
Currently, S3 and S4 are supported. These states are shared
with virNodeSuspendForDuration.
However, for now we don't support any duration other than zero.
The same apply for flags.

13 years agoresize: implement remote protocol for virStorageVolResize()
Zeeshan Ali (Khattak) [Fri, 27 Jan 2012 05:29:56 +0000 (07:29 +0200)]
resize: implement remote protocol for virStorageVolResize()

Autogeneration saves the day.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoresize: add virStorageVolResize() API
Zeeshan Ali (Khattak) [Fri, 27 Jan 2012 05:29:56 +0000 (07:29 +0200)]
resize: add virStorageVolResize() API

Add a new function to allow changing of capacity of storage volumes.
Plan out several flags, even if not all of them will be implemented
up front.

Expose the new command via 'virsh vol-resize'.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agotests: fix reversed comparisons
Eric Blake [Fri, 27 Jan 2012 23:35:14 +0000 (16:35 -0700)]
tests: fix reversed comparisons

Otherwise, a failed test gives misleading output.

* tests/commandtest.c (test13, test14, test16): Pass arguments in
correct order.

13 years agoReturn more error output if policykit auth fails.
Cole Robinson [Fri, 27 Jan 2012 22:01:21 +0000 (17:01 -0500)]
Return more error output if policykit auth fails.

Several not uncommon issues can be diagnosed through pkcheck output, like
lack of/malfunctioning desktop agent, or lack of/malfunctioning polkit
dbus agent.

13 years agoAdd new error code VIR_ERROR_AUTH_CANCELLED
Cole Robinson [Fri, 27 Jan 2012 18:06:49 +0000 (13:06 -0500)]
Add new error code VIR_ERROR_AUTH_CANCELLED

And hook it up for policykit auth. This allows virt-manager to detect
that the user clicked the policykit 'cancel' button and not throw
an 'authentication failed' error message at the user.

13 years agoqemu: avoid double free of qemu help output
Eric Blake [Fri, 27 Jan 2012 20:53:11 +0000 (13:53 -0700)]
qemu: avoid double free of qemu help output

If yajl was not compiled in, we end up freeing an incoming
parameter, which leads to a bogus free later on.  Regression
introduced in commit 6e769eb.

* src/qemu/qemu_capabilities.c (qemuCapsParseHelpStr): Avoid alloc
on failure path, which in turn fixes bogus free.
Reported by Cole Robinson.

13 years agobuild: fix missing include
Eric Blake [Fri, 27 Jan 2012 18:16:20 +0000 (11:16 -0700)]
build: fix missing include

Fix a build failure:

virt-host-validate.c: In function 'main':
virt-host-validate.c:82:5: error: implicit declaration of function 'setlocale' [-Werror=implicit-function-declaration]
virt-host-validate.c:82:5: error: nested extern declaration of 'setlocale' [-Werror=nested-externs]
virt-host-validate.c:82:20: error: 'LC_ALL' undeclared (first use in this function)

* tools/virt-host-validate.c: Add <locale.h>.
* .gitignore: Ignore built executable.

13 years agoxml: fix struct typos
Eric Blake [Fri, 27 Jan 2012 18:07:21 +0000 (11:07 -0700)]
xml: fix struct typos

Noticed this while reviewing Dan's patches.

* src/util/xml.c (virXMLRewritFileData): Rename to
virXMLRewriteFileData.

13 years agoMove virEmitXMLWarning into xml.h
Daniel P. Berrange [Fri, 27 Jan 2012 17:35:09 +0000 (17:35 +0000)]
Move virEmitXMLWarning into xml.h

The virEmitXMLWarning function should always have been in
the xml.[hc] files, and should use virXML as its name
prefix

* src/util/util.c, src/util/util.h: Remove virEmitXMLWarning
* src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning

13 years agoMove virMacAddrXXX functions to src/util/virmacaddr.[ch]
Daniel P. Berrange [Fri, 27 Jan 2012 17:23:05 +0000 (17:23 +0000)]
Move virMacAddrXXX functions to src/util/virmacaddr.[ch]

Move the virMacAddrXXX functions out of util.[ch] and into a
new dedicate file virmacaddr.[ch]

13 years agoRename virXXXXMacAddr to virMacAddrXXX
Daniel P. Berrange [Fri, 27 Jan 2012 16:48:38 +0000 (16:48 +0000)]
Rename virXXXXMacAddr to virMacAddrXXX

Rename virFormatMacAddr, virGenerateMacAddr and virParseMacAddr
to virMacAddrFormat, virMacAddrGenerate and virMacAddrParse
respectively

13 years agoAdd a virt-host-validate command to sanity check HV config
Daniel P. Berrange [Tue, 10 Jan 2012 17:31:21 +0000 (17:31 +0000)]
Add a virt-host-validate command to sanity check HV config

To assist people in verifying that their host is operating in an
optimal manner, provide a 'virt-host-validate' command. For each
type of hypervisor, it will check any pre-requisites, or other
good recommendations and report what's working & what is not.

eg

  # virt-host-validate
  QEMU: Checking for device /dev/kvm                                         : FAIL (Check that the 'kvm-intel' or 'kvm-amd' modules are loaded & the BIOS has enabled virtualization)
  QEMU: Checking for device /dev/vhost                                       : WARN (Load the 'vhost_net' module to improve performance of virtio networking)
  QEMU: Checking for device /dev/net/tun                                     : PASS
   LXC: Checking for Linux >= 2.6.26                                         : PASS

This warns people if they have vmx/svm, but don't have /dev/kvm. It
also warns about missing /dev/vhost net.

13 years agoqemu: parse and create -cpu ...,-kvmclock
Paolo Bonzini [Fri, 27 Jan 2012 13:49:52 +0000 (14:49 +0100)]
qemu: parse and create -cpu ...,-kvmclock

QEMU supports a bunch of CPUID features that are tied to the kvm CPUID
nodes rather than the processor's.  They are "kvmclock",
"kvm_nopiodelay", "kvm_mmu", "kvm_asyncpf".  These are not known to
libvirt and their CPUID leaf might move if (for example) the Hyper-V
extensions are enabled. Hence their handling would anyway require some
special-casing.

However, among these the most useful is kvmclock; an additional
"property" of this feature is that a <timer> element is a better model
than a CPUID feature.  Although, creating part of the -cpu command-line
from something other than the <cpu> XML element introduces some
ugliness.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoconf: add kvmclock timer
Paolo Bonzini [Fri, 27 Jan 2012 13:49:51 +0000 (14:49 +0100)]
conf: add kvmclock timer

Add kvmclock timer to documentation, schema and parsers.  Keep the
platform timer first since it is kind of special, and alphabetize
the others when possible (i.e. when it does not change the ABI).

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: do not create useless <cpu> element
Paolo Bonzini [Fri, 27 Jan 2012 13:49:50 +0000 (14:49 +0100)]
qemu: do not create useless <cpu> element

Avoid creating an empty <cpu> element when the QEMU command-line simply
specifies the default "-cpu qemu32" or "-cpu qemu64".

This requires the previous patch, which lets us represent "-cpu qemu32"
as <os arch='i686'> in the generated XML.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: get arch name from <cpu> element
Paolo Bonzini [Fri, 27 Jan 2012 13:49:49 +0000 (14:49 +0100)]
qemu: get arch name from <cpu> element

The qemu32 CPU model is chosen based on the <os arch=...> name when
creating the QEMU command line for a 64-bit host.  For the opposite
transformation we can test the guest CPU model for the "lm" feature.
If it is absent, def->os.arch needs to be corrected.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: detect arch correctly for KVM
Paolo Bonzini [Fri, 27 Jan 2012 13:49:48 +0000 (14:49 +0100)]
qemu: detect arch correctly for KVM

When running under KVM, the arch is usually set to i686 because
the name of the emulator is not qemu-system-x86_64.  Use the host
arch instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agox86: add kvm32 and kvm64, update qemu64
Paolo Bonzini [Fri, 27 Jan 2012 13:49:47 +0000 (14:49 +0100)]
x86: add kvm32 and kvm64, update qemu64

Recently (or not so recently) QEMU added the kvm32 and kvm64
architectures, representing a least common denominator of all
hosts that can run KVM.  Add them to the machine map.

Also, some features that TCG supports were added to qemu64.
Add them to the cpu_map.xml whenever KVM is guaranteed to support
those.  We still have to leave some out, because they would not
be available to guests running on older hosts.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: parse -enable-kvm
Paolo Bonzini [Fri, 27 Jan 2012 13:49:46 +0000 (14:49 +0100)]
qemu: parse -enable-kvm

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agoqemu: require qmp on new enough qemu
Eric Blake [Thu, 26 Jan 2012 04:57:38 +0000 (21:57 -0700)]
qemu: require qmp on new enough qemu

The qemu developers have made it clear that modern qemu will no
longer guarantee human monitor command stability; furthermore,
some features, such as async events, are only supported via qmp.
If we are compiled without support for handling JSON, we cannot
expect to sanely interact with modern qemu.

However, things must continue to build on RHEL 5, where qemu
is stuck at 0.10, and where yajl is not available.

Another benefit of this patch: future additions of new monitor
commands need only focus on qemu_monitor_json.c, instead of
also wasting time with qemu_monitor_text.c.

* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags): Report
error if yajl is missing but qemu requires qmp.
(qemuCapsParseHelpStr): Propagate error.
(qemuCapsExtractVersionInfo): Update caller.
* tests/qemuhelptest.c (testHelpStrParsing): Likewise.

13 years agoqemu: support qmp on RHEL/CentOS qemu
Eric Blake [Thu, 26 Jan 2012 04:33:21 +0000 (21:33 -0700)]
qemu: support qmp on RHEL/CentOS qemu

I'm getting tired of remembering to backport RHEL-specific
patches when building upstream libvirt on RHEL 6.x or CentOS.
All the affected versions of RHEL qemu-kvm have backported
enough patches to a) make JSON useful, and b) modify the
-help text to mention libvirt as the preferred interface;
which means this string in the help output is a reliable
indicator that we can outsmart a strict version check,
even when upstream qemu 0.12 lacked the needed features.

* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags):
Recognize particular help string present when enough features were
backported to be worth using JSON.
* tests/qemuhelptest.c (mymain): Update tests accordingly.

13 years agonwfilter: Rebuild filters only if new filter is different than current
Stefan Berger [Fri, 27 Jan 2012 13:19:58 +0000 (08:19 -0500)]
nwfilter: Rebuild filters only if new filter is different than current

Compare two filters' XML for equality and only rebuild/instantiate the new
filter if the new and current filters are found to be different. This
improves performance during an update of a filter with no obvious change
or the reloading of filters during a 'kill -SIGHUP'

13 years agonwfilter: Force instantiation of filters upon driver reload
Stefan Berger [Fri, 27 Jan 2012 13:19:58 +0000 (08:19 -0500)]
nwfilter: Force instantiation of filters upon driver reload

Introduce a function that rebuilds all running VMs' filters. Call
this function when reloading the nwfilter driver.

This addresses a problem introduced by the 2nd patch that typically
causes no filters to be reinstantiate anymore upon driver reload
since their XML has not changed. Yet the current behavior is that
upon a SIGHUP all filters get reinstantiated.

13 years agoqemu: Refactor qemuMonitorGetBlockInfo
Jiri Denemark [Wed, 18 Jan 2012 21:01:30 +0000 (22:01 +0100)]
qemu: Refactor qemuMonitorGetBlockInfo

QEMU always sends details about all available block devices as an answer
for "info block"/"query-block" command. On the other hand, our
qemuMonitorGetBlockInfo was made for a single block devices queries
only. Thus, when asking for multiple devices, we asked qemu multiple
times to always get the same answer from which different parts were
filtered. This patch makes qemuMonitorGetBlockInfo return a hash table
of all block devices, which may later be used for getting details about
specific devices.

13 years agoapparmor: Fix use of uninitialized random_data
Jiri Denemark [Fri, 27 Jan 2012 10:14:21 +0000 (11:14 +0100)]
apparmor: Fix use of uninitialized random_data

Without this, virt-aa-helper would segfault in -c or -r commands.

13 years agoUpdate VIRT_CONTROL audit record with pid.
Marcelo Cerri [Thu, 26 Jan 2012 17:16:16 +0000 (15:16 -0200)]
Update VIRT_CONTROL audit record with pid.

Added a new field "vm-pid" to the VIRT_CONTROL audit record. This information
is useful to correlated another audit events to the events generated by
libvirt.

13 years agobuild: allow for 64-bit pid in daemon
Eric Blake [Thu, 26 Jan 2012 00:49:48 +0000 (17:49 -0700)]
build: allow for 64-bit pid in daemon

Convert daemon code to handle 64-bit pid_t (even though at the
moment, it is not compiled on mingw).

* daemon/remote.c (remoteDispatchAuthList)
(remoteDispatchAuthPolkit): Print pid_t via %lld.

13 years agodaemon: convert virRun to virCommand
Eric Blake [Thu, 26 Jan 2012 00:34:50 +0000 (17:34 -0700)]
daemon: convert virRun to virCommand

Using snprintf to build up argv seems archaic.

* daemon/remote.c (remoteDispatchAuthPolkit): Modernize command call.

13 years agohash: minor touchups
Eric Blake [Wed, 25 Jan 2012 16:38:37 +0000 (16:38 +0000)]
hash: minor touchups

On RHEL5, I got:
util/virrandom.c:66: warning: nested extern declaration of '_gl_verify_function66' [-Wnested-externs]

The fix is to hoist the verify earlier.  Also some other hodge-podge
fixes I noticed while reviewing Dan's recent series.

* .gitignore: Ignore new test.
* src/util/cgroup.c: Bump copyright year.
* src/util/virhash.c: Fix typo in description.
* src/util/virrandom.c (virRandomBits): Mark doc comment, and
hoist assert to silence older gcc.

13 years agoutil: Include stdint.h because of uint32_t
Michal Privoznik [Thu, 26 Jan 2012 18:14:01 +0000 (19:14 +0100)]
util: Include stdint.h because of uint32_t

Some files are using uint32_t or int64_t without including
stdint.h which defines them. Fix this.

13 years agoRemove tabs from libvirt_public.syms & enforce it
Daniel P. Berrange [Thu, 26 Jan 2012 14:30:36 +0000 (14:30 +0000)]
Remove tabs from libvirt_public.syms & enforce it

* src/libvirt_public.syms: Death to tabs
* cfg.mk: Check .syms files for tabs

13 years agoAdd missing docs for <viridian/> feature flag
Daniel P. Berrange [Wed, 25 Jan 2012 14:34:12 +0000 (14:34 +0000)]
Add missing docs for <viridian/> feature flag

13 years agoReplace hashing algorithm with murmurhash
Daniel P. Berrange [Wed, 18 Jan 2012 16:10:43 +0000 (16:10 +0000)]
Replace hashing algorithm with murmurhash

Recent discussions have illustrated the potential for DOS attacks
with the hash table implementations used by most languages and
libraries.

   https://lwn.net/Articles/474912/

libvirt has an internal hash table impl, and uses hash tables for
a variety of purposes. The hash key generation code is pretty
simple and thus not strongly collision resistant.

This patch replaces the current libvirt hash key generator with
the (public domain) Murmurhash3 code. In addition every hash
table now gets a random seed value which is used to perturb the
hashing code. This should make it impossible to mount any
practical attack against libvirt hashing code.

* bootstrap.conf: Import bitrotate module
* src/Makefile.am: Add virhashcode.[ch]
* src/util/util.c: Make virRandom() return a fixed 32 bit
  integer value.
* src/util/hash.c, src/util/hash.h, src/util/cgroup.c: Replace
  hash code generation with a call to virHashCodeGen()
* src/util/virhashcode.h, src/util/virhashcode.c: Add a new
  virHashCodeGen() API using the Murmurhash3 algorithm.

13 years agoRename hash.h and hash.c to virhash.h and virhash.c
Daniel P. Berrange [Wed, 25 Jan 2012 16:13:59 +0000 (16:13 +0000)]
Rename  hash.h and hash.c to virhash.h and virhash.c

In preparation for the patch to include Murmurhash3, which
introduces a virhashcode.h and virhashcode.c files, rename
the existing hash.h and hash.c to virhash.h and virhash.c
respectively.

13 years agoConvert various virHash functions to use size_t / uint32
Daniel P. Berrange [Wed, 25 Jan 2012 15:55:00 +0000 (15:55 +0000)]
Convert various virHash functions to use size_t / uint32

In preparation for conversion over to use the Murmurhash3
algorithm, convert various virHash APIs to use size_t or
uint32 for their return values/parameters, instead of the
variable size 'unsigned long' or 'int' types

13 years agoIntroduce new API for generating random numbers
Daniel P. Berrange [Wed, 25 Jan 2012 15:17:46 +0000 (15:17 +0000)]
Introduce new API for generating random numbers

The old virRandom() API was not generating good random numbers.
Replace it with a new API virRandomBits which instead of being
told the upper limit, gets told the number of bits of randomness
required.

* src/util/virrandom.c, src/util/virrandom.h: Add virRandomBits,
  and move virRandomInitialize
* src/util/util.h, src/util/util.c: Delete virRandom and
  virRandomInitialize
* src/libvirt.c, src/security/security_selinux.c,
  src/test/test_driver.c, src/util/iohelper.c: Update for
  changes from virRandom to virRandomBits
* src/storage/storage_backend_iscsi.c: Remove bogus call
  to virRandomInitialize & convert to virRandomBits

13 years agoschema: Relax schema for domain name
Peter Krempa [Mon, 23 Jan 2012 17:41:44 +0000 (18:41 +0100)]
schema: Relax schema for domain name

The domain schema enforced restrictions on the domain name string that
the code doesn't. This patch relaxes the check, leaving the restrictions
on the driver or hypervisor. The only invalid character is a newline.

13 years agostorage: Support different wiping algorithms
Michal Privoznik [Mon, 9 Jan 2012 16:05:03 +0000 (17:05 +0100)]
storage: Support different wiping algorithms

Currently, we support only filling a volume with zeroes on wiping.
However, it is not enough as data might still be readable by
experienced and equipped attacker. Many technical papers have been
written, therefore we should support other wiping algorithms.

13 years agodocs: fix virsh man page
Eric Blake [Thu, 26 Jan 2012 05:17:54 +0000 (22:17 -0700)]
docs: fix virsh man page

Typo introduced in commit 4e9953a, and remained in 6fba577.

* tools/virsh.pod (snapshot-create): Fix pod error.

13 years agoCast pointer to int using intptr_t
Marc-André Lureau [Wed, 25 Jan 2012 20:13:25 +0000 (21:13 +0100)]
Cast pointer to int using intptr_t

Fix a few warnings with mingw64 x86_64.

13 years agobuild: fix header order on mingw
Eric Blake [Wed, 25 Jan 2012 22:05:13 +0000 (15:05 -0700)]
build: fix header order on mingw

In file included from ../gnulib/lib/unistd.h:51:0,
                 from ../src/util/util.h:30,
                 from rpc/virkeepalive.c:29:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

Reported by Marc-André Lureau.

* src/util/threads-win32.h (includes): Pick up winsock2.h before
windows.h, as required by mingw64.

13 years agoerrcode is typedef by mingw, rename an argument name
Marc-André Lureau [Wed, 25 Jan 2012 20:13:21 +0000 (21:13 +0100)]
errcode is typedef by mingw, rename an argument name

Fixes the following warning:
util/virterror.c:1242:31: warning: declaration of 'errcode' shadows a global declaration [-Wshadow]

13 years agoAdd missing virGetGroupName()
Marc-André Lureau [Wed, 25 Jan 2012 18:54:43 +0000 (19:54 +0100)]
Add missing virGetGroupName()

Add missing function if !HAVE_GETPWUID_R.

13 years agostorage: Fix any VolLookupByPath if we have an empty logical pool
Cole Robinson [Wed, 25 Jan 2012 17:07:14 +0000 (12:07 -0500)]
storage: Fix any VolLookupByPath if we have an empty logical pool

On F16 at least, empty volume groups don't have a directory under /dev.
The directory only appears once a logical volume is created.

This tickles some behavior in BackendStablePath which ends with
libvirt sleeping for 5 seconds while waiting for the directory to appear.
This causes all sorts of problems for the virStorageVolLookupByPath API
which virtinst uses, even if trying to resolve a path that is independent
of the logical pool.

In reality we don't even need to do that checking since logical pools
always have a stable target path. Short circuit the polling in that
case.

Fixes bug 782261

13 years agolxc: export container=lxc-libvirt for systemd
Eric Blake [Tue, 24 Jan 2012 18:51:01 +0000 (11:51 -0700)]
lxc: export container=lxc-libvirt for systemd

Systemd detects containers based on whether they have
an environment variable starting with 'container=lxc';
using a longer name fits the expectations, while also
allowing detection of who created the container.

Requested by Lennart Poettering, in response to
https://bugs.freedesktop.org/show_bug.cgi?id=45175

* src/lxc/lxc_container.c (lxcContainerBuildInitCmd): Add another
env-var.

13 years agoDon't bind mount onto a char device for /dev/ptmx in LXC
Daniel P. Berrange [Wed, 11 Jan 2012 09:59:37 +0000 (09:59 +0000)]
Don't bind mount onto a char device for /dev/ptmx in LXC

The current setup code for LXC is bind mounting /dev/pts/ptmx
on top of a character device /dev/ptmx. This is denied by SELinux
policy and is just wrong. The target of a bind mount should just
be a plain file

* src/lxc/lxc_container.c: Don't bind /dev/pts/ptmx onto
  a char device

13 years agoAdd virFileTouch for creating empty files
Daniel P. Berrange [Wed, 11 Jan 2012 09:58:59 +0000 (09:58 +0000)]
Add virFileTouch for creating empty files

Add a virFileTouch API which ensures that a file will always
exist, even if zero length

* src/util/virfile.c, src/util/virfile.h,
  src/libvirt_private.syms: Introduce virFileTouch

13 years agovirsh: Expose new VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag
Michal Privoznik [Tue, 24 Jan 2012 14:47:09 +0000 (15:47 +0100)]
virsh: Expose new VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag

to cmdSnapshotCreate and cmdSnapshotCreateAs.

13 years agosnapshots: Introduce VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag
Michal Privoznik [Tue, 24 Jan 2012 20:14:08 +0000 (21:14 +0100)]
snapshots: Introduce VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag

With this flag, virDomainSnapshotCreate will use fs-freeze and
fs-thaw guest agent commands to quiesce guest's disks.

13 years agoqemu_agent: Create file system freeze and thaw functions
Michal Privoznik [Tue, 24 Jan 2012 20:13:40 +0000 (21:13 +0100)]
qemu_agent: Create file system freeze and thaw functions

These functions simply issue command to guest agent which
should freeze or unfreeze all file systems within guest.

13 years agoqemu: Emit bootindex even for direct boot
Jiri Denemark [Mon, 23 Jan 2012 15:35:25 +0000 (16:35 +0100)]
qemu: Emit bootindex even for direct boot

Direct boot (using kernel, initrd, and command line) is used by
virt-install/virt-manager for network install. While any bootindex has
no direct effect since -kernel is always first, we need it as a hint for
SeaBIOS to present disks in the same order as they will be presented
during normal boot.

13 years agodocs: fix a few small typos in formatdomain.html.in
Laine Stump [Wed, 25 Jan 2012 01:09:20 +0000 (20:09 -0500)]
docs: fix a few small typos in formatdomain.html.in

13 years agometadata: group metadata next to description
Eric Blake [Wed, 25 Jan 2012 00:26:38 +0000 (17:26 -0700)]
metadata: group metadata next to description

It's better to group all the metadata together.  This is a
cosmetic output change; since the RNG allows interleave, it
doesn't matter where the user stuck it on input, and an XPath
query will find the same information when parsing the output.

* src/conf/domain_conf.c (virDomainDefFormatInternal): Output
metadata earlier.
* docs/formatdomain.html.in: Update documentation.
* tests/domainsnapshotxml2xmlout/metadata.xml: Update test.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml: Likewise.

13 years agobuild: simplify xmlFreeNode usage
Eric Blake [Wed, 25 Jan 2012 00:16:16 +0000 (17:16 -0700)]
build: simplify xmlFreeNode usage

Noticed while reviewing the previous patch; thankfully, there
are no violations.

* cfg.mk (useless_free_options): Add xmlFreeNode.

13 years agoAllow custom metadata in domain configuration XML
Zeeshan Ali (Khattak) [Tue, 24 Jan 2012 02:26:18 +0000 (04:26 +0200)]
Allow custom metadata in domain configuration XML

Applications can now insert custom nodes and hierarchies into domain
configuration XML. Although currently not enforced, applications are
required to use their own namespaces on every custom node they insert,
with only one top-level element per namespace.

13 years agovirCommandProcessIO(): make poll() usage more robust
Laszlo Ersek [Tue, 24 Jan 2012 14:55:19 +0000 (15:55 +0100)]
virCommandProcessIO(): make poll() usage more robust

POLLIN and POLLHUP are not mutually exclusive. Currently the following
seems possible: the child writes 3K to its stdout or stderr pipe, and
immediately closes it. We get POLLIN|POLLHUP (I'm not sure that's possible
on Linux, but SUSv4 seems to allow it). We read 1K and throw away the
rest.

When poll() returns and we're about to check the /revents/ member in a
given array element, let's map all the revents bits to two (independent)
ideas: "let's attempt to read()", and "let's attempt to write()". This
should cover all errors, EOFs, and normal conditions; the read()/write()
call should report any pending error.

Under this approach, both POLLHUP and POLLERR are mapped to "needs read()"
if we're otherwise prepared for POLLIN. POLLERR also maps to "needs
write()" if we're otherwise prepared for POLLOUT. The rest of the mappings
(POLLPRI etc.) would be easy, but probably useless for pipes.

Additionally, SUSv4 doesn't appear to forbid POLLIN|POLLERR (or
POLLOUT|POLLERR) set simultaneously. One could argue that the read() or
write() call would return without blocking in these cases (with an error),
so POLLIN / POLLOUT would be justified beside POLLERR.

The code now penalizes POLLIN|POLLERR differently from plain POLLERR. The
former (ie. read() returning -1) is terminal and we jump to cleanup, while
plain POLLERR masks only the affected file descriptor for the future.
Let's unify those.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
13 years agosrc/datatypes.h: fix typo
Alon Levy [Tue, 24 Jan 2012 12:45:39 +0000 (14:45 +0200)]
src/datatypes.h: fix typo

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoAllow choice of shutdown method via virsh
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:57 +0000 (18:31 +0100)]
Allow choice of shutdown method via virsh

Extend the 'shutdown' and 'reboot' methods so that they both
accept a new argument

    --mode acpi|agent

* tools/virsh.c: New args for shutdown/reboot
* tools/virsh.pod: Document new args

13 years agoWire up QEMU agent to reboot/shutdown APIs
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:56 +0000 (18:31 +0100)]
Wire up QEMU agent to reboot/shutdown APIs

This makes use of the QEMU guest agent to implement the
virDomainShutdownFlags and virDomainReboot APIs. With
no flags specified, it will prefer to use the agent, but
fallback to ACPI. Explicit choice can be made by using
a suitable flag

* src/qemu/qemu_driver.c: Wire up use of agent

13 years agoAdd new virDomainShutdownFlags API
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:55 +0000 (18:31 +0100)]
Add new virDomainShutdownFlags API

Add a new API virDomainShutdownFlags and define:

    VIR_DOMAIN_SHUTDOWN_DEFAULT        = 0,
    VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN = (1 << 0),
    VIR_DOMAIN_SHUTDOWN_GUEST_AGENT    = (1 << 1),

Also define some flags for the reboot API

    VIR_DOMAIN_REBOOT_DEFAULT        = 0,
    VIR_DOMAIN_REBOOT_ACPI_POWER_BTN = (1 << 0),
    VIR_DOMAIN_REBOOT_GUEST_AGENT    = (1 << 1),

Although these two APIs currently have the same flags, using
separate enums allows them to expand separately in the future.

Add stub impls of the new API for all existing drivers

13 years agoQEMU guest agent support
Daniel P. Berrange [Wed, 5 Oct 2011 17:31:54 +0000 (18:31 +0100)]
QEMU guest agent support

There is now a standard QEMU guest agent that can be installed
and given a virtio serial channel

    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
    </channel>

The protocol that runs over the guest agent is JSON based and
very similar to the JSON monitor. We can't use exactly the same
code because there are some odd differences in the way messages
and errors are structured. The qemu_agent.c file is based on
a combination and simplification of qemu_monitor.c and
qemu_monitor_json.c

* src/qemu/qemu_agent.c, src/qemu/qemu_agent.h: Support for
  talking to the agent for shutdown
* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add thread
  helpers for talking to the agent
* src/qemu/qemu_process.c: Connect to agent whenever starting
  a guest
* src/qemu/qemu_monitor_json.c: Make variable static

13 years agohashtest: Initialize variable in virHashEqual test
Michal Privoznik [Tue, 24 Jan 2012 11:09:42 +0000 (12:09 +0100)]
hashtest: Initialize variable in virHashEqual test

One of latest patches (b7bcb22ce2) enhanced testing for virHashEqual.
However, hash2 variable might be used uninitialized.

13 years agoAdd test case for virHashEqual function
Stefan Berger [Mon, 23 Jan 2012 20:35:54 +0000 (15:35 -0500)]
Add test case for virHashEqual function

Add a test case to test the virHashEqual function.

13 years agoCompare two hash tables for equality
Stefan Berger [Mon, 23 Jan 2012 20:35:54 +0000 (15:35 -0500)]
Compare two hash tables for equality

Add function to compare two hash tables for equality.

13 years agobuild: skip lxc with too-old glibc
Eric Blake [Thu, 19 Jan 2012 20:35:39 +0000 (13:35 -0700)]
build: skip lxc with too-old glibc

Since we already require the kernel to be new enough to support
LO_FLAGS_AUTOCLEAR, we might as well also require glibc to be
new enough to support epoll_create1().

* configure.ac (with_lxc): We require glibc 2.9 for LXC.
Reported and tested by Philipp Hahn.

13 years agoxen: Don't crash when we fail to init caps
Guido Günther [Fri, 20 Jan 2012 07:56:39 +0000 (08:56 +0100)]
xen: Don't crash when we fail to init caps

by dereferencing a NULL pointer in the call to
virNodeSuspendGetTargetMask.

13 years agoxen: properly report out of memory when hvm_type is too small
Guido Günther [Fri, 20 Jan 2012 16:27:08 +0000 (17:27 +0100)]
xen: properly report out of memory when hvm_type is too small

13 years agovirsh: let domif-{get,set}link take target name
Taku Izumi [Fri, 20 Jan 2012 06:30:47 +0000 (15:30 +0900)]
virsh: let domif-{get,set}link take target name

Other virsh domifXXX commands can accept target name
as a parameter to specify interface. From viewpoint of
consistency, virsh domif-getlink command should accept
target name as a parameter. This patch achieves this.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agomaint: cleanup qemu capabilities
Eric Blake [Fri, 20 Jan 2012 23:30:44 +0000 (16:30 -0700)]
maint: cleanup qemu capabilities

Fix inconsistent whitespace and long lines.

* src/qemu/qemu_capabilities.h (qemuCapsFlags): Improve formatting.

13 years agomaint: enforce use of _LAST marker
Eric Blake [Fri, 20 Jan 2012 21:00:58 +0000 (14:00 -0700)]
maint: enforce use of _LAST marker

When converting a linear enum to a string, we have checks in
place in the VIR_ENUM_IMPL macro to ensure that there is one
string for every value, which lets us quickly flag if a user
added a value but forgot to add a counterpart string.  However,
this only works if we use the _LAST marker.

* cfg.mk (sc_require_enum_last_marker): New syntax check.
* src/conf/domain_conf.h (virDomainSnapshotState): Add new marker.
* src/conf/domain_conf.c (virDomainSnapshotState): Fix offender.
* src/qemu/qemu_monitor_json.c (qemuMonitorWatchdogAction)
(qemuMonitorIOErrorAction, qemuMonitorGraphicsAddressFamily):
Likewise.
* src/util/virtypedparam.c (virTypedParameter): Likewise.

13 years agoAPI: make declaration of _LAST enum values conditional
Eric Blake [Fri, 20 Jan 2012 18:43:28 +0000 (11:43 -0700)]
API: make declaration of _LAST enum values conditional

Although this is a public API break, it only affects users that
were compiling against *_LAST values, and can be trivially
worked around without impacting compilation against older
headers, by the user defining VIR_ENUM_SENTINELS before using
libvirt.h.  It is not an ABI break, since enum values do not
appear as .so entry points.  Meanwhile, it prevents users from
using non-stable enum values without explicitly acknowledging
the risk of doing so.

See this list discussion:
https://www.redhat.com/archives/libvir-list/2012-January/msg00804.html

* include/libvirt/libvirt.h.in: Hide all sentinels behind
LIBVIRT_ENUM_SENTINELS, and add missing sentinels.
* src/internal.h (VIR_DEPRECATED): Allow inclusion after
libvirt.h.
(LIBVIRT_ENUM_SENTINELS): Expose sentinels internally.
* daemon/libvirtd.h: Use the sentinels.
* src/remote/remote_protocol.x (includes): Don't expose sentinels.
* python/generator.py (enum): Likewise.
* tests/cputest.c (cpuTestCompResStr): Silence compiler warning.
* tools/virsh.c (vshDomainStateReasonToString)
(vshDomainControlStateToString): Likewise.

13 years agoerror: drop old-style error reporting
Eric Blake [Mon, 28 Nov 2011 23:13:40 +0000 (16:13 -0700)]
error: drop old-style error reporting

While we still don't want to enable gcc's new -Wformat-literal
warning, I found a rather easy case where the warning could be
reduced, by getting rid of obsolete error-reporting practices.
This is the last place where we were passing the (unused) net
and conn arguments for constructing an error.

* src/util/virterror_internal.h (virErrorMsg): Delete prototype.
(virReportError): Delete macro.
* src/util/virterror.c (virErrorMsg): Make static.
* src/libvirt_private.syms (virterror_internal.h): Drop export.
* src/util/conf.c (virConfError): Convert to macro.
(virConfErrorHelper): New function, and adjust error calls.
* src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
(xenHypervisorGetSchedulerType)
(xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters)
(xenHypervisorDomainBlockStats)
(xenHypervisorDomainInterfaceStats)
(xenHypervisorDomainGetOSType)
(xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
Update callers.

13 years agoutil: use new virTypedParameter helpers
Eric Blake [Sat, 7 Jan 2012 12:47:43 +0000 (05:47 -0700)]
util: use new virTypedParameter helpers

Reusing common code makes things smaller; it also buys us some
additional safety, such as now rejecting duplicate parameters
during a set operation.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters)
(qemuDomainSetMemoryParameters, qemuDomainSetNumaParameters)
(qemuSetSchedulerParametersFlags)
(qemuDomainSetInterfaceParameters, qemuDomainSetBlockIoTune)
(qemuDomainGetBlkioParameters, qemuDomainGetMemoryParameters)
(qemuDomainGetNumaParameters, qemuGetSchedulerParametersFlags)
(qemuDomainBlockStatsFlags, qemuDomainGetInterfaceParameters)
(qemuDomainGetBlockIoTune): Use new helpers.
* src/esx/esx_driver.c (esxDomainSetSchedulerParametersFlags)
(esxDomainSetMemoryParameters)
(esxDomainGetSchedulerParametersFlags)
(esxDomainGetMemoryParameters): Likewise.
* src/libxl/libxl_driver.c
(libxlDomainSetSchedulerParametersFlags)
(libxlDomainGetSchedulerParametersFlags): Likewise.
* src/lxc/lxc_driver.c (lxcDomainSetMemoryParameters)
(lxcSetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
(lxcDomainGetMemoryParameters, lxcGetSchedulerParametersFlags)
(lxcDomainGetBlkioParameters): Likewise.
* src/test/test_driver.c (testDomainSetSchedulerParamsFlags)
(testDomainGetSchedulerParamsFlags): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorSetSchedulerParameters)
(xenHypervisorGetSchedulerParameters): Likewise.

13 years agoutil: add new file for virTypedParameter utils
Eric Blake [Mon, 2 Jan 2012 22:03:19 +0000 (15:03 -0700)]
util: add new file for virTypedParameter utils

Preparation for another patch that refactors common patterns
into the new file for fewer lines of code overall.

* src/util/util.h (virTypedParameterArrayClear): Move...
* src/util/virtypedparam.h: ...to new file.
(virTypedParameterArrayValidate, virTypedParameterAssign): New
prototypes.
* src/util/util.c (virTypedParameterArrayClear): Likewise.
* src/util/virtypedparam.c: New file.
* po/POTFILES.in: Mark file for translation.
* src/Makefile.am (UTIL_SOURCES): Build it.
* src/libvirt_private.syms (util.h): Split...
(virtypedparam.h): to new section.
(virkeycode.h): Sort.
* daemon/remote.c: Adjust callers.
* tools/virsh.c: Likewise.

13 years agolxc: use live/config helper
Eric Blake [Sat, 7 Jan 2012 12:36:46 +0000 (05:36 -0700)]
lxc: use live/config helper

Based on qemu changes made in commits ae523427 and 659ded58.

* src/lxc/lxc_driver.c (lxcSetSchedulerParametersFlags)
(lxcGetSchedulerParametersFlags, lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Use helpers.
(lxcDomainSetBlkioParameters): Allow setting live and config at
once.

13 years agobuild: silence some compiler warnings from gnulib
Eric Blake [Thu, 12 Jan 2012 21:14:44 +0000 (14:14 -0700)]
build: silence some compiler warnings from gnulib

Gnulib claims that there are some classes of warnings that are
worth enabling during development, but where silencing those
warnings causes code bloat that is not necessary in an optimized
build.  The code bloat to silence the warnings is only enabled
by -Dlint.  Follow the lead of coreutils in setting up -Dlint
whenever full warnings are requested.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-Dlint, and move _FORTIFY_SOURCE to config.h instead of CFLAGS.

13 years agothreads: check for failure to set thread-local value
Eric Blake [Tue, 20 Dec 2011 22:06:47 +0000 (15:06 -0700)]
threads: check for failure to set thread-local value

We had a memory leak on a very arcane OOM situation (unlikely to ever
hit in practice, but who knows if libvirt.so would ever be linked
into some other program that exhausts all thread-local storage keys?).
I found it by code inspection, while analyzing a valgrind report
generated by Alex Jia.

* src/util/threads.h (virThreadLocalSet): Alter signature.
* src/util/threads-pthread.c (virThreadHelper): Reduce allocation
lifetime.
(virThreadLocalSet): Detect failure.
* src/util/threads-win32.c (virThreadLocalSet): Likewise.
(virCondWait): Fix caller.
* src/util/virterror.c (virLastErrorObject): Likewise.

13 years agoFix rpc generator to anchor matches for method names
Daniel P. Berrange [Thu, 19 Jan 2012 14:19:42 +0000 (14:19 +0000)]
Fix rpc generator to anchor matches for method names

The RPC generator transforms methods matching certain
patterns like 'id' or 'uuid', etc but does not anchor
its matches to the end of the word. So if a method
contains 'id' in the middle (eg virIdentity) then the
RPC generator munges that.

* src/rpc/gendispatch.pl: Anchor matches

13 years agoRename APIs for fetching UNIX socket credentials
Daniel P. Berrange [Wed, 18 Jan 2012 17:41:36 +0000 (17:41 +0000)]
Rename APIs for fetching UNIX socket credentials

To avoid a namespace clash with forthcoming identity APIs,
rename the virNet*GetLocalIdentity() APIs to have the form
virNet*GetUNIXIdentity()

* daemon/remote.c, src/libvirt_private.syms: Update
  for renamed APIs
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h,
  src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: s/LocalIdentity/UNIXIdentity/