]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
11 years agoUse virFileFindResource to locate virtlockd daemon
Daniel P. Berrange [Fri, 25 Apr 2014 10:55:32 +0000 (11:55 +0100)]
Use virFileFindResource to locate virtlockd daemon

Make the lock plugin use virFileFindResource to find the
virtlockd daemon path, so that it executes the in-builddir
daemon if run from source tree.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate libvirtd daemon
Daniel P. Berrange [Fri, 25 Apr 2014 10:55:32 +0000 (11:55 +0100)]
Use virFileFindResource to locate libvirtd daemon

Make the remote driver use virFileFindResource to find the
libvirt daemon path, so that it executes the in-builddir
daemon if run from source tree.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRecheck disk backing chains after snapshot
Jiri Denemark [Fri, 25 Apr 2014 13:07:37 +0000 (15:07 +0200)]
Recheck disk backing chains after snapshot

When a snapshot operation finishes we have to recheck the backing chain
of all disks involved in the snapshot. And we need to do that even if
the operation failed because some of the disks might have changed if
QEMU did not support transactions.

11 years agonetwork: centralize check for active network during interface attach
Laine Stump [Thu, 10 Apr 2014 11:44:07 +0000 (14:44 +0300)]
network: centralize check for active network during interface attach

The check for a network being active during interface attach was being
done individually in several places (by both the lxc driver and the
qemu driver), but those places were too specific, leading to it *not*
being checked when allocating a connection/device from a macvtap or
hostdev network.

This patch puts a single check in networkAllocateActualDevice(), which
is always called before the any network interface is attached to any
type of domain. It also removes all the other now-redundant checks
from the lxc and qemu drivers.

NB: the following patches are prerequisites for this patch, in the
case that it is backported to any branch:

  440beeb network: fix virNetworkObjAssignDef and persistence
  8aaa5b6 network: create statedir during driver initialization
  b9e9549 network: change location of network state xml files
  411c548 network: set macvtap/hostdev networks active if their state
          file exists

This fixes:

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

11 years agonetwork: set macvtap/hostdev networks active if their state file exists
Laine Stump [Wed, 9 Apr 2014 14:16:45 +0000 (17:16 +0300)]
network: set macvtap/hostdev networks active if their state file exists

libvirt attempts to determine at startup time which networks are
already active, and set their active flags. Previously it has done
this by assuming that all networks are inactive, then setting the
active flag if the network has a bridge device associated with it and
that bridge device exists. This is not useful for macvtap and hostdev
based networks, since they do not use a bridge device.

Of course the reason that such a check had to be done was that the
presence of a status file in the network "stateDir" couldn't be
trusted as an indicator of whether or not a network was active. This
was due to the network driver mistakenly using
/var/lib/libvirt/network to store the status files, rather than
/var/run/libvirt/network (similar to what is done by every other
libvirt driver that stores status xml for its objects). The difference
is that /var/run is cleared out when the host reboots, so you can be
assured that the state file you are seeing isn't just left over from a
previous boot of the host.

Now that the network driver has been switched to using
/var/run/libvirt/network for status, we can also modify it to assume
that any network with an existing status file is by definition active
- we do this when reading the status file. To fine tune the results,
networkFindActiveConfigs() is changed to networkUpdateAllState(),
and only sets active = 0 if the conditions for particular network
types are *not* met.

The result is that during the first run of libvirtd after the host
boots, there are no status files, so no networks are active. Any time
libvirtd is restarted, any network with a status file will be marked
as active (unless the network uses a bridge device and that device for
some reason doesn't exist).

11 years agonetwork: change location of network state xml files
Laine Stump [Fri, 4 Apr 2014 13:48:54 +0000 (16:48 +0300)]
network: change location of network state xml files

For some reason these have been stored in /var/lib, although other
drivers (e.g. qemu and lxc) store their state files in /var/run.

It's much nicer to store state files in /var/run because it is
automatically cleared out when the system reboots. We can then use
existence of the state file as a convenient indicator of whether or
not a particular network is active.

Since changing the location of the state files by itself will cause
problems in the case of a *live* upgrade from an older libvirt that
uses /var/lib (because current status of active networks will be
lost), the network driver initialization has been modified to migrate
any network state files from /var/lib to /var/run.

This will not help those trying to *downgrade*, but in practice this
will only be problematic in two cases

1) If there are networks with network-wide bandwidth limits configured
   *and in use* by a guest during a downgrade to "old" libvirt. In this
   case, the class ID's used for that network's tc rules, as well as
   the currently in-use bandwidth "floor" will be forgotten.

2) If someone does this: 1) upgrade libvirt, 2) downgrade libvirt, 3)
   modify running state of network (e.g. add a static dhcp host, etc),
   4) upgrade. In this case, the modifications to the running network
   will be lost (but not any persistent changes to the network's
   config).

11 years agonetwork: create statedir during driver initialization
Laine Stump [Fri, 4 Apr 2014 11:21:13 +0000 (14:21 +0300)]
network: create statedir during driver initialization

This directory should be created when the network driver is first
started up, not just when a dhcp daemon is run. This hasn't posed a
problem in the past, because the directory has always been
pre-existing.

11 years agonetwork: fix virNetworkObjAssignDef and persistence
Laine Stump [Tue, 22 Apr 2014 13:48:54 +0000 (16:48 +0300)]
network: fix virNetworkObjAssignDef and persistence

Experimentation showed that if virNetworkCreateXML() was called for a
network that was already defined, and then the network was
subsequently shutdown, the network would continue to be persistent
after the shutdown (expected/desired), but the original config would
be lost in favor of the transient config sent in with
virNetworkCreateXML() (which would then be the new persistent config)
(obviously unexpected/not desired).

To fix this, virNetworkObjAssignDef() has been changed to

1) properly save/free network->def and network->newDef for all the
various combinations of live/active/persistent, including some
combinations that were previously considered to be an error but didn't
need to be (e.g. setting a "live" config for a network that isn't yet
active but soon will be - that was previously considered an error,
even though in practice it can be very useful).

2) automatically set the persistent flag whenever a new non-live
config is assigned to the network (and clear it when the non-live
config is set to NULL). the libvirt network driver no longer directly
manipulates network->persistent, but instead relies entirely on
virNetworkObjAssignDef() to do the right thing automatically.

After this patch, the following sequence will behave as expected:

virNetworkDefineXML(X)
virNetworkCreateXML(X') (same name but some config different)
virNetworkDestroy(X)

At the end of these calls, the network config will remain as it was
after the initial virNetworkDefine(), whereas previously it would take
on the changes given during virNetworkCreateXML().

Another effect of this tighter coupling between a) setting a !live def
and b) setting/clearing the "persistent" flag, is that future patches
which change the details of network lifecycle management
(e.g. upcoming patches to fix detection of "active" networks when
libvirtd is restarted) will find it much more difficult to break
persistence functionality.

11 years agobuild: -avoid-version on libvirt_driver_nwfilter
Dwight Engen [Fri, 25 Apr 2014 19:10:00 +0000 (15:10 -0400)]
build: -avoid-version on libvirt_driver_nwfilter

This fixes the following make rpm warning:

warning: Installed (but unpackaged) file(s) found:
   /usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so.0
   /usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so.0.0.0

introduced in comit 8d559864

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: Support PV consoles
Ian Campbell [Fri, 25 Apr 2014 15:54:20 +0000 (16:54 +0100)]
libxl: Support PV consoles

Currently the driver only exposes the ability to connect to the serial console
of a Xen guest, which doesn't work for a PV guest. Since for an HVM guest the
serial devices are duplicated as consoles it is sufficient to just use the
console devices unconditionally.

Tested with the following bit of config XML:

<domain type='xen'>
  ...
  <devices>
    <console type='pty'>
      <target type='xen'/>
    </console>
  </devices>
</domain>

I have observed and tested this on ARM but I believe it also applies to x86 PV
guests.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Jim Fehlig <jfehlig@suse.com>
Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Clark Laughlin <clark.laughlin@linaro.org>
11 years agobuild: add nwfilterxml2firewalldata to dist
Dwight Engen [Fri, 25 Apr 2014 16:46:02 +0000 (12:46 -0400)]
build: add nwfilterxml2firewalldata to dist

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
11 years agoConditionalize include of dlfcn.h in virmock.h
Daniel P. Berrange [Fri, 25 Apr 2014 14:48:30 +0000 (15:48 +0100)]
Conditionalize include of dlfcn.h in virmock.h

dlfcn.h does not exist on Win32 so must only be used
conditionally

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a test suite for nwfilter ebiptables tech driver
Daniel P. Berrange [Tue, 1 Apr 2014 06:19:38 +0000 (07:19 +0100)]
Add a test suite for nwfilter ebiptables tech driver

Create a nwfilterxml2firewalltest to exercise the
ebiptables_driver.applyNewRules method with a variety of
different XML input files. The XML input files are taken
from the libvirt-tck nwfilter tests. While the nwfilter
tests verify the final state of the iptables chains, this
test verifies the set of commands invoked to create the
chains.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove last trace of direct firewall command exection
Daniel P. Berrange [Mon, 31 Mar 2014 12:01:04 +0000 (13:01 +0100)]
Remove last trace of direct firewall command exection

Remove all the left over code related to the direct invocation
of firewall-cmd/iptables/ip6tables/ebtables. This is all handled
by the virFirewallPtr APIs now.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert ebiptablesDriverProbeStateMatch to virFirewall
Daniel P. Berrange [Mon, 31 Mar 2014 11:58:20 +0000 (12:58 +0100)]
Convert ebiptablesDriverProbeStateMatch to virFirewall

Conver the ebiptablesDriverProbeStateMatch initialization
check to use the virFirewall APIs for querying iptables
version.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebiptablesApplyNewRules to virFirewall
Daniel P. Berrange [Tue, 25 Mar 2014 14:33:19 +0000 (14:33 +0000)]
Convert nwfilter ebiptablesApplyNewRules to virFirewall

Convert the nwfilter ebtablesApplyNewRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebtablesApplyDropAllRules to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 16:27:39 +0000 (16:27 +0000)]
Convert nwfilter ebtablesApplyDropAllRules to virFirewall

Convert the nwfilter ebtablesApplyDropAllRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebtablesApplyDHCPOnlyRules to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 16:25:12 +0000 (16:25 +0000)]
Convert nwfilter ebtablesApplyDHCPOnlyRules to virFirewall

Convert the nwfilter ebtablesApplyDHCPOnlyRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebtablesApplyBasicRules to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 12:58:18 +0000 (12:58 +0000)]
Convert nwfilter ebtablesApplyBasicRules to virFirewall

Convert the nwfilter ebtablesApplyBasicRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebiptablesTearNewRules to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 12:48:33 +0000 (12:48 +0000)]
Convert nwfilter ebiptablesTearNewRules to virFirewall

Convert the nwfilter ebiptablesTearNewRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebtablesRemoveBasicRules to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 12:14:13 +0000 (12:14 +0000)]
Convert nwfilter ebtablesRemoveBasicRules to virFirewall

Convert the nwfilter ebtablesRemoveBasicRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebiptablesTearOldRules to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 12:05:00 +0000 (12:05 +0000)]
Convert nwfilter ebiptablesTearOldRules to virFirewall

Convert the nwfilter ebiptablesTearOldRules method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert nwfilter ebiptablesAllTeardown to virFirewall
Daniel P. Berrange [Fri, 14 Mar 2014 11:53:06 +0000 (11:53 +0000)]
Convert nwfilter ebiptablesAllTeardown to virFirewall

Convert the nwfilter ebiptablesAllTeardown method to use the
virFirewall object APIs instead of creating shell scripts
using virBuffer APIs. This provides a performance improvement
through allowing direct use of firewalld dbus APIs and will
facilitate automated testing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert ebtables code over to use firewall APIs
Daniel P. Berrange [Fri, 7 Mar 2014 17:46:19 +0000 (17:46 +0000)]
Convert ebtables code over to use firewall APIs

Convert the virebtables.{c,h} files to use the new virFirewall
APIs for changing ebtables rules.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd test for converting network XML to iptables rules
Daniel P. Berrange [Thu, 20 Mar 2014 10:30:44 +0000 (10:30 +0000)]
Add test for converting network XML to iptables rules

Using the virCommand dry run capability, capture iptables rules
created by various network XML documents.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoReplace virNetworkObjPtr with virNetworkDefPtr in network platform APIs
Daniel P. Berrange [Wed, 19 Mar 2014 16:56:35 +0000 (16:56 +0000)]
Replace virNetworkObjPtr with virNetworkDefPtr in network platform APIs

The networkCheckRouteCollision, networkAddFirewallRules and
networkRemoveFirewallRules APIs all take a virNetworkObjPtr
instance, but only ever access the 'def' member. It thus
simplifies testing if the APIs are changed to just take a
virNetworkDefPtr instead

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert bridge driver over to use new firewall APIs
Daniel P. Berrange [Thu, 6 Mar 2014 17:01:13 +0000 (17:01 +0000)]
Convert bridge driver over to use new firewall APIs

Update the iptablesXXXX methods so that instead of directly
executing iptables commands, they populate rules in an
instance of virFirewallPtr. The bridge driver can thus
construct the ruleset and then invoke it in one operation
having rollback handled automatically.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce an object for managing firewall rulesets
Daniel P. Berrange [Mon, 4 Mar 2013 16:30:40 +0000 (16:30 +0000)]
Introduce an object for managing firewall rulesets

The network and nwfilter drivers both have a need to update
firewall rules. The currently share no code for interacting
with iptables / firewalld. The nwfilter driver is fairly
tied to the concept of creating shell scripts to execute
which makes it very hard to port to talk to firewalld via
DBus APIs.

This patch introduces a virFirewallPtr object which is able
to represent a complete sequence of rule changes, with the
ability to have multiple transactional checkpoints with
rollbacks. By formally separating the definition of the rules
to be applied from the mechanism used to apply them, it is
also possible to write a firewall engine that uses firewalld
DBus APIs natively instead of via the slow firewalld-cmd.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoPreserve error when tearing down nwfilter rules
Daniel P. Berrange [Mon, 31 Mar 2014 11:25:17 +0000 (12:25 +0100)]
Preserve error when tearing down nwfilter rules

When a VM fails to launch due to error creating nwfilter
rules, we must avoid overwriting the original error when
tearing down the partially created rules.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove two-stage construction of commands in nwfilter
Daniel P. Berrange [Tue, 25 Mar 2014 16:10:56 +0000 (16:10 +0000)]
Remove two-stage construction of commands in nwfilter

The nwfilter ebiptables driver will build up commands to run in
two phases. The first phase contains all of the command, except
for the '-A' part. Instead it has a '%c' placeholder, along with
a '%s' placeholder for a position arg. The second phase than
substitutes these placeholders. The only values ever used for
these substitutions though is '-A' and '', so it is entirely
pointless. Remove the second phase entirely, since it will make
it harder to convert to the new firewall APIs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMerge nwfilter createRuleInstance driver into applyNewRules
Daniel P. Berrange [Tue, 25 Mar 2014 13:44:50 +0000 (13:44 +0000)]
Merge nwfilter createRuleInstance driver into applyNewRules

The current nwfilter tech driver API has a 'createRuleInstance' method
which populates virNWFilterRuleInstPtr with a command line string
containing variable placeholders. The 'applyNewRules' method then
expands the variables and executes the commands. This split of
responsibility won't work when switching to the virFirewallPtr
APIs, since we can't just build up command line strings. This patch
this merges the functionality of 'createRuleInstance' into the
applyNewRules method.

The virNWFilterRuleInstPtr struct is changed from holding an array
of opaque pointers, into holding generic metadata about the rules
to be processed. In essence this is the result of taking a linked
set of virNWFilterDefPtr's and flattening the tree to get a list
of virNWFilterRuleDefPtr's. At the same time we must keep track of
any nested virNWFilterObjPtr instances, so that the locks are held
for the duration of the 'applyNewRules' method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoPush virNWFilterRuleInstPtr out of (eb|ip)tablesCreateRuleInstance
Daniel P. Berrange [Tue, 25 Mar 2014 10:32:55 +0000 (10:32 +0000)]
Push virNWFilterRuleInstPtr out of (eb|ip)tablesCreateRuleInstance

Later refactoring will change use of the virNWFilterRuleInstPtr struct.
Prepare for this by pushing use of the virNWFilterRuleInstPtr parameter
out of the ebtablesCreateRuleInstance and iptablesCreateRuleInstance
methods. Instead they simply string(s) with the constructed rule data.
The ebiptablesCreateRuleInstance method will make use of the
virNWFilterRuleInstPtr struct instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd helper methods for determining what protocol layer is used
Daniel P. Berrange [Tue, 25 Mar 2014 11:50:18 +0000 (11:50 +0000)]
Add helper methods for determining what protocol layer is used

Add virNWFilterRuleIsProtocol{Ethernet,IPv4,IPv6} helper methods
to avoid having to write a giant switch statements with many cases.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove nwfilter tech driver 'displayRuleInstance' callback
Daniel P. Berrange [Tue, 25 Mar 2014 11:38:16 +0000 (11:38 +0000)]
Remove nwfilter tech driver 'displayRuleInstance' callback

The 'displayRuleInstance' callback in the nwfilter tech driver
is never invoked, so can be deleted.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove nwfilter tech driver 'removeRules' callback
Daniel P. Berrange [Mon, 24 Mar 2014 17:05:42 +0000 (17:05 +0000)]
Remove nwfilter tech driver 'removeRules' callback

The 'removeRules' callback in the nwfilter tech driver is never
invoked, so can be deleted.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove pointless storage of var names in virNWFilterHashTable
Daniel P. Berrange [Mon, 24 Mar 2014 16:35:23 +0000 (16:35 +0000)]
Remove pointless storage of var names in virNWFilterHashTable

The virNWFilterHashTable struct contains a virHashTable and
then a 'char **names' field which keeps a copy of all the
hash keys. Presumably this was intended to record the ordering
of the hash keys. No code ever uses this and the ordering is
mangled whenever a variable is removed from the hash, because
the last element in the list is copied into the middle of the
list when shrinking the array.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove virDomainNetType parameter from nwfilter drivers
Daniel P. Berrange [Mon, 24 Mar 2014 12:27:03 +0000 (12:27 +0000)]
Remove virDomainNetType parameter from nwfilter drivers

The 'virDomainNetType' is unused in every impl of the
virNWFilterRuleCreateInstance driver method. Remove it
from the code to avoid the dependancy on the external
enum.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMove virNWFilterTechDriver struct out of nwfilter_conf.h
Daniel P. Berrange [Mon, 24 Mar 2014 12:32:37 +0000 (12:32 +0000)]
Move virNWFilterTechDriver struct out of nwfilter_conf.h

The virNWFilterTechDriver struct is nothing to do with the nwfilter
XML configuration. It stores data specific to the driver implementation
so should be in a header in the driver directory instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak on OOM in virNWFilterVarValueCreateSimpleCopyValue
Daniel P. Berrange [Tue, 8 Apr 2014 14:43:45 +0000 (15:43 +0100)]
Fix leak on OOM in virNWFilterVarValueCreateSimpleCopyValue

If virNWFilterVarValueCreateSimple fails with OOM, then
'val' will be leaked by virNWFilterVarValueCreateSimpleCopyValue

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Avoid overflow when setting migration speed on inactive domains
Jiri Denemark [Fri, 11 Apr 2014 09:24:51 +0000 (11:24 +0200)]
qemu: Avoid overflow when setting migration speed on inactive domains

Commit c4206d7 fixed the overflow for running domains. However, we need
a similar check when setting migration speed on inactive domains.

At first look, it may seem the check in c4206d7 is now redundant but
qemuDomainMigrateSetMaxSpeed is not the only caller of
qemuMonitorSetMigrationSpeed so we need to check the bandwidth in both
places.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoUse virFileFindResource to locate CPU map XML
Daniel P. Berrange [Thu, 24 Apr 2014 15:59:37 +0000 (16:59 +0100)]
Use virFileFindResource to locate CPU map XML

Replace use of cpuMapOverride with virFileFindResource
to locate CPU map from build dir.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate driver plugins
Daniel P. Berrange [Thu, 24 Apr 2014 15:45:49 +0000 (16:45 +0100)]
Use virFileFindResource to locate driver plugins

Replace virDriverModuleInitialize with virFileFindResource
usage.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate lock manager plugins
Daniel P. Berrange [Thu, 24 Apr 2014 15:45:49 +0000 (16:45 +0100)]
Use virFileFindResource to locate lock manager plugins

Replace virLockManagerSetPluginDir with virFileFindResource
usage.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate iohelper for fdstream
Nehal J Wani [Tue, 25 Mar 2014 08:23:15 +0000 (13:53 +0530)]
Use virFileFindResource to locate iohelper for fdstream

Instead of hardcoding LIBEXECDIR as the location of the libvirt_iohelper
binary, use virFileFindResource to optionally find it in the current
build directory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate parthelper for storage backend
Nehal J Wani [Tue, 25 Mar 2014 08:23:14 +0000 (13:53 +0530)]
Use virFileFindResource to locate parthelper for storage backend

Instead of hardcoding LIBEXECDIR as the location of the libvirt_parthelper
binary, use virFileFindResource to optionally find it in the current
build directory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate libvirt_lxc for capabilities
Nehal J Wani [Tue, 25 Mar 2014 08:23:13 +0000 (13:53 +0530)]
Use virFileFindResource to locate libvirt_lxc for capabilities

Instead of hardcoding LIBEXECDIR as the location of the libvirt_lxc
binary set in the LXC driver capabilities, use virFileFindResource
to optionally find it in the current build directory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoUse virFileFindResource to locate iohelper for virFileWrapperFdNew
Nehal J Wani [Tue, 25 Mar 2014 08:23:12 +0000 (13:53 +0530)]
Use virFileFindResource to locate iohelper for virFileWrapperFdNew

Instead of hardcoding LIBEXECDIR as the location of the libvirt_iohelper
binary, use virFileFindResource to optionally find it in the current
build directory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoActivate build dir overrides in libvirtd, virtlockd, virsh & tests
Daniel P. Berrange [Thu, 24 Apr 2014 14:57:36 +0000 (15:57 +0100)]
Activate build dir overrides in libvirtd, virtlockd, virsh & tests

Add calls to virFileActivateDirOverride so that the build dir
overrides are activated.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd helpers for resolving path to resources in build tree
Daniel P. Berrange [Thu, 24 Apr 2014 14:05:42 +0000 (15:05 +0100)]
Add helpers for resolving path to resources in build tree

Add virFileFindResource which will try to locate files
in the local build tree if the calling binary (eg libvirtd or
test suite) is being run from the build tree. The corresponding
virFileActivateDirOverride should be called at startup passing
in argv[0]. This will be examined for evidence of libtool magic
binary prefix / sub-directory in order to activate the override.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd test suite for viralloc APIs
Daniel P. Berrange [Tue, 8 Apr 2014 14:44:40 +0000 (15:44 +0100)]
Add test suite for viralloc APIs

In debugging a crash on OOM, I thought that the virInsert APIs
might be at fault, but couldn't isolate them as a cause. While
the viralloc APIs are used in many test suites, this is as a
side-effect, they are not directly tested :-)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd support for addressing backing stores by index
Jiri Denemark [Fri, 18 Apr 2014 12:35:33 +0000 (14:35 +0200)]
Add support for addressing backing stores by index

Each backing store of a given disk is associated with a unique index
(which is also formatted in domain XML) for easier addressing of any
particular backing store. With this patch, any backing store can be
addressed by its disk target and the index. For example, "vdc[4]"
addresses the backing store with index equal to 4 of the disk identified
by "vdc" target. Such shorthand can be used in any API in place for a
backing file path:

    virsh blockcommit domain vda --base vda[3] --top vda[2]

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agovirStorageFileChainLookup: Return virStorageSourcePtr
Jiri Denemark [Fri, 18 Apr 2014 13:25:19 +0000 (15:25 +0200)]
virStorageFileChainLookup: Return virStorageSourcePtr

Returning both virStorageSourcePtr and its path member does not make a
lot of sense.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemuDomainBlockCommit: Track virStorageSourcePtr for base
Jiri Denemark [Fri, 18 Apr 2014 12:44:51 +0000 (14:44 +0200)]
qemuDomainBlockCommit: Track virStorageSourcePtr for base

virStorageFileChainLookup is able to give use virStorageSourcePtr which
contains the pointer to its canonical path. Let's use a more general
virStorageSourcePtr instead of just canonical path.

Former base_canon maps to baseSource->path.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemuDomainBlockCommit: Don't track top_canon path separately
Jiri Denemark [Fri, 18 Apr 2014 12:38:49 +0000 (14:38 +0200)]
qemuDomainBlockCommit: Don't track top_canon path separately

virStorageFileChainLookup is able to give use virStorageSourcePtr which
contains the pointer to its canonical path. There's no need for the
caller to store both of them.

Former top_meta maps to topSource and top_canon maps to topSource->path.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agobuild: avoid 'index' as variable name
Eric Blake [Thu, 24 Apr 2014 21:41:47 +0000 (15:41 -0600)]
build: avoid 'index' as variable name

Once again, gcc 4.4.7 (hello RHEL) rears its ugly head:

conf/domain_conf.c: In function 'virDomainDiskBackingStoreFormat':
conf/domain_conf.c:14940: error: declaration of 'index' shadows a global declaration [-Wshadow]
/usr/include/string.h:489: error: shadowed declaration is here [-Wshadow]

* src/conf/domain_conf.c (virDomainDiskBackingStoreFormat): Pacify
older gcc.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: document nmdm type console
Roman Bogorodskiy [Mon, 21 Apr 2014 13:16:58 +0000 (17:16 +0400)]
docs: document nmdm type console

* Add nmdm type device to domain format documnetation
* Add a section about nmdm console usage to the bhyve driver
  documentation

11 years agoqemu: don't check for backing chains for formats w/o snapshot support
Martin Kletzander [Wed, 16 Apr 2014 15:31:50 +0000 (17:31 +0200)]
qemu: don't check for backing chains for formats w/o snapshot support

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1019926
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=868673

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agotests: Test backing store XML formatting and parsing
Jiri Denemark [Thu, 17 Apr 2014 13:37:51 +0000 (15:37 +0200)]
tests: Test backing store XML formatting and parsing

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agotests: More output options for xml2xml tests
Jiri Denemark [Thu, 17 Apr 2014 13:23:21 +0000 (15:23 +0200)]
tests: More output options for xml2xml tests

So far, qemuxml2xml test was only able to check if the result matches
the original or the appropriate XML in qemuxml2xmloutdata regardless on
flags used to format the XML. Since the result can be different
depending on VIR_DOMAIN_XML_INACTIVE flag being used or not, this patch
adds support for qemuxml2xmlout-%s-active.xml and
qemuxml2xmlout-%s-inactive.xml output files. If the file specific to the
flag used exists, it is used in preference to the generic
qemuxml2xmlout-%s.xml file when reading the expected output.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: Format and parse backing chains in domain XML
Jiri Denemark [Thu, 17 Apr 2014 13:22:32 +0000 (15:22 +0200)]
conf: Format and parse backing chains in domain XML

This patch implements formating and parsing code for the backing store
schema defined and documented by the previous patch.

This patch does not aim at providing full persistent storage of disk
backing chains yet. The formatter is supposed to provide the backing
chain detected when starting a domain and thus it is not formatted into
an inactive domain XML. The parser is implemented mainly for the purpose
of testing the XML generated by the formatter and thus it does not
distinguish between no backingStore element and an empty backingStore
element. This will have to change once we fully implement support for
user-supplied backing chains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: Output disk backing store details in domain XML
Jiri Denemark [Wed, 16 Apr 2014 13:28:10 +0000 (15:28 +0200)]
conf: Output disk backing store details in domain XML

The XML for quite a longish backing chain is shown below:

  <disk type='network' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source protocol='nbd' name='bar'>
      <host transport='unix' socket='/var/run/nbdsock'/>
    </source>
    <backingStore type='block' index='1'>
      <format type='qcow2'/>
      <source dev='/dev/HostVG/QEMUGuest1'/>
      <backingStore type='file' index='2'>
        <format type='qcow2'/>
        <source file='/tmp/image2.qcow'/>
        <backingStore type='file' index='3'>
          <format type='qcow2'/>
          <source file='/tmp/image3.qcow'/>
          <backingStore type='file' index='4'>
            <format type='qcow2'/>
            <source file='/tmp/image4.qcow'/>
            <backingStore type='file' index='5'>
              <format type='qcow2'/>
              <source file='/tmp/image5.qcow'/>
              <backingStore type='file' index='6'>
                <format type='raw'/>
                <source file='/tmp/Fedora-17-x86_64-Live-KDE.iso'/>
                <backingStore/>
              </backingStore>
            </backingStore>
          </backingStore>
        </backingStore>
      </backingStore>
    </backingStore>
    <target dev='vdb' bus='virtio'/>
  </disk>

Various disk types and formats can be mixed in one chain. The
<backingStore/> empty element marks the end of the backing chain and it
is there mostly for future support of parsing the chain provided by a
user. If it's missing, we are supposed to probe for the rest of the
chain ourselves, otherwise complete chain was provided by the user. The
index attributes of backingStore elements can be used to unambiguously
identify a specific part of the image chain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoFix pci bus naming for PPC
Daniel P. Berrange [Wed, 23 Apr 2014 15:35:37 +0000 (16:35 +0100)]
Fix pci bus naming for PPC

Recent discussions around naming of 'pci' vs 'pci.0' for PPC
made me go back and look at the PPC emulator in every historical
version of QEMU since 1.0. The results were worse than I imagined.
This patch adds the logic required to make libvirt work with PPC
correctly with naming variations across all versions & machine
types.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoutil: storage: Invert the way recursive metadata retrieval works
Peter Krempa [Fri, 18 Apr 2014 12:49:54 +0000 (14:49 +0200)]
util: storage: Invert the way recursive metadata retrieval works

To avoid having the root of a backing chain present twice in the list we
need to invert the working of virStorageFileGetMetadataRecurse.

Until now the recursive worker created a new backing chain element from
the name and other information passed as arguments. This required us to
pass the data of the parent in a deconstructed way and the worker
created a new entry for the parent.

This patch converts this function so that it just fills in metadata
about the parent and creates a backing chain element from those. This
removes the duplication of the first element.

To avoid breaking the test suite, virstoragetest now calls a wrapper
that creates the parent structure explicitly and pre-fills it with the
test data with same function signature as previously used.

11 years agoutil: virstoragefile: Don't mangle data stored about directories
Peter Krempa [Fri, 18 Apr 2014 08:07:41 +0000 (10:07 +0200)]
util: virstoragefile: Don't mangle data stored about directories

Don't remove detected metadata about directory based storage volumes.

11 years agostorage: Move disk->backingChain to the recursive disk->src.backingStore
Peter Krempa [Thu, 17 Apr 2014 21:20:22 +0000 (23:20 +0200)]
storage: Move disk->backingChain to the recursive disk->src.backingStore

Switch over to storing of the backing chain as a recursive
virStorageSource structure.

This is a string based move. Currently the first element will be present
twice in the backing chain as currently the retrieval function stores
the parent in the newly detected chain. This will be fixed later.

11 years agoutil: virstoragefile: Rename backingMeta to backingStore
Peter Krempa [Thu, 17 Apr 2014 20:46:18 +0000 (22:46 +0200)]
util: virstoragefile: Rename backingMeta to backingStore

To conform with the naming of the planned XML output rename the metadata
variable name.

s/backingMeta/backingStore/g

11 years agoutil: virstorage: Kill struct virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 14:15:45 +0000 (16:15 +0200)]
util: virstorage: Kill struct virStorageFileMetadata

Remove the now unused pieces of the structure.

11 years agomaint: Switch over from struct virStorageFileMetadata to virStorageSource
Peter Krempa [Thu, 17 Apr 2014 14:05:16 +0000 (16:05 +0200)]
maint: Switch over from struct virStorageFileMetadata to virStorageSource

Replace the old structure with the new one. This change is a trivial
name change operation (along with change of the freeing function).

11 years agoutil: storagefile: Add fields from virStorageMetadata to virStorageSource
Peter Krempa [Thu, 17 Apr 2014 14:04:33 +0000 (16:04 +0200)]
util: storagefile: Add fields from virStorageMetadata to virStorageSource

Add the required fields that are missing from the new structure that
will allow us to switch the storage file metadata code entirely to the
new structure.

Add "relPath" and "relDir" and the raw backing store name. Also allow
creating linked lists of virStorageSourcePtrs to express backing chains.

11 years agoutil: storagefile: Add function to free a virStorageSourcePtr
Peter Krempa [Mon, 7 Apr 2014 15:58:08 +0000 (17:58 +0200)]
util: storagefile: Add function to free a virStorageSourcePtr

Add a free function as some parts of the code will allocate the
structure.

11 years agovirstoragefile: Kill "backingStore" field from virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 13:21:24 +0000 (15:21 +0200)]
virstoragefile: Kill "backingStore" field from virStorageFileMetadata

Remove the obsolete field replaced by data in "path".

The testsuite requires tweaking as the name of the backing file is now
stored one layer deeper in the backing chain linked list.

11 years agoutil: virstoragefile: Don't use "backingStore" directly
Peter Krempa [Thu, 17 Apr 2014 12:09:58 +0000 (14:09 +0200)]
util: virstoragefile: Don't use "backingStore" directly

As a temporary step to allow killing of the "backingStore" field of
struct virStorageFileMetadata the recursive metadata retrieval function
will be converted not to use the field in the lookup process.

11 years agoutil: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 11:47:41 +0000 (13:47 +0200)]
util: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata

As for the previous patch, this change is needed to achieve
compatibility with all the existing code, where we expect a fully
qualified path of local files to be present.

11 years agoutil: storage: Rename "path" to "relPath" in virStorageFileMetadata
Peter Krempa [Thu, 17 Apr 2014 11:36:59 +0000 (13:36 +0200)]
util: storage: Rename "path" to "relPath" in virStorageFileMetadata

To allow future change of virStorageFileMetadata to virStorageSource we
need to store a full path in the "path" variable as rest of the code
expects it to be a full path. Rename the "path" field to "relPath" to
keep tracking the info but allowing a real "path" field.

11 years agostorage: util: Clean up arguments of virStorageFileGetMetadataInternal
Peter Krempa [Tue, 15 Apr 2014 12:25:10 +0000 (14:25 +0200)]
storage: util: Clean up arguments of virStorageFileGetMetadataInternal

Avoid passing lot of arguments into guts of metadata retrieval to fill
the actual structure. Temporarily fill the structure before passing it
down to the actual metadata extractor.

This will later help the inversion of the steps taken to extract the
metadata so that this function can be fully converted to
virStorageSource as the data struct.

This patch also fixes regression when starting a gluster storage pool
where the volumes don't have local representation so that the
canonicalization of the volume's file name failed. Broken by commit
79f11b35

11 years agoutil: storage: Move checking of the actual backing image to the worker
Peter Krempa [Wed, 16 Apr 2014 13:44:06 +0000 (15:44 +0200)]
util: storage: Move checking of the actual backing image to the worker

Move the code checking the presence of the backing file to the recursive
worker function instead of the metadata parser. The recursive worker
will later be changed to parse more than just local files and this
change will help the separation.

11 years agoutil: storage: Remove obsolete argument virStorageFileGetMetadataInternal
Peter Krempa [Tue, 15 Apr 2014 12:28:10 +0000 (14:28 +0200)]
util: storage: Remove obsolete argument virStorageFileGetMetadataInternal

As we already pass the whole structure down the call path there's no
need to return some stuff in a separate argument. Remove the argument
and tweak callers to avoid breaking semantics.

virStorageFileGetMetadataFromBuf will be refactored later along with the
storage driver.

11 years agoutil: storagefile: Always store raw backing name in the metadata
Peter Krempa [Mon, 14 Apr 2014 13:49:28 +0000 (15:49 +0200)]
util: storagefile: Always store raw backing name in the metadata

Don't use the backingStoreRaw as a indication of broken chains. Fill it
always and tweak the broken image chain detector to avoid changing the
semantics.

The new semantics to detect a broken chain is the presence of string in
backingStoreRaw but the lack of the backing chain metadata structure in
the chain.

Now that the raw backing store name is always filled there's no need to
pass the raw name variable separately to fill in case the backing is not
a file. Tweak the function so that it can handle a NULL in that case.

11 years agoqemu: unexport qemuDiskChainCheckBroken
Peter Krempa [Tue, 15 Apr 2014 08:20:07 +0000 (10:20 +0200)]
qemu: unexport qemuDiskChainCheckBroken

The function isn't used in any other source file. Move it so that it
doesn't need a declaration.

11 years agoDocument behavior of setvcpus during guest boot
Ján Tomko [Wed, 23 Apr 2014 11:01:24 +0000 (13:01 +0200)]
Document behavior of setvcpus during guest boot

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

The hotplugged vcpus could fail to show up in the guest if
they were added during boot, see:
https://bugzilla.redhat.com/show_bug.cgi?id=807508

Also change arbitrary to arbitrarily.

11 years agoSave domain status after cpu hotplug
Ján Tomko [Wed, 23 Apr 2014 10:43:24 +0000 (12:43 +0200)]
Save domain status after cpu hotplug

The live change of vcpus was not reflected in the domain status
xml and it got lost during libvirtd restart.

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

11 years agobhyve: bhyveDomainDefineXML fixes
Roman Bogorodskiy [Mon, 21 Apr 2014 16:15:26 +0000 (20:15 +0400)]
bhyve: bhyveDomainDefineXML fixes

- do not lose new definition for an active domain
- do not leak oldDef
- do not set dom->id if virDomainSaveConfig() fails
- do not call virObjectUnlock(vm) if vm is NULL

11 years agoPPC64 prefers to set pci-ohci controller as default USB controller.
Li Zhang [Wed, 23 Apr 2014 11:30:42 +0000 (12:30 +0100)]
PPC64 prefers to set pci-ohci controller as default USB controller.
Currently, libvirt is using legacy USB controller as default. There
are problems with VGA which can't work correctly with USB Keyboard and
USB Mouse.

While providing -nodefaults, ppc64 should be specifying the usb
controller explicitly in place of using the legacy
controller(-usb). Qemu spapr initialization code when sees "-usb" adds a
USB Keyboard and USB Mouse by default. And libvirt has added a USB
keyboard and USB mouse.

A recent fix in the in qemu VGA code uncoverd this problem, which
resulted in addition of extra keyboard and mouse to the qemu machine.

This patch is to set pci-ohci as USB default controller.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoFix error for out of range vcpu in qemuDomainPinVcpuFlags
Ján Tomko [Tue, 22 Apr 2014 12:30:58 +0000 (14:30 +0200)]
Fix error for out of range vcpu in qemuDomainPinVcpuFlags

Changes:
error: invalid argument: vcpu number out of range 2 > 2
to slightly less confusing:
error: invalid argument: vcpu number out of range 2 > 1

11 years agoMake virDomainVcpuPinDel return void
Ján Tomko [Tue, 22 Apr 2014 12:24:47 +0000 (14:24 +0200)]
Make virDomainVcpuPinDel return void

Before, it only returned -1 on failure to shrink the array.
Since the switch to VIR_DELETE_ELEMENT in commit 2133441,
it returns either 0 or 0.

11 years agoProperly free vcpupin info for unplugged CPUs
Ján Tomko [Tue, 22 Apr 2014 12:11:54 +0000 (14:11 +0200)]
Properly free vcpupin info for unplugged CPUs

Remove the pointer from def->cputune.vcpupin after unplugging
the CPU and also free the bitmap contained in the structure
by calling virDomainVcpuPinDel instead of VIR_FREE.

Introduced by commit 0df1a79.

This makes virDomainLookupVcpuPin redundant.

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

11 years agoFix typos in src/*
Nehal J Wani [Sun, 20 Apr 2014 20:07:46 +0000 (01:37 +0530)]
Fix typos in src/*

Fix minor typos in source comments

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: update to latest gnulib
Eric Blake [Mon, 21 Apr 2014 20:52:06 +0000 (14:52 -0600)]
maint: update to latest gnulib

Among other patches, Natanael Copa contributed a fix for
pyshmem_available when using musl libc that directly affects
libvirt.

* .gnulib: Update to latest, in part for musl libc compat.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobhyve: domainCreateXML
Wojciech Macek [Thu, 10 Apr 2014 09:06:38 +0000 (11:06 +0200)]
bhyve: domainCreateXML

Implement bhyveDomainCreateXML function.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
11 years agodocs: document that vfio is default for hostdev networks too
Laine Stump [Wed, 16 Apr 2014 09:23:02 +0000 (12:23 +0300)]
docs: document that vfio is default for hostdev networks too

When the default was changed from kvm to vfio, the documentation for
hostdev and interface was changed, but the documentation in <network>
was forgotten.

Also document when the default was changed from "always kvm" to "vfio
if available, else kvm" (1.0.5).

11 years agoRemove QEMU_CAPS_MACHINE_USB_OPT from ComputeCmdFlags
Ján Tomko [Thu, 17 Apr 2014 14:54:02 +0000 (16:54 +0200)]
Remove QEMU_CAPS_MACHINE_USB_OPT from ComputeCmdFlags

The version check is for >=1.3.0, but ComputeCmdFlags
is only called for QEMU <1.2.0.

11 years agoOnly set QEMU_CAPS_NO_HPET on x86
Ján Tomko [Thu, 17 Apr 2014 14:50:43 +0000 (16:50 +0200)]
Only set QEMU_CAPS_NO_HPET on x86

QEMU only supports it on x86, but we've been assuming it for
all QEMUs when doing QMP capability detection.

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

11 years agoFix Memory Leak in virStorageFileGetMetadataRecurse()
Nehal J Wani [Thu, 17 Apr 2014 23:15:21 +0000 (04:45 +0530)]
Fix Memory Leak in virStorageFileGetMetadataRecurse()

While running virstoragetest, valgrind pointed out the following
memory leak:

==8142== 2 bytes in 1 blocks are definitely lost in loss record 1 of 92
==8142==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==8142==    by 0x4E7B53E: mdir_name (dirname-lgpl.c:78)
==8142==    by 0x4CBE2B0: virStorageFileGetMetadataInternal (virstoragefile.c:595)
==8142==    by 0x4CBE651: virStorageFileGetMetadataFromFDInternal (virstoragefile.c:1086)
==8142==    by 0x4CBEEB4: virStorageFileGetMetadataRecurse (virstoragefile.c:1175)
==8142==    by 0x4CBF1DE: virStorageFileGetMetadata (virstoragefile.c:1270)
==8142==    by 0x4028AD: testStorageChain (virstoragetest.c:275)
==8142==    by 0x407B91: virtTestRun (testutils.c:201)
==8142==    by 0x4039D7: mymain (virstoragetest.c:534)
==8142==    by 0x40830D: virtTestMain (testutils.c:789)
==8142==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)

...62 times

11 years agoqemu: Unlock the NWFilter update lock by leaving via the cleanup label
Stefan Berger [Thu, 17 Apr 2014 10:30:08 +0000 (06:30 -0400)]
qemu: Unlock the NWFilter update lock by leaving via the cleanup label

Fix a locking problem by leaving the function via the cleanup label.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agostorage: netfs: Handle backend errors
John Ferlan [Wed, 9 Apr 2014 16:17:39 +0000 (12:17 -0400)]
storage: netfs: Handle backend errors

Commit id '18642d10' caused a virt-test regression for NFS backend
storage error path checks when running the command:

    'virsh find-storage-pool-sources-as netfs Unknown  '

when the host did not have Gluster installed. Prior to the commit,
the test would fail with the error:

    error: internal error: Child process (/usr/sbin/showmount --no-headers
    --exports Unknown) unexpected exit status 1: clnt_create: RPC: Unknown host

After the commit, the error would be ignored, the call would succeed,
and an empty list of pool sources returned. This was tucked into the
commit message as an expected outcome.

When the target host does not have a GLUSTER_CLI this is a regression
over the previous release. Furthermore, even if Gluster CLI was present,
but had a failure to get devices, the API would return a failure even if
the NFS backend had found devices.

Modify the logic to return failure when the NFS backend check fails and
there's no GLUSTER_CLI or when both backend checks fail.

If either returns success and GLUSTER_CLI is defined, then fetch and return
a list of source devices even if it's empty

11 years agoconf: fix omission of <driver> in domain dumpxml
Eric Blake [Mon, 14 Apr 2014 22:54:19 +0000 (16:54 -0600)]
conf: fix omission of <driver> in domain dumpxml

I noticed that depending on the <driver> attributes the user passed
in, the output may omit the <driver> element altogether.  For example,
the rerror_policy has had this problem since commit 4bb4109 in Oct
2011.  But in adding testsuite coverage to expose it, I found another
problem: the C code is just fine without a driver name, but the
XML validator required either a name or a cache mode.

* src/conf/domain_conf.c (virDomainDiskDefFormat): Update
conditional.
* docs/schemas/domaincommon.rng (diskDriver): Simplify.
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-copy-on-read.xml:
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-copy-on-read.args:
New files.
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml:
Enhance test.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml:
Likewise.
* tests/qemuxml2argvtest.c (mymain): New test.
* tests/qemuxml2xmltest.c (mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: split <disk> schema into more pieces
Eric Blake [Mon, 14 Apr 2014 22:54:16 +0000 (16:54 -0600)]
conf: split <disk> schema into more pieces

To make <disk> schema more maintainable and to allow for moving the
pieces to a common file in the future. It relies on the ability to
override definitions as part of an include, set up in the previous
patch.

The diff is a bit hard to read, because it mixes reindentation
with refactoring; 'git diff -b --patience' may help.

* docs/schemas/domaincommon.rng (disk): Refactor into pieces.
(diskSource, diskSourceFile, diskSourceBlock, diskSourceDir)
(diskSourceVolume: New defines.
(diskSourceNetwork): Revise scope.
* docs/schemas/domainsnapshot.rng (disksnapshot): Adjust.
* tests/domainsnapshotxml2xmlin/disk-seclabel-invalid.xml,
tests/domainsnapshotxml2xmlin/disk-network-seclabel-invalid.xml: New
tests to check seclabel is forbidden in domain snapshot by schema.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: set up for per-grammar overrides in schemas
Eric Blake [Mon, 14 Apr 2014 22:54:15 +0000 (16:54 -0600)]
conf: set up for per-grammar overrides in schemas

This patch is my first experience playing with nested grammars,
as documented in http://relaxng.org/tutorial-20011203.html#IDA3PZR.
I plan on doing more overrides in order to make the RelaxNG
grammar mirror the C code refactoring into a common
virStorageSource, but where different clients of that source do
not support the same subset of functionality.  By starting with
something fairly easy to validate, I can make sure my later
patches will be possible.

This patch adds a use of the no-op <ref
name='sourceStartupPolicy'/> to the disksnapshot definition, so
that the snapshot version of a type='file' <source> more closely
resembles the version in domaincommon.  A future patch will merge
the two files into using a common define, but this patch is
sufficient for testing that adding <source
startupPolicy='optional'/> in any of the
tests/domainsnapshotxml2xmlin/*.xml files still gets rejected
unless it occurs within the <domain> subelement, because the
definition of startupPolicy is empty outside of domain.rng.

* docs/schemas/storagecommon.rng (storageStartupPolicy)
(storageSourceExtra): Create no-op defaults.
* docs/schemas/domainsnapshot.rng (domain): Use nested grammar
to avoid restricting <domain>.
(storageSourceExtra): Create new override.
(disksnapshot): Access overrides through common names.
* docs/schemas/domaincommon.rng (disk): Access overrides through
common names.
* docs/schemas/domain.rng (storageStartupPolicy)
(storageSourceExtra): Create new overrides.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: restrict external snapshots to backing store formats
Eric Blake [Mon, 14 Apr 2014 22:54:14 +0000 (16:54 -0600)]
conf: restrict external snapshots to backing store formats

Domain snapshots should only permit an external snapshot into
a storage format that permits a backing chain, since the new
snapshot file necessarily must be backed by the existing file.
The C code for the qemu driver is a little bit stricter in
currently enforcing only qcow2 or qed, but at the XML parser
level, including virt-xml-validate, it is fairly easy to
enforce that a user can't request a 'raw' external snapshot.

* docs/schemas/storagecommon.rng (storageFormat): Split out...
(storageFormatBacking): ...new sublist.
* docs/schemas/domainsnapshot.rng (disksnapshotdriver): Use new
type.
* src/util/virstoragefile.h (virStorageFileFormat): Rearrange for
easier code management.
* src/util/virstoragefile.c (virStorageFileFormat, fileTypeInfo):
Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML): Use
new marker to limit selection of formats.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: move storage formats to common RNG file
Eric Blake [Mon, 14 Apr 2014 22:54:13 +0000 (16:54 -0600)]
conf: move storage formats to common RNG file

We had incomplete RelaxNG support for storage formats listed
in virstoragefile.h: commit 027bf2e added 'vdi' but forgot
to update the <volume> and <domain> xml lists; the <volume>
list was also missing 'fat' and 'vhd'.  Maintaining two lists
is a recipe for them getting out of sync, so make the list
common so that both contexts benefit the next time we add a
format in a single location.

* docs/schemas/domaincommon.rng (storageFormat): Move...
* docs/schemas/storagecommon.rng: ...here, and add vdi.
* docs/schemas/storagevol.rng (formatfile): Use common list.

Signed-off-by: Eric Blake <eblake@redhat.com>