Commit Graph

2946 Commits

Author SHA1 Message Date
Pavel Hrdina
360cbf6f83 graphics: don't parse listens if socket attribute is present
If socket attribute is present we start VNC that listens only on that
unix socket.  This makes the parser behave the same way as we actually
use the socket attribute.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-17 10:41:45 +02:00
Andrea Bolognani
0e8a72a5ef qemu: Drop QEMU_CAPS_VIRTIO_BLK_SG_IO
The only QEMU versions that don't have such capability are <0.11,
which we no longer support anyway
2016-05-17 00:01:45 +02:00
Andrea Bolognani
859743c27c qemu: Drop QEMU_CAPS_CPU_HOST
The only QEMU versions that don't have such capability are <0.11,
which we no longer support anyway
2016-05-17 00:01:45 +02:00
Andrea Bolognani
8531b85ba6 qemu: Drop QEMU_CAPS_PCI_ROMBAR
The only QEMU versions that don't have such capability are <0.12,
which we no longer support anyway.

Additionally, this solves the issue of some QEMU binaries being
reported as not having such capability just because they lacked
the {kvm-}pci-assign QMP object.
2016-05-17 00:01:45 +02:00
Cole Robinson
e3a6859019 qemu: command: Use -name guest= if available
-name guest= is the explicit parameter for passing a VM name. Using
it is required to allow a VM with an '=' in the name

https://bugzilla.redhat.com/show_bug.cgi?id=1276485
2016-05-16 10:30:38 -04:00
Cole Robinson
7dbbc0ca07 qemu: command: escape commas in chardev socket path
After this, a default virt-manager VM will startup with a comma
in the VM name:

https://bugzilla.redhat.com/show_bug.cgi?id=639926
2016-05-16 10:30:38 -04:00
Cole Robinson
077ba95677 qemu: command: escape commas in VNC socket path
This path can be dependent on the VM libdir, which contains its name
2016-05-16 10:30:38 -04:00
Cole Robinson
3153ac08c9 qemu: command: escape commas in secret master path
Need to convert the local function to virBuffer usage, so we
can use qemuBufferEscapeComma
2016-05-16 10:30:38 -04:00
Cole Robinson
0f377eb1b0 qemu: command: escape commas in VM name
This isn't sufficient on its own, since the VM name is used for things
like monitor paths, which we don't escape yet
2016-05-16 10:30:38 -04:00
Peter Krempa
eb2116fd9a util: alloc: Introduce freeing helpers that clear the memory before freeing
For a few cases where we handle secret information it's good to clear
the buffers containing sensitive data before freeing them.

Introduce VIR_DISPOSE, VIR_DISPOSE_N and VIR_DISPOSE_STRING that allow
simple clearing fo the buffers holding sensitive information on cleanup
paths.
2016-05-16 12:58:48 +02:00
Jiri Denemark
ced1e846a0 capabilities: Advertise cpuselection if -cpu host is usable
When -cpu host is supported by a QEMU binary, a user can use
<cpu mode='host-passthrough'/> in domain XML even when libvirtd failed
to find a matching model for the host CPU. Let's make it obvious by
advertising <cpuselection/> guest capability whenever -cpu host is
supported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-16 10:42:28 +02:00
Jiri Denemark
1522503189 qemuaincapstest: Give better names to test data files
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-16 10:37:29 +02:00
Jiri Denemark
9ac9b039c4 domaincapstest: Give better names to test data files
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-16 10:37:29 +02:00
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
Cole Robinson
67f2b72723 conf: Drop restrictions on rng backend path
Currently we only allow /dev/random and /dev/hwrng as host input
for <rng><backend model='random'/> device. This was added after
various upstream discussions in commit 4932ef45

However this restriction has generated quite a few complaints over
the years, so a new discussion was initiated:

http://www.redhat.com/archives/libvir-list/2016-April/msg00987.html

Several people suggested removing the restriction, and nobody really
spoke up to defend it. So this patch drops the path restriction
entirely

https://bugzilla.redhat.com/show_bug.cgi?id=1074464
2016-04-26 11:43:33 -04:00
Cole Robinson
600a666ce5 schema: Allow space character in disk vendor/product
The hex range already tried to allow for it, but it wasn't using
the correct XML hex syntax. Fix it, and test it
2016-04-26 10:29:44 -04:00
Cole Robinson
856e84a516 tests: consistently source test-lib.sh in scripts
This unifies the test scripts to all use the similar pattern added for
schematests in ace4aecd. This gives the following

- Enables running all tests from outside of tests/ dir
- Drops redundant abs_* definitions, which are set by test-lib.sh
- Drops unnecessary srcdir variable which was only used for sourcing
    test-lib.sh

Behavior changes:

- srcdir can no longer be overwritten, but I don't know why anyone would
    really need to...
- Script VERBOSE setting no longer prints commands executed by test-lib.sh.
    if anyone cares I suggest handling this in test-lib.sh which already
    has other verbose style handling
2016-04-23 15:41:40 -04:00
Cole Robinson
fa90464faa tests: remove 'reconnect' and 'statstest'
These old tests expect to run against a real xen connection via
xend running on the host. Our intentions for the test suite are
that it doesn't require interacting with any specific host resources,
so these don't really belong here.
2016-04-23 13:37:09 -04:00
Cole Robinson
4839822faf tests: rename test_conf -> virconftest
And confdata to virconfdata, since 'conf' can mean a few different
things in libvirt
2016-04-21 18:14:07 -04:00
Cole Robinson
6cf52a2ffd tests: consistently name virsh tests with 'virsh-' prefix 2016-04-21 18:14:07 -04:00
Cole Robinson
af9d6b1c8c tests: build: Remove duplicate libvirtd test list
Store the test list in libvirtd_test_scripts, and use it where
appropriate. This also fixes the fact that we didn't ship
virsh-uriprecedence when libvirtd build is disabled.
2016-04-21 18:14:07 -04:00
Cole Robinson
3cc2a9e0d4 virconf: Handle conf file without ending newline
$ echo -n 'log_level=1' > ~/.config/libvirt/libvirtd.conf
$ libvirtd --timeout=10
2014-10-10 10:30:56.394+0000: 6626: info : libvirt version: 1.1.3.6, package: 1.fc20 (Fedora Project, 2014-09-08-17:50:42, buildvm-05.phx2.fedoraproject.org)
2014-10-10 10:30:56.394+0000: 6626: error : main:1261 : Can't load config file: configuration file syntax error: /home/rjones/.config/libvirt/libvirtd.conf:1: expecting a value: /home/rjones/.config/libvirt/libvirtd.conf

Rather than try to fix this in the depths of the parser, just catch
the case when a config file doesn't end in a newline, and manually
append a newline to the content before parsing

https://bugzilla.redhat.com/show_bug.cgi?id=1151409
2016-04-21 18:14:07 -04:00
Laine Stump
bf3d9f305e network: fix DHCPv6 on networks with prefix != 64
According to the dnsmasq manpage, the netmask for IPv4 address ranges
will be auto-deteremined from the interface dnsmasq is listening on,
but it can't do this for IPv6 for some reason - it instead assumes a
network prefix of 64 for all IPv6 address ranges. If this is
incorrect, dnsmasq will refuse to give out an address to clients,
instead logging this message:

 dnsmasq-dhcp[2380]: no address range available for DHCPv6 request via virbr0

The solution is for libvirt to add ",$prefix" to all IPv6 dhcp-range
arguments when building the dnsmasq.conf file.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1033739
2016-04-21 15:06:25 -04:00
Erik Skultety
ac55654e35 tests: virnetdaemontest: Enable testing for no-keepalive-required
Commit a8743c39 removed keepalive_required attribute from daemon, added a test
case for it, but forgot to enable the test itself in virnetdaemontest.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-21 12:36:03 +02:00
Erik Skultety
8da7520d22 tests: virnetdaemon: Replace tabs with spaces
We already did this once, but somehow commit 252610f7 managed to bring the tabs
back again.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-21 12:36:03 +02:00
Erik Skultety
4b5be9adb4 tests: remove virnetservertest data leftovers
Commit a4746114 renamed virnetservertest to virnetdaemontest to reflect some
refactor changes to virNetServer code (which moved daemon-related parts to
virNetDaemon module). Moving test data from virnetserverdata to
virnetdaemondata was also part of the commit, but the commit failed to clean
half of the files that were copied (rather than moved).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-04-21 12:36:03 +02:00
Cole Robinson
487d211d20 storage: remove support for /usr/bin/kvm-img
This an ubuntu/debian packaging convention. At one point it may have
been an actually different binary, but at least as of ubuntu precise
(the oldest supported ubuntu distro, released april 2012) kvm-img is
just a symlink to qemu-img for back compat.

I think it's safe to drop support for it
2016-04-20 08:55:36 -04:00
Andrea Bolognani
bf01999e9f tests: Fix enumeration value
Commit 3a773c43c8 introduced the testCompareNetXML2XMLResult
enumeration; however, in one instance the result variable was
assigned a value from the very similar testCompareDocXML2XMLResult
enumeration, leading to a build error.

  networkxml2xmltest.c:33:42: error:
    implicit conversion from enumeration type 'testCompareDomXML2XMLResult'
    to different enumeration type 'testCompareNetXML2XMLResult'
    [-Werror,-Wenum-conversion]

  testCompareNetXML2XMLResult result = TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS;
                              ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use the proper value (TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS) instead.
2016-04-20 14:36:37 +02:00
Andrea Bolognani
4e2d82f72b conf: Expose GIC capabilities
Add information about GIC capabilities to virDomainCaps and update
the formatter to include them in the XML output.
2016-04-20 12:52:41 +02:00
Andrea Bolognani
29980231db conf: Get rid of virDomainCapsDevice
The struct contains a single boolean field, 'supported':
the meaning of this field is too generic to be limited to
devices only, and in fact it's already being used for
other things like loaders and OSs.

Instead of trying to come up with a more generic name just
get rid of the struct altogether.
2016-04-20 12:41:54 +02:00
Laine Stump
3583e75d7e network: prevent duplicate entries in network device pools
Prior to this patch we didn't make any attempt to prevent two entries
in the array of interfaces/PCI devices from pointing to the same
device.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1002423
2016-04-19 12:39:13 -04:00
Laine Stump
3a773c43c8 test: enable testing for expected parse errors in network XML
This is patterned after similar functionality for domain XML tests,
but tries harder to avoid reading non-existent networkxml2xmlout data
file when parse fails.
2016-04-19 12:35:22 -04:00
Martin Kletzander
aca4d72b2a Include sysmacros.h where needed
So in glibc-2.23 sys/sysmacros.h is no longer included from sys/types.h
and we don't build because of the usage of major/minor/makedev macros.
Autoconf already has AC_HEADER_MAJOR macro that check where exactly
these functions/macros are defined, so let's use that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-18 20:36:57 +02:00
John Ferlan
dd1400280e tests: Fix syntax in iSCSI auth/secret tests
While working on the tests for the secret initialization vector, I found
that the existing iSCSI tests were lacking in how they defined the IQN.
Many had IQN's of just 'iqn.1992-01.com.example' for one disk while using
'iqn.1992-01.com.example/1' for the second disk (same for hostdevs - guess
how they were copied/generated).

Typically (and documented this way), IQN's would include be of the form
'iqn.1992-01.com.example:storage/1' indicating an IQN using "storage" for
naming authority specific string and "/1" for the iSCSI LUN.

So modify the input XML's to use the more proper format - this of course
has a ripple effect on the output XML and the args.

Also note that the "%3A" is generated by the virURIFormat/xmlSaveUri
to represent the colon.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-04-18 12:31:50 -04:00
Jason J. Herne
0e570a6acc Libvirt: virTypedParamsValidate: Fix detection of multiple parameters
virTypedParamsValidate currently uses an index based check to find
duplicate parameters. This check does not work. Consider the following
simple example:

We have only 2 keys
A  (multiples allowed)
B  (multiples NOT allowed)

We are given the following list of parameters to check:
A
A
B

If you work through the validation loop you will see that our last iteration
through the loop has i=2 and j=1. In this case, i > j and keys[j].value.i will
indicate that multiples are not allowed. Both conditionals are satisfied so
an incorrect error will be given: "parameter '%s' occurs multiple times"

This patch replaces the index based check with code that remembers
the name of the last parameter seen and only triggers the error case if
the current parameter name equals the last one. This works because the
list is sorted and duplicate parameters will be grouped together.

In reality, we hit this bug while using selective block migration to migrate
a guest with 5 disks. 5 was apparently just the right number to push i > j
and hit this bug.

virsh migrate --live guestname --copy-storage-all
              --migrate-disks vdb,vdc,vdd,vde,vdf
              qemu+ssh://dsthost/system

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
2016-04-18 15:57:20 +02:00
Peter Krempa
2242a00822 qemu: caps: Deprecate QEMU_CAPS_BALLOON
The flag is now unused and all qemus supported by libvirt already
support it.
2016-04-15 14:27:08 +02:00
Laine Stump
8b62c65d24 qemu: support new pci controller model "pcie-expander-bus"
This is backed by the qemu device pxb-pcie, which will be available in
qemu 2.6.0.

As with pci-expander-bus (which uses qemu's pxb device), the busNr
attribute and <node> subelement of <target> are used to set the bus_nr
and numa_node options.

During post-parse we validate that the domain's machinetype is
q35-based (since the device shows up for 440fx-based machinetypes, but
is unusable), as well as checking that <node> specifies a node that is
actually configured on the guest.
2016-04-14 14:00:34 -04:00
Laine Stump
bc07251f59 conf: new pci controller model pcie-expander-bus
This controller provides a single PCIe port on a new root. It is
similar to pci-expander-bus, intended to provide a bus that can be
associated with a guest-identifiable NUMA node, but is for
machinetypes with PCIe rather than PCI (e.g. q35-based machinetypes).

Aside from PCIe vs. PCI, the other main difference is that a
pci-expander-bus has a companion pci-bridge that is automatically
attached along with it, but pcie-expander-bus has only a single port,
and that port will only connect to a pcie-root-port, or to a
pcie-switch-upstream-port. In order for the bus to be of any use in
the guest, it must have either a pcie-root-port or a
pcie-switch-upstream-port attached (and one or more
pcie-switch-downstream-ports attached to the
pcie-switch-upstream-port).
2016-04-14 14:00:34 -04:00
Laine Stump
0ec0bc85d0 qemu: add capabilities bit for device "pxb-pcie"
The pxb device is a PCIe expander bus that can be added to any
    Q35-based machinetype. A single PCIe port (*not* hotpluggable) is
    provided; if more than one device is desired, or if hotplug
    support is needed, either a pcie-root-port, or some combination of
    pcie-switch-upstream-port and pcie-swith-downstream-ports must be
    added to it. It can have a NUMA node number associated with it, as
    well as a bus number.
2016-04-14 14:00:34 -04:00
Laine Stump
400b297692 qemu: support new pci controller model "pci-expander-bus"
This is backed by the qemu device "pxb".

The pxb device always includes a pci-bridge that is at the bus number
of the pxb + 1.

busNr and <node> from the <target> subelement are used to set the
bus_nr and numa_node options for pxb.

During post-parse we validate that the domain's machinetype is
440fx-based (since the pxb device only works on 440fx-based machines),
and <node> also gets a sanity check to assure that the NUMA node
specified for the pxb (if any - it's optional) actually exists on the
guest.
2016-04-14 14:00:34 -04:00
Laine Stump
52f3d0a4d2 conf: new pci controller model pci-expander-bus
This is a standard PCI root bus (not a bridge) that can be added to a
440fx-based domain. Although it uses a PCI slot, this is *not* how it
is connected into the PCI bus hierarchy, but is only used for
control. Each pci-expander-bus provides 32 slots (0-31) that can
accept hotplug of standard PCI devices.

The usefulness of pci-expander-bus relative to a pci-bridge is that
the NUMA node of the bus can be specified with the <node> subelement
of <target>. This gives guest-side visibility to the NUMA node of
attached devices (presuming that management apps only assign a device
to a bus that has a NUMA node number matching the node number of the
device on the host).

Each pci-expander-bus also has a "busNr" attribute. The expander-bus
itself will take the busNr specified, and all buses that are connected
to this bus (including the pci-bridge that is automatically added to
any expander bus of model "pxb" (see the next commit)) will use
busNr+1, busNr+2, etc, and the pci-root (or the expander-bus with next
lower busNr) will use bus numbers lower than busNr.
2016-04-14 14:00:34 -04:00
Laine Stump
5d4e2b1721 qemu: add capabilities bit for device "pxb"
The pxb device is a PCI expander bus that can be added to any
440fx-based machinetype. The PCI bus that is created has 32 standard
PCI slots (hotpluggable). It can have a NUMA node number associated
with it, as well as a bus number.
2016-04-14 14:00:34 -04:00
Laine Stump
0d668434f4 conf: allow use of slot 0 in a dmi-to-pci-bridge
When support for dmi-to-pci-bridge was added, it was assumed that,
just as with the pci-root bus, slot 0 was reserved. This is not the
case - it can be used to connect a device just like any other slot, so
remove the restriction and update the test cases that auto-assign an
address on a dmi-to-pci-bridge.
2016-04-14 14:00:33 -04:00
Cole Robinson
313272e074 test: genericxml2xml: test graphics listen= compat
* Add a test for listen=XXX and <listen address=YYY/> collision error
* Add an explicit test for listen=XXX duplicated to <listen address=XXX/>
  We implicitly test it elsewhere but I figure it's better to be explicit,
  and this test case can be extended in the future for additional listen
  back compat if/when we support <listen type='socket'/> syntax
2016-04-14 12:26:04 -04:00
Cole Robinson
c493d21642 tests: Enable failure testing with CompareDomXML2XML
This allows tests to check for specific failure scenarios
2016-04-14 12:25:57 -04:00
Ján Tomko
d0cc8b10c3 tests: do not overwrite return value when filling qemuCapsCache
In qemuHotplugCreateObjects, the ret variable was filled by
the value returned by qemuTestCapsCacheInsert.

If any of the functions after this assignment failed, we would still
return success.

Also adjust testCompareXMLToArgvHelper, where this change is just
cosmetic, because the value was overwritten right away.
2016-04-14 16:37:50 +02:00
Eli Qiao
f9433ea019 qemumonitorjsontest: add test for getting multithread compress params
Signed-off-by: Eli Qiao <liyong.qiao@intel.com>
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-14 14:57:41 +02:00
Chunyan Liu
da6bbc51fb libxl: support creating domain with VF assignment from a pool
Add codes to support creating domain with network defition of assigning
SRIOV VF from a pool.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-04-13 18:35:29 -06:00
Ján Tomko
cbbd74aad5 qemuxml2argvtest: do not mock virCommand
Mock virNetDevRunEthernetScript instead.

This restores the VIR_TEST_REGENERATE_OUTPUT functionality.
2016-04-13 15:01:17 +02:00
Ján Tomko
786bc2511a qemu: assign addresses before aliases
The address assigning code might add new pci bridges.
We need them to have an alias when building the command line.

In real word usage, this is not a problem because all the code
paths already call qemuDomainAssignAddresses. However moving
this call lets us remove one extra call from qemuxml2argvtest.
2016-04-13 13:07:20 +02:00
Ján Tomko
1922d2f11e qemuxml2argvtest: drop FLAG_EXPECT_ERROR
It is only used for failed address allocation
Since we already have FLAG_EXPECT_FAILURE, use that instead.

Also unify the output to print the whole log buffer instead
of just the last error message.
2016-04-13 13:04:32 +02:00