]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoconf: domain: Convert from virXPathLong
Peter Krempa [Wed, 5 Oct 2022 11:52:07 +0000 (13:52 +0200)]
conf: domain: Convert from virXPathLong

Convert the two uses of virXPathLong to proper
virXMLPropInt/virXMLPropLongLong so that virXPathLong can be removed in
an upcoming patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotestParseNodeInfo: Rewrite to virXPathU(Int|LongLong)
Peter Krempa [Wed, 5 Oct 2022 11:51:45 +0000 (13:51 +0200)]
testParseNodeInfo: Rewrite to virXPathU(Int|LongLong)

Use the function for appropriate types and simplify the error logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Disallow aliasing of negative numbers in virXPathUInt
Peter Krempa [Wed, 5 Oct 2022 07:56:38 +0000 (09:56 +0200)]
util: xml: Disallow aliasing of negative numbers in virXPathUInt

Passing negative number as an alias for the max value is an anti-feature
we unfortunately allowed in virsh, but luckily never encouraged in the
XML.

Refuse numbers with negative sign when parsing unsigned int from
XPaths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNodeDevCapsDefParseHexId: Use 'virXPathUIntBase'
Peter Krempa [Wed, 5 Oct 2022 07:24:26 +0000 (09:24 +0200)]
virNodeDevCapsDefParseHexId: Use 'virXPathUIntBase'

Switch to the proper function for parsing integer variant of a hex
number via XPath and spell out properly that the argument is 'unsigned
int'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Introduce virXPathU(Int|LongLong)Base
Peter Krempa [Wed, 5 Oct 2022 07:17:29 +0000 (09:17 +0200)]
util: xml: Introduce virXPathU(Int|LongLong)Base

In an effort to remove the 'Long' variants of XPath number fetching
functions we need a way to replace the hex number parsing capability.

The new helpers are created from the originals by adding a 'base'
argument and keeping the original function as a wrapper to pass 10.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Reimplement virXPath(U)Int via virXPathEvalString
Peter Krempa [Wed, 5 Oct 2022 11:04:17 +0000 (13:04 +0200)]
util: xml: Reimplement virXPath(U)Int via virXPathEvalString

Similarly to the refactor of virXPath(U)LongLong drop the ability to
convert from the internal double value forcing the use of the 'string()'
conversion.

In case of 32 bit integers there's no problem with overflows, but we can
implement the code identically to what we have in the other helpers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: cpu: Extract and refactor parsing of cache from virCPUDefParseXML
Peter Krempa [Wed, 5 Oct 2022 10:58:30 +0000 (12:58 +0200)]
conf: cpu: Extract and refactor parsing of cache from virCPUDefParseXML

Move the parser into a helper function named 'virCPUDefParseXMLCache'
and use the virXMLProp* helpers instead of multiple XPath lookups.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: numa: Don't fetch XML node count in virDomainNumatuneParseXML
Peter Krempa [Wed, 5 Oct 2022 10:33:19 +0000 (12:33 +0200)]
conf: numa: Don't fetch XML node count in virDomainNumatuneParseXML

The code only wants to refuse cases where more than one 'numatune'
element is present which can be achieved by using 'virXPathBoolean'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: node_device: Use 'string()' in XPath expressions for virNodeDevCapsDefParseIntO...
Peter Krempa [Wed, 5 Oct 2022 08:45:04 +0000 (10:45 +0200)]
conf: node_device: Use 'string()' in XPath expressions for virNodeDevCapsDefParseIntOptional

Upcoming patches will require that the XML XPath query returns a string
for conversion in virXPathInt. Convert all the XPaths used with
virNodeDevCapsDefParseIntOptional which uses virXPathInt internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: node_device: Convert rest of virXPathUInt XPath expressions to number
Peter Krempa [Wed, 5 Oct 2022 08:40:04 +0000 (10:40 +0200)]
conf: node_device: Convert rest of virXPathUInt XPath expressions to number

Convert the rest of the XPath expressions used with virXPathUInt
directly to convert via string(). This will become mandatory in upcoming
patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: node_device: Use 'string()' in XPath expressions for virNodeDevCapsDefParseUInt
Peter Krempa [Wed, 5 Oct 2022 08:37:36 +0000 (10:37 +0200)]
conf: node_device: Use 'string()' in XPath expressions for virNodeDevCapsDefParseUInt

Upcoming patches will require that the XML XPath query returns a string
for conversion in virXPathUInt. Convert all the XPaths used with
virNodeDevCapsDefParseUInt which uses virXPathUInt internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Disallow aliasing of negative numbers in virXPathULongLong
Peter Krempa [Wed, 5 Oct 2022 07:56:38 +0000 (09:56 +0200)]
util: xml: Disallow aliasing of negative numbers in virXPathULongLong

Passing negative number as an alias for the max value is an anti-feature
we unfortunately allowed in virsh, but luckily never encouraged in the
XML.

Refuse numbers with negative sign when parsing unsigned long long from
XPaths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: qemucapabilities: Add data for the qemu-7.2 dev cycle
Peter Krempa [Fri, 7 Oct 2022 08:14:55 +0000 (10:14 +0200)]
tests: qemucapabilities: Add data for the qemu-7.2 dev cycle

Add data based on the v7.1.0-1579-g5107fd3eff qemu commit.

Notable changes:

- New machine types and corresponding objects:
    - pc-i440fx-7.2, pc-i440fx-7.2-machine, pc-q35-7.2, pc-q35-7.2-machine
- new NETDEV_STREAM_CONNECTED/NETDEV_STREAM_DISCONNECTED events
- thread-context object and prealloc-property for memory devices added
- libblkio block driver backed support added:
    - new backend protocol drivers:
       - io_uring, nvme-io_uring, virtio-blk-vhost-user, virtio-blk-vhost-vdpa
- New CPU flags and some CPU features become migratable
  (corresponding 'cpu-host-model' test changed output)
- cpu features 'avx', 'avx2', 'f16c', 'fma', 'vaes' became available in
  TCG
- 'dumpdtb' command added
- New disk frontend properties:
    - account-failed, account-invalid
- New unstable commands for debugging virtio:
  x-query-virtio, x-query-virtio-status, x-query-virtio-queue-status,
  x-query-virtio-vhost-queue-status, x-query-virtio-queue-element

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu_namespace: Make qemuDomainGetPreservedMounts() more robust wrt running VMs
Michal Privoznik [Mon, 31 Oct 2022 15:26:17 +0000 (16:26 +0100)]
qemu_namespace: Make qemuDomainGetPreservedMounts() more robust wrt running VMs

The aim of qemuDomainGetPreservedMounts() is to get a list of
filesystems mounted under /dev and optionally generate a path for
each one where they are moved temporarily when building the
namespace. And if given domain is also running it looks into its
mount table rather than at the host one. But if it did look at
the domain's private mount table, it find /dev mounted twice: the
first time by udev, the second time the tmpfs mounted by us.

Now, later in the function there's a "sorting" algorithm that
tries to reduce number of mount points needing preservation, by
identifying nested mount points. And if we keep the second
occurrence of /dev on the list, well, after the "sorting" we are
left with nothing but "/dev" because all other mount points are
nested.

Fixes: 46b03819ae8d833b11c2aaccb2c2a0361727f51b
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu_namespace: Don't leak memory in qemuDomainGetPreservedMounts()
Michal Privoznik [Mon, 31 Oct 2022 14:38:13 +0000 (15:38 +0100)]
qemu_namespace: Don't leak memory in qemuDomainGetPreservedMounts()

The aim of qemuDomainGetPreservedMounts() is to get a list of
filesystems mounted under /dev and optionally generate a path for
each one where they are moved temporarily when building the
namespace. And the function tries to be a bit clever about it.
For instance, if /dev/shm mount point exists, there's no need to
consider /dev/shm/a nor /dev/shm/b as preserving just 'top level'
/dev/shm gives the same result. To achieve this, the function
iterates over the list of filesystem as returned by
virFileGetMountSubtree() and removes the nested ones. However, it
does so in a bit clumsy way: plain VIR_DELETE_ELEMENT() is used
without freeing the string itself. Therefore, if all three
aforementioned example paths appeared on the list, /dev/shm/a and
/dev/shm/b strings would be leaked.

And when I think about it more, there's no real need to shrink
the array down (realloc()). It's going to be free()-d when
returning from the function. Switch to
VIR_DELETE_ELEMENT_INPLACE() then.

Fixes: cdd9205dfffa3aaed935446a41f0d2dd1357c268
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuAppendDomainMemoryMachineParams: Refactor formatting of 'dump-guest-core'
Peter Krempa [Wed, 19 Oct 2022 12:14:33 +0000 (14:14 +0200)]
qemuAppendDomainMemoryMachineParams: Refactor formatting of 'dump-guest-core'

Use virTristateSwitchFromBool to fill in the default if user didn't
request it explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove double->(u)ll conversion in virXPath(U)LongLong
Peter Krempa [Wed, 5 Oct 2022 07:53:04 +0000 (09:53 +0200)]
util: xml: Remove double->(u)ll conversion in virXPath(U)LongLong

The conversion from double is not precise enough at the extremes so it
must not be used.

Spell out that the callers are required to use a string() conversion in
the XPath expression and remove the code path handling the direct
conversion from numbers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Extract XPath evaluation for strings
Peter Krempa [Wed, 5 Oct 2022 07:46:11 +0000 (09:46 +0200)]
util: xml: Extract XPath evaluation for strings

Extract the internals of virXPathString which evaluate the XPath and
validate that the returned object is a string into a new helper named
'virXPathEvalString'.

The function will be later reused in the number XPath evaluation
functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: Always use 'string()' conversion with virXPath(U)LongLong
Peter Krempa [Tue, 4 Oct 2022 15:06:14 +0000 (17:06 +0200)]
conf: Always use 'string()' conversion with virXPath(U)LongLong

When the 'string()' conversion is used the number is parsed inside
libvirt by our internal helpers which work on integers in contrast to
when 'number()' is used and libxml2 uses a 'double' variable internally.

On the upper extremes of the 64 bit variables the double precision
variable doesn't have enough precision to represent each distinct
integer and thus could cause problems.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNodeDeviceCapPCIDefFormat: Use %u for unsigned values
Peter Krempa [Tue, 4 Oct 2022 14:47:38 +0000 (16:47 +0200)]
virNodeDeviceCapPCIDefFormat: Use %u for unsigned values

'bus', 'slot' and 'function' are unsigned int variables parsed as
unsigned int, but were formated as signed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: node_device: Rename virNodeDevCapsDefParseULong to virNodeDevCapsDefParseUInt
Peter Krempa [Tue, 4 Oct 2022 14:39:46 +0000 (16:39 +0200)]
conf: node_device: Rename virNodeDevCapsDefParseULong to virNodeDevCapsDefParseUInt

The function parses an unsigned int so rename it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNodeDevCapsDefParseULong: Use virXPathUInt instead of virXPathULong
Peter Krempa [Tue, 4 Oct 2022 14:29:33 +0000 (16:29 +0200)]
virNodeDevCapsDefParseULong: Use virXPathUInt instead of virXPathULong

Fix the function argument to properly spell out 'unsigned int' and use
virXPathUInt instead of virXPathULong and a temporary value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove unused 'virXPathLongHex'
Peter Krempa [Tue, 4 Oct 2022 14:18:16 +0000 (16:18 +0200)]
util: xml: Remove unused 'virXPathLongHex'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Use consistent naming for RNG validation error handling functions
Peter Krempa [Tue, 4 Oct 2022 14:09:20 +0000 (16:09 +0200)]
util: xml: Use consistent naming for RNG validation error handling functions

Rename 'catchRNGError' to 'virXMLValidatorRNGErrorCatch' and
'ignoreRNGError' to 'virXMLValidatorRNGErrorIgnore'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Ensure proper header style in virxml.c
Peter Krempa [Tue, 4 Oct 2022 14:07:31 +0000 (16:07 +0200)]
util: xml: Ensure proper header style in virxml.c

Make the file use consistent header formatting and two line spacing
between functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Unexport virXMLXPathContextNew
Peter Krempa [Tue, 4 Oct 2022 13:55:01 +0000 (15:55 +0200)]
util: xml: Unexport virXMLXPathContextNew

The function is now referenced only within util/virxml.c other callers
should not use it directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove unused virXPathNumber
Peter Krempa [Tue, 4 Oct 2022 13:53:21 +0000 (15:53 +0200)]
util: xml: Remove unused virXPathNumber

'virXPathNumber' is not used currently, remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agostorage|test|vbox: Implement support for validating storage volume XMLs
Peter Krempa [Tue, 18 Oct 2022 12:07:55 +0000 (14:07 +0200)]
storage|test|vbox: Implement support for validating storage volume XMLs

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agostorage: Add VIR_STORAGE_VOL_CREATE_VALIDATE flag
Peter Krempa [Tue, 18 Oct 2022 11:59:29 +0000 (13:59 +0200)]
storage: Add VIR_STORAGE_VOL_CREATE_VALIDATE flag

Allow users to request validation of the storage volume XML. Add new
flag and virsh support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoconf: storage: Add support for validating storage vol XML to virStorageVolDefParse
Peter Krempa [Tue, 18 Oct 2022 11:47:31 +0000 (13:47 +0200)]
conf: storage: Add support for validating storage vol XML to virStorageVolDefParse

Introduce the VIR_VOL_XML_PARSE_VALIDATE parser flag and wire it up into
the validator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonodedev|test: Implement support for validating node device XMLs
Peter Krempa [Tue, 18 Oct 2022 11:41:04 +0000 (13:41 +0200)]
nodedev|test: Implement support for validating node device XMLs

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonodedev: Add VIR_NODE_DEVICE_(CREATE|DEFINE)_XML_VALIDATE flags
Peter Krempa [Tue, 18 Oct 2022 11:19:05 +0000 (13:19 +0200)]
nodedev: Add VIR_NODE_DEVICE_(CREATE|DEFINE)_XML_VALIDATE flags

The node device APIs which get XML from the user don't yet support XML
validation flags. Introduce virNodeDeviceCreateXMLFlags and
virNodeDeviceDefineXMLFlags with the appropriate flags and add virsh
support for the new flags.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoconf: node_device: Add 'validate' argument to virNodeDeviceDefParse
Peter Krempa [Tue, 18 Oct 2022 10:34:07 +0000 (12:34 +0200)]
conf: node_device: Add 'validate' argument to virNodeDeviceDefParse

Allow callers to request XML validation against the schema. All callers
for now pass 'false'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoschema: cpu: include 'arch' subelement in interleave definition of 'hostcpu'
Peter Krempa [Thu, 13 Oct 2022 16:49:19 +0000 (18:49 +0200)]
schema: cpu: include 'arch' subelement in interleave definition of 'hostcpu'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: storagepool: Allow interleaving of per-pool custom namespace elements
Peter Krempa [Thu, 13 Oct 2022 16:44:46 +0000 (18:44 +0200)]
schema: storagepool: Allow interleaving of per-pool custom namespace elements

The custom namespace parameters for 'rbd' and 'netfs' pool types were
not included in the interleave statement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: nwfilterbinding: Allow interleaving of subelements of 'owner' element
Peter Krempa [Thu, 13 Oct 2022 16:41:44 +0000 (18:41 +0200)]
schema: nwfilterbinding: Allow interleaving of subelements of 'owner' element

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: nwfilter: Allow interleaving subelements of the top level 'filter' element
Peter Krempa [Thu, 13 Oct 2022 16:40:15 +0000 (18:40 +0200)]
schema: nwfilter: Allow interleaving subelements of the top level 'filter' element

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: networkport: Allow interleaving of subelements of 'driver' subelement of...
Peter Krempa [Thu, 13 Oct 2022 16:21:30 +0000 (18:21 +0200)]
schema: networkport: Allow interleaving of subelements of 'driver' subelement of hostdev-pci

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: networkport: Allow interleaving of subelements of 'owner'
Peter Krempa [Thu, 13 Oct 2022 16:20:17 +0000 (18:20 +0200)]
schema: networkport: Allow interleaving of subelements of 'owner'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of 'watchdog' subelements
Peter Krempa [Thu, 13 Oct 2022 16:18:03 +0000 (18:18 +0200)]
schema: domain: Allow interleaving of 'watchdog' subelements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of <bootloader> and <os>
Peter Krempa [Thu, 13 Oct 2022 15:45:29 +0000 (17:45 +0200)]
schema: domain: Allow interleaving of <bootloader> and <os>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Add the 'type' subelement of the osexe case of 'os' element to interleave
Peter Krempa [Thu, 13 Oct 2022 15:35:30 +0000 (17:35 +0200)]
schema: domain: Add the 'type' subelement of the osexe case of 'os' element to interleave

The 'type' element was outside of the 'interleave' definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving 'ip' and 'route' sub-elements of interface
Peter Krempa [Thu, 13 Oct 2022 14:38:52 +0000 (16:38 +0200)]
schema: domain: Allow interleaving 'ip' and 'route' sub-elements of interface

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of subelements of disk's 'mirror'
Peter Krempa [Thu, 13 Oct 2022 14:38:23 +0000 (16:38 +0200)]
schema: domain: Allow interleaving of subelements of disk's 'mirror'

While for now the 'mirror' element is output only, the idea was to allow
it to be used for input too to restore the mirror job if that becomes
the necessity. Allowing interleaving of the subelements can be done
regardless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of subelements of 'memtune'
Peter Krempa [Thu, 13 Oct 2022 14:33:11 +0000 (16:33 +0200)]
schema: domain: Allow interleaving of subelements of 'memtune'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of 'tpm' config elements
Peter Krempa [Thu, 13 Oct 2022 14:32:13 +0000 (16:32 +0200)]
schema: domain: Allow interleaving of 'tpm' config elements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of PCI controller config elements
Peter Krempa [Thu, 13 Oct 2022 14:13:47 +0000 (16:13 +0200)]
schema: domain: Allow interleaving of PCI controller config elements

The 'model' and 'target' element can be freely moved around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoschema: domain: Allow interleaving of character device config elements
Peter Krempa [Thu, 13 Oct 2022 14:03:00 +0000 (16:03 +0200)]
schema: domain: Allow interleaving of character device config elements

Allow interleaving in the 'qemucdevSrcDef' definition which is shared
by all places using character device as backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoPost-release version bump to 8.10.0
Jiri Denemark [Tue, 1 Nov 2022 11:36:50 +0000 (12:36 +0100)]
Post-release version bump to 8.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoRelease of libvirt-8.9.0
Jiri Denemark [Tue, 1 Nov 2022 11:17:01 +0000 (12:17 +0100)]
Release of libvirt-8.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoNEWS: Mention VIR_DOMAIN_STATS_VM of virConnectGetAllDomainStats
Han Han [Tue, 1 Nov 2022 05:49:12 +0000 (13:49 +0800)]
NEWS: Mention VIR_DOMAIN_STATS_VM of virConnectGetAllDomainStats

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agoDocument caveats of 'VIR_DOMAIN_STATS_VM' group of statistics
Peter Krempa [Tue, 1 Nov 2022 09:39:16 +0000 (10:39 +0100)]
Document caveats of 'VIR_DOMAIN_STATS_VM' group of statistics

The original patches adding the functionality neglected to add any form
of documentation for the stats fields returned for this group.

The stats are directly converted from qemu's 'query-stats(-schema)' QMP
command without any further interpretation. The 'query-stats-schema' has
the following disclaimer:

 Note: runtime-collected statistics and their names fall outside QEMU's usual
       deprecation policies.  QEMU will try to keep the set of available data
       stable, together with their names, but will not guarantee stability
       at all costs; the same is true of providers that source statistics
       externally, e.g. from Linux.  For example, if the same value is being
       tracked with different names on different architectures or by different
       providers, one of them might be renamed.  A statistic might go away if
       an algorithm is changed or some code is removed; changing a default
       might cause previously useful statistics to always report 0.  Such
       changes, however, are expected to be rare.

Since libvirt is not doing any form of conversion of the stats we can't
meaningfully document any of the returned fields. At the same time we
can't even meaningfully provide any form of API stability for the field
names.

Modify the documentation for the 'VIR_DOMAIN_STATS_VM' group both in the
API docs and in the virsh man page to reflect that and disclaim any form
of stability guarantees we provide normally.

Fixes: 8c9e3dae142
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoNEWS: Mention the tool virt-qemu-qmp-proxy
Han Han [Tue, 1 Nov 2022 05:49:11 +0000 (13:49 +0800)]
NEWS: Mention the tool virt-qemu-qmp-proxy

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agoNEWS: Mention UNDEFINE_TPM and UNDEFINE_KEEP_TPM flags
Han Han [Tue, 1 Nov 2022 05:49:10 +0000 (13:49 +0800)]
NEWS: Mention UNDEFINE_TPM and UNDEFINE_KEEP_TPM flags

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agoinclude: Fix the introduced version of VIR_DOMAIN_STATS_VM
Han Han [Tue, 1 Nov 2022 02:45:08 +0000 (10:45 +0800)]
include: Fix the introduced version of VIR_DOMAIN_STATS_VM

Fixes: 8c9e3dae14
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agotests: Fix libxlxml2domconfigtest with latest xen
Cole Robinson [Thu, 27 Oct 2022 12:51:25 +0000 (08:51 -0400)]
tests: Fix libxlxml2domconfigtest with latest xen

shadow_memkb is populated from a libxl API call, and the value can
change. For example:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=2c992810854a15b41be920519ce83a4a328d5168

Mock libxl_get_required_shadow_memory to give consistent output

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agodocs: Remind users to remove --timeout option without socket activation
Martin Kletzander [Wed, 26 Oct 2022 14:19:25 +0000 (16:19 +0200)]
docs: Remind users to remove --timeout option without socket activation

There is part of our man page that describes how to switch to the
traditional (non-socket) activation but it might still happens sometimes that
there is an extra --timeout option specified for the daemon.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoRemove Before=libvirt-guests.service from other services
Martin Kletzander [Wed, 26 Oct 2022 12:43:39 +0000 (14:43 +0200)]
Remove Before=libvirt-guests.service from other services

libvirt-guests has After= dependency for all the sockets and that is enough.
With the extra Before= in the service file systemd postpones the start of the
socket activated service (when libvirt-guests is trying to connect to the
socket) until after libvirt-guests is stopped effectively making `systemctl stop
libvirt-guests` deadlock.  The reason for that is that all stop jobs are
scheduled before any start job.  Removing the redundant Before= specification
fixes this behaviour.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Wed, 26 Oct 2022 08:25:04 +0000 (10:25 +0200)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Wed, 26 Oct 2022 23:20:15 +0000 (01:20 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10386 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/uk/

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
2 years agoTranslated using Weblate (Korean)
김인수 [Wed, 26 Oct 2022 23:20:14 +0000 (01:20 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10386 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
2 years agonode_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd declarations
Michal Privoznik [Tue, 25 Oct 2022 13:56:33 +0000 (15:56 +0200)]
node_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd declarations

The node_device_driver.h declares nodeDeviceLock() and
nodeDeviceUnlock() functions which used to exist, but after
rework to automatic mutex management they exist no more. Their
last use was removed in v8.1.0-rc1~122.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device: Move fwd declaration of udevNodeRegister() into correct header file
Michal Privoznik [Tue, 25 Oct 2022 14:27:14 +0000 (16:27 +0200)]
node_device: Move fwd declaration of udevNodeRegister() into correct header file

Currently, udevNodeRegister() is forward declared in
node_device_driver.h even though the function is implemented in
node_device_udev.c which warrants node_device_udev.h header file.
Move the declaration into the correct file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device_udev.h: Drop include of libudev.h
Michal Privoznik [Tue, 25 Oct 2022 08:20:10 +0000 (10:20 +0200)]
node_device_udev.h: Drop include of libudev.h

Nothing in the header file requires the include of libudev.h, as
the former header file is now empty.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device: Move DMI_DEVPATH into node_device_udev.c
Michal Privoznik [Tue, 25 Oct 2022 08:19:46 +0000 (10:19 +0200)]
node_device: Move DMI_DEVPATH into node_device_udev.c

The DMI_DEVPATH macro is used exclusively within
node_device_udev.c. There's no need to expose it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agonode_device_udev.h: Drop unused macro
Michal Privoznik [Tue, 25 Oct 2022 08:04:34 +0000 (10:04 +0200)]
node_device_udev.h: Drop unused macro

The SYSFS_DATA_SIZE macro is Unused since its introduction in
v0.7.3~48. Sorry Dave.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoUpdate translation files
Weblate [Tue, 25 Oct 2022 11:11:14 +0000 (13:11 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
2 years agoRevert "cgroup/LXC: Do not condition availability of v2 by controllers"
Pavel Hrdina [Tue, 25 Oct 2022 09:34:43 +0000 (11:34 +0200)]
Revert "cgroup/LXC: Do not condition availability of v2 by controllers"

This reverts commit e49313b54ed2a149c71f9073659222742ff3ffb0.
This reverts commit a0f37232b9c4296ca16955cc625f75eb848ace39.

Revert them together to not break build.

This fix of the issue is incorrect and breaks usage of other controllers
in hybrid mode that systemd creates, specifically usage of devices and
cpuacct controllers as they are now assumed to be part of the cgroup v2
topology which is not true.

We need to find different solution to the issue.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agopo: Refresh potfile for v8.9.0
Jiri Denemark [Tue, 25 Oct 2022 11:00:12 +0000 (13:00 +0200)]
po: Refresh potfile for v8.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoci: integration: Bundle only failed Avocado test results
Erik Skultety [Thu, 13 Oct 2022 08:59:08 +0000 (10:59 +0200)]
ci: integration: Bundle only failed Avocado test results

Latest versions of Avocado create 'by-status' symlink shortcuts to test
results, IOW:

 # this is the main test results directory containing all data
 $ ls <path>/avocado/job-results/latest/test-results/
 01-scripts_networks_050-transient-lifecycle.t
 02-scripts_networks_051-transient-autostart.t
 ...
 22-scripts_networks_400-guest-bandwidth.t
 by_status/

 # list only the failed tests
 $ ls -l <path>/avocado/job-results/latest/test-results/by-status/FAIL
 19-scripts_networks_360-guest-network-vepa.t ->
    <path>/avocado/job-results/latest/test-results/19-scripts_networks_360-guest-network-vepa.t

Therefore, let's bundle only the failed ones, it's going to make the
log artifacts more obvious when looking for libvirt errors.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Create the avocado logs artifact dir conditionally
Erik Skultety [Fri, 14 Oct 2022 10:24:59 +0000 (12:24 +0200)]
ci: integration: Create the avocado logs artifact dir conditionally

Don't create an avocado directory in the resulting log artifacts
if Avocado didn't even run (e.g. libvirt errored out on service
restart).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Use 'set +e' in the log collecting job
Erik Skultety [Fri, 14 Oct 2022 10:36:06 +0000 (12:36 +0200)]
ci: integration: Use 'set +e' in the log collecting job

All 'script' blocks are defined as 'set -e' and so a single failed
return value means we won't collect some of the logs. Because of
the nature of the original job's failure some of the log sources
might not be available, but that's fine, however, the gitlab
after_script job cannot finish prematurely.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Only create a coredump log when a core exists
Erik Skultety [Fri, 14 Oct 2022 07:35:04 +0000 (09:35 +0200)]
ci: integration: Only create a coredump log when a core exists

It could be quite confusing looking at the job log artifacts and having
an empty coredump log in there, IOW it doesn't really give much
confidence that the reporting mechanism actually works.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Fix the test on avocado directory existence
Erik Skultety [Fri, 14 Oct 2022 10:33:28 +0000 (12:33 +0200)]
ci: integration: Fix the test on avocado directory existence

It's a directory, so -d should be used with 'test'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Add an extra level of quoting for augeas set options
Erik Skultety [Wed, 12 Oct 2022 15:33:27 +0000 (17:33 +0200)]
ci: integration: Add an extra level of quoting for augeas set options

Both log filters and log outputs expect string values, however, augeas
apparently requires an extra level of quotes apart from the ones we
pass via shell (see comment [1]) to work properly, otherwise augeas
ignores the value and returns 0.
Without this fix we don't set libvirt's log level to debug, we don't
set logging to a file and hence we don't include the logs in CI
artifacts in case the test suite fails.

[1] https://github.com/hercules-team/augeas/issues/301#issuecomment-143699880

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: integration: Add virtnetworkd to the list of restarted services
Erik Skultety [Wed, 12 Oct 2022 11:21:40 +0000 (13:21 +0200)]
ci: integration: Add virtnetworkd to the list of restarted services

It was missing from the set. While at it, order the daemon set
alphabetically.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodocs: Update best practices wrt "Fixes:" and GitLab
Michal Privoznik [Mon, 24 Oct 2022 11:45:23 +0000 (13:45 +0200)]
docs: Update best practices wrt "Fixes:" and GitLab

We document that a commit fixing an issue tracked in GitLab
should put just "Fixes: #NNN" into its commit message. But when
viewing git log, having full URL which is directly clickable is
more developer friendly and GitLab is capable of handling both.
Therefore, document that users should put full URL, just like
when fixing a bug tracked in other sites.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: fix conversion specifier in qemuBuildVsockDevProps
Ján Tomko [Mon, 24 Oct 2022 13:31:06 +0000 (15:31 +0200)]
qemu: fix conversion specifier in qemuBuildVsockDevProps

vhostfd is a signed integer.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: do not attempt to pass unopened vsock FD
Ján Tomko [Thu, 20 Oct 2022 14:19:20 +0000 (16:19 +0200)]
qemu: do not attempt to pass unopened vsock FD

On normal vm startup, we open a file descriptor
for the vsock device in qemuProcessPrepareHost.

However, when doing domxml-to-native, no file descriptors are open.

Only pass the fd if it's not -1, to make domxml-to-native work.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoNEWS: Document daemon crash on reconnect
Jiri Denemark [Fri, 14 Oct 2022 12:54:12 +0000 (14:54 +0200)]
NEWS: Document daemon crash on reconnect

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Do not crash when canceling migration on reconnect
Jiri Denemark [Wed, 12 Oct 2022 15:45:38 +0000 (17:45 +0200)]
qemu: Do not crash when canceling migration on reconnect

When libvirtd is restarted during an active outgoing migration (or
snapshot, save, or dump which are internally implemented as migration)
it wants to cancel the migration. But by a mistake in commit
v8.7.0-57-g2d7b22b561 the qemuMigrationSrcCancel function is called with
wait == true, which leads to an instant crash by dereferencing NULL
pointer stored in priv->job.current.

When canceling migration to file (snapshot, save, dump), we don't need
to wait until it is really canceled as no migration capabilities or
parameters need to be restored.

On the other hand we need to wait when canceling outgoing migration and
since we don't have virDomainJobData at this point, we have to
temporarily restore the migration job to make sure we can process
MIGRATION events from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu_migration: Properly wait for migration to be canceled
Jiri Denemark [Tue, 11 Oct 2022 12:00:13 +0000 (14:00 +0200)]
qemu_migration: Properly wait for migration to be canceled

In my commit v8.7.0-57-g2d7b22b561 I attempted to make
qemuMigrationSrcCancel synchronous, but failed. When we are canceling
migration after some kind of error which is detected in
in qemuMigrationSrcWaitForCompletion, jobData->status will be set to
VIR_DOMAIN_JOB_STATUS_FAILED regardless on QEMU state. So instead of
relying on the translated jobData->status in qemuMigrationSrcIsCanceled
we need to check the migration status we get from QEMU MIGRATION event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovircgroup: Remove unused variables in virCgroupV2Available
Peter Krempa [Mon, 24 Oct 2022 11:41:34 +0000 (13:41 +0200)]
vircgroup: Remove unused variables in virCgroupV2Available

After recent commit 'contFile' and 'contStr' became unused breaking
build with clang:

../../../libvirt/src/util/vircgroupv2.c:72:26: error: unused variable 'contFile' [-Werror,-Wunused-variable]
        g_autofree char *contFile = NULL;
                         ^
../../../libvirt/src/util/vircgroupv2.c:73:26: error: unused variable 'contStr' [-Werror,-Wunused-variable]
        g_autofree char *contStr = NULL;
                         ^

Fixes: a0f37232b9c4296ca16955cc625f75eb848ace39
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agocgroup/LXC: Do not condition availability of v2 by controllers
Eric van Blokland [Sun, 23 Oct 2022 12:08:28 +0000 (14:08 +0200)]
cgroup/LXC: Do not condition availability of v2 by controllers

systemd in hybrid mode uses v1 hierarchies for controllers and v2 for
process tracking.

The LXC code uses virCgroupAddMachineProcess() to move processes into
appropriate cgroup by manipulating cgroupfs directly. (Note, despite
libvirt also supports talking to systemd directly via
org.freedesktop.machine1 API.)

If this path is taken, libvirt/lxc must convince systemd that processes
really belong to new cgroup, i.e. also the tracking v2 hierarchy must
undergo migration too.

The current check would evaluate v2 backend as unavailable with hybrid
mode (because there are no available controllers). Simplify the
condition and consider the mounted cgroup2 as sufficient to touch v2
hierarchy.

This consequently creates an issue with binding the V2 mount. In hybrid
mode the V2 filesystem may be mounted upon the V1 filesystem. By reversing
the order in which backends are mounted in virCgroupBindMount this problem
is circumvented.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/182
Signed-off-by: Eric van Blokland <mail@ericvanblokland.nl>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoAdded translation using Weblate (Croatian)
Gogo Gogsi [Thu, 20 Oct 2022 10:47:01 +0000 (12:47 +0200)]
Added translation using Weblate (Croatian)

Co-authored-by: Gogo Gogsi <linux.hr@protonmail.com>
Signed-off-by: Gogo Gogsi <linux.hr@protonmail.com>
2 years agobuild: drop LINUGAS sorting rule
Ján Tomko [Thu, 20 Oct 2022 13:04:11 +0000 (15:04 +0200)]
build: drop LINUGAS sorting rule

A recent merge request from Weblate adding a new file fails syntax-check
because it adds a new language at the end of LINGUAS, instead of sorting
it alphabetically. Rather than trying to work around it, drop this
pointless rule.

Reverts: 8d160b7979ad2f5dcac79ffe85f79e5c3ae330d6
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemuxml2argvtest: Don't re-parse and re-generate commandline for QAPI schema validation
Peter Krempa [Wed, 19 Oct 2022 15:10:45 +0000 (17:10 +0200)]
qemuxml2argvtest: Don't re-parse and re-generate commandline for QAPI schema validation

The removal of the special internal flag for '-netdev' validatition now
allows us to use the same virCommand object for validation of the
schema.

Pass it into the validator instead of re-parsing and re-generating
everything.

This improved the runtime of qemuxml2argvtest by ~25% on my box.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: Enable for vCPUs on hotplug
Michal Privoznik [Thu, 11 Aug 2022 10:12:35 +0000 (12:12 +0200)]
qemu: Enable for vCPUs on hotplug

As advertised in the previous commit, QEMU_SCHED_CORE_VCPUS case
is implemented for hotplug case. The implementation is very
similar to the cold boot case, except here we fork off for every
vCPU (because the implementation is done in
qemuProcessSetupVcpu() which is also the function that's called
from hotplug code). But that's okay because our hotplug APIs
allow hotplugging one device at the time.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2074559
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Enable SCHED_CORE for vCPUs
Michal Privoznik [Thu, 11 Aug 2022 13:25:24 +0000 (15:25 +0200)]
qemu: Enable SCHED_CORE for vCPUs

For QEMU_SCHED_CORE_VCPUS case, the vCPU threads should be placed
all into one scheduling group, but not the emulator or any of its
threads. Therefore, as soon as vCPU TIDs are detected, fork off a
child which then creates a separate scheduling group and adds all
vCPU threads into it.

Please note, this commit only handles the cold boot case. Hotplug
is going to be implemented in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Enable SCHED_CORE for helper processes
Michal Privoznik [Thu, 11 Aug 2022 14:12:24 +0000 (16:12 +0200)]
qemu: Enable SCHED_CORE for helper processes

For QEMU_SCHED_CORE_FULL case, all helper processes should be
placed into the same scheduling group as the QEMU process they
serve. It may happen though, that a helper process is started
before QEMU (cold start of a domain). But we have the dummy
process running from which the QEMU process will inherit the
scheduling group, so we can use the dummy process PID as an
argument to virCommandSetRunAmong().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_process: Enable SCHED_CORE for QEMU process
Michal Privoznik [Thu, 11 Aug 2022 09:57:54 +0000 (11:57 +0200)]
qemu_process: Enable SCHED_CORE for QEMU process

For QEMU_SCHED_CORE_EMULATOR or QEMU_SCHED_CORE_FULL the QEMU
process (and its vCPU threads) should be placed into its own
scheduling group. Since we have the dummy process running for
exactly this purpose use its PID as an argument to
virCommandSetRunAmong().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_domain: Introduce qemuDomainSchedCoreStart()
Michal Privoznik [Wed, 10 Aug 2022 15:17:42 +0000 (17:17 +0200)]
qemu_domain: Introduce qemuDomainSchedCoreStart()

The aim of this helper function is to spawn a child process in
which new scheduling group is created. This dummy process will
then used to distribute scheduling group from (e.g. when starting
helper processes or QEMU itself). The process is not needed for
QEMU_SCHED_CORE_NONE case (obviously) nor for
QEMU_SCHED_CORE_VCPUS case (because in that case a slightly
different child will be forked off).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_conf: Introduce a knob to set SCHED_CORE
Michal Privoznik [Tue, 26 Apr 2022 14:57:03 +0000 (16:57 +0200)]
qemu_conf: Introduce a knob to set SCHED_CORE

Ideally, we would just pick the best default and users wouldn't
have to intervene at all. But in some cases it may be handy to
not bother with SCHED_CORE at all or place helper processes into
the same group as QEMU. Introduce a knob in qemu.conf to allow
users control this behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovirCommand: Introduce APIs for core scheduling
Michal Privoznik [Wed, 27 Apr 2022 10:22:24 +0000 (12:22 +0200)]
virCommand: Introduce APIs for core scheduling

There are two modes of core scheduling that are handy wrt
virCommand:

1) create new trusted group when executing a virCommand

2) place freshly executed virCommand into the trusted group of
   another process.

Therefore, implement these two new operations as new APIs:
virCommandSetRunAlone() and virCommandSetRunAmong(),
respectively.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovirprocess: Core Scheduling support
Michal Privoznik [Tue, 26 Apr 2022 12:05:27 +0000 (14:05 +0200)]
virprocess: Core Scheduling support

Since its 5.14 release the Linux kernel allows userspace to
define trusted groups of processes/threads that can run on
sibling Hyper Threads (HT) at the same time. This is to mitigate
side channel attacks like L1TF or MDS. If there are no tasks to
fully utilize all HTs, then a HT will idle instead of running a
task from another (un-)trusted group.

On low level, this is implemented by cookies (effectively an UL
value): processes in the same trusted group share the same cookie
and cookie is unique to the group. There are four basic
operations:

1) PR_SCHED_CORE_GET -- get cookie of given PID,
2) PR_SCHED_CORE_CREATE -- create a new unique cookie for PID,
3) PR_SCHED_CORE_SHARE_TO -- push cookie of the caller onto
   another PID,
4) PR_SCHED_CORE_SHARE_FROM -- pull cookie of another PID into
   the caller.

Since a system where the code is built can be different to the
one where the code is ran let's provide declaration of some
values. It's not unusual for distros to ship older linux-headers
than the actual kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Refresh rx-filters more often
Michal Privoznik [Fri, 30 Sep 2022 14:28:24 +0000 (16:28 +0200)]
qemu: Refresh rx-filters more often

There are couple of scenarios where we need to reflect MAC change
done in the guest:

  1) domain restore from a file (here, we don't store updated MAC
     in the save file and thus on restore create the macvtap with
     the original MAC),
  2) reconnecting to a running domain (here, the guest might have
     changed the MAC while we were not running),
  3) migration (here, guest might change the MAC address but we
     fail to respond to it,

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Refresh state after restore from a save image
Michal Privoznik [Tue, 18 Oct 2022 07:44:54 +0000 (09:44 +0200)]
qemu: Refresh state after restore from a save image

When restoring a domain from a save image, we need to query QEMU
for some runtime information that is not stored in status XML, or
even if it is, it's not parsed (e.g. virtio-mem actual size, or
soon rx-filters for macvtaps).

During migration, this is done in qemuMigrationDstFinishFresh(),
or in case of newly started domain in qemuProcessStart(). Except,
the way that the code is written, when restoring from a save
image (which is effectively a migration), the state is never
refreshed, because qemuProcessStart() sees incoming migration so
it does not refresh the state thinking it'll be done in the
finish phase. But restoring from a save image has no finish
phase. Therefore, refresh the state explicitly after the domain
was restored but before vCPUs are resumed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Acquire QUERY job instead of MODIFY when handling NIC_RX_FILTER_CHANGED event
Michal Privoznik [Fri, 7 Oct 2022 14:47:10 +0000 (16:47 +0200)]
qemu: Acquire QUERY job instead of MODIFY when handling NIC_RX_FILTER_CHANGED event

We are not updating domain XML to new MAC address, just merely
setting host side of macvtap. But we don't need a MODIFY job for
that, QUERY is just fine.

This allows us to process the event should it occur during
migration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Move parts of NIC_RX_FILTER_CHANGED event handling into a function
Michal Privoznik [Fri, 30 Sep 2022 14:01:38 +0000 (16:01 +0200)]
qemu: Move parts of NIC_RX_FILTER_CHANGED event handling into a function

Parts of the code that responds to the NIC_RX_FILTER_CHANGED
event are going to be re-used. Separate them into a function
(qemuDomainSyncRxFilter()) and move the code into qemu_domain.c
so that it can be re-used from other places of the driver.

There's one slight change though: instead of passing device alias
from the just received event to qemuMonitorQueryRxFilter(), I've
switched to using the alias stored in our domain definition. But
these two are guaranteed to be equal. virDomainDefFindDevice()
made sure about that, if nothing else.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoprocessNicRxFilterChangedEvent: Free @guestFilter and @hostFilter automatically
Michal Privoznik [Fri, 30 Sep 2022 13:55:46 +0000 (15:55 +0200)]
processNicRxFilterChangedEvent: Free @guestFilter and @hostFilter automatically

There's no need to call virNetDevRxFilterFree() explicitly, when
corresponding variables can be declared as
g_autoptr(virNetDevRxFilter).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>