On Tue, Jun 02, 2026 at 01:46:46AM -0400, Laine Stump via Devel wrote:
From: Laine Stump <[email protected]>

using qemuMonitorAnnounceSelf(). Note that the other public domain
interface APIs expect interface to be specified by either its "target"
name (i.e. the name of the tap/macvtap device on the host) or by the
MAC address, but qemuMonitorAnnounceSelf() expects the QEMU "device
id" (which is known in libvirt as the "alias"), so we have to convert.

Resolves: https://redhat.atlassian.net/browse/RHEL-7047
Signed-off-by: Laine Stump <[email protected]>
---
src/qemu/qemu_driver.c | 81 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 80 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 58b68a6e2b..872cf0e8ee 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20865,7 +20865,85 @@ qemuDomainDelThrottleGroup(virDomainPtr dom,
}


-static virHypervisorDriver qemuHypervisorDriver = {

This should stay here ...

+
+
+static int
+qemuDomainAnnounceInterface(virDomainPtr dom,
+                            const char *device,
+                            virTypedParameterPtr params,
+                            int nparams,
+                            unsigned int flags)
+{
+    virDomainObj *vm = NULL;
+    int ret = -1;
+    qemuDomainObjPrivate *priv;
+    const char *alias = NULL;
+    unsigned int initial = 0;
+    unsigned int max = 0;
+    unsigned int rounds = 0;
+    unsigned int step = 0;
+
+    /* no flags supported */
+    virCheckFlags(0, -1);
+
+    if (virTypedParamsValidate(params, nparams,
+                               VIR_DOMAIN_ANNOUNCE_INTERFACE_INITIAL, 
VIR_TYPED_PARAM_UINT,
+                               VIR_DOMAIN_ANNOUNCE_INTERFACE_MAX, 
VIR_TYPED_PARAM_UINT,
+                               VIR_DOMAIN_ANNOUNCE_INTERFACE_ROUNDS, 
VIR_TYPED_PARAM_UINT,
+                               VIR_DOMAIN_ANNOUNCE_INTERFACE_STEP, 
VIR_TYPED_PARAM_UINT,
+                               NULL) < 0)
+        return -1;
+
+    if (params && nparams) {
+        virTypedParamsGetUInt(params, nparams, 
VIR_DOMAIN_ANNOUNCE_INTERFACE_INITIAL, &initial);
+        virTypedParamsGetUInt(params, nparams, VIR_DOMAIN_ANNOUNCE_INTERFACE_MAX, 
&max);
+        virTypedParamsGetUInt(params, nparams, 
VIR_DOMAIN_ANNOUNCE_INTERFACE_ROUNDS, &rounds);
+        virTypedParamsGetUInt(params, nparams, VIR_DOMAIN_ANNOUNCE_INTERFACE_STEP, 
&step);
+    }
+
+    if (!(vm = qemuDomainObjFromDomain(dom)))
+        return -1;
+    priv = vm->privateData;
+
+    if (virDomainAnnounceInterfaceEnsureACL(dom->conn, vm->def) < 0)
+        goto cleanup;
+
+    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+        goto cleanup;
+
+    if (virDomainObjCheckActive(vm) < 0)
+        goto endjob;
+
+    /* the user is sending either the interface MAC address or the
+     * name of the tap device (because that's how other APIs are
+     * implemented), but qemu's announce-self command expects the
+     * device id (known in libvirt as the "alias id"), so we need to
+     * find the <interface> and grab the alias from there
+     */
+
+    if (device) {
+        virDomainNetDef *net = NULL;
+
+        if (!(net = virDomainNetFind(vm->def, device)))
+            goto endjob;
+
+        alias = net->info.alias;
+    }
+
+    qemuDomainObjEnterMonitor(vm);
+    ret = qemuMonitorAnnounceSelf(priv->mon, alias, initial, max, rounds, 
step);
+    qemuDomainObjExitMonitor(vm);
+
+ endjob:
+    virDomainObjEndJob(vm);
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
+
+ static virHypervisorDriver qemuHypervisorDriver = {

I think you added an extra space in front of the `static` and that's why
it messed up the diff, so s/^ static/static/

    .name = QEMU_DRIVER_NAME,
    .connectURIProbe = qemuConnectURIProbe,
    .connectOpen = qemuConnectOpen, /* 0.2.0 */
@@ -21119,6 +21197,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
    .domainSetAutostartOnce = qemuDomainSetAutostartOnce, /* 11.2.0 */
    .domainSetThrottleGroup = qemuDomainSetThrottleGroup, /* 11.2.0 */
    .domainDelThrottleGroup = qemuDomainDelThrottleGroup, /* 11.2.0 */
+    .domainAnnounceInterface = qemuDomainAnnounceInterface /* 12.4.0 */

This should be 12.5.0.

With both fixed:

Reviewed-by: Martin Kletzander <[email protected]>

};


--
2.54.0

Attachment: signature.asc
Description: PGP signature

Reply via email to