Commit Graph

10714 Commits

Author SHA1 Message Date
Michal Privoznik
71609477a2 qemu_capabilities: Don't leak @str in virQEMUCapsLoadMachines()
If parsing "maxCpus" attribute of <machine/> element fails an
error is printed but the corresponding string is not freed. While
it is very unlikely to happen (parsed XML is not user provided
and we are the ones generating it), it is possible. Instead of
freeing the variable in the error path explicitly, let's declare
it as g_autofree. And while I'm at it, let's bring it into the
loop where it's used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-02-10 09:38:49 +01:00
Michal Privoznik
f8f7bc254f qemu: Release <memory/> device address on failed hotplug
A few commits back I've introduced new 'virtio-pmem' <memory/>
device. Since it's virtio it goes onto PCI bus. Therefore, on
hotplug new PCI address is generated (or provided one is
reserved). However, if hotplug fails (for whatever reason) the
address needs to be released. This is different to 'dimm' type of
address because for that type we don't keep a map of used slots
rather generate one on each address assign request. The map is
then thrown away. But for PCI addresses we keep internal state
and thus has to keep it updated. Therefore, this new
qemuDomainReleaseMemoryDeviceSlot() function is NOP for those
models which use 'dimm' address type ('dimm' and 'nvdimm').

While I'm at it, let's release the address in case of hot unplug.
Not that is supported (any such attempt fails with the following
error:

  "virtio based memory devices cannot be unplugged"

But if QEMU ever implements hot unplug then we don't have to
remember to fix our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-02-08 20:05:08 +01:00
Yi Li
f209d40a7e qemuDomainAttachRedirdevDevice: Remove need_release variable
Get rid of the 'need_release' variable. The code can be rewritten
so that it is not needed.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-05 12:42:15 +01:00
Laine Stump
67ee6c0a6a qemu: replace VIR_FREE with g_free in all *Dispose() functions
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:22:09 -05:00
Laine Stump
5fb0c789c3 qemu: replace VIR_FREE with g_free in qemuFirmware*FreeContent()
These functions are all only called as a part of qemuFirmwareFree(),
which frees the qemuFirmware object before return, so we can be sure
none of the pointers is referenced after freeing (and thus there is no
need to clear any of them).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:22:09 -05:00
Laine Stump
e7942f65c9 qemu: pass pointers instead of copying objects for qemuFirmware*FreeContent()
These functions all cooperate to free memory pointed to by a single
object that contains (doesn't *point to*, but actually contains)
several sub-objects. They were written to send copies of these
sub-objects to subordinate functions, rather than just sending
pointers to the sub-objects.

Let's change these functions to just send pointers to the objects
they're cleaning out rather than all the wasteful and pointless
copying.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:21:54 -05:00
Laine Stump
e1b02e3a56 qemu: rename virFirmware*Free() functions to have more accurate names
Several functions had the names virFirmware[something]Free(), but they
aren't taking a pointer to some object and freeing it. Instead, they
are making a copy of the content of an entire object, then Freeing the
objects pointed to by that content.

As a first step in a too-complicated cleanup just to eliminate a few
occurrences of VIR_FREE(), this patch renames those functions to more
accurately reflect what they do - they Free the *Content* of their
arguments.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:20:45 -05:00
Laine Stump
674719afe6 qemu: replace VIR_FREE with g_free in all vir*Free() functions
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-02-05 00:20:43 -05:00
Pavel Hrdina
02ffd9909c qemu_driver: increase recorded counter for disk block stats
Commit <318d807a0bd3372b634d1952b559c5c627ccfa5b> added a fix to skip
most of the block stat code to not log error message for missing storage
sources but forgot to increase the recordnr counter.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-04 13:11:27 +01:00
Pavel Hrdina
8ebfd29cbd qemu_monitor_json: fix JSON generator for VC chardev
The correct backend type is 'vc', same as in qemuBuildChrChardevStr()
where we generate qemu command line.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-04 13:07:02 +01:00
Pavel Hrdina
d763466edc qemu: implement vhost-user-blk support
Implements QEMU support for vhost-user-blk together with live
hotplug/unplug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-03 18:56:34 +01:00
Pavel Hrdina
c8b0d5b0ad qemu_capabilities: introduce vhost-user-blk capability
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-03 18:56:34 +01:00
Pavel Hrdina
f00fe96eb0 conf: implement support for vhostuser disk
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-03 18:56:34 +01:00
Pavel Hrdina
592fb164e9 qemu_validate: move and refactor qemuValidateDomainDefVirtioFSSharedMemory
Make the function reusable by other vhost-user based devices.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-03 18:56:34 +01:00
Pavel Hrdina
6799cc3ada qemu_alias: introduce qemuDomainGetVhostUserAlias helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-03 18:56:33 +01:00
Daniel P. Berrangé
6a40c01ed0 qemu: taint the VM if it is using a deprecated machine type
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 17:32:27 +00:00
Daniel P. Berrangé
c212eb6c7f qemu: taint the VM if it is using a deprecated CPU model
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 17:31:57 +00:00
Daniel P. Berrangé
30626ed15b qemu: add ability to associate a string message with taint warning
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 17:31:31 +00:00
Daniel P. Berrangé
1e260cc449 qemu: report whether a machine type is deprecated in capabilities
QEMU has the ability to mark machine types as deprecated. This should be
exposed to management applications in the capabilities.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 17:30:52 +00:00
Daniel P. Berrangé
5138a09260 qemu: report whether a CPU model is deprecated in dom capabilities
QEMU has the ability to mark CPUs as deprecated. This should be exposed
to management applications in the domain capabilities.

This attribute is only set when the model is actually deprecated.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 17:26:39 +00:00
Peter Krempa
3b1d2ff510 qemuBuildRBDSecinfoURI: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
In this instance attempting to be correct is really pointless since the
secret is formatted into another string which is not erased securely and
then put on the commandline.

Keep the secure handling for correctness.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:13 +01:00
Peter Krempa
ee88bce43d qemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N
Phase out use of VIR_DISPOSE_N from the qemu driver. Use memset in the
appropriate cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:12 +01:00
Peter Krempa
ac4b55c99d qemuDomainMasterKeyCreate: Don't use VIR_DISPOSE_N on failure
When virRandomBytes fails we don't get any random bytes and even if we
did they don't have to be treated as secret as they weren't used in any
way.

Add a temporary variable with automatic freeing for the secret buffer
and assign it only on success.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-03 13:07:12 +01:00
gongwei
976bdfc8e7 conf: add realtime parameter for rtc
Pass the parameter clock rt to qemu to ensure that the
virtual machine is not synchronized with the host time

Signed-off-by: gongwei <gongwei@smartx.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-03 10:18:04 +01:00
Tim Wiederhake
2870d99f1b qemu_tpm: Fix indentation in qemuTPMEmulatorBuildCommand
This was found by clang-tidy's "readability-misleading-indentation"
check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-02-02 15:00:55 +01:00
Laine Stump
8fb0b08762 hostdevmgr: remove unneeded oldStateDir
Back in commit 2c71d3826, which appeared in libvirt-1.2.3 in April
2014, the location used to store saved MAC addresses and vlan tags of
SRIOV VFs was changed from /var/run/libvirt/qemu to
/var/run/libvirt/hostdevmgr. For backward compatibility the code was
made to continue looking in the old location for the files when it
didn't find them in the new location.

It's now been 6 years, and even if there was somebody still running
libvirt-1.2.3 on their system, that system would now be out of support
for libvirt, so there would be no way for them to upgrade to a new
libvirt that no longer looks in  "oldStateDir" for the files. So
let's no longer look in "oldStateDir" for the files!

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-02-02 00:27:58 -05:00
Daniel Henrique Barboza
b0264e9404 virpci.c: simplify virPCIDeviceNew() signature
The current virPCIDeviceNew() signature, receiving 4 uints in sequence
(domain, bus, slot, function), is not neat.

We already have a way to represent a PCI address in virPCIDeviceAddress
that is used in the code. Aside from the test files, most of
virPCIDeviceNew() callers have access to a virPCIDeviceAddress reference,
but then we need to retrieve the 4 required uints (addr.domain, addr.bus,
addr.slot, addr.function) to satisfy virPCIDeviceNew(). The result is
that we have extra verbosity/boilerplate to retrieve an information that
is already available in virPCIDeviceAddress.

A better way is presented by virNVMEDeviceNew(), where the caller just
supplies a virPCIDeviceAddress pointer and the function handles the
details internally.

This patch changes virPCIDeviceNew() to receive a virPCIDeviceAddress
pointer instead of 4 uints.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-29 17:52:10 -03:00
Daniel Henrique Barboza
0e0c974b20 domain_driver.c: use PCI address with virDomainDriverNodeDeviceGetPCIInfo()
Instead of receiving 4 uints in order and write domain/bus/slot/function,
receive a virPCIDeviceAddressPtr instead and write into it.

This change will allow us to simplify the API for virPCIDeviceNew()
in the next patch.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-29 17:51:03 -03:00
Daniel Henrique Barboza
28657b8001 qemu, lxc: move NodeDeviceGetPCIInfo() function to domain_driver.c
libxlNodeDeviceGetPCIInfo() and qemuNodeDeviceGetPCIInfo() are equal.
Let's move the logic to a new virDomainDriverNodeDeviceGetPCIInfo()
info to be used by libxl_driver.c and qemu_driver.c.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-29 17:49:54 -03:00
Ján Tomko
0e7907c10a qemu: format bootindex for vhost-user-fs
Wire up the QEMU command line for this option.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-29 14:34:15 +01:00
Ján Tomko
5b688e6dc1 Add validation for virtiofs boot order setting
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-29 14:34:15 +01:00
Ján Tomko
42dd7d797b qemu: add QEMU_CAPS_VHOST_USER_FS_BOOTINDEX
Introduced by QEMU commit:

commit 6da32fe5efdd71c9d254a436ce972194ff631285
Author:     Laszlo Ersek <lersek@redhat.com>
AuthorDate: 2021-01-12 14:16:03 +0100
Commit:     Michael S. Tsirkin <mst@redhat.com>
CommitDate: 2021-01-13 09:06:37 -0500

    vhost-user-fs: add the "bootindex" property

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-29 14:34:14 +01:00
Boris Fiuczynski
bd112c9e0f qemu: Add virtio related options to vsock
Add virtio related options iommu, ats and packed as driver element attributes
to vsock devices. Ex:

 <vsock model='virtio'>
   <cid auto='no' address='3'/>
   <driver iommu='on'/>
 </vsock>

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-29 12:25:49 +01:00
Daniel P. Berrangé
bed26ed508 qemu: fix release of virDomainObjPtr in SSH key APIs
The qemuDomainObjFromDomain() API must be paired with
the virDomainObjEndAPI API. The qemuDomainAuthorizedSSHKeysGet
method simply did 'return -1' leaking a reference and lock
in two paths.

The qemuDomainAuthorizedSSHKeysSet method marked the object
as an autoptr while also have some code paths that will call
virDomainObjEndAPI. As a result the object will be released
but not unlocked in error paths.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-27 09:31:18 +00:00
Michal Privoznik
69977ff105 qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()
If QEMU driver fails to initialize for whatever reason (it can be
as trivial as a typo on qemu.conf), the control jumps to error
label in qemuStateInitialize() where qemuStateCleanup() is called
which frees the driver. But the daemon then asks drivers to
prepare for shutdown, which in case of QEMU driver is implemented
in qemuStateShutdownPrepare(). In here, the driver is
dereferenced but since it was freed earlier, the pointer is NULL
which leads to instant crash.

Solution is simple - just check if qemu_driver is not NULL. But
doing so only in qemuStateShutdownPrepare() would push the
problem down to virStateShutdownWait(), well
qemuStateShutdownWait(). Therefore, duplicate the trick there
too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359#c14
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-27 09:39:40 +01:00
Peter Krempa
8fd72501c8 virStorageSourceChainLookup: Handle names like 'vda[4]' internally
All callers of this function called virStorageFileParseChainIndex
before. Internalize the logic of that function to prevent multiple calls
and passing around unnecessary temporary variables.

This is achieved by calling virStorageFileParseBackingStoreStr and using
it to fill the values internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-27 07:49:57 +01:00
Peter Krempa
db4d7a37ca virStorageSourceGetBackingStoreStr: Return relative paths only
Rename the function to virStorageSourceFetchRelativeBackingPath and
return relative paths only. The function is only used to restore the
relative relationship between images so there's no need for it to be
universal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-27 07:49:57 +01:00
Helmut Grohne
44b348134c meson: Fix cross-building of dtrace probes
dtrace invokes the C compiler, so when cross-building we need
to make sure that $CC is set in the environment and that it
points to the cross-compiler rather than the native one.

Until https://github.com/mesonbuild/meson/issues/266
is addressed, the workaround is to call dtrace via env(1).

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980334

Signed-off-by: Helmut Grohne <helmut@subdivi.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-26 10:59:45 +01:00
Pavel Hrdina
836e0a960b storage_source: use virStorageSource prefix for all functions
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
3e54766414 util: move virStorageSource code into conf
The code handles XML bits and internal definition and should be
in conf directory.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
2cdd833eae util: move virStorageFileProbe code into storage_file
Same as virStorageFileBackend, it doesn't belong into util directory.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
01f7ade912 util: extract virStorageFile code into storage_source
Up until now we had a runtime code and XML related code in the same
source file inside util directory.

This patch takes the runtime part and extracts it into the new
storage_file directory.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
296032bfb2 util: extract storage file probe code into virtstoragefileprobe.c
This code is not directly relevant to virStorageSource so move it to
separate file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
eaa0b3288e util: move virStorageSourceFindByNodeName into qemu_domain
It's only relevant for QEMU driver.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
23a68a0ed9 src: add missing virstoragefile.h includes
These files are using functions from virstoragefile.h but are missing
explicit include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Michal Privoznik
0123b42c54 conf: Turn @uuid member of _virDomainMemoryDef struct into a pointer
The _virDomainMemoryDef structure has @uuid member which is
needed for PPC64 guests. No other architectures use it. Since the
member is VIR_UUID_BUFLEN bytes long, the structure is
unnecessary big. If the member is just a pointer then we can also
replace some calls of virUUIDIsValid() with plain test against
NULL and also simplify formatter code which can now also check
the pointer against NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-18 16:18:48 +01:00
Michal Privoznik
6cf2ce8e8b qemu: Build command line for virtio-pmem
Now we have everything prepared for generating the command line.
The device alias prefix was chosen to be 'virtiopmem'.

Since virtio-pmem-pci device goes onto PCI bus generating device
alias must have been changed slightly because
qemuAssignDeviceMemoryAlias() might have used DIMM slot number to
generate the alias. This obviously won't work and thus the "old"
way (which includes qemuDomainDeviceAliasIndex()) must be used.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1735375
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:49 +01:00
Michal Privoznik
5b4b8dd1e2 qemu: Create virtio-pmem in namespace
Some users might want to have virtio-pmem backed by a block device
in which case we have to create the device in the domain private
namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:48 +01:00
Michal Privoznik
a536873d82 qemu: Allow virtio-pmem in CGroups
Some users might want to have virtio-pmem backed by a block
device in which case we have to allow the device in CGroups.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:47 +01:00
Michal Privoznik
173733b7a8 conf: Introduce virtio-pmem <memory/> model
The virtio-pmem is a virtio variant of NVDIMM and just like
NVDIMM virtio-pmem also allows accessing host pages bypassing
guest page cache. The difference is that if a regular file is
used to back guest's NVDIMM (model='nvdimm') the persistence of
guest writes might not be guaranteed while with virtio-pmem it
is.

To express this new model at domain XML level, I've chosen the
following:

  <memory model='virtio-pmem' access='shared'>
    <source>
      <path>/tmp/virtio_pmem</path>
    </source>
    <target>
      <size unit='KiB'>524288</size>
    </target>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
  </memory>

Another difference between NVDIMM and virtio-pmem is that while
the former supports NUMA node locality the latter doesn't. And
also, the latter goes onto PCI bus and not into a DIMM module.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:33 +01:00
Michal Privoznik
f06c1d908f qemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_PMEM_PCI
This commit introduces a new capability that reflects virtio-pmem-pci
device support in qemu:

  QEMU_CAPS_DEVICE_VIRTIO_PMEM_PCI, /* -device virtio-pmem-pci */

The virtio-pmem-pci device was introduced in QEMU 4.1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:31 +01:00
Laine Stump
3bb87556b8 qemu: don't set interface MTU when managed='no'
managed='no' on an <interface> allows an unprivileged libvirt to use a
pre-created tap/macvtap device that libvirt has permission to
open/read/write, but no permission to modify (i.e. set the MTU or MAC
address). But when the XML had an <mtu size='blah'/> setting (which
was put there in order to tell the *guest* OS what MTU to set for the
emulated device at the other end of the tap) we were attempting to set
the MTU of the tap device on the host, paying no attention to the
setting of 'managed'. That would of course end in failure.

This patch only sets the MTU if managed='no' is *not* set (so, if it
is 'yes', or just not set at all).

Note that MTU of the tap is also set when connecting the tap to a
bridge device, but managed='no' is only allowed for <interface
type='ethernet'>, which would never attach to a bridge anyway, so we
don't need the check there.

Resolves: https://bugzilla.redhat.com/1905929
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-15 12:19:57 -05:00
Andrea Bolognani
0a6cb05e95 qemu: Fix memstat for (non-)transitional memballoon
Depending on the memballoon model, the corresponding QOM node
will have a different type and we need to account for this
when searching for it in the QOM tree.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-13 15:16:55 +01:00
Peter Krempa
202d61db48 qemuBlockJobEventProcess: Always clear 'mirrorState' when a job finishes
When a block job is terminated we should clear the 'mirrorState' and
'mirrorJob' variables so that stale values are not present prior to a
new job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-11 18:32:59 +01:00
Peter Krempa
a09c421e3e qemuMigrationSrcNBDStorageCopyReady: Use ready-state of mirror from qemuBlockJobData
Use the per-job state to determine when the non-shared-storage mirror is
complete rather than the per-disk definition one. The qemuBlockJobData
is a newer approach and is always cleared after the blockjob is
terminated while the 'mirrorState' variable in the definition of the
disk may be left over. In such case the disk mirror would be considered
complete prematurely.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-11 18:32:59 +01:00
Laine Stump
c2b2cdf746 call virDomainNetNotifyActualDevice() for all interface types
Now that this function can be called regardless of interface type (and
whether or not we have a conn for the network driver), let's actually
call it for all interface types. This will assure that we re-connect
any disconnected bridge devices for <interface type='bridge'> as
mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=1730084#c26
(until now we've only been reconnecting bridge devices for <interface
type='network'>)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 11:34:49 -05:00
Peter Krempa
dc837a412f qemu: Implement '<metadata_cache><max_size>' control for qcow2
qemu's qcow2 driver allows control of the metadata cache of qcow2 driver
by the 'cache-size' property. Wire it up to the recently introduced
elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-08 15:27:44 +01:00
Ryan Gahagan
c7570bbef8 qemu: block: Add support for VIR_STORAGE_NET_PROTOCOL_NFS
Implement support for the 'nfs' native protocol driver in the qemu
driver.

QEMU accepts numeric UID/GID for 'nfs' protocol file driver thus libvirt
needs to perform the lookup prior to passing it to qemu.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-08 15:07:42 +01:00
Ryan Gahagan
6cfb4e2fe9 conf: Add VIR_STORAGE_NET_PROTOCOL_NFS disk protocol type
Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-08 15:03:16 +01:00
Peter Krempa
3e0d9131cc qemuDomainSetBlockIoTune: Skip monitor call for empty cdrom
Similarly to startup of the VM qemu doesn't like setting throttling for
an empty drive. Just skip it since we do the correct thing once new
media is inserted.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/117
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2021-01-08 09:18:00 +01:00
Peter Krempa
8792b74774 qemuDomainSetBlockIoTune: Remove old uninformative comment
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-08 09:18:00 +01:00
Peter Krempa
28088b6f0e qemuBuildChrChardevStr: Rename 'flags' to 'cdevflags'
The monitor code uses 'flags' for the flags of the monitor builder,
while in this function it's a different set of flags. All callers pass a
variable named 'cdevflags', so rename the argument to suit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:26 +01:00
Peter Krempa
521aef329c qemuMonitorAddObject: Refactor cleanup
Remove freeing/clearing of @props as the function doesn't guarantee that
it happens on success, rename the variable hodling copy of the alias and
use g_autofree to automatically free it and remove the cleanup label as
well as 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
64cf9b0fa7 qemuMonitorAddObject: Fix semantics of @alias
The callers of qemuMonitorAddObject rely on the fact that @alias is
filled only when the object is added successfully. This is documented
but the code didn't behave like that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
83e1d8fb97 qemuMonitorJSONMakeCommandInternal: Clear @arguments when stolen
All callers of qemuMonitorJSONMakeCommandInternal will benefit from
making @arguments a double pointer and passing it to
virJSONValueObjectCreate directly which will clear it if it steals the
value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
f18f4031b1 qemuMonitorJSONAddObject: Take double pointer for @props
Prepare for a refactor of qemuMonitorJSONMakeCommandInternal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
681006a14b qemuMonitorJSONSetMigrationCapabilities: Refactor cleanup
Use automatic memory freeing and remove the 'cleanup' label and 'ret'
variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
d430b5ab31 qemuMonitorSetMigrationCapabilities: Take double pointer for @caps
This allows simplification of the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
7e8a9118d5 qemuMonitorJSONSetMigrationParams: Take double pointer for @params
This allows simplification of the caller as well as will enable a later
refactor of qemuMonitorJSONMakeCommandInternal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Michal Privoznik
225b363d50 qemuMonitorFdsetsFree: Don't leak @set->fds
The @fds member of qemuMonitorFdsetInfo struct is an array and as
such, it's allocated in qemuMonitorJSONQueryFdsetsParse() but not
freed in qemuMonitorFdsetsFree().

Fixes: b8998cc670
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-07 20:26:08 +01:00
Nick Shyrokovskiy
c9e55f92fd qemu: build fix for 910b94df
Fixes compiler error:

src/qemu/qemu_migration.c:4814:20: error: ‘dstOffline’ may be used
    uninitialized in this function [-Werror=maybe-uninitialized]
    4814 |     if (offline && !dstOffline) {

The commit that introduced the error:
910b94df: qemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Signed-off-by: Nick Shyrokovskiy <nshyrokovskiy@gmail.com>
2021-01-06 18:45:22 +03:00
Tim Wiederhake
b44caea0b2 qemuDomainChangeNet: Check changed virtio network driver options
Changes to a virtio network device such as
  <interface type="network">
    <model type="virtio"/>
    <driver iommu="on" ats="on"/> <!-- this line added -->
    ...
  </interface>
were quietly dismissed by `virsh update-device ... --live`.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-06 15:33:49 +01:00
Nikolay Shirokovskiy
910b94dfe4 qemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-06 17:10:07 +03:00
Michal Privoznik
d53b092353 qemu: Restore default root qdisc when QoS is cleared out
When an interface has some bandwidth limitation set (it's root
qdisc is htb in that case) but this gets cleared out via public
API call (virDomainSetInterfaceParameters() or
virDomainUpdateDeviceFlags()) then virNetDevBandwidthSet() clears
out whatever qdiscs were set on the interface and kernel places
the default qdisc at the root. What we need to do next is to
replace the root qdisc with the one we want.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329644
Fixes: 0b66196d86
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-06 13:29:52 +01:00
Michal Privoznik
abb1554a2d qemu: Set default qdisc before setting bandwidth
While the code that's setting default qdisc is clever enough to
not overwrite any bandwidth (potentially) set by
virNetDevBandwidthSet() (and thus the root qdisc htb is not
replaced with noqueue), it does print a debug message when that's
the case. It's needless. We can set the root qdisc beforehand and
let virNetDevBandwidthSet() overwrite it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-06 13:29:43 +01:00
Michal Privoznik
5ac2439a83 qemu_process: Release domain seclabel later in qemuProcessStop()
Some secdrivers (typically SELinux driver) generate unique
dynamic seclabel for each domain (unless a static one is
requested in domain XML). This is achieved by calling
qemuSecurityGenLabel() from qemuProcessPrepareDomain() which
allocates unique seclabel and stores it in domain def->seclabels.
The counterpart is qemuSecurityReleaseLabel() which releases the
label and removes it from def->seclabels. Problem is, that with
current code the qemuProcessStop() may still want to use the
seclabel after it was released, e.g. when it wants to restore the
label of a disk mirror.

What is happening now, is that in qemuProcessStop() the
qemuSecurityReleaseLabel() is called, which removes the SELinux
seclabel from def->seclabels, yada yada yada and eventually
qemuSecurityRestoreImageLabel() is called. This bubbles down to
virSecuritySELinuxRestoreImageLabelSingle() which find no SELinux
seclabel (using virDomainDefGetSecurityLabelDef()) and this
returns early doing nothing.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1751664
Fixes: 8fa0374c5b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-06 13:29:09 +01:00
Pavel Hrdina
abab80e29a virstoragefile: move virStorageFileIsClusterFS into virfile
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-06 13:15:17 +01:00
Pavel Hrdina
b2b1702341 src: add missing headers to various files
All these headers are indirectly included provided by virfile.h having
virstoragefile.h which will be removed in the following patch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-06 13:15:17 +01:00
Eiichi Tsukata
cc6c49f6cd conf: Add support for keeping TPM emulator state
Currently, swtpm TPM state file is removed when a transient domain is
powered off or undefined. When we store TPM state on a shared storage
such as NFS and use transient domain, TPM states should be kept as it is.

Add per-TPM emulator option `persistent_sate` for keeping TPM state.
This option only works for the emulator type backend and looks as follows:

  <tpm model='tpm-tis'>
    <backend type='emulator' persistent_state='yes'/>
  </tpm>

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-06 11:44:12 +01:00
Jiri Denemark
f7c40b5c71 qemu: The TSC tolerance interval should be closed
The kernel refuses to set guest TSC frequency less than a minimum
frequency or greater than maximum frequency (both computed based on the
host TSC frequency). When writing the libvirt code with a reversed logic
(return success when the requested frequency falls within the tolerance
interval) I forgot to include the boundaries.

Fixes: d8e5b45600
https://bugzilla.redhat.com/show_bug.cgi?id=1839095

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-06 11:24:37 +01:00
Peter Krempa
6ac2327060 qemu: backup: Properly delete temporary bitmap after push-mode incremental backup
Refactor in 0316c28a45 used incorrect source variable to initialize
the variable which holds the name of the bitmap which needs to be
deleted after the backup job finishes. This resulted into deleting the
source bitmap of the backup rather than the temporary one.

Use 'dd->incrementalBitmap' which holds the temporary bitmap name
instead of 'dd->backupdisk->incremental' which holds the name of the
source bitmap which is used by the backup.

Fixes: 0316c28a45
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1908647
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-06 09:25:12 +01:00
Peter Krempa
d0819b9f02 qemu: Properly handle setting of <iotune> for empty cdrom
When starting a VM with an empty cdrom which has <iotune> configured the
startup fails as qemu is not happy about setting tuning for an empty
drive:

 error: internal error: unable to execute 'block_set_io_throttle', unexpected error: 'Device has no medium'

Resolve this by skipping the setting of throttling for empty drives and
updating the throttling when new medium is inserted into the drive.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/111
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-06 09:24:48 +01:00
Michal Privoznik
bf14a9be1e qemu: Don't prealloc mem for real NVDIMMs
Currently, we configure QEMU to prealloc memory almost by
default. Well, by default for NVDIMMs, hugepages and if user
asked us to (via memoryBacking <allocation mode="immediate"/>).

However, when guest's NVDIMM is backed by real life NVDIMM this
approach is not the best. In this case users should put <pmem/>
into the <memory/> device <source/>, like this:

  <memory model='nvdimm' access='shared'>
    <source>
      <path>/dev/pmem0</path>
      <pmem/>
    </source>
  </memory>

Instructing QEMU to do prealloc in this case means that each
page of the NVDIMM is "touched" (the first byte is read and
written back - see QEMU commit v2.9.0-rc1~26^2) which cripples
device wear.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1894053
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-05 13:19:22 +01:00
Michal Privoznik
97bc56d75f qemu: Fix retval if ACL check fails in qemuNodeGetSecurityModel
While previously we returned 0 this is not correct. We have to
return a negative value to indicate error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-04 20:18:11 +01:00
Michal Privoznik
b955fca629 qemu: Obtain @caps only after ACL check in qemuNodeGetSecurityModel
Even though we are getting driver capabilities with
refresh=false (so that it is not expensive), we still should do
ACL check first because there is no point in bothering with the
capabilities if caller doesn't have permissions to call the API.
Also, this way the comment makes more sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-04 20:18:02 +01:00
Michal Privoznik
4aff353dd5 qemu: Use virStrcpy in qemuNodeGetSecurityModel()
The code we have there to copy seclabel model or doi can be
replaced by virStrcpy() calls which do exactly the same checks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-04 20:17:55 +01:00
Michal Privoznik
1165467940 qemu: Drop has_ccw_address from _qemuAgentDiskAddress
In recent patches new mambers to _qemuAgentDiskAddress struct
were introduced to keep optional CCW address sent by the guest
agent. These two members are a struct to store CCW address into
and a boolean to keep track whether the CCW address is valid.
Well, we can hold the same information with a pointer - instead
of storing the CCW address structure let's keep just a pointer to
it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-01-04 14:53:08 +01:00
Thomas Huth
5db43b5a76 domain_conf: Allow to look up virtio-block devices by their CCW address
On s390x, devices are accessed via the channel subsystem by default,
so we need to look up the devices via their CCW address there instead
of using PCI.

This fixes "virsh domfsinfo" on s390x for virtio-block devices (the first
attempt from commit f8333b3b0a did it in the wrong way, reporting the
device name on the guest side instead of the target name on the host side).

Fixes: f8333b3b0a ("qemu: Fix domfsinfo for non-PCI device information ...")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1858771
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-22 14:16:31 +01:00
Thomas Huth
f5c8cf9e0e qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest
Newer versions of the QEMU guest agent will provide the CCW address
of devices on s390x. Store this information in the qemuAgentDiskInfo
so that we can use this later.

We also map the CSSID 0 from the guest to the value 0xfe on the host,
see https://www.qemu.org/docs/master/system/s390x/css.html for details.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-22 14:16:31 +01:00
Laine Stump
9606349172 qemu: remove redundant code that adds "template" netdev name
The lower level function virNetDevGenerateName() now understands that
a blank ifname should be replaced with a generated name based on a
template that it knows about itself - there is no need for the higher
level functions to stuff a template name ("vnet%d") into ifname.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-16 21:31:57 -05:00
Martin Kletzander
68164892fe qemu: Extra check for NBD URI being specified
It must be used when migration URI uses `unix:` transport because otherwise we
cannot just guess where to connect for disk migration.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2020-12-16 12:19:05 +01:00
Martin Kletzander
5db1fc5602 qemu: Fix possible segfault when migrating disks
Users can provide URI without a schema.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2020-12-16 12:18:58 +01:00
Shi Lei
9b5d741a9d netdevmacvlan: Use helper function to create unique macvlan/macvtap name
Simplify ReserveName/GenerateName for macvlan and macvtap by using
common functions.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-12-15 13:35:33 -05:00
Shi Lei
c36cad1a31 netdevtap: Use common helper function to create unique tap name
Simplify GenerateName/ReserveName for netdevtap by using common
functions.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-12-15 13:35:27 -05:00
Shi Lei
294fd4bd80 util: Introduce helper functions for generating unique netdev name
Extract ReserveName/GenerateName from netdevtap and netdevmacvlan as
common helper functions.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-12-15 13:35:21 -05:00
Michal Privoznik
bff2ad5d6b qemu: Relax validation for mem->access if guest has no NUMA
In v6.8.0-27-g88957116c9 and friends I've switched the way the
default RAM is specified for QEMU (from plain -m to
memory-backend-*). This means, that even if a guest doesn't have
any NUMA nodes configured we can use memory-backend-* attributes
to translate user config requests. For instance, we can allow
memory to be shared (<access mode='shared'/> under
<memoryBacking/>). But what my original commits are missing is
allowing such configuration in our validator.

Fixes: 88957116c9
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1839034#c12
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-14 14:00:25 +01:00
Daniel Henrique Barboza
69f30cfc67 domain_conf: move net device validation to domain_validate.c
The next objective is to move virDomainDeviceDefValidate() to
domain_validate.c. First let's move all the static helpers.

The net device validation functions are used across multiple
drivers, so let's move them separately first.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-14 09:32:31 -03:00
Daniel Henrique Barboza
9432693e2b domain_conf.c: move virDomainDeviceDefValidate() to domain_validate.c
Move virDomainDeviceDefValidate() and all its helper functions to
domain_validate.c.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-14 09:29:09 -03:00
Daniel Henrique Barboza
74a8318dc5 domain_conf: move address validation functions to domain_validate.c
virDomainDefValidateAliases() is one of the static functions that
needs to be handled before moving virDomainDefValidateInternal().
Let's move all related validate functions to domain_validate.c
at the same time.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-14 09:24:10 -03:00
Laine Stump
cd338954b7 qemu: remove redundant check for file length when determining PCIe vs. PCI
Now that virPCIDeviceIsPCIExpress() checks the length of the file when
the process lacks sufficient privilege to read the entire PCI config
file in sysfs, we can remove the open-coding for that case from its
consumer.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-12 21:18:46 -05:00