bhyve: Use g_strdup_printf() instead of virAsprintf()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2019-10-22 15:26:14 +02:00
parent 87af7ff8b7
commit 89b6825189
2 changed files with 7 additions and 16 deletions

View File

@ -159,11 +159,8 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn,
firmwares_alloc, firmwares->nvalues, 1) < 0) firmwares_alloc, firmwares->nvalues, 1) < 0)
goto cleanup; goto cleanup;
if (virAsprintf( firmwares->values[firmwares->nvalues] = g_strdup_printf("%s/%s",
&firmwares->values[firmwares->nvalues], firmware_dir, entry->d_name);
"%s/%s", firmware_dir, entry->d_name) < 0)
goto cleanup;
firmwares->nvalues++; firmwares->nvalues++;
} }
} else { } else {

View File

@ -86,11 +86,10 @@ bhyveNetCleanup(virDomainObjPtr vm)
} }
} }
static int static void
virBhyveFormatDevMapFile(const char *vm_name, char **fn_out) virBhyveFormatDevMapFile(const char *vm_name, char **fn_out)
{ {
return virAsprintf(fn_out, "%s/grub_bhyve-%s-device.map", BHYVE_STATE_DIR, *fn_out = g_strdup_printf("%s/grub_bhyve-%s-device.map", BHYVE_STATE_DIR, vm_name);
vm_name);
} }
int int
@ -113,9 +112,7 @@ virBhyveProcessStart(virConnectPtr conn,
int ret = -1, rc; int ret = -1, rc;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
if (virAsprintf(&logfile, "%s/%s.log", logfile = g_strdup_printf("%s/%s.log", BHYVE_LOG_DIR, vm->def->name);
BHYVE_LOG_DIR, vm->def->name) < 0)
return -1;
caps = bhyveDriverGetCapabilities(privconn); caps = bhyveDriverGetCapabilities(privconn);
if (!caps) if (!caps)
@ -165,9 +162,7 @@ virBhyveProcessStart(virConnectPtr conn,
* domain is ready to be started, so we can build * domain is ready to be started, so we can build
* and execute bhyveload command */ * and execute bhyveload command */
rc = virBhyveFormatDevMapFile(vm->def->name, &devmap_file); virBhyveFormatDevMapFile(vm->def->name, &devmap_file);
if (rc < 0)
goto cleanup;
if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def, devmap_file, if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def, devmap_file,
&devicemap))) &devicemap)))
@ -408,8 +403,7 @@ virBhyveProcessReconnect(virDomainObjPtr vm,
if (kp == NULL || nprocs != 1) if (kp == NULL || nprocs != 1)
goto cleanup; goto cleanup;
if (virAsprintf(&expected_proctitle, "bhyve: %s", vm->def->name) < 0) expected_proctitle = g_strdup_printf("bhyve: %s", vm->def->name);
goto cleanup;
proc_argv = kvm_getargv(data->kd, kp, 0); proc_argv = kvm_getargv(data->kd, kp, 0);
if (proc_argv && proc_argv[0]) { if (proc_argv && proc_argv[0]) {