[PATCH 0/3] Fix ARP table parsing over netlink messages
by Martin Kletzander
Somehow it happened that some kernels (I noticed this with 6.10.0 and 6.10.2 on
various machines) started sending NLMSG_DONE message (as they probably should've
even before), but our check for it could've never worked and now `virsh
domifaddr --source arp` sometimes fails with "wrong nlmsg len". So I set out on
a quest to tame the netlink beast and though fierceful debugging and... Oh, I
forgot, nobody reads cover letters. Never mind.
Martin Kletzander (3):
virarptable: Properly calculate rtattr length
virarptable: Fix check for message length
virarptable: End parsing earlier in case of NLMSG_DONE
src/util/virarptable.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
--
2.46.0
3 months
[PATCH 0/2] virsh: Simplify vshTableRowAppend() calling in cmdList()
by Michal Privoznik
*** BLURB HERE ***
Michal Prívozník (2):
virsh: Simplify vshTableRowAppend() calling in cmdList(), part one
virsh: Simplify vshTableRowAppend() calling in cmdList(), part two
tools/virsh-domain-monitor.c | 52 +++++++++++++++---------------------
1 file changed, 21 insertions(+), 31 deletions(-)
--
2.44.2
3 months
[PATCH 0/3] Implement support for QCOW2 data files
by Nikolai Barybin
There are use cases when the existing disks (i.e. LVM) are wanted
to be used with advanced features. For this purpose QEMU allows
data-file feature for qcow2 files: metadata is kept in the qcow2
file like usual, but guest data is written to an external file.
These patches enable support for this feature in libvirt.
Nikolai Barybin (3):
conf: add data-file feature and related fields to virStorageSource
storage: add qcow2 filename parsing from header
qemu: enable qcow2 data-file attach to VM on start
src/conf/storage_source_conf.c | 8 ++++
src/conf/storage_source_conf.h | 5 ++
src/qemu/qemu_block.c | 45 ++++++++++++++++++
src/qemu/qemu_cgroup.c | 3 ++
src/qemu/qemu_namespace.c | 6 +++
src/storage_file/storage_file_probe.c | 66 +++++++++++++++++++++++----
src/storage_file/storage_source.c | 38 ++++++++++++++-
7 files changed, 160 insertions(+), 11 deletions(-)
--
2.43.5
3 months
Shared LVM and starting/stopping volumes
by dajester2005@gmail.com
Ran into a situation using a shared LVM2 volume group, where if there were volumes locked by a server, the pool could not be started on another server due to "vgchange -aly" not being able to acquire locks on all volumes in the pool. This was referenced in issue #38 on gitlab.
Long story short, I've experimented with adding APIs for starting/stopping individual volumes in a storage pool, and implementing that API in the logical backend driver. I'm not a C developer by trade, but all the existing tests pass. I'd like to submit this for some feedback, and see what would be needed to incorporate this, or similar API: https://gitlab.com/dajester2013/libvirt/-/tree/shared-lvm-storage-mods
3 months
Plans for 10.7.0 release (freeze on Tuesday 27 Aug)
by Jiri Denemark
We are getting close to 10.7.0 release of libvirt. To aim for the
release on Monday 02 Sep I suggest entering the freeze on Tuesday 27
Aug and tagging RC2 on Thursday 29 Aug.
I hope this works for everyone.
Jirka
3 months
[PATCH] lib: Use NULLSTR family of macros more
by Michal Privoznik
There is a family of convenient macros: NULLSTR, NULLSTR_EMPTY,
NULLSTR_STAR, NULLSTR_MINUS which hides ternary operator.
Generated using the following spatch (and its obvious variants):
@@
expression s;
@@
<+...
- s ? s : "<null>"
+ NULLSTR(s)
...+>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt.c | 2 +-
src/network/network_iptables.c | 4 ++--
src/network/network_nftables.c | 4 ++--
src/qemu/qemu_firmware.c | 2 +-
src/util/virnetdevip.c | 8 ++++----
tools/virsh-checkpoint.c | 2 +-
tools/virsh-domain-monitor.c | 8 ++++----
tools/virsh-nodedev.c | 2 +-
8 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 26c3fe454f..1d37696d6f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -168,7 +168,7 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr cred,
}
if (cred[i].type != VIR_CRED_EXTERNAL) {
- cred[i].result = bufptr ? bufptr : g_strdup(cred[i].defresult ? cred[i].defresult : "");
+ cred[i].result = bufptr ? bufptr : g_strdup(NULLSTR_EMPTY(cred[i].defresult));
cred[i].resultlen = strlen(cred[i].result);
}
}
diff --git a/src/network/network_iptables.c b/src/network/network_iptables.c
index f774176b3d..e8da15426e 100644
--- a/src/network/network_iptables.c
+++ b/src/network/network_iptables.c
@@ -867,10 +867,10 @@ iptablesForwardMasquerade(virFirewall *fw,
if (addrStartStr && addrStartStr[0]) {
if (addrEndStr && addrEndStr[0]) {
natRangeStr = g_strdup_printf("%s-%s%s", addrStartStr, addrEndStr,
- portRangeStr ? portRangeStr : "");
+ NULLSTR_EMPTY(portRangeStr));
} else {
natRangeStr = g_strdup_printf("%s%s", addrStartStr,
- portRangeStr ? portRangeStr : "");
+ NULLSTR_EMPTY(portRangeStr));
}
virFirewallCmdAddArgList(fw, fwCmd,
diff --git a/src/network/network_nftables.c b/src/network/network_nftables.c
index 268d1f12ca..f8b5ab665d 100644
--- a/src/network/network_nftables.c
+++ b/src/network/network_nftables.c
@@ -588,10 +588,10 @@ nftablesAddForwardMasquerade(virFirewall *fw,
if (addrStartStr && addrStartStr[0]) {
if (addrEndStr && addrEndStr[0]) {
natRangeStr = g_strdup_printf("%s-%s%s", addrStartStr, addrEndStr,
- portRangeStr ? portRangeStr : "");
+ NULLSTR_EMPTY(portRangeStr));
} else {
natRangeStr = g_strdup_printf("%s%s", addrStartStr,
- portRangeStr ? portRangeStr : "");
+ NULLSTR_EMPTY(portRangeStr));
}
virFirewallCmdAddArgList(fw, fwCmd, "counter", "snat", "to", natRangeStr, NULL);
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 08ca99e1ac..914f8596bd 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -1090,7 +1090,7 @@ qemuFirmwareEnsureNVRAM(virDomainDef *def,
loader->nvram->path = g_strdup_printf("%s/%s_VARS%s",
cfg->nvramDir, def->name,
- ext ? ext : "");
+ NULLSTR_EMPTY(ext));
}
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 3b02fe0cec..f365c1999c 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -188,8 +188,8 @@ virNetDevIPAddrAdd(const char *ifname,
VIR_DEBUG("Adding IP address %s/%d%s%s%s%s to %s",
NULLSTR(ipStr), prefix,
- peerStr ? " peer " : "", peerStr ? peerStr : "",
- bcastStr ? " bcast " : "", bcastStr ? bcastStr : "",
+ peerStr ? " peer " : "", NULLSTR_EMPTY(peerStr),
+ bcastStr ? " bcast " : "", NULLSTR_EMPTY(bcastStr),
ifname);
if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_NEWADDR, ifname,
@@ -206,8 +206,8 @@ virNetDevIPAddrAdd(const char *ifname,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed to add IP address %1$s/%2$d%3$s%4$s%5$s%6$s to %7$s"),
ipStr, prefix,
- peerStr ? " peer " : "", peerStr ? peerStr : "",
- bcastStr ? " bcast " : "", bcastStr ? bcastStr : "",
+ peerStr ? " peer " : "", NULLSTR_EMPTY(peerStr),
+ bcastStr ? " bcast " : "", NULLSTR_EMPTY(bcastStr),
ifname);
return -1;
}
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 972b2f979c..a0ac0d7f71 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -455,7 +455,7 @@ cmdCheckpointInfo(vshControl *ctl,
_("unexpected problem querying checkpoint state"));
return false;
}
- vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent : "-");
+ vshPrint(ctl, "%-15s %s\n", _("Parent:"), NULLSTR_MINUS(parent));
/* Children, Descendants. */
flags = 0;
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 74deca2f94..37184baa69 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -712,11 +712,11 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
mac = virXPathString("string(./mac/@address)", ctxt);
if (vshTableRowAppend(table,
- target ? target : "-",
+ NULLSTR_MINUS(target),
type,
- source ? source : "-",
- model ? model : "-",
- mac ? mac : "-",
+ NULLSTR_MINUS(source),
+ NULLSTR_MINUS(model),
+ NULLSTR_MINUS(mac),
NULL) < 0)
return false;
}
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 910eaefc9e..145faff3e7 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -1233,7 +1233,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
parent = virNodeDeviceGetParent(device);
vshPrint(ctl, "%-15s %s\n", _("Name:"), virNodeDeviceGetName(device));
- vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent : "");
+ vshPrint(ctl, "%-15s %s\n", _("Parent:"), NULLSTR_EMPTY(parent));
vshPrint(ctl, "%-15s %s\n", _("Active:"), virNodeDeviceIsActive(device) ?
_("yes") : _("no"));
vshPrint(ctl, "%-15s %s\n", _("Persistent:"),
--
2.44.2
3 months
[PATCH 0/1] virsh: allow both --table and --uuid at the same time
by Nikolai Barybin
For now virsh does not provide a set of options to print all info about
domain: --all does not print uuid, combination of --id --name --uuid
does not have '--state' option.
I think we should address this issue and allow user to get all available
info with one command. The easiest way to do that is to allow combining
--table and --uuid (the same way it now works with --title).
Thus, the most diverse info would look like that:
# virsh list --table --title --uuid
Id Name State Title UUID
-----------------------------------
Nikolai Barybin (1):
virsh: allow both --table and --uuid at the same time
docs/manpages/virsh.rst | 14 +++++++-------
tools/virsh-domain-monitor.c | 37 ++++++++++++++++++++++++++++++++----
2 files changed, 40 insertions(+), 11 deletions(-)
--
2.43.5
3 months, 1 week
Re: [PATCH v2 4/4] virtio-net: Add support for USO features
by Thomas Huth
On 26/07/2024 08.08, Michael S. Tsirkin wrote:
> On Thu, Jul 25, 2024 at 06:18:20PM -0400, Peter Xu wrote:
>> On Tue, Aug 01, 2023 at 01:31:48AM +0300, Yuri Benditovich wrote:
>>> USO features of virtio-net device depend on kernel ability
>>> to support them, for backward compatibility by default the
>>> features are disabled on 8.0 and earlier.
>>>
>>> Signed-off-by: Yuri Benditovich <yuri.benditovich(a)daynix.com>
>>> Signed-off-by: Andrew Melnychecnko <andrew(a)daynix.com>
>>
>> Looks like this patch broke migration when the VM starts on a host that has
>> USO supported, to another host that doesn't..
>
> This was always the case with all offloads. The answer at the moment is,
> don't do this.
May I ask for my understanding:
"don't do this" = don't automatically enable/disable virtio features in QEMU
depending on host kernel features, or "don't do this" = don't try to migrate
between machines that have different host kernel features?
> Long term, we need to start exposing management APIs
> to discover this, and management has to disable unsupported features.
Ack, this likely needs some treatments from the libvirt side, too.
Thomas
3 months, 1 week
[RFC PATCH v4 0/5] Added virtio-net RSS with eBPF support.
by Andrew Melnychenko
This series of rfc patches adds support for loading the RSS eBPF
program and passing it to the QEMU.
Comments and suggestions would be useful.
QEMU with vhost may work with RSS through eBPF. To load eBPF,
the capabilities required that Libvirt may provide.
eBPF program and maps may be unique for particular QEMU and
Libvirt retrieves eBPF through qapi.
For now, there is only "RSS" eBPF object in QEMU, in the future,
there may be another one(g.e. network filters).
That's why in Libvirt added logic to load and store any
eBPF object that QEMU provides using qapi schema.
One of the reasons why this series of patches is in RFC are tests.
To this series of patches, the tests were added.
For now, the tests are synthetic, the proper "reply" file should
be generated with a new "caps" file. Currently, there are changes
in caps-9.0.0* and caps-9.1.0 files. There was added support for
ebpf_rss_fds feature, and request-ebpf command.
So, overall, the tests are required for review, comment, and discussion
how we want them to be implemented in the future.
For virtio-net RSS, the document has not changed.
```
<interface type="network">
<model type="virtio"/>
<driver queues="4" rss="on" rss_hash_report="off"/>
<interface type="network">
```
Simplified routine for RSS:
* Libvirt retrieves eBPF "RSS" and load it.
* Libvirt passes file descriptors to virtio-net with property "ebpf_rss_fds" ("rss" property should be "on" too).
* if fds was provided - QEMU using eBPF RSS implementation.
* if fds was not provided - QEMU tries to load eBPF RSS in own context and use it.
* if eBPF RSS was not loaded - QEMU uses "in-qemu" RSS(vhost not supported).
Changes since RFC v3:
* changed tests a bit
* refactored and rebased
* removed "allowEBPF" from qemu config(now env is used for tests)
Changes since RFC v2:
* refactored and rebased.
* applied changes according to the Qemu.
* added basic test.
Changes since RFC v1:
* changed eBPF format saved in the XML cache.
* refactored and checked with syntax test.
* refactored patch hunks.
Andrew Melnychenko (5):
qemu_monitor: Added QEMU's "request-ebpf" support.
qemu_capabilities: Added logic for retrieving eBPF objects from QEMU.
qemu_interface: Added routine for loading the eBPF objects.
qemu_command: Added "ebpf_rss_fds" support for virtio-net.
tests: Added tests for eBPF blob loading.
libvirt.spec.in | 3 +
meson.build | 7 +
meson_options.txt | 1 +
src/qemu/meson.build | 1 +
src/qemu/qemu_capabilities.c | 132 ++++++++++++
src/qemu/qemu_capabilities.h | 5 +
src/qemu/qemu_command.c | 60 ++++++
src/qemu/qemu_domain.c | 4 +
src/qemu/qemu_domain.h | 3 +
src/qemu/qemu_interface.c | 87 ++++++++
src/qemu/qemu_interface.h | 7 +
src/qemu/qemu_monitor.c | 9 +
src/qemu/qemu_monitor.h | 4 +
src/qemu/qemu_monitor_json.c | 27 +++
src/qemu/qemu_monitor_json.h | 4 +
.../caps_9.0.0_sparc.replies | 95 +++++----
.../qemucapabilitiesdata/caps_9.0.0_sparc.xml | 3 +
.../caps_9.0.0_x86_64.replies | 199 ++++++++++--------
.../caps_9.0.0_x86_64.xml | 4 +
.../caps_9.1.0_x86_64.replies | 199 ++++++++++--------
.../caps_9.1.0_x86_64.xml | 4 +
tests/qemuxml2argvmock.c | 24 +++
.../net-virtio-rss-bpf.x86_64-latest.args | 37 ++++
.../net-virtio-rss-bpf.x86_64-latest.xml | 46 ++++
tests/qemuxmlconfdata/net-virtio-rss-bpf.xml | 46 ++++
tests/qemuxmlconftest.c | 5 +
26 files changed, 792 insertions(+), 224 deletions(-)
create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
--
2.45.2
3 months, 1 week
[PATCH 0/7] network: implement automatic subnet selection for virtual networks
by Laine Stump
The problem this is solving has a very long history. with a simple
bugzilla search I found reports all the way back to 2012.
The issue is that sometimes when a libvirt virtual network is started,
it could be on exactly the same subnet as another interface already
active on the host at libvirt install time (which was fixed long ago),
or as another interface that isn't active in the install environment,
but will be active when libvirt is actually started at a later time,
possibly in a completely different environment than the install (this
*wasn't* fixed. until now).
At one point (which I've located in this bugzilla comment in 2014 -
https://bugzilla.redhat.com/1146232#c17) I thought of having a config
knob in virtual networks that would look for an unused network at
runtime, and start the network with that subnet. Of course that would
have solved the problem where the conflicting network was already
active when libvirt started its networks, but wouldn't do anything
about the case where the conflicting network was started *after*
libvirt had started its networks. And anyway it would have required
config settings in /etc/libvirt/network.conf which didn't exist at the
time.
Several years later (around 2020) I learned about NetworkManager
dispatcher scripts, which are called any time NM brings an interface
up or down, and wrote a python script that would use this to destroy
any libvirt network that had a conflict with a newly activated NM
interface. After sending it as an RFC patch, I promptly forgot about
it (except for being on my "list of things I should get to someday").
A few weeks ago I realized that the "there is no network.conf to store
config items" problem was recently solved (I had to add a network.conf
file for the knob that selects nftables vs iptables), which prompted
me to go back and find the branch with the NM dispatcher script, and
*finally* implement the runtime auto address selection. Combining this
with enhancing the NM dispatcher script to not only destroy
conflicting networks, but to also then *restart* them if they have
autoaddr set, gives what I think is finally a full solution to the
problem - no matter what order interfaces are started vs. libvirt
networks being started, a network with "autoaddr='yes'" set will
*always* end up with all networks being usable.
(Well, the one issue that still remains is that if there are already
guests attached to the autoaddr='yes' network when its address is
changed, those guests will then be disconnected, and once reconnected
they will have stale IP addresses. That's another hill for another day
though; I don't think anyone has complained about that. Yet.)
I think this may break the record for "oldest bug to be fixed", which
was previously set when danpb fixed the firewalling issue with guests
on two different NATed networks being able to communicate with each
other. :-)
Laine Stump (7):
conf: add XML config for autoaddr networks
network: add configurable network autoaddr items to driver config
network: reorganize the check for route collisions
network: turn on autoaddr selection in bridge driver
network: NetworkManager script to monitor/resolve conflicts with new
interfaces
network: turn on autoaddr in default network
spec: stop trying to find unused network during deamon-network-config
%post
docs/formatnetwork.rst | 42 +++-
libvirt.spec.in | 38 +---
meson.build | 14 +-
meson_options.txt | 4 +
src/conf/network_conf.c | 75 +++++--
src/conf/network_conf.h | 7 +
src/conf/schemas/network.rng | 5 +
src/network/bridge_driver.c | 201 +++++++++++++++++-
src/network/bridge_driver_conf.c | 61 ++++++
src/network/bridge_driver_conf.h | 4 +
src/network/bridge_driver_linux.c | 132 +++++++-----
src/network/bridge_driver_nop.c | 22 +-
src/network/bridge_driver_platform.h | 5 +-
src/network/default.xml.in | 2 +-
src/network/libvirtd_network.aug | 8 +-
src/network/meson.build | 12 ++
src/network/network.conf.in | 11 +
src/network/nm-dispatcher-check-nets.py | 196 +++++++++++++++++
src/network/test_libvirtd_network.aug.in | 3 +
.../networkxml2xmlin/nat-network-autoaddr.xml | 11 +
.../nat-network-autoaddr.xml | 11 +
tests/networkxml2xmltest.c | 1 +
22 files changed, 744 insertions(+), 121 deletions(-)
create mode 100755 src/network/nm-dispatcher-check-nets.py
create mode 100644 tests/networkxml2xmlin/nat-network-autoaddr.xml
create mode 100644 tests/networkxml2xmlout/nat-network-autoaddr.xml
--
2.45.2
3 months, 1 week