make_nonnull_server(admin_nonnull_server *srv_dst,
virNetServerPtr srv_src)
{
- if (VIR_STRDUP(srv_dst->name, virNetServerGetName(srv_src)) < 0)
- return -1;
+ srv_dst->name = g_strdup(virNetServerGetName(srv_src));
return 0;
}
/* Request credentials */
if (conn->uri->user != NULL) {
- if (VIR_STRDUP(username, conn->uri->user) < 0)
- goto cleanup;
+ username = g_strdup(conn->uri->user);
} else {
if (!(username = virAuthGetUsername(conn, auth, "hyperv",
"administrator",
return NULL;
}
- if (VIR_STRDUP(def->name, computerSystem->data.common->ElementName) < 0)
- goto cleanup;
+ def->name = g_strdup(computerSystem->data.common->ElementName);
if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
- if (VIR_STRDUP(def->description,
- virtualSystemSettingData->data.v1->Notes) < 0)
- goto cleanup;
+ def->description = g_strdup(virtualSystemSettingData->data.v1->Notes);
} else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2 &&
virtualSystemSettingData->data.v2->Notes.data != NULL) {
char **notes = (char **)virtualSystemSettingData->data.v2->Notes.data;
for (computerSystem = computerSystemList; computerSystem != NULL;
computerSystem = computerSystem->next) {
- if (VIR_STRDUP(names[count], computerSystem->data.common->ElementName) < 0)
- goto cleanup;
+ names[count] = g_strdup(computerSystem->data.common->ElementName);
++count;
if (STRCASEEQ(queryParam->name, "transport")) {
VIR_FREE((*parsedUri)->transport);
- if (VIR_STRDUP((*parsedUri)->transport, queryParam->value) < 0)
- goto cleanup;
+ (*parsedUri)->transport = g_strdup(queryParam->value);
if (STRNEQ((*parsedUri)->transport, "http") &&
STRNEQ((*parsedUri)->transport, "https")) {
if (STREQ(param->name, "socket")) {
VIR_FREE(sock_path);
- if (VIR_STRDUP(sock_path, param->value) < 0)
- goto error;
+ sock_path = g_strdup(param->value);
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown URI parameter '%s'"), param->name);
}
if (legacy) {
- if (VIR_STRDUP(sockbase, "libvirt-admin-sock") < 0)
- goto error;
+ sockbase = g_strdup("libvirt-admin-sock");
} else {
if (virAsprintf(&sockbase, "%s-admin-sock", uri->scheme) < 0)
goto error;
{
const char *defname = getenv("LIBVIRT_ADMIN_DEFAULT_URI");
if (defname && *defname) {
- if (VIR_STRDUP(*uristr, defname) < 0)
- return -1;
+ *uristr = g_strdup(defname);
VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr);
} else {
if (virConfGetValueString(conf, "uri_default", uristr) < 0)
* 'libvirtd:///session' depending on the process's EUID.
*/
if (geteuid() == 0) {
- if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
- return -1;
+ *uristr = g_strdup("libvirtd:///system");
} else {
- if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0)
- return -1;
+ *uristr = g_strdup("libvirtd:///session");
}
}
}
goto error;
if (name) {
- if (VIR_STRDUP(uristr, name) < 0)
- goto error;
+ uristr = g_strdup(name);
} else {
if (virAdmGetDefaultURI(conf, &uristr) < 0)
goto error;
}
if (cred[i].type != VIR_CRED_EXTERNAL) {
- if (VIR_STRDUP(cred[i].result,
- STREQ(bufptr, "") && cred[i].defresult ?
- cred[i].defresult : bufptr) < 0)
- return -1;
+ cred[i].result = g_strdup(STREQ(bufptr, "") && cred[i].defresult ? cred[i].defresult : bufptr);
cred[i].resultlen = strlen(cred[i].result);
}
}
const char *defname = getenv("LIBVIRT_DEFAULT_URI");
if (defname && *defname) {
VIR_DEBUG("Using LIBVIRT_DEFAULT_URI '%s'", defname);
- if (VIR_STRDUP(*name, defname) < 0)
- goto cleanup;
+ *name = g_strdup(defname);
} else {
if (virConfGetValueString(conf, "uri_default", name) < 0)
goto cleanup;
* if detectable.
*/
if (name) {
- if (VIR_STRDUP(uristr, name) < 0)
- goto failed;
+ uristr = g_strdup(name);
} else {
if (virConnectGetDefaultURI(conf, &uristr) < 0)
goto failed;
/* Avoid need for drivers to worry about NULLs, as
* no one needs to distinguish "" vs NULL */
- if (ret->uri->path == NULL &&
- VIR_STRDUP(ret->uri->path, "") < 0)
- goto failed;
+ if (ret->uri->path == NULL)
+ ret->uri->path = g_strdup("");
VIR_DEBUG("Split \"%s\" to URI components:\n"
" scheme %s\n"
goto error;
fs->type = VIR_DOMAIN_FS_TYPE_TEMPLATE;
- if (VIR_STRDUP(fs->src->path, temp) < 0)
- goto error;
+ fs->src->path = g_strdup(temp);
} else {
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp);
VIR_FREE(veid_str);
}
- if (VIR_STRDUP(fs->dst, "/") < 0)
- goto error;
+ fs->dst = g_strdup("/");
param = "DISKSPACE";
ret = openvzReadVPSConfigParam(veid, param, &temp);
}
def->os.type = VIR_DOMAIN_OSTYPE_EXE;
- if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
- goto cleanup;
+ def->os.init = g_strdup("/sbin/init");
ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
if (ret < 0) {
saveptr = NULL;
if ((token = strtok_r(sf, "\"\t\n", &saveptr)) != NULL) {
VIR_FREE(*value);
- if (VIR_STRDUP(*value, token) < 0) {
- err = 1;
- break;
- }
+ *value = g_strdup(token);
/* keep going - last entry wins */
}
}
void *parseOpaque G_GNUC_UNUSED)
{
/* fill the init path */
- if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
- if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
- return -1;
- }
+ if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init)
+ def->os.init = g_strdup("/sbin/init");
return 0;
}
/* if net is ethernet and the user has specified guest interface name,
* let's use it; otherwise generate a new one */
if (net->ifname_guest) {
- if (VIR_STRDUP(guest_ifname, net->ifname_guest) < 0)
- goto cleanup;
+ guest_ifname = g_strdup(net->ifname_guest);
} else {
guest_ifname = openvzGenerateContainerVethName(veid);
if (guest_ifname == NULL) {
continue;
}
snprintf(vpsname, sizeof(vpsname), "%d", veid);
- if (VIR_STRDUP(names[got], vpsname) < 0)
- goto out;
+ names[got] = g_strdup(vpsname);
got ++;
}
goto err;
if (conn->uri->user != NULL) {
- if (VIR_STRDUP(username, conn->uri->user) < 0)
- goto err;
+ username = g_strdup(conn->uri->user);
} else {
if (!(username = virAuthGetUsername(conn, auth, "ssh", NULL,
conn->uri->server)))
if (conn->uri->path[0] != '\0') {
/* need to shift one byte in order to remove the first "/" of URI component */
- if (VIR_STRDUP(managed_system,
- conn->uri->path + (conn->uri->path[0] == '/')) < 0)
- goto failure;
+ managed_system = g_strdup(conn->uri->path + (conn->uri->path[0] == '/'));
/* here we are handling only the first component of the path,
* so skipping the second:
else
goto cleanup;
- if (VIR_STRDUP(backing_device, char_ptr) < 0)
- goto cleanup;
+ backing_device = g_strdup(char_ptr);
} else {
backing_device = g_steal_pointer(&ret);
}
goto cleanup;
}
- if (VIR_STRDUP(voldef.key, vol->key) < 0)
- goto cleanup;
+ voldef.key = g_strdup(vol->key);
voldef.type = VIR_STORAGE_POOL_LOGICAL;
if (char_ptr) {
*char_ptr = '\0';
- if (VIR_STRDUP(volumes[got++], volumes_list) < 0)
- goto cleanup;
+ volumes[got++] = g_strdup(volumes_list);
char_ptr++;
volumes_list = char_ptr;
} else {
if (char_ptr) {
*char_ptr = '\0';
- if (VIR_STRDUP(pools[got++], storage_pools) < 0)
- goto cleanup;
+ pools[got++] = g_strdup(storage_pools);
char_ptr++;
storage_pools = char_ptr;
} else {
if (char_ptr) {
*char_ptr = '\0';
- if (VIR_STRDUP(names[got++], networks) < 0)
- goto cleanup;
+ names[got++] = g_strdup(networks);
char_ptr++;
networks = char_ptr;
} else {
if (char_ptr) {
*char_ptr = '\0';
- if (VIR_STRDUP(names[got++], domains) < 0)
- goto cleanup;
+ names[got++] = g_strdup(domains);
char_ptr++;
domains = char_ptr;
} else {
pDomain = vm->privateData;
- if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0)
- goto cleanup;
+ pDomain->vmxPath = g_strdup(vmxPath);
vmwareDomainConfigDisplay(pDomain, vmdef);
if (VIR_STRNDUP(*directory, path, separator - path - 1) < 0)
goto error;
- if (VIR_STRDUP(*filename, separator) < 0) {
- VIR_FREE(*directory);
- goto error;
- }
+ *filename = g_strdup(separator);
} else {
- if (VIR_STRDUP(*filename, path) < 0)
- goto error;
+ *filename = g_strdup(path);
}
return 0;
goto cleanup;
pDomain = vm->privateData;
- if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0)
- goto cleanup;
+ pDomain->vmxPath = g_strdup(vmxPath);
vmwareDomainConfigDisplay(pDomain, vmdef);
goto cleanup;
pDomain = vm->privateData;
- if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0)
- goto cleanup;
+ pDomain->vmxPath = g_strdup(vmxPath);
vmwareDomainConfigDisplay(pDomain, vmdef);
vmdef = NULL;
if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI || !driver)
return 0;
- if (VIR_STRDUP(copy, driver) < 0)
- return -1;
+ copy = g_strdup(driver);
tmp = copy;
for (; *tmp != '\0'; ++tmp)
if (ctx->datacenterPath || ctx->moref) {
struct virVMXDomainDefNamespaceData *nsdata = NULL;
- if (VIR_ALLOC(nsdata) < 0 ||
- VIR_STRDUP(nsdata->datacenterPath, ctx->datacenterPath) < 0 ||
- VIR_STRDUP(nsdata->moref, ctx->moref) < 0) {
+ if (VIR_ALLOC(nsdata) < 0) {
virVMXDomainDefNamespaceFree(nsdata);
goto cleanup;
}
+ nsdata->datacenterPath = g_strdup(ctx->datacenterPath);
+
+ nsdata->moref = g_strdup(ctx->moref);
+
def->ns = *virDomainXMLOptionGetNamespace(xmlopt);
def->namespaceData = nsdata;
}
goto cleanup;
}
- if (VIR_STRDUP((*def)->source->data.tcp.host, parsedUri->server) < 0)
- goto cleanup;
+ (*def)->source->data.tcp.host = g_strdup(parsedUri->server);
if (virAsprintf(&(*def)->source->data.tcp.service, "%d",
parsedUri->port) < 0)
if (dname) {
VIR_FREE(def->name);
- if (VIR_STRDUP(def->name, dname) < 0)
- goto cleanup;
+ def->name = g_strdup(dname);
}
if (virDomainMigratePrepare3ParamsEnsureACL(conn, def) < 0)
virCheckNonNullArgGoto(uuidstr, error);
virCheckNonNullArgGoto(uuid, error);
- if (VIR_STRDUP(tmp, uuidstr) < 0)
- goto error;
+ tmp = g_strdup(uuidstr);
tmp[strlen(tmp) - 1] = '\0';
fs->type = VIR_DOMAIN_FS_TYPE_VOLUME;
if (VIR_ALLOC(fs->src->srcpool) < 0)
goto cleanup;
- if (VIR_STRDUP(fs->src->srcpool->pool, matches[1]) < 0)
- goto cleanup;
- if (VIR_STRDUP(fs->src->srcpool->volume, matches[2]) < 0)
- goto cleanup;
+ fs->src->srcpool->pool = g_strdup(matches[1]);
+ fs->src->srcpool->volume = g_strdup(matches[2]);
VIR_FREE(buf);
} else {
fs->type = VIR_DOMAIN_FS_TYPE_FILE;
* always up */
net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
- if (VIR_STRDUP(net->data.network.name,
- PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
- goto cleanup;
+ net->data.network.name = g_strdup(PARALLELS_DOMAIN_ROUTED_NETWORK_NAME);
return 0;
}
if (emulatedType == PNA_ROUTED) {
net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
- if (VIR_STRDUP(net->data.network.name,
- PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
- goto cleanup;
+ net->data.network.name = g_strdup(PARALLELS_DOMAIN_ROUTED_NETWORK_NAME);
} else {
char *netid =
prlsdkGetStringParamVar(PrlVmDevNet_GetVirtualNetworkId,
goto cleanup;
if (!(uri = virURIParse(uristr)))
goto cleanup;
- if (VIR_STRDUP(chr->source->data.tcp.host, uri->server) < 0)
- goto cleanup;
+ chr->source->data.tcp.host = g_strdup(uri->server);
if (virAsprintf(&chr->source->data.tcp.service, "%d", uri->port) < 0)
goto cleanup;
chr->source->data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER;
goto cleanup;
if (!(uri = virURIParse(uristr)))
goto cleanup;
- if (VIR_STRDUP(chr->source->data.udp.bindHost, uri->server) < 0)
- goto cleanup;
+ chr->source->data.udp.bindHost = g_strdup(uri->server);
if (virAsprintf(&chr->source->data.udp.bindService, "%d", uri->port) < 0)
goto cleanup;
- if (VIR_STRDUP(chr->source->data.udp.connectHost, uri->server) < 0)
- goto cleanup;
+ chr->source->data.udp.connectHost = g_strdup(uri->server);
if (virAsprintf(&chr->source->data.udp.connectService, "%d", uri->port) < 0)
goto cleanup;
break;
break;
case PVT_CT:
def->os.type = VIR_DOMAIN_OSTYPE_EXE;
- if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
- return -1;
+ def->os.init = g_strdup("/sbin/init");
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,