Commit Graph

28555 Commits

Author SHA1 Message Date
John Ferlan
93412bb827 qemu: Convert jobInfo stats into a union
Convert the stats field in _qemuDomainJobInfo to be a union. This
will allow for the collection of various different types of stats
in the same field.

When starting the async job that will end up being used for stats,
set the @statsType value appropriately. The @mirrorStats are
special and are used with stats.mig in order to generate the
returned job stats for a migration.

Using the NONE should avoid the possibility that some random
async job would try to return stats for migration even though
a migration is not in progress.

For now a migration and a save job will use the same statsType

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-02-06 07:36:53 -05:00
Peter Krempa
cb775a51a0 util: bitmap: Note that shrinking the bitmap requires clearing of unused bits
Note the fact that the unused portion of the last element in the bitmap
needs to be cleared, since we use functions which process only full-size
elements and don't really deal with individual bits.
2018-02-05 16:08:57 +01:00
Peter Krempa
e88a08e80b util: bitmap: Use VIR_SHRINK_N in virBitmapShrink
The function only reduces the size of the bitmap thus we can use the
appropriate shrinking function which also does not have any return
value.

Since virBitmapShrink now does not return any value callers need to be
fixed as well.
2018-02-05 16:08:57 +01:00
Peter Krempa
bf924e8e1b util: bitmap: Fix value of 'map_alloc' when shrinking bitmap
The virBitmap code uses VIR_RESIZE_N to do quadratic scaling, which
means that along with the number of requested map elements we also need
to keep the number of actually allocated elements for the scaling
algorithm to work properly.

The shrinking code did not fix 'map_alloc' thus virResizeN might
actually not expand the bitmap properly after called on a previously
shrunk bitmap.
2018-02-05 16:08:26 +01:00
Peter Krempa
cdfc3d7cb8 util: bitmap: Add comments for functions which don't have them
virBitmap code is thoroughly documented. Add docs for the few functions
missing them.
2018-02-05 16:08:26 +01:00
Peter Krempa
fb549cd559 util: bitmap: Fix function formatting and spacing 2018-02-05 16:08:26 +01:00
Peter Krempa
eacc9312e4 util: bitmap: Rename 'max_bit' to 'nbits'
'max_bit' is misleading as the value is set to the first invalid bit
as it's used as the number of bits in the bitmap. Rename it to a more
descriptive name.
2018-02-05 16:08:26 +01:00
Martin Kletzander
3cac2a6c93 qemu: Refresh capabilities when creating resctrl allocation
Since one of the things in capabilities (info from resctrl updated with data
about caches) can be change on the system by remounting the /sys/fs/resctrl with
different options, the capabilities need to be refreshed.  There is a better fix
in the works, but it's going to be way bigger than this (hence the XXX note
there), so for the time being let's workaround this.  And in order not to slow
down the domain starting, only get the capabilities if there are any cachetunes.

Relates-to: https://bugzilla.redhat.com/show_bug.cgi?id=1540780

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-02-05 13:33:13 +01:00
Martin Kletzander
d300b54487 util: Check if kernel-provided info is consistent with itself
Just in case someone re-mounted /sys/fs/resctrl with different mount
options (cdp), add a check here.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-02-05 13:33:13 +01:00
Marc Hartmayer
07dcad41a2 qemu: Add and use qemuProcessEventFree for freeing qemuProcessEvents
Add and use qemuProcessEventFree for freeing qemuProcessEvents. This
is less error-prone as the compiler can help us make sure that for
every new enumeration value of qemuProcessEventType the
qemuProcessEventFree function has to be adapted.

All process*Event functions are *only* called by
qemuProcessHandleEvent and this function does the freeing by itself
with qemuProcessEventFree. This means that an explicit freeing of
processEvent->data is no longer required in each process*Event
handler.

The effectiveness of this change is also demonstrated by the fact that
it fixes a memory leak of the panic info data in
qemuProcessHandleGuestPanic.

Reported-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-02-05 10:33:21 +01:00
Marc Hartmayer
7db455cebd qemu: Use the return value of virObjectRef directly
Use the return value of virObjectRef directly. This way, it's easier
for another reader to identify the reason why the additional reference
is required.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-02-05 09:17:39 +01:00
John Ferlan
a8ef7b69dc netserver: Remove ServiceToggle during ServerDispose
No sense in calling ServiceToggle for all nservices during
ServiceDispose since ServerClose calls ServiceClose which
removes the IOCallback that's being toggled via ServiceToggle.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-02-02 18:01:00 -05:00
John Ferlan
5870f95a7a qemu: Add dump completed event to the capabilities
Add the DUMP_COMPLETED check to the capabilities. This is the
mechanism used to determine whether the dump-guest-memory command
can support the "-detach" option and thus be able to wait on the
event and allow for a query of the progress of the dump.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-02-02 15:19:14 -05:00
John Ferlan
3f99bb06d1 qemu: Introduce qemuDomainGetJobInfoMigrationStats
Extract out the parts of qemuDomainGetJobStatsInternal that get
the migration stats. We're about to add the ability to get just
dump information.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-02-02 15:19:14 -05:00
Laine Stump
9c27e464e3 vbox: fix SEGV during dumpxml of a serial port
commit 77a12987a4 changed the "virDomainChrSourceDef source" inside
virDomainChrDef to "virDomainChrSourceDefPtr source", and started
allocating source inside virDomainChrDefNew(), but vboxDumpSerial()
was allocating a virDomainChrDef with a simple VIR_ALLOC() (i.e. never
calling virDomainChrDefNew()), so source was never initialized,
leading to a SEGV any time a serial port was present. The same problem
was created in vboxDumpParallel().

This patch changes vboxDumpSerial() and vboxDumpParallel() to use
virDomainChrDefNew() instead of VIR_ALLOC(), and changes both of those
functions to return an error if virDomainChrDef() (or any other
allocation) fails.

This resolves: https://bugzilla.redhat.com/1536649
2018-02-02 15:16:19 -05:00
John Ferlan
5866f48673 nwfilter: Remove unnecessary UUID comparison bypass
Remove the unnecessary check as since commit id '46a811db07' it is
not possible to add or alter a filter using the same name, but with
a different UUID.

NB: It's not required to provide a UUID for a filter by name, but
if one is provided, then it must match the existing. If not provided,
then one is generated during ParseXML processing.

Reviewed-by: Laine Stump <laine@laine.org>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-02-02 15:01:10 -05:00
John Ferlan
39b933f197 util: Remove unnecessary initialization
VIR_ALLOC will already initialize, so no need to do it again.
2018-02-02 14:56:19 -05:00
Marc Hartmayer
b0fc6a69d0 qemu: Use switch statement for address types in qemuBuildControllerDevStr
Use a switch statement instead of if-else-if statements. Move the
command line building of the iothread attribute into the common path
as the SCSI controller attributes are already validated.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2018-02-02 14:52:23 -05:00
John Ferlan
5775089e14 qemu: Introduce qemuDomainDeviceDefValidateControllerSATA
Move the SATA controller check from command line building to
controller def validation. This includes copying the SATA
skip check found in qemuBuildSkipController.
2018-02-02 14:52:23 -05:00
John Ferlan
7de841cc8e qemu: Complete PCI command checks to controller def validate
Move the qemuCaps checks over to qemuDomainControllerDefValidatePCI.

This requires two test updates in order to set the correct capability
bit for an xml2xml test as well as setting up the similar capability
for the pseries memlocktest.
2018-02-02 14:52:23 -05:00
John Ferlan
2461476022 qemu: Move more PCI command checks to controller def validate
Excluding the qemuCaps checks, move the remainder of the checks
that validate whether the PCI definition is valid or not into
qemuDomainControllerDefValidatePCI.
2018-02-02 14:52:06 -05:00
John Ferlan
13b2083c42 qemu: Move PCI command modelName TypeToString to controller def validate
Similar to the checking the modelName vs. NAME_NONE, let's make the
ModelNameTypeToString check more generic too within the checking done
in controller validation (with the same ignore certain models.

NB: We need to keep the ModelNameTypeToString fetch in command line
validation since we use it, but at least we can assume it returns
something valid now.
2018-02-02 14:35:26 -05:00
John Ferlan
4d7f9bf0ef qemu: Move PCI command modelName check to controller def validate
Move the various modelName == NAME_NONE from the command line
generation into domain controller validation.  Also rather than
have multiple cases with the same check, let's make the code
more generic, but also note that it was the modelName option
that caused the failure. We also have to be sure not to check
the PCI models that we don't care about.

For the remaining checks in command line building, we can use
the field name in the error message to be more specific about
what causes the failure.
2018-02-02 14:35:26 -05:00
John Ferlan
c44ba1d4d1 qemu: Use virDomainPCIControllerOpts in qemuBuildControllerDevStr
Shorten up a few characters and reference the pciopts pointer
2018-02-02 14:35:26 -05:00
Andrea Bolognani
e1f7c354f0 qemu: Add missing checks for pcie-root-port options
We format the 'chassis' and 'port' properties on the QEMU command
line later on, so we should make sure they've been set.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-02-02 14:35:26 -05:00
John Ferlan
d84caf9b50 qemu: Introduce qemuDomainDeviceDefValidateControllerPCI
Move PCI validation checks out of qemu_command into the proper
qemu_domain validation helper.

Since there's a lot to move, we'll start slow by replicating the
pcie-root and pci-root avoidance from qemuBuildSkipController and
the first switch found in qemuBuildControllerDevStr.
2018-02-02 14:35:26 -05:00
John Ferlan
2d32fc81da qemu: Introduce qemuDomainDeviceDefValidateControllerSCSI
Move SCSI validation from qemu_command into qemu_domain.

Rename/reorder the args in qemuCheckSCSIControllerIOThreads
to match the caller as well as fixing up the comments to
remove the previously removed qemuCaps arg.
2018-02-02 14:35:26 -05:00
John Ferlan
cd8df1e6de qemu: Add check for iothread attribute in validate controller
Let's make sure that non SCSI virtio-scsi isn't used for any type
other than a virtio-scsi controller.
2018-02-02 14:35:26 -05:00
John Ferlan
b61ae99b6d qemu: Adjust SCSI controller switch in qemuBuildControllerDevStr
Modify the SCSI controller switch during command line building
to account for all virDomainControllerModelSCSI types rather
than using the default label.
2018-02-02 14:35:26 -05:00
John Ferlan
bbe6466692 qemu: Move and rename qemuBuildCheckSCSIControllerModel
Move to qemu_domain during the validation of controller options and
rename qemuDomainCheckSCSIControllerModel.
2018-02-02 14:35:26 -05:00
John Ferlan
d92f2efbed qemu: Introduce qemuDomainDeviceDefValidateControllerAttributes
Move the checks that various attributes are not set on any controller
other than SCSI controller using virtio-scsi model into the common
controller validate checks.
2018-02-02 14:35:26 -05:00
Martin Kletzander
958e0431a9 tests: Add test for properly removing cachetune entries
Cachetune for unavailable vCPUs should be cleared the same way vcpupin and other
things do, so let's add tests for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-02-02 14:51:32 +01:00
Martin Kletzander
d6e582da80 util: Clear unused part of the map in virBitmapShrink
Some of the other functions depend on the fact that unused bits and longs are
always zero and it's less error-prone to clear it than fix the other functions.
It's enough to zero out one piece of the map since we're calling realloc() to
get rid of the rest (and updating map_len).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-02-02 14:51:32 +01:00
Martin Kletzander
679543449c util: Fix possible leak in virResctrlAllocMasksAssign
Found by coverity.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-02-02 14:50:12 +01:00
Daniel P. Berrangé
1b9fe756ec rpc: fix non-NULL annotations when GNUTLS is disabled
The position of various parameters changes depending on the WITH_GNUTLS
macro.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-02 13:00:48 +00:00
Daniel P. Berrangé
17398ccef3 rpc: assume private data callbacks are always non-NULL
Since we annotate the APIs are having non-NULL parameters, we can remove
the checks for NULL in the code too.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-02 13:00:48 +00:00
Daniel P. Berrangé
72874b2d11 tests: validate private data / pre / post exec hooks for RPC APIs
Validate that the virNetServer(Client) RPC APIs are processing the
private data callbacks correctly by passing in non-NULL pointers.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-02 13:00:48 +00:00
Michal Privoznik
4d83a6722f qemuDomainRemoveMemoryDevice: unlink() memory backing file
https://bugzilla.redhat.com/show_bug.cgi?id=1461214

Since fec8f9c49a we try to use predictable file names for
'memory-backend-file' objects. But that made us provide full path
to qemu when hot plugging the object while previously we provided
merely a directory. But this makes qemu behave differently. If
qemu sees a path terminated with a directory it calls mkstemp()
and unlinks the file immediately. But if it sees full path it
just calls open(path, O_CREAT ..); and never unlinks the file.
Therefore it's up to libvirt to unlink the file and not leave it
behind.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-02-02 11:03:15 +01:00
Peter Krempa
93db7eea1b qemu: migration: Refresh device information after transferring state
In my first approach in 4b480d1076 I overlooked the comment in
qemuMigrationRunIncoming stating that during actual migration the
qemuMigrationRunIncoming does not wait until the migration is complete
but rather offloads that to the Finish phase of migration.

This means that during actual migration qemuProcessRefreshState was
called prior to qemu actually transferring the full state and thus the
queries did not get the correct information. The approach worked only
for restore, where we wait for the migration to finish during qemu
startup.

Fix the issue by calling qemuProcessRefreshState both from
qemuProcessStart if there's no incomming migration and from
qemuMigrationFinish so that the code actually works as expected.
2018-02-02 10:39:32 +01:00
Michal Privoznik
038eb472a0 qemu: Expose rx/tx_queue_size in qemu.conf too
In 2074ef6cd4 and c56cdf259 (and friends) we've added two
attributes to virtio NICs: rx_queue_size and tx_queue_size.
However, sysadmins might want to set these on per-host basis but
don't necessarily have an access to domain XML (e.g. because they
are generated by some other app). So let's expose them under
qemu.conf (the settings from domain XML still take precedence as
they are more specific ones).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-02 07:09:22 +01:00
Jie Wang
75fd48b945 blockjob: Fix a error checking of blockjob status in some case
Commit id 'bc444666f' added a check if the returned data
buffer had an error, but failed to adjust the event from
VIR_DOMAIN_BLOCK_JOB_COMPLETED to VIR_DOMAIN_BLOCK_JOB_FAILED
in order to propagate an error such as "File descriptor in bad
state" that may be returned from QEMU when both @offset and
@len are set to 0 such as is the case when performing an async
block job read on a read only filesystem.

Signed-off-by: Jie Wang <wangjie88@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-01 09:48:17 -05:00
Chen Hanxiao
10e1d5e276 news: Add VIR_ERR_DEVICE_MISSING change as improvements
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-01 07:17:01 -05:00
Chen Hanxiao
2f54eab7c7 qemu: Use VIR_ERR_DEVICE_MISSING for various coldplug messages
Use the DEVICE_MISSING error code when helpers fail to find
the requested device. This makes it easier for consumers to
key off the error code rather than the error message.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-01 07:17:01 -05:00
Chen Hanxiao
126db34a81 qemu: Use VIR_ERR_DEVICE_MISSING for various hotplug messages
Modify OPERATION_FAILED and INTERNAL_ERROR error codes to
use DEVICE_MISSING instead for failures associated with the
inability to find the device. This makes it easier for consumers
to key off the error code rather than the error message.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-01 07:17:01 -05:00
Chen Hanxiao
bb189c8e8c qemu: Introduce VIR_ERR_DEVICE_MISSING
Add new error code to be able to allow consumers (such as Nova) to be
able to key of a specific error code rather than needing to search the
error message."

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-01 07:17:01 -05:00
Chen Hanxiao
f0f2a5ec21 qemu: Add some more details for hotplug errors when device not found
More proper/detail error messages updated.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-02-01 07:17:01 -05:00
Andrea Bolognani
90161710b9 conf: Small indentation and coding style fixes
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-02-01 10:34:41 +01:00
Daniel P. Berrangé
7090a82041 admin: set XDR_CFLAGS when building admin server
The XDR_CFLAGS variable is needed when the XDR headers are not
part of the stock glibc install

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 19:05:45 +00:00
Daniel P. Berrangé
31869efe2a storage: remove virConnectPtr from all backend functions
Now that we can open connections to the secondary drivers on demand,
there is no need to pass a virConnectPtr into all the backend
functions.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 18:34:48 +00:00
Daniel P. Berrangé
decaeb2882 storage: open nodedev driver connection at time of use
Instead of passing around a virConnectPtr object, just open a connection
to the nodedev driver at time of use. Opening connections on demand will
be beneficial when the nodedev driver is in a separate daemon. It also
solves the problem that a number of callers just pass in a NULL
connection today which prevents nodedev lookup working at all.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 18:34:48 +00:00