[PATCH 53/75] qemu: Use g_strdup_printf() instead of virAsprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c            |  6 +--
 src/qemu/qemu_alias.c            | 88 +++++++++++++++----------------
 src/qemu/qemu_block.c            | 30 +++++------
 src/qemu/qemu_blockjob.c         |  8 +--
 src/qemu/qemu_capabilities.c     |  8 +--
 src/qemu/qemu_checkpoint.c       |  8 +--
 src/qemu/qemu_command.c          | 72 ++++++++++++-------------
 src/qemu/qemu_conf.c             | 90 ++++++++++++++++----------------
 src/qemu/qemu_domain.c           | 80 ++++++++++++++--------------
 src/qemu/qemu_hotplug.c          | 32 ++++++------
 src/qemu/qemu_interface.c        |  2 +-
 src/qemu/qemu_interop_config.c   |  6 +--
 src/qemu/qemu_migration.c        | 24 ++++-----
 src/qemu/qemu_migration_cookie.c |  2 +-
 src/qemu/qemu_monitor.c          | 30 +++++------
 src/qemu/qemu_monitor_json.c     | 14 ++---
 src/qemu/qemu_monitor_text.c     | 10 ++--
 src/qemu/qemu_process.c          | 32 ++++++------
 src/qemu/qemu_slirp.c            | 10 ++--
 src/qemu/qemu_tpm.c              | 10 ++--
 src/qemu/qemu_vhost_user_gpu.c   |  2 +-
 21 files changed, 282 insertions(+), 282 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index d1b590d842..5a50f7f3be 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -916,8 +916,8 @@ qemuAgentGuestSync(qemuAgentPtr mon)
     if (virTimeMillisNow(&id) < 0)
         return -1;
 
-    virAsprintf(&sync_msg.txBuffer, "{\"execute\":\"guest-sync\", "
-                "\"arguments\":{\"id\":%llu}}\n", id);
+    sync_msg.txBuffer = g_strdup_printf("{\"execute\":\"guest-sync\", "
+                                        "\"arguments\":{\"id\":%llu}}\n", id);
 
     sync_msg.txLength = strlen(sync_msg.txBuffer);
     sync_msg.sync = true;
@@ -1118,7 +1118,7 @@ qemuAgentCommand(qemuAgentPtr mon,
 
     if (!(cmdstr = virJSONValueToString(cmd, false)))
         goto cleanup;
-    virAsprintf(&msg.txBuffer, "%s" LINE_ENDING, cmdstr);
+    msg.txBuffer = g_strdup_printf("%s" LINE_ENDING, cmdstr);
     msg.txLength = strlen(msg.txBuffer);
 
     VIR_DEBUG("Send command '%s' for write, seconds = %d", cmdstr, seconds);
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 60ab5735a4..22160a6fd8 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -114,7 +114,7 @@ qemuAssignDeviceChrAlias(virDomainDefPtr def,
     if (idx == -1 && (idx = qemuGetNextChrDevIndex(def, chr, prefix)) < 0)
         return -1;
 
-    virAsprintf(&chr->info.alias, "%s%zd", prefix, idx);
+    chr->info.alias = g_strdup_printf("%s%zd", prefix, idx);
     return 0;
 }
 
@@ -142,14 +142,14 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
              * different naming convention ("pcie.0"), because it is
              * hardcoded that way in qemu.
              */
-            virAsprintf(&controller->info.alias, "pcie.%d", controller->idx);
+            controller->info.alias = g_strdup_printf("pcie.%d", controller->idx);
             return 0;
         }
         /* All other PCI controllers use the consistent "pci.%u"
          * (including the hardcoded pci-root controller on
          * multibus-capable qemus).
          */
-        virAsprintf(&controller->info.alias, "pci.%d", controller->idx);
+        controller->info.alias = g_strdup_printf("pci.%d", controller->idx);
         return 0;
     } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
         /* for any machine based on e.g. I440FX or G3Beige, the
@@ -179,7 +179,7 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
     /* all other controllers use the default ${type}${index} naming
      * scheme for alias/id.
      */
-    virAsprintf(&controller->info.alias, "%s%d", prefix, controller->idx);
+    controller->info.alias = g_strdup_printf("%s%d", prefix, controller->idx);
     return 0;
 }
 
@@ -204,20 +204,20 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
 
             if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI ||
                 controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
-                virAsprintf(&disk->info.alias, "%s%d-%d-%d", prefix,
-                            disk->info.addr.drive.controller,
-                            disk->info.addr.drive.bus,
-                            disk->info.addr.drive.unit);
+                disk->info.alias = g_strdup_printf("%s%d-%d-%d", prefix,
+                                                   disk->info.addr.drive.controller,
+                                                   disk->info.addr.drive.bus,
+                                                   disk->info.addr.drive.unit);
             } else {
-                virAsprintf(&disk->info.alias, "%s%d-%d-%d-%d", prefix,
-                            disk->info.addr.drive.controller,
-                            disk->info.addr.drive.bus,
-                            disk->info.addr.drive.target,
-                            disk->info.addr.drive.unit);
+                disk->info.alias = g_strdup_printf("%s%d-%d-%d-%d", prefix,
+                                                   disk->info.addr.drive.controller,
+                                                   disk->info.addr.drive.bus,
+                                                   disk->info.addr.drive.target,
+                                                   disk->info.addr.drive.unit);
             }
         } else {
             int idx = virDiskNameToIndex(disk->dst);
-            virAsprintf(&disk->info.alias, "%s-disk%d", prefix, idx);
+            disk->info.alias = g_strdup_printf("%s-disk%d", prefix, idx);
         }
     }
 
@@ -236,15 +236,15 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
             break;
 
         case VIR_DOMAIN_DISK_BUS_VIRTIO:
-            virAsprintf(&diskPriv->qomName,
-                        "/machine/peripheral/%s/virtio-backend",
-                        disk->info.alias);
+            diskPriv->qomName = g_strdup_printf(
+                                                "/machine/peripheral/%s/virtio-backend",
+                                                disk->info.alias);
             break;
 
         case VIR_DOMAIN_DISK_BUS_USB:
-            virAsprintf(&diskPriv->qomName,
-                        "/machine/peripheral/%s/%s.0/legacy[0]",
-                        disk->info.alias, disk->info.alias);
+            diskPriv->qomName = g_strdup_printf(
+                                                "/machine/peripheral/%s/%s.0/legacy[0]",
+                                                disk->info.alias, disk->info.alias);
             break;
 
         case VIR_DOMAIN_DISK_BUS_XEN:
@@ -290,7 +290,7 @@ qemuAssignDeviceHostdevAlias(virDomainDefPtr def,
         }
     }
 
-    virAsprintf(alias, "hostdev%d", idx);
+    *alias = g_strdup_printf("hostdev%d", idx);
 
     return 0;
 }
@@ -325,7 +325,7 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def,
         }
     }
 
-    virAsprintf(&net->info.alias, "net%d", idx);
+    net->info.alias = g_strdup_printf("net%d", idx);
     return 0;
 }
 
@@ -337,7 +337,7 @@ qemuAssignDeviceFSAlias(virDomainFSDefPtr fss,
     if (fss->info.alias)
         return 0;
 
-    virAsprintf(&fss->info.alias, "fs%d", idx);
+    fss->info.alias = g_strdup_printf("fs%d", idx);
     return 0;
 }
 
@@ -349,7 +349,7 @@ qemuAssignDeviceSoundAlias(virDomainSoundDefPtr sound,
     if (sound->info.alias)
         return 0;
 
-    virAsprintf(&sound->info.alias, "sound%d", idx);
+    sound->info.alias = g_strdup_printf("sound%d", idx);
     return 0;
 }
 
@@ -361,7 +361,7 @@ qemuAssignDeviceVideoAlias(virDomainVideoDefPtr video,
     if (video->info.alias)
         return 0;
 
-    virAsprintf(&video->info.alias, "video%d", idx);
+    video->info.alias = g_strdup_printf("video%d", idx);
     return 0;
 }
 
@@ -373,7 +373,7 @@ qemuAssignDeviceHubAlias(virDomainHubDefPtr hub,
     if (hub->info.alias)
         return 0;
 
-    virAsprintf(&hub->info.alias, "hub%d", idx);
+    hub->info.alias = g_strdup_printf("hub%d", idx);
     return 0;
 }
 
@@ -385,7 +385,7 @@ qemuAssignDeviceSmartcardAlias(virDomainSmartcardDefPtr smartcard,
     if (smartcard->info.alias)
         return 0;
 
-    virAsprintf(&smartcard->info.alias, "smartcard%d", idx);
+    smartcard->info.alias = g_strdup_printf("smartcard%d", idx);
     return 0;
 }
 
@@ -397,7 +397,7 @@ qemuAssingDeviceMemballoonAlias(virDomainMemballoonDefPtr memballoon,
     if (memballoon->info.alias)
         return 0;
 
-    virAsprintf(&memballoon->info.alias, "balloon%d", idx);
+    memballoon->info.alias = g_strdup_printf("balloon%d", idx);
     return 0;
 }
 
@@ -409,7 +409,7 @@ qemuAssignDeviceTPMAlias(virDomainTPMDefPtr tpm,
     if (tpm->info.alias)
         return 0;
 
-    virAsprintf(&tpm->info.alias, "tpm%d", idx);
+    tpm->info.alias = g_strdup_printf("tpm%d", idx);
     return 0;
 }
 
@@ -434,7 +434,7 @@ qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
         }
     }
 
-    virAsprintf(&redirdev->info.alias, "redir%d", idx);
+    redirdev->info.alias = g_strdup_printf("redir%d", idx);
     return 0;
 }
 
@@ -455,7 +455,7 @@ qemuAssignDeviceRNGAlias(virDomainDefPtr def,
             maxidx = idx + 1;
     }
 
-    virAsprintf(&rng->info.alias, "rng%d", maxidx);
+    rng->info.alias = g_strdup_printf("rng%d", maxidx);
 
     return 0;
 }
@@ -500,7 +500,7 @@ qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
         maxidx = mem->info.addr.dimm.slot;
     }
 
-    virAsprintf(&mem->info.alias, "%s%d", prefix, maxidx);
+    mem->info.alias = g_strdup_printf("%s%d", prefix, maxidx);
 
     return 0;
 }
@@ -529,7 +529,7 @@ qemuAssignDeviceShmemAlias(virDomainDefPtr def,
         }
     }
 
-    virAsprintf(&shmem->info.alias, "shmem%d", idx);
+    shmem->info.alias = g_strdup_printf("shmem%d", idx);
     return 0;
 }
 
@@ -565,7 +565,7 @@ qemuAssignDeviceInputAlias(virDomainDefPtr def,
         }
     }
 
-    virAsprintf(&input->info.alias, "input%d", idx);
+    input->info.alias = g_strdup_printf("input%d", idx);
 
     return 0;
 }
@@ -705,7 +705,7 @@ qemuAliasDiskDriveFromDisk(const virDomainDiskDef *disk)
         return NULL;
     }
 
-    virAsprintf(&ret, "%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
+    ret = g_strdup_printf("%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
     return ret;
 }
 
@@ -741,9 +741,9 @@ qemuAliasFromHostdev(const virDomainHostdevDef *hostdev)
         return NULL;
     }
 
-    virAsprintf(&ret, "%s-%s",
-                virDomainDeviceAddressTypeToString(hostdev->info->type),
-                hostdev->info->alias);
+    ret = g_strdup_printf("%s-%s",
+                          virDomainDeviceAddressTypeToString(hostdev->info->type),
+                          hostdev->info->alias);
     return ret;
 }
 
@@ -786,9 +786,9 @@ qemuDomainGetSecretAESAlias(const char *srcalias,
     }
 
     if (isLuks)
-        virAsprintf(&alias, "%s-luks-secret0", srcalias);
+        alias = g_strdup_printf("%s-luks-secret0", srcalias);
     else
-        virAsprintf(&alias, "%s-secret0", srcalias);
+        alias = g_strdup_printf("%s-secret0", srcalias);
 
     return alias;
 }
@@ -804,7 +804,7 @@ qemuAliasTLSObjFromSrcAlias(const char *srcAlias)
 {
     char *ret;
 
-    virAsprintf(&ret, "obj%s_tls0", srcAlias);
+    ret = g_strdup_printf("obj%s_tls0", srcAlias);
 
     return ret;
 }
@@ -820,7 +820,7 @@ qemuAliasChardevFromDevAlias(const char *devAlias)
 {
     char *ret;
 
-    virAsprintf(&ret, "char%s", devAlias);
+    ret = g_strdup_printf("char%s", devAlias);
 
     return ret;
 }
@@ -838,7 +838,7 @@ qemuDomainGetUnmanagedPRAlias(const char *parentalias)
 {
     char *ret;
 
-    virAsprintf(&ret, "pr-helper-%s", parentalias);
+    ret = g_strdup_printf("pr-helper-%s", parentalias);
 
     return ret;
 }
@@ -849,7 +849,7 @@ qemuAliasDBusVMStateFromId(const char *id)
     char *ret;
     size_t i;
 
-    virAsprintf(&ret, "dbus-vms-%s", id);
+    ret = g_strdup_printf("dbus-vms-%s", id);
 
     for (i = 0; ret[i]; i++) {
         if (ret[i] == ':')
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index f40915fe23..b8f0208742 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -423,17 +423,17 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
 
         uri->scheme = g_strdup(virStorageNetProtocolTypeToString(src->protocol));
     } else {
-        virAsprintf(&uri->scheme, "%s+%s",
-                    virStorageNetProtocolTypeToString(src->protocol),
-                    virStorageNetHostTransportTypeToString(src->hosts->transport));
+        uri->scheme = g_strdup_printf("%s+%s",
+                                      virStorageNetProtocolTypeToString(src->protocol),
+                                      virStorageNetHostTransportTypeToString(src->hosts->transport));
     }
 
     if (src->path) {
         if (src->volume) {
-            virAsprintf(&uri->path, "/%s/%s", src->volume, src->path);
+            uri->path = g_strdup_printf("/%s/%s", src->volume, src->path);
         } else {
-            virAsprintf(&uri->path, "%s%s", src->path[0] == '/' ? "" : "/",
-                        src->path);
+            uri->path = g_strdup_printf("%s%s", src->path[0] == '/' ? "" : "/",
+                                        src->path);
         }
     }
 
@@ -472,7 +472,7 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDefPtr host,
         else
             transport = "inet";
 
-        virAsprintf(&port, "%u", host->port);
+        port = g_strdup_printf("%u", host->port);
 
         if (virJSONValueObjectCreate(&server,
                                      "s:type", transport,
@@ -564,7 +564,7 @@ qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr host)
         return NULL;
     }
 
-    virAsprintf(&port, "%u", host->port);
+    port = g_strdup_printf("%u", host->port);
 
     ignore_value(virJSONValueObjectCreate(&ret,
                                           "s:host", host->name,
@@ -760,10 +760,10 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src,
 
     /* combine host and port into portal */
     if (virSocketAddrNumericFamily(src->hosts[0].name) == AF_INET6) {
-        virAsprintf(&portal, "[%s]:%u", src->hosts[0].name,
-                    src->hosts[0].port);
+        portal = g_strdup_printf("[%s]:%u", src->hosts[0].name,
+                                 src->hosts[0].port);
     } else {
-        virAsprintf(&portal, "%s:%u", src->hosts[0].name, src->hosts[0].port);
+        portal = g_strdup_printf("%s:%u", src->hosts[0].name, src->hosts[0].port);
     }
 
     if (!onlytarget && src->auth) {
@@ -1955,7 +1955,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src)
     if (!(backingJSON = virJSONValueToString(backingProps, false)))
         return NULL;
 
-    virAsprintf(&ret, "json:%s", backingJSON);
+    ret = g_strdup_printf("json:%s", backingJSON);
 
     return ret;
 }
@@ -2038,9 +2038,9 @@ qemuBlockStorageSourceCreateGetEncryptionLUKS(virStorageSourcePtr src,
 
     if (src->encryption) {
         if (src->encryption->encinfo.cipher_name) {
-            virAsprintf(&cipheralg, "%s-%u",
-                        src->encryption->encinfo.cipher_name,
-                        src->encryption->encinfo.cipher_size);
+            cipheralg = g_strdup_printf("%s-%u",
+                                        src->encryption->encinfo.cipher_name,
+                                        src->encryption->encinfo.cipher_size);
         }
 
         if (virJSONValueObjectAdd(props,
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index e59cab3478..f8ee00711a 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -227,7 +227,7 @@ qemuBlockJobDiskNewPull(virDomainObjPtr vm,
     g_autofree char *jobname = NULL;
 
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
-        virAsprintf(&jobname, "pull-%s-%s", disk->dst, disk->src->nodeformat);
+        jobname = g_strdup_printf("pull-%s-%s", disk->dst, disk->src->nodeformat);
     } else {
         if (!(jobname = qemuAliasDiskDriveFromDisk(disk)))
             return NULL;
@@ -261,7 +261,7 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm,
         jobtype = QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT;
 
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
-        virAsprintf(&jobname, "commit-%s-%s", disk->dst, top->nodeformat);
+        jobname = g_strdup_printf("commit-%s-%s", disk->dst, top->nodeformat);
     } else {
         if (!(jobname = qemuAliasDiskDriveFromDisk(disk)))
             return NULL;
@@ -294,7 +294,7 @@ qemuBlockJobNewCreate(virDomainObjPtr vm,
     if (storage)
         nodename = src->nodestorage;
 
-    virAsprintf(&jobname, "create-%s", nodename);
+    jobname = g_strdup_printf("create-%s", nodename);
 
     if (!(job = qemuBlockJobDataNew(QEMU_BLOCKJOB_TYPE_CREATE, jobname)))
         return NULL;
@@ -323,7 +323,7 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm,
     g_autofree char *jobname = NULL;
 
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
-        virAsprintf(&jobname, "copy-%s-%s", disk->dst, disk->src->nodeformat);
+        jobname = g_strdup_printf("copy-%s-%s", disk->dst, disk->src->nodeformat);
     } else {
         if (!(jobname = qemuAliasDiskDriveFromDisk(disk)))
             return NULL;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b2ea7ec373..8c339e96ca 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -734,7 +734,7 @@ virQEMUCapsFindBinary(const char *format,
     char *ret = NULL;
     char *binary = NULL;
 
-    virAsprintf(&binary, format, archstr);
+    binary = g_strdup_printf(format, archstr);
 
     ret = virFindFileInPath(binary);
     VIR_FREE(binary);
@@ -2411,7 +2411,7 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
 
         /* The QOM type for machine types is the machine type name
          * followed by the -machine suffix */
-        virAsprintf(&type, "%s-machine", canon);
+        type = g_strdup_printf("%s-machine", canon);
 
         if ((nvalues = qemuMonitorGetObjectProps(mon, type, &values)) < 0)
             return -1;
@@ -4847,7 +4847,7 @@ virQEMUCapsCacheNew(const char *libDir,
     virQEMUCapsCachePrivPtr priv = NULL;
     struct utsname uts;
 
-    virAsprintf(&capsCacheDir, "%s/capabilities", cacheDir);
+    capsCacheDir = g_strdup_printf("%s/capabilities", cacheDir);
 
     if (!(cache = virFileCacheNew(capsCacheDir, "xml", &qemuCapsCacheHandlers)))
         goto error;
@@ -4865,7 +4865,7 @@ virQEMUCapsCacheNew(const char *libDir,
     priv->kvmUsable = VIR_TRISTATE_BOOL_ABSENT;
 
     if (uname(&uts) == 0)
-        virAsprintf(&priv->kernelVersion, "%s %s", uts.release, uts.version);
+        priv->kernelVersion = g_strdup_printf("%s %s", uts.release, uts.version);
 
  cleanup:
     VIR_FREE(capsCacheDir);
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 4c224d6f40..e693e1ab14 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -92,14 +92,14 @@ qemuCheckpointWriteMetadata(virDomainObjPtr vm,
     if (newxml == NULL)
         return -1;
 
-    virAsprintf(&chkDir, "%s/%s", checkpointDir, vm->def->name);
+    chkDir = g_strdup_printf("%s/%s", checkpointDir, vm->def->name);
     if (virFileMakePath(chkDir) < 0) {
         virReportSystemError(errno, _("cannot create checkpoint directory '%s'"),
                              chkDir);
         return -1;
     }
 
-    virAsprintf(&chkFile, "%s/%s.xml", chkDir, def->parent.name);
+    chkFile = g_strdup_printf("%s/%s.xml", chkDir, def->parent.name);
 
     return virXMLSaveFile(chkFile, NULL, "checkpoint-edit", newxml);
 }
@@ -125,8 +125,8 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver,
         return -1;
     }
 
-    virAsprintf(&chkFile, "%s/%s/%s.xml", cfg->checkpointDir, vm->def->name,
-                chk->def->name);
+    chkFile = g_strdup_printf("%s/%s/%s.xml", cfg->checkpointDir, vm->def->name,
+                              chk->def->name);
 
     if (!metadata_only) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a55a5826a7..e234be298d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -262,7 +262,7 @@ qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
         return NULL;
     }
 
-    virAsprintf(&result, "set=%d,fd=%d", idx, fd);
+    result = g_strdup_printf("set=%d,fd=%d", idx, fd);
     return result;
 }
 
@@ -289,7 +289,7 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
         return NULL;
     }
 
-    virAsprintf(&result, "/dev/fdset/%d", idx);
+    result = g_strdup_printf("/dev/fdset/%d", idx);
     return result;
 }
 
@@ -795,8 +795,8 @@ qemuBuildGeneralSecinfoURI(virURIPtr uri,
                                _("found non printable characters in secret"));
                 return -1;
             }
-            virAsprintf(&uri->user, "%s:%s", secinfo->s.plain.username,
-                        secinfo->s.plain.secret);
+            uri->user = g_strdup_printf("%s:%s", secinfo->s.plain.username,
+                                        secinfo->s.plain.secret);
         } else {
             uri->user = g_strdup(secinfo->s.plain.username);
         }
@@ -946,7 +946,7 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
         return NULL;
 
     if (src->hosts->socket)
-        virAsprintf(&uri->query, "socket=%s", src->hosts->socket);
+        uri->query = g_strdup_printf("socket=%s", src->hosts->socket);
 
     if (qemuBuildGeneralSecinfoURI(uri, secinfo) < 0)
         return NULL;
@@ -1035,10 +1035,10 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
             }
 
             if (src->nhosts == 0) {
-                virAsprintf(&ret, "sheepdog:%s", src->path);
+                ret = g_strdup_printf("sheepdog:%s", src->path);
             } else if (src->nhosts == 1) {
-                virAsprintf(&ret, "sheepdog:%s:%u:%s", src->hosts->name,
-                            src->hosts->port, src->path);
+                ret = g_strdup_printf("sheepdog:%s:%u:%s", src->hosts->name,
+                                      src->hosts->port, src->path);
             } else {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("protocol 'sheepdog' accepts up to one host"));
@@ -2370,7 +2370,7 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
             driveLetter = 'A';
 
         if (bootindex)
-            virAsprintf(&bootindexStr, "bootindex%c=%u", driveLetter, bootindex);
+            bootindexStr = g_strdup_printf("bootindex%c=%u", driveLetter, bootindex);
 
         /* with -blockdev we setup the floppy device and it's backend with -device */
         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
@@ -2378,7 +2378,7 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
                 return -1;
 
             if (backendAlias)
-                virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias);
+                backendStr = g_strdup_printf("drive%c=%s", driveLetter, backendAlias);
         }
 
         if (!explicitfdc) {
@@ -3580,7 +3580,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
     unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa,
                                                                 cell);
 
-    virAsprintf(&alias, "ram-node%zu", cell);
+    alias = g_strdup_printf("ram-node%zu", cell);
 
     mem.size = memsize;
     mem.targetNode = cell;
@@ -3613,7 +3613,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
         return -1;
     }
 
-    virAsprintf(&alias, "mem%s", mem->info.alias);
+    alias = g_strdup_printf("mem%s", mem->info.alias);
 
     if (qemuBuildMemoryBackendProps(&props, alias, cfg,
                                     priv, def, mem, true) < 0)
@@ -3697,14 +3697,14 @@ qemuBuildLegacyNicStr(virDomainNetDefPtr net)
     char macaddr[VIR_MAC_STRING_BUFLEN];
     const char *netmodel = virDomainNetGetModelString(net);
 
-    virAsprintf(&str,
-                "nic,macaddr=%s,netdev=host%s%s%s%s%s",
-                virMacAddrFormat(&net->mac, macaddr),
-                net->info.alias,
-                netmodel ? ",model=" : "",
-                NULLSTR_EMPTY(netmodel),
-                (net->info.alias ? ",id=" : ""),
-                NULLSTR_EMPTY(net->info.alias));
+    str = g_strdup_printf(
+                          "nic,macaddr=%s,netdev=host%s%s%s%s%s",
+                          virMacAddrFormat(&net->mac, macaddr),
+                          net->info.alias,
+                          netmodel ? ",model=" : "",
+                          NULLSTR_EMPTY(netmodel),
+                          (net->info.alias ? ",id=" : ""),
+                          NULLSTR_EMPTY(net->info.alias));
     return str;
 }
 
@@ -4698,7 +4698,7 @@ qemuBuildVhostUserChardevStr(const char *alias,
         return NULL;
     }
 
-    virAsprintf(&chardev, "socket,id=chr-vu-%s,fd=%d", alias, *fd);
+    chardev = g_strdup_printf("socket,id=chr-vu-%s,fd=%d", alias, *fd);
 
     virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
     *fd = -1;
@@ -5543,7 +5543,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
                 if (virSCSIVHostOpenVhostSCSI(&vhostfd) < 0)
                     return -1;
 
-                virAsprintf(&vhostfdName, "%d", vhostfd);
+                vhostfdName = g_strdup_printf("%d", vhostfd);
 
                 virCommandPassFD(cmd, vhostfd,
                                  VIR_COMMAND_PASS_FD_CLOSE_PARENT);
@@ -5777,7 +5777,7 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
     g_autofree char *objAlias = NULL;
     g_autofree char *charBackendAlias = NULL;
 
-    virAsprintf(&objAlias, "obj%s", rng->info.alias);
+    objAlias = g_strdup_printf("obj%s", rng->info.alias);
 
     switch ((virDomainRNGBackend) rng->backend) {
     case VIR_DOMAIN_RNG_BACKEND_RANDOM:
@@ -8566,7 +8566,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
         int slirpfd = qemuSlirpGetFD(slirp);
         virCommandPassFD(cmd, slirpfd,
                          VIR_COMMAND_PASS_FD_CLOSE_PARENT);
-        virAsprintf(&slirpfdName, "%d", slirpfd);
+        slirpfdName = g_strdup_printf("%d", slirpfd);
     }
 
 
@@ -8574,14 +8574,14 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
         if (qemuSecuritySetTapFDLabel(driver->securityManager,
                                       def, tapfd[i]) < 0)
             goto cleanup;
-        virAsprintf(&tapfdName[i], "%d", tapfd[i]);
+        tapfdName[i] = g_strdup_printf("%d", tapfd[i]);
         virCommandPassFD(cmd, tapfd[i],
                          VIR_COMMAND_PASS_FD_CLOSE_PARENT);
         tapfd[i] = -1;
     }
 
     for (i = 0; i < vhostfdSize; i++) {
-        virAsprintf(&vhostfdName[i], "%d", vhostfd[i]);
+        vhostfdName[i] = g_strdup_printf("%d", vhostfd[i]);
         virCommandPassFD(cmd, vhostfd[i],
                          VIR_COMMAND_PASS_FD_CLOSE_PARENT);
         vhostfd[i] = -1;
@@ -8957,9 +8957,9 @@ qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem)
     g_autofree char *mem_path = NULL;
     virJSONValuePtr ret = NULL;
 
-    virAsprintf(&mem_path, "/dev/shm/%s", shmem->name);
+    mem_path = g_strdup_printf("/dev/shm/%s", shmem->name);
 
-    virAsprintf(&mem_alias, "shmmem-%s", shmem->info.alias);
+    mem_alias = g_strdup_printf("shmmem-%s", shmem->info.alias);
 
     qemuMonitorCreateObjectProps(&ret, "memory-backend-file", mem_alias,
                                  "s:mem-path", mem_path,
@@ -9689,8 +9689,8 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
     case VIR_DOMAIN_TPM_TYPE_EMULATOR:
         virBufferAddLit(&buf, ",chardev=chrtpm");
 
-        virAsprintf(chardev, "socket,id=chrtpm,path=%s",
-                    tpm->data.emulator.source.data.nix.path);
+        *chardev = g_strdup_printf("socket,id=chrtpm,path=%s",
+                                  tpm->data.emulator.source.data.nix.path);
 
         break;
     case VIR_DOMAIN_TPM_TYPE_LAST:
@@ -9775,13 +9775,13 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
     virBufferAsprintf(&buf, ",policy=0x%x", sev->policy);
 
     if (sev->dh_cert) {
-        virAsprintf(&path, "%s/dh_cert.base64", priv->libDir);
+        path = g_strdup_printf("%s/dh_cert.base64", priv->libDir);
         virBufferAsprintf(&buf, ",dh-cert-file=%s", path);
         VIR_FREE(path);
     }
 
     if (sev->session) {
-        virAsprintf(&path, "%s/session.base64", priv->libDir);
+        path = g_strdup_printf("%s/session.base64", priv->libDir);
         virBufferAsprintf(&buf, ",session-file=%s", path);
         VIR_FREE(path);
     }
@@ -10578,8 +10578,8 @@ static int
 qemuBuildParallelChrDeviceStr(char **deviceStr,
                               virDomainChrDefPtr chr)
 {
-    virAsprintf(deviceStr, "isa-parallel,chardev=char%s,id=%s",
-                chr->info.alias, chr->info.alias);
+    *deviceStr = g_strdup_printf("isa-parallel,chardev=char%s,id=%s",
+                                 chr->info.alias, chr->info.alias);
     return 0;
 }
 
@@ -10600,8 +10600,8 @@ qemuBuildChannelChrDeviceStr(char **deviceStr,
             return ret;
         port = virSocketAddrGetPort(chr->target.addr);
 
-        virAsprintf(deviceStr, "user,guestfwd=tcp:%s:%i-chardev:char%s,id=%s",
-                    addr, port, chr->info.alias, chr->info.alias);
+        *deviceStr = g_strdup_printf("user,guestfwd=tcp:%s:%i-chardev:char%s,id=%s",
+                                     addr, port, chr->info.alias, chr->info.alias);
         break;
 
     case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 41fd134afc..19f4b00710 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -130,29 +130,29 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
     cfg->cgroupControllers = -1; /* -1 == auto-detect */
 
     if (privileged) {
-        virAsprintf(&cfg->logDir, "%s/log/libvirt/qemu", LOCALSTATEDIR);
+        cfg->logDir = g_strdup_printf("%s/log/libvirt/qemu", LOCALSTATEDIR);
 
-        virAsprintf(&cfg->swtpmLogDir, "%s/log/swtpm/libvirt/qemu",
-                    LOCALSTATEDIR);
+        cfg->swtpmLogDir = g_strdup_printf("%s/log/swtpm/libvirt/qemu",
+                                           LOCALSTATEDIR);
 
         cfg->configBaseDir = g_strdup(SYSCONFDIR "/libvirt");
 
-        virAsprintf(&cfg->stateDir, "%s/libvirt/qemu", RUNSTATEDIR);
+        cfg->stateDir = g_strdup_printf("%s/libvirt/qemu", RUNSTATEDIR);
 
-        virAsprintf(&cfg->swtpmStateDir, "%s/libvirt/qemu/swtpm", RUNSTATEDIR);
+        cfg->swtpmStateDir = g_strdup_printf("%s/libvirt/qemu/swtpm", RUNSTATEDIR);
 
-        virAsprintf(&cfg->cacheDir, "%s/cache/libvirt/qemu", LOCALSTATEDIR);
+        cfg->cacheDir = g_strdup_printf("%s/cache/libvirt/qemu", LOCALSTATEDIR);
 
-        virAsprintf(&cfg->libDir, "%s/lib/libvirt/qemu", LOCALSTATEDIR);
-        virAsprintf(&cfg->saveDir, "%s/save", cfg->libDir);
-        virAsprintf(&cfg->snapshotDir, "%s/snapshot", cfg->libDir);
-        virAsprintf(&cfg->checkpointDir, "%s/checkpoint", cfg->libDir);
-        virAsprintf(&cfg->autoDumpPath, "%s/dump", cfg->libDir);
-        virAsprintf(&cfg->channelTargetDir, "%s/channel/target", cfg->libDir);
-        virAsprintf(&cfg->nvramDir, "%s/nvram", cfg->libDir);
-        virAsprintf(&cfg->memoryBackingDir, "%s/ram", cfg->libDir);
-        virAsprintf(&cfg->swtpmStorageDir, "%s/lib/libvirt/swtpm",
-                    LOCALSTATEDIR);
+        cfg->libDir = g_strdup_printf("%s/lib/libvirt/qemu", LOCALSTATEDIR);
+        cfg->saveDir = g_strdup_printf("%s/save", cfg->libDir);
+        cfg->snapshotDir = g_strdup_printf("%s/snapshot", cfg->libDir);
+        cfg->checkpointDir = g_strdup_printf("%s/checkpoint", cfg->libDir);
+        cfg->autoDumpPath = g_strdup_printf("%s/dump", cfg->libDir);
+        cfg->channelTargetDir = g_strdup_printf("%s/channel/target", cfg->libDir);
+        cfg->nvramDir = g_strdup_printf("%s/nvram", cfg->libDir);
+        cfg->memoryBackingDir = g_strdup_printf("%s/ram", cfg->libDir);
+        cfg->swtpmStorageDir = g_strdup_printf("%s/lib/libvirt/swtpm",
+                                               LOCALSTATEDIR);
         if (!virDoesUserExist("tss") ||
             virGetUserID("tss", &cfg->swtpm_user) < 0)
             cfg->swtpm_user = 0; /* fall back to root */
@@ -167,39 +167,39 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
         if (!cachedir)
             return NULL;
 
-        virAsprintf(&cfg->logDir, "%s/qemu/log", cachedir);
-        virAsprintf(&cfg->swtpmLogDir, "%s/qemu/log", cachedir);
-        virAsprintf(&cfg->cacheDir, "%s/qemu/cache", cachedir);
+        cfg->logDir = g_strdup_printf("%s/qemu/log", cachedir);
+        cfg->swtpmLogDir = g_strdup_printf("%s/qemu/log", cachedir);
+        cfg->cacheDir = g_strdup_printf("%s/qemu/cache", cachedir);
 
         rundir = virGetUserRuntimeDirectory();
         if (!rundir)
             return NULL;
-        virAsprintf(&cfg->stateDir, "%s/qemu/run", rundir);
+        cfg->stateDir = g_strdup_printf("%s/qemu/run", rundir);
 
-        virAsprintf(&cfg->swtpmStateDir, "%s/swtpm", cfg->stateDir);
+        cfg->swtpmStateDir = g_strdup_printf("%s/swtpm", cfg->stateDir);
 
         if (!(cfg->configBaseDir = virGetUserConfigDirectory()))
             return NULL;
 
-        virAsprintf(&cfg->libDir, "%s/qemu/lib", cfg->configBaseDir);
-        virAsprintf(&cfg->saveDir, "%s/qemu/save", cfg->configBaseDir);
-        virAsprintf(&cfg->snapshotDir, "%s/qemu/snapshot", cfg->configBaseDir);
-        virAsprintf(&cfg->checkpointDir, "%s/qemu/checkpoint",
-                    cfg->configBaseDir);
-        virAsprintf(&cfg->autoDumpPath, "%s/qemu/dump", cfg->configBaseDir);
-        virAsprintf(&cfg->channelTargetDir, "%s/qemu/channel/target",
-                    cfg->configBaseDir);
-        virAsprintf(&cfg->nvramDir, "%s/qemu/nvram", cfg->configBaseDir);
-        virAsprintf(&cfg->memoryBackingDir, "%s/qemu/ram", cfg->configBaseDir);
-        virAsprintf(&cfg->swtpmStorageDir, "%s/qemu/swtpm",
-                    cfg->configBaseDir);
+        cfg->libDir = g_strdup_printf("%s/qemu/lib", cfg->configBaseDir);
+        cfg->saveDir = g_strdup_printf("%s/qemu/save", cfg->configBaseDir);
+        cfg->snapshotDir = g_strdup_printf("%s/qemu/snapshot", cfg->configBaseDir);
+        cfg->checkpointDir = g_strdup_printf("%s/qemu/checkpoint",
+                                             cfg->configBaseDir);
+        cfg->autoDumpPath = g_strdup_printf("%s/qemu/dump", cfg->configBaseDir);
+        cfg->channelTargetDir = g_strdup_printf("%s/qemu/channel/target",
+                                                cfg->configBaseDir);
+        cfg->nvramDir = g_strdup_printf("%s/qemu/nvram", cfg->configBaseDir);
+        cfg->memoryBackingDir = g_strdup_printf("%s/qemu/ram", cfg->configBaseDir);
+        cfg->swtpmStorageDir = g_strdup_printf("%s/qemu/swtpm",
+                                               cfg->configBaseDir);
         cfg->swtpm_user = (uid_t)-1;
         cfg->swtpm_group = (gid_t)-1;
     }
 
-    virAsprintf(&cfg->configDir, "%s/qemu", cfg->configBaseDir);
-    virAsprintf(&cfg->autostartDir, "%s/qemu/autostart", cfg->configBaseDir);
-    virAsprintf(&cfg->slirpStateDir, "%s/slirp", cfg->stateDir);
+    cfg->configDir = g_strdup_printf("%s/qemu", cfg->configBaseDir);
+    cfg->autostartDir = g_strdup_printf("%s/qemu/autostart", cfg->configBaseDir);
+    cfg->slirpStateDir = g_strdup_printf("%s/slirp", cfg->stateDir);
 
     /* Set the default directory to find TLS X.509 certificates.
      * This will then be used as a fallback if the service specific
@@ -1354,8 +1354,8 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
                                       cfg->firmwares, cfg->nfirmwares) < 0)
             return NULL;
 
-        virAsprintf(&key, "%d:%d:%s:%s", data.arch, data.virttype,
-                    NULLSTR(data.machine), NULLSTR(data.path));
+        key = g_strdup_printf("%d:%d:%s:%s", data.arch, data.virttype,
+                              NULLSTR(data.machine), NULLSTR(data.path));
 
         if (virHashAddEntry(domCapsCache, key, domCaps) < 0)
             return NULL;
@@ -1386,7 +1386,7 @@ qemuGetSharedDeviceKey(const char *device_path)
         return NULL;
     }
 
-    virAsprintf(&key, "%d:%d", maj, min);
+    key = g_strdup_printf("%d:%d", maj, min);
 
     return key;
 }
@@ -1662,7 +1662,7 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
                                              scsihostsrc->unit)))
         return NULL;
 
-    virAsprintf(&dev_path, "/dev/%s", dev_name);
+    dev_path = g_strdup_printf("/dev/%s", dev_name);
     return dev_path;
 }
 
@@ -1839,7 +1839,7 @@ qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage)
 {
     char *ret;
 
-    virAsprintf(&ret, "%s/libvirt/qemu", hugepage->mnt_dir);
+    ret = g_strdup_printf("%s/libvirt/qemu", hugepage->mnt_dir);
 
     return ret;
 }
@@ -1854,7 +1854,7 @@ qemuGetDomainHugepagePath(const virDomainDef *def,
     char *ret = NULL;
 
     if (base && domPath)
-        virAsprintf(&ret, "%s/%s", base, domPath);
+        ret = g_strdup_printf("%s/%s", base, domPath);
     return ret;
 }
 
@@ -1906,7 +1906,7 @@ void
 qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg,
                              char **path)
 {
-    virAsprintf(path, "%s/libvirt/qemu", cfg->memoryBackingDir);
+    *path = g_strdup_printf("%s/libvirt/qemu", cfg->memoryBackingDir);
 }
 
 
@@ -1922,7 +1922,7 @@ qemuGetMemoryBackingDomainPath(const virDomainDef *def,
         return -1;
 
     qemuGetMemoryBackingBasePath(cfg, &base);
-    virAsprintf(path, "%s/%s", base, shortName);
+    *path = g_strdup_printf("%s/%s", base, shortName);
 
     return 0;
 }
@@ -1958,6 +1958,6 @@ qemuGetMemoryBackingPath(const virDomainDef *def,
     if (qemuGetMemoryBackingDomainPath(def, cfg, &domainPath) < 0)
         return -1;
 
-    virAsprintf(memPath, "%s/%s", domainPath, alias);
+    *memPath = g_strdup_printf("%s/%s", domainPath, alias);
     return 0;
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 25d4a0eb07..fe97e13c4f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2025,11 +2025,11 @@ qemuDomainSetPrivatePathsOld(virQEMUDriverPtr driver,
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 
     if (!priv->libDir)
-        virAsprintf(&priv->libDir, "%s/domain-%s", cfg->libDir, vm->def->name);
+        priv->libDir = g_strdup_printf("%s/domain-%s", cfg->libDir, vm->def->name);
 
     if (!priv->channelTargetDir)
-        virAsprintf(&priv->channelTargetDir, "%s/domain-%s",
-                    cfg->channelTargetDir, vm->def->name);
+        priv->channelTargetDir = g_strdup_printf("%s/domain-%s",
+                                                 cfg->channelTargetDir, vm->def->name);
 
     virObjectUnref(cfg);
 }
@@ -2048,11 +2048,11 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
         goto cleanup;
 
     if (!priv->libDir)
-        virAsprintf(&priv->libDir, "%s/domain-%s", cfg->libDir, domname);
+        priv->libDir = g_strdup_printf("%s/domain-%s", cfg->libDir, domname);
 
     if (!priv->channelTargetDir)
-        virAsprintf(&priv->channelTargetDir, "%s/domain-%s",
-                    cfg->channelTargetDir, domname);
+        priv->channelTargetDir = g_strdup_printf("%s/domain-%s",
+                                                 cfg->channelTargetDir, domname);
 
     ret = 0;
  cleanup:
@@ -9316,7 +9316,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
     ctxt->writefd = -1;
     ctxt->readfd = -1;
 
-    virAsprintf(&ctxt->path, "%s/%s.log", cfg->logDir, vm->def->name);
+    ctxt->path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
 
     if (cfg->stdioLogD) {
         ctxt->manager = virLogManagerNew(virQEMUDriverIsPrivileged(driver));
@@ -9496,7 +9496,7 @@ qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
     VIR_DEBUG("Append log message (vm='%s' message='%s) stdioLogD=%d",
               vm->def->name, message, cfg->stdioLogD);
 
-    virAsprintf(&path, "%s/%s.log", cfg->logDir, vm->def->name);
+    path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
 
     if (cfg->stdioLogD) {
         if (!(manager = virLogManagerNew(virQEMUDriverIsPrivileged(driver))))
@@ -9589,14 +9589,14 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
     if (newxml == NULL)
         return -1;
 
-    virAsprintf(&snapDir, "%s/%s", snapshotDir, vm->def->name);
+    snapDir = g_strdup_printf("%s/%s", snapshotDir, vm->def->name);
     if (virFileMakePath(snapDir) < 0) {
         virReportSystemError(errno, _("cannot create snapshot directory '%s'"),
                              snapDir);
         goto cleanup;
     }
 
-    virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->parent.name);
+    snapFile = g_strdup_printf("%s/%s.xml", snapDir, def->parent.name);
 
     ret = virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml);
 
@@ -9729,8 +9729,8 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
         }
     }
 
-    virAsprintf(&snapFile, "%s/%s/%s.xml", cfg->snapshotDir, vm->def->name,
-                snap->def->name);
+    snapFile = g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir, vm->def->name,
+                               snap->def->name);
 
     if (snap == virDomainSnapshotGetCurrent(vm->snapshots)) {
         virDomainSnapshotSetCurrent(vm->snapshots, NULL);
@@ -9818,7 +9818,7 @@ qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver,
         VIR_WARN("unable to remove all snapshots for domain %s",
                  vm->def->name);
     } else {
-        virAsprintf(&snapDir, "%s/%s", cfg->snapshotDir, vm->def->name);
+        snapDir = g_strdup_printf("%s/%s", cfg->snapshotDir, vm->def->name);
 
         if (rmdir(snapDir) < 0 && errno != ENOENT)
             VIR_WARN("unable to remove snapshot directory %s", snapDir);
@@ -9828,8 +9828,8 @@ qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver,
         VIR_WARN("unable to remove all checkpoints for domain %s",
                  vm->def->name);
     } else {
-        virAsprintf(&chkDir, "%s/%s", cfg->checkpointDir,
-                    vm->def->name);
+        chkDir = g_strdup_printf("%s/%s", cfg->checkpointDir,
+                                 vm->def->name);
         if (rmdir(chkDir) < 0 && errno != ENOENT)
             VIR_WARN("unable to remove checkpoint directory %s", chkDir);
     }
@@ -10177,7 +10177,7 @@ qemuDomainStorageAlias(const char *device, int depth)
     if (!depth)
         alias = g_strdup(device);
     else
-        virAsprintf(&alias, "%s.%d", device, depth);
+        alias = g_strdup_printf("%s.%d", device, depth);
     return alias;
 }
 
@@ -11726,8 +11726,8 @@ ppc64VFIODeviceIsNV2Bridge(const char *device)
     for (i = 0; i < G_N_ELEMENTS(nvlink2Files); i++) {
         g_autofree char *file = NULL;
 
-        virAsprintf(&file, "/sys/bus/pci/devices/%s/of_node/%s",
-                    device, nvlink2Files[i]);
+        file = g_strdup_printf("/sys/bus/pci/devices/%s/of_node/%s",
+                               device, nvlink2Files[i]);
 
         if (!virFileExists(file))
             return false;
@@ -12406,15 +12406,15 @@ qemuDomainPrepareChannel(virDomainChrDefPtr channel,
         return 0;
 
     if (channel->target.name) {
-        virAsprintf(&channel->source->data.nix.path, "%s/%s",
-                    domainChannelTargetDir, channel->target.name);
+        channel->source->data.nix.path = g_strdup_printf("%s/%s",
+                                                         domainChannelTargetDir, channel->target.name);
     } else {
         /* Generate a unique name */
-        virAsprintf(&channel->source->data.nix.path,
-                    "%s/vioser-%02d-%02d-%02d.sock", domainChannelTargetDir,
-                    channel->info.addr.vioserial.controller,
-                    channel->info.addr.vioserial.bus,
-                    channel->info.addr.vioserial.port);
+        channel->source->data.nix.path = g_strdup_printf(
+                                                         "%s/vioser-%02d-%02d-%02d.sock", domainChannelTargetDir,
+                                                         channel->info.addr.vioserial.controller,
+                                                         channel->info.addr.vioserial.bus,
+                                                         channel->info.addr.vioserial.port);
     }
 
     return 0;
@@ -12604,9 +12604,9 @@ qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
         shmem->server.chr.data.nix.path)
         return;
 
-    virAsprintf(&shmem->server.chr.data.nix.path,
-                "/var/lib/libvirt/shmem-%s-sock",
-                shmem->name);
+    shmem->server.chr.data.nix.path = g_strdup_printf(
+                                                      "/var/lib/libvirt/shmem-%s-sock",
+                                                      shmem->name);
 }
 
 
@@ -12932,7 +12932,7 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
     if (STREQ(mountpoint, "/dev"))
         suffix = "dev";
 
-    virAsprintf(&path, "%s/%s.%s", cfg->stateDir, domname, suffix);
+    path = g_strdup_printf("%s/%s.%s", cfg->stateDir, domname, suffix);
 
     /* Now consider that @mountpoint is "/dev/blah/blah2".
      * @suffix then points to "blah/blah2". However, caller
@@ -13112,8 +13112,8 @@ qemuDomainCreateDeviceRecursive(const char *device,
         if (i == data->ndevMountsPath) {
             /* Okay, @device is in /dev but not in any mount point under /dev.
              * Create it. */
-            virAsprintf(&devicePath, "%s/%s", data->path,
-                        device + strlen(QEMU_DEVPREFIX));
+            devicePath = g_strdup_printf("%s/%s", data->path,
+                                         device + strlen(QEMU_DEVPREFIX));
 
             if (virFileMakeParentPath(devicePath) < 0) {
                 virReportSystemError(errno,
@@ -13167,7 +13167,7 @@ qemuDomainCreateDeviceRecursive(const char *device,
             if ((c = strrchr(devTmp, '/')))
                 *(c + 1) = '\0';
 
-            virAsprintf(&tmp, "%s%s", devTmp, target);
+            tmp = g_strdup_printf("%s%s", devTmp, target);
             VIR_FREE(devTmp);
             VIR_FREE(target);
             target = g_steal_pointer(&tmp);
@@ -13330,7 +13330,7 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg,
      * tmpfs is limited to 64kb, since we only have device nodes in there
      * and don't want to DOS the entire OS RAM usage
      */
-    virAsprintf(&opts, "mode=755,size=65536%s", mount_options);
+    opts = g_strdup_printf("mode=755,size=65536%s", mount_options);
 
     if (virFileSetupDev(data->path, opts) < 0)
         goto cleanup;
@@ -14139,7 +14139,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
             if ((c = strrchr(fileTmp, '/')))
                 *(c + 1) = '\0';
 
-            virAsprintf(&tmp, "%s%s", fileTmp, target);
+            tmp = g_strdup_printf("%s%s", fileTmp, target);
             VIR_FREE(fileTmp);
             VIR_FREE(target);
             target = g_steal_pointer(&tmp);
@@ -14695,7 +14695,7 @@ qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
     char *ret = NULL;
 
     if (idx)
-        virAsprintf(&ret, "%s[%d]", disk->dst, idx);
+        ret = g_strdup_printf("%s[%d]", disk->dst, idx);
     else
         ret = g_strdup(disk->dst);
 
@@ -15138,8 +15138,8 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
 {
     src->id = qemuDomainStorageIdNew(priv);
 
-    virAsprintf(&src->nodestorage, "libvirt-%u-storage", src->id);
-    virAsprintf(&src->nodeformat, "libvirt-%u-format", src->id);
+    src->nodestorage = g_strdup_printf("libvirt-%u-storage", src->id);
+    src->nodeformat = g_strdup_printf("libvirt-%u-format", src->id);
 
     if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
         return -1;
@@ -15173,7 +15173,7 @@ qemuDomainPrepareDiskSourceBlockdev(virDomainDiskDefPtr disk,
 
     if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON &&
         !diskPriv->nodeCopyOnRead)
-        virAsprintf(&diskPriv->nodeCopyOnRead, "libvirt-CoR-%s", disk->dst);
+        diskPriv->nodeCopyOnRead = g_strdup_printf("libvirt-CoR-%s", disk->dst);
 
     for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
         if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
@@ -15326,7 +15326,7 @@ qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv)
 {
     char *ret = NULL;
 
-    virAsprintf(&ret, "%s/%s.sock", priv->libDir, qemuDomainGetManagedPRAlias());
+    ret = g_strdup_printf("%s/%s.sock", priv->libDir, qemuDomainGetManagedPRAlias());
 
     return ret;
 }
@@ -15418,7 +15418,7 @@ qemuDomainNVRAMPathFormat(virQEMUDriverConfigPtr cfg,
                             virDomainDefPtr def,
                             char **path)
 {
-    virAsprintf(path, "%s/%s_VARS.fd", cfg->nvramDir, def->name);
+    *path = g_strdup_printf("%s/%s_VARS.fd", cfg->nvramDir, def->name);
 }
 
 
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1bf0c63eb1..708e1041a3 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -154,7 +154,7 @@ qemuDomainDetachZPCIDevice(qemuMonitorPtr mon,
 {
     g_autofree char *zpciAlias = NULL;
 
-    virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci.uid);
+    zpciAlias = g_strdup_printf("zpci%d", info->addr.pci.zpci.uid);
 
     if (qemuMonitorDelDevice(mon, zpciAlias) < 0)
         return -1;
@@ -1307,7 +1307,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
             }
 
             slirpfd = qemuSlirpGetFD(slirp);
-            virAsprintf(&slirpfdName, "slirpfd-%s", net->info.alias);
+            slirpfdName = g_strdup_printf("slirpfd-%s", net->info.alias);
         }
         break;
 
@@ -1356,10 +1356,10 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         goto cleanup;
 
     for (i = 0; i < tapfdSize; i++)
-        virAsprintf(&tapfdName[i], "fd-%s%zu", net->info.alias, i);
+        tapfdName[i] = g_strdup_printf("fd-%s%zu", net->info.alias, i);
 
     for (i = 0; i < vhostfdSize; i++)
-        virAsprintf(&vhostfdName[i], "vhostfd-%s%zu", net->info.alias, i);
+        vhostfdName[i] = g_strdup_printf("vhostfd-%s%zu", net->info.alias, i);
 
     if (!(netstr = qemuBuildHostNetStr(net,
                                        tapfdName, tapfdSize,
@@ -1502,7 +1502,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         goto cleanup;
 
     virErrorPreserveLast(&originalError);
-    virAsprintf(&netdev_name, "host%s", net->info.alias);
+    netdev_name = g_strdup_printf("host%s", net->info.alias);
     if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp)
         qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver, net, true);
     qemuDomainObjEnterMonitor(driver, vm);
@@ -2353,7 +2353,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
     if (qemuAssignDeviceMemoryAlias(vm->def, mem, priv->memAliasOrderMismatch) < 0)
         goto cleanup;
 
-    virAsprintf(&objalias, "mem%s", mem->info.alias);
+    objalias = g_strdup_printf("mem%s", mem->info.alias);
 
     if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv)))
         goto cleanup;
@@ -2699,7 +2699,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
     if (virSCSIVHostOpenVhostSCSI(&vhostfd) < 0)
         goto cleanup;
 
-    virAsprintf(&vhostfdName, "vhostfd-%d", vhostfd);
+    vhostfdName = g_strdup_printf("vhostfd-%d", vhostfd);
 
     if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
         if (qemuDomainIsS390CCW(vm->def) &&
@@ -2970,7 +2970,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
         goto cleanup;
 
     if (shmem->server.enabled) {
-        virAsprintf(&charAlias, "char%s", shmem->info.alias);
+        charAlias = g_strdup_printf("char%s", shmem->info.alias);
     } else {
         if (!(props = qemuBuildShmemBackendMemProps(shmem)))
             goto cleanup;
@@ -3242,7 +3242,7 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver,
     if (qemuProcessOpenVhostVsock(vsock) < 0)
         goto cleanup;
 
-    virAsprintf(&fdname, "%s%u", fdprefix, vsockPriv->vhostfd);
+    fdname = g_strdup_printf("%s%u", fdprefix, vsockPriv->vhostfd);
 
     if (!(devstr = qemuBuildVsockDevStr(vm->def, vsock, priv->qemuCaps, fdprefix)))
         goto cleanup;
@@ -3975,7 +3975,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
         (auth->expires && auth->validTo <= now)) {
         expire = "now";
     } else if (auth->expires) {
-        virAsprintf(&validTo, "%lu", (unsigned long)auth->validTo);
+        validTo = g_strdup_printf("%lu", (unsigned long)auth->validTo);
         expire = validTo;
     } else {
         expire = "never";
@@ -4330,7 +4330,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
     VIR_DEBUG("Removing memory device %s from domain %p %s",
               mem->info.alias, vm, vm->def->name);
 
-    virAsprintf(&backendAlias, "mem%s", mem->info.alias);
+    backendAlias = g_strdup_printf("mem%s", mem->info.alias);
 
     qemuDomainObjEnterMonitor(driver, vm);
     rc = qemuMonitorDelObject(priv->mon, backendAlias);
@@ -4548,7 +4548,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
     VIR_DEBUG("Removing network interface %s from domain %p %s",
               net->info.alias, vm, vm->def->name);
 
-    virAsprintf(&hostnet_name, "host%s", net->info.alias);
+    hostnet_name = g_strdup_printf("host%s", net->info.alias);
     if (!(charDevAlias = qemuAliasChardevFromDevAlias(net->info.alias)))
         return -1;
 
@@ -4703,7 +4703,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
               rng->info.alias, vm, vm->def->name);
 
 
-    virAsprintf(&objAlias, "obj%s", rng->info.alias);
+    objAlias = g_strdup_printf("obj%s", rng->info.alias);
 
     if (!(charAlias = qemuAliasChardevFromDevAlias(rng->info.alias)))
         return -1;
@@ -4762,9 +4762,9 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver,
               shmem->info.alias, vm, vm->def->name);
 
     if (shmem->server.enabled) {
-        virAsprintf(&charAlias, "char%s", shmem->info.alias);
+        charAlias = g_strdup_printf("char%s", shmem->info.alias);
     } else {
-        virAsprintf(&memAlias, "shmmem-%s", shmem->info.alias);
+        memAlias = g_strdup_printf("shmmem-%s", shmem->info.alias);
     }
 
     qemuDomainObjEnterMonitor(driver, vm);
@@ -6005,7 +6005,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
     size_t i;
 
     if (newhotplug) {
-        virAsprintf(&vcpupriv->alias, "vcpu%u", vcpu);
+        vcpupriv->alias = g_strdup_printf("vcpu%u", vcpu);
 
         if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpuinfo)))
             goto cleanup;
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index 8377b4d01d..dff4b3d76d 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -365,7 +365,7 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg,
         virCommandAbort(cmd);
 
         if (errbuf && *errbuf)
-            virAsprintf(&errstr, "\nstderr=%s", errbuf);
+            errstr = g_strdup_printf("\nstderr=%s", errbuf);
 
         virReportError(VIR_ERR_INTERNAL_ERROR,
             _("%s: failed to communicate with bridge helper: %s%s"),
diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c
index 00b86fde83..cbabde45df 100644
--- a/src/qemu/qemu_interop_config.c
+++ b/src/qemu/qemu_interop_config.c
@@ -57,7 +57,7 @@ qemuBuildFileList(virHashTablePtr files, const char *dir)
 
         filename = g_strdup(ent->d_name);
 
-        virAsprintf(&path, "%s/%s", dir, filename);
+        path = g_strdup_printf("%s/%s", dir, filename);
 
         if (stat(path, &sb) < 0) {
             virReportSystemError(errno, _("Unable to access %s"), path);
@@ -121,10 +121,10 @@ qemuInteropFetchConfigs(const char *name,
             if (!home)
                 return -1;
 
-            virAsprintf(&xdgConfig, "%s/.config", home);
+            xdgConfig = g_strdup_printf("%s/.config", home);
         }
 
-        virAsprintf(&homeConfig, "%s/qemu/%s", xdgConfig, name);
+        homeConfig = g_strdup_printf("%s/qemu/%s", xdgConfig, name);
     }
 
     if (!(files = virHashCreate(10, virHashValueFree)))
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index aad2f77cb7..0447aa73bf 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -818,8 +818,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
 
     copysrc->tlsAlias = g_strdup(tlsAlias);
 
-    virAsprintf(&copysrc->nodestorage, "migration-%s-storage", disk->dst);
-    virAsprintf(&copysrc->nodeformat, "migration-%s-format", disk->dst);
+    copysrc->nodestorage = g_strdup_printf("migration-%s-storage", disk->dst);
+    copysrc->nodeformat = g_strdup_printf("migration-%s-format", disk->dst);
 
     /* Migration via blockdev-mirror was supported sooner than the auto-read-only
      * feature was added to qemu */
@@ -864,11 +864,11 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriverPtr driver,
     int mon_ret;
 
     if (strchr(host, ':')) {
-        virAsprintf(&nbd_dest, "nbd:[%s]:%d:exportname=%s", host, port,
-                    diskAlias);
+        nbd_dest = g_strdup_printf("nbd:[%s]:%d:exportname=%s", host, port,
+                                   diskAlias);
     } else {
-        virAsprintf(&nbd_dest, "nbd:%s:%d:exportname=%s", host, port,
-                    diskAlias);
+        nbd_dest = g_strdup_printf("nbd:%s:%d:exportname=%s", host, port,
+                                   diskAlias);
     }
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm,
@@ -1831,7 +1831,7 @@ qemuMigrationDstGetURI(const char *migrateFrom,
     char *uri = NULL;
 
     if (STREQ(migrateFrom, "stdio"))
-        virAsprintf(&uri, "fd:%d", migrateFd);
+        uri = g_strdup_printf("fd:%d", migrateFd);
     else
         uri = g_strdup(migrateFrom);
 
@@ -2255,7 +2255,7 @@ qemuMigrationDstPrepare(virDomainObjPtr vm,
             incFormat = "%s:[%s]:%d";
         else
             incFormat = "%s:%s:%d";
-        virAsprintf(&migrateFrom, incFormat, protocol, listenAddress, port);
+        migrateFrom = g_strdup_printf(incFormat, protocol, listenAddress, port);
     }
 
     inc = qemuProcessIncomingDefNew(priv->qemuCaps, listenAddress,
@@ -2695,7 +2695,7 @@ qemuMigrationAnyParseURI(const char *uri, bool *wellFormed)
     /* For compatibility reasons tcp://... URIs are sent as tcp:...
      * We need to transform them to a well-formed URI before parsing. */
     if (STRPREFIX(uri, "tcp:") && !STRPREFIX(uri + 4, "//")) {
-        virAsprintf(&tmp, "tcp://%s", uri + 4);
+        tmp = g_strdup_printf("tcp://%s", uri + 4);
         uri = tmp;
     }
 
@@ -2790,7 +2790,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver,
         else
             incFormat = "%s:%s:%d";
 
-        virAsprintf(uri_out, incFormat, "tcp", hostname, port);
+        *uri_out = g_strdup_printf(incFormat, "tcp", hostname, port);
     } else {
         bool well_formed_uri;
 
@@ -2828,7 +2828,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver,
                 if (!(*uri_out = virURIFormat(uri)))
                     goto cleanup;
             } else {
-                virAsprintf(uri_out, "%s:%d", uri_in, port);
+                *uri_out = g_strdup_printf("%s:%d", uri_in, port);
             }
         } else {
             port = uri->port;
@@ -3294,7 +3294,7 @@ qemuMigrationSrcConnect(virQEMUDriverPtr driver,
     int ret = -1;
 
     host = spec->dest.host.name;
-    virAsprintf(&port, "%d", spec->dest.host.port);
+    port = g_strdup_printf("%d", spec->dest.host.port);
 
     spec->destType = MIGRATION_DEST_FD;
     spec->dest.fd.qemu = -1;
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 990f2b06d0..1e2babf325 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -141,7 +141,7 @@ qemuDomainExtractTLSSubject(const char *certdir)
     int ret;
     size_t subjectlen;
 
-    virAsprintf(&certfile, "%s/server-cert.pem", certdir);
+    certfile = g_strdup_printf("%s/server-cert.pem", certdir);
 
     if (virFileReadAll(certfile, 8192, &pemdata) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 6495447188..c533819f4d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -961,7 +961,7 @@ qemuMonitorNextCommandID(qemuMonitorPtr mon)
 {
     char *id;
 
-    virAsprintf(&id, "libvirt-%d", ++mon->nextSerial);
+    id = g_strdup_printf("libvirt-%d", ++mon->nextSerial);
     return id;
 }
 
@@ -2560,8 +2560,8 @@ qemuMonitorMigrateToHost(qemuMonitorPtr mon,
     QEMU_CHECK_MONITOR(mon);
 
     if (strchr(hostname, ':')) {
-        virAsprintf(&uri, "%s:[%s]:%d", protocol, hostname, port);
-    } else virAsprintf(&uri, "%s:%s:%d", protocol, hostname, port);
+        uri = g_strdup_printf("%s:[%s]:%d", protocol, hostname, port);
+    } else uri = g_strdup_printf("%s:%s:%d", protocol, hostname, port);
 
     ret = qemuMonitorJSONMigrate(mon, flags, uri);
 
@@ -4246,20 +4246,20 @@ qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info)
 
     switch (info->type) {
     case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV:
-        virAsprintf(&ret,
-                    "hyper-v: arg1='0x%llx', arg2='0x%llx', "
-                    "arg3='0x%llx', arg4='0x%llx', arg5='0x%llx'",
-                    info->data.hyperv.arg1, info->data.hyperv.arg2,
-                    info->data.hyperv.arg3, info->data.hyperv.arg4,
-                    info->data.hyperv.arg5);
+        ret = g_strdup_printf(
+                              "hyper-v: arg1='0x%llx', arg2='0x%llx', "
+                              "arg3='0x%llx', arg4='0x%llx', arg5='0x%llx'",
+                              info->data.hyperv.arg1, info->data.hyperv.arg2,
+                              info->data.hyperv.arg3, info->data.hyperv.arg4,
+                              info->data.hyperv.arg5);
         break;
     case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390:
-        virAsprintf(&ret, "s390: core='%d' psw-mask='0x%016llx' "
-                    "psw-addr='0x%016llx' reason='%s'",
-                    info->data.s390.core,
-                    info->data.s390.psw_mask,
-                    info->data.s390.psw_addr,
-                    info->data.s390.reason);
+        ret = g_strdup_printf("s390: core='%d' psw-mask='0x%016llx' "
+                              "psw-addr='0x%016llx' reason='%s'",
+                              info->data.s390.core,
+                              info->data.s390.psw_mask,
+                              info->data.s390.psw_addr,
+                              info->data.s390.reason);
         break;
     case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE:
     case QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST:
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 697b302a7c..ab49cb5f54 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7120,7 +7120,7 @@ qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
 
     switch ((virStorageNetHostTransport)server->transport) {
     case VIR_STORAGE_NET_HOST_TRANS_TCP:
-        virAsprintf(&port_str, "%u", server->port);
+        port_str = g_strdup_printf("%u", server->port);
         addr = qemuMonitorJSONBuildInetSocketAddress(server->name, port_str);
         break;
     case VIR_STORAGE_NET_HOST_TRANS_UNIX:
@@ -8051,7 +8051,7 @@ qemuMonitorJSONSetIOThread(qemuMonitorPtr mon,
     char *path = NULL;
     qemuMonitorJSONObjectProperty prop;
 
-    virAsprintf(&path, "/objects/iothread%u", iothreadInfo->iothread_id);
+    path = g_strdup_printf("/objects/iothread%u", iothreadInfo->iothread_id);
 
 #define VIR_IOTHREAD_SET_PROP(propName, propVal) \
     if (iothreadInfo->set_##propVal) { \
@@ -8209,11 +8209,11 @@ qemuMonitorJSONFindObjectPathByAlias(qemuMonitorPtr mon,
     if (npaths < 0)
         return -1;
 
-    virAsprintf(&child, "child<%s>", name);
+    child = g_strdup_printf("child<%s>", name);
 
     for (i = 0; i < npaths; i++) {
         if (STREQ(paths[i]->name, alias) && STREQ(paths[i]->type, child)) {
-            virAsprintf(path, "/machine/peripheral/%s", alias);
+            *path = g_strdup_printf("/machine/peripheral/%s", alias);
 
             ret = 0;
             goto cleanup;
@@ -8265,7 +8265,7 @@ qemuMonitorJSONFindObjectPathByName(qemuMonitorPtr mon,
         if (STREQ_NULLABLE(paths[i]->type, name)) {
             VIR_DEBUG("Path to '%s' is '%s/%s'", name, curpath, paths[i]->name);
             ret = 0;
-            virAsprintf(path, "%s/%s", curpath, paths[i]->name);
+            *path = g_strdup_printf("%s/%s", curpath, paths[i]->name);
             goto cleanup;
         }
 
@@ -8273,7 +8273,7 @@ qemuMonitorJSONFindObjectPathByName(qemuMonitorPtr mon,
          * traversed looking for more entries
          */
         if (paths[i]->type && STRPREFIX(paths[i]->type, "child<")) {
-            virAsprintf(&nextpath, "%s/%s", curpath, paths[i]->name);
+            nextpath = g_strdup_printf("%s/%s", curpath, paths[i]->name);
 
             ret = qemuMonitorJSONFindObjectPathByName(mon, nextpath, name, path);
             VIR_FREE(nextpath);
@@ -8316,7 +8316,7 @@ qemuMonitorJSONFindLinkPath(qemuMonitorPtr mon,
             return ret;
     }
 
-    virAsprintf(&linkname, "link<%s>", name);
+    linkname = g_strdup_printf("link<%s>", name);
 
     ret = qemuMonitorJSONFindObjectPathByName(mon, "/", linkname, path);
     VIR_FREE(linkname);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index a5b2d2ccfd..9054682d60 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -42,7 +42,7 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
 
     /* 'dummy' here is just a placeholder since there is no PCI
      * address required when attaching drives to a controller */
-    virAsprintf(&cmd, "drive_add dummy %s", drivestr);
+    cmd = g_strdup_printf("drive_add dummy %s", drivestr);
 
     if (qemuMonitorJSONHumanCommand(mon, cmd, &reply) < 0)
         goto cleanup;
@@ -91,7 +91,7 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
     char *reply = NULL;
     int ret = -1;
 
-    virAsprintf(&cmd, "drive_del %s", drivestr);
+    cmd = g_strdup_printf("drive_del %s", drivestr);
 
     if (qemuMonitorJSONHumanCommand(mon, cmd, &reply) < 0)
         goto cleanup;
@@ -129,7 +129,7 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon,
     char *reply = NULL;
     int ret = -1;
 
-    virAsprintf(&cmd, "savevm \"%s\"", name);
+    cmd = g_strdup_printf("savevm \"%s\"", name);
 
     if (qemuMonitorJSONHumanCommand(mon, cmd, &reply))
         goto cleanup;
@@ -163,7 +163,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
     int ret = -1;
     char *safename;
 
-    virAsprintf(&cmd, "loadvm \"%s\"", name);
+    cmd = g_strdup_printf("loadvm \"%s\"", name);
 
     if (qemuMonitorJSONHumanCommand(mon, cmd, &reply))
         goto cleanup;
@@ -206,7 +206,7 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
     char *reply = NULL;
     int ret = -1;
 
-    virAsprintf(&cmd, "delvm \"%s\"", name);
+    cmd = g_strdup_printf("delvm \"%s\"", name);
     if (qemuMonitorJSONHumanCommand(mon, cmd, &reply))
         goto cleanup;
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 925fc44a70..0917ad98d1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -108,7 +108,7 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 
-    virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name);
+    file = g_strdup_printf("%s/%s.xml", cfg->stateDir, vm->def->name);
 
     if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
         VIR_WARN("Failed to remove domain XML for %s: %s",
@@ -2098,7 +2098,7 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
             qemuMonitorChardevInfoPtr entry;
 
             VIR_FREE(id);
-            virAsprintf(&id, "char%s", chr->info.alias);
+            id = g_strdup_printf("char%s", chr->info.alias);
 
             entry = virHashLookup(info, id);
             if (!entry || !entry->ptyPath) {
@@ -2187,7 +2187,7 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
         if (chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
 
             VIR_FREE(id);
-            virAsprintf(&id, "char%s", chr->info.alias);
+            id = g_strdup_printf("char%s", chr->info.alias);
 
             /* port state not reported */
             if (!(entry = virHashLookup(info, id)) ||
@@ -3194,7 +3194,7 @@ qemuProcessPrepareMonitorChr(virDomainChrSourceDefPtr monConfig,
     monConfig->type = VIR_DOMAIN_CHR_TYPE_UNIX;
     monConfig->data.nix.listen = true;
 
-    virAsprintf(&monConfig->data.nix.path, "%s/monitor.sock", domainDir);
+    monConfig->data.nix.path = g_strdup_printf("%s/monitor.sock", domainDir);
     return 0;
 }
 
@@ -3400,8 +3400,8 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
         } else {
             newState = VIR_DOMAIN_PAUSED;
             newReason = reason;
-            virAsprintf(&msg, "was paused (%s)",
-                        virDomainPausedReasonTypeToString(reason));
+            msg = g_strdup_printf("was paused (%s)",
+                                  virDomainPausedReasonTypeToString(reason));
         }
     }
 
@@ -4066,7 +4066,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
         if (def->hyperv_features[i] != VIR_TRISTATE_SWITCH_ON)
             continue;
 
-        virAsprintf(&cpuFeature, "hv-%s", virDomainHypervTypeToString(i));
+        cpuFeature = g_strdup_printf("hv-%s", virDomainHypervTypeToString(i));
 
         rc = virCPUDataCheckFeature(cpu, cpuFeature);
         VIR_FREE(cpuFeature);
@@ -4898,8 +4898,8 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
                  * default instead of tcp listen. */
                 if (useSocket) {
                     memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
-                    virAsprintf(&glisten->socket, "%s/%s.sock", priv->libDir,
-                                type);
+                    glisten->socket = g_strdup_printf("%s/%s.sock", priv->libDir,
+                                                      type);
                     glisten->fromConfig = true;
                     glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
                 } else if (listenAddr) {
@@ -4920,8 +4920,8 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
 
         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
             if (!glisten->socket) {
-                virAsprintf(&glisten->socket, "%s/%s.sock", priv->libDir,
-                            type);
+                glisten->socket = g_strdup_printf("%s/%s.sock", priv->libDir,
+                                                  type);
                 glisten->autoGenerated = true;
             }
             break;
@@ -5998,7 +5998,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriverPtr driver,
 
         if (vcpu->hotpluggable == VIR_TRISTATE_BOOL_YES && vcpu->online &&
             vcpupriv->vcpus != 0) {
-            virAsprintf(&vcpupriv->alias, "vcpu%zu", i);
+            vcpupriv->alias = g_strdup_printf("vcpu%zu", i);
 
             if (VIR_APPEND_ELEMENT(bootHotplug, nbootHotplug, vcpu) < 0)
                 goto cleanup;
@@ -8480,7 +8480,7 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
 
     VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
 
-    virAsprintf(&template, "%s/qmp-XXXXXX", proc->libDir);
+    template = g_strdup_printf("%s/qmp-XXXXXX", proc->libDir);
 
     if (!(proc->uniqDir = mkdtemp(template))) {
         virReportSystemError(errno,
@@ -8493,16 +8493,16 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
     if (qemuProcessQEMULabelUniqPath(proc) < 0)
         goto cleanup;
 
-    virAsprintf(&proc->monpath, "%s/%s", proc->uniqDir, "qmp.monitor");
+    proc->monpath = g_strdup_printf("%s/%s", proc->uniqDir, "qmp.monitor");
 
-    virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath);
+    proc->monarg = g_strdup_printf("unix:%s,server,nowait", proc->monpath);
 
     /*
      * Normally we'd use runDir for pid files, but because we're using
      * -daemonize we need QEMU to be allowed to create them, rather
      * than libvirtd. So we're using libDir which QEMU can write to
      */
-    virAsprintf(&proc->pidfile, "%s/%s", proc->uniqDir, "qmp.pid");
+    proc->pidfile = g_strdup_printf("%s/%s", proc->uniqDir, "qmp.pid");
 
     ret = 0;
 
diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c
index c08a365548..5266b36eaa 100644
--- a/src/qemu/qemu_slirp.c
+++ b/src/qemu/qemu_slirp.c
@@ -156,7 +156,7 @@ qemuSlirpCreatePidFilename(virQEMUDriverConfigPtr cfg,
     if (!(shortName = virDomainDefGetShortName(def)))
         return NULL;
 
-    virAsprintf(&name, "%s-%s-slirp", shortName, alias);
+    name = g_strdup_printf("%s-%s-slirp", shortName, alias);
 
     return virPidFileBuildPath(cfg->slirpStateDir, name);
 }
@@ -210,7 +210,7 @@ qemuSlirpGetDBusVMStateId(virDomainNetDefPtr net)
     char *id = NULL;
 
     /* can't use alias, because it's not stable across restarts */
-    virAsprintf(&id, "slirp-%s", virMacAddrFormat(&net->mac, macstr));
+    id = g_strdup_printf("slirp-%s", virMacAddrFormat(&net->mac, macstr));
 
     return id;
 }
@@ -227,8 +227,8 @@ qemuSlirpGetDBusPath(virQEMUDriverConfigPtr cfg,
     if (!(shortName = virDomainDefGetShortName(def)))
         return NULL;
 
-    virAsprintf(&path, "%s/%s-%s-slirp",
-                cfg->slirpStateDir, shortName, alias);
+    path = g_strdup_printf("%s/%s-%s-slirp",
+                           cfg->slirpStateDir, shortName, alias);
 
     return path;
 }
@@ -380,7 +380,7 @@ qemuSlirpStart(qemuSlirpPtr slirp,
             return -1;
         }
 
-        virAsprintf(&dbus_addr, "unix:path=%s", dbus_path);
+        dbus_addr = g_strdup_printf("unix:path=%s", dbus_path);
 
         virCommandAddArgFormat(cmd, "--dbus-id=%s", id);
 
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
index d6d418533c..62b9f803bd 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -78,7 +78,7 @@ qemuTPMCreateEmulatorStoragePath(const char *swtpmStorageDir,
         return NULL;
     }
 
-    virAsprintf(&path, "%s/%s/%s", swtpmStorageDir, uuidstr, dir);
+    path = g_strdup_printf("%s/%s/%s", swtpmStorageDir, uuidstr, dir);
     return path;
 }
 
@@ -206,7 +206,7 @@ qemuTPMCreateEmulatorSocket(const char *swtpmStateDir,
 {
     char *path = NULL;
 
-    virAsprintf(&path, "%s/%s-swtpm.sock", swtpmStateDir, shortName);
+    path = g_strdup_printf("%s/%s-swtpm.sock", swtpmStateDir, shortName);
 
     return path;
 }
@@ -249,7 +249,7 @@ qemuTPMEmulatorCreatePidFilename(const char *swtpmStateDir,
     char *pidfile = NULL;
     char *devicename = NULL;
 
-    virAsprintf(&devicename, "%s-swtpm", shortName);
+    devicename = g_strdup_printf("%s-swtpm", shortName);
 
     pidfile = virPidFileBuildPath(swtpmStateDir, devicename);
 
@@ -332,7 +332,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
 
     /* create logfile name ... */
     if (!tpm->data.emulator.logfile)
-        virAsprintf(&tpm->data.emulator.logfile, "%s/%s-swtpm.log", logDir, vmname);
+        tpm->data.emulator.logfile = g_strdup_printf("%s/%s-swtpm.log", logDir, vmname);
 
     if (!virFileExists(tpm->data.emulator.logfile) &&
         virFileTouch(tpm->data.emulator.logfile, 0644) < 0) {
@@ -486,7 +486,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath,
         goto cleanup;
 
     virUUIDFormat(vmuuid, uuid);
-    virAsprintf(&vmid, "%s:%s", vmname, uuid);
+    vmid = g_strdup_printf("%s:%s", vmname, uuid);
 
     virCommandSetUID(cmd, swtpm_user);
     virCommandSetGID(cmd, swtpm_group);
diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c
index 7355ae70f8..37e424eac3 100644
--- a/src/qemu/qemu_vhost_user_gpu.c
+++ b/src/qemu/qemu_vhost_user_gpu.c
@@ -47,7 +47,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
 {
     g_autofree char *devicename = NULL;
 
-    virAsprintf(&devicename, "%s-%s-vhost-user-gpu", shortName, alias);
+    devicename = g_strdup_printf("%s-%s-vhost-user-gpu", shortName, alias);
 
     return virPidFileBuildPath(stateDir, devicename);
 }
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux