]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
11 years agoconf: better <disk> interleaving in schema
Eric Blake [Mon, 14 Apr 2014 22:54:12 +0000 (16:54 -0600)]
conf: better <disk> interleaving in schema

In general, we try to make virt-xml-validate tolerant of input
elements in any order when possible.  However, as written, the
RNG grammar did not permit <source> unless there was an explicit
type= attribute (even though the C code manages just fine by
defaulting to type='file').  After making the attribute optional
on the 'file' branch, I noticed that the use of diskspec was now
redundant with the branch when no <source> was supplied.

View this patch with 'git diff -b' for a better picture of the
schema change.

* docs/schemas/domaincommon.rng (disk): Hoist 'diskspec' out of
choice, make type='file' default, and still preserve interleave.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool.xml:
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-discard.xml:
New files.
* tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml:
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.xml:
Reorder XML.
* tests/qemuxml2xmltest.c (mymain): Cover new files.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix virsystemdtest without SYSTEMD_DAEMON
Ján Tomko [Mon, 14 Apr 2014 17:45:47 +0000 (19:45 +0200)]
Fix virsystemdtest without SYSTEMD_DAEMON

Commit 4897698 fixed the build without dbus by only building
the virSystemdPMSupportTarget with SYSTEMD_DAEMON.

Introduce a virDBusMessageUnref wrapper for dbus_message_unref
to let virsystemd.c build without dbus, while still allowing
virsystemdtest to run without SYSTEM_DAEMON.

11 years agobuild: Don't use code with dbus_message_unref when built without dbus
Martin Kletzander [Mon, 14 Apr 2014 08:50:42 +0000 (10:50 +0200)]
build: Don't use code with dbus_message_unref when built without dbus

In order to do that, virNodeSuspendSupportsTargetPMUtils() and
virSystemdPMSupportTarget() are created even when pm-utils and dbus
are compiled out, respectively, but in that case returning -2 meaning
"unavailable" (this return code was already used for unavailability
before).  Error is reported in virNodeSuspendSupportsTarget() only if
both functions returned -2, otherwise the error (or success) is properly
propagated up the stack.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoconf: create common storage RNG grammar file
Eric Blake [Sat, 12 Apr 2014 01:33:45 +0000 (19:33 -0600)]
conf: create common storage RNG grammar file

Having two tiny files with a couple definitions didn't make
as much sense as one common file, especially since I plan to
add more definitions and use it in more places.

* docs/schemas/storageencryption.rng: Merge this...
* docs/schemas/storagefilefeatures.rng: ...and this, into...
* docs/schemas/storagecommon.rng: ...this new file.
* docs/schemas/Makefile.am (schema_DATA): Reflect renames.
* docs/schemas/storagevol.rng: Likewise.
* docs/schemas/domaincommon.rng: Likewise.
* libvirt.spec.in: Likewise.
* mingw-libvirt.spec.in: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: Avoid overflow when setting migration speed
Jiri Denemark [Fri, 11 Apr 2014 09:24:51 +0000 (11:24 +0200)]
qemu: Avoid overflow when setting migration speed

When passing migration bandwidth to QEMU, we multiply it by 1024 * 1024
to convert the speed to B/s and the result still needs to fit in
int64_t.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: delete internal directory field
Eric Blake [Thu, 10 Apr 2014 03:22:27 +0000 (21:22 -0600)]
conf: delete internal directory field

Another field no longer needed, getting us one step closer to
merging virStorageFileMetadata and virStorageSource.

* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileGetMetadataFromFDInternal): Alter signature.
(virStorageFileFreeMetadata, virStorageFileGetMetadataFromBuf)
(virStorageFileGetMetadataFromFD): Adjust clients.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: tweak chain lookup internals
Eric Blake [Fri, 11 Apr 2014 03:44:45 +0000 (21:44 -0600)]
conf: tweak chain lookup internals

Thanks to the testsuite, I feel quite confident that this rewrite
is correct; it gives the same results for all cases except for one.
I can make the argument that _that_ case was a pre-existing bug:
when looking up relative names, the lookup is supposed to be
pegged to the directory that contains the parent qcow2 file.  Thus,
this resolves the fixme first mentioned in commit 367cd69 (even
though I accidentally removed the fixme comment early in 74430fe).

* src/util/virstoragefile.c (virStorageFileChainLookup): Depend on
new rather than old fields.
* tests/virstoragetest.c (mymain): Adjust test to match fix.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: drop redundant parameter to chain lookup
Eric Blake [Sat, 12 Apr 2014 04:08:07 +0000 (22:08 -0600)]
conf: drop redundant parameter to chain lookup

The original chain lookup code had to pass in the starting name,
because it was not available in the chain.  But now that we have
added fields to the struct, this parameter is redundant.

* src/util/virstoragefile.h (virStorageFileChainLookup): Alter
signature.
* src/util/virstoragefile.c (virStorageFileChainLookup): Adjust
handling of top of chain.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Adjust caller.
* tests/virstoragetest.c (testStorageLookup, mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: report error on chain lookup failure
Eric Blake [Fri, 11 Apr 2014 01:03:01 +0000 (19:03 -0600)]
conf: report error on chain lookup failure

The chain lookup function was inconsistent on whether it left
a message in the log when looking up a name that is not found
on the chain (leaving a message for OOM or if name was
relative but not part of the chain), and could litter the log
even when successful (when name was relative but deep in the
chain, use of virFindBackingFile early in the chain would complain
about a file not found).  It's easier to make the function
consistently emit a message exactly once on failure, and to let
all callers rely on the clean semantics.

* src/util/virstoragefile.c (virStorageFileChainLookup): Always
report error on failure.  Simplify relative lookups.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Avoid
overwriting error.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: new virFileRelLinkPointsTo function
Eric Blake [Thu, 10 Apr 2014 23:36:06 +0000 (17:36 -0600)]
util: new virFileRelLinkPointsTo function

When checking if two filenames point to the same inode (whether
by hardlink or symlink), sometimes one of the names might be
relative.  This convenience function makes it easier to check.

* src/util/virfile.h (virFileRelLinkPointsTo): New prototype.
* src/util/virfile.c (virFileRelLinkPointsTo): New function.
* src/libvirt_private.syms (virfile.h): Export it.
* src/xen/xm_internal.c (xenXMDomainGetAutostart): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: test backing chain lookup
Eric Blake [Thu, 10 Apr 2014 19:56:57 +0000 (13:56 -0600)]
conf: test backing chain lookup

I realized that we had no good test coverage of looking up a
name from within a backing chain, even though code like
block-commit is relying on it.

* tests/virstoragetest.c (testStorageLookup): New function.
(mymain): New tests.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoIntroduce --without-pm-utils to get rid of pm-is-supported dependency
Cédric Bosdonnat [Fri, 11 Apr 2014 07:20:48 +0000 (09:20 +0200)]
Introduce --without-pm-utils to get rid of pm-is-supported dependency

This uses the dbus api of systemd to check the power management
capabilities of the node.

11 years agotests: drop dead code from argv2xml and xml2xml
Eric Blake [Fri, 11 Apr 2014 18:51:00 +0000 (12:51 -0600)]
tests: drop dead code from argv2xml and xml2xml

Noticed while tweaking the RelaxNG grammar for <disk> elements.

* tests/qemuxml2xmloutdata/qemuxml2xmlout-numad-static-vcpu-no-numatune.xml:
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-cdrom-empty.xml:
Drop unused files.
* tests/qemuargv2xmltest.c (testInfo, DO_TEST_FULL): Drop unused
field.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobhyve: fix domain management
Wojciech Macek [Wed, 9 Apr 2014 05:52:11 +0000 (07:52 +0200)]
bhyve: fix domain management

When domain is not persistent, it should be forgotten upon destroying.

11 years agoconf: delete useless backingStoreFormat field
Eric Blake [Thu, 10 Apr 2014 02:37:16 +0000 (20:37 -0600)]
conf: delete useless backingStoreFormat field

Drop another redundant field from virStorageFileMetadata.

* src/util/virstoragefile.h (_virStorageFileMetadata): Drop
field.
* src/util/virstoragefile.c
(virStorageFileGetMetadataFromFDInternal)
(virStorageFileGetMetadataFromFD)
(virStorageFileGetMetadataRecurse): Adjust callers.
* tests/virstoragetest.c (_testFileData, testStorageChain)
(mymain): Simplify test.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: return backing information separately from metadata
Eric Blake [Thu, 10 Apr 2014 01:49:07 +0000 (19:49 -0600)]
conf: return backing information separately from metadata

A couple pieces of virStorageFileMetadata are used only while
collecting information about the chain, and don't need to
live permanently in the struct.  This patch refactors external
callers to collect the information separately, so that the
next patch can remove the fields.

* src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
Alter signature.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
Likewise.
(virStorageFileGetMetadataFromFDInternal): Adjust callers.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.

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