Commit Graph

28482 Commits

Author SHA1 Message Date
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
Daniel P. Berrangé
a494f7fd4f storage: open secret driver connection at time of use
Instead of passing around a virConnectPtr object, just open a connection
to the secret driver at time of use. Opening connections on demand will
be beneficial when the secret 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 secret lookup working at all.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 18:34:48 +00:00
Daniel P. Berrangé
2870419eb9 driver: add some helpers for opening secondary driver connections
Various parts of libvirt will want to open connections to secondary
drivers. The right URI to use will depend on the context, so rather than
duplicating that logic in various places, use some helper APIs. This
will also make it easier for us to later pre-open/cache connections to
avoid repeated opening & closing the same connectiong during autostart.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 18:34:47 +00:00
Daniel P. Berrangé
74d7c51815 secret: allow opening with secret:///system and secret:///session URIs
Allow the possibility of opening a connection to only the secret
driver, by defining secret:///system and secret:///session URIs
and registering a fake hypervisor driver that supports them.

The hypervisor drivers can now directly open a secret driver
connection at time of need, instead of having to pass around a
virConnectPtr through many functions. This will facilitate the later
change to support separate daemons for each driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:46:26 +00:00
Daniel P. Berrangé
dfb79d6cec nodedev: allow opening with nodedev:///system and nodedev:///session URIs
Allow the possibility of opening a connection to only the nodedev
driver, by defining nodedev:///system and nodedev:///session URIs
and registering a fake hypervisor driver that supports them.

The hypervisor drivers can now directly open a nodedev driver
connection at time of need, instead of having to pass around a
virConnectPtr through many functions. This will facilitate the later
change to support separate daemons for each driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:46:09 +00:00
Daniel P. Berrangé
3bd64d3306 interface: allow opening with interface:///system and interface:///session URIs
Allow the possibility of opening a connection to only the interface
driver, by defining interface:///system and interface:///session URIs
and registering a fake hypervisor driver that supports them.

The hypervisor drivers can now directly open a interface driver
connection at time of need, instead of having to pass around a
virConnectPtr through many functions. This will facilitate the later
change to support separate daemons for each driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:45:51 +00:00
Daniel P. Berrangé
1292de7ef1 nwfilter: allow opening with nwfilter:///system URI
Allow the possibility of opening a connection to only the storage
driver, by defining a nwfilter:///system URI and registering a fake
hypervisor driver that supports it.

The hypervisor drivers can now directly open a nwfilter driver
connection at time of need, instead of having to pass around a
virConnectPtr through many functions. This will facilitate the later
change to support separate daemons for each driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:45:16 +00:00
Daniel P. Berrangé
1409a541c0 network: allow opening with network:///system and network:///session URIs
Allow the possibility of opening a connection to only the network
driver, by defining network:///system and network:///session URIs
and registering a fake hypervisor driver that supports them.

The hypervisor drivers can now directly open a network driver
connection at time of need, instead of having to pass around a
virConnectPtr through many functions. This will facilitate the later
change to support separate daemons for each driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:45:01 +00:00
Daniel P. Berrangé
c9fc538939 network: move driver registration back to end of the file
By convention the last thing in the driver.c files should be the driver
callback table and function to register it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:44:44 +00:00
Daniel P. Berrangé
b8eb6194da storage: allow opening with storage:///system and storage:///session URIs
Allow the possibility of opening a connection to only the storage
driver, by defining storage:///system and storage:///session URIs
and registering a fake hypervisor driver that supports them.

The hypervisor drivers can now directly open a storage driver
connection at time of need, instead of having to pass around a
virConnectPtr through many functions. This will facilitate the later
change to support separate daemons for each driver.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:44:43 +00:00
Daniel P. Berrangé
d8924a6408 storage: move driver registration back to end of the file
By convention the last thing in the driver.c files should be the driver
callback table and function to register it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:40:32 +00:00
Daniel P. Berrange
5315d20698 util: use union for sockaddr structs to avoid aliasing
Some platforms/toolchains will complain about casting
sockaddr_storage to sockaddr_un because it breaks strict
aliasing rule

../../src/util/virutil.c: In function 'virGetUNIXSocketPath':
../../src/util/virutil.c:2005: error: dereferencing pointer 'un' does break strict-aliasing rules [-Wstrict-aliasing]

Change the code to use a union, in the same way that the
virsocketaddr.h header does.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 17:33:08 +00:00
Daniel P. Berrangé
707022c3e8 tools: unlink bash completion files before symlinking
"ln" will not replace an existing symlink, so if you run 'make install'
twice, the second time will get an error:

  ln: failed to create symbolic link 'virsh': File exists

We must always remove the symlink target first.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:30:55 +00:00
Daniel P. Berrangé
eef9812827 Fixed virGetUNIXSocketPath stub on Win32
The _() macro was not terminated and an argument needs to be marked as
unused.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 17:10:52 +00:00
John Ferlan
5b5bff35a8 qemu: Update qemuDomainFindSCSIControllerModel return
Now that the controller model is updated during post parse callback,
this code no longer needs to fetch the model based on the capabilities
and can just return the model directly if the controller is found.

Removal of @qemuCaps cascades through various callers which are now
updated to not pass the capabilities.
2018-01-31 11:32:04 -05:00
John Ferlan
de8fac5f21 qemu: Reduce need to call qemuDomainGetSCSIControllerModel
Now that post parse processing handles setting the SCSI controller
model, there's no need to call qemuDomainGetSCSIControllerModel to
get the "default controller" when building the command line controller
string or when assigning the spaprvio address since the controller
model value will already be filled in.
2018-01-31 11:32:04 -05:00
John Ferlan
d1b59c6214 conf: Allow configuration of implicit controller model
When an implicit controller is added, the model is defined as -1
(IOW: undefined). So, if an implicit SCSI controller was added,
can set the model to the default value if the underlying hypervisor
supports it.
2018-01-31 11:32:04 -05:00
John Ferlan
62f8c94732 qemu: Introduce qemuDomainSetSCSIControllerModel
During post parse processing, let's force setting the controller
model to default value if not already set for defined controllers
(e.g. the non implicit ones).
2018-01-31 11:32:04 -05:00
John Ferlan
13d216617d qemu: Fetch/save the default SCSI controller model during hotplug
If we're going to add a controller to the domain, let's set the
default SCSI model value if we cannot find another SCSI controller
already present.

NB: Requires updating the live output test data since the model
will now be formatted.
2018-01-31 11:32:04 -05:00
John Ferlan
fadfb4f9b3 qemu: Introduce qemuDomainGetSCSIControllerModel
Rename and rework qemuDomainSetSCSIControllerModel since we're
really not setting the SCSI controller model. Instead the code
is either returning the existing SCSI controller model value, the
default value based on the capabilities, or -1 with the error set.
2018-01-31 11:32:04 -05:00
John Ferlan
6ae6ffd88e qemu: Introduce qemuDomainFindSCSIControllerModel
Rather than repeat multiple steps in order to find the SCSI
controller model, let's combine them into one helper that will
return either the model from the definition or the default
model based on the capabilities.

This patch adds an extra check/error that the controller
that's being found actually exists. This just clarifies that
the error was because the controller doesn't exist rather
than the more generic error that we were unable to determine
the model from qemuDomainSetSCSIControllerModel when a -1
was passed in and the capabilities were unable to find one.
2018-01-31 11:32:04 -05:00
John Ferlan
932862b8bf conf: Rework and rename virDomainDeviceFindControllerModel
As it turns out virDomainDeviceFindControllerModel was only ever
called for SCSI controllers using VIR_DOMAIN_CONTROLLER_TYPE_SCSI
as a parameter.

So rename to virDomainDeviceFindSCSIController and rather than
return a model, let's return a virDomainControllerDefPtr to let
the caller reference whatever it wants.
2018-01-31 11:32:04 -05:00
John Ferlan
e37540f459 qemu: Split qemuDomainSetSCSIControllerModel
Rather than one function serving two purposes, let's split out the
else condition which is checking whether the model can be used
during command line building based on the capabilities.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-01-31 11:32:04 -05:00
Michal Privoznik
7b0ea999fc virUSBDeviceNew: Construct vroot path properly
When starting an LXC container, the /dev entries are created
under temp root (/var/run/libvirt/lxc/$name.dev), relabelled and
then the root is pivoted. However, when it comes to USB devices
which keep path to the device in the structure we need a way to
override the default /dev/usb/... path because we want to work
with the one under temp root. That's what @vroot argument is for
in virUSBDeviceNew. However, what is being passed there is:

  vroot = /var/run/libvirt/lxc/lxc_0.dev/bus/usb

Therefore, constructed path is wrong:

  dev->path = //var/run/libvirt/lxc/lxc_0.dev/bus/usb//dev/bus/usb/002/002

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-01-31 17:10:01 +01:00