mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
use virAsprintf instead of asprintf
This commit is contained in:
parent
922f5e6845
commit
043d702f02
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Tue Dec 23 13:39:48 CET 2008 Guido Günther <agx@sigxcpu.org>
|
||||||
|
|
||||||
|
use virAsprintf instead of asprintf
|
||||||
|
* .x-sc_prohibit_asprintf, Makefile.maint (sc_prohibit_asprintf): new
|
||||||
|
rule
|
||||||
|
* src/cgroup.c, src/domain_conf.c, src/driver.c, src/libvirt.c,
|
||||||
|
src/logging.c, src/lxc_container.c, src/lxc_controller.c,
|
||||||
|
src/lxc_driver.c, src/network_conf.c, src/network_driver.c,
|
||||||
|
src/openvz_conf.c, src/qemu_conf.c, src/qemu_driver.c,
|
||||||
|
src/remote_internal.c, src/stats_linux.c, src/storage_backend_iscsi.c,
|
||||||
|
src/storage_driver.c, src/uml_conf.c, src/uml_driver.c, src/util.c,
|
||||||
|
src/veth.c, src/virsh.c, src/xm_internal.c: use virAsprintf instead of
|
||||||
|
asprintf
|
||||||
|
|
||||||
Mon Dec 22 11:33:16 EST 2008 Cole Robinson <crobinso@redhat.com>
|
Mon Dec 22 11:33:16 EST 2008 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
* src/storage_driver.c: Fix storage driver null dereference.
|
* src/storage_driver.c: Fix storage driver null dereference.
|
||||||
|
@ -105,6 +105,11 @@ sc_prohibit_strcmp:
|
|||||||
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \
|
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \
|
||||||
1>&2; exit 1; } || :
|
1>&2; exit 1; } || :
|
||||||
|
|
||||||
|
# Use virAsprintf rather than a'sprintf since *strp is undefined on error.
|
||||||
|
sc_prohibit_asprintf:
|
||||||
|
@grep -nE '\<[a]sprintf\>' $$($(VC_LIST_EXCEPT)) && \
|
||||||
|
{ echo '$(ME): use virAsprintf, not a'sprintf 1>&2; exit 1; } || :
|
||||||
|
|
||||||
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
# Using EXIT_SUCCESS as the first argument to error is misleading,
|
||||||
# since when that parameter is 0, error does not exit. Use `0' instead.
|
# since when that parameter is 0, error does not exit. Use `0' instead.
|
||||||
sc_error_exit_success:
|
sc_error_exit_success:
|
||||||
|
28
src/cgroup.c
28
src/cgroup.c
@ -128,7 +128,7 @@ static int virCgroupPathOfGroup(const char *group,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(path, "%s/%s", root->path, group) == -1)
|
if (virAsprintf(path, "%s/%s", root->path, group) == -1)
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
out:
|
out:
|
||||||
virCgroupFree(&root);
|
virCgroupFree(&root);
|
||||||
@ -156,7 +156,7 @@ static int virCgroupPathOf(const char *grppath,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(path, "%s/%s/%s", root->path, grppath, key) == -1)
|
if (virAsprintf(path, "%s/%s/%s", root->path, grppath, key) == -1)
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
out:
|
out:
|
||||||
virCgroupFree(&root);
|
virCgroupFree(&root);
|
||||||
@ -212,7 +212,7 @@ static int virCgroupSetValueU64(virCgroupPtr group,
|
|||||||
char *strval = NULL;
|
char *strval = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (asprintf(&strval, "%" PRIu64, value) == -1)
|
if (virAsprintf(&strval, "%" PRIu64, value) == -1)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
rc = virCgroupSetValueStr(group, key, strval);
|
rc = virCgroupSetValueStr(group, key, strval);
|
||||||
@ -281,7 +281,7 @@ static int virCgroupSetValueI64(virCgroupPtr group,
|
|||||||
char *strval = NULL;
|
char *strval = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (asprintf(&strval, "%" PRIi64, value) == -1)
|
if (virAsprintf(&strval, "%" PRIi64, value) == -1)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
rc = virCgroupSetValueStr(group, key, strval);
|
rc = virCgroupSetValueStr(group, key, strval);
|
||||||
@ -341,7 +341,7 @@ static int _virCgroupInherit(const char *path,
|
|||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
if (asprintf(&keypath, "%s/%s", path, key) == -1) {
|
if (virAsprintf(&keypath, "%s/%s", path, key) == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -351,7 +351,7 @@ static int _virCgroupInherit(const char *path,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&pkeypath, "%s/../%s", path, key) == -1) {
|
if (virAsprintf(&pkeypath, "%s/../%s", path, key) == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
VIR_FREE(keypath);
|
VIR_FREE(keypath);
|
||||||
goto out;
|
goto out;
|
||||||
@ -493,10 +493,10 @@ static int virCgroupNew(virCgroupPtr *parent,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = asprintf(&((*newgroup)->path),
|
rc = virAsprintf(&((*newgroup)->path),
|
||||||
"%s/%s",
|
"%s/%s",
|
||||||
(*parent)->path,
|
(*parent)->path,
|
||||||
group);
|
group);
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
@ -631,7 +631,7 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
|
|||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (asprintf(&taskpath, "%s/tasks", grppath) == -1) {
|
if (virAsprintf(&taskpath, "%s/tasks", grppath) == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&pidstr, "%lu", (unsigned long)pid) == -1) {
|
if (virAsprintf(&pidstr, "%lu", (unsigned long)pid) == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -745,7 +745,7 @@ int virCgroupAllowDevice(virCgroupPtr group,
|
|||||||
int rc;
|
int rc;
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
|
|
||||||
if (asprintf(&devstr, "%c %i:%i rwm", type, major, minor) == -1) {
|
if (virAsprintf(&devstr, "%c %i:%i rwm", type, major, minor) == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -775,7 +775,7 @@ int virCgroupAllowDeviceMajor(virCgroupPtr group,
|
|||||||
int rc;
|
int rc;
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
|
|
||||||
if (asprintf(&devstr, "%c %i:* rwm", type, major) == -1) {
|
if (virAsprintf(&devstr, "%c %i:* rwm", type, major) == -1) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -3457,7 +3457,7 @@ char *virDomainConfigFile(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
if (asprintf(&ret, "%s/%s.xml", dir, name) < 0) {
|
if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
|
||||||
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
virDomainReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ virDriverLoadModule(const char *name)
|
|||||||
|
|
||||||
DEBUG("Module load %s", name);
|
DEBUG("Module load %s", name);
|
||||||
|
|
||||||
if (asprintf(&modfile, "%s/libvirt_driver_%s.so", moddir, name) < 0)
|
if (virAsprintf(&modfile, "%s/libvirt_driver_%s.so", moddir, name) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (access(modfile, R_OK) < 0) {
|
if (access(modfile, R_OK) < 0) {
|
||||||
@ -63,8 +63,7 @@ virDriverLoadModule(const char *name)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(®func, "%sRegister", name) < 0) {
|
if (virAsprintf(®func, "%sRegister", name) < 0) {
|
||||||
regfunc = NULL;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,8 +941,8 @@ do_open (const char *name,
|
|||||||
"Is the libvirtd daemon running ?");
|
"Is the libvirtd daemon running ?");
|
||||||
} else {
|
} else {
|
||||||
char *msg;
|
char *msg;
|
||||||
if (asprintf(&msg, "Is the %s daemon running?",
|
if (virAsprintf(&msg, "Is the %s daemon running?",
|
||||||
virDeviceMonitorTab[i]->name) > 0) {
|
virDeviceMonitorTab[i]->name) > 0) {
|
||||||
virLibConnWarning (NULL, VIR_WAR_NO_NODE, msg);
|
virLibConnWarning (NULL, VIR_WAR_NO_NODE, msg);
|
||||||
VIR_FREE(msg);
|
VIR_FREE(msg);
|
||||||
}
|
}
|
||||||
|
@ -512,15 +512,15 @@ void virLogMessage(const char *category, int priority, const char *funcname,
|
|||||||
localtime_r(&cur_time.tv_sec, &time_info);
|
localtime_r(&cur_time.tv_sec, &time_info);
|
||||||
|
|
||||||
if ((funcname != NULL) && (priority == VIR_LOG_DEBUG)) {
|
if ((funcname != NULL) && (priority == VIR_LOG_DEBUG)) {
|
||||||
ret = asprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s:%lld : %s\n",
|
ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s:%lld : %s\n",
|
||||||
time_info.tm_hour, time_info.tm_min,
|
time_info.tm_hour, time_info.tm_min,
|
||||||
time_info.tm_sec, (int) cur_time.tv_usec / 1000,
|
time_info.tm_sec, (int) cur_time.tv_usec / 1000,
|
||||||
virLogPriorityString(priority), funcname, linenr, str);
|
virLogPriorityString(priority), funcname, linenr, str);
|
||||||
} else {
|
} else {
|
||||||
ret = asprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s\n",
|
ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s\n",
|
||||||
time_info.tm_hour, time_info.tm_min,
|
time_info.tm_hour, time_info.tm_min,
|
||||||
time_info.tm_sec, (int) cur_time.tv_usec / 1000,
|
time_info.tm_sec, (int) cur_time.tv_usec / 1000,
|
||||||
virLogPriorityString(priority), str);
|
virLogPriorityString(priority), str);
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -277,8 +277,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&oldroot, "%s/.oldroot", root->src) < 0) {
|
if (virAsprintf(&oldroot, "%s/.oldroot", root->src) < 0) {
|
||||||
oldroot = NULL;
|
|
||||||
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -378,7 +377,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
|
|||||||
if (vmDef->fss[i]->type != VIR_DOMAIN_FS_TYPE_MOUNT)
|
if (vmDef->fss[i]->type != VIR_DOMAIN_FS_TYPE_MOUNT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (asprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) {
|
if (virAsprintf(&src, "/.oldroot/%s", vmDef->fss[i]->src) < 0) {
|
||||||
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -122,11 +122,10 @@ out:
|
|||||||
static char*lxcMonitorPath(virDomainDefPtr def)
|
static char*lxcMonitorPath(virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
char *sockpath;
|
char *sockpath;
|
||||||
if (asprintf(&sockpath, "%s/%s.sock",
|
|
||||||
LXC_STATE_DIR, def->name) < 0) {
|
if (virAsprintf(&sockpath, "%s/%s.sock",
|
||||||
|
LXC_STATE_DIR, def->name) < 0)
|
||||||
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return sockpath;
|
return sockpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,8 +610,8 @@ static int lxcMonitorClient(virConnectPtr conn,
|
|||||||
int fd;
|
int fd;
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
|
|
||||||
if (asprintf(&sockpath, "%s/%s.sock",
|
if (virAsprintf(&sockpath, "%s/%s.sock",
|
||||||
driver->stateDir, vm->def->name) < 0) {
|
driver->stateDir, vm->def->name) < 0) {
|
||||||
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
|
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -854,8 +854,8 @@ static int lxcVmStart(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&logfile, "%s/%s.log",
|
if (virAsprintf(&logfile, "%s/%s.log",
|
||||||
driver->logDir, vm->def->name) < 0) {
|
driver->logDir, vm->def->name) < 0) {
|
||||||
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
|
lxcError(conn, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ virNetworkDefParseXML(virConnectPtr conn,
|
|||||||
inaddress.s_addr &= innetmask.s_addr;
|
inaddress.s_addr &= innetmask.s_addr;
|
||||||
netaddr = inet_ntoa(inaddress);
|
netaddr = inet_ntoa(inaddress);
|
||||||
|
|
||||||
if (asprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) {
|
if (virAsprintf(&def->network, "%s/%s", netaddr, def->netmask) < 0) {
|
||||||
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -643,16 +643,14 @@ int virNetworkSaveConfig(virConnectPtr conn,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!net->configFile &&
|
if (!net->configFile &&
|
||||||
asprintf(&net->configFile, "%s/%s.xml",
|
virAsprintf(&net->configFile, "%s/%s.xml",
|
||||||
configDir, net->def->name) < 0) {
|
configDir, net->def->name) < 0) {
|
||||||
net->configFile = NULL;
|
|
||||||
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!net->autostartLink &&
|
if (!net->autostartLink &&
|
||||||
asprintf(&net->autostartLink, "%s/%s.xml",
|
virAsprintf(&net->autostartLink, "%s/%s.xml",
|
||||||
autostartDir, net->def->name) < 0) {
|
autostartDir, net->def->name) < 0) {
|
||||||
net->autostartLink = NULL;
|
|
||||||
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -720,15 +718,13 @@ virNetworkObjPtr virNetworkLoadConfig(virConnectPtr conn,
|
|||||||
virNetworkObjPtr net;
|
virNetworkObjPtr net;
|
||||||
int autostart;
|
int autostart;
|
||||||
|
|
||||||
if (asprintf(&configFile, "%s/%s",
|
if (virAsprintf(&configFile, "%s/%s",
|
||||||
configDir, file) < 0) {
|
configDir, file) < 0) {
|
||||||
configFile = NULL;
|
|
||||||
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (asprintf(&autostartLink, "%s/%s",
|
if (virAsprintf(&autostartLink, "%s/%s",
|
||||||
autostartDir, file) < 0) {
|
autostartDir, file) < 0) {
|
||||||
autostartLink = NULL;
|
|
||||||
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,8 @@ networkStartup(void) {
|
|||||||
networkDriverLock(driverState);
|
networkDriverLock(driverState);
|
||||||
|
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
if (asprintf(&driverState->logDir,
|
if (virAsprintf(&driverState->logDir,
|
||||||
"%s/log/libvirt/qemu", LOCAL_STATE_DIR) == -1)
|
"%s/log/libvirt/qemu", LOCAL_STATE_DIR) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
|
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
|
||||||
@ -151,13 +151,11 @@ networkStartup(void) {
|
|||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&driverState->logDir,
|
if (virAsprintf(&driverState->logDir,
|
||||||
"%s/.libvirt/qemu/log", pw->pw_dir) == -1)
|
"%s/.libvirt/qemu/log", pw->pw_dir) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) {
|
if (virAsprintf(&base, "%s/.libvirt", pw->pw_dir) == -1) {
|
||||||
networkLog (NETWORK_ERR,
|
|
||||||
"%s", _("out of memory in asprintf\n"));
|
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,11 +163,11 @@ networkStartup(void) {
|
|||||||
/* Configuration paths are either ~/.libvirt/qemu/... (session) or
|
/* Configuration paths are either ~/.libvirt/qemu/... (session) or
|
||||||
* /etc/libvirt/qemu/... (system).
|
* /etc/libvirt/qemu/... (system).
|
||||||
*/
|
*/
|
||||||
if (asprintf (&driverState->networkConfigDir, "%s/qemu/networks", base) == -1)
|
if (virAsprintf(&driverState->networkConfigDir, "%s/qemu/networks", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (&driverState->networkAutostartDir, "%s/qemu/networks/autostart",
|
if (virAsprintf(&driverState->networkAutostartDir, "%s/qemu/networks/autostart",
|
||||||
base) == -1)
|
base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
VIR_FREE(base);
|
VIR_FREE(base);
|
||||||
|
@ -406,10 +406,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
dom->pid = veid;
|
dom->pid = veid;
|
||||||
dom->def->id = dom->state == VIR_DOMAIN_SHUTOFF ? -1 : veid;
|
dom->def->id = dom->state == VIR_DOMAIN_SHUTOFF ? -1 : veid;
|
||||||
|
|
||||||
if (asprintf(&dom->def->name, "%i", veid) < 0) {
|
if (virAsprintf(&dom->def->name, "%i", veid) < 0)
|
||||||
dom->def->name = NULL;
|
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
}
|
|
||||||
|
|
||||||
openvzGetVPSUUID(veid, uuidstr);
|
openvzGetVPSUUID(veid, uuidstr);
|
||||||
ret = virUUIDParse(uuidstr, dom->def->uuid);
|
ret = virUUIDParse(uuidstr, dom->def->uuid);
|
||||||
|
@ -708,9 +708,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||||||
do { \
|
do { \
|
||||||
ADD_ARG_LIT("-usbdevice"); \
|
ADD_ARG_LIT("-usbdevice"); \
|
||||||
ADD_ARG_SPACE; \
|
ADD_ARG_SPACE; \
|
||||||
if ((asprintf((char **)&(qargv[qargc++]), \
|
if ((virAsprintf((char **)&(qargv[qargc++]), \
|
||||||
"disk:%s", thisarg)) == -1) { \
|
"disk:%s", thisarg)) == -1) { \
|
||||||
qargv[qargc-1] = NULL; \
|
|
||||||
goto no_memory; \
|
goto no_memory; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -743,7 +742,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||||||
char *envval; \
|
char *envval; \
|
||||||
ADD_ENV_SPACE; \
|
ADD_ENV_SPACE; \
|
||||||
if (val != NULL) { \
|
if (val != NULL) { \
|
||||||
if (asprintf(&envval, "%s=%s", envname, val) < 0) \
|
if (virAsprintf(&envval, "%s=%s", envname, val) < 0) \
|
||||||
goto no_memory; \
|
goto no_memory; \
|
||||||
qenv[qenvc++] = envval; \
|
qenv[qenvc++] = envval; \
|
||||||
} \
|
} \
|
||||||
@ -1157,12 +1156,12 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||||||
char *display = NULL;
|
char *display = NULL;
|
||||||
|
|
||||||
if (vm->def->graphics->data.sdl.xauth &&
|
if (vm->def->graphics->data.sdl.xauth &&
|
||||||
asprintf(&xauth, "XAUTHORITY=%s",
|
virAsprintf(&xauth, "XAUTHORITY=%s",
|
||||||
vm->def->graphics->data.sdl.xauth) < 0)
|
vm->def->graphics->data.sdl.xauth) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
if (vm->def->graphics->data.sdl.display &&
|
if (vm->def->graphics->data.sdl.display &&
|
||||||
asprintf(&display, "DISPLAY=%s",
|
virAsprintf(&display, "DISPLAY=%s",
|
||||||
vm->def->graphics->data.sdl.display) < 0) {
|
vm->def->graphics->data.sdl.display) < 0) {
|
||||||
VIR_FREE(xauth);
|
VIR_FREE(xauth);
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
}
|
}
|
||||||
@ -1209,19 +1208,18 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
||||||
if(hostdev->source.subsys.u.usb.vendor) {
|
if(hostdev->source.subsys.u.usb.vendor) {
|
||||||
ret = asprintf(&usbdev, "host:%.4x:%.4x",
|
ret = virAsprintf(&usbdev, "host:%.4x:%.4x",
|
||||||
hostdev->source.subsys.u.usb.vendor,
|
hostdev->source.subsys.u.usb.vendor,
|
||||||
hostdev->source.subsys.u.usb.product);
|
hostdev->source.subsys.u.usb.product);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ret = asprintf(&usbdev, "host:%.3d.%.3d",
|
ret = virAsprintf(&usbdev, "host:%.3d.%.3d",
|
||||||
hostdev->source.subsys.u.usb.bus,
|
hostdev->source.subsys.u.usb.bus,
|
||||||
hostdev->source.subsys.u.usb.device);
|
hostdev->source.subsys.u.usb.device);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
usbdev = NULL;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
ADD_ARG_LIT("-usbdevice");
|
ADD_ARG_LIT("-usbdevice");
|
||||||
ADD_ARG_LIT(usbdev);
|
ADD_ARG_LIT(usbdev);
|
||||||
VIR_FREE(usbdev);
|
VIR_FREE(usbdev);
|
||||||
|
@ -252,8 +252,8 @@ qemudStartup(void) {
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
if (asprintf(&qemu_driver->logDir,
|
if (virAsprintf(&qemu_driver->logDir,
|
||||||
"%s/log/libvirt/qemu", LOCAL_STATE_DIR) == -1)
|
"%s/log/libvirt/qemu", LOCAL_STATE_DIR) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
|
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
|
||||||
@ -269,11 +269,11 @@ qemudStartup(void) {
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&qemu_driver->logDir,
|
if (virAsprintf(&qemu_driver->logDir,
|
||||||
"%s/.libvirt/qemu/log", pw->pw_dir) == -1)
|
"%s/.libvirt/qemu/log", pw->pw_dir) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1)
|
if (virAsprintf(&base, "%s/.libvirt", pw->pw_dir) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", base) == -1)
|
if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", base) == -1)
|
||||||
@ -293,10 +293,10 @@ qemudStartup(void) {
|
|||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
driverConf[sizeof(driverConf)-1] = '\0';
|
driverConf[sizeof(driverConf)-1] = '\0';
|
||||||
|
|
||||||
if (asprintf (&qemu_driver->configDir, "%s/qemu", base) == -1)
|
if (virAsprintf(&qemu_driver->configDir, "%s/qemu", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (&qemu_driver->autostartDir, "%s/qemu/autostart", base) == -1)
|
if (virAsprintf(&qemu_driver->autostartDir, "%s/qemu/autostart", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
VIR_FREE(base);
|
VIR_FREE(base);
|
||||||
@ -2253,7 +2253,7 @@ static int qemudDomainSave(virDomainPtr dom,
|
|||||||
"%s", _("out of memory"));
|
"%s", _("out of memory"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (asprintf (&command, "migrate \"exec:"
|
if (virAsprintf(&command, "migrate \"exec:"
|
||||||
"dd of='%s' oflag=append conv=notrunc 2>/dev/null"
|
"dd of='%s' oflag=append conv=notrunc 2>/dev/null"
|
||||||
"\"", safe_path) == -1) {
|
"\"", safe_path) == -1) {
|
||||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
@ -2880,21 +2880,21 @@ static char *qemudDiskDeviceName(const virConnectPtr conn,
|
|||||||
switch (disk->bus) {
|
switch (disk->bus) {
|
||||||
case VIR_DOMAIN_DISK_BUS_IDE:
|
case VIR_DOMAIN_DISK_BUS_IDE:
|
||||||
if (disk->device== VIR_DOMAIN_DISK_DEVICE_DISK)
|
if (disk->device== VIR_DOMAIN_DISK_DEVICE_DISK)
|
||||||
ret = asprintf(&devname, "ide%d-hd%d", busid, devid);
|
ret = virAsprintf(&devname, "ide%d-hd%d", busid, devid);
|
||||||
else
|
else
|
||||||
ret = asprintf(&devname, "ide%d-cd%d", busid, devid);
|
ret = virAsprintf(&devname, "ide%d-cd%d", busid, devid);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
|
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
|
||||||
ret = asprintf(&devname, "scsi%d-hd%d", busid, devid);
|
ret = virAsprintf(&devname, "scsi%d-hd%d", busid, devid);
|
||||||
else
|
else
|
||||||
ret = asprintf(&devname, "scsi%d-cd%d", busid, devid);
|
ret = virAsprintf(&devname, "scsi%d-cd%d", busid, devid);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DISK_BUS_FDC:
|
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||||
ret = asprintf(&devname, "floppy%d", devid);
|
ret = virAsprintf(&devname, "floppy%d", devid);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
||||||
ret = asprintf(&devname, "virtio%d", devid);
|
ret = virAsprintf(&devname, "virtio%d", devid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
|
||||||
@ -2980,7 +2980,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
|
|||||||
VIR_FREE(devname);
|
VIR_FREE(devname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (asprintf (&cmd, "change %s \"%s\"", devname, safe_path) == -1) {
|
if (virAsprintf(&cmd, "change %s \"%s\"", devname, safe_path) == -1) {
|
||||||
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
|
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
VIR_FREE(safe_path);
|
VIR_FREE(safe_path);
|
||||||
VIR_FREE(devname);
|
VIR_FREE(devname);
|
||||||
@ -2988,7 +2988,7 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
VIR_FREE(safe_path);
|
VIR_FREE(safe_path);
|
||||||
|
|
||||||
} else if (asprintf(&cmd, "eject %s", devname) == -1) {
|
} else if (virAsprintf(&cmd, "eject %s", devname) == -1) {
|
||||||
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
|
qemudReportError(conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
VIR_FREE(devname);
|
VIR_FREE(devname);
|
||||||
return -1;
|
return -1;
|
||||||
@ -3052,8 +3052,8 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = asprintf(&cmd, "pci_add 0 storage file=%s,if=%s",
|
ret = virAsprintf(&cmd, "pci_add 0 storage file=%s,if=%s",
|
||||||
safe_path, type);
|
safe_path, type);
|
||||||
VIR_FREE(safe_path);
|
VIR_FREE(safe_path);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
@ -3122,7 +3122,7 @@ static int qemudDomainAttachUsbMassstorageDevice(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = asprintf(&cmd, "usb_add disk:%s", safe_path);
|
ret = virAsprintf(&cmd, "usb_add disk:%s", safe_path);
|
||||||
VIR_FREE(safe_path);
|
VIR_FREE(safe_path);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
@ -3170,13 +3170,13 @@ static int qemudDomainAttachHostDevice(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dev->data.hostdev->source.subsys.u.usb.vendor) {
|
if (dev->data.hostdev->source.subsys.u.usb.vendor) {
|
||||||
ret = asprintf(&cmd, "usb_add host:%.4x:%.4x",
|
ret = virAsprintf(&cmd, "usb_add host:%.4x:%.4x",
|
||||||
dev->data.hostdev->source.subsys.u.usb.vendor,
|
dev->data.hostdev->source.subsys.u.usb.vendor,
|
||||||
dev->data.hostdev->source.subsys.u.usb.product);
|
dev->data.hostdev->source.subsys.u.usb.product);
|
||||||
} else {
|
} else {
|
||||||
ret = asprintf(&cmd, "usb_add host:%.3d.%.3d",
|
ret = virAsprintf(&cmd, "usb_add host:%.3d.%.3d",
|
||||||
dev->data.hostdev->source.subsys.u.usb.bus,
|
dev->data.hostdev->source.subsys.u.usb.bus,
|
||||||
dev->data.hostdev->source.subsys.u.usb.device);
|
dev->data.hostdev->source.subsys.u.usb.device);
|
||||||
}
|
}
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
@ -3306,9 +3306,8 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&cmd, "pci_del 0 %d", detach->slotnum) < 0) {
|
if (virAsprintf(&cmd, "pci_del 0 %d", detach->slotnum) < 0) {
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
cmd = NULL;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3979,10 +3978,9 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Caller frees */
|
/* Caller frees */
|
||||||
if (asprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
|
if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0) {
|
||||||
qemudReportError (dconn, NULL, NULL, VIR_ERR_NO_MEMORY,
|
qemudReportError (dconn, NULL, NULL, VIR_ERR_NO_MEMORY,
|
||||||
"%s", strerror (errno));
|
"%s", strerror (errno));
|
||||||
*uri_out = NULL;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -347,7 +347,7 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
|
|
||||||
/* Remote server defaults to "localhost" if not specified. */
|
/* Remote server defaults to "localhost" if not specified. */
|
||||||
if (conn->uri && conn->uri->port != 0) {
|
if (conn->uri && conn->uri->port != 0) {
|
||||||
if (asprintf (&port, "%d", conn->uri->port) == -1) goto out_of_memory;
|
if (virAsprintf(&port, "%d", conn->uri->port) == -1) goto out_of_memory;
|
||||||
} else if (transport == trans_tls) {
|
} else if (transport == trans_tls) {
|
||||||
port = strdup (LIBVIRTD_TLS_PORT);
|
port = strdup (LIBVIRTD_TLS_PORT);
|
||||||
if (!port) goto out_of_memory;
|
if (!port) goto out_of_memory;
|
||||||
@ -582,10 +582,9 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf (&sockname, "@%s" LIBVIRTD_USER_UNIX_SOCKET, pw->pw_dir) < 0) {
|
if (virAsprintf(&sockname, "@%s" LIBVIRTD_USER_UNIX_SOCKET, pw->pw_dir) < 0)
|
||||||
sockname = NULL;
|
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (flags & VIR_DRV_OPEN_REMOTE_RO)
|
if (flags & VIR_DRV_OPEN_REMOTE_RO)
|
||||||
sockname = strdup (LIBVIRTD_PRIV_UNIX_SOCKET_RO);
|
sockname = strdup (LIBVIRTD_PRIV_UNIX_SOCKET_RO);
|
||||||
|
@ -292,9 +292,9 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (strlen(path) >= 5 && STRPREFIX(path, "/dev/"))
|
if (strlen(path) >= 5 && STRPREFIX(path, "/dev/"))
|
||||||
retval = asprintf(&mod_path, "%s", path);
|
retval = virAsprintf(&mod_path, "%s", path);
|
||||||
else
|
else
|
||||||
retval = asprintf(&mod_path, "/dev/%s", path);
|
retval = virAsprintf(&mod_path, "/dev/%s", path);
|
||||||
|
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
statsErrorFunc (conn, VIR_ERR_NO_MEMORY, __FUNCTION__,
|
statsErrorFunc (conn, VIR_ERR_NO_MEMORY, __FUNCTION__,
|
||||||
|
@ -180,12 +180,12 @@ virStorageBackendISCSINewLun(virConnectPtr conn, virStoragePoolObjPtr pool,
|
|||||||
|
|
||||||
vol->type = VIR_STORAGE_VOL_BLOCK;
|
vol->type = VIR_STORAGE_VOL_BLOCK;
|
||||||
|
|
||||||
if (asprintf(&(vol->name), "lun-%d", lun) < 0) {
|
if (virAsprintf(&(vol->name), "lun-%d", lun) < 0) {
|
||||||
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
|
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&devpath, "/dev/%s", dev) < 0) {
|
if (virAsprintf(&devpath, "/dev/%s", dev) < 0) {
|
||||||
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("devpath"));
|
virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("devpath"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ storageDriverStartup(void) {
|
|||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) {
|
if (virAsprintf(&base, "%s/.libvirt", pw->pw_dir) == -1) {
|
||||||
storageLog("out of memory in asprintf");
|
storageLog("out of memory in virAsprintf");
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,12 +140,12 @@ storageDriverStartup(void) {
|
|||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
driverConf[sizeof(driverConf)-1] = '\0';
|
driverConf[sizeof(driverConf)-1] = '\0';
|
||||||
|
|
||||||
if (asprintf (&driverState->configDir,
|
if (virAsprintf(&driverState->configDir,
|
||||||
"%s/storage", base) == -1)
|
"%s/storage", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (&driverState->autostartDir,
|
if (virAsprintf(&driverState->autostartDir,
|
||||||
"%s/storage/autostart", base) == -1)
|
"%s/storage/autostart", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
VIR_FREE(base);
|
VIR_FREE(base);
|
||||||
|
@ -99,29 +99,29 @@ umlBuildCommandLineChr(virConnectPtr conn,
|
|||||||
|
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_DOMAIN_CHR_TYPE_NULL:
|
case VIR_DOMAIN_CHR_TYPE_NULL:
|
||||||
if (asprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) {
|
if (virAsprintf(&ret, "%s%d=null", dev, def->dstPort) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||||
if (asprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) {
|
if (virAsprintf(&ret, "%s%d=pts", dev, def->dstPort) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_DEV:
|
case VIR_DOMAIN_CHR_TYPE_DEV:
|
||||||
if (asprintf(&ret, "%s%d=tty:%s", dev, def->dstPort,
|
if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->dstPort,
|
||||||
def->data.file.path) < 0) {
|
def->data.file.path) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_STDIO:
|
case VIR_DOMAIN_CHR_TYPE_STDIO:
|
||||||
if (asprintf(&ret, "%s%d=fd:0,fd:1", dev, def->dstPort) < 0) {
|
if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->dstPort) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -134,8 +134,8 @@ umlBuildCommandLineChr(virConnectPtr conn,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&ret, "%s%d=port:%s", dev, def->dstPort,
|
if (virAsprintf(&ret, "%s%d=port:%s", dev, def->dstPort,
|
||||||
def->data.tcp.service) < 0) {
|
def->data.tcp.service) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -204,9 +204,9 @@ int umlBuildCommandLine(virConnectPtr conn,
|
|||||||
do { \
|
do { \
|
||||||
char *arg; \
|
char *arg; \
|
||||||
ADD_ARG_SPACE; \
|
ADD_ARG_SPACE; \
|
||||||
if (asprintf(&arg, "%s=%s", key, val) < 0) \
|
if (virAsprintf(&arg, "%s=%s", key, val) < 0) \
|
||||||
goto no_memory; \
|
goto no_memory; \
|
||||||
qargv[qargc++] = arg; \
|
qargv[qargc++] = arg; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ int umlBuildCommandLine(virConnectPtr conn,
|
|||||||
char *envval; \
|
char *envval; \
|
||||||
ADD_ENV_SPACE; \
|
ADD_ENV_SPACE; \
|
||||||
if (val != NULL) { \
|
if (val != NULL) { \
|
||||||
if (asprintf(&envval, "%s=%s", envname, val) < 0) \
|
if (virAsprintf(&envval, "%s=%s", envname, val) < 0) \
|
||||||
goto no_memory; \
|
goto no_memory; \
|
||||||
qenv[qenvc++] = envval; \
|
qenv[qenvc++] = envval; \
|
||||||
} \
|
} \
|
||||||
@ -281,7 +281,7 @@ int umlBuildCommandLine(virConnectPtr conn,
|
|||||||
if (i == 0 && vm->def->console)
|
if (i == 0 && vm->def->console)
|
||||||
ret = umlBuildCommandLineChr(conn, vm->def->console, "con");
|
ret = umlBuildCommandLineChr(conn, vm->def->console, "con");
|
||||||
else
|
else
|
||||||
if (asprintf(&ret, "con%d=none", i) < 0)
|
if (virAsprintf(&ret, "con%d=none", i) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
ADD_ARG(ret);
|
ADD_ARG(ret);
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ int umlBuildCommandLine(virConnectPtr conn,
|
|||||||
if (chr)
|
if (chr)
|
||||||
ret = umlBuildCommandLineChr(conn, chr, "ssl");
|
ret = umlBuildCommandLineChr(conn, chr, "ssl");
|
||||||
else
|
else
|
||||||
if (asprintf(&ret, "ssl%d=none", i) < 0)
|
if (virAsprintf(&ret, "ssl%d=none", i) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
ADD_ARG(ret);
|
ADD_ARG(ret);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ umlIdentifyOneChrPTY(virConnectPtr conn,
|
|||||||
char *cmd;
|
char *cmd;
|
||||||
char *res = NULL;
|
char *res = NULL;
|
||||||
int retries = 0;
|
int retries = 0;
|
||||||
if (asprintf(&cmd, "config %s%d", dev, def->dstPort) < 0) {
|
if (virAsprintf(&cmd, "config %s%d", dev, def->dstPort) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -327,23 +327,23 @@ umlStartup(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
if (asprintf(¨_driver->logDir,
|
if (virAsprintf(¨_driver->logDir,
|
||||||
"%s/log/libvirt/uml", LOCAL_STATE_DIR) == -1)
|
"%s/log/libvirt/uml", LOCAL_STATE_DIR) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
|
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
} else {
|
} else {
|
||||||
if (asprintf(¨_driver->logDir,
|
if (virAsprintf(¨_driver->logDir,
|
||||||
"%s/.libvirt/uml/log", pw->pw_dir) == -1)
|
"%s/.libvirt/uml/log", pw->pw_dir) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1)
|
if (virAsprintf(&base, "%s/.libvirt", pw->pw_dir) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf (¨_driver->monitorDir,
|
if (virAsprintf(¨_driver->monitorDir,
|
||||||
"%s/.uml", pw->pw_dir) == -1)
|
"%s/.uml", pw->pw_dir) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
/* Configuration paths are either ~/.libvirt/uml/... (session) or
|
/* Configuration paths are either ~/.libvirt/uml/... (session) or
|
||||||
@ -353,10 +353,10 @@ umlStartup(void) {
|
|||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
driverConf[sizeof(driverConf)-1] = '\0';
|
driverConf[sizeof(driverConf)-1] = '\0';
|
||||||
|
|
||||||
if (asprintf (¨_driver->configDir, "%s/uml", base) == -1)
|
if (virAsprintf(¨_driver->configDir, "%s/uml", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
if (asprintf (¨_driver->autostartDir, "%s/uml/autostart", base) == -1)
|
if (virAsprintf(¨_driver->autostartDir, "%s/uml/autostart", base) == -1)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
VIR_FREE(base);
|
VIR_FREE(base);
|
||||||
@ -517,8 +517,8 @@ static int umlReadPidFile(virConnectPtr conn,
|
|||||||
int retries = 0;
|
int retries = 0;
|
||||||
|
|
||||||
vm->pid = -1;
|
vm->pid = -1;
|
||||||
if (asprintf(&pidfile, "%s/%s/pid",
|
if (virAsprintf(&pidfile, "%s/%s/pid",
|
||||||
driver->monitorDir, vm->def->name) < 0) {
|
driver->monitorDir, vm->def->name) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -558,8 +558,8 @@ static int umlMonitorAddress(virConnectPtr conn,
|
|||||||
struct sockaddr_un *addr) {
|
struct sockaddr_un *addr) {
|
||||||
char *sockname;
|
char *sockname;
|
||||||
|
|
||||||
if (asprintf(&sockname, "%s/%s/mconsole",
|
if (virAsprintf(&sockname, "%s/%s/mconsole",
|
||||||
driver->monitorDir, vm->def->name) < 0) {
|
driver->monitorDir, vm->def->name) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -749,8 +749,8 @@ static int umlStartVMDaemon(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&logfile, "%s/%s.log",
|
if (virAsprintf(&logfile, "%s/%s.log",
|
||||||
driver->logDir, vm->def->name) < 0) {
|
driver->logDir, vm->def->name) < 0) {
|
||||||
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
umlReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -922,11 +922,8 @@ int virFileOpenTty(int *ttymaster ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
char* virFilePid(const char *dir, const char* name)
|
char* virFilePid(const char *dir, const char* name)
|
||||||
{
|
{
|
||||||
char* pidfile;
|
char *pidfile;
|
||||||
|
virAsprintf(&pidfile, "%s/%s.pid", dir, name);
|
||||||
if (asprintf(&pidfile, "%s/%s.pid", dir, name) < 0) {
|
|
||||||
pidfile = NULL;
|
|
||||||
}
|
|
||||||
return pidfile;
|
return pidfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1170,7 +1167,7 @@ virParseNumber(const char **str)
|
|||||||
/**
|
/**
|
||||||
* virAsprintf
|
* virAsprintf
|
||||||
*
|
*
|
||||||
* like asprintf but makes sure *strp == NULL on failure
|
* like glibc's_asprintf but makes sure *strp == NULL on failure
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virAsprintf(char **strp, const char *fmt, ...)
|
virAsprintf(char **strp, const char *fmt, ...)
|
||||||
|
@ -203,7 +203,7 @@ int moveInterfaceToNetNs(const char* interface, int pidInNs)
|
|||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf(&pid, "%d", pidInNs) == -1)
|
if (virAsprintf(&pid, "%d", pidInNs) == -1)
|
||||||
goto error_out;
|
goto error_out;
|
||||||
|
|
||||||
argv[5] = pid;
|
argv[5] = pid;
|
||||||
|
18
src/virsh.c
18
src/virsh.c
@ -3417,19 +3417,19 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = port ?
|
ret = port ?
|
||||||
asprintf(&srcSpec,
|
virAsprintf(&srcSpec,
|
||||||
"<source><host name='%.*s' port='%s'/></source>",
|
"<source><host name='%.*s' port='%s'/></source>",
|
||||||
(int)hostlen, host, port) :
|
(int)hostlen, host, port) :
|
||||||
asprintf(&srcSpec,
|
virAsprintf(&srcSpec,
|
||||||
"<source><host name='%.*s'/></source>",
|
"<source><host name='%.*s'/></source>",
|
||||||
(int)hostlen, host);
|
(int)hostlen, host);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
vshError(ctl, FALSE, "%s", _("Out of memory"));
|
vshError(ctl, FALSE, "%s", _("Out of memory"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vshError(ctl, FALSE, _("asprintf failed (errno %d)"), errno);
|
vshError(ctl, FALSE, _("virAsprintf failed (errno %d)"), errno);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -5301,9 +5301,9 @@ editFile (vshControl *ctl, const char *filename)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asprintf (&command, "%s %s", editor, filename) == -1) {
|
if (virAsprintf(&command, "%s %s", editor, filename) == -1) {
|
||||||
vshError(ctl, FALSE,
|
vshError(ctl, FALSE,
|
||||||
_("asprintf: could not create editing command: %s"),
|
_("virAsprintf: could not create editing command: %s"),
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2687,16 +2687,14 @@ xenXMDomainBlockPeek (virDomainPtr dom,
|
|||||||
static char *xenXMAutostartLinkName(virDomainPtr dom)
|
static char *xenXMAutostartLinkName(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
if (asprintf(&ret, "/etc/xen/auto/%s", dom->name) < 0)
|
virAsprintf(&ret, "/etc/xen/auto/%s", dom->name);
|
||||||
return NULL;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *xenXMDomainConfigName(virDomainPtr dom)
|
static char *xenXMDomainConfigName(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
if (asprintf(&ret, "/etc/xen/%s", dom->name) < 0)
|
virAsprintf(&ret, "/etc/xen/%s", dom->name);
|
||||||
return NULL;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user