]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoqemu: process: Minor language improvement in one of the SEV debug msgs
Luyao Huang [Wed, 20 Jun 2018 09:05:03 +0000 (17:05 +0800)]
qemu: process: Minor language improvement in one of the SEV debug msgs

Be more consistent and use 'preparing' instead of 'prepare' here.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: process: Fix the return value in qemuProcessSEVCreateFile
Luyao Huang [Wed, 20 Jun 2018 09:05:02 +0000 (17:05 +0800)]
qemu: process: Fix the return value in qemuProcessSEVCreateFile

When commit 6718132d enforced usage of the cleanup label, it forgot to
set the @ret variable to 0 on "success" exit path.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: sev: Don't jump to endjob if SEV measurement retrieval fails
Erik Skultety [Mon, 18 Jun 2018 07:20:13 +0000 (09:20 +0200)]
qemu: sev: Don't jump to endjob if SEV measurement retrieval fails

If measurement retrieval fails we'd forget to call ExitMonitor to unlock
the monitor.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reported-by: Luyao Huang <lhuang@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
6 years agoqemu: sev: Use EnterMonitor instead of EnterMonitorAsync
Erik Skultety [Mon, 18 Jun 2018 07:20:12 +0000 (09:20 +0200)]
qemu: sev: Use EnterMonitor instead of EnterMonitorAsync

Since it's being called with QEMU_ASYNC_JOB_NONE which is what
qemuDomainObjEnterMonitor is going to use with the internal helper,
let's use that one instead.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
6 years agotests: Fix qemucapsfixreplies
Andrea Bolognani [Tue, 19 Jun 2018 11:51:00 +0000 (13:51 +0200)]
tests: Fix qemucapsfixreplies

Since e6be524508d5 we include the executed command along
with the reply in *.replies files, which breaks the
renumbering logic implemented in qemucapsfixreplies.

Adapt the script so that it works with the new format.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovirsh: Introduce --nowait to domstats
Michal Privoznik [Thu, 7 Jun 2018 11:30:01 +0000 (13:30 +0200)]
virsh: Introduce --nowait to domstats

This new switch can be used to set
VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT flag for stats
fetching API.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoIntroduce VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT
Michal Privoznik [Wed, 6 Jun 2018 15:12:34 +0000 (17:12 +0200)]
Introduce VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT

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

If there's a long running job it might cause us to wait 30
seconds before we give up acquiring the job. This is problematic
to interactive applications that fetch stats repeatedly every few
seconds.

The solution is to introduce
VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT flag which tries to
acquire job but does not wait if acquiring failed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_domain: Introduce qemuDomainObjBeginJobNowait
Michal Privoznik [Thu, 7 Jun 2018 08:19:52 +0000 (10:19 +0200)]
qemu_domain: Introduce qemuDomainObjBeginJobNowait

The aim of this API is to allow the caller to do best effort.
Some functions can work even when acquiring the job fails (e.g.
qemuConnectGetAllDomainStats()). But what they can't bear is
delay if they have to wait up to 30 seconds for each domain that
is processing some other job.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuDomainObjBeginJobInternal: Remove spurious @ret assignment
Michal Privoznik [Thu, 7 Jun 2018 08:20:15 +0000 (10:20 +0200)]
qemuDomainObjBeginJobInternal: Remove spurious @ret assignment

The variable is initialized to -1 already. There's no way it can
be overwritten by the time control gets to the line I'm removing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_domain: Document qemuDomainObjBeginJob
Michal Privoznik [Thu, 7 Jun 2018 08:17:09 +0000 (10:17 +0200)]
qemu_domain: Document qemuDomainObjBeginJob

Provide a small comment on the function and its parameters.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Escape commas for qemuBuildGrapicsSPICECommandLine
Anya Harter [Mon, 18 Jun 2018 17:57:26 +0000 (13:57 -0400)]
qemu: Escape commas for qemuBuildGrapicsSPICECommandLine

Add comma escaping for cfg->spiceTLSx509certdir and
graphics->data.spice.rendernode.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Escape commas for qemuBuildSmartcardCommandLine
Anya Harter [Mon, 18 Jun 2018 17:57:25 +0000 (13:57 -0400)]
qemu: Escape commas for qemuBuildSmartcardCommandLine

Add comma escaping for smartcard->data.cert.file[i] and
smartcard->data.cert.database.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Escape commas for qemuBuildChrChardevFileStr
Anya Harter [Mon, 18 Jun 2018 17:57:24 +0000 (13:57 -0400)]
qemu: Escape commas for qemuBuildChrChardevFileStr

Add comma escaping for fileval.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Escape commas for qemuBuildChrChardevStr
Anya Harter [Mon, 18 Jun 2018 17:57:23 +0000 (13:57 -0400)]
qemu: Escape commas for qemuBuildChrChardevStr

Add comma escaping for dev->data.file.path in cases
VIR_DOMAIN_CHR_TYPE_DEV and VIR_DOMAIN_CHR_TYPE_PIPE.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: add test file for smartcard database
Anya Harter [Fri, 15 Jun 2018 14:45:05 +0000 (10:45 -0400)]
tests: add test file for smartcard database

Add test case explicitly defining a smartcard host certificates
database via the following xml:

    <smartcard mode='host-certificates'>
      <database>/tmp/foo</database>
    </smartcard>

This case is not currently covered in the test suite.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Fix qemuMonitorCreateObjectProps
John Ferlan [Mon, 18 Jun 2018 11:35:38 +0000 (07:35 -0400)]
qemu: Fix qemuMonitorCreateObjectProps

Fix the return value status comparison checking for call to
virJSONValueObjectCreateVArgs introduced by commit id f0a23c0c3.

If a NULL arglist is passed, then a 0 is returned which is a
valid status and we only should fail when the return is < 0.

This resolves an issue seen for "virsh iothreadadd $dom $iothread"
where a "error: An error occurred, but the cause is unknown" error
was generated when trying to hotplug an IOThread to a domain since
qemuDomainHotplugAddIOThread passes a NULL arglist.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoevents: Remove ATTRIBUTE_NONNULL for virObjectEventStateQueue[Remote]
John Ferlan [Fri, 15 Jun 2018 19:25:59 +0000 (15:25 -0400)]
events: Remove ATTRIBUTE_NONNULL for virObjectEventStateQueue[Remote]

Commit aad3a0b5f altered virObjectEventStateQueueRemote to move
the "if (!event) return" call added in the previous commit 031eb8f6
to virObjectEventStateQueue. Neither commit altered the function
prototype which used ATTRIBUTE_NONNULL(2).

This caused Coverity build problems. Since @event is now checked,
just remove the ATTRIBUTE_NONNULL check from both prototypes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuDomainDetachDeviceConfig: Don't free device from @dev
Michal Privoznik [Fri, 15 Jun 2018 14:16:08 +0000 (16:16 +0200)]
qemuDomainDetachDeviceConfig: Don't free device from @dev

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

For reasons I don't understand my original patch of 75f0fd51124
freed not only the chardev from domain but also the one from
passed virDomainDeviceDefPtr. This caused no troubles until now,
because those two pointers were separate, but after I've
introduced virDomainDetachDeviceAlias() they became the same
resulting in double free on detach.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotravis: Add MinGW builds
Andrea Bolognani [Thu, 14 Jun 2018 14:34:20 +0000 (16:34 +0200)]
travis: Add MinGW builds

We build on Fedora Rawhide, same as on the CentOS CI
environment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Add CentOS 7 build
Andrea Bolognani [Tue, 12 Jun 2018 09:00:02 +0000 (11:00 +0200)]
travis: Add CentOS 7 build

Now that we use pre-built Docker images, it's very easy
to extend our test matrix; adding CentOS 7 is a good start.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Use pre-built Docker images
Andrea Bolognani [Tue, 12 Jun 2018 08:59:20 +0000 (10:59 +0200)]
travis: Use pre-built Docker images

Instead of starting from the minimal Ubuntu 18.04 base
image and installing all requirements at build time,
use a Docker image that has been specifically tailored
at building libvirt and thus already includes all
required packages.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Drop Ubuntu 16.04 build
Andrea Bolognani [Tue, 12 Jun 2018 08:56:07 +0000 (10:56 +0200)]
travis: Drop Ubuntu 16.04 build

This will make further changes easier; all coverage
lost due to this will be reintroduced later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: Fix formatting of <sev> element in domain capabilities XML
Erik Skultety [Thu, 14 Jun 2018 12:18:30 +0000 (14:18 +0200)]
conf: Fix formatting of <sev> element in domain capabilities XML

We only formatted the <sev> element when QEMU supported the feature when
in fact we should always format the element to make clear that libvirt
knows about the feature and the fact whether it is or isn't supported
depends on QEMU version, in other words if QEMU doesn't support the
feature we're going to format the following into the domain capabilities
XML:

<sev supported='no'/>

This patch also adjusts the RNG schema accordingly in order to reflect
the proposed change.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotravis: Skip first compilation for Linux builds
Andrea Bolognani [Thu, 14 Jun 2018 16:27:36 +0000 (18:27 +0200)]
travis: Skip first compilation for Linux builds

We already perform a full build as part of distcheck, so
we can speed things up a bit by skipping the first
compilation.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Fix error path
Andrea Bolognani [Thu, 14 Jun 2018 16:23:47 +0000 (18:23 +0200)]
travis: Fix error path

Without a proper separator, all commands in the error path
end up being interpreted as a single command, which is not
what we want.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Rename DOCKER_CMD to LINUX_CMD
Andrea Bolognani [Thu, 7 Jun 2018 15:54:43 +0000 (17:54 +0200)]
travis: Rename DOCKER_CMD to LINUX_CMD

The new name is arguably more informative, especially now
that we have MACOS_CMD and knowing that MINGW_CMD will
be introduced later on.

We still use DOCKER_CMD when calling Docker, and we assign
the actual script on a per-image basis. Having this
separation will help us when we introduce MinGW builds.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Introduce MACOS_CMD
Andrea Bolognani [Thu, 7 Jun 2018 15:54:42 +0000 (17:54 +0200)]
travis: Introduce MACOS_CMD

It mirrors the existing DOCKER_CMD, both in how it's defined
as part of the environment and how it's called by passing it
directly to the shell.

In addition to making the configuration more consistent, this
also allows us to move from having the macOS build script
divided into four steps, some of which have slightly different
semantics and the relationship between which is not immediately
obvious without consulting the documentation, to a single
straightforward shell invocation.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Don't duplicate Docker invocation
Andrea Bolognani [Thu, 7 Jun 2018 15:54:41 +0000 (17:54 +0200)]
travis: Don't duplicate Docker invocation

All variable parts are taken from the environment, so we
can exploit inheritance and avoid duplication. This will
become more important as we start building on additional
platforms.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Skip macOS upgrade
Andrea Bolognani [Thu, 7 Jun 2018 15:54:40 +0000 (17:54 +0200)]
travis: Skip macOS upgrade

Upgrading takes quite a bit of time, doesn't offer any
real value and causes a lot of grief. Let's just skip it.

We need to install xz explicitly now, since it's required
to make dist and no longer being dragged in by Python 3.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoxen_common: Split per-Vif logic from xenParseVif()
Fabiano Fidêncio [Thu, 14 Jun 2018 04:59:52 +0000 (06:59 +0200)]
xen_common: Split per-Vif logic from xenParseVif()

xenParseVif() does a lot of stuff and, in order to make things cleaner,
let's split it in two new functions:
- xenParseVif(): it's a new function that keeps the old name. It's
responsible for the whole per-Vif logic from the old xenParseVif();
- xenParseVifList(): it's basically the old xenParsePCI(), but now it
just iterates over the list of Vifs, calling xenParsePCI() per each Vif.

This patch is basically preparing the ground for the future when
typesafe virConf acessors will be used.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agonews: Add the qemu VM reconnect segfault fix into bugfixes section
Erik Skultety [Fri, 8 Jun 2018 11:44:45 +0000 (13:44 +0200)]
news: Add the qemu VM reconnect segfault fix into bugfixes section

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemuxml2argvtest: Don't leak TPM unix path
Michal Privoznik [Wed, 13 Jun 2018 11:16:20 +0000 (13:16 +0200)]
qemuxml2argvtest: Don't leak TPM unix path

When testing a domain XML with TPM we overwrite UNIX socket path
to mimic what qemuTPMEmulatorPrepareHost() is doing (because
*PrepareHost() functions are not called from the test). But we
are not doing it fully - we need to set the chardev's type too so
that virDomainTPMDefFree() can free the path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: ignore query-sev-capabilities errors
Ján Tomko [Thu, 14 Jun 2018 07:30:27 +0000 (09:30 +0200)]
qemu: ignore query-sev-capabilities errors

The query-sev-capabilities command fails if SEV is not compiled in,
even though both the command and -object sev-guest are present
in that case :/

Ignore the errors to avoid spamming the logs:
internal error: unable to execute QEMU command 'query-sev-capabilities': SEV feature is not available

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirtportallocator: Change number of ports to 65536
Pavel Hrdina [Thu, 14 Jun 2018 07:17:10 +0000 (09:17 +0200)]
virtportallocator: Change number of ports to 65536

USHRT_MAX is not good enough because the value is 65535 which specifies
the number of bits in bitmap.  The allowed port range is 0-65535 so we
need to increase the number.

We could have USHRT_MAX + 1 but let's define the number explicitly.

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

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agorename more Sev functions to SEV
Ján Tomko [Tue, 12 Jun 2018 11:28:22 +0000 (13:28 +0200)]
rename more Sev functions to SEV

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoRename virDomainSevDefPtr to virDomainSEVDefPtr
Ján Tomko [Tue, 12 Jun 2018 11:27:16 +0000 (13:27 +0200)]
Rename virDomainSevDefPtr to virDomainSEVDefPtr

Some identifiers use Sev, some SEV. Prefer the latter.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemuProcessSEVCreateFile: use a cleanup label
Ján Tomko [Tue, 12 Jun 2018 11:39:42 +0000 (13:39 +0200)]
qemuProcessSEVCreateFile: use a cleanup label

A common cleanup path for both the success and the error case.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agorename qemuBuildSevCreateFile to qemuProcessSEVCreateFile
Ján Tomko [Tue, 12 Jun 2018 11:39:21 +0000 (13:39 +0200)]
rename qemuBuildSevCreateFile to qemuProcessSEVCreateFile

Make the function prefix match the file it's in.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemuDomainGetSEVMeasurement: fix possible leak
Ján Tomko [Tue, 12 Jun 2018 11:38:43 +0000 (13:38 +0200)]
qemuDomainGetSEVMeasurement: fix possible leak

Free tmp even on failure.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoremove virQEMUCapsSetSEVCapabilities
Ján Tomko [Tue, 12 Jun 2018 11:38:29 +0000 (13:38 +0200)]
remove virQEMUCapsSetSEVCapabilities

It is only used in one place.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: Rework virDomainSEVDefParseXML()
Michal Privoznik [Wed, 13 Jun 2018 10:44:06 +0000 (12:44 +0200)]
conf: Rework virDomainSEVDefParseXML()

Firstly, this function changes node for relative XPaths but
doesn't restore the original one in case VIR_ALLOC(def) fails.
Secondly, @type is leaked. Thirdly, dh-cert and session
attributes are strdup()-ed needlessly, virXPathString already
does that so we can use the retval immediately.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuBuildSevCommandLine: fix buffer leak
Michal Privoznik [Wed, 13 Jun 2018 10:33:57 +0000 (12:33 +0200)]
qemuBuildSevCommandLine: fix buffer leak

The buffer is not freed anywhere. Nor in the error paths. Also
the usage virCommand with respect to buffer is very odd.

==2504== 1,100 bytes in 1 blocks are definitely lost in loss record 167 of 175
==2504==    at 0x4C2CE3F: malloc (vg_replace_malloc.c:298)
==2504==    by 0x4C2F1BF: realloc (vg_replace_malloc.c:785)
==2504==    by 0x5D32EE2: virReallocN (viralloc.c:245)
==2504==    by 0x5D37278: virBufferGrow (virbuffer.c:150)
==2504==    by 0x5D3783E: virBufferVasprintf (virbuffer.c:408)
==2504==    by 0x5D377A9: virBufferAsprintf (virbuffer.c:381)
==2504==    by 0x57017C1: qemuBuildSevCommandLine (qemu_command.c:9707)
==2504==    by 0x57030F7: qemuBuildCommandLine (qemu_command.c:10324)
==2504==    by 0x575FA48: qemuProcessCreatePretendCmd (qemu_process.c:6644)
==2504==    by 0x11351A: testCompareXMLToArgv (qemuxml2argvtest.c:564)
==2504==    by 0x1392F7: virTestRun (testutils.c:180)
==2504==    by 0x137895: mymain (qemuxml2argvtest.c:2900)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemuBuildSevCommandLine: s/obj/buf/
Michal Privoznik [Wed, 13 Jun 2018 10:25:52 +0000 (12:25 +0200)]
qemuBuildSevCommandLine: s/obj/buf/

The variable points to a buffer not a domain object therefore its
current name is misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: prefer camelCase for launchSecurity
Ján Tomko [Tue, 12 Jun 2018 11:50:25 +0000 (13:50 +0200)]
conf: prefer camelCase for launchSecurity

Adjust the documentation, parser and tests to change:
launch-security -> launchSecurity
reduced-phys-bits -> reducedPhysBits
dh-cert -> dhCert

Also fix the headline in formatdomain.html to be more generic,
and some leftover closing elements in the documentation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodomaincaps: rename reduced-phys-bits to reducedPhysBits
Ján Tomko [Tue, 12 Jun 2018 11:38:19 +0000 (13:38 +0200)]
domaincaps: rename reduced-phys-bits to reducedPhysBits

We have enough elements using underscores instead of camelCase,
do not bring dashes into the mix.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agolibvirt: fix a typo
Chen Hanxiao [Wed, 13 Jun 2018 08:35:47 +0000 (16:35 +0800)]
libvirt: fix a typo

s/httsp/https/

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agolib: Document limitation of virDomainInterfaceAddresses
Michal Privoznik [Tue, 12 Jun 2018 11:13:06 +0000 (13:13 +0200)]
lib: Document limitation of virDomainInterfaceAddresses

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

This API takes @source argument which tells it where to get
domain IP addresses from. However, not all sources are capable of
providing all the information we report, for instance ARP table
has no notion of IP address prefixes. Document this limitation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agoevents: remove umlDomainEventQueue wrapper func
Anya Harter [Tue, 12 Jun 2018 17:33:03 +0000 (13:33 -0400)]
events: remove umlDomainEventQueue wrapper func

And replace all calls with virObjectEventStateQueue such that:

    umlDomainEventQueue(driver, event);

becomes:

    virObjectEventStateQueue(driver->domainEventState, event);

And remove NULL checking from all callers.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoevents: remove qemuDomainEventQueue wrapper func
Anya Harter [Tue, 12 Jun 2018 17:33:02 +0000 (13:33 -0400)]
events: remove qemuDomainEventQueue wrapper func

And replace all calls with virObjectEventStateQueue such that:

    qemuDomainEventQueue(driver, event);

becomes:

    virObjectEventStateQueue(driver->domainEventState, event);

And remove NULL checking from all callers.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoevents: remove libxlDomainEventQueue wrapper func
Anya Harter [Tue, 12 Jun 2018 17:33:01 +0000 (13:33 -0400)]
events: remove libxlDomainEventQueue wrapper func

And replace all calls with virObjectEventStateQueue such that:

    libxlDomainEventQueue(driver, event);

becomes:

    virObjectEventStateQueue(driver->domainEventState, event);

And remove NULL checking from all callers.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoevents: remove testObjectEventQueue wrapper func
Anya Harter [Tue, 12 Jun 2018 17:33:00 +0000 (13:33 -0400)]
events: remove testObjectEventQueue wrapper func

And replace all calls with virObjectEventStateQueue such that:

    testObjectEventQueue(privconn, event);

becomes:

    virObjectEventStateQueue(privconn->eventState, event);

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agolibvirtd: Add service dependency on systemd-logind
Cole Robinson [Thu, 7 Jun 2018 14:44:34 +0000 (10:44 -0400)]
libvirtd: Add service dependency on systemd-logind

At daemon startup we query logind for host PM support status. Without
a service dependency host startup can trigger libvirtd errors like:

error : virNodeSuspendSupportsTarget:336 : internal error: Cannot probe for
supported suspend types
warning : virQEMUCapsInit:949 : Failed to get host power management
capabilities

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

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoapparmor: fix vfio usage without initial hostdev
Christian Ehrhardt [Mon, 11 Jun 2018 11:45:31 +0000 (13:45 +0200)]
apparmor: fix vfio usage without initial hostdev

The base vfio has not much functionality but to provide a custom
container by opening this path.
See https://www.kernel.org/doc/Documentation/vfio.txt for more.

Systems with static hostdevs will get /dev/vfio/vfio by virt-aa-hotplug
right from the beginning. But if the guest initially had no hostdev at
all it will run into the following deny before the security module
labelling callbacks will make the actual vfio device (like /dev/vfio/93)
known.

Example of such a deny:
[ 2652.756712] audit: type=1400 audit(1491303691.719:25):
  apparmor="DENIED" operation="open"
  profile="libvirt-17a61b87-5132-497c-b928-421ac2ee0c8a"
  name="/dev/vfio/vfio" pid=8486 comm="qemu-system-x86"
  requested_mask="wr" denied_mask="wr" fsuid=64055 ouid=0

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1678322
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1775777

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: add qemu_monitor_priv.h to sources list
Daniel P. Berrangé [Tue, 12 Jun 2018 09:16:41 +0000 (10:16 +0100)]
qemu: add qemu_monitor_priv.h to sources list

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: remove duplicated typedefs for virDomainSevDef
Daniel P. Berrangé [Tue, 12 Jun 2018 09:11:41 +0000 (10:11 +0100)]
conf: remove duplicated typedefs for virDomainSevDef

The typedefs were present twice in the header file which causes failures
with some compilers, eg FreeBSD 10 CLang:

../../src/conf/domain_conf.h:2330:33: error: redefinition of typedef 'virDomainSevDef' is a C11 feature
+[-Werror,-Wtypedef-redefinition]
typedef struct _virDomainSevDef virDomainSevDef;
                                ^
../../src/conf/domain_conf.h:145:33: note: previous definition is here
typedef struct _virDomainSevDef virDomainSevDef;
                                ^

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoAppArmor: allow virt-aa-helper read access to Nova's qcow backing files.
intrigeri [Sat, 9 Jun 2018 19:26:26 +0000 (19:26 +0000)]
AppArmor: allow virt-aa-helper read access to Nova's qcow backing files.

As reported on https://bugs.debian.org/892431, without this rule, when launching
a QEMU KVM instance, an error occurs immediately upon launching the QEMU
process such as:

  Could not open backing file: Could not open
  '/var/lib/nova/instances/_base/affe96668a4c64ef380ff1c71b4caec17039080e':
  Permission denied

The other instance disk images are already covered by the existing rule:

  /**/disk{,.*} r

Signed-off-by: intrigeri <intrigeri@boum.org>
6 years agotests: qemucapabilities: Test commands used to query capabilities
Peter Krempa [Fri, 1 Jun 2018 08:03:01 +0000 (10:03 +0200)]
tests: qemucapabilities: Test commands used to query capabilities

Use qemuMonitorTestNewFromFileFull which allows to test commands used
along with providing replies. This has two advantages:

1) It's easier to see which command was used when looking at the files
2) We check that the used commands are actually in the correct order

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemucapsprobemock: Prepare 'qemucapsprobe' for the new format
Peter Krempa [Thu, 3 May 2018 15:29:36 +0000 (17:29 +0200)]
tests: qemucapsprobemock: Prepare 'qemucapsprobe' for the new format

Change the output of qemucapsprobe to record the commands used for
querying. This allows to easily identify which reply belongs to which
command and also will allow to test whether we use stable queries.

This change includes changing dropping of the QMP greeting from the file
and reformatting of the query and output to stdout.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemucapsprobemock: Fail if JSON reply from qemu can't be reformatted
Peter Krempa [Fri, 4 May 2018 13:34:41 +0000 (15:34 +0200)]
tests: qemucapsprobemock: Fail if JSON reply from qemu can't be reformatted

Rather than skipping output on failure fail loudly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemucapsprobemock: Simplify and extract skipping of empty lines
Peter Krempa [Thu, 3 May 2018 15:34:43 +0000 (17:34 +0200)]
tests: qemucapsprobemock: Simplify and extract skipping of empty lines

The prettyfied output may sometimes contain empty lines which would
desynchonize the test monitor workers. The skipping code can be much
simplified though. Also a extract it so so that it's obvious what
it's doing and can be reused.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemumonitor: Optimize control flow when concatenating replies
Peter Krempa [Thu, 3 May 2018 09:43:34 +0000 (11:43 +0200)]
tests: qemumonitor: Optimize control flow when concatenating replies

The test file can be broken up by newlines and is automatically
concatenated back. Fix the control flow so that the concatenation code
'continues' the loop rather than branching out.

Also add an anotation to the concatenation code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemumonitor: Simplify handling of end of file in full file test
Peter Krempa [Thu, 3 May 2018 09:38:23 +0000 (11:38 +0200)]
tests: qemumonitor: Simplify handling of end of file in full file test

On EOF, the loop can be terminated right away since most of it is
skipped anyways and the handling of the last command is repeated after
the loop.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemucapabilities: Reset command sequence before second probe
Peter Krempa [Mon, 4 Jun 2018 09:21:51 +0000 (11:21 +0200)]
tests: qemucapabilities: Reset command sequence before second probe

The test data for capabilities is obtained from two consecutive qemu
runs when the regular monitor object will be reset. Do the same for the
test monitor object which is not disposed between runs by calling
qemuMonitorResetCommandID.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: monitor: Add possibility to reset command sequence in tests
Peter Krempa [Fri, 4 May 2018 14:26:08 +0000 (16:26 +0200)]
qemu: monitor: Add possibility to reset command sequence in tests

qemucapabilitiestest for simplicity uses one test monitor object for
simulating work of two separate inquiries of the qemu process. To allow
better testing in the future it will be required to reset the counter
so that it accurately simulates how qemu would behave.

This patch adds a private monitor API which allows to reset the counter
which will be usable only in tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: fix uninitialised variable in virQEMUDriverConfigLoadFile
Julio Faracco [Mon, 11 Jun 2018 20:35:33 +0000 (17:35 -0300)]
qemu: fix uninitialised variable in virQEMUDriverConfigLoadFile

Since virConfGetValueBool() can return earlier, the parameter 'value'
might be not initialised properly inside this method. Another proof:
Valgrind is returning this error during the libvirtd daemon startup:

==16199== Conditional jump or move depends on uninitialised value(s)
==16199==    at 0x27FFFEF4: virQEMUDriverConfigLoadFile (qemu_conf.c:809)
==16199==    by 0x2807665C: qemuStateInitialize (qemu_driver.c:654)
==16199==    by 0x5535428: virStateInitialize (libvirt.c:662)
==16199==    by 0x12AED8: daemonRunStateInit (remote_daemon.c:802)
==16199==    by 0x536DE18: virThreadHelper (virthread.c:206)
==16199==    by 0x6CB36DA: start_thread (pthread_create.c:463)
==16199==    by 0x6FEC88E: clone (clone.S:95)

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Extract formatting of 'mirror' disk sub-element
Peter Krempa [Mon, 11 Jun 2018 14:51:16 +0000 (16:51 +0200)]
conf: Extract formatting of 'mirror' disk sub-element

Move the code to a separate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Use virXMLFormatElement to format disk 'driver' element
Peter Krempa [Mon, 11 Jun 2018 13:32:05 +0000 (15:32 +0200)]
conf: Use virXMLFormatElement to format disk 'driver' element

Formatting of 'driver' already used a separate buffer but was part of
the main function. Separate it and remove bunch of unnecessary temporary
variables.

Note that some checks are removed but they are not really necessary
anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Use virXMLFormatElement to format disk IO tuning
Peter Krempa [Mon, 11 Jun 2018 13:32:05 +0000 (15:32 +0200)]
conf: Use virXMLFormatElement to format disk IO tuning

Extract and refactor the code to use the new approach which allows to
delete a monster condition to check if the element needs to be
formatted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Implement the driver backend for virDomainGetLaunchSecurityInfo
Brijesh Singh [Fri, 8 Jun 2018 14:41:01 +0000 (09:41 -0500)]
qemu: Implement the driver backend for virDomainGetLaunchSecurityInfo

This patch implements the internal driver API for launch event into
qemu driver. When SEV is enabled, execute 'query-sev-launch-measurement'
to get the measurement of memory encrypted through launch sequence.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoremote: Implement the remote protocol for launch security
Brijesh Singh [Fri, 8 Jun 2018 14:41:00 +0000 (09:41 -0500)]
remote: Implement the remote protocol for launch security

Add remote support for launch security info.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolibvirt: Introduce virDomainGetLaunchSecurityInfo public API
Brijesh Singh [Fri, 8 Jun 2018 14:40:59 +0000 (09:40 -0500)]
libvirt: Introduce virDomainGetLaunchSecurityInfo public API

The API can be used outside the libvirt to get the launch security
information. When SEV is enabled, the API can be used to get the
measurement of the launch process.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: Add support to launch an SEV guest
Brijesh Singh [Fri, 8 Jun 2018 14:40:58 +0000 (09:40 -0500)]
qemu: Add support to launch an SEV guest

QEMU >= 2.12 provides 'sev-guest' object which is used to launch encrypted
VMs on AMD platform using SEV feature. The various inputs required to
launch SEV guest is provided through the <launch-security> tag. A typical
SEV guest launch command line looks like this:

  -object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=5 ...\
  -machine memory-encryption=sev0 \

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu/cgroup: Add /dev/sev in shared devices list
Brijesh Singh [Fri, 8 Jun 2018 14:40:57 +0000 (09:40 -0500)]
qemu/cgroup: Add /dev/sev in shared devices list

QEMU uses /dev/sev device while creating the SEV guest, lets add /dev/sev
in the list of devices allowed to be accessed by the QEMU.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Introduce launch-security element in domain
Brijesh Singh [Fri, 8 Jun 2018 14:40:56 +0000 (09:40 -0500)]
conf: Introduce launch-security element in domain

The launch-security element can be used to define the security
model to use when launching a domain. Currently we support 'sev'.

When 'sev' is used, the VM will be launched with AMD SEV feature enabled.
SEV feature supports running encrypted VM under the control of KVM.
Encrypted VMs have their pages (code and data) secured such that only the
guest itself has access to the unencrypted version. Each encrypted VM is
associated with a unique encryption key; if its data is accessed to a
different entity using a different key the encrypted guests data will be
incorrectly decrypted, leading to unintelligible data.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: Implement the driver backend for virNodeGetSEVInfo()
Brijesh Singh [Fri, 8 Jun 2018 14:40:55 +0000 (09:40 -0500)]
qemu: Implement the driver backend for virNodeGetSEVInfo()

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoremote: Implement the remote protocol for virNodeGetSEVInfo()
Brijesh Singh [Fri, 8 Jun 2018 14:40:54 +0000 (09:40 -0500)]
remote: Implement the remote protocol for virNodeGetSEVInfo()

Add remote support for virNodeGetSEVInfo().

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolibvirt: Introduce virNodeGetSEVInfo public API
Brijesh Singh [Fri, 8 Jun 2018 14:40:53 +0000 (09:40 -0500)]
libvirt: Introduce virNodeGetSEVInfo public API

The API can be used by application to retrieve the Platform Diffie-Hellman
Key and Platform Certificate chain.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Expose SEV feature in domain capabilities
Brijesh Singh [Fri, 8 Jun 2018 14:40:52 +0000 (09:40 -0500)]
conf: Expose SEV feature in domain capabilities

Extend hypervisor capabilities to include sev feature. When available,
hypervisor supports launching an encrypted VM on AMD platform. The
sev feature tag provides additional details like Platform Diffie-Hellman
(PDH) key and certificate chain which can be used by the guest owner to
establish a cryptographic session with the SEV firmware to negotiate
keys used for attestation or to provide secret during launch.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: Provide support to query the SEV capability
Brijesh Singh [Fri, 8 Jun 2018 14:40:51 +0000 (09:40 -0500)]
qemu: Provide support to query the SEV capability

QEMU version >= 2.12 provides support for launching an encrypted VMs on
AMD x86 platform using Secure Encrypted Virtualization (SEV) feature.
This patch adds support to query the SEV capability from the qemu.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoevents: remove remoteEventQueue wrapper function
Anya Harter [Mon, 11 Jun 2018 19:38:19 +0000 (15:38 -0400)]
events: remove remoteEventQueue wrapper function

And replace all calls with virObjectEventStateQueue such that:

    remoteEventQueue(priv, event, callbackID);

becomes:

    virObjectEventStateQueue(priv->eventState, event, callbackID);

Signed-off-by: Anya Harter <aharter@redhat.com>
6 years agoevents: move NULL check to EventStateQueueRemote
Anya Harter [Mon, 11 Jun 2018 19:38:18 +0000 (15:38 -0400)]
events: move NULL check to EventStateQueueRemote

Remove NULL check around call to virObjectEventStateQueueRemote in
remote_driver.c.

Signed-off-by: Anya Harter <aharter@redhat.com>
6 years agoevents: add NULL check in virObjectEventStateQueue
Anya Harter [Mon, 11 Jun 2018 19:38:17 +0000 (15:38 -0400)]
events: add NULL check in virObjectEventStateQueue

And remove NULL checking from all callers.

Signed-off-by: Anya Harter <aharter@redhat.com>
6 years agoqemu: Allow no address to be defined for virtio-scsi iothread attach
John Ferlan [Thu, 7 Jun 2018 00:21:26 +0000 (20:21 -0400)]
qemu: Allow no address to be defined for virtio-scsi iothread attach

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

When attaching a virtio-scsi with IOThreads for the config of a
live domain, allow the <address> to not be defined thus allowing
post parse processing to fill in the address. This allows parsing
of an individual device to succeed for attach config.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Alter error message when IOThread address not correct
John Ferlan [Mon, 11 Jun 2018 22:44:02 +0000 (18:44 -0400)]
qemu: Alter error message when IOThread address not correct

Make the error a bit clearer that virtio-scsi IOThreads require
virtio pci or ccw controller address types.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Fix error for attach controller config for live guest
John Ferlan [Thu, 7 Jun 2018 00:21:25 +0000 (20:21 -0400)]
qemu: Fix error for attach controller config for live guest

Fix the error message to indicate what exactly is failing - that
the controller index provided matches an existing controller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Check error from virXMLFormatElement call
John Ferlan [Fri, 8 Jun 2018 17:07:55 +0000 (13:07 -0400)]
conf: Check error from virXMLFormatElement call

Commit id 1bd5a08d added a call to virXMLFormatElement without
also checking the return status.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
6 years agotest: Check return status for libxlxml2domconfigtest
John Ferlan [Wed, 14 Feb 2018 12:12:35 +0000 (07:12 -0500)]
test: Check return status for libxlxml2domconfigtest

Commit id d8e8b63d introduced the test, but neglected to check for
error from virTestLoadFile in testCompareXMLToDomConfig.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
6 years agotest: Fix resource leak in qemumonitorjsontest
John Ferlan [Wed, 18 Apr 2018 10:33:42 +0000 (06:33 -0400)]
test: Fix resource leak in qemumonitorjsontest

Introduced by commmit id 37bd4571c. Need to goto cleanup and
not return directly.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
6 years agoqemu: Fix Coverity build for qemu_monitor
John Ferlan [Fri, 8 Jun 2018 10:46:32 +0000 (06:46 -0400)]
qemu: Fix Coverity build for qemu_monitor

Commit id '7ef0471bf' added a new parameter to qemuMonitorOpen,
but didn't update the ATTTRIBUTE_NONNULL for the @cb (param 5).

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
6 years agovbox: Fix resource leak
John Ferlan [Tue, 5 Jun 2018 12:33:04 +0000 (08:33 -0400)]
vbox: Fix resource leak

The @disk was allocated, filled in, and consumed on the normal path,
but for error/cleanup paths it would be leaked.  Rename to newHardDisk
and manage properly.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
6 years agovbox: Fix resource leak
John Ferlan [Tue, 5 Jun 2018 12:18:32 +0000 (08:18 -0400)]
vbox: Fix resource leak

Need to free the allocated hardDiskToOpen array. The contents of the
array are just pointers returned by virVBoxSnapshotConfHardDiskByLocation
and not allocated AFAICT so they don't need to also be freed as well.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
6 years agovirstring: fix a typo
Chen Hanxiao [Mon, 11 Jun 2018 10:46:21 +0000 (18:46 +0800)]
virstring: fix a typo

s/glibc's_asprintf/glibc's asprintf

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoxen_common: Split per-PCI logic from xenParsePCI()
Fabiano Fidêncio [Sun, 27 May 2018 22:28:23 +0000 (00:28 +0200)]
xen_common: Split per-PCI logic from xenParsePCI()

xenParsePCI() does a lot of stuff and, in order to make things cleaner,
let's split it in two new functions:
- xenParsePCI(): it's a new function that keeps the old name. It's
responsible for the whole per-PCI logic from the old xenParsePCI();
- xenParsePCIList(): it's basically the old xenParsePCI(), but now it
just iterates over the list of PCIs, calling xenParsePCI() per each PCI.

This patch is basically preparing the ground for the future when
typesafe virConf acessors will be used.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agovmx: convert to typesafe virConf accessors
Fabiano Fidêncio [Sun, 27 May 2018 22:28:22 +0000 (00:28 +0200)]
vmx: convert to typesafe virConf accessors

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoxen_vm: convert to typesafe virConf accessors
Fabiano Fidêncio [Sun, 27 May 2018 22:28:21 +0000 (00:28 +0200)]
xen_vm: convert to typesafe virConf accessors

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoxen_xm: Split the per-disk logic from xenParseXMDisk()
Fabiano Fidêncio [Sun, 27 May 2018 22:28:20 +0000 (00:28 +0200)]
xen_xm: Split the per-disk logic from xenParseXMDisk()

xenParseXMDisk() does a lot of stuff and, in order to make things
cleaner, let's split it in two new functions:
- xenParseXMDisk(): it's a new function that keeps the old name. It's
responsible for the whole per-disk logic from the old xenParseXMDisk();
- xenParseXMDiskList(): it's basically the old xenParseXMDisk(), but
now it just iterates over the list of disks, calling xenParseXMDisk()
per each disk.

This patch is basically preparing the ground for the future when
typesafe virConf acessors will be used.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agobhyve: tests: Add missing data files
Roman Bogorodskiy [Fri, 8 Jun 2018 17:52:17 +0000 (21:52 +0400)]
bhyve: tests: Add missing data files

Add missing data files for bhyve cpu topology tests that should have been
added in b66fda0a74.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
6 years agoqemu: Fix segmentation fault on reconnect
Marc Hartmayer [Fri, 8 Jun 2018 10:49:07 +0000 (12:49 +0200)]
qemu: Fix segmentation fault on reconnect

On start up of libvirtd the worker pool of the QEMU driver must be
initialized before trying to reconnect to all the running QEMU
instances. Otherwise segmentation faults can occur if there are QEMU
monitor events emitted.

 #0  __GI___pthread_mutex_lock
 #1  0x000003fffdba9e62 in virMutexLock
 #2  0x000003fffdbab2dc in virThreadPoolSendJob
 #3  0x000003ffd8343b70 in qemuProcessHandleSerialChanged
 #4  0x000003ffd836a776 in qemuMonitorEmitSerialChange
 #5  0x000003ffd8378e52 in qemuMonitorJSONHandleSerialChange
 #6  0x000003ffd8378930 in qemuMonitorJSONIOProcessEvent
 #7  0x000003ffd837edee in qemuMonitorJSONIOProcessLine
 #8  0x000003ffd837ef86 in qemuMonitorJSONIOProcess
 #9  0x000003ffd836757a in qemuMonitorIOProcess
 #10 0x000003ffd836863e in qemuMonitorIO
 #11 0x000003fffdb4033a in virEventPollDispatchHandles
 #12 0x000003fffdb4055e in virEventPollRunOnce
 #13 0x000003fffdb3e782 in virEventRunDefaultImpl
 #14 0x000003fffdc89400 in virNetDaemonRun
 #15 0x000000010002a816 in main

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: Remove cbm_mask from virResctrlInfoPerType
Martin Kletzander [Thu, 8 Feb 2018 15:02:04 +0000 (16:02 +0100)]
util: Remove cbm_mask from virResctrlInfoPerType

It was used just temporarily to do a calculation, no need to keep that around.
Also use virBitmap in the code instead of reimplementing two of its existing
functions.  And move the counting part next to where the value is read.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoMove virCacheKernel enum implemetation from conf/ to util/
Martin Kletzander [Thu, 8 Feb 2018 14:55:09 +0000 (15:55 +0100)]
Move virCacheKernel enum implemetation from conf/ to util/

It will be used in that file later on, plus it makes sense for all the
implementations to be in same place.  Also comment each one of them nicely and
add a comment explaining why they all need to end with the same _LAST value.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>