]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agovirStorageSourceNew: Abort on failure
Peter Krempa [Tue, 22 Sep 2020 09:04:17 +0000 (11:04 +0200)] 
virStorageSourceNew: Abort on failure

Add an abort() on the class/object allocation failures so that
virStorageSourceNew() always returns a virStorageSource and remove
checks from all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: substitute missing model name for host-passthrough
Collin Walling [Wed, 23 Sep 2020 07:26:58 +0000 (09:26 +0200)] 
qemu: substitute missing model name for host-passthrough

Before:
  $ uname -m
  s390x
  $ cat passthrough-cpu.xml
  <cpu check="none" mode="host-passthrough" />
  $ virsh hypervisor-cpu-compare passthrough-cpu.xml
  error: Failed to compare hypervisor CPU with passthrough-cpu.xml
  error: internal error: unable to execute QEMU command 'query-cpu-model-comp
  arison': Invalid parameter type for 'modelb.name', expected: string

After:
  $ virsh hypervisor-cpu-compare passthrough-cpu.xml
  CPU described in passthrough-cpu.xml is identical to the CPU provided by hy
  pervisor on the host

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoNEWS.rst: update NVDIMM changes entry
Daniel Henrique Barboza [Tue, 22 Sep 2020 12:18:29 +0000 (09:18 -0300)] 
NEWS.rst: update NVDIMM changes entry

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse()
Daniel Henrique Barboza [Tue, 22 Sep 2020 12:12:07 +0000 (09:12 -0300)] 
domain_conf.c: auto-align pSeries NVDIMM in virDomainMemoryDefPostParse()

The alignment for the pSeries NVDIMM does not depend on runtime
constraints. This means that it can be done in device parse
time, instead of runtime, allowing the domain XML to reflect
what the auto-alignment would do when the domain starts.

This brings consistency between the NVDIMM size reported by the
domain XML and what the guest sees, without impacting existing
guests that are using an unaligned size - they'll work as usual,
but the domain XML will be updated with the actual size of the
NVDIMM.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c
Daniel Henrique Barboza [Tue, 15 Sep 2020 01:02:47 +0000 (22:02 -0300)] 
conf, qemu: move qemuDomainNVDimmAlignSizePseries to domain_conf.c

We'll use the auto-alignment function during parse time, in
domain_conf.c. Let's move the function to that file, renaming
it to virDomainNVDimmAlignSizePseries(). This will also make it
clearer that, although QEMU is the only driver that currently
supports it, pSeries NVDIMM restrictions aren't tied to QEMU.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoTranslated using Weblate (Italian)
Milo Casagrande [Thu, 10 Sep 2020 13:43:35 +0000 (15:43 +0200)] 
Translated using Weblate (Italian)

Currently translated at 24.6% (2559 of 10366 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/it/

Co-authored-by: Milo Casagrande <milo@milo.name>
Signed-off-by: Milo Casagrande <milo@milo.name>
4 years agotests: build SELinux tests
Ján Tomko [Wed, 23 Sep 2020 13:12:59 +0000 (15:12 +0200)] 
tests: build SELinux tests

We set WITH_LIBATTR in meson.build, not WITH_ATTR.

Also link securityselinuxlabeltest with test_qemu_driver_lib.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 3ace72965c3b11fc763f781ae7ce3ca29dd36507
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: do not unref event thread after joining it
Ján Tomko [Wed, 23 Sep 2020 14:30:22 +0000 (16:30 +0200)] 
util: do not unref event thread after joining it

g_thread_join() eats a reference.

==295055== Invalid read of size 4
==295055==    at 0x4DA4AE4: g_thread_unref (in /usr/lib64/libglib-2.0.so.0.6400.5)
==295055==    by 0x491D5FA: vir_event_thread_finalize (vireventthread.c:47)
==295055==    by 0x4E6BCFF: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.6400.5)
==295055==    by 0x22F35CF4: qemuProcessQMPFree (qemu_process.c:8525)
==295055==    by 0x22E71B58: glib_autoptr_clear_qemuProcessQMP (qemu_process.h:237)
...
==295055==    by 0x22E98A29: qemuDomainPostParseDataAlloc (qemu_domain.c:5476)
==295055==    by 0x49ABF83: virDomainDefPostParse (domain_conf.c:6023)
==295055==  Address 0x2acb1c68 is 24 bytes inside a block of size 88 free'd
==295055==    at 0x483B9F5: free (vg_replace_malloc.c:538)
==295055==    by 0x4D80A4C: g_free (in /usr/lib64/libglib-2.0.so.0.6400.5)
...
==295055==    by 0x491D5F1: vir_event_thread_finalize (vireventthread.c:46)
==295055==    by 0x4E6BCFF: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.6400.5)
==295055==    by 0x22F35CF4: qemuProcessQMPFree (qemu_process.c:8525)
==295055==    by 0x22E71B58: glib_autoptr_clear_qemuProcessQMP (qemu_process.h:237)
...
==295055==  Block was alloc'd at
==295055==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==295055==    by 0x4D80958: g_malloc (in /usr/lib64/libglib-2.0.so.0.6400.5)
...
==295055==    by 0x4DA4C32: g_thread_try_new (in /usr/lib64/libglib-2.0.so.0.6400.5)
==295055==    by 0x491D3BC: virEventThreadStart (vireventthread.c:159)
==295055==    by 0x491D3BC: virEventThreadNew (vireventthread.c:185)
...

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f4fc3db9204407874181117085756c9ced78adad
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: use g_new0 instead of VIR_ALLOC_N
Ján Tomko [Tue, 22 Sep 2020 23:04:17 +0000 (01:04 +0200)] 
tests: use g_new0 instead of VIR_ALLOC_N

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirnetdaemon: fix memory leak in virNetDaemonCallInhibit
Pavel Hrdina [Wed, 23 Sep 2020 14:31:21 +0000 (16:31 +0200)] 
virnetdaemon: fix memory leak in virNetDaemonCallInhibit

g_variant_new() returns a weak reference which can be consumed by passing
to other g_variant* functions or to g_dbus_connection_call* functions.

This make it possible to call g_variant_new() directly as argument to
the functions above. Because this might be confusing I explicitly call
g_variant_ref_sink() to make it normal reference in both
virGDBusCallMethod() and virGDBusCallMethodWithFD() so the caller is
always responsible for the data.

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil/virgdbus: fix memory leak in virGDBusIsServiceInList
Pavel Hrdina [Wed, 23 Sep 2020 13:40:37 +0000 (15:40 +0200)] 
util/virgdbus: fix memory leak in virGDBusIsServiceInList

g_variant_iter_loop() handles freeing all arguments unless we break out
of the loop, in that case we have to free them manually.

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: manpages: Strip table of contents from manpages
Peter Krempa [Wed, 23 Sep 2020 13:13:57 +0000 (15:13 +0200)] 
docs: manpages: Strip table of contents from manpages

After meson conversion the man pages started to contain the table of
contents.

In autoconf we prevented this by a 'grep -v ::contents' in the command
building the manpages.

A more cultured solution is to strip out the 'contents' docutils element
directly.

Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: use g_new0 instead of VIR_ALLOC
Ján Tomko [Tue, 22 Sep 2020 22:42:45 +0000 (00:42 +0200)] 
tests: use g_new0 instead of VIR_ALLOC

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: cpuTestLoadMultiXML: use g_new0 instead of VIR_ALLOC_N
Ján Tomko [Tue, 22 Sep 2020 22:59:59 +0000 (00:59 +0200)] 
tests: cpuTestLoadMultiXML: use g_new0 instead of VIR_ALLOC_N

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: virNumaGetPages: use g_new0 instead of VIR_ALLOC_N
Ján Tomko [Tue, 22 Sep 2020 22:58:49 +0000 (00:58 +0200)] 
tests: virNumaGetPages: use g_new0 instead of VIR_ALLOC_N

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoUse (un)signed printf specifiers correctly
Ján Tomko [Tue, 22 Sep 2020 20:17:03 +0000 (22:17 +0200)] 
Use (un)signed printf specifiers correctly

Various places reported by cppcheck's invalidPrintfArgType_sint
and invalidPrintfArgType_uint.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsh: do not return bool in virshNetworkPortUUIDCompleter
Ján Tomko [Tue, 22 Sep 2020 20:19:26 +0000 (22:19 +0200)] 
virsh: do not return bool in virshNetworkPortUUIDCompleter

portability: Returning an integer in a function with pointer
return type is not portable. [CastIntegerToAddressAtReturn]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agorpc: socket: properly call virSetCloseExec
Ján Tomko [Tue, 22 Sep 2020 20:29:25 +0000 (22:29 +0200)] 
rpc: socket: properly call virSetCloseExec

cppcheck reports:
style: Argument 'fd<0' to function virSetCloseExec is always 0 [knownArgument]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 4b9919af4024a6fbc3d4ee996d8a4c27dbc44285
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: firmware: check virJSONValueObjectGet return value
Ján Tomko [Tue, 22 Sep 2020 21:22:06 +0000 (23:22 +0200)] 
qemu: firmware: check virJSONValueObjectGet return value

If the mapping is not present, we should not try to
access its elements.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 8b5b80f4c5f7342eedce0747469223387ab709ef
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: event: check return value of virInitialize
Ján Tomko [Tue, 22 Sep 2020 21:17:18 +0000 (23:17 +0200)] 
util: event: check return value of virInitialize

This function can possibly fail.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 2e07a1e14635ad25c57b66c13488feff4c8d2b0c
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: esxutilstest: depend on esx_gen_headers
Ján Tomko [Wed, 23 Sep 2020 08:29:56 +0000 (10:29 +0200)] 
tests: esxutilstest: depend on esx_gen_headers

Sometimes parallel compilation randomly fails on platforms
that do not have many drivers enabled, like macOS:

In file included from ../tests/esxutilstest.c:13:
../src/esx/esx_vi_types.h:62:10: fatal error: 'esx_vi_types.generated.typedef' file not found
 #include "esx_vi_types.generated.typedef"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

List esx_gen_headers as a source to stop meson from building
it before the headers are generated.

https://gitlab.com/libvirt/libvirt/-/jobs/726039284

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoesx: separate header and source file generation
Ján Tomko [Wed, 23 Sep 2020 06:37:20 +0000 (08:37 +0200)] 
esx: separate header and source file generation

Invoke the generator twice and introduce separate
meson targets for headers and C sources.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agogdbus: fix virGDBusCallMethodWithFD stub for non-UNIX
Ján Tomko [Wed, 23 Sep 2020 11:18:49 +0000 (13:18 +0200)] 
gdbus: fix virGDBusCallMethodWithFD stub for non-UNIX

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: a961d93768f18c28979ca2841832cd7278bf95b8
4 years agovirgdbus: add DBus reply format check
Pavel Hrdina [Mon, 21 Sep 2020 13:42:00 +0000 (15:42 +0200)] 
virgdbus: add DBus reply format check

We used to check the format of reply data with libdbus so we should do
the same with GLib DBus as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirfirewalld: fix g_variant_get call
Pavel Hrdina [Mon, 21 Sep 2020 12:39:49 +0000 (14:39 +0200)] 
virfirewalld: fix g_variant_get call

We need to pass pointer to `array`.

Reported-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Ján Tomko <jtomko@redhat.com>
4 years agoRemove redundant check when storage pool is mounted
Yi Li [Wed, 23 Sep 2020 03:34:57 +0000 (11:34 +0800)] 
Remove redundant check when storage pool is mounted

virFileComparePaths just return 0 or 1 after commit 7b48bb8
so break while after virFileComparePaths return 1

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Yi Li <yili@winhong.com>
4 years agotests: Don't advertise VIR_TEST_EXPENSIVE to users
Andrea Bolognani [Tue, 22 Sep 2020 11:41:49 +0000 (13:41 +0200)] 
tests: Don't advertise VIR_TEST_EXPENSIVE to users

Right now, the logic that takes care of deciding whether expensive
tests should be run or not is not working correctly: more
specifically, it's not possible to use something like

  $ VIR_TEST_EXPENSIVE=1 ninja test

to override the default choice, because in meson.build we always
pass an explicit value that overrides whatever is present in the
environment.

We could implement logic to make this work properly, but that
would require some refactoring of our test infrastructure and is
arguably of little value given that running

  $ meson build -Dexpensive_tests=enabled

is very fast, so let's just stop telling users about the variable
instead and call it a day.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agomeson: Include value of expensive_tests in summary
Andrea Bolognani [Tue, 22 Sep 2020 13:15:49 +0000 (15:15 +0200)] 
meson: Include value of expensive_tests in summary

It's useful information to have available at a glance.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agodocs: Document global_{period,quota} schedinfo fields
Andrea Bolognani [Fri, 18 Sep 2020 16:36:25 +0000 (18:36 +0200)] 
docs: Document global_{period,quota} schedinfo fields

These fields have existed for a very long time but they were
never documented in virsh(1).

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agolibvirt: ensure defresult is used in virConnectAuthCallbackDefault
Matt Coleman [Tue, 22 Sep 2020 02:01:46 +0000 (22:01 -0400)] 
libvirt: ensure defresult is used in virConnectAuthCallbackDefault

A previous change to this function's password handling broke the use of
default values for credential types other than VIR_CRED_PASSPHRASE and
VIR_CRED_NOECHOPROMPT.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Signed-off-by: Matt Coleman <matt@datto.com>
4 years agobhyve: add VNC password support
Fabian Freyer [Wed, 6 May 2020 13:35:55 +0000 (13:35 +0000)] 
bhyve: add VNC password support

Support setting a password for the VNC framebuffer using the passwd
attribute on the <graphics/> element, if the driver has the
BHYVE_CAP_VNC_PASSWORD capability.

Note that virsh domxml-from-native does not output the password in the
generated XML, as VIR_DOMAIN_DEF_FORMAT_SECURE is not set when
formatting the domain definition.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: probe for VNC password capability
Fabian Freyer [Wed, 6 May 2020 13:35:54 +0000 (13:35 +0000)] 
bhyve: probe for VNC password capability

Introduces the BHYVE_CAP_VNC_PASSWORD capability, which is probed by
parsing the error message from the bhyve command. When it is not
supported, bhyve -s 0,fbuf,password= will return an error message.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: add support for setting fbuf resolution
Fabian Freyer [Wed, 6 May 2020 13:35:53 +0000 (13:35 +0000)] 
bhyve: add support for setting fbuf resolution

The resolution of the VNC framebuffer can now be set via the resolution
definition introduced in 5.9.0.

Also, add "gop" to the list of model types  the <resolution/>
sub-element is valid for.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: support parsing fbuf PCI device
Fabian Freyer [Wed, 6 May 2020 13:35:52 +0000 (13:35 +0000)] 
bhyve: support parsing fbuf PCI device

Add a new helper function, bhyveParsePCIFbuf, to parse the bhyve-argv
parameters for a frame-buffer device to <graphics/> and <video/>
definitions.

For now, only the listen address, port, and vga mode are detected.
Unsupported parameters are silently skipped.

This involves upgrading the private API to expose the
virDomainGraphicsDefNew helper function, which is used by
bhyveParsePCIFbuf.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: add missing test files
Roman Bogorodskiy [Tue, 22 Sep 2020 11:59:37 +0000 (15:59 +0400)] 
bhyve: add missing test files

Fixes: 4277e61e22b7532dc476c44a356081053da470f8
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
4 years agonews: Document changes to NVDIMM handling on ppc64
Andrea Bolognani [Tue, 22 Sep 2020 10:24:04 +0000 (12:24 +0200)] 
news: Document changes to NVDIMM handling on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: revert latest pSeries NVDIMM design changes
Daniel Henrique Barboza [Tue, 15 Sep 2020 02:42:56 +0000 (23:42 -0300)] 
qemu: revert latest pSeries NVDIMM design changes

In [1], changes were made to remove the existing auto-alignment
for pSeries NVDIMM devices. That design promotes strange situations
where the NVDIMM size reported in the domain XML is different
from what QEMU is actually using. We removed the auto-alignment
and relied on standard size validation.

However, this goes against Libvirt design philosophy of not
tampering with existing guest behavior, as pointed out by Daniel
in [2]. Since we can't know for sure whether there are guests that
are relying on the auto-alignment feature to work, the changes
made in [1] are a direct violation of this rule.

This patch reverts [1] entirely, re-enabling auto-alignment for
pSeries NVDIMM as it was before. Changes will be made to ease
the limitations of this design without hurting existing
guests.

This reverts the following commits:

- commit 2d93cbdea9d1b8dbf36bc0ffee6cb73d83d208c7
  Revert "formatdomain.html.in: mention pSeries NVDIMM 'align down' mechanic"

- commit 0ee56369c8b4f2f898b6aa1ff1f51ab033be1c02
  qemu_domain.c: change qemuDomainMemoryDeviceAlignSize() return type

- commit 07de813924caf37e535855541c0c1183d9d382e2
  qemu_domain.c: do not auto-align ppc64 NVDIMMs

- commit 0ccceaa57c50e5ee528f7073fa8723afd62b88b7
  qemu_validate.c: add pSeries NVDIMM size alignment validation

- commit 4fa2202d884414ad34d9952e72fb39b1d93c7e14
  qemu_domain.c: make qemuDomainGetMemorySizeAlignment() public

[1] https://www.redhat.com/archives/libvir-list/2020-July/msg02010.html
[2] https://www.redhat.com/archives/libvir-list/2020-September/msg00572.html

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agotests: avoid close of bad file handle in commandtest
Daniel P. Berrangé [Mon, 21 Sep 2020 17:37:03 +0000 (18:37 +0100)] 
tests: avoid close of bad file handle in commandtest

Closed file handles need to be initialized to -1, not 0. This caused a
inappropriate double close of stdin, which is not desirable, although
it had no ill effects.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: don't mix FILE* and UNIX FD I/O on same stream
Daniel P. Berrangé [Mon, 21 Sep 2020 17:32:29 +0000 (18:32 +0100)] 
tests: don't mix FILE* and UNIX FD I/O on same stream

There is currently a hang in test27 that exhibits itself on FreeBSD 11.4
only. The behaviour is that virCommandProcessIO gets POLLIN on the
FD for stdout, but read() blocks. Meanwhile commandtest also blocks
in write for stderr because the pipe buffers are full.

This fix in commandhelper likely does not really address the root cause
just hides it due to the buffering done by FILE *. Mixing UNIX FD I/O
and FILE * I/O is bad practice regardless.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoudevProcessCSS: Check if def->driver is non-NULL
Marc Hartmayer [Mon, 21 Sep 2020 17:06:32 +0000 (19:06 +0200)] 
udevProcessCSS: Check if def->driver is non-NULL

Don't process subchannel devices where `def->driver` is not set. This
fixes the following segfault:

Thread 21 "nodedev-init" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x3ffb08fc910 (LWP 64303)]
(gdb) bt
 #0  0x000003fffd1272b4 in __strcmp_vx () at /lib64/libc.so.6
 #1  0x000003ffc260c3a8 in udevProcessCSS (device=0x3ff9018d130, def=0x3ff90194a90)
 #2  0x000003ffc260cb78 in udevGetDeviceDetails (device=0x3ff9018d130, def=0x3ff90194a90)
 #3  0x000003ffc260d126 in udevAddOneDevice (device=0x3ff9018d130)
 #4  0x000003ffc260d414 in udevProcessDeviceListEntry (udev=0x3ffa810d800, list_entry=0x3ff90001990)
 #5  0x000003ffc260d638 in udevEnumerateDevices (udev=0x3ffa810d800)
 #6  0x000003ffc260e08e in nodeStateInitializeEnumerate (opaque=0x3ffa810d800)
 #7  0x000003fffdaa14b6 in virThreadHelper (data=0x3ffa810df00)
 #8  0x000003fffc309ed6 in start_thread ()
 #9  0x000003fffd185e66 in thread_start ()
(gdb) p *def
$2 = {
  name = 0x0,
  sysfs_path = 0x3ff90198e80 "/sys/devices/css0/0.0.ff40",
  parent = 0x0,
  parent_sysfs_path = 0x0,
  parent_wwnn = 0x0,
  parent_wwpn = 0x0,
  parent_fabric_wwn = 0x0,
  driver = 0x0,
  devnode = 0x0,
  devlinks = 0x3ff90194670,
  caps = 0x3ff90194380
}

Fixes: 05e6cdafa6e0 ("node_device: detect CSS devices")
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
4 years agobhyve: soften requirements for slot 1
Roman Bogorodskiy [Sun, 20 Sep 2020 14:53:57 +0000 (18:53 +0400)] 
bhyve: soften requirements for slot 1

Currently, slot 1 is only allowed to be used by the LPC device.
Relax this requirement and allow to use slot 1 if it was explicitly
specified by the user for any other device type. In this case the LPC
device will have the next available address.

If slot 1 was not used by the user, it'll be reserved for the LPC
device, even if it is not configured to make address assignment
consistent in case the LPC device becomes necessary (e.g. the user
adds a console or a video device which require LPC).

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: support 'isa' controller for LPC
Roman Bogorodskiy [Sun, 17 Feb 2019 13:04:00 +0000 (17:04 +0400)] 
bhyve: support 'isa' controller for LPC

Support modeling of the 'isa' controller for bhyve. User can manually
define any PCI slot for the 'isa' controller, including PCI slot 1,
but other devices are not allowed to use this address.

When domain configuration requires the 'isa' controller to be present,
automatically add it on domain post-parse stage.

Now, as this controller is always available when needed, it's not
necessary to implicitly add it to the bhyve command line, so remove
bhyveBuildLPCArgStr().

Also, make bhyveDomainDefNeedsISAController() static as it's no longer
used outside of bhyve_domain.c.

As more than one ISA controller is not supported by bhyve,
and multiple controllers with the same index are forbidden,
so forbid ISA controllers with non-zero index for bhyve.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add 'isa' controller type
Roman Bogorodskiy [Sun, 17 Feb 2019 13:04:00 +0000 (17:04 +0400)] 
conf: add 'isa' controller type

Introduce 'isa' controller type. In domain XML it looks this way:

    ...
    <controller type='isa' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01'
               function='0x0'/>
    </controller>
    ...

Currently, this is needed for the bhyve driver to allow choosing a
specific PCI address for that. In bhyve, this controller is used to
attach serial ports and a boot ROM.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: fix non-null pointer parameter annotations
Daniel P. Berrangé [Mon, 21 Sep 2020 08:57:45 +0000 (09:57 +0100)] 
util: fix non-null pointer parameter annotations

An extra parameter was added to virQEMUBuildQemuImgKeySecretOpts in

  commit ecfc4094d832a23fb56e1825d799c93488c168d7
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Tue Sep 15 16:30:37 2020 +0100

    storage: add support for qcow2 LUKS encryption

but the non-null pointer annotations were not adjusted to take account.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonews: dbus: use GLib implementation instead of libdbus
Pavel Hrdina [Thu, 17 Sep 2020 16:32:49 +0000 (18:32 +0200)] 
news: dbus: use GLib implementation instead of libdbus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonews: node_device: remove HAL node device backend
Pavel Hrdina [Thu, 17 Sep 2020 16:31:13 +0000 (18:31 +0200)] 
news: node_device: remove HAL node device backend

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoremote: slightly improve debugging of socket selection
Daniel P. Berrangé [Wed, 16 Sep 2020 13:51:47 +0000 (14:51 +0100)] 
remote: slightly improve debugging of socket selection

The current debug message reports the "mode" after selection has
completed, however, the "mode" value can be changed by the selection
logic. It is thus beneficial to report most values upfront, and only
report newly changed values at the end.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorage: add support for qcow2 LUKS encryption
Daniel P. Berrangé [Tue, 15 Sep 2020 15:30:37 +0000 (16:30 +0100)] 
storage: add support for qcow2 LUKS encryption

The storage driver was wired up to support creating raw volumes in LUKS
format, but was never adapted to support LUKS-in-qcow2. This is trivial
as it merely requires the encryption properties to be prefixed with
the "encrypt." prefix, and "encrypt.format=luks" when creating the
volume.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: remove redundant LUKS volume data files
Daniel P. Berrangé [Thu, 17 Sep 2020 11:32:54 +0000 (12:32 +0100)] 
tests: remove redundant LUKS volume data files

The two removed files have exactly the same config as other LUKS volume
data files, simply with different file names. Consolidate down to just
two LUKS volume data files as that's all that we need for the test
coverage.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: detect LUKS encryption scheme in qcow2 files
Daniel P. Berrangé [Wed, 16 Sep 2020 17:00:35 +0000 (18:00 +0100)] 
util: detect LUKS encryption scheme in qcow2 files

Crypt method number 2 indicates LUKS format.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoscripts: fix logic error in argv wrapping code
Daniel P. Berrangé [Thu, 17 Sep 2020 11:49:12 +0000 (12:49 +0100)] 
scripts: fix logic error in argv wrapping code

The first piece of the command we process must be added to the list
straight away regardless of whether it starts with a '-' or not.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxl: use b_info->{acpi,acpi} when available
Marek Marczykowski-Górecki [Thu, 10 Sep 2020 04:18:01 +0000 (06:18 +0200)] 
libxl: use b_info->{acpi,acpi} when available

b_info->u.hvm.{acpi,apic} are deprecated. But also, on recent libxl
version (4.14) the old one seems to be broken. While libxl part should
be fixed too, update the usage here and at some point drop support for
the old version.
b_info->acpi was added in Xen 4.8
b_info->apic was added in Xen 4.10
Xen 4.10 is the oldest version that still has security support (until
December 2020).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
4 years agodrop libdbus from libvirt
Pavel Hrdina [Tue, 15 Sep 2020 12:22:57 +0000 (14:22 +0200)] 
drop libdbus from libvirt

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/rpc/virnetdaemon: convert to use GLib DBus
Pavel Hrdina [Wed, 16 Sep 2020 14:01:51 +0000 (16:01 +0200)] 
src/rpc/virnetdaemon: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/remote/remote_daemon: convert to use GLib DBus
Pavel Hrdina [Wed, 9 Sep 2020 14:44:03 +0000 (16:44 +0200)] 
src/remote/remote_daemon: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/nwfilter/nwfilter_driver: convert to use GLib DBus
Pavel Hrdina [Wed, 9 Sep 2020 14:43:47 +0000 (16:43 +0200)] 
src/nwfilter/nwfilter_driver: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/network/bridge_driver: convert to use GLib DBus
Pavel Hrdina [Wed, 9 Sep 2020 14:43:32 +0000 (16:43 +0200)] 
src/network/bridge_driver: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/lxc/lxc_controller: convert to use GLib DBus
Pavel Hrdina [Wed, 9 Sep 2020 14:43:12 +0000 (16:43 +0200)] 
src/lxc/lxc_controller: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/util/virsystemd: convert to use GLib DBus
Pavel Hrdina [Wed, 9 Sep 2020 14:42:42 +0000 (16:42 +0200)] 
src/util/virsystemd: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/util/virfirewalld: convert to use GLib DBus
Pavel Hrdina [Tue, 15 Sep 2020 12:00:53 +0000 (14:00 +0200)] 
src/util/virfirewalld: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/util/virpolkit: convert to use GLib DBus
Pavel Hrdina [Wed, 9 Sep 2020 14:42:16 +0000 (16:42 +0200)] 
src/util/virpolkit: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: introduce virgdbusmock to mock GLib DBus functions
Pavel Hrdina [Fri, 11 Sep 2020 12:17:01 +0000 (14:17 +0200)] 
tests: introduce virgdbusmock to mock GLib DBus functions

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests/virmock: extend number of arguments
Pavel Hrdina [Fri, 11 Sep 2020 12:12:07 +0000 (14:12 +0200)] 
tests/virmock: extend number of arguments

Rewrite to use GLib DBus instead of libdbus will introduce function with
large number of arguments that we will have to mock for our tests so we
need to extend the number of arguments for our macros.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: introduce helpers for GLib DBus implementation
Pavel Hrdina [Tue, 8 Sep 2020 11:55:24 +0000 (13:55 +0200)] 
util: introduce helpers for GLib DBus implementation

With libdbus our wrappers had a special syntax to create the DBus
messages by defining the DBus message signature followed by list
of arguments providing data based on the signature.

There will be no similar helper with GLib implementation as they
provide same functionality via GVariant APIs. The syntax is slightly
different mostly for how arrays, variadic types and dictionaries are
created/parsed.

Additional difference is that with GLib DBus everything is wrapped in
extra tuple (struct). For more details refer to the documentation [1].

[1] <https://developer.gnome.org/glib/stable/gvariant-format-strings.html>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: mock libdbus in networkxml2firewalltest
Pavel Hrdina [Tue, 15 Sep 2020 11:55:53 +0000 (13:55 +0200)] 
tests: mock libdbus in networkxml2firewalltest

This test calls into src/util/virfirewalld.c where it uses DBus to
figure out if firewalld is registered. Without the mock it luckily
fails and the test works correctly.

To isolate the tests from host environment we should mock the DBus
calls.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoremove HAL node device driver
Pavel Hrdina [Thu, 3 Sep 2020 12:20:43 +0000 (14:20 +0200)] 
remove HAL node device driver

There was one attempt a year ago done by me to drop HAL [1] but it was
never resolved. There was another time when Dan suggested to drop HAL
driver [2] but it was decided to keep it around in case device
assignment will be implemented for FreeBSD and the fact that
virt-manager uses node device driver [3].

I checked git history and code and it doesn't look like bhyve supports
device assignment so from that POV it should not block removing HAL.

The argument about virt-manager is not strong as well because libvirt
installed from FreeBSD packages doesn't have HAL support so it will not
affect these users as well [4].

The only users affected by this change would be the ones compiling
libvirt from GIT on FreeBSD.

I looked into alternatives and there is libudev-devd package on FreeBSD
but unfortunately it doesn't work as it doesn't list any devices when
used with libvirt. It provides libudev APIs using devd.

I also looked into devd directly and it provides some APIs but there are
no APIs for device monitoring and events so that would have to be
somehow done by libvirt.

Main motivation for dropping HAL support is to replace libdbus with GLib
dbus implementation and it cannot be done with HAL driver present in
libvirt because HAL APIs heavily depends on symbols provided by libdbus.

[1] <https://www.redhat.com/archives/libvir-list/2019-May/msg00203.html>
[2] <https://www.redhat.com/archives/libvir-list/2016-April/msg00992.html>
[3] <https://www.redhat.com/archives/libvir-list/2016-April/msg00994.html>
[4] <https://svnweb.freebsd.org/ports/head/devel/libvirt/Makefile?view=markup>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: virsh: Document the IO mode 'io_uring'
Lin Ma [Wed, 16 Sep 2020 07:17:36 +0000 (15:17 +0800)] 
docs: virsh: Document the IO mode 'io_uring'

Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: event: options --list, --all and --event are mutually exclusive
Lin Ma [Wed, 16 Sep 2020 07:17:35 +0000 (15:17 +0800)] 
virsh: event: options --list, --all and --event are mutually exclusive

Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: net-port-create: log errors for non-existent xml file
Lin Ma [Wed, 16 Sep 2020 07:17:34 +0000 (15:17 +0800)] 
virsh: net-port-create: log errors for non-existent xml file

Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoaccess: ensure ACL files are rebuilt when protocol changes
Daniel P. Berrangé [Wed, 16 Sep 2020 09:42:02 +0000 (10:42 +0100)] 
access: ensure ACL files are rebuilt when protocol changes

Meson is not told that the .x protocol files are an input for the
generator, so it doesn't know to setup a rebuild dependancy.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: fix concurrency crash bug in force snapshot revert
Nikolay Shirokovskiy [Mon, 14 Sep 2020 11:58:05 +0000 (14:58 +0300)] 
qemu: fix concurrency crash bug in force snapshot revert

This patch is just revert of [1]. Actually we should NOT pass
QEMU_ASYNC_JOB_NONE as that patch suggests while we are in async job in order
to acquire nested jobs correctly. The patch tries to fix issues introduced by
another patch [2] where jobs are mistakenly cleared out in qemuProcessStop.
Later patch [3] fixed the issue introduced by patch [2]. Now we need to revert
[1] as well as we now still have same concurrency crash issues as [3] described
but for the force revert.

[1] 0c4408c83: qemu: Don't use asyncJob after stop during snapshot revert
[2] 888aa4b6b: qemuDomainObjPrivateDataClear: Don't leak @migParams
[3] d75f865fb: qemu: fix concurrency crash bug in snapshot revert

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: fix the number of threads per core
Matt Coleman [Tue, 15 Sep 2020 22:27:16 +0000 (18:27 -0400)] 
hyperv: fix the number of threads per core

The operands were reversed, producing an incorrect result.

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBuildHostdevSCSIAttachPrepare: Propagate 'readonly' flag also for iSCSI
Peter Krempa [Tue, 15 Sep 2020 15:58:04 +0000 (17:58 +0200)] 
qemuBuildHostdevSCSIAttachPrepare: Propagate 'readonly' flag also for iSCSI

The 'readonly' hostdev property is stored separately from the
virStorageSource as some hostdevs are not described by a virStorage
source. We need to propagate the flag to the virStorage source also for
iSCSI backends as it's used to generate the backend properties.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuxml2argvtest: hostdev-scsi-virtio-scsi: Add <readonly/> to one of the iSCSI hostdevs
Peter Krempa [Tue, 15 Sep 2020 15:48:22 +0000 (17:48 +0200)] 
qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add <readonly/> to one of the iSCSI hostdevs

Test a readonly iSCSI backend as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: backup: Write TLS cert and secret object aliases into status XML
Peter Krempa [Mon, 14 Sep 2020 15:59:07 +0000 (17:59 +0200)] 
qemu: backup: Write TLS cert and secret object aliases into status XML

We've put the aliases into the backup job definition after the status
XML was already written so they didn't appear in the on-disk state.

Move the code putting them into the private definition earlier, so that
the status XML update done by saving blockjobs already writes them out.

Also add a note notifying that the block job status update writes the
status XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1870488
Fixes: 423576679a5
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: backup: Remove note that TLS should be implemented
Peter Krempa [Mon, 14 Sep 2020 15:58:09 +0000 (17:58 +0200)] 
qemu: backup: Remove note that TLS should be implemented

Commit 423576679a5 implementing TLS forgot to remove the comment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemustatusxml2xml: backup-pull: Test private data formatting/parsing
Peter Krempa [Mon, 14 Sep 2020 15:46:42 +0000 (17:46 +0200)] 
qemustatusxml2xml: backup-pull: Test private data formatting/parsing

Modify the test case to enable TLS and add private data containing
aliases of objects corresponding to a TLS setup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2argvtest: hostdev-scsi-virtio-scsi: Use longer user-alias for SCSI hostdev
Peter Krempa [Thu, 10 Sep 2020 15:00:13 +0000 (17:00 +0200)] 
qemuxml2argvtest: hostdev-scsi-virtio-scsi: Use longer user-alias for SCSI hostdev

Test that we can cope with a long useralias when generating SCSI hostdev
commandline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainPrepareHostdev: Don't base backend nodename on device alias
Peter Krempa [Thu, 10 Sep 2020 13:43:54 +0000 (15:43 +0200)] 
qemuDomainPrepareHostdev: Don't base backend nodename on device alias

QEMU's blockdev nodenames which are used to back SCSI/iSCSI hostdevs are
limited to 32 characters. If a user passes a very long user alias as
name of the host device it's easy to end up with a too-long nodename.

To prevent this from happening don't base the nodename on the possibly
user-specified alias but on the normal sequential node name generator.

We then store the name in the status XML for further use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainPrepareHostdev: base hostdev secret object names on backend alias
Peter Krempa [Thu, 10 Sep 2020 13:39:49 +0000 (15:39 +0200)] 
qemuDomainPrepareHostdev: base hostdev secret object names on backend alias

The secret object is used to pass data to the backend so it's better
fitting to base the secret object name on the SCSI host device backend
name.

Since we store the object alias in the status XML this modification is
safe in regards to existing guests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainPrepareHostdev: Allocate backend nodenames in the prepare function
Peter Krempa [Thu, 10 Sep 2020 13:33:45 +0000 (15:33 +0200)] 
qemuDomainPrepareHostdev: Allocate backend nodenames in the prepare function

Allocate the nodename in the setup function rather than in the command
line generator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainSecretHostdevPrepare: remove
Peter Krempa [Thu, 10 Sep 2020 13:10:21 +0000 (15:10 +0200)] 
qemuDomainSecretHostdevPrepare: remove

The function is no longer used once we setup per-hostdev data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: domain: Extract preparation of hostdev specific data to a separate function
Peter Krempa [Thu, 10 Sep 2020 10:32:04 +0000 (12:32 +0200)] 
qemu: domain: Extract preparation of hostdev specific data to a separate function

Historically we've prepared secrets for all objects in one place. This
doesn't make much sense and it's semantically more appealing to prepare
everything for a single device type in one place.

Move the setup of the (iSCSI|SCSI) hostdev secrets into a new function
which will be used to setup other things as well in the future.

This is a similar approach we do for disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuBlockStorageSourceAttachData: remove 'storageNodeNameCopy'
Peter Krempa [Thu, 10 Sep 2020 06:32:41 +0000 (08:32 +0200)] 
qemuBlockStorageSourceAttachData: remove 'storageNodeNameCopy'

This was a hack when we were locally regenerating the nodename so that
it's not leaked. Now that we use proper virStorageSource with
persistence it's no longer required.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuBuildHostdevSCSI(A|De)tachPrepare: Use virStorageSource in def for SCSI hostdevs
Peter Krempa [Thu, 10 Sep 2020 06:25:37 +0000 (08:25 +0200)] 
qemuBuildHostdevSCSI(A|De)tachPrepare: Use virStorageSource in def for SCSI hostdevs

Modify the attach/detach data generators to actually use the
virStorageSourceStructure embedded in the SCSI config data rather than
creating an ad-hoc internal one.

The modification will allow us to properly store the nodename used for
the backend in the status XML rather than re-generating it all the
time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: domain: Fill in (i)SCSI backend nodename if it is not present in status XML
Peter Krempa [Wed, 9 Sep 2020 15:58:34 +0000 (17:58 +0200)] 
qemu: domain: Fill in (i)SCSI backend nodename if it is not present in status XML

For upgrade reasons so that we can modify the used nodename we must
generate the old version for all status XMLs which don't have it stored
explicitly.

The change will be required as using the user-provided alias may result
in too-long nodenames which will be rejected by qemu.

Add code which fills in the appropriate old value and add test cases to
validate that it's added and also that existing nodenames are not
overwritten.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemustatusxml2xmldata: Add local SCSI hostdev to 'upgrade' case
Peter Krempa [Thu, 10 Sep 2020 15:28:46 +0000 (17:28 +0200)] 
tests: qemustatusxml2xmldata: Add local SCSI hostdev to 'upgrade' case

Add a local SCSI host device to validate upcoming generated data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemustatusxml2xmldata: Rename 'disk-secinfo-upgrade' case to 'upgrade'
Peter Krempa [Fri, 11 Sep 2020 13:40:23 +0000 (15:40 +0200)] 
tests: qemustatusxml2xmldata: Rename 'disk-secinfo-upgrade' case to 'upgrade'

The test case tests other things besides disk secinfos, so we can make
it more universal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: Add virStorageSource member for SCSI host device config data
Peter Krempa [Wed, 9 Sep 2020 13:27:45 +0000 (15:27 +0200)] 
conf: Add virStorageSource member for SCSI host device config data

The backend for the SCSI host device is a storage source. While the
definition doesn't look like that it's converted to a storage source
when the VM is running.

Add the storage source to the definition object and also parse/format
its private data which will be used for internal state storage while
the VM is running.

Note that the virStorageSourcePtr may not be allocated all the time so
the private data parser allocates it if there is any private data
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2argvtest: hostdev-scsi-virtio-scsi: Add hostdev with useralias
Peter Krempa [Thu, 10 Sep 2020 13:48:38 +0000 (15:48 +0200)] 
qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add hostdev with useralias

Add a SCSI host device with a user-specified alias to illustrate the
upcoming changes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agosyntax-check: Don't forbid curly braces around single line condition body
Peter Krempa [Thu, 10 Sep 2020 13:37:33 +0000 (15:37 +0200)] 
syntax-check: Don't forbid curly braces around single line condition body

This syntax rule doesn't make much sense, especially if there are so
much exceptions to it. Just remove it and adjust the coding style.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainHostdevSubsysSCSIHostDefParseXML: Switch to a more modern XML parsing approach
Peter Krempa [Wed, 9 Sep 2020 14:17:05 +0000 (16:17 +0200)] 
virDomainHostdevSubsysSCSIHostDefParseXML: Switch to a more modern XML parsing approach

Use XPath instead of iterating through the nodes.

Few error messages were modified so that the parser can be written in a
simpler way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainStorageNetworkParseHosts: Switch to a more modern XML parsing approach
Peter Krempa [Wed, 9 Sep 2020 14:17:05 +0000 (16:17 +0200)] 
virDomainStorageNetworkParseHosts: Switch to a more modern XML parsing approach

Use XPath to get the host list instead of iterating through the nodes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainHostdevSubsysSCSIiSCSIClear: Inline contents into only caller
Peter Krempa [Wed, 9 Sep 2020 13:22:57 +0000 (15:22 +0200)] 
virDomainHostdevSubsysSCSIiSCSIClear: Inline contents into only caller

There's just one caller for the function. Move the code into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-completer: use g_new0 instead of VIR_ALLOC_N
Ján Tomko [Mon, 14 Sep 2020 14:24:44 +0000 (16:24 +0200)] 
virsh-completer: use g_new0 instead of VIR_ALLOC_N

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh-completer: use g_free instead of VIR_FREE
Ján Tomko [Mon, 14 Sep 2020 14:10:15 +0000 (16:10 +0200)] 
virsh-completer: use g_free instead of VIR_FREE

All of them are in the cleanup section right before the variables
they free go out of scope.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh-completer: use g_clear_pointer in virshCommaStringListComplete
Ján Tomko [Mon, 14 Sep 2020 14:05:52 +0000 (16:05 +0200)] 
virsh-completer: use g_clear_pointer in virshCommaStringListComplete

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoesx: implement domainInterfaceAddresses
Pino Toscano [Mon, 14 Sep 2020 09:11:38 +0000 (11:11 +0200)] 
esx: implement domainInterfaceAddresses

Implement the .domainInterfaceAddresses hypervisor API, although only
functional for the VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT source.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoesx: generator: add GuestNicInfo object
Pino Toscano [Mon, 14 Sep 2020 09:10:58 +0000 (11:10 +0200)] 
esx: generator: add GuestNicInfo object

Add the definition of the GuestNicInfo object, with all the required
objects for it.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoesx: implement connectListAllNetworks
Pino Toscano [Mon, 14 Sep 2020 16:28:04 +0000 (18:28 +0200)] 
esx: implement connectListAllNetworks

Implement the .connectListAllNetworks networks API in the esx network
driver.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>