Commit Graph

28393 Commits

Author SHA1 Message Date
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
Daniel P. Berrangé
12ba706d6d Check for tabs in augeas files
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-01-31 15:19:26 +00:00
Daniel P. Berrange
ce7ae55ea1 lockd: add support for admin protocol in virtlockd
Add a virtlockd-admin-sock can serves the admin protocol for the virtlockd
daemon and define a virtlockd:///{system,session}  URI scheme for
connecting to it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:18:36 +00:00
Daniel P. Berrange
85d45ff05d logd: add support for admin protocol in virtlogd
Add a virtlogd-admin-sock can serves the admin protocol for the virtlogd
daemon and define a virtlogd:///{system,session}  URI scheme for
connecting to it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:17:47 +00:00
Daniel P. Berrange
8aca141081 rpc: refactor virNetServer setup for post-exec restarts
With the current code it is neccessary to call

  virNetDaemonNewPostExecRestart()

and then for each server that needs restarting you are supposed
to call

  virNetDaemonAddSeverPostExecRestart()

This is fine if there's only ever one server, but as soon as you
have two servers it is impossible to use this design. The code
has no idea which servers were recorded in the JSON state doc,
nor in which order the hash table serialized its keys.

So this patch changes things so that we only call

  virNetDaemonNewPostExecRestart()

passing in a callback, which is invoked once for each server
found int he JSON state doc.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:17:14 +00:00
Daniel P. Berrange
e72f3e5933 rpc: add method for checking if a named server exists
It is not possible to blindly call virNetDaemonGetServer()
because in a post-exec restart scenario, some servers may
not exist and this method will pollute the error logs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:16:40 +00:00
Daniel P. Berrange
9da0cc9ddb rpc: annotate various parameters as being required to be non-NULL
The server name and client data callbacks need to be non-NULL or the
system will crash at various times. This is particularly bad when some
of the crashes only occur post-exec restart.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:16:03 +00:00
Daniel P. Berrange
b41780e47a rpc: pass virNetServer to post-exec restart callback in typesafe manner
The virNetServer class is passing a pointer to itself to the
virNetServerClient as a 'void *' pointer. This is presumably due to fact
that the virnetserverclient.h file doesn't see the virNetServerPtr
typedef. The typedef is easily movable though, which lets us get
typesafe parameter passing, removing the confusion of passing two
distinct 'void *' pointers to one method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:15:25 +00:00
Daniel P. Berrange
2c76fa91d3 rpc: clarify "void *" values passed to client callbacks
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:14:47 +00:00
Daniel P. Berrange
9fe6619d4a util: add virGetUNIXSocketPath helper
When receiving multiple socket FDs from systemd, it is critical to know
what socket address each corresponds to so we can setup the right
protocols on each.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:12:53 +00:00
Daniel P. Berrange
b42c591fec admin: add support for post-exec restart callbacks
We don't have any per-client private data we need to persist, but the
RPC infrastructure requires that we provide the callbacks and serialize
an empty JSON object. This makes us future proof going forwards.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:12:44 +00:00
Daniel P. Berrange
99d69f6925 libvirtd: rename virNetServerClient callback impls to match type names
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:12:33 +00:00
Daniel P. Berrange
b1e03dad86 admin: move admins server impl/dispatch into src/admin directory
The admin server functionality is a generic concept that should be wired
up into all libvirt daemons, but is currently integrated with the
libvirtd code. Move it all into the src/admin directory to prepare for
broader reuse.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-31 15:12:30 +00:00
Michal Privoznik
08327dfff3 tools: Make symlinks to vsh bash-completion script
The bash-completion project documents that only those scripts
from $BASH_COMPLETIONS_DIR that share name with the current
command for which <TAB> was hit are loaded [1]. This means, that
vsh script we have there is not loaded. We have to create
symlinks for virsh and virt-admin.

At the same time, we have to create new RPM package because
virt-admin and client packages are independent. That means we
cannot place the vsh script in either of them. What we can do is
to have a different package that contains the completion script
and then virt-admin and client packages contain only the symlink
and require the bash-completion package.

1: https://github.com/scop/bash-completion#faq

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-31 15:41:51 +01:00
Michal Privoznik
74f044acf7 virsh: Offer only persistent domains for autostart
The 'autostart' command accepts only persistent domains. Make the
completer return only those.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-31 15:41:51 +01:00
Michal Privoznik
3b225256cd virshDomainNameCompleter: Prune accepted flags
Only a small subset of VIR_CONNECT_LIST_DOMAINS_* flags are
actually used for this completer. Remove the unused ones. Note
that this is unrelated to other commands using
VIR_CONNECT_LIST_DOMAINS_* (i.e. cmdList) as this commit targets
the completer only and nothing else.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-01-31 15:41:51 +01:00
Martin Kletzander
6c44013b17 qemu: Restore resctrl alloc data after restart
During reconnect we need to reconstruct the paths of all cachetunes so that they
get cleaned up when the domain is stopped.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-31 14:51:34 +01:00
Martin Kletzander
b9ceacba7c util: Extract path formatting into virResctrlAllocDeterminePath
We can use this from more places later, so just a future code de-duplication.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-31 14:51:34 +01:00
Martin Kletzander
272649a1d7 qemu: Restore machinename even without cgroups
The virresctrl will use this as well and we need to have that info after restart
to properly clean up /sys/fs/resctrl.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-31 14:51:34 +01:00
Martin Kletzander
859186091c util: Don't overwrite mask in virResctrlAllocFindUnused
Due to confusing naming the pointer to the mask got copied which must not
happen, so use UpdateMask instead of SetMask.  That also means we can get
completely rid of SetMask.

Also don't clear the free bits since it is not used again (leftover from
previous versions).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-31 14:51:34 +01:00
Martin Kletzander
c39ce914dd util: Use default group's mask for unspecified resctrl allocations
Introduce virResctrlAllocCopyMasks() and use that to initially copy the default
group schemata to the allocation before reserving any parts of the cache.  The
reason for this is that when new group is created the schemata will have unknown
data in it.  If there was previously group with the same CLoS ID, it will have
the previous valies, if not it will have all bits set.  And we need to set all
unspecified (in the XML) allocations to the same one as the default group.

Some non-Linux functions now need to be made public due to this change.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-31 14:51:34 +01:00
Martin Kletzander
f6199295a9 util: Add helpers for getting resctrl group allocs
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-31 14:51:34 +01:00
Peter Krempa
f46d6e22f2 util: storage: Parse 'lun' for iSCSI protocol from JSON as string or number
While the QEMU QAPI schema describes 'lun' as a number, the code dealing
with JSON strings does not strictly adhere to this schema and thus
formats the number back as a string. Use the new helper to retrieve both
possibilities.

Note that the formatting code is okay and qemu will accept it as an int.

Tweak also one of the test strings to verify that both formats work
with libvirt.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540290
2018-01-31 12:22:25 +01:00
Peter Krempa
d3da8013cc util: json: Add helper to return string or number properties as string
The helper is useful in cases when the JSON we have to parse may contain
one of the two due to historical reasons and the number value itself
would be stored as a string.
2018-01-31 12:21:39 +01:00
Andrea Bolognani
c7f6d4d010 conf: Use correct attribute name in error message
The <capabilities> feature has an attribute named 'policy', but the
error message mentioned the non-existing 'state' attribute instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-01-30 18:44:11 +01:00
Peter Krempa
b2c5f28a72 storage: util: Properly ignore errors when backing volume is inaccessible
Commit 000e950455 tried to fix improper bracketing when refreshing disk
volume stats for a backing volume. Unfortunately the condition is still
wrong as in cases as the backing store being inaccessible
storageBackendUpdateVolTargetInfo returns -2 if instructed to ignore
errors. The condition does not take this into account.

Dumping XML of a volume which has inacessible backing store would then
result into:

 # virsh vol-dumpxml http.img --pool default
 error: An error occurred, but the cause is unknown

Properly ignore -2 for backing volumes.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540022
2018-01-30 11:41:59 +01:00
Martin Kletzander
f2e16994f7 util: Don't check if entries under /sys/fs/resctrl/(info/) are directories
We are skipping non-directories under /sys/fs/resctrl/(info/) since those are not
interesting for us.  However in tests it can sometimes happen that ent->d_type
is 0 instead of 4 (DT_DIR) for directories.

I've seen it fail on two machines.  Different machines, different systems, I
cannot reproduce it even using the same setup.  So one of the ways how to work
around this is call stat() on it.  The other one is not checking if it is a
directory since we'll find out eventually when we want to read some files
underneath it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-29 21:40:54 +01:00
Martin Kletzander
e28ccd2643 util: Remove unused variable in virResctrlGetInfo
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-29 21:40:54 +01:00
Martin Kletzander
6899118043 util: Make it possible for virResctrlAllocSetMask to replace existing mask
This wil be used in the future, but it makes sense for now as well.  It makes
sure there is no mask leftover that would leak.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-29 21:40:54 +01:00
Martin Kletzander
ebafc603c1 util: Use "resctrl" instead of "resctrlfs" spelling
Pointed out during review on one or two places, but it actually appears in lot
more places.  So let's be consistent.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-29 21:40:54 +01:00
Martin Kletzander
bd5d07425d util: Check for empty allocation instead of just NULL pointer
When working on the CAT series one of the changes was that the pointer got
allocated in another part of the code, even when resctrl was not available on
the host system.  However this one particular place neglected that so it needs
to be fixed in order to get the proper error message when requesting
<cachetune/> on HW with no support for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-29 21:40:53 +01:00
Erik Skultety
b7a7912411 build: Fix broken build on FreeBSD and OSX after recent nodedev series
Commits f83c7c88 and 6eb1f2b9 broke the build on FreeBSD and OSX because
of symbols being undefined for those platforms.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 17:53:13 +01:00
John Ferlan
6b7c5c4726 qemu: Fix memory leak in processGuestPanicEvent
After processing the processEvent->data for a qemuProcessEventHandler
callout, it's expected that the called processEvent->eventType helper
will perform the proper free on the data field. In this case it's
a qemuMonitorEventPanicInfoPtr.
2018-01-29 11:44:20 -05:00
Kashyap Chamarthy
d449dbdcc0 docs: formatdomain: Document the CPU feature 'name' attribute
Currently, the CPU feature 'name' XML attribute, as in:

    [...]
    <cpu match='exact'>
      <model fallback='forbid'>IvyBridge</model>
      <vendor>Intel</vendor>
      <feature policy='require' name='pcid'/>
    </cpu>
    [...]

isn't explicitly documented in formatdomain.html.

Document it now.

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2018-01-29 11:35:49 -05:00
Erik Skultety
75dbb27b10 conf: nodedev: Update PCI mdev capabilities dynamically
Just like SRIOV, a PCI device is only capable of the mediated devices
framework when it's bound to the vendor native driver, thus if a driver
change occurs, e.g. vendor_native->vfio, we need to refresh some of the
device's capabilities to reflect the reality, mdev included.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Suggested-by: Wu Zongyong <cordius.wu@huawei.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 15:34:30 +01:00
Erik Skultety
882fd7a13c conf: Replace usage of virNodeDevCapMdevType with virMediatedDeviceType
Now that we have all the building blocks in place, switch the nodedev
driver to use the "new" virMediatedDeviceType type instead of the "old"
virNodeDevCapMdevType one.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 15:34:30 +01:00
Erik Skultety
3cbac4dec0 nodedev: udev: Drop the unused mdev type helpers
These are not necessary anymore, since these are going to be shadowed by
the helpers provided by util/virmdev.c module.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 15:34:30 +01:00
Erik Skultety
6eb1f2b9d0 util: pci: Introduce virPCIGetMdevTypes helper
This is a replacement for the existing udevPCIGetMdevTypesCap which is
static to the udev backend. This simple helper constructs the sysfs path
from the device's base path for each mdev type and queries the
corresponding attributes of that type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 15:34:30 +01:00
Erik Skultety
3545cbef7f util: mdev: Introduce virMediatedDeviceTypeReadAttrs getter
This should serve as a replacement for the existing udevFillMdevType
which is responsible for fetching the device type's attributes from the
sysfs interface. The problem with the existing solution is that it's
tied to the udev backend.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 15:34:30 +01:00
Erik Skultety
c3faa92a1b util: mdev: Introduce virMediatedDeviceType structure
This is later going to replace the existing virNodeDevCapMdevType, since:
1) it's going to couple related stuff in a single module
2) util is supposed to contain helpers that are widely accessible across
the whole repository.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-01-29 15:34:30 +01:00