qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
	"Steve Sistare" <steven.sistare@oracle.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Zhenzhong Duan" <zhenzhong.duan@intel.com>
Subject: [PULL 16/27] vfio/iommufd: add vfio_device_free_name
Date: Fri,  4 Jul 2025 10:45:17 +0200	[thread overview]
Message-ID: <20250704084528.1412959-17-clg@redhat.com> (raw)
In-Reply-To: <20250704084528.1412959-1-clg@redhat.com>

From: Steve Sistare <steven.sistare@oracle.com>

Define vfio_device_free_name to free the name created by
vfio_device_get_name.  A subsequent patch will do more there.
No functional change.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/1751493538-202042-11-git-send-email-steven.sistare@oracle.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 include/hw/vfio/vfio-device.h | 1 +
 hw/vfio/ap.c                  | 4 ++--
 hw/vfio/ccw.c                 | 4 ++--
 hw/vfio/device.c              | 5 +++++
 hw/vfio/pci.c                 | 2 +-
 hw/vfio/platform.c            | 2 +-
 6 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h
index f503837ccc6936b730a7752ca092da5acba1806f..1901a35aa90214c36369f8ac0b0cfef36acbbaa8 100644
--- a/include/hw/vfio/vfio-device.h
+++ b/include/hw/vfio/vfio-device.h
@@ -279,6 +279,7 @@ int vfio_device_get_irq_info(VFIODevice *vbasedev, int index,
 
 /* Returns 0 on success, or a negative errno. */
 bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp);
+void vfio_device_free_name(VFIODevice *vbasedev);
 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **errp);
 void vfio_device_init(VFIODevice *vbasedev, int type, VFIODeviceOps *ops,
                       DeviceState *dev, bool ram_discard);
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index 1df4438149d2a06ef176e03e358336381bfa4caa..7719f245797ef45b6392270741c7dd0a36527fd2 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -265,7 +265,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
 
 error:
     error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name);
-    g_free(vbasedev->name);
+    vfio_device_free_name(vbasedev);
 }
 
 static void vfio_ap_unrealize(DeviceState *dev)
@@ -275,7 +275,7 @@ static void vfio_ap_unrealize(DeviceState *dev)
     vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX);
     vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_CFG_CHG_IRQ_INDEX);
     vfio_device_detach(&vapdev->vdev);
-    g_free(vapdev->vdev.name);
+    vfio_device_free_name(&vapdev->vdev);
 }
 
 static const Property vfio_ap_properties[] = {
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index cea9d6e00562c241832184cafe862005fcdc992b..9560b8d851b6b25e647476c51efe845ebff10410 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -619,7 +619,7 @@ out_io_notifier_err:
 out_region_err:
     vfio_device_detach(vbasedev);
 out_attach_dev_err:
-    g_free(vbasedev->name);
+    vfio_device_free_name(vbasedev);
 out_unrealize:
     if (cdc->unrealize) {
         cdc->unrealize(cdev);
@@ -637,7 +637,7 @@ static void vfio_ccw_unrealize(DeviceState *dev)
     vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
     vfio_ccw_put_region(vcdev);
     vfio_device_detach(&vcdev->vdev);
-    g_free(vcdev->vdev.name);
+    vfio_device_free_name(&vcdev->vdev);
 
     if (cdc->unrealize) {
         cdc->unrealize(cdev);
diff --git a/hw/vfio/device.c b/hw/vfio/device.c
index 3cd365fb8b10a180c454d07efb4b7d4e6f403046..97eddd04f5756a0e9e4763c4fef84c9829272053 100644
--- a/hw/vfio/device.c
+++ b/hw/vfio/device.c
@@ -333,6 +333,11 @@ bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp)
     return true;
 }
 
+void vfio_device_free_name(VFIODevice *vbasedev)
+{
+    g_clear_pointer(&vbasedev->name, g_free);
+}
+
 void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **errp)
 {
     ERRP_GUARD();
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index dd0b2a0b947d4f9c788c6cd8b41e8ac916098724..1093b28df7c3f5f37e622e6d76a99ad8d2b7e01e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2996,7 +2996,7 @@ void vfio_pci_put_device(VFIOPCIDevice *vdev)
 
     vfio_device_detach(&vdev->vbasedev);
 
-    g_free(vdev->vbasedev.name);
+    vfio_device_free_name(&vdev->vbasedev);
     g_free(vdev->msix);
 }
 
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 9a21f2e50a2945a6658b9be4fdec1bc1c98d0f20..5c1795a26fe79b98a9886e15f365fa7a921409a4 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -530,7 +530,7 @@ static bool vfio_base_device_init(VFIODevice *vbasedev, Error **errp)
 {
     /* @fd takes precedence over @sysfsdev which takes precedence over @host */
     if (vbasedev->fd < 0 && vbasedev->sysfsdev) {
-        g_free(vbasedev->name);
+        vfio_device_free_name(vbasedev);
         vbasedev->name = g_path_get_basename(vbasedev->sysfsdev);
     } else if (vbasedev->fd < 0) {
         if (!vbasedev->name || strchr(vbasedev->name, '/')) {
-- 
2.50.0



  parent reply	other threads:[~2025-07-04  8:49 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-04  8:45 [PULL 00/27] vfio queue Cédric Le Goater
2025-07-04  8:45 ` [PULL 01/27] vfio/container: Fix potential SIGSEGV when recover from unmap-all-vaddr failure Cédric Le Goater
2025-07-04  8:45 ` [PULL 02/27] vfio/container: Fix vfio_container_post_load() Cédric Le Goater
2025-07-04  8:45 ` [PULL 03/27] vfio-user: do not register vfio-user container with cpr Cédric Le Goater
2025-07-04  8:45 ` [PULL 04/27] i386/tdx: Build TDX only for 64-bit target Cédric Le Goater
2025-07-04  8:45 ` [PULL 05/27] b4: Drop linktrailermask Cédric Le Goater
2025-07-04  8:45 ` [PULL 06/27] Makefile: prune quilt source files for cscope Cédric Le Goater
2025-07-04  8:45 ` [PULL 07/27] vfio-pci: preserve MSI Cédric Le Goater
2025-07-04  8:45 ` [PULL 08/27] vfio-pci: preserve INTx Cédric Le Goater
2025-07-04  8:45 ` [PULL 09/27] migration: close kvm after cpr Cédric Le Goater
2025-07-04  8:45 ` [PULL 10/27] migration: cpr_get_fd_param helper Cédric Le Goater
2025-07-04  8:45 ` [PULL 11/27] backends/iommufd: iommufd_backend_map_file_dma Cédric Le Goater
2025-07-04  8:45 ` [PULL 12/27] backends/iommufd: change process ioctl Cédric Le Goater
2025-07-04  8:45 ` [PULL 13/27] physmem: qemu_ram_get_fd_offset Cédric Le Goater
2025-07-04  8:45 ` [PULL 14/27] vfio/iommufd: use IOMMU_IOAS_MAP_FILE Cédric Le Goater
2025-07-04  8:45 ` [PULL 15/27] vfio/iommufd: invariant device name Cédric Le Goater
2025-07-04  8:45 ` Cédric Le Goater [this message]
2025-07-04  8:45 ` [PULL 17/27] vfio/iommufd: device name blocker Cédric Le Goater
2025-07-04  8:45 ` [PULL 18/27] vfio/iommufd: register container for cpr Cédric Le Goater
2025-07-04  8:45 ` [PULL 19/27] migration: vfio cpr state hook Cédric Le Goater
2025-07-04  8:45 ` [PULL 20/27] vfio/iommufd: cpr state Cédric Le Goater
2025-07-04  8:45 ` [PULL 21/27] vfio/iommufd: preserve descriptors Cédric Le Goater
2025-07-04  8:45 ` [PULL 22/27] vfio/iommufd: reconstruct device Cédric Le Goater
2025-07-04  8:45 ` [PULL 23/27] vfio/iommufd: reconstruct hwpt Cédric Le Goater
2025-07-04  8:45 ` [PULL 24/27] vfio/iommufd: change process Cédric Le Goater
2025-07-04  8:45 ` [PULL 25/27] iommufd: preserve DMA mappings Cédric Le Goater
2025-07-04  8:45 ` [PULL 26/27] vfio/container: delete old cpr register Cédric Le Goater
2025-07-04  8:45 ` [PULL 27/27] vfio: doc changes for cpr Cédric Le Goater
2025-07-04 17:49 ` [PULL 00/27] vfio queue Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250704084528.1412959-17-clg@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=steven.sistare@oracle.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).