]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agohyperv: fix typo in Makefile.am.inc
Laine Stump [Thu, 21 Jun 2018 06:19:45 +0000 (02:19 -0400)]
hyperv: fix typo in Makefile.am.inc

The problem has been around for quite awhile - the misspelling was
faithfully copied from src/Makefile.am to src/hyperv/Makefile.am.inc
in commit 253b528c.

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Don't use asyncJob after stop during snapshot revert
John Ferlan [Tue, 19 Jun 2018 22:54:19 +0000 (18:54 -0400)]
qemu: Don't use asyncJob after stop during snapshot revert

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

Attempting to use the FORCE flag for snapshot-revert was resulting
in failures because qemuProcessStart and qemuProcessStartCPUs were
using QEMU_ASYNC_JOB_START after a qemuProcessStop resulting in an
error when entering the monitor:

error: internal error: unexpected async job 6 type expected 0

So create a local @jobType, initialize to QEMU_ASYNC_JOB_START, and
change to QEMU_ASYNC_JOB_NONE if we end up in the --force path
where the qemuProcessStop is run before a Start and StartCPUs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Unset the genid start change flag for revert force
John Ferlan [Tue, 19 Jun 2018 22:54:18 +0000 (18:54 -0400)]
qemu: Unset the genid start change flag for revert force

If the the snapshot revert involves a forced revert option, then
let's not cause startup to change the genid flag in order to signify
that we're still running the same/previous guest and not some
snapshot reversion.

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1149445

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Use start_flags for RUNNING and PAUSED transitions
John Ferlan [Tue, 19 Jun 2018 22:54:17 +0000 (18:54 -0400)]
qemu: Use start_flags for RUNNING and PAUSED transitions

Use and set the @start_flags at the top of the RUNNING and PAUSED
transitions to GEN_VMID | PAUSED.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Promote start_flags in qemuDomainRevertToSnapshot
John Ferlan [Tue, 19 Jun 2018 22:54:16 +0000 (18:54 -0400)]
qemu: Promote start_flags in qemuDomainRevertToSnapshot

Promote the @start_flags to the top of the function, a
subsequent patch needs to use it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Adjust async job failure message
John Ferlan [Tue, 19 Jun 2018 22:54:15 +0000 (18:54 -0400)]
qemu: Adjust async job failure message

Make it clearer what asyncJob type was passed and what was expected.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu_command: vhost: cleanup error reporting
Cole Robinson [Tue, 19 Jun 2018 16:26:25 +0000 (12:26 -0400)]
qemu_command: vhost: cleanup error reporting

- Switch to cleanup: label and share free calls
- Don't overwrite qemuBuildNicDevStr error

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu_command: replace vlan= with netdev= for legacy nic
Cole Robinson [Tue, 19 Jun 2018 15:42:37 +0000 (11:42 -0400)]
qemu_command: replace vlan= with netdev= for legacy nic

VMs with hardcoded platform network devices are forced to use old
style '-net nic' command line config. Current we use qemu's vlan
option to hook this with the '-netdev' host side of things.

However since qemu 1.2 there is '-net nic,netdev=X' option for
explicitly referencing a netdev ID, which is more inline with
typical VM commandlines, so let's switch to that

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu_command: remove unused LegacyNicStr arg 'prefix'
Cole Robinson [Tue, 19 Jun 2018 15:35:32 +0000 (11:35 -0400)]
qemu_command: remove unused LegacyNicStr arg 'prefix'

Hardcode the only string that's passed in

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu_command: Rename BuildNicStr to BuildLegacyNicStr
Cole Robinson [Tue, 19 Jun 2018 15:31:37 +0000 (11:31 -0400)]
qemu_command: Rename BuildNicStr to BuildLegacyNicStr

Makes it less ambiguous

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu_command: Make qemuBuildNicStr static
Cole Robinson [Tue, 19 Jun 2018 15:30:52 +0000 (11:30 -0400)]
qemu_command: Make qemuBuildNicStr static

It doesn't have any external callers

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Remove unused virDomainDefNewFull
Cole Robinson [Tue, 19 Jun 2018 18:30:55 +0000 (14:30 -0400)]
conf: Remove unused virDomainDefNewFull

The last usages were removed with the xend driver in 1dac5fbbbb0

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Switch code to use new agent job APIs
Michal Privoznik [Fri, 8 Jun 2018 12:02:09 +0000 (14:02 +0200)]
qemu: Switch code to use new agent job APIs

There are two sets of functions here:
1) some functions talk on both monitor and agent monitor,
2) some functions only talk on agent monitor.

For functions from set 1) we need to use
qemuDomainObjBeginJobWithAgent() and for functions from set 2) we
need to use qemuDomainObjBeginAgentJob() only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemuDomainSnapshotCreateActiveExternal: Grab agent job
Michal Privoznik [Tue, 19 Jun 2018 17:26:44 +0000 (19:26 +0200)]
qemuDomainSnapshotCreateActiveExternal: Grab agent job

Now that we have agent job we can grab it while freezing/thawing
guest file system before/after doing snapshot.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemu: Introduce APIs for manipulating qemuDomainAgentJob
Michal Privoznik [Tue, 19 Jun 2018 06:12:11 +0000 (08:12 +0200)]
qemu: Introduce APIs for manipulating qemuDomainAgentJob

The point is to break QEMU_JOB_* into smaller pieces which
enables us to achieve higher throughput. For instance, if there
are two threads, one is trying to query something on qemu
monitor while the other is trying to query something on agent
monitor these two threads would serialize. There is not much
reason for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemu: Introduce qemuDomainAgentJob
Michal Privoznik [Tue, 19 Jun 2018 06:11:39 +0000 (08:11 +0200)]
qemu: Introduce qemuDomainAgentJob

Introduce guest agent specific job categories to allow threads to
run agent monitor specific jobs while normal monitor jobs can
also be running.

Alter _qemuDomainJobObj in order to duplicate certain fields that
will be used for guest agent specific tasks to increase
concurrency and throughput and reduce serialization.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agodocs: Remove an extra space in the SEV xml element example
Luyao Huang [Wed, 20 Jun 2018 09:05:04 +0000 (17:05 +0800)]
docs: Remove an extra space in the SEV xml element example

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
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>