Commit Graph
53911 Commits
Author SHA1 Message Date
Peter Krempa b37cdad9ba hyperv: Use 'size_t' for variable named 'i'
Per our syntax check iterator variables ought to be declared as
'size_t'.

Fixes: 9a82b2a92f
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2026-04-16 10:15:29 +02:00
Jonathon Jongsma 056c1e74db hyperv: Implement domainSnapshotCreateXML()
The Hyper-V driver does not support specifying <memory> or <disks> in
the snapshot xml and rejects those configurations.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-15 13:45:28 -05:00
Jonathon Jongsma 9a82b2a92f hyperv: Add a utility function for getting method output params
When invoking a method in WMI, it can either return synchronously or
asynchronously (with return value 4096). In the latter case, the output
parameters of the method are not present in the method response xml
document. We have to fetch the output parameters via associations with
the Job object that is returned in the method response.

the hypervInvokeMethod() function already partially handles the async
case by polling the job until it fails, completes successfully, or
times out. This patch adds a utility function to fetch a named output
parameter from a given method response xml document. It handles both
synchronous and asynchronous cases.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-15 13:45:28 -05:00
Jonathon Jongsma 6554e6ad95 hyperv: Implement domainSnapshotDelete()
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-15 13:45:28 -05:00
Jonathon Jongsma af9a26ef32 hyperv: Add snapshot related WMI class definitions
Msvm_VirtualSystemSnapshotService and  Msvm_VirtualSystemSnapshotSettingData

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2026-04-15 13:45:28 -05:00
Peter Krempa 98017d28d4 qemu: Add support for 'VIR_DOMAIN_BLOCK_RESIZE_CAPACITY' with qcow2 using the 'data-file' feature
If a qcow2 image uses a 'data-file' on a local block device we can still
honour VIR_DOMAIN_BLOCK_RESIZE_CAPACITY but use the capacity of the
data-file instead.

The code is modified to first pick the virStorageSource which we'll
probe for size based on the config of the VM and uses to determine the
new size.

Resolves: https://redhat.atlassian.net/browse/RHEL-155809
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-15 14:02:04 +02:00
Peter Krempa 6499c0a28f virsh: blockresize: Introduce '--extend' flag
Use the new VIR_DOMAIN_BLOCK_RESIZE_EXTEND to prevent accidentally
shrinking a disk and thus destroying data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-15 14:02:04 +02:00
Peter Krempa 47ed93c216 API/qemu: Introduce 'VIR_DOMAIN_BLOCK_RESIZE_EXTEND' for 'virDomainBlockResize'
Introduce a new flag VIR_DOMAIN_BLOCK_RESIZE_EXTEND which will prevent
accidental shrinking of the block device.

Warn callers that they ought to use it.

While this won't prevent any old uses without the flag (which we
couldn't change due to our API guarantees) it will give the users tools
to handle the resizing of devices more safely.

Implement it in the qemu driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-15 14:02:04 +02:00
Peter Krempa d0072e4d27 virDomainBlockResizeFlags: Convert to prefix-style docs
Upcoming patches will want to add more extensive docs for one of the new
flags so this format will make it more readable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-15 14:02:04 +02:00
Peter Krempa 62231c560e conf: Reject blockio settings for "<disk device='lun'>"
Overriding the blockio settings for disk passthrough via
"<disk device='lun'>" doesn't make sense and in fact the 'scsi-block'
device in qemu doesn't even expose the appropriate properties:

  qemu-system-x86_64: -device {"driver":"scsi-block","bus":"scsi0.0","channel":0,"scsi-id":0,"lun":0,"drive":"libvirt-1-format","id":"scsi0-0-0-0","logical_block_size":512,"physical_block_size":512}: Property 'scsi-block.physical_block_size' not found

Reject those at validation.

Resolves: https://redhat.atlassian.net/browse/RHEL-145937
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-04-15 14:02:04 +02:00
Zhenzhong Duan 9b6b234c0e docs: Change TD example policy to 0x10000000
The definition of BIT0 in policy element comes from TDX spec, but it makes
confusion for some customers whether 0 or 1 activates debug:

  1. We know that "off-TD debug mode" basically means debug from outside the
     TD --> 1 activates debug.
  2. But when a customer is not aware of the term "off-TD debug" it is very
     easy to misinterpret this as "TD debug mode off" --> 1 deactivates debug.

Given that the policy example uses "0x10000001", the second interpretation
even becomes more likely, because a customer may assume that security by
default is applied in the example.

Thus, change the policy in example configuration to "0x10000000" and update
BIT0 definition to be more explicit.

Suggested-by: Fuhry Benny <benny.fuhry@intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-15 10:09:53 +02:00
Roman Bogorodskiy 80fb188790 qemu: fix success return from qemuDomainGetHostnameLease
The current qemuDomainGetHostnameLease() implementation
jumps to the "endjob" label when it finds hostname.
As the label is defined after "ret = 0",
qemuDomainGetHostnameLease() returns -1 in this case.

That works because in qemuDomainGetHostname() it is used like that:

...
       if (qemuDomainGetHostnameLease(vm, &hostname) < 0)
           goto cleanup;

...

   cleanup:
      virDomainObjEndAPI(&vm);
      return hostname;
  }

So it works, but it looks confusing. To make more consistent,
use 'break' in qemuDomainGetHostnameLease() when the hostname
is found, so it returns 0 in this case.

Fixes: a4a5827c9f
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-14 19:09:06 +02:00
Roman Bogorodskiy 47e9e16100 bhyve: implement domainInterfaceAddresses and domainGetHostname
Implement the domainInterfaceAddresses and domainGetHostname APIs.
These APIs could use multiple sources of information, though
for bhyve only the 'lease' source is supported.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-14 19:09:06 +02:00
Wesley Hershberger 8895c45a18 virt-aa-helper: Include macvtap tapfd path
Wthout this change, the tapfd path would only be appended to a domain's
profile when the device is hotplugged (either during domain start or
normal operation). Operations which regenerate the profile (blockcommit,
etc) will cause this path to be dropped from the profile.

Since the domain status XML now includes the path to the tap device,
include it in the profile.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/692
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2126574
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
2026-04-14 11:18:42 +02:00
Wesley Hershberger 732756dac8 apparmor: Pass status XML to virt-aa-helper
VIR_DOMAIN_DEF_FORMAT_STATUS is used to include disk & network
privateData elements in the domain XML, which contain misc information
that should be available to the virt-aa-helper when generating rules.

For now, this will be used in a subsequent patch to pass tap paths to
the virt-aa-helper.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
2026-04-14 11:18:42 +02:00
Wesley Hershberger 0afb35ff19 qemu: Store tapfd path in domstatus XML
Introduce a read-only `tapfd` element for direct interfaces (macvtap),
which contains the path to the backing tapfd for that interface
(e.g. `/dev/tapXX`).

The element is only included when the domain is being formatted for
internal consumption (VIR_DOMAIN_DEF_FORMAT_STATUS) and is not accepted
in user-provided XML (!VIR_DOMAIN_DEF_PARSE_INACTIVE).

This will be used by the AppArmor security driver when re-generating
profiles.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
2026-04-14 11:18:42 +02:00
Pavel Hrdina 74e619c8ce chSocketRecv: Fix memory leak
Add missing g_autofree as the code looks like it was already written to
use it.

Fixes: 6316f26cd2
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-14 10:29:20 +02:00
Pavel Hrdina f2434e8bd2 virNetworkIPDefFormat: Fix memory leaks
Use g_auto() for every virBuffer in this function to make sure none of
them will leak memory. It is not necessary to use on all of them because
for some of the buffers virXMLFormatElement() is called before any
return from the function but for consistency reasons it's better to use
g_auto() for all cases.

Fixes: d9b34ad12b
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-14 10:29:20 +02:00
Michal Privoznik e52ca27026 virnetdevmacvlan: Drop udev busy loop from virNetDevMacVLanTapOpen()
Now that after previous commit the wait for udev to settle down
is done right after device creation, there's no need to have
additional wait in virNetDevMacVLanTapOpen(). It's effectively a
dead code. Remove it.

Tested-by: Johannes Segitz <jsegitz@suse.de>
Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-14 10:02:19 +02:00
Michal Privoznik 44bcb77ef4 virnetdevmacvlan: Wait for udev to settle after creating macvtap
When a macvtap interface is created (e.g. during domain startup
or on device hotplug) libvirt then open corresponding /dev/tapNN
in order to pass FDs to the hypervisor. These FDs are labelled
before passing, but if creating the interface and open() happen
in quick succession, i.e. when udev did not had chance to run,
then the /dev/tapNN node might have default SELinux label
(device_t) instead of correct one (tun_tap_device_t). This then
leads to AVC messages, like the following:

  type=AVC msg=audit(1774535384.365:1238): avc:  denied  { open } for  pid=6765
  comm="rpc-virtqemud" path="/dev/tap33" dev="devtmpfs" ino=805
  scontext=system_u:system_r:virtqemud_t:s0
  tcontext=system_u:object_r:device_t:s0 tclass=chr_file permissive=1

Therefore, allow udev to settle down after macvtap is created (by
calling virWaitForDevices()).

Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/866
Tested-by: Johannes Segitz <jsegitz@suse.de>
Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2026-04-14 09:59:37 +02:00
Laine Stump 792cb6bf60 util: add info about g_get_user_*_dir directories to log banner
When running in session/unprivileged mode, nearly all paths are
prefixed with the returns from one of glib's g_get_user_*_dir()
functions, which in turn base their selected paths on the settings of
a few items in the user's environment ($XDG_*, or a subdirectory of
$HOME if the relevant $XDG_* isn't set).

This patch logs the settings of these directories in the log banner in
an attempt to help diagnose the problem when a file/socket open/create
fails.

An example of the banner:

libvirt version: 12.3.0, package: 1.fc43 (Unknown, 2026-04-07-22:43:30, vhost)
hostname: 83be0e173e02, uid: 107
home dir: '/' (HOME='/')
runtime dir: '/.cache' (XDG_RUNTIME_DIR='(unset)')
config dir: '/.config' (XDG_CONFIG_HOME='(unset)')
log dir: '/.cache' (XDG_CACHE_HOME='(unset)')
libvirt: XML-RPC error : Cannot create user runtime directory '/.cache/libvirt': Permission denied

Resolves: https://redhat.atlassian.net/browse/RHEL-70222
Resolves: https://redhat.atlassian.net/browse/RHEL-105490
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-09 01:12:24 -04:00
Laine Stump 92dd8a5d6c util: add uid to the log banner
As libvirt is used more and more in unprivileged/session mode,
file/socket permission errors have become more common. This patch adds
the uid of the current libvirt process (whatever it may be) to the
"hostname" line in the log banner (the first thing sent to every log
target after the process starts).

This is a first step in providing more useful info for session mode
users. We can expand on this idea to include additional generally
useful stuff about the environment we're running in. (We just need to
remember that in this context we can't call anything that could lead
to recursively calling the logging system (i.e. we can't call any code
that reports an error, or a VIR_WARN, etc))

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-09 01:12:24 -04:00
Laine Stump 481a832ef0 util: make it easier to add lines to the log "init banner"
The same thing happens for each line of the log banner:

1) A helper function is called that a) creates a "raw" string (just
   the desired info, e.g. version string) and b) calls
   virLogFormatString() to create a "cooked" version of the string
   (containing thread-id and log priority)

2) the outputFunc for the target is called with strings (a) and (b)

By making a helper that does (1b) & (2), we can further reduce the
amount of redundant code that needs to be written to add another line
to the banner - now all we need to do is:

1) create the raw string
2) call the helper, sending it the raw string

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-09 01:12:21 -04:00
Laine Stump 498038d183 util: eliminate duplicate code in virLogVMessage
The same several lines were repeated, once in a loop iterating through
all log targets, and again to output to stderr when there are no log
targets specified. This just moves those lines into a helper function,
making it easier and less error prone to add additional info to the
banner that is logged each time a daemon starts logging.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-08 22:24:42 -04:00
Laine Stump 8b6eba83ca util: consistently use typedef virLogMetadata
For some reason there were some uses of this struct where "struct
_virLogMetadata" was used instead of just using the typedef
"virLogMetadata" (they are both defined in the same file -
virlog.h). Possibly at one point the struct was in virlog.c and
outsiders could only see it as an opaque object, but even if that was
the case, there are already cases of the typedef being used outside of
virlog.c, and constinuing to use "struct _virLogMetadata" in some
places both looks too much K&R 1st edition and might incorrectly imply
to someone that there *is* data abstraction/hiding going on when there
really isn't. So let's just always use plain virLogMetadata.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-08 22:24:42 -04:00
Laine Stump cdd8f0a5ab util: log the name of the log directory that couldn't be created
The message previously just said "Could not create log directory", but
didn't provide the name of the directory, which could be helpful in
determine why the failure occured.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-08 22:24:42 -04:00
Cole Robinson a97bb897b5 qemu: remove qemuDomainOpenFile() TODO comment
qemuDomainOpenFile() only acts on the 'dac' driver, where 'label'
and 'imagelabel' are always identical (see virSecurityDACGenLabel()).
So there's nothing TODO here

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2026-04-07 19:30:32 -04:00
Cole Robinson e8e335cae0 qemu: require non-NULL 'cfg' in qemuDomainGetImageIds()
Every caller passes this in, we can depend on it being non-NULL.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2026-04-07 19:30:31 -04:00
Cole Robinson 810024a043 qemu: virtiofs: make fs->sock guard more consistent
When fs->sock is set, virtiofs is externally managed, and most
of qemu_virtiofs.c should do nothing.

Some qemu_virtiofs.c functions handle this case, but some require the
caller to guard against it.

Standardize on making this the responsibility of qemu_virtiofs.c

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2026-04-07 19:18:05 -04:00
Cole Robinson 4a1a3384be qemu: conf: reuse cfg->stateDir when setting cfg->swtpmStateDir
Use cfg->stateDir rather than duplicating it

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2026-04-07 19:13:50 -04:00
Laine Stump 29ba47d21d qemu: allow update-device of vhostuser network devices
When support for vhostuser devices was added, it was just
blanket-prevented from making any changes to a live device with
update-device. This is problematic because the link state of a network
device is modified with update-device. Most all of the parameters of a
vhostuser network device are individually checked within
qemuDomainChangeNet() anyway, so we don't need to just do a BRS (Big
Red Switch) forbidding of any change. We do need to check for
modifications to the socket parameters (path, type, reconnect) though,
since those are vhostuser-specific (we're not already checking for
them elsewhere) and they can't be changed on a live interface.

Resolves https://redhat.atlassian.net/browse/RHEL-152533
Resolves: https://bugs.passt.top/show_bug.cgi?id=198
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-07 15:27:37 -04:00
Laine Stump 20b9b04c50 qemu: log error on attempts to change backend type of live network interface
Somehow we've never checked for this, and nobody has ever tested for
it or complained about it, but certainly attempting to change a user
or vhostuser network device to/from a passt backend wouldn't work. Now
we check for it and log an error.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-07 15:27:37 -04:00
Pavel Hrdina 5e3cc48fe8 qemuDomainSetThrottleGroup: Fix memory leak
The commit missed freeing group_name in info and conf_info structs.

Fixes: 937f300c56
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-07 20:55:35 +02:00
Pavel Hrdina 7e4892553b virStorageVolPoolRefreshDataFree: Fix memory leak
When vol_path was added it missed adding free as well.

Fixes: 03e750f35d
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-07 20:55:32 +02:00
Pavel Hrdina e01529d5a7 nodeDeviceEventSubmit: Fix memory leak
In case driver is null we would leak memory allocated in event.

Fixes: b56458d443
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-07 20:55:32 +02:00
Pavel Hrdina 4f77823617 qemuBlockStorageSourceGetNFSProps: Fix memory handeling
We would leak ret if the remaining two virJSONValueObjectAdd() calls
would fail but it will not happen with current code.

Fixes: c7570bbef8
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-07 20:55:32 +02:00
Arun Menon e4b26d01db secret: Update virt_secret_init_encryption_conf initialization
Refactor the configuration data setup to pass the localstatedir variable
directly during initialization.
No functional change intended.

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2026-04-07 15:52:58 +02:00
Arun Menon 2db552dc6a remote: Move secrets encryption dependency to a systemd drop-in
The monolithic libvirtd.service currently has a dependency on
virt-secret-init-encryption.service. This causes libvirtd to fail
to start on systems where the secret driver is not installed or
enabled, as systemd cannot satisfy the Requires= unit or the
LoadCredentialEncrypted= path. See below,

Requires=virt-secret-init-encryption.service
LoadCredentialEncrypted=secrets-encryption-key:@localstatedir@/lib/libvirt/secrets/secrets-encryption-key

This patch decouples the secrets encryption logic from the main
libvirtd service file. It is moved into a new systemd drop-in
(10-secret.conf) which is only installed when libvirt is built
with secret driver support. The override snippet is added to the
daemon-driver-secret package.

Fixes: 97758bc9a0
Signed-off-by: Arun Menon <armenon@redhat.com>
Fix-Suggested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2026-04-07 15:52:53 +02:00
Michal Privoznik e68e67ab1d hyperv: Implement virDomainGetGuestInfo()
The hyperv hypervisor also has guest agent, in fact multiple ones
[1][2]. The first one, KVP, is for storing Key-Value Pairs and in
fact it's already used by our hyperv driver when querying
domifaddr (see v12.1.0-rc1~148 for more info). Anyhow, the KVP
service is capable of more, it can provide guest OS info, guest
FQDN and others. These informations are exposed via
GuestIntrinsicExchangeItems member of the
Msvm_KvpExchangeComponent struct [3]. You may have noticed the
member is an array of strings, well those strings are in fact XML
documents. For instance:

  <INSTANCE CLASSNAME="Msvm_KvpExchangeDataItem">
    <PROPERTY NAME="Caption" TYPE="string"/>
    <PROPERTY NAME="Data" TYPE="string">
      <VALUE>6.12.61-1-lts</VALUE>
    </PROPERTY>
    <PROPERTY NAME="Description" TYPE="string"/>
    <PROPERTY NAME="ElementName" TYPE="string"/>
    <PROPERTY NAME="InstanceID" TYPE="string"/>
    <PROPERTY NAME="Name" TYPE="string">
      <VALUE>OSBuildNumber</VALUE>
    </PROPERTY>
    <PROPERTY NAME="Source" TYPE="uint16">
      <VALUE>2</VALUE>
    </PROPERTY>
  </INSTANCE>

This is a bit messy to work with, because it's not like in QEMU's
world where each type of guest info (virDomainGuestInfoTypes)
corresponds 1:1 to a guest agent command. Hence the lookupTable
in hypervGetServicesProcessOne().

NB, the original jira issue asks for exposing plain fact whether
KVP daemon is running inside the guest and this commit implements
seemingly different feature. Well, thing is, in case of QEMU
there's a domain XML part where guest agent is configured and
where we expose whether there's somebody listening inside the
guest. But in case of hyperv there's no <channel/> to be
configured as communication with KVP daemon happens through
vmbus [4]. Users are advised to call the virDomainGetGuestInfo()
API with non-zero 'types' argument and if they get an error with
VIR_ERR_AGENT_UNRESPONSIVE code then the KVP daemon is not
running.

1: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/hv/hv_kvp_daemon.c
2: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/hv/hv_vss_daemon.c
3: https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/msvm-kvpexchangecomponent
4: https://docs.kernel.org/virt/hyperv/vmbus.html
Resolves: https://redhat.atlassian.net/browse/RHEL-147661
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2026-04-07 10:06:59 +02:00
Cole Robinson a9aed6716f qemu: virtiofs: remove unused qemuVirtioFSCreateSocketFilename
Replaced by qemuDomainGetVHostUserFSSocketPath in e7801a490c

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2026-04-02 11:22:59 -04:00
Michal Privoznik 46479568b8 security: Don't error out on seclabels of type='none'
Ever since of commit v1.2.13-rc1~66 the model attribute of a
<seclabel/> is validated against secdriver names enabled. In
nearly all cases this is something users want so that domain XML
does not claim to set seclabels of a model that's not enabled.
However, consider the following seclabel:

  <seclabel type='none' model='selinux'/>

It tells us to not bother setting selinux labels on given domain.
A mgmt app might format this into domain XML if it sees selinux
is disabled on the host. But if that's the case, selinux driver
is not loaded and this virSecurityManagerCheckModel() doesn't
find it and reports an error.

Well, the error doesn't need to be reported as we will just
ignore selinux as each driver callback checks if relabel is false
(which it is for type='none'). This is true for other secdrivers
too.

Resolves: https://redhat.atlassian.net/browse/RHEL-156689
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-02 09:42:30 +02:00
Michal Privoznik 21d573706a security: Rewrite virSecurityManagerCheckModel() to use g_autofree
Let's use automatic memory freeing inside of
virSecurityManagerCheckModel() as it will simplify future
commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-02 09:42:28 +02:00
Michal Privoznik 6a74d90fb9 conf: Fix seclabel type parsing wrt default value
Prior to v7.10.0-rc1~26 seclabels defaulted to
VIR_DOMAIN_SECLABEL_DYNAMIC (type='dynamic'). But after switching
the parser to virXMLPropEnum() the type is overwritten to
VIR_DOMAIN_SECLABEL_DEFAULT because the first thing that the
helper function does is to set variable that holds the result to
zero. Switch to virXMLPropEnumDefault() to restore the previous
behavior.

Fixes: f7ff8556ad
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2026-04-02 09:42:17 +02:00
Martin Kletzander 24134964f6 tests/virhostcpudata: Add test case with many offline CPUs
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-04-01 10:46:47 +02:00
Felix Huettner fa72b634cd virhostcpu: Fix potential use of unallocated memory
In case of a host that has a large number of cpus offline the count of
host cpus and the last bit set in the virHostCPUGetOnlineBitmap might
diverge significantly. This can e.g. be the case when disabling smt via
/sys/devices/system/cpu/smt/control.

On the host this looks like:
```
$ cat /sys/devices/system/cpu/present
0-255
$ cat /sys/devices/system/cpu/online
0-127
```

However in this case virBitmapToData previously only allocated 16 bytes
for the output bitmap. This is becase the last set bit is on the 15th
byte.

Users of virHostCPUGetMap however rely on the "cpumap" containing enough
space for all existing cpus (so they would expect 32 bytes in this case).
E.g. cmdNodeCpuMap relies on this for its output. It will then actually
read 32 bytes from the start of the "cpumap" address where in this case
the last 16 of these bytes are uninitialized.

This manifests itself in flapping outputs of "virsh nodecpumap --pretty" like:
```
$ virsh nodecpumap --pretty
CPUs present:   256
CPUs online:    128
CPU map:        0-127,192,194,202

$ virsh nodecpumap --pretty
CPUs present:   256
CPUs online:    128
CPU map:        0-127,192,194,197

$ virsh nodecpumap --pretty
CPUs present:   256
CPUs online:    128
CPU map:        0-127,192,194,196-197
```

This in turn potentially causes users of this data to report wrong cpu
counts.

Note that this only seems to happen with at least 256 physical cpus
where at least 128 are offline.

We fix this by preallocating the expected bitmap size.

Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-04-01 10:46:47 +02:00
Martin Kletzander 527e2316dc tests: Extend virhostcputest to check virHostCPUGetMap
This commit goes through all virhostcpudata subdirectories and checks
that `virHostCPUGetMap()` returns valid data for each one of them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-04-01 10:46:47 +02:00
Jiri Denemark bfb70fba59 Post-release version bump to 12.3.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2026-04-01 09:41:48 +02:00
Jiri Denemark 93a00a3db8 Release of libvirt-12.2.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
v12.2.0
2026-04-01 09:37:13 +02:00
Jonathon Jongsma f9c95bdbd0 NEWS: mention new hyperv features
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2026-04-01 09:17:17 +02:00
Peter Krempa 8850040735 NEWS: Document 'handle' fs backend removal, blockjob backend zeroing and stats for '<dataStore>'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2026-03-31 15:24:36 +02:00