]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoconf: Move/Rename createVport and deleteVport
John Ferlan [Wed, 15 Mar 2017 14:56:26 +0000 (10:56 -0400)]
conf: Move/Rename createVport and deleteVport

Move the bulk of createVport and rename to virNodeDeviceCreateVport.

Remove the deleteVport entirely and replace with virNodeDeviceDeleteVport

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Rename virFileWaitForDevices
John Ferlan [Mon, 20 Feb 2017 12:00:51 +0000 (07:00 -0500)]
util: Rename virFileWaitForDevices

The function is actually in virutil.c, but prototyped in virfile.h.
This patch fixes that by renaming the function to virWaitForDevices,
adding the prototype in virutil.h and libvirt_private.syms, and then
changing the callers to use the new name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Convert virStoragePoolSourceAdapter to virStorageAdapter
John Ferlan [Tue, 28 Feb 2017 12:38:12 +0000 (07:38 -0500)]
conf: Convert virStoragePoolSourceAdapter to virStorageAdapter

Move the virStoragePoolSourceAdapter from storage_conf.h and rename
to virStorageAdapter.

Continue with code realignment for brevity and flow.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Rework createVport and deleteVport
John Ferlan [Fri, 10 Mar 2017 16:43:11 +0000 (11:43 -0500)]
storage: Rework createVport and deleteVport

Rework the code to use the new FCHost specific adapter structures.

Also rework the parameters to only pass what's need and leave logic in
the caller for the adapter type and the need to call the helpers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Rework getAdapterName to use adapter specific typedefs
John Ferlan [Fri, 10 Mar 2017 16:28:35 +0000 (11:28 -0500)]
storage: Rework getAdapterName to use adapter specific typedefs

Use the FCHost and SCSIHost adapter specific typedefs

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rework storage_conf to use adapter specific typedefs
John Ferlan [Fri, 10 Mar 2017 18:03:38 +0000 (13:03 -0500)]
conf: Rework storage_conf to use adapter specific typedefs

Rework the helpers/APIs to use the FCHost and SCSIHost adapter types.
Continue to realign the code for shorter lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rework storage_adapter_conf to use adapter specific typedefs
John Ferlan [Fri, 10 Mar 2017 17:08:46 +0000 (12:08 -0500)]
conf: Rework storage_adapter_conf to use adapter specific typedefs

Rework the helpers/APIs to use the FCHost and SCSIHost adapter types.
Continue to realign the code for shorter lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Split up virStoragePoolSourceAdapter
John Ferlan [Fri, 10 Mar 2017 16:21:12 +0000 (11:21 -0500)]
conf: Split up virStoragePoolSourceAdapter

Create typedef'd substructures and rework typedef to utilize.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Extract SCSI adapter type processing into their own helpers
John Ferlan [Fri, 10 Mar 2017 14:29:57 +0000 (09:29 -0500)]
conf: Extract SCSI adapter type processing into their own helpers

Rather than have lots of ugly inline code, create helpers to try and
make things more readable. While creating the helpers realign the code
as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Extract FCHost adapter type processing into their own helpers
John Ferlan [Fri, 10 Mar 2017 14:05:09 +0000 (09:05 -0500)]
conf: Extract FCHost adapter type processing into their own helpers

Rather than have lots of ugly inline code, create helpers to try and
make things more readable. While creating the helpers realign the code
as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rename API's in storage_adapter_conf
John Ferlan [Fri, 10 Mar 2017 18:24:56 +0000 (13:24 -0500)]
conf: Rename API's in storage_adapter_conf

Rename the API's to remove the storage pool source pieces

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce storage_adapter_conf
John Ferlan [Fri, 10 Mar 2017 12:32:46 +0000 (07:32 -0500)]
conf: Introduce storage_adapter_conf

Move code from storage_conf into storage_adapter_conf

Pure code motion

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Rework parsing in virStoragePoolDefParseSourceAdapter
John Ferlan [Fri, 10 Mar 2017 13:18:48 +0000 (08:18 -0500)]
conf: Rework parsing in virStoragePoolDefParseSourceAdapter

Rather than use virXPathString, pass along an virXPathNode and alter
the parsing to use virXMLPropString.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Split out storage pool source adapter helpers
John Ferlan [Fri, 10 Mar 2017 12:06:22 +0000 (07:06 -0500)]
conf: Split out storage pool source adapter helpers

Split out the code that munges through the storage pool adapter into
helpers - it's about to be moved into it's own source file.

This is purely code motion at this point.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Add missing validate for fchost search fields
John Ferlan [Fri, 10 Mar 2017 15:04:20 +0000 (10:04 -0500)]
conf: Add missing validate for fchost search fields

Commit id 'bb74a7ffe' added some new fields to search for a fchost by
parent wwnn/wwpn or parent_fabric_name, but neglected to validate that
the data within the fields was valid at parse time. This could lead to
eventual failure at run time, so rather than have the failure then, let's
validate now.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Ensure both parent_wwnn/parent_wwpn provided
John Ferlan [Fri, 10 Mar 2017 15:29:32 +0000 (10:29 -0500)]
conf: Ensure both parent_wwnn/parent_wwpn provided

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

Commit id 'bb74a7ffe' neglected to check that both the parent_wwnn
parent_wwpn are in the XML if one or the other is similar to how
the node device code checked (commit id '2b13361bc').

If only one is provided, the "default" is to use a vHBA capable
adapter (see commit id '78be2e8b'), so the vHBA could start, but
perhaps not on the expected adapter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoSwitch to GSSAPI (kerberos) instead of the insecure DIGEST-MD5
Daniel P. Berrange [Mon, 13 Mar 2017 12:15:57 +0000 (12:15 +0000)]
Switch to GSSAPI (kerberos) instead of the insecure DIGEST-MD5

RFC 6331 documents a number of serious security weaknesses in
the SASL DIGEST-MD5 mechanism. As such, libvirtd should not
by using it as a default mechanism. GSSAPI is the only other
viable SASL mechanism that can provide secure session encryption
so enable that by defalt as the replacement.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: Namespaces for NVDIMM
Michal Privoznik [Wed, 22 Feb 2017 16:37:39 +0000 (17:37 +0100)]
qemu: Namespaces for NVDIMM

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Allow nvdimm in devices CGroups
Michal Privoznik [Wed, 22 Feb 2017 15:33:12 +0000 (16:33 +0100)]
qemu: Allow nvdimm in devices CGroups

Some users might want to pass a blockdev or a chardev as a
backend for NVDIMM. In fact, this is expected to be the mostly
used configuration. Therefore libvirt should allow the device in
devices CGroup then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_hotplug: Relabel memdev
Michal Privoznik [Thu, 4 Aug 2016 13:26:09 +0000 (15:26 +0200)]
qemu_hotplug: Relabel memdev

Now that we have APIs for relabel memdevs on hotplug, fill in the
missing implementation in qemu hotplug code.

The qemuSecurity wrappers might look like overkill for now,
because qemu namespace code does not deal with the nvdimms yet.
Nor does our cgroup code.  But hey, there's cgroup_device_acl
variable in qemu.conf. If users add their /dev/pmem* device in
there, the device is allowed in cgroups and created in the
namespace so they can successfully passthrough it to the domain.
It doesn't look like overkill after all, does it?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecdrivers: Implement memdev relabel APIs
Michal Privoznik [Thu, 4 Aug 2016 12:55:16 +0000 (14:55 +0200)]
secdrivers: Implement memdev relabel APIs

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurity: Introduce internal APIs for memdev labelling
Michal Privoznik [Thu, 4 Aug 2016 12:48:15 +0000 (14:48 +0200)]
security: Introduce internal APIs for memdev labelling

These APIs will be used whenever we are hot (un-)plugging a
memdev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurity_selinux: Label host side of NVDIMM
Michal Privoznik [Thu, 4 Aug 2016 12:04:38 +0000 (14:04 +0200)]
security_selinux: Label host side of NVDIMM

When domain is being started up, we ought to relabel the host
side of NVDIMM so qemu has access to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurity_dac: Label host side of NVDIMM
Michal Privoznik [Thu, 4 Aug 2016 10:01:38 +0000 (12:01 +0200)]
security_dac: Label host side of NVDIMM

When domain is being started up, we ought to relabel the host
side of NVDIMM so qemu has access to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Introduce label-size for NVDIMMs
Michal Privoznik [Mon, 27 Feb 2017 10:20:26 +0000 (11:20 +0100)]
qemu: Introduce label-size for NVDIMMs

For NVDIMM devices it is optionally possible to specify the size
of internal storage for namespaces. Namespaces are a feature that
allows users to partition the NVDIMM for different uses.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Implement @access for <memory/> banks
Michal Privoznik [Mon, 1 Aug 2016 13:49:35 +0000 (15:49 +0200)]
qemu: Implement @access for <memory/> banks

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconf: Introduce @access to <memory/>
Michal Privoznik [Mon, 1 Aug 2016 12:59:38 +0000 (14:59 +0200)]
conf: Introduce @access to <memory/>

Now that NVDIMM has found its way into libvirt, users might want
to fine tune some settings for each module separately. One such
setting is 'share=on|off' for the memory-backend-file object.
This setting - just like its name suggest already - enables
sharing the nvdimm module with other applications. Under the hood
it controls whether qemu mmaps() the file as MAP_PRIVATE or
MAP_SHARED.

Yet again, we have such config knob in domain XML, but it's just
an attribute to numa <cell/>. This does not give fine enough
tuning on per-memdevice basis so we need to have the attribute
for each device too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Implement NVDIMM
Michal Privoznik [Fri, 29 Jul 2016 09:02:25 +0000 (11:02 +0200)]
qemu: Implement NVDIMM

So, majority of the code is just ready as-is. Well, with one
slight change: differentiate between dimm and nvdimm in places
like device alias generation, generating the command line and so
on.

Speaking of the command line, we also need to append 'nvdimm=on'
to the '-machine' argument so that the nvdimm feature is
advertised in the ACPI tables properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Introduce QEMU_CAPS_DEVICE_NVDIMM
Michal Privoznik [Fri, 29 Jul 2016 06:17:42 +0000 (08:17 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_NVDIMM

Introduce a qemu capability for -device nvdimm.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoIntroduce NVDIMM memory model
Michal Privoznik [Thu, 28 Jul 2016 16:54:18 +0000 (18:54 +0200)]
Introduce NVDIMM memory model

NVDIMM is new type of memory introduced into QEMU 2.6. The idea
is that we have a Non-Volatile memory module that keeps the data
persistent across domain reboots.

At the domain XML level, we already have some representation of
'dimm' modules. Long story short, NVDIMM will utilize the
existing <memory/> element that lives under <devices/> by adding
a new attribute 'nvdimm' to the existing @model and introduce a
new <path/> element for <source/> while reusing other fields. The
resulting XML would appear as:

    <memory model='nvdimm'>
      <source>
        <path>/tmp/nvdimm</path>
      </source>
      <target>
        <size unit='KiB'>523264</size>
        <node>0</node>
      </target>
      <address type='dimm' slot='0'/>
    </memory>

So far, this is just a XML parser/formatter extension. QEMU
driver implementation is in the next commit.

For more info on NVDIMM visit the following web page:

    http://pmem.io/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Reorder args and update comment
Michal Privoznik [Thu, 16 Feb 2017 14:17:47 +0000 (15:17 +0100)]
qemuBuildMemoryBackendStr: Reorder args and update comment

Frankly, this function is one big mess. A lot of arguments,
complicated behaviour. It's really surprising that arguments were
in random order (input and output arguments were mixed together),
the documentation was outdated, the description of return values
was bogus.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Pass virDomainMemoryDefPtr
Michal Privoznik [Wed, 8 Mar 2017 15:56:23 +0000 (16:56 +0100)]
qemuBuildMemoryBackendStr: Pass virDomainMemoryDefPtr

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Check for @memAccess properly
Michal Privoznik [Wed, 8 Mar 2017 14:58:26 +0000 (15:58 +0100)]
qemuBuildMemoryBackendStr: Check for @memAccess properly

Even though this variable contains just values from an enum where
zero has the usual meaning, it's enum after all and we should
check it as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Don't overwrite @force
Michal Privoznik [Wed, 8 Mar 2017 14:56:36 +0000 (15:56 +0100)]
qemuBuildMemoryBackendStr: Don't overwrite @force

This is an input argument. We should not overwrite it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agobhyve: add config file support
Roman Bogorodskiy [Sat, 11 Mar 2017 16:19:03 +0000 (20:19 +0400)]
bhyve: add config file support

Introduce config file support for the bhyve driver. The only available
setting at present is 'firmware_dir' for specifying a directory with
UEFI firmware files.

8 years agodocs: Move 'timestamps' and 'encryption' sub-element description
Alexander Vasilenko [Sun, 12 Mar 2017 15:47:07 +0000 (18:47 +0300)]
docs: Move 'timestamps' and 'encryption' sub-element description

The description should be in the target for a volume not a pool.

8 years agocputest: New test for Intel Core i7-4510U
Jiri Denemark [Fri, 3 Mar 2017 15:29:16 +0000 (16:29 +0100)]
cputest: New test for Intel Core i7-4510U

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Report better host-model CPUs in domain caps
Jiri Denemark [Wed, 8 Mar 2017 12:32:46 +0000 (13:32 +0100)]
qemu: Report better host-model CPUs in domain caps

One of the main reasons for introducing host-model CPU definition in a
domain capabilities XML was the inability to express disabled features
in a host capabilities XML. That is, when a host CPU is, e.g., Haswell
without x2apic support, host capabilities XML will have to report it as
Westmere + a bunch of additional features., but we really want to use
Haswell - x2apic when creating a host-model CPU.

Unfortunately, I somehow forgot to do the last step and the code would
just copy the CPU definition found in the host capabilities XML. This
changed recently for new QEMU versions which allow us to query host CPU,
but any slightly older QEMU will not benefit from any change I did. This
patch makes sure the right CPU model is filled in the domain
capabilities even with old QEMU.

The issue was reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1426456

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Refactor virQEMUCapsInitCPU
Jiri Denemark [Tue, 7 Mar 2017 18:33:37 +0000 (19:33 +0100)]
qemu: Refactor virQEMUCapsInitCPU

The function is now called virQEMUCapsProbeHostCPU. Both the refactoring
and the change of the name is done for consistency with a new function
which will be introduced in the following commit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Add list of allowed CPU models to virCPUGetHost
Jiri Denemark [Tue, 7 Mar 2017 11:20:01 +0000 (12:20 +0100)]
cpu: Add list of allowed CPU models to virCPUGetHost

When creating host CPU definition usable with a given emulator, the CPU
should not be defined using an unsupported CPU model. The new @models
and @nmodels parameters can be used to limit CPU models which can be
used in the result.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Add virCPUType parameter to virCPUGetHost
Jiri Denemark [Tue, 7 Mar 2017 10:38:38 +0000 (11:38 +0100)]
cpu: Add virCPUType parameter to virCPUGetHost

The parameter can be used to request either VIR_CPU_TYPE_HOST (which has
been assumed so far) or VIR_CPU_TYPE_GUEST definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Replace cpuNodeData with virCPUGetHost
Jiri Denemark [Mon, 6 Mar 2017 20:35:49 +0000 (21:35 +0100)]
cpu: Replace cpuNodeData with virCPUGetHost

cpuNodeData has always been followed by cpuDecode as no hypervisor
driver is really interested in raw CPUID data for a host CPU. Let's
create a new CPU driver API which returns virCPUDefPtr directly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoDo not format <arch> in guest CPU XML
Jiri Denemark [Wed, 24 Jul 2013 08:15:38 +0000 (10:15 +0200)]
Do not format <arch> in guest CPU XML

This element is only allowed for host CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodocs: document virt-host-validate bhyve support
Roman Bogorodskiy [Sat, 11 Mar 2017 18:08:05 +0000 (22:08 +0400)]
docs: document virt-host-validate bhyve support

Add an entry about virt-host-validate bhyve support and
update the driver's page.

8 years agoqemuDomainBuildNamespace: Handle file mount points
Michal Privoznik [Fri, 10 Mar 2017 14:53:58 +0000 (15:53 +0100)]
qemuDomainBuildNamespace: Handle file mount points

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

Yeah, that's right. A mount point doesn't have to be a directory.
It can be a file too. However, the code that tries to preserve
mount points under /dev for new namespace for qemu does not count
with that option.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoEnable forgotten VIR_CONNECT_LIST_STORAGE_POOLS_* flags
Jiri Denemark [Mon, 13 Mar 2017 08:20:35 +0000 (09:20 +0100)]
Enable forgotten VIR_CONNECT_LIST_STORAGE_POOLS_* flags

VIR_CONNECT_LIST_STORAGE_POOLS_VSTORAGE and
VIR_CONNECT_LIST_STORAGE_POOLS_ZFS were added to libvirt but the listing
API was not properly updated to use them.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agobhyve: test cases for VNC
Roman Bogorodskiy [Sun, 12 Feb 2017 14:06:23 +0000 (18:06 +0400)]
bhyve: test cases for VNC

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
8 years agobhyve: add video support
Fabian Freyer [Sat, 16 Jul 2016 21:03:33 +0000 (21:03 +0000)]
bhyve: add video support

bhyve supports 'gop' video device that allows clients to connect
to VMs using VNC clients. This commit adds support for that to
the bhyve driver:

 - Introducr 'gop' video device type
 - Add capabilities probing for the 'fbuf' device that's
   responsible for graphics
 - Update command builder routines to let users configure
   domain's VNC via gop graphics.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
8 years agobhyve: enumerate UEFI firmwares
Fabian Freyer [Fri, 8 Jul 2016 17:51:12 +0000 (17:51 +0000)]
bhyve: enumerate UEFI firmwares

Extend domain capabilities XML with the information about
available UEFI firmware files. It searches in the location
that the sysutils/bhyve-firmware FreeBSD port installs
files to.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
8 years agobhyve: test cases for UEFI bhyvexml2argvtest
Fabian Freyer [Thu, 30 Jun 2016 03:00:04 +0000 (03:00 +0000)]
bhyve: test cases for UEFI bhyvexml2argvtest

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
8 years agobhyve: add support for booting from UEFI
Fabian Freyer [Thu, 30 Jun 2016 02:29:15 +0000 (02:29 +0000)]
bhyve: add support for booting from UEFI

Allow to boot using UEFI rather than using an external boot loader
such as bhyveload or grub-bhyve.

Also, make LPC PCI-ISA bridge handling more flexible as now it's
needed not only for serial ports, but for bootrom as well.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
8 years agobhyve: virBhyveProbeCaps: BHYVE_CAP_LPC_BOOTROM
Fabian Freyer [Tue, 24 May 2016 13:30:56 +0000 (15:30 +0200)]
bhyve: virBhyveProbeCaps: BHYVE_CAP_LPC_BOOTROM

Implement the BHACE_CAP_LPC_BOOTROM capability by checking the stderr
output of 'bhyve -l bootrom'. If the bootrom option is unsupported, this
will contain the following output:

    bhyve: invalid lpc device configuration 'bootrom'

On newer bhyve versions that do support specifying a bootrom image, the
standard help will be printed.

8 years agovirt-host-validate: add bhyve support
Roman Bogorodskiy [Fri, 24 Feb 2017 16:27:56 +0000 (20:27 +0400)]
virt-host-validate: add bhyve support

Add bhyve support to virt-host-validate(1). It checks for the
essential kernel modules to be available so that user can actually
start VMs, have networking and console access.

It uses the kldnext(2)/kldstat(2) routines to retrieve modules list.
As bhyve is only available on FreeBSD and these routines were available
long before bhyve appeared, not adding any specific configure checks
for that.

Also, update tools/Makefile.am to add
virt-host-validate-$driver.[hc] to the build only if the
appropriate driver is enabled.

8 years agotests: Add createVHBAByStoragePool-by-parent to fchosttest
John Ferlan [Sun, 29 Jan 2017 16:12:48 +0000 (11:12 -0500)]
tests: Add createVHBAByStoragePool-by-parent to fchosttest

Add a new test to fchosttest in order to test creation of our vHBA
via the Storage Pool logic.  Unlike the real code, we cannot yet use
the virVHBA* API's because they (currently) traverse the file system
in order to get the parent vport capable scsi_host. Besides there's
no "real" NPIV device here - so we have to take some liberties, at
least for now.

Instead, we'll follow the node device tests partially in order to
create and destroy the vHBA with the test node devices.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemuProcessHandleMonitorEOF: Disable namespace for domain
Michal Privoznik [Fri, 10 Mar 2017 12:34:15 +0000 (13:34 +0100)]
qemuProcessHandleMonitorEOF: Disable namespace for domain

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

If a qemu process has died, we get EOF on its monitor. At this
point, since qemu process was the only one running in the
namespace kernel has already cleaned the namespace up. Any
attempt of ours to enter it has to fail.

This really happened in the bug linked above. We've tried to
attach a disk to qemu and while we were in the monitor talking to
qemu it just died. Therefore our code tried to do some roll back
(e.g. deny the device in cgroups again, restore labels, etc.).
However, during the roll back (esp. when restoring labels) we
still thought that domain has a namespace. So we used secdriver's
transactions. This failed as there is no namespace to enter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoDocument preferred naming conventions
Daniel P. Berrange [Fri, 3 Mar 2017 09:46:16 +0000 (09:46 +0000)]
Document preferred naming conventions

This documents the preferred conventions for naming files,
structs, enums, typedefs and functions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemuxml2argvtest: Don't overwrite driver stateDir
Michal Privoznik [Fri, 10 Mar 2017 08:55:43 +0000 (09:55 +0100)]
qemuxml2argvtest: Don't overwrite driver stateDir

This is a very historic artefact. Back in the old days of
830ba76c3e when we had macros to add arguments onto qemu command
line (!) we thought it was a good idea to let qemu write out the
PID file. So we passed -pidfile $stateDir/$domName onto the
command line. Thus, in order for tests to work we needed stable
stateDir in the qemu driver. Unfortunately, after 16efa11aa696
where stateDir is mkdtemp()-d, this approach lead to a leak of
temp dir.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: hotplug: Reset device removal waiting code after vCPU unplug
Peter Krempa [Fri, 3 Mar 2017 15:04:57 +0000 (16:04 +0100)]
qemu: hotplug: Reset device removal waiting code after vCPU unplug

If the delivery of the DEVICE_DELETED event for the vCPU being deleted
would time out, the code would not call 'qemuDomainResetDeviceRemoval'.

Since the waiting thread did not unregister itself prior to stopping the
waiting the monitor code would try to wake it up instead of dispatching
it to the event worker. As a result the unplug process would not be
completed and the definition would not be updated.

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

8 years agoqemu: hotplug: Add debug log when dispatching device removal to existing thread
Peter Krempa [Fri, 3 Mar 2017 15:02:01 +0000 (16:02 +0100)]
qemu: hotplug: Add debug log when dispatching device removal to existing thread

Note that the waiting thread is signaled in the debug logs to simplify
debugging.

8 years agoRevert "conf: move iothread XML validation from qemu_command"
Pavel Hrdina [Thu, 9 Mar 2017 13:55:44 +0000 (14:55 +0100)]
Revert "conf: move iothread XML validation from qemu_command"

This reverts commit c96bd78e4e71c799dc391566fa9f0652dec55dca.

So our code is one big mess and we modify domain definition while
building qemu_command line and our hotplug code share only part
of the parsing and command line building code.  Let's revert
that change because to fix it properly would require refactor and
move a lot of things.

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

8 years agoconfigure: disable scsi stroage driver on non-Linux
Roman Bogorodskiy [Sun, 5 Mar 2017 14:17:22 +0000 (18:17 +0400)]
configure: disable scsi stroage driver on non-Linux

Even though scsi storage driver builds fine on non-Linux, it
will not work properly because it relies on Linux procfs, so
disable that in configure if we're not building for Linux.

8 years agoconf: properly skip graphics listen element in migratable XML
Pavel Hrdina [Mon, 27 Feb 2017 16:16:17 +0000 (17:16 +0100)]
conf: properly skip graphics listen element in migratable XML

We should skip <listen type='socket'/> only if the 'socket' path
is specified because if there is no 'socket' path we need to
keep that element in migratable XML.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: store "autoGenerated" for graphics listen in status XML
Pavel Hrdina [Mon, 27 Feb 2017 16:00:15 +0000 (17:00 +0100)]
conf: store "autoGenerated" for graphics listen in status XML

When libvirtd is started we call qemuDomainRecheckInternalPaths
to detect whether a domain has VNC socket path generated by libvirt
based on option from qemu.conf.  However if we are parsing status XML
for running domain the existing socket path can be generated also if
the config XML uses the new <listen type='socket'/> element without
specifying any socket.

The current code doesn't make difference how the socket was generated
and always marks it as "fromConfig".  We need to store the
"autoGenerated" value in the status XML in order to preserve that
information.

The difference between "fromConfig" and "autoGenerated" is important
for migration, because if the socket is based on "fromConfig" we don't
print it into the migratable XML and we assume that user has properly
configured qemu.conf on both hosts.  However if the socket is based
on "autoGenerated" it means that a new feature was used and therefore
we need to leave the socket in migratable XML to make sure that if
this feature is not supported on destination the migration will fail.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: Rename variable
John Ferlan [Wed, 8 Mar 2017 19:37:05 +0000 (14:37 -0500)]
qemu: Rename variable

Rename 'secretUsageType' to 'usageType' since it's superfluous in an
API qemu*Secret*

8 years agoqemu: Introduce qemuDomainGetTLSObjects
John Ferlan [Fri, 17 Feb 2017 15:06:14 +0000 (10:06 -0500)]
qemu: Introduce qemuDomainGetTLSObjects

Split apart and rename qemuDomainGetChardevTLSObjects in order to make a
more generic API that can create the TLS JSON prop objects (secret and
tls-creds-x509) to be used to create the objects

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Move qemuDomainPrepareChardevSourceTLS call
John Ferlan [Fri, 17 Feb 2017 14:46:16 +0000 (09:46 -0500)]
qemu: Move qemuDomainPrepareChardevSourceTLS call

Move the call to inside the qemuDomainAddChardevTLSObjects in order to
further converge the code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Move qemuDomainSecretChardevPrepare call
John Ferlan [Fri, 17 Feb 2017 14:37:34 +0000 (09:37 -0500)]
qemu: Move qemuDomainSecretChardevPrepare call

Move the call to inside the qemuDomainAddChardevTLSObjects in order to
further converge the code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Refactor qemuDomainGetChardevTLSObjects to converge code
John Ferlan [Wed, 22 Feb 2017 17:54:10 +0000 (12:54 -0500)]
qemu: Refactor qemuDomainGetChardevTLSObjects to converge code

Create a qemuDomainAddChardevTLSObjects which will encapsulate the
qemuDomainGetChardevTLSObjects and qemuDomainAddTLSObjects so that
the callers don't need to worry about the props.

Move the dev->type and haveTLS checks in to the Add function to avoid
an unnecessary call to qemuDomainAddTLSObjects

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Refactor hotplug to introduce qemuDomain{Add|Del}TLSObjects
John Ferlan [Thu, 16 Feb 2017 15:33:35 +0000 (10:33 -0500)]
qemu: Refactor hotplug to introduce qemuDomain{Add|Del}TLSObjects

Refactor the TLS object adding code to make two separate API's that will
handle the add/remove of the "secret" and "tls-creds-x509" objects including
the Enter/Exit monitor commands.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Move exit monitor calls in failure paths
John Ferlan [Wed, 22 Feb 2017 17:39:17 +0000 (12:39 -0500)]
qemu: Move exit monitor calls in failure paths

Since qemuDomainObjExitMonitor can also generate error messages,
let's move it inside any error message saving code on error paths
for various hotplug add activities.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Introduce qemuDomainSecretInfoTLSNew
John Ferlan [Wed, 1 Mar 2017 19:14:40 +0000 (14:14 -0500)]
qemu: Introduce qemuDomainSecretInfoTLSNew

Building upon the qemuDomainSecretInfoNew, create a helper which will
build the secret used for TLS.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Introduce qemuDomainSecretInfoNew
John Ferlan [Mon, 20 Feb 2017 20:04:58 +0000 (15:04 -0500)]
qemu: Introduce qemuDomainSecretInfoNew

Create a helper which will create the secinfo used for disks, hostdevs,
and chardevs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests: Add storagevol tests for format=iso
Cole Robinson [Tue, 7 Mar 2017 15:50:59 +0000 (10:50 -0500)]
tests: Add storagevol tests for format=iso

Demonstrates the bug fix in commit 0e5db762627

8 years agodoc: fix writing of QEMU
Philipp Hahn [Tue, 7 Mar 2017 17:09:58 +0000 (18:09 +0100)]
doc: fix writing of QEMU

QEMU should be written all upper or all lower case.

8 years agodoc: Correct the default werror policy
Philipp Hahn [Wed, 1 Mar 2017 19:44:54 +0000 (20:44 +0100)]
doc: Correct the default werror policy

It's only implemented by QEMU and its default is
VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE anyway.

Signed-off-by: Philipp Hahn <hahn@univention.de>
8 years agoqemu_process: don't probe iothreads if it's not supported by QEMU
Pavel Hrdina [Wed, 8 Mar 2017 09:45:10 +0000 (10:45 +0100)]
qemu_process: don't probe iothreads if it's not supported by QEMU

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemuTestDriverInit: Don't access live data
Michal Privoznik [Mon, 6 Mar 2017 07:27:23 +0000 (08:27 +0100)]
qemuTestDriverInit: Don't access live data

Some of our tests (e.g. qemuhotplugtest) call
virDomainSaveConfig(). Now the problem is, qemuTestDriverInit()
creates a fake qemu driver and fills it with some fake
configuration. At least so we hoped. The truth is, it calls
regular virQEMUDriverConfigNew() and then fix couple of paths.
Literally. Therefore our tests see regular stateDir and configDir
for the user that is running the tests. Directories, where live
domain XMLs are stored. Let's just hope our test suite hasn't
mangled any of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainSaveImageUpdateDef: Don't overwrite errors from virDomainDefCheckABIStability
Michal Privoznik [Fri, 3 Mar 2017 09:45:31 +0000 (10:45 +0100)]
qemuDomainSaveImageUpdateDef: Don't overwrite errors from virDomainDefCheckABIStability

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

When we are restoring a domain from a saved image, or just
updating its XML in the saved image - we have to make sure that
the ABI guests sees will not change. We have a function for that
which reports errors. But for some reason if this function fails,
we call it again with slightly different argument. Therefore it
might happen that we overwrite the original error and leave user
with less helpful one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonews: Update the news.xml about perf events added
Nitesh Konkar [Thu, 23 Feb 2017 14:55:39 +0000 (20:25 +0530)]
news: Update the news.xml about perf events added

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add emulation_faults software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:38 +0000 (20:25 +0530)]
perf: add emulation_faults software perf event support

This patch adds support and documentation
for the emulation_faults perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add alignment_faults software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:37 +0000 (20:25 +0530)]
perf: add alignment_faults software perf event support

This patch adds support and documentation
for the alignment_faults perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add page_faults_maj software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:36 +0000 (20:25 +0530)]
perf: add page_faults_maj software perf event support

This patch adds support and documentation
for the page_faults_maj perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add page_faults_min software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:35 +0000 (20:25 +0530)]
perf: add page_faults_min software perf event support

This patch adds support and documentation
for the page_faults_min perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add cpu_migrations software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:34 +0000 (20:25 +0530)]
perf: add cpu_migrations software perf event support

This patch adds support and documentation
for the cpu_migrations perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add context_switches software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:33 +0000 (20:25 +0530)]
perf: add context_switches software perf event support

This patch adds support and documentation
for the context_switches perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add page_faults software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:32 +0000 (20:25 +0530)]
perf: add page_faults software perf event support

This patch adds support and documentation
for the page_faults perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add task_clock software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:31 +0000 (20:25 +0530)]
perf: add task_clock software perf event support

This patch adds support and documentation for
the task_clock perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoperf: add cpu_clock software perf event support
Nitesh Konkar [Thu, 23 Feb 2017 14:55:30 +0000 (20:25 +0530)]
perf: add cpu_clock software perf event support

This patch adds support and documentation for
the cpu_clock perf event.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoconf: Use consistent function name prefixes for virnwfilterobj
John Ferlan [Thu, 2 Mar 2017 18:18:32 +0000 (13:18 -0500)]
conf: Use consistent function name prefixes for virnwfilterobj

Use "virNWFilterObj" as a prefix for any external API in virnwfilterobj

8 years agoconf: Alter coding style of nwfilter function prototypes
John Ferlan [Thu, 2 Mar 2017 17:58:41 +0000 (12:58 -0500)]
conf: Alter coding style of nwfilter function prototypes

In an effort to be consistent with the source module, alter the function
prototypes to follow the similar style of source with the "type" on one
line followed by the function name and arguments on subsequent lines with
with argument getting it's own line.

8 years agoconf: Adjust coding style for nwfilter conf sources
John Ferlan [Thu, 2 Mar 2017 17:13:02 +0000 (12:13 -0500)]
conf: Adjust coding style for nwfilter conf sources

Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.

8 years agoconf: Introduce virnwfilterobj
John Ferlan [Tue, 28 Feb 2017 22:37:15 +0000 (17:37 -0500)]
conf: Introduce virnwfilterobj

Move all the NWFilterObj API's into their own module virnwfilterobj
from the nwfilter_conf

Purely code motion at this point, plus adjustments to cleanly build.

8 years agoconf: Change virNWFilterObjDeleteDef to virNWFilterDeleteDef
John Ferlan [Tue, 28 Feb 2017 22:25:36 +0000 (17:25 -0500)]
conf: Change virNWFilterObjDeleteDef to virNWFilterDeleteDef

Rather than pass the nwfilter object, just pass the def to the function

8 years agoconf: Change virNWFilterObjSaveDef to virNWFilterSaveDef
John Ferlan [Tue, 28 Feb 2017 22:12:09 +0000 (17:12 -0500)]
conf: Change virNWFilterObjSaveDef to virNWFilterSaveDef

There's no need to pass the driver pointer to nwfilter_conf, just
pass the configDir.

8 years agoutil: Avoid possible NULL dereference in virSysinfoParsePPCProcessor
John Ferlan [Tue, 7 Mar 2017 12:01:21 +0000 (07:01 -0500)]
util: Avoid possible NULL dereference in virSysinfoParsePPCProcessor

Found by Coverity. Because there's an "if ((cur = strstr(base, "revision"))
 != NULL) {" followed by a "base = cur" coverity notes that 'base' could
then be NULL causing the return to the top of the "while ((tmp_base =
strstr(base, "processor")) != NULL) {" to have strstr deref a NULL 'base'
pointer because the setting of base at the bottom of the loop is unconditional.

Alter the code to set "base = cur" after processing each key. That will
"ensure" that base doesn't get set to NULL if both "cpu" and "revision"
do no follow a "processor".

While a /proc/cpuinfo file that has a "processor" key but with neither
a "cpu" nor a "revision" doesn't seem feasible, the code is written as if
it could happen, so we have to account for it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Resource some resource leaks in virsysinfo code
John Ferlan [Tue, 7 Mar 2017 11:33:38 +0000 (06:33 -0500)]
util: Resource some resource leaks in virsysinfo code

Calls to virFileReadAll after a VIR_ALLOC that return NULL all show
a memory leak since 'ret' isn't virSysinfoDefFree'd and normal path
"return ret" doesn't free outbuf.

Reported by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agolibvirt: document UNDEFINE_KEEP_NVRAM in UndefineFlags docs
Cole Robinson [Mon, 6 Mar 2017 22:54:40 +0000 (17:54 -0500)]
libvirt: document UNDEFINE_KEEP_NVRAM in UndefineFlags docs

8 years agostorage: Don't pass 'iso' format to qemu-img
Cole Robinson [Mon, 6 Mar 2017 21:50:53 +0000 (16:50 -0500)]
storage: Don't pass 'iso' format to qemu-img

$ virsh vol-clone /tmp/test.iso new.iso
error: Failed to clone vol from test.iso
error: internal error: Child process (/bin/qemu-img convert -f iso -O iso /tmp/test.iso /tmp/new.iso) unexpected exit status 1: qemu-img: Could not open '/tmp/test.iso': Unknown driver 'iso'

Map iso->raw before sending the format value to qemu-img

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

8 years agoqemu_domain: cleanup the controller post parse code
Pavel Hrdina [Wed, 1 Mar 2017 18:41:56 +0000 (19:41 +0100)]
qemu_domain: cleanup the controller post parse code

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_domain: move controller post parse code into its own function
Pavel Hrdina [Wed, 1 Mar 2017 18:31:19 +0000 (19:31 +0100)]
qemu_domain: move controller post parse code into its own function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>