]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agovbox: Read runtime RDP port and handle autoport
Dawid Zamirski [Tue, 24 Oct 2017 21:09:17 +0000 (17:09 -0400)]
vbox: Read runtime RDP port and handle autoport

VirutalBox has a IVRDEServerInfo structure available that
gives the effective runtime port that the VM is using when it's
running. This is useful when the "TCP/Ports" VBox property was set to
port range (e.g. via autoport = "yes" or via VBoxManage) in which
case it would be impossible to get the "active" port otherwise.

7 years agovbox: Make autoport set RDP port range.
Dawid Zamirski [Tue, 24 Oct 2017 21:09:16 +0000 (17:09 -0400)]
vbox: Make autoport set RDP port range.

Originally autoport in vbox driver was setting the port to default value
(3389) which caused multiple VM instances use the same port. Since
libvirt XML does not allow to set port ranges, this patch changes the
"autoport" behavior to set VBox's "TCP/Ports" property to an arbitrary
port range (3389-3689) to avoid that issue.

7 years agovbox: Remove old unflexible macros
Dawid Zamirski [Tue, 24 Oct 2017 21:09:15 +0000 (17:09 -0400)]
vbox: Remove old unflexible macros

The VBOX_SESSION_OPEN/CLOSE macros are only called in
_vboxDomainSnapshotRestore and they are unflexible because:

* assume the caller will have variable named "data"
* can only create Write lock type

As per above, it's not that hard to simply use the VBOX API directly.

7 years agovirsh: domain: Fix option handling in domxml-to-native
Peter Krempa [Tue, 10 Oct 2017 15:19:10 +0000 (17:19 +0200)]
virsh: domain: Fix option handling in domxml-to-native

Commit fdeac7a05fdf85458d72e89efcfa0f444525aaad tried to fix the output
of 'virsh domxml-to-native --help' by switching types around. One of the
changes broke the option parser. VSH_OT_ARGV should be used only for
variable argument count, not to make the help generator look pretty.

The correct option type in this case is VSH_OT_STRING as it's not
mandatory now since it can be substituted by using --domain.

This makes --help for this command look incorrect, but the parser works
as it should.

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

7 years agoqemu: Reset hasManagedSave after removing a corrupted image
Jiri Denemark [Tue, 24 Oct 2017 08:32:03 +0000 (10:32 +0200)]
qemu: Reset hasManagedSave after removing a corrupted image

When starting a domain with managed save image, we try to restore it
first. If the image is corrupted, we silently unlink it and just
normally start the domain. At this point the domain has no managed save
image, yet we did not reset the hasManagedSave flag.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoiohelper: use saferead if later write with O_DIRECT
Nikolay Shirokovskiy [Thu, 28 Sep 2017 07:06:47 +0000 (10:06 +0300)]
iohelper: use saferead if later write with O_DIRECT

One of the usecases of iohelper is to read from pipe and write
to file with O_DIRECT. As we read from pipe we can have partial
read and then we fail to write this data because output file
is open with O_DIRECT and buffer size is not aligned.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Set correct job status when qemuMigrationRun fails
Jiri Denemark [Thu, 19 Oct 2017 12:26:24 +0000 (14:26 +0200)]
qemu: Set correct job status when qemuMigrationRun fails

Instead of enumerating all states which need to be turned into
QEMU_DOMAIN_JOB_STATUS_FAILED (and failing to add all of them), it's
better to mention just the one which needs to be left alone.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Consistently use exit_monitor in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 12:22:53 +0000 (14:22 +0200)]
qemu: Consistently use exit_monitor in qemuMigrationRun

Almost every failure in qemuMigrationRun while we are talking to QEMU
monitor results in a jump to exit_monitor label. The only exception is
removed by this patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Don't misuse "ret" in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 12:21:00 +0000 (14:21 +0200)]
qemu: Don't misuse "ret" in qemuMigrationRun

The "ret" variable is used for storing the return value of a function
and should not be used as a temporary variable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Unite error handling in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 12:15:46 +0000 (14:15 +0200)]
qemu: Unite error handling in qemuMigrationRun

Merge cancel and cancelPostCopy sections with the generic error section,
where we can easily decide whether canceling the ongoing migration is
required.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Split cleanup and error code in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 13:09:25 +0000 (15:09 +0200)]
qemu: Split cleanup and error code in qemuMigrationRun

Let cleanup only do things common to both failure and success paths and
move error handling code inside the new "error" section.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Refactor qemuMigrationRun a bit
Jiri Denemark [Wed, 18 Oct 2017 13:34:31 +0000 (15:34 +0200)]
qemu: Refactor qemuMigrationRun a bit

Some code which was supposed to be executed only when migration
succeeded was buried inside the cleanup code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use switch in qemuMigrationCompleted
Jiri Denemark [Tue, 17 Oct 2017 19:27:55 +0000 (21:27 +0200)]
qemu: Use switch in qemuMigrationCompleted

When adding a new job state it's useful to let the compiler complain
about places where we need to think about what to do with the new
state.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonews: Document user aliases
Michal Privoznik [Fri, 20 Oct 2017 14:19:07 +0000 (16:19 +0200)]
news: Document user aliases

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
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.