]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
12 years agoqemu: Initialize cpuset for hotplugged vcpu as def->cpuset
Osier Yang [Fri, 12 Oct 2012 09:50:47 +0000 (17:50 +0800)]
qemu: Initialize cpuset for hotplugged vcpu as def->cpuset

The onlined vcpu pinning policy should inherit def->cpuset if
it's not specified explicitly, and the affinity should be set
in this case. Oppositely, the offlined vcpu pinning policy should
be free()'ed.

12 years agoqemu: Create or remove cgroup when doing vcpu hotpluging
Osier Yang [Fri, 12 Oct 2012 09:50:46 +0000 (17:50 +0800)]
qemu: Create or remove cgroup when doing vcpu hotpluging

Various APIs use cgroup to either set or get the statistics of
host or guest. Hotplug or hot unplug new vcpus without creating
or removing the cgroup for the vcpus could cause problems for
those APIs. E.g.

% virsh vcpucount dom
maximum      config        10
maximum      live          10
current      config         1
current      live           1

% virsh setvcpu dom 2

% virsh schedinfo dom --set vcpu_quota=1000
Scheduler      : posix
error: Unable to find vcpu cgroup for rhel6.2(vcpu: 1): No such file or
directory

This patch fixes the problem by creating cgroups for each of the
onlined vcpus, and destroying cgroups for each of the offlined
vcpus.

12 years agoconf: Initialize the pinning policy for vcpus
Osier Yang [Fri, 12 Oct 2012 09:50:45 +0000 (17:50 +0800)]
conf: Initialize the pinning policy for vcpus

Document for <vcpu>'s "cpuset" says:

Since 0.4.4, this element can contain an optional cpuset attribute,
which is a comma-separated list of physical CPU numbers that virtual
CPUs can be pinned to.

However, it's not the truth, libvirt actually pins the domain
process to the specified pCPUs by "cpuset" of <vcpu>. And the
vcpu thread are pinned to all available pCPUs if no <vcpupin>
is specified for it.

This patch is to implement the codes to inherit <vcpu>'s "cpuset" for
vcpu that doesn't have <vcpupin> specified, and <vcpupin>
for these vcpu will be ignored when formating. Underlying
driver implementation will make sure the vcpu thread pinned
to correct pCPUs.

12 years agoconf: Ignore vcpupin for not onlined vcpus when parsing
Osier Yang [Fri, 12 Oct 2012 13:52:07 +0000 (21:52 +0800)]
conf: Ignore vcpupin for not onlined vcpus when parsing

Setting pinning policy for vcpu which exceeds current vcpus number
just makes no sense, however, it could cause various problems, E.g.

<vcpu current='1'>4</vcpu>
<cputune>
  <vcpupin vcpuid='3' cpuset='4'/>
</cputune>

% virsh start linux
error: Failed to start domain linux
error: cannot set CPU affinity on process 32534: No such process

We must have some odd codes underlying which produces the
"on process 32534", but the point is why we not to prevent
earlier when parsing? Note that this is only one of the
problem it could cause.

This patch is to ignore the <vcpupin> for not onlined vcpus.

12 years agodoc: Sort out the relationship between <vcpu>, <vcpupin>, and <emulatorpin>
Osier Yang [Fri, 12 Oct 2012 09:50:43 +0000 (17:50 +0800)]
doc: Sort out the relationship between <vcpu>, <vcpupin>, and <emulatorpin>

These 3 elements conflicts with each other in either the doc
or the underlying codes.

Current problems:

Problem 1:

The doc shouldn't simply say "These settings are superseded
by CPU tuning. " for element <vcpu>. As except the tuning, <vcpu>
allows to specify the current, maxmum vcpu number. Apart from that,
<vcpu> also allows to specify the placement as "auto", which binds
the domain process to the advisory nodeset from numad.

Problem 2:

Doc for <vcpu> says its "cpuset" specify the physical CPUs
that the vcpus can be pinned. But it's not the truth, as
actually it only pin domain process to the specified physical
CPUs. So either it's a document bug, or code bug.

Problem 3:

Doc for <vcpupin> says it supersed "cpuset" of <vcpu>, it's
not quite correct, as each <vcpupin> specify the pinning policy
only for one vcpu. How about the ones which doesn't have
<vcpupin> specified? it says the vcpu will be pinned to all
available physical CPUs, but what's the meaning of attribute
"cpuset" of <vcpu> then?

Problem 4:

Doc for <emulatorpin> says it pin the emulator threads (domain
process in other context, perhaps another follow up patch to
cleanup the inconsistency is needed) to the physical CPUs
specified its attribute "cpuset". Which conflicts with
<vcpu>'s "cpuset". And actually in the underlying codes,
it set the affinity for domain process twice if both
"cpuset" for <vcpu> and <emulatorpin> are specified,
and <emulatorpin>'s pinning will override <vcpu>'s.

Problem 5:

When "placement" of <vcpu> is "auto" (I.e. uses numad to
get the advisory nodeset to which the domain process is
pinned to), it will also be overridden by <emulatorpin>,

This patch is trying to sort out the conflicts or bugs by:

1) Don't say <vcpu> is superseded by <cputune>

2) Keep the semanteme for "cpuset" of <vcpu> (I.e. Still says it
   specify the physical CPUs the virtual CPUs). But modifying it
   to mention it also set the pinning policy for domain process,
   and the CPU placement of domain process specified by "cpuset"
   of <vcpu> will be ingored if <emulatorpin> specified, and
   similary, the CPU placement of vcpu thread will be ignored
   if it has <vcpupin> specified, for vcpu which doesn't have
   <vcpupin> specified, it inherits "cpuset" of <vcpu>.

3) Don't say <vcpu> is supersed by <vcpupin>. If neither <vcpupin>
   nor "cpuset" of <vcpu> is specified, the vcpu will be pinned
   to all available pCPUs.

4) If neither <emulatorpin> nor "cpuset" of <vcpu> is specified,
   the domain process (emulator threads in the context) will be
   pinned to all available pCPUs.

5) If "placement" of <vcpu> is "auto", <emulatorpin> is not allowed.

6) hotplugged vcpus will also inherit "cpuset" of <vcpu>

Codes changes according to above document changes:

1) Inherit def->cpumask for each vcpu which doesn't have <vcpupin>
   specified, during parsing.

2) ping the vcpu which doesn't have <vcpupin> specified to def->cpumask
   either by cgroup for sched_setaffinity(2), which is actually done
   by 1).

3) Error out if "placement" == "auto", and <emulatorpin> is specified.
   Otherwise, <emulatorpin> is honored, and "cpuset" of <cpuset> is
   ignored.

4) Setup cgroup for each hotplugged vcpu, and setup the pinning policy
   by either cgroup or sched_setaffinity(2).

5) Remove cgroup and <vcpupin> for each hot unplugged vcpu.

Patches are following (6 in total except this patch)

12 years agoTweak comments in the policykit rules file
Cole Robinson [Fri, 12 Oct 2012 15:56:17 +0000 (11:56 -0400)]
Tweak comments in the policykit rules file

- Add the XML header so vim gives us syntax highlighting
- polkit-policy-file-validate hasn't existed for 3 years
- Permissions comment was not accurate

12 years agoOnly keep one polkit rules file
Cole Robinson [Fri, 12 Oct 2012 14:51:48 +0000 (10:51 -0400)]
Only keep one polkit rules file

Just tweak it at build time depending on what polkit version we are
building for.

12 years agodaemon: Use $(AM_V_GEN) in a few more places
Cole Robinson [Sat, 13 Oct 2012 14:12:04 +0000 (10:12 -0400)]
daemon: Use $(AM_V_GEN) in a few more places

12 years agoProperly parse (unsigned) long long
Guido Günther [Fri, 12 Oct 2012 23:05:40 +0000 (01:05 +0200)]
Properly parse (unsigned) long long

This fixes problems on platforms where sizeof(long) != sizeof(long long)
like ia32.

12 years agospec: Add support for libssh2 transport
Peter Krempa [Fri, 12 Oct 2012 14:50:42 +0000 (16:50 +0200)]
spec: Add support for libssh2 transport

Libssh2 transport support was enabled lately but the spec file wasn't
updated to take this into account. This caused libvirt to be built
without libssh2 support in Red Hat based OSes.

12 years agoselinux: Use raw contexts
Martin Kletzander [Fri, 5 Oct 2012 14:41:22 +0000 (16:41 +0200)]
selinux: Use raw contexts

We are currently able to work only with non-translated SELinux
contexts, but we are using functions that work with translated
contexts throughout the code.  This patch swaps all SELinux context
translation relative calls with their raw sisters to avoid parsing
problems.

The problems can be experienced with mcstrans for example.  The
difference is that if you have translations enabled (yum install
mcstrans; service mcstrans start), fgetfilecon_raw() will get you
something like 'system_u:object_r:virt_image_t:s0', whereas
fgetfilecon() will return 'system_u:object_r:virt_image_t:SystemLow'
that we cannot parse.

I was trying to confirm that the _raw variants were here since the dawn of
time, but the only thing I see now is that it was imported together in
the upstream repo [1] from svn, so before 2008.

Thanks Laurent Bigonville for finding this out.

[1] http://oss.tresys.com/git/selinux.git

12 years agoconf: Mark missing optional USB devices in domain XML
Jiri Denemark [Thu, 11 Oct 2012 20:33:46 +0000 (22:33 +0200)]
conf: Mark missing optional USB devices in domain XML

When startupPolicy set for a USB devices allows such device to be
missing, there was no way this could be detected from domain XML. With
this patch, libvirt emits a new missing='yes' attribute for such devices
when active domain XML is generated.

12 years agovirsh: remove reference to migration in blockcopy
Ján Tomko [Thu, 11 Oct 2012 15:14:39 +0000 (17:14 +0200)]
virsh: remove reference to migration in blockcopy

12 years agovirsh: block SIGINT while getting BlockJobInfo
Ján Tomko [Thu, 11 Oct 2012 15:12:13 +0000 (17:12 +0200)]
virsh: block SIGINT while getting BlockJobInfo

SIGINT hasn't been blocked, which could lead to losing it somewhere in
virDomainGetBlockJobInfo and not aborting the job.

12 years agoVarious typos and misspellings
Ján Tomko [Thu, 11 Oct 2012 16:31:20 +0000 (18:31 +0200)]
Various typos and misspellings

12 years agoqemu: Fix misleading comment for qemuDomainObjBeginJobWithDriver()
Peter Krempa [Thu, 27 Sep 2012 09:17:19 +0000 (11:17 +0200)]
qemu: Fix misleading comment for qemuDomainObjBeginJobWithDriver()

The comment stated that you may call qemuDomainObjBeginJobWithDriver
without passing qemud_driver to signal it's not locked.
qemuDomainObjBeginJobWithDriver still accesses the qemud_driver
structure and the lock singaling is done through a separate parameter.

12 years agoqemu: Make save/restore with USB devices usable
Jiri Denemark [Tue, 9 Oct 2012 11:15:46 +0000 (13:15 +0200)]
qemu: Make save/restore with USB devices usable

Save/restore with passed through USB devices currently only works if the
USB device can be found at the same USB address where it used to be
before saving a domain. This makes sense in case a user explicitly
configure the USB address in domain XML. However, if the device was
found automatically by vendor/product identification, we should try to
search for that device when restoring the domain and use any device we
find as long as there is only one available. In other words, the USB
device can now be removed and plugged again or the host can be rebooted
between saving and restoring the domain.

12 years agoAdd MIGRATABLE flag for virDomainGetXMLDesc
Jiri Denemark [Mon, 8 Oct 2012 09:58:05 +0000 (11:58 +0200)]
Add MIGRATABLE flag for virDomainGetXMLDesc

Using VIR_DOMAIN_XML_MIGRATABLE flag, one can request domain's XML
configuration that is suitable for migration or save/restore. Such XML
may contain extra run-time stuff internal to libvirt and some default
configuration may be removed for better compatibility of the XML with
older libvirt releases.

This flag may serve as an easy way to get the XML that can be passed
(after desired modifications) to APIs that accept custom XMLs, such as
virDomainMigrate{,ToURI}2 or virDomainSaveFlags.

12 years agoqemu: Implement startupPolicy for USB passed through devices
Jiri Denemark [Thu, 4 Oct 2012 14:18:16 +0000 (16:18 +0200)]
qemu: Implement startupPolicy for USB passed through devices

12 years agoqemu: Add option to treat missing USB devices as success
Jiri Denemark [Wed, 3 Oct 2012 14:57:28 +0000 (16:57 +0200)]
qemu: Add option to treat missing USB devices as success

All USB device lookup functions emit an error when they cannot find the
requested device. With this patch, their caller can choose if a missing
device is an error or normal condition.

12 years agoqemu: Introduce qemuFindHostdevUSBDevice
Jiri Denemark [Wed, 3 Oct 2012 11:55:35 +0000 (13:55 +0200)]
qemu: Introduce qemuFindHostdevUSBDevice

The code which looks up a USB device specified by hostdev is duplicated
in two places. This patch creates a dedicated function that can be
called in both places.

12 years agoconf: Add support for startupPolicy for USB devices
Jiri Denemark [Tue, 2 Oct 2012 13:14:02 +0000 (15:14 +0200)]
conf: Add support for startupPolicy for USB devices

USB devices can disappear without OS being mad about it, which makes
them ideal for startupPolicy. With this attribute, USB devices can be
configured to be mandatory (the default), requisite (will disappear
during migration if they cannot be found), or completely optional.

12 years agolocking: Implement lock failure action in sanlock driver
Jiri Denemark [Tue, 18 Sep 2012 11:41:26 +0000 (13:41 +0200)]
locking: Implement lock failure action in sanlock driver

While the changes to sanlock driver should be stable, the actual
implementation of sanlock_helper is supposed to be replaced in the
future. However, before we can implement a better sanlock_helper, we
need an administrative interface to libvirtd so that the helper can just
pass a "leases lost" event to the particular libvirt driver and
everything else will be taken care of internally. This approach will
also allow libvirt to pass such event to applications and use
appropriate reasons when changing domain states.

The temporary implementation handles all actions directly by calling
appropriate libvirt APIs (which among other things means that it needs
to know the credentials required to connect to libvirtd).

12 years agolocking: Add support for lock failure action
Jiri Denemark [Tue, 18 Sep 2012 11:40:13 +0000 (13:40 +0200)]
locking: Add support for lock failure action

12 years agolocking: Pass hypervisor driver name when acquiring locks
Jiri Denemark [Mon, 17 Sep 2012 13:36:47 +0000 (15:36 +0200)]
locking: Pass hypervisor driver name when acquiring locks

This is required in case a lock manager needs to contact libvirtd in
case of an unexpected event.

12 years agolocking: Add const char * parameter to avoid ugly typecasts
Jiri Denemark [Mon, 17 Sep 2012 13:12:53 +0000 (15:12 +0200)]
locking: Add const char * parameter to avoid ugly typecasts

12 years agoconf: Add on_lockfailure event configuration
Jiri Denemark [Thu, 6 Sep 2012 20:17:01 +0000 (22:17 +0200)]
conf: Add on_lockfailure event configuration

Using this new element, one can configure an action that should be
performed when resource locks are lost.

12 years agoconf: Rename life cycle actions to event actions
Jiri Denemark [Thu, 6 Sep 2012 19:56:49 +0000 (21:56 +0200)]
conf: Rename life cycle actions to event actions

While current on_{poweroff,reboot,crash} action configuration is about
configuring life cycle actions, they can all be considered events and
actions that need to be done on a particular event. Let's generalize the
code by renaming life cycle actions to event actions so that it can be
reused later for non-lifecycle events.

12 years agoCorrect name of domain/pm/suspend-to-mem in docs
Zeeshan Ali (Khattak) [Wed, 10 Oct 2012 19:44:35 +0000 (22:44 +0300)]
Correct name of domain/pm/suspend-to-mem in docs

12 years agostorage: Report UUID/name consistently in driver errors
Cole Robinson [Mon, 8 Oct 2012 22:37:22 +0000 (18:37 -0400)]
storage: Report UUID/name consistently in driver errors

Done with:

sed -i -e "s/no pool with matching uuid/no storage pool with matching uuid/g" src/storage/storage_driver.c
sed -i -e 's/"%s", _("no storage pool with matching uuid")/_("no storage pool with matching uuid %s"), obj->uuid/g' src/storage/storage_driver.c
sed -i -e 's/"%s", _("storage pool is not active")/_("storage pool '%s' is not active"), pool->def->name/g' src/storage/storage_driver.c

And a couple fixups before, during, and after, and a manual inspection
pass to make sure nothing was wonky.

12 years agoChange qemuSetSchedularParameters to use AFFECT_CURRENT
Daniel P. Berrange [Wed, 26 Sep 2012 11:14:42 +0000 (12:14 +0100)]
Change qemuSetSchedularParameters to use AFFECT_CURRENT

When adding variants of parameter setting APIs which accepted
flags, the existing APIs were all adapted internally to pass
VIR_DOMAIN_AFFECT_CURRENT to the new API. The QEMU impl
qemuSetSchedularParameters was an exception, which instead
used VIR_DOMAIN_AFFECT_LIVE. Change this to match other
compatibility scenarios, so that calling

   virDomainSetSchedularParameters(dom, params, nparams);

Has the same semantics as

   virDomainSetSchedularParametersFlags(dom, params, nparams, 0);

And

   virDomainSetSchedularParametersFlags(dom, params, nparams, VIR_DOMAIN_AFFECT_CURRENT);

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agowin32: Pretend that close-on-exec works
Matthias Bolte [Tue, 9 Oct 2012 20:49:46 +0000 (22:49 +0200)]
win32: Pretend that close-on-exec works

Currently virNetSocketNew fails because virSetCloseExec fails as there
is no proper implementation for it on Windows at the moment. Workaround
this by pretending that setting close-on-exec on the fd works. This can
be done because libvirt currently lacks the ability to create child
processes on Windows anyway. So there is no point in failing to set a
flag that isn't useful at the moment anyway.

12 years agoesx: Fix dynamic dispatch for types with more than one level of inheritance
Matthias Bolte [Sat, 6 Oct 2012 16:30:45 +0000 (18:30 +0200)]
esx: Fix dynamic dispatch for types with more than one level of inheritance

Traverse the whole inheritance hierarchy for dynamic dispatch as it is
already done for the dynamic cast.

Also make AnyType cast errors more verbose.

Reported by Ata Bohra.

12 years agointerface: add udevIfaceIsActive() to udev backend
Doug Goldstein [Sat, 6 Oct 2012 19:20:29 +0000 (14:20 -0500)]
interface: add udevIfaceIsActive() to udev backend

Add support to check if a specific interface is active by supporting the
following API function in the udev based virInterface backend:
* virConnectInterfaceIsActive()

12 years agointerface: always build all available backends
Doug Goldstein [Sat, 6 Oct 2012 19:20:27 +0000 (14:20 -0500)]
interface: always build all available backends

Always build all available backends to avoid bit-rot. At run time we
select the correct backend and load it by attempting netcf first and
then udev.

12 years agointerface: fix netcf based backend naming
Doug Goldstein [Sat, 6 Oct 2012 19:20:26 +0000 (14:20 -0500)]
interface: fix netcf based backend naming

All other backends for virInterface or other HVs implementations of
virInterface list their own names for the name instead of the generic
'Interface' value. This does the same for the netcf based backend.
Also, report any errors during registration.

12 years agointerface: add udev based backend for virInterface
Doug Goldstein [Sat, 6 Oct 2012 19:20:25 +0000 (14:20 -0500)]
interface: add udev based backend for virInterface

Add a read-only udev based backend for virInterface. Useful for distros
that do not have netcf support yet. Multiple libvirt based utilities use
a HAL based fallback when virInterface is not available which is less
than ideal. This implements:
* virConnectNumOfInterfaces()
* virConnectListInterfaces()
* virConnectNumOfDefinedInterfaces()
* virConnectListDefinedInterfaces()
* virConnectListAllInterfaces()
* virConnectInterfaceLookupByName()
* virConnectInterfaceLookupByMACString()

12 years agohooks: let virCommand do the error reporting
Eric Blake [Tue, 9 Oct 2012 03:44:36 +0000 (21:44 -0600)]
hooks: let virCommand do the error reporting

The code was reporting raw exit status without decoding it into
normal vs. signal exit.  virCommandRun already does this, but
with a different error type, so all we have to do is recast
the error to the correct type.
Reported by li guang.

* src/util/hooks.c (virHookCall): Simplify.

12 years agodoc: update description about user/group in qemu.conf
Marcelo Cerri [Tue, 9 Oct 2012 12:57:58 +0000 (09:57 -0300)]
doc: update description about user/group in qemu.conf

As a side effect of changes in the functions virGetUserID and
virGetGroupID, the user and group configurations for DAC in qemu.conf
are now able to accept both names and IDs, supporting a leading plus
sign to ensure that a numeric value will not be interpreted as a name.

This patch updates the comments in qemu.conf, including a description of
this new behavior.

12 years agodocs: Drop useless </p> in drvphyp.html.in
Michal Privoznik [Tue, 9 Oct 2012 13:20:32 +0000 (15:20 +0200)]
docs: Drop useless </p> in drvphyp.html.in

12 years agonodeinfo: Fully convert to new virReportError
Michal Privoznik [Tue, 9 Oct 2012 09:46:48 +0000 (11:46 +0200)]
nodeinfo: Fully convert to new virReportError

With our latest s/[a-z]+ReportError/virReportError/ rewrite
(47ab34e2) we forgot to update arm part of the code.

12 years agoqemu: Fix QMP detection of QXL graphics
Jiri Denemark [Tue, 9 Oct 2012 06:25:02 +0000 (08:25 +0200)]
qemu: Fix QMP detection of QXL graphics

With the recent introduction of QMP capabilities probing, libvirt failed
to detect support for QXL graphics in QEMU 1.2 and newer. In addition to
fixing that, this patch also causes libvirt to detect QXL support for
qemu-kvm-0.13.0, which doesn't advertise it in -help output but mentions
it in device list. Since qemu-kvm-0.13.0 supported -spice, it looks like
not having qxl in -help was a bug.

12 years agovirsh: add qemu-monitor-command --pretty
Eric Blake [Thu, 4 Oct 2012 23:14:19 +0000 (17:14 -0600)]
virsh: add qemu-monitor-command --pretty

I was using qemu-monitor-command during development, and found it quite
hard to use.  Compare the results of this patch on ease of reading:

$ virsh qemu-monitor-command          dom '{"execute":"query-version"}'
{"return":{"qemu":{"micro":1,"minor":12,"major":0},"package":"(qemu-kvm-0.12.1.2)"},"id":"libvirt-7683"}

$ virsh qemu-monitor-command --pretty dom '{"execute":"query-version"}'
{
    "return": {
        "qemu": {
            "micro": 1,
            "minor": 12,
            "major": 0
        },
        "package": "(qemu-kvm-0.12.1.2)"
    },
    "id": "libvirt-7674"
}

* tools/virsh-host.c (cmdQemuMonitorCommand): New option.
* tools/virsh.pod (qemu-monitor-command): Document it.

12 years agosecurity: update user and group parsing in security_dac.c
Marcelo Cerri [Mon, 8 Oct 2012 20:37:02 +0000 (17:37 -0300)]
security: update user and group parsing in security_dac.c

The functions virGetUserID and virGetGroupID are now able to parse
user/group names and IDs in a similar way to coreutils' chown. So, user
and group parsing in security_dac can be simplified.

12 years agoutil: extend virGetUserID and virGetGroupID to support names and IDs
Marcelo Cerri [Mon, 8 Oct 2012 20:37:01 +0000 (17:37 -0300)]
util: extend virGetUserID and virGetGroupID to support names and IDs

This patch updates virGetUserID and virGetGroupID to be able to parse a
user or group name in a similar way to coreutils' chown. This means that
a numeric value with a leading plus sign is always parsed as an ID,
otherwise the functions try to parse the input first as a user or group
name and if this fails they try to parse it as an ID.

This patch includes Peter Krempa's changes to correctly handle errors
returned by getpwnam_r and getgrnam_r.

12 years agoCall curl_global_init from virInitialize to avoid thread-safety issues
Matthias Bolte [Sat, 6 Oct 2012 18:09:20 +0000 (20:09 +0200)]
Call curl_global_init from virInitialize to avoid thread-safety issues

curl_global_init is not thread-safe. curl_easy_init might call
curl_global_init when it was no called before. But curl_easy_init
can be called from different threads by the ESX driver. Therefore,
call curl_global_init from virInitialize to stop curl_easy_init from
calling it.

Reported by Benjamin Wang.

12 years agofix kvm_pv_eoi with kvmclock
Martin Kletzander [Mon, 8 Oct 2012 16:51:57 +0000 (18:51 +0200)]
fix kvm_pv_eoi with kvmclock

When both kvmclock and kvm_pv_eoi are configured (either disabled or
enabled) libvirt will generate invalid CPU specification due to the
fact that even though kvmclock causes the CPU to be specified, it
doesn't set have_cpu flag to true (and the new kvm_pv_eoi as well).
This patch fixes the issue and adds a test exactly for that to show
that it is fixed correctly (and also to keep it that way in the future
of course).

12 years agoFix typo in HAVE_DBUS automake conditional
Alexander Larsson [Mon, 8 Oct 2012 14:57:47 +0000 (16:57 +0200)]
Fix typo in HAVE_DBUS automake conditional

The variable that is set in the script is with_dbus, not have_dbus.

12 years agopython: keep consistent handling of Python integer conversion
Guannan Ren [Fri, 28 Sep 2012 12:29:03 +0000 (20:29 +0800)]
python: keep consistent handling of Python integer conversion

libvirt_ulonglongUnwrap requires the integer type of python obj.
But libvirt_longlongUnwrap still could handle python obj of
Pyfloat_type which causes the float value to be rounded up
to an integer.

For example
 >>> dom.setSchedulerParameters({'vcpu_quota': 0.88})
 0
libvirt_longlongUnwrap treats 0.88 as a valid value 0

However
 >>> dom.setSchedulerParameters({'cpu_shares': 1000.22})
libvirt_ulonglongUnwrap will throw out an error
"TypeError: an integer is required"

The patch make this consistent.

12 years agopython: cleanup vcpu related binding APIs
Guannan Ren [Fri, 28 Sep 2012 08:27:38 +0000 (16:27 +0800)]
python: cleanup vcpu related binding APIs

libvirt_virDomainGetVcpus: add error handling, return -1 instead of None
libvirt_virDomainPinVcpu and libvirt_virDomainPinVcpuFlags:
  check the type of argument
  make use of libvirt_boolUnwrap

  Set bitmap according to these values which are contained in given
  argument of vcpu tuple and turn off these bit corresponding to
  missing vcpus in argument tuple

  The original way ignored the error info from PyTuple_GetItem
  if index is out of range.
  "IndexError: tuple index out of range"
  The error message will only be raised on next command in interactive mode.

12 years agoesx: Disable libcurl's use of signals to fix a segfault
Matthias Bolte [Sat, 29 Sep 2012 20:16:30 +0000 (22:16 +0200)]
esx: Disable libcurl's use of signals to fix a segfault

libcurl uses a SIGALRM in combination with sigsetjmp/siglongjmp to be
able to abort a DNS lookup when it takes too long. The problem with this
in a multi-threaded application is that the signal handler for SIGALRM
and the call to siglongjmp can be executed on a thread that is different
from the one that initially did the SIGALRM setup and the call to
sigsetjmp. In the reported case this triggered a segfault.

Disable libcurl's use of signals to avoid this situation. This has the
disadvantage of losing the ability to abort synchronous DNS lookups which
might result in libcurl getting stuck in a DNS lookup in the worst case.
When libcurl was build with an asynchronous DNS backend such as c-ares
then there is no problem because the timeout mechanism works without
signals here anyway.

Reported by Benjamin Wang.

12 years agoS390: Buffer too small for large CPU numbers.
Viktor Mihajlovski [Fri, 5 Oct 2012 13:59:08 +0000 (15:59 +0200)]
S390: Buffer too small for large CPU numbers.

The output buffer for virFileReadAll was too small for systems with
more than 30 CPUs which leads to a log entry and incorrect behavior.
The new size will be sufficient for the current
architectural limits.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agobuild: fix VPATH builds
Eric Blake [Fri, 5 Oct 2012 14:53:17 +0000 (08:53 -0600)]
build: fix VPATH builds

This reverts part of commit 5468594f465; the perl changes in that
patch were sufficient.  Since libvirt.syms is already a generated
file created in part from libvirt_private.syms, we don't need a
second pass over libvirt_private.syms in isolation.

* src/Makefile.am: Undo addition of check-private-symfile.

12 years agoCheck for private symbols presence as well
Michal Privoznik [Fri, 5 Oct 2012 12:57:36 +0000 (14:57 +0200)]
Check for private symbols presence as well

Currently, we are checking if libvirt.so contains public symbols.
However, sometimes we rename an internal symbol and forget to
change libvirt_private.syms accordingly. Hence, it's safer to check
for internal symbols as well.

12 years agospec: prefer canonical name of util-linux
Eric Blake [Thu, 4 Oct 2012 16:02:02 +0000 (10:02 -0600)]
spec: prefer canonical name of util-linux

I noticed that in two places, we require util-linux, and in a third,
we require util-linux-ng.  On Fedora (I tested F15 through rawhide),
util-linux-ng is obsoleted by util-linux; on RHEL 6, util-linux
is obsoleted by util-linux-ng.  That is, on either platform, either
name will get you the correct package installed (where the preferred
name on fedora is util-linux, and on RHEL 6 is util-linux-ng).  But
on RHEL 5, there is no util-linux-ng

* libvirt.spec.in (Requires): Use util-linux, not util-linux-ng.

12 years agoprivate.syms: Drop virKillProcess
Michal Privoznik [Fri, 5 Oct 2012 11:32:09 +0000 (13:32 +0200)]
private.syms: Drop virKillProcess

After it got renamed to virProcessKill (cf470068a11)
it is no longer needed in the private syms file.

12 years agodocs: fix links in migration.html TOC
Eric Blake [Thu, 4 Oct 2012 22:57:27 +0000 (16:57 -0600)]
docs: fix links in migration.html TOC

Use of the wrong attribute name caused the table of contents to
be useless.  Fix suggested by Daniel P. Berrange.

* docs/migration.html.in: Use correct anchoring attribute.

12 years agodoc: Add Maven repository to Java bindings documentation
Wido den Hollander [Thu, 27 Sep 2012 20:48:17 +0000 (22:48 +0200)]
doc: Add Maven repository to Java bindings documentation

Getting a artifact into Maven central has a lot of restrictions as
where the artifact should be hosted.

This seemed like a big hassle which we don't want to go through now.

Document a way for users to use libvirt.org as a repository so they can
fetch the Java bindings with maven.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
12 years agoCorrect checking of virStrcpyStatic() return value
Kyle Mestery [Wed, 3 Oct 2012 19:46:55 +0000 (15:46 -0400)]
Correct checking of virStrcpyStatic() return value

Correct the check for the return value of virStrcpyStatic()
when copying port-profile names. Fixes Open vSwitch ports
which utilize port-profiles from network definitions.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
12 years agodocs: rudimentary phyp documentation
Eric Blake [Thu, 27 Sep 2012 22:19:37 +0000 (16:19 -0600)]
docs: rudimentary phyp documentation

Based on a report that phyp is undocumented:
https://www.redhat.com/archives/libvirt-users/2012-July/msg00013.html

* docs/drvphyp.html.in (phyp): New file.
* docs/drivers.html.in: List it.

12 years agobuild: update gnulib for FreeBSD build
Eric Blake [Tue, 2 Oct 2012 23:18:04 +0000 (17:18 -0600)]
build: update gnulib for FreeBSD build

Several gnulib tests were failing 'make check', and compilation with
CFLAGS=-g failed due to a gcc 4.2.1 limitation.

* .gnulib: Update to latest, for gcc 4.2 support and fixed FreeBSD tests.

12 years agodoc: update description about security labels on formatdomain.html
Marcelo Cerri [Tue, 2 Oct 2012 17:57:37 +0000 (14:57 -0300)]
doc: update description about security labels on formatdomain.html

This patch adds a brief description about labels for each security
driver.

12 years agosecurity: also parse user/group names instead of just IDs for DAC labels
Marcelo Cerri [Tue, 2 Oct 2012 17:57:36 +0000 (14:57 -0300)]
security: also parse user/group names instead of just IDs for DAC labels

The DAC driver is missing parsing of group and user names for DAC labels
and currently just parses uid and gid. This patch extends it to support
names, so the following security label definition is now valid:

  <seclabel type='static' model='dac' relabel='yes'>
      <label>qemu:qemu</label>
      <imagelabel>qemu:qemu</imagelabel>
  </seclabel>

When it tries to parse an owner or a group, it first tries to resolve it as
a name, if it fails or it's an invalid user/group name then it tries to
parse it as an UID or GID. A leading '+' can also be used for both owner and
group to force it to be parsed as IDs, so the following example is also
valid:

  <seclabel type='static' model='dac' relabel='yes'>
      <label>+101:+101</label>
      <imagelabel>+101:+101</imagelabel>
  </seclabel>

This ensures that UID 101 and GUI 101 will be used instead of an user or
group named "101".

12 years agobuild: avoid -Wno-format on new-enough gcc
Eric Blake [Tue, 2 Oct 2012 14:37:00 +0000 (08:37 -0600)]
build: avoid -Wno-format on new-enough gcc

Commit c579d6b added a sledgehammer to silence spurious warnings from
gcc 4.2, but in the process, it also silenced useful warnings from
gcc 4.3 through 4.5.  As a result, a bug slipped in to commit 0caccb58.

Tested with FreeBSD (gcc 4.2.1), RHEL 6.3 (gcc 4.4), and F17 (gcc 4.7.2),
where the former didn't trip on spurious warnings, and where the latter
two detected a revert of 2b804cf.

* m4/virt-compile-warnings.m4 (-Wno-format): Probe for the actual
spurious message, to once again allow gcc 4.4 to use -Wformat.

12 years agobuild: fix typo in debug message
Eric Blake [Tue, 2 Oct 2012 12:36:50 +0000 (06:36 -0600)]
build: fix typo in debug message

Introduced in commit 0caccb58.

  CC     libvirt_driver_qemu_impl_la-qemu_capabilities.lo
../../src/qemu/qemu_capabilities.c: In function 'qemuCapsInitQMP':
../../src/qemu/qemu_capabilities.c:2327:13: error: format '%d' expects argument of type 'int', but argument 8 has type 'const char *' [-Werror=format]

* src/qemu/qemu_capabilities.c (qemuCapsInitQMP): Use correct format.

12 years agoqemu: Kill processes used for QMP caps probing
Jiri Denemark [Tue, 2 Oct 2012 08:59:56 +0000 (10:59 +0200)]
qemu: Kill processes used for QMP caps probing

Since libvirt switched to QMP capabilities probing recently, it starts
QEMU process used for this probing with -daemonize, which means
virCommandAbort can no longer reach these processes. As a result of
that, restarting libvirtd will leave several new QEMU processes behind.
Let's use QEMU's -pidfile and use it to kill the process when QMP caps
probing is done.

12 years agoqemu: Use proper agent entering function when freezing filesystems
Peter Krempa [Mon, 1 Oct 2012 15:58:29 +0000 (17:58 +0200)]
qemu: Use proper agent entering function when freezing filesystems

When doing snapshots, the filesystem freeze function used the agent
entering function that expects the qemud_driver unlocked. This might
cause a deadlock of the qemu driver if the agent does not respond.

The only call path of this function has the qemud_driver locked, so this
patch changes the entering functions to those expecting the driver
locked.

12 years agolxc: Correctly report active cgroups
Michal Privoznik [Mon, 1 Oct 2012 12:22:42 +0000 (14:22 +0200)]
lxc: Correctly report active cgroups

There was an inverted return value in lxcCgroupControllerActive().
The function assumes cgroups are active and do couple of checks
to prove that. If any of them fails, false is returned. Therefore,
at the end, after all checks are done we must return true, not false.

12 years agobuild: avoid journald on rhel 5
Eric Blake [Mon, 1 Oct 2012 22:38:56 +0000 (16:38 -0600)]
build: avoid journald on rhel 5

Commit f6430390 broke builds on RHEL 5, where glibc (2.5) is too
old to support mkostemp (2.7) or htole64 (2.9).  While gnulib
has mkostemp, it still lacks htole64; and it's not worth dragging
in replacements on systems where journald is unlikely to exist
in the first place, so we just use an extra configure-time check
as our witness of whether to attempt compiling the code.

* src/util/logging.c (virLogParseOutputs): Don't attempt to
compile journald on older glibc.
* configure.ac (AC_CHECK_DECLS): Check for htole64.

12 years agobuild: fix bitmap conversion when !CPU_ALLOC
Eric Blake [Mon, 1 Oct 2012 23:00:58 +0000 (17:00 -0600)]
build: fix bitmap conversion when !CPU_ALLOC

Commit f1a43a8 missed one side of an #if/#else.

* src/util/processinfo.c (virProcessInfoGetAffinity): Use correct
bitmap operation.

12 years agoAdd note about numeric domain names to manpage
Dave Allan [Mon, 1 Oct 2012 18:01:36 +0000 (14:01 -0400)]
Add note about numeric domain names to manpage

Clarify that domains with numeric names can only be identified by
their domain id.

12 years agobuild: avoid infinite autogen loop
Eric Blake [Mon, 1 Oct 2012 15:10:20 +0000 (09:10 -0600)]
build: avoid infinite autogen loop

Several people have reported that if the .gnulib submodule is dirty,
then 'make' will go into an infinite loop attempting to rerun bootstrap,
because that never cleans up the dirty submodule.  By default, we
should halt and make the user investigate, but if the user doesn't
know why or care that the submodule is dirty, I also added the ability
to 'make CLEAN_SUBMODULE=1' to get things going again.

Also, while testing this, I noticed that when a submodule update was
needed, 'make' would first run autoreconf, then bootstrap (which
reruns autoreconf); adding a strategic dependency allows for less work.

* .gnulib: Update to latest, for maint.mk improvements.
* cfg.mk (_autogen): Also hook maint.mk, to run before autoreconf.
* autogen.sh (bootstrap): Refuse to run if gnulib is dirty, unless
user requests discarding gnulib changes.

12 years agohyperv: Fix and improve hypervListAllDomains
Matthias Bolte [Sun, 9 Sep 2012 15:39:40 +0000 (17:39 +0200)]
hyperv: Fix and improve hypervListAllDomains

Use MATCH for all flags checks.

hypervMsvmComputerSystemToDomain expects the domain pointer to the
initialized to NULL.

All items in doms up to the count-th one are valid, no need to double
check before freeing them.

12 years agoesx: Fix and improve esxListAllDomains function
Matthias Bolte [Sun, 9 Sep 2012 10:31:16 +0000 (12:31 +0200)]
esx: Fix and improve esxListAllDomains function

Avoid requesting information such as identity or power state when it
is not necessary.

Lookup virtual machine list with the required fields (configStatus,
name, and config.uuid) to make esxVI_GetVirtualMachineIdentity work.

No need to call esxVI_GetNumberOfSnapshotTrees. rootSnapshotTreeList
can be tested for emptiness by checking it for NULL.

esxVI_LookupRootSnapshotTreeList already does the error reporting,
don't overwrite it.

Check if autostart is enabled at all before looking up the individual
autostart setting of a virtual machine.

Reorder VIR_EXPAND_N(doms, ndoms, 1) to avoid leaking the result of
the call to virGetDomain if VIR_EXPAND_N fails.

Replace VIR_EXPAND_N by VIR_RESIZE_N to avoid quadratic scaling, as in
the Hyper-V version of the function.

If virGetDomain fails it already reports an error, don't overwrite it
with an OOM error.

All items in doms up to the count-th one are valid, no need to double
check before freeing them.

Finally, don't leak autoStartDefaults and powerInfoList.

12 years agobuild: default selinuxfs mount point to /sys/fs/selinux
Daniel J Walsh [Fri, 28 Sep 2012 18:11:43 +0000 (14:11 -0400)]
build: default selinuxfs mount point to /sys/fs/selinux

Currently if you build on a machine that does not support SELinux we end up
with the default mount point being /selinux, since this is moved to
/sys/fs/selinux, we should start defaulting there.

I believe this is causing a bug in libvirt-lxc when /selinux does not exists,
even though /sys/fs/selinux exists.

12 years agoAdd support for detecting capablities using QMP commands
Daniel P. Berrange [Wed, 22 Aug 2012 17:05:08 +0000 (18:05 +0100)]
Add support for detecting capablities using QMP commands

Start a QEMU process using

   $QEMU -S -no-user-config -nodefaults \
         -nographic -M none -qmp unix:/some/path,server,nowait

and talk QMP over stdio to discover what capabilities the
binary supports. This works for QEMU 1.2.0 or later and
for older QEMU automatically fallback to the old approach
of parsing -help and related command line args.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoIgnore error from query-cpu-definitions
Daniel P. Berrange [Fri, 28 Sep 2012 14:55:54 +0000 (15:55 +0100)]
Ignore error from query-cpu-definitions

Some architectures provide the query-cpu-definitions command,
but are set to always return a "GenericError" from it :-(
Catch this & treat it as if there was an empty list of CPUs
returned

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAvoid bogus I/O event errors when closing the QEMU monitor
Daniel P. Berrange [Fri, 28 Sep 2012 14:27:39 +0000 (15:27 +0100)]
Avoid bogus I/O event errors when closing the QEMU monitor

After calling qemuMonitorClose(), it is still possible for
the QEMU monitor I/O event callback to get invoked. This
will trigger an error message because mon->fd has been set
to -1 at this point. Silently ignore the case where mon->fd
is -1, likewise for mon->watch being zero.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove need to pass in a virDomainObjPtr instance to qemuMonitorOpen
Daniel P. Berrange [Fri, 28 Sep 2012 14:26:36 +0000 (15:26 +0100)]
Remove need to pass in a virDomainObjPtr instance to qemuMonitorOpen

The qemuMonitorOpen method only needs a virDomainObjPtr in order
to access the QEMU pid. This is not critical when detecting the
QEMU capabilties, so can easily be skipped

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix QEMU test with 1.2.0 help output
Daniel P. Berrange [Fri, 28 Sep 2012 15:48:58 +0000 (16:48 +0100)]
Fix QEMU test with 1.2.0 help output

The help output for QEMU 1.2.0 changed 'pci-assign' to 'kvm-pci-assign'.
Since the new capabilities code does exact device name matching
instead of substring matching, this caused the capabilities to go
missing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoARMHF: implement /proc/cpuinfo parsing
Chuck Short [Thu, 26 Jul 2012 13:32:07 +0000 (08:32 -0500)]
ARMHF: implement /proc/cpuinfo parsing

Minimal CPU "parser" for armhf to avoid compile time warning.

Signed-off-by: Chuck Short <chuck.short@canonical.com>
12 years agoAutomatically enable systemd journal logging
Daniel P. Berrange [Thu, 27 Sep 2012 12:13:09 +0000 (13:13 +0100)]
Automatically enable systemd journal logging

Probe to see if the systemd journal is accessible, and if
so enable logging to the journal by default, rather than
stderr (current default under systemd).

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd systemd journal support
Daniel P. Berrange [Tue, 25 Sep 2012 17:31:01 +0000 (18:31 +0100)]
Add systemd journal support

Add support for logging to the systemd journal, using its
simple client library. The benefit over syslog is that it
accepts structured log data, so the journald can store
individual items like code file/line/func separately from
the string message. Tools which require structured log
data can then query the journal to extract exactly what
they desire without resorting to string parsing

While systemd provides a simple client library for logging,
it is more convenient for libvirt to directly write its
own client code. This lets us build up the iovec's on
the stack, avoiding the need to alloc memory when writing
log messages.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRefactor qemuCapsParseDeviceStr to work from data tables
Daniel P. Berrange [Thu, 13 Sep 2012 17:04:24 +0000 (18:04 +0100)]
Refactor qemuCapsParseDeviceStr to work from data tables

Currently the qemuCapsParseDeviceStr method has a bunch of open
coded string searches/comparisons to detect devices and their
properties. Soon this data will be obtained from QMP queries
instead of -device help output. Maintaining the list of device
and properties in two places is undesirable. Thus the existing
qemuCapsParseDeviceStr() method needs to be refactored to
separate the device types and properties from the actual
search code.

Thus the -device help output is now parsed to construct a
list of device names, and device properties. These are then
checked against a set of datatables to set the capability
flags

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDon't initialize logging twice in libvirtd
Daniel P. Berrange [Thu, 27 Sep 2012 16:27:17 +0000 (17:27 +0100)]
Don't initialize logging twice in libvirtd

The virInitialize function initializes logging from the env,
so there is no need for another call to virLogSetFromEnv

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoChange logging category parameter into an enum
Daniel P. Berrange [Thu, 27 Sep 2012 13:44:22 +0000 (14:44 +0100)]
Change logging category parameter into an enum

The 'const char *category' parameter only has a few possible
values now that the filename has been separated. Turn this
parameter into an enum instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoInclude filename explicitly in logging APIs
Daniel P. Berrange [Thu, 27 Sep 2012 13:28:44 +0000 (14:28 +0100)]
Include filename explicitly in logging APIs

Currently the logging APIs have a 'const char *category' parameter
which indicates where the log message comes from. This is typically
a combination of the __FILE__ string and other prefix. Split the
__FILE__ off into a dedicated parameter so it can passed to the
log outputs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoWhitespace cleanup in logging files
Daniel P. Berrange [Thu, 27 Sep 2012 13:14:01 +0000 (14:14 +0100)]
Whitespace cleanup in logging files

General whitespace cleanup in the logging files

 - Move '{' to a new line after funtion declaration
 - Put each parameter on a new line to avoid long lines
 - Put return type on new line
 - Leave 2 blank lines between functions

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agos/int/virLogDestination/ in logging code
Daniel P. Berrange [Thu, 27 Sep 2012 13:04:21 +0000 (14:04 +0100)]
s/int/virLogDestination/ in logging code

The log destinations are an enum, but most of the code was
just using a plain 'int' for function params / variables.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agos/long long/size_t/ for file line numbers in logging code
Daniel P. Berrange [Thu, 27 Sep 2012 13:00:21 +0000 (14:00 +0100)]
s/long long/size_t/ for file line numbers in logging code

The __LINE__ macro value is specified to fit in the size_t
type, so use that instead of 'long long' in the logging code

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agos/int/virLogPriority/ in logging code
Daniel P. Berrange [Thu, 27 Sep 2012 12:58:58 +0000 (13:58 +0100)]
s/int/virLogPriority/ in logging code

The log priority levels are an enum, but most of the code was
just using a plain 'int' for function params / variables.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agopython: return error if PyObject obj is NULL for unwrapper helper functions
Guannan Ren [Wed, 26 Sep 2012 17:33:50 +0000 (01:33 +0800)]
python: return error if PyObject obj is NULL for unwrapper helper functions

The result is indeterminate for NULL argument to python
functions as follows. It's better to return negative value in
these situations.

PyObject_IsTrue will segfault if the argument is NULL
PyFloat_AsDouble(NULL) is -1.000000
PyLong_AsUnsignedLongLong(NULL) is 0.000000

12 years agonetwork: fix dnsmasq/radvd binding to IPv6 on recent kernels
Benjamin Cama [Wed, 26 Sep 2012 19:02:20 +0000 (21:02 +0200)]
network: fix dnsmasq/radvd binding to IPv6 on recent kernels

I hit this problem recently when trying to create a bridge with an IPv6
address on a 3.2 kernel: dnsmasq (and, further, radvd) would not bind to
the given address, waiting 20s and then giving up with -EADDRNOTAVAIL
(resp. exiting immediately with "error parsing or activating the config
file", without libvirt noticing it, BTW). This can be reproduced with (I
think) any kernel >= 2.6.39 and the following XML (to be used with
"virsh net-create"):

        <network>
          <name>test-bridge</name>
          <bridge name='testbr0' />
          <ip family='ipv6' address='fd00::1' prefix='64'>
          </ip>
        </network>

(it happens even when you have an IPv4, too)

The problem is that since commit [1] (which, ironically, was made to
“help IPv6 autoconfiguration”) the linux bridge code makes bridges
behave like “real” devices regarding carrier detection. This makes the
bridges created by libvirt, which are started without any up devices,
stay with the NO-CARRIER flag set, and thus prevents DAD (Duplicate
address detection) from happening, thus letting the IPv6 address flagged
as “tentative”. Such addresses cannot be bound to (see RFC 2462), so
dnsmasq fails binding to it (for radvd, it detects that "interface XXX
is not RUNNING", thus that "interface XXX does not exist, ignoring the
interface" (sic)). It seems that this behavior was enhanced somehow with
commit [2] by avoiding setting NO-CARRIER on empty bridges, but I
couldn't reproduce this behavior on my kernel. Anyway, with the “dummy
tap to set MAC address” trick, this wouldn't work.

To fix this, the idea is to get the bridge's attached device to be up so
that DAD can happen (deactivating DAD altogether is not a good idea, I
think). Currently, libvirt creates a dummy TAP device to set the MAC
address of the bridge, keeping it down. But even if we set this device
up, it is not RUNNING as soon as the tap file descriptor attached to it
is closed, thus still preventing DAD. So, we must modify the API a bit,
so that we can get the fd, keep the tap device persistent, run the
daemons, and close it after DAD has taken place. After that, the bridge
will be flagged NO-CARRIER again, but the daemons will be running, even
if not happy about the device's state (but we don't really care about
the bridge's daemons doing anything when no up interface is connected to
it).

Other solutions that I envisioned were:
      * Keeping the *-nic interface up: this would waste an fd for each
        bridge during all its life. May be acceptable, I don't really
        know.
      * Stop using the dummy tap trick, and set the MAC address directly
        on the bridge: it is possible since quite some time it seems,
        even if then there is the problem of the bridge not being
        RUNNING when empty, contrary to what [2] says, so this will need
        fixing (and this fix only happened in 3.1, so it wouldn't work
        for 2.6.39)
      * Using the --interface option of dnsmasq, but I saw somewhere
        that it's not used by libvirt for backward compatibility. I am
        not sure this would solve this problem, though, as I don't know
        how dnsmasq binds itself to it with this option.

This is why this patch does what's described earlier.

This patch also makes radvd start even if the interface is
“missing” (i.e. it is not RUNNING), as it daemonizes before binding to
it, and thus sometimes does it after the interface has been brought down
by us (by closing the tap fd), and then originally stops. This also
makes it stop yelling about it in the logs when the interface is down at
a later time.

[1]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=1faa4356a3bd89ea11fb92752d897cff3a20ec0e
[2]
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=b64b73d7d0c480f75684519c6134e79d50c1b341

12 years agoFix regression starting QEMU instances without query-events
Daniel P. Berrange [Thu, 27 Sep 2012 14:25:16 +0000 (15:25 +0100)]
Fix regression starting QEMU instances without query-events

If QEMU reports CommandNotFound for the 'query-events' command,
we must treat that as success, returning a zero-length array
of events

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix compilation of legacy xen driver with Xen 4.2
Jim Fehlig [Wed, 26 Sep 2012 21:20:35 +0000 (15:20 -0600)]
Fix compilation of legacy xen driver with Xen 4.2

In Xen 4.2, xs.h is deprecated in favor of xenstore.h.  xs.h now
contains

#warning xs.h is deprecated use xenstore.h instead
#include <xenstore.h>

which fails compilation when warnings are treated as errors.

Introduce a configure-time check for xenstore.h and if found,
use it instead of xs.h.

12 years agoPass the "raw" log message to each virLogOutputFunc
Miloslav Trmač [Thu, 27 Sep 2012 11:45:33 +0000 (12:45 +0100)]
Pass the "raw" log message to each virLogOutputFunc

In addition to the preformatted text line, pass the raw message as well,
to allow the output functions to use a different output format.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSplit priority conversion from virLogOutputToSyslog
Miloslav Trmač [Thu, 27 Sep 2012 11:34:04 +0000 (12:34 +0100)]
Split priority conversion from virLogOutputToSyslog

Allow for the code converting from libvirt log levels to syslog
log levels to be reused.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove command/event capabilities detection out of QEMU monitor code
Daniel P. Berrange [Thu, 13 Sep 2012 14:54:02 +0000 (15:54 +0100)]
Move command/event capabilities detection out of QEMU monitor code

The qemuMonitorSetCapabilities() API is used to initialize the QMP
protocol capabilities. It has since been abused to initialize some
libvirt internal capabilities based on command/event existance too.
Move the latter code out into qemuCapsProbeQMP() in the QEMU
capabilities source file instead

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove some unused includes in QEMU code
Daniel P. Berrange [Thu, 13 Sep 2012 14:36:56 +0000 (15:36 +0100)]
Remove some unused includes in QEMU code

The qemu monitor does not require qemu_conf.h, and the
qemu capabilities code actually wants bitmap.h

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a qemuMonitorGetTargetArch() method for QMP query-target command
Daniel P. Berrange [Wed, 22 Aug 2012 09:48:41 +0000 (10:48 +0100)]
Add a qemuMonitorGetTargetArch() method for QMP query-target command

Add a new qemuMonitorGetTargetArch() method to support invocation
of the 'query-target' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>