]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agoqemu: domain: Fix typo in qemuDomainObjPtrivateXMLFormatAutomaticPlacement
Peter Krempa [Tue, 26 Sep 2017 14:36:48 +0000 (16:36 +0200)]
qemu: domain: Fix typo in qemuDomainObjPtrivateXMLFormatAutomaticPlacement

7 years agoconf: fix formatting of udp chardev attributes
Ján Tomko [Tue, 26 Sep 2017 11:30:10 +0000 (13:30 +0200)]
conf: fix formatting of udp chardev attributes

It is possible (although possibly not very useful) to leave out
the service attribute when using <source mode='bind'/>

Fix the formatter bug introduced by commit 4a0da34 and format
the host when its present (checked for non-NULL inside
virBufferEscapeString) instead of basing it on the presence
of the service attribute.

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

7 years agoqemu: block: Use correct alias when extracting disk node names
Peter Krempa [Mon, 25 Sep 2017 09:44:00 +0000 (11:44 +0200)]
qemu: block: Use correct alias when extracting disk node names

The alias recorded in disk->info.alias is the alias for the frontend
device but we are interested in the backend drive. This messed up the
disk node name extraction code as qemu reports the drive alias in the
block query commands. This was broken in the node name detector
refactoring done in commit 0175dc6ea024d

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

7 years agoqemu: block: Don't lookup node names if they are already known
Peter Krempa [Mon, 25 Sep 2017 09:39:55 +0000 (11:39 +0200)]
qemu: block: Don't lookup node names if they are already known

Move the check that skips node name detection if they are already
present earlier so that the hash table lookup is skipped.

7 years agoPrint hex values with '0x' prefix and octal with '0' in debug messages
Daniel P. Berrange [Mon, 25 Sep 2017 10:43:33 +0000 (11:43 +0100)]
Print hex values with '0x' prefix and octal with '0' in debug messages

Seeing a log message saying 'flags=93' is ambiguous & confusing unless
you happen to know that libvirt always prints flags as hex.  Change our
debug messages so that they always add a '0x' prefix when printing flags,
and '0' prefix when printing mode. A few other misc places gain a '0x'
prefix in error messages too.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoapparmor: support ptrace checks
Jim Fehlig [Fri, 22 Sep 2017 23:02:42 +0000 (17:02 -0600)]
apparmor: support ptrace checks

Kernel 4.13 introduced finer-grained ptrace checks

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?h=v4.13.2&id=290f458a4f16f9cf6cb6562b249e69fe1c3c3a07

With kernel 4.13 and apparmor 2.11, simply starting libvirtd
results in the following apparmor denial

type=AVC msg=audit(1506112085.645:954): apparmor="DENIED"
operation="ptrace" profile="/usr/sbin/libvirtd" pid=6984
comm="libvirtd" requested_mask="trace" denied_mask="trace"
peer="unconfined"

Attempting to start an unconfined domain results in

type=AVC msg=audit(1506112301.227:1112): apparmor="DENIED"
operation="ptrace" profile="/usr/sbin/libvirtd" pid=7498
comm="libvirtd" requested_mask="trace" denied_mask="trace"
peer="/usr/sbin/libvirtd"

And attempting to start a confined domain results in

type=AVC msg=audit(1506112631.408:1312): apparmor="DENIED"
operation="open" profile="virt-aa-helper" name="/etc/libnl/classid"
pid=8283 comm="virt-aa-helper" requested_mask="r" denied_mask="r"
fsuid=0 ouid=0
type=AVC msg=audit(1506112631.530:1319): apparmor="DENIED"
operation="open" profile="virt-aa-helper" name="/etc/libnl/classid"
pid=8289 comm="virt-aa-helper" requested_mask="r" denied_mask="r"
fsuid=0 ouid=0
type=AVC msg=audit(1506112632.186:1324): apparmor="DENIED"
operation="ptrace" profile="/usr/sbin/libvirtd" pid=8342
comm="libvirtd" requested_mask="trace" denied_mask="trace"
peer="libvirt-66154842-e926-4f92-92f0-1c1bf61dd1ff"

Add ptrace rules to allow the trace operations.

Resolves: https://bugzilla.suse.com/show_bug.cgi?id=1058847
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
7 years agonews: remove kernel version reference from switchdev entry
Ján Tomko [Wed, 20 Sep 2017 13:23:47 +0000 (15:23 +0200)]
news: remove kernel version reference from switchdev entry

The functionality was added in 4.8, but due to a rename of
the DEVLINK_CMD_ESWITCH_GET constant in the kernel headers,
the headers from kernel 4.11 are required by the libvirt code.

Remove the reference from the news entry, since it could be
misleading.

7 years agoqemu: capabilities: Remove support for downstream-only QMP monitor backport
Peter Krempa [Wed, 20 Sep 2017 08:45:23 +0000 (10:45 +0200)]
qemu: capabilities: Remove support for downstream-only QMP monitor backport

Some distros (see diff) chose to backport QMP support rather than rebase
to newer version of qemu. As a hack they added the string 'libvirt' to
the qemu -help output. Remove this as downstream-only hacks should be
carried by downstream and not litter upstream.

This effectively reverts commit ff88cd590572277f10ecee4ebb1174d9b70fc0d7

7 years agoqemu: Use qemuDomainDefFormatXML in qemuDomainDefCopy
Jiri Denemark [Fri, 15 Sep 2017 14:32:00 +0000 (16:32 +0200)]
qemu: Use qemuDomainDefFormatXML in qemuDomainDefCopy

Because qemuDomainDefCopy needs a string representation of a domain
definition, there's no reason for calling the lower level
qemuDomainDefFormatBuf API.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Fix error checking in qemuDomainDefFormatXMLInternal
Jiri Denemark [Fri, 15 Sep 2017 14:41:18 +0000 (16:41 +0200)]
qemu: Fix error checking in qemuDomainDefFormatXMLInternal

virDomainDefFormatInternal (called by qemuDomainDefFormatXMLInternal)
already checks for buffer errors and properly resets the buffer on
failure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agolibvirt_nss.c: Fix typo in aiforaf()
Michal Privoznik [Fri, 22 Sep 2017 10:41:51 +0000 (12:41 +0200)]
libvirt_nss.c: Fix typo in aiforaf()

In my previous commit of b1d87f9ad96f I've made a typo breaking
the FreeBSD build. s/ipAaddr/ipAddr/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoapparmor: delete profile on VM shutdown
Guido Günther [Mon, 18 Sep 2017 19:23:25 +0000 (21:23 +0200)]
apparmor: delete profile on VM shutdown

instead of only unloading it. This makes sure old profiles don't pile up
in /etc/apparmor.d/libvirt and we get updates to modified templates on
VM restart.

Reviewed-by: Jim Fehlig <jfehlig@suse.com>
7 years agoutil: Fix stack smashing in virNetDevGetFamilyId
Laine Stump [Thu, 21 Sep 2017 17:57:30 +0000 (13:57 -0400)]
util: Fix stack smashing in virNetDevGetFamilyId

After commit 8708ca01c0d libvirtd consistently aborts with "stack
 smashing detected" when nodedev driver is initialized.

This is caused by nlmsg_parse() being told that its array of nlattr*
has CTRL_CMD_MAX (10) entries, when in fact it is declared to have
CTRL_ATTR_MAX (8) entries. Since all the entries are initialized to
NULL, the result is that nlmsg_parse is overwriting 2*(sizof(nlattr*))
bytes outside the array.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agonss: Don't leak @ipAddr
Michal Privoznik [Thu, 21 Sep 2017 15:47:45 +0000 (17:47 +0200)]
nss: Don't leak @ipAddr

In aiforaf() (which exists only when building for BSD) the
@ipAddr may be leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoutil: Fix secret generation in virStorageSourceParseRBDColonString
John Ferlan [Fri, 15 Sep 2017 19:21:35 +0000 (15:21 -0400)]
util: Fix secret generation in virStorageSourceParseRBDColonString

Commit id '5604c056' used the wrong API to generate the
<secret type='%s'..." field. The previous code used the
correct API as was done in commit id '6887af39'. The data
is actually a usage type not an auth type even though the
result is the same.

7 years agoutil: Move virSecretUsageType to virsecret.h
John Ferlan [Fri, 15 Sep 2017 18:55:46 +0000 (14:55 -0400)]
util: Move virSecretUsageType to virsecret.h

Move the virSecretUsageType into the util.

7 years agoqemu: Avoid a possible NULL pointer deref in qemuDomainGetTLSObjects
Ashish Mittal [Wed, 20 Sep 2017 12:32:29 +0000 (05:32 -0700)]
qemu: Avoid a possible NULL pointer deref in qemuDomainGetTLSObjects

Passing a NULL value for the argument secAlias to the function
qemuDomainGetTLSObjects would cause a segmentation fault in
libvirtd.

Changed code to check before dereferencing a NULL secAlias.

Signed-off-by: Ashish Mittal <ashmit602@gmail.com>
7 years agotests: Add QEMU 2.10.0 capabilities test for s390x
Boris Fiuczynski [Tue, 19 Sep 2017 14:06:11 +0000 (16:06 +0200)]
tests: Add QEMU 2.10.0 capabilities test for s390x

Adding s390x qemu caps test for qemu version 2.10.0.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
7 years agoqemu: Introduce a wrapper over virFileWrapperFdClose
Michal Privoznik [Thu, 14 Sep 2017 14:28:34 +0000 (16:28 +0200)]
qemu: Introduce a wrapper over virFileWrapperFdClose

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

When migrating to a file (e.g. when doing 'virsh save file'),
couple of things are happening in the thread that is executing
the API:

1) the domain obj is locked
2) iohelper is spawned as a separate process to handle all I/O
3) the thread waits for iohelper to finish
4) the domain obj is unlocked

Now, the problem is that while the thread waits in step 3 for
iohelper to finish this may take ages because iohelper calls
fdatasync(). And unfortunately, we are waiting the whole time
with the domain locked. So if another thread wants to jump in and
say copy the domain name ('virsh list' for instance), they are
stuck.

The solution is to unlock the domain whenever waiting for I/O and
lock it back again when it finished.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Be more selective when determining cdrom for taint messaging
John Ferlan [Mon, 11 Sep 2017 12:35:05 +0000 (08:35 -0400)]
qemu: Be more selective when determining cdrom for taint messaging

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

Commit id '99a2d6af2' was a bit too aggressive with determining whether
the provided path was a "physical" cd-rom in order to generate a taint
message due to the possibility of some guest and host trying to control
the tray. For cd-rom guest devices backed to some VIR_STORAGE_TYPE_FILE
storage, this wouldn't be a problem and as such it shouldn't be a problem
for guest devices using some sort of block device on the host such as
iSCSI, LVM, or a Disk pool would present.

So before issuing a taint message, let's check if the provided path of
the VIR_STORAGE_TYPE_BLOCK backed device is a "known" physical cdrom name
by comparing the beginning of the path w/ "/dev/cdrom" and "/dev/sr".
Also since it's possible the provided path could resolve to some /dev/srN
device, let's get that path as well and perform the same check.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuBuildHostNetStr: Don't leak @addr
Michal Privoznik [Thu, 21 Sep 2017 12:52:58 +0000 (14:52 +0200)]
qemuBuildHostNetStr: Don't leak @addr

The virSocketAddrFormat() allocates the string and it's caller
responsibility to free it afterwards.

==28857== 11 bytes in 1 blocks are definitely lost in loss record 37 of 168
==28857==    at 0x4C2BEDF: malloc (vg_replace_malloc.c:299)
==28857==    by 0x9A81D79: strdup (in /lib64/libc-2.23.so)
==28857==    by 0x5DA3BF0: virStrdup (virstring.c:902)
==28857==    by 0x5D96182: virSocketAddrFormatFull (virsocketaddr.c:427)
==28857==    by 0x5D95E13: virSocketAddrFormat (virsocketaddr.c:352)
==28857==    by 0x5706890: qemuBuildHostNetStr (qemu_command.c:3891)
==28857==    by 0x57138D3: qemuBuildInterfaceCommandLine (qemu_command.c:8597)
==28857==    by 0x5713D6A: qemuBuildNetCommandLine (qemu_command.c:8699)
==28857==    by 0x57176F6: qemuBuildCommandLine (qemu_command.c:10027)
==28857==    by 0x5769D61: qemuProcessCreatePretendCmd (qemu_process.c:6004)
==28857==    by 0x4056EC: testCompareXMLToArgv (qemuxml2argvtest.c:502)
==28857==    by 0x41DF40: virTestRun (testutils.c:180)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Don't update CPU when formatting live def
Jiri Denemark [Fri, 30 Jun 2017 14:55:20 +0000 (16:55 +0200)]
qemu: Don't update CPU when formatting live def

Since commit v2.2.0-199-g7ce711a30e libvirt stores an updated guest CPU
in domain's live definition and there's no need to update it every time
we want to format the definition. The commit itself tried to address
this in qemuDomainFormatXML, but forgot to fix qemuDomainDefFormatLive.
Not to mention that masking a previously set flag is only acceptable if
the flag was set by a public API user. Internally, libvirt should have
never set the flag in the first place.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Use correct host model for updating guest cpu
Jiri Denemark [Fri, 30 Jun 2017 15:05:22 +0000 (17:05 +0200)]
qemu: Use correct host model for updating guest cpu

When a user requested a domain XML description with
VIR_DOMAIN_XML_UPDATE_CPU flag, libvirt would use the host CPU
definition from host capabilities rather than the one which will
actually be used once the domain is started.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoconf: Drop unused VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU
Jiri Denemark [Fri, 30 Jun 2017 14:09:06 +0000 (16:09 +0200)]
conf: Drop unused VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU

The only real usage of this flag was removed by "cpu_conf: Drop
updateCPU from virCPUDefFormat".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu_conf: Simplify formatting of guest CPU attributes
Jiri Denemark [Fri, 30 Jun 2017 14:05:28 +0000 (16:05 +0200)]
cpu_conf: Simplify formatting of guest CPU attributes

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu_conf: Drop updateCPU from virCPUDefFormat
Jiri Denemark [Fri, 30 Jun 2017 13:47:23 +0000 (15:47 +0200)]
cpu_conf: Drop updateCPU from virCPUDefFormat

In the past we updated host-model CPUs with host CPU data by adding a
model and features, but keeping the host-model mode. And since the CPU
model is not normally formatted for host-model CPU defs, we had to pass
the updateCPU flag to the formatting code to be able to properly output
updated host-model CPUs. Libvirt doesn't do this anymore, host-model
CPUs are turned into custom mode CPUs once updated with host CPU data
and thus there's no reason for keeping the hacks inside CPU XML
formatters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemuxml2xmltest: Add tests for Power CPUs
Jiri Denemark [Mon, 18 Sep 2017 07:59:18 +0000 (09:59 +0200)]
qemuxml2xmltest: Add tests for Power CPUs

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: reject parallel ports for pseries machines
Pino Toscano [Thu, 7 Sep 2017 12:19:40 +0000 (14:19 +0200)]
qemu: reject parallel ports for pseries machines

They are simply not supported on that machine type.

Partially-resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1487499

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
7 years agoqemu: reject parallel ports for s390 archs
Pino Toscano [Thu, 7 Sep 2017 12:19:39 +0000 (14:19 +0200)]
qemu: reject parallel ports for s390 archs

They are simply not supported on those architectures.

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

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
7 years agoqemu: pass the virDomainDef to qemuDomainChrDefValidate
Pino Toscano [Thu, 7 Sep 2017 12:19:38 +0000 (14:19 +0200)]
qemu: pass the virDomainDef to qemuDomainChrDefValidate

This will be used to improve the validation for this type of devices.

The former @def parameter is renamed to @dev, leaving @def for the
virDomainDef (following the style used elsewhere).

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
7 years agotests: qemuxml2argv: fail also on unexpected pass
Pino Toscano [Thu, 7 Sep 2017 12:19:37 +0000 (14:19 +0200)]
tests: qemuxml2argv: fail also on unexpected pass

If a test expects either a parse error or a failure but then there is
neither a parse error nor a failure, then properly mark the test as
failing, instead of failing later on (e.g. trying to open a
non-existing .args file).

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
7 years agotests: qemuxml2argv: fix expected type for usb-bus-missing
Pino Toscano [Thu, 7 Sep 2017 12:19:36 +0000 (14:19 +0200)]
tests: qemuxml2argv: fix expected type for usb-bus-missing

The guest of usb-bus-missing does not cause a parse error, but a
validation issue -- hence, switch from DO_TEST_PARSE_ERROR to
DO_TEST_FAILURE.

Fixes commit b003b9781b6ae633cfe4fdf6b9620ca246fa2432.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
7 years agoFix commandhelper build on win32
Daniel P. Berrange [Thu, 21 Sep 2017 07:55:07 +0000 (08:55 +0100)]
Fix commandhelper build on win32

For win32 we need EXIT_AM_SKIP which is in testutils.h. We must
define NO_LIBVIRT to prevent replacement of fprintf with
virFilePrintf as we can't link to libvirt_util.la

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoiohelper: avoid calling read() with misaligned buffers for O_DIRECT
Daniel P. Berrange [Wed, 20 Sep 2017 15:25:56 +0000 (16:25 +0100)]
iohelper: avoid calling read() with misaligned buffers for O_DIRECT

The iohelper currently calls saferead() to get data from the
underlying file. This has a problem with O_DIRECT when hitting
end-of-file. saferead() is asked to read 1MB, but the first
read() it does may return only a few KB, so it'll try another
read() to fill the remaining buffer. Unfortunately the buffer
pointer passed into this 2nd read() is likely not aligned
to the extent that O_DIRECT requires, so rather than seeing
'0' for end-of-file, we'll get -1 + EINVAL due to misaligned
buffer.

The way the iohelper is currently written, it already handles
getting short reads, so there is actually no need to use
saferead() at all. We can simply call read() directly. The
benefit of this is that we can now write() the data immediately
so when we go into the subsequent reads() we'll always have a
correctly aligned buffer.

Technically the file position ought to be aligned for O_DIRECT
too, but this does not appear to matter when at end-of-file.

Tested-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoStop linking tests/commandhelper to libvirt code
Daniel P. Berrange [Wed, 20 Sep 2017 11:03:47 +0000 (12:03 +0100)]
Stop linking tests/commandhelper to libvirt code

The commandhelper binary is a helper for commandtest that
validates what file handles were inherited. For this to
work reliably we must not have any libraries that leak
file descriptors into commandhelper. Unfortunately some
versions of gnutls will intentionally open file handles
at library load time via a constructor function.

We previously hacked around this in

  commit 4cbc15d037e1cd8abf5c4aa6acc30d83ae13e34d
  Author: Martin Kletzander <mkletzan@redhat.com>
  Date:   Fri May 2 09:55:52 2014 +0200

    tests: don't fail with newer gnutls

    gnutls-3.3.0 and newer leaves 2 FDs open in order to be backwards
    compatible when it comes to chrooted binaries [1].  Linking
    commandhelper with gnutls then leaves these two FDs open and
    commandtest fails thanks to that.  This patch does not link
    commandhelper with libvirt.la, but rather only the utilities making
    the test pass.

    Based on suggestion from Daniel [2].

    [1] http://lists.gnutls.org/pipermail/gnutls-help/2014-April/003429.html
    [2] https://www.redhat.com/archives/libvir-list/2014-April/msg01119.html

That fix relied on fact that while libvirt.so linked with
gnutls, libvirt_util.la did not link to it.  With the
introduction of the util/vircrypto.c file that assumption
is no longer valid. We must not link to libvirt_util.la
at all - only gnulib and libc can (hopefully) be relied
on not to open random file descriptors in constructors.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agovhost-user: add support reconnect for vhost-user ports
ZhiPeng Lu [Fri, 8 Sep 2017 09:12:09 +0000 (17:12 +0800)]
vhost-user: add support reconnect for vhost-user ports

For vhost-user ports, Open vSwitch acts as the server and QEMU the client.
When OVS crashed or restart, QEMU shoule be reconnect to OVS.

Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agostorage: Add new events for *PoolBuild() and *PoolDelete().
Julio Faracco [Sat, 9 Sep 2017 15:09:49 +0000 (12:09 -0300)]
storage: Add new events for *PoolBuild() and *PoolDelete().

This commit adds new events for two methods and operations: *PoolBuild() and
*PoolDelete(). Using the event-test and the commands set below we have the
following outputs:

$ sudo ./event-test
Registering event callbacks
myStoragePoolEventCallback EVENT: Storage pool test Defined 0
myStoragePoolEventCallback EVENT: Storage pool test Created 0
myStoragePoolEventCallback EVENT: Storage pool test Started 0
myStoragePoolEventCallback EVENT: Storage pool test Stopped 0
myStoragePoolEventCallback EVENT: Storage pool test Deleted 0
myStoragePoolEventCallback EVENT: Storage pool test Undefined 0

Another terminal:
$ sudo virsh pool-define test.xml
Pool test defined from test.xml

$ sudo virsh pool-build test
Pool test built

$ sudo virsh pool-start test
Pool test started

$ sudo virsh pool-destroy test
Pool test destroyed

$ sudo virsh pool-delete test
Pool test deleted

$ sudo virsh pool-undefine test
Pool test has been undefined

This commits can be a solution for RHBZ #1475227.

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: handle reconnect on chardev hotplug
ZhiPeng Lu [Wed, 13 Sep 2017 00:33:40 +0000 (08:33 +0800)]
qemu: handle reconnect on chardev hotplug

The patch passes the reconnect timeout to QEMU by monitor on
chardev hotplug.

Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoLink libvirt_util.la with gnutls
Daniel P. Berrange [Wed, 20 Sep 2017 08:08:40 +0000 (09:08 +0100)]
Link libvirt_util.la with gnutls

The util/vircrypto.c file uses gnutls, so we must directly link
libvirt_util.la with gnutls to avoid errors on OS which do not
resolve symbols against indirectly linked libraries.

This fixes a build failure on Ubuntu Trusty

  CCLD     storagevolxml2argvtest
/usr/bin/ld: ../src/.libs/libvirt_util.a(libvirt_util_la-vircrypto.o): undefined reference to symbol 'gnutls_strerror@@GNUTLS_1_4'

//usr/lib/x86_64-linux-gnu/libgnutls.so.26: error adding symbols: DSO missing from command line

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Add qemu command line generation for a VxHS block device
Ashish Mittal [Wed, 30 Aug 2017 13:46:53 +0000 (09:46 -0400)]
qemu: Add qemu command line generation for a VxHS block device

The VxHS block device will only use the newer formatting options and
avoid the legacy URI syntax.

An excerpt for a sample QEMU command line is:

  -drive file.driver=vxhs,file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,\
   file.server.type=tcp,file.server.host=192.168.0.1,\
   file.server.port=9999,format=raw,if=none,id=drive-virtio-disk0,cache=none \
  -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
   id=virtio-disk0

Update qemuxml2argvtest with a simple test.

Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Refactor qemuBlockStorageSourceBuildHostsJSONSocketAddress
Ashish Mittal [Tue, 12 Sep 2017 11:43:31 +0000 (07:43 -0400)]
qemu: Refactor qemuBlockStorageSourceBuildHostsJSONSocketAddress

Extract out the "guts" of building a server entry into it's own
separately callable/usable function in order to allow building
a server entry for a consumer with src->nhosts == 1.

7 years agoutil: storage: Add JSON backing volume parse for VxHS
Ashish Mittal [Wed, 30 Aug 2017 13:46:50 +0000 (09:46 -0400)]
util: storage: Add JSON backing volume parse for VxHS

Add the backing parse and a test case to verify parsing of VxHS
backing storage.

Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Add schema and docs for Veritas HyperScale (VxHS)
Ashish Mittal [Wed, 30 Aug 2017 13:41:23 +0000 (09:41 -0400)]
docs: Add schema and docs for Veritas HyperScale (VxHS)

Alter the schema to allow a VxHS block device. Sample XML is:

  <disk type='network' device='disk'>
    <driver name='qemu' type='raw' cache='none'/>
    <source protocol='vxhs' name='eb90327c-8302-4725-9e1b-4e85ed4dc251'>
      <host name='192.168.0.1' port='9999'/>
    </source>
    <target dev='vda' bus='virtio'/>
    <serial>eb90327c-8302-4725-9e1b-4e85ed4dc251</serial>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  </disk>

Update the html docs to describe the capability for VxHS.

Alter the qemuxml2xmltest to validate the formatting.

Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agostorage: Introduce VIR_STORAGE_NET_PROTOCOL_VXHS
Ashish Mittal [Tue, 29 Aug 2017 11:21:51 +0000 (07:21 -0400)]
storage: Introduce VIR_STORAGE_NET_PROTOCOL_VXHS

Add a new virStorageNetProtocol for Veritas HyperScale (VxHS) disks

Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Detect support for vxhs
John Ferlan [Tue, 29 Aug 2017 22:44:19 +0000 (18:44 -0400)]
qemu: Detect support for vxhs

Using the query-qmp-schema introspection - look for the 'vxhs'
blockdevOptions type.

NB: This is a "best effort" type situation as there is not a
    mechanism to determine whether the running QEMU has been
    built with '--enable-vxhs'. All we can do is check if the
    option to use vxhs for a blockdev-add exists in the command
    infrastructure which does not take that into account when
    building its table of commands and options.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: virPCIGetNetName(): use first netdev name when phys_port_id isn't matched
Laine Stump [Fri, 15 Sep 2017 15:26:14 +0000 (11:26 -0400)]
util: virPCIGetNetName(): use first netdev name when phys_port_id isn't matched

The mlx4 (Mellanox) netdev driver implements the sysfs phys_port_id
file for both VFs and PFs, so you can find the VF netdev plugged into
the same physical port as any given PF netdev by comparing the
contents of phys_port_id of the respective netdevs. That's what
libvirt does when attempting to find the PF netdev for a given VF
netdev (or vice versa).

Most other netdev's drivers don't implement phys_port_id, so the file
is visible in sysfs directory listing, but attempts to read it result
in ENOTSUPP. In these cases, libvirt is unable to read phys_port_id of
either the PF or the VF, so it just returns the first entry in the
PF/VF's list of netdevs.

But we've found that the i40e driver is in between those two
situations - it implements phys_port_id for PF netdevs, but doesn't
implement it for VF netdevs. So libvirt would successfully read the
phys_port_id of the PF netdev, then try to find a VF netdev with
matching phys_port_id, but would fail because phys_port_id is NULL for
all VFs. This would result in a message like the following:

   Could not find network device with phys_port_id '3cfdfe9edc39'
   under PCI device at /sys/class/net/ens4f1/device/virtfn0

To solve this problem in a way that won't break functionality for
anyone else, this patch saves the first netdev name we find for the
device, and returns that if we fail to find a netdev with the desired
phys_port_id.

7 years agoqemu: blockPeek: Enforce buffer filling
Peter Krempa [Mon, 18 Sep 2017 14:08:40 +0000 (16:08 +0200)]
qemu: blockPeek: Enforce buffer filling

Documentation states:

"'offset' and 'size' represent an area which must lie entirely within
the device or file." Enforce the that the buffer lies within fully.

7 years agoqemu: blockPeek: Fix filling of the return buffer
Peter Krempa [Mon, 18 Sep 2017 14:03:58 +0000 (16:03 +0200)]
qemu: blockPeek: Fix filling of the return buffer

Commit 3956af495e broke the blockPeek API since virStorageFileRead
allocates a return buffer and fills it with the data, while the API
fills a user-provided buffer. This did not get caught by the compiler
since the API prototype uses a 'void *'.

Fix it by transferring the data from the allocated buffer to the user
provided buffer.

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

7 years agoRevert "travis: Limit git depth to 5 commits"
Andrea Bolognani [Tue, 19 Sep 2017 13:49:19 +0000 (15:49 +0200)]
Revert "travis: Limit git depth to 5 commits"

Turns out a build job can be stuck waiting for a macOS worker to
become available for a pretty long time: if more than 5 commits
have been pushed in the meantime, the clone will be too shallow
for the worker to find the commit it's supposed to verify, and
the build job will fail.

See https://travis-ci.org/libvirt/libvirt/jobs/277244110 for an
example of the failure described.

This reverts commit 2e975abdc9bbc9e965486e8486cc17a771cdaeb3.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agopython: Don't hardcode interpreter path
Andrea Bolognani [Tue, 19 Sep 2017 10:42:09 +0000 (12:42 +0200)]
python: Don't hardcode interpreter path

This is particularly useful on operating systems that don't ship
Python as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.

While at it, make it explicit that our scripts are only going to
work with Python 2, and remove the usage of unbuffered I/O, which
as far as I can tell has no effect on the output files.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoperl: Don't hardcode interpreter path
Andrea Bolognani [Mon, 18 Sep 2017 12:35:50 +0000 (14:35 +0200)]
perl: Don't hardcode interpreter path

This is particularly useful on operating systems that don't ship
Perl as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.

In one case (src/rpc/genprotocol.pl) the interpreter path was
missing altogether.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Mark graphics ports used on reconnect
Michal Privoznik [Mon, 18 Sep 2017 13:39:58 +0000 (15:39 +0200)]
qemu: Mark graphics ports used on reconnect

I don't want to mask the real problem, but one can advocate
that we should be marking graphics ports as already in use on
qemuProcessReconnect anyway, because we already know that they
are taken.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconfigure: fix check for DEVLINK_CMD_ESWITCH_GET
Ján Tomko [Mon, 18 Sep 2017 17:21:47 +0000 (13:21 -0400)]
configure: fix check for DEVLINK_CMD_ESWITCH_GET

Instead of checking for all possible constants that every
kernel header with devlink support should have (and defining
HAVE_DECL_DEVLINK as 1 if any of them is present due to the
way AC_CHECK_DECLS works), only check for DEVLINK_CMD_ESWITCH_GET.

This is the name of the constant since kernel 4.11. Between 4.8
and 4.11, the now deprecated spelling DEVLINK_CMD_ESWITCH_MODE_GET
was used.

Assume DEVLINK_ESWITCH_MODE_SWITCHDEV is available, since it was
introduced along with the deprecated spelling.

7 years agostorage: Use virStoragePoolObjDefUseNewDef
John Ferlan [Wed, 26 Jul 2017 17:05:03 +0000 (13:05 -0400)]
storage: Use virStoragePoolObjDefUseNewDef

Use the new accessor API for storage_driver.

7 years agostorage: Use virStoragePoolObj{Get|Incr|Decr}Asyncjobs
John Ferlan [Wed, 26 Jul 2017 16:27:26 +0000 (12:27 -0400)]
storage: Use virStoragePoolObj{Get|Incr|Decr}Asyncjobs

Use the new accessor APIs for storage_driver.

7 years agostorage: Internally represent @autostart as bool
John Ferlan [Sat, 19 Aug 2017 12:16:18 +0000 (08:16 -0400)]
storage: Internally represent @autostart as bool

Since it's been used that way anyway, let's just convert it to a bool
and only make the external representation be an int.

7 years agostorage: Use virStoragePoolObj{Is|Set}Autostart
John Ferlan [Wed, 26 Jul 2017 16:23:11 +0000 (12:23 -0400)]
storage: Use virStoragePoolObj{Is|Set}Autostart

Use the new accessor APIs for storage_driver and test_driver.

7 years agostorage: Use virStoragePoolObj{Is|Set}Active
John Ferlan [Wed, 26 Jul 2017 16:15:42 +0000 (12:15 -0400)]
storage: Use virStoragePoolObj{Is|Set}Active

Use the new accessor APIs for storage_driver, test_driver, and
gluster backend.

7 years agostorage: Use virStoragePoolObjGetAutostartLink
John Ferlan [Wed, 26 Jul 2017 16:06:58 +0000 (12:06 -0400)]
storage: Use virStoragePoolObjGetAutostartLink

Use the new accessor API for storage_driver.

7 years agostorage: Use virStoragePoolObj{Get|Set}ConfigFile
John Ferlan [Wed, 26 Jul 2017 15:56:31 +0000 (11:56 -0400)]
storage: Use virStoragePoolObj{Get|Set}ConfigFile

Use the new accessor APIs for storage_driver and test_driver.

7 years agostorage: Introduce APIs to search/scan storage pool volumes list
John Ferlan [Tue, 9 May 2017 12:18:33 +0000 (08:18 -0400)]
storage: Introduce APIs to search/scan storage pool volumes list

Introduce virStoragePoolObjForEachVolume to scan each volume
calling the passed callback function until all volumes have been
processed in the storage pool volume list, unless the callback
function returns an error.

Introduce virStoragePoolObjSearchVolume to search each volume
calling the passed callback function until it returns true
indicating that the desired volume was found.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agostorage: Introduce storage volume add, delete, count APIs
John Ferlan [Tue, 9 May 2017 12:05:16 +0000 (08:05 -0400)]
storage: Introduce storage volume add, delete, count APIs

Create/use virStoragePoolObjAddVol in order to add volumes onto list.

Create/use virStoragePoolObjRemoveVol in order to remove volumes from list.

Create/use virStoragePoolObjGetVolumesCount to get count of volumes on list.

For the storage driver, the logic alters when the volumes.obj list grows
to after we've fetched the volobj. This is an optimization of sorts, but
also doesn't "needlessly" grow the volumes.objs list and then just decr
the count if the virGetStorageVol fails.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agostorage: Fill in storage pool @active properly
John Ferlan [Sat, 19 Aug 2017 12:25:21 +0000 (08:25 -0400)]
storage: Fill in storage pool @active properly

It's a bool not an int, so use true/false and not 1/0

7 years agostorage: Introduce virStoragePoolObjNew
John Ferlan [Mon, 8 May 2017 20:02:36 +0000 (16:02 -0400)]
storage: Introduce virStoragePoolObjNew

Create/use a helper to perform object allocation.

Adjust storagevolxml2argvtest.c in order to use the allocator and
setting of the obj->def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agostorage: Create accessor API's for virStoragePoolObj
John Ferlan [Sun, 7 May 2017 11:56:03 +0000 (07:56 -0400)]
storage: Create accessor API's for virStoragePoolObj

In preparation for making a private object, create accessor API's for
consumer storage functions to use:

    virStoragePoolObjGetDef
    virStoragePoolObjSetDef
    virStoragePoolObjGetNewDef
    virStoragePoolObjDefUseNewDef
    virStoragePoolObjGetConfigFile
    virStoragePoolObjSetConfigFile
    virStoragePoolObjGetAutostartLink
    virStoragePoolObjIsActive
    virStoragePoolObjSetActive
    virStoragePoolObjIsAutostart
    virStoragePoolObjSetAutostart
    virStoragePoolObjGetAsyncjobs
    virStoragePoolObjIncrAsyncjobs
    virStoragePoolObjDecrAsyncjobs

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: man: Describe the 'create' command a bit more
Erik Skultety [Fri, 8 Sep 2017 12:52:44 +0000 (14:52 +0200)]
virsh: man: Describe the 'create' command a bit more

So we refer to the terms 'persistent' and 'transient' across the whole
man page, without describing it further, but more importantly, how the
create command affects it, i.e. explicitly stating that domain created
via the 'create' command are going to be transient or persistent,
depending on whether there is an existing persistent domain with a
matching <name> and <uuid>, in which case it will remain persistent, but
will run using a one-time configuration, otherwise it's going to be
transient and will vanish once destroyed.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoiohelper: reduce zero-out in align case
Nikolay Shirokovskiy [Thu, 7 Sep 2017 07:44:15 +0000 (10:44 +0300)]
iohelper: reduce zero-out in align case

We only need to zero-out bytes that will be written.
May be we even don't need to zero-out at all because
of immediate truncate.

7 years agoiohelper: simplify last direct write alignment
Nikolay Shirokovskiy [Thu, 7 Sep 2017 07:44:14 +0000 (10:44 +0300)]
iohelper: simplify last direct write alignment

Make alignment of last direct write more straightforward. Using
additionally two flags 'end' and 'shortRead' looks complicated.

7 years agoiohelper: drop unused operation length limit
Nikolay Shirokovskiy [Thu, 7 Sep 2017 07:44:13 +0000 (10:44 +0300)]
iohelper: drop unused operation length limit

7 years agoapparmor: cater for new AAVMF image location
Guido Günther [Fri, 15 Sep 2017 16:04:21 +0000 (18:04 +0200)]
apparmor: cater for new AAVMF image location

Things moved again, sigh.

Reviewed-By: Jamie Strandboge <jamie@canonical.com>
Michal Privoznik <mprivozn@redhat.com>

7 years agoapparmor: add attach_disconnected
Guido Günther [Fri, 15 Sep 2017 15:13:16 +0000 (17:13 +0200)]
apparmor: add attach_disconnected

Otherwise we fail to reconnect to /dev/net/tun opened by libvirtd
like

    [ 8144.507756] audit: type=1400 audit(1505488162.386:38069121): apparmor="DENIED" operation="file_perm" info="Failed name lookup - disconnected path" error=-13 profile="libvirt-5dfcc8a7-b79a-4fa9-a41f-f6271651934c" name="dev/net/tun" pid=9607 comm="qemu-system-x86" requested_mask="r" denied_mask="r" fsuid=117 ouid=0

Reviewed-By: Jamie Strandboge <jamie@canonical.com>
Acked-By: Michal Privoznik <mprivozn@redhat.com>
7 years agocpu: Add new Skylake-Server CPU model
Jiri Denemark [Wed, 13 Sep 2017 11:27:03 +0000 (13:27 +0200)]
cpu: Add new Skylake-Server CPU model

Available since QEMU 2.10.0 (specifically commit
v2.9.0-2233-g53f9a6f45f).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agocpu: Add clwb/pcommit CPU features
Jiri Denemark [Wed, 13 Sep 2017 11:27:10 +0000 (13:27 +0200)]
cpu: Add clwb/pcommit CPU features

The features were added to QEMU by commit v2.4.0-1690-gf7fda28094 as
Skylake Server features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: Add CPUID data for Intel(R) Xeon(R) Gold 6148 CPU
Jiri Denemark [Wed, 13 Sep 2017 11:07:50 +0000 (13:07 +0200)]
tests: Add CPUID data for Intel(R) Xeon(R) Gold 6148 CPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agodocs: Update news.xml to describe switchdev offloading
John Ferlan [Sat, 26 Aug 2017 13:22:25 +0000 (09:22 -0400)]
docs: Update news.xml to describe switchdev offloading

7 years agonodedev: add switchdev to NIC capabilities
Edan David [Mon, 21 Aug 2017 09:19:53 +0000 (05:19 -0400)]
nodedev: add switchdev to NIC capabilities

Adding functionality to libvirt that will allow querying the interface
for the availability of switchdev Offloading NIC capabilities.

The switchdev mode was introduced in kernel 4.8, the iproute2-devlink
command to retrieve the switchdev NIC feature with command example:

    devlink dev eswitch show pci/0000:03:00.0

This feature is needed for Openstack so we can do a scheduling decision
if the NIC is in Hardware Offload (switchdev) or regular SR-IOV (legacy) mode.
And select the appropriate hypervisors with the requested capability see [1].

[1] - https://specs.openstack.org/openstack/nova-specs/specs/pike/approved/enable-sriov-nic-features.html

Reviewed-by: Laine Stump <laine@laine.org>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Implement usernet address
Michal Privoznik [Wed, 13 Sep 2017 09:16:04 +0000 (11:16 +0200)]
qemu: Implement usernet address

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

Apart from generic checks, we need to constrain netmask/prefix
length a bit. Thing is, with current implementation QEMU needs to
be able to 'assign' some IP addresses to the virtual network. For
instance, the default gateway is at x.x.x.2, dns is at x.x.x.3,
the default DHCP range is x.x.x.15-x.x.x.30. Since we don't
expose these settings yet, it's safer to require shorter prefix
to have room for the defaults.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: laine@laine.org
7 years agoconf: Allow usernet to have an address
Michal Privoznik [Wed, 13 Sep 2017 08:47:52 +0000 (10:47 +0200)]
conf: Allow usernet to have an address

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

Currently, all that users can specify for an interface type of
'user' is the common attributes: PCI address, NIC model (and
that's basically it). However, some need to configure other
address range than the default one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: laine@laine.org
7 years agocpu_x86: Implement virCPUValidateFeatures
Jiri Denemark [Thu, 14 Sep 2017 14:14:40 +0000 (16:14 +0200)]
cpu_x86: Implement virCPUValidateFeatures

The function checks whether all CPU features used in a CPU definition
are specified in cpu_map.xml.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu_s390: Implement virCPUValidateFeatures
Jiri Denemark [Thu, 14 Sep 2017 14:09:35 +0000 (16:09 +0200)]
cpu_s390: Implement virCPUValidateFeatures

Only feature policy is checked on s390, which was previously done in
virCPUUpdate, but that's not the correct place for the check once we
have virCPUValidateFeatures.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Validate guest CPU features before starting a domain
Jiri Denemark [Thu, 14 Sep 2017 14:07:59 +0000 (16:07 +0200)]
qemu: Validate guest CPU features before starting a domain

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu: Introduce virCPUValidateFeatures
Jiri Denemark [Thu, 14 Sep 2017 14:04:13 +0000 (16:04 +0200)]
cpu: Introduce virCPUValidateFeatures

This new API may be used to check whether all features used in a CPU
definition are valid (e.g., libvirt knows their name, their policy is
supported, etc.). Leaving this API unimplemented in an arch subdriver
means libvirt does not restrict CPU features usable on the associated
architectures.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Filter CPU features returned by qemuConnectBaselineCPU
Jiri Denemark [Wed, 13 Sep 2017 15:28:48 +0000 (17:28 +0200)]
qemu: Filter CPU features returned by qemuConnectBaselineCPU

The host CPU definitions reported in the capabilities XML may contain
CPU features unknown to QEMU, but the result of virConnectBaselineCPU is
supposed to be directly usable as a guest CPU definition and thus it
should only contain features QEMU knows about.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Publish virQEMUCapsCPUFilterFeatures
Jiri Denemark [Wed, 13 Sep 2017 15:28:13 +0000 (17:28 +0200)]
qemu: Publish virQEMUCapsCPUFilterFeatures

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Pass virArch * to virQEMUCapsCPUFilterFeatures
Jiri Denemark [Wed, 13 Sep 2017 15:26:07 +0000 (17:26 +0200)]
qemu: Pass virArch * to virQEMUCapsCPUFilterFeatures

The filter only needs to know the CPU architecture. Passing
virQEMUCapsPtr as opaque is a bit overkill.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu: Drop cpuBaselineXML
Jiri Denemark [Wed, 13 Sep 2017 14:27:15 +0000 (16:27 +0200)]
cpu: Drop cpuBaselineXML

The implementation of virConnectBaselineCPU may be different for each
hypervisor. Thus it shouldn't really be implmented in the cpu code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu: Don't log CPU models in cpuBaselineXML
Jiri Denemark [Wed, 13 Sep 2017 14:05:15 +0000 (16:05 +0200)]
cpu: Don't log CPU models in cpuBaselineXML

They are logged in cpuBaseline anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu: Use virCPUDefListParse in cpuBaselineXML
Jiri Denemark [Wed, 13 Sep 2017 13:38:31 +0000 (15:38 +0200)]
cpu: Use virCPUDefListParse in cpuBaselineXML

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu_conf: Introduce virCPUDefList{Parse,Free}
Jiri Denemark [Wed, 13 Sep 2017 13:23:43 +0000 (15:23 +0200)]
cpu_conf: Introduce virCPUDefList{Parse,Free}

For parsing a list of CPU XMLs into a NULL-terminated list of CPU defs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agovirsh: Enhance documentation of --rdma-pin-all option
Jiri Denemark [Fri, 8 Sep 2017 19:31:29 +0000 (21:31 +0200)]
virsh: Enhance documentation of --rdma-pin-all option

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agospec: Fix %license compat on RHEL6
Cole Robinson [Fri, 15 Sep 2017 17:04:18 +0000 (13:04 -0400)]
spec: Fix %license compat on RHEL6

The macro needs to be defined closer to its usage

7 years agospec: Use %license when available
Cole Robinson [Thu, 14 Sep 2017 21:21:29 +0000 (17:21 -0400)]
spec: Use %license when available

This is required by the fedora packaging guidelines:

https://fedoraproject.org/wiki/Packaging:LicensingGuidelines

This macro isn't available on stock RHEL6 so provide a backcompat
definition

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

Reported-by: Ville Skyttä <ville.skytta@iki.fi>
7 years agospec: Own %{_libdir}/libvirt{,/connection-driver} dirs
Ville Skyttä [Sun, 27 Aug 2017 16:35:07 +0000 (12:35 -0400)]
spec: Own %{_libdir}/libvirt{,/connection-driver} dirs

Owning all created directories is a requirement of the Fedora
packaging guidelines

https://bugzilla.redhat.com/show_bug.cgi?id=1483293
Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: Fix return check on virHashAddEntry call
John Ferlan [Fri, 15 Sep 2017 11:36:55 +0000 (07:36 -0400)]
qemu: Fix return check on virHashAddEntry call

Luckily it only returns 0 or -1

7 years agoconf: Use virXMLFormatElement to format disk source network
John Ferlan [Wed, 13 Sep 2017 20:45:51 +0000 (16:45 -0400)]
conf: Use virXMLFormatElement to format disk source network

Commit id 'e02ff020cac' neglected to use the attrBuf and childBuf
in the virDomainDiskSourceFormatNetwork call.

So make the necessary alterations to allow usage.

7 years agoconf: Move <disk> encryption validation
John Ferlan [Thu, 14 Sep 2017 15:01:40 +0000 (11:01 -0400)]
conf: Move <disk> encryption validation

Rather than checking during XML processing, move the check for
valid <encryption> into virDomainDiskDefParseValidate and alter
the text of the message slightly to be a bit more correct.

7 years agoconf: Add invalid domain disk encryption test
John Ferlan [Thu, 14 Sep 2017 15:14:57 +0000 (11:14 -0400)]
conf: Add invalid domain disk encryption test

Add a test to prove checking for invalid luks disk formatting check.
The error message will indicate supplying the <cipher> element is
unnecessary.

7 years agoconf: Move <disk> authdef validation
John Ferlan [Wed, 13 Sep 2017 15:00:28 +0000 (11:00 -0400)]
conf: Move <disk> authdef validation

Rather than checking during XML processing, move the checks for correct
and valid auth into virDomainDiskDefParseValidate. This will introduce
virDomainDiskSourceDefParseAuthValidate to validate that the authdef
stored for the virStorageSource is valid. This can then be expanded
to service backingStore sources as well.

Alter the message text slightly as well to distinguish between an
unknown name and an incorrectly used name.  Since type is not a
mandatory field, add the NULLSTR() around the output of the unknown
error. NB, a config using unknown formatting would fail virschematest
since it only accepts 'iscsi' and 'ceph' as "valid" types.

7 years agoconf: Add invalid secrettype checks
John Ferlan [Wed, 13 Sep 2017 19:24:41 +0000 (15:24 -0400)]
conf: Add invalid secrettype checks

Add a couple of tests to "validate" checks in domain_conf that either
a missing secrettype (CONFIG_UNSUPPORTED) or an mismatched secrettype
of ceph for an iSCSI disk (INTERNAL_ERROR) will cause a parsing error.

7 years agodocs: Remove unnecessary <auth> example for iscsi disk type='volume'
John Ferlan [Wed, 13 Sep 2017 18:22:55 +0000 (14:22 -0400)]
docs: Remove unnecessary <auth> example for iscsi disk type='volume'

Alter the example to remove the <auth> from:

  <disk type='volume' device='disk'>
    <driver name='qemu' type='raw'/>
    <source pool='iscsi-pool' volume='unit:0:0:1' mode='host'/>
    <auth username='myuser'>
      <secret type='iscsi' usage='libvirtiscsi'/>
    </auth>
    <target dev='vdb' bus='virtio'/>
  </disk>

and

  <disk type='volume' device='disk'>
    <driver name='qemu' type='raw'/>
    <source pool='iscsi-pool' volume='unit:0:0:2' mode='direct'/>
    <auth username='myuser'>
      <secret type='iscsi' usage='libvirtiscsi'/>
    </auth>
    <target dev='vdc' bus='virtio'/>
  </disk>

The reality is, it's not even used. For a <source pool> the authdef
from the storage source pool will supercede whatever is in the <disk>
definition during virStorageTranslateDiskSourcePool processing. In fact,
if the pool doesn't have/need authentication, then the authdef would
be removed anyway as the storage pool would be handling things.

The "proof" for this is in the adjustment to the test to add an
<auth> for a disk. The resulting .args file won't add what normally
would be added "myname:encodedpassword@" prior to the hostname in
the IQN (e.g. iscsi://myname:encodedpassword@iscsi.example.org:3260/...