Commit Graph

3732 Commits

Author SHA1 Message Date
Jiri Denemark
702013f3b3 conf: Refactor virCPUDefParseXML
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Ján Tomko
bb74c66e67 conf: only format <controller> as a pair tag when needed
Make the decision based on the usage of childBuf buffer.

This fixes the oddity in the test case introduced by commit c1c4d0d
where we would format an empty pair tag.
2017-06-05 16:13:50 +02:00
Michal Privoznik
567f04808e bhyveargv2xmltest: Fix call of virDomainDefCheckABIStability
In 4f0aeed I've expanded the list of arguments for
virDomainDefCheckABIStability() but I forgot to fix
bhyveargv2xmltest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-06-05 11:46:02 +02:00
Martin Kletzander
f4c09b913e Reset the whole stack in testutils
The memset() was resetting only 30 bytes in the array (size of the
array), but it is array of pointers.  Since it is a static array,
let's just reset it by its size.

Found by gcc-7.1:

  testutils.c: In function 'virTestRun':
  testutils.c:243:13: error: 'memset' used with length equal to number
  of elements without multiplication by element size [-Werror=memset-elt-size]
    memset(testAllocStack, 0, ARRAY_CARDINALITY(testAllocStack));
    ^~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-06-05 09:50:51 +02:00
Eli Qiao
0ab409ccc4 Expose resource control capabilities for caches
Add cache resource control into capabilities for CAT without CDP:

  <cache>
    <bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
      <control min='768' unit='KiB' scope='both' max_allocation='4'/>
    </bank>
  </cache>

and with CDP:

  <cache>
    <bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
      <control min='768' unit='KiB' scope='code' max_allocation='4'/>
      <control min='768' unit='KiB' scope='data' max_allocation='4'/>
    </bank>
  </cache>

Also add new test cases for vircaps2xmltest.

Signed-off-by: Eli Qiao <liyong.qiao@intel.com>
2017-06-05 09:50:51 +02:00
Michal Privoznik
4f0aeed871 virDomainXMLOption: Introduce virDomainABIStabilityDomain
While checking for ABI stability, drivers might pose additional
checks that are not valid for general case. For instance, qemu
driver might check some memory backing attributes because of how
qemu works. But those attributes may work well in other drivers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-06-05 09:08:52 +02:00
Bjoern Walk
bb2adfe934 node_device: introduce new capability FC_RPORT
Similar to scsi_host and fc_host, there is a relation between a
scsi_target and its transport specific fc_remote_port. Let's expose this
relation and relevant information behind it.

An example for a virsh nodedev-dumpxml:

    virsh # nodedev-dumpxml scsi_target0_0_0
    <device>
      <name>scsi_target0_0_0</name>
      <path>/sys/devices/[...]/host0/rport-0:0-0/target0:0:0</path>
      <parent>scsi_host0</parent>
      <capability type='scsi_target'>
        <target>target0:0:0</target>
        <capability type='fc_remote_port'>
          <rport>rport-0:0-0</rport>
          <wwpn>0x9d73bc45f0e21a86</wwpn>
        </capability>
      </capability>
    </device>

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Bjoern Walk
b0ffd938d4 node_device: detect CCW devices
Make CCW devices available to the node_device driver. The devices are
already seen by udev so let's implement necessary code for detecting
them properly.

Topologically, CCW devices are similar to PCI devices, e.g.:

    +- ccw_0_0_1a2b
        |
        +- scsi_host0
            |
            +- scsi_target0_0_0
                |
                +- scsi_0_0_0_0

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Ján Tomko
381e638d81 qemu: format eim on intel-iommu command line
This option turns on extended interrupt mode,
which allows more than 255 vCPUs.

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

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-05-26 08:16:29 +02:00
Ján Tomko
dc61d92758 conf: add eim attribute to <iommu><driver>
Add an attribute to control extended interrupt mode.

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

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-05-26 08:11:25 +02:00
Wim ten Have
4cd3f24139 xenconfig: fix handling of NULL disk source
It is possible to crash libvirtd when converting xl native config to
domXML when the xl config contains an empty disk source, e.g. an empty
CDROM. Fix by checking that the disk source is non-NULL before parsing it.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
2017-05-19 08:47:36 -06:00
Michal Privoznik
2f69dd36bb virfiletest: include linux/falloc.h
On systems with older glibc including fcntl.h for getting
FALLOC_FL_PUNCH_HOLE defined is not enough. We must also include
linux/falloc.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-19 14:02:37 +02:00
Michal Privoznik
adbd1626cb virfiletest: Test virFileInData iff SEEK_HOLE is defined
Yet another place where we need to wrap code in
HAVE_DECL_SEEK_HOLE block.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-19 14:02:37 +02:00
Erik Skultety
88ef73e13c nodedev: Introduce mdev capability for mediated devices
Start discovering the mediated devices on the host system and format the
attributes for the mediated device into the XML. Compared to the parent
device which reports generic information about the abstract mediated
devices types, a child device only reports the type name it has been
instantiated from and the IOMMU group number, since that's device
specific compared to the rest of the info that can be gathered about
mediated devices at the moment.
This patch introduces both the formatting and parsing routines, updates
nodedev.rng schema, adding a testcase as well.

The resulting mdev child device XML:
<device>
  <name>mdev_4b20d080_1b54_4048_85b3_a6a62d165c01</name>
  <path>/sys/devices/.../4b20d080-1b54-4048-85b3-a6a62d165c01</path>
  <parent>pci_0000_06_00_0</parent>
  <driver>
    <name>vfio_mdev</name>
  </driver>
  <capability type='mdev'>
    <type id='vendor_supplied_type_id'/>
    <iommuGroup number='NUM'/>
  <capability/>
<device/>

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-05-18 12:21:45 +02:00
Erik Skultety
500cbc066a nodedev: Introduce the mdev capability to a PCI parent device
The parent device needs to report the generic stuff about the supported
mediated devices types, like device API, available instances, type name,
etc. Therefore this patch introduces a new nested capability element of
type 'mdev_types' with the resulting XML of the following format:

<device>
  ...
  <capability type='pci'>
    ...
    <capability type='mdev_types'>
      <type id='vendor_supplied_id'>
        <name>optional_vendor_supplied_codename</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>NUM</availableInstances>
      </type>
        ...
      <type>
        ...
      </type>
    </capability>
  </capability>
  ...
</device>

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-05-18 12:21:33 +02:00
Michal Privoznik
b928d140f4 util: Introduce virFileInData
This function takes a FD and determines whether the current
position is in data section or in a hole. In addition to that,
it also determines how much bytes are there remaining till the
current section ends.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-18 07:42:13 +02:00
Andrea Bolognani
bc07101a7c qemu: Use GICv2 for aarch64/virt TCG guests
There are currently some limitations in the emulated GICv3
that make it unsuitable as a default. Use GICv2 instead.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-05-16 16:48:30 +02:00
Andrea Bolognani
b24eaf6210 tests: Check default GIC version for aarch64/virt TCG guests
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-05-16 16:48:30 +02:00
Pavel Hrdina
ed99660446 qemu: improve detection of UNIX path generated by libvirt
Currently we consider all UNIX paths with specific prefix as generated
by libvirt, but that's a wrong assumption.  Let's make the detection
better by actually checking whether the whole path matches one of the
paths that we generate or generated in the past.

The UNIX path isn't stored in config XML since libvirt-1.3.1.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-16 11:33:49 +02:00
Ján Tomko
a56914486c qemu: format caching-mode on iommu command line
Format the caching-mode option for the intel-iommu device,
based on its <driver caching> attribute value.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
2017-05-15 15:44:11 +02:00
Ján Tomko
d12781b47e conf: add caching_mode attribute to iommu device
Add a new attribute to control the caching mode.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
2017-05-15 15:44:11 +02:00
Ján Tomko
04028a9db9 qemu: format intel-iommu,intremap on the command line
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
2017-05-15 15:44:11 +02:00
Ján Tomko
2020e2c6f2 conf: add <driver intremap> to <iommu>
Add a new attribute to control interrupt remapping.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
2017-05-15 15:44:11 +02:00
Ján Tomko
6b5c6314b2 qemu: format kernel_irqchip on the command line
Add kernel_irqchip=split/on to the QEMU command line
and a capability that looks for it in query-command-line-options
output. For the 'split' option, use a version check
since it cannot be reasonably probed.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
2017-05-15 15:44:11 +02:00
Ján Tomko
8023b21a95 conf: add <ioapic driver> to <features>
Add a new <ioapic> element with a driver attribute.

Possible values are qemu and kvm. With 'qemu', the I/O
APIC can be put in the userspace even for KVM domains.

https://bugzilla.redhat.com/show_bug.cgi?id=1427005
2017-05-15 15:41:17 +02:00
Martin Kletzander
ec337aee9b test-wrap-argv.pl: Accept short parameter -i for --in-place
I like to use it that way and every time I try running it I just
instinctively use '-i' (like with sed, etc.) and it makes sense, IMHO.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-15 12:34:19 +02:00
Pavel Hrdina
0918b84968 util: introduce virBufferEscapeRegex
Add a helper to escape all possible meta-characters used for
POSIX extended regular expressions.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-12 16:54:33 +02:00
Pavel Hrdina
f15f155403 util: introduce virStringMatch
Simply tries to match the provided regex on a string and returns
the result.  Useful if caller don't care about the matched substring
and want to just test if some pattern patches a string.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-12 16:51:18 +02:00
Daniel P. Berrange
300c7c7035 tests: stub out virfilewrapper.c on Win32
The Win32 platform can not do link time overrides in the same way
that we can on POSIX / ELF based platforms, so we cannot build
the virfilewrapper.c code reliably. Just stub it out on Win32
so it is a no-op. Tests that use this file are already written
to skip on Win32.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-11 11:45:41 +01:00
Daniel P. Berrange
4a1a4be37e Add missing deps on virfilewrapper.h
The test programs depend on virfilewrapper.h as well as the
virfilewrapper.c. Adding the dep ensures that virfilewrapper.h
gets included in the dist tarball.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-10 16:15:05 +01:00
Roman Bogorodskiy
058bf5549f tests: fix virfilewrapper
If __lxstat() and __xstat() functions are not available, build fails with:

  CC       virfilewrapper.o
virfilewrapper.c:180:5: error: no previous prototype for function '__lxstat' [-Werror,-Wmissing-prototypes]
int __lxstat(int ver, const char *path, struct stat *sb)
    ^
virfilewrapper.c:208:5: error: no previous prototype for function '__xstat' [-Werror,-Wmissing-prototypes]
int __xstat(int ver, const char *path, struct stat *sb)

Luckily, we already check presence of these functions in configure
using AC_CHECK_FUNCS, so just don't wrap these if they're not available.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2017-05-09 17:03:02 +04:00
Martin Kletzander
0e3ff22c6f tests: Add resctrl test for vircaps2xmltest
Add info from yet another machine, this time with resctrl data so that
we can extend tests easily in a test-driven way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
fec6e4c48c tests: Add support for more complicated hierarchies in vircaps2xmltest
More directories will need to be mocked, so let's prepare for that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
4ad6a73bfc Add host cache information in capabilities
We're only adding only info about L3 caches, we can add more
later (just by changing one line), but for now that's more than enough
without overwhelming anyone.

XML snippet of how this should look like (also seen as part of the commit):

  <cache>
    <bank id='0' level='3' type='both' size='8192' unit='KiB' cpus='0-7'/>
  </cache>

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
90a118fa69 tests: Add missing cache data for vircaps2xmltest
Commit a0fdd2f6f9 added some data from
the system but forgot 3 files for each cache.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
eb18683fdb tests: Test vircaps2xmldata XMLs in virschematest
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
7008e10869 util: Remove virsysfs and instead enhance virFileReadValue* functions
It is no longer needed thanks to the great virfilewrapper.c.  And this
way we don't have to add a new set of functions for each prefixed
path.

While on that, add two functions that weren't there before, string and
scaled integer reading ones.  Also increase the length of the string
being read by one to accompany for the optional newline at the
end (i.e. change INT_STRLEN_BOUND to INT_BUFSIZE_BOUND).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
ae60ea48bc tests: Add virfilewrapper -- the new super "mock"
This mock (which is actually not mock at all, see later) can redirect
all accesses to a path into another path.  There is no need to
create mocks for particular directories, you just create a directory
with all the data a redirect the test there.

In the future, this should also be able to register callbacks for
calls/paths, e.g. when the test is going to write into anything under
"/sys/devices", call function fce();  Then in the open() call we would
add information about the fd into some structure and in write() we
would call fce() with parameters like @path to write to, @data to
be written and pointer to optional return value, so that fce() itself
could stop the call from happening or change its behaviour.  But
that's an idea for a latter day.

This is not a mock because it will not be preloaded, but compiled in
the test itself.  See future patches for usage.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Michal Privoznik
b8ef4758f3 fdstreamtest: Print more info on read failure
It helps with debugging if we know what's the return value of
saferead().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-04-28 14:17:10 +02:00
Michal Privoznik
1cb23be2a5 fdstreamtest: Rename tempdir
Because of copy-paste the temporary directory used for this test
is called "fakesysdir". That's probably misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-04-28 14:17:10 +02:00
Pavel Hrdina
568887a32f qemu: use qemu-xhci USB controller by default for ppc64 and aarch64
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
2017-04-28 10:47:12 +02:00
Pavel Hrdina
278e70f8f8 qemu: add support for qemu-xhci USB controller
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
2017-04-28 10:44:36 +02:00
Pavel Hrdina
5237a74d4a qemu: introduce QEMU_CAPS_DEVICE_QEMU_XHCI
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
2017-04-28 10:44:03 +02:00
Pavel Hrdina
233f8d0bd4 qemu: use nec-usb-xhci as a default controller for aarch64 if available
This is a USB3 controller and it's a better choice than piix3-uhci.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Andrea Bolognani <abologna@redhat.com>
2017-04-28 10:42:26 +02:00
Peter Krempa
ef0bb841c9 tests: genericxml2xml: Add test case for HTTP based disk 2017-04-28 10:22:40 +02:00
Wim ten Have
5ade0ff905 xlconfigtest: add tests for 'nestedhvm' support
Testing various configuration schemas targeting postive and negative
nestedhvm under libvirt <cpu mode="host-passthrough"> configuration.

Mode "host-passthrough" generates nestedhvm=1 in/from xl format where

Intel virtualization (VT-x):
<feature policy='disable' name='vmx'/>

    or

AMD virtualization (AMD-V):
<feature policy='disable' name='svm'/>

disables virtualization mode under guest domains.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2017-04-27 15:05:44 -06:00
Jiri Denemark
df13c0b477 qemu: Add support for guest CPU cache
This patch maps /domain/cpu/cache element into -cpu parameters:

- <cache mode='passthrough'/> is translated to host-cache-info=on
- <cache level='3' mode='emulate'/> is transformed into l3-cache=on
- <cache mode='disable'/> is turned in host-cache-info=off,l3-cache=off

Any other <cache> element is forbidden.

The tricky part is detecting whether QEMU supports the CPU properties.

The 'host-cache-info' property is introduced in v2.4.0-1389-ge265e3e480,
earlier QEMU releases enabled host-cache-info by default and had no way
to disable it. If the property is present, it defaults to 'off' for any
QEMU until at least 2.9.0.

The 'l3-cache' property was introduced later by v2.7.0-200-g14c985cffa.
Earlier versions worked as if l3-cache=off was passed. For any QEMU
until at least 2.9.0 l3-cache is 'off' by default.

QEMU 2.9.0 was the first release which supports probing both properties
by running device-list-properties with typename=host-x86_64-cpu. Older
QEMU releases did not support device-list-properties command for CPU
devices. Thus we can't really rely on probing them and we can just use
query-cpu-model-expansion QMP command as a witness.

Because the cache property probing is only reliable for QEMU >= 2.9.0
when both are already supported for quite a few releases, we let QEMU
report an error if a specific cache mode is explicitly requested. The
other mode (or both if a user requested CPU cache to be disabled) is
explicitly turned off for QEMU >= 2.9.0 to avoid any surprises in case
the QEMU defaults change. Any older QEMU already turns them off so not
doing so explicitly does not make any harm.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-27 22:41:10 +02:00
Jiri Denemark
a646a6016a Add support for CPU cache specification
This patch introduces

    <cache level='N' mode='emulate'/>
    <cache mode='passthrough'/>
    <cache mode='disable'/>

sub element of /domain/cpu. Currently only a single <cache> element is
allowed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-27 22:07:14 +02:00
Michal Privoznik
1a4a4ffa3e lib: Fix c99 style comments
We prefer c89 style of comments.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-04-27 14:13:19 +02:00
Pavel Hrdina
26d21e5de8 tests: update QEMU 2.9.0 caps data to final version
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-04-26 19:34:25 +02:00