[libvirt] [PATCH 5/9] Use g_autoptr instead of VIR_AUTOPTR

Ján Tomko jtomko at redhat.com
Tue Oct 15 15:03:10 UTC 2019


Since commit 44e7f029159ed701b4a1739ac711507ee53790ed
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOPTR aliases to g_autoptr. Replace all of its use by the GLib
macro version.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/bhyve/bhyve_conf.c                     |   2 +-
 src/conf/checkpoint_conf.c                 |   2 +-
 src/conf/domain_conf.c                     |  40 ++++----
 src/conf/interface_conf.c                  |   2 +-
 src/conf/network_conf.c                    |   6 +-
 src/conf/node_device_conf.c                |   2 +-
 src/conf/nwfilter_conf.c                   |   2 +-
 src/conf/secret_conf.c                     |   4 +-
 src/conf/snapshot_conf.c                   |   2 +-
 src/conf/storage_conf.c                    |  16 ++--
 src/conf/virnetworkobj.c                   |   2 +-
 src/conf/virnetworkportdef.c               |   2 +-
 src/conf/virstorageobj.c                   |   4 +-
 src/esx/esx_storage_backend_vmfs.c         |   4 +-
 src/libvirt-admin.c                        |   2 +-
 src/libvirt.c                              |   2 +-
 src/libxl/libxl_conf.c                     |   2 +-
 src/libxl/libxl_driver.c                   |   4 +-
 src/libxl/xen_xl.c                         |   2 +-
 src/libxl/xen_xm.c                         |   2 +-
 src/locking/lock_daemon.c                  |   2 +-
 src/locking/lock_daemon_config.c           |   2 +-
 src/locking/lock_driver_lockd.c            |   2 +-
 src/locking/lock_driver_sanlock.c          |   2 +-
 src/logging/log_daemon.c                   |   2 +-
 src/logging/log_daemon_config.c            |   2 +-
 src/lxc/lxc_conf.c                         |   2 +-
 src/lxc/lxc_native.c                       |   2 +-
 src/network/bridge_driver.c                |   2 +-
 src/phyp/phyp_driver.c                     |   4 +-
 src/qemu/qemu_agent.c                      |  16 ++--
 src/qemu/qemu_block.c                      | 102 ++++++++++-----------
 src/qemu/qemu_blockjob.c                   |   4 +-
 src/qemu/qemu_capabilities.c               |   6 +-
 src/qemu/qemu_checkpoint.c                 |   4 +-
 src/qemu/qemu_command.c                    |  46 +++++-----
 src/qemu/qemu_conf.c                       |   2 +-
 src/qemu/qemu_dbus.c                       |   2 +-
 src/qemu/qemu_domain.c                     |   2 +-
 src/qemu/qemu_driver.c                     |  12 +--
 src/qemu/qemu_firmware.c                   |  32 +++----
 src/qemu/qemu_hotplug.c                    |  12 +--
 src/qemu/qemu_interface.c                  |   2 +-
 src/qemu/qemu_interop_config.c             |   2 +-
 src/qemu/qemu_migration.c                  |   2 +-
 src/qemu/qemu_monitor_json.c               |  64 ++++++-------
 src/qemu/qemu_process.c                    |   4 +-
 src/qemu/qemu_qapi.c                       |   4 +-
 src/qemu/qemu_slirp.c                      |  10 +-
 src/qemu/qemu_vhost_user.c                 |  12 +--
 src/qemu/qemu_vhost_user_gpu.c             |   2 +-
 src/remote/remote_daemon.c                 |   2 +-
 src/remote/remote_daemon_config.c          |   4 +-
 src/security/security_selinux.c            |   2 +-
 src/security/virt-aa-helper.c              |   2 +-
 src/storage/storage_backend_disk.c         |  10 +-
 src/storage/storage_backend_fs.c           |  10 +-
 src/storage/storage_backend_gluster.c      |   4 +-
 src/storage/storage_backend_iscsi.c        |   2 +-
 src/storage/storage_backend_iscsi_direct.c |   4 +-
 src/storage/storage_backend_logical.c      |  22 ++---
 src/storage/storage_backend_mpath.c        |   2 +-
 src/storage/storage_backend_rbd.c          |   2 +-
 src/storage/storage_backend_sheepdog.c     |  14 +--
 src/storage/storage_backend_vstorage.c     |   4 +-
 src/storage/storage_backend_zfs.c          |  14 +--
 src/storage/storage_driver.c               |  10 +-
 src/storage/storage_util.c                 |  22 ++---
 src/test/test_driver.c                     |  12 +--
 src/util/virauth.c                         |   2 +-
 src/util/virbitmap.c                       |   2 +-
 src/util/vircommand.c                      |   6 +-
 src/util/virfile.c                         |   2 +-
 src/util/virfirewall.c                     |   6 +-
 src/util/virhook.c                         |   2 +-
 src/util/virhostdev.c                      |  30 +++---
 src/util/viriscsi.c                        |  16 ++--
 src/util/virjson.c                         |   4 +-
 src/util/virkmod.c                         |   4 +-
 src/util/virlease.c                        |   4 +-
 src/util/virmdev.c                         |   4 +-
 src/util/virnetdev.c                       |   2 +-
 src/util/virnetdevbridge.c                 |   2 +-
 src/util/virnetdevip.c                     |  18 ++--
 src/util/virnetdevmacvlan.c                |   6 +-
 src/util/virnetdevopenvswitch.c            |  16 ++--
 src/util/virnetdevveth.c                   |   4 +-
 src/util/virnetlink.c                      |  12 +--
 src/util/virnodesuspend.c                  |   2 +-
 src/util/virnuma.c                         |   8 +-
 src/util/virpci.c                          |  18 ++--
 src/util/virqemu.c                         |   2 +-
 src/util/virscsi.c                         |   6 +-
 src/util/virscsivhost.c                    |   2 +-
 src/util/virstoragefile.c                  |  18 ++--
 src/util/virtpm.c                          |   4 +-
 src/util/virusb.c                          |   2 +-
 src/util/virutil.c                         |   2 +-
 src/vbox/vbox_storage.c                    |   2 +-
 src/vmx/vmx.c                              |   2 +-
 tests/qemublocktest.c                      |  18 ++--
 tests/qemufirmwaretest.c                   |   4 +-
 tests/qemuhotplugtest.c                    |   2 +-
 tests/qemumonitorjsontest.c                |  80 ++++++++--------
 tests/qemumonitortestutils.c               |   6 +-
 tests/qemuvhostusertest.c                  |   4 +-
 tests/storagebackendsheepdogtest.c         |   6 +-
 tests/storagepoolxml2argvtest.c            |   2 +-
 tests/storagepoolxml2xmltest.c             |   2 +-
 tests/storagevolxml2argvtest.c             |   8 +-
 tests/storagevolxml2xmltest.c              |   4 +-
 tests/virbitmaptest.c                      |   6 +-
 tests/virconftest.c                        |  12 +--
 tests/virjsontest.c                        |  32 +++----
 tests/virnetworkportxml2xmltest.c          |   2 +-
 tests/virstoragetest.c                     |   4 +-
 tests/virsystemdtest.c                     |   2 +-
 tests/xlconfigtest.c                       |   4 +-
 tests/xmconfigtest.c                       |   4 +-
 tools/virsh-completer-domain.c             |  16 ++--
 tools/virsh-completer-host.c               |   8 +-
 tools/virsh-domain.c                       |   6 +-
 tools/virt-login-shell-helper.c            |   2 +-
 123 files changed, 527 insertions(+), 527 deletions(-)

diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c
index 946be4a811..617b25eb8f 100644
--- a/src/bhyve/bhyve_conf.c
+++ b/src/bhyve/bhyve_conf.c
@@ -70,7 +70,7 @@ int
 virBhyveLoadDriverConfig(virBhyveDriverConfigPtr cfg,
                          const char *filename)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (access(filename, R_OK) == -1) {
         VIR_INFO("Could not read bhyve config file %s", filename);
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index 9b407dca78..376a627ee4 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -209,7 +209,7 @@ virDomainCheckpointDefParseNode(xmlDocPtr xml,
                                 void *parseOpaque,
                                 unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     g_autofree char *schema = NULL;
 
     if (!virXMLNodeNameEqual(root, "domaincheckpoint")) {
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 139dccefff..a0690e23f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2000,7 +2000,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
 {
     int maxvcpus = virDomainDefGetVcpusMax(def);
     size_t i;
-    VIR_AUTOPTR(virBitmap) allcpumap = NULL;
+    g_autoptr(virBitmap) allcpumap = NULL;
 
     if (hostcpus < 0)
         return -1;
@@ -3188,7 +3188,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
     size_t i;
     ssize_t nxt = -1;
     virDomainIOThreadIDDefPtr iothrid = NULL;
-    VIR_AUTOPTR(virBitmap) thrmap = NULL;
+    g_autoptr(virBitmap) thrmap = NULL;
 
     /* Same value (either 0 or some number), then we have none to fill in or
      * the iothreadid array was filled from the XML
@@ -7974,7 +7974,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
     int auth_secret_usage = -1;
     xmlNodePtr cur;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &def->u.iscsi;
-    VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
+    g_autoptr(virStorageAuthDef) authdef = NULL;
 
     /* For the purposes of command line creation, this needs to look
      * like a disk storage source */
@@ -9954,7 +9954,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     bool source = false;
     virStorageEncryptionPtr encryption = NULL;
-    VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
+    g_autoptr(virStorageAuthDef) authdef = NULL;
     g_autofree char *tmp = NULL;
     g_autofree char *snapshot = NULL;
     g_autofree char *rawio = NULL;
@@ -16392,9 +16392,9 @@ virDomainDeviceDefParse(const char *xmlStr,
                         void *parseOpaque,
                         unsigned int flags)
 {
-    VIR_AUTOPTR(xmlDoc) xml = NULL;
+    g_autoptr(xmlDoc) xml = NULL;
     xmlNodePtr node;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     g_autofree virDomainDeviceDefPtr dev = NULL;
     char *netprefix;
 
@@ -16570,8 +16570,8 @@ virDomainDiskDefParse(const char *xmlStr,
                       virDomainXMLOptionPtr xmlopt,
                       unsigned int flags)
 {
-    VIR_AUTOPTR(xmlDoc) xml = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) xml = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     virSecurityLabelDefPtr *seclabels = NULL;
     size_t nseclabels = 0;
 
@@ -18321,7 +18321,7 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
     virDomainIOThreadIDDefPtr iothrid;
     unsigned int iothreadid;
     g_autofree char *tmp = NULL;
-    VIR_AUTOPTR(virBitmap) cpumask = NULL;
+    g_autoptr(virBitmap) cpumask = NULL;
 
     if (!(tmp = virXMLPropString(node, "iothread"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -18386,7 +18386,7 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 {
     virBitmapPtr ret = NULL;
     g_autofree char *tmp = NULL;
-    VIR_AUTOPTR(virBitmap) def = NULL;
+    g_autoptr(virBitmap) def = NULL;
 
     if (!(tmp = virXMLPropString(node, "cpuset"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -18790,7 +18790,7 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
     virDomainThreadSchedParamPtr sched = NULL;
     virProcessSchedPolicy policy = 0;
     int priority = 0;
-    VIR_AUTOPTR(virBitmap) map = NULL;
+    g_autoptr(virBitmap) map = NULL;
 
     if (!(map = virDomainSchedulerParse(node, name, &policy, &priority)))
         return -1;
@@ -19524,7 +19524,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
     ssize_t i = 0;
     int n;
     int ret = -1;
-    VIR_AUTOPTR(virBitmap) vcpus = NULL;
+    g_autoptr(virBitmap) vcpus = NULL;
     g_autofree xmlNodePtr *nodes = NULL;
     VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
 
@@ -19722,7 +19722,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt);
     virDomainResctrlDefPtr resctrl = NULL;
-    VIR_AUTOPTR(virBitmap) vcpus = NULL;
+    g_autoptr(virBitmap) vcpus = NULL;
     g_autofree xmlNodePtr *nodes = NULL;
     VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
     ssize_t i = 0;
@@ -21662,8 +21662,8 @@ virDomainDefParseNode(xmlDocPtr xml,
                       void *parseOpaque,
                       unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
-    VIR_AUTOPTR(virDomainDef) def = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
+    g_autoptr(virDomainDef) def = NULL;
 
     if (!(ctxt = virXMLXPathContextNew(xml)))
         return NULL;
@@ -21692,7 +21692,7 @@ virDomainObjParseNode(xmlDocPtr xml,
                       virDomainXMLOptionPtr xmlopt,
                       unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "domstatus")) {
         virReportError(VIR_ERR_XML_ERROR,
@@ -30634,7 +30634,7 @@ virNetworkPortDefPtr
 virDomainNetDefToNetworkPort(virDomainDefPtr dom,
                              virDomainNetDefPtr iface)
 {
-    VIR_AUTOPTR(virNetworkPortDef) port = NULL;
+    g_autoptr(virNetworkPortDef) port = NULL;
 
     if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -30793,7 +30793,7 @@ virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
                                    virDomainNetDefPtr iface)
 {
     virDomainActualNetDefPtr actual;
-    VIR_AUTOPTR(virNetworkPortDef) port = NULL;
+    g_autoptr(virNetworkPortDef) port = NULL;
 
     if (!iface->data.network.actual) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -30937,7 +30937,7 @@ virDomainNetCreatePort(virConnectPtr conn,
 {
     virErrorPtr save_err;
     VIR_AUTOUNREF(virNetworkPtr) net = NULL;
-    VIR_AUTOPTR(virNetworkPortDef) portdef = NULL;
+    g_autoptr(virNetworkPortDef) portdef = NULL;
     VIR_AUTOUNREF(virNetworkPortPtr) port = NULL;
     g_autofree char *portxml = NULL;
 
@@ -31342,7 +31342,7 @@ int
 virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
 {
     virStorageVolInfo info;
-    VIR_AUTOPTR(virStoragePoolDef) pooldef = NULL;
+    g_autoptr(virStoragePoolDef) pooldef = NULL;
     g_autofree char *poolxml = NULL;
     VIR_AUTOUNREF(virConnectPtr) conn = NULL;
     VIR_AUTOUNREF(virStoragePoolPtr) pool = NULL;
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 2b65a235ea..69ac049eaa 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -819,7 +819,7 @@ virInterfaceDefPtr
 virInterfaceDefParseNode(xmlDocPtr xml,
                          xmlNodePtr root)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "interface")) {
         virReportError(VIR_ERR_XML_ERROR,
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 75ec5ccc27..7f8e43b25c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2114,7 +2114,7 @@ virNetworkDefParseNode(xmlDocPtr xml,
                        xmlNodePtr root,
                        virNetworkXMLOptionPtr xmlopt)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "network")) {
         virReportError(VIR_ERR_XML_ERROR,
@@ -3635,8 +3635,8 @@ virNetworkDefUpdateSection(virNetworkDefPtr def,
                            const char *xml,
                            unsigned int flags)  /* virNetworkUpdateFlags */
 {
-    VIR_AUTOPTR(xmlDoc) doc = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) doc = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!(doc = virXMLParseStringCtxt(xml, _("network_update_xml"), &ctxt)))
         return -1;
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 3aba04c54c..d33f6736ab 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2052,7 +2052,7 @@ virNodeDeviceDefParseNode(xmlDocPtr xml,
                           int create,
                           const char *virt_type)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "device")) {
         virReportError(VIR_ERR_XML_ERROR,
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index aba12cd698..0f025637ee 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2746,7 +2746,7 @@ virNWFilterDefPtr
 virNWFilterDefParseNode(xmlDocPtr xml,
                         xmlNodePtr root)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (STRNEQ((const char *)root->name, "filter")) {
         virReportError(VIR_ERR_XML_ERROR,
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index cb2aeea172..6ee9315933 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -131,8 +131,8 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
 static virSecretDefPtr
 secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
-    VIR_AUTOPTR(virSecretDef) def = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
+    g_autoptr(virSecretDef) def = NULL;
     g_autofree char *prop = NULL;
     g_autofree char *uuidstr = NULL;
 
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 184dec5e77..9628a8df62 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -429,7 +429,7 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml,
                               bool *current,
                               unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "domainsnapshot")) {
         virReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot"));
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index b0bb9d2b8e..4c7e7b3f4d 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -534,7 +534,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
     size_t i;
     virStoragePoolOptionsPtr options;
     int n;
-    VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
+    g_autoptr(virStorageAuthDef) authdef = NULL;
     g_autofree char *port = NULL;
     g_autofree char *ver = NULL;
     g_autofree xmlNodePtr *nodeset = NULL;
@@ -695,10 +695,10 @@ virStoragePoolSourcePtr
 virStoragePoolDefParseSourceString(const char *srcSpec,
                                    int pool_type)
 {
-    VIR_AUTOPTR(xmlDoc) doc = NULL;
+    g_autoptr(xmlDoc) doc = NULL;
     xmlNodePtr node = NULL;
-    VIR_AUTOPTR(xmlXPathContext) xpath_ctxt = NULL;
-    VIR_AUTOPTR(virStoragePoolSource) def = NULL;
+    g_autoptr(xmlXPathContext) xpath_ctxt = NULL;
+    g_autoptr(virStoragePoolSource) def = NULL;
 
     if (!(doc = virXMLParseStringCtxt(srcSpec,
                                       _("(storage_source_specification)"),
@@ -849,7 +849,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
     virStoragePoolOptionsPtr options;
     virStoragePoolDefPtr ret = NULL;
     xmlNodePtr source_node;
-    VIR_AUTOPTR(virStoragePoolDef) def = NULL;
+    g_autoptr(virStoragePoolDef) def = NULL;
     g_autofree char *type = NULL;
     g_autofree char *uuid = NULL;
     g_autofree char *target_path = NULL;
@@ -1007,7 +1007,7 @@ virStoragePoolDefPtr
 virStoragePoolDefParseNode(xmlDocPtr xml,
                            xmlNodePtr root)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "pool")) {
         virReportError(VIR_ERR_XML_ERROR,
@@ -1278,7 +1278,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
     xmlNodePtr node;
     size_t i;
     int n;
-    VIR_AUTOPTR(virStorageVolDef) def = NULL;
+    g_autoptr(virStorageVolDef) def = NULL;
     g_autofree char *type = NULL;
     g_autofree char *allocation = NULL;
     g_autofree char *capacity = NULL;
@@ -1444,7 +1444,7 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool,
                           xmlNodePtr root,
                           unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
 
     if (!virXMLNodeNameEqual(root, "volume")) {
         virReportError(VIR_ERR_XML_ERROR,
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 94e598ddea..560839ea7d 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1887,7 +1887,7 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net,
     int ret = -1;
     int rc;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
-    VIR_AUTOPTR(virNetworkPortDef) portdef = NULL;
+    g_autoptr(virNetworkPortDef) portdef = NULL;
 
     if (!(dir = virNetworkObjGetPortStatusDir(net, stateDir)))
         goto cleanup;
diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c
index 43140198f8..32834e41d4 100644
--- a/src/conf/virnetworkportdef.c
+++ b/src/conf/virnetworkportdef.c
@@ -75,7 +75,7 @@ virNetworkPortDefFree(virNetworkPortDefPtr def)
 static virNetworkPortDefPtr
 virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
 {
-    VIR_AUTOPTR(virNetworkPortDef) def = NULL;
+    g_autoptr(virNetworkPortDef) def = NULL;
     g_autofree char *uuid = NULL;
     xmlNodePtr virtPortNode;
     xmlNodePtr vlanNode;
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 664dc12776..b9717b2fa2 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1624,7 +1624,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
                       const char *autostartLink)
 {
     virStoragePoolObjPtr obj;
-    VIR_AUTOPTR(virStoragePoolDef) def = NULL;
+    g_autoptr(virStoragePoolDef) def = NULL;
 
     if (!(def = virStoragePoolDefParseFile(path)))
         return NULL;
@@ -1671,7 +1671,7 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr pools,
     xmlDocPtr xml = NULL;
     xmlXPathContextPtr ctxt = NULL;
     xmlNodePtr node = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) def = NULL;
+    g_autoptr(virStoragePoolDef) def = NULL;
 
     if (!(stateFile = virFileBuildPath(stateDir, name, ".xml")))
         return NULL;
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index c56f887c25..a69e097a52 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -851,7 +851,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
     char *taskInfoErrorMessage = NULL;
     char *uuid_string = NULL;
     char *key = NULL;
-    VIR_AUTOPTR(virStorageVolDef) def = NULL;
+    g_autoptr(virStorageVolDef) def = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -1067,7 +1067,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     char *taskInfoErrorMessage = NULL;
     char *uuid_string = NULL;
     char *key = NULL;
-    VIR_AUTOPTR(virStorageVolDef) def = NULL;
+    g_autoptr(virStorageVolDef) def = NULL;
 
     virCheckFlags(0, NULL);
 
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index adb783395a..93c73615e3 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -222,7 +222,7 @@ virAdmConnectOpen(const char *name, unsigned int flags)
     char *sock_path = NULL;
     char *alias = NULL;
     virAdmConnectPtr conn = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     char *uristr = NULL;
 
     if (virAdmInitialize() < 0)
diff --git a/src/libvirt.c b/src/libvirt.c
index a5113b9206..812cb9efde 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -856,7 +856,7 @@ virConnectOpenInternal(const char *name,
     size_t i;
     int res;
     virConnectPtr ret;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     char *uristr = NULL;
 
     ret = virGetConnect();
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 74246e7b3a..bbf0f8d8c1 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1868,7 +1868,7 @@ libxlDriverConfigGet(libxlDriverPrivatePtr driver)
 int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
                               const char *filename)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     /* defaults for keepalive messages */
     cfg->keepAliveInterval = 5;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 59398a0a4d..631cfc9a49 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2681,7 +2681,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
     libxlDriverPrivatePtr driver = conn->privateData;
     libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
     virDomainDefPtr def = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     char *xml = NULL;
 
     virCheckFlags(0, NULL);
@@ -2731,7 +2731,7 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
     libxlDriverPrivatePtr driver = conn->privateData;
     libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
     virDomainDefPtr def = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     int len = MAX_CONFIG_SIZE;
     char *ret = NULL;
 
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index 65c7a6c2d8..8ae0dbbbd5 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -2205,7 +2205,7 @@ xenFormatXLDomainChannels(virConfPtr conf, virDomainDefPtr def)
 virConfPtr
 xenFormatXL(virDomainDefPtr def, virConnectPtr conn)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (!(conf = virConfNew()))
         return NULL;
diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c
index 086e438cbc..65882b7c0b 100644
--- a/src/libxl/xen_xm.c
+++ b/src/libxl/xen_xm.c
@@ -599,7 +599,7 @@ virConfPtr
 xenFormatXM(virConnectPtr conn,
             virDomainDefPtr def)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (!(conf = virConfNew()))
         return NULL;
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index baffaa6de9..0894ee8e93 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -1283,7 +1283,7 @@ int main(int argc, char **argv) {
      * (but still need to add @lockProgram into @srv). rv == 0 means that no
      * saved state is present, therefore initialize from scratch here. */
     if (rv == 0) {
-        VIR_AUTOPTR(virSystemdActivation) act = NULL;
+        g_autoptr(virSystemdActivation) act = NULL;
         virSystemdActivationMap actmap[] = {
             { .name = "virtlockd.socket", .family = AF_UNIX, .path = sock_file },
             { .name = "virtlockd-admin.socket", .family = AF_UNIX, .path = admin_sock_file },
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index f77d6c9017..a506423e5e 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -114,7 +114,7 @@ virLockDaemonConfigLoadFile(virLockDaemonConfigPtr data,
                             const char *filename,
                             bool allow_missing)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (allow_missing &&
         access(filename, R_OK) == -1 &&
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index b29a1da48f..47b49add66 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -81,7 +81,7 @@ static virLockManagerLockDaemonDriverPtr driver;
 
 static int virLockManagerLockDaemonLoadConfig(const char *configFile)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (access(configFile, R_OK) == -1) {
         if (errno != ENOENT) {
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 5a5d130f3a..9cedf39578 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -119,7 +119,7 @@ static int
 virLockManagerSanlockLoadConfig(virLockManagerSanlockDriverPtr driver,
                                 const char *configFile)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     int ret = -1;
     char *user = NULL;
     char *group = NULL;
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index c667e31185..851695b109 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -1056,7 +1056,7 @@ int main(int argc, char **argv) {
      * scratch if rv == 0
      */
     if (rv == 0) {
-        VIR_AUTOPTR(virSystemdActivation) act = NULL;
+        g_autoptr(virSystemdActivation) act = NULL;
         virSystemdActivationMap actmap[] = {
             { .name = "virtlogd.socket", .family = AF_UNIX, .path = sock_file },
             { .name = "virtlogd-admin.socket", .family = AF_UNIX, .path = admin_sock_file },
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index 9895babc2f..c339da1808 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -120,7 +120,7 @@ virLogDaemonConfigLoadFile(virLogDaemonConfigPtr data,
                            const char *filename,
                            bool allow_missing)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (allow_missing &&
         access(filename, R_OK) == -1 &&
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 9d1653f437..4d8314045e 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -252,7 +252,7 @@ int
 virLXCLoadDriverConfig(virLXCDriverConfigPtr cfg,
                        const char *filename)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     /* Avoid error from non-existent or unreadable file. */
     if (access(filename, R_OK) == -1)
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 7a3d1cc00e..8ae3c7b006 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -1079,7 +1079,7 @@ lxcParseConfigString(const char *config,
                      virDomainXMLOptionPtr xmlopt)
 {
     virDomainDefPtr vmdef = NULL;
-    VIR_AUTOPTR(virConf) properties = NULL;
+    g_autoptr(virConf) properties = NULL;
     g_autofree char *value = NULL;
 
     if (!(properties = virConfReadString(config, VIR_CONF_FLAG_LXC_FORMAT)))
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b3b4e8ab2c..901896d775 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -5566,7 +5566,7 @@ networkPortCreateXML(virNetworkPtr net,
     virNetworkDriverStatePtr driver = networkGetDriver();
     virNetworkObjPtr obj;
     virNetworkDefPtr def;
-    VIR_AUTOPTR(virNetworkPortDef) portdef = NULL;
+    g_autoptr(virNetworkPortDef) portdef = NULL;
     virNetworkPortPtr ret = NULL;
     int rc;
 
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 2b4dd7c9bb..de9f197dae 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1965,8 +1965,8 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
     virStorageVolPtr vol = NULL;
     virStorageVolPtr dup_vol = NULL;
     char *key = NULL;
-    VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) spdef = NULL;
+    g_autoptr(virStorageVolDef) voldef = NULL;
+    g_autoptr(virStoragePoolDef) spdef = NULL;
 
     if (VIR_ALLOC(spdef) < 0)
         return NULL;
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9e4b4d802e..ccd076d540 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2043,8 +2043,8 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon,
 {
     size_t i;
     int ret = -1;
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data;
     size_t ndata = 0;
     qemuAgentFSInfoPtr *info_ret = NULL;
@@ -2550,8 +2550,8 @@ qemuAgentGetUsers(qemuAgentPtr mon,
                   int *nparams,
                   int *maxparams)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data = NULL;
     size_t ndata;
     size_t i;
@@ -2642,8 +2642,8 @@ qemuAgentGetOSInfo(qemuAgentPtr mon,
                    int *nparams,
                    int *maxparams)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data = NULL;
 
     if (!(cmd = qemuAgentMakeCommand("guest-get-osinfo", NULL)))
@@ -2696,8 +2696,8 @@ qemuAgentGetTimezone(qemuAgentPtr mon,
                      int *nparams,
                      int *maxparams)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data = NULL;
     const char *name;
     int offset;
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 9a13351d2f..46584f2f1b 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -130,7 +130,7 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
                                         virHashTablePtr nodenamestable,
                                         qemuBlockNodeNameBackingChainDataPtr *nodenamedata)
 {
-    VIR_AUTOPTR(qemuBlockNodeNameBackingChainData) data = NULL;
+    g_autoptr(qemuBlockNodeNameBackingChainData) data = NULL;
     qemuBlockNodeNameBackingChainDataPtr backingdata = NULL;
     virJSONValuePtr backing = virJSONValueObjectGetObject(next, "backing");
     virJSONValuePtr parent = virJSONValueObjectGetObject(next, "parent");
@@ -198,7 +198,7 @@ qemuBlockNodeNameGetBackingChainDisk(size_t pos G_GNUC_UNUSED,
 {
     struct qemuBlockNodeNameGetBackingChainData *data = opaque;
     const char *device = virJSONValueObjectGetString(item, "device");
-    VIR_AUTOPTR(qemuBlockNodeNameBackingChainData) devicedata = NULL;
+    g_autoptr(qemuBlockNodeNameBackingChainData) devicedata = NULL;
 
     if (qemuBlockNodeNameGetBackingChainBacking(item, data->nodenamestable,
                                                 &devicedata) < 0)
@@ -231,8 +231,8 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namednodes,
                                  virJSONValuePtr blockstats)
 {
     struct qemuBlockNodeNameGetBackingChainData data;
-    VIR_AUTOPTR(virHashTable) namednodestable = NULL;
-    VIR_AUTOPTR(virHashTable) disks = NULL;
+    g_autoptr(virHashTable) namednodestable = NULL;
+    g_autoptr(virHashTable) disks = NULL;
 
     memset(&data, 0, sizeof(data));
 
@@ -327,9 +327,9 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
                          qemuDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    VIR_AUTOPTR(virHashTable) disktable = NULL;
-    VIR_AUTOPTR(virJSONValue) data = NULL;
-    VIR_AUTOPTR(virJSONValue) blockstats = NULL;
+    g_autoptr(virHashTable) disktable = NULL;
+    g_autoptr(virJSONValue) data = NULL;
+    g_autoptr(virJSONValue) blockstats = NULL;
     virDomainDiskDefPtr disk;
     size_t i;
 
@@ -371,7 +371,7 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
 virHashTablePtr
 qemuBlockGetNodeData(virJSONValuePtr data)
 {
-    VIR_AUTOPTR(virHashTable) nodedata = NULL;
+    g_autoptr(virHashTable) nodedata = NULL;
 
     if (!(nodedata = virHashCreate(50, virJSONValueHashFree)))
         return NULL;
@@ -408,7 +408,7 @@ qemuBlockStorageSourceSupportsConcurrentAccess(virStorageSourcePtr src)
 virURIPtr
 qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(virURI) uri = NULL;
+    g_autoptr(virURI) uri = NULL;
 
     if (src->nhosts != 1) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -470,7 +470,7 @@ static virJSONValuePtr
 qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDefPtr host,
                                              bool legacy)
 {
-    VIR_AUTOPTR(virJSONValue) server = NULL;
+    g_autoptr(virJSONValue) server = NULL;
     const char *transport;
     const char *field;
     g_autofree char *port = NULL;
@@ -530,8 +530,8 @@ static virJSONValuePtr
 qemuBlockStorageSourceBuildHostsJSONSocketAddress(virStorageSourcePtr src,
                                                   bool legacy)
 {
-    VIR_AUTOPTR(virJSONValue) servers = NULL;
-    VIR_AUTOPTR(virJSONValue) server = NULL;
+    g_autoptr(virJSONValue) servers = NULL;
+    g_autoptr(virJSONValue) server = NULL;
     virStorageNetHostDefPtr host;
     size_t i;
 
@@ -597,8 +597,8 @@ qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr host)
 static virJSONValuePtr
 qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(virJSONValue) servers = NULL;
-    VIR_AUTOPTR(virJSONValue) server = NULL;
+    g_autoptr(virJSONValue) servers = NULL;
+    g_autoptr(virJSONValue) server = NULL;
     virStorageNetHostDefPtr host;
     size_t i;
 
@@ -626,8 +626,8 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src,
                                       bool legacy,
                                       bool onlytarget)
 {
-    VIR_AUTOPTR(virJSONValue) servers = NULL;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) servers = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, legacy)))
         return NULL;
@@ -657,7 +657,7 @@ static virJSONValuePtr
 qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr src,
                                    bool onlytarget)
 {
-    VIR_AUTOPTR(virJSONValue) server = NULL;
+    g_autoptr(virJSONValue) server = NULL;
     const char *tlsAlias = src->tlsAlias;
     virJSONValuePtr ret = NULL;
 
@@ -696,7 +696,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
     const char *passwordalias = NULL;
     const char *username = NULL;
     virJSONValuePtr ret = NULL;
-    VIR_AUTOPTR(virURI) uri = NULL;
+    g_autoptr(virURI) uri = NULL;
     g_autofree char *uristr = NULL;
 
     /**
@@ -804,7 +804,7 @@ static virJSONValuePtr
 qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src,
                                   bool onlytarget)
 {
-    VIR_AUTOPTR(virJSONValue) serverprops = NULL;
+    g_autoptr(virJSONValue) serverprops = NULL;
     const char *tlsAlias = src->tlsAlias;
     virJSONValuePtr ret = NULL;
 
@@ -838,11 +838,11 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src,
                                   bool onlytarget)
 {
     qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
-    VIR_AUTOPTR(virJSONValue) servers = NULL;
+    g_autoptr(virJSONValue) servers = NULL;
     virJSONValuePtr ret = NULL;
     const char *username = NULL;
-    VIR_AUTOPTR(virJSONValue) authmodes = NULL;
-    VIR_AUTOPTR(virJSONValue) mode = NULL;
+    g_autoptr(virJSONValue) authmodes = NULL;
+    g_autoptr(virJSONValue) mode = NULL;
     const char *keysecret = NULL;
 
     if (src->nhosts > 0 &&
@@ -888,7 +888,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src,
 static virJSONValuePtr
 qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(virJSONValue) serverprops = NULL;
+    g_autoptr(virJSONValue) serverprops = NULL;
     virJSONValuePtr ret = NULL;
 
     if (src->nhosts != 1) {
@@ -916,7 +916,7 @@ qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src)
 static virJSONValuePtr
 qemuBlockStorageSourceGetSshProps(virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(virJSONValue) serverprops = NULL;
+    g_autoptr(virJSONValue) serverprops = NULL;
     virJSONValuePtr ret = NULL;
     const char *username = NULL;
 
@@ -973,7 +973,7 @@ static virJSONValuePtr
 qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src,
                                     bool onlytarget)
 {
-    VIR_AUTOPTR(virJSONValue) ret = NULL;
+    g_autoptr(virJSONValue) ret = NULL;
 
     /* libvirt currently does not handle the following attributes:
      * '*fat-type': 'int'
@@ -997,7 +997,7 @@ static int
 qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSourcePtr src,
                                                virJSONValuePtr props)
 {
-    VIR_AUTOPTR(virJSONValue) cacheobj = NULL;
+    g_autoptr(virJSONValue) cacheobj = NULL;
     bool direct = false;
     bool noflush = false;
 
@@ -1038,7 +1038,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src,
                                       bool autoreadonly)
 {
     int actualType = virStorageSourceGetActualType(src);
-    VIR_AUTOPTR(virJSONValue) fileprops = NULL;
+    g_autoptr(virJSONValue) fileprops = NULL;
     const char *driver = NULL;
     virTristateBool aro = VIR_TRISTATE_BOOL_ABSENT;
     virTristateBool ro = VIR_TRISTATE_BOOL_ABSENT;
@@ -1244,7 +1244,7 @@ qemuBlockStorageSourceGetFormatQcowGenericProps(virStorageSourcePtr src,
                                                 const char *format,
                                                 virJSONValuePtr props)
 {
-    VIR_AUTOPTR(virJSONValue) encprops = NULL;
+    g_autoptr(virJSONValue) encprops = NULL;
 
     if (qemuBlockStorageSourceGetCryptoProps(src, &encprops) < 0)
         return -1;
@@ -1289,7 +1289,7 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(virStorageSourcePtr src)
     const char *discard = NULL;
     int detectZeroesMode = virDomainDiskGetDetectZeroesMode(src->discard,
                                                             src->detect_zeroes);
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (qemuBlockNodeNameValidate(src->nodeformat) < 0)
         return NULL;
@@ -1323,7 +1323,7 @@ static virJSONValuePtr
 qemuBlockStorageSourceGetBlockdevFormatProps(virStorageSourcePtr src)
 {
     const char *driver = NULL;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (!(props = qemuBlockStorageSourceGetBlockdevFormatCommonProps(src)))
         return NULL;
@@ -1405,7 +1405,7 @@ virJSONValuePtr
 qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src,
                                        virStorageSourcePtr backingStore)
 {
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
         return NULL;
@@ -1481,7 +1481,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src,
                                             virStorageSourcePtr backingStore,
                                             bool autoreadonly)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
 
     if (VIR_ALLOC(data) < 0)
         return NULL;
@@ -1668,7 +1668,7 @@ qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src,
                                     char *driveAlias)
 {
     qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
     qemuBlockStorageSourceAttachDataPtr ret = NULL;
 
     if (VIR_ALLOC(data) < 0)
@@ -1738,8 +1738,8 @@ qemuBlockStorageSourceChainDataFree(qemuBlockStorageSourceChainDataPtr data)
 qemuBlockStorageSourceChainDataPtr
 qemuBlockStorageSourceChainDetachPrepareBlockdev(virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend = NULL;
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
     virStorageSourcePtr n;
 
     if (VIR_ALLOC(data) < 0)
@@ -1769,8 +1769,8 @@ qemuBlockStorageSourceChainDataPtr
 qemuBlockStorageSourceChainDetachPrepareDrive(virStorageSourcePtr src,
                                               char *driveAlias)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend = NULL;
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
 
     if (VIR_ALLOC(data) < 0)
         return NULL;
@@ -1928,8 +1928,8 @@ char *
 qemuBlockGetBackingStoreString(virStorageSourcePtr src)
 {
     int actualType = virStorageSourceGetActualType(src);
-    VIR_AUTOPTR(virJSONValue) backingProps = NULL;
-    VIR_AUTOPTR(virURI) uri = NULL;
+    g_autoptr(virJSONValue) backingProps = NULL;
+    g_autoptr(virURI) uri = NULL;
     g_autofree char *backingJSON = NULL;
     char *ret = NULL;
 
@@ -2022,7 +2022,7 @@ qemuBlockStorageSourceCreateGetFormatPropsGeneric(virStorageSourcePtr src,
                                                   virJSONValuePtr *retprops,
                                                   virStorageSourcePtr backing)
 {
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (virJSONValueObjectCreate(&props,
                                  "s:driver", driver,
@@ -2045,7 +2045,7 @@ qemuBlockStorageSourceCreateGetEncryptionLUKS(virStorageSourcePtr src,
                                               virJSONValuePtr *luksProps)
 {
     qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
     g_autofree char *cipheralg = NULL;
     const char *keysecret = NULL;
 
@@ -2085,7 +2085,7 @@ static int
 qemuBlockStorageSourceCreateGetFormatPropsLUKS(virStorageSourcePtr src,
                                                virJSONValuePtr *props)
 {
-    VIR_AUTOPTR(virJSONValue) luksprops = NULL;
+    g_autoptr(virJSONValue) luksprops = NULL;
 
     if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &luksprops) < 0)
         return -1;
@@ -2106,7 +2106,7 @@ static int
 qemuBlockStorageSourceCreateAddEncryptionQcow(virStorageSourcePtr src,
                                               virJSONValuePtr props)
 {
-    VIR_AUTOPTR(virJSONValue) encryptProps = NULL;
+    g_autoptr(virJSONValue) encryptProps = NULL;
 
     if (!src->encryption)
         return 0;
@@ -2135,7 +2135,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQcow2(virStorageSourcePtr src,
                                                 virStorageSourcePtr backing,
                                                 virJSONValuePtr *props)
 {
-    VIR_AUTOPTR(virJSONValue) qcow2props = NULL;
+    g_autoptr(virJSONValue) qcow2props = NULL;
     const char *qcow2version = NULL;
 
     if (STREQ_NULLABLE(src->compat, "0.10"))
@@ -2165,7 +2165,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQcow(virStorageSourcePtr src,
                                                virStorageSourcePtr backing,
                                                virJSONValuePtr *props)
 {
-    VIR_AUTOPTR(virJSONValue) qcowprops = NULL;
+    g_autoptr(virJSONValue) qcowprops = NULL;
 
     if (virJSONValueObjectCreate(&qcowprops,
                                  "s:driver", "qcow",
@@ -2188,7 +2188,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQed(virStorageSourcePtr src,
                                               virStorageSourcePtr backing,
                                               virJSONValuePtr *props)
 {
-    VIR_AUTOPTR(virJSONValue) qedprops = NULL;
+    g_autoptr(virJSONValue) qedprops = NULL;
 
     if (virJSONValueObjectCreate(&qedprops,
                                  "s:driver", "qed",
@@ -2300,7 +2300,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorageSourcePtr src,
                                             virJSONValuePtr *props)
 {
     int actualType = virStorageSourceGetActualType(src);
-    VIR_AUTOPTR(virJSONValue) location = NULL;
+    g_autoptr(virJSONValue) location = NULL;
     const char *driver = NULL;
     const char *filename = NULL;
 
@@ -2382,7 +2382,7 @@ qemuBlockStorageSourceCreateGeneric(virDomainObjPtr vm,
                                     bool storageCreate,
                                     qemuDomainAsyncJob asyncJob)
 {
-    VIR_AUTOPTR(virJSONValue) props = createProps;
+    g_autoptr(virJSONValue) props = createProps;
     qemuDomainObjPrivatePtr priv = vm->privateData;
     qemuBlockJobDataPtr job = NULL;
     int ret = -1;
@@ -2438,7 +2438,7 @@ qemuBlockStorageSourceCreateStorage(virDomainObjPtr vm,
                                     qemuDomainAsyncJob asyncJob)
 {
     int actualType = virStorageSourceGetActualType(src);
-    VIR_AUTOPTR(virJSONValue) createstorageprops = NULL;
+    g_autoptr(virJSONValue) createstorageprops = NULL;
     int ret;
 
     /* We create local files directly to be able to apply security labels
@@ -2474,7 +2474,7 @@ qemuBlockStorageSourceCreateFormat(virDomainObjPtr vm,
                                    virStorageSourcePtr chain,
                                    qemuDomainAsyncJob asyncJob)
 {
-    VIR_AUTOPTR(virJSONValue) createformatprops = NULL;
+    g_autoptr(virJSONValue) createformatprops = NULL;
     int ret;
 
     if (src->format == VIR_STORAGE_FILE_RAW)
@@ -2595,7 +2595,7 @@ qemuBlockStorageSourceCreateDetectSize(virDomainObjPtr vm,
                                        qemuDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    VIR_AUTOPTR(virHashTable) stats = NULL;
+    g_autoptr(virHashTable) stats = NULL;
     qemuBlockStatsPtr entry;
     int rc;
 
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 3d52cfe0ef..239bf772d5 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -797,7 +797,7 @@ qemuBlockJobEventProcessConcludedRemoveChain(virQEMUDriverPtr driver,
                                              qemuDomainAsyncJob asyncJob,
                                              virStorageSourcePtr chain)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
 
     if (!(data = qemuBlockStorageSourceChainDetachPrepareBlockdev(chain)))
         return;
@@ -1212,7 +1212,7 @@ qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver,
                                         qemuBlockJobDataPtr job,
                                         qemuDomainAsyncJob asyncJob)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
 
     /* if there is a synchronous client waiting for this job that means that
      * it will handle further hotplug of the created volume and also that
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 00ac2aed0e..b8f5153cbc 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1580,7 +1580,7 @@ static int
 virQEMUCapsSEVInfoCopy(virSEVCapabilityPtr *dst,
                        virSEVCapabilityPtr src)
 {
-    VIR_AUTOPTR(virSEVCapability) tmp = NULL;
+    g_autoptr(virSEVCapability) tmp = NULL;
 
     if (VIR_ALLOC(tmp) < 0 ||
         VIR_STRDUP(tmp->pdh, src->pdh) < 0 ||
@@ -3576,7 +3576,7 @@ virQEMUCapsCachePrivFree(void *privData)
 static int
 virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xmlXPathContextPtr ctxt)
 {
-    VIR_AUTOPTR(virSEVCapability) sev = NULL;
+    g_autoptr(virSEVCapability) sev = NULL;
 
     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST))
         return 0;
@@ -5583,7 +5583,7 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
                                     virDomainCapsPtr domCaps)
 {
     virSEVCapability *cap = qemuCaps->sevCapabilities;
-    VIR_AUTOPTR(virSEVCapability) sev = NULL;
+    g_autoptr(virSEVCapability) sev = NULL;
 
     if (!cap)
         return 0;
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 5f2372779a..7f675d4b79 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -159,7 +159,7 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver,
                 parentdef = virDomainCheckpointObjGetDef(moment);
                 for (j = 0; j < parentdef->ndisks; j++) {
                     virDomainCheckpointDiskDef *disk2;
-                    VIR_AUTOPTR(virJSONValue) arr = NULL;
+                    g_autoptr(virJSONValue) arr = NULL;
 
                     disk2 = &parentdef->disks[j];
                     if (STRNEQ(disk->name, disk2->name) ||
@@ -356,7 +356,7 @@ qemuCheckpointCreateXML(virDomainPtr domain,
     virDomainMomentObjPtr other = NULL;
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
     VIR_AUTOUNREF(virCapsPtr) caps = NULL;
-    VIR_AUTOPTR(virJSONValue) actions = NULL;
+    g_autoptr(virJSONValue) actions = NULL;
     int ret;
     VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 130476b9e5..6829bede99 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -731,7 +731,7 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
                                  qemuDomainSecretInfoPtr secinfo)
 {
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (qemuBuildSecretInfoProps(secinfo, &props) < 0)
         return -1;
@@ -922,7 +922,7 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
                             virQEMUCapsPtr qemuCaps)
 {
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias,
                                      certEncSecretAlias, qemuCaps, &props) < 0)
@@ -942,7 +942,7 @@ static char *
 qemuBuildNetworkDriveURI(virStorageSourcePtr src,
                          qemuDomainSecretInfoPtr secinfo)
 {
-    VIR_AUTOPTR(virURI) uri = NULL;
+    g_autoptr(virURI) uri = NULL;
 
     if (!(uri = qemuBlockStorageSourceGetURI(src)))
         return NULL;
@@ -1557,7 +1557,7 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src,
 static virJSONValuePtr
 qemuDiskSourceGetProps(virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
     virJSONValuePtr ret;
 
     if (!(props = qemuBlockStorageSourceGetBackendProps(src, true, false, false)))
@@ -1600,7 +1600,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
     qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
     qemuDomainSecretInfoPtr secinfo = NULL;
     qemuDomainSecretInfoPtr encinfo = NULL;
-    VIR_AUTOPTR(virJSONValue) srcprops = NULL;
+    g_autoptr(virJSONValue) srcprops = NULL;
     g_autofree char *source = NULL;
     bool rawluks = false;
 
@@ -2477,8 +2477,8 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
                                virDomainDiskDefPtr disk,
                                virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
-    VIR_AUTOPTR(virJSONValue) copyOnReadProps = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(virJSONValue) copyOnReadProps = NULL;
     g_autofree char *copyOnReadPropsStr = NULL;
     size_t i;
 
@@ -3330,7 +3330,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
     bool prealloc = false;
     virBitmapPtr nodemask = NULL;
     int rc;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
     bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, mem->targetNode);
     unsigned long long pagesize = mem->pagesize;
     bool needHugepage = !!pagesize;
@@ -3584,7 +3584,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
                               qemuDomainObjPrivatePtr priv,
                               virBufferPtr buf)
 {
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
     g_autofree char *alias = NULL;
     int rc;
     virDomainMemoryDef mem = { 0 };
@@ -3616,7 +3616,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
                               virQEMUDriverConfigPtr cfg,
                               qemuDomainObjPrivatePtr priv)
 {
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
     g_autofree char *alias = NULL;
 
     if (!mem->info.alias) {
@@ -4933,7 +4933,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
 {
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     g_autofree char *netsource = NULL;
-    VIR_AUTOPTR(virJSONValue) srcprops = NULL;
+    g_autoptr(virJSONValue) srcprops = NULL;
     virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
     virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
     qemuDomainStorageSourcePrivatePtr srcPriv =
@@ -5887,7 +5887,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
     size_t i;
 
     for (i = 0; i < def->nrngs; i++) {
-        VIR_AUTOPTR(virJSONValue) props = NULL;
+        g_autoptr(virJSONValue) props = NULL;
         virBuffer buf = VIR_BUFFER_INITIALIZER;
         virDomainRNGDefPtr rng = def->rngs[i];
         g_autofree char *chardev = NULL;
@@ -9000,7 +9000,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
                           virQEMUCapsPtr qemuCaps,
                           bool chardevStdioLogd)
 {
-    VIR_AUTOPTR(virJSONValue) memProps = NULL;
+    g_autoptr(virJSONValue) memProps = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     g_autofree char *devstr = NULL;
     g_autofree char *chardev = NULL;
@@ -9991,7 +9991,7 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
                               qemuDomainObjPrivatePtr priv)
 {
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (!virDomainDefHasManagedPR(def))
         return 0;
@@ -10050,7 +10050,7 @@ qemuBuildDBusVMStateCommandLineEach(void *payload,
     qemuBuildDBusVMStateCommandLineData *data = user_data;
     qemuDBusVMStatePtr vms = payload;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
 
     if (!(props = qemuBuildDBusVMStateInfoProps(id, vms->addr)))
         return -1;
@@ -10276,7 +10276,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
 {
     size_t i;
     char uuid[VIR_UUID_STRING_BUFLEN];
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
     unsigned int bootHostdevNet = 0;
     qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -10715,7 +10715,7 @@ virJSONValuePtr
 qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
 {
     qemuDomainVcpuPrivatePtr vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
-    VIR_AUTOPTR(virJSONValue) ret = NULL;
+    g_autoptr(virJSONValue) ret = NULL;
 
     if (!(ret = virJSONValueCopy(vcpupriv->props)))
         return NULL;
@@ -10741,7 +10741,7 @@ qemuBlockStorageSourceAttachDataPtr
 qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
                                          virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
     qemuBlockStorageSourceAttachDataPtr ret = NULL;
 
     if (VIR_ALLOC(data) < 0)
@@ -10809,8 +10809,8 @@ qemuBlockStorageSourceChainDataPtr
 qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDefPtr disk,
                                               virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem = NULL;
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) elem = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
 
     if (VIR_ALLOC(data) < 0)
         return NULL;
@@ -10834,7 +10834,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevOne(qemuBlockStorageSourceChainD
                                                     virStorageSourcePtr backingStore,
                                                     virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) elem = NULL;
 
     if (!(elem = qemuBlockStorageSourceAttachPrepareBlockdev(src, backingStore, true)))
         return -1;
@@ -10861,7 +10861,7 @@ qemuBlockStorageSourceChainDataPtr
 qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top,
                                                  virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
     virStorageSourcePtr n;
 
     if (VIR_ALLOC(data) < 0)
@@ -10892,7 +10892,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr top,
                                                     virStorageSourcePtr backingStore,
                                                     virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
 
     if (VIR_ALLOC(data) < 0)
         return NULL;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index de03069036..630e31723a 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1000,7 +1000,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
                                 const char *filename,
                                 bool privileged)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     /* Just check the file is readable before opening it, otherwise
      * libvirt emits an error.
diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c
index 15c9bf519e..d0f25dd0d4 100644
--- a/src/qemu/qemu_dbus.c
+++ b/src/qemu/qemu_dbus.c
@@ -37,7 +37,7 @@ VIR_LOG_INIT("qemu.dbus");
 qemuDBusVMStatePtr
 qemuDBusVMStateNew(const char *id, const char *addr)
 {
-    VIR_AUTOPTR(qemuDBusVMState) self = NULL;
+    g_autoptr(qemuDBusVMState) self = NULL;
 
     if (VIR_ALLOC(self) < 0)
         return NULL;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5b3e1d8fcb..e25f5a7ee8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3648,7 +3648,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
     for (i = 0; i < n; i++) {
         g_autofree char *alias = virXMLPropString(nodes[i], "alias");
         g_autofree char *pid = virXMLPropString(nodes[i], "pid");
-        VIR_AUTOPTR(qemuSlirp) slirp = qemuSlirpNew();
+        g_autoptr(qemuSlirp) slirp = qemuSlirpNew();
         virDomainDeviceDef dev;
 
         if (!alias || !pid || !slirp ||
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 69919ac203..beb72f21d1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14487,7 +14487,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
     virDomainObjPtr vm;
     qemuDomainObjPrivatePtr priv;
     bool postcopy = !!(flags & VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY);
-    VIR_AUTOPTR(qemuMigrationParams) migParams = NULL;
+    g_autoptr(qemuMigrationParams) migParams = NULL;
     unsigned long long max;
     int ret = -1;
 
@@ -14565,7 +14565,7 @@ qemuDomainMigrationGetPostcopyBandwidth(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
                                         unsigned long *bandwidth)
 {
-    VIR_AUTOPTR(qemuMigrationParams) migParams = NULL;
+    g_autoptr(qemuMigrationParams) migParams = NULL;
     unsigned long long bw;
     int rc;
     int ret = -1;
@@ -15687,7 +15687,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
                                    qemuDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    VIR_AUTOPTR(virJSONValue) actions = NULL;
+    g_autoptr(virJSONValue) actions = NULL;
     int rc;
     int ret = -1;
     size_t i;
@@ -18223,8 +18223,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
     VIR_AUTOUNREF(virStorageSourcePtr) mirror = mirrorsrc;
     bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
     bool mirror_initialized = false;
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) crdata = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) crdata = NULL;
     virStorageSourcePtr n;
     virStorageSourcePtr mirrorBacking = NULL;
     int rc = 0;
@@ -21586,7 +21586,7 @@ qemuDomainGetStats(virConnectPtr conn,
                    unsigned int flags)
 {
     g_autofree virDomainStatsRecordPtr tmp = NULL;
-    VIR_AUTOPTR(virTypedParamList) params = NULL;
+    g_autoptr(virTypedParamList) params = NULL;
     size_t i;
 
     if (VIR_ALLOC(params) < 0)
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 10644a0e28..b8a17ed1ca 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -289,7 +289,7 @@ qemuFirmwareInterfaceParse(const char *path,
                            qemuFirmwarePtr fw)
 {
     virJSONValuePtr interfacesJSON;
-    VIR_AUTOPTR(qemuFirmwareOSInterface) interfaces = NULL;
+    g_autoptr(qemuFirmwareOSInterface) interfaces = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     size_t ninterfaces;
     size_t i;
@@ -509,7 +509,7 @@ qemuFirmwareTargetParse(const char *path,
     for (i = 0; i < ntargets; i++) {
         virJSONValuePtr item = virJSONValueArrayGet(targetsJSON, i);
         virJSONValuePtr machines;
-        VIR_AUTOPTR(qemuFirmwareTarget) t = NULL;
+        g_autoptr(qemuFirmwareTarget) t = NULL;
         const char *architectureStr = NULL;
         size_t nmachines;
         size_t j;
@@ -575,7 +575,7 @@ qemuFirmwareFeatureParse(const char *path,
                          qemuFirmwarePtr fw)
 {
     virJSONValuePtr featuresJSON;
-    VIR_AUTOPTR(qemuFirmwareFeature) features = NULL;
+    g_autoptr(qemuFirmwareFeature) features = NULL;
     size_t nfeatures;
     size_t i;
 
@@ -619,8 +619,8 @@ qemuFirmwarePtr
 qemuFirmwareParse(const char *path)
 {
     g_autofree char *cont = NULL;
-    VIR_AUTOPTR(virJSONValue) doc = NULL;
-    VIR_AUTOPTR(qemuFirmware) fw = NULL;
+    g_autoptr(virJSONValue) doc = NULL;
+    g_autoptr(qemuFirmware) fw = NULL;
     qemuFirmwarePtr ret = NULL;
 
     if (virFileReadAll(path, DOCUMENT_SIZE, &cont) < 0)
@@ -657,7 +657,7 @@ static int
 qemuFirmwareInterfaceFormat(virJSONValuePtr doc,
                             qemuFirmwarePtr fw)
 {
-    VIR_AUTOPTR(virJSONValue) interfacesJSON = NULL;
+    g_autoptr(virJSONValue) interfacesJSON = NULL;
     size_t i;
 
     if (!(interfacesJSON = virJSONValueNewArray()))
@@ -682,7 +682,7 @@ qemuFirmwareInterfaceFormat(virJSONValuePtr doc,
 static virJSONValuePtr
 qemuFirmwareFlashFileFormat(qemuFirmwareFlashFile flash)
 {
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     virJSONValuePtr ret;
 
     if (!(json = virJSONValueNewObject()))
@@ -707,8 +707,8 @@ static int
 qemuFirmwareMappingFlashFormat(virJSONValuePtr mapping,
                                qemuFirmwareMappingFlashPtr flash)
 {
-    VIR_AUTOPTR(virJSONValue) executable = NULL;
-    VIR_AUTOPTR(virJSONValue) nvram_template = NULL;
+    g_autoptr(virJSONValue) executable = NULL;
+    g_autoptr(virJSONValue) nvram_template = NULL;
 
     if (!(executable = qemuFirmwareFlashFileFormat(flash->executable)))
         return -1;
@@ -764,7 +764,7 @@ static int
 qemuFirmwareMappingFormat(virJSONValuePtr doc,
                           qemuFirmwarePtr fw)
 {
-    VIR_AUTOPTR(virJSONValue) mapping = NULL;
+    g_autoptr(virJSONValue) mapping = NULL;
 
     if (!(mapping = virJSONValueNewObject()))
         return -1;
@@ -805,7 +805,7 @@ static int
 qemuFirmwareTargetFormat(virJSONValuePtr doc,
                          qemuFirmwarePtr fw)
 {
-    VIR_AUTOPTR(virJSONValue) targetsJSON = NULL;
+    g_autoptr(virJSONValue) targetsJSON = NULL;
     size_t i;
 
     if (!(targetsJSON = virJSONValueNewArray()))
@@ -813,8 +813,8 @@ qemuFirmwareTargetFormat(virJSONValuePtr doc,
 
     for (i = 0; i < fw->ntargets; i++) {
         qemuFirmwareTargetPtr t = fw->targets[i];
-        VIR_AUTOPTR(virJSONValue) target = NULL;
-        VIR_AUTOPTR(virJSONValue) machines = NULL;
+        g_autoptr(virJSONValue) target = NULL;
+        g_autoptr(virJSONValue) machines = NULL;
         size_t j;
 
         if (!(target = virJSONValueNewObject()))
@@ -857,7 +857,7 @@ static int
 qemuFirmwareFeatureFormat(virJSONValuePtr doc,
                           qemuFirmwarePtr fw)
 {
-    VIR_AUTOPTR(virJSONValue) featuresJSON = NULL;
+    g_autoptr(virJSONValue) featuresJSON = NULL;
     size_t i;
 
     if (!(featuresJSON = virJSONValueNewArray()))
@@ -882,7 +882,7 @@ qemuFirmwareFeatureFormat(virJSONValuePtr doc,
 char *
 qemuFirmwareFormat(qemuFirmwarePtr fw)
 {
-    VIR_AUTOPTR(virJSONValue) doc = NULL;
+    g_autoptr(virJSONValue) doc = NULL;
 
     if (!fw)
         return NULL;
@@ -1391,7 +1391,7 @@ qemuFirmwareGetSupported(const char *machine,
         }
 
         if (fws && fwpath) {
-            VIR_AUTOPTR(virFirmware) tmp = NULL;
+            g_autoptr(virFirmware) tmp = NULL;
 
             /* Append only unique pairs. */
             for (j = 0; j < *nfws; j++) {
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f22b509ffa..7b3363c0c7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -422,7 +422,7 @@ qemuDomainAttachDBusVMState(virQEMUDriverPtr driver,
                             qemuDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    VIR_AUTOPTR(virJSONValue) props = NULL;
+    g_autoptr(virJSONValue) props = NULL;
     int ret;
 
     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
@@ -505,8 +505,8 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) newbackend = NULL;
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) oldbackend = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) newbackend = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) oldbackend = NULL;
     g_autofree char *nodename = NULL;
     int rc;
 
@@ -672,12 +672,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
                             virDomainObjPtr vm,
                             virDomainDiskDefPtr disk)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
     g_autofree char *devstr = NULL;
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
-    VIR_AUTOPTR(virJSONValue) corProps = NULL;
+    g_autoptr(virJSONValue) corProps = NULL;
     g_autofree char *corAlias = NULL;
     bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
 
@@ -4232,7 +4232,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
                            virDomainDiskDefPtr disk)
 {
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-    VIR_AUTOPTR(qemuBlockStorageSourceChainData) diskBackend = NULL;
+    g_autoptr(qemuBlockStorageSourceChainData) diskBackend = NULL;
     virDomainDeviceDef dev;
     size_t i;
     qemuDomainObjPrivatePtr priv = vm->privateData;
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index 7f3ac8f085..11d21837ea 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -644,7 +644,7 @@ qemuInterfacePrepareSlirp(virQEMUDriverPtr driver,
                           virDomainNetDefPtr net)
 {
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    VIR_AUTOPTR(qemuSlirp) slirp = NULL;
+    g_autoptr(qemuSlirp) slirp = NULL;
     size_t i;
 
     if (!(slirp = qemuSlirpNewForHelper(cfg->slirpHelperName)))
diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c
index 9281935d9a..7193d31dfd 100644
--- a/src/qemu/qemu_interop_config.c
+++ b/src/qemu/qemu_interop_config.c
@@ -99,7 +99,7 @@ qemuInteropFetchConfigs(const char *name,
                         char ***configs,
                         bool privileged)
 {
-    VIR_AUTOPTR(virHashTable) files = NULL;
+    g_autoptr(virHashTable) files = NULL;
     g_autofree char *homeConfig = NULL;
     g_autofree char *xdgConfig = NULL;
     g_autofree char *sysLocation = virFileBuildPath(QEMU_SYSTEM_LOCATION, name, NULL);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index fbd6681051..1166236124 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -794,7 +794,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
                                        unsigned int mirror_shallow,
                                        const char *tlsAlias)
 {
-    VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
+    g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     int mon_ret = 0;
     VIR_AUTOUNREF(virStorageSourcePtr) copysrc = NULL;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e9967eadfe..5ca7c592dc 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2679,7 +2679,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
     int nstats = 0;
     int rc;
     size_t i;
-    VIR_AUTOPTR(virJSONValue) devices = NULL;
+    g_autoptr(virJSONValue) devices = NULL;
 
     if (!(devices = qemuMonitorJSONQueryBlockstats(mon)))
         return -1;
@@ -4347,8 +4347,8 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
                            bool shallow,
                            bool reuse)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     cmd = qemuMonitorJSONMakeCommand("drive-mirror",
                                      "s:device", device,
@@ -4381,8 +4381,8 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
                               unsigned long long buf_size,
                               bool shallow)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
     virTristateBool autodismiss = VIR_TRISTATE_BOOL_ABSENT;
 
@@ -5023,8 +5023,8 @@ int
 qemuMonitorJSONJobDismiss(qemuMonitorPtr mon,
                           const char *jobname)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("job-dismiss",
                                            "s:id", jobname,
@@ -5046,8 +5046,8 @@ qemuMonitorJSONJobCancel(qemuMonitorPtr mon,
                          const char *jobname,
                          bool quiet)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("job-cancel",
                                            "s:id", jobname,
@@ -5073,8 +5073,8 @@ int
 qemuMonitorJSONJobComplete(qemuMonitorPtr mon,
                            const char *jobname)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("job-complete",
                                            "s:id", jobname,
@@ -5808,9 +5808,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
                                     bool fail_no_props,
                                     qemuMonitorCPUModelInfoPtr *model_info)
 {
-    VIR_AUTOPTR(virJSONValue) model = NULL;
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) model = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data;
     virJSONValuePtr cpu_model;
     virJSONValuePtr cpu_props = NULL;
@@ -5883,10 +5883,10 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
                                    virCPUDefPtr cpu_b,
                                    qemuMonitorCPUModelInfoPtr *baseline)
 {
-    VIR_AUTOPTR(virJSONValue) model_a = NULL;
-    VIR_AUTOPTR(virJSONValue) model_b = NULL;
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) model_a = NULL;
+    g_autoptr(virJSONValue) model_b = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data;
     virJSONValuePtr cpu_model;
     virJSONValuePtr cpu_props = NULL;
@@ -5925,10 +5925,10 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
                                      virCPUDefPtr cpu_b,
                                      char **result)
 {
-    VIR_AUTOPTR(virJSONValue) model_a = NULL;
-    VIR_AUTOPTR(virJSONValue) model_b = NULL;
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) model_a = NULL;
+    g_autoptr(virJSONValue) model_b = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     const char *data_result;
     virJSONValuePtr data;
 
@@ -6468,8 +6468,8 @@ qemuMonitorJSONGetStringListProperty(qemuMonitorPtr mon,
                                      const char *property,
                                      char ***strList)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     VIR_AUTOSTRINGLIST list = NULL;
     virJSONValuePtr data;
     size_t n;
@@ -6959,7 +6959,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
     const char *cert_chain = NULL;
     unsigned int cbitpos;
     unsigned int reduced_phys_bits;
-    VIR_AUTOPTR(virSEVCapability) capability = NULL;
+    g_autoptr(virSEVCapability) capability = NULL;
 
     *capabilities = NULL;
 
@@ -7750,8 +7750,8 @@ static int
 qemuMonitorJSONGetCPUProperties(qemuMonitorPtr mon,
                                 char ***props)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     *props = NULL;
 
@@ -8699,8 +8699,8 @@ qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon,
                               const char *jobname,
                               virJSONValuePtr props)
 {
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     cmd = qemuMonitorJSONMakeCommand("blockdev-create",
                                      "s:job-id", jobname,
@@ -9292,7 +9292,7 @@ qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data)
     const char *status = virJSONValueObjectGetString(data, "status");
     const char *errmsg = virJSONValueObjectGetString(data, "error");
     int tmp;
-    VIR_AUTOPTR(qemuMonitorJobInfo) job = NULL;
+    g_autoptr(qemuMonitorJobInfo) job = NULL;
     qemuMonitorJobInfoPtr ret = NULL;
 
     if (VIR_ALLOC(job) < 0)
@@ -9323,8 +9323,8 @@ qemuMonitorJSONGetJobInfo(qemuMonitorPtr mon,
                           size_t *njobs)
 {
     virJSONValuePtr data;
-    VIR_AUTOPTR(virJSONValue) cmd = NULL;
-    VIR_AUTOPTR(virJSONValue) reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     size_t i;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("query-jobs", NULL)))
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index afbbe1a853..d21d95a977 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2517,7 +2517,7 @@ qemuProcessGetAllCpuAffinity(virBitmapPtr *cpumapRet)
 static int
 qemuProcessInitCpuAffinity(virDomainObjPtr vm)
 {
-    VIR_AUTOPTR(virBitmap) cpumapToSet = NULL;
+    g_autoptr(virBitmap) cpumapToSet = NULL;
     virDomainNumatuneMemMode mem_mode;
     qemuDomainObjPrivatePtr priv = vm->privateData;
 
@@ -2644,7 +2644,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
     virDomainNumatuneMemMode mem_mode;
     virCgroupPtr cgroup = NULL;
     virBitmapPtr use_cpumask = NULL;
-    VIR_AUTOPTR(virBitmap) hostcpumap = NULL;
+    g_autoptr(virBitmap) hostcpumap = NULL;
     char *mem_mask = NULL;
     int ret = -1;
 
diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
index 2fc56dcfa4..41179f72ec 100644
--- a/src/qemu/qemu_qapi.c
+++ b/src/qemu/qemu_qapi.c
@@ -501,8 +501,8 @@ virQEMUQAPISchemaEntryProcess(size_t pos G_GNUC_UNUSED,
 virHashTablePtr
 virQEMUQAPISchemaConvert(virJSONValuePtr schemareply)
 {
-    VIR_AUTOPTR(virHashTable) schema = NULL;
-    VIR_AUTOPTR(virJSONValue) schemajson = schemareply;
+    g_autoptr(virHashTable) schema = NULL;
+    g_autoptr(virJSONValue) schemajson = schemareply;
 
     if (!(schema = virHashCreate(512, virJSONValueHashFree)))
         return NULL;
diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c
index 53e8f27e2d..b4d85c49df 100644
--- a/src/qemu/qemu_slirp.c
+++ b/src/qemu/qemu_slirp.c
@@ -81,7 +81,7 @@ qemuSlirpHasFeature(const qemuSlirp *slirp,
 qemuSlirpPtr
 qemuSlirpNew(void)
 {
-    VIR_AUTOPTR(qemuSlirp) slirp = NULL;
+    g_autoptr(qemuSlirp) slirp = NULL;
 
     if (VIR_ALLOC(slirp) < 0 ||
         !(slirp->features = virBitmapNew(QEMU_SLIRP_FEATURE_LAST)))
@@ -97,10 +97,10 @@ qemuSlirpNew(void)
 qemuSlirpPtr
 qemuSlirpNewForHelper(const char *helper)
 {
-    VIR_AUTOPTR(qemuSlirp) slirp = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(qemuSlirp) slirp = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *output = NULL;
-    VIR_AUTOPTR(virJSONValue) doc = NULL;
+    g_autoptr(virJSONValue) doc = NULL;
     virJSONValuePtr featuresJSON;
     size_t i, nfeatures;
 
@@ -297,7 +297,7 @@ qemuSlirpStart(qemuSlirpPtr slirp,
                bool incoming)
 {
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *pidfile = NULL;
     g_autofree char *dbus_path = NULL;
     g_autofree char *dbus_addr = NULL;
diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c
index 8a653fc101..5bab7ff5fa 100644
--- a/src/qemu/qemu_vhost_user.c
+++ b/src/qemu/qemu_vhost_user.c
@@ -183,8 +183,8 @@ qemuVhostUserPtr
 qemuVhostUserParse(const char *path)
 {
     g_autofree char *cont = NULL;
-    VIR_AUTOPTR(virJSONValue) doc = NULL;
-    VIR_AUTOPTR(qemuVhostUser) vu = NULL;
+    g_autoptr(virJSONValue) doc = NULL;
+    g_autoptr(qemuVhostUser) vu = NULL;
     qemuVhostUserPtr ret = NULL;
 
     if (virFileReadAll(path, DOCUMENT_SIZE, &cont) < 0)
@@ -214,7 +214,7 @@ qemuVhostUserParse(const char *path)
 char *
 qemuVhostUserFormat(qemuVhostUserPtr vu)
 {
-    VIR_AUTOPTR(virJSONValue) doc = NULL;
+    g_autoptr(virJSONValue) doc = NULL;
 
     if (!vu)
         return NULL;
@@ -285,7 +285,7 @@ qemuVhostUserGPUFillCapabilities(qemuVhostUserPtr vu,
     virJSONValuePtr featuresJSON;
     size_t nfeatures;
     size_t i;
-    VIR_AUTOPTR(qemuVhostUserGPUFeature) features = NULL;
+    g_autoptr(qemuVhostUserGPUFeature) features = NULL;
 
     if (!(featuresJSON = virJSONValueObjectGetArray(doc, "features"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -350,9 +350,9 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
         goto end;
 
     for (i = 0; i < nvus; i++) {
-        VIR_AUTOPTR(virJSONValue) doc = NULL;
+        g_autoptr(virJSONValue) doc = NULL;
         g_autofree char *output = NULL;
-        VIR_AUTOPTR(virCommand) cmd = NULL;
+        g_autoptr(virCommand) cmd = NULL;
 
         vu = vus[i];
         if (vu->type != QEMU_VHOST_USER_TYPE_GPU)
diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c
index 291a6a0d9e..6daccf170e 100644
--- a/src/qemu/qemu_vhost_user_gpu.c
+++ b/src/qemu/qemu_vhost_user_gpu.c
@@ -108,7 +108,7 @@ int qemuExtVhostUserGPUStart(virQEMUDriverPtr driver,
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
     g_autofree char *shortname = NULL;
     g_autofree char *pidfile = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int pair[2] = { -1, -1 };
     int cmdret = 0, rc;
     int exitstatus = 0;
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 916b14dc7f..e87ff12512 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -400,7 +400,7 @@ daemonSetupNetworking(virNetServerPtr srv,
     int unix_sock_rw_mask = 0;
     int unix_sock_adm_mask = 0;
     int ret = -1;
-    VIR_AUTOPTR(virSystemdActivation) act = NULL;
+    g_autoptr(virSystemdActivation) act = NULL;
     virSystemdActivationMap actmap[] = {
         { .name = DAEMON_NAME ".socket", .family = AF_UNIX, .path = sock_path },
         { .name = DAEMON_NAME "-ro.socket", .family = AF_UNIX, .path = sock_path_ro },
diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_config.c
index ce5f8c5278..4c712bf2dc 100644
--- a/src/remote/remote_daemon_config.c
+++ b/src/remote/remote_daemon_config.c
@@ -401,7 +401,7 @@ daemonConfigLoadFile(struct daemonConfig *data,
                      const char *filename,
                      bool allow_missing)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     if (allow_missing &&
         access(filename, R_OK) == -1 &&
@@ -419,7 +419,7 @@ int daemonConfigLoadData(struct daemonConfig *data,
                          const char *filename,
                          const char *filedata)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
 
     conf = virConfReadString(filedata, 0);
     if (!conf)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 17d39125bb..0812def922 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -637,7 +637,7 @@ virSecuritySELinuxGenNewContext(const char *basecontext,
 static int
 virSecuritySELinuxLXCInitialize(virSecurityManagerPtr mgr)
 {
-    VIR_AUTOPTR(virConf) selinux_conf = NULL;
+    g_autoptr(virConf) selinux_conf = NULL;
     virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr);
 
     data->skipAllLabel = true;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 2ff34dacbd..afc5324b77 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -170,7 +170,7 @@ parserCommand(const char *profile_name, const char cmd)
         const char * const argv[] = {
             "/sbin/apparmor_parser", flag, profile, NULL
         };
-        VIR_AUTOPTR(virCommand) command = virCommandNewArgs(argv);
+        g_autoptr(virCommand) command = virCommandNewArgs(argv);
 
         virCommandRawStatus(command);
         if ((ret = virCommandRun(command, &status)) != 0 ||
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 742539036c..1228da1f47 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -360,7 +360,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
         .vol = vol,
     };
     g_autofree char *parthelper_path = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
                                                 abs_top_builddir "/src",
@@ -414,7 +414,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     g_autofree char *parthelper_path = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
                                                 abs_top_builddir "/src",
@@ -492,7 +492,7 @@ virStorageBackendDiskBuildPool(virStoragePoolObjPtr pool,
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int format = def->source.format;
     const char *fmt;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int ret = -1;
 
     virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
@@ -774,7 +774,7 @@ virStorageBackendDiskDeleteVol(virStoragePoolObjPtr pool,
     char *srcname = last_component(src_path);
     bool isDevMapperDevice;
     g_autofree char *devpath = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virCheckFlags(0, -1);
 
@@ -856,7 +856,7 @@ virStorageBackendDiskCreateVol(virStoragePoolObjPtr pool,
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     virErrorPtr save_err;
     g_autofree char *partFormat = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(PARTED,
                                def->source.devices[0].path,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 132b7e721f..a00308bc17 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -109,7 +109,7 @@ virStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState *state)
         1
     };
 
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(SHOWMOUNT,
                                "--no-headers",
@@ -139,7 +139,7 @@ virStorageBackendFileSystemNetFindPoolSources(const char *srcSpec,
     size_t i;
     int retNFS = -1;
     int retGluster = 0;
-    VIR_AUTOPTR(virStoragePoolSource) source = NULL;
+    g_autoptr(virStoragePoolSource) source = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -299,7 +299,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int rc;
     g_autofree char *src = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (virStorageBackendFileSystemIsValid(pool) < 0)
         return -1;
@@ -365,7 +365,7 @@ virStorageBackendFileSystemStop(virStoragePoolObjPtr pool)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int rc;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (virStorageBackendFileSystemIsValid(pool) < 0)
         return -1;
@@ -413,7 +413,7 @@ static int
 virStorageBackendExecuteMKFS(const char *device,
                              const char *format)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(MKFS, "-t", format, NULL);
 
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 7fb4e1ef8e..07aca084d8 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -238,7 +238,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     glfs_fd_t *fd = NULL;
     ssize_t len;
     int backingFormat;
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
     VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL;
     g_autofree char *header = NULL;
 
@@ -478,7 +478,7 @@ virStorageBackendGlusterFindPoolSources(const char *srcSpec,
     char *ret = NULL;
     int rc;
     size_t i;
-    VIR_AUTOPTR(virStoragePoolSource) source = NULL;
+    g_autoptr(virStoragePoolSource) source = NULL;
 
     virCheckFlags(0, NULL);
 
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index eba9c4790f..b11d1d6622 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -161,7 +161,7 @@ virStorageBackendISCSIFindPoolSources(const char *srcSpec,
         .sources = NULL
     };
     g_autofree char *portal = NULL;
-    VIR_AUTOPTR(virStoragePoolSource) source = NULL;
+    g_autoptr(virStoragePoolSource) source = NULL;
 
     virCheckFlags(0, NULL);
 
diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c
index 9d8f7d9ed2..78e347c9b0 100644
--- a/src/storage/storage_backend_iscsi_direct.c
+++ b/src/storage/storage_backend_iscsi_direct.c
@@ -307,7 +307,7 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool,
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     uint32_t block_size;
     uint64_t nb_block;
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
 
     if (virISCSIDirectTestUnitReady(iscsi, lun) < 0)
         return -1;
@@ -491,7 +491,7 @@ virStorageBackendISCSIDirectFindPoolSources(const char *srcSpec,
         .sources = NULL
     };
     g_autofree char *portal = NULL;
-    VIR_AUTOPTR(virStoragePoolSource) source = NULL;
+    g_autoptr(virStoragePoolSource) source = NULL;
 
     virCheckFlags(0, NULL);
 
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 784e238ba7..04f3decdf3 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -49,7 +49,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool,
                                   bool on)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int ret;
 
     cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, on);
@@ -71,7 +71,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool,
 static void
 virStorageBackendLogicalRemoveDevice(const char *path)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(PVREMOVE, path, NULL);
     if (virCommandRun(cmd, NULL) < 0)
@@ -89,7 +89,7 @@ virStorageBackendLogicalRemoveDevice(const char *path)
 static int
 virStorageBackendLogicalInitializeDevice(const char *path)
 {
-    VIR_AUTOPTR(virCommand) pvcmd = NULL;
+    g_autoptr(virCommand) pvcmd = NULL;
 
     /*
      * LVM requires that the first sector is blanked if using
@@ -421,7 +421,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
         .pool = pool,
         .vol = vol,
     };
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(LVS,
                                "--separator", "#",
@@ -520,7 +520,7 @@ virStorageBackendLogicalGetPoolSources(virStoragePoolSourceListPtr sourceList)
     int vars[] = {
         2
     };
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     /*
      * NOTE: ignoring errors here; this is just to "touch" any logical volumes
@@ -702,7 +702,7 @@ virStorageBackendLogicalBuildPool(virStoragePoolObjPtr pool,
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int ret = -1;
     size_t i = 0;
-    VIR_AUTOPTR(virCommand) vgcmd = NULL;
+    g_autoptr(virCommand) vgcmd = NULL;
 
     virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
                   VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, ret);
@@ -765,7 +765,7 @@ virStorageBackendLogicalRefreshPool(virStoragePoolObjPtr pool)
         2
     };
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virWaitForDevices();
 
@@ -817,7 +817,7 @@ virStorageBackendLogicalDeletePool(virStoragePoolObjPtr pool,
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     size_t i;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virCheckFlags(0, -1);
 
@@ -841,8 +841,8 @@ virStorageBackendLogicalDeleteVol(virStoragePoolObjPtr pool G_GNUC_UNUSED,
                                   virStorageVolDefPtr vol,
                                   unsigned int flags)
 {
-    VIR_AUTOPTR(virCommand) lvchange_cmd = NULL;
-    VIR_AUTOPTR(virCommand) lvremove_cmd = NULL;
+    g_autoptr(virCommand) lvchange_cmd = NULL;
+    g_autoptr(virCommand) lvremove_cmd = NULL;
 
     virCheckFlags(0, -1);
 
@@ -869,7 +869,7 @@ virStorageBackendLogicalLVCreate(virStorageVolDefPtr vol,
                                  virStoragePoolDefPtr def)
 {
     unsigned long long capacity = vol->target.capacity;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (vol->target.encryption &&
         vol->target.encryption->format != VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index cbd544b038..2d9ebf3ba3 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -46,7 +46,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
                              const char *dev)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
 
     if (VIR_ALLOC(vol) < 0)
         return -1;
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 8b62969219..485cabb219 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -720,7 +720,7 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
         goto cleanup;
 
     for (i = 0; names[i] != NULL; i++) {
-        VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+        g_autoptr(virStorageVolDef) vol = NULL;
 
         if (VIR_ALLOC(vol) < 0)
             goto cleanup;
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 25183d0d2f..f03c5c7e05 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -110,7 +110,7 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
 static int
 virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr pool, const char *diskInfo)
 {
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
 
     if (diskInfo == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -140,7 +140,7 @@ virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool)
     g_autofree char *output = NULL;
     VIR_AUTOSTRINGLIST lines = NULL;
     VIR_AUTOSTRINGLIST cells = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", "-r", NULL);
     virStorageBackendSheepdogAddHostArg(cmd, pool);
@@ -177,7 +177,7 @@ static int
 virStorageBackendSheepdogRefreshPool(virStoragePoolObjPtr pool)
 {
     g_autofree char *output = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(SHEEPDOGCLI, "node", "info", "-r", NULL);
     virStorageBackendSheepdogAddHostArg(cmd, pool);
@@ -198,7 +198,7 @@ virStorageBackendSheepdogDeleteVol(virStoragePoolObjPtr pool,
                                    virStorageVolDefPtr vol,
                                    unsigned int flags)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virCheckFlags(0, -1);
 
@@ -241,7 +241,7 @@ virStorageBackendSheepdogBuildVol(virStoragePoolObjPtr pool,
                                   virStorageVolDefPtr vol,
                                   unsigned int flags)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virCheckFlags(0, -1);
 
@@ -325,7 +325,7 @@ virStorageBackendSheepdogRefreshVol(virStoragePoolObjPtr pool,
 {
     char *output = NULL;
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", vol->name, "-r", NULL);
     virStorageBackendSheepdogAddHostArg(cmd, pool);
@@ -355,7 +355,7 @@ virStorageBackendSheepdogResizeVol(virStoragePoolObjPtr pool,
                                    unsigned long long capacity,
                                    unsigned int flags)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virCheckFlags(0, -1);
 
diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_backend_vstorage.c
index ee944c18e1..ef51f254a8 100644
--- a/src/storage/storage_backend_vstorage.c
+++ b/src/storage/storage_backend_vstorage.c
@@ -41,7 +41,7 @@ virStorageBackendVzPoolStart(virStoragePoolObjPtr pool)
     g_autofree char *grp_name = NULL;
     g_autofree char *usr_name = NULL;
     g_autofree char *mode = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int ret;
 
     /* Check the permissions */
@@ -122,7 +122,7 @@ virStorageBackendVzPoolStop(virStoragePoolObjPtr pool)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int rc;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     /* Short-circuit if already unmounted */
     if ((rc = virStorageBackendVzIsMounted(pool)) != 1)
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 5a417119f3..6bfff9f5dd 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -53,7 +53,7 @@ virStorageBackendZFSVolModeNeeded(void)
 {
     int ret = -1, exit_code = -1;
     g_autofree char *error = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     /* 'zfs get' without arguments prints out
      * usage information to stderr, including
@@ -178,7 +178,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     size_t i;
     VIR_AUTOSTRINGLIST lines = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *volumes_list = NULL;
 
     /**
@@ -223,7 +223,7 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool G_GNUC_UNUSED)
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     char *zpool_props = NULL;
     size_t i;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     VIR_AUTOSTRINGLIST lines = NULL;
     VIR_AUTOSTRINGLIST tokens = NULL;
 
@@ -297,7 +297,7 @@ virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool,
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int ret = -1;
     int volmode_needed = -1;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (vol->target.encryption != NULL) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -366,7 +366,7 @@ virStorageBackendZFSDeleteVol(virStoragePoolObjPtr pool,
                               unsigned int flags)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virCommand) destroy_cmd = NULL;
+    g_autoptr(virCommand) destroy_cmd = NULL;
 
     virCheckFlags(0, -1);
 
@@ -384,7 +384,7 @@ virStorageBackendZFSBuildPool(virStoragePoolObjPtr pool,
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     size_t i;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int ret = -1;
 
     virCheckFlags(0, -1);
@@ -413,7 +413,7 @@ virStorageBackendZFSDeletePool(virStoragePoolObjPtr pool,
                                unsigned int flags)
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     virCheckFlags(0, -1);
 
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index af3b04fbf4..d878329a45 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -738,7 +738,7 @@ storagePoolCreateXML(virConnectPtr conn,
     virStorageBackendPtr backend;
     virObjectEventPtr event = NULL;
     unsigned int build_flags = 0;
-    VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
+    g_autoptr(virStoragePoolDef) newDef = NULL;
     g_autofree char *stateFile = NULL;
 
     virCheckFlags(VIR_STORAGE_POOL_CREATE_WITH_BUILD |
@@ -825,7 +825,7 @@ storagePoolDefineXML(virConnectPtr conn,
     virStoragePoolDefPtr def;
     virStoragePoolPtr pool = NULL;
     virObjectEventPtr event = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
+    g_autoptr(virStoragePoolDef) newDef = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -1908,7 +1908,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
     virStoragePoolDefPtr def;
     virStorageBackendPtr backend;
     virStorageVolPtr vol = NULL, newvol = NULL;
-    VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
+    g_autoptr(virStorageVolDef) voldef = NULL;
 
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
 
@@ -2047,7 +2047,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
     virStorageVolPtr newvol = NULL;
     virStorageVolPtr vol = NULL;
     int buildret;
-    VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
+    g_autoptr(virStorageVolDef) voldef = NULL;
 
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
                   VIR_STORAGE_VOL_CREATE_REFLINK,
@@ -2295,7 +2295,7 @@ virStorageVolPoolRefreshDataFree(void *opaque)
 static int
 virStorageBackendPloopRestoreDesc(char *path)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *refresh_tool = NULL;
     g_autofree char *desc = NULL;
 
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 6a99387597..c51494045d 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -598,7 +598,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
 {
     int ret = -1;
     bool created = false;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *create_tool = NULL;
 
     virCheckFlags(0, -1);
@@ -667,7 +667,7 @@ static int
 storagePloopResize(virStorageVolDefPtr vol,
                    unsigned long long capacity)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *resize_tool = NULL;
 
     resize_tool = virFindFileInPath("ploop");
@@ -1285,7 +1285,7 @@ storageBackendDoCreateQemuImg(virStoragePoolObjPtr pool,
                               const char *inputSecretPath,
                               virStorageVolEncryptConvertStep convertStep)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol,
                                                    flags, create_tool,
@@ -2261,7 +2261,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool,
     int ret = -1;
     const char *type;
     virStorageEncryptionPtr enc = vol->target.encryption;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *img_tool = NULL;
     g_autofree char *secretPath = NULL;
     g_autofree char *secretAlias = NULL;
@@ -2381,7 +2381,7 @@ static int
 storageBackendPloopHasSnapshots(char *path)
 {
     char *snap_tool = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *output = NULL;
 
     snap_tool = virFindFileInPath("ploop");
@@ -2595,7 +2595,7 @@ storageBackendVolWipeLocalFile(const char *path,
     const char *alg_char = NULL;
     struct stat st;
     VIR_AUTOCLOSE fd = -1;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     fd = open(path, O_RDWR);
     if (fd == -1) {
@@ -2672,7 +2672,7 @@ static int
 storageBackendVolWipePloop(virStorageVolDefPtr vol,
                            unsigned int algorithm)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *target_path = NULL;
     g_autofree char *disk_desc = NULL;
     g_autofree char *create_tool = NULL;
@@ -2913,7 +2913,7 @@ virStorageBackendFindGlusterPoolSources(const char *host,
                                         bool report)
 {
     int rc;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *glusterpath = NULL;
     g_autofree char *outbuf = NULL;
 
@@ -3181,7 +3181,7 @@ virStorageBackendPARTEDFindLabel(const char *device,
     };
     char *start, *end;
     int ret = VIR_STORAGE_PARTED_ERROR;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *output = NULL;
     g_autofree char *error = NULL;
 
@@ -3527,7 +3527,7 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
     struct stat statbuf;
     int direrr;
     int ret = -1;
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
     VIR_AUTOCLOSE fd = -1;
     VIR_AUTOUNREF(virStorageSourcePtr) target = NULL;
 
@@ -3666,7 +3666,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     int retval = -1;
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
     g_autofree char *devpath = NULL;
 
     /* Check if the pool is using a stable target path. The call to
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 237bcb9c7e..8c77ec6e0d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1075,7 +1075,7 @@ testOpenVolumesForPool(const char *file,
     int num;
     g_autofree char *vol_xpath = NULL;
     g_autofree xmlNodePtr *nodes = NULL;
-    VIR_AUTOPTR(virStorageVolDef) volDef = NULL;
+    g_autoptr(virStorageVolDef) volDef = NULL;
 
     /* Find storage volumes */
     if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
@@ -6347,7 +6347,7 @@ testConnectFindStoragePoolSources(virConnectPtr conn G_GNUC_UNUSED,
 {
     int pool_type;
     char *ret = NULL;
-    VIR_AUTOPTR(virStoragePoolSource) source = NULL;
+    g_autoptr(virStoragePoolSource) source = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -6428,7 +6428,7 @@ testStoragePoolCreateXML(virConnectPtr conn,
     virStoragePoolDefPtr def;
     virStoragePoolPtr pool = NULL;
     virObjectEventPtr event = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
+    g_autoptr(virStoragePoolDef) newDef = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -6491,7 +6491,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
     virStoragePoolDefPtr def;
     virStoragePoolPtr pool = NULL;
     virObjectEventPtr event = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
+    g_autoptr(virStoragePoolDef) newDef = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -6994,7 +6994,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
     virStoragePoolObjPtr obj;
     virStoragePoolDefPtr def;
     virStorageVolPtr ret = NULL;
-    VIR_AUTOPTR(virStorageVolDef) privvol = NULL;
+    g_autoptr(virStorageVolDef) privvol = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -7054,7 +7054,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
     virStoragePoolDefPtr def;
     virStorageVolDefPtr origvol = NULL;
     virStorageVolPtr ret = NULL;
-    VIR_AUTOPTR(virStorageVolDef) privvol = NULL;
+    g_autoptr(virStorageVolDef) privvol = NULL;
 
     virCheckFlags(0, NULL);
 
diff --git a/src/util/virauth.c b/src/util/virauth.c
index 004b2f3a71..979cb5773e 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -111,7 +111,7 @@ virAuthGetCredential(const char *servicename,
                      const char *path,
                      char **value)
 {
-    VIR_AUTOPTR(virAuthConfig) config = NULL;
+    g_autoptr(virAuthConfig) config = NULL;
     const char *tmp;
 
     *value = NULL;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index ed8f06acc7..5ac489004d 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -1199,7 +1199,7 @@ char *
 virBitmapDataFormat(const void *data,
                     int len)
 {
-    VIR_AUTOPTR(virBitmap) map = NULL;
+    g_autoptr(virBitmap) map = NULL;
 
     if (!(map = virBitmapNewData(data, len)))
         return NULL;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index a62a513b0c..93b3dd218f 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -488,7 +488,7 @@ virCommandMassClose(virCommandPtr cmd,
                     int childout,
                     int childerr)
 {
-    VIR_AUTOPTR(virBitmap) fds = NULL;
+    g_autoptr(virBitmap) fds = NULL;
     int openmax = sysconf(_SC_OPEN_MAX);
     int fd = -1;
 
@@ -839,7 +839,7 @@ virExec(virCommandPtr cmd)
 int
 virRun(const char *const*argv, int *status)
 {
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgs(argv);
+    g_autoptr(virCommand) cmd = virCommandNewArgs(argv);
 
     return virCommandRun(cmd, status);
 }
@@ -3020,7 +3020,7 @@ virCommandFree(virCommandPtr cmd)
  * This requests asynchronous string IO on @cmd. It is useful in
  * combination with virCommandRunAsync():
  *
- *      VIR_AUTOPTR(virCommand) cmd = virCommandNew*(...);
+ *      g_autoptr(virCommand) cmd = virCommandNew*(...);
  *      g_autofree char *buf = NULL;
  *
  *      ...
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 457235d195..e0b6398823 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -910,7 +910,7 @@ int virFileNBDDeviceAssociate(const char *file,
 {
     g_autofree char *nbddev = NULL;
     g_autofree char *qemunbd = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     const char *fmtstr = NULL;
 
     if (!virFileNBDLoadDriver())
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index a38516a1bb..cc1e2b34ea 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -113,7 +113,7 @@ virFirewallCheckUpdateLock(bool *lockflag,
                            const char *const*args)
 {
     int status; /* Ignore failed commands without logging them */
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgs(args);
+    g_autoptr(virCommand) cmd = virCommandNewArgs(args);
     if (virCommandRun(cmd, &status) < 0 || status) {
         VIR_INFO("locking not supported by %s", args[0]);
     } else {
@@ -666,7 +666,7 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule,
 {
     size_t i;
     const char *bin = virFirewallLayerCommandTypeToString(rule->layer);
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int status;
     g_autofree char *error = NULL;
 
@@ -838,7 +838,7 @@ virFirewallApply(virFirewallPtr firewall)
         if (virFirewallApplyGroup(firewall, i) < 0) {
             VIR_DEBUG("Rolling back groups up to %zu for %p", i, firewall);
             size_t first = i;
-            VIR_AUTOPTR(virError) saved_error = virSaveLastError();
+            g_autoptr(virError) saved_error = virSaveLastError();
 
             /*
              * Look at any inheritance markers to figure out
diff --git a/src/util/virhook.c b/src/util/virhook.c
index 19207c2b25..a687629fc2 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -241,7 +241,7 @@ virHookCall(int driver,
 {
     int ret;
     g_autofree char *path = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     const char *drvstr;
     const char *opstr;
     const char *subopstr;
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 984f6bb290..dbc235d6f1 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -229,7 +229,7 @@ static int
 virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
                            virPCIDevicePtr *pci)
 {
-    VIR_AUTOPTR(virPCIDevice) actual = NULL;
+    g_autoptr(virPCIDevice) actual = NULL;
     const virDomainHostdevSubsysPCI *pcisrc = &hostdev->source.subsys.u.pci;
 
     *pci = NULL;
@@ -272,7 +272,7 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
 
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
-        VIR_AUTOPTR(virPCIDevice) pci = NULL;
+        g_autoptr(virPCIDevice) pci = NULL;
 
         if (virHostdevGetPCIHostDevice(hostdev, &pci) < 0)
             return NULL;
@@ -537,7 +537,7 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev,
     g_autofree char *linkdev = NULL;
     g_autofree virMacAddrPtr MAC = NULL;
     g_autofree virMacAddrPtr adminMAC = NULL;
-    VIR_AUTOPTR(virNetDevVlan) vlan = NULL;
+    g_autoptr(virNetDevVlan) vlan = NULL;
     virNetDevVPortProfilePtr virtPort;
     int vf = -1;
     bool port_profile_associate = false;
@@ -1111,7 +1111,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
 
     for (i = 0; i < nhostdevs; i++) {
         const virDomainHostdevDef *hostdev = hostdevs[i];
-        VIR_AUTOPTR(virPCIDevice) actual = NULL;
+        g_autoptr(virPCIDevice) actual = NULL;
 
         if (virHostdevGetPCIHostDevice(hostdev, &actual) < 0)
             goto cleanup;
@@ -1156,7 +1156,7 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
     virObjectLock(mgr->activeUSBHostdevs);
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevSubsysUSBPtr usbsrc;
-        VIR_AUTOPTR(virUSBDevice) usb = NULL;
+        g_autoptr(virUSBDevice) usb = NULL;
         hostdev = hostdevs[i];
         usbsrc = &hostdev->source.subsys.u.usb;
 
@@ -1191,7 +1191,7 @@ virHostdevUpdateActiveSCSIHostDevices(virHostdevManagerPtr mgr,
                                       const char *dom_name)
 {
     virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
-    VIR_AUTOPTR(virSCSIDevice) scsi = NULL;
+    g_autoptr(virSCSIDevice) scsi = NULL;
     virSCSIDevicePtr tmp = NULL;
 
     if (!(scsi = virSCSIDeviceNew(NULL,
@@ -1260,7 +1260,7 @@ virHostdevUpdateActiveMediatedDevices(virHostdevManagerPtr mgr,
 {
     int ret = -1;
     size_t i;
-    VIR_AUTOPTR(virMediatedDevice) mdev = NULL;
+    g_autoptr(virMediatedDevice) mdev = NULL;
 
     if (nhostdevs == 0)
         return 0;
@@ -1462,7 +1462,7 @@ virHostdevPrepareUSBDevices(virHostdevManagerPtr mgr,
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         bool required = true;
-        VIR_AUTOPTR(virUSBDevice) usb = NULL;
+        g_autoptr(virUSBDevice) usb = NULL;
 
         if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
             continue;
@@ -1507,7 +1507,7 @@ virHostdevPrepareSCSIHostDevices(virDomainHostdevDefPtr hostdev,
                                  virSCSIDeviceListPtr list)
 {
     virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
-    VIR_AUTOPTR(virSCSIDevice) scsi = NULL;
+    g_autoptr(virSCSIDevice) scsi = NULL;
 
     if (hostdev->managed) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -1651,7 +1651,7 @@ virHostdevPrepareSCSIVHostDevices(virHostdevManagerPtr mgr,
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         virDomainHostdevSubsysSCSIVHostPtr hostsrc = &hostdev->source.subsys.u.scsi_host;
-        VIR_AUTOPTR(virSCSIVHostDevice) host = NULL;
+        g_autoptr(virSCSIVHostDevice) host = NULL;
 
         if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
             hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST)
@@ -1734,7 +1734,7 @@ virHostdevPrepareMediatedDevices(virHostdevManagerPtr mgr,
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         virDomainHostdevSubsysMediatedDevPtr src = &hostdev->source.subsys.u.mdev;
-        VIR_AUTOPTR(virMediatedDevice) mdev = NULL;
+        g_autoptr(virMediatedDevice) mdev = NULL;
 
         if (!virHostdevIsMdevDevice(hostdev))
             continue;
@@ -1782,7 +1782,7 @@ virHostdevReAttachUSBDevices(virHostdevManagerPtr mgr,
     for (i = 0; i < nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         virDomainHostdevSubsysUSBPtr usbsrc = &hostdev->source.subsys.u.usb;
-        VIR_AUTOPTR(virUSBDevice) usb = NULL;
+        g_autoptr(virUSBDevice) usb = NULL;
         virUSBDevicePtr tmp;
         const char *usedby_drvname;
         const char *usedby_domname;
@@ -1834,7 +1834,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr mgr,
                                   const char *dom_name)
 {
     virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
-    VIR_AUTOPTR(virSCSIDevice) scsi = NULL;
+    g_autoptr(virSCSIDevice) scsi = NULL;
     virSCSIDevicePtr tmp;
 
     if (!(scsi = virSCSIDeviceNew(NULL,
@@ -1909,7 +1909,7 @@ virHostdevReAttachSCSIVHostDevices(virHostdevManagerPtr mgr,
 
     virObjectLock(mgr->activeSCSIVHostHostdevs);
     for (i = 0; i < nhostdevs; i++) {
-        VIR_AUTOPTR(virSCSIVHostDevice) host = NULL;
+        g_autoptr(virSCSIVHostDevice) host = NULL;
         virSCSIVHostDevicePtr tmp;
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         virDomainHostdevSubsysSCSIVHostPtr hostsrc = &hostdev->source.subsys.u.scsi_host;
@@ -1978,7 +1978,7 @@ virHostdevReAttachMediatedDevices(virHostdevManagerPtr mgr,
 
     virObjectLock(mgr->activeMediatedHostdevs);
     for (i = 0; i < nhostdevs; i++) {
-        VIR_AUTOPTR(virMediatedDevice) mdev = NULL;
+        g_autoptr(virMediatedDevice) mdev = NULL;
         virMediatedDevicePtr tmp;
         virDomainHostdevSubsysMediatedDevPtr mdevsrc;
         virDomainHostdevDefPtr hostdev = hostdevs[i];
diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index f2140b47de..50e8e7afc5 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -90,7 +90,7 @@ virISCSIGetSession(const char *devpath,
     int exitstatus = 0;
     g_autofree char *error = NULL;
 
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM, "--mode",
+    g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM, "--mode",
                                                        "session", NULL);
     virCommandSetErrorBuffer(cmd, &error);
 
@@ -125,7 +125,7 @@ virStorageBackendIQNFound(const char *initiatoriqn,
     g_autofree char *outbuf = NULL;
     g_autofree char *iface = NULL;
     g_autofree char *iqn = NULL;
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM,
+    g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
                                                        "--mode", "iface", NULL);
 
     *ifacename = NULL;
@@ -210,7 +210,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
     int exitstatus = -1;
     g_autofree char *iface_name = NULL;
     g_autofree char *temp_ifacename = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (virAsprintf(&temp_ifacename,
                     "libvirt-iface-%08llx",
@@ -285,7 +285,7 @@ virISCSIConnection(const char *portal,
         "--targetname", target,
         NULL
     };
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *ifacename = NULL;
 
     cmd = virCommandNewArgs(baseargv);
@@ -349,7 +349,7 @@ virISCSIConnectionLogout(const char *portal,
 int
 virISCSIRescanLUNs(const char *session)
 {
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM,
+    g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
                                                        "--mode", "session",
                                                        "-r", session,
                                                        "-R",
@@ -404,7 +404,7 @@ virISCSIScanTargetsInternal(const char *portal,
     int vars[] = { 2 };
     struct virISCSITargetList list;
     size_t i;
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM,
+    g_autoptr(virCommand) cmd = virCommandNewArgList(ISCSIADM,
                                                        "--mode", "discovery",
                                                        "--type", "sendtargets",
                                                        "--portal", portal,
@@ -519,7 +519,7 @@ int
 virISCSINodeNew(const char *portal,
                 const char *target)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int status;
 
     cmd = virCommandNewArgList(ISCSIADM,
@@ -553,7 +553,7 @@ virISCSINodeUpdate(const char *portal,
                    const char *name,
                    const char *value)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int status;
 
     cmd = virCommandNewArgList(ISCSIADM,
diff --git a/src/util/virjson.c b/src/util/virjson.c
index c876a4a261..c1476bfbbe 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -2050,7 +2050,7 @@ char *
 virJSONStringReformat(const char *jsonstr,
                       bool pretty)
 {
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
 
     if (!(json = virJSONValueFromString(jsonstr)))
         return NULL;
@@ -2144,7 +2144,7 @@ virJSONValueObjectDeflattenWorker(const char *key,
 virJSONValuePtr
 virJSONValueObjectDeflatten(virJSONValuePtr json)
 {
-    VIR_AUTOPTR(virJSONValue) deflattened = NULL;
+    g_autoptr(virJSONValue) deflattened = NULL;
     virJSONValuePtr ret = NULL;
 
     if (!(deflattened = virJSONValueNewObject()))
diff --git a/src/util/virkmod.c b/src/util/virkmod.c
index 56758750ae..2f6ab90ded 100644
--- a/src/util/virkmod.c
+++ b/src/util/virkmod.c
@@ -28,7 +28,7 @@
 static int
 doModprobe(const char *opts, const char *module, char **outbuf, char **errbuf)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNew(MODPROBE);
     if (opts)
@@ -49,7 +49,7 @@ doModprobe(const char *opts, const char *module, char **outbuf, char **errbuf)
 static int
 doRmmod(const char *module, char **errbuf)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(RMMOD, module, NULL);
     virCommandSetErrorBuffer(cmd, errbuf);
diff --git a/src/util/virlease.c b/src/util/virlease.c
index 79fdd0699d..a49bd5b9fb 100644
--- a/src/util/virlease.c
+++ b/src/util/virlease.c
@@ -49,7 +49,7 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
                             char **server_duid)
 {
     g_autofree char *lease_entries = NULL;
-    VIR_AUTOPTR(virJSONValue) leases_array = NULL;
+    g_autoptr(virJSONValue) leases_array = NULL;
     long long expirytime;
     int custom_lease_file_len = 0;
     virJSONValuePtr lease_tmp = NULL;
@@ -212,7 +212,7 @@ virLeaseNew(virJSONValuePtr *lease_ret,
             const char *iaid,
             const char *server_duid)
 {
-    VIR_AUTOPTR(virJSONValue) lease_new = NULL;
+    g_autoptr(virJSONValue) lease_new = NULL;
     const char *exptime_tmp = getenv("DNSMASQ_LEASE_EXPIRES");
     long long expirytime = 0;
     g_autofree char *exptime = NULL;
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 7260799e5d..31fd961277 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -141,7 +141,7 @@ virMediatedDevicePtr
 virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model)
 {
     virMediatedDevicePtr ret = NULL;
-    VIR_AUTOPTR(virMediatedDevice) dev = NULL;
+    g_autoptr(virMediatedDevice) dev = NULL;
     g_autofree char *sysfspath = NULL;
 
     if (!(sysfspath = virMediatedDeviceGetSysfsPath(uuidstr)))
@@ -495,7 +495,7 @@ int
 virMediatedDeviceTypeReadAttrs(const char *sysfspath,
                                virMediatedDeviceTypePtr *type)
 {
-    VIR_AUTOPTR(virMediatedDeviceType) tmp = NULL;
+    g_autoptr(virMediatedDeviceType) tmp = NULL;
 
 #define MDEV_GET_SYSFS_ATTR(attr, dst, cb, optional) \
     do { \
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index e23061dd4c..d8ae5fbc5f 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2726,7 +2726,7 @@ static int virNetDevGetMcastList(const char *ifname,
     char *buf = NULL;
     char *next = NULL;
     int ret = -1, len;
-    VIR_AUTOPTR(virNetDevMcastEntry) entry = NULL;
+    g_autoptr(virNetDevMcastEntry) entry = NULL;
 
     mcast->entries = NULL;
     mcast->nentries = 0;
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index edaf1e7c34..edf4cc6236 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -952,7 +952,7 @@ virNetDevBridgeFDBAddDel(const virMacAddr *mac, const char *ifname,
     struct nlmsgerr *err;
     unsigned int recvbuflen;
     struct ndmsg ndm = { .ndm_family = PF_BRIDGE, .ndm_state = NUD_NOARP };
-    VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
+    g_autoptr(virNetlinkMsg) nl_msg = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
 
     if (virNetDevGetIndex(ifname, &ndm.ndm_ifindex) < 0)
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index bc31581f77..1bd18ea30a 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -166,8 +166,8 @@ virNetDevIPAddrAdd(const char *ifname,
                    unsigned int prefix)
 {
     unsigned int recvbuflen;
-    VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
-    VIR_AUTOPTR(virSocketAddr) broadcast = NULL;
+    g_autoptr(virNetlinkMsg) nlmsg = NULL;
+    g_autoptr(virSocketAddr) broadcast = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
     g_autofree char *ipStr = NULL;
     g_autofree char *peerStr = NULL;
@@ -239,7 +239,7 @@ virNetDevIPAddrDel(const char *ifname,
                    unsigned int prefix)
 {
     unsigned int recvbuflen;
-    VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
+    g_autoptr(virNetlinkMsg) nlmsg = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
 
     if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_DELADDR, ifname,
@@ -289,7 +289,7 @@ virNetDevIPRouteAdd(const char *ifname,
     int errCode;
     virSocketAddr defaultAddr;
     virSocketAddrPtr actualAddr;
-    VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
+    g_autoptr(virNetlinkMsg) nlmsg = NULL;
     g_autofree char *toStr = NULL;
     g_autofree char *viaStr = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
@@ -431,7 +431,7 @@ virNetDevIPWaitDadFinish(virSocketAddrPtr *addrs, size_t count)
     unsigned int recvbuflen;
     bool dad = true;
     time_t max_time = time(NULL) + VIR_DAD_WAIT_TIMEOUT;
-    VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
+    g_autoptr(virNetlinkMsg) nlmsg = NULL;
 
     if (!(nlmsg = nlmsg_alloc_simple(RTM_GETADDR,
                                      NLM_F_REQUEST | NLM_F_DUMP))) {
@@ -620,7 +620,7 @@ virNetDevIPCheckIPv6Forwarding(void)
         .devices = NULL,
         .ndevices = 0
     };
-    VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
+    g_autoptr(virNetlinkMsg) nlmsg = NULL;
 
 
     /* Prepare the request message */
@@ -688,7 +688,7 @@ virNetDevIPAddrAdd(const char *ifname,
                    unsigned int prefix)
 {
     virSocketAddr broadcast;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *addrstr = NULL;
     g_autofree char *bcaststr = NULL;
     g_autofree char *peerstr = NULL;
@@ -743,7 +743,7 @@ virNetDevIPAddrDel(const char *ifname,
                    virSocketAddr *addr,
                    unsigned int prefix)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *addrstr = NULL;
 
     if (!(addrstr = virSocketAddrFormat(addr)))
@@ -778,7 +778,7 @@ virNetDevIPRouteAdd(const char *ifname,
                     virSocketAddrPtr gateway,
                     unsigned int metric)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *addrstr = NULL;
     g_autofree char *gatewaystr = NULL;
 
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 0e02824acc..4c388b6c55 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -1117,9 +1117,9 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
     }
 
     if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
-        VIR_AUTOPTR(virMacAddr) MAC = NULL;
-        VIR_AUTOPTR(virMacAddr) adminMAC = NULL;
-        VIR_AUTOPTR(virNetDevVlan) vlan = NULL;
+        g_autoptr(virMacAddr) MAC = NULL;
+        g_autoptr(virMacAddr) adminMAC = NULL;
+        g_autoptr(virNetDevVlan) vlan = NULL;
 
         if ((virNetDevReadNetConfig(linkdev, -1, stateDir,
                                     &adminMAC, &vlan, &MAC) == 0) &&
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index a3c0da85a0..6e13c0f684 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -141,7 +141,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
     char macaddrstr[VIR_MAC_STRING_BUFLEN];
     char ifuuidstr[VIR_UUID_STRING_BUFLEN];
     char vmuuidstr[VIR_UUID_STRING_BUFLEN];
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *attachedmac_ex_id = NULL;
     g_autofree char *ifaceid_ex_id = NULL;
     g_autofree char *profile_ex_id = NULL;
@@ -213,7 +213,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
  */
 int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char *ifname)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNew(OVSVSCTL);
     virNetDevOpenvswitchAddTimeout(cmd);
@@ -240,7 +240,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname G_GNUC_UNUSED, const char
 int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
 {
     size_t len;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNew(OVSVSCTL);
     virNetDevOpenvswitchAddTimeout(cmd);
@@ -276,7 +276,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
  */
 int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!migrate) {
         VIR_DEBUG("No OVS port data for interface %s", ifname);
@@ -315,7 +315,7 @@ int
 virNetDevOpenvswitchInterfaceParseStats(const char *json,
                                         virDomainInterfaceStatsPtr stats)
 {
-    VIR_AUTOPTR(virJSONValue) jsonStats = NULL;
+    g_autoptr(virJSONValue) jsonStats = NULL;
     virJSONValuePtr jsonMap = NULL;
     size_t i;
 
@@ -386,7 +386,7 @@ int
 virNetDevOpenvswitchInterfaceStats(const char *ifname,
                                    virDomainInterfaceStatsPtr stats)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *output = NULL;
 
     cmd = virCommandNew(OVSVSCTL);
@@ -504,7 +504,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
     size_t ntokens = 0;
     int status;
     int ret = -1;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     /* Openvswitch vhostuser path are hardcoded to
      * /<runstatedir>/openvswitch/<ifname>
@@ -550,7 +550,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
 int virNetDevOpenvswitchUpdateVlan(const char *ifname,
                                    virNetDevVlanPtr virtVlan)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNew(OVSVSCTL);
     virNetDevOpenvswitchAddTimeout(cmd);
diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index 36a1e89c9e..4e10cdf12b 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -120,7 +120,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
     for (i = 0; i < MAX_VETH_RETRIES; i++) {
         g_autofree char *veth1auto = NULL;
         g_autofree char *veth2auto = NULL;
-        VIR_AUTOPTR(virCommand) cmd = NULL;
+        g_autoptr(virCommand) cmd = NULL;
 
         int status;
         if (!*veth1) {
@@ -195,7 +195,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
 int virNetDevVethDelete(const char *veth)
 {
     int status;
-    VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList("ip", "link",
+    g_autoptr(virCommand) cmd = virCommandNewArgList("ip", "link",
                                                        "del", veth, NULL);
 
     if (virCommandRun(cmd, &status) < 0)
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 34c3f28087..90049b58a1 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -297,7 +297,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
     };
     struct pollfd fds[1];
     g_autofree struct nlmsghdr *temp_resp = NULL;
-    VIR_AUTOPTR(virNetlinkHandle) nlhandle = NULL;
+    g_autoptr(virNetlinkHandle) nlhandle = NULL;
     int len = 0;
 
     memset(fds, 0, sizeof(fds));
@@ -338,7 +338,7 @@ virNetlinkDumpCommand(struct nl_msg *nl_msg,
             .nl_pid    = dst_pid,
             .nl_groups = 0,
     };
-    VIR_AUTOPTR(virNetlinkHandle) nlhandle = NULL;
+    g_autoptr(virNetlinkHandle) nlhandle = NULL;
 
     if (!(nlhandle = virNetlinkSendRequest(nl_msg, src_pid, nladdr,
                                            protocol, groups)))
@@ -396,7 +396,7 @@ virNetlinkDumpLink(const char *ifname, int ifindex,
         .ifi_index  = ifindex
     };
     unsigned int recvbuflen;
-    VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
+    g_autoptr(virNetlinkMsg) nl_msg = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
 
     if (ifname && ifindex <= 0 && virNetDevGetIndex(ifname, &ifindex) < 0)
@@ -507,7 +507,7 @@ virNetlinkNewLink(const char *ifname,
     struct nlattr *infodata = NULL;
     unsigned int buflen;
     struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
-    VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
+    g_autoptr(virNetlinkMsg) nl_msg = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
 
     *error = 0;
@@ -613,7 +613,7 @@ virNetlinkDelLink(const char *ifname, virNetlinkDelLinkFallback fallback)
     struct nlmsgerr *err;
     struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
     unsigned int recvbuflen;
-    VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
+    g_autoptr(virNetlinkMsg) nl_msg = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
 
     nl_msg = nlmsg_alloc_simple(RTM_DELLINK,
@@ -697,7 +697,7 @@ virNetlinkGetNeighbor(void **nlData, uint32_t src_pid, uint32_t dst_pid)
         .ndm_family = AF_UNSPEC,
     };
     unsigned int recvbuflen;
-    VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
+    g_autoptr(virNetlinkMsg) nl_msg = NULL;
     g_autofree struct nlmsghdr *resp = NULL;
 
     nl_msg = nlmsg_alloc_simple(RTM_GETNEIGH, NLM_F_DUMP | NLM_F_REQUEST);
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index c58d429fdb..f81ea1ce02 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -239,7 +239,7 @@ int virNodeSuspend(unsigned int target,
 static int
 virNodeSuspendSupportsTargetPMUtils(unsigned int target, bool *supported)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *binary = NULL;
     int status;
 
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 37a5fc894b..6f3f0420d2 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -57,7 +57,7 @@ char *
 virNumaGetAutoPlacementAdvice(unsigned short vcpus,
                               unsigned long long balloon)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     char *output = NULL;
 
     cmd = virCommandNewArgList(NUMAD, "-w", NULL);
@@ -259,7 +259,7 @@ virNumaGetNodeCPUs(int node,
     size_t i;
     g_autofree unsigned long *mask = NULL;
     g_autofree unsigned long *allonesmask = NULL;
-    VIR_AUTOPTR(virBitmap) cpumap = NULL;
+    g_autoptr(virBitmap) cpumap = NULL;
 
     *cpus = NULL;
 
@@ -312,7 +312,7 @@ int
 virNumaNodesetToCPUset(virBitmapPtr nodeset,
                        virBitmapPtr *cpuset)
 {
-    VIR_AUTOPTR(virBitmap) allNodesCPUs = NULL;
+    g_autoptr(virBitmap) allNodesCPUs = NULL;
     size_t nodesetSize;
     size_t i;
 
@@ -325,7 +325,7 @@ virNumaNodesetToCPUset(virBitmapPtr nodeset,
     nodesetSize = virBitmapSize(nodeset);
 
     for (i = 0; i < nodesetSize; i++) {
-        VIR_AUTOPTR(virBitmap) nodeCPUs = NULL;
+        g_autoptr(virBitmap) nodeCPUs = NULL;
 
         if (!virBitmapIsBitSet(nodeset, i))
             continue;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index ed053ed9f5..fa1c67b4cb 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -460,7 +460,7 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate,
 
     while ((ret = virDirRead(dir, &entry, PCI_SYSFS "devices")) > 0) {
         unsigned int domain, bus, slot, function;
-        VIR_AUTOPTR(virPCIDevice) check = NULL;
+        g_autoptr(virPCIDevice) check = NULL;
         char *tmp;
 
         /* expected format: <domain>:<bus>:<slot>.<function> */
@@ -782,8 +782,8 @@ virPCIDeviceTrySecondaryBusReset(virPCIDevicePtr dev,
                                  int cfgfd,
                                  virPCIDeviceList *inactiveDevs)
 {
-    VIR_AUTOPTR(virPCIDevice) parent = NULL;
-    VIR_AUTOPTR(virPCIDevice) conflict = NULL;
+    g_autoptr(virPCIDevice) parent = NULL;
+    g_autoptr(virPCIDevice) conflict = NULL;
     uint8_t config_space[PCI_CONF_LEN];
     uint16_t ctl;
     int ret = -1;
@@ -1370,7 +1370,7 @@ virPCIDeviceNew(unsigned int domain,
                 unsigned int slot,
                 unsigned int function)
 {
-    VIR_AUTOPTR(virPCIDevice) dev = NULL;
+    g_autoptr(virPCIDevice) dev = NULL;
     g_autofree char *vendor = NULL;
     g_autofree char *product = NULL;
 
@@ -1624,7 +1624,7 @@ virPCIDeviceListAdd(virPCIDeviceListPtr list,
 int
 virPCIDeviceListAddCopy(virPCIDeviceListPtr list, virPCIDevicePtr dev)
 {
-    VIR_AUTOPTR(virPCIDevice) copy = virPCIDeviceCopy(dev);
+    g_autoptr(virPCIDevice) copy = virPCIDeviceCopy(dev);
 
     if (!copy)
         return -1;
@@ -1834,7 +1834,7 @@ static int
 virPCIDeviceGetIOMMUGroupAddOne(virPCIDeviceAddressPtr newDevAddr, void *opaque)
 {
     virPCIDeviceListPtr groupList = opaque;
-    VIR_AUTOPTR(virPCIDevice) newDev = NULL;
+    g_autoptr(virPCIDevice) newDev = NULL;
 
     if (!(newDev = virPCIDeviceNew(newDevAddr->domain, newDevAddr->bus,
                                    newDevAddr->slot, newDevAddr->function)))
@@ -2057,7 +2057,7 @@ virPCIDeviceDownstreamLacksACS(virPCIDevicePtr dev)
 static int
 virPCIDeviceIsBehindSwitchLackingACS(virPCIDevicePtr dev)
 {
-    VIR_AUTOPTR(virPCIDevice) parent = NULL;
+    g_autoptr(virPCIDevice) parent = NULL;
 
     if (virPCIDeviceGetParent(dev, &parent) < 0)
         return -1;
@@ -2081,7 +2081,7 @@ virPCIDeviceIsBehindSwitchLackingACS(virPCIDevicePtr dev)
      * parent can be found
      */
     do {
-        VIR_AUTOPTR(virPCIDevice) tmp = NULL;
+        g_autoptr(virPCIDevice) tmp = NULL;
         int acs;
         int ret;
 
@@ -2616,7 +2616,7 @@ virPCIGetMdevTypes(const char *sysfspath,
     DIR *dir = NULL;
     struct dirent *entry;
     g_autofree char *types_path = NULL;
-    VIR_AUTOPTR(virMediatedDeviceType) mdev_type = NULL;
+    g_autoptr(virMediatedDeviceType) mdev_type = NULL;
     virMediatedDeviceTypePtr *mdev_types = NULL;
     size_t ntypes = 0;
     size_t i;
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 2fccfc24ff..162c3c603f 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -56,7 +56,7 @@ virQEMUBuildCommandLineJSONArrayBitmap(const char *key,
 {
     ssize_t pos = -1;
     ssize_t end;
-    VIR_AUTOPTR(virBitmap) bitmap = NULL;
+    g_autoptr(virBitmap) bitmap = NULL;
 
     if (virJSONValueGetArrayAsBitmap(array, &bitmap) < 0)
         return -1;
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 5cae15afd2..425d7adfe9 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -183,7 +183,7 @@ virSCSIDeviceNew(const char *sysfs_prefix,
                  bool readonly,
                  bool shareable)
 {
-    VIR_AUTOPTR(virSCSIDevice) dev = NULL;
+    g_autoptr(virSCSIDevice) dev = NULL;
     virSCSIDevicePtr ret = NULL;
     g_autofree char *sg = NULL;
     g_autofree char *vendor_path = NULL;
@@ -273,7 +273,7 @@ virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev,
                        const char *drvname,
                        const char *domname)
 {
-    VIR_AUTOPTR(virUsedByInfo) copy = NULL;
+    g_autoptr(virUsedByInfo) copy = NULL;
 
     if (VIR_ALLOC(copy) < 0)
         return -1;
@@ -440,7 +440,7 @@ virSCSIDeviceListDel(virSCSIDeviceListPtr list,
                 virSCSIDeviceUsedByInfoFree(dev->used_by[i]);
                 VIR_DELETE_ELEMENT(dev->used_by, i, dev->n_used_by);
             } else {
-                VIR_AUTOPTR(virSCSIDevice) tmp = NULL;
+                g_autoptr(virSCSIDevice) tmp = NULL;
                 tmp = virSCSIDeviceListSteal(list, dev);
             }
             break;
diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index cbd9069146..9ba0d3f2a0 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -250,7 +250,7 @@ virSCSIVHostDeviceGetPath(virSCSIVHostDevicePtr dev)
 virSCSIVHostDevicePtr
 virSCSIVHostDeviceNew(const char *name)
 {
-    VIR_AUTOPTR(virSCSIVHostDevice) dev = NULL;
+    g_autoptr(virSCSIVHostDevice) dev = NULL;
     virSCSIVHostDevicePtr ret = NULL;
 
     if (VIR_ALLOC(dev) < 0)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 5726e62e68..51d80b1cb8 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1369,7 +1369,7 @@ int virStorageFileGetLVMKey(const char *path,
      */
     int status;
     int ret = -1;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList(LVS, "--noheadings",
                                "--unbuffered", "--nosuffix",
@@ -1442,7 +1442,7 @@ virStorageFileGetSCSIKey(const char *path,
                          bool ignoreError G_GNUC_UNUSED)
 {
     int status;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList("/lib/udev/scsi_id",
                                "--replace-whitespace",
@@ -1510,7 +1510,7 @@ virStorageFileGetNPIVKey(const char *path,
     const char *serial;
     const char *port;
     g_autofree char *outbuf = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     cmd = virCommandNewArgList("/lib/udev/scsi_id",
                                "--replace-whitespace",
@@ -1852,7 +1852,7 @@ virStorageAuthDefPtr
 virStorageAuthDefCopy(const virStorageAuthDef *src)
 {
     virStorageAuthDefPtr ret = NULL;
-    VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
+    g_autoptr(virStorageAuthDef) authdef = NULL;
 
     if (VIR_ALLOC(authdef) < 0)
         return NULL;
@@ -1879,7 +1879,7 @@ virStorageAuthDefParse(xmlNodePtr node,
     xmlNodePtr saveNode = ctxt->node;
     virStorageAuthDefPtr ret = NULL;
     xmlNodePtr secretnode = NULL;
-    VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
+    g_autoptr(virStorageAuthDef) authdef = NULL;
     g_autofree char *authtype = NULL;
 
     ctxt->node = node;
@@ -2680,7 +2680,7 @@ static int
 virStorageSourceParseBackingURI(virStorageSourcePtr src,
                                 const char *uristr)
 {
-    VIR_AUTOPTR(virURI) uri = NULL;
+    g_autoptr(virURI) uri = NULL;
     const char *path = NULL;
     VIR_AUTOSTRINGLIST scheme = NULL;
 
@@ -2829,7 +2829,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
 {
     char *p, *e, *next;
     g_autofree char *options = NULL;
-    VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
+    g_autoptr(virStorageAuthDef) authdef = NULL;
 
     /* optionally skip the "rbd:" prefix if provided */
     if (STRPREFIX(rbdstr, "rbd:"))
@@ -3615,7 +3615,7 @@ static int
 virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
                                          virJSONValuePtr json)
 {
-    VIR_AUTOPTR(virJSONValue) deflattened = NULL;
+    g_autoptr(virJSONValue) deflattened = NULL;
     virJSONValuePtr file;
     const char *drvname;
     size_t i;
@@ -3656,7 +3656,7 @@ static int
 virStorageSourceParseBackingJSON(virStorageSourcePtr src,
                                  const char *json)
 {
-    VIR_AUTOPTR(virJSONValue) root = NULL;
+    g_autoptr(virJSONValue) root = NULL;
 
     if (!(root = virJSONValueFromString(json)))
         return -1;
diff --git a/src/util/virtpm.c b/src/util/virtpm.c
index 9d5e36ba7b..c7702c8c25 100644
--- a/src/util/virtpm.c
+++ b/src/util/virtpm.c
@@ -174,7 +174,7 @@ virTPMExecGetCaps(virCommandPtr cmd,
     int exitstatus;
     virBitmapPtr bitmap;
     g_autofree char *outbuf = NULL;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     virJSONValuePtr featureList;
     virJSONValuePtr item;
     size_t idx;
@@ -234,7 +234,7 @@ static virBitmapPtr
 virTPMGetCaps(TypeFromStringFn typeFromStringFn,
                   const char *exec, const char *param1)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!(cmd = virCommandNew(exec)))
         return NULL;
diff --git a/src/util/virusb.c b/src/util/virusb.c
index 9ff16a769c..036a7caf79 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -120,7 +120,7 @@ virUSBDeviceSearch(unsigned int vendor,
     struct dirent *de;
     virUSBDeviceListPtr list = NULL;
     virUSBDeviceListPtr ret = NULL;
-    VIR_AUTOPTR(virUSBDevice) usb = NULL;
+    g_autoptr(virUSBDevice) usb = NULL;
     int direrr;
 
     if (!(list = virUSBDeviceListNew()))
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 742acd8b9b..cf3a397516 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1481,7 +1481,7 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
 
 void virWaitForDevices(void)
 {
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *udev = NULL;
     int exitstatus;
 
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 1ef4a39667..ba5b876ffb 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -414,7 +414,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
     PRUint32 variant = HardDiskVariant_Standard;
     resultCodeUnion resultCode;
     virStorageVolPtr ret = NULL;
-    VIR_AUTOPTR(virStorageVolDef) def = NULL;
+    g_autoptr(virStorageVolDef) def = NULL;
 
     if (!data->vboxObj)
         return ret;
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 6e0467d251..5396353412 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1275,7 +1275,7 @@ virVMXParseConfig(virVMXContext *ctx,
                   const char *vmx)
 {
     bool success = false;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     char *encoding = NULL;
     char *utf8;
     virDomainDefPtr def = NULL;
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index e8c892fdd6..3bf1271b3e 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -46,11 +46,11 @@ static int
 testBackingXMLjsonXML(const void *args)
 {
     const struct testBackingXMLjsonXMLdata *data = args;
-    VIR_AUTOPTR(xmlDoc) xml = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) xml = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOPTR(virJSONValue) backendprops = NULL;
-    VIR_AUTOPTR(virJSONValue) wrapper = NULL;
+    g_autoptr(virJSONValue) backendprops = NULL;
+    g_autoptr(virJSONValue) wrapper = NULL;
     g_autofree char *propsstr = NULL;
     g_autofree char *protocolwrapper = NULL;
     g_autofree char *actualxml = NULL;
@@ -193,7 +193,7 @@ testQemuDiskXMLToProps(const void *opaque)
     virStorageSourcePtr n;
     virJSONValuePtr formatProps = NULL;
     virJSONValuePtr storageProps = NULL;
-    VIR_AUTOPTR(virJSONValue) storageSrcOnlyProps = NULL;
+    g_autoptr(virJSONValue) storageSrcOnlyProps = NULL;
     char *xmlpath = NULL;
     char *xmlstr = NULL;
     int ret = -1;
@@ -363,8 +363,8 @@ testQemuImageCreateLoadDiskXML(const char *name,
 
 {
     virDomainSnapshotDiskDefPtr diskdef = NULL;
-    VIR_AUTOPTR(xmlDoc) doc = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) doc = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     xmlNodePtr node;
     g_autofree char *xmlpath = NULL;
     virStorageSourcePtr ret = NULL;
@@ -398,8 +398,8 @@ static int
 testQemuImageCreate(const void *opaque)
 {
     struct testQemuImageCreateData *data = (void *) opaque;
-    VIR_AUTOPTR(virJSONValue) protocolprops = NULL;
-    VIR_AUTOPTR(virJSONValue) formatprops = NULL;
+    g_autoptr(virJSONValue) protocolprops = NULL;
+    g_autoptr(virJSONValue) formatprops = NULL;
     VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;
     g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) actualbuf = VIR_BUFFER_INITIALIZER;
diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c
index ca396b36b1..9287ea554b 100644
--- a/tests/qemufirmwaretest.c
+++ b/tests/qemufirmwaretest.c
@@ -18,9 +18,9 @@ testParseFormatFW(const void *opaque)
 {
     const char *filename = opaque;
     g_autofree char *path = NULL;
-    VIR_AUTOPTR(qemuFirmware) fw = NULL;
+    g_autoptr(qemuFirmware) fw = NULL;
     g_autofree char *buf = NULL;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     g_autofree char *expected = NULL;
     g_autofree char *actual = NULL;
 
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 76b131295a..d3da08875a 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -591,7 +591,7 @@ testQemuHotplugCpuIndividual(const void *opaque)
 static int
 mymain(void)
 {
-    VIR_AUTOPTR(virHashTable) qmpschema = NULL;
+    g_autoptr(virHashTable) qmpschema = NULL;
     int ret = 0;
     struct qemuHotplugTestData data = {0};
     struct testQemuHotplugCpuParams cpudata;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index b989e3897f..f754e4d94b 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -154,7 +154,7 @@ testQemuMonitorJSONGetStatus(const void *opaque)
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     bool running = false;
     virDomainPausedReason reason = 0;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -247,7 +247,7 @@ testQemuMonitorJSONGetVersion(const void *opaque)
     int minor;
     int micro;
     char *package = NULL;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -351,7 +351,7 @@ testQemuMonitorJSONGetMachines(const void *opaque)
     const char *null = NULL;
     size_t i;
 
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -432,7 +432,7 @@ testQemuMonitorJSONGetCPUDefinitions(const void *opaque)
     qemuMonitorCPUDefInfoPtr *cpus = NULL;
     int ncpus = 0;
     size_t i;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -515,7 +515,7 @@ testQemuMonitorJSONGetCommands(const void *opaque)
     char **commands = NULL;
     int ncommands = 0;
     size_t i;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -579,7 +579,7 @@ testQemuMonitorJSONGetTPMModels(const void *opaque)
     int ret = -1;
     char **tpmmodels = NULL;
     int ntpmmodels = 0;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -633,7 +633,7 @@ testQemuMonitorJSONGetCommandLineOptionParameters(const void *opaque)
     char **params = NULL;
     int nparams = 0;
     bool found = false;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -947,7 +947,7 @@ testQemuMonitorJSONDetachChardev(const void *opaque)
 {
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -980,7 +980,7 @@ testQemuMonitorJSONGetListPaths(const void *opaque)
     qemuMonitorJSONListPathPtr *paths;
     int npaths = 0;
     size_t i;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1055,7 +1055,7 @@ testQemuMonitorJSONGetObjectProperty(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     qemuMonitorJSONObjectProperty prop;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1095,7 +1095,7 @@ testQemuMonitorJSONSetObjectProperty(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     qemuMonitorJSONObjectProperty prop;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1148,7 +1148,7 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaque)
     const char **alias;
     const char *expected[] = {
         "virtio-disk25", "video0", "serial0", "ide0-0-0", "usb", NULL };
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1205,7 +1205,7 @@ testQemuMonitorJSONCPU(const void *opaque)
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     bool running = false;
     virDomainPausedReason reason = 0;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1260,7 +1260,7 @@ testQemuMonitorJSONSimpleFunc(const void *opaque)
         (testQemuMonitorJSONSimpleFuncDataPtr) opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     const char *reply = data->reply;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1284,7 +1284,7 @@ testQemuMonitorJSON ## funcName(const void *opaque) \
     const testQemuMonitorJSONSimpleFuncData *data = opaque; \
     virDomainXMLOptionPtr xmlopt = data->xmlopt; \
     const char *reply = data->reply; \
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL; \
+    g_autoptr(qemuMonitorTest) test = NULL; \
  \
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) \
         return -1; \
@@ -1358,7 +1358,7 @@ testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque)
         .socket = (char *)"/tmp/sock",
         .transport = VIR_STORAGE_NET_HOST_TRANS_UNIX,
     };
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1387,8 +1387,8 @@ testQemuMonitorJSONqemuMonitorJSONMergeBitmaps(const void *opaque)
 {
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
-    VIR_AUTOPTR(virJSONValue) arr = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
+    g_autoptr(virJSONValue) arr = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1481,7 +1481,7 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *opaque)
             {0, 17629, (char *) "/machine/unattached/device[0]", false},
             {1, 17630, (char *) "/machine/unattached/device[1]", false},
     };
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1562,7 +1562,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     unsigned long long currmem;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1594,7 +1594,7 @@ testQemuMonitorJSONqemuMonitorJSONGetVirtType(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     virDomainVirtType virtType;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1671,7 +1671,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const void *opaque)
     int ret = -1;
     virHashTablePtr blockDevices = NULL, expectedBlockDevices = NULL;
     struct qemuDomainDiskInfo *info;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1750,7 +1750,7 @@ testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void *opaque)
     virHashTablePtr blockstats = NULL;
     qemuBlockStatsPtr stats;
     int ret = -1;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     const char *reply =
         "{"
@@ -1910,7 +1910,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     unsigned long long cacheSize;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -1944,7 +1944,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *opaque)
     int ret = -1;
     qemuMonitorMigrationStats stats, expectedStats;
     char *error = NULL;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2042,7 +2042,7 @@ testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *opaque)
     qemuMonitorChardevInfo info1 = { (char *) "/dev/pts/21", VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED };
     qemuMonitorChardevInfo info2 = { (char *) "/dev/pts/20", VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT };
     qemuMonitorChardevInfo info3 = { NULL, VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED };
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2159,7 +2159,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *opaque)
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     int ret = -1;
     virDomainBlockIoTuneInfo info, expectedInfo;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2214,7 +2214,7 @@ testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque)
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     int ret = -1;
     char *arch;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2264,7 +2264,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
         "    ],"
         "    \"id\": \"libvirt-22\""
         "}";
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2310,7 +2310,7 @@ testQemuMonitorJSONqemuMonitorJSONSendKey(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     unsigned int keycodes[] = {43, 26, 46, 32};
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2332,7 +2332,7 @@ testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *opaque)
     const testGenericData *data = opaque;
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     unsigned int keycodes[] = {43, 26, 46, 32};
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2374,7 +2374,7 @@ testQemuMonitorJSONqemuMonitorSupportsActiveCommit(const void *opaque)
         "    \"desc\": \"Parameter 'top' is missing\""
         "  }"
         "}";
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2416,7 +2416,7 @@ testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *opaqu
         "    },"
         "    \"id\": \"libvirt-9\""
         "}";
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2455,7 +2455,7 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
     char *jsonStr = NULL;
     char *actual = NULL;
     int ret = -1;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
         return -1;
@@ -2517,7 +2517,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
     virDomainXMLOptionPtr xmlopt = data->xmlopt;
     virCPUDataPtr cpuData = NULL;
     int rv, ret = -1;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2562,7 +2562,7 @@ testQemuMonitorJSONGetIOThreads(const void *opaque)
     int ninfo = 0;
     int ret = -1;
     size_t i;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
         return -1;
@@ -2708,7 +2708,7 @@ testQemuMonitorCPUInfo(const void *opaque)
     qemuMonitorCPUInfoPtr vcpus = NULL;
     int rc;
     int ret = -1;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
         return -1;
@@ -3008,9 +3008,9 @@ static int
 testQemuMonitorJSONTransaction(const void *opaque)
 {
     const testGenericData *data = opaque;
-    VIR_AUTOPTR(qemuMonitorTest) test = NULL;
-    VIR_AUTOPTR(virJSONValue) actions = NULL;
-    VIR_AUTOPTR(virJSONValue) mergebitmaps = NULL;
+    g_autoptr(qemuMonitorTest) test = NULL;
+    g_autoptr(virJSONValue) actions = NULL;
+    g_autoptr(virJSONValue) mergebitmaps = NULL;
 
     if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
         return -1;
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index cc196263f3..6b3aa97e39 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -513,7 +513,7 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
 {
     g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
     virJSONValuePtr schemaroot;
-    VIR_AUTOPTR(virJSONValue) emptyargs = NULL;
+    g_autoptr(virJSONValue) emptyargs = NULL;
     g_autofree char *schemapath = NULL;
 
     if (!test->qapischema)
@@ -568,7 +568,7 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
                                      const char *cmdstr)
 {
     struct qemuMonitorTestHandlerData *data = item->opaque;
-    VIR_AUTOPTR(virJSONValue) val = NULL;
+    g_autoptr(virJSONValue) val = NULL;
     virJSONValuePtr cmdargs = NULL;
     const char *cmdname;
     int rc;
@@ -624,7 +624,7 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
     struct qemuMonitorTestHandlerData *data = item->opaque;
     g_autofree char *reformatted = NULL;
     g_autofree char *errmsg = NULL;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     virJSONValuePtr cmdargs;
     const char *cmdname;
     int ret = -1;
diff --git a/tests/qemuvhostusertest.c b/tests/qemuvhostusertest.c
index b25f7f65b0..0ee96d9ecc 100644
--- a/tests/qemuvhostusertest.c
+++ b/tests/qemuvhostusertest.c
@@ -18,9 +18,9 @@ testParseFormatVU(const void *opaque)
 {
     const char *filename = opaque;
     g_autofree char *path = NULL;
-    VIR_AUTOPTR(qemuVhostUser) vu = NULL;
+    g_autoptr(qemuVhostUser) vu = NULL;
     g_autofree char *buf = NULL;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     g_autofree char *expected = NULL;
     g_autofree char *actual = NULL;
 
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index ae038a78ea..6504881920 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -58,7 +58,7 @@ test_node_info_parser(const void *opaque)
     const struct testNodeInfoParserData *data = opaque;
     collie_test test = data->data;
     g_autofree char *output = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
+    g_autoptr(virStoragePoolDef) pool = NULL;
 
     if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
         return -1;
@@ -86,8 +86,8 @@ test_vdi_list_parser(const void *opaque)
     const struct testVDIListParserData *data = opaque;
     collie_test test = data->data;
     g_autofree char *output = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
+    g_autoptr(virStoragePoolDef) pool = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
 
     if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
         return -1;
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 766588c369..2ec7cbef66 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -28,7 +28,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
     const char *defTypeStr;
     g_autofree char *actualCmdline = NULL;
     g_autofree char *src = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!(def = virStoragePoolDefParseFile(poolxml)))
         goto cleanup;
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index 4fb37c976a..0f7bc27293 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -19,7 +19,7 @@ static int
 testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
 {
     g_autofree char *actual = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) dev = NULL;
+    g_autoptr(virStoragePoolDef) dev = NULL;
 
     if (!(dev = virStoragePoolDefParseFile(inxml)))
         return -1;
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 955620eb47..af90aa6953 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -47,10 +47,10 @@ testCompareXMLToArgvFiles(bool shouldFail,
     virStoragePoolDefPtr def = NULL;
     virStoragePoolObjPtr obj = NULL;
     g_autofree char *actualCmdline = NULL;
-    VIR_AUTOPTR(virStorageVolDef) vol = NULL;
-    VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) inputpool = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virStorageVolDef) vol = NULL;
+    g_autoptr(virStorageVolDef) inputvol = NULL;
+    g_autoptr(virStoragePoolDef) inputpool = NULL;
+    g_autoptr(virCommand) cmd = NULL;
 
     if (!(def = virStoragePoolDefParseFile(poolxml)))
         goto cleanup;
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index 2d15480c96..0c8cecc10d 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -18,8 +18,8 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
                          const char *outxml, unsigned int flags)
 {
     g_autofree char *actual = NULL;
-    VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
-    VIR_AUTOPTR(virStorageVolDef) dev = NULL;
+    g_autoptr(virStoragePoolDef) pool = NULL;
+    g_autoptr(virStorageVolDef) dev = NULL;
 
     if (!(pool = virStoragePoolDefParseFile(poolxml)))
         return -1;
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index ff6b506b7d..545e9272df 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -745,9 +745,9 @@ static int
 test15(const void *opaque)
 {
     const struct testBinaryOpData *data = opaque;
-    VIR_AUTOPTR(virBitmap) amap = NULL;
-    VIR_AUTOPTR(virBitmap) bmap = NULL;
-    VIR_AUTOPTR(virBitmap) resmap = NULL;
+    g_autoptr(virBitmap) amap = NULL;
+    g_autoptr(virBitmap) bmap = NULL;
+    g_autoptr(virBitmap) resmap = NULL;
 
     if (!(amap = virBitmapParseUnlimited(data->a)) ||
         !(bmap = virBitmapParseUnlimited(data->b)) ||
diff --git a/tests/virconftest.c b/tests/virconftest.c
index eb8c9cb579..1ad34caec6 100644
--- a/tests/virconftest.c
+++ b/tests/virconftest.c
@@ -33,7 +33,7 @@ static int testConfRoundTrip(const void *opaque)
 {
     const char *name = opaque;
     int ret = -1;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     int len = 10000;
     char *buffer = NULL;
     char *srcfile = NULL;
@@ -79,7 +79,7 @@ static int testConfMemoryNoNewline(const void *opaque G_GNUC_UNUSED)
         "string = 'foo'\n" \
         "uint = 12345";
 
-    VIR_AUTOPTR(virConf) conf = virConfReadString(srcdata, 0);
+    g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
     int ret = -1;
     virConfValuePtr val;
     unsigned long long llvalue;
@@ -148,7 +148,7 @@ static int testConfParseInt(const void *opaque G_GNUC_UNUSED)
         "ssize_t = -87539319\n" \
         "string = \"foo\"\n";
 
-    VIR_AUTOPTR(virConf) conf = virConfReadString(srcdata, 0);
+    g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
     int iv;
     unsigned int ui;
     size_t s;
@@ -293,7 +293,7 @@ static int testConfParseBool(const void *opaque G_GNUC_UNUSED)
         "int = 6963472309248\n" \
         "string = \"foo\"\n";
 
-    VIR_AUTOPTR(virConf) conf = virConfReadString(srcdata, 0);
+    g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
     bool f = true;
     bool t = false;
 
@@ -353,7 +353,7 @@ static int testConfParseString(const void *opaque G_GNUC_UNUSED)
         "string = \"foo\"\n";
 
     int ret = -1;
-    VIR_AUTOPTR(virConf) conf = virConfReadString(srcdata, 0);
+    g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
     char *str = NULL;
 
     if (!conf)
@@ -392,7 +392,7 @@ static int testConfParseStringList(const void *opaque G_GNUC_UNUSED)
         "string = \"foo\"\n";
 
     int ret = -1;
-    VIR_AUTOPTR(virConf) conf = virConfReadString(srcdata, 0);
+    g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
     char **str = NULL;
 
     if (!conf)
diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 13717ad522..f72e70879b 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -20,7 +20,7 @@ static int
 testJSONFromFile(const void *data)
 {
     const struct testInfo *info = data;
-    VIR_AUTOPTR(virJSONValue) injson = NULL;
+    g_autoptr(virJSONValue) injson = NULL;
     g_autofree char *infile = NULL;
     g_autofree char *indata = NULL;
     g_autofree char *outfile = NULL;
@@ -66,7 +66,7 @@ static int
 testJSONFromString(const void *data)
 {
     const struct testInfo *info = data;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     const char *expectstr = info->expect ? info->expect : info->doc;
     g_autofree char *formatted = NULL;
 
@@ -107,8 +107,8 @@ static int
 testJSONAddRemove(const void *data)
 {
     const struct testInfo *info = data;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
-    VIR_AUTOPTR(virJSONValue) name = NULL;
+    g_autoptr(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) name = NULL;
     g_autofree char *infile = NULL;
     g_autofree char *indata = NULL;
     g_autofree char *outfile = NULL;
@@ -178,7 +178,7 @@ static int
 testJSONLookup(const void *data)
 {
     const struct testInfo *info = data;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) json = NULL;
     virJSONValuePtr value = NULL;
     g_autofree char *result = NULL;
     int rc;
@@ -279,8 +279,8 @@ static int
 testJSONCopy(const void *data)
 {
     const struct testInfo *info = data;
-    VIR_AUTOPTR(virJSONValue) json = NULL;
-    VIR_AUTOPTR(virJSONValue) jsonCopy = NULL;
+    g_autoptr(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) jsonCopy = NULL;
     g_autofree char *result = NULL;
     g_autofree char *resultCopy = NULL;
 
@@ -343,8 +343,8 @@ static int
 testJSONDeflatten(const void *data)
 {
     const struct testInfo *info = data;
-    VIR_AUTOPTR(virJSONValue) injson = NULL;
-    VIR_AUTOPTR(virJSONValue) deflattened = NULL;
+    g_autoptr(virJSONValue) injson = NULL;
+    g_autoptr(virJSONValue) deflattened = NULL;
     g_autofree char *infile = NULL;
     g_autofree char *indata = NULL;
     g_autofree char *outfile = NULL;
@@ -387,9 +387,9 @@ testJSONDeflatten(const void *data)
 static int
 testJSONEscapeObj(const void *data G_GNUC_UNUSED)
 {
-    VIR_AUTOPTR(virJSONValue) json = NULL;
-    VIR_AUTOPTR(virJSONValue) nestjson = NULL;
-    VIR_AUTOPTR(virJSONValue) parsejson = NULL;
+    g_autoptr(virJSONValue) json = NULL;
+    g_autoptr(virJSONValue) nestjson = NULL;
+    g_autoptr(virJSONValue) parsejson = NULL;
     g_autofree char *neststr = NULL;
     g_autofree char *result = NULL;
     const char *parsednestedstr;
@@ -439,10 +439,10 @@ testJSONEscapeObj(const void *data G_GNUC_UNUSED)
 static int
 testJSONObjectFormatSteal(const void *opaque G_GNUC_UNUSED)
 {
-    VIR_AUTOPTR(virJSONValue) a1 = NULL;
-    VIR_AUTOPTR(virJSONValue) a2 = NULL;
-    VIR_AUTOPTR(virJSONValue) t1 = NULL;
-    VIR_AUTOPTR(virJSONValue) t2 = NULL;
+    g_autoptr(virJSONValue) a1 = NULL;
+    g_autoptr(virJSONValue) a2 = NULL;
+    g_autoptr(virJSONValue) t1 = NULL;
+    g_autoptr(virJSONValue) t2 = NULL;
 
     if (!(a1 = virJSONValueNewString("test")) ||
         !(a2 = virJSONValueNewString("test"))) {
diff --git a/tests/virnetworkportxml2xmltest.c b/tests/virnetworkportxml2xmltest.c
index 9cbb327d92..973fee5747 100644
--- a/tests/virnetworkportxml2xmltest.c
+++ b/tests/virnetworkportxml2xmltest.c
@@ -38,7 +38,7 @@ testCompareXMLToXMLFiles(const char *expected)
 {
     char *actual = NULL;
     int ret = -1;
-    VIR_AUTOPTR(virNetworkPortDef) dev = NULL;
+    g_autoptr(virNetworkPortDef) dev = NULL;
 
     if (!(dev = virNetworkPortDefParseFile(expected)))
         goto cleanup;
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index c3a2cc10c8..6cec458088 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -117,7 +117,7 @@ testPrepImages(void)
 {
     int ret = EXIT_FAILURE;
     bool compat = false;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     g_autofree char *buf = NULL;
 
     qemuimg = virFindFileInPath("qemu-img");
@@ -663,7 +663,7 @@ mymain(void)
     struct testBackingParseData data5;
     virStorageSourcePtr chain2; /* short for chain->backingStore */
     virStorageSourcePtr chain3; /* short for chain2->backingStore */
-    VIR_AUTOPTR(virCommand) cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     VIR_AUTOUNREF(virStorageSourcePtr) chain = NULL;
 
     if (storageRegisterAll() < 0)
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 109e0a5456..1a78f006cc 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -553,7 +553,7 @@ testActivation(bool useNames)
     virSystemdActivationMap map[2];
     int *fds = NULL;
     size_t nfds = 0;
-    VIR_AUTOPTR(virSystemdActivation) act = NULL;
+    g_autoptr(virSystemdActivation) act = NULL;
     g_auto(virBuffer) names = VIR_BUFFER_INITIALIZER;
 
     virBufferAddLit(&names, "demo-unix.socket");
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index f49202d292..8e84c84887 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -68,7 +68,7 @@ static int
 testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
 {
     char *gotxlcfgData = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     virConnectPtr conn = NULL;
     int wrote = 4096;
     int ret = -1;
@@ -128,7 +128,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
 {
     char *xlcfgData = NULL;
     char *gotxml = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     int ret = -1;
     virConnectPtr conn;
     virDomainDefPtr def = NULL;
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index 484b023a1c..b67b14ea9d 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -41,7 +41,7 @@ static int
 testCompareParseXML(const char *xmcfg, const char *xml)
 {
     char *gotxmcfgData = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     int ret = -1;
     virConnectPtr conn = NULL;
     int wrote = 4096;
@@ -87,7 +87,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
 {
     char *xmcfgData = NULL;
     char *gotxml = NULL;
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     int ret = -1;
     virDomainDefPtr def = NULL;
 
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index 68ccd73056..16c209ab36 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -82,8 +82,8 @@ virshDomainInterfaceCompleter(vshControl *ctl,
                               unsigned int flags)
 {
     virshControlPtr priv = ctl->privData;
-    VIR_AUTOPTR(xmlDoc) xmldoc = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) xmldoc = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     int ninterfaces;
     g_autofree xmlNodePtr *interfaces = NULL;
     size_t i;
@@ -133,8 +133,8 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
                                unsigned int flags)
 {
     virshControlPtr priv = ctl->privData;
-    VIR_AUTOPTR(xmlDoc) xmldoc = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) xmldoc = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     g_autofree xmlNodePtr *disks = NULL;
     int ndisks;
     size_t i;
@@ -199,8 +199,8 @@ virshDomainInterfaceStateCompleter(vshControl *ctl,
     virshControlPtr priv = ctl->privData;
     const char *iface = NULL;
     char **ret = NULL;
-    VIR_AUTOPTR(xmlDoc) xml = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) xml = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     virMacAddr macaddr;
     char macstr[VIR_MAC_STRING_BUFLEN] = "";
     int ninterfaces;
@@ -260,8 +260,8 @@ virshDomainDeviceAliasCompleter(vshControl *ctl,
                                 unsigned int flags)
 {
     virshControlPtr priv = ctl->privData;
-    VIR_AUTOPTR(xmlDoc) xmldoc = NULL;
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlDoc) xmldoc = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     int naliases;
     g_autofree xmlNodePtr *aliases = NULL;
     size_t i;
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index 5a54c0a3a0..ce43818be3 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -54,11 +54,11 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
                                  const vshCmd *cmd G_GNUC_UNUSED,
                                  unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     virshControlPtr priv = ctl->privData;
     unsigned int npages = 0;
     g_autofree xmlNodePtr *pages = NULL;
-    VIR_AUTOPTR(xmlDoc) doc = NULL;
+    g_autoptr(xmlDoc) doc = NULL;
     size_t i = 0;
     const char *cellnum = NULL;
     bool cellno = vshCommandOptBool(cmd, "cellno");
@@ -110,11 +110,11 @@ virshCellnoCompleter(vshControl *ctl,
                      const vshCmd *cmd G_GNUC_UNUSED,
                      unsigned int flags)
 {
-    VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     virshControlPtr priv = ctl->privData;
     unsigned int ncells = 0;
     g_autofree xmlNodePtr *cells = NULL;
-    VIR_AUTOPTR(xmlDoc) doc = NULL;
+    g_autoptr(xmlDoc) doc = NULL;
     size_t i = 0;
     g_autofree char *cap_xml = NULL;
     char **ret = NULL;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e8097bb165..f46d30341d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8645,7 +8645,7 @@ static const vshCmdOptDef opts_inject_nmi[] = {
 static bool
 cmdInjectNMI(vshControl *ctl, const vshCmd *cmd)
 {
-    VIR_AUTOPTR(virshDomain) dom = NULL;
+    g_autoptr(virshDomain) dom = NULL;
 
     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
@@ -8832,7 +8832,7 @@ static int getSignalNumber(vshControl *ctl, const char *signame)
 static bool
 cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
 {
-    VIR_AUTOPTR(virshDomain) dom = NULL;
+    g_autoptr(virshDomain) dom = NULL;
     const char *signame;
     long long pid_value;
     int signum;
@@ -9506,7 +9506,7 @@ static const vshCmdOptDef opts_qemu_monitor_command[] = {
 static bool
 cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
 {
-    VIR_AUTOPTR(virshDomain) dom = NULL;
+    g_autoptr(virshDomain) dom = NULL;
     g_autofree char *monitor_cmd = NULL;
     g_autofree char *result = NULL;
     unsigned int flags = 0;
diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helper.c
index a24a14d1d3..eb2b2dfe9e 100644
--- a/tools/virt-login-shell-helper.c
+++ b/tools/virt-login-shell-helper.c
@@ -152,7 +152,7 @@ hideErrorFunc(void *opaque G_GNUC_UNUSED,
 int
 main(int argc, char **argv)
 {
-    VIR_AUTOPTR(virConf) conf = NULL;
+    g_autoptr(virConf) conf = NULL;
     const char *login_shell_path = conf_file;
     pid_t cpid = -1;
     int ret = EXIT_CANCELED;
-- 
2.19.2




More information about the libvir-list mailing list