if (VIR_ALLOC(caps->host.secModels) < 0)
goto error;
caps->host.nsecModels = 1;
- if (VIR_STRDUP(caps->host.secModels[0].model, model) < 0)
- goto error;
- if (VIR_STRDUP(caps->host.secModels[0].doi, doi) < 0)
- goto error;
+ caps->host.secModels[0].model = g_strdup(model);
+ caps->host.secModels[0].doi = g_strdup(doi);
if (label &&
virCapabilitiesHostSecModelAddBaseLabel(&caps->host.secModels[0],
type,
cfg->securityRequireConfined = false;
/* Set the container configuration directory */
- if (VIR_STRDUP(cfg->configDir, LXC_CONFIG_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->stateDir, LXC_STATE_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->logDir, LXC_LOG_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->autostartDir, LXC_AUTOSTART_DIR) < 0)
- goto error;
+ cfg->configDir = g_strdup(LXC_CONFIG_DIR);
+ cfg->stateDir = g_strdup(LXC_STATE_DIR);
+ cfg->logDir = g_strdup(LXC_LOG_DIR);
+ cfg->autostartDir = g_strdup(LXC_AUTOSTART_DIR);
return cfg;
- error:
- virObjectUnref(cfg);
- return NULL;
}
int
lxcIsBasicMountLocation(mntent.mnt_dir))
continue;
- if (VIR_STRDUP(tmp, mntent.mnt_dir) < 0 ||
- VIR_APPEND_ELEMENT(mounts, nmounts, tmp) < 0) {
+ tmp = g_strdup(mntent.mnt_dir);
+
+ if (VIR_APPEND_ELEMENT(mounts, nmounts, tmp) < 0) {
VIR_FREE(tmp);
goto cleanup;
}
*/
if (userns_enabled && netns_disabled &&
STREQ(mnt->src, "sysfs")) {
- if (VIR_STRDUP(mnt_src, "/sys") < 0)
- goto cleanup;
+ mnt_src = g_strdup("/sys");
mnt_mflags = MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY|MS_BIND;
} else {
- if (VIR_STRDUP(mnt_src, mnt->src) < 0)
- goto cleanup;
+ mnt_src = g_strdup(mnt->src);
mnt_mflags = mnt->mflags;
}
goto cleanup;
}
- if (VIR_STRDUP(*type, data) < 0)
- goto cleanup;
+ *type = g_strdup(data);
done:
ret = 0;
int ret = -1;
char *dir, *tmp;
- if (VIR_STRDUP(dir, dev) < 0)
- return -1;
+ dir = g_strdup(dev);
if ((tmp = strrchr(dir, '/'))) {
*tmp = '\0';
char *hostname = NULL;
/* Filter the VM name to get a valid hostname */
- if (VIR_STRDUP(name, def->name) < 0)
- goto cleanup;
+ name = g_strdup(def->name);
/* RFC 1123 allows 0-9 digits as a first character in hostname */
virStringFilterChars(name, hostname_validchars);
def->type = type;
def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
- if (src && VIR_STRDUP(def->src->path, src) < 0)
- goto error;
- if (VIR_STRDUP(def->dst, dst) < 0)
- goto error;
+ if (src)
+ def->src->path = g_strdup(src);
+ def->dst = g_strdup(dst);
def->readonly = readonly;
def->usage = usage;
return def;
-
- error:
- virDomainFSDefFree(def);
- return NULL;
}
typedef struct _lxcFstab lxcFstab;
char **parts;
char **result = NULL;
- if (VIR_STRDUP(tmp, string) < 0)
- return NULL;
+ tmp = g_strdup(string);
/* Replace potential \t by a space */
for (i = 0; tmp[i]; i++) {
if (VIR_EXPAND_N(result, ntokens, 1) < 0)
goto error;
- if (VIR_STRDUP(result[ntokens-2], parts[i]) < 0)
- goto error;
+ result[ntokens - 2] = g_strdup(parts[i]);
}
VIR_FREE(tmp);
if (!parts[0] || !parts[1] || !parts[2] || !parts[3])
goto error;
- if (VIR_STRDUP(fstab->src, parts[0]) < 0 ||
- VIR_STRDUP(fstab->dst, parts[1]) < 0 ||
- VIR_STRDUP(fstab->type, parts[2]) < 0 ||
- VIR_STRDUP(fstab->options, parts[3]) < 0)
- goto error;
+ fstab->src = g_strdup(parts[0]);
+ fstab->dst = g_strdup(parts[1]);
+ fstab->type = g_strdup(parts[2]);
+ fstab->options = g_strdup(parts[3]);
virStringListFree(parts);
if (virAsprintf(&dst, "/%s", fstab->dst) < 0)
goto cleanup;
} else {
- if (VIR_STRDUP(dst, fstab->dst) < 0)
- goto cleanup;
+ dst = g_strdup(fstab->dst);
}
/* Check that we don't add basic mounts */
else
net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN;
- if (VIR_STRDUP(net->ifname_guest, name) < 0)
- goto error;
+ net->ifname_guest = g_strdup(name);
if (mac && virMacAddrParse(mac, &macAddr) == 0)
net->mac = macAddr;
if (STREQ(type, "veth")) {
if (linkdev) {
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
- if (VIR_STRDUP(net->data.bridge.brname, linkdev) < 0)
- goto error;
+ net->data.bridge.brname = g_strdup(linkdev);
} else {
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
}
} else if (STREQ(type, "macvlan")) {
net->type = VIR_DOMAIN_NET_TYPE_DIRECT;
- if (!linkdev || VIR_STRDUP(net->data.direct.linkdev, linkdev) < 0)
+ if (!linkdev)
goto error;
+ net->data.direct.linkdev = g_strdup(linkdev);
+
if (!macvlanmode || STREQ(macvlanmode, "private"))
net->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_PRIVATE;
else if (STREQ(macvlanmode, "vepa"))
hostdev->mode = mode;
hostdev->source.caps.type = type;
- if (type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET &&
- VIR_STRDUP(hostdev->source.caps.u.net.ifname, data) < 0) {
- virDomainHostdevDefFree(hostdev);
- hostdev = NULL;
- }
+ if (type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
+ hostdev->source.caps.u.net.ifname = g_strdup(data);
return hostdev;
}
char *familyStr = NULL;
char *zero = NULL;
- if (VIR_STRDUP(zero, family == AF_INET ? VIR_SOCKET_ADDR_IPV4_ALL
- : VIR_SOCKET_ADDR_IPV6_ALL) < 0)
- goto error;
+ zero = g_strdup(family == AF_INET ? VIR_SOCKET_ADDR_IPV4_ALL : VIR_SOCKET_ADDR_IPV6_ALL);
- if (VIR_STRDUP(familyStr, family == AF_INET ? "ipv4" : "ipv6") < 0)
- goto error;
+ familyStr = g_strdup(family == AF_INET ? "ipv4" : "ipv6");
if (!(route = virNetDevIPRouteCreate(_("Domain interface"), familyStr,
zero, NULL, address, 0, false,
VIR_FREE(value);
}
- if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0)
- goto error;
+ vmdef->os.init = g_strdup("/sbin/init");
if (virConfGetValueString(properties, "lxc.uts.name", &value) <= 0) {
virResetLastError();
goto error;
}
- if (VIR_STRDUP(vmdef->name, value) < 0)
- goto error;
+ vmdef->name = g_strdup(value);
- if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0))
- goto error;
+ if (!vmdef->name)
+ vmdef->name = g_strdup("unnamed");
if (lxcSetRootfs(vmdef, properties) < 0)
goto error;