Commit Graph

30569 Commits

Author SHA1 Message Date
Cole Robinson
8c496a1d00 conf: Replace SKIP_OSTYPE_CHECKS with SKIP_VALIDATE
SKIP_OSTYPE_CHECKS only hides some error reporting at this point,
so it can be foled into SKIP_VALIDATE

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:13:00 -04:00
Cole Robinson
031363cbde tests: Remove redundant lxc test
This test was added in 2d40e2da7b to ensure LXC domains could be
defined correctly when caps probing was skipped due to SKIP_OSTYPE.
However we do caps probing unconditionally now, so this test case
is redundant

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:13:00 -04:00
Cole Robinson
cd9d439a71 conf: Sync caps data even when SKIP_OSTYPE_CHECKS
We should still make an effort to fill in data, just not raise
an error if say an ostype/virttype combo disappeared from caps.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:13:00 -04:00
Cole Robinson
b251d6ad24 conf: Drop unnecessary caps parsing logic
The comment says:

    /* If the logic here seems fairly arbitrary, that's because it is :)
     * This is duplicating how the code worked before
     * CapabilitiesDomainDataLookup was added. We can simplify this,
     * but it would take a bit of work because the test suite fails
     * in numerous minor ways. */

Nowadays the test suite changes appear quite simple, just extending
test capabilities data a bit so that we aren't trying to define
invalid arch/os/virtType/machine combos

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:13:00 -04:00
Cole Robinson
f14f0836c5 tests: qemuhotplug: Fix segfault when XML loading fails
Some tests use the same VM state multiple times in a row. But if we
failed loading the VM XML, subsequent tests crash on the NULL def
pointer

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:13:00 -04:00
Cole Robinson
8e2982b576 conf: Clean up virDomainDefParseCaps
- Convert to 'cleanup' label naming
- Use more than one 'tmp' string and do all freeing at the end
- Make the code easier to follow

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:12:59 -04:00
Cole Robinson
bd884c566e conf: Break out virDomainDefParseCaps
Handles parse virtType, os.type, bootloader bits, arch, machine,
emulator

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-26 10:12:59 -04:00
Han Han
d1c4480390 conf: Fix a error msg typo in virDomainVideoDefValidate
https://bugzilla.redhat.com/show_bug.cgi?id=1607825

Introduced by commit d48813e8.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 16:05:59 +02:00
John Ferlan
5229494b01 nwfilter: Resolve SEGV for NWFilter Snoop processing
https://bugzilla.redhat.com/show_bug.cgi?id=1599973

Commit id fca9afa08 changed the @req->ifname to use
@req->binding->portdevname fillingin the @req->binding
in a similar way that @req->ifname would have been
filled in during virNWFilterDHCPSnoopReq processing.

However, in doing so it did not take into account some
code paths where the @req->binding should be checked
instead of @req->binding->portdevname. These checks
led to SEGVs in some cases during libvirtd reload
processing in virNWFilterSnoopRemAllReqIter (for
stop during nwfilterStateCleanup processing) and
virNWFilterSnoopReqLeaseDel (for start during
nwfilterStateInitialize processing).

In particular, when reading the nwfilter.leases file
a new @req is created, but the @req->binding is not
filled in. That's left to virNWFilterDHCPSnoopReq
processing which checks if the @req already exists
in the @virNWFilterSnoopState.snoopReqs hash table
after adding a virNWFilterSnoopState.ifnameToKey
entry for the @req->binding->portdevname by a
@ref->ikey value.

NB: virNWFilterSnoopIPLeaseInstallRule and
    virNWFilterDHCPSnoopThread do not need the
    req->binding check since they can only be called
    after the filter->binding is created/assigned.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-26 09:35:40 -04:00
Michal Privoznik
e6d3e46bb5 lxc: Don't mangle @cfg refs in virLXCProcessBuildControllerCmd
The config object is refed but unrefed only on error which leaves
refcount unbalanced on successful return.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 14:18:35 +02:00
Michal Privoznik
696a9faa8e lxc: Don't leak @veths in virLXCProcessStart
The individual strings are freed, but the array is never freed.

 8 bytes in 1 blocks are definitely lost in loss record 28 of 1,098
    at 0x4C2CE3F: malloc (vg_replace_malloc.c:298)
    by 0x4C2F1BF: realloc (vg_replace_malloc.c:785)
    by 0x52C9C92: virReallocN (viralloc.c:245)
    by 0x52C9D88: virExpandN (viralloc.c:294)
    by 0x23414D99: virLXCProcessSetupInterfaces (lxc_process.c:552)
    by 0x23417457: virLXCProcessStart (lxc_process.c:1356)
    by 0x2341F71C: lxcDomainCreateWithFiles (lxc_driver.c:1088)
    by 0x2341F805: lxcDomainCreate (lxc_driver.c:1123)
    by 0x55917EB: virDomainCreate (libvirt-domain.c:6534)
    by 0x1367D1: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4434)
    by 0x1366EA: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4410)
    by 0x546FDF1: virNetServerProgramDispatchCall (virnetserverprogram.c:437)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 14:18:06 +02:00
Michal Privoznik
9bf5ca8620 lxc: Enable under valgrind again
So we originally disabled LXC driver when libvirtd is running
under valgrind back in 05436ab7ff (which dates to beginning of
2009) as it was causing valgrind to crash. It's not the case
anymore. Valgrind works with LXC happily.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 14:15:43 +02:00
Michal Privoznik
008cdddd7c lxc: Report supported huge pages
There are two places where we report supported sizes of huge pages:

  /capabilities/host/cpu/pages
  /capabilities/host/topology/cells/cell/pages

The former aggregates sizes over all NUMA nodes while the latter
reports supported sizes only for given node. While we are
reporting per NUMA node sizes we are not reporting the aggregated
sizes. I've noticed this when wondering why doesn't allocpages
completer work.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 14:15:22 +02:00
Michal Privoznik
832d620ed3 lxc: Refresh capabilities on virConnectGetCapabilities
While not as critical as in qemu driver, there are still some
runtime information we report in capabilities XML that might
change throughout time. For instance, onlined CPUs (which affects
reported L3 cache sizes).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 14:11:34 +02:00
Michal Privoznik
142c4b10fd networkGetDHCPLeases: Don't always report error if unable to read leases file
https://bugzilla.redhat.com/show_bug.cgi?id=1600468

If we are unable to read leases file (no matter what the reason
is), we return 0 - just like if there were no leases. However,
because we use virFileReadAll() an error is printed into the log.
Note that not all networks have leases file - only those for
which we start dnsmasq.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-26 11:39:11 +02:00
Daniel P. Berrangé
2eb748d259 rpc: treat EADDRNOTAVAIL as non-fatal when listening
Consider creating a listener socket from a hostname that resolves to
multiple addresses. It might be the case that the hostname resolves to
both an IPv4 and IPv6 address because it is reachable over both
protocols, but the IPv6 connectivity is provided off-host. In such a
case no local NIC will have IPv6 and so bind() would fail with the
EADDRNOTAVAIL errno. Thus it should be treated as non-fatal as long as
at least one socket was succesfully bound.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-25 16:55:55 +01:00
Daniel P. Berrangé
f56eb726b1 socket: preserve real errno when socket/bind calls fail
When reporting socket/bind failures we want to ensure any fatal error
reported is as accurate as possible. We'll prefer reporting a bind()
errno over a socket() errno, because if socket() works but bind() fails
that is a more significant event.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-25 16:55:38 +01:00
John Ferlan
55ce656463 qemu: Use the correct vm def on cold attach
https://bugzilla.redhat.com/show_bug.cgi?id=1559867

When attaching a device to the domain we need to be sure
to use the correct domain definition (vm->def or vm->newDef)
when calling virDomainDeviceDefParse because the post parse
processing algorithms that may assign an address for the
device will use whatever domain definition was passed in.

Additionally, some devices (SCSI hostdev and SCSI disk) use
algorithms that rely on knowing what already exists of the
other type when generating the new device's address. Using
the wrong VM definition could result in duplicated addresses.

In the case of the bz, two hostdev's with no domain address
provided were added to the running domain's config only.
However, the parsing algorithm used the live domain in
order to figure out the host device address resulting in
the same address being used and a subsequent start failing
due to duplicate address.

Fix this by separating the checks/code into CONFIG and LIVE
processing using the correct definition for each block and
performing cleanup for both options as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-25 08:45:00 -04:00
Shi Lei
7564daca8a network: Use 'switch' control statement with virNetworkForwardType enum
With 'switch' we can utilize the compile time enum checks which we can't
rely on with plain 'if' conditions.

Signed-off-by: Shi Lei <shilei.massclouds@gmx.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-07-25 14:33:52 +02:00
Marcos Paulo de Souza
a1450d774f esx storage: Fix typo lsilogic -> lsiLogic
Commit 77298458d0 changed the esx storage
adapter from busLogic to lsilogic, introducing a typo. Changing it back
to lsiLogic (with capital L) solves the issue. With this change, libvirt can now
create volumes in ESX again.

Thanks to Jaroslav Suchanek who figured out what was the issue in the
first place.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1571759
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
2018-07-25 13:30:24 +02:00
Andrea Bolognani
f025c1bf79 util: Fix virStorageBackendIQNFound() to work on FreeBSD
Despite being standardized in POSIX.1-2008, the 'm'
sscanf() modifier is currently not available on FreeBSD.

Reimplement parsing without sscanf() to work around the
issue.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-25 13:23:10 +02:00
Han Han
f26958462e news: Add --alias to virsh attach-disk and attach-interface
Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-25 13:19:37 +02:00
Michal Privoznik
8c8c32339a qemuDomainSaveMemory: Don't enforce dynamicOwnership
https://bugzilla.redhat.com/show_bug.cgi?id=1589115

When doing a memory snapshot qemuOpenFile() is used. This means
that the file where memory is saved is firstly attempted to be
created under root:root (because that's what libvirtd is running
under) and if this fails the second attempt is done under
domain's uid:gid. This does not make much sense - qemu is given
opened FD so it does not need to access the file. Moreover, if
dynamicOwnership is set in qemu.conf and the file lives on a
squashed NFS this is deadly combination and very likely to fail.

The fix consists of using:

  qemuOpenFileAs(fallback_uid = cfg->user,
                 fallback_gid = cfg->group,
                 dynamicOwnership = false)

In other words, dynamicOwnership is turned off for memory
snapshot (chown() will still be attempted if the file does not
live on NFS) and instead of using domain DAC label, configured
user:group is set as fallback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2018-07-25 08:14:54 +02:00
Michal Privoznik
149f0c4e00 viriscsitest: Extend virISCSIConnectionLogin test
Extend this existing test so that a case when IQN is provided is
tested too. Since a special iSCSI interface is created and its
name is randomly generated at runtime we need to link with
virrandommock to have predictable names.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
9c2ccd64c9 viriscsitest: Introduce testIscsiadmCbData struct
Some tests will want to pass their own callback data into the
testIscsiadmCbData callback. Introduce testIscsiadmCbData struct
to give this some form and order.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
e97cd364f7 viriscsitest: Move testSessionInfo struct
This struct has nothing to do with testIscsiadmCb() rather than
testISCSIGetSession(). Move it closer to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
b5871d0c75 viriscsitest: Test virISCSIConnectionLogin
Introduce one basic test that tests the simplest case:
logging into portal without any IQN.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
c1a75828e4 virCommandWait: Propagate dryRunCallback return value properly
The documentation to virCommandWait() function states that if
@exitstatus is NULL and command finished with error -1 is
returned. In other words, if @dryRunCallback is set and returns
an error (by setting its @status argument to a nonzero value) we
must propagate this error properly honouring the documentation
(and also regular run).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
adfcbdff91 virISCSIScanTargets: Allow making targets persistent
After a new iSCSI interface is successfully set up, we issue a
sendtargets command. However, after 56057900dc we don't
update the host config which in turn makes login fail because
iscsiadm is unable to find any matching record for the interface.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
2e5ad5881b virISCSIScanTargets: Honour iSCSI interface
When scanning for targets, iSCSI might give different results
depending on the interface used. This is basically just name of
config file under /etc/iscsi/ifaces to use. The file contains
initiator IQN thus different results claim.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
f28099ddd7 virStorageBackendIQNFound: Rework iscsiadm output parsing
Firstly, we can utilize virCommandSetOutputBuffer() API which
will collect the command output for us. Secondly, sscanf()-ing
through each line is easier to understand (and more robust) than
jumping over a string with strchr().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
adeadc53a7 virStorageBackendIQNFound: Rename out label
This is in fact 'cleanup' label and it should be named as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Michal Privoznik
893ccaeca4 virStorageBackendIQNFound: Fix ret value assignment
Perform some method clean-up to follow more accepted coding standards:

 * Initialize @ret to error value and prove otherwise.
 * Initialize *ifacename to NULL

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-25 07:11:13 +02:00
Cole Robinson
0dc8ecbf1d run: Fix LIBVIRTD_PATH
It wasn't updated when libvirtd was moved from daemon/ to src/

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-24 12:10:21 -04:00
Michal Privoznik
fa18da2d81 storage_util: Prefer generic FICLONE over btrfs/xfs defines
After my change to the original patch that resulted in commit
8ed874b39b it was brought to my attention that all three defines
are the same: FICLONE = BTRFS_IOC_CLONE = XFS_IOC_CLONE (as
documented in ioctl_ficlone(2)). Therefore we should prefer
generic FICLONE over 'specific' defines for btrfs/xfs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-07-24 15:15:34 +02:00
Peter Krempa
986152e004 qemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR
If we'd fail to enter or exit the monitor the saved error would be
leaked. Introduced in 8498a1e222 .

Pointed out by coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-24 10:20:32 +02:00
Marc Hartmayer
5f02e28480 virTypedParamsDeserialize: set nparams to 0 in case of an error
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-23 14:28:58 -04:00
Marc Hartmayer
97be85dcc3 virTypedParamsSerialize: set remote_params_len at the end
Update the length @remote_params_len only if the related
@remote_params_val has also been set.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-23 14:28:53 -04:00
Ján Tomko
c31146685f tests: also skip qemuagenttest with old jansson
qemuagenttest also depends on JSON object key ordering:
Invalid value of argument 'vcpus' of command 'guest-set-vcpus':
expected '[{"logical-id":1,"online":false}]' got '[{"online":false,"logical-id":1}]'

Skip it as well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 17:03:02 +02:00
Peter Krempa
9c9d697a5c tests: qemuxml2argv: Add CAPS_LATEST version of security-related tests
'disk-network-source-auth' and 'disk-network-tlsx509'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:36 +02:00
Peter Krempa
ca19bb378f tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-sheepdog'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:36 +02:00
Peter Krempa
9b7631d2b6 tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-gluster'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
d276a6a517 tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-readonly' and 'disk-shared'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
a08aa3154b tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-floppy' and 'floppy-drive-fat'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
60ed5f7b7a tests: qemu: Remove pointless 'disk-many' test
We have several cases when a VM has multiple disks in the test files so
having another one without any interesting configuration is not
necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
d20de39c3f tests: qemuxml2argv: Unify testing of 'disk-network-rbd'
Move the authentication and ipv6 cases into the main test file. To allow
removal of the separate testing of the secure credential passing via the
'secret' object in qemu, use the DO_TEST_CAPS_VER macro with version
2.5.0 when the secret object is not supported by qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
4d016addca tests: qemu: Remove pointless 'disk-network-ceph-env' test
The xml2argv variant was unused. The xml2xml variant is redundant in
other tests for RBD.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
ff8bc0876d tests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-nbd'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
14ded7bb83 tests: qemu: Unify nbd disk source testing
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00
Peter Krempa
a1bca5479e tests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-iscsi'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:35 +02:00