Commit Graph

30398 Commits

Author SHA1 Message Date
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
Peter Krempa
a717cf2c94 tests: qemu: Unify iscsi disk source testing
Move various different iSCSI configuration into one test file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
d1c9c6bf74 tests: qemu: Unify disk cache testing
Move the 'unsafe' cache test into 'disk-cache' and remove all the
individual cases for one cache mode each.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
b60e5f9198 tests: qemu: Add xml2xml and minimal version of 'disk-cache' test
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
e38a890c93 tests: qemuxml2argv: Rename disk-write-cache test do disk-cache
We'll aggregate testing of all cache modes in this test later on.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
9245aad664 tests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-aio' test
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
cc0f112a63 tests: qemuxml2argv: Add 'CAPS_LATEST' version for 'disk-detect-zeroes'
This test also excercises options of 'discard'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
6bcffc5113 tests: qemuxml2argv: Add 'CAPS_LATEST' data for disk-cdrom* tests
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
e5dce69a9c tests: qemuxml2argv: Unify testing of local cdroms
Test empty cdroms along with cdroms with medium.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:34 +02:00
Peter Krempa
5617c1d30f tests: qemuxml2argv: Unify network cdrom source testing
Unify most of the tests into a common test named disk-cdrom-network by
adding multiple cdroms. The 'http' test is dropped since there can be
only 4 cdroms.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:33 +02:00
Peter Krempa
f6a1a8911e tests: qemuxml2argv: Remove tests obsoleted by assuming support for '-device'
Few disk tests were testing support for pure -drive command line
generation for disks now that we assume it for all qemu versions the
cases are obsolete.

Replacements:
disk-readonly-no-device -> disk-readonly-disk
disk-floppy-tray-no-device -> disk-floppy-tray
disk-cdrom-tray-no-device -> disk-cdrom-tray

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:33 +02:00
Peter Krempa
e38ebbc1c0 tests: qemuxml2argv: Add 'CAPS_LATEST' version of "disk-copy_on_read"
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:33 +02:00
Peter Krempa
e9d0e2fd7f tests: qemuxml2xml: Remove duplicate test disk-copy-on-read.xml
We also have disk-copy_on_read.xml which also tests the command line.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:33 +02:00
Peter Krempa
0bdb704383 tests: qemu: Drop 'drive' from disk tests
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-23 15:32:33 +02:00
Andrea Bolognani
7d70a63b94 util: Improve virStrncpy() implementation
We finally get rid of the strncpy()-like semantics
and implement our own, more sensible ones instead.

As a bonus, this also fixes compilation on MinGW.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:37 +02:00
Andrea Bolognani
19136bbf10 esx: Use memcpy() in esxVI_CURL_Debug()
We're going to change virStrncpy() in a way that
requires the source string to be NULL-terminated, so
we'll no longer be able to use in this context.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:33 +02:00
Andrea Bolognani
6c0d0210cb src: Make virStr*cpy*() functions return an int
Currently, the functions return a pointer to the
destination buffer on success or NULL on failure.

Not only does this kind of error handling look quite
alien in the context of libvirt, where most functions
return zero on success and a negative int on failure,
but it's also somewhat pointless because unless there's
been a failure the returned pointer will be the same
one passed in by the user, thus offering no additional
value.

Change the functions so that they return an int
instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:30 +02:00
Andrea Bolognani
583bdfa65c src: Don't rely on strncpy()-like behavior
The strncpy() function has this quirk where it will copy
*up* to the requested number of bytes, that is, it will
stop early if it encounters a NULL byte in the source
string.

This makes it legal to pass the size of the destination
buffer (minus one byte needed for the string terminator)
as the number of bytes to copy and still get something
somewhat reasonable out of the operation; unfortunately,
it also makes the function difficult to reason about
and way too easy to misuse.

We want to move away from the way strncpy() behaves and
towards better defined semantics, where virStrncpy()
will always copy *exactly* the number of bytes it's
been asked to copy; before we can do that, though, we
have to change a few of the callers.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:27 +02:00
Andrea Bolognani
dee35f6acf src: Use virStrcpy() wherever possible
virStrncpy() allows us to copy a substring, but if we're
going to copy the entire thing it's much more convenient
to use virStrcpy() instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:25 +02:00
Andrea Bolognani
5d481d0d02 src: Use VIR_STRDUP() wherever possible
virStrcpy() and friends are useful when the destination
buffer has already been allocated, eg. as part of a struct;
if we have to allocate it on the spot, VIR_STRDUP() is a
better choice.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:23 +02:00
Andrea Bolognani
bfb8ab1b2c src: Use virStrcpyStatic() wherever possible
This convenience macro was created for the simple cases
where the length of the source string and the size of the
destination buffer can be figued out with strlen() and
sizeof() respectively, so we should use it wherever
possible instead of open-coding parts of it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:21 +02:00
Andrea Bolognani
c9d5f2d989 src: Use virStrcpyStatic() to avoid truncation
The way virStrncpy() is called here will never result in
buffer overflow, but it won't prevent or detect truncation
either, despite what the error message might suggest. Use
virStrcpyStatic(), which does all of the above, instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-07-23 14:27:13 +02:00