]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agoqemu: implement input device hotunplug
Ján Tomko [Tue, 17 Oct 2017 14:44:24 +0000 (16:44 +0200)]
qemu: implement input device hotunplug

Allow unplugging USB and virtio USB devices.

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

7 years agoqemu: implement input device hotplug
Ján Tomko [Wed, 4 Oct 2017 09:09:27 +0000 (11:09 +0200)]
qemu: implement input device hotplug

For both virtio input devices and USB input devices.

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

7 years agoIntroduce qemuBuildInputDevStr
Ján Tomko [Wed, 4 Oct 2017 09:34:31 +0000 (11:34 +0200)]
Introduce qemuBuildInputDevStr

A function that builds the -device string for input devices.

7 years agosplit out qemuAssignDeviceInputAlias
Ján Tomko [Wed, 4 Oct 2017 09:09:22 +0000 (11:09 +0200)]
split out qemuAssignDeviceInputAlias

Move assignment of input device alias into a separate function,
for reuse on hotplug.

7 years agoqemu: allow cold unplugging of input devices
Ján Tomko [Tue, 3 Oct 2017 14:25:13 +0000 (16:25 +0200)]
qemu: allow cold unplugging of input devices

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

7 years agoqemu: allow coldplugging input devices
Ján Tomko [Tue, 3 Oct 2017 13:39:33 +0000 (15:39 +0200)]
qemu: allow coldplugging input devices

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

7 years agoUse qemuDomainEnsureVirtioAddress where possible
Ján Tomko [Thu, 12 Oct 2017 12:53:27 +0000 (14:53 +0200)]
Use qemuDomainEnsureVirtioAddress where possible

There are two more cases where we set an S390/CCW/PCI address
type based on the machine type.

Reuse qemuDomainEnsureVirtioAddress to reduce repetition.

7 years agoSplit out qemuDomainEnsureVirtioAddress
Ján Tomko [Thu, 12 Oct 2017 12:27:29 +0000 (14:27 +0200)]
Split out qemuDomainEnsureVirtioAddress

Split out the common code responsible for reserving/assigning
PCI/CCW addresses for virtio disks into a helper function
for reuse by other virtio devices.

7 years agoMove qemuCheckCCWS390AddressSupport to qemu_domain
Ján Tomko [Wed, 11 Oct 2017 13:06:07 +0000 (15:06 +0200)]
Move qemuCheckCCWS390AddressSupport to qemu_domain

Let it be reused in qemu_domain_address.

7 years agoqemuDomainAttachRNGDevice: do not access source.file randomly
Ján Tomko [Thu, 12 Oct 2017 12:55:53 +0000 (14:55 +0200)]
qemuDomainAttachRNGDevice: do not access source.file randomly

We pass the source.file to qemuCheckCCWS390AddressSupport for
the purpose of reporting an error message without actually checking
that the rng device is of type VIR_DOMAIN_RNG_BACKEND_RANDOM.

Change it to a hardcoded "rng" string, which also avoids
referring to the device by a host-side attribute.

7 years agoqemuDomainAttachControllerDevice: remove dead code
Ján Tomko [Thu, 12 Oct 2017 13:06:56 +0000 (15:06 +0200)]
qemuDomainAttachControllerDevice: remove dead code

After a successful attach, the device address has already been set.
Remove the pointless assignment.

7 years agoconf: audit passthrough input devices at domain startup
Ján Tomko [Mon, 16 Oct 2017 12:58:51 +0000 (14:58 +0200)]
conf: audit passthrough input devices at domain startup

Introduce virDomainAuditInput and use it to log the evdev passed
to the guest.

7 years agoqemu: implement virDomainSetLifecycleAction() API
Pavel Hrdina [Wed, 11 Oct 2017 14:09:49 +0000 (16:09 +0200)]
qemu: implement virDomainSetLifecycleAction() API

There is one limitation for using this API, when the guest is started
with all actions set to "destroy" we put "-no-reboot" on the QEMU
command line.  That cannot be changed while QEMU is running and
the QEMU process is always terminated no matter what is configured
for any action.

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

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: send allowReboot in migration cookie
Pavel Hrdina [Fri, 13 Oct 2017 10:06:54 +0000 (12:06 +0200)]
qemu: send allowReboot in migration cookie

We need to send allowReboot in the migration cookie to ensure the same
behavior of the virDomainSetLifecycleAction() API on the destination.

Consider this scenario:

    1. On the source the domain is started with:
        <on_poweroff>destroy</on_poweroff>
        <on_reboot>restart</on_reboot>
        <on_crash>destroy</on_crash>

    2. User calls an API to set "destroy" for <on_reboot>:
        <on_poweroff>destroy</on_poweroff>
        <on_reboot>destroy</on_reboot>
        <on_crash>destroy</on_crash>

    3. The guest is migrated to a different host

    4a. Without the allowReboot in the migration cookie the QEMU
        process on destination would be started with -no-reboot
        which would prevent using the virDomainSetLifecycleAction() API
        for the rest of the guest lifetime.

    4b. With the allowReboot in the migration cookie the QEMU process
        on destination is started without -no-reboot like it was started
        on the source host and the virDomainSetLifecycleAction() API
        continues to work.

The following patch adds a QEMU implementation of the
virDomainSetLifecycleAction() API and that implementation disallows
using the API if all actions are set to "destroy" because we add
"-no-reboot" on the QEMU command line.  Changing the lifecycle action
is in this case pointless because the QEMU process is always terminated.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: move detection whether to use -no-reboot to qemu_domain
Pavel Hrdina [Wed, 11 Oct 2017 13:57:16 +0000 (15:57 +0200)]
qemu: move detection whether to use -no-reboot to qemu_domain

This will be used later on in implementation of new API
virDomainSetLifecycleAction().  In order to use it, we need to store
the value in status XML to not lose the information if libvirtd is
restarted.

If some guest was started by old libvirt where it was not possible
to change the lifecycle action for running guest, we can safely
detect it based on the current actions from the status XML.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agovirsh: introduce set-lifecycle-action command
Pavel Hrdina [Thu, 12 Oct 2017 14:25:43 +0000 (16:25 +0200)]
virsh: introduce set-lifecycle-action command

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agolib: introduce virDomainSetLifecycleAction() API
Pavel Hrdina [Wed, 11 Oct 2017 12:02:01 +0000 (14:02 +0200)]
lib: introduce virDomainSetLifecycleAction() API

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: pass priv data instead of qemuCaps and autoNodeset
Pavel Hrdina [Wed, 11 Oct 2017 11:09:50 +0000 (13:09 +0200)]
qemu: pass priv data instead of qemuCaps and autoNodeset

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: pass priv data to qemuBuildMasterKeyCommandLine
Pavel Hrdina [Wed, 11 Oct 2017 11:08:13 +0000 (13:08 +0200)]
qemu: pass priv data to qemuBuildMasterKeyCommandLine

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: pass priv data to qemuBuildPMCommandLine
Pavel Hrdina [Wed, 11 Oct 2017 11:07:19 +0000 (13:07 +0200)]
qemu: pass priv data to qemuBuildPMCommandLine

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: pass priv data to qemuBuildMonitorCommandLine
Pavel Hrdina [Wed, 11 Oct 2017 11:06:09 +0000 (13:06 +0200)]
qemu: pass priv data to qemuBuildMonitorCommandLine

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: pass virDomainObjPtr to qemuBuildCommandLine
Pavel Hrdina [Wed, 11 Oct 2017 10:44:30 +0000 (12:44 +0200)]
qemu: pass virDomainObjPtr to qemuBuildCommandLine

Extract the required data inside a function instead of passing it
all as arguments.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: merge virDomainLifecycleCrashAction with virDomainLifecycleAction
Pavel Hrdina [Tue, 10 Oct 2017 12:51:38 +0000 (14:51 +0200)]
conf: merge virDomainLifecycleCrashAction with virDomainLifecycleAction

There is no need to have two different enums where one has the same
values as the other one with some additions.

Currently for on_poweroff and on_reboot we allow only subset of actions
that are allowed for on_crash.  This was covered in parse time using
two different enums.  Now to make sure that we don't allow setting
actions that are not supported we need to check it while validating
domain config.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: introduce virDomainLifecycle enum to list all lifecycle types
Pavel Hrdina [Tue, 10 Oct 2017 11:35:30 +0000 (13:35 +0200)]
conf: introduce virDomainLifecycle enum to list all lifecycle types

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: rename virDomainLifecycleAction enum functions
Pavel Hrdina [Tue, 10 Oct 2017 12:32:58 +0000 (14:32 +0200)]
conf: rename virDomainLifecycleAction enum functions

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: rename lifecycle enum values to correspond with typedef keyword
Pavel Hrdina [Tue, 10 Oct 2017 12:32:11 +0000 (14:32 +0200)]
conf: rename lifecycle enum values to correspond with typedef keyword

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agobhyve: Fix build
Jiri Denemark [Thu, 19 Oct 2017 09:13:54 +0000 (11:13 +0200)]
bhyve: Fix build

Commit v3.8.0-95-gfd885a06a dropped nmodels parameter from several APIs
in src/cpu/cpu.h, but failed to update all callers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agonodedev: udev: Hook up virFileWaitForAccess to work around uevent race
Erik Skultety [Tue, 20 Jun 2017 14:15:22 +0000 (16:15 +0200)]
nodedev: udev: Hook up virFileWaitForAccess to work around uevent race

If we find ourselves in the situation that the 'add' uevent has been
fired earlier than the sysfs tree for a device was created, we should
use the best-effort approach and give kernel some predetermined amount
of time, thus waiting for the attributes to be ready rather than
discarding the device from our device list forever. If those don't appear
in the given time frame, we need to move on, since libvirt can't wait
indefinitely.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoutil: Introduce virFileWaitForExists
Erik Skultety [Tue, 20 Jun 2017 14:09:33 +0000 (16:09 +0200)]
util: Introduce virFileWaitForExists

Since we have a number of places where we workaround timing issues with
devices, attributes (files in general) not being available at the time
of processing them by calling usleep in a loop for a fixed number of
tries, we could as well have a utility function that would do that.
Therefore we won't have to duplicate this ugly workaround even more.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Convert udevEventHandleThread to an actual thread routine
Erik Skultety [Wed, 28 Jun 2017 12:34:41 +0000 (14:34 +0200)]
nodedev: udev: Convert udevEventHandleThread to an actual thread routine

Adjust udevEventHandleThread to be a proper thread routine running in an
infinite loop handling devices. The handler thread pulls all available
data from the udev monitor and only then waits until a wakeup signal for
new incoming data has been emitted by udevEventHandleCallback.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Split udevEventHandleCallback in two functions
Erik Skultety [Wed, 28 Jun 2017 12:20:37 +0000 (14:20 +0200)]
nodedev: udev: Split udevEventHandleCallback in two functions

This patch splits udevEventHandleCallback in two (introduces
udevEventHandleThread) in order to be later able to refactor the latter
to actually become a normal thread which will wait some time for the
kernel to create the whole sysfs tree for a device as we cannot do that
in the event loop directly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Unlock the private data before setting up 'system' node
Erik Skultety [Wed, 18 Oct 2017 12:58:51 +0000 (14:58 +0200)]
nodedev: udev: Unlock the private data before setting up 'system' node

udevSetupSystemDev only needs the udev data lock to be locked because of
calling udevGetDMIData which accesses some protected structure members,
but it can do that on its own just fine, no need to hold the lock the
whole time.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Remove driver locks from stateInitialize and stateCleanup
Erik Skultety [Wed, 18 Oct 2017 10:51:40 +0000 (12:51 +0200)]
nodedev: udev: Remove driver locks from stateInitialize and stateCleanup

The driver locks are unnecessary here, since currently the cleanup is
only called from the main daemon thread, so we can't race here. Moreover
@devs and @privateData are self-lockable objects, so no problem there
either.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Convert udev private data to a lockable object
Erik Skultety [Fri, 6 Oct 2017 13:21:55 +0000 (15:21 +0200)]
nodedev: udev: Convert udev private data to a lockable object

Since there's going to be a worker thread which needs to have some data
protected by a lock, the whole code would just simply get unnecessary
complex, since two sets of locks would be necessary, driver lock (for
udev monitor and event handle) and a mutex protecting thread-local data.
Given the future thread will need to access the udev monitor socket as
well, why not protect everything with a single lock, even better, by
converting the driver's private data to a lockable object, we get the
automatic object disposal feature for free.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Introduce udevEventMonitorSanityCheck helper function
Erik Skultety [Wed, 26 Jul 2017 13:16:09 +0000 (15:16 +0200)]
nodedev: udev: Introduce udevEventMonitorSanityCheck helper function

We need to perform a sanity check on the udev monitor before every
use so that we know nothing has changed in the meantime. The reason for
moving the code to a separate helper is to enhance readability and shift
the focus on the important stuff within the udevEventHandleCallback
handler.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: Move privileged flag from udev private data to driver's state
Erik Skultety [Mon, 16 Oct 2017 09:53:33 +0000 (11:53 +0200)]
nodedev: Move privileged flag from udev private data to driver's state

Even though hal doesn't make use of it, the privileged flag is related
to the daemon/driver rather than the backend actually used.
While at it, get rid of some tab indentation in the driver state struct.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agovirsh: domifaddr: clarify description of --full option
Chen Hanxiao [Mon, 16 Oct 2017 06:53:22 +0000 (14:53 +0800)]
virsh: domifaddr: clarify description of --full option

Option --full will always display the name and MAC address of the
the interface. Both virsh help and virsh man page didn't mention that.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agomaint: Remove not-so-much informative block commentaries
Erik Skultety [Tue, 17 Oct 2017 07:34:55 +0000 (09:34 +0200)]
maint: Remove not-so-much informative block commentaries

There were a bunch of commentary blocks that were literally useless in
terms of describing what the code following them does, since most of
them were documenting "the obvious" or it just wouldn't help at all.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agomaint: Replace tabs with spaces in all source files in repo
Erik Skultety [Tue, 17 Oct 2017 15:05:47 +0000 (17:05 +0200)]
maint: Replace tabs with spaces in all source files in repo

So we have a syntax-check rule to catch all tab indents but it naturally
can't catch tab spacing, i.e. as a delimiter. This patch is a result of
running 'vim -en +retab +wq'
(using tabstop=8 softtabstop=4 shiftwidth=4 expandtab) on each file from
a list generated by the following:
find . -regextype gnu-awk \
         -regex ".*\.(rng|syms|html|s?[ch]|py|pl|php(\.code)?)(\.in)?" \
         | xargs git grep -lP "\t"

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoutil: storagefile: Track whether a virStorageSource was auto-detected
Peter Krempa [Tue, 26 Sep 2017 11:52:43 +0000 (13:52 +0200)]
util: storagefile: Track whether a virStorageSource was auto-detected

When formatting an inactive or migratable XML we will need to suppress
backing chain members which were detected from the disk to keep
semantics straight. This means we need to record, whether a
virStorageSource originates from autodetection.

7 years agoqemu: block: Add support for file/block/dir storage to JSON disk src generator
Peter Krempa [Thu, 13 Jul 2017 07:48:14 +0000 (09:48 +0200)]
qemu: block: Add support for file/block/dir storage to JSON disk src generator

qemuBlockStorageSourceGetBackendProps now is able to format the JSON
definition for regular storage too.

7 years agoqemu: command: Separate wrapping of disk backend props to 'file' object
Peter Krempa [Tue, 10 Oct 2017 06:23:12 +0000 (08:23 +0200)]
qemu: command: Separate wrapping of disk backend props to 'file' object

The file object is needed when formatting the command line, but it makes
nesting of the objects less easy for use with blockdev. Separate the
wrapping into the 'file' object into a helper used specifically for disk
sources in the old code path.

7 years agoqemu: Move qemuFreeKeywords into qemu_parse_command.c
Kothapally Madhu Pavan [Mon, 16 Oct 2017 20:20:04 +0000 (01:50 +0530)]
qemu: Move qemuFreeKeywords into qemu_parse_command.c

Move qemuFreeKeywords into qemu_parse_command.c as
qemuParseKeywordsFree and call it rather than inline code
in multiple places.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agodocs: Fix multiUser/replaceUser in RDP display doc.
Dawid Zamirski [Tue, 10 Oct 2017 21:52:02 +0000 (17:52 -0400)]
docs: Fix multiUser/replaceUser in RDP display doc.

The original description from commit id '24e0171b' got it backwards.

7 years agocputest: Add query-cpu-definitions reply for Xeon-E7-8890
Jiri Denemark [Tue, 10 Oct 2017 11:33:30 +0000 (13:33 +0200)]
cputest: Add query-cpu-definitions reply for Xeon-E7-8890

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Update Xeon-E7-8890 data
Jiri Denemark [Tue, 10 Oct 2017 11:32:22 +0000 (13:32 +0200)]
cputest: Update Xeon-E7-8890 data

Without the fix in the previous patch the JSON data from QEMU would be
interpreted as Haswell-noTSX because x86DataFilterTSX would filter rtm
and hle features as a result of

    family == 6 && model == 63 && stepping < 4

test even though this CPU has stepping == 4.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Parse CPU stepping from query-cpu-model-expansion
Jiri Denemark [Tue, 10 Oct 2017 11:34:28 +0000 (13:34 +0200)]
qemu: Parse CPU stepping from query-cpu-model-expansion

Even though only family and model are used for matching CPUID data with
CPU models from cpu_map.xml, stepping is used by x86DataFilterTSX which
is supposed to disable TSX on CPU models with broken TSX support. Thus
we need to start parsing stepping from QEMU to make sure we don't
disable TSX on CPUs which provide working TSX implementation. See the
following patch for a real world example of such CPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: fix use of uninitialized variable
Nikolay Shirokovskiy [Tue, 17 Oct 2017 13:56:33 +0000 (16:56 +0300)]
conf: fix use of uninitialized variable

If same boot order is specified twice (or more) in domain xml
we call free for uninitiaziled loadparm on cleanup in virDomainDeviceBootParseXML
and SIGABRT (or similar) as a result.

7 years agovz: fix typo for 0d3d020b
Nikolay Shirokovskiy [Tue, 17 Oct 2017 13:55:15 +0000 (16:55 +0300)]
vz: fix typo for 0d3d020b

7 years agovz: missing pieces for fd885a06 for vz driver
Nikolay Shirokovskiy [Tue, 17 Oct 2017 13:55:14 +0000 (16:55 +0300)]
vz: missing pieces for fd885a06 for vz driver

7 years agoqemu: Fix CPU model broken by older libvirt
Jiri Denemark [Fri, 6 Oct 2017 12:49:07 +0000 (14:49 +0200)]
qemu: Fix CPU model broken by older libvirt

When libvirt older than 3.9.0 reconnected to a running domain started by
old libvirt it could have messed up the expansion of host-model by
adding features QEMU does not support (such as cmt). Thus whenever we
reconnect to a running domain, revert to an active snapshot, or restore
a saved domain we need to check the guest CPU model and remove the
CPU features unknown to QEMU. We can do this because we know the domain
was successfully started, which means the CPU did not contain the
features when libvirt started the domain.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Filter CPU features when using host CPU
Jiri Denemark [Fri, 6 Oct 2017 11:23:36 +0000 (13:23 +0200)]
qemu: Filter CPU features when using host CPU

When reconnecting to a domain started with a host-model CPU which was
started by old libvirt that did not replace host-model with the real CPU
definition, libvirt replaces the host-model CPU with the CPU from
capabilities (because this is what the old libvirt did when it started
the domain). Without this patch libvirt could use features unknown to
QEMU in the CPU definition which replaced the original host-model CPU.
Such domain would keep running just fine, but any attempt to migrate it
will fail and once the domain is saved or snapshotted, restoring it
would fail too.

In other words whenever we want to use the CPU definition from host
capabilities as a guest CPU definition, we have to filter the unknown
features.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: Introduce virCPUDefFindFeature
Jiri Denemark [Mon, 9 Oct 2017 14:20:43 +0000 (16:20 +0200)]
conf: Introduce virCPUDefFindFeature

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Separate CPU updating code from qemuProcessReconnect
Jiri Denemark [Fri, 6 Oct 2017 10:57:15 +0000 (12:57 +0200)]
qemu: Separate CPU updating code from qemuProcessReconnect

The new function is called qemuProcessRefreshCPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Check QEMU error on failed migration
Jiri Denemark [Thu, 12 Oct 2017 13:19:19 +0000 (15:19 +0200)]
qemu: Check QEMU error on failed migration

When migration fails, QEMU may provide a description of the error in
the reply to query-migrate QMP command. We can fetch this error and use
it instead of the generic "unexpectedly failed" message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agodocs: remove duplicate https links
Ján Tomko [Tue, 17 Oct 2017 07:16:52 +0000 (09:16 +0200)]
docs: remove duplicate https links

Commit e371b3b changed all the links to libvirt.org to use https.
Remove the leftover 'http' links from downloads page, since they
point to https anyway.

7 years agoTerminate backing chains explicitly
Peter Krempa [Thu, 12 Oct 2017 17:13:44 +0000 (19:13 +0200)]
Terminate backing chains explicitly

Express a properly terminated backing chain by putting a
virStorageSource of type VIR_STORAGE_TYPE_NONE in the chain. The newly
used helpers simplify this greatly.

The change fixes a bug as formatting an incomplete backing chain and
parsing it back would end up in expressing a terminated chain since
src->backingStoreRaw was not populated. By relying on the terminator
object this can be now processed appropriately.

7 years agoutil: storagefile: Add helpers to check presence of backing store
Peter Krempa [Thu, 12 Oct 2017 17:27:40 +0000 (19:27 +0200)]
util: storagefile: Add helpers to check presence of backing store

Add helpers that will simplify checking if a backing file is valid or
whether it has backing store. The helper virStorageSourceIsBacking
returns true if the given virStorageSource is a valid backing store
member. virStorageSourceHasBacking returns true if the virStorageSource
has a backing store child.

Adding these functions creates a central points for further refactors.

7 years agotest: set 'type' field of virStorageSource
Peter Krempa [Thu, 12 Oct 2017 18:45:50 +0000 (20:45 +0200)]
test: set 'type' field of virStorageSource

Set the type so that the iterators will work after upcoming
modification.

7 years agostorage: Fill in 'type' field for virStorageSource in storage driver
Peter Krempa [Thu, 12 Oct 2017 18:31:33 +0000 (20:31 +0200)]
storage: Fill in 'type' field for virStorageSource in storage driver

Storage driver uses virStorageSource only partially to store it's
configuration but fully when parsing backing files of storage volumes.
This patch sets the 'type' field to a value other than
VIR_STORAGE_TYPE_NONE so that further patches can add a terminator
element to backing chains without breaking iteration.

7 years agoutil: storagefile: Tolerate NULL path when looking up volume in chain
Peter Krempa [Thu, 12 Oct 2017 17:26:10 +0000 (19:26 +0200)]
util: storagefile: Tolerate NULL path when looking up volume in chain

chain->path may be NULL e.g. for NBD drives, so the check needs to avoid
dereferencing the path in such case

7 years agoutil: storage: use stored index to lookup disks
Peter Krempa [Fri, 6 Oct 2017 12:23:05 +0000 (14:23 +0200)]
util: storage: use stored index to lookup disks

We can now use the backing store ID directly rather than counting the
number of images seen while looking up images.

7 years agoutil: storage: Store backing chain index in virStorageSource
Peter Krempa [Fri, 6 Oct 2017 11:35:24 +0000 (13:35 +0200)]
util: storage: Store backing chain index in virStorageSource

The backing store indexes were not bound to the storage sources in any
way. To allow us to bind a given alias to a given storage source we need
to save the index in virStorageSource. The backing store ids are now
generated when detecting the backing chain.

Since we don't re-detect the backing chain after snapshots, the
numbering needs to be fixed there.

7 years agoconf: Make backing store index optional
Peter Krempa [Tue, 26 Sep 2017 12:00:57 +0000 (14:00 +0200)]
conf: Make backing store index optional

Index will remain an internal property even if we allow backing store
parsing from the XML, so we need to allow backing store without it in
the schema.

7 years agoconf: domain: Simplify return from backing store parser
Peter Krempa [Fri, 6 Oct 2017 10:50:30 +0000 (12:50 +0200)]
conf: domain: Simplify return from backing store parser

Use VIR_STEAL_PTR to remove conditional cleanup.

7 years agoqemu: argv: parse qemu commandline memory arguments
Kothapally Madhu Pavan [Mon, 9 Oct 2017 17:16:29 +0000 (22:46 +0530)]
qemu: argv: parse qemu commandline memory arguments

Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
format along with existing format. And adds a testcase to validate the changes.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agohyperv: Map Limit to max_memory and VirtualQuantity to cur_balloon
Ladi Prosek [Fri, 6 Oct 2017 06:47:35 +0000 (08:47 +0200)]
hyperv: Map Limit to max_memory and VirtualQuantity to cur_balloon

Hyper-V uses its own specific memory management so no mapping is going to
be perfect. However, it is more correct to map Limit to max_memory (it
really is the upper limit of what the VM may potentially use) and keep
cur_balloon equal to total_memory.

The typical value returned from Hyper-V in Limit is 1 TiB, which is not
really going to work if interpreted as "startup memory" to be ballooned
away later.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
7 years agohyperv: Escape WQL queries
Ladi Prosek [Fri, 6 Oct 2017 06:47:34 +0000 (08:47 +0200)]
hyperv: Escape WQL queries

The code was vulnerable to SQL injection. Likely not a security issue due to
WMI SQL and other constraints but still lame. For example:

  virsh # dominfo \"
  error: failed to get domain '"'
  error: internal error: SOAP fault during enumeration: code 's:Sender', subcode
  'n:CannotProcessFilter', reason 'The data source could not process the filter.
  The filter might be missing or it might be invalid. Change the filter and try
  the request again.  ', detail 'The WS-Management service cannot process the
  request. The WQL query is invalid. '

This commit fixes the Hyper-V driver by escaping all WMI SQL string parameters.

The same command with the fix:

  virsh # dominfo \"
  error: failed to get domain '"'
  error: Domain not found: No domain with name "

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
7 years agohyperv: Fix hypervInitConnection error reporting
Ladi Prosek [Fri, 6 Oct 2017 06:47:33 +0000 (08:47 +0200)]
hyperv: Fix hypervInitConnection error reporting

"%s is not a Hyper-V server" is not a correct generalization of all possible
error conditions of hypervEnumAndPull. For example:

  $ virsh --connect hyperv://localhost/?transport=http
  Enter username for localhost [administrator]:
  Enter administrator's password for localhost: <enters incorrect password>
  error: failed to connect to the hypervisor
  error: internal error: localhost is not a Hyper-V server

This commit removes the general virReportError from hypervInitConnection and
also the "Invalid query" virReportError from hypervSerializeEprParam, which
does not correctly describe the error either (virBufferCheckError has
already set a meaningful error message at that point).

The same scenario with the fix:

  $ virsh --connect hyperv://localhost/?transport=http
  Enter username for localhost [administrator]:
  Enter administrator's password for localhost: <enters incorrect password>
  error: failed to connect to the hypervisor
  error: internal error: Transport error during enumeration: User, password or
  similar was not accepted (26)

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
7 years agoqemu: ensure TLS clients always verify the server certificate
Daniel P. Berrange [Thu, 5 Oct 2017 16:54:28 +0000 (17:54 +0100)]
qemu: ensure TLS clients always verify the server certificate

The default_tls_x509_verify (and related) parameters in qemu.conf
control whether the QEMU TLS servers request & verify certificates
from clients. This works as a simple access control system for
servers by requiring the CA to issue certs to permitted clients.
This use of client certificates is disabled by default, since it
requires extra work to issue client certificates.

Unfortunately the code was using this configuration parameter when
setting up both TLS clients and servers in QEMU. The result was that
TLS clients for character devices and disk devices had verification
turned off, meaning they would ignore errors while validating the
server certificate.

This allows for trivial MITM attacks between client and server,
as any certificate returned by the attacker will be accepted by
the client.

This is assigned CVE-2017-1000256  / LSN-2017-0002

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoUse https:// links for most sites
Daniel P. Berrange [Fri, 13 Oct 2017 15:30:41 +0000 (16:30 +0100)]
Use https:// links for most sites

This adds a rule to require https links for the libvirt, qemu
and kvm websites.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoRemove obsolete TODO file
Daniel P. Berrange [Fri, 13 Oct 2017 15:31:07 +0000 (16:31 +0100)]
Remove obsolete TODO file

We stopped autogenerating a TODO file from RFE bugs a long time
ago.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: reserve PCI addresses for implicit i440fx devices
Ján Tomko [Tue, 26 Sep 2017 10:35:29 +0000 (12:35 +0200)]
qemu: reserve PCI addresses for implicit i440fx devices

Somewhere around commit 9ff9d9f reserving entire PCI slots was
eliminated, as demonstrated by commit 6cc2014.

Reserve the functions required by the implicit devices:
00:01.0 ISA Bridge
00:01.1 IDE Controller
00:01.2 USB Controller (unless USB is disabled)
00:01.3 Bridge

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

7 years agocputest: Make a crippled version of Core-i7-2600
Jiri Denemark [Tue, 3 Oct 2017 22:55:46 +0000 (00:55 +0200)]
cputest: Make a crippled version of Core-i7-2600

xsaveopt is artificially removed from the host to test disabled feature
which is only included in QEMU's version of the CPU model.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Update Core-i7-2600 data
Jiri Denemark [Wed, 4 Oct 2017 12:01:25 +0000 (14:01 +0200)]
cputest: Update Core-i7-2600 data

arat is now enabled even if the hardware does not support it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Add query-cpu-definitions reply for Xeon-E3-1245
Jiri Denemark [Tue, 26 Sep 2017 19:08:58 +0000 (21:08 +0200)]
cputest: Add query-cpu-definitions reply for Xeon-E3-1245

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Update Xeon-E3-1245 data
Jiri Denemark [Wed, 20 Sep 2017 08:50:01 +0000 (10:50 +0200)]
cputest: Update Xeon-E3-1245 data

xsaves is supported by current QEMU/KVM on this CPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Add query-cpu-definitions reply for Xeon-E7-4830
Jiri Denemark [Tue, 26 Sep 2017 20:14:25 +0000 (22:14 +0200)]
cputest: Add query-cpu-definitions reply for Xeon-E7-4830

This CPU was incorrectly detected as SandyBridge before because the
number of additional <feature> elements was the same for both
SandyBridge and Westmere CPU models, but SandyBridge is newer (the CPU
signature does not help here because it doesn't match any signature
defined in cpu_map.xml). But since QEMU's version of SandyBridge CPU
model contains xsaveopt which needs to be disabled, Westmere becomes the
best CPU model when translating CPUID data to virCPUDef. Unfortunately,
this doesn't help with translating the data we got from QEMU and the CPU
model is still computed as SandyBridge in this case.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Add CPUID data for Intel(R) Xeon(R) CPU E7-4830
Jiri Denemark [Tue, 26 Sep 2017 19:57:04 +0000 (21:57 +0200)]
cputest: Add CPUID data for Intel(R) Xeon(R) CPU E7-4830

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Add query-cpu-definitions reply for Core-i5-2540M
Jiri Denemark [Tue, 26 Sep 2017 21:07:47 +0000 (23:07 +0200)]
cputest: Add query-cpu-definitions reply for Core-i5-2540M

The unavailable features do not make any difference in this case,
because this is a SandyBridge CPU which has an empty list of unavailable
features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Use CPU models from QEMU when available
Jiri Denemark [Wed, 27 Sep 2017 07:29:28 +0000 (09:29 +0200)]
cputest: Use CPU models from QEMU when available

When testing cpuDecode for computing guest CPU definition from CPUID
data (the CPU definition reported by domain capabilities), we need to
use CPU models (and their usability blockers) from QEMU if they are
available to cpuDecode in the same way it is actually used in the qemu
driver.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Separate QEMUCaps creation from cpuTestCPUIDJson
Jiri Denemark [Wed, 27 Sep 2017 09:58:23 +0000 (11:58 +0200)]
cputest: Separate QEMUCaps creation from cpuTestCPUIDJson

To make the code reusable by other tests.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Test CPU usability blockers
Jiri Denemark [Tue, 26 Sep 2017 19:08:37 +0000 (21:08 +0200)]
cputest: Test CPU usability blockers

Gather query-cpu-definitions results and use them for testing CPU model
usability blockers in CPUID to virCPUDef translation.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Print correct feature in virCPUUpdateLive test
Jiri Denemark [Wed, 27 Sep 2017 09:21:36 +0000 (11:21 +0200)]
cputest: Print correct feature in virCPUUpdateLive test

If the actual result does not match our expectation, the tests would
not correctly show the difference if a CPU feature is disabled in the
expected result and the actual result does not mention it at all. The
test could complain about an unrelated CPU feature or it could even
crash in case the actual result contains no more features to go through.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Avoid calling json_reformat in cpu-parse.sh
Jiri Denemark [Tue, 26 Sep 2017 21:02:48 +0000 (23:02 +0200)]
cputest: Avoid calling json_reformat in cpu-parse.sh

Various version of json_reformat use different number of spaces for
indenting. Let's use a simple python reformatter to gain full control
over the formatting for consistent results.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Replace bool with cpuTestCPUIDJson enum
Jiri Denemark [Tue, 26 Sep 2017 19:01:56 +0000 (21:01 +0200)]
cputest: Replace bool with cpuTestCPUIDJson enum

We will soon need to handle more than two values.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocpu_x86: Disable blockers from unusable CPU models
Jiri Denemark [Fri, 13 Oct 2017 16:17:52 +0000 (18:17 +0200)]
cpu_x86: Disable blockers from unusable CPU models

When decoding CPUID data to virCPUDef we need to be careful about using
a CPU model which cannot be directly used on the current host. Normally,
libvirt would notice the features which prevent the model from being
usable and it would disable them in the computed virCPUDef, but this
won't work in case the definition of the CPU model in QEMU contains more
features than what we have in cpu_map.xml. We need to count with the
usability blockers we got from QEMU and explicitly disable all of them
to make the computed virCPUDef usable.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocpu_x86: Move x86FeatureFind* to avoid forward prototypes
Jiri Denemark [Tue, 26 Sep 2017 12:52:34 +0000 (14:52 +0200)]
cpu_x86: Move x86FeatureFind* to avoid forward prototypes

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Introduce virDomainCapsCPUModelsGet
Jiri Denemark [Fri, 13 Oct 2017 15:37:34 +0000 (17:37 +0200)]
conf: Introduce virDomainCapsCPUModelsGet

This internal API can be used to find a specific CPU model in
virDomainCapsCPUModels list.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocpu: Drop unused parameter from cpuDecode
Jiri Denemark [Tue, 26 Sep 2017 08:24:05 +0000 (10:24 +0200)]
cpu: Drop unused parameter from cpuDecode

The "preferred" parameter is not used by any caller of cpuDecode
anymore. It's only used internally in cpu_x86 to implement cpuBaseline.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocpu: Use virDomainCapsCPUModelsPtr in cpu driver APIs
Jiri Denemark [Fri, 22 Sep 2017 13:51:33 +0000 (15:51 +0200)]
cpu: Use virDomainCapsCPUModelsPtr in cpu driver APIs

All APIs which expect a list of CPU models supported by hypervisors were
switched from char **models and int models to just accept a pointer to
virDomainCapsCPUModels object stored in domain capabilities. This avoids
the need to transform virDomainCapsCPUModelsPtr into a NULL-terminated
list of model names and also allows the various cpu driver APIs to
access additional details (such as its usability) about each CPU model.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Parse unavailable features for CPU models
Jiri Denemark [Wed, 20 Sep 2017 08:45:49 +0000 (10:45 +0200)]
qemu: Parse unavailable features for CPU models

query-cpu-definitions QMP command returns a list of unavailable features
which prevent CPU models from being usable on the current host. So far
we only checked whether the list was empty to mark CPU models as
(un)usable. This patch parses all unavailable features for each CPU
model and stores them in virDomainCapsCPUModel as a list of usability
blockers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Store CPU usability blockers in caps cache
Jiri Denemark [Thu, 21 Sep 2017 14:11:14 +0000 (16:11 +0200)]
qemu: Store CPU usability blockers in caps cache

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Add usability blockers to virDomainCapsCPUModel
Jiri Denemark [Tue, 19 Sep 2017 16:35:08 +0000 (18:35 +0200)]
conf: Add usability blockers to virDomainCapsCPUModel

When a hypervisor marks a CPU model as unusable on the current host, it
may also give us a list of features which prevent the model from being
usable. Storing this list in virDomainCapsCPUModel will help the CPU
driver with creating a host-model CPU configuration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Introduce virStringListCopy
Jiri Denemark [Wed, 20 Sep 2017 08:41:35 +0000 (10:41 +0200)]
util: Introduce virStringListCopy

The API makes a deep copy of a NULL-terminated string list.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agovirDomainDeviceInfoParseXML: Clear whole @info on failure
Michal Privoznik [Tue, 3 Oct 2017 08:38:50 +0000 (10:38 +0200)]
virDomainDeviceInfoParseXML: Clear whole @info on failure

Currently, if parsing of device info fails info->alias is freed.
It doesn't make much sense to leave the rest of the struct
behind.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirDomainDeviceInfoParseXML: Separate address parsing into separate func
Michal Privoznik [Tue, 3 Oct 2017 08:35:52 +0000 (10:35 +0200)]
virDomainDeviceInfoParseXML: Separate address parsing into separate func

There's one 'return' in the middle of the function body. It's
very easy to miss and so it makes adding new code harder. Also
the function doesn't follow our style 100%.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirDomainInterfaceStats: Accept MAC addresses properly
Michal Privoznik [Fri, 13 Oct 2017 23:29:36 +0000 (16:29 -0700)]
virDomainInterfaceStats: Accept MAC addresses properly

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

In 0d3d020ba6c4f I've added capability to accept MAC addresses
for the API too. However, the implementation was faulty. It needs
to lookup the corresponding interface in the domain definition
and pass the ifname instead of MAC address.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Fix missing network devices
John Ferlan [Tue, 10 Oct 2017 13:04:54 +0000 (09:04 -0400)]
nodedev: Fix missing network devices

Commit id '8708ca01c' added a check to determine whether the NIC had
Switchdev capabilities; however, in doing so inadvertently would cause
network devices without a PCI device to not be added to the node device
database. Thus, network devices having a "computer" as a parent, such
as "net_lo*", "net_virbr*", "net_tun*", "net_vnet*", etc. were not added.

Alter the check to not even check for Switchdev bits if no PCI device found.

7 years agovirsh: Deal with multiple matching devices in domif-getlink
Michal Privoznik [Wed, 4 Oct 2017 15:39:59 +0000 (17:39 +0200)]
virsh: Deal with multiple matching devices in domif-getlink

The command tries to match interface in domain definition by MAC
address or interface name. However, since it's possible to
configure two interfaces with the same MAC address, it may
happen that the XPath returns two or more nodes. We should check
for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>