]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: Warn verbosely if using old loader:nvram pairs
Michal Privoznik [Mon, 11 Nov 2019 16:22:50 +0000 (17:22 +0100)]
qemu: Warn verbosely if using old loader:nvram pairs

There are two ways for specifying loader:nvram pairs:

  1) --with-loader-nvram configure option
  2) nvram variable in qemu.conf

Since we have FW descriptors, using this old style is
discouraged, but not as strong as one would expect. Produce more
warnings:

  1) produce a warning if somebody tries the configure option
  2) produce a warning if somebody sets nvram variable and at
     least on FW descriptor was found

The reason for producing warning in case 1) is that package
maintainers, who set the configure option in the first place
should start moving towards FW descriptors and abandon the
configure option. After all, the warning is printed into config
output only in this case.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: pci: Remove always-false condition
Peter Krempa [Mon, 11 Nov 2019 12:03:14 +0000 (13:03 +0100)]
util: pci: Remove always-false condition

Commit d19c21429fd modified the condition so that it checks whether the
value is more than 0xFFFFFFFF. Since addr->domain is an unsigned int, it
will never be more than that.

Remove the whole check

src/util/virpci.c:1291:22: error: result of comparison 'unsigned int' > 4294967295 is always false [-Werror,-Wtautological-type-limit-compare]
    if (addr->domain > 0xFFFFFFFF) {
        ~~~~~~~~~~~~ ^ ~~~~~~~~~~

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: make domaincapstest less anoying to debug
Peter Krempa [Fri, 25 Oct 2019 11:59:46 +0000 (13:59 +0200)]
tests: make domaincapstest less anoying to debug

Since 6a077cf2b3 domaincapstest does not run through all cases on
failure but terminates right away. This makes it super annoying to debug
or use in combination with VIR_TEST_REGENERATE_OUTPUT.

Fix it by remembering failure and still running through all cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agobuild: fix substitution of RUNSTATEDIR in man pages
Daniel P. Berrangé [Fri, 18 Oct 2019 14:31:30 +0000 (15:31 +0100)]
build: fix substitution of RUNSTATEDIR in man pages

When RUNSTATEDIR was introduced

  commit d29c917ef470a25149d1f3787ec494d006549f27
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Tue Aug 20 16:05:12 2019 +0100

    src: honour the RUNSTATEDIR variable in all code

The makefile rules for man pages were accidentally not updated for the
new variablle name.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: comment on why we're not adopting certain flake8 rules
Daniel P. Berrangé [Tue, 8 Oct 2019 09:38:29 +0000 (10:38 +0100)]
build: comment on why we're not adopting certain flake8 rules

Simplify the list of ignored warnings now that we only have two left,
and document why we're not honouring them.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: sanitize indentation after line continuations
Daniel P. Berrangé [Tue, 24 Sep 2019 16:26:29 +0000 (17:26 +0100)]
python: sanitize indentation after line continuations

Line continuations should be 4 space indented unless a previous opening
brace required different alignment.

docs/apibuild.py:2014:24: E126 continuation line over-indented for hanging indent
                       token[0], token[1]))
                       ^
docs/apibuild.py:74:3: E121 continuation line under-indented for hanging indent
  "ATTRIBUTE_UNUSED": (0, "macro keyword"),
  ^
...more...

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: sanitize spaces either side of operators
Daniel P. Berrangé [Tue, 24 Sep 2019 15:47:02 +0000 (16:47 +0100)]
python: sanitize spaces either side of operators

There should be a single space either side of operators. Inline
comments should have two spaces before the '#'

src/hyperv/hyperv_wmi_generator.py:130:45: E261 at least two spaces before inline comment
            source += '    { "", "", 0 },\n' # null terminated
                                            ^
src/esx/esx_vi_generator.py:417:25: E221 multiple spaces before operator
    FEATURE__DESERIALIZE  = (1 << 6)
                        ^
tests/cputestdata/cpu-cpuid.py:187:78: E225 missing whitespace around operator
                f.write("  <msr index='0x%x' edx='0x%08x' eax='0x%08x'/>\n" %(
                                                                             ^
docs/apibuild.py:524:47: E226 missing whitespace around arithmetic operator
                            self.line = line[i+2:]
                                              ^
...more...

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: sanitize blank line usage
Daniel P. Berrangé [Tue, 24 Sep 2019 12:55:56 +0000 (13:55 +0100)]
python: sanitize blank line usage

Coding style expects 1 blank line between each method and 2 blank lines
before each class.

docs/apibuild.py:171:5: E303 too many blank lines (2)
    def set_header(self, header):
    ^
docs/apibuild.py:230:1: E302 expected 2 blank lines, found 1
class index:
^
docs/apibuild.py:175:5: E301 expected 1 blank line, found 0
    def set_module(self, module):
    ^
...more...

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: avoid bare 'except:' clause
Daniel P. Berrangé [Tue, 24 Sep 2019 12:42:51 +0000 (13:42 +0100)]
python: avoid bare 'except:' clause

Exception catching statements should always match on a class name, the
most specific one possible. Rather than analyse the code to look at what
the most specific one is, this just uses the base Exception class.

docs/apibuild.py:255:9: E722 do not use bare 'except'
        except:
        ^
docs/apibuild.py:279:9: E722 do not use bare 'except'
        except:
        ^
...more...

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: avoid variable named 'l'
Daniel P. Berrangé [Tue, 24 Sep 2019 12:40:44 +0000 (13:40 +0100)]
python: avoid variable named 'l'

Python code style recommends avoiding a variable named 'l' as it is
visually similar to '1'.

docs/apibuild.py:482:13: E741 ambiguous variable name 'l'
            l = len(line)
            ^
docs/apibuild.py:503:21: E741 ambiguous variable name 'l'
                    l = len(line)
                    ^
...more...

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: mark regex strings with 'r' prefix
Daniel P. Berrangé [Tue, 24 Sep 2019 12:29:27 +0000 (13:29 +0100)]
python: mark regex strings with 'r' prefix

When writing regexes special regex matches like "\d" can get
misinterpreted as normal string escape sequences:

docs/apibuild.py:1359:51: W605 invalid escape sequence '\d'
                        value = value + re.sub("^(\d+)U$", "\\1", token[1])
                                                  ^
docs/apibuild.py:2134:31: W605 invalid escape sequence '\('
                m = re.match("\(?1<<(\d+)\)?", info[0])
                              ^
docs/apibuild.py:2134:38: W605 invalid escape sequence '\d'
                m = re.match("\(?1<<(\d+)\)?", info[0])
                                     ^
docs/apibuild.py:2134:42: W605 invalid escape sequence '\)'
                m = re.match("\(?1<<(\d+)\)?", info[0])
                                         ^

To avoid this probem all regexes should use the r"...." syntax for their
strings, which disables normal string escape sequences.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopython: fix use of undeclared variables in python scripts
Daniel P. Berrangé [Tue, 24 Sep 2019 12:10:46 +0000 (13:10 +0100)]
python: fix use of undeclared variables in python scripts

docs/apibuild.py:2436:65: F821 undefined name 'first_letter'
                        chunks.append(["chunk%s" % (chunk - 1), first_letter, letter])
                                                                ^
src/hyperv/hyperv_wmi_generator.py:415:57: F821 undefined name 'number'
        report_error("line %d: invalid block header" % (number))
                                                        ^

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: change flake8 to use blacklist instead of whitelist
Daniel P. Berrangé [Tue, 24 Sep 2019 11:50:43 +0000 (12:50 +0100)]
build: change flake8 to use blacklist instead of whitelist

The current flake8 check only looks at one item (semicolons at end of
line). This means that our code quality will continue to get worse,
violating an increasing number of checks.

Switching to a whitelist means that we freeze the badness at its
current level & can incrementally fix things up.

We are excluding the following...

Indentation:

  E114 indentation is not a multiple of four (comment)
  E115 expected an indented block (comment)
  E116 unexpected indentation (comment)
  E121 continuation line under-indented for hanging indent
  E125 continuation line with same indent as next logical line
  E126 continuation line over-indented for hanging indent
  E127 continuation line over-indented for visual indent
  E128 continuation line under-indented for visual indent
  E129 visually indented line with same indent as next logical line
  E131 continuation line unaligned for hanging indent

Whitespace:

  E211 whitespace before ‘(‘
  E221 multiple spaces before operator
  E222 multiple spaces after operator
  E225 missing whitespace around operator
  E226 missing whitespace around arithmetic operator
  E231 missing whitespace after ‘,’, ‘;’, or ‘:’
  E261 at least two spaces before inline comment

Blank lines

  E301 expected 1 blank line, found 0
  E302 expected 2 blank lines, found 0
  E303 too many blank lines (3)
  E305 expected 2 blank lines after end of function or class

Line length

  E501 line too long (82 > 79 characters)

Statements

  E722 do not use bare except, specify exception instead
  E741 do not use variables named ‘l’, ‘O’, or ‘I’

Errors:

  F821 undefined name 'name'

Warnings:

  W504 line break after binary operator
  W605 invalid escape sequence ‘x’

Later commits will enable most of these exclusions.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: remove some dead code in apibuild.py
Daniel P. Berrangé [Tue, 24 Sep 2019 16:29:11 +0000 (17:29 +0100)]
docs: remove some dead code in apibuild.py

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agospec: fix rpm build with VPATH
Pavel Hrdina [Sat, 9 Nov 2019 12:04:04 +0000 (13:04 +0100)]
spec: fix rpm build with VPATH

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosrc: lxc: Fix typo in a Makefile variable
Michal Privoznik [Sun, 10 Nov 2019 10:06:19 +0000 (11:06 +0100)]
src: lxc: Fix typo in a Makefile variable

In commit 0985a9597bb0348d46c0d18dc548a676bf0ad8e2 we stopped
distributing generated source file. This is done by prepending
binary_SOURCES variable with "nodist_". However, there is a typo
- the prefix is "nodst_" instead of "nodist_".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: add missing include access path for bhyve and vz drivers
Pavel Hrdina [Fri, 8 Nov 2019 20:11:24 +0000 (21:11 +0100)]
src: add missing include access path for bhyve and vz drivers

Commit <b98f90cf913965243c6e2c49a52aa170a48093ef> forgot to update
bhyve and vz Makefile files as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
5 years agodocs: update news file
Laine Stump [Wed, 28 Aug 2019 01:46:39 +0000 (21:46 -0400)]
docs: update news file

with info about support for using precreated tap/macvtap devices in
unprivileged libvirtd.

Signed-off-by: Laine Stump <laine@redhat.com>
5 years agotools: stop distributing generated source files
Pavel Hrdina [Thu, 17 Oct 2019 12:03:15 +0000 (14:03 +0200)]
tools: stop distributing generated source files

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: stop distributing generated source files
Pavel Hrdina [Wed, 23 Oct 2019 12:24:37 +0000 (14:24 +0200)]
src: stop distributing generated source files

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: remote: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:52:23 +0000 (14:52 +0200)]
src: remote: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: lxc: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:51:25 +0000 (14:51 +0200)]
src: lxc: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: logging: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:49:44 +0000 (14:49 +0200)]
src: logging: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: locking: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:48:01 +0000 (14:48 +0200)]
src: locking: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: hyperv: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:46:20 +0000 (14:46 +0200)]
src: hyperv: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: esx: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:45:15 +0000 (14:45 +0200)]
src: esx: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: admin: generate source files into build directory
Pavel Hrdina [Wed, 23 Oct 2019 22:56:14 +0000 (00:56 +0200)]
src: admin: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: access: generate source files into build directory
Pavel Hrdina [Wed, 23 Oct 2019 23:36:43 +0000 (01:36 +0200)]
src: access: generate source files into build directory

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: generate source files into build directory
Pavel Hrdina [Wed, 16 Oct 2019 12:41:49 +0000 (14:41 +0200)]
src: generate source files into build directory

This affects more than src/Makefile.am as the rule to generate source
files for protocols is generic for all sub-directories.

Affected files are:
    src/admin/admin_protocol.{h,c}
    src/locking/lock_protocol.{h,c}
    src/logging/log_protocol.{h,c}
    src/lxc/lxc_monitor_protocol.{h,c}
    src/remote/{lxc,qemu,remote}_protocol.{h,c}
    src/rpc/{virkeepalive,virnet}protocol.{h,c}

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: unify rpc server dispatch generated files
Pavel Hrdina [Wed, 23 Oct 2019 23:22:16 +0000 (01:22 +0200)]
remote: unify rpc server dispatch generated files

Our naming was not consistent.  Use the protocol name as prefix for all
generated files.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopo: README.md: add a note about which Zanata client is required
Pavel Hrdina [Thu, 24 Oct 2019 12:56:16 +0000 (14:56 +0200)]
po: README.md: add a note about which Zanata client is required

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopo: rewrite the way how we generate files
Pavel Hrdina [Fri, 8 Nov 2019 14:25:33 +0000 (15:25 +0100)]
po: rewrite the way how we generate files

There was no need to handle files for translation from build directory
but that will change with following patches where we will stop
generating source files into source directory.

In order to have them included for translation we have to prefix each
file with SRCDIR or BUILDDIR.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agopo: generate files into build directory
Pavel Hrdina [Wed, 23 Oct 2019 19:56:50 +0000 (21:56 +0200)]
po: generate files into build directory

Historically we did not support VPATH builds and everything was
generated into source directory.  The introduction of VPATH builds
did not changed the way how our translation files are handled.

This patch changes the rules to generate everything into build
directory and stops distributing generated files in order to have
properly separated VPATH builds.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosyntax-check.mk: cleanup generated_files list for sc_po_check
Pavel Hrdina [Wed, 23 Oct 2019 19:33:31 +0000 (21:33 +0200)]
syntax-check.mk: cleanup generated_files list for sc_po_check

Move generated_files variable closer to the sc_po_check rule and
remove non-existent gnulib internal path.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosyntax-check.mk: cleanup sc_po_check dependencies
Pavel Hrdina [Wed, 23 Oct 2019 13:35:05 +0000 (15:35 +0200)]
syntax-check.mk: cleanup sc_po_check dependencies

Introduce new rule 'generated-sources' as a helper for PO files check
to make sure that all generated files are prepared and to not duplicate
the list on different places.  This will be used as a dependency for
sc_po_check rule instead of duplicated list of generated files.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosyntax-check.mk: fix sc_po_check rule
Pavel Hrdina [Wed, 23 Oct 2019 19:26:31 +0000 (21:26 +0200)]
syntax-check.mk: fix sc_po_check rule

Commit <22d8e27ccd5faf48ee2bf288a1b9059aa7ffd28b> introduced our
syntax-check.mk file based on gnulib rules. However, the rule was
completely ignored as we don't have POTFILES.in file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years ago.gitignore: cleanup old and obsolete ignores
Pavel Hrdina [Thu, 24 Oct 2019 08:26:12 +0000 (10:26 +0200)]
.gitignore: cleanup old and obsolete ignores

Now that we forbid builds in source directory we can remove a lot of
ignores that are created during build time.  To make the cleanup easier
in the future create a sections in our .gitignore file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: mandate use of a build dir != src dir
Pavel Hrdina [Wed, 6 Nov 2019 14:55:12 +0000 (15:55 +0100)]
build: mandate use of a build dir != src dir

Historically we've allowed builds in the main src dir, but meson does
not support this. Explicitly force separate build dir in autotools to
align with meson. We must re-enable dependency tracking which the RPM
%configure macro turns off. Without this, the build dir doesn't get
the source directory tree mirrored.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Check for job being set when getting iothread stats
Michal Privoznik [Thu, 7 Nov 2019 12:43:21 +0000 (13:43 +0100)]
qemu: Check for job being set when getting iothread stats

The qemuDomainGetStatsIOThread() accesses the monitor by calling
qemuDomainGetIOThreadsMon(). And it's also marked as "need
monitor" in qemuDomainGetStatsWorkers[]. However, it's not
checking if acquiring job was successful.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoqemu: Warn on possibly incorrect usage of EnterMonitor*
Michal Privoznik [Thu, 7 Nov 2019 13:05:43 +0000 (14:05 +0100)]
qemu: Warn on possibly incorrect usage of EnterMonitor*

The qemuDomainObjEnterMonitor() should not be called without a
job set. Catch this error and produce a warning message if such
call occurred.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoutil: Set SIGPIPE to a no-op handler in virFork
Wang Yechao [Fri, 8 Nov 2019 00:25:15 +0000 (08:25 +0800)]
util: Set SIGPIPE to a no-op handler in virFork

Libvirtd has set SIGPIPE to ignored, and virFork resets all signal
handlers to the defaults. But child process may write logs to
stderr/stdout, that may generate SIGPIPE if journald has stopped.

So set SIGPIPE to a dummy no-op handler before unmask signals in
virFork(), and the handler will get reset to SIG_DFL when execve()
runs. Now we can delete sigaction() call entirely in virExec().

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
5 years agoutil: set bridge device MAC address explicitly during virNetDevBridgeCreate
Laine Stump [Fri, 18 Oct 2019 01:12:30 +0000 (21:12 -0400)]
util: set bridge device MAC address explicitly during virNetDevBridgeCreate

When libvirt first implemented a stable and configurable MAC address
for the bridges created for libvirt virtual networks (commit
5754dbd56d, in libvirt v0.8.8) most distro stable releases didn't
support explicitly setting the MAC address of a bridge; the bridge
just always assumed the lowest numbered MAC of all attached
interfaces. Because of this, we stabilized the bridge MAC address by
creating a "dummy" tap interface with a MAC address guaranteed to be
lower than any of the guest tap devices' MACs (which all started with
0xFE, so it's not difficult to do) and attached it to the bridge -
this was the inception of the "virbr0-nic" device that has confused so
many people over the years.

Even though the linux kernel had recently gained support for
explicitly setting a bridge MAC, we deemed it unnecessary to set the
MAC that way, because the other (indirect) method worked everywhere.

But recently there have been reports that the bridge MAC address was
not following the setting in the network config, and mismatched the
MAC of the dummy tap device (which was still correct). It turns out
that this is due to a change in systemd-242 that persists whatever MAC
address is set for a bridge when it's initially started. According to
the systemd NEWS file entry for version 242
(https://github.com/systemd/systemd/blob/master/NEWS):

  "if a bridge interface is created without any slaves, and gains
   a slave later, then now the bridge does not inherit slave's MAC."

This change was the result of:

  https://github.com/systemd/systemd/issues/3374

(apparently if there is no MAC saved for a bridge by the name of a
bridge being created, the random MAC generated during creation is
saved, and then that same MAC is used to explicitly set the MAC each
time it is created). Once a bridge has an explicitly set MAC, the "use
the lowest numbered MAC of attached devices" rule is ignored, so our
dummy tap device is like the goggles - it does nothing! (well, almost).

We could whine about changes in default behavior, etc. etc., but
because the change was in response to actual user problems, that seems
likely a fruitless task. Fortunately, time has marched on, and even
distro releases that are old enough that they are no longer supported
by upstream libvirt (e.g. RHEL6) have support for explicitly setting a
bridge device MAC address, either during creation or with a separate
ioctl after creation, so we can now do that.

To enable explicitly setting the mac during bridge creation, we add a
mac arg to virNetDevBridgeCreate().  In the case of platforms where
the bridge is created with a netlink RTM_NEWLINK message, we just add
that mac to the message. For platforms that still use an ioctl (either
SIOCBRADDBR or SIOCIFCREATE2), we make a separate call to
virNetDevSetMAC() after creating the bridge.

(NB: I was unable to test the calling of virNetDevSetMAC() from the
SIOCIFCREATE2 (BSD) version of virNetDevBridgeCreate(); even though I
managed to get a FreeBSD system setup and libvirt built there, when I
tried to start the default network the SIOCIFCREATE2 ioctl itself
failed, so it never even got to the virNetDevSetMAC(). That leaves the
FreeBSD implementation untested.)

This makes the dummy tap pointless for purposes of setting the MAC
address, but it is still useful for IPv6 DAD initialization (which
apparently requires at least one interface to be attached to the
bridge and online), as well as for setting an initial MTU for the
bridge, so it hasn't been removed.

(NB: we can safely *always* call virNetDevBridgeCreate() with
&def->mac from the network driver because, in spite of the existence
of a "mac_specified" bool in the config suggesting that it may not
always be present, in reality a mac address will always be added to
any network that doesn't have one - this is guaranteed in all cases by
commit a47ae7c004)

https://bugzilla.redhat.com/show_bug.cgi?id=1760851
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoutil: allow sending mac addr to virNetNewLink without ifindex
Laine Stump [Wed, 16 Oct 2019 18:06:54 +0000 (14:06 -0400)]
util: allow sending mac addr to virNetNewLink without ifindex

Although until now, any use of the extra_args argument (a pointer to a
struct containing extra attributes to add the the RTM_NEWLINK message)
would always have the ifindex and mac set, so the code could assume it
was safe to add both to the message if extra_args != NULL. There is
now a use for setting a MAC address in the RTM_NEWLINK without setting
the ifindex, so we should check each of these separately.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agocpu_map: Ship arm_features.xml
Andrea Bolognani [Thu, 7 Nov 2019 17:04:31 +0000 (18:04 +0100)]
cpu_map: Ship arm_features.xml

The file was introduced in be03587a3446, but it was not added
to $(cpumap_DATA) at the time and so it didn't show up in the
distribution archive.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: avoid double reservation of PCI address for interface type='hostdev'
Laine Stump [Sat, 19 Oct 2019 05:58:07 +0000 (01:58 -0400)]
qemu: avoid double reservation of PCI address for interface type='hostdev'

Commit 01ca4010d86 (libvirt v5.1.0) moved address reservation for
hotplugged interface devices up to an earlier point in
qemuDomainAttachNetDevice(), because that function calls
qemuDomainSupportsNicdev() (in the case of
VIR_DOMAIN_NET_TYPE_VHOSTUSER), and qemuDomainSupportsNicdev() needs
to know the address type (for ARM machinetypes) and returns incorrect
results when the address type is "none".

This bugfix unfortunately caused a regression, because it also made PCI
address reservation happen before we noticed that the device was a
*hostdev* interface. Those interfaces are hotplugged by just calling
out to qemuDomainAttachHostdevDevice() - that function would then also
attempt to reserve the *same PCI address* that had just been reserved
in qemuDomainAttachNetDevice().

The solution is to move the bit of code that short-circuits out to
virDomainHostdevAttach() up *even earlier* so that no PCI address has
been allocated by the time it's called.

https://bugzilla.redhat.com/show_bug.cgi?id=1744523
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonews: Update for ARM CPU features
Andrea Bolognani [Thu, 25 Jul 2019 13:38:38 +0000 (15:38 +0200)]
news: Update for ARM CPU features

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Introduce tests for ARM CPU features
Andrea Bolognani [Mon, 24 Jun 2019 13:22:24 +0000 (15:22 +0200)]
tests: Introduce tests for ARM CPU features

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Validate ARM CPU features
Andrea Bolognani [Fri, 11 Oct 2019 08:05:59 +0000 (10:05 +0200)]
qemu: Validate ARM CPU features

This introduces semantic validation for SVE-related features,
preventing the user from combining them in invalid ways; it also
automatically enables overall SVE support if any SVE vector
length has been enabled by the user to make sure QEMU behaves
correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agocpu: Validate ARM CPU features
Andrea Bolognani [Fri, 11 Oct 2019 08:05:49 +0000 (10:05 +0200)]
cpu: Validate ARM CPU features

For now we only perform very basic validation, such as making sure
that the user is not trying to enable/disable unknown CPU features
and the like.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agocpu_map: Introduce ARM CPU features
Andrea Bolognani [Mon, 22 Jul 2019 14:41:45 +0000 (16:41 +0200)]
cpu_map: Introduce ARM CPU features

The only feature we care about for the moment is SVE, which can
be controlled both with a coarse granularity by turning it on/off
completely and with a finer granularity by enabling/disabling
individual vector lengths.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Perform full expansion on ARM
Andrea Bolognani [Mon, 24 Jun 2019 12:16:17 +0000 (14:16 +0200)]
qemu: Perform full expansion on ARM

The ARM implementation of query-cpu-model-expansion only
supports full expansion, so we have to make sure we're using
that expansion mode if we want to obtain any useful data.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Update query-cpu-model-expansion check
Andrea Bolognani [Tue, 2 Jul 2019 13:29:30 +0000 (15:29 +0200)]
qemu: Update query-cpu-model-expansion check

CPU features are available on ARM only wherever the
query-cpu-model-expansion QMP command is available, same as
on s390. Update qemuBuildCpuModelArgStr() to reflect this
fact.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Query max-arm-cpu properties
Andrea Bolognani [Mon, 8 Jul 2019 11:46:37 +0000 (13:46 +0200)]
qemu: Query max-arm-cpu properties

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Introduce QEMU_CAPS_ARM_MAX_CPU
Andrea Bolognani [Mon, 8 Jul 2019 11:21:00 +0000 (13:21 +0200)]
qemu: Introduce QEMU_CAPS_ARM_MAX_CPU

Mirrors the existing QEMU_CAPS_X86_MAX_CPU.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Rename virQEMUCapsObjectPropsMaxX86CPU
Andrea Bolognani [Mon, 8 Jul 2019 11:14:53 +0000 (13:14 +0200)]
qemu: Rename virQEMUCapsObjectPropsMaxX86CPU

We're going to use it on non-x86 soon, so it needs a more
generic name: virQEMUCapsObjectPropsMaxCPU.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Update capabilities for QEMU 4.2.0 on aarch64
Andrea Bolognani [Thu, 10 Oct 2019 16:28:47 +0000 (12:28 -0400)]
tests: Update capabilities for QEMU 4.2.0 on aarch64

Unfortunately this results in a lot of churn because of the eigth
hundred and change QEMU commits since the file was last touched,
but the only part we actually care about is the fact that the
query-cpu-model-expansion QMP command is now available on aarch64.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Fix logic to not have possible NULL deref
John Ferlan [Sun, 3 Nov 2019 12:55:21 +0000 (07:55 -0500)]
tests: Fix logic to not have possible NULL deref

It's possible that virBitmapNewString returns NULL with an error
string (and not an allocation failure that would abort); however, if
virBitmapToString is called with a NULL @bitmap, then it will fail
in an ugly manner. So rather than have if (!map && !str) logic, split
the checks for each variable.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: Add return value check in checkUserInfo
John Ferlan [Sun, 3 Nov 2019 12:39:22 +0000 (07:39 -0500)]
tests: Add return value check in checkUserInfo

Commit 1c8113f9c added the call to virTypedParamsGetString without
a return value check which caused Coverity to complain especially
since other checks for the same function are made.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Fix possible NULL deref in qemuDomainSaveImageStartVM
John Ferlan [Sun, 3 Nov 2019 12:35:25 +0000 (07:35 -0500)]
qemu: Fix possible NULL deref in qemuDomainSaveImageStartVM

Commit 075523438 added a direct reference to @cookie even though
it may be NULL as shown by a comment a few lines previous - so add
the check here as well.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: Remove _NULLABLE in virNetDevExists mock
John Ferlan [Sun, 3 Nov 2019 12:34:04 +0000 (07:34 -0500)]
tests: Remove _NULLABLE in virNetDevExists mock

The @ifname is listed as an ATTRIBUTE_NONNULL(1) parameter, so
checking for _NULLABLE causes a coverity build failure - remove
that and if it's NULL for the test let's fail miserably.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolxc: Remove unnecessary comment
John Ferlan [Sun, 3 Nov 2019 12:24:07 +0000 (07:24 -0500)]
lxc: Remove unnecessary comment

Commit 66e2adb2ba moved the code and the coverity comment which now
was useless since the context was in lxcContainerSetupPivotRoot.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: Fix memory leak in mymain
John Ferlan [Sun, 3 Nov 2019 12:19:48 +0000 (07:19 -0500)]
tests: Fix memory leak in mymain

Commit 944a35d7f0 added @fakerootdir; however, there are multiple
paths out of mymain that didn't free the memory - so just use the
g_autofree to resolve the potential leak.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: Remove ATTRIBUTE_NONNULL for virDomainQemuMonitorEventNew
John Ferlan [Sun, 3 Nov 2019 12:12:58 +0000 (07:12 -0500)]
conf: Remove ATTRIBUTE_NONNULL for virDomainQemuMonitorEventNew

Commit 17561eb36 modified the logic to check "if (!event)" for an
attribute that was not supposed to be passed as NULL.  This causes
the static checker/Coverity build to fail. Since the check is made,
alter the header.

Also add an error message since returning -1 without some sort of
error message as previously would have happened with the failed
VIR_STRDUP so that the eventual error doesn't get the default
for some reason message.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: Fix possible NULL deref
John Ferlan [Sun, 3 Nov 2019 12:05:15 +0000 (07:05 -0500)]
vbox: Fix possible NULL deref

The @valueTypeUtf8 references need to use the STREQ_NULLABLE since
they're variantly filled in by @valueTypeUtf16.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agomaint: Post-release version bump to 5.10.0
Andrea Bolognani [Wed, 6 Nov 2019 14:49:10 +0000 (15:49 +0100)]
maint: Post-release version bump to 5.10.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoRelease of libvirt-5.9.0
Daniel Veillard [Wed, 6 Nov 2019 14:39:52 +0000 (15:39 +0100)]
Release of libvirt-5.9.0

* doc/news.xml: update for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agogitdm: Add missing entries
Andrea Bolognani [Thu, 17 Oct 2019 14:44:03 +0000 (16:44 +0200)]
gitdm: Add missing entries

A few new companies and individuals contributed to libvirt since
the last time the gitdm configuration was updated.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
5 years agogitdm: Fix sorting
Andrea Bolognani [Thu, 17 Oct 2019 14:43:34 +0000 (16:43 +0200)]
gitdm: Fix sorting

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
5 years agonews: Update for 5.9.0 release
Andrea Bolognani [Mon, 4 Nov 2019 11:33:27 +0000 (12:33 +0100)]
news: Update for 5.9.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agonews: Document more possible sections
Andrea Bolognani [Mon, 4 Nov 2019 11:33:19 +0000 (12:33 +0100)]
news: Document more possible sections

The "Security" section has been used in the past, so we're only
documenting existing behavior; the "Packaging changes" will be
used in the next commit, as well as in future releases when we
make more changes that are relevant to packagers, such as the
switch to Meson.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agodocs: Fix attribute names in filesystem/driver example
Jim Fehlig [Fri, 1 Nov 2019 17:46:55 +0000 (11:46 -0600)]
docs: Fix attribute names in filesystem/driver example

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
5 years agonews: Add entry for ACPI firmware support in Xen
Jim Fehlig [Thu, 31 Oct 2019 15:47:49 +0000 (09:47 -0600)]
news: Add entry for ACPI firmware support in Xen

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Fix version that introduced Xen support for ACPI firmware
Jim Fehlig [Thu, 31 Oct 2019 15:27:42 +0000 (09:27 -0600)]
docs: Fix version that introduced Xen support for ACPI firmware

Xen support for specifying ACPI firmware path was introduced in the
5.9.0 dev cycle, not 5.8.0 as currently indicated by the docs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: xml: Make virXMLFormatElement void
Peter Krempa [Thu, 24 Oct 2019 13:50:50 +0000 (15:50 +0200)]
util: xml: Make virXMLFormatElement void

Now that we don't have to deal with errors of virBuffer we can also make
this function void.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Remove virBufferCheckError
Peter Krempa [Thu, 24 Oct 2019 12:34:44 +0000 (14:34 +0200)]
util: buffer: Remove virBufferCheckError

The function now does not return an error so we can drop it fully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Remove virBufferError
Peter Krempa [Thu, 24 Oct 2019 12:25:59 +0000 (14:25 +0200)]
util: buffer: Remove virBufferError

The function now does not return an error so we can drop it fully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Remove error handling internals
Peter Krempa [Thu, 24 Oct 2019 12:09:42 +0000 (14:09 +0200)]
util: buffer: Remove error handling internals

Now that there are no errors reported and tracked in virBuffer, remove
all the internals which were used to track them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Reimplement virBuffer internals using glib's GString
Peter Krempa [Thu, 24 Oct 2019 11:02:41 +0000 (13:02 +0200)]
util: buffer: Reimplement virBuffer internals using glib's GString

GString is surprisingly similar to what libvirt was doing painstakingly
manually. Yet it doesn't support the automatic indentation features we
use for XML so we rather keep those in form of virBuffer using GString
internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Encode URIs with upper case hex characters
Peter Krempa [Thu, 24 Oct 2019 11:26:16 +0000 (13:26 +0200)]
util: buffer: Encode URIs with upper case hex characters

rfc3986 uses uppercase characters so switch to using them as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Properly URLencode strings
Peter Krempa [Thu, 24 Oct 2019 11:23:32 +0000 (13:23 +0200)]
util: buffer: Properly URLencode strings

According to rfc3986:

2.3.  Unreserved Characters

   Characters that are allowed in a URI but do not have a reserved
   purpose are called unreserved.  These include uppercase and lowercase
   letters, decimal digits, hyphen, period, underscore, and tilde.

      unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

   URIs that differ in the replacement of an unreserved character with
   its corresponding percent-encoded US-ASCII octet are equivalent: they
   identify the same resource.  However, URI comparison implementations
   do not always perform normalization prior to comparison (see Section
   6).  For consistency, percent-encoded octets in the ranges of ALPHA
   (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
   underscore (%5F), or tilde (%7E) should not be created by URI
   producers and, when found in a URI, should be decoded to their
   corresponding unreserved characters by URI normalizers.

Thus we must not include few other characters which don't match
c_isalpha to conform to the rules.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: virbuffer: Remove @dynamic from virBufferGetIndent
Peter Krempa [Thu, 24 Oct 2019 10:51:24 +0000 (12:51 +0200)]
util: virbuffer: Remove @dynamic from virBufferGetIndent

After the conversion of all callers that would pass true as @dynamic to
a different function we can remove the unused argument now.

Additionally modify the return type to 'size_t' as indentation can't be
negative and remove checks whether @buf is passed as it's caller's duty
to do so.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: sysinfo: Use virXMLFormatElement and infrastructure in virSysinfoFormat
Peter Krempa [Thu, 24 Oct 2019 10:44:01 +0000 (12:44 +0200)]
util: sysinfo: Use virXMLFormatElement and infrastructure in virSysinfoFormat

It basically implements almost the same thing, so we can replace it with
existing helpers with a few tweaks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Split getting of effective indent out of virBufferGetIndent
Peter Krempa [Thu, 24 Oct 2019 10:29:12 +0000 (12:29 +0200)]
util: buffer: Split getting of effective indent out of virBufferGetIndent

The function basically does two very distinct things depending on a
bool. As a first step of conversion split out the case when @dynamic is
true and implement it as a new function and convert all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virbuffer: Remove unused test data struct
Peter Krempa [Thu, 24 Oct 2019 10:18:13 +0000 (12:18 +0200)]
tests: virbuffer: Remove unused test data struct

The DO_TEST macro initializes 'struct testInfo' but it's not used by any
of the tests. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virbuffer: Drop 'infinite loop' tests
Peter Krempa [Thu, 24 Oct 2019 10:14:32 +0000 (12:14 +0200)]
tests: virbuffer: Drop 'infinite loop' tests

The tests are deeply based on internals of virBuffer which will be
replaced in an upcoming patch with glib's GString. Remove the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Simplify handling of indent overflows
Peter Krempa [Thu, 24 Oct 2019 07:25:20 +0000 (09:25 +0200)]
util: buffer: Simplify handling of indent overflows

Rather than setting usage error truncate the indentation level. Having
the output string misformated is way more useful to figure out where the
error lies rather than reporting an error after a giant formatter
function.

In testBufAutoIndent we now validate that the indentation is truncated
and testBufAddBuffer2 is removed since it became bogus.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Don't treat missing truncation in virBufferTrim as usage error
Peter Krempa [Thu, 24 Oct 2019 07:05:49 +0000 (09:05 +0200)]
util: buffer: Don't treat missing truncation in virBufferTrim as usage error

Usage errors in the virBuffer are hard to track anyways. Just trim
noting if the user requests the trimming string to be used without
providing it.

The change in the test proves that it's a no-op now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: alloc: drop xalloc_oversized macro
Peter Krempa [Thu, 24 Oct 2019 07:03:10 +0000 (09:03 +0200)]
util: alloc: drop xalloc_oversized macro

We've now got rid of all the uses.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Reimplement _vshCalloc using g_malloc0_n
Peter Krempa [Thu, 24 Oct 2019 07:02:24 +0000 (09:02 +0200)]
virsh: Reimplement _vshCalloc using g_malloc0_n

Drop the dead code by using glib's allocator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Simplify escape buffer allocations
Peter Krempa [Thu, 24 Oct 2019 06:49:57 +0000 (08:49 +0200)]
util: buffer: Simplify escape buffer allocations

Replace combinations of xalloc_oversized and VIR_ALLOC_N_QUIET by using
g_malloc0_n which does the checking internally.

This conversion is done with a semantic difference and slightly higher
memory requirements as I've opted to allocate one chunk more than
necessary rather than trying to accomodate the NUL byte separately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Use 'cleanup' as label name in virBufferAddBuffer
Peter Krempa [Thu, 24 Oct 2019 06:10:18 +0000 (08:10 +0200)]
util: buffer: Use 'cleanup' as label name in virBufferAddBuffer

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: buffer: Simplify convoluted condition
Peter Krempa [Thu, 24 Oct 2019 06:06:21 +0000 (08:06 +0200)]
util: buffer: Simplify convoluted condition

Spare a few more lines rather than having a condition with a nested
ternary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agointernal: Use g_strcmp0 in STR(N)EQ_NULLABLE
Peter Krempa [Thu, 24 Oct 2019 14:06:19 +0000 (16:06 +0200)]
internal: Use g_strcmp0 in STR(N)EQ_NULLABLE

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoremote: Serialize typed parameters earlier
Peter Krempa [Tue, 22 Oct 2019 12:57:55 +0000 (14:57 +0200)]
remote: Serialize typed parameters earlier

Move calls to virTypedParamsSerialize earlier in the event dispatch
functions so that we don't have to call 'xdr_free' afterwards.

This is possible as virTypedParamsSerialize cleans up after itself if it
fails.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agoremote: Use g_new0 to allocate 'remote_string' in event RPC handlers
Peter Krempa [Tue, 22 Oct 2019 14:10:53 +0000 (16:10 +0200)]
remote: Use g_new0 to allocate 'remote_string' in event RPC handlers

Few events emit optional strings. We need to allocate the container for
it first. Note that remote_nonnull_string is used as the type as the
internal part of the string is nonnull if the container is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agoremote: Replace VIR_ALLOC_N with g_new0 in remoteRelayDomainEventGraphics
Peter Krempa [Tue, 22 Oct 2019 14:08:07 +0000 (16:08 +0200)]
remote: Replace VIR_ALLOC_N with g_new0 in remoteRelayDomainEventGraphics

Allocate the array of graphics identity objects using g_new0 to allow
dropping the 'error' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agoremote: dispatch: Remove return value from make_nonnull_* helpers
Peter Krempa [Tue, 22 Oct 2019 11:46:37 +0000 (13:46 +0200)]
remote: dispatch: Remove return value from make_nonnull_* helpers

After conversion to g_strdup, the helpers now always return success.
Remove the return value to simplify the callers.

Note that many occurrences of these is in the code generated by
gendispatch.pl. Since gendispatch aggregates many cases together an
incremental conversion would require more invasive changes to
gendispatch for the time of conversion which doesn't make sense.

Also in many cases the helper was the last place where the 'error:'
label was used and thus also those conversions must be included in this
patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
ACKed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: blockjob: Use 'g_free' in qemuBlockJobDataDispose
Peter Krempa [Fri, 18 Oct 2019 13:45:43 +0000 (15:45 +0200)]
qemu: blockjob: Use 'g_free' in qemuBlockJobDataDispose

Prepare the function for addition of new members to clean.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: blockjob: Refactor qemuBlockJobEventProcessConcludedTransition
Peter Krempa [Fri, 4 Oct 2019 12:01:20 +0000 (14:01 +0200)]
qemu: blockjob: Refactor qemuBlockJobEventProcessConcludedTransition

Use only one switch case selecting job type and decide what's successful
outcome on a case-by-case basis.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Add helper for generating data for block bitmap merging
Peter Krempa [Mon, 7 Oct 2019 14:19:34 +0000 (16:19 +0200)]
qemu: monitor: Add helper for generating data for block bitmap merging

Introduce qemuMonitorTransactionBitmapMergeSourceAddBitmap which adds
the appropriate entry into a virJSONValue array to be used with
qemuMonitorTransactionBitmapMerge. Bitmap merging supports two possible
formats and this new helper implements the more universal one specifying
also the source node name.

In addition use the new helper in the testQemuMonitorJSONTransaction
test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>