Commit Graph

4360 Commits

Author SHA1 Message Date
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
Stefan Berger
b3e8f9f415 The following issues are fixed in the patch below:
- ebtables requires that some of the command line parameters are passed as hex numbers; so have those attributes call a function that prints 16 and 8 bit integers as hex nunbers.

- ip6tables requires '--icmpv6-type' rather than '--icmp-type'

- ebtables complains about protocol identifiers lower than 0x600, so already discard anything lower than 0x600 in the parser

- make the protocol entry types more readable using a #define for its entries

- continue parsing a filtering rule even if a faulty entry is encountered; return an error value at the end and let the caller decide what to do with the rule's object

- fix an error message
2010-04-02 13:21:10 -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
Chris Lalancette
96e5a2d4d5 Add a missing break statement to nwfilter errors.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-02 10:13:44 -04:00
Chris Lalancette
fba3dfd156 Make virDomainLoadConfig static.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-02 10:13:07 -04:00
Jiri Denemark
f76c3493d8 VBox: Fix use of uninitialized value 2010-04-02 15:59:23 +02:00
Laine Stump
4ee2b31804 Changes to clock timer XML to match final design.
The clock timer XML is being updated in the following ways (based on
further off-list discussion that was missed during the initial
implementation):

1) 'wallclock' is changed to 'track', and the possible values are 'boot'
 (corresponds to old 'host'), 'guest', and 'wall'.

2) 'mode' has an additional value 'smpsafe'

3) when tickpolicy='catchup', there can be an optional sub-element of
   timer called 'catchup':

   <catchup threshold=123 slew=120 limit=10000/>

Those three values are all longs, always optional, and if they are present,
they are positive. Internally, 0 indicates "unspecified".

* docs/schemas/domain.rng: updated RNG definition to account for changes

* src/conf/domain_conf.h: change the C struct and enums to match changes.

* src/conf/domain_conf.c: timer parse and format functions changed to
                          handle the new selections and new element.

* src/libvirt_private.syms: *TimerWallclock* changes to *TimerTrack*

* src/qemu/qemu_conf.c: again, account for Wallclock --> Track change.
2010-04-02 09:50:29 -04:00
Laine Stump
8a7b4be5ab Allow domain disk images on root-squash NFS to coexist with security driver.
(suggested by Daniel Berrange, tested by Dan Kenigsberg)

virStorageFileGetMetadata will fail for disk images that are stored on
a root-squash NFS share that isn't world-readable.
SELinuxSetSecurityImageLabel is called during the startup of every
domain (as long as security_driver != "none"), and it will propogate
the error from virStorageFileGetMetadata, causing the domain startup
to fail. This is, however, a common scenario when qemu is run as a
non-root user and the disk image is stored on NFS.

Ignoring this failure (which doesn't matter in this case, since the
next thing done by SELinuxSetSecurityImageLabel - setting the file
context - will also fail (and that function already ignores failures
due to root-squash NFS) will allow us to continue bringing up the
domain. The result is that we don't need to disable the entire
security driver just because a domain's disk image is stored on
root-squashed NFS.
2010-04-02 09:39:20 -04:00
Laine Stump
78151ec96e Eliminate compile warnings in nwfilter error log calls 2010-04-02 09:39:00 -04:00
Chris Lalancette
d62f4c36c2 Don't use virFileReadLimFD in qemuDomainRestore.
virFileReadLimFD is a poor fit for reading the header
of the restore file.  The problem is that virFileReadLimFD
returns an error when there is more data after the amount
you ask to read, but that is *expected* in this case.

This patch is essentially a revert of
1a4d5c9543, but I don't think
that commit does what it says anyway.  It purports to prevent
an unwarranted OOM error, but since virFileReadLimFD will
allocate memory up to the maximum anyway, the upper limit
on the total amount of memory allocated is the same for either
the old version or the new version.  Since the old saferead
actually works and virFileReadLimFD does not, revert to
using saferead.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-02 09:23:41 -04:00
Jim Fehlig
320ea3a47e Only parse 'CPU XML' in virCPUDefParseXML()
Received report of user crashing libvirtd with

virsh capabilities > capabilities.xml
virsh cpu-compare capabilities.xml

While user has been informed about proper usage of cpu-compare,
segfaulting libvirt should be avoided.

Do not parse CPU definition in virCPUDefParseXML() if XML is not
a 'cpu' node.
2010-04-01 14:04:43 +02:00
Daniel P. Berrange
f983c32675 Keep build quiet for generated file
Adds $(AM_V_GEN) to many more manual makefile.am rules that
were generating files
2010-04-01 12:35:51 +01:00
Daniel P. Berrange
cd2404a3c3 Keep track of guest paused state after disk IO / watchdog events
When a watchdog/IO error occurs, one of the possible actions that
QEMU might take is to pause the guest. In this scenario libvirt
needs to update its internal state for the VM, and emit a
lifecycle event:

  VIR_DOMAIN_EVENT_SUSPENDED

with a detail being one of:

  VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
  VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG

To future proof against possible QEMU support for multiple monitor
consoles, this patch also hooks into the 'STOPPED' event in QEMU
and emits a generic VIR_DOMAIN_EVENT_SUSPENDED_PAUSED event

* include/libvirt/libvirt.h.in: Add VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
* src/qemu/qemu_driver.c: Update VM state to paused when IO error
  or watchdog events occurrs
* src/qemu/qemu_monitor_json.c: Fix typo in disk IO event name
2010-04-01 12:35:46 +01:00
Matthias Bolte
d13eb9fc95 Replace sscanf in PCI device address parsing
This also fixes a problem with MinGW's GCC on Windows. GCC complains
about the L modifier being unknown.

Parsing in pciIterDevices is stricter now and doesn't accept trailing
characters after the actual <domain>:<bus>:<slot>.<function> sequence
anymore.

Parsing in pciWaitForDeviceCleanup is also stricter now and expects
the <start>-<end> : <domain>:<bus>:<slot>.<function> sequence to be
terminated by \n.

Change domain from unsigned long long to unsigned int in
pciWaitForDeviceCleanup, because everywhere else domain is handled as
unsigned int too.
2010-04-01 12:53:41 +02:00
Matthias Bolte
57dab74804 xen: Use virStrToLong_i instead of sscanf for XenD port parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
Matthias Bolte
82cb2e73aa xenapi: Use virStrToLong_i instead of sscanf for CPU map parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
Matthias Bolte
1778da7185 openvz: Use strtok_r instead of sscanf for VPS UUID parsing
Also free 2k stack space.
2010-04-01 12:53:41 +02:00
Matthias Bolte
00e00510c5 xen: Use virParseMacAddr instead of sscanf
This also fixes a bug in xenXMDomainConfigParse where uninitialized
memory would be used as MAC address if sscanf fails.
2010-04-01 12:53:41 +02:00
Matthias Bolte
2f047d4816 vbox: Replace atoi with virStrToLong_i
Parsing is stricter now and doesn't accept trailing characters
after the actual value or non-number strings anymore. atoi just
returns 0 in case it cannot parse a number from the given string.
Now an error is reported for such a string.
2010-04-01 12:53:41 +02:00
Matthias Bolte
73b45bfbff cgroup: Replace sscanf with virStrToLong_ll
The switch from %lli to %lld in virCgroupGetValueI64 is intended,
as virCgroupGetValueU64 uses base 10 too, and virCgroupSetValueI64
uses %lld to format the number to string.

Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
Matthias Bolte
56bac4a221 Refactor major.minor.micro version parsing into a function
virParseVersionString uses virStrToLong_ui instead of sscanf.

This also fixes a bug in the UML driver, that always returned 0
as version number.

Introduce STRSKIP to check if a string has a certain prefix and
to skip this prefix.
2010-04-01 12:53:41 +02:00
Matthias Bolte
ea54570efb Replace sscanf in nwfilter rule parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
Matthias Bolte
2072d63c5b Replace sscanf in legacy device address parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual <domain>:<bus>:<slot> sequence anymore.
2010-04-01 12:52:19 +02:00
Stefan Berger
e813200714 While writing a couple of test cases for the nwfilter's XML parser I
found some cases where the output ended up not looking as expected. So
the following changes are in the patch below:

- if the protocol ID in the MAC header is an integer, just write it into
the datastructure without trying to find a corresponding string for it
and if none is found failing
- when writing the protocol ID as string, simply write it as integer if
no corresponding string can be found
- same changes for arpOpcode parsing and printing
- same changes for protocol ID in an IP packet
- DSCP value needs to be written into the data structure
- IP protocol version number is redundant at this level, so remove it
- parse the protocol ID found inside an IP packet not only as string but
also as uint8
- arrange the display of the src and destination masks to be shown after
the src and destination ip address respectively in the XML
- the existing libvirt IP address parser accepts for example '25' as an
IP address. I want this to be parsed as a CIDR type netmask. So try to
parse it as an integer first (CIDR netmask) and if that doesn't work as
a dotted IP address style netmask.
- instantiation of rules with MAC masks didn't work because they weren't
printed into a buffer, yet.
2010-04-01 06:37:26 -04:00
Stefan Berger
6cbc33063a ESX test case needs '/' in interface name
To fix an ESX test case, valid interface names need '/' as valid letter.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-04-01 12:15:11 +02:00
Matthias Bolte
a77821c864 Fix linker errors in proxy
domain_conf.c:494: undefined reference to 'virNWFilterHashTableFree'
domain_conf.c:5107: undefined reference to 'virNWFilterFormatParamAttributes'

Add missing source to the proxy and disable XML parsing code in
nwfilter_params.c for a proxy build.
2010-03-31 23:21:34 +02:00
Eric Blake
a792bf240f build: more fallout from test -a
* cfg.mk (sc_prohibit_test_minus_ao): Also check for [.
* docs/Makefile.am (%.html, html/index.html): Avoid non-portable
test usage.
* libvirt.spec.in (%post): Likewise.
* tools/virt-pki-validate.in (servercert.pem): Likewise.
* configure.ac (LOGNAME): Use test, not [, in files processed by
autoconf.
Detected by Matthias Bolte.
2010-03-31 15:18:13 -06:00
Matthias Bolte
eff24046d8 Fix apibuild.py warning about virNWFilterLookupByUUIDString
The function name was written with capital I in the Filter part.
2010-03-31 18:11:06 +02:00
Matthias Bolte
6fc93f1e75 website: Add archive link for libvirt-users list 2010-03-31 18:11:06 +02:00
Eric Blake
9d6614df86 maint: remove redundant tests after virStrToLong
virStrToLong* guarantees (via strtol) that the end pointer will be set
to the point at which parsing stopped (even on failure, this point is
the start of the input string).

* src/esx/esx_driver.c (esxGetVersion): Remove pointless
conditional.
* src/qemu/qemu_conf.c (qemuParseCommandLinePCI)
(qemuParseCommandLineUSB, qemuParseCommandLineSmp): Likewise.
* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetMigrationStatus): Likewise.
2010-03-31 08:58:46 -06:00
Eric Blake
8d773c0f4f maint: update AUTHORS
* AUTHORS: Add recent contributors.
2010-03-31 08:50:42 -06:00
Paolo Smiraglia
0327ed8718 virConnectGetLibVersion: Avoid error message on success.
* src/libvirt.c (virConnectGetLibVersion): Don't emit error on
success.
2010-03-31 08:47:33 -06:00
Eric Blake
890af4ca8f virsh: add 'exit' as an alias for 'quit'
Call me lazy: some shells use exit (e.g. sh), others use quit (e.g. ftp),
but I never remember which.  So it's faster to write a patch to make
virsh take both than it is to take a 50-50 guess, and get it wrong
in half of my attempts.

* tools/virsh.c (commands): Add 'exit'.
* tools/virsh.pod: Document it.
2010-03-31 08:40:06 -06:00
Jim Meyering
3cda0eb487 maint: fix cpp indentation syntax-check failure
* src/esx/esx_vi_types.h: Filter through cppi.
2010-03-31 16:32:38 +02:00
Jim Meyering
00195f9f8d maint: mark xenapiSessionErrorHandler messages for translation
* cfg.mk (msg_gen_function): Add xenapiSessionErrorHandler.
* po/POTFILES.in: Add src/xenapi/xenapi_driver.c
* src/xenapi/xenapi_driver.c: Mark strings for translation.
* src/xenapi/xenapi_utils.c (xenapiUtil_ParseQuery):
2010-03-31 16:30:41 +02:00
Stefan Berger
2f646237da Blank out invalid interface names with escaped letters etc.
Check that interface names only contain valid characters. Blank them out
otherwise.
Valid characters in this code are currently a-z,A-Z,0-9, '-' and '_'.
2010-03-31 10:22:10 -04:00
Matthias Bolte
ffbfd2c813 Add virt-aa-helper and secaatest to .gitignore 2010-03-31 13:36:54 +02:00
Matthias Bolte
63c0c9a77f esx: Remove redundant semicolons 2010-03-31 13:36:54 +02:00
Matthias Bolte
50723581b0 esx: Generate most SOAP mapping and improve inheritance handling
The Python script generates the mappings based on the type descriptions
in the esx_vi_generator.input file.

This also improves the inheritance handling and allows to get rid of the
ugly, inflexible, and error prone _base/_super approach. Now every struct
that represents a SOAP type contains a _type member, that allows to
recreate C++-like dynamic dispatch for "method" calls in C.
2010-03-31 13:36:54 +02:00
Daniel Veillard
b4b0949dd7 Distribute nwfilter xml files and add them to rpm
* examples/xml/nwfilter/Makefile.am: add all xml to the distribution
* libvirt.spec.in: reference them from the rpm spec file to have them
  available in the main libvirt package
2010-03-31 10:20:22 +02:00
Daniel Veillard
25d5e16e9e Make sure nwfilter headers are part of distribution
* src/Makefile.am: adds a few missing header files in the associated
  file variables, it's needed otherwise the missing headers breaks
  compilation from a distribution tarball
2010-03-31 10:19:06 +02:00
Eric Blake
7b5114f62b maint: show which compiler warning triggered
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-fdiagnostics-show-option.
2010-03-30 11:29:09 -06:00
Eric Blake
4eb8022260 build: automate the rerun of autogen.sh
Automate the reuse of autogen.sh, rather than just erroring out.

* cfg.mk (_update_required): Run autogen.sh, rather than just
warning about it.
(_autogen): New target.
2010-03-30 11:29:09 -06:00
Stefan Berger
062b0aa33b A cosmetic change that makes the entries in the int-2-string maps look
more readable. Add some missing entries: ipv6 and icmpv6.
2010-03-30 11:42:03 -04:00
Stefan Berger
0e0f6021ce Use libvirt's existing ipv6/ipv4 parser/printer rather than self-written ones
This patch changes the network filtering code to use libvirt's existing
IPv4 and IPv6 address parsers/printers rather than my self-written ones.

I am introducing a new function in network.c that counts the number of
bits in a netmask and ensures that the given address is indeed a netmask,
return -1 on error or values of 0-32 for IPv4 addresses and 0-128 for
IPv6 addresses. I then based the function checking for valid netmask
on invoking this function.
2010-03-30 11:18:04 -04:00
Stefan Berger
bc2102104f Add ip6tables support for IPv6 filtering
This patch adds IPv6 filtering support for the following protocols:
- tcp-ipv6
- udp-ipv6
- udplite-ipv6
- esp-ipv6
- ah-ipv6
- sctp-ipv6
- all-ipv6
- icmpv6

Many of the IPv4 data structure could be re-used for IPv6 support.
Since ip6tables also supports pretty much the same command line parameters
as iptables does, also much of the code could be re-used and now
command lines are invoked with the ip(6)tables tool parameter passed
through the functions as a parameter.
2010-03-30 10:36:35 -04:00
Stefan Berger
0af0ded038 Remove driver dependency from nwfilter_conf.c
This patch removes the driver dependency from nwfilter_conf.c and moves
a callback function calling into the driver into
nwfilter_gentech_driver.c and passes a pointer to that callback function
upon initialization of nwfilter_conf.c.
2010-03-30 10:25:22 -04:00
Stefan Berger
285d38931f Add support for so-far missing protocols for iptables filtering
This patch adds filtering support for the so-far missing protocols 'ah',
'esp' and 'udplite'.
2010-03-30 10:16:40 -04:00
Daniel Veillard
0ec5cd0704 Fix daemon hook script initialization
* daemon/libvirtd.c: we should error out only if virHookInitialize()
  return value is negative
2010-03-30 15:06:13 +02:00
Laine Stump
8bf6799b09 Implement the qemu-kvm backend of clock timer elements
Since the timers are defined to cover all possible config cases for
several different hypervisors, many of these possibilities generate an
error on qemu. Here is what is currently supported:

RTC: If the -rtc commandline option is available, allow setting
"clock=host"
     or "clock=vm" based on the rtc timer clock='host|guest' value. Also
     add "driftfix=slew" if the tickpolicy is 'catchup', or add nothing
if
     tickpolicy is 'delay'. (Other tickpolicies will raise an error).

     If -rtc isn't available, but -rtc-td-hack is, add that option
     if the tickpolicy is 'catchup', add -rtc-td-hack, if it is 'delay'
     add nothing, and if it's anything else, raise an error.

PIT: If -no-kvm-pit-reinjection is available, and tickpolicy is
     'delay', add that option. if tickpolicy is 'catchup', do
     nothing. Anything else --> raise an error.

     If -no-kvm-pit-reinjection *isn't* available, but -tdf is, when
     tickpolicy is 'catchup' add -tdf. If it's 'delay', do
     nothing. Anything else --> raise an error.

     If neither of those commandline options is available, and
     tickpolicy is anything other than 'delay' (or unspecified), raise
     an error.

HPET: If -no-hpet flag is available and present='no', add -no-hpet.
      If -no-hpet is not available, and present='yes', raise an error.
      If present is unspecified, the default is to do whatever this
      particular qemu does by default, so don't raise an error.

All other timer types are unsupported by QEMU, so they will raise an
error.

* src/qemu/qemu_conf.c: extend qemuBuildClockArgStr() to generate the
  command line arguments for the new options
2010-03-30 13:57:40 +02:00