Commit Graph

452 Commits

Author SHA1 Message Date
Stefan Berger
aea68ce906 nwfilter: add support for RAPR protocol
This patch adds support for the RARP protocol. This may be needed due to
qemu sending out a RARP packet (at least that's what it seems to want to
do even though the protocol id is wrong) when migration finishes and
we'd need a rule to let the packets pass.

Unfortunately my installation of ebtables does not understand -p RARP
and also seems to otherwise depend on strings in /etc/ethertype
translated to protocol identifiers. Therefore I need to pass -p 0x8035
for RARP. To generally get rid of the dependency of that file I switch
all so far supported protocols to use their protocol identifier in the
-p parameter rather than the string.

I am also extending the schema and added a test case.

changes from v1 to v2:
- added test case into patch
2010-04-27 07:26:12 -04:00
David Allan
1b9347b5f1 Fix indentation for storage conf XML
* virStorageEncryptionFormat is called from both
  virDomainDiskDefFormat and virStorageVolTargetDefFormat.  The proper
  indentation in the generated XML depends on the caller.  My earlier
  patch to fix the incorrect indentation for the domain XML broke the
  indentation for the storage XML.  This patch adopts Laine's
  suggestion of requring the caller of virStorageEncryptionFormat to
  provide an unsigned int with the number of spaces the output should
  be indented.  The patch modifies both callers to provide the
  additional argument.

* Add a regression test for the domain XML

* src/conf/domain_conf.c src/conf/storage_conf.c
  src/conf/storage_encryption_conf.c src/conf/storage_encryption_conf.h:
  change the indentation code
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.args
  tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.xml: add a regression test
2010-04-27 12:01:32 +02:00
Stefan Berger
5c7c755f50 nwfilter: enable hex number inputs in filter XML
With this patch I want to enable hex number inputs in the filter XML. A
number that was entered as hex is also printed as hex unless a string
representing the meaning can be found.

I am also extending the schema and adding a test case. A problem with
the DSCP value is fixed on the way as well.

Changes from V1 to V2:

- using asHex boolean in all printf type of functions to select the
output format in hex or decimal format
2010-04-26 13:50:40 -04:00
Stefan Berger
9db01465e5 nwfilter: extend schema + add testcase w/ connlimit-above
I am extending the schema with the recently added connlimit-above
attribute and adding a test case for it to the test suite.
2010-04-23 11:42:39 -04:00
Eric Blake
2788f4d1d4 testutilsqemu: avoid uninitialized variable
* tests/testutilsqemu.c (testQemuCapsInit): Initialize variables.
2010-04-22 09:00:30 -06:00
Jiri Denemark
b34e082079 Fake host CPU for qemu tests 2010-04-22 10:21:05 +02:00
Matthias Bolte
1d8099f4b6 esx: Fix virtualHW.version generation
The supported virtualHW.version doesn't depend on the API version,
but on the product version.
2010-04-21 00:37:46 +02:00
Matthias Bolte
c6375aa796 esx: Add support for the VMXNET 2 (Enhanced) NIC model
Add a test case and document it.
2010-04-20 20:58:24 +02:00
Eric Blake
5e06ef743a virt-aa-helper-test: avoid non-portable echo -n
* tests/virt-aa-helper-test (testme): Use printf instead.
2010-04-14 11:17:18 -06:00
Jim Meyering
ad896a1cdd schematestutils.sh: improve shell portability: avoid "echo -e"
* tests/schematestutils.sh: Use printf rather than echo -e.
2010-04-14 17:34:12 +02:00
Daniel P. Berrange
e7ebe9f357 Fix nodeinfotest on NUMA machines
The nodeinfotest was reliant on the host NUMA topology, but all
the test data files assumed 1 single NUMA node. This test thus
failed on any NUMA machine with > 1 node

* tests/nodeinfotest.c: Hardcode 1 single numa node
2010-04-13 15:50:07 +01:00
David Allan
cddd3ac8b0 Add enospace option to qemu disk error policy
* Dan Kenigsberg requested explicit support for the qemu default disk error policy which is enospace
2010-04-09 03:35:47 -04:00
Stefan Berger
b5cc01ef2e nwfilter: More XML parser test cases
This patch adds a couple more nwfilter test cases for the XML parser tests.
2010-04-09 07:25:02 -04:00
Matthias Bolte
1aaa909116 esx: Add domain snapshot support
Fix invalid code generating in esx_vi_generator.py regarding deep copy
types that contain enum properties.

Add strptime and timegm to bootstrap.conf. Both are used to convert a
xsd:dateTime to calendar time.

Add a testcase of the xsd:dateTime conversion.
2010-04-08 21:54:43 +02:00
Matthias Bolte
4acab37f56 esx: Allow 'lsisas1068' as SCSI controller type
Extend tests to cover all SCSI controller types and document the
new type.

The lsisas1068 SCSI controller type was added in ESX 4.0. The VMX
parser reports an error when this controller type is present. This
makes virsh dumpxml fail for every domain that uses this controller
type.

This patch fixes this and adds lsisas1068 to the list of accepted
SCSI controller types.

Reported by Jonathan Kelley.
2010-04-08 12:05:51 +02:00
Stefan Berger
edb9d54bd1 Executable does not belong into repository.
Removing the tests/nwfilterxml2xmltest executable that got in with a previous patch.
2010-04-07 19:52:25 -04:00
Stefan Berger
3bf24abc8c nwfilter: Support for learning a VM's IP address
This patch implements support for learning a VM's IP address. It uses
the pcap library to listen on the VM's backend network interface (tap)
or the physical ethernet device (macvtap) and tries to capture packets
with source or destination MAC address of the VM and learn from DHCP
Offers, ARP traffic, or first-sent IPv4 packet what the IP address of
the VM's interface is. This then allows to instantiate the network
traffic filtering rules without the user having to provide the IP
parameter somewhere in the filter description or in the interface
description as a parameter. This only supports to detect the parameter
IP, which is for the assumed single IPv4 address of a VM. There is not
support for interfaces that may have multiple  IP addresses (IP
aliasing) or IPv6 that may then require more than one valid IP address
to be detected. A VM can have multiple independent interfaces that each
uses a different IP address and in that case it will be attempted to
detect each one of the address independently.

So, when for example an interface description in the domain XML has
looked like this up to now:

    <interface type='bridge'>
      <source bridge='mybridge'/>
      <model type='virtio'/>
      <filterref filter='clean-traffic'>
        <parameter name='IP' value='10.2.3.4'/>
      </filterref>
    </interface>

you may omit the IP parameter:

    <interface type='bridge'>
      <source bridge='mybridge'/>
      <model type='virtio'/>
      <filterref filter='clean-traffic'/>
    </interface>

Internally I am walking the 'tree' of a VM's referenced network filters
and determine with the given variables which variables are missing. Now,
the above IP parameter may be missing and this causes a libvirt-internal
thread to be started that uses the pcap library's API to listen to the
backend interface  (in case of macvtap to the physical interface) in an
attempt to determine the missing IP parameter. If the backend interface
disappears the thread terminates assuming the VM was brought down. In
case of a macvtap device a timeout is being used to wait for packets
from the given VM (filtering by VM's interface MAC address). If the VM's
macvtap device disappeared the thread also terminates. In all other
cases it tries to determine the IP address of the VM and will then apply
the rules late on the given interface, which would have happened
immediately if the IP parameter had been explicitly given. In case an
error happens while the firewall rules are applied, the VM's backend
interface is 'down'ed preventing it to communicate. Reasons for failure
for applying the network firewall rules may that an ebtables/iptables
command failes or OOM errors. Essentially the same failure reasons may
occur as when the firewall rules are applied immediately on VM start,
except that due to the late application of the filtering rules the VM
now is already running and cannot be hindered anymore from starting.
Bringing down the whole VM would probably be considered too drastic.
While a VM's IP address is attempted to be determined only limited
updates to network filters are allowed. In particular it is prevented
that filters are modified in such a way that they would introduce new
variables.

A caveat: The algorithm does not know which one is the appropriate IP
address of a VM. If the VM spoofs an IP address in its first ARP traffic
or IPv4 packets its filtering rules will be instantiated for this IP
address, thus 'locking' it to the found IP address. So, it's still
'safer' to explicitly provide the IP address of a VM's interface in the
filter description if it is known beforehand.

* configure.ac: detect libpcap
* libvirt.spec.in: require libpcap[-devel] if qemu is built
* src/internal.h: add the new ATTRIBUTE_PACKED define
* src/Makefile.am src/libvirt_private.syms: add the new modules and symbols
* src/nwfilter/nwfilter_learnipaddr.[ch]: new module being added
* src/nwfilter/nwfilter_driver.c src/conf/nwfilter_conf.[ch]
  src/nwfilter/nwfilter_ebiptables_driver.[ch]
  src/nwfilter/nwfilter_gentech_driver.[ch]: plu the new functionality in
* tests/nwfilterxml2xmltest: extend testing
2010-04-07 23:12:21 +02:00
Jamie Strandboge
ef962afb74 Update of the apparmore regression tests
* tests/virt-aa-helper-test: test augmented with hostdev and sdl display
  checks
2010-04-06 23:01:24 +02:00
Stefan Berger
8cf0ed02be nwfilter: Add filter schema for nwfilter XML, extend domain XML schema
This patch adds a relaxng nwfilter schema along with a test that
verifies all the test output XML against the schema. The input XMLs
contain a lot of intentional out-of-range values that make them fail the
schema verification, so I am not verifying against those.
2010-04-06 11:09:46 -04:00
Matthias Bolte
6c175fa3d1 Remove virConnectPtr from nodeReportError 2010-04-06 01:47:51 +02:00
Stefan Berger
45274d4121 This patch removes the virConnectPtr parameter from all functions where it's not necessary starting out with removing it as a parameter to the error reporting function. 2010-04-05 12:34:55 -04:00
Chris Lalancette
462c74c38a Snapshot QEMU driver.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:51 -04:00
Stefan Berger
8459218cbc This patch adds a couple of test cases for the XML parsing test suite covering various filterable protocols. For each test case an input XML and an output XML is provided checking the input XML after parsing and converting back into XML against the exepcted output XML.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-04-02 13:28:28 -04:00
Eric Blake
e7168f7965 build: import latest gnulib
A lot of syntax check rules have to be rewritten, but the
result is easier to maintain.  I tested each syntax rule
by intentionally introducing a temporary violation of the rule.
Additionally, some false positives for unmarked_diagnostics
crept in, and an improved copyright_format test caught some bugs.

* .gnulib: Update to latest.
* cfg.mk (sc_prohibit_test_minus_ao): Delete, it was moved into
gnulib's maint.mk.
(sc_avoid_write, sc_prohibit_strcmp_and_strncmp)
(sc_prohibit_asprintf, sc_prohibit_strncpy, sc_prohibit_readlink)
(sc_prohibit_gethostname, sc_prohibit_gettext_noop)
(sc_prohibit_VIR_ERR_NO_MEMORY, sc_prohibit_nonreentrant)
(sc_prohibit_ctype_h, sc_TAB_in_indentation)
(sc_avoid_ctype_macros)
(sc_prohibit_virBufferAdd_with_string_literal)
(sc_prohibit_gethostby, sc_copyright_format): Rewrite in terms of
new maint.mk macros.
(sc_libvirt_unmarked_diagnostics): Fix whitespace.
* .x-sc_unmarked_diagnostics: New file.
* tests/object-locking.ml: Fix copyright.
* tools/virt-pki-validate.in: Likewise.
* tools/virt-xml-validate.in: Likewise.
2010-04-02 10:18:55 -06:00
Matthias Bolte
ffbfd2c813 Add virt-aa-helper and secaatest to .gitignore 2010-03-31 13:36:54 +02:00
Laine Stump
0fdf649672 Add flags to indicate presence of timekeeping-related qemu options
* src/qemu/qemu_conf.h: define 4 new flags
* src/qemu/qemu_conf.c: check the help text of qemu for presence of
                        features indicated by each flag.
* tests/qemuhelptest.c: add appropriate flags into the masks for each test
2010-03-30 13:57:40 +02:00
David Allan
447c586a0d Add disk error policy to domain XML
* Fixes per feedback from Dan and Daniel
* Added test datafiles
* Re-disabled JSON flags
* Added code to print the error policy attribute when generating XML
* Re-add empty tag
2010-03-26 16:35:18 -04:00
Eric Blake
e07cf19fe5 build: don't use "test cond1 -o cond2": it's not portable
* configure.ac: Use "test cond1 || test cond2" instead.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Likewise.
* tests/test-lib.sh (verbose): Likewise.
2010-03-25 09:28:24 +01:00
Matthias Bolte
5edaf95599 esx: Make the conf parser compare names case insensitive in VMX mode
The keys of entries in a VMX file are case insensitive. Both scsi0:1.fileName
and scsi0:1.filename are valid. Therefore, make the conf parser compare names
case insensitive in VMX mode to accept every capitalization variation.

Also add test cases for this.
2010-03-24 21:03:37 +01:00
Jim Meyering
ca7db6cb80 tests: shell script portability and clean-up
* tests/test-lib.sh: "echo -n" is not portable.  Use printf instead.
Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient).
Remove uses of tests' -a operator; it is not portable.
Instead, use "test cond && test cond2".
* tests/schematestutils.sh: Replace use of test's -a.
2010-03-24 09:23:01 +01:00
Matthias Bolte
8a7783c163 tests: Don't add extra padding if counter mod 40 is 0
This change only affects the output of tests that have an exact
multiple of 40 test cases. For example the domainschematest currently:

TEST: domainschematest
      ........................................ 40
      ........................................ 80
      ........................................ 120
      ........................................ 160
      ........................................                                         200 OK
PASS: domainschematest

It outputs additional 40 spaces on the last line.

The domainschematest output is fixed by the change in test-lib.sh. The
change in testutils.c fixes this for tests written in C. Currently no
C test has an exact multiple of 40 test cases, but I checked it and
the same problem exists there.

This patch stops that in both cases.
2010-03-24 01:07:57 +01:00
Jim Meyering
67904847f0 tests: do not use the ":disk" suffix in sample xml input
* tests/xml2sexprdata/xml2sexpr-curmem.xml: Remove ":disk" suffix from
"<target dev=" value.
* tests/xml2sexprdata/xml2sexpr-pv-localtime.xml: Likewise.
* tests/xml2sexprdata/xml2sexpr-curmem.sexpr: Update expected output
to match.
* tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr: Likewise.
2010-03-23 11:22:26 +01:00
Matthias Bolte
3528d66641 Make sure virtTestCaptureProgramOutput has a body on Windows
Now the virsh tests compile at least.
2010-03-23 02:08:14 +01:00
Eric Blake
0a33633579 maint: make Red Hat copyright notices consistent
Spell out 'Red Hat, Inc.':
 git grep -i 'Copyright.*Red Hat' | grep -v Inc

Include (C) consistently:
 git grep -i 'Copyright [^(].*Red Hat'

* src/lxc/lxc_container.c: Update copyright formatting.
* src/node_device/node_device_udev.c: Likewise.
* src/node_device/node_device_udev.h: Likewise.
* src/xen/xend_internal.h: Likewise.
* src/xen/xm_internal.c: Likewise.
* src/xen/xm_internal.h: Likewise.
* tests/xmconfigtest.c: Likewise.
* tests/object-locking.ml: Likewise.
* tools/virt-pki-validate.in: Likewise.
* tools/virt-xml-validate.in: Likewise.
2010-03-18 16:48:05 +01:00
Daniel Veillard
f92c041a1c qemu: pass the information when disks are read-only
* src/qemu/qemu_conf.c: add the ",readonly=on" for read-only disks
  and also parse it back in qemuParseCommandLineDisk()
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.args
  tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.xml:
  add a specific regression test
2010-03-15 17:03:26 +01:00
Eric Blake
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
Chris Lalancette
aa2f6f96dd Get thread and socket information in virsh nodeinfo.
The current code for "nodeinfo" is pretty naive
about socket and thread information.  To determine the
sockets, it just takes the number of cpus and divides
by the number of cores.  For the thread count, it always
sets it to 1.  With more recent Intel machines, however,
hyperthreading is again an option, meaning that these
heuristics no longer work and give bogus numbers.  This
patch goes through /sys to get the additional
information so we properly report it.

Note that I had to edit the tests not to report on
socket and thread counts, since these are determined
dynamically now.

v2: As pointed out by Eric Blake, gnulib provides
    count-one-bits (which is LGPLv2+).  Use it instead
    of a hand-coded popcnt.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-08 09:26:04 -05:00
Daniel P. Berrange
74042b8fba Allow configurable timezones with QEMU
Allow an arbitrary timezone with QEMU by setting the $TZ environment
variable when launching QEMU

* src/qemu/qemu_conf.c: Set TZ environment variable if a timezone
  is requested
* tests/qemuxml2argvtest.c: Add test case for timezones
* tests/qemuxml2argvdata/qemuxml2argv-clock-france.xml,
  tests/qemuxml2argvdata/qemuxml2argv-clock-france.args: Data
  for timezone tests
2010-03-01 18:43:04 +00:00
Daniel P. Berrange
200c83b29d Support variable clock offset mode in QEMU
This allows QEMU guests to be started with an arbitrary clock
offset

The test case can't actually be enabled, since QEMU argv expects
an absolute timestring, and this will obviously change every
time the test runs :-( Hopefully QEMU will allow a relative
time offset in the future.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Use the -rtc arg
  if available to support variable clock offset mode
* tests/qemuhelptest.c: Add QEMUD_CMD_FLAG_RTC for qemu 0.12.1
* qemuxml2argvdata/qemuxml2argv-clock-variable.args,
  qemuxml2argvdata/qemuxml2argv-clock-variable.xml,
  qemuxml2argvtest.c: Test case, except we can't actually enable
  it yet.
2010-03-01 18:41:40 +00:00
Cole Robinson
a09af3b004 qemu: Report binary path if error parsing -help 2010-02-25 11:43:57 -05:00
Jim Meyering
083b901eb3 build: avoid non-srcdir "make distcheck" failures (srcdir vs wildcard)
* tests/xencapsdata/Makefile.am: Use $(wildcard in $(srcdir)-aware manner
* tests/xmconfigdata/Makefile.am: Likewise.
* tests/xml2sexprdata/Makefile.am: Likewise.
* tests/sexpr2xmldata/Makefile.am (EXTRA_DIST): Likewise.
* Makefile.am (XML_EXAMPLES): Use $(wildcard in $(srcdir)-aware manner.
2010-02-25 10:50:18 +01:00
Jim Meyering
327d5fe072 build: avoid non-srcdir "make distcheck" failure (test_conf.sh)
* tests/confdata/Makefile.am (EXTRA_DIST): Apply $(wildcard... to
$(srcdir)/..., and then remove the prefix.
2010-02-25 10:50:09 +01:00
David Allan
b4bf51253b Fix daemon-conf invalid failures
The daemon-conf test would fail on my system if there was a system libvirtd
running.  In the course of troubleshooting that problem, I discovered that the
daemon-conf script would always fail if run by itself because it found the line:

\# that each "PARAMETER = VALUE" line in this file have the parameter

which it mistook for a line containing a parameter.  I have changed the test to
avoid mistaking a line containing \"PARAMETER = VALUE\" for a parameter line.

The corrupted config tests turned out to be failing because the test daemon was
discovering the pid file from the running daemon and exiting before it processed
the test config file.  Specifying the pid file for the corrupt config tests in
the same way as for the valid config test solved that problem.
2010-02-20 15:26:53 +01:00
Matthew Booth
3ec09478de Add QEMU support for virtio channel
Support virtio-serial controller and virtio channel in QEMU backend.
Will output
the following for virtio-serial controller:

-device
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4,max_ports=16,vectors=4

and the following for a virtio channel:

-chardev pty,id=channel0 \
-device
virtserialport,bus=virtio-serial0.0,chardev=channel0,name=org.linux-kvm.port.0

* src/qemu/qemu_conf.c: Add argument output for virtio
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args: Add test for
  QEMU command line generation
2010-02-18 17:56:50 +01:00
Matthew Booth
7813a0f81c Add domain support for virtio channel
Add support for virtio-serial by defining a new 'virtio' channel target type
and a virtio-serial controller. Allows the following to be specified in a
domain:

<controller type='virtio-serial' index='0' ports='16' vectors='4'/>
<channel type='pty'>
  <target type='virtio' name='org.linux-kvm.port.0'/>
  <address type='virtio-serial' controller='0' bus='0'/>
</channel>

* docs/schemas/domain.rng: Add virtio-serial controller and virtio
  channel type.
* src/conf/domain_conf.[ch]: Domain parsing/serialization for
  virtio-serial controller and virtio channel.
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: add domain xml
  parsing test
* src/libvirt_private.syms src/qemu/qemu_conf.c:
  virDomainDefAddDiskControllers() renamed to
  virDomainDefAddImplicitControllers()
2010-02-18 17:52:03 +01:00
Jim Meyering
b78fddea39 tests: avoid NULL deref upon OOM failure
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Handle malloc
failure.
2010-02-16 18:09:13 +01:00
Daniel P. Berrange
38536d6f7f Annotate some virConnectPtr as mandatory non-null
Use the ATTRIBUTE_NONNULL annotation to mark some virConnectPtr
args as mandatory non-null so the compiler can warn of mistakes

* src/conf/domain_event.h: All virConnectPtr args must be non-null
* src/qemu/qemu_conf.h: qemudBuildCommandLine and
  qemudNetworkIfaceConnect() must be given non-null connection
* tests/qemuxml2argvtest.c: Provide a non-null (dummy) connection to
  qemudBuildCommandLine()
2010-02-10 13:33:06 +00:00
Daniel P. Berrange
a70e599d80 Remove virConnectPtr from interface XML APIs
The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in interface_conf.{h,c} and update all callers to
match
2010-02-10 13:32:48 +00:00
Daniel P. Berrange
031366383a Remove virConnectPtr from storage APIs & driver
The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in storage_conf.{h,c} and storage_encryption_conf.{h,c}
and update all callers to match
2010-02-10 13:32:11 +00:00
Daniel P. Berrange
99edc443e9 Remove virConnectPtr from all node device XML APIs
The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in node_device_conf.{h,c} and update all callers to
match
2010-02-10 13:32:01 +00:00