Commit Graph

2664 Commits

Author SHA1 Message Date
John Ferlan
2e09729b1c conf: Don't allow duplicated target names regardless of bus
https://bugzilla.redhat.com/show_bug.cgi?id=1142631

Commit id 'e0e290552' added a check to determine if the same bus
had the same target value.  It seems that's not quite good enough
as the check should check the target name value regardless of bus type.

Also added a DO_TEST_DIFFERENT to exhibit the issue
2015-07-09 08:30:02 -04:00
Luyao Huang
955d9bb8d0 qemu: report error when shmem has an invalid address
If user passes an invalid address for shared memory device to qemu,
neither libvirt nor qemu will report an error, but qemu will auto assign
a pci address to the shared memory device.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-07-08 16:30:42 +02:00
Luyao Huang
e9401342e1 qemu: Assign IDs for shared memory devices
Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-07-08 16:30:42 +02:00
Luyao Huang
e309ea6658 qemu: Auto assign pci addresses for shared memory devices
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1165029

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-07-08 16:30:42 +02:00
Ján Tomko
4edf01c92c Explicitly format the isa-fdc controller for newer q35 machines
Since QEMU commit ea96bc6 [1]:
i386: drop FDC in pc-q35-2.4+ if neither it nor floppy drives are wanted
the floppy controller is no longer implicit.

Specify it explicitly on the command line if the machine type version
is 2.4 or later.

Note that libvirt's floppy drives do not result in QEMU implying the
controller, because libvirt uses if=none instead of if=floppy.

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

[1] http://git.qemu.org/?p=qemu.git;a=commitdiff;h=ea96bc6
2015-07-08 15:35:35 +02:00
Jiri Denemark
ffbafd4e88 qemu: Avoid using ".(null)" in UNIX socket path
The code which generates paths for UNIX socket blindly used target name
without checking if it was set. Thus for the following device XML

    <channel type='unix'>
      <source mode='bind'/>
      <target type='virtio'/>
    </channel>

we would generate "/var/lib/libvirt/qemu/channel/target/NAME.(null)"
path which works but is not really correct. Let's not use the
".target_name" suffix at all if target name is not set.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-01 09:47:32 +02:00
John Ferlan
c79ebf53b5 conf: Validate disk lun using correct types
https://bugzilla.redhat.com/show_bug.cgi?id=1201143

The formatdomain.html description for <disk> device 'lun' indicates that
it must be either a type 'block' or type 'network' with protocol 'iscsi';
however, we did not make that check until domain startup.

This caused issues for virt-manager which had an unexpected failure at
run time rather config time.

This patch adds a check in post part disk device checking for the specific
and supported lun types as well as adjusting the test failure to be for
parse config rather than run time.
2015-06-30 08:39:32 -04:00
Jiri Denemark
365b454ed9 qemu: Fix assignment of the default spicevmc channel name
Make sure we only assign the default spicevmc channel name to spicevmc
virtio channels. Caused by commits 3269ee65 and 1133ee2b, which moved
the assignment from XML parsing code to QEMU but failed to keep the
logic.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-30 10:31:29 +02:00
Jiri Denemark
528e70a29a qemuxml2argv: Remove Haswell CPU from unrelated tests
Proper Haswell CPU model handling is tested in several
qemuxml2argv-cpu-* which are run in a special environment. Let's remove
the CPU model from other tests to make them less fragile.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-29 13:28:20 +02:00
Peter Krempa
1c5e782caa test: qemu: Make sure that wr_highest_offset_valid gets set properly
Remove one instance of the field being present so that the code that
sets that flag can be tested.
2015-06-26 16:41:24 +02:00
Peter Krempa
78aefb5275 qemu: monitor: Remove qemuMonitorGetBlockExtent
Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.
2015-06-26 16:41:24 +02:00
Peter Krempa
0d130a011c qemu: monitor: Open-code retrieval of wr_highest_offset
Instead of using qemuMonitorJSONDevGetBlockExtent (which I plan to
remove later) extract the data in place.

Additionally add a flag that will be set when the wr_highest_offset was
extracted correctly so that callers can act according to that.

The test case addition should help make sure that everything works.
2015-06-26 16:41:24 +02:00
Michal Privoznik
70d75ffc79 qemuBuildMemoryBackendStr: Honour passed @pagesize
So far the argument has not much meaning and was practically ignored.
This is not good since when doing memory hotplug, the size of desired
hugepage backing is passed in that argument. Taking closer look at the
tests I'm fixing reveals the bug. For instance, while the following is
in the test:

    <memory model='dimm'>
      <source>
        <nodemask>1-3</nodemask>
        <pagesize unit='KiB'>4096</pagesize>
      </source>
      <target>
        <size unit='KiB'>524287</size>
        <node>0</node>
      </target>
      <address type='dimm' slot='0' base='0x100000000'/>
    </memory>

the generated commandline corresponding to this XML was:

    -object memory-backend-ram,id=memdimm0,size=536870912,\
    host-nodes=1-3,policy=bind

Have you noticed? Yes, memory-backend-ram! Nothing can be further away
from the right answer. The hugepage backing is requested in the XML
and we happily ignore it. This is just not right. It's
memory-backend-file which should have been used:

    -object memory-backend-file,id=memdimm0,prealloc=yes,\
    mem-path=/dev/hugepages4M/libvirt/qemu,size=536870912,\
    host-nodes=1-3,policy=bind

The problem is, that @pagesize passed to qemuBuildMemoryBackendStr
(where this part of commandline is built) was ignored. The hugepage to
back memory was searched only and only by NUMA nodes pinning. This
works only for regular guest NUMA nodes.

Then, I'm changing the hugepages size in the test XMLs too. This is
simply because in the test suite we create dummy mount points just for
2M and 1G hugepages. And in the test 4M was requested. I'm sticking to
2M, but 1G should just work too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-26 09:23:06 +02:00
Michal Privoznik
f8e9deb1d4 qemuBuildMemoryBackendStr: Fix hugepages lookup process
https://bugzilla.redhat.com/show_bug.cgi?id=1196644

This function constructs the backend (host facing) part of the
memory device.  At the beginning, the configured hugepages are
searched to find the best match for given guest NUMA node.
Configured hugepages can have a @nodeset attribute to specify on
which guest NUMA nodes should be the hugepages backing used.
There is, however, one 'corner case'. Users may just tell 'use
hugepages to back all the nodes'. In other words:

  <memoryBacking>
    <hugepages/>
  </memoryBacking>

  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='1024000' unit='KiB'/>
    </numa>
  </cpu>

Our code fails in this case. Well, since there's no @nodeset (nor
any <page/> child element to <hugepages/>) we fail to lookup the
default hugepage size to use.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-26 09:15:26 +02:00
Luyao Huang
786539d6bf conf: Format scheduler priority when it is zero
https://bugzilla.redhat.com/show_bug.cgi?id=1235116

According to our XML definition, zero is as valid as any other value.
Mainly because it should be kernel-agnostic.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-06-25 23:25:30 +02:00
Eric Blake
cb005533ab json: enhance parser test
We already enable the parser option to detect invalid UTF-8, but
didn't test it.  Also, JSON states that behavior of an object
with a duplicated key is undefined; we chose to reject it, but
were not testing it.

With the enhanced tests in place, we can simplify yajl2
initialization by relying on parser defaults being sane.

* src/util/virjson.c (virJSONValueFromString): Simplify.
* tests/jsontest.c (mymain): Test more bad usage.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-25 09:11:15 +02:00
Eric Blake
7e191fd939 json: even stricter trailing garbage detection
Since older yajl ignores trailing garbage, a client can cause
problems by intentionally ending the wrapper array early. Since
we already track nesting, it's not too much harder to reject
invalid nesting pops.

* src/util/virjson. (_virJSONParser): Add field.
(virJSONValueFromString): Set witness.
(virJSONParserHandleEndArray): Use it to catch abuse.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-25 09:11:15 +02:00
Eric Blake
7cd991b74c json: reject trailing garbage
Yajl 2 has a nice feature that it can be configured whether to
allow multiple JSON objects parsed from a single stream, defaulting
to off.  And yajl 1.0.12 at least provided a way to tell if all
input bytes were parsed, or if trailing bytes remained after a
valid JSON object was parsed.  But we target RHEL 6 yajl 1.0.7,
which has neither of these.  So fake it by always parsing '[...]'
instead, so that trailing garbage either trips up the array parse,
or is easily detected when unwrapping the result.

* src/util/virjson.c (virJSONValueFromString): With older json,
wrap text to avoid trailing garbage.
* tests/jsontest.c (mymain): Add tests for this.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-25 09:11:15 +02:00
Eric Blake
54dbba5bc3 json: reject javascript comments
We have been allowing javascript style comments in JSON ever
since commit 9428f2c (v0.7.5), but qemu doesn't send them, and
they are not strict JSON.  Reject them for now; if we can later
prove that it is worthwhile, we can reinstate it at that point
(or even make it conditional, by adding a bool parameter to
the libvirt entry point).

* src/util/virjson.c (virJSONValueFromString): Don't enable
comment parsing.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-25 09:11:15 +02:00
Eric Blake
f2acaebd40 json: cope with older yajl semantics
Commit ceb496e5 fails on RHEL 6, with yajl 1.0.7, because that
version of yajl returns yajl_status_insufficient_data when the
parser is waiting for the rest of a token (this enum value was
dropped in yajl 2, so we have to wrap it).  It also exposes a
problem where older yajl silently ignores trailing garbage after
a successful parse, so this patch works around that by changing
the testsuite.  Another more invasive patch can add tighter
semantics to json parsing, but this is sufficient for a minimal
clean backport.

While touching this, fix up our error message cleanup. Yajl
documents that error messages produced by yajl_get_error()
MUST be cleaned with yajl_free_error(); this is certainly
true if we were to pass non-NULL allocator callbacks during
yajl_alloc(), but probably harmless in our usage of passing
NULL.  But better safe than sorry.

* src/util/virjson.c (virJSONValueFromString): Allow different
error code.  Use canonical cleanup of error message.
(VIR_YAJL_STATUS_OK): New helper macro.
* tests/jsontest.c (mymain): Wrap text to avoid difference in
trailing garbage handling

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-25 09:11:15 +02:00
Boris Fiuczynski
366e31a6ef Test for the new watchdog model diag288
Adding a test for the new watchdog model diag288.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2015-06-24 15:26:32 +02:00
Boris Fiuczynski
4fda44940b Test for the new watchdog action inject-nmi
Adding a test for the new watchdog action "inject-nmi".

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2015-06-24 15:26:31 +02:00
Michal Privoznik
82285d5290 vircapstest: Properly report error for failed tests
There are two macros used in the test: CAPSCOMP and CAPS_EXPECT_ERR.
Both run a test case and if a failure occurred, they set the @ret
variable to a value of -1 to indicate an error. Well, that's what they
should do. Due to a typo, they set the variable to a positive one
effectively masking any failed test.

Then, we have couple of tests failing. Fix them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-24 13:47:05 +02:00
Eric Farman
c733e97323 docs: Fix XML schema handling of LUN address in hostdev tag
Defining a domain with a SCSI disk attached via a hostdev
tag and a source address unit value longer than two digits
causes an error when editing the domain with virsh edit,
even if no changes are made to the domain definition.
The error suggests invalid XML, somewhere:

  # virsh edit lmb_guest
  error: XML document failed to validate against schema:
  Unable to validate doc against /usr/local/share/libvirt/schemas/domain.rng
  Extra element devices in interleave
  Element domain failed to validate content

The virt-xml-validate tool fails with a similar error:

  # virt-xml-validate lmb_guest.xml
  Relax-NG validity error : Extra element devices in interleave
  lmb_guest.xml:17: element devices: Relax-NG validity error :
  Element domain failed to validate content
  lmb_guest.xml fails to validate

The hostdev tag requires a source address to be specified,
which includes bus, target, and unit address attributes.
According to the SCSI Architecture Model spec (section
4.9 of SAM-2), a LUN address is 64 bits and thus could be
up to 20 decimal digits long.  Unfortunately, the XML
schema limits this string to just two digits.  Similarly,
the target field can be up to 32 bits in length, which
would be 10 decimal digits.

  # lsscsi -xx
  [0:0:19:0x4022401100000000]  disk    IBM      2107900          3.44 /dev/sda
  # lsscsi
  [0:0:19:1074872354]disk    IBM      2107900          3.44  /dev/sda
  # cat lmb_guest.xml
  <domain type='kvm'>
    <name>lmb_guest</name>
    <memory unit='MiB'>1024</memory>
  ...trimmed...
    <devices>
      <controller type='scsi' model='virtio-scsi' index='0'/>
      <hostdev mode='subsystem' type='scsi'>
        <source>
          <adapter name='scsi_host0'/>
          <address bus='0' target='19' unit='1074872354'/>
        </source>
      </hostdev>
  ...trimmed...

Since the reference unit and target fields are used in
several places in the XML schema, create a separate one
specific for SCSI Logical Units that will permit the
greater length.  This permits both the validation utility
and the virsh edit command to succeed when a hostdev
tag is included.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2015-06-22 16:15:49 -04:00
Eric Farman
22b8a61756 Convert SCSI logical unit from unsigned int to unsigned long long
The SCSI Architecture Model defines a logical unit address
as 64-bits in length, so change the field accordingly so
that the entire value could be stored.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
2015-06-22 16:03:33 -04:00
Eric Blake
58fd670335 json: make it easier to type-check when getting from object
While working in qemu_monitor_json, I repeatedly found myself
getting a value then checking if it was an object.  Add some
wrappers to make this task easier.

* src/util/virjson.c (virJSONValueObjectGetByType)
(virJSONValueObjectGetObject, virJSONValueObjectGetArray): New
functions.
(virJSONValueObjectGetString, virJSONValueObjectGetNumberInt)
(virJSONValueObjectGetNumberUint)
(virJSONValueObjectGetNumberLong)
(virJSONValueObjectGetNumberUlong)
(virJSONValueObjectGetNumberDouble)
(virJSONValueObjectGetBoolean): Simplify.
(virJSONValueIsNull): Change return type.
* src/util/virjson.h: Reflect changes.
* src/libvirt_private.syms (virjson.h): Export them.
* tests/jsontest.c (testJSONLookup): New test.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-22 10:38:21 -06:00
Eric Blake
ceb496e5f0 json: fully parse input string
I was adding a JSON test, and was shocked to find out our parser
treated the input string of "1" as invalid JSON.  It turns out
that YAJL specifically documents that it buffers input, and that
if the last input read could be a prefix to a longer token, then
you have to explicitly tell the parser that the buffer has ended
before that token will be processed.

It doesn't help that yajl 2 renamed the function from what it was
in yajl 1.

* src/util/virjson.c (virJSONValueFromString): Complete parse, in
case buffer ends in possible token prefix.
* tests/jsontest.c (mymain): Expose the problem.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-22 10:38:21 -06:00
Jiri Denemark
2ad46e5b0e qemu: Do not poll for spice migration status
QEMU_CAPS_SEAMLESS_MIGRATION capability says QEMU supports
SPICE_MIGRATE_COMPLETED event. Thus we can just drop all code which
polls query-spice and replace it with waiting for the event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Pavel Boldin
5eb03b6ea0 util: add virTypedParamsAddStringList
The `virTypedParamsAddStringList' function provides interface to add a
NULL-terminated array of string values as a multi-value to the params.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Pavel Boldin
952907f540 util: virTypedParams{Filter,GetStringList}
Add multikey API:

 * virTypedParamsFilter that filters all the parameters with specified name.
 * virTypedParamsGetStringList that returns a list with all the values for
   specified name and string type.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Pavel Boldin
a5250449de util: multi-value virTypedParameter
The `virTypedParamsValidate' function now can be instructed to allow
multiple entries for some of the keys. For this flag the type with
the `VIR_TYPED_PARAM_MULTIPLE' flag.

Add unit tests for this new behaviour.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Peter Krempa
0b416434f8 qemu: 'privileged' flag is not really configuration
The privileged flag will not change while the configuration might
change. Make the 'privileged' flag member of the driver again and mark
it immutable. Should that ever change add an accessor that will group
reads of the state.
2015-06-18 15:13:45 +02:00
James Cowgill
f486bb0494 qemu: implement address for isa-serial
I needed to specify the iobase address for certain exotic mips configurations.

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
2015-06-18 08:17:20 -04:00
Michal Privoznik
a9a27e602c virSysinfo: Introduce SMBIOS type 2 support
https://bugzilla.redhat.com/show_bug.cgi?id=1220527

This type of information defines attributes of a system
baseboard. With one exception: board type is yet not implemented
in qemu so it's not introduced here either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 10:10:26 +02:00
Michal Privoznik
7690a5a838 tests: Sort EXTRA_DIST in the Makefile
We tend to keep the folders in the EXTRA_DIST sorted alphabetically.
However, we've failed sometimes and the list is not ordered anymore.
Reorder it back.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 09:37:26 +02:00
Michal Privoznik
992ae99d9e tests: Follow virnetserver to virnetdaemon transition
In a474611458 the virnetserver test was renamed to virnetdaemon.
Moreover, as the test relies on some data stored under
virnetserverdata/ the folder was renamed too. But this was not
reflected in the Makefile. Therefore when building outside of the
repository, the data folder was not distributed and test failed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-17 14:22:23 +02:00
Martin Kletzander
beb0eda2e3 Add configuration options for permissions on daemon's admin socket
This is not going to be very widely used, but for some corner cases and
easier (unsafe) debugging, it might be nice.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:21 +02:00
Martin Kletzander
a474611458 tests: Adapt virnetservertest to daemon refactor
Rename the test to virnetdaemontest and use virNetDaemon objects instead
of virNetServer inside.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:20 +02:00
John Ferlan
38c9494878 storage: Fix the schema and add tests for cifs pool
Commit id '887dd362' added support for a netfs pool format type 'cifs'
and 'gluster' in order to add rng support for Samba and glusterfs netfs
pools. Originally, the CIFS type support was added as part of commit
id '61fb6979'. Eventually commit id 'b325be12' fixed the gluster rng
definition to match expectations.

As it turns out the CIFS rng needed a similar change since the directory
path is not an absDirPath, rather just a dirPath will be required.
2015-06-15 17:25:33 -04:00
Martin Kletzander
38788a3209 tests: Use libvirt properly with initialization and error dispatching
We were using "complicated" error printing in virnetservertest even
though we could've just dispatched the error.  Also add some good
practices that might come in handy (the code may fail without proper
initialization and event loop).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-15 17:13:00 +02:00
Martin Kletzander
73ad20e936 Generate JSON with mDNS entries only when built --with-avahi
One string was already used only if that condition was true, second one
is added now.  Both are used in a nicer way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-15 17:13:00 +02:00
Ján Tomko
243bbcc5db qemu caps: spell queue 2015-06-15 13:32:44 +02:00
Michal Privoznik
a377408f0b tests: Distribute virnetserverdata
Fairly recently we've introduced virnetservertest. This test has some
input data stored under tests/virnetserverdata which unfortunately was
not distributed among with the test. Therefore 'make distcheck'
failed. Fix this by adding the directory into EXTRA_DIST.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-12 09:48:04 +02:00
Martin Kletzander
d9a610f90c util: add virJSONValueCopy
Faster version of virJSONValueFromString(virJSONValueToString()).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 15:39:30 +02:00
Maxime Leroy
366c22f2bc qemu: add multiqueue vhost-user support
This patch adds the support of queues attribute of the driver element
for vhost-user interface type. Example:

<interface type='vhostuser'>
      <mac address='52:54:00:ee:96:6d'/>
      <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
      <model type='virtio'/>
      <driver queues='4'/>
</interface>

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

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 14:28:29 +02:00
Martin Kletzander
181e02dfda conf: Ignore multiqueue with one queue.
Multi != One.  And indeed, libvirt behaves the same way for queues='1'
as without such setting.  Let's make it clear in the XML.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 14:17:46 +02:00
Daniel P. Berrange
d1f6efb1d0 rpc: add testing of RPC JSON (de)serialization
The virNetServer class has the ability to serialize its state
to a JSON file, and then re-load that data after an in-place
execve() call to re-connect to active file handles. This data
format is critical ABI that must have compatibility across
releases, so it should be tested...
2015-06-11 12:21:14 +01:00
Daniel P. Berrange
43c0a84cda rpc: add API for checking IPv4/6 availability
The socket test suite has a function for checking if IPv4
or IPv6 are available, and returning a free socket. The
first bit of that will be needed in another test, so pull
that logic out into a separate helper method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-06-11 12:11:18 +01:00
Daniel P. Berrange
d587704cc7 rpc: allow selection of TCP address family
By default, getaddrinfo() will return addresses for both
IPv4 and IPv6 if both protocols are enabled, and so the
RPC code will listen/connect to both protocols too. There
may be cases where it is desirable to restrict this to
just one of the two protocols, so add an 'int family'
parameter to all the TCP related APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-06-11 12:11:18 +01:00
Shivaprasad G Bhat
310c98d0c4 network: escape quotes for dsmasq conf contents
dnsmasq conf file contents needs to have quotes escaped for it to
work.  Because of this, the network-create/start for a network with
quotes in the name fails. The patch escapes strings for the entries
that go into the conf file.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
2015-06-09 13:56:00 -04:00
Cole Robinson
29ce1693fa qemu: command: Support arm 32-on-64 KVM with -cpu aarch64=off
qemu 2.3.0 added the -cpu host,aarch64=off option, which allows using
qemu-system-aarch64 KVM to run armv7l VMs.

Add a capabilities check for it, wire it up in qemu_command, and test
the command line generation.
2015-06-08 17:51:06 -04:00
Michal Privoznik
ceb46a662d utiltest: Use int8_t instead of char.
Not every architecture out there has 'char' signed by default.
For instance, my arm box has it unsigned by default:

  $ gcc -dM -E - < /dev/null | grep __CHAR_UNSIGNED__
  #define __CHAR_UNSIGNED__ 1

Therefore, after 65c61e50 the test if failing for me. Problem is,
we are trying to assign couple of negative values into char
assuming some will overflow and some don't. That can't be the
case if 'char' is unsigned by default. Lets use more explicit types
instead: int8_t and uint8_t where is no ambiguity.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-08 12:54:32 +02:00
Ján Tomko
8728a78e90 Always add 'console' matching the 'serial' device
We have been formatting the first serial device also
as a console device, but only if there were no other consoles.

If there is a <serial> device present in the XML, but no serial
<console>, or if there isn't any <console> at all but the domain
definition hasn't gone through a parse->format->parse round-trip,
the <console> device would not be formatted.

Change the code to always add the stub device for the first
serial device.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1089914
2015-06-04 10:04:44 +02:00
Peter Krempa
65c61e5030 util: Add macro to overflow check integer assignments
Add a macro that will allow to simplify overflow checks and make them
more universal in case data types change.
2015-06-03 09:42:08 +02:00
Laine Stump
1e334a0a00 network: validate DHCP ranges are completely within defined network
virSocketAddrGetRange() has been updated to take the network address
and prefix, and now checks that both the start and end of the range
are within that network, thus validating that the entire range of
addresses is in the network. For IPv4, it also checks that ranges to
not start with the "network address" of the subnet, nor end with the
broadcast address of the subnet (this check doesn't apply to IPv6,
since IPv6 doesn't have a broadcast or network address)

Negative tests have been added to the network update and socket tests
to verify that bad ranges properly generate an error.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=985653
2015-06-02 12:40:07 -04:00
Laine Stump
48e8b95d8e test: fix IP address range failure test
This was revealed when I made a cut-paste mistake in an upgrade to
virSocketAddrGetRange(), leading to failure to check for the end
address being outside of the defined network, but a negative test case
that should have caught the error instead returned success.

The problem was that testRange in sockettest.c was written so that
when it expected a failure, even an "unexpected success" would be
considered as an "expected failure" because of the way the check in
testRange was done. testRange had this:

 if (gotsize < 0 || gotsize != size) {
     return pass ? -1 : 0;
 } else {
     return pass ? 0 : -1;
 }

but all the tests that expected a failure give "-1" as the expected
size. So in a case where we expect a failure, we would have pass ==
false and size == -1. If virSocketAddrGetRange() was incorrectly
*successful* (returned some positive number), then "gotsize != size"
would be, e.g. "276 != -1", so we would take the if clause and, since
pass == false, we would return 0 (success i.e. expected failure).

The solution is that in the case where we expect failure, we should
just ignore size - virSocketAddrGetRange() must return -1 in order for
us to report "expected failure == success".

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653
2015-06-02 12:40:07 -04:00
Andrea Bolognani
815dc963ee virsh: Move error messages inside vshCommandOpt*() functions 2015-06-02 09:20:31 -04:00
Andrea Bolognani
d27160bb82 virsh: Use standard error messages in vshCommandOptTimeoutToMs()
I missed this in the first time around, thanks Michal for noticing.
2015-06-02 09:20:30 -04:00
Andrea Bolognani
779457a19c tests: Add a bunch of new tests to virsh-optparse
The new tests deal with numeric options of three kinds: regular,
scaled and timeouts. For each, both valid and invalid inputs
are provided, hopefully covering all cases: this should allow us
to avoid regressions when changing the relevant code in virsh.
2015-06-02 09:20:30 -04:00
Andrea Bolognani
778c56f000 qemu: Automatically add <panic> element for pSeries guests.
The guest firmware provides the same functionality as the pvpanic
device, and the relevant element should always be present in the
domain XML to reflect this fact, so add it after parsing the
definition if it wasn't there already.
2015-06-01 06:44:37 -04:00
Andrea Bolognani
7bd769e0ab qemu: Allow panic device for pSeries guests
The guest firmware provides the same functionality as the pvpanic
device, which is not available in QEMU on pSeries, so the domain
XML should be allowed to contain the <panic> element.

On the other hand, unlike the pvpanic device, the guest firmware
can't be configured, so report an error if an address has been
provided in the XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1182388
2015-06-01 06:16:29 -04:00
Roman Bogorodskiy
b071ec4347 zfs: fix storagepoolxml2xml test
Commit 7c2d65d dropped setting default mode.

Update zfs tests accordingly.
2015-05-27 14:03:42 +04:00
Cole Robinson
42dd6a993f conf: storage: Don't emit empty <permissions> block 2015-05-25 20:52:57 -04:00
Cole Robinson
7c2d65dde2 storage: conf: Don't set any default <mode> in the XML
The XML parser sets a default <mode> if none is explicitly passed in.
This is then used at pool/vol creation time, and unconditionally reported
in the XML.

The problem with this approach is that it's impossible for other code
to determine if the user explicitly requested a storage mode. There
are some cases where we want to make this distinction, but we currently
can't.

Handle <mode> parsing like we handle <owner>/<group>: if no value is
passed in, set it to -1, and adjust the internal consumers to handle
it.
2015-05-25 20:52:55 -04:00
Roman Bogorodskiy
6005bac45d zfs: fix storagepoolxml2xml test
Commit c4d27bd dropped output of owner/group -1.

Update zfs tests accordingly.
2015-05-24 10:20:05 +03:00
Laine Stump
ba5566e80f interface: allow multiple IPv4 addresses + dhcp on a single interface
As of netcf-0.2.8, netcf supports configuring multipl IPv4 addresses,
as well as simultaneously configuring dhcp and static IPv4 addresses,
on a single interface. This patch updates libvirt's interface.rng to
allow such configurations.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1223688
2015-05-22 10:14:01 -04:00
Cole Robinson
c4d27bdddf storage: conf: Don't output owner/group -1
-1 is just an internal placeholder and is meaningless to output in the XML.
2015-05-21 15:00:52 -04:00
Michal Privoznik
85128e2962 sysinfo: Fix reports on ARM
Due to a kernel commit (b4b8f770e), cpuinfo format has changed on
ARMs. Firstly, 'Processor: ...' may not be reported, it's
replaced by 'model name: ...'. Secondly, the "Processor" string
may occur in CPU name, e.g. 'ARMv7 Processor rev 5 (v7l)'.
Therefore, we must firstly look for 'model name' and then for
'Processor' if not found.
Moreover, lines in the cpuinfo file are shuffled, so we better
not manipulate the pointer to start of internal buffer as we may
lost some info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-05-21 18:13:18 +02:00
Michal Privoznik
8e33cb41f3 qemu: Implement pci-serial
https://bugzilla.redhat.com/show_bug.cgi?id=998813

Implementation is pretty straight-forward. Of course, not all qemus
out there supports the device, so new capability is introduced and
checked prior each use of the device.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-05-21 17:49:02 +02:00
Michal Privoznik
335b834d95 Introduce pci-serial
https://bugzilla.redhat.com/show_bug.cgi?id=998813

Like usb-serial, the pci-serial device allows a serial device to be
attached to PCI bus. An example XML looks like this:

  <serial type='dev'>
    <source path='/dev/ttyS2'/>
    <target type='pci-serial' port='0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  </serial>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-05-21 17:49:02 +02:00
Luyao Huang
aef2a0a26c conf: Restore the XML parser context in virDomainMemoryDefParseXML
After parsing the memory device XML the function would not restore the
XML parser context causing invalid XPath starting point for the rest of
the elements. This is a regression since 3e4230d2.

The test case addition uses the <idmap> element that is currently unused
by qemu, but parsed after the memory device definition and formatted
always.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2015-05-21 11:06:18 +02:00
Jim Fehlig
a5b55bd931 xenconfig: fix spice mousemode and copypaste
From xl.cfg950 man page:

spiceagent_mouse=BOOLEAN
Whether SPICE agent is used for client mouse mode. The default is
true (1) (turn on)

spicevdagent=BOOLEAN
Enables spice vdagent. The Spice vdagent is an optional component for
enhancing user experience and performing guest-oriented management
tasks. Its features includes: client mouse mode (no need to grab
mouse by client, no mouse lag), automatic adjustment of screen
resolution, copy and paste (text and image) between client and domU.
It also requires vdagent service installed on domU o.s. to work.
The default is 0.

spice_clipboard_sharing=BOOLEAN
Enables Spice clipboard sharing (copy/paste). It requires spicevdagent
enabled. The default is false (0).

So if spiceagent_mouse is enabled (client mouse mode) or
spice_clipboard_sharing is enabled, spicevdagent must be enabled.
Along with this change, s/spicedvagent/spicevdagent, set
spiceagent_mouse correctly, and add a test for these spice
features.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-18 12:46:16 -06:00
Jim Fehlig
a460295f4e xenconfig: fix spicepasswd handling
The logic related to spicedisable_ticketing and spicepasswd was
inverted.  As per man xl.cfg(5), 'spicedisable_ticketing = 1'
means no passwd is required.  On the other hand, a passwd is
required if 'spicedisable_ticketing = 0'.  Fix the logic and
produce and error if 'spicedisable_ticketing = 0' but spicepasswd
is not provided.  Also fix the spice cfg test file.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-18 12:46:16 -06:00
Jim Fehlig
e21b1180a9 xenconfig: format spice listenAddr when formating ports
Move formating of spice listenAddr to the section of code
where spice ports are formatted.  It is more logical to
format address and ports together.  Account for the change
in spice cfg test file by moving 'spicehost'.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-18 12:46:16 -06:00
Andrea Bolognani
449316701b virsh: Improve error message on integer value parsing failure.
Replace more than 30 ad-hoc error messages with a single, generic one
that contains the name of the option being processed and some hints
to help the user understand what could have gone wrong.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207043
2015-05-18 10:50:06 +02:00
Tony Krowiak
8ed0bcfd81 libvirt: tests: test protected key mgmt ops support
Test the support for enabling/disabling CPACF protected key management
operations for a guest.

Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-05-18 09:54:16 +02:00
Laine Stump
eadd757cce qemu: log error when domain has an unsupported IDE controller
We have previously effectively ignored all <controller type='ide'>
elements in a domain definition.

On the i440fx-based machinetypes there is an IDE controller that is
included in the chipset and can't be removed (which is the ide
controller with index='0'>), so it makes sense to ignore that one
controller. However, if an i440fx domain definition has a 2nd
controller, nothing catches this error (unless you also have a disk
attached to it, in which case qemu will complain that you're trying to
use the ide controller named "ide1", which doesn't exist), and if any
other type of domain has even a single controller defined, it will be
incorrectly ignored.

Ignoring a bogus controller definition isn't such a big problem, as
long as an error is logged when any disk is attached to that
non-existent controller. But in the case of q35-based machinetypes,
the hardcoded id ("alias" in libvirt terms) of its builtin SATA
controller is "ide", which happens to be the same id as the builtin
IDE controller on i440fx machinetypes. So libvirt creates a
commandline believing that it is connecting the disk to the builtin
(but actually nonexistent) IDE controller, qemu thinks that libvirt
wanted that disk connected to the builtin SATA controller, and
everybody is happy.

Until you try to connect a 2nd disk to the IDE controller. Then qemu
will complain that you're trying to set unit=1 on a controller that
requires unit=0 (SATA controllers are organized differently than IDE
controllers).

After this patch, if a domain has an IDE controller defined for a
machinetype that has no IDE controllers, libvirt will log an error
about the controller itself as it is building the qemu commandline
(rather than a (possible) error from qemu about disks attached to that
controller). This is done by adding IDE to the list of controller
types that are handled in the loop that creates controller command
strings in qemuBuildCommandline() (previously it would *always* skip
IDE controllers). Then qemuBuildControllerDevStr() is modified to log
an appropriate error in the case of IDE controllers.

In the future, if we add support for extra IDE controllers (piix3-ide
and/or piix4-ide) we can just add it into the IDE case in
qemuBuildControllerDevStr(). For now, nobody seems anxious to add
extra support for an aging and very slow controller, when there are so
many better options available.

Resolves:

https://bugzilla.redhat.com/show_bug.cgi?id=1176071 (Fedora)
2015-05-15 15:40:43 -04:00
Laine Stump
548ba43028 qemu: remove test for allowing ide controller in s390, rename usb tests
Back in 2013, commit 877bc089 added in some tests that made sure no
error was generated on a domain definition that had an automatically
added usb controller if that domain didn't have a PCI bus to attach
the usb controller to. This was done because, at that time, libvirt
was automatically adding a usb controller to *any* domain definition
that didn't have one.  Along with permitting the controller, two
s390-specific tests were added to ensure this behavior was maintained
- one with <controller type='usb' model='none'/> and another (called
"s390-piix-controllers") that had both usb and ide controllers, but
nothing attached to them.

Then in February of this year, commit 09ab9dcc eliminated the annoying
auto-adding of a usb device for s390 and s390x machines, stating:

 "Since s390 does not support usb the default creation of a usb
  controller for a domain should not occur."

Although, as verified here, the s390 doesn't support usb, and usb
controllers aren't currently added to s390 domain definitions
automatically, there are likely still some domain definitions in the
wild that have a usb controller (which was added *by libvirt*, not by
the user), so we will keep the tests verifying that behavior for
now. But this patch changes the names of the tests to reflect that
they don't actually contain a valid s390 config; this way future
developers won't propagate the incorrect idea that an s390 virtual
machine can have a USB (or IDE) bus.

In the case of the IDE controller, though, libvirt has never
automatically added an IDE controller unless a user added an IDE disk
(which itself would have caused an error), and we specifically *do*
want to begin generating an error when someone tries to add an IDE
controller to a domain that can't support one. For that reason, while
renaming the sz390-piix-controllers patch, this patch removes the
<controller type='ide'...> from it (otherwise the upcoming patch would
break make check)
2015-05-15 15:37:51 -04:00
Laine Stump
0260506c65 qemu: use controller alias when constructing device/controller args
This makes sure that that the commandlines generated for devices and
controller devices are all using the alias that has been set in the
controller's object as the id of the controller, rather than
hardcoding a printf (or worse, encoding exceptions to the standard
${controller}${index} into the logic)

Since this "fixes" the controller name used for the sata controller,
the commandline arg for the sata controller in the sata test case had
to be adjusted to be "sata0" instead of "ahci0". All other tests
remain unchanged, verifying that the patch causes no other functional
change.

Because the function that finds a controller alias based on a device
def requires a pointer to the full domainDef in order to get the list
of controllers, the arglist of a few functions had to have this added.
2015-05-15 15:36:28 -04:00
Martin Kletzander
07df9e1f74 Some alignment fixes in lxc_controller and jsontest
Again, a clean-up for which we don't have proper syntax-check.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-05-14 15:03:33 +02:00
Roman Bogorodskiy
846cc14c4d bhyve: fix bhyvexml2argvtest build with gcc
gcc5 reports an error like this:

bhyvexml2argvtest.c: In function 'testCompareXMLToArgvFiles':
bhyvexml2argvtest.c:24:18: error: variable 'vm' set but not used
[-Werror=unused-but-set-variable]
     virDomainObj vm;
                  ^
cc1: all warnings being treated as errors

Fix by dropping this variable.
2015-05-11 20:08:47 +03:00
Cole Robinson
8910e063db caps: Fix regression defaulting to host arch
My commit 747761a79 (v1.2.15 only) dropped this bit of logic when filling
in a default arch in the XML:

-    /* First try to find one matching host arch */
-    for (i = 0; i < caps->nguests; i++) {
-        if (caps->guests[i]->ostype == ostype) {
-            for (j = 0; j < caps->guests[i]->arch.ndomains; j++) {
-                if (caps->guests[i]->arch.domains[j]->type == domain &&
-                    caps->guests[i]->arch.id == caps->host.arch)
-                    return caps->guests[i]->arch.id;
-            }
-        }
-    }

That attempt to match host.arch is important, otherwise we end up
defaulting to i686 on x86_64 host for KVM, which is not intended.
Duplicate it in the centralized CapsLookup function.

Additionally add some testcases that would have caught this.

https://bugzilla.redhat.com/show_bug.cgi?id=1219191
2015-05-08 11:11:32 -04:00
Cole Robinson
fd74e23175 tests: Remove redundant aarch64 tests
My commit 7b9de914 added some aarch64 CPU test cases. I wanted to test
two different code paths but inadvertently added two of the same test
cases.

The second code path (using <cpu><model>host</model</cpu>) isn't easily
exercised via the qemu tests anyways, I'll need to look elsewhere.

Regardless, remove the redundant tests for now
2015-05-07 11:54:46 -04:00
Michal Privoznik
608c95c76c qemu: Implement GIC
The only version that's supported in QEMU is version 2, currently.
Fortunately, it is enabled by aarch64 automatically, so there's
nothing for us that needs to be put onto command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-05-05 09:45:52 +02:00
Andrea Bolognani
320e61b26c tests: Fix grammar in comments.
Replace all occurrences of "stream write to differences to"
with "stream to write differences to".
2015-05-04 15:01:27 +02:00
Marc-André Lureau
620655f353 tests: add machine vmport qemu test
Check that the vmport feature is correctly used in qemu commande line.
2015-05-04 13:19:38 +02:00
Jiri Denemark
6280294574 qemu: Check address type for USB disks
Only USB addresses are allowed for USB disks. Report an error if another
address is configured.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-30 15:34:57 +02:00
Jiri Denemark
01ecee247a cpu: Honor vendor_id override in host-model
https://bugzilla.redhat.com/show_bug.cgi?id=858147

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-30 15:34:57 +02:00
Cole Robinson
066f7c7c3a domain: conf: Drop unused OSTYPE_AIX
The phyp driver stuffed it into a DomainDefPtr during its attachdevice
routine, but the value is never advertised via capabilities so it should
be safe to drop.

Have the phyp driver use OSTYPE_LINUX, which is what it advertises via
capabilities.
2015-04-29 09:42:26 -04:00
Martin Kletzander
922563e73a Fix building virnetserverclientmock with MinGW
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-28 17:37:58 +02:00
Zhang Bo
e6bb622032 tests: free ChardevInfo correctly in qemumonitorjsontest
The free callback should be qemuMonitorChardevInfoFree rather
than just 'free' when virHashCreate'ing the chardevInfo hash.

==29959== 24 bytes in 2 blocks are definitely lost in loss record 19 of 53
==29959==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==29959==    by 0xB95C679: strdup (in /lib64/libc-2.20.so)
==29959==    by 0x63C6546: virStrdup (virstring.c:709)
==29959==    by 0x4805ED: qemuMonitorJSONExtractChardevInfo (qemu_monitor_json.c:3429)
==29959==    by 0x4807A5: qemuMonitorJSONGetChardevInfo (qemu_monitor_json.c:3479)
==29959==    by 0x434AEC: testQemuMonitorJSONqemuMonitorJSONGetChardevInfo (qemumonitorjsontest.c:1824)
==29959==    by 0x436F2F: virtTestRun (testutils.c:211)
==29959==    by 0x436932: mymain (qemumonitorjsontest.c:2404)
==29959==    by 0x4382EA: virtTestMain (testutils.c:863)
==29959==    by 0x436B27: main (qemumonitorjsontest.c:2423)

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
2015-04-28 17:01:16 +02:00
John Ferlan
b515339fe7 qemu: Remove need for qemuMonitorIOThreadInfoFree
Replace with just VIR_FREE.
2015-04-28 06:33:49 -04:00
John Ferlan
4c2ca5664a qemu: Remove need for qemuDomainParseIOThreadAlias
Rather than have a separate routine to parse the alias of an iothread
returned from qemu in order to get the iothread_id value, parse the alias
when returning and just return the iothread_id in qemuMonitorIOThreadInfoPtr

This set of patches removes the function, changes the "char *name" to
"unsigned int" and handles all the fallout.
2015-04-28 06:33:30 -04:00
Laine Stump
dcbedfa672 test: Fix actual vs. expected in virtTestCompareFiles
Commit ca329299 added a utility function virtTestCompareFiles() to
eliminate repetitive code in several test programs. It unfortunately
calls virtTestDifference() with the arguments in the wrong order -
strcontent is the "actual" output gathered by the test rig, while
filecontent is the "expected", and virtTestDifference() wants expected
(filecontent) followed by actual (strcontent), but
virtTestCompareFiles() does the opposite, which can make the output a
bit confusing when there is a failure.
2015-04-27 15:12:23 -04:00
John Ferlan
4dec8a0160 conf: Adjust the iothreadsched expectations
With iothreadid's allowing any 'id' value for an iothread_id, the
iothreadsched code needs a slight adjustment to allow for "any"
unsigned int value in order to create the bitmap of ids that will
have scheduler adjustments. Adjusted the doc description as well.
2015-04-27 12:36:35 -04:00
John Ferlan
b266486fb9 Move iothreadspin information into iothreadids
Remove the iothreadspin array from cputune and replace with a cpumask
to be stored in the iothreadids list.

Adjust the test output because our printing goes in order of the iothreadids
list now.
2015-04-27 12:36:35 -04:00
John Ferlan
8d4614a512 qemu: Use domain iothreadids to IOThread's 'thread_id'
Add 'thread_id' to the virDomainIOThreadIDDef as a means to store the
'thread_id' as returned from the live qemu monitor data.

Remove the iothreadpids list from _qemuDomainObjPrivate and replace with
the new iothreadids 'thread_id' element.

Rather than use the default numbering scheme of 1..number of iothreads
defined for the domain, use the iothreadid's list for the iothread_id

Since iothreadids list keeps track of the iothread_id's, these are
now used in place of the many places where a for loop would "know"
that the ID was "+ 1" from the array element.

The new tests ensure usage of the <iothreadid> values for an exact number
of iothreads and the usage of a smaller number of <iothreadid> values than
iothreads that exist (and usage of the default numbering scheme).
2015-04-27 12:36:35 -04:00
Martin Kletzander
a7f0db6904 Cleanup parameters for mock libraries
All the libraries use same parameters when building, why not have it in
one place at the begining of the Makefile.

This will also ensure no new mock library will have a problem with
missing e.g. MINGW_EXTRA_LDFLAGS.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-27 16:31:19 +02:00
Michal Privoznik
f58a3a51fc Cleanup srcdir usage
In a lot places we use path like this:

  $(srcdir)/../src/....

when in fact it can be:

  $(top_srcdir)/src/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-27 16:03:31 +02:00
Pavel Fedin
9dc57ce2c4 Add missing linker flags for MinGW build
This fix should completely close
https://bugzilla.redhat.com/show_bug.cgi?id=1214605

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
2015-04-27 15:36:54 +02:00
Zhang Bo
083ac198bc tests: fix some memleaks in tests
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Roman Bogorodskiy
0d6563d7f0 bhyve: fix build in tests
Commit ca32929 caused build errors in bhyvexml2argvtest.c because of
some undefined variables.

Pushing under the build breaker rule.
2015-04-24 19:54:12 +03:00
Cole Robinson
7b9de91404 tests: qemu: Couple aarch64 CPU tests
- Make sure aarch64 host-passthrough works correctly
- Make sure libvirt doesn't choke on cpu model=host, which is what
  virt-install/virt-manager were incorrectly specifying up until recently.
2015-04-24 10:27:01 -04:00
Cole Robinson
edb27a7048 tests: Add VIR_TEST_REGENERATE_OUTPUT
If this enviroment variable is set, the virTestCompareToFile helper
will overwrite the file content we are comparing against, if the
file doesn't exist or it doesn't match the expected input.

This is useful when adding new test cases, or making changes that
generate a lot of output churn.
2015-04-23 17:08:48 -04:00
Cole Robinson
ca32929908 tests: Add virtTestCompareToFile
Replaces a common pattern used in many test files
2015-04-23 17:08:48 -04:00
Cole Robinson
bdbe26b504 tests: Use *DefParseFile more 2015-04-23 17:08:48 -04:00
Cole Robinson
01f2f6c6c9 tests: Add VIR_TEST_DEBUG and VIR_TEST_VERBOSE
To remove a bunch of TestGetDebug()/TestGetVerbose() checks
2015-04-23 17:08:48 -04:00
Daniel P. Berrange
615bdfda07 rng: fix port number range validation
The PortNumber data type is declared to derive from 'short'.
Unfortunately this is an signed type, so validates the range
[-32,768, 32,767] which excludes valid port numbers between
32767 and 65535.

We can't use 'unsignedShort', since we need -1 to be a valid
port number too.

This change is to use 'int' and set an explicit max boundary
instead of relying on the data types' built-in max.

One of the existing tests is changed to use a high port number
to validate the schema.

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-04-23 12:59:52 +01:00
Roman Bogorodskiy
c42dbd8a18 bhyve: fix build in tests
Commit 835cf84 dropped expectedVirtTypes argument for
virDomainDefParse*() functions, however bhyve tests still try to pass
that to virDomainDefParseFile(), therefore build fails.

Fix build by fixing virDomainDefParseFile() usage.
2015-04-23 10:54:32 +04:00
Roman Bogorodskiy
a7c1eb140f vircapstest: fix build without LXC, QEMU or XEN
When building without lxc support enabled, build fails with:

CLD     vircapstest
vircapstest.o: In function `test_virCapsDomainDataLookupLXC':
vircapstest.c:(.text+0x9ef): undefined reference to `testLXCCapsInit'

Fix that by hiding LXC tests under appropriate #ifdef. Same applies
for QEMU and XEN.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-21 16:53:02 +02:00
Cole Robinson
835cf84b7e domain: conf: Drop expectedVirtTypes
This needs to specified in way too many places for a simple validation
check. The ostype/arch/virttype validation checks later in
DomainDefParseXML should catch most of the cases that this was covering.
2015-04-20 16:43:43 -04:00
Cole Robinson
747761a79a caps: Use DomainDataLookup to replace GuestDefault*
This revealed that GuestDefaultEmulator was a bit buggy, capable
of returning an emulator that didn't match the passed domain type. Fix
up the test suite input to continue to pass.
2015-04-20 16:43:13 -04:00
Cole Robinson
a693652341 caps: Add virCapabilitiesDomainDataLookup
This is a helper function to look up all capabilities data for all
the OS bits that are relevant to <domain>. This is

- os type
- arch
- domain type
- emulator
- machine type

This will be used to replace several functions in later commits.
2015-04-20 16:43:08 -04:00
Cole Robinson
4fa6f9b413 caps: Convert to use VIR_DOMAIN_VIRT internally 2015-04-20 16:40:26 -04:00
Cole Robinson
5f7c599456 domain: Convert os.type to VIR_DOMAIN_OSTYPE enum 2015-04-20 16:40:09 -04:00
Cole Robinson
d0440e3269 caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value
Rather than an opencoded string. This should be a no-op
2015-04-20 16:38:09 -04:00
Erik Skultety
cea1b86fa7 rng: Forbid to validate mismatched <disk> 'device' and 'type' attributes
According to docs, using 'lun' as a value for device attribute is only valid
with disk types 'block' and 'network'. However current RNG schema also allows
a combination type='file' device='lun' which results in a successfull
xml validation, but fails at qemuBuildCommandLine.
Besides fixing the RNG schema, this patch also adds a qemuxml2argvtest
for this case.

https://bugzilla.redhat.com/show_bug.cgi?id=1210669
2015-04-20 10:04:06 +02:00
Michal Privoznik
2397be694d virNetDevBandwidthSet: Add priority to filter
Currently, when constructing traffic shaping rules, the ingress
filter is created without any priority specified on the command
line. This makes kernel to make up one. While this works, it
simplifies things a bit if we provide the filter priority. In
this case, since it's the root filter lets give it the highest
priority of number 1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-17 10:18:58 +02:00
Jim Fehlig
13e2c22099 libxl: support HVM direct kernel boot
Add support for HVM direct kernel boot in libxl.  Also add a
test to verify domXML <-> native conversions.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-16 16:14:51 -06:00
Jim Fehlig
0fe504f15a xenconfig: don't use "kernel" for hvmloader
In xl config, hvmloader is implied for hvm guests.  It is not
specified with the "kernel" option like xm config.  The "kernel"
option, along with "ramdisk" and "extra", is used for HVM direct
kernel boot.  Instead of using "kernel" option to populate
virDomainDef object's os.loader->path, use hvmloader discovered
when gathering capabilities.

This change required fixing initialization of capabilities in
the test utils and removing 'kernel = "/usr/lib/xen/boot/hvmloader"'
from the test config files.
2015-04-16 16:11:01 -06:00
Jim Fehlig
717a92513d xenconfig: move <os> parsing/formating to config-specific files
xl and xm differ a bit in how <os> configuration is represented.
E.g. xl config supports <os><nvram .../></os> via its "bios"
setting.

Move the xenParseOS and xenFormatOS functions from xen_common.c
and copy to xen_xl.c and xen_xm.c so they can be customized for
xm vs xl config.  An unfortunate fallout is reordering of entries
in the test config files.
2015-04-16 16:11:01 -06:00
Michal Privoznik
7cf87f750b RNG schema: allow plain @floor to <bandwidth/>
The <inbound/> element to <bandwidth/> has several attributes from
which two are mandatory. Well, from two at least one has to be
present: @average or @floor or both. Instead of inventing crazy RNG
schema, let's make all the attributes optional there and rely on our
parsing code to correctly handle the situation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-16 09:07:43 +02:00
Eric Blake
9289c85841 tests: fix build on old 32-bit platforms
gcc 4.1.2 (hello RHEL 5) on 32-bit platforms complains:

vircgrouptest.c: In function 'testCgroupGetPercpuStats':
vircgrouptest.c:627: warning: integer constant is too large for 'long' type
vircgrouptest.c:628: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:634: warning: integer constant is too large for 'long' type
vircgrouptest.c:635: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:636: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:644: warning: integer constant is too large for 'long' type

* tests/vircgrouptest.c (testCgroupGetPercpuStats): Use ULL suffix.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-04-15 12:50:23 -06:00
Ján Tomko
aeb5262e43 Strip control codes in virBufferEscapeString
These cannot be represented in XML.

We have been stripping them, but only if the string had
characters that needed escaping: <>"'&

Extend the strcspn check to include control codes, and strip
them even if we don't do any escaping.

https://bugzilla.redhat.com/show_bug.cgi?id=1184131
https://bugzilla.redhat.com/show_bug.cgi?id=1066564
2015-04-15 18:41:20 +02:00
Ján Tomko
2a530a3e50 Add functions dealing with control characters in strings
Add virStringHasControlChars that checks if the string has
any control characters other than \t\r\n,
and virStringStripControlChars that removes them in-place.
2015-04-15 18:41:20 +02:00
Ján Tomko
e892842dfd tests: rename testStripIPv6BracketsData to testStripData
For reuse with other Strip* functions.
2015-04-15 18:41:20 +02:00
Michal Privoznik
598f3fddbc tests: Add virnetdevtestdata to EXTRA_DIST
In one of my previous commits (49ed6cff9) I've introduced a test
among with some files stored under virnetdevtestdata folder.
While this works perfectly within a git tree, the folder was not
getting into .tar.gz and therefore the dist-check would fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-15 16:43:28 +02:00
John Ferlan
960e009c58 tests: Resolve Coverity RESOURCE_LEAK
Commit id 'b77ce18a2' added a new bitmap, but neglected to virBitmapFree it
2015-04-15 10:29:41 -04:00
Michal Privoznik
49ed6cff99 Introduce virnetdevtest
This is yet another test for check of basic functionality of our
NIC state handling code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-14 19:33:02 +02:00
Ján Tomko
a832735df9 Rename virStorageBackendCreateQemuImgCmd
Add FromVol at the end. This function will create the qemu-img
command line from volume definitions and check them.
2015-04-13 15:59:20 +02:00
Erik Skultety
b77ce18a28 virBitmap: Place virBitmapIsAllClear check after virBitmapParse calls
This patch adds checks for empty bitmaps right after the calls of
virBitmapParse. These only include spots where set API's are called and
where domain's XML is parsed.
Also, it partially reverts commit 983f5a which added a check for
invalid nodeset "0,^0" into virBitmapParse function. This change broke
the logic, as an empty bitmap should not cause an error.

https://bugzilla.redhat.com/show_bug.cgi?id=1210545
2015-04-13 14:21:02 +02:00
Ján Tomko
a75069be35 Fix usb device version parsing issues
Request that the number be parsed as decimal, to allow 08
and 09.

Format it with the leading zero, 1.01 and 1.10 are two
different versions.

https://bugzilla.redhat.com/show_bug.cgi?id=1210650
2015-04-13 12:33:41 +02:00
Ján Tomko
3f4c27497e Do xml->xml test for usb-redir-filter
We don't format the default '-1' fields back.
2015-04-13 12:24:26 +02:00
Andrea Bolognani
e4d7ddfdd2 conf: Don't output <cpu> tag if it contains no information.
The tag is already marked as optional in the schema, so no changes
are needed there.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1202606
2015-04-13 09:27:26 +02:00
Peter Krempa
db37f3cc3a qemu: Clean up old leftovers in qemuMonitorDrivePivot
There are two leftover unused variables. Remove them and clean up the
fallout of the change.
2015-04-09 14:18:48 +02:00
Peter Krempa
fac04598bb util: file: Don't carelessly sanitize URIs
rfc3986 states that the separator in URI path is a single slash.
Multiple slashes may potentially lead to different resources and thus we
should not remove them.
2015-04-09 09:43:36 +02:00
Peter Krempa
b8e7facfa7 test: Add tests for virFileSanitizePath
Add test infrastructure for virFileSanitizePath so that it can be
sensibly refactored later.
2015-04-09 09:43:36 +02:00
Michal Privoznik
d65acbde35 vircgroup: Introduce virCgroupControllerAvailable
This new internal API checks if given CGroup controller is
available.  It is going to be needed later when we need to make a
decision whether pin domain memory onto NUMA nodes using cpuset
CGroup controller or using numa_set_membind().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-08 11:54:24 +02:00
Ján Tomko
b84c5729d9 Fix xlconfigtest with older libxl
Commit cd5dc30 added this test, but it fails if
LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST is not defined:

6) Xen XM-2-XML Format fullvirt-multiusb
... libvirt:  error : unsupported configuration: multiple USB
devices not supported
FAILED
2015-04-02 15:11:43 +02:00
Ján Tomko
1371ea92f0 Auto add virtio-serial controllers
In virDomainVirtioSerialAddrNext, add another controller
if we've exhausted all ports of the existing controllers.

https://bugzilla.redhat.com/show_bug.cgi?id=1076708
2015-04-02 15:00:13 +02:00
Ján Tomko
89e991a2aa Assign an address when hotplugging a virtio-serial device 2015-04-02 15:00:13 +02:00
Ján Tomko
5903378834 Allocate virtio-serial addresses when starting a domain
Instead of always using controller 0 and incrementing port number,
respect the maximum port numbers of controllers and use all of them.

Ports for virtio consoles are quietly reserved, but not formatted
(neither in XML nor on QEMU command line).

Also rejects duplicate virtio-serial addresses.
https://bugzilla.redhat.com/show_bug.cgi?id=890606
https://bugzilla.redhat.com/show_bug.cgi?id=1076708

Test changes:
* virtio-auto.args
  Filling out the port when just the controller is specified.
  switched from using
    maxport + 1
  to:
    first free port on the controller
* virtio-autoassign.args
  Filling out the address when no <address> is specified.
  Started using all the controllers instead of 0, also discards
  the bus value.
* xml -> xml output of virtio-auto
  The port assignment is no longer done as a part of XML parsing,
  so the unspecified values stay 0.
2015-04-02 15:00:13 +02:00
Ján Tomko
8945d6a805 Add test for virtio serial port assignment
Add a test to demonstrate the effect of automatic virtio-serial
address assignment.
2015-04-02 15:00:13 +02:00
Michal Privoznik
184a927a0a nodeinfodata: Remove broken symlinks and uneeded files
The 7c3c7f217e and f5c2d6 commits introduced a nodeinfo test.
In order to do that, some parts of sysfs had to be copied.
However, sysfs is full of symlinks, so during copying some
symlinks broke. Remove them, as on different systems they can
point to different files or be broken. At the same time, we don't
need all files added in those commits. For instance we don't care
about 'uevent' files, 'power' folders, and others.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-02 11:12:01 +02:00
Ján Tomko
a0482396d7 Remove unused macros
In the order of appearance:

* MAX_LISTEN - never used
  added by 23ad665c (qemud) and addec57 (lock daemon)

* NEXT_FREE_CLASS_ID - never used, added by 07d1b6b

* virLockError - never used, added by eb8268a4

* OPENVZ_MAX_ARG, CMDBUF_LEN, CMDOP_LEN
  unused since the removal of ADD_ARG_LIT in d8b31306

* QEMU_NB_PER_CPU_STAT_PARAM - unused since 897808e

* QEMU_CMD_PROMPT, QEMU_PASSWD_PROMPT - unused since 1dc10a7

* TEST_MODEL_WORDSIZE - unused since c25c18f7

* TEMPDIR - never used, added by 714bef5

* NSIG - workaround around old headers
  added by commit 60ed1d2
  unused since virExec was moved by commit 02e8691

* DO_TEST_PARSE - never used, added by 9afa006

* DIFF_MSEC, GETTIMEOFDAY - unused since eee6eb6
2015-04-02 10:27:56 +02:00
Cole Robinson
7c3c7f217e tests: nodeinfo: Add test for RHELSA on APM mustang
This would have caught the bug fixed by Wei's commit c13de016

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-03-31 14:40:28 -06:00
Cole Robinson
f5c2d6f033 tests: nodeinfo: Test F21 aarch64 on APM mustang
Signed-off-by: Eric Blake <eblake@redhat.com>
2015-03-31 14:38:41 -06:00
Pavel Hrdina
eb05cb0d5c tests: introduce qemucaps2xmlmock
We need to mock virFileExists to return true for "/dev/kvm" because the
test should not depend on host system.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-27 16:55:33 +01:00
Pavel Hrdina
a894d61ba1 Revert "qemucaps2xmltest: fix test to successfully run without kvm support"
This reverts commit 49bf09d16c.  That
commit is wrong and doesn't fix the issue.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-27 16:55:33 +01:00
Eric Blake
dfc708750b relaxng: allow : in /dev/disk/by-path names
On IRC, Hydrar pointed a problem where 'virsh edit' failed on
his domain created through an ISCSI pool managed by virt-manager,
all because the XML included a block device with colons in the
name.

* docs/schemas/basictypes.rng (absFilePath): Add colon as safe.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml: New file.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args: Likewise.
* tests/qemuxml2argvtest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-03-26 16:57:26 -06:00
Ján Tomko
9e48f6cf9f Rename qemuMonitorIOThreadsInfo* to qemuMonitorIOThreadInfo*
It only deals with a single thread.
2015-03-26 16:11:10 +01:00
Luyao Huang
a0bbdcd788 qemu: command: Fix property name for start address of a pc-dimm module
Starting a qemu VM with a memory module that has the base address
specified results in the following error:

 error: internal error: early end of file from monitor: possible problem:
 2015-03-26T03:45:52.338891Z qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,
 id=dimm0,slot=0,base=4294967296: Property '.base' not found

The correct property name for the base address is 'addr'.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-03-26 09:22:21 +01:00
Jiri Denemark
c563b50605 cpu: Add {Haswell,Broadwell}-noTSX CPU models
QEMU 2.3 adds these new models to cover Haswell and Broadwell CPUs with
updated microcode. Luckily, they also reverted former the machine type
specific changes to existing models. And since these changes were never
released, we don't need to hack around them in libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-03-26 09:19:59 +01:00
Peter Krempa
02f0f1ccc7 tests: qemuxml2xml: Test status XML formatting and parsing
Recently we've fixed a bug where the status XML could not be parsed as
the parser used absolute path XPath queries. This test enhancement tests
all XML files used in the qemu-xml-2-xml test as a part of a status XML
snippet to see whether they are parsed correctly. The status XML-2-XML is
currently tested in 223 cases with this patch.
2015-03-25 15:42:52 +01:00
Peter Krempa
6ff59cbc83 util: buffer: Add support for adding text blocks with indentation
The current auto-indentation buffer code applies indentation only on
complete strings. To allow adding a string containing newlines and
having it properly indented this patch adds virBufferAddStr.
2015-03-25 15:42:52 +01:00
Peter Krempa
785fd9fa12 tests: qemuxml2xml: Refactor the qemuxml2xml test
To allow adding more tests, refactor the XML-2-XML test so that the
files are not reloaded always and clarify the control flow.

Result of this changes is that the active and inactive portions of the
XML are tested in separate steps rather than one test step.
2015-03-25 13:35:42 +01:00
Pavel Hrdina
49bf09d16c qemucaps2xmltest: fix test to successfully run without kvm support
Function virQEMUCapsInitGuestFromBinary detect kvm support by testing
whether /dev/kvm exists or whether we pass path to kvmbin.  Provide the
path we are testing via kvmbin for testing purpose instead of detecting
presence of /dev/kvm to successfully run the tests on all hosts.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-25 12:28:56 +01:00
Pavel Hrdina
6d4269eca0 qemucaps2xmltest: fix the test to correspond to new domain formatting
Commit 2360fe5d updated formating of <domain> element but forgot to
update qemucaps2xmldata xml files.  In addition the test code was broken
too.  Update the xml files and return -1 if testCompareXMLToXML fails
together with indentation fix.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-24 16:44:08 +01:00
Peter Krempa
8b54bffbab qemu: add support for memory devices
Add support to start qemu instance with 'pc-dimm' device. Thanks to the
refactors we are able to reuse the existing function to determine the
parameters.
2015-03-23 14:25:15 +01:00
Peter Krempa
3e4230d270 conf: Add interface to parse and format memory device information
This patch adds code that parses and formats configuration for memory
devices.

A simple configuration would be:
<memory model='dimm'>
  <target>
    <size unit='KiB'>524287</size>
    <node>0</node>
  </target>
</memory>

A complete configuration of a memory device:
<memory model='dimm'>
  <source>
    <pagesize unit='KiB'>4096</pagesize>
    <nodemask>1-3</nodemask>
  </source>
  <target>
    <size unit='KiB'>524287</size>
    <node>1</node>
  </target>
</memory>

This patch preemptively forbids use of the <memory> device in individual
drivers so the users are warned right away that the device is not
supported.
2015-03-23 14:25:15 +01:00
Peter Krempa
a41185d8d1 qemu: Implement setup of memory hotplug parameters
To enable memory hotplug the maximum memory size and slot count need to
be specified. As qemu supports now other units than mebibytes when
specifying memory, use the new interface in this case.
2015-03-23 14:25:14 +01:00
Peter Krempa
bffb9163a1 conf: Add support for parsing and formatting max memory and slot count
Add a XML element that will allow to specify maximum supportable memory
and the count of memory slots to use with memory hotplug.

To avoid possible confusion and misuse of the new element this patch
also explicitly forbids the use of the maxMemory setting in individual
drivers's post parse callbacks. This limitation will be lifted when the
support is implemented.
2015-03-23 14:25:14 +01:00
Michal Privoznik
cbbb9baaf2 objecteventtest: Check for virNetwork* return values
Lets not give a bad example and check for return values of
virNetwork* APIs called within the test. Even though it's
unlikely that any API will fail, it can happen. We're connected
to the test driver after all, and our API sequence is correct. So
test driver should fail only in case of bug or OOM.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-23 09:56:15 +01:00
Jiri Denemark
9c23b325b4 maint: Distribute tests/vircgroupdata
My commit 2dbfa71 added test data for vircgrouptest but forgot to
distribute the new directory.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-03-18 12:13:41 +01:00
Jiri Denemark
2dbfa716e8 tests: Add tests for virCgroupDetectMounts
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-03-18 09:53:24 +01:00
Antoni Segura Puimedon
a9fbe3b157 docs: schema and docs for the midonet virtualport type
Midonet is an opensource virtual networking that over lays the IP
network between hypervisors. Currently, such networks can be made
with the openvswitch virtualport type.

This patch, defines the schema and documentation that will serve
as basis for the follow up patches that will add support to libvirt
for using Midonet virtual ports for its interfaces. The schema
definition requires that the port profile expresses its interfaceid
as part of the port profile. For that reason, this is part of the
patch too.

Signed-off-by: Antoni Segura Puimedon <toni+libvirt@midokura.com>
2015-03-17 13:09:05 -04:00
Nehal J Wani
0977b8aa07 domifaddr: Implement the API for qemu
By querying the qemu guest agent with the QMP command
"guest-network-get-interfaces" and converting the received JSON
output to structured objects.

Although "ifconfig" is deprecated, IP aliases created by "ifconfig"
are supported by this API. The legacy syntax of an IP alias is:
"<ifname>:<alias-name>". Since we want all aliases to be clubbed
under parent interface, simply stripping ":<alias-name>" suffices.
Note that IP aliases formed by "ip" aren't visible to "ifconfig",
and aliases created by "ip" do not have any specific name. But
we are lucky, as qemu guest agent detects aliases created by both.

src/qemu/qemu_agent.h:
  * Define qemuAgentGetInterfaces

src/qemu/qemu_agent.c:
  * Implement qemuAgentGetInterface

src/qemu/qemu_driver.c:
  * New function qemuGetDHCPInterfaces
  * New function qemuDomainInterfaceAddresses

src/remote_protocol-sructs:
  * Define new structs

tests/qemuagenttest.c:
  * Add new test: testQemuAgentGetInterfaces
    Test cases for IP aliases, 0 or multiple ipv4/ipv6 address(es)

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
2015-03-17 15:15:38 +00:00
Martin Kletzander
02ce97bca6 conf: Reorder elements inside memballoon
All the devices we have format their address as its last sub-element, so
let's change memballoon to follow suit.  Also adjust RNG to allow any
order of them so 'virsh edit' doesn't shout at us.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-17 12:03:33 +01:00
Peter Krempa
4bca6192f2 conf: Make specifying <memory> optional
Now that the size of guest's memory can be inferred from the NUMA
configuration (if present) make it optional to specify <memory>
explicitly.

To make sure that memory is specified add a check that some form of
memory size was specified. One side effect of this change is that it is
no longer possible to specify 0KiB as memory size for the VM, but I
don't think it would be any useful to do so. (I can imagine embedded
systems without memory, just registers, but that's far from what libvirt
is usually doing).

Forbidding 0 memory for guests also fixes a few corner cases where 0 was
not interpreted correctly and caused failures. (Arguments for numad when
using automatic placement, size of the balloon). This fixes problems
described in https://bugzilla.redhat.com/show_bug.cgi?id=1161461

Test case changes are added to verify that the schema change and code
behave correctly.
2015-03-16 14:32:20 +01:00
Peter Krempa
caf88a3c88 conf: Automatically use NUMA memory size in case NUMA is enabled
Use the NUMA total instead of the configured size both in XML and for
uses in the code once NUMA is enabled for a domain.

One test case change is necessary as the rounding of the individual cell
sizes was not matching the rounding of the total size.
2015-03-16 14:32:20 +01:00
Marek Marczykowski-Górecki
e1bfa03a83 tests: xenconfig: test for multiple USB devices and other HVM options
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-03-13 12:00:50 -06:00
Marek Marczykowski-Górecki
cd5dc3031f xenconfig: add support for multiple USB devices syntax
In Xen>=4.3, libxl supports new syntax for USB devices:
usbdevice=[ "DEVICE", "DEVICE", ... ]
Add support for that in xenconfig driver. When only one device is
defined, keep using old syntax for backward compatibility.

Adjust tests for changed options order.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-03-13 12:00:49 -06:00
Michal Privoznik
ea57049156 network_conf: Make virNetworkObj actually virObject
So far it's just a structure which happens to have 'Obj' in its
name, but otherwise it not related to virObject at all. No
reference counting, not virObjectLock(), nothing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Peter Krempa
3a83dcf43e test: qemu: json: Avoid using the now obsolete functions
Use the new single function instead of calling
qemuMonitorJSONGetBlockStatsInfo and
qemuMonitorJSONGetBlockStatsParamsNumber. This will allow to delete the
functions later while still maintaining coverage.
2015-03-11 11:28:04 +01:00
Peter Krempa
f6563bc361 qemu: monitor: Implement HMP version for listing all block device stats
Add a different version of parser for "info blockstats" that basically
parses the same information as the existing copy of the function.

This will allow us to remove the single device version
qemuMonitorGetBlockStatsInfo in the future.

The new implementation uses few new helpers so it should be more
understandable and provides a test case to verify that it works.
2015-03-11 11:28:04 +01:00
Peter Krempa
fc4713454d test: qemu: Fix qemu monitor test utils to allow testing HMP
qemu HMP commands sent by libvirt are terminated just by a '\r'. The
fake monitor used in tests wasn't prepared to handle this and the
communication would hang on an attempt to do a HMP conversation.

Add a special case for handling commands separated by \r in case HMP is
used.
2015-03-11 11:28:03 +01:00
Peter Krempa
32288fc9b9 qemu: monitor: Drop parsing of 'errs' from block info
The error count statistic is not supported by qemu, so there's no need
to pass the variables around if the result is ignored anyways.
2015-03-11 11:28:03 +01:00
Michal Privoznik
6cc5080a09 RNG: Allow multiple parameters to be passed to an interface filter
Our code supports that for ages. When using a <filterref/> to an
<interface/> several parameters can be passed to the filter. Later,
when building firewall rules, parameters are substituted for their
values. However, our RNG schema allowed only one parameter to be
passed.

Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 09:54:29 +01:00
Ján Tomko
5989b00563 Reverse the logic in virbitmaptest
Test the whole range in testBit, not just the first bit.
2015-03-10 13:45:51 +01:00
Pavel Hrdina
c2851781f1 tests: fix qemuxml2argvtest to be arch independent
Commit 5aee81a0 introduced a new test for disk-serial.  The test fails
on i686 arch because there is no need to add "-cpu qemu32" to command
line.  To fix the test update emulator in XML to "/usr/bin/qemu" so we
don't add the "-cpu qemu32" to command while running the test on i686 or
x86_64 host.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-09 13:34:37 +01:00
Martin Kletzander
5882064084 tests: Add test for os interleaving
We don't usually do tests purely for one change, but one change was
special because when users will migrate to OVMF/AAVMF, commit 18f9f69b
makes their lives easier by allowing them to interleave <type/> inside
<os/>.  It would be nice of us to keep the possibility of them pasting
the loader and nvram elements wherever it is valid, hence this test.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-09 07:52:34 +01:00
Martin Kletzander
6b22e0b562 tests: Add test for virtio-mmio address type
Commit 3e4b783e fixed an issue with RNG schema where this address type
was missing, this commit adds a test for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-09 07:52:34 +01:00
Michal Privoznik
b39b1397ea domain_conf: Format <pvpanic/> without address correctly
We have something like pvpanic device. However, in some cases it does
not have any address assigned, in which case we produce this ugly XML
(still valid though):

  <devices>
    <emulator>/usr/bin/qemu</emulator>
    ...
    <panic>
    </panic>
  </devices>

Lets format "<panic/>" instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-06 14:22:45 +01:00
Pavel Hrdina
cf521fc8ba memtune: change the way how we store unlimited value
There was a mess in the way how we store unlimited value for memory
limits and how we handled values provided by user.  Internally there
were two possible ways how to store unlimited value: as 0 value or as
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED.  Because we chose to store memory
limits as unsigned long long, we cannot use -1 to represent unlimited.
It's much easier for us to say that everything greater than
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED means unlimited and leave 0 as valid
value despite that it makes no sense to set limit to 0.

Remove unnecessary function virCompareLimitUlong.  The update of test
is to prevent the 0 to be miss-used as unlimited in future.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-06 11:52:24 +01:00
Peter Krempa
7909300498 conf: Remove duplicate entries in <metadata> by namespace
Since the APIs support just one element per namespace and while
modifying an element all duplicates would be removed, let's do this
right away in the post parse callback.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1190590
2015-03-05 16:24:34 +01:00
Michal Privoznik
5aee81a0cb qemu: Allow spaces in disk serial
https://bugzilla.redhat.com/show_bug.cgi?id=1195660

There's been a bug report appearing on the qemu-devel list, that
libvirt is unable to pass spaces in disk serial number [1]. Not only
our RNG schema forbids that, the code is not prepared either. However,
with a bit of escaping (if needed) we can allow spaces there.

1: https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg04041.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-05 13:35:55 +01:00
James Chapman
c9027d8f44 SRIOV NIC offload feature discovery
Adding functionality to libvirt that will allow it
query the ethtool interface for the availability
of certain NIC HW offload features

Here is an example of the feature XML definition:

<device>
<name>net_eth4_90_e2_ba_5e_a5_45</name>
  <path>/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.1/net/eth4</path>
  <parent>pci_0000_08_00_1</parent>
  <capability type='net'>
    <interface>eth4</interface>
    <address>90:e2:ba:5e:a5:45</address>
    <link speed='10000' state='up'/>
    <feature name='rx'/>
    <feature name='tx'/>
    <feature name='sg'/>
    <feature name='tso'/>
    <feature name='gso'/>
    <feature name='gro'/>
    <feature name='rxvlan'/>
    <feature name='txvlan'/>
    <feature name='rxhash'/>
    <capability type='80203'/>
  </capability>
</device>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-03-05 11:31:05 +01:00
Michal Privoznik
53cae19561 conf: s/virNetworkFindByName/virNetworkObjFindByName/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:12:16 +01:00
Michal Privoznik
82f240ae56 conf: s/virNetworkFindByUUID/virNetworkObjFindByUUID/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:11:40 +01:00
Prerna Saxena
8672a1e496 tests : Add test for 'ppc64le' architecture.
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
2015-03-03 10:58:02 +01:00
Peter Krempa
8eb907b8d0 schema: Fix interface link state schema
In commit edd1295e1d I've introduced an
XML element that allows to configure state of the network interface
link. Somehow the RNG schema hunk ended up in a weird place in the
network schema definition. Move it to the right place and add a test
case.

Note that the link state is set up via the monitor at VM startup so I
originally didn't think of adding a test case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1173468
2015-03-03 09:43:13 +01:00
John Ferlan
e0e290552b disk: Disallow duplicated target 'dev' values
https://bugzilla.redhat.com/show_bug.cgi?id=1142631

This patch resolves a situation where the same "<target dev='$name'...>"
can be used for multiple disks in the domain.

While the $name is "mostly" advisory regarding the expected order that
the disk is added to the domain and not guaranteed to map to the device
name in the guest OS, it still should be unique enough such that other
domblk* type operations can be performed.

Without the patch, the domblklist will list the same Target twice:

$ virsh domblklist $dom
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/file.qcow2
sda        /var/lib/libvirt/images/file.img

Additionally, getting domblkstat, domblkerror, domblkinfo, and other block*
type calls will not be able to reference the second target.

Fortunately, hotplug disallows adding a "third" sda value:

$ qemu-img create -f raw /var/lib/libvirt/images/file2.img 10M
$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sda
error: Failed to attach disk
error: operation failed: target sda already exists

$

BUT, it since 'sdb' doesn't exist one would get the following on the same
hotplug attempt, but changing to use 'sdb' instead of 'sda'

$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sdb
error: Failed to attach disk
error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'scsi0-0-1' for device

$

Since we cannot fix this issue at parsing time, the best that can be done so
as to not "lose" a domain is to make the check prior to starting the guest
with the results as follows:

$ virsh start $dom
error: Failed to start domain $dom
error: XML error: target 'sda' duplicated for disk sources '/var/lib/libvirt/images/file.qcow2' and '/var/lib/libvirt/images/file.img'

$

Running 'make check' found a few more instances in the tests where this
duplicated target dev value was being used. These also exhibited some
duplicated 'id=' values (negating the uniqueness argument of aliases) in
the corresponding .args file and of course the *xmlout version of a few
input XML files.
2015-03-02 22:38:36 -05:00
Ján Tomko
155ca616eb Allow creating volumes with a backing store but no capacity
The tool creating the image can get the capacity from the backing
storage. Just refresh the volume afterwards.

https://bugzilla.redhat.com/show_bug.cgi?id=958510
2015-03-02 08:07:11 +01:00
Ján Tomko
e3f1d2a820 Allow cloning volumes with no capacity specified
In virStorageVolCreateXML, add VIR_VOL_XML_PARSE_NO_CAPACITY
to the call parsing the XML of the new volume to make the capacity
optional.

If the capacity is omitted, use the capacity of the old volume.
We already do that for values that are less than the original
volume capacity.
2015-03-02 08:07:11 +01:00
Ján Tomko
cbd788eba6 Add flags argument to virStorageVolDefParse*
Allow the callers to pass down libvirt-internal flags.
2015-03-02 08:07:11 +01:00
Ján Tomko
496156807b Implement VIR_CONNECT_BASELINE_CPU_MIGRATABLE in the x86 cpu driver
Filter out non-migratable features if
VIR_CONNECT_BASELINE_CPU_MIGRATABLE was specified.
2015-03-02 07:59:12 +01:00
Ján Tomko
92572c3d71 Remove code handling the QEMU_CAPS_DOMID capability
This option is xenner-only (since commit b81a7ece),
and we dropped support for xenner in commit de9be0a.
2015-03-02 07:39:09 +01:00
Ján Tomko
9aa316612a Remove bootloader option from QEMU
It was only supported by xenner (since commit 763a59d8),
for which we removed support in commit de9be0a.

Remove the code generating this command line option,
refuse to parse it and delete the outdated tests.

https://bugzilla.redhat.com/show_bug.cgi?id=1176050
2015-03-02 07:39:09 +01:00
Laine Stump
4bbe1029f2 qemu: fix ifindex array reported to systemd
Commit f7afeddc added code to report to systemd an array of interface
indexes for all tap devices used by a guest. Unfortunately it not only
didn't add code to report the ifindexes for macvtap interfaces
(interface type='direct') or the tap devices used by type='ethernet',
it ended up sending "-1" as the ifindex for each macvtap or hostdev
interface. This resulted in a failure to start any domain that had a
macvtap or hostdev interface (or actually any type other than
"network" or "bridge").

This patch does the following with the nicindexes array:

1) Modify qemuBuildInterfaceCommandLine() to only fill in the
nicindexes array if given a non-NULL pointer to an array (and modifies
the test jig calls to the function to send NULL). This is because
there are tests in the test suite that have type='ethernet' and still
have an ifname specified, but that device of course doesn't actually
exist on the test system, so attempts to call virNetDevGetIndex() will
fail.

2) Even then, only add an entry to the nicindexes array for
appropriate types, and to do so for all appropriate types ("network",
"bridge", and "direct"), but only if the ifname is known (since that
is required to call virNetDevGetIndex().
2015-02-25 13:11:14 -05:00
Michal Privoznik
0e69d97648 cpu: Format <cpu/> properly
Well, not that we are not formatting invalid XML, rather than not as
beautiful as we can:

  <cpu mode='host-passthrough'>
  </cpu>

If there are no children, let's use the singleton element.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:26:04 +01:00
Michal Privoznik
83c5467ee9 util: Introduce virBufferAddBuffer
This API joins the following two lines:

char *s = virBufferContentAndReset(buf1);
virBufferAdd(buf2, s, -1);

into one:

virBufferAddBuffer(buf2, buf1);

With one exception: there's no re-indentation applied to @buf1.
The idea is, that in general both can have different indentation
(like the test I'm adding proves)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:23:42 +01:00
Stefan Zimmermann
09ab9dcc85 Prevent default creation of usb controller on s390 and s390x
Since s390 does not support usb the default creation of a usb controller
for a domain should not occur.

Also adjust s390 test cases by removing usb device instances since
usb devices are no longer created by default for s390 the s390
test cases need to be adjusted.

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2015-02-23 14:50:15 -05:00
Peter Krempa
103707d4b7 qemu: caps: Add capability bit for the "pc-dimm" device
The pc-dimm device represents a RAM memory module.
2015-02-20 19:25:09 +01:00
Peter Krempa
181742d43f conf: Move all NUMA configuration to virDomainNuma
For historical reasons data regarding NUMA configuration were split
between the CPU definition and numatune. We cannot do anything about the
XML still being split, but we certainly can at least store the relevant
data in one place.

This patch moves the NUMA stuff to the right place.
2015-02-20 17:50:08 +01:00
Peter Krempa
c03411199e conf: Allocate domain definition with the new helper
Use the virDomainDefNew() helper to allocate the definition instead of
doing it via VIR_ALLOC.
2015-02-20 17:43:05 +01:00
Peter Krempa
6b6166329f conf: numa: Recalculate rather than remember total NUMA cpu count
It's easier to recalculate the number in the one place it's used as
having a separate variable to track it. It will also help with moving
the NUMA code to the separate module.
2015-02-20 17:43:04 +01:00
Peter Krempa
2562141f19 conf: numa: Don't duplicate NUMA cell cpumask
The mask was stored both as a bitmap and as a string. The string is used
for XML output only. Remove the string, as it can be reconstructed from
the bitmap.

The test change is necessary as the bitmap formatter doesn't "optimize"
using the '^' operator.
2015-02-20 17:43:03 +01:00
Peter Krempa
34a1dd73b8 conf: Refactor virDomainNumaDefCPUParseXML
Rewrite the function to save a few local variables and reorder the code
to make more sense.

Additionally the ncells_max member of the virCPUDef structure is used
only for tracking allocation when parsing the numa definition, which can
be avoided by switching to VIR_ALLOC_N as the array is not resized
after initial allocation.
2015-02-20 17:43:03 +01:00
Pavel Hrdina
81dd81e475 virsh: fix vcpupin info
The "virDomainGetInfo" will get for running domain only live info and for
offline domain only config info. There was no way how to get config info
for running domain. We will use "vshCPUCountCollect" instead to get the
correct cpu count that we need to pass to "virDomainGetVcpuPinInfo".

Also cleanup some unnecessary variables and checks that are done by
drivers.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-02-20 16:17:19 +01:00
Michal Privoznik
af20423264 virQEMUCapsCacheLookupCopy: Filter qemuCaps based on machineType
Not all machine types support all devices, device properties, backends,
etc. So until we create a matrix of [machineType, qemuCaps], lets just
filter out some capabilities before we return them to the consumer
(which is going to make decisions based on them straight away).
Currently, as qemu is unable to tell which capabilities are (not)
enabled for given machine types, it's us who has to hardcode the matrix.
One day maybe the hardcoding will go away and we can create the matrix
dynamically on the fly based on a few monitor calls.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-20 13:28:04 +01:00
Michal Privoznik
7832fac847 qemuBuildMemoryBackendStr: Report backend requirement more appropriately
So, when building the '-numa' command line, the
qemuBuildMemoryBackendStr() function does quite a lot of checks to
chose the best backend, or to check if one is in fact needed. However,
it returned that backend is needed even for this little fella:

  <numatune>
    <memory mode="strict" nodeset="0,2"/>
  </numatune>

This can be guaranteed via CGroups entirely, there's no need to use
memory-backend-ram to let qemu know where to get memory from. Well, as
long as there's no <memnode/> element, which explicitly requires the
backend. Long story short, we wouldn't have to care, as qemu works
either way. However, the problem is migration (as always). Previously,
libvirt would have started qemu with:

  -numa node,memory=X

in this case and restricted memory placement in CGroups. Today, libvirt
creates more complicated command line:

  -object memory-backend-ram,id=ram-node0,size=X
  -numa node,memdev=ram-node0

Again, one wouldn't find anything wrong with these two approaches.
Both work just fine. Unless you try to migrated from the older libvirt
into the newer one. These two approaches are, unfortunately, not
compatible. My suggestion is, in order to allow users to migrate, lets
use the older approach for as long as the newer one is not needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-17 09:07:09 +01:00
Michal Privoznik
3806480696 qemuxml2argvtest: Fake response from numad
Well, we can pretend that we've asked numad for its suggestion and let
qemu command line be built with that respect. Again, this alone has no
big value, but see later commits which build on the top of this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-17 08:38:19 +01:00
Ján Tomko
6ba5d1afec Wire up mrg_rxbuf option for qemu
<interface ...>
  ...
  <model type='virtio'/>
  <driver ...>
    <host mrg_rxbuf='off'/>
  </driver>
</interface>

will result in:
-device virtio-net-pci,mrg_rxbuf=off,...

https://bugzilla.redhat.com/show_bug.cgi?id=1186886
2015-02-13 12:31:38 +01:00
Martin Kletzander
8680ea9749 docs, schema, conf: Add support for setting scheduler parameters of guest threads
In order for QEMU vCPU (and other) threads to run with RT scheduler,
libvirt needs to take care of that so QEMU doesn't have to run privileged.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-02-11 17:30:06 +01:00
Pavel Hrdina
9ec8da9704 bhyvexml2argvmock: change int to size_t for tapfdSize
Commit c5b6a4a5 forget to update also this mock function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-02-11 14:30:45 +01:00
Erik Skultety
357f0072ca conf: forbid seclabel duplicates for domain devices
Parser checks for per-domain seclabel duplicates, so it would be nice if
it checked for per-device seclabel duplicates the same way

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1165485
2015-02-11 09:45:22 +01:00
Erik Skultety
862bbf8a5a schema: allow multiple seclabel for devices in domaincommon.rng
In our RNG schema we do allow multiple (different) seclabels per-domain,
but don't allow this for devices, yet we neither have a check in our XML parser,
nor in a post-parse callback. In that case we should allow multiple
(different) seclabels for devices as well.
2015-02-11 09:41:36 +01:00
Peter Krempa
d7ec244f6e qemu: command: Shuffle around formatting of alias for RNG device backend
Move the alias name right after the object type for rng-egd backend so
that we can later use the JSON to commandline generator to create the
command line.
2015-02-10 13:05:22 +01:00
Luyao Huang
98e982b455 qemu: command: Make RNG backend device IDs unique
Libvirt didn't prefix the random number generator backend object alias
with any string thus the device alias and object alias were identical.

To avoid possible problems, rename the alias for the backend object and
tweak tests to comply with the change.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2015-02-10 13:05:22 +01:00
Martin Kletzander
3f9f4aa84f conf: disallow invalid values for video attributes
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1190956

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-02-10 09:05:36 +01:00
Ján Tomko
84f741812f Only parse custom vhost path for virtio interfaces
It is only supported for virtio adapters.
Silently drop it if it was specified for other models,
as is done for other virtio attributes.

Also mention this in the documentation.

https://bugzilla.redhat.com/show_bug.cgi?id=1147195
2015-02-06 12:52:50 +01:00
Peter Krempa
fdb80ed4f6 util: storage: Fix parsing of nbd:// URI without path
If a storage file would be backed with a NBD device without path
(nbd://localhost) libvirt would crash when parsing the backing path for
the disk as the URI structure's path element is NULL in such case but
the NBD parser would access it shamelessly.
2015-02-04 08:38:25 +01:00
Peter Krempa
df04741cd3 tests: virstoragetest: Switch backing chain test to use automatic numbering
I'm going to add a few test cases so it's the best time to convert the
test to automatic numbering.
2015-02-04 08:31:36 +01:00
Daniel P. Berrange
b38da58423 Make tests independant of system page size
Some code paths have special logic depending on the page size
reported by sysconf, which in turn affects the test results.
We must mock this so tests always have a consistent page size.
2015-02-02 20:27:43 +00:00
Peter Krempa
b92a003710 qemu: command: Don't combine old and modern NUMA node creation
Change done by commit f309db1f4d wrongly
assumes that qemu can start with a combination of NUMA nodes specified
with the "memdev" option and the appropriate backends, and the legacy
way by specifying only "mem" as a size argument. QEMU rejects such
commandline though:

$ /usr/bin/qemu-system-x86_64 -S -M pc -m 1024 -smp 2 \
-numa node,nodeid=0,cpus=0,mem=256 \
-object memory-backend-ram,id=ram-node1,size=12345 \
-numa node,nodeid=1,cpus=1,memdev=ram-node1
qemu-system-x86_64: -numa node,nodeid=1,cpus=1,memdev=ram-node1: qemu: memdev option must be specified for either all or no nodes

To fix this issue we need to check if any of the nodes requires the new
definition with the backend and if so, then all other nodes have to use
it too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1182467
2015-01-31 08:53:22 +01:00
Peter Krempa
b50b4ef30c qemu: command: Switch to bytes when formatting size for memory backends
QEMU's command line visitor as well as the JSON interface take bytes by
default for memory object sizes. Convert mebibytes to bytes so that we
can later refactor the existing code for hotplug purposes.
2015-01-31 08:53:22 +01:00
Peter Krempa
a47174c508 qemu: command: Unify values for boolean values when formating memory backends
QEMU's qapi visitor code allows yes/on/y for true and no/off/n for false
value of boolean properities. Unify the used style so that we can
generate it later and fix test cases.
2015-01-31 08:53:22 +01:00
Peter Krempa
172100ac85 qemu: command: Shuffle around formating of alias for memory backend objs
Move the alias as the second formated argument and tweak the tests so
that a future refactor that will change the order doesn't break tests.
2015-01-31 08:53:22 +01:00
Peter Krempa
331b2583ec qemu: command: Add helper to format -object strings from JSON representation
Unlike -device, qemu uses a JSON object to add backend "objects" via the
monitor rather than the string that would be passed on the commandline.

To be able to reuse code parts that configure backends for various
devices, this patch adds a helper that will allow generating the command
line representations from the JSON property object.
2015-01-31 08:53:22 +01:00
Peter Krempa
d793aeedf2 test: utils: Add helpers for automatic numbering of test cases
Adding or reordering test cases is usually a pain due to static test
case names that are then passed to virtTestRun(). To ease the numbering
of test cases, this patch adds two simple helpers that generate the test
names according to the order they are run. The test name can be
configured via the reset function.

This will allow us to freely add test cases in middle of test groups
without the need to re-number the rest of test cases.
2015-01-31 08:53:21 +01:00
Michal Privoznik
bbd3eb5098 conf: Don't mangle vcpu placement randomly
https://bugzilla.redhat.com/show_bug.cgi?id=1170492

In one of our previous commits (dc8b7ce7) we've done a functional
change even though it was intended as pure refactor. The problem is,
that the following XML:

 <vcpu placement='static' current='2'>6</vcpu>
 <cputune>
   <emulatorpin cpuset='1-3'/>
 </cputune>
 <numatune>
   <memory mode='strict' placement='auto'/>
 </numatune>

gets translated into this one:

 <vcpu placement='auto' current='2'>6</vcpu>
 <cputune>
   <emulatorpin cpuset='1-3'/>
 </cputune>
 <numatune>
   <memory mode='strict' placement='auto'/>
 </numatune>

We should not change the vcpu placement mode. Moreover, we're doing
something similar in case of emulatorpin and iothreadpin. If they were
set, but vcpu placement was auto, we've mistakenly removed them from
the domain XML even though we are able to set them independently on
vcpus.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-30 13:51:22 +01:00
Michal Privoznik
5222256849 schemas: Allow all generic elements and attributes for all interfaces
There are some interface types (notably 'server' and 'client')
which instead of allowing the default set of elements and
attributes (like the rest do), try to enumerate only the elements
they know of. This way it's, however, easy to miss something. For
instance, the <address/> element was not mentioned at all. This
resulted in a strange behavior: when such interface was added
into XML, the address was automatically generated by parsing
code. Later, the formatted XML hasn't passed the RNG schema. This
became more visible once we've turned on the XML validation on
domain XML changes: appending an empty line at the end of
formatted XML (to trick virsh think the XML had changed) made
libvirt to refuse the very same XML it formatted.

Instead of trying to find each element and attribute we are
missing in the schema, lets just allow all the elements and
attributes like we're doing that for the rest of types. It's no
harm if the schema is wider than our parser allows.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-29 16:23:15 +01:00
Michal Privoznik
436dcf0b74 qemu: Add AAVMF to the list of known UEFIs
Well, even though users can pass the list of UEFI:NVRAM pairs at the
configure time, we may maintain the list of widely available UEFI
ourselves too. And as arm64 begin to rises, OVMF was ported there too.
With a slight name change - it's called AAVMF, with AAVMF_CODE.fd
being the UEFI firmware and AAVMF_VARS.fd being the NVRAM store file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-29 15:20:47 +01:00
Michal Privoznik
bc03a23149 qemu: Allow UEFI paths to be specified at compile time
Up until now there are just two ways how to specify UEFI paths to
libvirt. The first one is editing qemu.conf, the other is editing
qemu_conf.c and recompile which is not that fancy. So, new
configure option is introduced: --with-loader-nvram which takes a
list of pairs of UEFI firmware and NVRAM store. This way, the
compiled in defaults can be passed during compile time without
need to change the code itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-29 15:20:42 +01:00
Daniel P. Berrange
f7afeddce9 qemu: report TAP device indexes to systemd
Record the index of each TAP device created and report them to
systemd, so they show up in machinectl status for the VM.
2015-01-27 13:57:02 +00:00
Daniel P. Berrange
55ea7be7d9 Removing probing of secondary drivers
For stateless, client side drivers, it is never correct to
probe for secondary drivers. It is only ever appropriate to
use the secondary driver that is associated with the
hypervisor in question. As a result the ESX & HyperV drivers
have both been forced to do hacks where they register no-op
drivers for the ones they don't implement.

For stateful, server side drivers, we always just want to
use the same built-in shared driver. The exception is
virtualbox which is really a stateless driver and so wants
to use its own server side secondary drivers. To deal with
this virtualbox has to be built as 3 separate loadable
modules to allow registration to work in the right order.

This can all be simplified by introducing a new struct
recording the precise set of secondary drivers each
hypervisor driver wants

struct _virConnectDriver {
    virHypervisorDriverPtr hypervisorDriver;
    virInterfaceDriverPtr interfaceDriver;
    virNetworkDriverPtr networkDriver;
    virNodeDeviceDriverPtr nodeDeviceDriver;
    virNWFilterDriverPtr nwfilterDriver;
    virSecretDriverPtr secretDriver;
    virStorageDriverPtr storageDriver;
};

Instead of registering the hypervisor driver, we now
just register a virConnectDriver instead. This allows
us to remove all probing of secondary drivers. Once we
have chosen the primary driver, we immediately know the
correct secondary drivers to use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-01-27 12:02:04 +00:00
Michal Privoznik
c6ec7c6b0b tests: Check for virQEMUDriverConfigNew return value
The function may return NULL if something went wrong. In some places
in the tests we are not checking the return value rather than
accessing the pointer directly resulting in SIGSEGV.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-26 17:34:33 +01:00
Ján Tomko
b54f48812d Fix a memory leak in virCgroupGetPercpuStats
Coverity reports that my commit af1c98e introduced
two memory leaks:
the cpumap if ncpus == 0 in virCgroupGetPercpuStats
and the params array in the test of the function.
2015-01-26 16:13:06 +01:00
Ján Tomko
d66e136bd5 Fix build with older gcc
My commit af1c98e4 broke the build on RHEL-6:
vircgrouptest.c: In function 'testCgroupGetPercpuStats':
vircgrouptest.c:566: error: nested extern declaration of
'_gl_verify_function2' [-Wnested-externs]

The only thing that needs checking is that the array size
is at least EXPECTED_NCPUS, to prevent access beyond the array.

We can ensure the minimum size also by specifying the array
size upfront.
2015-01-23 10:35:20 +01:00
Ján Tomko
af1c98e406 Fix virCgroupGetPercpuStats with non-continuous present CPUs
Per-cpu stats are only shown for present CPUs in the cgroups,
but we were only parsing the largest CPU number from
/sys/devices/system/cpu/present and looking for stats even for
non-present CPUs.
This resulted in:
internal error: cpuacct parse error
2015-01-22 17:01:11 +01:00
Ján Tomko
280ece4af9 qemu: format server interface without a listen address
https://bugzilla.redhat.com/show_bug.cgi?id=1130390

The listen address is not mandatory for <interface type='server'>
but when it's not specified, we've been formatting it as:
-netdev socket,listen=(null):5558,id=hostnet0
which failed with:
Device 'socket' could not be initialized

Omit the address completely and only format the port in the listen
attribute.

Also fix the schema to allow specifying a model.
2015-01-21 13:22:36 +01:00
Jim Fehlig
e274d5882e tests: fix xlconfigtest build failure
When libvirt is configured --without-xen, building the xlconfigtest
fails with

  CCLD   xlconfigtest
  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o
  In function `_start': (.text+0x20): undefined reference to `main'
  collect2: error: ld returned 1 exit status

Introduced in commit 4ed5fb91 by too much copy and paste from
xmconfigtest.
2015-01-20 21:03:09 -07:00
Josh Stone
298fa4858c network: Let domains be restricted to local DNS
This adds a new "localOnly" attribute on the domain element of the
network xml.  With this set to "yes", DNS requests under that domain
will only be resolved by libvirt's dnsmasq, never forwarded upstream.

This was how it worked before commit f69a6b987d, and I found that
functionality useful.  For example, I have my host's NetworkManager
dnsmasq configured to forward that domain to libvirt's dnsmasq, so I can
easily resolve guest names from outside.  But if libvirt's dnsmasq
doesn't know a name and forwards it to the host, I'd get an endless
forwarding loop.  Now I can set localOnly="yes" to prevent the loop.

Signed-off-by: Josh Stone <jistone@redhat.com>
2015-01-20 01:07:18 -05:00
Gary R Hook
e11490e358 Make ZFS storage pool XML tests optional
Do not run ZFS tests when ZFS is unsupported in the environment.

The recent patch b4af40226d adds tests
to storagepoolxml2xmltest for the optional ZFS feature. When ZFS is
not included in the configuration these tests should not / cannot be
run. Modify the test source file to check for use of the feature and
compile in the tests accordingly.

Signed-off-by: Gary R Hook <gary.hook@nimboxx.com>
2015-01-19 15:03:01 +01:00
Ján Tomko
bc378060f7 Add an XML test for host-model CPU with features
This was broken in a dowstream build due to a missing backport:
https://bugzilla.redhat.com/show_bug.cgi?id=1182448
2015-01-19 10:11:15 +01:00
Dmitry Guryanov
c8a6f844c3 add ploop fs driver type
Ploop is a pseudo device which makeit possible to access
to an image in a file as a block device. Like loop devices,
but with additional features, like snapshots, write tracker
and without double-caching.

It used in PCS for containers and in OpenVZ. You can manage
ploop devices and images with ploop utility
(http://git.openvz.org/?p=ploop).

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-01-16 14:07:46 +01:00
Martin Kletzander
6514c04c18 qemu: Add support for enabling/disabling PMU
This is used as a boolean parameter for the '-cpu' option.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-01-16 13:43:46 +01:00
Martin Kletzander
199390117c docs, schema, conf: Add support for PMU feature
Just a new feature that can be turned on/off.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-01-16 13:43:46 +01:00
Erik Skultety
78f911d7d0 Add XML test for too many PCI devices on default PCI bus 2015-01-16 10:59:26 +01:00
Cédric Bosdonnat
a117652917 Use the network route definitions for domains 2015-01-16 10:14:03 +01:00