From nobody Tue Mar 24 00:58:09 2026 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1773938345; cv=none; d=zohomail.com; s=zohoarc; b=angPHihnNd/2MbZKFU15LK0VHWViw2Dn8IZItNe3a+8IlzgbfrfFnyaRWbnltVjSnxDHckbx9AXVEvGhOAm46JUvj9k9Qgw+cWsfjC9VqaGX7Z8ZBR6fJCm4XQYvDDJKNyioYKVRUblCQClslEb9YDv65hy/Ipwxz7qYm4tkSxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773938345; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=x0oPPDVCmH0pnh+mF11vQICye4CjHl9xfrBBmeYq+Bk=; b=JR16zyviFERzf6Qca1YuWElIJIJQsGyPcXEcm+ytrpd8AfdHkgfghQ7Zie7rJDj8WQeRvDuZxxoSZDXV5yqeZ0XEu1MSOt622DazKmlMgQvH6Yv7vsTiigrWEwDABXNFZE5fqhYlbDO/5XTvfcVWL2B62VvhWOtRoLU23enio2U= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1773938345653130.45348794064387; Thu, 19 Mar 2026 09:39:05 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6BE3E41990; Thu, 19 Mar 2026 12:39:04 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id E119D41B35; Thu, 19 Mar 2026 12:37:08 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E73FA3F363; Thu, 19 Mar 2026 12:37:03 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6EFDE3F363 for ; Thu, 19 Mar 2026 12:37:03 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-gX1HbzGdMvOad82EIe2WsQ-1; Thu, 19 Mar 2026 12:37:01 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4891618005BA for ; Thu, 19 Mar 2026 16:37:00 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.44.33.53]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 92EE530001A1 for ; Thu, 19 Mar 2026 16:36:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773938222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x0oPPDVCmH0pnh+mF11vQICye4CjHl9xfrBBmeYq+Bk=; b=VVCNdQb7TpDGB8sibh3S7/aeAWxSeiF4gAqaHzT5+ONkQwKkIOtq4CXuGI6PyNNPsxOAw2 myx1GTIfvvZhnYaFeabbkNciB1ijo8kEMx2fInHFqkN8ePl7a2Dlyu1Pb2Zs4WbsuEO/FW fLZeiw0UnsygzBaPQr4L3uKy2vgS1hs= X-MC-Unique: gX1HbzGdMvOad82EIe2WsQ-1 X-Mimecast-MFC-AGG-ID: gX1HbzGdMvOad82EIe2WsQ_1773938220 To: devel@lists.libvirt.org Subject: [libvirt PATCH 01/11] conf: Move and rename virStorageSourceFDTuple object Date: Thu, 19 Mar 2026 17:36:47 +0100 Message-ID: <497d6009d4032f89dada5f0ca06278f3176c1c06.1773938045.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HSO0LoIQkhdURdYlHKBkURc_9sJxSOf-NdIkie5pLMo_1773938220 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YWY5EMTZ5OW5ZBX3XNT4S6RGXCT7M3FM X-Message-ID-Hash: YWY5EMTZ5OW5ZBX3XNT4S6RGXCT7M3FM X-MailFrom: phrdina@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1773938348000158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Associating FD can be used by other parts of VM so rename it to generic virDomainFDTuple. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/meson.build | 1 + src/conf/storage_source_conf.c | 42 --------------------------- src/conf/storage_source_conf.h | 24 ++-------------- src/conf/virdomainfd.c | 52 ++++++++++++++++++++++++++++++++++ src/conf/virdomainfd.h | 27 ++++++++++++++++++ src/libvirt_private.syms | 5 +++- src/qemu/qemu_backup.c | 2 +- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 6 ++-- tests/testutilsqemu.c | 2 +- 10 files changed, 92 insertions(+), 71 deletions(-) create mode 100644 src/conf/virdomainfd.c create mode 100644 src/conf/virdomainfd.h diff --git a/src/conf/meson.build b/src/conf/meson.build index 5116c23fe3..6f95b23cce 100644 --- a/src/conf/meson.build +++ b/src/conf/meson.build @@ -20,6 +20,7 @@ domain_conf_sources =3D [ 'numa_conf.c', 'snapshot_conf.c', 'virdomaincheckpointobjlist.c', + 'virdomainfd.c', 'virdomainjob.c', 'virdomainmomentobjlist.c', 'virdomainobjlist.c', diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index e5f20fba80..010b44ccb0 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -1417,48 +1417,6 @@ virStorageSourceInitiatorClear(virStorageSourceIniti= atorDef *initiator) VIR_FREE(initiator->iqn); } =20 -G_DEFINE_TYPE(virStorageSourceFDTuple, vir_storage_source_fd_tuple, G_TYPE= _OBJECT); - -static void -vir_storage_source_fd_tuple_init(virStorageSourceFDTuple *fdt G_GNUC_UNUSE= D) -{ -} - - -static void -virStorageSourceFDTupleFinalize(GObject *object) -{ - virStorageSourceFDTuple *fdt =3D VIR_STORAGE_SOURCE_FD_TUPLE(object); - size_t i; - - if (!fdt) - return; - - for (i =3D 0; i < fdt->nfds; i++) - VIR_FORCE_CLOSE(fdt->fds[i]); - - g_free(fdt->fds); - g_free(fdt->testfds); - g_free(fdt->selinuxLabel); - G_OBJECT_CLASS(vir_storage_source_fd_tuple_parent_class)->finalize(obj= ect); -} - - -static void -vir_storage_source_fd_tuple_class_init(virStorageSourceFDTupleClass *klass) -{ - GObjectClass *obj =3D G_OBJECT_CLASS(klass); - - obj->finalize =3D virStorageSourceFDTupleFinalize; -} - - -virStorageSourceFDTuple * -virStorageSourceFDTupleNew(void) -{ - return g_object_new(vir_storage_source_fd_tuple_get_type(), NULL); -} - =20 /** * virStorageSourceNetworkProtocolPathSplit: diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index d3a9b0e7a2..5ddcebb282 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -24,6 +24,7 @@ #include "storage_encryption_conf.h" #include "virbitmap.h" #include "virconftypes.h" +#include "virdomainfd.h" #include "virenum.h" #include "virobject.h" #include "virpci.h" @@ -269,27 +270,6 @@ struct _virStorageSourceSlice { void virStorageSourceSliceFree(virStorageSourceSlice *slice); =20 -struct _virStorageSourceFDTuple { - GObject parent; - int *fds; - size_t nfds; - int *testfds; /* populated by tests to ensure stable FDs */ - - bool writable; - bool tryRestoreLabel; - - /* connection this FD tuple is associated with for auto-closing */ - virConnect *conn; - - /* original selinux label when we relabel the image */ - char *selinuxLabel; -}; -G_DECLARE_FINAL_TYPE(virStorageSourceFDTuple, vir_storage_source_fd_tuple,= VIR, STORAGE_SOURCE_FD_TUPLE, GObject); - -virStorageSourceFDTuple * -virStorageSourceFDTupleNew(void); - - typedef struct _virStorageSource virStorageSource; =20 /* Stores information related to a host resource. In the case of backing @@ -442,7 +422,7 @@ struct _virStorageSource { * one event for it */ bool thresholdEventWithIndex; =20 - virStorageSourceFDTuple *fdtuple; + virDomainFDTuple *fdtuple; =20 /* Setting 'seclabelSkipRemember' to true will cause the security driv= er to * not remember the security label even if it otherwise were to be diff --git a/src/conf/virdomainfd.c b/src/conf/virdomainfd.c new file mode 100644 index 0000000000..13c3161e6a --- /dev/null +++ b/src/conf/virdomainfd.c @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include + +#include "virdomainfd.h" + +#include "virfile.h" + +G_DEFINE_TYPE(virDomainFDTuple, vir_domain_fd_tuple, G_TYPE_OBJECT); + + +static void +vir_domain_fd_tuple_init(virDomainFDTuple *fdt G_GNUC_UNUSED) +{ +} + + +static void +virDomainFDTupleFinalize(GObject *object) +{ + virDomainFDTuple *fdt =3D VIR_DOMAIN_FD_TUPLE(object); + size_t i; + + if (!fdt) + return; + + for (i =3D 0; i < fdt->nfds; i++) + VIR_FORCE_CLOSE(fdt->fds[i]); + + g_free(fdt->fds); + g_free(fdt->testfds); + g_free(fdt->selinuxLabel); + G_OBJECT_CLASS(vir_domain_fd_tuple_parent_class)->finalize(object); +} + + +static void +vir_domain_fd_tuple_class_init(virDomainFDTupleClass *klass) +{ + GObjectClass *obj =3D G_OBJECT_CLASS(klass); + + obj->finalize =3D virDomainFDTupleFinalize; +} + + +virDomainFDTuple * +virDomainFDTupleNew(void) +{ + return g_object_new(vir_domain_fd_tuple_get_type(), NULL); +} diff --git a/src/conf/virdomainfd.h b/src/conf/virdomainfd.h new file mode 100644 index 0000000000..0c0d475ed6 --- /dev/null +++ b/src/conf/virdomainfd.h @@ -0,0 +1,27 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#pragma once + +#include "internal.h" + +struct _virDomainFDTuple { + GObject parent; + int *fds; + size_t nfds; + int *testfds; /* populated by tests to ensure stable FDs */ + + bool writable; + bool tryRestoreLabel; + + /* connection this FD tuple is associated with for auto-closing */ + virConnect *conn; + + /* original selinux label when we relabel the image */ + char *selinuxLabel; +}; +G_DECLARE_FINAL_TYPE(virDomainFDTuple, vir_domain_fd_tuple, VIR, DOMAIN_FD= _TUPLE, GObject); + +virDomainFDTuple * +virDomainFDTupleNew(void); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f5acf46bc0..cd028c488a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1180,7 +1180,6 @@ virStorageSourceChainHasManagedPR; virStorageSourceChainHasNVMe; virStorageSourceClear; virStorageSourceCopy; -virStorageSourceFDTupleNew; virStorageSourceGetActualType; virStorageSourceGetSecurityLabelDef; virStorageSourceHasBacking; @@ -1233,6 +1232,10 @@ virDomainCheckpointUpdateRelations; virDomainListCheckpoints; =20 =20 +# conf/virdomainfd.h +virDomainFDTupleNew; + + #conf/virdomainjob.h virDomainAgentJobTypeToString; virDomainAsyncJobTypeFromString; diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 44514d08fc..d380dd3a63 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -876,7 +876,7 @@ qemuBackupBegin(virDomainObj *vm, priv->backup =3D g_steal_pointer(&def); =20 if (pull && priv->backup->server->fdgroup) { - virStorageSourceFDTuple *fdt =3D NULL; + virDomainFDTuple *fdt =3D NULL; VIR_AUTOCLOSE fdcopy =3D -1; =20 if (!(fdt =3D virHashLookup(priv->fds, priv->backup->server->fdgro= up))) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6fdca4be09..90d0f02612 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9835,7 +9835,7 @@ qemuDomainPrepareStorageSourceFDs(virStorageSource *s= rc, { qemuDomainStorageSourcePrivate *srcpriv =3D NULL; virStorageType actualType =3D virStorageSourceGetActualType(src); - virStorageSourceFDTuple *fdt =3D NULL; + virDomainFDTuple *fdt =3D NULL; size_t i; =20 if (actualType !=3D VIR_STORAGE_TYPE_FILE && diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8b148b33b4..5ef3ec649f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20269,7 +20269,7 @@ qemuDomainFDHashCloseConnect(virDomainObj *vm, virConnectPtr conn) { qemuDomainObjPrivate *priv =3D QEMU_DOMAIN_PRIVATE(vm); - virStorageSourceFDTuple *data; + virDomainFDTuple *data; GHashTableIter htitr; =20 if (!priv->fds) @@ -20293,7 +20293,7 @@ qemuDomainFDAssociate(virDomainPtr domain, { virDomainObj *vm =3D NULL; qemuDomainObjPrivate *priv; - g_autoptr(virStorageSourceFDTuple) new =3D NULL; + g_autoptr(virDomainFDTuple) new =3D NULL; size_t i; int ret =3D -1; =20 @@ -20311,7 +20311,7 @@ qemuDomainFDAssociate(virDomainPtr domain, =20 priv =3D vm->privateData; =20 - new =3D virStorageSourceFDTupleNew(); + new =3D virDomainFDTupleNew(); new->nfds =3D nfds; new->fds =3D g_new0(int, new->nfds); for (i =3D 0; i < new->nfds; i++) { diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index e00e52d2a8..e9bdbdbbe7 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -712,7 +712,7 @@ testQemuInfoSetArgs(testQemuInfo *info, break; =20 case ARG_FD_GROUP: { - virStorageSourceFDTuple *new =3D virStorageSourceFDTupleNew(); + virDomainFDTuple *new =3D virDomainFDTupleNew(); const char *fdname =3D va_arg(argptr, char *); VIR_AUTOCLOSE fakefd =3D open("/dev/zero", O_RDWR); bool writable =3D va_arg(argptr, int); --=20 2.53.0