goto cleanup;
}
- if (VIR_STRDUP(*hostname, result) < 0)
- goto cleanup;
+ *hostname = g_strdup(result);
ret = 0;
virDomainFSInfoPtr ret = NULL;
size_t i;
- if (VIR_ALLOC(ret) < 0 ||
- VIR_STRDUP(ret->mountpoint, agent->mountpoint) < 0 ||
- VIR_STRDUP(ret->name, agent->name) < 0 ||
- VIR_STRDUP(ret->fstype, agent->fstype) < 0)
+ if (VIR_ALLOC(ret) < 0)
goto error;
+ ret->mountpoint = g_strdup(agent->mountpoint);
+ ret->name = g_strdup(agent->name);
+ ret->fstype = g_strdup(agent->fstype);
+
if (agent->disks &&
VIR_ALLOC_N(ret->devAlias, agent->ndisks) < 0)
goto error;
ret->ndevAlias = agent->ndisks;
- for (i = 0; i < ret->ndevAlias; i++) {
- if (VIR_STRDUP(ret->devAlias[i], agent->disks[i]->alias) < 0)
- goto error;
- }
+ for (i = 0; i < ret->ndevAlias; i++)
+ ret->devAlias[i] = g_strdup(agent->disks[i]->alias);
return ret;
return -1;
disk = fsinfo->disks[i];
- if ((val = virJSONValueObjectGetString(jsondisk, "serial"))) {
- if (VIR_STRDUP(disk->serial, val) < 0)
- return -1;
- }
+ if ((val = virJSONValueObjectGetString(jsondisk, "serial")))
+ disk->serial = g_strdup(val);
- if ((val = virJSONValueObjectGetString(jsondisk, "dev"))) {
- if (VIR_STRDUP(disk->devnode, val) < 0)
- return -1;
- }
+ if ((val = virJSONValueObjectGetString(jsondisk, "dev")))
+ disk->devnode = g_strdup(val);
#define GET_DISK_ADDR(jsonObject, var, name) \
do { \
unit)))
continue;
- if (VIR_STRDUP(disk->alias, diskDef->dst) < 0)
- return -1;
+ disk->alias = g_strdup(diskDef->dst);
}
return 0;
goto cleanup;
}
- if (VIR_STRDUP(info_ret[i]->mountpoint, result) < 0)
- goto cleanup;
+ info_ret[i]->mountpoint = g_strdup(result);
if (!(result = virJSONValueObjectGetString(entry, "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
goto cleanup;
}
- if (VIR_STRDUP(info_ret[i]->name, result) < 0)
- goto cleanup;
+ info_ret[i]->name = g_strdup(result);
if (!(result = virJSONValueObjectGetString(entry, "type"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
goto cleanup;
}
- if (VIR_STRDUP(info_ret[i]->fstype, result) < 0)
- goto cleanup;
+ info_ret[i]->fstype = g_strdup(result);
/* 'used-bytes' and 'total-bytes' were added in qemu-ga 3.0 */
iface = ifaces_ret[ifaces_count - 1];
iface->naddrs = 0;
- if (VIR_STRDUP(iface->name, ifname_s) < 0)
- goto error;
+ iface->name = g_strdup(ifname_s);
hwaddr = virJSONValueObjectGetString(tmp_iface, "hardware-address");
- if (VIR_STRDUP(iface->hwaddr, hwaddr) < 0)
- goto error;
+ iface->hwaddr = g_strdup(hwaddr);
}
/* Has to be freed for each interface. */
" field for interface '%s'"), name);
goto error;
}
- if (VIR_STRDUP(ip_addr->addr, addr) < 0)
- goto error;
+ ip_addr->addr = g_strdup(addr);
if (virJSONValueObjectGetNumberUint(ip_addr_obj, "prefix",
&ip_addr->prefix) < 0) {
case VIR_DOMAIN_DISK_BUS_IDE:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SCSI:
- if (VIR_STRDUP(diskPriv->qomName, disk->info.alias) < 0)
- return -1;
+ diskPriv->qomName = g_strdup(disk->info.alias);
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
if (watchdog->info.alias)
return 0;
- if (VIR_STRDUP(watchdog->info.alias, "watchdog0") < 0)
- return -1;
+ watchdog->info.alias = g_strdup("watchdog0");
return 0;
}
{
if (vsock->info.alias)
return 0;
- if (VIR_STRDUP(vsock->info.alias, "vsock0") < 0)
- return -1;
+ vsock->info.alias = g_strdup("vsock0");
return 0;
}
if (VIR_ALLOC(data) < 0)
return -1;
- if (VIR_STRDUP(data->nodeformat, nodename) < 0 ||
- VIR_STRDUP(data->nodestorage, parentnodename) < 0 ||
- VIR_STRDUP(data->qemufilename, filename) < 0 ||
- VIR_STRDUP(data->drvformat, drvname) < 0 ||
- VIR_STRDUP(data->drvstorage, drvparent) < 0)
- return -1;
+ data->nodeformat = g_strdup(nodename);
+ data->nodestorage = g_strdup(parentnodename);
+ data->qemufilename = g_strdup(filename);
+ data->drvformat = g_strdup(drvname);
+ data->drvstorage = g_strdup(drvparent);
if (backing &&
qemuBlockNodeNameGetBackingChainBacking(backing, nodenamestable,
break;
} else {
- if (VIR_STRDUP(src->nodeformat, entry->nodeformat) < 0 ||
- VIR_STRDUP(src->nodestorage, entry->nodestorage) < 0)
- goto cleanup;
+ src->nodeformat = g_strdup(entry->nodeformat);
+ src->nodestorage = g_strdup(entry->nodestorage);
}
entry = entry->backing;
if (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
uri->port = src->hosts->port;
- if (VIR_STRDUP(uri->scheme,
- virStorageNetProtocolTypeToString(src->protocol)) < 0)
- return NULL;
+ uri->scheme = g_strdup(virStorageNetProtocolTypeToString(src->protocol));
} else {
if (virAsprintf(&uri->scheme, "%s+%s",
virStorageNetProtocolTypeToString(src->protocol),
}
}
- if (VIR_STRDUP(uri->server, src->hosts->name) < 0)
- return NULL;
+ uri->server = g_strdup(src->hosts->name);
return g_steal_pointer(&uri);
}
* }
*/
- if (VIR_STRDUP(target, src->path) < 0)
- return NULL;
+ target = g_strdup(src->path);
/* Separate the target and lun */
if ((lunStr = strchr(target, '/'))) {
}
if (src->pr &&
- !virStoragePRDefIsManaged(src->pr) &&
- VIR_STRDUP(data->prmgrAlias, src->pr->mgralias) < 0)
- goto cleanup;
+ !virStoragePRDefIsManaged(src->pr))
+ data->prmgrAlias = g_strdup(src->pr->mgralias);
- if (VIR_STRDUP(data->tlsAlias, src->tlsAlias) < 0)
- goto cleanup;
+ data->tlsAlias = g_strdup(src->tlsAlias);
if (srcpriv) {
- if (srcpriv->secinfo &&
- srcpriv->secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES &&
- VIR_STRDUP(data->authsecretAlias, srcpriv->secinfo->s.aes.alias) < 0)
- goto cleanup;
+ if (srcpriv->secinfo && srcpriv->secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
+ data->authsecretAlias = g_strdup(srcpriv->secinfo->s.aes.alias);
- if (srcpriv->encinfo &&
- srcpriv->encinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES &&
- VIR_STRDUP(data->encryptsecretAlias, srcpriv->encinfo->s.aes.alias) < 0)
- goto cleanup;
+ if (srcpriv->encinfo && srcpriv->encinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
+ data->encryptsecretAlias = g_strdup(srcpriv->encinfo->s.aes.alias);
}
ret = g_steal_pointer(&data);
if (!(job = virObjectNew(qemuBlockJobDataClass)))
return NULL;
- if (VIR_STRDUP(job->name, name) < 0)
- return NULL;
+ job->name = g_strdup(name);
job->state = QEMU_BLOCKJOB_STATE_NEW;
job->newstate = -1;
* execute the finishing steps */
job->newstate = job->state;
} else if (newstate == QEMU_BLOCKJOB_STATE_CONCLUDED) {
- if (VIR_STRDUP(job->errmsg, jobinfo[i]->error) < 0)
- goto cleanup;
+ job->errmsg = g_strdup(jobinfo[i]->error);
if (job->errmsg)
job->newstate = QEMU_BLOCKJOB_STATE_FAILED;
if (STRNEQ_NULLABLE(job->name, jobinfo[i]->id))
continue;
- if (VIR_STRDUP(job->errmsg, jobinfo[i]->error) < 0)
- rc = -1;
+ job->errmsg = g_strdup(jobinfo[i]->error);
if (job->errmsg)
job->newstate = QEMU_BLOCKJOB_STATE_FAILED;
/* RHEL doesn't follow the usual naming for QEMU binaries and ships
* a single binary named qemu-kvm outside of $PATH instead */
- if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) {
- if (VIR_STRDUP(binary, "/usr/libexec/qemu-kvm") < 0)
- return -1;
- }
+ if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary)
+ binary = g_strdup("/usr/libexec/qemu-kvm");
/* Ignore binary if extracting version info fails */
if (binary) {
{
g_autoptr(virSEVCapability) tmp = NULL;
- if (VIR_ALLOC(tmp) < 0 ||
- VIR_STRDUP(tmp->pdh, src->pdh) < 0 ||
- VIR_STRDUP(tmp->cert_chain, src->cert_chain) < 0)
+ if (VIR_ALLOC(tmp) < 0)
return -1;
+ tmp->pdh = g_strdup(src->pdh);
+ tmp->cert_chain = g_strdup(src->cert_chain);
+
tmp->cbitpos = src->cbitpos;
tmp->reduced_phys_bits = src->reduced_phys_bits;
ret->usedQMP = qemuCaps->usedQMP;
ret->kvmSupportsNesting = qemuCaps->kvmSupportsNesting;
- if (VIR_STRDUP(ret->binary, qemuCaps->binary) < 0)
- goto error;
+ ret->binary = g_strdup(qemuCaps->binary);
ret->ctime = qemuCaps->ctime;
ret->kvmVersion = qemuCaps->kvmVersion;
ret->microcodeVersion = qemuCaps->microcodeVersion;
- if (VIR_STRDUP(ret->package, qemuCaps->package) < 0)
- goto error;
-
- if (VIR_STRDUP(ret->kernelVersion, qemuCaps->kernelVersion) < 0)
- goto error;
+ ret->package = g_strdup(qemuCaps->package);
+ ret->kernelVersion = g_strdup(qemuCaps->kernelVersion);
ret->arch = qemuCaps->arch;
goto error;
ret->nmachineTypes = qemuCaps->nmachineTypes;
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
- if (VIR_STRDUP(ret->machineTypes[i].name, qemuCaps->machineTypes[i].name) < 0 ||
- VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[i].alias) < 0)
- goto error;
+ ret->machineTypes[i].name = g_strdup(qemuCaps->machineTypes[i].name);
+ ret->machineTypes[i].alias = g_strdup(qemuCaps->machineTypes[i].alias);
ret->machineTypes[i].maxCpus = qemuCaps->machineTypes[i].maxCpus;
ret->machineTypes[i].hotplugCpus = qemuCaps->machineTypes[i].hotplugCpus;
ret->machineTypes[i].qemuDefault = qemuCaps->machineTypes[i].qemuDefault;
goto error;
(*machines)[i] = mach;
if (qemuCaps->machineTypes[i].alias) {
- if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].alias) < 0 ||
- VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i].name) < 0)
- goto error;
+ mach->name = g_strdup(qemuCaps->machineTypes[i].alias);
+ mach->canonical = g_strdup(qemuCaps->machineTypes[i].name);
} else {
- if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].name) < 0)
- goto error;
+ mach->name = g_strdup(qemuCaps->machineTypes[i].name);
}
mach->maxCpus = qemuCaps->machineTypes[i].maxCpus;
}
VIR_FREE(mach);
goto error;
}
- if (VIR_STRDUP(mach->name, machine->canonical) < 0)
- goto error;
+ mach->name = g_strdup(machine->canonical);
mach->maxCpus = machine->maxCpus;
i++;
}
mach = &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]);
- if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 ||
- VIR_STRDUP(mach->name, machines[i]->name) < 0)
- goto cleanup;
+ mach->alias = g_strdup(machines[i]->alias);
+ mach->name = g_strdup(machines[i]->name);
mach->maxCpus = machines[i]->maxCpus;
mach->hotplugCpus = machines[i]->hotplugCpus;
continue;
VIR_FREE(cpus[i]->name);
- if (VIR_STRDUP(cpus[i]->name, *name) < 0)
- goto error;
+ cpus[i]->name = g_strdup(*name);
}
}
}
model = "host";
}
- if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, model) < 0)
+ if (VIR_ALLOC(cpu) < 0)
goto cleanup;
+ cpu->model = g_strdup(model);
+
/* Some x86_64 features defined in cpu_map.xml use spelling which differ
* from the one preferred by QEMU. Static expansion would give us only the
* preferred spelling. With new QEMU we always use the QEMU's canonical
if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
continue;
- if (VIR_STRDUP(list[n++],
- virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name)) < 0)
- goto cleanup;
+ list[n++] = g_strdup(virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name));
}
*features = g_steal_pointer(&list);
else
ret = 0;
- cleanup:
virStringListFree(list);
return ret;
}
return 2;
}
- if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 ||
- VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0)
+ cpu->model = g_strdup(modelInfo->name);
+ if (VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0)
return -1;
cpu->nfeatures_max = modelInfo->nprops;
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
continue;
- if (VIR_STRDUP(feature->name, name) < 0)
- return -1;
+ feature->name = g_strdup(name);
if (!prop->value.boolean ||
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
if (!(qemuCaps = virQEMUCapsNew()))
goto error;
- if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
- goto error;
+ qemuCaps->binary = g_strdup(binary);
/* We would also want to check faccessat if we cared about ACLs,
* but we don't. */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
qemuCaps->microcodeVersion = microcodeVersion;
- if (VIR_STRDUP(qemuCaps->kernelVersion, kernelVersion) < 0)
- goto error;
+ qemuCaps->kernelVersion = g_strdup(kernelVersion);
qemuCaps->kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
}
if (!qemuCaps)
return NULL;
- if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
- goto error;
+ qemuCaps->binary = g_strdup(binary);
if (virQEMUCapsLoadCache(priv->hostArch, qemuCaps, filename) < 0)
goto error;
goto error;
virFileCacheSetPriv(cache, priv);
- if (VIR_STRDUP(priv->libDir, libDir) < 0)
- goto error;
+ priv->libDir = g_strdup(libDir);
priv->hostArch = virArchFromHost();
if (j != capsLoader->values.nvalues)
continue;
- if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalues],
- filename) < 0)
- return -1;
+ capsLoader->values.values[capsLoader->values.nvalues] = g_strdup(filename);
capsLoader->values.nvalues++;
}
if (VIR_ALLOC(sev) < 0)
return -1;
- if (VIR_STRDUP(sev->pdh, cap->pdh) < 0)
- return -1;
+ sev->pdh = g_strdup(cap->pdh);
- if (VIR_STRDUP(sev->cert_chain, cap->cert_chain) < 0)
- return -1;
+ sev->cert_chain = g_strdup(cap->cert_chain);
sev->cbitpos = cap->cbitpos;
sev->reduced_phys_bits = cap->reduced_phys_bits;
if (VIR_ALLOC(res) < 0)
goto cleanup;
- if (VIR_STRDUP(res->partition, "/machine") < 0) {
- VIR_FREE(res);
- goto cleanup;
- }
+ res->partition = g_strdup("/machine");
vm->def->resource = res;
}
other = virDomainCheckpointGetCurrent(vm->checkpoints);
if (other) {
- if (!redefine &&
- VIR_STRDUP(chk->def->parent_name, other->def->name) < 0)
- goto endjob;
+ if (!redefine)
+ chk->def->parent_name = g_strdup(other->def->name);
}
/* actually do the checkpoint */
VIR_FREE(moment->def->parent_name);
- if (rep->parent->def &&
- VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) {
- rep->err = -1;
- return 0;
- }
+ if (rep->parent->def)
+ moment->def->parent_name = g_strdup(rep->parent->def->name);
rep->err = qemuCheckpointWriteMetadata(rep->vm, moment, rep->caps,
rep->xmlopt, rep->dir);
secinfo->s.plain.secret) < 0)
return -1;
} else {
- if (VIR_STRDUP(uri->user, secinfo->s.plain.username) < 0)
- return -1;
+ uri->user = g_strdup(secinfo->s.plain.username);
}
break;
case VIR_STORAGE_TYPE_BLOCK:
case VIR_STORAGE_TYPE_FILE:
case VIR_STORAGE_TYPE_DIR:
- if (VIR_STRDUP(*source, src->path) < 0)
- return -1;
+ *source = g_strdup(src->path);
break;
* ourselves especially for cases when -blockdev will be used */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_DEVICE_ID)) {
if (disk->serial) {
- if (VIR_STRDUP(scsiVPDDeviceId, disk->serial) < 0)
- goto error;
+ scsiVPDDeviceId = g_strdup(disk->serial);
} else {
if (!(scsiVPDDeviceId = qemuAliasDiskDriveFromDisk(disk)))
goto error;
def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
if (mem->nvdimmPath) {
- if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
- return -1;
+ memPath = g_strdup(mem->nvdimmPath);
if (!priv->memPrealloc)
prealloc = true;
} else if (useHugepage) {
return -1;
}
- if (VIR_STRDUP(cpu, default_model) < 0)
- return -1;
+ cpu = g_strdup(default_model);
}
if (cpu) {
"%s/log/swtpm/libvirt/qemu", LOCALSTATEDIR) < 0)
return NULL;
- if (VIR_STRDUP(cfg->configBaseDir, SYSCONFDIR "/libvirt") < 0)
- return NULL;
+ cfg->configBaseDir = g_strdup(SYSCONFDIR "/libvirt");
if (virAsprintf(&cfg->stateDir,
"%s/libvirt/qemu", RUNSTATEDIR) < 0)
* This will then be used as a fallback if the service specific
* directory doesn't exist (although we don't check if this exists).
*/
- if (VIR_STRDUP(cfg->defaultTLSx509certdir,
- SYSCONFDIR "/pki/qemu") < 0)
- return NULL;
+ cfg->defaultTLSx509certdir = g_strdup(SYSCONFDIR "/pki/qemu");
- if (VIR_STRDUP(cfg->vncListen, VIR_LOOPBACK_IPV4_ADDR) < 0)
- return NULL;
-
- if (VIR_STRDUP(cfg->spiceListen, VIR_LOOPBACK_IPV4_ADDR) < 0)
- return NULL;
+ cfg->vncListen = g_strdup(VIR_LOOPBACK_IPV4_ADDR);
+ cfg->spiceListen = g_strdup(VIR_LOOPBACK_IPV4_ADDR);
cfg->remotePortMin = QEMU_REMOTE_PORT_MIN;
cfg->remotePortMax = QEMU_REMOTE_PORT_MAX;
return NULL;
}
- if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0 ||
- VIR_STRDUP(cfg->prHelperName, QEMU_PR_HELPER) < 0 ||
- VIR_STRDUP(cfg->slirpHelperName, QEMU_SLIRP_HELPER) < 0)
- return NULL;
+ cfg->bridgeHelperName = g_strdup(QEMU_BRIDGE_HELPER);
+ cfg->prHelperName = g_strdup(QEMU_PR_HELPER);
+ cfg->slirpHelperName = g_strdup(QEMU_SLIRP_HELPER);
cfg->clearEmulatorCapabilities = true;
const char *path,
bool deflt)
{
- if (VIR_STRDUP(hugetlbfs->mnt_dir, path) < 0 ||
- virFileGetHugepageSize(path, &hugetlbfs->size) < 0) {
+ hugetlbfs->mnt_dir = g_strdup(path);
+ if (virFileGetHugepageSize(path, &hugetlbfs->size) < 0)
return -1;
- }
hugetlbfs->deflt = deflt;
return 0;
if (!cfg->val## TLSx509certdir && \
!cfg->val## TLSx509secretUUID && \
cfg->defaultTLSx509secretUUID) { \
- if (VIR_STRDUP(cfg->val## TLSx509secretUUID, \
- cfg->defaultTLSx509secretUUID) < 0) { \
- return -1; \
- } \
+ cfg->val## TLSx509secretUUID = g_strdup(cfg->defaultTLSx509secretUUID); \
} \
} while (0)
if (cfg->val ## TLSx509certdir) \
break; \
if (virFileExists(SYSCONFDIR "/pki/libvirt-"#val)) { \
- if (VIR_STRDUP(cfg->val ## TLSx509certdir, \
- SYSCONFDIR "/pki/libvirt-"#val) < 0) { \
- return -1; \
- } \
+ cfg->val ## TLSx509certdir = g_strdup(SYSCONFDIR "/pki/libvirt-"#val); \
} else { \
- if (VIR_STRDUP(cfg->val ## TLSx509certdir, \
- cfg->defaultTLSx509certdir) < 0) { \
- return -1; \
- } \
+ cfg->val ## TLSx509certdir = g_strdup(cfg->defaultTLSx509certdir); \
} \
} while (0)
virCapsHostSecModelPtr sm = &caps->host.secModels[i];
doi = qemuSecurityGetDOI(sec_managers[i]);
model = qemuSecurityGetModel(sec_managers[i]);
- if (VIR_STRDUP(sm->model, model) < 0 ||
- VIR_STRDUP(sm->doi, doi) < 0)
- return NULL;
+ sm->model = g_strdup(model);
+ sm->doi = g_strdup(doi);
for (j = 0; j < G_N_ELEMENTS(virtTypes); j++) {
lbl = qemuSecurityGetBaseLabel(sec_managers[i], virtTypes[j]);
* recorded in the table.
*/
if (!qemuSharedDeviceEntryDomainExists(entry, name, NULL)) {
- if (VIR_EXPAND_N(entry->domains, entry->ref, 1) < 0 ||
- VIR_STRDUP(entry->domains[entry->ref - 1], name) < 0) {
+ if (VIR_EXPAND_N(entry->domains, entry->ref, 1) < 0) {
/* entry is owned by the hash table here */
entry = NULL;
goto error;
}
+ entry->domains[entry->ref - 1] = g_strdup(name);
}
} else {
if (VIR_ALLOC(entry) < 0 ||
- VIR_ALLOC_N(entry->domains, 1) < 0 ||
- VIR_STRDUP(entry->domains[0], name) < 0)
+ VIR_ALLOC_N(entry->domains, 1) < 0)
goto error;
+ entry->domains[0] = g_strdup(name);
+
entry->ref = 1;
if (virHashAddEntry(driver->sharedDevices, key, entry) < 0)
if (VIR_ALLOC(self) < 0)
return NULL;
- if (VIR_STRDUP(self->id, id) < 0)
- return NULL;
-
- if (VIR_STRDUP(self->addr, addr) < 0)
- return NULL;
+ self->id = g_strdup(id);
+ self->addr = g_strdup(addr);
return g_steal_pointer(&self);
}
return -1;
secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN;
- if (VIR_STRDUP(secinfo->s.plain.username, username) < 0)
- goto cleanup;
+ secinfo->s.plain.username = g_strdup(username);
ret = virSecretGetSecretString(conn, seclookupdef, usageType,
&secinfo->s.plain.secret,
&secinfo->s.plain.secretlen);
- cleanup:
virObjectUnref(conn);
return ret;
}
return -1;
secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
- if (VIR_STRDUP(secinfo->s.aes.username, username) < 0)
- goto cleanup;
+ secinfo->s.aes.username = g_strdup(username);
if (!(secinfo->s.aes.alias = qemuDomainGetSecretAESAlias(srcalias, isLuks)))
goto cleanup;
if (!cfg->vncTLS)
return 0;
- if (VIR_STRDUP(gfxPriv->tlsAlias, "vnc-tls-creds0") < 0)
- return -1;
+ gfxPriv->tlsAlias = g_strdup("vnc-tls-creds0");
if (cfg->vncTLSx509secretUUID) {
gfxPriv->secinfo = qemuDomainSecretInfoTLSNew(priv, gfxPriv->tlsAlias,
if (STRNEQ(canon, def->os.machine)) {
char *tmp;
- if (VIR_STRDUP(tmp, canon) < 0)
- return -1;
+ tmp = g_strdup(canon);
VIR_FREE(def->os.machine);
def->os.machine = tmp;
}
else
nodename = disk->src->nodeformat;
- if (VIR_STRDUP(*backendAlias, nodename) < 0)
- return -1;
+ *backendAlias = g_strdup(nodename);
return 0;
}
src->tlsFromConfig = true;
}
- if (src->haveTLS == VIR_TRISTATE_BOOL_YES) {
- if (VIR_STRDUP(src->tlsCertdir, cfg->vxhsTLSx509certdir) < 0)
- return -1;
- }
+ if (src->haveTLS == VIR_TRISTATE_BOOL_YES)
+ src->tlsCertdir = g_strdup(cfg->vxhsTLSx509certdir);
return 0;
}
return -1;
}
- if (VIR_STRDUP(src->tlsCertdir, cfg->nbdTLSx509certdir) < 0)
- return -1;
+ src->tlsCertdir = g_strdup(cfg->nbdTLSx509certdir);
}
return 0;
toAlloc = 2;
if (VIR_ALLOC_N(tmpPaths, toAlloc) < 0 ||
- VIR_ALLOC_N(tmpPerms, toAlloc) < 0 ||
- VIR_STRDUP(tmpPaths[0], tmpPath) < 0)
+ VIR_ALLOC_N(tmpPerms, toAlloc) < 0)
goto cleanup;
+ tmpPaths[0] = g_strdup(tmpPath);
tmpNpaths = toAlloc;
tmpPerms[0] = perm;
if (includeVFIO) {
- if (VIR_STRDUP(tmpPaths[1], QEMU_DEV_VFIO) < 0)
- goto cleanup;
+ tmpPaths[1] = g_strdup(QEMU_DEV_VFIO);
tmpPerms[1] = VIR_CGROUP_DEVICE_RW;
}
}
if (IS_RELATIVE_FILE_NAME(target)) {
char *c = NULL, *tmp = NULL, *devTmp = NULL;
- if (VIR_STRDUP(devTmp, device) < 0)
- goto cleanup;
+ devTmp = g_strdup(device);
if ((c = strrchr(devTmp, '/')))
*(c + 1) = '\0';
if (IS_RELATIVE_FILE_NAME(target)) {
char *c = NULL, *tmp = NULL, *fileTmp = NULL;
- if (VIR_STRDUP(fileTmp, file) < 0)
- goto cleanup;
+ fileTmp = g_strdup(file);
if ((c = strrchr(fileTmp, '/')))
*(c + 1) = '\0';
}
/* qemu-pr-helper might require access to /dev/mapper/control. */
- if (src->pr &&
- (VIR_STRDUP(dmPath, QEMU_DEVICE_MAPPER_CONTROL_PATH) < 0 ||
- VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0))
- goto cleanup;
+ if (src->pr) {
+ dmPath = g_strdup(QEMU_DEVICE_MAPPER_CONTROL_PATH);
+ if (VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0)
+ goto cleanup;
+ }
if (qemuDomainNamespaceMknodPaths(vm, paths, npaths) < 0)
goto cleanup;
VIR_FREE(src->pr->path);
if (!(src->pr->path = qemuDomainGetManagedPRSocketPath(priv)))
return -1;
- if (VIR_STRDUP(src->pr->mgralias, qemuDomainGetManagedPRAlias()) < 0)
- return -1;
+ src->pr->mgralias = g_strdup(qemuDomainGetManagedPRAlias());
} else {
if (!(src->pr->mgralias = qemuDomainGetUnmanagedPRAlias(parentalias)))
return -1;
return 0;
cfg = virQEMUDriverGetConfig(qemu_driver);
- if (VIR_STRDUP(*uri, cfg->uri) < 0)
- return -1;
+ *uri = g_strdup(cfg->uri);
return 0;
}
virMacAddr mac = net->mac;
char *script = net->script;
- if (VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0)
- goto cleanup;
+ model = g_strdup(virDomainNetGetModelString(net));
net->script = NULL;
if (qemuDomainNVRAMPathFormat(cfg, vm->def, &nvram_path) < 0)
goto endjob;
} else {
- if (vm->def->os.loader &&
- VIR_STRDUP(nvram_path, vm->def->os.loader->nvram) < 0)
- goto endjob;
+ if (vm->def->os.loader)
+ nvram_path = g_strdup(vm->def->os.loader->nvram);
}
if (nvram_path && virFileExists(nvram_path)) {
if (snapdisk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
VIR_FREE(defdisk->src->path);
- if (VIR_STRDUP(defdisk->src->path, snapdisk->src->path) < 0) {
- /* we cannot rollback here in a sane way */
- goto cleanup;
- }
+ defdisk->src->path = g_strdup(snapdisk->src->path);
defdisk->src->format = snapdisk->src->format;
if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0)
current = virDomainSnapshotGetCurrent(vm->snapshots);
if (current) {
- if (!redefine &&
- VIR_STRDUP(snap->def->parent_name, current->def->name) < 0)
- goto endjob;
+ if (!redefine)
+ snap->def->parent_name = g_strdup(current->def->name);
}
/* actually do the snapshot */
VIR_FREE(moment->def->parent_name);
- if (rep->parent->def &&
- VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) {
- rep->err = -1;
- return 0;
- }
+ if (rep->parent->def)
+ moment->def->parent_name = g_strdup(rep->parent->def->name);
rep->err = rep->writeMetadata(rep->vm, moment, rep->caps, rep->xmlopt,
rep->dir);
goto cleanup;
dest->type = (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) ?
VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE;
- if (VIR_STRDUP(dest->path, base) < 0)
- goto cleanup;
+ dest->path = g_strdup(base);
if (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
dest->format = VIR_STORAGE_FILE_RAW;
if (!(set_fields & QEMU_BLOCK_IOTUNE_SET_SIZE_IOPS))
newinfo->size_iops_sec = oldinfo->size_iops_sec;
- if (!(set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME) &&
- VIR_STRDUP(newinfo->group_name, oldinfo->group_name) < 0)
- return -1;
+ if (!(set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME))
+ newinfo->group_name = g_strdup(oldinfo->group_name);
/* The length field is handled a bit differently. If not defined/set,
* QEMU will default these to 0 or 1 depending on whether something in
/* NB: Cannot use macro since this is a value.s not a value.ul */
if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_GROUP_NAME)) {
- if (VIR_STRDUP(info.group_name, param->value.s) < 0)
- goto endjob;
+ info.group_name = g_strdup(param->value.s);
set_fields |= QEMU_BLOCK_IOTUNE_SET_GROUP_NAME;
if (virTypedParamsAddString(&eventParams, &eventNparams,
&eventMaxparams,
/* Group name needs to be copied since qemuMonitorGetBlockIoThrottle
* allocates it as well */
- if (VIR_STRDUP(reply.group_name, disk->blkdeviotune.group_name) < 0)
- goto endjob;
+ reply.group_name = g_strdup(disk->blkdeviotune.group_name);
}
#define BLOCK_IOTUNE_ASSIGN(name, var) \
if (n == nerrors)
break;
- if (VIR_STRDUP(errors[n].disk, disk->dst) < 0)
- goto endjob;
+ errors[n].disk = g_strdup(disk->dst);
errors[n].error = info->io_status;
n++;
}
if (!(res->vcpus = virBitmapFormat(domresmon->vcpus)))
goto error;
- if (VIR_STRDUP(res->name, virResctrlMonitorGetID(monitor)) < 0)
- goto error;
+ res->name = g_strdup(virResctrlMonitorGetID(monitor));
if (virResctrlMonitorGetStats(monitor, (const char **)features,
&res->stats, &res->nstats) < 0)
if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0)
goto error;
- if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
- goto error;
+ iface->name = g_strdup(vm->def->nets[i]->ifname);
- if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
- goto error;
+ iface->hwaddr = g_strdup(macaddr);
}
for (j = 0; j < n_leases; j++) {
virNetworkDHCPLeasePtr lease = leases[j];
virDomainIPAddressPtr ip_addr = &iface->addrs[j];
- if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0)
- goto error;
+ ip_addr->addr = g_strdup(lease->ipaddr);
ip_addr->type = lease->type;
ip_addr->prefix = lease->prefix;
if (VIR_ALLOC(iface) < 0)
goto cleanup;
- if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
- goto cleanup;
+ iface->name = g_strdup(vm->def->nets[i]->ifname);
- if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
- goto cleanup;
+ iface->hwaddr = g_strdup(macaddr);
if (VIR_ALLOC(iface->addrs) < 0)
goto cleanup;
iface->naddrs = 1;
- if (VIR_STRDUP(iface->addrs->addr, entry.ipaddr) < 0)
- goto cleanup;
+ iface->addrs->addr = g_strdup(entry.ipaddr);
if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < 0)
goto cleanup;
cfg = virQEMUDriverGetConfig(driver);
- if (VIR_STRDUP(new_dom_name, new_name) < 0)
- goto cleanup;
+ new_dom_name = g_strdup(new_name);
if (!(new_dom_cfg_file = virDomainConfigFile(cfg->configDir,
new_dom_name)) ||
goto endjob;
}
- if (VIR_STRDUP(nodename, src->nodestorage) < 0)
- goto endjob;
+ nodename = g_strdup(src->nodestorage);
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorSetBlockThreshold(priv->mon, nodename, threshold);
return -1;
}
- if (VIR_STRDUP(flash->filename, filename) < 0)
- return -1;
+ flash->filename = g_strdup(filename);
if (!(format = virJSONValueObjectGetString(doc, "format"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
return -1;
}
- if (VIR_STRDUP(flash->format, format) < 0)
- return -1;
+ flash->format = g_strdup(format);
return 0;
}
path);
}
- if (VIR_STRDUP(kernel->filename, filename) < 0)
- return -1;
+ kernel->filename = g_strdup(filename);
return 0;
}
path);
}
- if (VIR_STRDUP(memory->filename, filename) < 0)
- return -1;
+ memory->filename = g_strdup(filename);
return 0;
}
virJSONValuePtr machine = virJSONValueArrayGet(machines, j);
g_autofree char *machineStr = NULL;
- if (VIR_STRDUP(machineStr, virJSONValueGetString(machine)) < 0)
- goto cleanup;
+ machineStr = g_strdup(virJSONValueGetString(machine));
VIR_APPEND_ELEMENT_INPLACE(t->machines, t->nmachines, machineStr);
}
}
VIR_FREE(def->os.loader->path);
- if (VIR_STRDUP(def->os.loader->path,
- flash->executable.filename) < 0)
- return -1;
+ def->os.loader->path = g_strdup(flash->executable.filename);
if (STRNEQ(flash->nvram_template.format, "raw")) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
}
VIR_FREE(def->os.loader->templt);
- if (VIR_STRDUP(def->os.loader->templt,
- flash->nvram_template.filename) < 0)
- return -1;
+ def->os.loader->templt = g_strdup(flash->nvram_template.filename);
if (qemuDomainNVRAMPathGenerate(cfg, def) < 0)
return -1;
case QEMU_FIRMWARE_DEVICE_KERNEL:
VIR_FREE(def->os.kernel);
- if (VIR_STRDUP(def->os.kernel, kernel->filename) < 0)
- return -1;
+ def->os.kernel = g_strdup(kernel->filename);
VIR_DEBUG("decided on kernel '%s'",
def->os.kernel);
return -1;
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_ROM;
- if (VIR_STRDUP(def->os.loader->path, memory->filename) < 0)
- return -1;
+ def->os.loader->path = g_strdup(memory->filename);
VIR_DEBUG("decided on loader '%s'",
def->os.loader->path);
break;
}
- if (j == *nfws &&
- (VIR_ALLOC(tmp) < 0 ||
- VIR_STRDUP(tmp->name, fwpath) < 0 ||
- VIR_STRDUP(tmp->nvram, nvrampath) < 0 ||
- VIR_APPEND_ELEMENT(*fws, *nfws, tmp) < 0))
- return -1;
+ if (j == *nfws) {
+ if (VIR_ALLOC(tmp) < 0)
+ return -1;
+
+ tmp->name = g_strdup(fwpath);
+ tmp->nvram = g_strdup(nvrampath);
+ if (VIR_APPEND_ELEMENT(*fws, *nfws, tmp) < 0)
+ return -1;
+ }
}
}
if (blockdev) {
- if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0)
- goto cleanup;
+ corAlias = g_strdup(diskPriv->nodeCopyOnRead);
if (diskPriv->blockjob) {
/* the block job keeps reference to the disk chain */
* save the alias to use when sending a DEVICE_REMOVED event after
* all other teardown is complete
*/
- if ((info = virDomainDeviceGetInfo(dev)) &&
- VIR_STRDUP(alias, info->alias) < 0) {
- return -1;
- }
+ if ((info = virDomainDeviceGetInfo(dev)))
+ alias = g_strdup(info->alias);
info = NULL;
switch ((virDomainDeviceType)dev->type) {
STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
strchr(net->ifname, '%')) {
VIR_FREE(net->ifname);
- if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
- goto cleanup;
+ net->ifname = g_strdup(VIR_NET_GENERATED_TAP_PREFIX "%d");
/* avoid exposing vnet%d in getXMLDesc or error outputs */
template_ifname = true;
}
STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
strchr(net->ifname, '%')) {
VIR_FREE(net->ifname);
- if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
- goto cleanup;
+ net->ifname = g_strdup(VIR_NET_GENERATED_TAP_PREFIX "%d");
/* avoid exposing vnet%d in getXMLDesc or error outputs */
template_ifname = true;
}
if (STRPREFIX(ent->d_name, "."))
continue;
- if (VIR_STRDUP(filename, ent->d_name) < 0)
- goto cleanup;
+ filename = g_strdup(ent->d_name);
if (virAsprintf(&path, "%s/%s", dir, filename) < 0)
goto cleanup;
* much sense to parse files in root's home directory. It
* makes sense only for session daemon which runs under
* regular user. */
- if (VIR_STRDUP(xdgConfig, getenv("XDG_CONFIG_HOME")) < 0)
- return -1;
+ xdgConfig = g_strdup(getenv("XDG_CONFIG_HOME"));
if (!xdgConfig) {
g_autofree char *home = virGetUserDirectory();
return 0;
}
- if (VIR_STRDUP(basePath, disk->src->path) < 0)
- goto cleanup;
+ basePath = g_strdup(disk->src->path);
if (!(volName = strrchr(basePath, '/'))) {
virReportError(VIR_ERR_INVALID_ARG,
if (!(copysrc->backingStore = virStorageSourceNew()))
return -1;
- if (VIR_STRDUP(copysrc->path, diskAlias) < 0)
- return -1;
+ copysrc->path = g_strdup(diskAlias);
if (VIR_ALLOC_N(copysrc->hosts, 1) < 0)
return -1;
copysrc->nhosts = 1;
copysrc->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
copysrc->hosts->port = port;
- if (VIR_STRDUP(copysrc->hosts->name, host) < 0)
- return -1;
+ copysrc->hosts->name = g_strdup(host);
- if (VIR_STRDUP(copysrc->tlsAlias, tlsAlias) < 0)
- return -1;
+ copysrc->tlsAlias = g_strdup(tlsAlias);
if (virAsprintf(©src->nodestorage, "migration-%s-storage", disk->dst) < 0 ||
virAsprintf(©src->nodeformat, "migration-%s-format", disk->dst) < 0)
char *migrateFrom = NULL;
if (tunnel) {
- if (VIR_STRDUP(migrateFrom, "stdio") < 0)
- goto cleanup;
+ migrateFrom = g_strdup("stdio");
} else {
bool encloseAddress = false;
bool hostIPv6Capable = false;
*def = NULL;
priv = vm->privateData;
- if (VIR_STRDUP(priv->origname, origname) < 0)
- goto cleanup;
+ priv->origname = g_strdup(origname);
if (taint_hook) {
/* Domain XML has been altered by a hook script. */
if (virSocketAddrNumericFamily(migrateHost) == AF_INET6)
encloseAddress = true;
- if (VIR_STRDUP(hostname, migrateHost) < 0)
- goto cleanup;
+ hostname = g_strdup(migrateHost);
} else {
if ((hostname = virGetHostname()) == NULL)
goto cleanup;
if (dname) {
name = def->name;
- if (VIR_STRDUP(def->name, dname) < 0) {
- virDomainDefFree(def);
- def = NULL;
- }
+ def->name = g_strdup(dname);
}
cleanup:
!(mig->tlsSubject = qemuDomainExtractTLSSubject(cfg->spiceTLSx509certdir)))
goto error;
- if (VIR_STRDUP(mig->listen, listenAddr) < 0)
- goto error;
+ mig->listen = g_strdup(listenAddr);
virObjectUnref(cfg);
return mig;
name = origname;
else
name = def->name;
- if (VIR_STRDUP(mig->name, name) < 0)
- goto error;
+ mig->name = g_strdup(name);
memcpy(mig->uuid, def->uuid, VIR_UUID_BUFLEN);
if (!(mig->localHostname = virGetHostname()))
}
if (virDomainObjGetState(dom, NULL) == VIR_DOMAIN_PAUSED) {
- if (VIR_STRDUP(mig->lockState, priv->lockState) < 0)
- return -1;
+ mig->lockState = g_strdup(priv->lockState);
} else {
if (virDomainLockProcessInquire(driver->lockManager, dom, &mig->lockState) < 0)
return -1;
}
- if (VIR_STRDUP(mig->lockDriver, virLockManagerPluginGetName(driver->lockManager)) < 0) {
- VIR_FREE(mig->lockState);
- return -1;
- }
+ mig->lockDriver = g_strdup(virLockManagerPluginGetName(driver->lockManager));
mig->flags |= QEMU_MIGRATION_COOKIE_LOCKSTATE;
mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_LOCKSTATE;
!(entry = virHashLookup(stats, disk->info.alias)))
continue;
- if (VIR_STRDUP(mig->nbd->disks[mig->nbd->ndisks].target,
- disk->dst) < 0)
- goto cleanup;
+ mig->nbd->disks[mig->nbd->ndisks].target = g_strdup(disk->dst);
mig->nbd->disks[mig->nbd->ndisks].capacity = entry->capacity;
mig->nbd->ndisks++;
}
mig->persistent &&
STRNEQ(def->name, mig->persistent->name)) {
VIR_FREE(mig->persistent->name);
- if (VIR_STRDUP(mig->persistent->name, def->name) < 0)
- goto error;
+ mig->persistent->name = g_strdup(def->name);
}
if (mig->flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) {
case QEMU_MIGRATION_PARAM_TYPE_STRING:
if ((str = virJSONValueObjectGetString(params, name))) {
- if (VIR_STRDUP(pv->value.s, str) < 0)
- goto error;
+ pv->value.s = g_strdup(str);
pv->set = true;
}
break;
}
return migParams;
-
- error:
- qemuMigrationParamsFree(migParams);
- return NULL;
}
if (qemuMigrationParamsCheckType(param, QEMU_MIGRATION_PARAM_TYPE_STRING) < 0)
return -1;
- if (VIR_STRDUP(migParams->params[param].value.s, value) < 0)
- return -1;
+ migParams->params[param].value.s = g_strdup(value);
migParams->params[param].set = true;
goto cleanup;
}
- if (alias && VIR_STRDUP(tmp, id) < 0)
- goto cleanup;
+ if (alias)
+ tmp = g_strdup(id);
ret = qemuMonitorJSONAddObject(mon, *props);
*props = NULL;
if (VIR_ALLOC_N(copy->props, orig->nprops) < 0)
goto error;
- if (VIR_STRDUP(copy->name, orig->name) < 0)
- goto error;
+ copy->name = g_strdup(orig->name);
copy->migratability = orig->migratability;
copy->nprops = orig->nprops;
for (i = 0; i < orig->nprops; i++) {
- if (VIR_STRDUP(copy->props[i].name, orig->props[i].name) < 0)
- goto error;
+ copy->props[i].name = g_strdup(orig->props[i].name);
copy->props[i].migratable = orig->props[i].migratable;
copy->props[i].type = orig->props[i].type;
break;
case QEMU_MONITOR_CPU_PROPERTY_STRING:
- if (VIR_STRDUP(copy->props[i].value.string,
- orig->props[i].value.string) < 0)
- goto error;
+ copy->props[i].value.string = g_strdup(orig->props[i].value.string);
break;
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
ret->data.s390.psw_mask = psw_mask;
ret->data.s390.psw_addr = psw_addr;
- if (VIR_STRDUP(ret->data.s390.reason, reason) < 0)
- goto error;
+ ret->data.s390.reason = g_strdup(reason);
return ret;
const char *data;
data = virJSONValueGetString(obj);
- if (VIR_STRDUP(*reply_str, NULLSTR_EMPTY(data)) < 0)
- goto cleanup;
+ *reply_str = g_strdup(NULLSTR_EMPTY(data));
}
ret = 0;
cpus[i].qemu_id = cpuid;
cpus[i].tid = thread;
cpus[i].halted = halted;
- if (VIR_STRDUP(cpus[i].qom_path, qom_path) < 0)
- goto cleanup;
+ cpus[i].qom_path = g_strdup(qom_path);
/* process optional architecture-specific data */
if (STREQ_NULLABLE(arch, "s390") || STREQ_NULLABLE(arch, "s390x"))
*tmp = *info;
tmp->nodename = NULL;
- if (info->nodename &&
- VIR_STRDUP(tmp->nodename, info->nodename) < 0)
- goto cleanup;
+ if (info->nodename)
+ tmp->nodename = g_strdup(info->nodename);
if (virHashAddEntry(table, entryname, tmp) < 0)
goto cleanup;
case QEMU_MONITOR_MIGRATION_STATUS_ERROR:
if (error) {
tmp = virJSONValueObjectGetString(ret, "error-desc");
- if (tmp && VIR_STRDUP(*error, tmp) < 0)
- return -1;
+ if (tmp)
+ *error = g_strdup(tmp);
}
break;
"in query-rx-filter response"));
goto cleanup;
}
- if (VIR_STRDUP(fil->name, tmp) < 0)
- goto cleanup;
+ fil->name = g_strdup(tmp);
if ((!(tmp = virJSONValueObjectGetString(entry, "main-mac"))) ||
virMacAddrParse(tmp, &fil->mac) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (VIR_ALLOC(entry) < 0)
goto cleanup;
- if (STRPREFIX(type, "pty:") &&
- VIR_STRDUP(entry->ptyPath, type + strlen("pty:")) < 0)
- goto cleanup;
+ if (STRPREFIX(type, "pty:"))
+ entry->ptyPath = g_strdup(type + strlen("pty:"));
if (virJSONValueObjectGetBoolean(chardev, "frontend-open", &connected) == 0) {
if (connected)
return qemuMonitorJSONDiskNameLookupOne(backing, top->backingStore,
target);
}
- if (VIR_STRDUP(ret, virJSONValueObjectGetString(image, "filename")) < 0)
- return NULL;
+ ret = g_strdup(virJSONValueObjectGetString(image, "filename"));
/* Sanity check - the name qemu gave us should resolve to the same
file tracked by our target description. */
if (virStorageSourceIsLocalStorage(target) &&
GET_THROTTLE_STATS_OPTIONAL("iops_wr_max", write_iops_sec_max);
GET_THROTTLE_STATS_OPTIONAL("iops_size", size_iops_sec);
- if (VIR_STRDUP(reply->group_name,
- virJSONValueObjectGetString(inserted, "group")) < 0)
- goto cleanup;
+ reply->group_name = g_strdup(virJSONValueObjectGetString(inserted, "group"));
GET_THROTTLE_STATS_OPTIONAL("bps_max_length", total_bytes_sec_max_length);
GET_THROTTLE_STATS_OPTIONAL("bps_rd_max_length", read_bytes_sec_max_length);
_("query-version reply was missing 'package' version"));
goto cleanup;
}
- if (VIR_STRDUP(*package, tmp) < 0)
- goto cleanup;
+ *package = g_strdup(tmp);
}
ret = 0;
goto cleanup;
}
- if (VIR_STRDUP(info->name, tmp) < 0)
- goto cleanup;
+ info->name = g_strdup(tmp);
if (virJSONValueObjectHasKey(child, "is-default") &&
virJSONValueObjectGetBoolean(child, "is-default", &info->isDefault) < 0) {
_("query-machines reply has malformed 'alias' data"));
goto cleanup;
}
- if (VIR_STRDUP(info->alias, tmp) < 0)
- goto cleanup;
+ info->alias = g_strdup(tmp);
}
if (virJSONValueObjectHasKey(child, "cpu-max") &&
virJSONValueObjectGetNumberUint(child, "cpu-max", &info->maxCpus) < 0) {
goto cleanup;
}
- if (VIR_STRDUP(cpu->name, tmp) < 0)
- goto cleanup;
+ cpu->name = g_strdup(tmp);
if (virJSONValueObjectHasKey(child, "unavailable-features")) {
virJSONValuePtr blockers;
goto cleanup;
}
- if (VIR_STRDUP(cpu->blockers[j], virJSONValueGetString(blocker)) < 0)
- goto cleanup;
+ cpu->blockers[j] = g_strdup(virJSONValueGetString(blocker));
}
}
}
switch ((virJSONType)virJSONValueGetType(value)) {
case VIR_JSON_TYPE_STRING:
- if (VIR_STRDUP(prop->value.string, virJSONValueGetString(value)) < 0)
- return -1;
+ prop->value.string = g_strdup(virJSONValueGetString(value));
prop->type = QEMU_MONITOR_CPU_PROPERTY_STRING;
break;
}
machine_model->nprops++;
- if (VIR_STRDUP(prop->name, key) < 0)
- return -1;
+ prop->name = g_strdup(key);
return 0;
}
if (VIR_ALLOC(machine_model) < 0)
goto cleanup;
- if (VIR_STRDUP(machine_model->name, cpu_name) < 0)
- goto cleanup;
+ machine_model->name = g_strdup(cpu_name);
if (cpu_props) {
size_t nprops = virJSONValueObjectKeysNumber(cpu_props);
goto cleanup;
}
- if (VIR_STRDUP(commandlist[i], tmp) < 0)
- goto cleanup;
+ commandlist[i] = g_strdup(tmp);
}
ret = n;
goto cleanup;
}
- if (VIR_STRDUP(eventlist[i], tmp) < 0)
- goto cleanup;
+ eventlist[i] = g_strdup(tmp);
}
ret = n;
goto cleanup;
}
- if (VIR_STRDUP(paramlist[i], tmp) < 0)
- goto cleanup;
+ paramlist[i] = g_strdup(tmp);
}
ret = n;
goto cleanup;
}
- if (VIR_STRDUP(typelist[i], tmp) < 0)
- goto cleanup;
+ typelist[i] = g_strdup(tmp);
}
ret = n;
goto cleanup;
}
- if (VIR_STRDUP(info->name, tmp) < 0)
- goto cleanup;
+ info->name = g_strdup(tmp);
if (virJSONValueObjectHasKey(child, "type")) {
if (!(tmp = virJSONValueObjectGetString(child, "type"))) {
_("qom-list reply has malformed 'type' data"));
goto cleanup;
}
- if (VIR_STRDUP(info->type, tmp) < 0)
- goto cleanup;
+ info->type = g_strdup(tmp);
}
}
break;
case QEMU_MONITOR_OBJECT_PROPERTY_STRING:
tmp = virJSONValueGetString(data);
- if (tmp && VIR_STRDUP(prop->val.str, tmp) < 0)
- goto cleanup;
+ if (tmp)
+ prop->val.str = g_strdup(tmp);
if (tmp)
ret = 0;
break;
return -1;
}
- if (VIR_STRDUP(list[i], virJSONValueGetString(item)) < 0)
- return -1;
+ list[i] = g_strdup(virJSONValueGetString(item));
}
*strList = g_steal_pointer(&list);
goto cleanup;
}
- if (VIR_STRDUP(proplist[count++], tmp) < 0)
- goto cleanup;
+ proplist[count++] = g_strdup(tmp);
}
ret = count;
goto cleanup;
}
- if (VIR_STRDUP(list[i], name) < 1)
- goto cleanup;
+ list[i] = g_strdup(name);
}
ret = n;
if (VIR_ALLOC(capability) < 0)
goto cleanup;
- if (VIR_STRDUP(capability->pdh, pdh) < 0)
- goto cleanup;
+ capability->pdh = g_strdup(pdh);
- if (VIR_STRDUP(capability->cert_chain, cert_chain) < 0)
- goto cleanup;
+ capability->cert_chain = g_strdup(cert_chain);
capability->cbitpos = cbitpos;
capability->reduced_phys_bits = reduced_phys_bits;
goto cleanup;
}
- if (VIR_STRDUP(list[i], tmp) < 0)
- goto cleanup;
+ list[i] = g_strdup(tmp);
}
ret = n;
goto cleanup;
}
- if (VIR_STRDUP(chr->data.file.path, path) < 0)
- goto cleanup;
+ chr->data.file.path = g_strdup(path);
}
ret = 0;
return -1;
}
- if (VIR_STRDUP(entry->type, tmp) < 0)
- return -1;
+ entry->type = g_strdup(tmp);
if (virJSONValueObjectGetNumberUint(vcpu, "vcpus-count", &entry->vcpus) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
/* qom path is not present unless the vCPU is online */
if ((tmp = virJSONValueObjectGetString(vcpu, "qom-path"))) {
- if (VIR_STRDUP(entry->qom_path, tmp) < 0)
- return -1;
+ entry->qom_path = g_strdup(tmp);
/* alias is the part after last slash having a "vcpu" prefix */
- if ((tmp = strrchr(tmp, '/')) && STRPREFIX(tmp + 1, "vcpu")) {
- if (VIR_STRDUP(entry->alias, tmp + 1) < 0)
- return -1;
- }
+ if ((tmp = strrchr(tmp, '/')) && STRPREFIX(tmp + 1, "vcpu"))
+ entry->alias = g_strdup(tmp + 1);
}
return 0;
if (!(tmp = virJSONValueObjectGetString(data, "data")))
goto cleanup;
- if (VIR_STRDUP(measurement, tmp) < 0)
- goto cleanup;
+ measurement = g_strdup(tmp);
cleanup:
virJSONValueFree(cmd);
job->status = tmp;
- if (VIR_STRDUP(job->id, id) < 0 ||
- VIR_STRDUP(job->error, errmsg) < 0)
- return NULL;
+ job->id = g_strdup(id);
+ job->error = g_strdup(errmsg);
ret = g_steal_pointer(&job);
return ret;
goto cleanup;
processEvent->eventType = QEMU_PROCESS_EVENT_BLOCK_JOB;
- if (VIR_STRDUP(data, diskAlias) < 0)
- goto cleanup;
+ data = g_strdup(diskAlias);
processEvent->data = data;
processEvent->vm = virObjectRef(vm);
processEvent->action = type;
if (VIR_ALLOC(localAddr) < 0)
goto error;
localAddr->family = localFamily;
- if (VIR_STRDUP(localAddr->service, localService) < 0 ||
- VIR_STRDUP(localAddr->node, localNode) < 0)
- goto error;
+ localAddr->service = g_strdup(localService);
+ localAddr->node = g_strdup(localNode);
if (VIR_ALLOC(remoteAddr) < 0)
goto error;
remoteAddr->family = remoteFamily;
- if (VIR_STRDUP(remoteAddr->service, remoteService) < 0 ||
- VIR_STRDUP(remoteAddr->node, remoteNode) < 0)
- goto error;
+ remoteAddr->service = g_strdup(remoteService);
+ remoteAddr->node = g_strdup(remoteNode);
if (VIR_ALLOC(subject) < 0)
goto error;
if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
goto error;
subject->nidentity++;
- if (VIR_STRDUP(subject->identities[subject->nidentity-1].type, "x509dname") < 0 ||
- VIR_STRDUP(subject->identities[subject->nidentity-1].name, x509dname) < 0)
- goto error;
+ subject->identities[subject->nidentity - 1].type = g_strdup("x509dname");
+ subject->identities[subject->nidentity - 1].name = g_strdup(x509dname);
}
if (saslUsername) {
if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0)
goto error;
subject->nidentity++;
- if (VIR_STRDUP(subject->identities[subject->nidentity-1].type, "saslUsername") < 0 ||
- VIR_STRDUP(subject->identities[subject->nidentity-1].name, saslUsername) < 0)
- goto error;
+ subject->identities[subject->nidentity - 1].type = g_strdup("saslUsername");
+ subject->identities[subject->nidentity - 1].name = g_strdup(saslUsername);
}
virObjectLock(vm);
goto error;
processEvent->eventType = QEMU_PROCESS_EVENT_DEVICE_DELETED;
- if (VIR_STRDUP(data, devAlias) < 0)
- goto error;
+ data = g_strdup(devAlias);
processEvent->data = data;
processEvent->vm = virObjectRef(vm);
goto error;
processEvent->eventType = QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED;
- if (VIR_STRDUP(data, devAlias) < 0)
- goto error;
+ data = g_strdup(devAlias);
processEvent->data = data;
processEvent->vm = virObjectRef(vm);
goto error;
processEvent->eventType = QEMU_PROCESS_EVENT_SERIAL_CHANGED;
- if (VIR_STRDUP(data, devAlias) < 0)
- goto error;
+ data = g_strdup(devAlias);
processEvent->data = data;
processEvent->action = connected;
processEvent->vm = virObjectRef(vm);
VIR_DEBUG("netdev=%s,gid_status=%d,subnet_prefix=0x%llx,interface_id=0x%llx",
netdev, gid_status, subnet_prefix, interface_id);
- if (VIR_ALLOC(info) < 0 ||
- VIR_STRDUP(info->netdev, netdev) < 0)
+ if (VIR_ALLOC(info) < 0)
goto cleanup;
+ info->netdev = g_strdup(netdev);
+
info->gid_status = gid_status;
info->subnet_prefix = subnet_prefix;
info->interface_id = interface_id;
}
VIR_FREE(chr->source->data.file.path);
- if (VIR_STRDUP(chr->source->data.file.path, entry->ptyPath) < 0)
- goto cleanup;
+ chr->source->data.file.path = g_strdup(entry->ptyPath);
}
}
if (VIR_ALLOC(inc) < 0)
return NULL;
- if (VIR_STRDUP(inc->address, listenAddress) < 0)
- goto error;
+ inc->address = g_strdup(listenAddress);
inc->launchURI = qemuMigrationDstGetURI(migrateFrom, fd);
if (!inc->launchURI)
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_INCOMING_DEFER)) {
inc->deferredURI = inc->launchURI;
- if (VIR_STRDUP(inc->launchURI, "defer") < 0)
- goto error;
+ inc->launchURI = g_strdup("defer");
}
inc->fd = fd;
/* TODO: reject configuration without network specified for network listen */
if (!glisten->network) {
- if (VIR_STRDUP(glisten->address, listenAddr) < 0)
- return -1;
+ glisten->address = g_strdup(listenAddr);
return 0;
}
glisten->fromConfig = true;
glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
} else if (listenAddr) {
- if (VIR_STRDUP(glisten->address, listenAddr) < 0)
- goto cleanup;
+ glisten->address = g_strdup(listenAddr);
glisten->fromConfig = true;
}
}
if (VIR_ALLOC(proc) < 0)
goto cleanup;
- if (VIR_STRDUP(proc->binary, binary) < 0 ||
- VIR_STRDUP(proc->libDir, libDir) < 0)
- goto cleanup;
+ proc->binary = g_strdup(binary);
+ proc->libDir = g_strdup(libDir);
proc->runUid = runUid;
proc->runGid = runGid;
VIR_DEBUG("vhost-user description path '%s' binary : %s",
path, binary);
- if (VIR_STRDUP(vu->binary, binary) < 0)
- return -1;
+ vu->binary = g_strdup(binary);
return 0;
}
goto end;
VIR_FREE(video->driver->vhost_user_binary);
- if (VIR_STRDUP(video->driver->vhost_user_binary, vu->binary) < 0)
- goto end;
+ video->driver->vhost_user_binary = g_strdup(vu->binary);
break;
}