From nobody Tue Sep 9 23:39:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1738158398723465.69274559360804; Wed, 29 Jan 2025 05:46:38 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2C8841901; Wed, 29 Jan 2025 08:46:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 107DA1786; Wed, 29 Jan 2025 08:42:24 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 05059165C; Wed, 29 Jan 2025 08:42:17 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7A7061611 for ; Wed, 29 Jan 2025 08:42:07 -0500 (EST) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-7mAjbkWLPK6RfH8qGTU6aA-1; Wed, 29 Jan 2025 08:42:04 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 30F3F19560A3 for ; Wed, 29 Jan 2025 13:42:03 +0000 (UTC) Received: from localhost (unknown [10.39.208.35]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D531419560A3; Wed, 29 Jan 2025 13:42:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738158127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cdaqBb2WHfxng7eNTHvTGKEe7AuxRrlO42VNnlu/ViM=; b=UTj3TBnGejmqIXx8UfMYxmiC/VoL6VpraHe6+m6/zaZFSs9NCVkpJKTiXbwXCtR+pi1UfM zT/cPlbWOfYynB/TG0ehOX4s3pHBe+pL+NOMJTaD1KozlcN2UoQHt9e5pzCM48lf+nEyaQ 4rFGhmGZMyXbS3ASIQpCflxijeUu1ic= X-MC-Unique: 7mAjbkWLPK6RfH8qGTU6aA-1 X-Mimecast-MFC-AGG-ID: 7mAjbkWLPK6RfH8qGTU6aA From: marcandre.lureau@redhat.com To: devel@lists.libvirt.org Subject: [PATCH 13/19] qemu/dbus: keep a connection to the VM D-Bus Date: Wed, 29 Jan 2025 17:40:35 +0400 Message-ID: <20250129134042.1282472-14-marcandre.lureau@redhat.com> In-Reply-To: <20250129134042.1282472-1-marcandre.lureau@redhat.com> References: <20250129134042.1282472-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: b1KgbCdRWOdH3XjlpHml_X5TQHxdJfxOXxonNWL6v9w_1738158123 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: A3DXCOSRTFTKVTNWOTNTZDBS2XFVBURA X-Message-ID-Hash: A3DXCOSRTFTKVTNWOTNTZDBS2XFVBURA X-MailFrom: marcandre.lureau@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1738158399384019000 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau The following changes are going to communicate with the qemu-rdp server through the VM D-Bus bus, keep a connection for that and further usage. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_dbus.c | 22 +++++++++++++++++++--- src/qemu/qemu_domain.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 06b655d870..4a019ae092 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -85,7 +85,7 @@ qemuDBusGetAddress(virQEMUDriver *driver, =20 =20 static int -qemuDBusWriteConfig(const char *filename, const char *path) +qemuDBusWriteConfig(const char *filename, const char *address) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *config =3D NULL; @@ -96,7 +96,7 @@ qemuDBusWriteConfig(const char *filename, const char *pat= h) virBufferAdjustIndent(&buf, 2); =20 virBufferAddLit(&buf, "org.libvirt.qemu\n"); - virBufferAsprintf(&buf, "unix:path=3D%s\n", path); + virBufferAsprintf(&buf, "%s\n", address); virBufferAddLit(&buf, "EXTERNAL\n"); =20 virBufferAddLit(&buf, "\n"); @@ -140,6 +140,8 @@ qemuDBusStop(virQEMUDriver *driver, } else { priv->dbusDaemonRunning =3D false; } + + g_clear_object(&priv->dbusConnection); } =20 =20 @@ -175,11 +177,13 @@ qemuDBusStart(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCommand) cmd =3D NULL; + g_autoptr(GError) gerr =3D NULL; g_autofree char *dbusDaemonPath =3D NULL; g_autofree char *shortName =3D NULL; g_autofree char *pidfile =3D NULL; g_autofree char *configfile =3D NULL; g_autofree char *sockpath =3D NULL; + g_autofree char *address =3D NULL; virTimeBackOffVar timebackoff; const unsigned long long timeout =3D 500 * 1000; /* ms */ VIR_AUTOCLOSE errfd =3D -1; @@ -205,8 +209,9 @@ qemuDBusStart(virQEMUDriver *driver, pidfile =3D qemuDBusCreatePidFilename(cfg, shortName); configfile =3D qemuDBusCreateConfPath(cfg, shortName); sockpath =3D qemuDBusCreateSocketPath(cfg, shortName); + address =3D g_strdup_printf("unix:path=3D%s", sockpath); =20 - if (qemuDBusWriteConfig(configfile, sockpath) < 0) { + if (qemuDBusWriteConfig(configfile, address) < 0) { virReportSystemError(errno, _("Failed to write '%1$s'"), configfil= e); return -1; } @@ -264,6 +269,17 @@ qemuDBusStart(virQEMUDriver *driver, if (qemuSecurityDomainSetPathLabel(driver, vm, sockpath, false) < 0) goto cleanup; =20 + priv->dbusConnection =3D + g_dbus_connection_new_for_address_sync(address, + G_DBUS_CONNECTION_FLAGS_AUT= HENTICATION_CLIENT| + G_DBUS_CONNECTION_FLAGS_MES= SAGE_BUS_CONNECTION, + NULL, NULL, &gerr); + if (!priv->dbusConnection) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("Failed to connect to dbus-daemon: %1$s"), gerr->m= essage); + goto cleanup; + } + priv->dbusDaemonRunning =3D true; ret =3D 0; cleanup: diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 04577f1297..03cf84695f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -39,6 +39,7 @@ #include "qemu_fd.h" #include "virchrdev.h" #include "virobject.h" +#include "virgdbus.h" #include "virdomainmomentobjlist.h" #include "virenum.h" #include "vireventthread.h" @@ -240,6 +241,7 @@ struct _qemuDomainObjPrivate { /* running backup job */ virDomainBackupDef *backup; =20 + GDBusConnection *dbusConnection; bool dbusDaemonRunning; =20 /* list of Ids to migrate */ --=20 2.47.0