Commit Graph

2883 Commits

Author SHA1 Message Date
Jiri Denemark
8ba37e7a6e domaincapstest: Use arch strings
They are shorter and most of the code requires the strings anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-16 10:37:29 +02:00
Michal Privoznik
4b3a46ca6a tests: Introduce check-file-access.pl
This script will check output generated by virtestmock against a
white list. All non matching records found are printed out. So
far, the white list is rather sparse at the moment.
This test should be ran only after all other tests finished, and
should cleanup the temporary file before their execution. Because
I'm unable to reflect these requirements in Makefile.am
correctly, I've introduced new target 'check-access' under which
this test is available.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:46:44 +02:00
Michal Privoznik
6326865e6b virtestmock: Print invalid file accesses into a file
All the accesses to files outside our build or source directories
are now identified and appended into a file for later processing.
The location of the file that contains all the records can be
controlled via VIR_TEST_FILE_ACCESS env variable and defaults to
abs_builddir "/test_file_access.txt".

The script that will process the access file is to be added in
next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:46:23 +02:00
Michal Privoznik
47d2dc831a tests: Introduce global mock library
The intent is that this library is going to be called every time
to check if we are not touching anything outside srcdir or
builddir.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:30:25 +02:00
Michal Privoznik
86d1705a8a virmock.h: Introduce VIR_MOCK_CALL_STAT
There is some magic going on when it comes to stat() or lstat().
Basically, stat() can either be a regular function, an inline
function that calls __xstat(_STAT_VER, ...) or a macro that does
the same as the inline func. Don't ask why is that, just read the
documentation in sys/stat.h and make sure you have a bucket next
to you. Anyway, currently there will not be both stat and __xstat
symbols at the same time, as one of them gets overwritten to the
other one during compilation. But this is not true anymore once
we start chaining our mocking libraries. Therefore we need a
wrapper that calls desired function from glibc.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:25:56 +02:00
Michal Privoznik
a1ffedc682 securityselinuxhelper: Adapt to virmock.h
Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:22:12 +02:00
Michal Privoznik
ca88c0e7b2 nssmock: Adapt to virmock.h
Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:19:51 +02:00
Michal Privoznik
d16b7a8853 vircgroupmock: Adapt to virmock.h
Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:18:14 +02:00
Michal Privoznik
57c484dbac virpcimock: Adapt to virmock.h
Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:10:40 +02:00
Jim Fehlig
b90c4b5f50 xlconfigtests: use qemu-xen in all test data files
Some of the test configuration files in tests/xlconfigdata
use the old qemu-dm as the emulator. Many of the configuration
features tested (spice, rbd, multi-usb) are not even usable with
the old qemu. Change these files to use the new qemu-xen (also
known as qemu upstream) emulator.

Note: This change fixes xlconfigtest failures when the old
qemu is actually installed on the system. During device post
parse, the libxl driver attempts to invoke the emulator to
determine if it is the old or new qemu so it can properly set
video RAM defaults. With the old qemu installed, the default
video RAM was set differently than the expected value.
Changing all the test data files to use qemu-xen ensures
predictable results wrt default video RAM size.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-05-13 10:08:34 -06:00
Ján Tomko
96b21fb0ec Fix tests to include video ram size
My commit 3e42867 started filling out the video size in post-parse,
but did not adjust the tests.
2016-05-12 14:32:17 +02:00
Laine Stump
e5aecc2f80 conf: log error when incorrect PCI root controller is added to domain
libvirt may automatically add a pci-root or pcie-root controller to a
domain, depending on the arch/machinetype, and it hopefully always
makes the right decision about which to add (since in all cases these
controllers are an implicit part of the virtual machine).

But it's always possible that someone will create a config that
explicitly supplies the wrong type of PCI controller for the selected
machinetype. In the past that would lead to an error later when
libvirt was trying to assign addresses to other devices, for example:

  XML error: PCI bus is not compatible with the device at
  0000:00:02.0. Device requires a PCI Express slot, which is not
  provided by bus 0000:00

(that's the error message that appears if you replace the pcie-root
controller in a Q35 domain with a pci-root controller).

This patch adds a check at the same place that the implicit
controllers are added (to ensure that the same logic is used to check
which type of pci root is correct). If a pci controller with index='0'
is already present, we verify that it is of the model that we would
have otherwise added automatically; if not, an error is logged:

  The PCI controller with index='0' must be " model='pcie-root' for
  this machine type, " but model='pci-root' was found instead.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1004602
2016-05-10 17:03:24 -04:00
Michal Privoznik
cd25acba26 seclabeltest: Update to use VIRT_TEST_MAIN
Our tests should use either VIRT_TEST_MAIN() or
VIRT_TEST_MAIN_PRELOAD() macros which create main() function and
call the passed callback subsequently. This is important because
the wrapper which calls the callback eventually does important
stuff like setting logging based on env variables and such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-10 17:16:11 +02:00
Pavel Hrdina
1ccc7fbff3 qemu_hotplug: fix checking graphics ports
We cannot change ports for running domain and we should error out if
autoport is enabled.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-10 10:44:46 +02:00
Pavel Hrdina
9f51c1c7c7 graphics: generate fake ports also for tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-10 10:44:45 +02:00
Cole Robinson
5ed235c68f domaincaps: Report video modelType
Requires adding the plumbing for <device><video>
The value is <enum name='modelType'> to match the associated domain
XML of <video><model type='XXX'/>

Wire it up for qemu too
2016-05-09 16:05:31 -04:00
Cole Robinson
6da27ad1b5 domaincaps: Report graphics type enum
Requires adding the plumbing for <device><graphics>
Wire it up for qemu too
2016-05-09 16:05:31 -04:00
Pavel Hrdina
99c17cb205 genericxml2xml: add several graphics tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-06 15:53:16 +02:00
Jiri Denemark
3957dd1acf domaincapstest: Add tests for QEMU 2.6
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:38:31 +02:00
Jiri Denemark
3d59cce230 qemucapabilitiestest: Add tests for aarch64 and ppc64le
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:38:30 +02:00
Jiri Denemark
f51e8a6282 domaincapstest: Use default machine type
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:38:30 +02:00
Jiri Denemark
7aa86f6358 qemucapabilitiestest: Rename *.caps to *.xml
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:38:30 +02:00
Jiri Denemark
55b1073451 qemucapabilitiestest: Test all capabilities
Enhance the test to cover all capabilities we probe for rather than
testing the flags only.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:35:32 +02:00
Jiri Denemark
a37ffef5e9 qemucapabilitiestest: Reorder flags in caps files
The flags should follow the order in which they are defined in
virQEMUCaps enum.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:27:33 +02:00
Jiri Denemark
a3ac028713 qemucapabilitiestest: Reindent *.caps files
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:27:33 +02:00
Jiri Denemark
0afb159d11 qemucapabilitiestest: Uses consistent names
In other tests we use "expected" and "actual" to refer to the expected
outcome of the tested API and the result we got, respectively.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:27:33 +02:00
Jiri Denemark
800c98af6f qemucapabilitiestest: Prepare for testing non-x86_64 archs
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:26:28 +02:00
Jiri Denemark
d90877f7eb tests: Refactor domaincapstest
The test was just a big mess passing callbacks and their data through
data for another callback.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:26:28 +02:00
Jiri Denemark
f943a28ca8 tests: Add qemucapsprobe helper
Adding new *.replies files for qemucapabilitiestest or updating the
files when libvirt adds an additional QMP command into the probing
process is quite painful. The goal of the new qemucapsprobe command is
to make this process as easy as

    tests/qemucapsprobe /path/to/qemu/binary >caps.replies

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-05 10:01:55 +02:00
Jiri Denemark
7197e5fd3f virjson: Make pretty format more compact
json_reformat uses two spaces for when indenting nested objects, let's
do the same. The result of virJSONValueToString will be exactly the same
as json_reformat would produce.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-05 10:01:55 +02:00
Jiri Denemark
18f63c17a4 tests: Decouple preload code from main()
The new VIRT_TEST_PRELOAD macro does not force the caller to create a
special main function which would need to be called through
virtTestMain().

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-05 10:01:55 +02:00
Jiri Denemark
dd214b5fb6 tests: Create a shared library with qemu driver
Currently all qemu driver tests are statically linked to qemu driver
library, which makes it impossible to mock any API from the library.
This patch creates a shared qemu driver library which can be used
instead of the static one.

NB we can't use libvirt_driver_qemu.so directly since it is linked with
-module and it is supposed to be dlopened.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-05 10:01:55 +02:00
John Ferlan
d0b5845952 qemu: Add 'iothread' to command line for supported controller
https://bugzilla.redhat.com/show_bug.cgi?id=1286709

Now that we have all the pieces in place, we can add the 'iothread=#' to
the command line for the (two) controllers that support it (virtio-scsi-pci
and virtio-scsi-ccw). Add the tests as well...
2016-05-04 09:59:14 -04:00
John Ferlan
e0d0e53086 conf: Add support for virtio-scsi iothreads
Add the ability to add an 'iothread' to the controller which will be how
virtio-scsi-pci and virtio-scsi-ccw iothreads have been implemented in qemu.

Describe the new functionality and add tests to parse/validate that the
new attribute can be added.
2016-05-04 09:59:14 -04:00
John Ferlan
e2faa97672 qemu: Add capability for virtio-scsi iothreads
An iothread for virtio-scsi is a property of the controller. Add a lookup
of the 'virtio-scsi-pci' and 'virtio-scsi-ccw' device properties and parse
the output.  For both, support for the iothread was added in qemu 2.4
while support for virtio-scsi in general was added in qemu 1.4.

Modify the various mock capabilities replies (by hand) to reflect the
when virtio-scsi was supported and then specifically when the iothread
property was added. For versions prior to 1.4, use the no device error
return for virtio-scsi. For versions 1.4 to before 2.4, add some data
for virtio-scsi-pci even though it isn't complete we're not looking for
anything specific there anyway. For 2.4 to 2.6, add a more complete reply.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-03 14:08:05 -04:00
Erik Skultety
9b45c9f049 virnetsocket: Provide socket address format in a more standard form
Our socket address format is in a rather non-standard format and that is
because sasl library requires the IP address and service to be delimited by a
semicolon. The string form is a completely internal matter, however once the
admin interfaces to retrieve client identity information are merged, we should
return the socket address string in a common format, e.g. format defined by
URI rfc-3986, i.e. the IP address and service are delimited by a colon and
in case of an IPv6 address, square brackets are added:

Examples:
    127.0.0.1:1234
    [::1]:1234

This patch changes our default format to the one described above, while adding
separate methods to request the non-standard SASL format using semicolon as a
delimiter.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-05-03 15:52:50 +02:00
Cole Robinson
600977e293 qemu: support configuring usb3 controller port count
This adds a ports= attribute to usb controller XML, like

  <controller type='usb' model='nec-xhci' ports='8'/>

This maps to:

  qemu -device nec-usb-xhci,p2=8,p3=8

Meaning, 8 ports that support both usb2 and usb3 devices. Gerd
suggested to just expose them as one knob.

https://bugzilla.redhat.com/show_bug.cgi?id=1271408
2016-05-03 08:58:30 -04:00
Cole Robinson
48e12de51e qemu: caps: introduce QEMU_CAPS_NEC_USB_XHCI_PORTS
Reports whether we support -device nec-usb-xhci,p3=XXX value,
which has been available since qemu 1.3.0
2016-05-03 08:58:30 -04:00
Erik Skultety
a32135b3b1 rpc: virnetserverclient: Introduce new attribute conn_time to client
Besides ID, libvirt should provide several parameters to help the user
distinguish two clients from each other. One of them is the connection
timestamp. This patch also adds a testcase for proper JSON formatting of the
new attribute too (proper formatting of older clients that did not support
this attribute yet is included in the existing tests) - in order to
testGenerateJSON to work, a mock of time_t time(time_t *timer) needed to be
created.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-05-02 22:25:52 +02:00
Erik Skultety
5841d64d25 rpc: virnetserverclient: Identify clients by an integer ID
Admin API needs a way of addressing specific clients. Unlike servers, which we
are happy to address by names both because its name reflects its purpose (to
some extent) and we only have two of them (so far), naming clients doesn't make
any sense, since a) each client is an anonymous, i.e. not recognized after a
disconnect followed by a reconnect, b) we can't predict what kind of requests
it's going to send to daemon, and c) the are loads of them comming and going,
so the only viable option is to use an ID which is of a reasonably wide data
type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-05-02 22:25:51 +02:00
Boris Fiuczynski
383c6f7f4d tests: add tests for panic device model s390
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-05-02 17:01:40 +02:00
Boris Fiuczynski
73e4e10e62 qemu: add default panic device to S390 guests
This patch adds by default a panic device with model s390 to S390 guests.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-05-02 17:01:40 +02:00
Cole Robinson
b1fc6a7b73 conf: domain: reject name containing '/'
Trying to define a domain name containing an embedded '/'
will immediately fail when trying to write the XML to disk for
our stateful drivers. This patch explicitly rejects names
containing a '/', and provides an xmlopt feature for drivers
to avoid this validation check, which is enabled in every
non-stateful driver that already has xmlopt handling wired up.

(Technically this could reject a previously accepted vmname like
 '/foo', however at least for the qemu driver that falls over
 later when starting qemu)

https://bugzilla.redhat.com/show_bug.cgi?id=639923
2016-05-02 10:06:04 -04:00
Martin Kletzander
541f21afa6 conf: Parse more of our nodedev XML
We were lacking tests that are checking for the completeness of our
nodedev XMLs and also whether we output properly formatted ones.  This
patch adds parsing for the capability elements inside the <capability
type='pci'> element.  Also bunch of tests are added to show everything
works properly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-05-02 15:46:23 +02:00
Martin Kletzander
9840761fb4 schemas: Update nodedev schema to match reality
There were few things done in the nodedev code but we were lacking tests
for it.  And because of that we missed that the schema was not updated
either.  Fix the schema and add various test files to show the schema
is correct.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-05-02 15:46:23 +02:00
Martin Kletzander
88c8be67d4 Move capability formatting together
All sub-PCI capabilities should be next to each other for clarity.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-05-02 15:46:23 +02:00
John Ferlan
27726d8c21 qemu: Introduce qemuDomainHostdevPrivatePtr
Modeled after the qemuDomainDiskPrivatePtr logic, create a privateData
pointer in the _virDomainHostdevDef to allow storage of private data
for a hypervisor in order to at least temporarily store auth/secrets
data for usage during qemuBuildCommandLine.

NB: Since the qemu_parse_command (qemuParseCommandLine) code is not
expecting to restore the auth/secret data, there's no need to add
code to handle this new structure there.

Updated copyrights for modules touched. Some didn't have updates in a
couple years even though changes have been made.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
Peter Krempa
833ae6b435 qemu: hotplug: Skip waiting for tray opening if qemu doesn't notify us
If qemu doesn't support DEVICE_TRAY_MOVED event the code that attempts
to change media would attempt to re-eject the tray even if it wouldn't
be notified when the tray opened. Add a capability bit and skip retrying
for old qemus.
2016-05-02 08:49:34 +02:00
Martin Kletzander
0c56d94318 tools: Fix connect command
The man page says: "(Re)-Connect to the hypervisor. When the shell is
first started, this is automatically run with the URI parameter
requested by the "-c" option on the command line."  However, if you run:

  virsh -c 'test://default' 'connect; uri'

the output will not be 'test://default'.  That's because the 'connect'
command does not care about any virsh-only related settings and if it is
run without parameters, it connects with @uri == NULL.  Not only that
doesn't comply to what the man page describes, but it also doesn't make
sense.  It also means you aren't able to reconnect to whatever you are
connected currently.

So let's fix that in both virsh and virt-admin add a test case for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-05-02 07:18:25 +02:00
Martin Kletzander
55320c23dd qemu: Regenerate VNC socket paths
Similarly to what commit 7140807917 did with some internal paths,
clear vnc socket paths that were generated by us.  Having such path in
the definition can cause trouble when restoring the domain.  The path is
generated to the per-domain directory that contains the domain ID.
However, that ID will be different upon restoration, so qemu won't be
able to create that socket because the directory will not be prepared.

To be able to migrate to older libvirt, skip formatting the socket path
in migratable XML if it was autogenerated.  And mark it as autogenerated
if it already exists and we're parsing live XML.

Best viewed with '-C'.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-28 16:13:45 +02:00