Commit Graph

31852 Commits

Author SHA1 Message Date
Tim Wiederhake
9c2afd17fd conf: domain: Add hyperv passthrough mode
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-14 16:50:45 +01:00
Tim Wiederhake
5050b71da0 virDomainDefFormatFeatures: Write attribute "mode" of element "hyperv"
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-14 16:50:45 +01:00
Tim Wiederhake
6e83fafe33 virDomainFeaturesHyperVDefParse: Read attribute "mode" of element "hyperv"
Currently, this attribute may either have a value of "custom", or be absent
(which defaults to "custom"), for backwards compatibility.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-14 16:50:45 +01:00
Tim Wiederhake
cc1546ac6b conf: domain: Define enum for HyperV mode
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-14 16:50:45 +01:00
Ján Tomko
6698d8f530 util: use g_auto in virNodeSuspendHelper
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:36 +01:00
Ján Tomko
00a565aa78 util: refactor virNodeSuspendSetNodeWakeup
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:36 +01:00
Ján Tomko
9abf18ace7 util: iscsi: use two vars in CreateIfaceIQN
Do not mix automatic and manual cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:36 +01:00
Ján Tomko
1b5510c42d util: dnsmasq: refactor CapsRefresh
Use two variables with automatic cleanup instead of reusing one.

Remove the pointless cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:36 +01:00
Ján Tomko
e86d62f8f7 vmware: refactor vmwareExtractVersion
Use g_auto for cleanup and remove the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
4f1c1c9ff7 vmware: use g_auto in vmwareLoadDomains
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
f7bdd27d2c vmware: refactor vmwareUpdateVMStatus
Use g_auto and get rid of the cleanup label, as well as the ret
variable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
975a2b3555 vz: utils: use g_auto for virCommand
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
4a56179646 openvz: refactor openvzVEGetStringParam
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
7cd718cca5 openvz: use g_auto in openvzDomainMigratePerform3Params
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
c5ae8135df openvz: refactor openvzGetVEStatus
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
783e0b9c8e openvz: refactor openvzDomainSetBarrierLimit
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
0d47463356 openvz: refactor openvzDomainGetBarrierLimit
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
5c7c1db2f5 openvz: refactor openvzConnectListDefinedDomains
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:06 +01:00
Ján Tomko
80134168fe openvz: refactor openvzConnectListDomains
Use g_auto where possible, reduce scope of some variables and remove
pointless ret and rc variables.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
0681365dc3 openvz: refactor openvzDomainSetNetwork
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
83b063ca60 openvz: refactor openvzSetDiskQuota
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
8690caf5d4 openvz: refactor openvzSetInitialConfig
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
560de4e5cd openvz: refactor openvzDomainDefineCmd
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
0dfb73a511 openvz: refactor openvzGetVEID
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
680d8c91e8 openvz: refactor openvzLoadDomains
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Ján Tomko
73a716eecd openvz: refactor openvzExtractVersionInfo
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 16:41:05 +01:00
Hyman Huang(黄勇)
359e9f5cf4 qemu: Generate command line for dirty-ring-size
On QEMU command line it's represented by the dirty-ring-size
attribute of KVM accelerator.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 13:18:53 +01:00
Hyman Huang(黄勇)
5d18d740d8 qemu: support dirty ring feature
Dirty ring feature was introduced in qemu-6.1.0, this patch
add the corresponding feature named 'dirty-ring', which enable
dirty ring feature when starting VM.

To enable the feature, the following XML needs to be added to
the guest's domain description:

<features>
   <kvm>
     <dirty-ring state='on' size='xxx'>
   </kvm>
</features>

If property "state=on", property "size" must be specified, which
should be power of 2 and range in [1024, 65526].

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 13:17:41 +01:00
Michal Privoznik
a8e0f9c682 conf: Turn virDomainDef.kvm_features into a struct
In future commits we will need to store not just an array of
VIR_TRISTATE_SWITCH_* but also an additional integer. Follow the
example of TCG and introduce a structure where both the array an
integer can live.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-14 12:49:50 +01:00
Laine Stump
497e6f5fa6 util: remove virFirewallOnceInit()
There is no longer anything to initialize at binary startup time.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
d566cc55bf util: remove currentBackend from virfirewall.c
Since the currentBackend (direct vs. firewalld) setting is no longer
used for anything, we don't need to set it (either explicitly from
tests, or implicitly during init), and can completely remove it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
ab238e23b4 util: remove check for iptables binary during virFirewallInit
It's unclear exactly why this check exists; possibly a parallel to a
long-removed check for the firewall-cmd binary (added to viriptables.c
with the initial support for firewalld in commit bf156385a0 in 2012,
and long since removed), or possibly because virFirewallOnceInit() was
intended to be called at daemon startup, and it seemed like a good
idea to just log this error once when trying to determine whether to
use firewalld, or direct iptables commands, and then not waste time
building commands that could never be executed. The odd thing is that
it would sometimes result in logging an error when it couldn't find a
binary that wasn't needed anyway (e.g., if all the rules were iptables
rules, but ebtables and/or ip6tables weren't also installed).

If we just remove this check, then virCommandRun() will end up logging
an error and failing if the needed binary isn't found when we try to
execute it, which seems like it should just as good (or at least good
enough, especially since we eventually want to get rid of iptables
completely).

So let's remove it!

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
d3cd0d19ee util: move and rename virFirewallBackendSynchronize()
This function doesn't have anything to do with manipulating
virFirewall objects, but rather should be called in response to dbus
events about the firewalld service. Move this function into
virfirewalld.c, and rename it to virFirewallDSynchronize().

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
be670a91b4 util: simplify virFirewallBackendSynchronize()
This function doesn't need to check for a backend - synchronization
with firewalld should always be done whenever firewalld is registered
and available, not just when the firewalld backend is selected.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
9e8e639fd7 util: eliminate pointless switch in virFirewallApplyRule
Since commit b19863640 both useful cases of the switch statement in
this function have made the same call (and the other/default case is
just an error that can never happen). Eliminate the switch to help
eliminate use of currentBackend.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
afc8272bdf util: rename iptables operators to something less generic
Rather than calling these "ADD" and "REMOVE", which could be confused
with some other random items with the same names, make them more
specific by prepending "VIR_NETFILTER_" (because they will also be
used by the nftables backend) and rename them to match the
iptables/nftables operators they signify, i.e. INSERT and DELETE, just
to eliminate confusion (in particular, in case someone ever decides
that we need to also use the nftables "add" operator, which appends a
rule to a chain rather than inserting it at the beginning of the
chain).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
426afc0082 util: rename/move iptablesFormatNetwork to virSocketAddrFormatWithPrefix
This function formats an address + prefix as, e.g. 192.168.122.0/24,
which is useful in places other than iptables. Move it to
virsocketaddr.c and make it public so that others can use it. While
moving, the bit that masks off the host bits of the address is made
optional, so that the function is more generally useful.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Laine Stump
b449603192 network: eliminate code that uses default iptables chains
The network driver has put all its rules into private chains (created
by libvirt) since commit 7431b3eb9a, which was included in
libvirt-5.1.0. When the conversion was made, code was included that
would attempt to delete existing rules in the default chains, to make
it possible to upgrade libvirt without restarting the host OS.

Almost 3 years has passed, and it is doubtful that anyone will be
attempting to upgrade directly from a pre-5.1.0 libvirt to something
as new as 8.0.0 (possibly with the exception of upgrading the entire
OS to a new release, which would include also rebooting), so it is now
safe to remove this code.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 13:37:31 -05:00
Ján Tomko
d9fdc65a51 qemu: use automatic cleanup for virCommand
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
eff68d3637 security: apparmor: use automatic cleanup in load_profile
Use g_auto for virCommand and char * and drop the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
fd206c2867 storage: util: steal cmd in CreateQemuImgCmdFromVol
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
42823e67dc storage: logical: use two cmd vars in GetPoolSources
Do not mix manual and automatic freeing.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
4c5bcaf027 lxc: use g_auto for virCommand in virLXCProcessEnsureRootFS
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
1e6b81cdec lxc: refactor virLXCProcessBuildControllerCmd
Use automatic cleanup and remove the labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
fe9d5d6d00 lxc: use g_auto in lxcContainerChild
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
ee6b552aab bhyve: refactor virBhyveProcessBuildBhyveCmd
Use automatic cleanup for virCommand, steal it on success
and remove the error label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:46 +01:00
Ján Tomko
0c0a8ba43b bhyve: use g_auto in virBhyveProcessStop
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:45 +01:00
Ján Tomko
d604666d77 bhyve: use g_auto in virBhyveProcessStartImpl
Use g_auto and VIR_AUTOCLOSE where possible.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:45 +01:00
Ján Tomko
a55ee2a3fd bhyve: refactor bhyveConnectDomainXMLToNative
Use g_auto and remove the ret variable, as well as the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:45 +01:00
Ján Tomko
681df4776b bhyve: refactor bhyveProbeCapsFromHelp
Use g_auto and remove the 'ret' variable, as well as the out label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 18:20:45 +01:00