]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agolxc: handle missing switch enum cases
Daniel P. Berrangé [Wed, 14 Feb 2018 09:43:59 +0000 (09:43 +0000)]
lxc: handle missing switch enum cases

Ensure all enum cases are listed in switch statements, or cast away
enum type in places where we don't wish to cover all cases.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agolibxl: handle missing switch enum cases
Daniel P. Berrangé [Wed, 14 Feb 2018 09:43:59 +0000 (09:43 +0000)]
libxl: handle missing switch enum cases

Cast away enum type for libxl scheduler constants since we don't want to
cover all of them and don't want build to break when new ones are added.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agohyperv: handle missing switch enum cases
Daniel P. Berrangé [Wed, 14 Feb 2018 09:43:59 +0000 (09:43 +0000)]
hyperv: handle missing switch enum cases

Ensure all enum cases are listed in switch statements. This improves
debug logging integration with openwsman.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoesx: handle missing switch enum cases
Daniel P. Berrangé [Wed, 14 Feb 2018 09:43:59 +0000 (09:43 +0000)]
esx: handle missing switch enum cases

Ensure all enum cases are listed in switch statements, or explicitly
cast away enum type where we don't want to list all cases.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: handle missing switch enum cases
Daniel P. Berrangé [Wed, 14 Feb 2018 09:43:59 +0000 (09:43 +0000)]
conf: handle missing switch enum cases

Ensure all enum cases are listed in switch statements.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoutil: handle missing switch enum cases
Daniel P. Berrangé [Wed, 14 Feb 2018 09:43:59 +0000 (09:43 +0000)]
util: handle missing switch enum cases

Ensure all enum cases are listed in switch statements.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoutil: add a virReportEnumRangeError for bad value reporting
Daniel P. Berrangé [Tue, 20 Feb 2018 15:56:52 +0000 (15:56 +0000)]
util: add a virReportEnumRangeError for bad value reporting

To ensure we have standardized error messages when reporting problems
with enum values being out of a range, add virReportEnumRangeError().

   virReportEnumRangeError(virDomainState, 34);

results in a message

   "internal error: Unexpected enum value 34 for virDomainState"

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agosrc: remove WITH_LIBVIRTD condition around hal/udev build
Daniel P. Berrangé [Wed, 21 Feb 2018 15:21:03 +0000 (15:21 +0000)]
src: remove WITH_LIBVIRTD condition around hal/udev build

Currently building --without-libvirtd causes a failure to link the node
device driver:

node_device/.libs/libvirt_driver_nodedev_la-node_device_driver.o: In function `nodedevRegister':
/home/berrange/src/virt/libvirt/src/node_device/node_device_driver.c:649: undefined reference to `udevNodeRegister'
collect2: error: ld returned 1 exit status

because it causes us to build the core nodedev driver, but then skip the
implementations, despite udev being available.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonwfilter: assure virNWFilterSnoop(Eth|Dhcp)Hdr structs don't change size
Laine Stump [Mon, 19 Feb 2018 17:56:11 +0000 (12:56 -0500)]
nwfilter: assure virNWFilterSnoop(Eth|Dhcp)Hdr structs don't change size

These two objects are used to access fields in actual ethernet packets
captures with libpcap, so it's essential that they don't change size
for any reason. This patch uses gnulib's verify() macro to make sure
their sizes don't change.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoFix build with GCC 8 new switch fallthrough warnings
Daniel P. Berrangé [Tue, 13 Feb 2018 11:28:45 +0000 (11:28 +0000)]
Fix build with GCC 8 new switch fallthrough warnings

GCC 8 became more fussy about detecting switch
fallthroughs. First it doesn't like it if you have
a fallthrough attribute that is not before a case
statement. e.g.

   FOO:
   BAR:
   WIZZ:
      ATTRIBUTE_FALLTHROUGH;

Is unacceptable as there's no final case statement,
so while FOO & BAR are falling through, WIZZ is
not falling through. IOW, GCC wants us to write

  FOO:
  BAR:
    ATTRIBUTE_FALLTHROUGH;
  WIZZ:

Second, it will report risk of fallthrough even if you
have a case statement for every single enum value, but
only if the switch is nested inside another switch and
the outer case statement has no final break. This is
is arguably valid because despite the fact that we have
cast from "int" to the enum typedef, nothing guarantees
that the variable we're switching on only contains values
that have corresponding switch labels. e.g.

   int domstate = 87539319;
   switch ((virDomainState)domstate) {
      ...
   }

will not match enum value, but also not raise any kind
of compiler warning. So it is right to complain about
risk of fallthrough if no default: is present.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: add enum constants for default controller models
Daniel P. Berrangé [Wed, 14 Feb 2018 10:51:26 +0000 (10:51 +0000)]
conf: add enum constants for default controller models

The controller model is slightly unusual in that the default value is
-1, not 0. As a result the default value is not covered by any of the
existing enum cases. This in turn means that any switch() statements
that think they have covered all cases, will in fact not match the
default value at all. In the qemuDomainDeviceCalculatePCIConnectFlags()
method this has caused a serious mistake where we fallthrough from the
SCSI controller case, to the VirtioSerial controller case, and from
the USB controller case to the IDE controller case.

By adding explicit enum constant starting at -1, we can ensure switches
remember to handle the default case.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: Simplify modelName stringification
Andrea Bolognani [Mon, 12 Feb 2018 17:55:04 +0000 (18:55 +0100)]
qemu: Simplify modelName stringification

There's no need to perform checks before conversion, we can just
call virDomainControllerPCIModelNameTypeToString() and check the
results later on.

Since the variables involved are only used for PCI controllers,
we can declare them in the 'case' scope rather than in the
function scope to make everything a bit nicer while at it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Move skip for implicit PHB of pSeries guests
Andrea Bolognani [Mon, 12 Feb 2018 17:52:40 +0000 (18:52 +0100)]
qemu: Move skip for implicit PHB of pSeries guests

Performing the skip earlier will help us making the function
nicer later on. We also make the condition for the skip a bit
more precise, though that'a more for self-documenting purposes
and doesn't change anything in practice.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Move 'done' label in qemuBuildControllerDevStr()
Andrea Bolognani [Mon, 12 Feb 2018 17:46:23 +0000 (18:46 +0100)]
qemu: Move 'done' label in qemuBuildControllerDevStr()

Even when we skip part of the processing, we still want error
checking on the buffer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agostorage_conf: Make virStorageAuthDefFormat return void
Michal Privoznik [Tue, 20 Feb 2018 11:24:36 +0000 (12:24 +0100)]
storage_conf: Make virStorageAuthDefFormat return void

This function returns nothing but zero. Therefore it makes no
sense to have it returning an integer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agovirDomainDiskSourceFormatInternal: Avoid leaking @childBuf
Michal Privoznik [Tue, 20 Feb 2018 11:22:26 +0000 (12:22 +0100)]
virDomainDiskSourceFormatInternal: Avoid leaking @childBuf

If formatting of storage encryption or private data fails we must
jump to the error label instead of returning immediately
otherwise @attrBuf and @childBuf might be leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agodaemon: trigger RPC re-generation when Makefile.am changes
Daniel P. Berrangé [Mon, 19 Feb 2018 14:51:34 +0000 (14:51 +0000)]
daemon: trigger RPC re-generation when Makefile.am changes

The src/Makefile.am rules all re-generate the RPC dispatch code whenever
the Makefile.am changes, so for consistency do that for
daemon/Makefile.am too.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agodocs: Document pcie-root requirement for q35 guests
Andrea Bolognani [Mon, 19 Feb 2018 16:37:17 +0000 (17:37 +0100)]
docs: Document pcie-root requirement for q35 guests

When you add a bunch of pcie-root-port controllers to a q35 guest
in order to have hotplug capabilities, you also need to make sure
you're adding the pcie-root controller at the same time or you
will get an error. Document this fact.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agotests: fix bhyve build
Laine Stump [Tue, 20 Feb 2018 02:16:20 +0000 (21:16 -0500)]
tests: fix bhyve build

This file was modified in an editor buffer but not saved prior to
commit e62cb4a9b78 (which removed virMacAddr::generated), so the bhyve
build would fail.

Signed-off-by: Laine Stump <laine@laine.org>
7 years agoconf: move 'generated' member from virMacAddr to virDomainNetDef
Laine Stump [Fri, 16 Feb 2018 17:26:17 +0000 (12:26 -0500)]
conf: move 'generated' member from virMacAddr to virDomainNetDef

Commit 7e62c4cd26d (first appearing in libvirt-3.9.0 as a resolution
to rhbz #1343919) added a "generated" attribute to virMacAddr that was
set whenever a mac address was auto-generated by libvirt. This
knowledge was used in a single place - when trying to match a NetDef
from the Domain to Delete with user-provided XML. Since the XML parser
always auto-generates a MAC address for NetDefs when none is provided,
it was previously impossible to make a search where the MAC address
isn't significant, but the addition of the "generated" attribute made
it possible for the search function to ignore auto-generated MACs.

This implementation had a problem though - it was adding a field to a
"low level" struct - virMacAddr - which is used in other places with
the assumption that it contains exactly a 6 byte MAC address and
nothing else. In particular, virNWFilterSnoopEthHdr uses virMacAddr as
part of the definition of an ethernet packet header, whose layout must
of course match an actual ethernet packet. Adding the extra bools into
virNWFilterSnoopEthHdr caused the nwfilter driver's "IP discovery via
DHCP packet snooping" functionality to mysteriously stop working.

In order to fix that behavior, and prevent potential future similar
odd behavior, this patch moves the "generated" member out of
virMacAddr (so that it is again really is just a MAC address) into
virDomainNetDef, and sets it only when virDomainNetGenerateMAC() is
called from virDomainNetDefParseXML() (which is the only time we care
about it).

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

(It should also be applied to any maintenance branch that applies
commit 7e62c4cd26 and friends to resolve
https://bugzilla.redhat.com/1343919)

Signed-off-by: Laine Stump <laine@laine.org>
7 years agodocs: Fix indentation of inlined JavaScript snippet
Andrea Bolognani [Mon, 19 Feb 2018 16:32:20 +0000 (17:32 +0100)]
docs: Fix indentation of inlined JavaScript snippet

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: rename migration APIs to include Src or Dst in their name
Daniel P. Berrangé [Mon, 12 Feb 2018 17:11:41 +0000 (17:11 +0000)]
qemu: rename migration APIs to include Src or Dst in their name

It is very difficult while reading the migration code trying to
understand whether a particular function is being called on the src side
or the dst side, or either. Putting "Src" or "Dst" in the method names will
make this much more obvious. "Any" is used in a few helpers which can be
called from both sides.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: blockcopy: Add check for bandwidth
Peter Krempa [Mon, 19 Feb 2018 08:21:29 +0000 (09:21 +0100)]
qemu: blockcopy: Add check for bandwidth

QEMU code does not work well with too big numbers on the JSON monitor so
our monitor code supports sending only numbers up to LLONG_MAX. Avoid a
weird error message by limiting the size of the 'bandwidth' parameter
for block copy.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agovirsh: Fix internal naming of some blockjob commands
Peter Krempa [Mon, 19 Feb 2018 06:19:47 +0000 (07:19 +0100)]
virsh: Fix internal naming of some blockjob commands

The variable names for the options and information about a command
should have an underscore in places where the virsh command has a
hyphen. The function callback name should capitalize the letter after
the hyphen. This was not used in 'blockcommit', 'blockcopy', 'blockjob',
'blockpull', and 'blockresize' commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agobhyve: Fix build
Andrea Bolognani [Mon, 19 Feb 2018 13:19:41 +0000 (14:19 +0100)]
bhyve: Fix build

Commit 2d43f0a2dcfd dropped virDomainDiskTranslateSourcePool()'s
first argument but failed to update callers in the bhyve driver.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agotests: remove networkRegister() call from qemuxml2argvtest
Daniel P. Berrangé [Mon, 19 Feb 2018 12:57:16 +0000 (12:57 +0000)]
tests: remove networkRegister() call from qemuxml2argvtest

Further cleanup from

  commit 0c63c117a2d17f66b05dd83e50aa36ac0b0c9843
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Fri Feb 9 15:08:53 2018 +0000

    conf: reimplement virDomainNetResolveActualType in terms of public API

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agotests: drop linkage to libvirt_driver_network_impl.la
Daniel P. Berrangé [Mon, 19 Feb 2018 12:11:40 +0000 (12:11 +0000)]
tests: drop linkage to libvirt_driver_network_impl.la

The qemuxml2argvtest does not need to link to the network driver
after this commit:

  commit 0c63c117a2d17f66b05dd83e50aa36ac0b0c9843
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Fri Feb 9 15:08:53 2018 +0000

    conf: reimplement virDomainNetResolveActualType in terms of public API

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: don't export migration job APIs
Daniel P. Berrangé [Mon, 12 Feb 2018 16:54:23 +0000 (16:54 +0000)]
qemu: don't export migration job APIs

These APIs are not required anywhere outside the migration code so need
not be exported to the rest of the QEMU driver.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: remove virConnectPtr in some migration methods
Daniel P. Berrangé [Mon, 12 Feb 2018 16:50:01 +0000 (16:50 +0000)]
qemu: remove virConnectPtr in some migration methods

The qemuMigrationPrecreateStorage method needs a connection
to access the storage driver. Instead of passing it around,
open it at time of use.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: remove virConnectPtr from some more startup code paths
Daniel P. Berrangé [Fri, 9 Feb 2018 17:19:44 +0000 (17:19 +0000)]
qemu: remove virConnectPtr from some more startup code paths

There's a few places in startup code paths which pass around a
virConnectPtr which is no longer required. Specifically, the
qemuProcessStart() method now only requires a non-NULL connection if
autodestroy is requested.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: stop passing in virConnectPtr for looking up networks
Daniel P. Berrangé [Fri, 9 Feb 2018 16:36:24 +0000 (16:36 +0000)]
qemu: stop passing in virConnectPtr for looking up networks

When setting up graphics, we sometimes need to resolve networks,
requiring the caller to pass in a virConnectPtr, except sometimes they
pass in NULL. Use virGetConnectNetwork() to acquire the connection to
the network driver when it is needed.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: don't pass virConnectPtr around for secrets
Daniel P. Berrangé [Fri, 9 Feb 2018 16:14:41 +0000 (16:14 +0000)]
qemu: don't pass virConnectPtr around for secrets

During domain startup there are many places where we need to acquire
secrets. Currently code passes around a virConnectPtr, except in the
places where we pass in NULL. So there are a few codepaths where ability
to start guests using secrets will fail. Change to acquire a handle to
the secret driver when needed.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: stop passing virConnectPtr into virDomainDiskTranslateSourcePool
Daniel P. Berrangé [Fri, 9 Feb 2018 16:06:43 +0000 (16:06 +0000)]
conf: stop passing virConnectPtr into virDomainDiskTranslateSourcePool

Rather than expecting callers to pass a virConnectPtr into the
virDomainDiskTranslateSourcePool() method, just acquire a connection
to the storage driver when needed.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: stop passing virConnectPtr into qemuMonitorStartCPUs
Daniel P. Berrangé [Fri, 9 Feb 2018 15:40:51 +0000 (15:40 +0000)]
qemu: stop passing virConnectPtr into qemuMonitorStartCPUs

There is a long standing hack to pass a virConnectPtr into the
qemuMonitorStartCPUs method, so that when the text monitor prompts
for a disk password, we can lookup virSecretPtr objects. This causes
us to have to pass a virConnectPtr around through countless methods
up the call chain....except some places don't have any virConnectPtr
available so have always just passed NULL. We can finally fix this
disastrous design by using virGetConnectSecret() to open a connection
to the secret driver at time of use.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: reimplement virDomainNetResolveActualType in terms of public API
Daniel P. Berrangé [Fri, 9 Feb 2018 15:08:53 +0000 (15:08 +0000)]
conf: reimplement virDomainNetResolveActualType in terms of public API

Now that we have the ability to easily open connections to secondary
drivers, eg network:///system,  it is possible to reimplement the
virDomainNetResolveActualType method in terms of the public API. This
avoids the need to have the network driver provide a callback for it.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agodriver: allow override of connection for secondary drivers
Daniel P. Berrangé [Tue, 13 Feb 2018 10:08:00 +0000 (10:08 +0000)]
driver: allow override of connection for secondary drivers

When the test suite is running, we don't want to be triggering the
startup of daemons for the secondary drivers. Thus we must provide a way
to set a custom connection for the secondary drivers, to override the
default logic which opens a new connection.

This will also be useful for code where we have a whole set of separate
functions calls all needing the secret driver. Currently the connection
to the secret driver is opened & closed many times in quick
succession. This will allow us to pre-open a connection temporarily,
improving the performance of startup.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonews: Add support for setting Chassis SMBIOS data fields
Zhuang Yanying [Wed, 14 Feb 2018 09:22:40 +0000 (17:22 +0800)]
news: Add support for setting Chassis SMBIOS data fields

Signed-off-by: Zhuang Yanying <ann.zhuangyanying@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Generate SMBIOS Chassis strings command line
Zhuang Yanying [Wed, 14 Feb 2018 09:22:39 +0000 (17:22 +0800)]
qemu: Generate SMBIOS Chassis strings command line

This wires up the previously added Chassis strings XML schema to be able to
generate comamnd line args for QEMU. This requires QEMU >= 2.1 release
containing this patch:

SMBIOS: Build aggregate smbios tables and entry point
https://git.qemu.org/?p=qemu.git;a=commit;h=c97294ec1b9e36887e119589d456557d72ab37b5

Signed-off-by: Zhuang Yanying <ann.zhuangyanying@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Add support for setting Chassis SMBIOS data fields
Zhuang Yanying [Wed, 14 Feb 2018 09:22:38 +0000 (17:22 +0800)]
conf: Add support for setting Chassis SMBIOS data fields

This type of information defines attributes of a system
chassis, such as SMBIOS Chassis Asset Tag.

access inside VM (for example)
Linux:   /sys/class/dmi/id/chassis_asset_tag.
Windows: (Get-WmiObject Win32_SystemEnclosure).SMBIOSAssetTag
          wirhin Windows PowerShell.

As an example, add the following to the guest XML

    <chassis>
      <entry name='manufacturer'>Dell Inc.</entry>
      <entry name='version'>2.12</entry>
      <entry name='serial'>65X0XF2</entry>
      <entry name='asset'>40000101</entry>
      <entry name='sku'>Type3Sku1</entry>
    </chassis>

Signed-off-by: Zhuang Yanying <ann.zhuangyanying@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agom4: disable gcc8 -Wcast-function-type warnings from -Wextra
Daniel P. Berrangé [Tue, 13 Feb 2018 16:40:19 +0000 (16:40 +0000)]
m4: disable gcc8 -Wcast-function-type warnings from -Wextra

The -Wextra flag bundle gained a new warning -Wcast-function-type.
This complains if you cast between two function prototypes where
the number of parameters or their data types are not compatible.
Unfortunately we need such "bad" function casts for our event
callbacks. It is possible to silence the warning by first casting
to the generic "void (*)(void)" function prototype, but that is
rather ugly to add throughout libvirt code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agovirsh: Remove <backingStore> sub-element in virshFindDisk
Peter Krempa [Wed, 14 Feb 2018 14:17:51 +0000 (15:17 +0100)]
virsh: Remove <backingStore> sub-element in virshFindDisk

Previously we've removed the data only in virshUpdateDiskXML when
changing the disk source for the CDROM since the backing store would be
invalid. Move the code into a separate function and callit from
virshFindDisk which is also used when detaching disk.

The detaching code does not necessarily need to get the full backing
chain since it will need to act on the one managed by libvirt anyways
and this also takes care of problems when parts of the backing store
were invalid due to buggy RBD detection code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoutil: storage: Remove detected authentication data for backing chains
Peter Krempa [Wed, 14 Feb 2018 13:12:23 +0000 (14:12 +0100)]
util: storage: Remove detected authentication data for backing chains

We can't really detect all the authentication data in a sane manner for
disk backing chains. Since the old RBD parser parses it in some cases as
the argv->XML convertor requires it, we can't just drop it.

Instead clear any detected authentication data in the code paths related
to disk backing chain lookup and fix the tests to cope with the change.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agovirsh: detach-disk: Add --print-xml switch
Peter Krempa [Wed, 14 Feb 2018 14:13:29 +0000 (15:13 +0100)]
virsh: detach-disk: Add --print-xml switch

Similarly to other commands add an argument which allows to check the
XML which would be used to execute the operation instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agovirstoragetest: Add test case for NBD over unix socket with new syntax
Peter Krempa [Mon, 12 Feb 2018 15:16:42 +0000 (16:16 +0100)]
virstoragetest: Add test case for NBD over unix socket with new syntax

Use the new syntax which uses the 'UnixSocket' type in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agostorage: Fix formatting and parsing of qemu type 'UnixSocketAddress'
Peter Krempa [Mon, 12 Feb 2018 14:44:11 +0000 (15:44 +0100)]
storage: Fix formatting and parsing of qemu type 'UnixSocketAddress'

The documentation for the JSON/qapi type 'UnixSocketAddress' states that
the unix socket path field is named 'path'. Unfortunately qemu uses
'socket' in case of the gluster driver (despite documented otherwise).

Add logic which will format the correct fields while keeping support of
the old spelling.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agospec: Drop overlapping triggers
Jiri Denemark [Wed, 14 Feb 2018 12:16:52 +0000 (13:16 +0100)]
spec: Drop overlapping triggers

The postun trigger for libvirt-daemon was defined twice for overlapping
ranges of package verions if systemd support was switched off (which
happens when building on something ancient, such as RHEL-6).

Let's combine the two triggers into the one which is called when
libvirt-daemon < 1.3.0 is uninstalled. As a side effect, virtlockd and
virtlogd might be reloaded twice after an upgrade from libvirt newer
than 1.2.1 and older than 1.3.0 (by postun script from the old libvirt
and postun trigger from the new libvirt).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Fix indentation in daemon's triggerpostun
Jiri Denemark [Wed, 14 Feb 2018 11:09:32 +0000 (12:09 +0100)]
spec: Fix indentation in daemon's triggerpostun

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Prepare for future RHEL
Jiri Denemark [Fri, 9 Feb 2018 13:08:45 +0000 (14:08 +0100)]
spec: Prepare for future RHEL

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Drop checks for old Fedora releases
Jiri Denemark [Fri, 9 Feb 2018 13:02:00 +0000 (14:02 +0100)]
spec: Drop checks for old Fedora releases

The oldest Fedora release supported by the spec file is 26. Checking for
anything older makes no sense.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Build virt-login-shell iff LXC driver is enabled
Jiri Denemark [Wed, 14 Feb 2018 13:49:28 +0000 (14:49 +0100)]
spec: Build virt-login-shell iff LXC driver is enabled

Building virt-login-shell doesn't really make any sense without LXC and
doing so even breaks "make rpm" since the associated files are installed
but unpackaged (the login-shell sub package already depends on LXC).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Enable fuse only if LXC is enabled
Jiri Denemark [Fri, 9 Feb 2018 12:42:50 +0000 (13:42 +0100)]
spec: Enable fuse only if LXC is enabled

Enabling fuse without LXC does not make a lot of sense because fuse is
used only by LXC.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: Check for down limit of SLIRP prefix too
Michal Privoznik [Tue, 6 Feb 2018 09:21:56 +0000 (10:21 +0100)]
qemu: Check for down limit of SLIRP prefix too

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

We're already checking if IPv4 prefix isn't too long. But we are
not checking if it isn't too short. QEMU supports prefixes longer
than 4 (including). I haven't find anything similar related to
IPv6 in qemu sources.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: block: Remove misleading part of comment in qemuBlockStorageSourceBuildJSONSock...
Peter Krempa [Mon, 12 Feb 2018 14:50:12 +0000 (15:50 +0100)]
qemu: block: Remove misleading part of comment in qemuBlockStorageSourceBuildJSONSocketAddress

The array indexes are formatted if the JSON->commandline translator is
translating an array type. It does not at all depend on this function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agotests: run virshtest independent of current pwd
Bjoern Walk [Thu, 8 Feb 2018 12:38:25 +0000 (13:38 +0100)]
tests: run virshtest independent of current pwd

virshtest execves the virsh binary. Make sure that it finds the binary's
location independent of the current working directory by specifying the
absolute path as determined by the build environment.

Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
7 years agotests: Clean up HPT tests
Andrea Bolognani [Tue, 23 Jan 2018 09:50:04 +0000 (10:50 +0100)]
tests: Clean up HPT tests

Give them better names and remove some redundancy.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Improve HPT feature handling
Andrea Bolognani [Tue, 6 Feb 2018 13:49:41 +0000 (14:49 +0100)]
conf: Improve HPT feature handling

Instead of storing separately whether the feature is enabled
or not and what resizing policy should be used, store both of
them in a single place.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Improve IOAPIC feature handling
Andrea Bolognani [Tue, 6 Feb 2018 13:30:40 +0000 (14:30 +0100)]
conf: Improve IOAPIC feature handling

Instead of storing separately whether the feature is enabled
or not and what driver should be used, store both of them in
a single place.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Fix GIC behavior for the default case
Andrea Bolognani [Thu, 1 Feb 2018 16:52:48 +0000 (17:52 +0100)]
qemu: Fix GIC behavior for the default case

When no GIC version is specified, we currently default to GIC v2;
however, that's not a great default, since guests will fail to
start if the hardware only supports GIC v3.

Change the behavior so that a sensible default is chosen instead.
That basically means using the same algorithm whether the user
didn't explicitly enable the GIC feature or they explicitly
enabled it but didn't specify any GIC version.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotests: Improve GIC tests
Andrea Bolognani [Thu, 1 Feb 2018 17:17:13 +0000 (18:17 +0100)]
tests: Improve GIC tests

Account for the fact that the default might change based on what
GIC versions are supported by QEMU. That's not the case at the
moment, but it will be soon.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Integrate all features ABI checks in the switch
Andrea Bolognani [Fri, 2 Feb 2018 14:55:14 +0000 (15:55 +0100)]
conf: Integrate all features ABI checks in the switch

There are a few stray checks which still live outside of the
switch in virDomainDefFeaturesCheckABIStability() for no good
reason. Move them inside the switch, and update the error
messages to be consistent while at it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Validate VIR_DOMAIN_FEATURE_CAPABILITIES properly
Andrea Bolognani [Thu, 1 Feb 2018 11:35:15 +0000 (12:35 +0100)]
conf: Validate VIR_DOMAIN_FEATURE_CAPABILITIES properly

Unlike most other features, VIR_DOMAIN_FEATURE_CAPABILITIES is
of type virDomainCapabilitiesPolicy instead of virTristateSwitch,
so we need to handle it separately for the error message to make
sense.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Use switch in virDomainDefFeaturesCheckABIStability()
Andrea Bolognani [Thu, 1 Feb 2018 11:31:57 +0000 (12:31 +0100)]
conf: Use switch in virDomainDefFeaturesCheckABIStability()

The compiler can make sure we are handling all features.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Move GIC checks to qemuDomainDefValidateFeatures()
Andrea Bolognani [Fri, 2 Feb 2018 15:05:51 +0000 (16:05 +0100)]
qemu: Move GIC checks to qemuDomainDefValidateFeatures()

Keep them along with other arch/machine type checks for
features instead of waiting until command line generation
time.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use switch in qemuDomainDefValidateFeatures()
Andrea Bolognani [Fri, 2 Feb 2018 15:05:01 +0000 (16:05 +0100)]
qemu: Use switch in qemuDomainDefValidateFeatures()

The compiler can make sure we are handling all features.

While reworking the logic, also change error messages to a more
consistent style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Move feature verification from PostParse() to Validate()
Andrea Bolognani [Fri, 2 Feb 2018 09:58:13 +0000 (10:58 +0100)]
qemu: Move feature verification from PostParse() to Validate()

We want to perform all feature verification in a single spot, but
some of it (eg. GIC) is currently being performed at command line
generation time, and moving it to PostParse() would cause guests
to disappear. Moving verification to Validate() allows us to
side-step the issue.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Fix indentation in qemuBuildControllerDevStr()
Andrea Bolognani [Mon, 12 Feb 2018 17:55:38 +0000 (18:55 +0100)]
qemu: Fix indentation in qemuBuildControllerDevStr()

Add braces around the multi-line body as well, in compliance
with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoRevert "qemu: Expose rx/tx_queue_size in qemu.conf too"
Daniel P. Berrangé [Mon, 12 Feb 2018 14:52:04 +0000 (14:52 +0000)]
Revert "qemu: Expose rx/tx_queue_size in qemu.conf too"

This reverts commit 038eb472a0d970a17ccf4343ead0666df5c92f9d.

On reflection adding defaults for arbitrary guest XML device config
settings to the qemu.conf is not a sustainable path. Removing the
support for rx/tx queue size so that it doesn't set a bad precedent.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: Alter condition to avoid possible NULL deref
John Ferlan [Fri, 9 Feb 2018 13:52:10 +0000 (08:52 -0500)]
qemu: Alter condition to avoid possible NULL deref

Commit 'f0f2a5ec2' neglected to adjust the if condition to split
out the possibility that the @watchdog is NULL when altering the
message to add detail about the model.

Just split out the condition and use previous/original message, but
with the new message code.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agotests: fix running of qemuxml2argvtest program
Daniel P. Berrangé [Mon, 12 Feb 2018 11:10:11 +0000 (11:10 +0000)]
tests: fix running of qemuxml2argvtest program

The previous commit:

  commit a455d41e3e1c1af3a36ccdbb2e3f2356cc58993e
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Jan 25 09:35:50 2018 +0000

    conf: expand network device callbacks to cover resolving NIC type

mistakenly dropped qemuxml2argvtest from the tests due to a typo.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agolog: fix deadlock obtaining hostname (related CVE-2018-6764)
Daniel P. Berrangé [Mon, 12 Feb 2018 10:03:08 +0000 (10:03 +0000)]
log: fix deadlock obtaining hostname (related CVE-2018-6764)

The fix for CVE-2018-6764 introduced a potential deadlock scenario
that gets triggered by the NSS module when virGetHostname() calls
getaddrinfo to resolve the hostname:

 #0  0x00007f6e714b57e7 in futex_wait
 #1  futex_wait_simple
 #2  __pthread_once_slow
 #3  0x00007f6e71d16e7d in virOnce
 #4  0x00007f6e71d0997c in virLogInitialize
 #5  0x00007f6e71d0a09a in virLogVMessage
 #6  0x00007f6e71d09ffd in virLogMessage
 #7  0x00007f6e71d0db22 in virObjectNew
 #8  0x00007f6e71d0dbf1 in virObjectLockableNew
 #9  0x00007f6e71d0d3e5 in virMacMapNew
 #10 0x00007f6e71cdc50a in findLease
 #11 0x00007f6e71cdcc56 in _nss_libvirt_gethostbyname4_r
 #12 0x00007f6e724631fc in gaih_inet
 #13 0x00007f6e72464697 in __GI_getaddrinfo
 #14 0x00007f6e71d19e81 in virGetHostnameImpl
 #15 0x00007f6e71d1a057 in virGetHostnameQuiet
 #16 0x00007f6e71d09936 in virLogOnceInit
 #17 0x00007f6e71d09952 in virLogOnce
 #18 0x00007f6e714b5829 in __pthread_once_slow
 #19 0x00007f6e71d16e7d in virOnce
 #20 0x00007f6e71d0997c in virLogInitialize
 #21 0x00007f6e71d0a09a in virLogVMessage
 #22 0x00007f6e71d09ffd in virLogMessage
 #23 0x00007f6e71d0db22 in virObjectNew
 #24 0x00007f6e71d0dbf1 in virObjectLockableNew
 #25 0x00007f6e71d0d3e5 in virMacMapNew
 #26 0x00007f6e71cdc50a in findLease
 #27 0x00007f6e71cdc839 in _nss_libvirt_gethostbyname3_r
 #28 0x00007f6e71cdc724 in _nss_libvirt_gethostbyname2_r
 #29 0x00007f6e7248f72f in __gethostbyname2_r
 #30 0x00007f6e7248f494 in gethostbyname2
 #31 0x000056348c30c36d in hosts_keys
 #32 0x000056348c30b7d2 in main

Fortunately the extra stuff virGetHostname does is totally irrelevant to
the needs of the logging code, so we can just inline a call to the
native hostname() syscall directly.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: command: Extract formatting of floppy related stuff into a helper
Peter Krempa [Thu, 8 Feb 2018 11:23:50 +0000 (12:23 +0100)]
qemu: command: Extract formatting of floppy related stuff into a helper

The floppy command formatting is special-cased since it does not
directly translate to a single '-device' argument.

Move the code from qemuBuildDiskDriveCommandLine to a new helper
function so that all the related code is together.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoqemu: don't leak in qemuGetDHCPInterfaces when failing to alloc
Chen Hanxiao [Sun, 11 Feb 2018 03:07:10 +0000 (11:07 +0800)]
qemu: don't leak in qemuGetDHCPInterfaces when failing to alloc

We forgot to free alloced mem when failed to
dup ifname or macaddr.

Also use VIR_STEAL_PTR to simplify codes.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoutil: virnetlink: Fix the parameter description of functions
Chen Hanxiao [Tue, 6 Feb 2018 11:38:17 +0000 (19:38 +0800)]
util: virnetlink: Fix the parameter description of functions

Some of function comments don't have the right named parameters
and others are not consistent with the description alignment.
This patch fixes this.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agoqemu: Remove redundancy from qemuBuildControllerDevStr()
Andrea Bolognani [Fri, 9 Feb 2018 16:10:28 +0000 (17:10 +0100)]
qemu: Remove redundancy from qemuBuildControllerDevStr()

Several PCI controllers have the same options, and thus
can be handled together.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Error out on invalid pci-root controller model name
Andrea Bolognani [Fri, 9 Feb 2018 15:56:13 +0000 (16:56 +0100)]
qemu: Error out on invalid pci-root controller model name

This is a hard error, and should be handled as such.
Introduced in 24614760228b.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Fix indentation in qemuDomainDeviceDefValidateControllerPCI()
Andrea Bolognani [Fri, 9 Feb 2018 15:57:28 +0000 (16:57 +0100)]
qemu: Fix indentation in qemuDomainDeviceDefValidateControllerPCI()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agorpc: export xdr_virNetMessageError for virnetmessagetest on Win32
Daniel P. Berrangé [Fri, 9 Feb 2018 14:29:33 +0000 (14:29 +0000)]
rpc: export xdr_virNetMessageError for virnetmessagetest on Win32

The Win32 symbol export file format can't do wildcards, so none of
the 'xdr_*' symbols are exported from the libvirt DLL. This doesn't
matter generally since the RPC client is built into the DLL and we
don't build libvirtd on Win32. The virnetmessagetest, however, does
require xdr_virNetMessageError to be exported, so just do a hack for
that.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agolockd: Install the admin sockets
John Ferlan [Tue, 6 Feb 2018 15:51:08 +0000 (10:51 -0500)]
lockd: Install the admin sockets

Commit id 'ce7ae55e' added support for the lockd admin socket, but
forgot to add the socket to the make and spec files for installation
purposes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agologd: Install the admin sockets
John Ferlan [Tue, 6 Feb 2018 15:57:25 +0000 (10:57 -0500)]
logd: Install the admin sockets

Commit id '85d45ff0' added support for the logd admin socket, but
forgot to add the socket to the make and spec files for installation
purposes.

NB: Includes breaking up the long %systemd_ lists across multiple lines
    for ease of reading

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agodocs: document requirement to provide Signed-off-by lines for DCO
Daniel P. Berrange [Mon, 22 Jan 2018 12:37:31 +0000 (12:37 +0000)]
docs: document requirement to provide Signed-off-by lines for DCO

Document that contributors are required to assert compliance with the
Developers Certification of Origin 1.1, by providing Signed-off-by tags
for all commit messages. The DCO is formally stating what we have long
implicitly expected of contributors in terms of their legal rights to
make the contribution. This puts the project in a stronger position
should any questions around contributions be raised going forward in the
future.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agocfg: forbid includes of headers in network and storage drivers again
Daniel P. Berrangé [Thu, 25 Jan 2018 10:53:54 +0000 (10:53 +0000)]
cfg: forbid includes of headers in network and storage drivers again

Loadable drivers must never depend on each other. Over time some usage
mistakenly crept in for the storage and network drivers, but now this is
eliminated the syntax-check rules can enforce this separation once more.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agobuild: passing the "-z defs" linker flag to prevent undefined symbols
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:58 +0000 (09:35 +0000)]
build: passing the "-z defs" linker flag to prevent undefined symbols

Undefined symbols are a bad thing in general because they can get
resolved in unexpected ways at runtime if multiple sources provide the
same symbol name. For example both glibc and libtirpc may provide XDR
symbols and we want to ensure that we resolve to libtirpc if that's what
we originally built against.

The toolchain maintainers thus strongly recommend that all applications
use the '-z defs' linker flag to prevent undefined symbols. This is
shortly becoming part of the default linker flags for RPMs. As an added
benefit this aligns Linux builds with Windows builds, where the linker
has never permitted undefined symbols.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agobuild: provide a AM_FLAGS_MOD for loadable modules
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:57 +0000 (09:35 +0000)]
build: provide a AM_FLAGS_MOD for loadable modules

Dynamic loadable modules all need a common set of linker flags

  -module -avoid-version $(AM_LDFLAGS)

Bundle those up into a $(AM_LDFLAGS_MOD) to avoid repetition.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agobuild: explicitly link all modules with libvirt.so
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:56 +0000 (09:35 +0000)]
build: explicitly link all modules with libvirt.so

The dlopened modules we currently build all use various symbols from
libvirt.so, but don't actually link to it. They rely on the libvirtd
daemon re-exporting the libvirt.so symbols. This means that at the
time the modules are linked, they contain a huge number of undefined
symbols. It also means that these undefined symbols are not versioned,
so despite us providing a LIBVIRT_PRIVATE_XXXX version that
intentionally changes on every release, the loadable modules could
actually be loaded into any libvirtd regardless of version.

This change explicitly links all modules against libvirt.so so
that they don't rely on the re-export behave and can be fully resolved
at build time. This will give us a stronger guarantee modules will
actually be loadable at runtime and that we're using modules from the
matched build.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agostorage: export virStoragePoolLookupByTargetPath as a public API
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:52 +0000 (09:35 +0000)]
storage: export virStoragePoolLookupByTargetPath as a public API

The storagePoolLookupByTargetPath() method in the storage driver is used
by the QEMU driver during block migration. If there's a valid use case
for this in the QEMU driver, then external apps likely have similar
needs. Exposing it in the public API removes the direct dependancy from
the QEMU driver to the storage driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: move virStorageTranslateDiskSourcePool into domain conf
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:51 +0000 (09:35 +0000)]
conf: move virStorageTranslateDiskSourcePool into domain conf

The virStorageTranslateDiskSourcePool method modifies a virDomainDiskDef
to resolve any storage pool reference. For some reason this was added
into the storage driver code, despite working entirely in terms of the
public APIs. Move it into the domain conf file and rename it to match the
object it modifies.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonetwork: remove conditional declarations
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:51 +0000 (09:35 +0000)]
network: remove conditional declarations

The networkDnsmasqConfContents() method is only used by the test suite
and that's only built with WITH_NETWORK is set. So there is no longer
any reason to conditionalize the declaration of this method.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: expand network device callbacks to cover resolving NIC type
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:50 +0000 (09:35 +0000)]
conf: expand network device callbacks to cover resolving NIC type

Currently the QEMU driver will call directly into the network driver
impl to modify resolve the atual type of NICs with type=network. It
has todo this before it has allocated the actual NIC. This introduces
a callback system to allow us to decouple the QEMU driver from the
network driver.

This is a short term step, as it ought to be possible to achieve the
same end goal by simply querying XML via the public network API. The
QEMU code in question though, has no virConnectPtr conveniently
available at this time.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: replace networkGetNetworkAddress with public API calls
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:49 +0000 (09:35 +0000)]
qemu: replace networkGetNetworkAddress with public API calls

The QEMU driver calls into the network driver to get the first IP
address of the network. This information is readily available via the
formal public API by fetching the XML doc and then parsing it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: expand network device callbacks to cover bandwidth updates
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:48 +0000 (09:35 +0000)]
conf: expand network device callbacks to cover bandwidth updates

Currently the QEMU driver will call directly into the network driver
impl to modify network device bandwidth for interfaces with
type=network. This introduces a callback system to allow us to decouple
the QEMU driver from the network driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoconf: introduce callback registration for domain net device allocation
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:47 +0000 (09:35 +0000)]
conf: introduce callback registration for domain net device allocation

Currently virt drivers will call directly into the network driver impl
to allocate domain interface devices where type=network. This introduces
a callback system to allow us to decouple the virt drivers from the
network driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agobuild: link libvirt_lxc against libvirt.so
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:59 +0000 (09:35 +0000)]
build: link libvirt_lxc against libvirt.so

Rather than static linking in various of the helper libraries to
libvirt_lxc, just link against the main libvirt.so. This is more memory
and time efficient because it will already be cached in memory and
sharable between processes.

CAPNG flags need adding because the LXC code directly calls various
libcapng APIs and no longer inherits the CAPNG flags via the statically
linked .a libs.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agorpc: don't link in second copy of RPC code to libvirtd & lockd plugin
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:47 +0000 (09:35 +0000)]
rpc: don't link in second copy of RPC code to libvirtd & lockd plugin

The libvirt_driver_remote.la static library is linked into the
libvirt.so dynamic library, providing both the generic RPC layer code
and the remote protocol client driver. The libvirtd daemon the itself
links to libvirt_driver_remote.la, in order to get access to the generic
RPC layer code and the XDR functions for the remote driver. This means
we get multiple copies of the same code in libvirtd, one direct and one
indirect via libvirt.so. The same mistake affects the lockd plugin.

The libvirtd daemon should instead just link aganist the generic RPC
layer code that's in libvirt.so. This is easily doable if we add exports
for the few symbols we've previously missed, and wildcard export xdr_*
to expose the auto-generated XDR marshallers.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agostorage: move storage file backend framework into util directory
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:46 +0000 (09:35 +0000)]
storage: move storage file backend framework into util directory

The QEMU driver loadable module needs to be able to resolve all ELF
symbols it references against libvirt.so. Some of its symbols can only
be resolved against the storage_driver.so loadable module which creates
a hard dependancy between them. By moving the storage file backend
framework into the util directory, this gets included directly in the
libvirt.so library. The actual backend implementations are still done as
loadable modules, so this doesn't re-add deps on gluster libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agostorage: extract storage file backend from main storage driver backend
Daniel P. Berrangé [Thu, 25 Jan 2018 09:35:44 +0000 (09:35 +0000)]
storage: extract storage file backend from main storage driver backend

The storage driver backends are serving the public storage pools API,
while the storage file backends are serving the internal QEMU driver and
/ or libvirt utility code.

To prep for moving this storage file backend framework into the utility
code, split out the backend definitions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agofix regex to check CN from server certificate
Tiago M. Vieira [Fri, 26 Jan 2018 19:33:02 +0000 (14:33 -0500)]
fix regex to check CN from server certificate

Currently when the script validates the PKI files and
the certificate 'Subject:' field contains RDNs after
the Common Name (CN), these values are also included,
creating a false result that the CN is not correct.

A small change to the sed regex fixes this issue, by
extracting only the value for CN and nothing else. The
regex is replaced with the exact same regex used to
extract the CN value from the client certificate.

7 years agoAUTHORS: Add myself to the list of committers
Christian Ehrhardt [Thu, 8 Feb 2018 11:44:09 +0000 (12:44 +0100)]
AUTHORS: Add myself to the list of committers

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoutil: Fix syntax-check
Andrea Bolognani [Wed, 7 Feb 2018 13:39:18 +0000 (14:39 +0100)]
util: Fix syntax-check

Broken by 759b4d1b0fe5f4d84d98b99153dfa7ac289dd167.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agovirlog: determine the hostname on startup CVE-2018-6764
Lubomir Rintel [Sat, 27 Jan 2018 22:43:58 +0000 (23:43 +0100)]
virlog: determine the hostname on startup CVE-2018-6764

At later point it might not be possible or even safe to use getaddrinfo(). It
can in turn result in a load of NSS module.

Notably, on a LXC container startup we may find ourselves with the guest
filesystem already having replaced the host one. Loading a NSS module
from the guest tree would allow a malicous guest to escape the
confinement of its container environment because libvirt will not yet
have locked it down.

7 years agoqemu: Limit refresh of CPU halted state to s390
Viktor Mihajlovski [Tue, 6 Feb 2018 10:18:56 +0000 (11:18 +0100)]
qemu: Limit refresh of CPU halted state to s390

Refreshing the halted state can cause VM performance issues. Since
s390 is currently the only architecture with a known interest in
the halted state, we're avoiding to call QEMU on other platforms.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>