]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
7 years agotests: Test user set aliases for qemu
Michal Privoznik [Fri, 20 Oct 2017 14:48:14 +0000 (16:48 +0200)] 
tests: Test user set aliases for qemu

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Parse alias from inactive XMLs
Michal Privoznik [Thu, 19 Oct 2017 06:39:40 +0000 (08:39 +0200)] 
qemu: Parse alias from inactive XMLs

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

This way users can uniquely identify devices at define time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodocs: Document user aliases
Michal Privoznik [Wed, 18 Oct 2017 11:48:46 +0000 (13:48 +0200)] 
docs: Document user aliases

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Format alias even for inactive XMLs
Michal Privoznik [Wed, 18 Oct 2017 11:12:08 +0000 (13:12 +0200)] 
conf: Format alias even for inactive XMLs

We need to format alias even for inactive XMLs since that's the
way how users are going to identify their devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuhotplugtest: Load active XML
Michal Privoznik [Tue, 17 Oct 2017 11:13:08 +0000 (13:13 +0200)] 
qemuhotplugtest: Load active XML

The point of this test is to load live XML and test hotplug. But
even though the XMLs we are parsing are live, the parsing is done
with VIR_DOMAIN_DEF_PARSE_INACTIVE flag.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuxml2argvdata: Drop device aliases
Michal Privoznik [Tue, 17 Oct 2017 11:27:01 +0000 (13:27 +0200)] 
qemuxml2argvdata: Drop device aliases

The qemuxml2argvtest expects the domain XMLs to be inactive ones.
Therefore we should pass inactive XMLs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuDomainABIStabilityCheck: Check for memory aliases too
Michal Privoznik [Tue, 17 Oct 2017 08:42:54 +0000 (10:42 +0200)] 
qemuDomainABIStabilityCheck: Check for memory aliases too

Since we will be allowing users to set device aliases and memory
devices are fragile when it comes to aliases we have to make sure
they won't change during migration. Other devices should be fine.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Validate user supplied aliases
Michal Privoznik [Wed, 18 Oct 2017 15:46:18 +0000 (17:46 +0200)] 
conf: Validate user supplied aliases

They have to be unique within the domain. As usual, backwards
compatibility takes its price. In this particular situation we
have a device that is represented twice in a domain and so is its
alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Parse user supplied aliases
Michal Privoznik [Wed, 18 Oct 2017 12:59:01 +0000 (14:59 +0200)] 
conf: Parse user supplied aliases

If driver that is calling the parse supports user supplied
aliases, they can be parsed even for inactive XMLs. However, to
avoid any clashes with aliases that libvirt generates, the user
ones have to have "ua-" prefix.

Note, that some drivers don't have notion of device aliases at
all. Also, in order to support user supplied aliases some extra
checks need to be done (e.g. during hotplug). Therefore we can't
just enable this feature for all the drivers. Thus we need a flag
that drivers set to tell parsing code that they can handle user
supplied device aliases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu_alias: Be more tolerant if alias don't follow our format
Michal Privoznik [Fri, 20 Oct 2017 11:24:41 +0000 (13:24 +0200)] 
qemu_alias: Be more tolerant if alias don't follow our format

When assigning alias to a device we usually iterate over other
devices of its kind trying to find next index. We do this by
stripping down the prefix and then parsing number at the end,
Usually, if the prefix doesn't match the one we are expecting, we
just continue with next iteration. Except for couple of
functions: qemuGetNextChrDevIndex(),
qemuAssignDeviceRedirdevAlias() and qemuAssignDeviceShmemAlias().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Rename [n]macs and maxmacs to [n]names and maxnames
John Ferlan [Fri, 20 Oct 2017 18:48:23 +0000 (14:48 -0400)] 
conf: Rename [n]macs and maxmacs to [n]names and maxnames

To avoid further confusion - rename the array elements to what they are.

7 years agoconf: duplicate interface name instead of MAC provided to lookup the interface
Pavel Hrdina [Fri, 20 Oct 2017 14:01:03 +0000 (16:01 +0200)] 
conf: duplicate interface name instead of MAC provided to lookup the interface

Introduced by 6094d6ec7fc9ea3e28c18c880b76858f06a8b129.
Found by running libvirt-perl tests.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: Missing 'removeTimeoutImpl' check variable inside virEventRegisterImpl() function.
Julio Faracco [Thu, 19 Oct 2017 15:35:03 +0000 (13:35 -0200)] 
util: Missing 'removeTimeoutImpl' check variable inside virEventRegisterImpl() function.

The function virEventRegisterImpl() checks the attempt to replace the
registered events. But there is a duplicate variable inside the IF statement.
The variable 'removeHandleImpl' was wrongly repeated. One of them needs to be
replaced by 'removeTimeoutImpl'.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Enhance debug message in qemuMonitorSetMigrationCapability
Jiri Denemark [Wed, 18 Oct 2017 10:46:39 +0000 (12:46 +0200)] 
qemu: Enhance debug message in qemuMonitorSetMigrationCapability

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Drop qemuMonitorGetMigrationCapability
Jiri Denemark [Tue, 17 Oct 2017 20:01:01 +0000 (22:01 +0200)] 
qemu: Drop qemuMonitorGetMigrationCapability

The only remaining user of qemuMonitorGetMigrationCapability is our test
suite. Let's replace qemuMonitorGetMigrationCapability with
qemuMonitorGetMigrationCapabilities there and drop the unused function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use bitmap with migration capabilities
Jiri Denemark [Tue, 17 Oct 2017 20:00:35 +0000 (22:00 +0200)] 
qemu: Use bitmap with migration capabilities

All calls to qemuMonitorGetMigrationCapability in QEMU driver are
replaced with qemuMigrationCapsGet.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Store supported migration capabilities in a bitmap
Jiri Denemark [Tue, 17 Oct 2017 19:39:41 +0000 (21:39 +0200)] 
qemu: Store supported migration capabilities in a bitmap

Each time we need to check whether a given migration capability is
supported by QEMU, we call query-migrate-capabilities QMP command and
lookup the capability in the returned list. Asking for the list of
supported capabilities once when we connect to QEMU and storing the
result in a bitmap is much better and we don't need to enter a monitor
just to check whether a migration capability is supported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Create a wrapper around qemuMonitorSetCapabilities
Jiri Denemark [Mon, 16 Oct 2017 10:52:36 +0000 (12:52 +0200)] 
qemu: Create a wrapper around qemuMonitorSetCapabilities

The new function is called qemuProcessInitMonitor and it will enter/exit
the monitor so that the caller doesn't have to deal with this.

The goal of this patch is to simplify the code in qemuConnectMonitor
which would otherwise be a bit hairy after the following patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agointerfaces: Convert virInterfaceObjList to virObjectRWLockable
John Ferlan [Mon, 9 Oct 2017 20:39:38 +0000 (16:39 -0400)] 
interfaces: Convert virInterfaceObjList to virObjectRWLockable

Rather than a forward linked list, let's use the virHashTable in
order to manage the objsName data.

Requires numerous changes from List to Object management similar to
many other drivers/vir*obj.c modules

7 years agointerface: Make _virInterfaceObjList virObjectRWLockable
John Ferlan [Thu, 19 Oct 2017 15:51:22 +0000 (11:51 -0400)] 
interface: Make _virInterfaceObjList virObjectRWLockable

Modify the allocation to be a real RWLockable object and add the
various RWLock{Read|Write} and RWUnlock calls to process the list
of interfaces.

7 years agoconf: Add/Allow parsing the encryption in the disk source
John Ferlan [Thu, 14 Sep 2017 13:32:57 +0000 (09:32 -0400)] 
conf: Add/Allow parsing the encryption in the disk source

Since the virStorageEncryptionPtr encryption; is a member of
 _virStorageSource it really should be allowed to be a subelement
of the disk <source> for various disk formats:

   Source{File|Dir|Block|Volume}
   SourceProtocol{RBD|ISCSI|NBD|Gluster|Simple|HTTP}

NB: Simple includes sheepdog, ftp, ftps, tftp

That way we can set up to allow the <encryption> element to be
formatted within the disk source, but we still need to be wary
from whence the element was read - see keep track and when it
comes to format the data, ensure it's written in the correct place.

Modify the qemuxml2argvtest to add a parse failure when there is an
<encryption> as a child of <disk> *and* an <encryption> as a child
of <source>.

The virschematest will read the new test files and validate from a
RNG viewpoint things are fine.

7 years agoconf: Add/Allow parsing the auth in the disk source
John Ferlan [Wed, 13 Sep 2017 14:25:25 +0000 (10:25 -0400)] 
conf: Add/Allow parsing the auth in the disk source

Since the virStorageAuthDefPtr auth; is a member of _virStorageSource
it really should be allowed to be a subelement of the disk <source>
for the RBD and iSCSI prototcols. That way we can set up to allow
the <auth> element to be formatted within the disk source.

Since we've allowed the <auth> to be a child of <disk>, we'll need
to keep track of how it was read so that when writing out we'll know
whether to format as child of <disk> or <source>. For the argv2xml
parsing, let's format under <source> as a preference. Do not allow
<auth> to be both a child of <disk> and <source>.

Modify the qemuxml2argvtest to add a parse failure when there is an
<auth> as a child of <disk> *and* an <auth> as a child of <source>.

Add tests to validate that if the <auth> was found in <source>, then
the resulting xml2xml and xml2arg works just fine.  The two new .args
file are exact copies of the non "-source" version of the file.

The virschematest will read the new test files and validate from a
RNG viewpoint things are fine

Update the virstoragefile, virstoragetest, and args2xml file to show
the "preference" to place <auth> as a child of <source>.

7 years agoqemu: Move encinfo from private disk to private disk src
John Ferlan [Thu, 19 Oct 2017 11:50:50 +0000 (13:50 +0200)] 
qemu: Move encinfo from private disk to private disk src

Since the encryption information can also be disk source specific
move it from qemuDomainDiskPrivate to qemuDomainStorageSourcePrivate

Since the last allocated element from qemuDomainDiskPrivate is
removed, that means we no longer need qemuDomainDiskPrivateDispose.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoqemu: Relocate qemuDomainSecretInfoPtr to qemuDomainStorageSourcePrivate
John Ferlan [Thu, 5 Oct 2017 13:22:13 +0000 (09:22 -0400)] 
qemu: Relocate qemuDomainSecretInfoPtr to qemuDomainStorageSourcePrivate

Since the secret information is really virStorageSource specific
piece of data, let's manage the privateData from there instead of
at the Disk level.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoqemu: Introduce privateData object for virStorageSource
John Ferlan [Thu, 5 Oct 2017 13:22:09 +0000 (09:22 -0400)] 
qemu: Introduce privateData object for virStorageSource

Add the object definition and helpers to store security-related private
data for virStorageSources.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoutil: storage: Introduce privateData for _virStorageSource
John Ferlan [Thu, 5 Oct 2017 13:22:09 +0000 (09:22 -0400)] 
util: storage: Introduce privateData for _virStorageSource

Introduce the bare necessities to add privateData to _virStorageSource.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoqemu: Add missing encinfo cleanup
John Ferlan [Thu, 5 Oct 2017 13:22:12 +0000 (09:22 -0400)] 
qemu: Add missing encinfo cleanup

When commit id 'da86c6c22' added support for diskPriv->encinfo in
qemuDomainSecretDiskPrepare a change to qemuDomainSecretDiskDestroy
to was missed. Although qemuDomainDiskPrivateDispose probably would
do the trick.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu-ns: Detect /dev/* mount point duplicates better
Michal Privoznik [Thu, 19 Oct 2017 13:23:15 +0000 (15:23 +0200)] 
qemu-ns: Detect /dev/* mount point duplicates better

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

When creating new /dev for domain ran in namespace we try to
preserve all sub-mounts of /dev. Well, not quite all. For
instance if /dev/foo/bar and /dev/foo are both mount points, only
/dev/foo needs preserving. /dev/foo/bar is preserved with it too.
Now, to identify such cases like this one STRPREFIX() is used.
That is not good enough. While it works for [/dev/foo/bar;
/dev/foo] case, it fails for [/dev/prefix; /dev/prefix2] where
the strings share the same prefix but are in fact two different
paths. The solution is to use STRSKIP().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agoconf: Pass xmlopt down to virDomainDeviceInfoParseXML
Michal Privoznik [Wed, 18 Oct 2017 13:30:07 +0000 (15:30 +0200)] 
conf: Pass xmlopt down to virDomainDeviceInfoParseXML

This function is going to make decisions based on the features
set per each driver. For that we need the virDomainXMLOption
object.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Be tolerant to preexisting aliases
Michal Privoznik [Sat, 14 Oct 2017 17:16:20 +0000 (10:16 -0700)] 
qemu: Be tolerant to preexisting aliases

In the future, some aliases might be already parsed therefore we
should avoid overwriting them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Move device alias assignment to separate functions
Michal Privoznik [Wed, 20 Sep 2017 16:17:32 +0000 (18:17 +0200)] 
qemu: Move device alias assignment to separate functions

Let's move all the virAsprintf()-s into separate functions for
better structure of the code. Later, when somebody wants to
generate a device alias, all they need is to expose the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuAssignDeviceAliases: Use qemuAssignDeviceRNGAlias for assigning RNG aliases
Michal Privoznik [Sat, 14 Oct 2017 17:53:03 +0000 (10:53 -0700)] 
qemuAssignDeviceAliases: Use qemuAssignDeviceRNGAlias for assigning RNG aliases

We have a special function for assigning aliases to RNG devices.
Use that instead of plain virAsprintf().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirDomainObjGetOneDefState: Fix error message
Michal Privoznik [Wed, 18 Oct 2017 17:40:29 +0000 (19:40 +0200)] 
virDomainObjGetOneDefState: Fix error message

It looks like the error message was copied from virsh, because
that's where we have @ctl. Nevertheless, it's @flags which is
invalid, not @ctl.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: hotplug: Reuse qemuDomainAttachDiskGeneric in qemuDomainAttachUSBMassStorageDevice
Peter Krempa [Wed, 18 Oct 2017 15:27:08 +0000 (17:27 +0200)] 
qemu: hotplug: Reuse qemuDomainAttachDiskGeneric in qemuDomainAttachUSBMassStorageDevice

Apart from killing a lot of code this also "implements" authentication
and encryption for USB disks.

7 years agoqemu: hotplug: Reuse qemuDomainAttachDiskGeneric in qemuDomainAttachSCSIDisk
Peter Krempa [Wed, 18 Oct 2017 15:22:23 +0000 (17:22 +0200)] 
qemu: hotplug: Reuse qemuDomainAttachDiskGeneric in qemuDomainAttachSCSIDisk

Get rid of the first copy of the mess.

7 years agoqemu: hotplug: extract disk hotplug worker code
Peter Krempa [Wed, 18 Oct 2017 15:17:45 +0000 (17:17 +0200)] 
qemu: hotplug: extract disk hotplug worker code

This horrible piece of spaghetti code is copy-past(ae)d in the SCSI and
USB disk hotplug code with minimal changes. Extract it for further
reuse.

7 years agoqemu: hotplug: Use disk target in debug/warning messages where appropriate
Peter Krempa [Wed, 18 Oct 2017 14:11:44 +0000 (16:11 +0200)] 
qemu: hotplug: Use disk target in debug/warning messages where appropriate

Some messages deal with the disk itself thus using the disk target is
better than using the disk source name which can be NULL in some cases.

7 years agoqemu: hotplug: Remove wrong check for empty disks
Peter Krempa [Wed, 18 Oct 2017 13:49:41 +0000 (15:49 +0200)] 
qemu: hotplug: Remove wrong check for empty disks

The check if the disk is empty is wrong and would spuriously reject NBD
sources. Remove it.

7 years agoqemu: address: Remove dead code when un-reserving PCI address
Peter Krempa [Wed, 18 Oct 2017 14:12:53 +0000 (16:12 +0200)] 
qemu: address: Remove dead code when un-reserving PCI address

The code can't fail so having error handling is pointless.

7 years agofix error message spacing in qemuDomainDetachNetDevice
Ján Tomko [Thu, 19 Oct 2017 12:46:13 +0000 (14:46 +0200)] 
fix error message spacing in qemuDomainDetachNetDevice

Move the space after the colon.

7 years agoqemu: remove pointless address validation on hot unplug
Ján Tomko [Wed, 18 Oct 2017 13:39:33 +0000 (15:39 +0200)] 
qemu: remove pointless address validation on hot unplug

Back in the times of using 'pci_del', unplugging a device without
a PCI address was not wired up.

After completely removing support for qemu without QEMU_CAPS_DEVICE,
aliases are used to uniquely identify devices in all cases.

Remove the pointless validation of data that was already present
in the domain definition.

7 years agoqemuIsMultiFunctionDevice: return early for non-PCI addresses
Ján Tomko [Wed, 18 Oct 2017 13:33:45 +0000 (15:33 +0200)] 
qemuIsMultiFunctionDevice: return early for non-PCI addresses

There is no point in iterating over all devices if none of them
could possibly match.

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.