]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoqemu: track quiesced status in qemuDomainSnapshotFSFreeze
Tomoki Sekiyama [Fri, 2 May 2014 00:06:01 +0000 (20:06 -0400)]
qemu: track quiesced status in qemuDomainSnapshotFSFreeze

Adds 'quiesced' status into qemuDomainObjPrivate that tracks whether
FSFreeze is requested in the domain.

It modifies error code from qemuDomainSnapshotFSFreeze and
qemuDomainSnapshotFSThaw, so that a caller can know whether the command is
actually sent to the guest agent. If the error is caused before sending a
freeze command, a counterpart thaw command shouldn't be sent either, not to
confuse fsfreeze status tracking.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoremote: Implement virDomainFSFreeze and virDomainFSThaw
Tomoki Sekiyama [Fri, 2 May 2014 00:05:54 +0000 (20:05 -0400)]
remote: Implement virDomainFSFreeze and virDomainFSThaw

New rules are added in fixup_name in gendispatch.pl to keep the name
FSFreeze and FSThaw. This adds a new ACL permission 'fs_freeze',
which is also applied to VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoIntroduce virDomainFSFreeze() and virDomainFSThaw() public API
Tomoki Sekiyama [Fri, 2 May 2014 00:05:48 +0000 (20:05 -0400)]
Introduce virDomainFSFreeze() and virDomainFSThaw() public API

These will freeze and thaw filesystems within guest specified by
@mountpoints parameters. The parameters can be NULL and 0, then all
mounted filesystems are frozen or thawed. @flags parameter, which are
currently not used, is for future extensions.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoudev: consider the device a CDROM when ID_CDROM=1
Giuseppe Scrivano [Wed, 23 Apr 2014 10:42:01 +0000 (12:42 +0200)]
udev: consider the device a CDROM when ID_CDROM=1

Some CDROM devices are reported by udev to have an ID_TYPE="generic"
thus it is necessary to check if ID_CDROM is present.

As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will
enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the
udevKludgeStorageType heuristic.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: update README-hacking
Chen Hanxiao [Tue, 6 May 2014 07:02:29 +0000 (15:02 +0800)]
docs: update README-hacking

We don't have a "README-valgrind" file.
So remove related description.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirdbus: Make virDBusCall static
Cole Robinson [Sat, 3 May 2014 19:28:08 +0000 (15:28 -0400)]
virdbus: Make virDBusCall static

11 years agovirerror: Fix an error message typo
Cole Robinson [Sat, 3 May 2014 19:36:15 +0000 (15:36 -0400)]
virerror: Fix an error message typo

11 years agoLSN-2014-0003: Don't expand entities when parsing XML
Daniel P. Berrange [Tue, 15 Apr 2014 10:20:29 +0000 (11:20 +0100)]
LSN-2014-0003: Don't expand entities when parsing XML

If the XML_PARSE_NOENT flag is passed to libxml2, then any
entities in the input document will be fully expanded. This
allows the user to read arbitrary files on the host machine
by creating an entity pointing to a local file. Removing
the XML_PARSE_NOENT flag means that any entities are left
unchanged by the parser, or expanded to "" by the XPath
APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agospec: Don't install nonexistent test_libvirt_lockd.aug
Jiri Denemark [Tue, 6 May 2014 07:40:49 +0000 (09:40 +0200)]
spec: Don't install nonexistent test_libvirt_lockd.aug

test_libvirt_lockd.aug is only generated when qemu driver is enabled.

11 years agospec: sanlock is x86_64 only on RHEL
Jiri Denemark [Tue, 6 May 2014 07:39:18 +0000 (09:39 +0200)]
spec: sanlock is x86_64 only on RHEL

11 years agoqemu: specify domain in host-side PCI addresses when needed/supported
Laine Stump [Wed, 30 Apr 2014 11:32:19 +0000 (14:32 +0300)]
qemu: specify domain in host-side PCI addresses when needed/supported

This uses the new QEMU_CAPS_HOST_PCI_MULTIDOMAIN capability when
present, for -devivce pci-assign, -device vfio-pci, and -pcidevice.

While creating tests for this new functionality, I noticed that the
xmls for two existing tests had erroneously specified an
until-now-ignored domain="0x0002", so I corrected those two tests, and
also added two failure tests to be sure that we alert users who
attempt to use a non-zero domain with a qemu that doesn't support it.

11 years agoqemu: add host-pci-multidomain capability
Laine Stump [Tue, 29 Apr 2014 15:11:45 +0000 (18:11 +0300)]
qemu: add host-pci-multidomain capability

Quite a long time ago, (apparently between qemu 0.12 and 0.13) qemu
quietly began supporting the optional specification of a domain in the
host-side address of all pci passthrough commands (by simply
prepending it to the bus:slot.function format, as
"dddd:bb:ss.f"). Since machines with multiple PCI domains are very
rare, this never came up in practice, so libvirt was never updated to
support it.

This patch takes the first step to supporting specification of a non-0
domain in the host-side address of PCI devices being assigned to a
domain, by adding a capability bit to indicate support
"QEMU_CAPS_HOST_PCI_MULTIDOMAIN", and detect it. Since this support
was added in a version prior to the minimum version required for
QMP-style capabilities detection, the capability is always enabled for
any qemu that uses QMP for capabilities detection. For older qemus,
the only clue that a domain can be specified in the host pci address
is the presence of the string "[seg:]" in the help string for
-pcidevice. (Ironically, libvirt will not be modified to support
specification of domain for -pcidevice, since any qemu new enough for
us to care about also supports "-device pci-assign" or "-device
vfio-pci", which are greatly preferred).

11 years agostorageVolCreateXMLFrom: Allow multiple accesses to origvol
Michal Privoznik [Wed, 16 Apr 2014 13:16:20 +0000 (15:16 +0200)]
storageVolCreateXMLFrom: Allow multiple accesses to origvol

When creating a new volume, it is possible to copy data into it from
another already existing volume (referred to as @origvol). Obviously,
the read-only access to @origvol is required, which is thread safe
(probably not performance-wise though). However, with current code
both @newvol and @origvol are marked as building for the time of
copying data from the @origvol to @newvol. The rationale behind
is to disallow some operations on both @origvol and @newvol, e.g.
vol-wipe, vol-delete, vol-download. While it makes sense to not allow
such operations on partly copied mirror, but it doesn't make sense to
disallow vol-create or vol-download on the source (@origvol).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoFix build wihout macvtap or virtualport
Ján Tomko [Tue, 6 May 2014 07:14:05 +0000 (09:14 +0200)]
Fix build wihout macvtap or virtualport

Commit 1b14c44 broke the build on FreeBSD by changing
the signature of a few functions without updating the
corresponding stubs that are used when WITH_MACVTAP
or WITH_VIRTUALPORT is not defined.

11 years agodocs: fix a typo in formatdomain
Chen Hanxiao [Tue, 6 May 2014 03:13:23 +0000 (11:13 +0800)]
docs: fix a typo in formatdomain

s/virual/virtual

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoconf: use typedefs for enums in "src/conf/{network,interface}_conf.h"
Julio Faracco [Mon, 28 Apr 2014 00:15:22 +0000 (21:15 -0300)]
conf: use typedefs for enums in "src/conf/{network,interface}_conf.h"

In "src/conf/" there are many enumeration (enum) declarations.
Similar to the recent cleanup to "src/util" directory, it's
better to use a typedef for variable types, function types and
other usages. Other enumeration and folders will be changed to
typedef's in the future. Most of the files changed in this commit
are reltaed to Network (network_conf.* and interface_conf.*) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: use typedefs for enums in "src/conf/cpu_conf.h"
Julio Faracco [Mon, 28 Apr 2014 00:15:21 +0000 (21:15 -0300)]
conf: use typedefs for enums in "src/conf/cpu_conf.h"

In "src/conf/" there are many enumeration (enum) declarations.
Similar to the recent cleanup to "src/util" directory, it's
better to use a typedef for variable types, function types and
other usages. Other enumeration and folders will be changed to
typedef's in the future. Most of the files changed in this commit
are related to CPU (cpu_conf) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: use typedefs for enums in "src/util/" directory
Julio Faracco [Sun, 27 Apr 2014 00:15:22 +0000 (21:15 -0300)]
util: use typedefs for enums in "src/util/" directory

In "src/util/" there are many enumeration (enum) declarations.
Sometimes, it's better using a typedef for variable types,
function types and other usages. Other enumeration will be
changed to typedef's in the future.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirsh: Replace list element to defined variable
Li Yang [Tue, 29 Apr 2014 02:10:18 +0000 (22:10 -0400)]
virsh: Replace list element to defined variable

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
11 years agolibxl: support PARAVIRT reboot flag
Jim Fehlig [Thu, 1 May 2014 21:00:47 +0000 (15:00 -0600)]
libxl: support PARAVIRT reboot flag

Add support for the VIR_DOMAIN_REBOOT_PARAVIRT flag in
libxlDomainReboot().

11 years agolibxl: support PARAVIRT and ACPI shutdown flags
Jim Fehlig [Thu, 1 May 2014 18:11:51 +0000 (12:11 -0600)]
libxl: support PARAVIRT and ACPI shutdown flags

Add support for VIR_DOMAIN_SHUTDOWN_PARAVIRT and
VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN flags in
libxlDomainShutdownFlags().

11 years agoIntroduce a new flag for controlling shutdown/reboot
Jim Fehlig [Thu, 1 May 2014 17:42:54 +0000 (11:42 -0600)]
Introduce a new flag for controlling shutdown/reboot

Add a new flag to virDomain{Reboot,Shutdown}FlagValues to allow
shutting down and rebooting a domain via the Xen paravirt control
interface.

11 years agoconf: drop extra storage probe
Eric Blake [Tue, 29 Apr 2014 03:40:22 +0000 (21:40 -0600)]
conf: drop extra storage probe

All callers of virStorageFileGetMetadataFromBuf were first calling
virStorageFileProbeFormatFromBuf, to learn what format to pass in.
But this function is already wired to do the exact same probe if
the incoming format is VIR_STORAGE_FILE_AUTO, so it's simpler to
just refactor the probing into the central function.

* src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
Drop parameter.
(virStorageFileProbeFormatFromBuf): Drop declaration.
* src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
Do probe here instead of in callers.
(virStorageFileProbeFormatFromBuf): Make static.
* src/libvirt_private.syms (virstoragefile.h): Drop function.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Update caller.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobhyve: report cpuTime in bhyveDomainGetInfo
Roman Bogorodskiy [Mon, 21 Apr 2014 10:59:58 +0000 (14:59 +0400)]
bhyve: report cpuTime in bhyveDomainGetInfo

Add a helper function virBhyveGetDomainTotalCpuStats() to
obtain process CPU time using kvm (kernel memory interface)
and use it to set cpuTime field of the virDomainInfo struct in
bhyveDomainGetInfo().

11 years agotypos: fix s/it/is/ where applicable
Martin Kletzander [Mon, 5 May 2014 09:49:24 +0000 (11:49 +0200)]
typos: fix s/it/is/ where applicable

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agodatatypes: Fix comment of secret uuid
Li Yang [Tue, 29 Apr 2014 02:10:19 +0000 (22:10 -0400)]
datatypes: Fix comment of secret uuid

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
11 years agobhyve: implement connectDomainXMLToNative
Roman Bogorodskiy [Sun, 13 Apr 2014 09:48:17 +0000 (13:48 +0400)]
bhyve: implement connectDomainXMLToNative

The only accepted format for now is 'bhyve-argv' which
prints out a bhyve command corresponding to the given
domain definition.

11 years agobhyve: improve bhyve_command.c testability
Roman Bogorodskiy [Sun, 13 Apr 2014 09:27:03 +0000 (13:27 +0400)]
bhyve: improve bhyve_command.c testability

* bhyve_command.c (bhyveBuildNetArgStr, virBhyveProcessBuildBhyveCmd):
  add dryRun mode which doesn't create any devices when enabled
* bhyve_command.c (virBhyveProcessBuildBhyveCmd,
  virBhyveProcessBuildDestroyCmd, virBhyveProcessBuildLoadCmd): accept
  virDomainDefPtr instead of virDomainObjPtr.

11 years agoFix vlan ID detection in udev interface driver
Ján Tomko [Thu, 24 Apr 2014 12:58:47 +0000 (14:58 +0200)]
Fix vlan ID detection in udev interface driver

Instead of guessing it from the interface name, look into
/proc/net/vlan/<interface>.

This works for devices not named <real_device>.<vlan ID>,
avoiding an error flood when virt-manager keeps asking about
them every second:

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

11 years agoBump version to 1.2.5 for new dev cycle
John Ferlan [Sun, 4 May 2014 12:57:00 +0000 (08:57 -0400)]
Bump version to 1.2.5 for new dev cycle

11 years agoRelease of libvirt-1.2.4
Daniel Veillard [Sun, 4 May 2014 06:41:29 +0000 (14:41 +0800)]
Release of libvirt-1.2.4

* docs/news.html.in libvirt.spec.in: updates for release
* po/*.po*: fetched new localization and regenerated

11 years agoExplicitly link virfirewalltest and virsystemdtest against dbus
Guido Günther [Sat, 3 May 2014 11:17:12 +0000 (13:17 +0200)]
Explicitly link virfirewalltest and virsystemdtest against dbus

This fixes link failures like:

  CCLD     virfirewalltest
  /usr/bin/ld: virfirewalltest-virfirewalltest.o: undefined reference to
  symbol 'dbus_message_iter_init_append'

11 years agoqemuxml2argvtest: Don't use privileged mode upfront
Guido Günther [Sat, 3 May 2014 11:12:18 +0000 (13:12 +0200)]
qemuxml2argvtest: Don't use privileged mode upfront

When building packages in a clean chroot the QEMU_USER and QEMU_GROUP
don't exist making VirQemuDriverConfigNew fail with privileged=true.

Avoid that by not requiring privileged mode upfront but setting it later
so we skip the user/group existence check.

This solution was suggested by Daniel P. Berrange and tested by Martin
Kletzander.

11 years agotests: skip virfirewalltest on non-Linux systems
Roman Bogorodskiy [Thu, 1 May 2014 18:43:58 +0000 (22:43 +0400)]
tests: skip virfirewalltest on non-Linux systems

Currently firewalling is supported on Linux only, so skip the
virfirewalltest on other platforms.

11 years agoRestore skipping of setting capacity
John Ferlan [Tue, 15 Apr 2014 20:32:04 +0000 (16:32 -0400)]
Restore skipping of setting capacity

Commit id 'ac9a0963' refactored out the 'withCapacity' for the
virStorageBackendUpdateVolInfo() API.  See:

http://www.redhat.com/archives/libvir-list/2014-April/msg00043.html

This resulted in a difference in how 'virsh vol-info --pool <poolName>
<volume>' or 'virsh vol-list vol-list --pool <poolName> --details' outputs
the capacity information for a directory pool with a qcow2 sparse file.

For example, using the following XML

mkdir /home/TestPool
cat testpool.xml
<pool type='dir'>
  <name>TestPool</name>
  <uuid>6bf80895-10b6-75a6-6059-89fdea2aefb7</uuid>
  <source>
  </source>
  <target>
    <path>/home/TestPool</path>
    <permissions>
      <mode>0755</mode>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>

virsh pool-create testpool.xml
virsh vol-create-as --pool TestPool temp_vol_1 \
      --capacity 1048576 --allocation 1048576 --format qcow2
virsh vol-info --pool TestPool temp_vol_1

Results in listing a Capacity value.  Prior to the commit, the value would
be '1.0 MiB' (1048576 bytes). However, after the commit the output would be
(for example) '192.50 KiB', which for my system was the size of the volume
in my file system (eg 'ls -l TestPool/temp_vol_1' results in '197120' bytes
or 192.50 KiB). While perhaps technically correct, it's not necessarily
what the user expected (certainly virt-test didn't expect it).

This patch restores the code to not update the target capacity for this path

11 years agotests: don't fail with newer gnutls
Martin Kletzander [Fri, 2 May 2014 07:55:52 +0000 (09:55 +0200)]
tests: don't fail with newer gnutls

gnutls-3.3.0 and newer leaves 2 FDs open in order to be backwards
compatible when it comes to chrooted binaries [1].  Linking
commandhelper with gnutls then leaves these two FDs open and
commandtest fails thanks to that.  This patch does not link
commandhelper with libvirt.la, but rather only the utilities making
the test pass.

Based on suggestion from Daniel [2].

[1] http://lists.gnutls.org/pipermail/gnutls-help/2014-April/003429.html
[2] https://www.redhat.com/archives/libvir-list/2014-April/msg01119.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agofix build with older gcc
Ján Tomko [Fri, 2 May 2014 07:37:34 +0000 (09:37 +0200)]
fix build with older gcc

Older gcc (4.1.2-55.el5, 4.2.1 on FreeBSD) reports bogus warnings:
../../src/conf/nwfilter_conf.c:2111: warning: 'protocol' may be used
uninitialized in this function
../../src/conf/nwfilter_conf.c:2110: warning: 'dataProtocolID' may be
used uninitialized in this function

Initialize them to NULL to make the compiler happy.

11 years agostorage: reject negative indices
Eric Blake [Thu, 1 May 2014 02:17:42 +0000 (20:17 -0600)]
storage: reject negative indices

Commit f22b7899 stumbled across a difference between 32-bit and
64-bit platforms when parsing "-1" as an int.  Now that we've
fixed that difference, it's time to fix the testsuite.

* src/util/virstoragefile.c (virStorageFileParseChainIndex):
Require a positive index.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: new stricter unsigned int parsing
Eric Blake [Thu, 1 May 2014 02:11:09 +0000 (20:11 -0600)]
util: new stricter unsigned int parsing

strtoul() is required to parse negative numbers as their
twos-complement positive counterpart.  But sometimes we want
to reject negative numbers.  Add new functions to do this.
The 'p' suffix is a mnemonic for 'positive' (technically it
also parses 0, but 'non-negative' doesn't lend itself to a
nice one-letter suffix).

* src/util/virstring.h (virStrToLong_uip, virStrToLong_ulp)
(virStrToLong_ullp): New prototypes.
* src/util/virstring.c (virStrToLong_uip, virStrToLong_ulp)
(virStrToLong_ullp): New functions.
* src/libvirt_private.syms (virstring.h): Export them.
* tests/virstringtest.c (testStringToLong): Test them.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: fix uint parsing on 64-bit platforms
Eric Blake [Wed, 30 Apr 2014 20:46:18 +0000 (14:46 -0600)]
util: fix uint parsing on 64-bit platforms

Commit f22b7899 called to light a long-standing latent bug: the
behavior of virStrToLong_ui was different on 32-bit platforms
than on 64-bit platforms.  Curse you, C type promotion and
narrowing rules, and strtoul specification.  POSIX says that for
a 32-bit long, strtol handles only 2^32 values [LONG_MIN to
LONG_MAX] while strtoul handles 2^33 - 1 values [-ULONG_MAX to
ULONG_MAX] with twos-complement wraparound for negatives.  Thus,
parsing -1 as unsigned long produces ULONG_MAX, rather than a
range error.  We WANT[1] this same shortcut for turning -1 into
UINT_MAX when parsing to int; and get it for free with 32-bit
long.  But with 64-bit long, ULONG_MAX is outside the range
of int and we were rejecting it as invalid; meanwhile, we were
silently treating -18446744073709551615 as 1 even though it
textually exceeds INT_MIN.  Too bad there's not a strtoui() in
libc that does guaranteed parsing to int, regardless of the size
of long.

The bug has been latent since 2007, introduced by Jim Meyering
in commit 5d25419 in the attempt to eradicate unsafe use of
strto[u]l when parsing ints and longs.  How embarrassing that we
are only discovering it now - so I'm adding a testsuite to ensure
that it covers all the corner cases we care about.

[1] Ideally, we really want the caller to be able to choose whether
to allow negative numbers to wrap around to their 2s-complement
counterpart, as in strtoul, or to force a stricter input range
of [0 to UINT_MAX] by rejecting negative signs; this will be added
in a later patch for all three int types.

This patch is tested on both 32- and 64-bit; the enhanced
virstringtest passes on both platforms, while virstoragetest now
reliably fails on both platforms instead of just 32-bit platforms.
That test will be fixed later.

* src/util/virstring.c (virStrToLong_ui): Ensure same behavior
regardless of platform long size.
* tests/virstringtest.c (testStringToLong): New function.
(mymain): Comprehensively test string to long parsing.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoMisc error reporting bugs in QEMU cli builder
Daniel P. Berrange [Thu, 1 May 2014 16:24:45 +0000 (17:24 +0100)]
Misc error reporting bugs in QEMU cli builder

A couple of places in the QEMU XML -> ARGV conversion code
raised an error but then forgot to return an error status
due to missing gotos. While fixing this also tweak style
of a couple of other error reports

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: fix crash when removing <filterref> from interface with update-device
Laine Stump [Thu, 1 May 2014 08:40:41 +0000 (11:40 +0300)]
qemu: fix crash when removing <filterref> from interface with update-device

If a domain network interface that contains a <filterref> is modified
"live" using "virsh update-device --live", libvirtd would crash. This
was because the code supporting live update of an interface's
filterref was assuming that a filterref might be added or modified,
but didn't account for removing the filterref, resulting in a null
dereference of the filter name.

Introduced with commit 258fb278, which was first in libvirt v1.0.1.

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

11 years agostorage: Clear all data allocated about backing store before reparsing
Peter Krempa [Sat, 26 Apr 2014 06:27:58 +0000 (08:27 +0200)]
storage: Clear all data allocated about backing store before reparsing

To avoid memory leak of the "backingStoreRaw" field when reparsing
backing chains a new function is being introduced by this patch that
shall be used to clear backing store information.

The memory leak was introduced in commit 8823272d41a259c1246c05d.

11 years agonwfilter: Tear down temp. filters when tearing all filters
Stefan Berger [Wed, 30 Apr 2014 16:51:38 +0000 (12:51 -0400)]
nwfilter: Tear down temp. filters when tearing all filters

Refactor the ebiptablesTearNewRules function so that the teardown of temporary
filters can also be called by the ebiptablesAllTeardown function.

This fixes a problem that leaves temporary filters behind when a VM shuts down
while its filters are modified.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
v1->v2:
  - test cases adjusted to expect more commands

11 years agoDevice{Attach,Detach}: Document S4 limitations
Michal Privoznik [Wed, 30 Apr 2014 13:50:34 +0000 (15:50 +0200)]
Device{Attach,Detach}: Document S4 limitations

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

Well, libvirt doesn't distinguish between domain poweroff and
hibernation (S4). It's hard to differentiate these two on a real
machine anyway. As a result, any device that is hot(un-)plugged is
lost (appears again) when domain is started again as from our POV
it is a fresh cold boot. Instead of doing anything wise here, we
should just document this as known limitation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoSet mknod permission in device ACL for LXC USB devices
Daniel P. Berrange [Wed, 30 Apr 2014 13:57:51 +0000 (14:57 +0100)]
Set mknod permission in device ACL for LXC USB devices

The LXC controller itself needs to mknod the USB device
node in /dev/bus/usb, so we can't block mknod permission
from the cgroup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agonwfilter: Validate rule after parsing
Stefan Berger [Wed, 30 Apr 2014 15:41:18 +0000 (11:41 -0400)]
nwfilter: Validate rule after parsing

An IP or IPv6 rule with port specification but without protocol
specification cannot be instantiated by ebtables. The documentation
points to 'protocol' being required but implementation does not
enforce it to be given.

Implement a rule validation function that checks whether the rule is
valid when it is defined. This for example prevents the definition
of rules like:

<ip dstportstart='53'>

where a protocol attribute would be required for it to be valid and for
ebtables to be able to instantiate it. A valid rule then is:

<ip protocol='udp' dstportstart='53'>

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agoAdd a new example to illustrate domain migration
Sahid Orentino Ferdjaoui [Fri, 11 Apr 2014 18:44:32 +0000 (18:44 +0000)]
Add a new example to illustrate domain migration

This commit adds a new example to illustrate peer to
peer domain migration with virDomainMigrateToURI.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@cloudwatt.com>
11 years agoAdd support for QEMU migration to use SASL authentication
Sahid Orentino Ferdjaoui [Fri, 11 Apr 2014 19:17:47 +0000 (19:17 +0000)]
Add support for QEMU migration to use SASL authentication

This commit provides the ability to virDomainMigrateToURI to
check for SASL credentials when attempts to migrate a domain
with the driver QEMU.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@cloudwatt.com>
11 years agonetworkxml2firewalltest: fix build failure on freebsd
Pavel Hrdina [Wed, 30 Apr 2014 08:16:09 +0000 (10:16 +0200)]
networkxml2firewalltest: fix build failure on freebsd

We need to include the testutils.h also for freebsd.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agovirfirewall: fix build on freebsd
Pavel Hrdina [Wed, 30 Apr 2014 06:51:29 +0000 (08:51 +0200)]
virfirewall: fix build on freebsd

Freebsd doesn't know ENODATA so we have to use different EINVAL
error code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoconf: avoid null deref during storage probe
Eric Blake [Tue, 29 Apr 2014 03:26:10 +0000 (21:26 -0600)]
conf: avoid null deref during storage probe

Commit 5c43e2e introduced a NULL deref if there is a failure
in virStorageFileGetMetadataInternal.

* src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
Fix error handling.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoDisable libvirtd by default when building on Win32
Daniel P. Berrange [Mon, 28 Apr 2014 12:30:36 +0000 (13:30 +0100)]
Disable libvirtd by default when building on Win32

We don't support building libvirtd on Win32 since we lack the
fork/exec feature needed for the stateful drivers. Disable this
by default, so users can just do 'mingw32-configure' with no
special args required.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDon't use SO_REUSEADDR on Win32 platforms
Daniel P. Berrange [Fri, 25 Apr 2014 16:47:08 +0000 (17:47 +0100)]
Don't use SO_REUSEADDR on Win32 platforms

SO_REUSEADDR on Windows is actually akin to SO_REUSEPORT
on Linux/BSD. ie it allows 2 apps to listen to the same
port at once. Thus we must not set it on Win32 platforms

See http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: properly quit migration with abort_on_error
Martin Kletzander [Thu, 24 Apr 2014 14:28:36 +0000 (16:28 +0200)]
qemu: properly quit migration with abort_on_error

When EIO comes to qemu while it's replying to
qemuMigrationUpdateJobStatus(), qemu blocks, the migration of RAM can
complete in the meantime, and when qemu unblocks, it sends us
BLOCK_IO_ERROR plus migrations "status": "complete".  Even though we
act upon the BLOCK_IO_ERROR by setting the proper state of the domain,
the call still waits for the proper reply on monitor for query_migrate
and after it gets it, it checks that migration is completed and the
migration is finished.  This is what abort_on_error flag was meant for
(we can migrate with these errors, but this flag must inhibit such
behaviour).  Changing the order of the steps guarantees the flag works
properly.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoqemu: don't call virFileExists() for network type disks
Martin Kletzander [Tue, 29 Apr 2014 07:20:26 +0000 (09:20 +0200)]
qemu: don't call virFileExists() for network type disks

Based on suggestion from Eric [1], because it might not get cleaned up
before the release, so to avoid potential errors.

[1] https://www.redhat.com/archives/libvir-list/2014-April/msg00929.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agodocs: update docs for setting the QEMU BIOS path
Chen Hanxiao [Tue, 29 Apr 2014 07:47:26 +0000 (15:47 +0800)]
docs: update docs for setting the QEMU BIOS path

commit ddf2dfa1f79af0405df5ca10583764a497c7a0db
provided a way to determine which bios files to use.
But we need to update related docs.

disccussed at:
http://www.redhat.com/archives/libvir-list/2012-June/msg01286.html

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agostorage_backend_rbd: Correct argument order to rbd_create3
Steven McDonald [Tue, 29 Apr 2014 02:19:01 +0000 (12:19 +1000)]
storage_backend_rbd: Correct argument order to rbd_create3

The stripe_unit and stripe_count arguments are passed to rbd_create3 in
the wrong order, resulting in a stripe size of 1 byte with 4194304
stripes on newly created RBD volumes.

https://bugzilla.redhat.com/show_bug.cgi?id=1092208
Signed-off-by: Steven McDonald <steven.mcdonald@anchor.net.au>
11 years agoenforce sane readdir usage
Eric Blake [Mon, 21 Apr 2014 22:33:15 +0000 (16:33 -0600)]
enforce sane readdir usage

Now that all clients have been adjusted, ensure that no future
misuse of readdir is introduced into the code base.

* cfg.mk (sc_prohibit_readdir): New rule.
* src/util/virfile.c (virDirRead): Exempt the wrapper.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agonetwork: use virDirRead in networkMigrateStateFiles
Laine Stump [Mon, 28 Apr 2014 10:45:15 +0000 (13:45 +0300)]
network: use virDirRead in networkMigrateStateFiles

This attempts to follow the same variable name and usage patterns as
the other conversions to virDirRead().

11 years agostorage: use virDirRead API
Eric Blake [Thu, 24 Apr 2014 21:48:55 +0000 (15:48 -0600)]
storage: use virDirRead API

More instances of failure to report (unlikely) readdir errors.
In one case, I chose to ignore them, given that a readdir error
would be no different than timing out on the loop, where the
fallback path behaves correctly either way.

* src/storage/storage_backend.c (virStorageBackendStablePath):
Ignore readdir errors.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemRefresh): Report readdir errors.
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIGetHostNumber): Likewise.
* src/storage/storage_backend_scsi.c (getNewStyleBlockDevice)
(getBlockDevice, virStorageBackendSCSIFindLUs): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodrivers: use virDirRead API
Eric Blake [Sat, 26 Apr 2014 04:11:05 +0000 (22:11 -0600)]
drivers: use virDirRead API

Convert all remaining clients of readdir to use the new
interface, so that we can ensure (unlikely) errors while
reading a directory are reported.

* src/openvz/openvz_conf.c (openvzAssignUUIDs): Use new
interface.
* src/parallels/parallels_storage.c (parallelsFindVolumes)
(parallelsFindVmVolumes): Report readdir failures.
* src/qemu/qemu_driver.c (qemuDomainSnapshotLoad): Ignore readdir
failures.
* src/secret/secret_driver.c (loadSecrets): Likewise.
* src/qemu/qemu_hostdev.c
(qemuHostdevHostSupportsPassthroughVFIO): Report readdir failures.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xm_internal.c (xenXMConfigCacheRefresh): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: use virDirRead API
Eric Blake [Fri, 25 Apr 2014 20:45:49 +0000 (14:45 -0600)]
util: use virDirRead API

In making the conversion to the new API, I fixed a couple bugs:
virSCSIDeviceGetSgName would leak memory if a directory
unexpectedly contained multiple entries;
virNetDevTapGetRealDeviceName could report a spurious error
from a stale errno inherited before starting the readdir search.

The decision on whether to store the result of virDirRead into
a variable is based on whether the end of the loop falls through
to cleanup code automatically.  In some cases, we have loops that
are documented to return NULL on failure, and which raise an
error on most failure paths but not in the case where the directory
was unexpectedly empty; it may be worth a followup patch to
explicitly report an error if readdir was successful but the
directory was empty, so that a NULL return always has an error set.

* src/util/vircgroup.c (virCgroupRemoveRecursively): Use new
interface.
(virCgroupKillRecursiveInternal, virCgroupSetOwner): Report
readdir failures.
* src/util/virfile.c (virFileLoopDeviceOpenSearch)
(virFileNBDDeviceFindUnused, virFileDeleteTree): Use new
interface.
* src/util/virnetdevtap.c (virNetDevTapGetRealDeviceName):
Properly check readdir errors.
* src/util/virpci.c (virPCIDeviceIterDevices)
(virPCIDeviceFileIterate, virPCIGetNetName): Report readdir
failures.
(virPCIDeviceAddressIOMMUGroupIterate): Use new interface.
* src/util/virscsi.c (virSCSIDeviceGetSgName): Report readdir
failures, and avoid memory leak.
(virSCSIDeviceGetDevName): Report readdir failures.
* src/util/virusb.c (virUSBDeviceSearch): Report readdir
failures.
* src/util/virutil.c (virGetFCHostNameByWWN)
(virFindFCHostCapableVport): Report readdir failures.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: use virDirRead API
Eric Blake [Thu, 24 Apr 2014 04:27:44 +0000 (22:27 -0600)]
conf: use virDirRead API

When reading configuration files, we were silently ignoring
directory read failures.  While unlikely, we might as well
report them.

* src/conf/domain_conf.c (virDomainObjListLoadAllConfigs): Report
readdir errors.
* src/conf/network_conf.c (virNetworkLoadAllState)
(virNetworkLoadAllConfigs): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterLoadAllConfigs): Likewise.
* src/conf/storage_conf.c (virStoragePoolLoadAllConfigs):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agonodeinfo: use virDirRead API
Natanael Copa [Sun, 20 Apr 2014 11:53:46 +0000 (13:53 +0200)]
nodeinfo: use virDirRead API

This makes sure that errno is reset before readdir is called, even if
the loop does a 'continue'.

This fixes issue with musl libc which sets errno on sscanf. The
following 'continue' makes the errno be set before calling readdir.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: introduce virDirRead wrapper for readdir
Natanael Copa [Sun, 20 Apr 2014 11:53:45 +0000 (13:53 +0200)]
util: introduce virDirRead wrapper for readdir

Introduce a wrapper for readdir. This helps us make sure that we always
set errno before calling readdir and it will make sure errors are
properly logged.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: remove hostdevmgr directory on cleanup
Martin Kletzander [Mon, 28 Apr 2014 13:34:52 +0000 (15:34 +0200)]
tests: remove hostdevmgr directory on cleanup

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoxen: ensure /usr/sbin/xend exists before checking status
Jim Fehlig [Mon, 28 Apr 2014 18:35:44 +0000 (12:35 -0600)]
xen: ensure /usr/sbin/xend exists before checking status

With xend on the way out, installations may not even have
/usr/sbin/xend, which results in the following error when the
drivers are probed

2014-04-28 18:21:19.271+0000: 22129: error : virCommandWait:2426 :
internal error: Child process (/usr/sbin/xend status) unexpected exit
status 127: libvirt:  error : cannot execute binary /usr/sbin/xend:
No such file or directory

Check for existence of /usr/sbin/xend before trying to run it with
the 'status' option.

11 years agoRemove bogus ATTRIBUTE_NONNULL from virFirewallAddRuleFull
Daniel P. Berrange [Mon, 28 Apr 2014 13:17:15 +0000 (14:17 +0100)]
Remove bogus ATTRIBUTE_NONNULL from virFirewallAddRuleFull

The virFirewallAddRuleFull method originally had a single
compulsory virFirewallQueryCallback parameter. During dev
work though the ignoreErrors parameter was added and the
callback parameter made optional. The ATTRIBUTE_NONNULL
annotation was never removed though.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMake autostart of virtlockd actually work
Daniel P. Berrange [Fri, 25 Apr 2014 11:21:57 +0000 (12:21 +0100)]
Make autostart of virtlockd actually work

The virnetsocket.c API is hardcoded to pass --timeout=30 to
any daemon it auto-starts. For inexplicable reasons the virtlockd
daemon did not implement the --timeout option, so it would
immediately exit on autostart with an error.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
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>