]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoqemu: Use the correct vm def on cold attach
John Ferlan [Tue, 12 Jun 2018 12:44:21 +0000 (08:44 -0400)]
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>
6 years agonetwork: Use 'switch' control statement with virNetworkForwardType enum
Shi Lei [Tue, 24 Jul 2018 03:49:48 +0000 (11:49 +0800)]
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>
6 years agoesx storage: Fix typo lsilogic -> lsiLogic
Marcos Paulo de Souza [Tue, 24 Jul 2018 00:15:51 +0000 (00:15 +0000)]
esx storage: Fix typo lsilogic -> lsiLogic

Commit 77298458d027db4d3e082213355e2d792f65158d 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>
6 years agoutil: Fix virStorageBackendIQNFound() to work on FreeBSD
Andrea Bolognani [Wed, 25 Jul 2018 09:18:39 +0000 (11:18 +0200)]
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>
6 years agonews: Add --alias to virsh attach-disk and attach-interface
Han Han [Mon, 23 Jul 2018 14:12:46 +0000 (22:12 +0800)]
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>
6 years agoqemuDomainSaveMemory: Don't enforce dynamicOwnership
Michal Privoznik [Tue, 26 Jun 2018 13:34:21 +0000 (15:34 +0200)]
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>
6 years agoviriscsitest: Extend virISCSIConnectionLogin test
Michal Privoznik [Wed, 4 Jul 2018 08:41:54 +0000 (10:41 +0200)]
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>
6 years agoviriscsitest: Introduce testIscsiadmCbData struct
Michal Privoznik [Wed, 4 Jul 2018 08:47:07 +0000 (10:47 +0200)]
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>
6 years agoviriscsitest: Move testSessionInfo struct
Michal Privoznik [Wed, 4 Jul 2018 08:43:36 +0000 (10:43 +0200)]
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>
6 years agoviriscsitest: Test virISCSIConnectionLogin
Michal Privoznik [Wed, 4 Jul 2018 08:08:48 +0000 (10:08 +0200)]
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>
6 years agovirCommandWait: Propagate dryRunCallback return value properly
Michal Privoznik [Wed, 4 Jul 2018 07:57:05 +0000 (09:57 +0200)]
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>
6 years agovirISCSIScanTargets: Allow making targets persistent
Michal Privoznik [Fri, 29 Jun 2018 14:18:23 +0000 (16:18 +0200)]
virISCSIScanTargets: Allow making targets persistent

After a new iSCSI interface is successfully set up, we issue a
sendtargets command. However, after 56057900dc53df490d 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>
6 years agovirISCSIScanTargets: Honour iSCSI interface
Michal Privoznik [Fri, 29 Jun 2018 14:05:50 +0000 (16:05 +0200)]
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>
6 years agovirStorageBackendIQNFound: Rework iscsiadm output parsing
Michal Privoznik [Fri, 29 Jun 2018 09:34:23 +0000 (11:34 +0200)]
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>
6 years agovirStorageBackendIQNFound: Rename out label
Michal Privoznik [Fri, 29 Jun 2018 09:43:54 +0000 (11:43 +0200)]
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>
6 years agovirStorageBackendIQNFound: Fix ret value assignment
Michal Privoznik [Fri, 29 Jun 2018 08:12:58 +0000 (10:12 +0200)]
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>
6 years agorun: Fix LIBVIRTD_PATH
Cole Robinson [Tue, 24 Jul 2018 14:31:21 +0000 (10:31 -0400)]
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>
6 years agostorage_util: Prefer generic FICLONE over btrfs/xfs defines
Michal Privoznik [Mon, 9 Jul 2018 10:59:20 +0000 (12:59 +0200)]
storage_util: Prefer generic FICLONE over btrfs/xfs defines

After my change to the original patch that resulted in commit
8ed874b39b3 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>
6 years agoqemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR
Peter Krempa [Mon, 23 Jul 2018 13:38:02 +0000 (15:38 +0200)]
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 8498a1e2221 .

Pointed out by coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirTypedParamsDeserialize: set nparams to 0 in case of an error
Marc Hartmayer [Tue, 17 Jul 2018 12:02:33 +0000 (14:02 +0200)]
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>
6 years agovirTypedParamsSerialize: set remote_params_len at the end
Marc Hartmayer [Tue, 17 Jul 2018 12:02:32 +0000 (14:02 +0200)]
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>
6 years agotests: also skip qemuagenttest with old jansson
Ján Tomko [Mon, 23 Jul 2018 14:57:20 +0000 (16:57 +0200)]
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>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of security-related tests
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
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>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-sheepdog'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
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>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-gluster'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
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>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-readonly' and 'disk-shared'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
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>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-floppy' and 'floppy-drive-fat'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
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>
6 years agotests: qemu: Remove pointless 'disk-many' test
Peter Krempa [Thu, 19 Jul 2018 15:22:09 +0000 (17:22 +0200)]
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>
6 years agotests: qemuxml2argv: Unify testing of 'disk-network-rbd'
Peter Krempa [Thu, 19 Jul 2018 15:07:45 +0000 (17:07 +0200)]
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>
6 years agotests: qemu: Remove pointless 'disk-network-ceph-env' test
Peter Krempa [Thu, 19 Jul 2018 14:58:26 +0000 (16:58 +0200)]
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>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-nbd'
Peter Krempa [Thu, 19 Jul 2018 14:29:19 +0000 (16:29 +0200)]
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>
6 years agotests: qemu: Unify nbd disk source testing
Peter Krempa [Thu, 19 Jul 2018 14:26:48 +0000 (16:26 +0200)]
tests: qemu: Unify nbd disk source testing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-iscsi'
Peter Krempa [Thu, 19 Jul 2018 14:19:32 +0000 (16:19 +0200)]
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>
6 years agotests: qemu: Unify iscsi disk source testing
Peter Krempa [Thu, 19 Jul 2018 13:39:23 +0000 (15:39 +0200)]
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>
6 years agotests: qemu: Unify disk cache testing
Peter Krempa [Thu, 19 Jul 2018 13:00:50 +0000 (15:00 +0200)]
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>
6 years agotests: qemu: Add xml2xml and minimal version of 'disk-cache' test
Peter Krempa [Thu, 19 Jul 2018 13:21:40 +0000 (15:21 +0200)]
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>
6 years agotests: qemuxml2argv: Rename disk-write-cache test do disk-cache
Peter Krempa [Thu, 19 Jul 2018 12:51:21 +0000 (14:51 +0200)]
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>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-aio' test
Peter Krempa [Thu, 19 Jul 2018 12:14:11 +0000 (14:14 +0200)]
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>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version for 'disk-detect-zeroes'
Peter Krempa [Thu, 19 Jul 2018 12:12:19 +0000 (14:12 +0200)]
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>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' data for disk-cdrom* tests
Peter Krempa [Thu, 19 Jul 2018 12:07:17 +0000 (14:07 +0200)]
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>
6 years agotests: qemuxml2argv: Unify testing of local cdroms
Peter Krempa [Thu, 19 Jul 2018 12:01:07 +0000 (14:01 +0200)]
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>
6 years agotests: qemuxml2argv: Unify network cdrom source testing
Peter Krempa [Thu, 19 Jul 2018 11:46:05 +0000 (13:46 +0200)]
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>
6 years agotests: qemuxml2argv: Remove tests obsoleted by assuming support for '-device'
Peter Krempa [Thu, 19 Jul 2018 11:38:29 +0000 (13:38 +0200)]
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>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of "disk-copy_on_read"
Peter Krempa [Thu, 19 Jul 2018 11:49:39 +0000 (13:49 +0200)]
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>
6 years agotests: qemuxml2xml: Remove duplicate test disk-copy-on-read.xml
Peter Krempa [Thu, 19 Jul 2018 11:21:28 +0000 (13:21 +0200)]
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>
6 years agotests: qemu: Drop 'drive' from disk tests
Peter Krempa [Thu, 19 Jul 2018 08:29:29 +0000 (10:29 +0200)]
tests: qemu: Drop 'drive' from disk tests

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Improve virStrncpy() implementation
Andrea Bolognani [Fri, 20 Jul 2018 11:00:44 +0000 (13:00 +0200)]
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>
6 years agoesx: Use memcpy() in esxVI_CURL_Debug()
Andrea Bolognani [Fri, 20 Jul 2018 07:50:37 +0000 (09:50 +0200)]
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>
6 years agosrc: Make virStr*cpy*() functions return an int
Andrea Bolognani [Fri, 20 Jul 2018 07:50:37 +0000 (09:50 +0200)]
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>
6 years agosrc: Don't rely on strncpy()-like behavior
Andrea Bolognani [Fri, 20 Jul 2018 12:15:09 +0000 (14:15 +0200)]
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>
6 years agosrc: Use virStrcpy() wherever possible
Andrea Bolognani [Fri, 20 Jul 2018 11:00:34 +0000 (13:00 +0200)]
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>
6 years agosrc: Use VIR_STRDUP() wherever possible
Andrea Bolognani [Fri, 20 Jul 2018 07:45:12 +0000 (09:45 +0200)]
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>
6 years agosrc: Use virStrcpyStatic() wherever possible
Andrea Bolognani [Mon, 16 Jul 2018 14:20:39 +0000 (16:20 +0200)]
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>
6 years agosrc: Use virStrcpyStatic() to avoid truncation
Andrea Bolognani [Tue, 17 Jul 2018 08:21:50 +0000 (10:21 +0200)]
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>
6 years agorpm: remove conditionals for systemd
Daniel P. Berrangé [Fri, 20 Jul 2018 10:54:37 +0000 (11:54 +0100)]
rpm: remove conditionals for systemd

All our supported RHEL and Fedora versions include systemd, so we can
assume it is always present in the spec.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agorpm: increase min required RHEL to 7
Daniel P. Berrangé [Fri, 20 Jul 2018 10:50:01 +0000 (11:50 +0100)]
rpm: increase min required RHEL to 7

We no longer build on RHEL-6, so can bump min required RHEL to 7
removing many conditions.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: fix TLS handshake failure with TLS 1.3
Daniel P. Berrangé [Wed, 18 Jul 2018 18:21:06 +0000 (19:21 +0100)]
tests: fix TLS handshake failure with TLS 1.3

When gnutls negotiates TLS 1.3 instead of 1.2, the order of messages
sent by the handshake changes. This exposed a logic bug in the test
suite which caused us to wait for the server to see handshake
completion, but not wait for the client to see completion. The result
was the client didn't receive the certificate for verification and the
test failed.

This is exposed in Fedora 29 rawhide which has just enabled TLS 1.3 in
its GNUTLS builds.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirsh: Support alias in attach-interface
Han Han [Sun, 15 Jul 2018 10:08:17 +0000 (18:08 +0800)]
virsh: Support alias in attach-interface

Add --alias to support custom alias in virsh attach-interface.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovirsh: Support alias in attach-disk
Han Han [Sun, 15 Jul 2018 10:08:16 +0000 (18:08 +0800)]
virsh: Support alias in attach-disk

Add --alias to support custom disk alias in virsh attach-disk.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agosrc: Fix memory leak in virNWFilterBindingDispose
John Ferlan [Fri, 20 Jul 2018 14:58:45 +0000 (10:58 -0400)]
src: Fix memory leak in virNWFilterBindingDispose

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

Commit b57a9aec neglected to VIR_FREE(binding->filtername) as seen
in the following valgrind report

==6423== 17,328 bytes in 1,083 blocks are definitely lost in loss record 2,275 of 2,297
==6423==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==6423==    by 0x83B20C9: strdup (in /usr/lib64/libc-2.17.so)
==6423==    by 0x533C144: virStrdup (virstring.c:977)
==6423==    by 0x54BDD53: virGetNWFilterBinding (datatypes.c:865)
==6423==    by 0x318D633C: nwfilterBindingCreateXML (nwfilter_driver.c:767)
==6423==    by 0x54F3FC5: virNWFilterBindingCreateXML (libvirt-nwfilter.c:701)
==6423==    by 0x539CE29: virDomainConfNWFilterInstantiate (domain_nwfilter.c:116)
==6423==    by 0x31E516C2: qemuInterfaceBridgeConnect (qemu_interface.c:589)
==6423==    by 0x31D98B56: qemuBuildInterfaceCommandLine (qemu_command.c:8418)
==6423==    by 0x31D9F783: qemuBuildNetCommandLine (qemu_command.c:8673)
==6423==    by 0x31D9F783: qemuBuildCommandLine (qemu_command.c:10354)
==6423==    by 0x31DE355F: qemuProcessLaunch (qemu_process.c:6292)
==6423==    by 0x31DE7881: qemuProcessStart (qemu_process.c:6686)

and

==6423== 17,328 bytes in 1,083 blocks are definitely lost in loss record 2,276 of 2,297
==6423==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==6423==    by 0x83B20C9: strdup (in /usr/lib64/libc-2.17.so)
==6423==    by 0x533C144: virStrdup (virstring.c:977)
==6423==    by 0x54BDD53: virGetNWFilterBinding (datatypes.c:865)
==6423==    by 0x318D641F: nwfilterBindingLookupByPortDev (nwfilter_driver.c:678)
==6423==    by 0x54F3B63: virNWFilterBindingLookupByPortDev (libvirt-nwfilter.c:593)
==6423==    by 0x539CBC5: virDomainConfNWFilterTeardownImpl.isra.0 (domain_nwfilter.c:136)
==6423==    by 0x539CFA5: virDomainConfVMNWFilterTeardown (domain_nwfilter.c:170)
==6423==    by 0x31DE5651: qemuProcessStop (qemu_process.c:6912)
==6423==    by 0x31E37974: qemuDomainDestroyFlags (qemu_driver.c:2229)
==6423==    by 0x54C24BB: virDomainDestroy (libvirt-domain.c:475)
==6423==    by 0x1589A2: remoteDispatchDomainDestroy (remote_daemon_dispatch_stubs.h:4827)
==6423==    by 0x1589A2: remoteDispatchDomainDestroyHelper (remote_daemon_dispatch_stubs.h:4803)

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agorpc: Fix name of include guard
Marc Hartmayer [Tue, 3 Jul 2018 11:37:38 +0000 (13:37 +0200)]
rpc: Fix name of include guard

The include guard should match the file name and comment.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirt-admin: Fix two error messages
Marc Hartmayer [Tue, 3 Jul 2018 11:37:37 +0000 (13:37 +0200)]
virt-admin: Fix two error messages

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodaemon: Raise an error if 'max_workers' < 1 in libvirtd.conf
Marc Hartmayer [Tue, 3 Jul 2018 11:37:36 +0000 (13:37 +0200)]
daemon: Raise an error if 'max_workers' < 1 in libvirtd.conf

Hypervisor drivers (e.g. QEMU) assume that they run in a separate
thread from the main event loop thread otherwise deadlocks can
occur. Therefore let's report an error if max_workers < 1 is set in
the libvirtd configuration file.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirThreadPool: Prevent switching between zero and non-zero maxWorkers
Marc Hartmayer [Tue, 3 Jul 2018 11:37:35 +0000 (13:37 +0200)]
virThreadPool: Prevent switching between zero and non-zero maxWorkers

...since maxWorkers=0 is only intended for virtlockd or virlogd which
must not be multithreaded.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agorpc: Fix deadlock if there is no worker pool available
Marc Hartmayer [Tue, 3 Jul 2018 11:37:33 +0000 (13:37 +0200)]
rpc: Fix deadlock if there is no worker pool available

@srv must be unlocked for the call virNetServerProcessMsg otherwise a
deadlock can occur.

Since the pointer 'srv->workers' will never be changed after
initialization and the thread pool has it's own locking we can release
the lock of 'srv' earlier. This also fixes the deadlock.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Replace qemuDomainDiskSourceDiffers by virStorageSourceIsSameLocation
Peter Krempa [Wed, 18 Jul 2018 15:11:50 +0000 (17:11 +0200)]
qemu: Replace qemuDomainDiskSourceDiffers by virStorageSourceIsSameLocation

Now that we have a saner replacement for checking if the disk source is
the same use it instead of formatting qemu command-line chunks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutils: storage: Add helper for checking if storage source is the same
Peter Krempa [Fri, 13 Jul 2018 15:25:33 +0000 (17:25 +0200)]
utils: storage: Add helper for checking if storage source is the same

To allow checking whether a storage source points to the same location
add a helper which checks the relevant fields. This will allow replacing
a similar check done by formatting the command line arguments for
qemu-like syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Split out code to gather data from 'query-block'
Peter Krempa [Wed, 20 Jun 2018 08:43:07 +0000 (10:43 +0200)]
qemu: monitor: Split out code to gather data from 'query-block'

Extract the code for future reuse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: json: Extract gathering of block statistics
Peter Krempa [Mon, 31 Jul 2017 12:35:45 +0000 (14:35 +0200)]
qemu: json: Extract gathering of block statistics

The code is useful also when gathering statistics per node name, so
extract it to a separate functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Add the 'query-nodes' argument for query-blockstats
Peter Krempa [Fri, 15 Jun 2018 12:55:19 +0000 (14:55 +0200)]
qemu: monitor: Add the 'query-nodes' argument for query-blockstats

The 'query-blockstats' command does not return statistics for the
explicitly named nodes unless the new argument is specified. Add
infrastrucuture that will allow us to use the new approach if desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: command: use qemuDomainDiskGetBackendAlias in commandline building
Peter Krempa [Tue, 26 Jun 2018 05:32:28 +0000 (07:32 +0200)]
qemu: command: use qemuDomainDiskGetBackendAlias in commandline building

Use the proper backend for the block device both when using -drive and
when -blockdev will be used for disk drives and floppy disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: Add helper for getting the disk backend alias
Peter Krempa [Tue, 26 Jun 2018 04:58:47 +0000 (06:58 +0200)]
qemu: domain: Add helper for getting the disk backend alias

The disk backend alias was historically the alias of the -drive backing
the storage. For setups with -blockdev this will become more complex as
it will depend on other configs and generally will differ.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: Move out clearing of backing chain in qemuDomainDetermineDiskChain
Peter Krempa [Tue, 24 Apr 2018 12:07:22 +0000 (14:07 +0200)]
qemu: domain: Move out clearing of backing chain in qemuDomainDetermineDiskChain

In some cases backing chain needs to be cleared prior to re-detection.
Move this step out of qemuDomainDetermineDiskChain as only certain
places need it and the function itself is able to skip to the end of the
chain to perform detection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: driver: Reuse qemuDomainBlocksStatsGather in qemuDomainGetBlockInfo
Peter Krempa [Mon, 18 Jun 2018 11:06:53 +0000 (13:06 +0200)]
qemu: driver: Reuse qemuDomainBlocksStatsGather in qemuDomainGetBlockInfo

Allow updating capacity for the block devices returned by
qemuDomainBlocksStatsGather and replace the open-coded call to
qemuMonitorGetAllBlockStatsInfo by the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutils: storage: Add copying of PR definition to virStorageSource
Peter Krempa [Fri, 13 Jul 2018 14:19:38 +0000 (16:19 +0200)]
utils: storage: Add copying of PR definition to virStorageSource

Despite the warning that virStorageSourceCopy needs to be populated on
additions to the structure commit 687730540e4 neglected to implement the
copy function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Add/remove managed PR objects on media change
Peter Krempa [Fri, 13 Jul 2018 16:37:43 +0000 (18:37 +0200)]
qemu: hotplug: Add/remove managed PR objects on media change

When changing cdrom media we did not handle the managed PR objects thus
we'd either have a stale PR object left behind or the media change would
fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Make qemuHotplugWaitForTrayEject reusable
Peter Krempa [Fri, 13 Jul 2018 15:55:59 +0000 (17:55 +0200)]
qemu: hotplug: Make qemuHotplugWaitForTrayEject reusable

Remove the issue of the monitor command to the caller so that the
function can be used with the modern approach.

Additionally improve the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Extract legacy disk media changing bits
Peter Krempa [Fri, 13 Jul 2018 15:44:32 +0000 (17:44 +0200)]
qemu: hotplug: Extract legacy disk media changing bits

Prepare for the -blockdev implementation of ejectable media changing by
splitting up the old bits.

Additionally since both callers make sure that the device is a cdrom or
floppy the check is no longer necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Refactor/simplify PR managed addition to VM
Peter Krempa [Fri, 13 Jul 2018 12:14:17 +0000 (14:14 +0200)]
qemu: hotplug: Refactor/simplify PR managed addition to VM

Similarly to qemuDomainDiskRemoveManagedPR make it enter monitor on
its own so that it can be reused. Future users will be in the snapshot
code and in removable media change code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Simplify removal of managed PR infrastructure on unplug
Peter Krempa [Wed, 11 Jul 2018 12:24:49 +0000 (14:24 +0200)]
qemu: hotplug: Simplify removal of managed PR infrastructure on unplug

Extract the (possible) removal of the PR backend and daemon into a
separate helper which enters monitor on its own. This simplifies the
code and allows reuse of this function in the future e.g. for blockjobs
where removing a image with PR may result into PR not being necessary.

Since the PR is not used often the overhead of entering monitor again
should be negligible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Reuse qemuHotplugDiskSourceRemove for disk backend removal
Peter Krempa [Wed, 11 Jul 2018 09:16:41 +0000 (11:16 +0200)]
qemu: hotplug: Reuse qemuHotplugDiskSourceRemove for disk backend removal

Add code which will convert a disk definition into
qemuHotplugDiskSourceData and then reuse qemuHotplugDiskSourceRemove to
remove all the backend related objects.

This unifies the detach code as much as possible with the already
existing helpers and will allow reuse this infrastructure when changing
removable disk media.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Don't leak 'disk' if VM crashes during unplug finishing
Peter Krempa [Fri, 13 Jul 2018 10:54:26 +0000 (12:54 +0200)]
qemu: hotplug: Don't leak 'disk' if VM crashes during unplug finishing

qemuDomainRemoveDiskDevice would leak the disk to be removed if the VM
crashed since it was removed from the definition but not freed.

Broken in commit 105bcdde76b which moved the removal from the definition
earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Prepare for multiple backing chain member hotplug
Peter Krempa [Wed, 11 Jul 2018 16:26:12 +0000 (18:26 +0200)]
qemu: hotplug: Prepare for multiple backing chain member hotplug

Similarly to how we've intergrated data belonging to a single
virStorageSource for purposes of attaching it to a qemu instance we will
need to agregate data relevant for the whole disk. With blockdev there
will be some disk-wide backing chain members such as the copy-on-read
handler.

Introduce qemuHotplugDiskSourceData which agregates the backing chain
and other data relevant for the disk and functions which generate it
and apply and rollback it.

In addition to disk hotplug this will also be reused for media changing
where we need to exchange the full disk backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Don't format NULL in %s in qemuHotplugPrepareDiskAccess
Peter Krempa [Wed, 11 Jul 2018 15:30:19 +0000 (17:30 +0200)]
qemu: hotplug: Don't format NULL in %s in qemuHotplugPrepareDiskAccess

The warning messages which include the disk source could potentially
format NULL using %s as virDomainDiskGetSource may return NULL for e.g.
NBD disks. As most of the APIs are NOOP for remote disks the usage of
the source string only should be fine for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Remove pointless variable
Peter Krempa [Wed, 11 Jul 2018 15:25:19 +0000 (17:25 +0200)]
qemu: hotplug: Remove pointless variable

Now that there's only one use of it, replace it directly by the code
filling it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Reuse qemuHotplugPrepareDiskAccess in qemuDomainRemoveDiskDevice
Peter Krempa [Wed, 11 Jul 2018 15:21:36 +0000 (17:21 +0200)]
qemu: hotplug: Reuse qemuHotplugPrepareDiskAccess in qemuDomainRemoveDiskDevice

qemuHotplugPrepareDiskAccess can be used to tear down disk access so we
can replace the open-coded version collecting the same function calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotools: Fix typo generating adapter_wwpn field
John Ferlan [Thu, 19 Jul 2018 18:00:07 +0000 (14:00 -0400)]
tools: Fix typo generating adapter_wwpn field

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

Fix typo from commit id d45bee449 for the parent_wwpn field
resulting in parent_wwnn being printed twice.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: monitor: Remove old code for dual handling of 'transaction' data
Peter Krempa [Tue, 3 Jul 2018 12:21:56 +0000 (14:21 +0200)]
qemu: monitor: Remove old code for dual handling of 'transaction' data

Now that we use only the separate function for creating data for the
'transaction' command we can remove all the boilerplate which was
necessary before.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Remove old external snapshot code
Peter Krempa [Tue, 3 Jul 2018 12:16:27 +0000 (14:16 +0200)]
qemu: monitor: Remove old external snapshot code

Remove the dual mode code which allowed to create snapshots without
support for 'transaction'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Create helper for creating data for legacy snapshots
Peter Krempa [Tue, 3 Jul 2018 12:13:29 +0000 (14:13 +0200)]
qemu: block: Create helper for creating data for legacy snapshots

With 'transaction' support we don't need to keep around the multipurpose
code which would create the snapshot if 'transaction' is not supported.

To simplify this add a new helper that just wraps the arguments for
'blockdev-snapshot-sync' operation in 'transaction' and use it instead
of qemuBlockSnapshotAddLegacy.

Additionally this allows to format the arguments prior to creating the
file for simpler cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Add API to help creating 'transaction' arguments
Peter Krempa [Tue, 3 Jul 2018 07:24:40 +0000 (09:24 +0200)]
qemu: monitor: Add API to help creating 'transaction' arguments

Add a new helper that will be solely used to create arguments for the
transaction command. Later on this will make it possible to remove the
overloading which was caused by the fact that snapshots were created
without transaction and also will help in blockdevification of snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Audit actual disk snapshot creation
Peter Krempa [Tue, 3 Jul 2018 05:58:48 +0000 (07:58 +0200)]
qemu: snapshot: Audit actual disk snapshot creation

Currently we'd audit that we managed to format the data for the
'transaction' command rather than the (un)successful attempt to create
the snapshot.

Move the auditing code so that it can actually audit the result of the
'transaction' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Unify conditions checking whether snapshot needs to be taken
Peter Krempa [Tue, 3 Jul 2018 05:52:11 +0000 (07:52 +0200)]
qemu: snapshot: Unify conditions checking whether snapshot needs to be taken

In the cleanup path we already checked whether a snapshot needed to be
taken by looking into the collected data. Use the same approach when
creating the snapshot command data and when committing the changes to the
domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Remove monitor code now that 'transaction' is always used
Peter Krempa [Tue, 5 Jun 2018 12:56:01 +0000 (14:56 +0200)]
qemu: snapshot: Remove monitor code now that 'transaction' is always used

Since we now always do the snapshot via the 'transaction' command we can
drop the code which would enter monitor for individual disk snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Require support of 'transaction' command for external snapshots
Peter Krempa [Tue, 3 Jul 2018 05:17:29 +0000 (07:17 +0200)]
qemu: snapshot: Require support of 'transaction' command for external snapshots

While qemu supports the 'transaction' command since v1.1.0
(52e7c241ac766406f05fa) and the 'blockdev-snapshot-sync' command since
v0.14.0-rc0 we need to keep the capability bits present since some qemu
downstreams (RHEL/CentOS 7 for example) chose to cripple qemu by
arbitrarily compiling out some stuff which was already present at that
time.

To simplify the crazy code just require both commands to be present at
the beginning of an external snapshot so that we can remove the case when
'transaction' would not be supported.

This also allows to drop any logic connected to the
VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC flag since snapshots are atomic with
the 'transaction' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirt-xml-validate: Add schema for nwfilterbinding
Han Han [Fri, 13 Jul 2018 01:39:29 +0000 (09:39 +0800)]
virt-xml-validate: Add schema for nwfilterbinding

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

Add nwfilterbinding schema in virt-xml-validate for autoprobing.
Add document of nwfilterbinding schema in tools/virt-xml-validate.pod.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agobuild: Fix accidental revert of .gnulib update
John Ferlan [Thu, 19 Jul 2018 19:48:34 +0000 (15:48 -0400)]
build: Fix accidental revert of .gnulib update

Commit id 1bff5bbe25eb7a7e7a4e0067c4ca7cbc1cb34999 accidentally
reverted .gnulib back to d6397dde2e127e246e3eeb5254a21f42cac783c8
which was two updates ago.

Update to the latest 68df637b5f1b5c10370f6981d2a43a5cf74368df
which includes three changes since the previous fetch of
cdbf3d385a32ff904c96f20c26f3470bd8345248.

> autoupdate
> hard-locale: simplify by removing hard-locale.m4
> gnulib-tool: limit line length for git send-email

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agotest: Implement virConnectListAllInterfaces
Cole Robinson [Tue, 10 Jul 2018 19:01:45 +0000 (15:01 -0400)]
test: Implement virConnectListAllInterfaces

This adds some generic virinterfaceobj code, roughly matching what
is used by other stateful drivers like network, storage, etc.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Fix broken autostart symlink after renaming domain
Julio Faracco [Thu, 19 Jul 2018 04:21:48 +0000 (01:21 -0300)]
qemu: Fix broken autostart symlink after renaming domain

If a domain is configured to start on boot, it has a symlink to the
domain definition inside the autostart directory. If you rename this
domain, the definition is renamed too. The symlink need to be pointed to
this renamed file. This commit recreates the symlink after renaming the
XML file.

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: set OOM in virCopyLastError if error is not set
Nikolay Shirokovskiy [Mon, 2 Jul 2018 11:16:52 +0000 (14:16 +0300)]
util: set OOM in virCopyLastError if error is not set

virCopyLastError is intended to be used after last error is set.
However due to virLastErrorObject failures (very unlikely though
as thread local error is allocated on first use) we can have zero
fields in a copy as a result. In particular code field can be set
to VIR_ERR_OK.

In some places (qemu monitor, qemu agent and qemu migaration code
for example) we use copy result as a flag and this leads to bugs.

Let's set OOM-like error in copy in case of virLastErrorObject failures.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>