]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Move and rename virStorageSourceFDTuple object
authorPavel Hrdina <phrdina@redhat.com>
Fri, 13 Mar 2026 15:59:01 +0000 (16:59 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 20 Mar 2026 08:49:35 +0000 (09:49 +0100)
Associating FD can be used by other parts of VM so rename it to generic
virDomainFDTuple.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/meson.build
src/conf/storage_source_conf.c
src/conf/storage_source_conf.h
src/conf/virdomainfd.c [new file with mode: 0644]
src/conf/virdomainfd.h [new file with mode: 0644]
src/libvirt_private.syms
src/qemu/qemu_backup.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
tests/testutilsqemu.c

index 5116c23fe396fb320ae75a262c61244ad337d5da..6f95b23ccee62290fb9092f355e894fb6cd02481 100644 (file)
@@ -20,6 +20,7 @@ domain_conf_sources = [
   'numa_conf.c',
   'snapshot_conf.c',
   'virdomaincheckpointobjlist.c',
+  'virdomainfd.c',
   'virdomainjob.c',
   'virdomainmomentobjlist.c',
   'virdomainobjlist.c',
index e5f20fba8031f5021098bbbf64aa2bb81caa6480..010b44ccb0997a078cccc3536969da092aa9df21 100644 (file)
@@ -1417,48 +1417,6 @@ virStorageSourceInitiatorClear(virStorageSourceInitiatorDef *initiator)
     VIR_FREE(initiator->iqn);
 }
 
-G_DEFINE_TYPE(virStorageSourceFDTuple, vir_storage_source_fd_tuple, G_TYPE_OBJECT);
-
-static void
-vir_storage_source_fd_tuple_init(virStorageSourceFDTuple *fdt G_GNUC_UNUSED)
-{
-}
-
-
-static void
-virStorageSourceFDTupleFinalize(GObject *object)
-{
-    virStorageSourceFDTuple *fdt = VIR_STORAGE_SOURCE_FD_TUPLE(object);
-    size_t i;
-
-    if (!fdt)
-        return;
-
-    for (i = 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(object);
-}
-
-
-static void
-vir_storage_source_fd_tuple_class_init(virStorageSourceFDTupleClass *klass)
-{
-    GObjectClass *obj = G_OBJECT_CLASS(klass);
-
-    obj->finalize = virStorageSourceFDTupleFinalize;
-}
-
-
-virStorageSourceFDTuple *
-virStorageSourceFDTupleNew(void)
-{
-    return g_object_new(vir_storage_source_fd_tuple_get_type(), NULL);
-}
-
 
 /**
  * virStorageSourceNetworkProtocolPathSplit:
index d3a9b0e7a203b3779939ca9be711fd35444d32ea..5ddcebb282d9bd6bf0f15ee217acfab8a4e34fe5 100644 (file)
@@ -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);
 
-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;
 
 /* Stores information related to a host resource.  In the case of backing
@@ -442,7 +422,7 @@ struct _virStorageSource {
      * one event for it */
     bool thresholdEventWithIndex;
 
-    virStorageSourceFDTuple *fdtuple;
+    virDomainFDTuple *fdtuple;
 
     /* Setting 'seclabelSkipRemember' to true will cause the security driver 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 (file)
index 0000000..13c3161
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include <config.h>
+
+#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 = VIR_DOMAIN_FD_TUPLE(object);
+    size_t i;
+
+    if (!fdt)
+        return;
+
+    for (i = 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 = G_OBJECT_CLASS(klass);
+
+    obj->finalize = 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 (file)
index 0000000..0c0d475
--- /dev/null
@@ -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);
index f5acf46bc0357f9994c13026bfa8281c9fac9635..cd028c488afee68ebc97375fda9d31b2175502d4 100644 (file)
@@ -1180,7 +1180,6 @@ virStorageSourceChainHasManagedPR;
 virStorageSourceChainHasNVMe;
 virStorageSourceClear;
 virStorageSourceCopy;
-virStorageSourceFDTupleNew;
 virStorageSourceGetActualType;
 virStorageSourceGetSecurityLabelDef;
 virStorageSourceHasBacking;
@@ -1233,6 +1232,10 @@ virDomainCheckpointUpdateRelations;
 virDomainListCheckpoints;
 
 
+# conf/virdomainfd.h
+virDomainFDTupleNew;
+
+
 #conf/virdomainjob.h
 virDomainAgentJobTypeToString;
 virDomainAsyncJobTypeFromString;
index 44514d08fcdfef3cfddcd40558a964a1f54b2b63..d380dd3a63d3de8d48fd5dcb42adcabbc52cfe13 100644 (file)
@@ -876,7 +876,7 @@ qemuBackupBegin(virDomainObj *vm,
     priv->backup = g_steal_pointer(&def);
 
     if (pull && priv->backup->server->fdgroup) {
-        virStorageSourceFDTuple *fdt = NULL;
+        virDomainFDTuple *fdt = NULL;
         VIR_AUTOCLOSE fdcopy = -1;
 
         if (!(fdt = virHashLookup(priv->fds, priv->backup->server->fdgroup))) {
index 6fdca4be099510cad542b35addff4e4659b6f8f5..90d0f0261276a743979a3647dccfa2097a9c7e3d 100644 (file)
@@ -9835,7 +9835,7 @@ qemuDomainPrepareStorageSourceFDs(virStorageSource *src,
 {
     qemuDomainStorageSourcePrivate *srcpriv = NULL;
     virStorageType actualType = virStorageSourceGetActualType(src);
-    virStorageSourceFDTuple *fdt = NULL;
+    virDomainFDTuple *fdt = NULL;
     size_t i;
 
     if (actualType != VIR_STORAGE_TYPE_FILE &&
index 8b148b33b43d4f382f00a573e76817d33b5568d6..5ef3ec649fbb8d9147d041a3eb8fca1867d0ae28 100644 (file)
@@ -20269,7 +20269,7 @@ qemuDomainFDHashCloseConnect(virDomainObj *vm,
                              virConnectPtr conn)
 {
     qemuDomainObjPrivate *priv = QEMU_DOMAIN_PRIVATE(vm);
-    virStorageSourceFDTuple *data;
+    virDomainFDTuple *data;
     GHashTableIter htitr;
 
     if (!priv->fds)
@@ -20293,7 +20293,7 @@ qemuDomainFDAssociate(virDomainPtr domain,
 {
     virDomainObj *vm = NULL;
     qemuDomainObjPrivate *priv;
-    g_autoptr(virStorageSourceFDTuple) new = NULL;
+    g_autoptr(virDomainFDTuple) new = NULL;
     size_t i;
     int ret = -1;
 
@@ -20311,7 +20311,7 @@ qemuDomainFDAssociate(virDomainPtr domain,
 
     priv = vm->privateData;
 
-    new = virStorageSourceFDTupleNew();
+    new = virDomainFDTupleNew();
     new->nfds = nfds;
     new->fds = g_new0(int, new->nfds);
     for (i = 0; i < new->nfds; i++) {
index e00e52d2a8421164364f930b232fe1f5768ce9f8..e9bdbdbbe7eb54bbca5e97a95e18167a23d3e2d7 100644 (file)
@@ -712,7 +712,7 @@ testQemuInfoSetArgs(testQemuInfo *info,
             break;
 
         case ARG_FD_GROUP: {
-            virStorageSourceFDTuple *new = virStorageSourceFDTupleNew();
+            virDomainFDTuple *new = virDomainFDTupleNew();
             const char *fdname = va_arg(argptr, char *);
             VIR_AUTOCLOSE fakefd = open("/dev/zero", O_RDWR);
             bool writable = va_arg(argptr, int);