The function now does not return an error so we can drop it fully.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
virBufferFreeAndReset(&device);
}
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
virCommandAddArg(cmd, "-s");
virCommandAddArgFormat(cmd, "%d:0,ahci%s",
controller->info.addr.pci.slot,
if (virSysinfoFormat(&buf, privconn->hostsysinfo) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
virBufferAdd(&buf, virCommandToString(cmd, false), -1);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
ret = virBufferContentAndReset(&buf);
cleanup:
if (virBufferCurrentContent(&buf) &&
!virBufferCurrentContent(&buf)[0])
virBufferAsprintf(&buf, "%s", _("any configuration"));
- if (virBufferCheckError(&buf) < 0) {
- virBufferFreeAndReset(&buf);
- goto error;
- }
virReportError(VIR_ERR_INVALID_ARG,
_("could not find capabilities for %s"),
monitor->features[i]);
}
- if (virBufferCheckError(&childrenBuf) < 0)
- return -1;
-
virBufferAddBuffer(buf, &childrenBuf);
virBufferAddLit(buf, "</monitor>\n");
controls->max_allocation);
}
- if (virBufferCheckError(&childrenBuf) < 0)
- return -1;
-
if (virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
control->granularity, control->min,
control->max_allocation);
- if (virBufferCheckError(&childrenBuf) < 0)
- return -1;
-
if (virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</capabilities>\n");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
error:
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</domaincheckpoint>\n");
- if (virBufferCheckError(buf) < 0)
- goto error;
-
return 0;
error:
if (virCPUDefFormatBufFull(&buf, def, numa) < 0)
goto cleanup;
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
return virBufferContentAndReset(&buf);
cleanup:
if (virDomainNumaDefCPUFormatXML(&childrenBuf, numa) < 0)
goto cleanup;
- if (virBufferCheckError(&attributeBuf) < 0 ||
- virBufferCheckError(&childrenBuf) < 0)
- goto cleanup;
-
/* Put it all together */
if (virBufferUse(&attributeBuf) || virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, "<cpu");
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainUSBAddressPortFormatBuf(&buf, port);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domainCapabilities>\n");
- virBufferCheckError(&buf);
return virBufferContentAndReset(&buf);
}
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
- if (virBufferCheckError(&driverBuf) < 0)
- goto cleanup;
-
if (virBufferUse(&driverBuf)) {
virBufferAddLit(buf, "<driver");
virBufferAddBuffer(buf, &driverBuf);
}
virBufferTrim(&buf, " ", -1);
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*outstr = virBufferContentAndReset(&buf);
return 0;
}
}
virBufferTrim(&buf, " ", -1);
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*outstr = virBufferContentAndReset(&buf);
return 0;
}
virDomainVirtioOptionsFormat(&buf, def->virtio);
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*outstr = virBufferContentAndReset(&buf);
return 0;
}
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
goto cleanup;
- if (virBufferCheckError(&childBuf) < 0)
- goto cleanup;
-
virBufferAsprintf(buf, "<smartcard mode='%s'", mode);
if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH &&
virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) {
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
goto cleanup;
- if (virBufferCheckError(&childBuf) < 0)
- goto cleanup;
-
virBufferAsprintf(buf, "<sound model='%s'", model);
if (virBufferUse(&childBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddLit(buf, "<video>\n");
virBufferAdjustIndent(buf, 2);
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
- if (virBufferCheckError(&driverBuf) < 0)
- goto cleanup;
if (virBufferUse(&driverBuf) || (def->driver && def->driver->vgaconf) ||
def->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT) {
virBufferAddLit(buf, "<driver");
goto cleanup;
}
- if (virBufferCheckError(&childrenBuf) < 0)
- goto cleanup;
-
if (!virBufferUse(&childrenBuf)) {
ret = 0;
goto cleanup;
&childrenBuf) < 0)
goto cleanup;
- if (virBufferCheckError(&childrenBuf) < 0)
- goto cleanup;
-
if (!virBufferUse(&childrenBuf)) {
ret = 0;
goto cleanup;
for (i = 0; i < def->nresctrls; i++)
virDomainMemorytuneDefFormat(&childrenBuf, def->resctrls[i], flags);
- if (virBufferCheckError(&childrenBuf) < 0)
- return -1;
-
if (virBufferUse(&childrenBuf)) {
virBufferAddLit(buf, "<cputune>\n");
virBufferAddBuffer(buf, &childrenBuf);
virBufferAdjustIndent(buf, -2);
virBufferAsprintf(buf, "</%s>\n", rootname);
- if (virBufferCheckError(buf) < 0)
- goto error;
-
return 0;
error:
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domstatus>\n");
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
def->blkio.devices[i].param); \
} \
virBufferTrim(&buf, ",", -1); \
- if (virBufferCheckError(&buf) < 0) \
- goto error; \
data = virBufferContentAndReset(&buf); \
if (virTypedParameterAssign(&(params[(*nparams)++]), name, \
VIR_TYPED_PARAM_STRING, data) < 0) \
virBufferAsprintf(&buf, "%d-", id);
virDomainMachineNameAppendValid(&buf, name);
- virBufferCheckError(&buf);
return virBufferContentAndReset(&buf);
}
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</interface>\n");
- if (virBufferCheckError(buf) < 0)
- goto cleanup;
-
return 0;
cleanup:
if (virNetworkDefFormatBuf(&buf, def, xmlopt, flags) < 0)
goto error;
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</device>\n");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
printTCPFlags(&buf, flags);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
printed = true;
}
- if (virBufferCheckError(&buf) < 0)
- goto err_exit;
-
msg = virBufferContentAndReset(&buf);
virReportError(VIR_ERR_INVALID_ARG, "%s", msg);
VIR_FREE(msg);
- err_exit:
return NULL;
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</filter>\n");
- if (virBufferCheckError(&buf) < 0)
- goto err_exit;
-
return virBufferContentAndReset(&buf);
err_exit:
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</secret>\n");
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</domainsnapshot>\n");
- if (virBufferCheckError(buf) < 0)
- goto error;
-
return 0;
error:
if (virStoragePoolDefFormatBuf(&buf, def) < 0)
goto error;
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</volume>\n");
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
return virBufferContentAndReset(&buf);
cleanup:
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</poolstate>\n");
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
if (!(xml = virBufferContentAndReset(&buf)))
return -1;
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</sources>\n");
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
return virBufferContentAndReset(&buf);
cleanup:
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</networkstatus>");
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
return NULL;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
return NULL;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</filterbindingstatus>\n");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (virSaveCookieFormatBuf(&buf, obj, saveCookie) < 0)
goto error;
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
goto cleanup;
virBufferAsprintf(&buf, "./arch[@name='%s']", arch);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
xpath = virBufferContentAndReset(&buf);
}
virBufferAddLit(&buf, "</cpudata>\n");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferTrim(&buf, ",", -1);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferTrim(&bufAdded, ",", -1);
virBufferTrim(&bufRemoved, ",", -1);
- if (virBufferCheckError(&bufAdded) < 0 ||
- virBufferCheckError(&bufRemoved) < 0)
- goto cleanup;
-
added = virBufferContentAndReset(&bufAdded);
removed = virBufferContentAndReset(&bufRemoved);
virBufferAddChar(&buffer, separator);
virBufferAdd(&buffer, directoryAndFileName, -1);
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
result = virBufferContentAndReset(&buffer);
} else if (*fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
domain->conn->uri->server, domain->conn->uri->port);
virBufferURIEncodeString(&buffer, virtualMachine->obj->value);
- if (virBufferCheckError(&buffer))
- goto cleanup;
-
url = virBufferContentAndReset(&buffer);
mimeType = g_strdup("image/png");
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
url = virBufferContentAndReset(&buffer);
if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0)
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
url = virBufferContentAndReset(&buffer);
/* Check, if VMX file already exists */
}
}
- if (virBufferCheckError(&buffer) < 0)
- return NULL;
-
return virBufferContentAndReset(&buffer);
}
virBufferEscapeString(&buffer, "%s", string);
- if (virBufferCheckError(&buffer) < 0)
- return NULL;
-
return virBufferContentAndReset(&buffer);
}
goto cleanup;
}
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
if (length)
*length = virBufferUse(&buffer);
goto cleanup;
}
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
ctx->datacenterPath = virBufferContentAndReset(&buffer);
/* Lookup (Cluster)ComputeResource */
goto cleanup;
}
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
ctx->computeResourcePath = virBufferContentAndReset(&buffer);
/* Lookup HostSystem */
if ((*response)->responseCode < 0)
goto cleanup;
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
(*response)->content = virBufferContentAndReset(&buffer);
if ((*response)->responseCode == 500 || (*response)->responseCode == 200) {
++answerIndex;
}
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
possibleAnswers = virBufferContentAndReset(&buffer);
}
\
virBufferAddLit(&buffer, "</"#_name">"); \
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER); \
- \
- if (virBufferCheckError(&buffer) < 0) \
- goto cleanup; \
\
request = virBufferContentAndReset(&buffer); \
\
notes++;
}
- if (virBufferCheckError(&buf))
- goto cleanup;
-
def->description = virBufferContentAndReset(&buf);
}
}
wsmc_set_action_option(options, FLAG_ENUMERATION_ENUM_EPR);
- /* Get query and create filter based on it */
- if (virBufferCheckError(p->epr.query) < 0) {
- virBufferFreeAndReset(p->epr.query);
- goto cleanup;
- }
query_string = virBufferContentAndReset(p->epr.query);
filter = filter_create_simple(WSM_WQL_FILTER_DIALECT, query_string);
XML_TYPE_PTR data = NULL;
hypervObject *object;
- if (virBufferCheckError(wqlQuery->query) < 0) {
- virBufferFreeAndReset(wqlQuery->query);
- return -1;
- }
-
query_string = virBufferContentAndReset(wqlQuery->query);
if (list == NULL || *list != NULL) {
virBufferAddStr;
virBufferAdjustIndent;
virBufferAsprintf;
-virBufferCheckErrorInternal;
virBufferContentAndReset;
virBufferCurrentContent;
virBufferEscape;
if (src->configFile)
virBufferEscape(&buf, '\\', ":", ":conf=%s", src->configFile);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
ret = virBufferContentAndReset(&buf);
break;
}
}
}
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
x_nic->bridge = g_strdup(virBufferCurrentContent(&buf));
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</libxl-migration>\n");
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*cookieout = virBufferContentAndReset(&buf);
*cookieoutlen = strlen(*cookieout) + 1;
return -1;
}
- if (virBufferCheckError(buf) < 0)
- return -1;
-
return 0;
}
} else {
virBufferAddLit(&buf, "none");
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
if (VIR_ALLOC(val) < 0)
goto cleanup;
if (net->bandwidth && net->bandwidth->out && net->bandwidth->out->average)
virBufferAsprintf(&buf, ",rate=%lluKB/s", net->bandwidth->out->average);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
if (VIR_ALLOC(val) < 0)
goto cleanup;
virBufferAsprintf(&buf, ",keymap=%s",
def->graphics[0]->data.vnc.keymap);
}
- if (virBufferCheckError(&buf) < 0)
- return -1;
vfbstr = virBufferContentAndReset(&buf);
virBufferEscapeSexpr(&buf, "%s", model);
}
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
str = virBufferContentAndReset(&buf);
return xenConfigSetString(conf, "soundhw", str);
int ret = -1;
virConfValuePtr numaPnode, tmp;
- if (virBufferCheckError(buf) < 0)
- goto cleanup;
-
if (VIR_ALLOC(numaPnode) < 0)
goto cleanup;
}
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
ret = virBufferContentAndReset(&buf);
break;
}
if (target)
virBufferAsprintf(&buf, ",target=%s", target);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
if (VIR_ALLOC(val) < 0)
goto cleanup;
return -1;
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
if (VIR_ALLOC(val) < 0)
goto cleanup;
virBufferEscape(&buf, '\\', "\\ ", "%s",
virDomainLockFailureTypeToString(action));
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
/* Unfortunately, sanlock_killpath() does not use const for either
* path or args even though it will just copy them into its own
* buffers.
}
virBufferTrim(&buf, NULL, 1);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
virUUIDFormat(vmDef->uuid, uuidstr);
cmd = virCommandNew(vmDef->os.init);
virBufferAsprintf(&map_value, "%u %u %u\n",
map[i].start, map[i].target, map[i].count);
- if (virBufferCheckError(&map_value) < 0)
- goto cleanup;
-
VIR_DEBUG("Set '%s' to '%s'", path, virBufferCurrentContent(&map_value));
if (virFileWriteStr(path, virBufferCurrentContent(&map_value), 0) < 0) {
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
virBufferAdd(new_meminfo, line, -1);
}
- if (virBufferCheckError(new_meminfo) < 0) {
- res = -errno;
- goto cleanup;
- }
}
res = strlen(virBufferCurrentContent(new_meminfo));
if (res > size)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</hookData>");
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
xml = virBufferContentAndReset(&buf);
hookret = virHookCall(VIR_HOOK_DRIVER_NETWORK, def->name,
op, sub_op, NULL, xml, NULL);
virBufferAddLit(&configbuf, "};\n");
- if (virBufferCheckError(&configbuf) < 0)
- goto cleanup;
-
*configstr = virBufferContentAndReset(&configbuf);
ret = 0;
if (s != NULL)
virBufferAsprintf(&buf, "_%s", s);
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
def->name = virBufferContentAndReset(&buf);
for (i = 0; i < strlen(def->name); i++) {
}
}
- if (virBufferCheckError(&vb) < 0)
- return -1;
-
flags = virBufferContentAndReset(&vb);
if (virStrcpy(buf, flags, bufsize) < 0) {
"",
flags,
false);
- if (virBufferCheckError(&buf) < 0)
- return -1;
*bufptr = virBufferContentAndReset(&buf);
return 0;
}
if (ENTRY_WANT_NEG_SIGN(&rule->p.ipv6HdrFilter.dataICMPTypeStart))
virFirewallRuleAddArg(fw, fwrule, "!");
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
r = virBufferContentAndReset(&buf);
virFirewallRuleAddArg(fw, fwrule, r);
virHashForEach(vars, printString, &ps);
- if (virBufferCheckError(&ps.buf) < 0)
- return NULL;
return virBufferContentAndReset(&ps.buf);
}
channel = NULL;
VIR_FREE(buffer);
- if (virBufferCheckError(&tex_ret) < 0)
- return NULL;
return virBufferContentAndReset(&tex_ret);
err:
char *cmd;
char *ret;
- if (virBufferCheckError(buf) < 0)
- return NULL;
cmd = virBufferContentAndReset(buf);
ret = phypExec(session, cmd, exit_status, conn);
VIR_FREE(cmd);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</qemuCaps>\n");
- if (virBufferCheckError(&buf) == 0)
- ret = virBufferContentAndReset(&buf);
+ ret = virBufferContentAndReset(&buf);
return ret;
}
if (src->path)
virBufferAsprintf(&buf, ":exportname=%s", src->path);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
/* NBD code uses URI formatting scheme as others in some cases */
if (src->configFile)
virBufferEscape(&buf, '\\', ":", ":conf=%s", src->configFile);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
ret = virBufferContentAndReset(&buf);
break;
qemuBuildDiskThrottling(disk, &opt);
- if (virBufferCheckError(&opt) < 0)
- goto error;
-
return virBufferContentAndReset(&opt);
error:
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_WERROR))
qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt);
- if (virBufferCheckError(&opt) < 0)
- goto error;
-
return virBufferContentAndReset(&opt);
error:
dev->alias,
dev->addr.pci.zpci.uid);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (fs->readonly)
virBufferAddLit(&opt, ",readonly");
- if (virBufferCheckError(&opt) < 0)
- return NULL;
-
return virBufferContentAndReset(&opt);
}
if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&opt) < 0)
- return NULL;
-
return virBufferContentAndReset(&opt);
}
if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0)
return -1;
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*devstr = virBufferContentAndReset(&buf);
return 0;
}
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
qemuBuildVirtioOptionsStr(&buf, net->virtio, qemuCaps) < 0)
goto error;
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
error:
virBufferTrim(&buf, ",", -1);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
return NULL;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildVirtioOptionsStr(&buf, dev->virtio, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &sound->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildVirtioOptionsStr(&buf, video->virtio, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildRomStr(&buf, dev->info) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferAddLit(&buf, ",if=none,format=raw");
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (dev->readonly)
virBufferAddLit(&buf, ",readonly=on");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
return NULL;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferAsprintf(&buf, ",name=%s", dev->target.name
? dev->target.name : "com.redhat.spice.0");
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
}
virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
dev->info.alias, dev->info.alias);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
virQEMUBuildBufferEscapeComma(&buf, def->location);
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virQEMUBuildBufferEscapeComma(&buf, def->sku);
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
}
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferTrim(&boot_buf, ",", -1);
- if (virBufferCheckError(&boot_buf) < 0)
- return -1;
-
boot_opts_str = virBufferContentAndReset(&boot_buf);
if (boot_opts_str) {
virCommandAddArg(cmd, "-boot");
virBufferAddLit(&buf, ",l3-cache=off");
}
- if (virBufferCheckError(&cpu_buf) < 0)
- return -1;
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
cpu = virBufferContentAndReset(&cpu_buf);
cpu_flags = virBufferContentAndReset(&buf);
virBufferAsprintf(&buf, ",threads=%u", 1);
}
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
virCommandAddArgBuffer(cmd, &buf);
return 0;
}
}
- if (virBufferCheckError(&opt) < 0)
- return -1;
-
virCommandAddArgBuffer(cmd, &opt);
return 0;
graphics->data.egl_headless.rendernode);
}
- if (virBufferCheckError(&opt) < 0)
- return -1;
-
virCommandAddArg(cmd, "-display");
virCommandAddArgBuffer(cmd, &opt);
if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
model, tpm->info.alias, tpm->info.alias);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
return NULL;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
if (qemuBuildDeviceAddressStr(&buf, def, &serial->info, qemuCaps) < 0)
return -1;
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*deviceStr = virBufferContentAndReset(&buf);
return 0;
}
virBufferAddLit(&buf, "/([^/]+\\.)|(domain-[^/]+/)");
virBufferEscapeRegex(&buf, "%s$", chr->target.name);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
regexp = virBufferContentAndReset(&buf);
if (virStringMatch(chr->source->data.nix.path, regexp))
VIR_FREE(chr->source->data.nix.path);
ret = 0;
- cleanup:
VIR_FREE(regexp);
virObjectUnref(cfg);
return ret;
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
return NULL;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
goto cleanup;
virBufferAddLit(&cmdbuf, "\r\n");
- if (virBufferCheckError(&cmdbuf) < 0)
- goto cleanup;
-
msg.txLength = virBufferUse(&cmdbuf);
msg.txBuffer = virBufferContentAndReset(&cmdbuf);
msg.txFD = scm_fd;
if (virBufferUse(&buff) > 0)
virBufferAddChar(&buff, '\n');
- if (virBufferCheckError(&buff) < 0)
- return -1;
-
for (iprompt = 0; iprompt < nprompts; ++iprompt) {
virConnectCredential retr_passphrase;
const char *promptStr;
virBufferAddBuffer(&prompt_buff, &buff);
virBufferAdd(&prompt_buff, promptStr, promptStrLen);
- if (virBufferCheckError(&prompt_buff) < 0)
- goto prompt_error;
-
prompt = virBufferContentAndReset(&prompt_buff);
} else {
if (VIR_STRNDUP(prompt, promptStr, promptStrLen) < 0)
virCommandAddArgList(cmd, "--", nodename, "sh", "-c", NULL);
virBufferEscapeShell(&buf, netcat);
- if (virBufferCheckError(&buf) < 0) {
- virCommandFree(cmd);
- return -1;
- }
quoted = virBufferContentAndReset(&buf);
virBufferEscapeShell(&buf, quoted);
VIR_FREE(quoted);
- if (virBufferCheckError(&buf) < 0) {
- virCommandFree(cmd);
- return -1;
- }
quoted = virBufferContentAndReset(&buf);
/*
virBufferAsprintf(&buff, "%02hhX:", keyhash[i]);
virBufferTrim(&buff, ":", 1);
- if (virBufferCheckError(&buff) < 0)
- return -1;
-
keyhashstr = virBufferContentAndReset(&buff);
askKey.type = VIR_CRED_ECHOPROMPT;
* to port number */
virBufferAsprintf(&buff, "[%s]:%d", sess->hostname, sess->port);
- if (virBufferCheckError(&buff) < 0)
- return -1;
-
hostnameStr = virBufferContentAndReset(&buff);
if (libssh2_knownhost_addc(sess->knownHosts,
}
}
- if (virBufferCheckError(&mon_host) < 0)
- goto cleanup;
-
mon_buff = virBufferContentAndReset(&mon_host);
if (virStorageBackendRBDRADOSConfSet(ptr->cluster,
"mon_host",
virBufferAsprintf(&snapname, "libvirt-%d", (int)virRandomInt(65534));
- if (virBufferCheckError(&snapname) < 0)
- goto cleanup;
-
snapname_buff = virBufferContentAndReset(&snapname);
if (virStorageBackendRBDSnapshotCreate(image, origvol, snapname_buff) < 0)
virBufferTrim(&buf, ",", -1);
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
*opts = virBufferContentAndReset(&buf);
return 0;
virBufferAsprintf(&buf, "secret,id=%s,file=", secretAlias);
virQEMUBuildBufferEscapeComma(&buf, secretPath);
- if (virBufferCheckError(&buf) < 0) {
- virBufferFreeAndReset(&buf);
- return -1;
- }
-
commandStr = virBufferContentAndReset(&buf);
virCommandAddArgList(cmd, "--object", commandStr, NULL);
secretAlias);
virQEMUBuildBufferEscapeComma(&buf, path);
- if (virBufferCheckError(&buf) < 0) {
- virBufferFreeAndReset(&buf);
- return -1;
- }
-
commandStr = virBufferContentAndReset(&buf);
virCommandAddArgList(cmd, "--image-opts", commandStr, NULL);
bitmap->map[sz]);
}
- virBufferCheckError(&buf);
ret = virBufferContentAndReset(&buf);
if (!ret)
return NULL;
memset(buf, 0, sizeof(*buf));
}
-/**
- * virBufferCheckErrorInternal:
- * @buf: the buffer
- *
- * Report an error if the buffer is in an error state.
- *
- * Return -1 if an error has been reported, 0 otherwise.
- */
-int
-virBufferCheckErrorInternal(const virBuffer *buf G_GNUC_UNUSED)
-{
- return 0;
-}
-
/**
* virBufferUse:
* @buf: the usage of the string in the buffer
const char *virBufferCurrentContent(virBufferPtr buf);
char *virBufferContentAndReset(virBufferPtr buf);
void virBufferFreeAndReset(virBufferPtr buf);
-int virBufferCheckErrorInternal(const virBuffer *buf)
- ATTRIBUTE_NONNULL(1);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virBuffer, virBufferFreeAndReset);
-/**
- * virBufferCheckError
- *
- * Checks if the buffer is in error state and reports an error.
- *
- * Returns 0 if no error has occurred, otherwise an error is reported
- * and -1 is returned.
- */
-#define virBufferCheckError(buf) \
- virBufferCheckErrorInternal(buf)
-
size_t virBufferUse(const virBuffer *buf);
void virBufferAdd(virBufferPtr buf, const char *str, int len);
void virBufferAddBuffer(virBufferPtr buf, virBufferPtr toadd);
prevopt = (cmd->args[i][0] == '-');
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
cur = cur->next;
}
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
virBufferFreeAndReset(&buf);
cur = cur->next;
}
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
use = virBufferUse(&buf);
content = virBufferContentAndReset(&buf);
virBufferEscapeString(&buf, "/%s", name);
virBufferAsprintf(&buf, ".%s", DNSMASQ_ADDNHOSTSFILE_SUFFIX);
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
if (!(addnhostsfile->path = virBufferContentAndReset(&buf)))
goto error;
virBufferEscapeString(&buf, "/%s", name);
virBufferAsprintf(&buf, ".%s", DNSMASQ_HOSTSFILE_SUFFIX);
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
if (!(hostsfile->path = virBufferContentAndReset(&buf)))
goto error;
return hostsfile;
if (cache->suffix)
virBufferAsprintf(&buf, ".%s", cache->suffix);
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virBufferAsprintf(&buf, "%d", virtVlan->tag[i]);
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
virCommandAddArg(cmd, virBufferCurrentContent(&buf));
} else if (virtVlan->nTags) {
virCommandAddArgFormat(cmd, "tag=%d", virtVlan->tag[0]);
}
ret = 0;
- cleanup:
virBufferFreeAndReset(&buf);
return ret;
}
virBufferAsprintf(&buf, "%s", dir);
virBufferEscapeString(&buf, "/%s.pid", name);
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
return virBufferContentAndReset(&buf);
-
- error:
- virBufferFreeAndReset(&buf);
- return NULL;
}
virQEMUBuildCommandLineJSONArrayNumbered) < 0)
goto cleanup;
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
ret = virBufferContentAndReset(&buf);
cleanup:
virBufferTrim(buf, ";", 1);
virBufferAddChar(buf, '\n');
- return virBufferCheckError(buf);
+ return 0;
}
}
}
- return virBufferCheckError(buf);
+ return 0;
}
virBufferAdd(&buf, components[i], -1);
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
/* if the output string is empty just return an empty string */
if (!(ret = virBufferContentAndReset(&buf)))
ret = g_strdup("");
virBufferAdd(&buf, delim, -1);
strings++;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
ret = virBufferContentAndReset(&buf);
if (!ret)
ret = g_strdup("");
tmp1 = tmp2;
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
return -1;
}
- if (virBufferCheckError(buf) < 0)
- return -1;
-
return 0;
}
virSystemdEscapeName(&buf, name);
virBufferAddLit(&buf, ".scope");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
virSystemdEscapeName(&buf, partition);
virBufferAddLit(&buf, ".slice");
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
}
}
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
return virBufferContentAndReset(&buf);
}
return 0;
}
- if ((attrBuf && virBufferCheckError(attrBuf) < 0) ||
- (childBuf && virBufferCheckError(childBuf) < 0))
- goto cleanup;
-
virBufferAsprintf(buf, "<%s", name);
if (attrBuf && virBufferUse(attrBuf) > 0)
ret = 0;
- cleanup:
virBufferFreeAndReset(attrBuf);
virBufferFreeAndReset(childBuf);
return ret;
}
/* Get final VMX output */
- if (virBufferCheckError(&buffer) < 0)
- goto cleanup;
-
vmx = virBufferContentAndReset(&buffer);
cleanup:
if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
return NULL;
- if (virBufferCheckError(&buf) < 0)
- return NULL;
return virBufferContentAndReset(&buf);
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</vz-migration>\n");
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
*cookieout = virBufferContentAndReset(&buf);
*cookieoutlen = strlen(*cookieout) + 1;
VIR_FREE(jsonstr);
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
ret = virTestCompareToFile(actual, jsonpath);
virBufferAdd(&buf, jsonstr, -1);
}
- if (virBufferCheckError(&buf) < 0)
- return -1;
-
actual = virBufferContentAndReset(&buf);
return virTestCompareToFile(actual, jsonpath);
virBufferTrim(&buf, "\n", -1);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
if (virTestCompareToFile(actual, resultFile) < 0)
virBufferTrim(&buf, "\n", -1);
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
actual = virBufferContentAndReset(&buf);
if (virTestCompareToFile(actual, filenameResult) < 0)
usermsg = "unexpected command";
virBufferEscape(&buf, '\\', "\"", "%s", usermsg);
- if (virBufferCheckError(&buf) < 0)
- return -1;
escapemsg = virBufferContentAndReset(&buf);
/* replace newline/carriage return with space */
}
virBufferAsprintf(&buf, "%-12s %s\n",
"unified", NULLSTR(group->unified.mountPoint));
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
actual = virBufferCurrentContent(&buf);
if (virTestCompareToFile(actual, parsed) < 0)
virBufferEscapeString(&buf, "<driver type='%s'/>\n", format);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</disk>\n");
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
xmlstr = virBufferContentAndReset(&buf);
}
arg = opt->data;
}
- if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
vshReadlineInit(ctl);
if (!(rl_line_buffer = virBufferContentAndReset(&buf)))