Commit Graph

30079 Commits

Author SHA1 Message Date
Daniel P. Berrangé
c21679fa3f conf: introduce a virNWFilterBindingObjListPtr struct
Introduce a new struct to act as the manager of a collection of
virNWFilterBindingObjPtr objects.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
191b4396d3 conf: introduce a virNWFilterBindingObjPtr struct
Introduce a new struct to act as the stateful owner of the
virNWFilterBindingDefPtr objects.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
c0fa7713b8 conf: report an error if nic needs filtering by no driver is present
If a <interface> includes a filter name but the nwfilter driver is not
present we silently do nothing. This is very bad, because an application
that thinks it is protected by malicious guest traffic will in fact be
vulnerable. Reporting an error gives the administrator the ability to
know there is a problem and fix it.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
fca9afa084 nwfilter: convert DHCP address snooping code to virNWFilterBindingDefPtr
Use the virNWFilterBindingDefPtr struct in the DHCP address snooping code
directly.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
5b6c02e292 nwfilter: convert IP address learning code to virNWFilterBindingDefPtr
Use the virNWFilterBindingDefPTr struct in the IP address learning code
directly.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
d1a7c08eb1 nwfilter: convert the gentech driver code to use virNWFilterBindingDefPtr
Use the virNWFilterBindingDefPtr struct in the gentech driver code
directly.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
278659fff6 virsh: add nwfilter binding commands
$ virsh nwfilter-binding-list
 Port Dev                              Filter
------------------------------------------------------------------
 vnet0                 clean-traffic
 vnet1                 clean-traffic

$ virsh nwfilter-binding-dumpxml vnet1
<filterbinding>
  <owner>
    <name>f25arm7</name>
    <uuid>12ac8b8c-4f23-4248-ae42-fdcd50c400fd</uuid>
  </owner>
  <portdev name='vnet1'/>
  <mac address='52:54:00:9d:81:b1'/>
  <filterref filter='clean-traffic'>
    <parameter name='MAC' value='52:54:00:9d:81:b1'/>
  </filterref>
</filterbinding>

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
ede0924eb4 remote: add support for nwfilter binding objects
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
099812f59d access: add nwfilter binding object permissions
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
b57a9aecaf nwfilter: export port binding concept in the public API
When the daemons are split there will need to be a way for the virt
drivers and/or network driver to create and delete bindings between
network ports and network filters. This defines a set of public APIs
that are suitable for managing this facility.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
41d619e99c schemas: add schema for nwfilter binding XML document
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
17b1ebf4ec conf: add support for parsing/formatting virNWFilterBindingDefPtr
A typical XML representation of the virNWFilterBindingDefPtr struct
looks like this:

  <filterbinding>
    <owner>
      <name>f25arm7</name>
      <uuid>12ac8b8c-4f23-4248-ae42-fdcd50c400fd</uuid>
    </owner>
    <portdev name='vnet1'/>
    <mac address='52:54:00:9d:81:b1'/>
    <filterref filter='clean-traffic'>
      <parameter name='MAC' value='52:54:00:9d:81:b1'/>
    </filterref>
  </filterbinding>

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
7c7880dd98 conf: move virNWFilterBindingDefPtr into its own files
There's no code sharing between virNWFilterDef and
virNWFilterBindingDefPtr types, so it is clearer if they live in
separate source files and headers.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
ce376228e9 conf: add missing virxml.h include for nwfilter_params.h
The nwfilter_params.h header references the xmlNodePtr type, so must
include the virxml.h header to get the libxml2 types defined.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
ce1144960c conf: change virNWFilterBindingPtr to virNWFilterBindingDefPtr
We are going to want to expose the NWFilter binding concept in the
public API, so the virNWFilterBindingPtr type needs to be used there.
Our internal type will shortly gain an XML representation, so rename
it to virNWFilterBindingDefPtr which follows our normal conventions.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Andrea Bolognani
aa51063927 spec: Move SASL configuration file from -libs to -daemon
SASL authentication is configured server-side, so the sample
configuration file should be shipped along with the daemon
rather than with the libraries.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:57:54 +02:00
Andrea Bolognani
b8736ed87e news: Update for HPT maxpagesize feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:58 +02:00
Andrea Bolognani
a12e7a3944 qemu: Format HPT maxpagesize on the command line
This makes the feature fully functional.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:56 +02:00
Andrea Bolognani
0ee6f885e0 conf: Parse and format HPT maxpagesize
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:52 +02:00
Andrea Bolognani
15f9db5303 conf: Tweak HPT feature parsing and formatting
This doesn't seem very useful at the moment, but it will make
sense once we introduce another HPT-related setting.

The output XML is decoupled from the input XML in preparation
of future changes as well; while doing so, we can shave a few
lines off the latter.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:50 +02:00
Andrea Bolognani
c2fef631ba conf: Reintroduce virDomainDef::hpt_resizing
We're going to introduce a second HPT-related setting soon,
at which point using a single location to store everything is
no longer going to cut it.

This mostly, but not completely, reverts 3dd1eb3b26.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:47 +02:00
Andrea Bolognani
90e6e0fae8 qemu: Add capability for the HPT maxpagesize feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:44 +02:00
Andrea Bolognani
0a527017c4 tests: Add replies for QEMU 3.0.0 on ppc64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:36 +02:00
Julio Faracco
794b576c2b util: fix mount issue by moving NULL value to "none" in syscall.
After running libvirt daemon with valgrind tools, some errors are
appearing when you try to start a domain. One example:

==18012== Syscall param mount(type) points to unaddressable byte(s)
==18012==    at 0x6FEE3CA: mount (syscall-template.S:78)
==18012==    by 0x531344D: virFileMoveMount (virfile.c:3828)
==18012==    by 0x27FE7675: qemuDomainBuildNamespace (qemu_domain.c:11501)
==18012==    by 0x2800C44E: qemuProcessHook (qemu_process.c:2870)
==18012==    by 0x52F7E1D: virExec (vircommand.c:726)
==18012==    by 0x52F7E1D: virCommandRunAsync (vircommand.c:2477)
==18012==    by 0x52F4EDD: virCommandRun (vircommand.c:2309)
==18012==    by 0x2800A731: qemuProcessLaunch (qemu_process.c:6235)
==18012==    by 0x2800D6B4: qemuProcessStart (qemu_process.c:6569)
==18012==    by 0x28074876: qemuDomainObjStart (qemu_driver.c:7314)
==18012==    by 0x280522EB: qemuDomainCreateWithFlags (qemu_driver.c:7367)
==18012==    by 0x55484BF: virDomainCreate (libvirt-domain.c:6531)
==18012==    by 0x12CDBD: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4350)
==18012==    by 0x12CDBD: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4326)
==18012==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Some documentation recommends to use "none" when you don't have a
filesystem type to use. Specially, for bind and move actions.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2018-06-26 08:05:57 +02:00
Eric Blake
0ec6343a06 snapshots: Clarify comments on snapshot role
Give some more details on what a snapshot is good for, to make
it easier to distinguish from the role of upcoming additions for
incremental backups.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-25 20:22:28 -05:00
Han Han
f78b73e68e docs: schema: Add missing <interleave> to devices
For input,hub,redirdev devices, their sub-elements should be interleaved.

input device: interleave for <driver>, <alias>, <address>
hub device: interleave for <alias>, <address>
redirdev device: interleave for <source>, <alias>, <address>, <boot>

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-25 20:03:34 +02:00
w00251574
a03f5cddfc qemu: Fix memory leak in qemuDomainBlockJobSetSpeed()
fix 'device' leak in qemuDomainBlockJobSetSpeed

Signed-off-by: Jie Wang <wangjie88.huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-25 19:46:20 +02:00
w00251574
d63f1c6ad9 qemu: monitor: Fix memory leak in qemuMonitorJSONNBDServerStart()
Exiting early through the return path did result in 'port_str'
being leaked.

Signed-off-by: Jie Wang <wangjie88.huawei.com>
2018-06-25 19:41:40 +02:00
Daniel P. Berrangé
b0c6300fc4 qemu: ensure FDs passed to QEMU for chardevs have correct SELinux labels
The UNIX socket FDs were we passing to QEMU inherited a label based on
libvirtd's context. QEMU is thus denied ability to access the UNIX
socket. We need to use the security manager to change our current
context temporarily when creating the UNIX socket FD.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-25 17:28:38 +01:00
Kashyap Chamarthy
a2913aed53 docs: formatdomain: Mention that 'urandom' is the recommended RNG backend
Since libvirt 1.3.4, any RNG source is accepted for the 'random'
backend.  However, '/dev/urandom' is the _recommended_ source of
entropy. Therefore we should mention that in the docs.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-25 12:20:39 +02:00
Michal Privoznik
a0d6894af1 qemuDomainObjBeginJobInternal: Log agent job too
If a thread is unable to start a job (e.g. because of timeout)
a warning is printed into the logs. So far, the message does not
contain agent job info. Add it as it might help future debugging.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-06-25 07:28:53 +02:00
Michal Privoznik
be108d934e news: Document recent agent job change
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-25 07:20:12 +02:00
Michal Privoznik
95cd4904e1 virDomainSnapshotDefParse: Prefer VIR_STEAL_PTR
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-25 07:19:53 +02:00
Weilun Zhu
f92d164c13 qemu: fix msg could be a wild pointer in qemuMonitorIOProcess()
As qemuMonitorJSONIOProcess will call qemuMonitorJSONIOProcessEvent
which unlocks the monitor mutex, there is some extreme situation,
eg qemu send message to monitor twice in a short time, where the
local viriable 'msg' of qemuMonitorIOProcess could be a wild point:

1. qemuMonitorSend() assign mon->msg to parameter 'msg', which is alse a
local variable of its caller qemuMonitorJSONCommandWithFd(), cause
eventloop to send message to monitor, then wait condition.
2. qemu send message to monitor for the first time immediately.
3. qemuMonitorIOProcess() is called, then wake up the qemuMonitorSend()
thread, but the qemuMonitorSend() thread stuck for a while as cpu pressure
or some other reasons, which means the qemu monitor is still unlocked.
4. qemu send event message to monitor for the second time,
such as RTC_CHANGE event
5. qemuMonitorIOProcess() is called again, the local viriable 'msg' is
assigned to mon->msg.
6. qemuMonitorIOProcess() call qemuMonitorJSONIOProcess() to deal with
the qemu event.
7. qemuMonitorJSONIOProcess() unlock the qemu monitor in the macro
'QEMU_MONITOR_CALLBACK', then qemuMonitorSend() thread get the mutex
and free the mon->msg, assign mon->msg to NULL.

Signed-off-by: Weilun Zhu <zhuweilun@huawei.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-06-22 10:40:59 +02:00
Pino Toscano
c92b6023e8 vmx: allow an odd number of vCPUs
Most probably this was a limitation in older ESX versions, and it seems
it does not exist anymore in more recent versions; see the following
thread:
https://www.redhat.com/archives/libvir-list/2018-May/msg02159.html
https://www.redhat.com/archives/libvir-list/2018-June/msg00043.html

Hence, allow an odd number (greater than 1) of vCPUs, since most
probably older versions of ESXi will error out anyway.

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

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-06-22 10:37:24 +02:00
Anya Harter
1136fd4ebe qemu: Escape commas for qemuBuildDiskThrottling
Add comma escaping for disk->blkdeviotune.group_name.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-21 17:49:15 -04:00
Chen Hanxiao
fd51ab5f11 news: add cmdDomblkinfo --all option
Update news for cmdDomblkinfo --all option.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-21 17:39:25 -04:00
Chen Hanxiao
62c3919328 cmdDomblkinfo: add --all to show all block devices info
This patch introduces --all to show all block devices info
of guests like:

virsh # domblkinfo w08 --all
Target     Capacity        Allocation      Physical
---------------------------------------------------
hda        42949672960     9878110208      9878110208
vda        10737418240     10736439296     10737418240

Target     Capacity        Allocation      Physical
---------------------------------------------------
hda        40.000 GiB      9.200 GiB       9.200 GiB
vda        10.000 GiB      9.999 GiB       10.000 GiB

For inactive domains using networked storage, a "-" will
be printed instead of the value since it's not possible
to determine the value without the storage connection.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-21 17:39:22 -04:00
Chen Hanxiao
4afcaa8843 cmdDomblkinfo: introduce helper cmdDomblkinfoPrint
Introduce helper cmdDomblkinfoPrint for printing.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-21 17:39:19 -04:00
Laine Stump
17b4734288 schema: allow a <rule> element with no subelements in a nwfilter
This is a regression in behavior caused by commit 37359814. It was
intended to limit the schema to allow only a single subelement of
<rule>, but it is also acceptable for <rule> to have no subelement at
all.

To prevent the same error from reoccurring in the future, the
examples/xml/nwfilter directory was added to the list of nwfilter
schema test directories.

Resolves: https://bugzilla.redhat.com/1593549

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-21 04:04:49 -04:00
Laine Stump
205462b60b hyperv: erase "generated files" sentinel during make maintainer-clean
Re-generating of generated source files in the hyperv directory
depends on src/.hyperv_wmi_generator.stamp not existing, or having a
timestamp older than src/hyperv/hyperv_wmi_generator.py. "make
maintainer-clean" erases the generated files, but not this sentinel
file, so the erased files aren't regenerated during the next
make. Once we add it to the list of MAINTAINERCLEANFILES, it gets
deleted at the same time as the generated files, so make is able to
understand they need regeneration.

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-21 04:04:13 -04:00
Laine Stump
34dc7f4b83 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>
2018-06-21 04:03:14 -04:00
John Ferlan
0c4408c832 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>
2018-06-20 18:43:09 -04:00
John Ferlan
e5d7064be0 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>
2018-06-20 18:42:49 -04:00
John Ferlan
3d94e45820 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>
2018-06-20 18:42:44 -04:00
John Ferlan
7a32752ead 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>
2018-06-20 18:42:40 -04:00
John Ferlan
eb3f6e5634 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>
2018-06-20 18:42:23 -04:00
Cole Robinson
279d6d1c70 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>
2018-06-20 14:26:37 -04:00
Cole Robinson
14781dcde6 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>
2018-06-20 14:26:21 -04:00
Cole Robinson
131ca8f4ff qemu_command: remove unused LegacyNicStr arg 'prefix'
Hardcode the only string that's passed in

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-06-20 14:26:29 -04:00