Commit Graph

20136 Commits

Author SHA1 Message Date
John Ferlan
ccc8c311b2 storage: Internally represent @autostart as bool
Since it's been used that way anyway, let's just convert it to a bool
and only make the external representation be an int.
2017-09-19 08:30:37 -04:00
John Ferlan
bb15e65af2 storage: Use virStoragePoolObj{Is|Set}Autostart
Use the new accessor APIs for storage_driver and test_driver.
2017-09-19 08:30:19 -04:00
John Ferlan
0147f72741 storage: Use virStoragePoolObj{Is|Set}Active
Use the new accessor APIs for storage_driver, test_driver, and
gluster backend.
2017-09-19 08:30:19 -04:00
John Ferlan
1bd4349671 storage: Use virStoragePoolObjGetAutostartLink
Use the new accessor API for storage_driver.
2017-09-19 08:28:50 -04:00
John Ferlan
8603d848a3 storage: Use virStoragePoolObj{Get|Set}ConfigFile
Use the new accessor APIs for storage_driver and test_driver.
2017-09-19 08:28:50 -04:00
John Ferlan
5bf9b65501 storage: Introduce APIs to search/scan storage pool volumes list
Introduce virStoragePoolObjForEachVolume to scan each volume
calling the passed callback function until all volumes have been
processed in the storage pool volume list, unless the callback
function returns an error.

Introduce virStoragePoolObjSearchVolume to search each volume
calling the passed callback function until it returns true
indicating that the desired volume was found.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-09-19 08:28:50 -04:00
John Ferlan
40630a8e45 storage: Introduce storage volume add, delete, count APIs
Create/use virStoragePoolObjAddVol in order to add volumes onto list.

Create/use virStoragePoolObjRemoveVol in order to remove volumes from list.

Create/use virStoragePoolObjGetVolumesCount to get count of volumes on list.

For the storage driver, the logic alters when the volumes.obj list grows
to after we've fetched the volobj. This is an optimization of sorts, but
also doesn't "needlessly" grow the volumes.objs list and then just decr
the count if the virGetStorageVol fails.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-09-19 08:28:50 -04:00
John Ferlan
acd9a38069 storage: Fill in storage pool @active properly
It's a bool not an int, so use true/false and not 1/0
2017-09-19 08:28:50 -04:00
John Ferlan
407e6a3678 storage: Introduce virStoragePoolObjNew
Create/use a helper to perform object allocation.

Adjust storagevolxml2argvtest.c in order to use the allocator and
setting of the obj->def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-09-19 08:28:38 -04:00
John Ferlan
b31982868a storage: Create accessor API's for virStoragePoolObj
In preparation for making a private object, create accessor API's for
consumer storage functions to use:

    virStoragePoolObjGetDef
    virStoragePoolObjSetDef
    virStoragePoolObjGetNewDef
    virStoragePoolObjDefUseNewDef
    virStoragePoolObjGetConfigFile
    virStoragePoolObjSetConfigFile
    virStoragePoolObjGetAutostartLink
    virStoragePoolObjIsActive
    virStoragePoolObjSetActive
    virStoragePoolObjIsAutostart
    virStoragePoolObjSetAutostart
    virStoragePoolObjGetAsyncjobs
    virStoragePoolObjIncrAsyncjobs
    virStoragePoolObjDecrAsyncjobs

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-09-19 07:58:15 -04:00
Nikolay Shirokovskiy
776b9ac594 iohelper: reduce zero-out in align case
We only need to zero-out bytes that will be written.
May be we even don't need to zero-out at all because
of immediate truncate.
2017-09-19 11:37:24 +02:00
Nikolay Shirokovskiy
f830e371ef iohelper: simplify last direct write alignment
Make alignment of last direct write more straightforward. Using
additionally two flags 'end' and 'shortRead' looks complicated.
2017-09-19 11:37:20 +02:00
Nikolay Shirokovskiy
3b8a0f6ac2 iohelper: drop unused operation length limit 2017-09-19 11:37:15 +02:00
Guido Günther
3faf3ca60a apparmor: cater for new AAVMF image location
Things moved again, sigh.

Reviewed-By: Jamie Strandboge <jamie@canonical.com>
Michal Privoznik <mprivozn@redhat.com>
2017-09-18 19:06:53 +02:00
Jiri Denemark
848b72421f cpu: Add new Skylake-Server CPU model
Available since QEMU 2.10.0 (specifically commit
v2.9.0-2233-g53f9a6f45f).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-09-18 15:10:46 +02:00
Jiri Denemark
78d177df67 cpu: Add clwb/pcommit CPU features
The features were added to QEMU by commit v2.4.0-1690-gf7fda28094 as
Skylake Server features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-09-18 15:10:46 +02:00
Edan David
8708ca01c0 nodedev: add switchdev to NIC capabilities
Adding functionality to libvirt that will allow querying the interface
for the availability of switchdev Offloading NIC capabilities.

The switchdev mode was introduced in kernel 4.8, the iproute2-devlink
command to retrieve the switchdev NIC feature with command example:

    devlink dev eswitch show pci/0000:03:00.0

This feature is needed for Openstack so we can do a scheduling decision
if the NIC is in Hardware Offload (switchdev) or regular SR-IOV (legacy) mode.
And select the appropriate hypervisors with the requested capability see [1].

[1] - https://specs.openstack.org/openstack/nova-specs/specs/pike/approved/enable-sriov-nic-features.html

Reviewed-by: Laine Stump <laine@laine.org>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-09-18 08:32:24 -04:00
Michal Privoznik
8703813aae qemu: Implement usernet address
https://bugzilla.redhat.com/show_bug.cgi?id=1075520

Apart from generic checks, we need to constrain netmask/prefix
length a bit. Thing is, with current implementation QEMU needs to
be able to 'assign' some IP addresses to the virtual network. For
instance, the default gateway is at x.x.x.2, dns is at x.x.x.3,
the default DHCP range is x.x.x.15-x.x.x.30. Since we don't
expose these settings yet, it's safer to require shorter prefix
to have room for the defaults.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: laine@laine.org
2017-09-18 13:54:27 +02:00
Michal Privoznik
d1dbb30782 conf: Allow usernet to have an address
https://bugzilla.redhat.com/show_bug.cgi?id=1075520

Currently, all that users can specify for an interface type of
'user' is the common attributes: PCI address, NIC model (and
that's basically it). However, some need to configure other
address range than the default one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: laine@laine.org
2017-09-18 13:54:27 +02:00
Jiri Denemark
ea9741f600 cpu_x86: Implement virCPUValidateFeatures
The function checks whether all CPU features used in a CPU definition
are specified in cpu_map.xml.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
20edbad776 cpu_s390: Implement virCPUValidateFeatures
Only feature policy is checked on s390, which was previously done in
virCPUUpdate, but that's not the correct place for the check once we
have virCPUValidateFeatures.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
3f0193f7e5 qemu: Validate guest CPU features before starting a domain
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
6ef9c202f2 cpu: Introduce virCPUValidateFeatures
This new API may be used to check whether all features used in a CPU
definition are valid (e.g., libvirt knows their name, their policy is
supported, etc.). Leaving this API unimplemented in an arch subdriver
means libvirt does not restrict CPU features usable on the associated
architectures.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
2ba32a86dd qemu: Filter CPU features returned by qemuConnectBaselineCPU
The host CPU definitions reported in the capabilities XML may contain
CPU features unknown to QEMU, but the result of virConnectBaselineCPU is
supposed to be directly usable as a guest CPU definition and thus it
should only contain features QEMU knows about.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
399f91694f qemu: Publish virQEMUCapsCPUFilterFeatures
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
b0b5c9c620 qemu: Pass virArch * to virQEMUCapsCPUFilterFeatures
The filter only needs to know the CPU architecture. Passing
virQEMUCapsPtr as opaque is a bit overkill.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
abec725ab1 cpu: Drop cpuBaselineXML
The implementation of virConnectBaselineCPU may be different for each
hypervisor. Thus it shouldn't really be implmented in the cpu code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
7816de498b cpu: Don't log CPU models in cpuBaselineXML
They are logged in cpuBaseline anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
50234e4eaf cpu: Use virCPUDefListParse in cpuBaselineXML
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
Jiri Denemark
57f3999d72 cpu_conf: Introduce virCPUDefList{Parse,Free}
For parsing a list of CPU XMLs into a NULL-terminated list of CPU defs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-09-18 10:40:12 +02:00
John Ferlan
1f8528c2b8 qemu: Fix return check on virHashAddEntry call
Luckily it only returns 0 or -1
2017-09-15 08:34:57 -04:00
John Ferlan
304e0f6d16 conf: Use virXMLFormatElement to format disk source network
Commit id 'e02ff020cac' neglected to use the attrBuf and childBuf
in the virDomainDiskSourceFormatNetwork call.

So make the necessary alterations to allow usage.
2017-09-15 08:17:32 -04:00
John Ferlan
fae7a7354c conf: Move <disk> encryption validation
Rather than checking during XML processing, move the check for
valid <encryption> into virDomainDiskDefParseValidate and alter
the text of the message slightly to be a bit more correct.
2017-09-15 08:12:26 -04:00
John Ferlan
c09c93cf57 conf: Move <disk> authdef validation
Rather than checking during XML processing, move the checks for correct
and valid auth into virDomainDiskDefParseValidate. This will introduce
virDomainDiskSourceDefParseAuthValidate to validate that the authdef
stored for the virStorageSource is valid. This can then be expanded
to service backingStore sources as well.

Alter the message text slightly as well to distinguish between an
unknown name and an incorrectly used name.  Since type is not a
mandatory field, add the NULLSTR() around the output of the unknown
error. NB, a config using unknown formatting would fail virschematest
since it only accepts 'iscsi' and 'ceph' as "valid" types.
2017-09-15 07:52:04 -04:00
Peter Krempa
a823d0a62e qemu: Restore errors when rolling back disk image state
Some operations done to rollback disk image labelling and locking might
overwrite (or clear) the actual error. Remember the original error when
tearing down disk access so that it's not obscured.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1461301
2017-09-15 05:28:21 +02:00
Peter Krempa
6f18150f7b qemu: hotplug: Use new helpers for storing libvirt errors
The helpers allow to simplify restoring original errors in most cases.
2017-09-15 05:28:21 +02:00
Peter Krempa
8333e7455e util: error: Add helpers for saving and restoring of last error
Some cleanup paths overwrite a usefull error message with a less useful
one and we then try to preserve the original message. The handlers added
in this patch will simplify the operations since they are designed right
for the purpose.
2017-09-15 05:28:21 +02:00
Peter Krempa
1666d10793 qemu: caps: Deprecate QEMU_CAPS_BLOCKJOB_SYNC
Interestingly, none of the qemus we have caps for supported it ...

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-09-14 10:03:47 +02:00
Peter Krempa
771a38609d qemu: monitor: Remove support for "legacy" block jobs
Drop all the monitor code necessary to do the downstream block jobs.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-09-14 10:03:38 +02:00
Peter Krempa
2350d10149 qemu: Remove support for legacy block jobs
Block job QMP commands with underscores rather than dashes were never
released in upstream qemu, (they were added, but modified in the same
release [1]), but a certain distro managed to backport the version in the
middle.

The change also slightly modified semantics for the abort command, which
made us have a lot of code which was only ever present in certain
downstream distros.

Clean the upstream code from the legacy cruft and support only the
upstream implementations.

[1] See qemu commit v1.0-2176-gdb58f9c060

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-09-14 10:03:25 +02:00
John Ferlan
23706c1708 qemu: Clean up qemuDomainSecretPrepare
No need to pass a @driver parameter since all that's done is deref
the @cfg especially since the only caller can just pass an already
referenced @cfg.

Also, looks like commit id '0298531b' at one time had a different
name for the API, so I took the liberty of fixing the comments too
since I would already be updating them for the @cfg variable.
2017-09-13 06:22:52 -04:00
Cole Robinson
98931187ee security: dac: relabel spice rendernode
For a logged in user this a path like /dev/dri/renderD128 will have
default ownership root:video which won't work for the qemu:qemu user,
so we need to chown it.

We only do this when mount namespaces are enabled in the qemu driver,
so the chown'ing doesn't interfere with other users of the shared
render node path

https://bugzilla.redhat.com/show_bug.cgi?id=1460804
2017-09-12 12:27:42 -04:00
Cole Robinson
321031e482 security: add MANAGER_MOUNT_NAMESPACE flag
The VIR_SECURITY_MANAGER_MOUNT_NAMESPACE flag informs the DAC driver
if mount namespaces are in use for the VM. Will be used for future
changes.

Wire it up in the qemu driver
2017-09-12 12:27:42 -04:00
John Ferlan
239781e03a storage: Adjust expected format for Disk startup processing
https://bugzilla.redhat.com/show_bug.cgi?id=1464313

If a Disk pool was defined/created using XML that either didn't
specify a specific format or specified format type='unknown', then
restarting a pool after an initial disk backend build with overwrite
would fail after a libvirtd restart for a non-autostarted pool.

This is because the persistent pool data is not updated during pool
build w/ overwrite processing to have the VIR_STORAGE_POOL_DISK_DOS
default format.

So in addition to the alteration done during disk build processing,
alter the default expectation for disk startup to be DOS if nothing
has been defined yet. That will either succeed if the pool had been
successfully built previously using the default DOS format or fail
with a message indicating the format is something else that does not
match the expect format 'dos'.
2017-09-12 10:52:06 -04:00
John Ferlan
f64f03b5b1 qemu: Provide default LUN=0 for iSCSI if not provided
https://bugzilla.redhat.com/show_bug.cgi?id=1477880

If the "/#" is missing from the provided iSCSI path, then we need
to provide the default LUN of /0; otherwise, QEMU will fail to parse
the URL causing a failure to either create the guest or hotplug
attach the storage.

During post parse, for any iSCSI disk or hostdev, scan the source
path looking for the presence of '/', if found, then we can assume
the LUN is provided.  If not found, alter the input XML to add the
"/0".  This will cause the generated XML to have the generated
value when the domain config is saved after post parse.
2017-09-12 10:33:25 -04:00
Peter Krempa
4fc3051258 qemu: blockcopy: Probe image format only with VIR_DOMAIN_BLOCK_COPY_REUSE_EXT
Commit 703abf1d7 changed the logic so that we don't attempt to re-create
the image if it's a block device. This was done by modifying the
'reuse' variable. Unfortunately after modifying it one of the uses was
to infer whether we should probe the disk format. After changes in the
commit mentioned above we would attempt the probe if the target of the
copy is a block device and the format was not provided explicitly rather
than using the format of the disk.

Fix it by explicitly checking whether the user requested a reuse of the
disk rather than the modified boolean flag.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1490826
2017-09-12 16:03:56 +02:00
Michal Privoznik
607a00d170 qemu: cold-unplug of watchdog
https://bugzilla.redhat.com/show_bug.cgi?id=1447169

Again, no special here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-09-12 15:59:38 +02:00
Michal Privoznik
50c1dbafae qemu: cold-plug of watchdog
https://bugzilla.redhat.com/show_bug.cgi?id=1447169

With this patch users can cold plug a watchdog. Things are pretty
simple because a domain can have at most one watchdog device.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-09-12 15:59:32 +02:00
Michal Privoznik
891b3c119e qemuBuildHostNetStr: Don't leak buffer
If there was an error when constructing the buffer, NULL is
returned. The buffer is never freed though.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-09-12 13:41:31 +02:00
Guido Günther
cdecfbed02 virnetserver: fix mesage vs message typo 2017-09-11 18:17:22 +02:00