Commit Graph

2873 Commits

Author SHA1 Message Date
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
Ján Tomko
f36c9f7b6c tests: clean up includes
After removing qemuBuildCommandLineCallbacks, testutilsqemu.h does not
need to include qemu_command.h.

Include just qemu_conf.h here and qemu_domain_address.h in files that
need it.
2016-04-13 13:00:53 +02:00
Ján Tomko
0da965c5e0 drop qemuBuildCommandLineCallbacks
Essentially revert commit 3a6204c which added these to allow the test
suite to pass without depending on the host system state.

Since commit 4b527c1 we already mock virSCSIDeviceGetSgName, so these
callbacks are useless.
2016-04-13 13:00:53 +02:00
Ján Tomko
4b35a7155a tests: fix xen-related tests
My commit 6879be4 moved the addition of the implicit video device
from the XML parser to the PostParse function, but did not regenerate
all the tests.
2016-04-12 14:58:43 +02:00
Ján Tomko
6d8b6d2847 conf: also mark the implicit video as primary
Commit 119cd06 started setting the primary bool for the first
user-specified video even if user omitted the 'primary' attribute.

However this was done before the addition of the implicit device.
This broke startup of transient qemu domains with no <video>:
https://bugzilla.redhat.com/show_bug.cgi?id=1325757

Move this default to virDomainDefPostParseInternal,
after the addition of the implicit video device, to catch the implicit
video as well.
2016-04-12 10:45:35 +02:00
Pavel Hrdina
1d9d0c9397 domain_conf: fix graphics parsing
Commit dc98a5bc refactored the code a lot and forget about checking if
listen attribute is specified.  This ensures that listen attribute and
first listen element are compared only if both exist.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-11 13:50:55 +02:00
Pavel Hrdina
71ea10851d tests: remove unwanted VIR_FREE of spice and vnc default listen
After the test and qemu_process refactor now we can benefit from default
listen address for spice and vnc in tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-08 17:36:27 +02:00
Ján Tomko
f06ca25d23 qemu: support virt-2.6 machine type on arm
Some places already check for "virt-" prefix as well as plain "virt".
virQEMUCapsHasPCIMultiBus did not, resulting in multiple PCI devices
having assigned the same unnumbered "pci" alias.

Add a test for the "virt-2.6" machine type which also omits the
<model type='virtio'/> in <interface>, to check if
qemuDomainDefaultNetModel works too.

https://bugzilla.redhat.com/show_bug.cgi?id=1325085
2016-04-08 14:15:51 +02:00
Vasiliy Tolstov
6e244c659f qemu domain allow to set ip address, peer address and route
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:34:48 +01:00
John Ferlan
d8a8cae342 qemu: Introduce qemuBuildMasterKeyCommandLine
If the -object secret capability exists, then get the path to the
masterKey file and provide that to qemu. Checking for the existence
of the file before passing to qemu could be done, but causes issues
in mock test environment.

Since the qemuDomainObjPrivate is not available when building the
command line, the qemuBuildHasMasterKey API will have to suffice
as the primary arbiter for whether the capability exists in order
to find/return the path to the master key for usage.

Created the qemuDomainGetMasterKeyAlias API which will be used by
later patches to define the 'keyid' (eg, masterKey) to be used by
other secrets to provide the id to qemu for the master key.
2016-04-06 20:27:09 -04:00
John Ferlan
d125685ad3 qemu: Add capability bit for qemu secret object
Add a capability bit for the qemu secret object.

Adjust the 2.6.0-1 caps/replies to add the secret object. For the
.replies it's take from the '{"execute":"qom-list-types"}' output.
2016-04-06 20:27:09 -04:00
Martin Kletzander
17a94ba70f nodedev: Fix parsing of generated XMLs
Commit d77ffb6876 added not only reporting of the PCI header type, but
also parsing of that information.  However, because there was no parsing
done for the other sub-PCI capabilities, if there was any other
capability then a valid header type name (like phys_function or
virt_functions) the parsing would fail.  This prevented passing node
device XMLs that we generated into our own functions when dealing with,
e.g. with SRIOV cards.

Instead of reworking the whole parsing, just fix this one occurence and
remove a test for it for the time being.  Future patches will deal with
the rest.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-04 14:24:02 +02:00
Roman Bogorodskiy
45408cd892 nss: FreeBSD support
* tools/nss/libvirt_nss.[ch]: add BSD-comptabile wrappers and
   register via the nss_module_register() interface
 * m4/virt-nss.m4: add checks if we're building NSS for FreeBSD
 * tools/Makefile.am: handle target library name differences, as
   Linux needs libnss_libvirt.so.2 and FreeBSD needs
   nss_libvirt.so.1. Also, different syms files have to be used
   as Linux needs to export all the methods while FreeBSD
   only needs to have nss_module_register()
 * tests/nsstest.c, tests/nssmock.c: s/__linux__/NSS/
 * tests/nssmock.c: pass int instead of mode_t to va_arg() to please
   gcc 4.8
 * libvirt_nss_bsd.syms: FreeBSD syms file
2016-03-30 10:21:44 +03:00
Peter Krempa
917426c8d7 util: bitmap: Introduce self-expanding bitmap APIs
In some cases it's impractical to use the regular APIs as the bitmap
size needs to be pre-declared. These new APIs allow to use bitmaps that
self expand.

The new code adds a property to the bitmap to track the allocation of
memory so that VIR_RESIZE_N can be used.
2016-03-29 21:25:41 +02:00
Peter Krempa
b2c9d77b4e vsh: Tweak error message for scaled integers
It was too similar to the non-scaled alternative.

before:
error: Numeric value 'abc' for <size> option is malformed or out of range
after:
error: Scaled numeric value 'abc' for <size> option is malformed or out of range
2016-03-29 15:28:46 +02:00
Qiaowei Ren
afe833e9bd perf: add new xml element
This patch adds new xml element, and so we can have the option of
also having perf events enabled immediately at startup.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-6-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Cole Robinson
4902231777 tests: virtnettlscontexttest: Use virGetLastErrorMessage()
Use virGetLastErrorMessage() rather than open code it
2016-03-28 13:27:47 -04:00
Maxim Nestratov
7068b56c85 conf: qemu: Add support for more HyperV Enlightenment features
This patch adds support for "vpindex", "runtime", "synic",
"stimer", and "vendor_id" features available in qemu 2.5+.

- When Hyper-V "vpindex" is on, guest can use MSR HV_X64_MSR_VP_INDEX
to get virtual processor ID.

- Hyper-V "runtime" enlightement feature allows to use MSR
HV_X64_MSR_VP_RUNTIME to get the time the virtual processor consumes
running guest code, as well as the time the hypervisor spends running
code on behalf of that guest.

- Hyper-V "synic" stands for Synthetic Interrupt Controller, which is
lapic extension controlled via MSRs.

- Hyper-V "stimer" switches on Hyper-V SynIC timers MSR's support.
Guest can setup and use fired by host events (SynIC interrupt and
appropriate timer expiration message) as guest clock events

- Hyper-V "reset" allows guest to reset VM.

- Hyper-V "vendor_id" exposes hypervisor vendor id to guest.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-28 13:10:18 -04:00
Anatole Denis
289f37ea81 tests: storagepoolxml2xmltest: Enable pool-rbd
This test was commited 4 years ago, but was never enabled in
storagepoolxml2xmltest.c. This patch reactivates it, conditionnaly on RBD
storage support being enabled
2016-03-28 12:02:31 -04:00
Anatole Denis
478474515d tests: storagepoolxml2xmltest: Fix pool-rbd test
This test failed for two reasons:
* The uuid was missing from the input file
* The output file had the <name> in a different place from the actual output
2016-03-28 12:02:31 -04:00
Christophe Fergeau
5e6d2af72f test: Fix typo in testutils.h header guard
This changes __VIT_TEST_UTILS_H__ to __VIR_TEST_UTILS_H__
2016-03-25 09:04:51 -04:00
Michal Privoznik
ee70fe7e14 virTestSetEnvPath: Avoid clearing out PATH
If the abs_builddir path already is in PATH and it's in the first
position, due to a bug in our code PATH would be cleared out.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-25 10:20:28 +01:00
Michal Privoznik
98354e362c testutils: Adapt to highly unlikely case
Coverity pointed out that getenv("PATH") may return NULL. Well,
we check for that in virFindFileInPath() too. If this happens, we
will pass NULL into strstr(). Ouch.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-24 17:35:14 +01:00
Michal Privoznik
8c50daa1e1 nsstest: Drop useless @data check
The variable is dereferenced prior its check for NULL. The check
itself does not make much sense anyway - it's our test, we know
we are not passing NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-24 17:35:14 +01:00
Erik Skultety
2f3472ca82 tests: Add new testcases to test parsing of log filters in virlogtest 2016-03-24 16:39:28 +01:00
Erik Skultety
f2b799cfc7 tests: virlogtest: Fix testLogParseOutputs return value
The test can return positive value even though it should have failed. It just
returns the value parser returned, which should be flipped back to -1 if
something went wrong or the result was unexpected, but it isn't.
2016-03-24 16:39:28 +01:00
Michal Privoznik
950a90d489 qemuxml2argvtest: Adapt to ethernet automatic tap creation
After 9c17d665fd the tap device for ethernet network type is
automatically precreated before spawning qemu. Problem is, the
qemuxml2argvtest wasn't updated and thus is failing. Because of
all the APIs that new code is calling, I had to mock a lot. Also,
since the tap FDs are labeled separately from the rest of the
devices/files I had to enable NOP security driver for the test
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-24 07:38:46 +01:00
Michal Privoznik
4b527c1acf qemuxml2argv: Mock virSCSIDeviceGetSgName
When constructing SCSI hostdev command line for qemu, the
/sys/bus/scsi/devices/... dir is scanned. Unfortunately, even in
the tests. This is needed to determine the name of SCSI device to
passthrough to qemu, because in the domain XML we were given its
address instead. Anyway, we should not be touching live system
data in our test suite as it produced unpredictable results. The
test is regressing from 1e9a083742 on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-23 12:50:19 +01:00
Andrea Bolognani
ee07c9802b tests: hostdev: Add more tests
Ensure the code behaves properly even for situations that were not
being considered before, such as simply detaching devices from the
host without attaching them to a guest and attaching devices as
managed even though they had already been manually detached from
the host.
2016-03-23 11:38:20 +01:00
Pavel Hrdina
1e9a083742 qemuxml2argvtest: cleanup test
Use qemuProcessCreatePretendCmd instead duplicating required steps from
qemuProcessStart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:49 +01:00
Pavel Hrdina
9dca74ee6f qemuxml2argvtest: use driver.config and priv for qemuDomainSetPrivatePaths
Update testutilsqemu to overwrite libDir and channelTargetDir and set
private paths using domain's privateData.  This changes is required for
following patch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
1e38ef728c qemu_process: move checks to qemuProcessStartValidate
Move all code that checks host and domain.  Do not check host if we use
VIR_QEMU_PROCESS_START_PRETEND flag.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
a431d3440f qemu: update callers of qemuProcessStartValidate to use virDomainObjPtr
This change is required by following patches.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
c374851960 tests: cleanup qemuxml2argvtest
This removes the testFailed magic and makes the code more readable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Michal Privoznik
a8dc3ac28a tests: Produce predictable results in nsstest
Problem is that in the test any status file matching
tests/nssdata/*.status is loaded as it contains IP addresses that
are parsed. However, there's no order specified in which the
files are loaded. Therefore on different systems the order may be
different. This is then producing an unexpected results.
Instead of defining an order in which the files are loaded, make
the code that checks for missing IP addresses (or redundant ones)
cope with unordered list of addresses. The reasoning behind is
that the code doing the parsing is used in real NSS module where
we don't care for ordering.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-21 19:34:18 +01:00
Bjoern Walk
1de354ccc5 tests: nodedevxml2xml: add test for SCSI target
Let's add a test for SCSI target nodedev devices.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2016-03-21 12:06:49 -04:00
Jim Fehlig
4c9ffc5388 xenconfig: change 'hap' setting to align with Xen behavior
hap is enabled by default in xm and xl config and usually only
specified when it is desirable to disable hap (hap = 0). Change
the xm,xl <-> xml converter to behave similarly. I.e. only
produce 'hap = 0' when <hap state='off'/> and vice versa.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-21 09:28:17 -06:00
Martin Kletzander
573c41a275 util: Add virSocketAddrSetIPv[46]AddrNetOrder and use it
This allows setting the address in host and/or network order and makes
the naming consistent.  Now you don't need to call [hn]to[nh]l()
functions as that is taken care of by these functions.  Also, now
the *NetOrder take the address in network order, the other functions in
host order so the naming and usage is consistent.  Some places were
having the address in network order and calling ntohl() just so the
original function can call htonl() again.  This makes it nicer to read.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-21 11:28:33 +01:00
Christophe Fergeau
6d28ef912c qemu: Don't add -spice port=0 when no port is specified
If a <graphics type='spice'> has no port nor tlsPort set, the generated
QEMU command line will contain -spice port=0.
This is later going to be ignored by spice-server, but it's better not
to add it at all in this situation.
As an empty -spice is not allowed, we still need to append port=0 if we
did not add any other argument.
2016-03-21 10:43:40 +01:00
Christophe Fergeau
8dab3d1d19 qemu: Omit SPICE address if no port is specified
Currently -spice addr=127.0.0.1 is generated, but spice-server is going
to ignore this as no port is specified.
2016-03-21 10:43:39 +01:00
Roman Bogorodskiy
ae33a7b336 nss: don't try to build nss plugin when disabled
Even if nss is disabled, the build system tries to build some
targets like libnss_libvirt_impl.la and nsstest. Hide those
under the "if WITH_NSS" block like the rest of NSS plugin bits.
2016-03-20 18:44:35 +03:00
Martin Kletzander
d77ffb6876 nodedev: Expose PCI header type
If we expose this information, which is one byte in every PCI config
file, we let all mgmt apps know whether the device itself is an endpoint
or not so it's easier for them to decide whether such device can be
passed through into a VM (endpoint) or not (*-bridge).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-18 17:35:06 +01:00
Michal Privoznik
5bcd96f531 tests: Introduce nsslinktest
The only purpose of this test is to catch possible linking
problems with libnss_libvirt.so.2.
One of the problems I faced was that the NSS plugin was unloaded
immediately after it got loaded and the name resolution process
continued with next configured option. Without any error. It was
very hard to debug why until I created this simple test and found
out immediately that there were some symbols missing. The reason
why problem was not caught in nsstest is that in the test we want
to use all the fancy stuff and therefore link it with libvirt.la.
So even if there's a symbol missing in the NSS plugin it will be
found in the libvirt.la.
But even after I resolved the issue we still need this test
because files the NSS plugin is built from are still live (mostly
those under utils/ dir). So as they change new symbol might be
required which would render the NSS plugin unusable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
38e32d4ac1 nss: Introduce a test
A small test to see how is the nss module working.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
7dbcb26f7f nss: Implement _nss_libvirt_gethostbyname3_r
The implementation is pretty straightforward. Moreover, because
of the nature of things, gethostbyname_r and gethostbyname2_r can
be implemented at the same time too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Jim Fehlig
adddaff183 tests: add schema test for default cache mode
None of the existing domXML configs under tests/* specify a
default cache mode since default generally means "use the
hypervisor default" and is left unset by the various hypervisor
drivers. Add a config to tests/domainschemadata that specifies
cache='default'.
2016-03-18 08:48:48 -06:00
Jim Fehlig
1a01e8792c tests: add xlconfigdata to domainschematests
Include the XML files under tests/xlconfigdata in the domain
schema tests
2016-03-18 08:48:48 -06:00
Michal Privoznik
363b401f94 tests: Set PATH in each test
Currently we spawn couple of binaries in our test suite.
Moreover, we provide some spoofed versions of system binaries
hoping that those will be executed instead of the system ones.
For instance, for testing SSH socket we have written our own ssh
binary for producing predictable results. We certainly don't want
to execute the system ssh binary.
However, in order to prefer our binaries over system ones, we
need to set PATH environment variable. But this is done only at
the Makefile level. So if anybody runs a test by hand that
expects our spoofed binary, the test ends up executing real
system binaries. This is not good. In fact, it's terribly wrong.
The fix lies in a small trick - putting our build directory at
the beginning of the PATH environment variable in each test.
Hopefully, since every test has this VIRT_TEST_MAIN* wrapper, we
can fix this at a single place.
Moreover, while this removes setting PATH for our tests written
in bash, it's safe as we are not calling anything ours that would
require PATH change there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 11:38:37 +01:00
Michal Privoznik
865764de06 Drop paths.h include
We include the file in plenty of places. This is mostly due to
historical reasons. The only place that needs something from the
header file is storage_backend_fs which opens _PATH_MOUNTED. But
it gets the file included indirectly via mntent.h. At no other
place in our code we need _PATH_.*. Drop the include and
configure check then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 09:43:45 +01:00
Erik Skultety
6bd9758e58 tests: Add a new test for logging outputs parser
Test for parser's functionality.
2016-03-16 14:24:15 +01:00
Erik Skultety
814b2ec625 tests: Slightly tweak virlogtest
Patch adds a generic DO_TEST_FULL macro, some PASS/FAIL macros to better
visually distinguish tests that should fail and tests that should pass. Also,
some cosmetic changes like renames and direct call to fprintf is replaced with
our VIR_TEST_DEBUG macro, as using testutils should be our preferred way of
reporting errors in tests.
2016-03-16 14:24:15 +01:00
Martin Kletzander
fd4f278e1a daemon: Get server name from the server itself
Since servers know their name, there is no need to supply such
information twice.  Also defeats inconsistencies.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
dad3b07814 server: Store server name in server object
At first I did not want to do this, but after trying to implement some
newer feaures in the admin API I realized we need that to make our lives
easier.  On the other hand they are not saved redundantly and the
virNetServer objects are still kept in a hash table.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Marc-André Lureau
1e34a8f919 qemu: enable debug threads
When debug-threads is enabled, individual threads are given a separate
name (on Linux)

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-10 22:54:40 +01:00
Marc-André Lureau
0683ffc2ea qemu: check for debug-threads capability
QEMU (somewhere around 2.0) added a new sub-option to the -name flag
-name debug-threads=on.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-10 22:54:40 +01:00
Jiri Denemark
2f0d57e4b0 qemuxml2argvtest: Fix monitor path in serial-file-log
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-10 18:54:59 +01:00
Daniel P. Berrange
3e12ec4a1e qemu: use virtlogd for character device log files
If use of virtlogd is enabled, then use it for backing the
character device log files too. This avoids the possibility
of a guest denial of service by writing too much data to
the log file.
2016-03-10 15:41:52 +00:00
Daniel P. Berrange
06cb0cf7ce qemu: add support for logging chardev output to a file
Honour the <log file='...'/> element in chardevs to output
data to a file. This requires QEMU >= 2.6

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:51 +00:00
Andrea Bolognani
3632185617 tests: hostdev: Group test cases
Instead of considering each single step its own test case, create
high level test cases that reproduce a certain scenario.
2016-03-08 10:42:25 +01:00
Andrea Bolognani
f8388cdce4 tests: hostdev: Add more checks on list size
Always call CHECK_LIST_COUNT() to check the size of both the active
and inactive devices list.
2016-03-08 10:42:25 +01:00
Andrea Bolognani
4a9ea5048c tests: hostdev: Use size_t for count variables
virPCIDeviceListCount()'s return type is size_t, so variables that
store its return value should be of that type.
2016-03-08 10:42:22 +01:00
Andrea Bolognani
ff087d8dae tests: hostdev: Move variable declaration inside CHECK_LIST_COUNT()
The 'actualCount' variable, formerly just 'count', is only used
internally by the macro, so it's better to move its declaration
inside the macro as well: this way, it doesn't have to be declared
by every single user.

The new name is less generic to make clashes less likely.
2016-03-08 10:34:13 +01:00
Andrea Bolognani
dd9f8e0292 tests: hostdev: Use better variable names
Change the extremely generic count1 and count2 to the more
descriptive active_count and inactive_count.
2016-03-08 10:16:43 +01:00
Andrea Bolognani
9f506fdb6b tests: hostdev: Remove magic numbers
When checking the number of devices added to a device list, use the
nhostdevs variable instead of its value, so that the test can keep
working even if more hostdevs are added.
2016-03-08 10:16:43 +01:00
Alexander Burluka
946758deee Add global_period and global_quota XML validation test
Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
2016-03-01 14:29:06 +00:00
Pavel Hrdina
b4a5fd95f7 qemu: introduce vram64 attribute for QXL video device
This attribute is used to extend secondary PCI bar and expose it to the
guest as 64bit memory.  It works like this: attribute vram is there to
set size of secondary PCI bar and guest sees it as 32bit memory,
attribute vram64 can extend this secondary PCI bar.  If both attributes
are used, guest sees two memory bars, both address the same memory, with
the difference that the 32bit bar can address only the first part of the
whole memory.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
Pavel Hrdina
37b746336e qemu_capabilities: introduce QEMU_CAPS_QXL(_VGA)_VRAM64
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
Pavel Hrdina
119cd06ef7 domain_conf: always set primary video device as primary
We always place primary video device at first place, to make it easier
to create a qemu command or format an xml, but we should also set the
primary boolean for primary video device to 'true'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
John Ferlan
1d35f6ffe1 polkit: Adjust message when authentication agent isn't found
When there isn't a ssh -X type session running and a user has not
been added to the libvirt group, attempts to run 'virsh -c qemu:///system'
commands from an otherwise unprivileged user will fail with rather
generic or opaque error message:

    "error: authentication failed: no agent is available to authenticate"

This patch will adjust the error code and message to help reflect the
situation that the problem is the requested mechanism is UNAVAILABLE and
a slightly more descriptive error. The result on a failure then becomes:

    "error: authentication unavailable: no polkit agent available to
            authenticate action 'org.libvirt.unix.manage'"

A bit more history on this - at one time a failure generated the
following type message when running the 'pkcheck' as a subprocess:

"error: authentication failed: polkit\56retains_authorization_after_challenge=1
Authorization requires authentication but no agent is available."

but, a patch was generated to adjust the error message to help provide
more details about what failed. This was pushed as commit id '96a108c99'.
That patch prepended a "polkit: " to the output. It really didn't solve
the problem, but gave a hint.

After some time it was deemed using DBus API calls directly was a
better way to go (since pkcheck calls them anyway). So, commit id
'1b854c76' (more or less) copied the code from remoteDispatchAuthPolkit
and adjusted it. Then commit id 'c7542573' adjusted the remote.c
code to call the new API (virPolkitCheckAuth). Finally, commit id
'308c0c5a' altered the code to call DBus APIs directly. In doing
so, it reverted the failing error message to the generic message
that would have been received from DBus anyway.
2016-03-01 06:50:16 -05:00
Marc-André Lureau
937ebba00e qemu: add spice opengl support
Add Spice graphics gl attribute. qemu 2.6 should have -spice gl=on argument to
enable opengl rendering context (patches on the ML). This is necessary to
actually enable virgl rendering.

Add a qemuxml2argv test for virtio-gpu + spice with virgl.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-01 09:45:47 +01:00
Martin Kletzander
a89f05ba8d qemu: Shorten per-domain directory names
Per-domain directories were introduced in order to be able to
completely separate security labels for each domain (commit
f1f68ca334).  However when the domain
name is long (let's say a ridiculous 110 characters), we cannot
connect to the monitor socket because on length of UNIX socket address
is limited.  In order to get around this, let's shorten it in similar
fashion and in order to avoid conflicts, throw in an ID there as well.
Also save that into the status XML and load the old status XMLs
properly (to clean up after older domains).  That way we can change it
in the future.

The shortening can be seen in qemuxml2argv tests, for example in the
hugepages-pages2 case.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-01 07:15:29 +01:00
Ján Tomko
21b316f4d3 qemu: error out on missing machine type in configs
Commit f1a89a8 allowed parsing configs from /etc/libvirt
without validating the emulator capabilities.

Check for the presence of a machine type in the qemu driver's
post parse function instead of crashing.

https://bugzilla.redhat.com/show_bug.cgi?id=1267256
2016-02-26 10:32:31 +01:00
Ján Tomko
b564113d56 tests: add parseFlags to qemuxml2argvtest 2016-02-26 09:47:46 +01:00
Ján Tomko
2d40e2da7b tests: add a test for persistent LXC XML parsing
Check if we correctly parse the persistent config even with
the VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS flag.
2016-02-26 09:47:45 +01:00