return -1;
}
- if (virTypedParamListAddUInt(paramlist, minWorkers,
- "%s", VIR_THREADPOOL_WORKERS_MIN) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist, maxWorkers,
- "%s", VIR_THREADPOOL_WORKERS_MAX) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist, nWorkers,
- "%s", VIR_THREADPOOL_WORKERS_CURRENT) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist, freeWorkers,
- "%s", VIR_THREADPOOL_WORKERS_FREE) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist, nPrioWorkers,
- "%s", VIR_THREADPOOL_WORKERS_PRIORITY) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist, jobQueueDepth,
- "%s", VIR_THREADPOOL_JOB_QUEUE_DEPTH) < 0)
- return -1;
+ virTypedParamListAddUInt(paramlist, minWorkers, VIR_THREADPOOL_WORKERS_MIN);
+ virTypedParamListAddUInt(paramlist, maxWorkers, VIR_THREADPOOL_WORKERS_MAX);
+ virTypedParamListAddUInt(paramlist, nWorkers, VIR_THREADPOOL_WORKERS_CURRENT);
+ virTypedParamListAddUInt(paramlist, freeWorkers, VIR_THREADPOOL_WORKERS_FREE);
+ virTypedParamListAddUInt(paramlist, nPrioWorkers, VIR_THREADPOOL_WORKERS_PRIORITY);
+ virTypedParamListAddUInt(paramlist, jobQueueDepth, VIR_THREADPOOL_JOB_QUEUE_DEPTH);
if (virTypedParamListSteal(paramlist, params, nparams) < 0)
return -1;
&sock_addr, &identity) < 0)
return -1;
- if (virTypedParamListAddBoolean(paramlist, readonly,
- "%s", VIR_CLIENT_INFO_READONLY) < 0)
- return -1;
+ virTypedParamListAddBoolean(paramlist, readonly, VIR_CLIENT_INFO_READONLY);
if ((rc = virIdentityGetSASLUserName(identity, &attr)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddString(paramlist, attr,
- "%s", VIR_CLIENT_INFO_SASL_USER_NAME) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_SASL_USER_NAME);
if (!virNetServerClientIsLocal(client)) {
- if (virTypedParamListAddString(paramlist, sock_addr,
- "%s", VIR_CLIENT_INFO_SOCKET_ADDR) < 0)
- return -1;
+ virTypedParamListAddString(paramlist, sock_addr, VIR_CLIENT_INFO_SOCKET_ADDR);
if ((rc = virIdentityGetX509DName(identity, &attr)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddString(paramlist, attr,
- "%s", VIR_CLIENT_INFO_X509_DISTINGUISHED_NAME) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_X509_DISTINGUISHED_NAME);
} else {
pid_t pid;
uid_t uid;
gid_t gid;
if ((rc = virIdentityGetUNIXUserID(identity, &uid)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddInt(paramlist, uid,
- "%s", VIR_CLIENT_INFO_UNIX_USER_ID) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddInt(paramlist, uid, VIR_CLIENT_INFO_UNIX_USER_ID);
if ((rc = virIdentityGetUserName(identity, &attr)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddString(paramlist, attr,
- "%s", VIR_CLIENT_INFO_UNIX_USER_NAME) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_UNIX_USER_NAME);
if ((rc = virIdentityGetUNIXGroupID(identity, &gid)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddInt(paramlist, gid,
- "%s", VIR_CLIENT_INFO_UNIX_GROUP_ID) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddInt(paramlist, gid, VIR_CLIENT_INFO_UNIX_GROUP_ID);
if ((rc = virIdentityGetGroupName(identity, &attr)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddString(paramlist, attr,
- "%s", VIR_CLIENT_INFO_UNIX_GROUP_NAME) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_UNIX_GROUP_NAME);
if ((rc = virIdentityGetProcessID(identity, &pid)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddInt(paramlist, pid,
- "%s", VIR_CLIENT_INFO_UNIX_PROCESS_ID) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddInt(paramlist, pid, VIR_CLIENT_INFO_UNIX_PROCESS_ID);
}
if ((rc = virIdentityGetSELinuxContext(identity, &attr)) < 0)
return -1;
- if (rc == 1 &&
- virTypedParamListAddString(paramlist, attr,
- "%s", VIR_CLIENT_INFO_SELINUX_CONTEXT) < 0)
- return -1;
+ if (rc == 1)
+ virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_SELINUX_CONTEXT);
if (virTypedParamListSteal(paramlist, params, nparams) < 0)
return -1;
virCheckFlags(0, -1);
- if (virTypedParamListAddUInt(paramlist,
- virNetServerGetMaxClients(srv),
- "%s", VIR_SERVER_CLIENTS_MAX) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist,
- virNetServerGetCurrentClients(srv),
- "%s", VIR_SERVER_CLIENTS_CURRENT) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist,
- virNetServerGetMaxUnauthClients(srv),
- "%s", VIR_SERVER_CLIENTS_UNAUTH_MAX) < 0)
- return -1;
-
- if (virTypedParamListAddUInt(paramlist,
- virNetServerGetCurrentUnauthClients(srv),
- "%s", VIR_SERVER_CLIENTS_UNAUTH_CURRENT) < 0)
- return -1;
+ virTypedParamListAddUInt(paramlist, virNetServerGetMaxClients(srv), VIR_SERVER_CLIENTS_MAX);
+ virTypedParamListAddUInt(paramlist, virNetServerGetCurrentClients(srv), VIR_SERVER_CLIENTS_CURRENT);
+ virTypedParamListAddUInt(paramlist, virNetServerGetMaxUnauthClients(srv), VIR_SERVER_CLIENTS_UNAUTH_MAX);
+ virTypedParamListAddUInt(paramlist, virNetServerGetCurrentUnauthClients(srv), VIR_SERVER_CLIENTS_UNAUTH_CURRENT);
if (virTypedParamListSteal(paramlist, params, nparams) < 0)
return -1;
virTypedParamList *params,
unsigned int privflags G_GNUC_UNUSED)
{
- if (virTypedParamListAddInt(params, dom->state.state, "state.state") < 0)
- return -1;
-
- if (virTypedParamListAddInt(params, dom->state.reason, "state.reason") < 0)
- return -1;
+ virTypedParamListAddInt(params, dom->state.state, "state.state");
+ virTypedParamListAddInt(params, dom->state.reason, "state.reason");
return 0;
}
if (nresdata == 0)
return 0;
- if (virTypedParamListAddUInt(params, nresdata,
- "memory.bandwidth.monitor.count") < 0)
- goto cleanup;
+ virTypedParamListAddUInt(params, nresdata, "memory.bandwidth.monitor.count");
for (i = 0; i < nresdata; i++) {
- if (virTypedParamListAddString(params, resdata[i]->name,
- "memory.bandwidth.monitor.%zu.name",
- i) < 0)
- goto cleanup;
-
- if (virTypedParamListAddString(params, resdata[i]->vcpus,
- "memory.bandwidth.monitor.%zu.vcpus",
- i) < 0)
- goto cleanup;
-
- if (virTypedParamListAddUInt(params, resdata[i]->nstats,
- "memory.bandwidth.monitor.%zu.node.count",
- i) < 0)
- goto cleanup;
-
+ virTypedParamListAddString(params, resdata[i]->name, "memory.bandwidth.monitor.%zu.name", i);
+ virTypedParamListAddString(params, resdata[i]->vcpus, "memory.bandwidth.monitor.%zu.vcpus", i);
+ virTypedParamListAddUInt(params, resdata[i]->nstats, "memory.bandwidth.monitor.%zu.node.count", i);
for (j = 0; j < resdata[i]->nstats; j++) {
- if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->id,
- "memory.bandwidth.monitor.%zu."
- "node.%zu.id",
- i, j) < 0)
- goto cleanup;
+ virTypedParamListAddUInt(params, resdata[i]->stats[j]->id,
+ "memory.bandwidth.monitor.%zu.node.%zu.id", i, j);
features = resdata[i]->stats[j]->features;
if (STREQ(features[k], "mbm_local_bytes")) {
/* The accumulative data passing through local memory
* controller is recorded with 64 bit counter. */
- if (virTypedParamListAddULLong(params,
- resdata[i]->stats[j]->vals[k],
- "memory.bandwidth.monitor."
- "%zu.node.%zu.bytes.local",
- i, j) < 0)
- goto cleanup;
+ virTypedParamListAddULLong(params, resdata[i]->stats[j]->vals[k],
+ "memory.bandwidth.monitor.%zu.node.%zu.bytes.local", i, j);
}
if (STREQ(features[k], "mbm_total_bytes")) {
/* The accumulative data passing through local and remote
* memory controller is recorded with 64 bit counter. */
- if (virTypedParamListAddULLong(params,
- resdata[i]->stats[j]->vals[k],
- "memory.bandwidth.monitor."
- "%zu.node.%zu.bytes.total",
- i, j) < 0)
- goto cleanup;
+ virTypedParamListAddULLong(params, resdata[i]->stats[j]->vals[k],
+ "memory.bandwidth.monitor.%zu.node.%zu.bytes.total", i, j);
}
}
}
VIR_RESCTRL_MONITOR_TYPE_CACHE) < 0)
goto cleanup;
- if (virTypedParamListAddUInt(params, nresdata, "cpu.cache.monitor.count") < 0)
- goto cleanup;
+ virTypedParamListAddUInt(params, nresdata, "cpu.cache.monitor.count");
for (i = 0; i < nresdata; i++) {
- if (virTypedParamListAddString(params, resdata[i]->name,
- "cpu.cache.monitor.%zu.name", i) < 0)
- goto cleanup;
-
- if (virTypedParamListAddString(params, resdata[i]->vcpus,
- "cpu.cache.monitor.%zu.vcpus", i) < 0)
- goto cleanup;
-
- if (virTypedParamListAddUInt(params, resdata[i]->nstats,
- "cpu.cache.monitor.%zu.bank.count", i) < 0)
- goto cleanup;
+ virTypedParamListAddString(params, resdata[i]->name, "cpu.cache.monitor.%zu.name", i);
+ virTypedParamListAddString(params, resdata[i]->vcpus, "cpu.cache.monitor.%zu.vcpus", i);
+ virTypedParamListAddUInt(params, resdata[i]->nstats, "cpu.cache.monitor.%zu.bank.count", i);
for (j = 0; j < resdata[i]->nstats; j++) {
- if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->id,
- "cpu.cache.monitor.%zu.bank.%zu.id", i, j) < 0)
- goto cleanup;
+ virTypedParamListAddUInt(params, resdata[i]->stats[j]->id,
+ "cpu.cache.monitor.%zu.bank.%zu.id", i, j);
/* 'resdata[i]->stats[j]->vals[0]' keeps the value of how many last
* level cache in bank j currently occupied by the vcpus listed in
* than 4G bytes in size, to keep the 'domstats' interface
* historically consistent, it is safe to report the value with a
* truncated 'UInt' data type here. */
- if (virTypedParamListAddUInt(params,
- (unsigned int)resdata[i]->stats[j]->vals[0],
- "cpu.cache.monitor.%zu.bank.%zu.bytes",
- i, j) < 0)
- goto cleanup;
+ virTypedParamListAddUInt(params, (unsigned int)resdata[i]->stats[j]->vals[0],
+ "cpu.cache.monitor.%zu.bank.%zu.bytes", i, j);
}
}
unsigned long long cpu_time = 0;
unsigned long long user_time = 0;
unsigned long long sys_time = 0;
- int err = 0;
if (!priv->cgroup)
return 0;
- err = virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time);
- if (!err && virTypedParamListAddULLong(params, cpu_time, "cpu.time") < 0)
- return -1;
+ if (virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time) == 0)
+ virTypedParamListAddULLong(params, cpu_time, "cpu.time");
- err = virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time);
- if (!err && virTypedParamListAddULLong(params, user_time, "cpu.user") < 0)
- return -1;
- if (!err && virTypedParamListAddULLong(params, sys_time, "cpu.system") < 0)
- return -1;
+ if (virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time) == 0) {
+ virTypedParamListAddULLong(params, user_time, "cpu.user");
+ virTypedParamListAddULLong(params, sys_time, "cpu.system");
+ }
return 0;
}
return 0;
}
- if (virTypedParamListAddULLong(params, cpuTime, "cpu.time") < 0 ||
- virTypedParamListAddULLong(params, userTime, "cpu.user") < 0 ||
- virTypedParamListAddULLong(params, sysTime, "cpu.system") < 0)
- return -1;
+ virTypedParamListAddULLong(params, cpuTime, "cpu.time");
+ virTypedParamListAddULLong(params, userTime, "cpu.user");
+ virTypedParamListAddULLong(params, sysTime, "cpu.system");
return 0;
}
virHostCPUGetHaltPollTime(dom->pid, &haltPollSuccess, &haltPollFail) < 0)
return 0;
- if (virTypedParamListAddULLong(params, haltPollSuccess, "cpu.haltpoll.success.time") < 0 ||
- virTypedParamListAddULLong(params, haltPollFail, "cpu.haltpoll.fail.time") < 0)
- return -1;
+ virTypedParamListAddULLong(params, haltPollSuccess, "cpu.haltpoll.success.time");
+ virTypedParamListAddULLong(params, haltPollFail, "cpu.haltpoll.fail.time");
return 0;
}
cur_balloon = dom->def->mem.cur_balloon;
}
- if (virTypedParamListAddULLong(params, cur_balloon, "balloon.current") < 0)
- return -1;
-
- if (virTypedParamListAddULLong(params, virDomainDefGetMemoryTotal(dom->def),
- "balloon.maximum") < 0)
- return -1;
+ virTypedParamListAddULLong(params, cur_balloon, "balloon.current");
+ virTypedParamListAddULLong(params, virDomainDefGetMemoryTotal(dom->def), "balloon.maximum");
if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom))
return 0;
#define STORE_MEM_RECORD(TAG, NAME) \
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ ##TAG) \
- if (virTypedParamListAddULLong(params, stats[i].val, "balloon." NAME) < 0) \
- return -1;
+ virTypedParamListAddULLong(params, stats[i].val, "balloon." NAME);
for (i = 0; i < nr_stats; i++) {
STORE_MEM_RECORD(SWAP_IN, "swap_in")
if (virJSONValueGetBoolean(value, &stat) < 0)
continue;
- ignore_value(virTypedParamListAddBoolean(params, stat, "%s.%s.%s",
- prefix, key, type));
+ virTypedParamListAddBoolean(params, stat, "%s.%s.%s", prefix, key, type);
} else {
unsigned long long stat;
if (virJSONValueGetNumberUlong(value, &stat) < 0)
continue;
- ignore_value(virTypedParamListAddULLong(params, stat, "%s.%s.%s",
- prefix, key, type));
+ virTypedParamListAddULLong(params, stat, "%s.%s.%s", prefix, key, type);
}
}
}
qemuDomainObjPrivate *priv = dom->privateData;
g_autoptr(virJSONValue) queried_stats = NULL;
- if (virTypedParamListAddUInt(params, virDomainDefGetVcpus(dom->def),
- "vcpu.current") < 0)
- return -1;
-
- if (virTypedParamListAddUInt(params, virDomainDefGetVcpusMax(dom->def),
- "vcpu.maximum") < 0)
- return -1;
+ virTypedParamListAddUInt(params, virDomainDefGetVcpus(dom->def), "vcpu.current");
+ virTypedParamListAddUInt(params, virDomainDefGetVcpusMax(dom->def), "vcpu.maximum");
cpuinfo = g_new0(virVcpuInfo, virDomainDefGetVcpus(dom->def));
cpuwait = g_new0(unsigned long long, virDomainDefGetVcpus(dom->def));
g_autoptr(GHashTable) stats = NULL;
g_autofree char *prefix = g_strdup_printf("vcpu.%u", cpuinfo[i].number);
- if (virTypedParamListAddInt(params, cpuinfo[i].state,
- "vcpu.%u.state", cpuinfo[i].number) < 0)
- return -1;
+ virTypedParamListAddInt(params, cpuinfo[i].state, "vcpu.%u.state", cpuinfo[i].number);
/* stats below are available only if the VM is alive */
if (!virDomainObjIsActive(dom))
continue;
- if (virTypedParamListAddULLong(params, cpuinfo[i].cpuTime,
- "vcpu.%u.time", cpuinfo[i].number) < 0)
- return -1;
-
- if (virTypedParamListAddULLong(params, cpuwait[i],
- "vcpu.%u.wait", cpuinfo[i].number) < 0)
- return -1;
-
- if (virTypedParamListAddULLong(params, cpudelay[i],
- "vcpu.%u.delay", cpuinfo[i].number) < 0)
- return -1;
+ virTypedParamListAddULLong(params, cpuinfo[i].cpuTime, "vcpu.%u.time", cpuinfo[i].number);
+ virTypedParamListAddULLong(params, cpuwait[i], "vcpu.%u.wait", cpuinfo[i].number);
+ virTypedParamListAddULLong(params, cpudelay[i], "vcpu.%u.delay", cpuinfo[i].number);
/* state below is extracted from the individual vcpu structs */
if (!(vcpu = virDomainDefGetVcpu(dom->def, cpuinfo[i].number)))
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
if (vcpupriv->halted != VIR_TRISTATE_BOOL_ABSENT) {
- if (virTypedParamListAddBoolean(params,
- vcpupriv->halted == VIR_TRISTATE_BOOL_YES,
- "vcpu.%u.halted",
- cpuinfo[i].number) < 0)
- return -1;
+ virTypedParamListAddBoolean(params, vcpupriv->halted == VIR_TRISTATE_BOOL_YES,
+ "vcpu.%u.halted", cpuinfo[i].number);
}
if (!queried_stats)
}
#define QEMU_ADD_NET_PARAM(params, num, name, value) \
- if (value >= 0 && \
- virTypedParamListAddULLong((params), (value), "net.%zu.%s", (num), (name)) < 0) \
- return -1;
+ if (value >= 0)\
+ virTypedParamListAddULLong((params), (value), "net.%zu.%s", (num), (name));
static int
qemuDomainGetStatsInterface(virQEMUDriver *driver G_GNUC_UNUSED,
if (!virDomainObjIsActive(dom))
return 0;
- if (virTypedParamListAddUInt(params, dom->def->nnets, "net.count") < 0)
- return -1;
+ virTypedParamListAddUInt(params, dom->def->nnets, "net.count");
/* Check the path is one of the domain's network interfaces. */
for (i = 0; i < dom->def->nnets; i++) {
actualType = virDomainNetGetActualType(net);
- if (virTypedParamListAddString(params, net->ifname, "net.%zu.name", i) < 0)
- return -1;
+ virTypedParamListAddString(params, net->ifname, "net.%zu.name", i);
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
if (virNetDevOpenvswitchInterfaceStats(net->ifname, &tmp) < 0) {
}
}
- QEMU_ADD_NET_PARAM(params, i,
- "rx.bytes", tmp.rx_bytes);
- QEMU_ADD_NET_PARAM(params, i,
- "rx.pkts", tmp.rx_packets);
- QEMU_ADD_NET_PARAM(params, i,
- "rx.errs", tmp.rx_errs);
- QEMU_ADD_NET_PARAM(params, i,
- "rx.drop", tmp.rx_drop);
- QEMU_ADD_NET_PARAM(params, i,
- "tx.bytes", tmp.tx_bytes);
- QEMU_ADD_NET_PARAM(params, i,
- "tx.pkts", tmp.tx_packets);
- QEMU_ADD_NET_PARAM(params, i,
- "tx.errs", tmp.tx_errs);
- QEMU_ADD_NET_PARAM(params, i,
- "tx.drop", tmp.tx_drop);
+ QEMU_ADD_NET_PARAM(params, i, "rx.bytes", tmp.rx_bytes);
+ QEMU_ADD_NET_PARAM(params, i, "rx.pkts", tmp.rx_packets);
+ QEMU_ADD_NET_PARAM(params, i, "rx.errs", tmp.rx_errs);
+ QEMU_ADD_NET_PARAM(params, i, "rx.drop", tmp.rx_drop);
+ QEMU_ADD_NET_PARAM(params, i, "tx.bytes", tmp.tx_bytes);
+ QEMU_ADD_NET_PARAM(params, i, "tx.pkts", tmp.tx_packets);
+ QEMU_ADD_NET_PARAM(params, i, "tx.errs", tmp.tx_errs);
+ QEMU_ADD_NET_PARAM(params, i, "tx.drop", tmp.tx_drop);
}
return 0;
return 0;
}
- if (src->allocation &&
- virTypedParamListAddULLong(params, src->allocation,
- "block.%zu.allocation", block_idx) < 0)
- return -1;
+ if (src->allocation)
+ virTypedParamListAddULLong(params, src->allocation, "block.%zu.allocation", block_idx);
- if (src->capacity &&
- virTypedParamListAddULLong(params, src->capacity,
- "block.%zu.capacity", block_idx) < 0)
- return -1;
+ if (src->capacity)
+ virTypedParamListAddULLong(params, src->capacity, "block.%zu.capacity", block_idx);
- if (src->physical &&
- virTypedParamListAddULLong(params, src->physical,
- "block.%zu.physical", block_idx) < 0)
- return -1;
+ if (src->physical)
+ virTypedParamListAddULLong(params, src->physical, "block.%zu.physical", block_idx);
return 0;
}
if (!stats || !entryname || !(entry = virHashLookup(stats, entryname)))
return 0;
- if (virTypedParamListAddULLong(params, entry->wr_highest_offset,
- "block.%zu.allocation", block_idx) < 0)
- return -1;
+ virTypedParamListAddULLong(params, entry->wr_highest_offset, "block.%zu.allocation", block_idx);
- if (entry->capacity &&
- virTypedParamListAddULLong(params, entry->capacity,
- "block.%zu.capacity", block_idx) < 0)
- return -1;
+ if (entry->capacity)
+ virTypedParamListAddULLong(params, entry->capacity, "block.%zu.capacity", block_idx);
if (entry->physical) {
- if (virTypedParamListAddULLong(params, entry->physical,
- "block.%zu.physical", block_idx) < 0)
- return -1;
+ virTypedParamListAddULLong(params, entry->physical, "block.%zu.physical", block_idx);
} else {
if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0) {
- if (virTypedParamListAddULLong(params, src->physical,
- "block.%zu.physical", block_idx) < 0)
- return -1;
+ virTypedParamListAddULLong(params, src->physical, "block.%zu.physical", block_idx);
}
}
if (!stats || !entryname || !(entry = virHashLookup(stats, entryname)))
return 0;
- if (entry->write_threshold &&
- virTypedParamListAddULLong(params, entry->write_threshold,
- "block.%zu.threshold", recordnr) < 0)
- return -1;
+ if (entry->write_threshold)
+ virTypedParamListAddULLong(params, entry->write_threshold, "block.%zu.threshold", recordnr);
return 0;
}
if (!stats || !frontendname || !(en = virHashLookup(stats, frontendname)))
return 0;
- if (virTypedParamListAddULLong(par, en->rd_req, "block.%zu.rd.reqs", idx) < 0 ||
- virTypedParamListAddULLong(par, en->rd_bytes, "block.%zu.rd.bytes", idx) < 0 ||
- virTypedParamListAddULLong(par, en->rd_total_times, "block.%zu.rd.times", idx) < 0 ||
- virTypedParamListAddULLong(par, en->wr_req, "block.%zu.wr.reqs", idx) < 0 ||
- virTypedParamListAddULLong(par, en->wr_bytes, "block.%zu.wr.bytes", idx) < 0 ||
- virTypedParamListAddULLong(par, en->wr_total_times, "block.%zu.wr.times", idx) < 0 ||
- virTypedParamListAddULLong(par, en->flush_req, "block.%zu.fl.reqs", idx) < 0 ||
- virTypedParamListAddULLong(par, en->flush_total_times, "block.%zu.fl.times", idx) < 0)
- return -1;
+ virTypedParamListAddULLong(par, en->rd_req, "block.%zu.rd.reqs", idx);
+ virTypedParamListAddULLong(par, en->rd_bytes, "block.%zu.rd.bytes", idx);
+ virTypedParamListAddULLong(par, en->rd_total_times, "block.%zu.rd.times", idx);
+ virTypedParamListAddULLong(par, en->wr_req, "block.%zu.wr.reqs", idx);
+ virTypedParamListAddULLong(par, en->wr_bytes, "block.%zu.wr.bytes", idx);
+ virTypedParamListAddULLong(par, en->wr_total_times, "block.%zu.wr.times", idx);
+ virTypedParamListAddULLong(par, en->flush_req, "block.%zu.fl.reqs", idx);
+ virTypedParamListAddULLong(par, en->flush_total_times, "block.%zu.fl.times", idx);
return 0;
}
size_t recordnr,
virTypedParamList *params)
{
- if (virTypedParamListAddString(params, disk->dst, "block.%zu.name", recordnr) < 0)
- return -1;
+ virTypedParamListAddString(params, disk->dst, "block.%zu.name", recordnr);
- if (virStorageSourceIsLocalStorage(src) && src->path &&
- virTypedParamListAddString(params, src->path, "block.%zu.path", recordnr) < 0)
- return -1;
+ if (virStorageSourceIsLocalStorage(src) && src->path)
+ virTypedParamListAddString(params, src->path, "block.%zu.path", recordnr);
- if (src->id &&
- virTypedParamListAddUInt(params, src->id, "block.%zu.backingIndex", recordnr) < 0)
- return -1;
+ if (src->id)
+ virTypedParamListAddUInt(params, src->id, "block.%zu.backingIndex", recordnr);
return 0;
}
return -1;
}
- if (virTypedParamListAddUInt(params, visited, "block.count") < 0)
- return -1;
-
+ virTypedParamListAddUInt(params, visited, "block.count");
virTypedParamListConcat(params, &blockparams);
return 0;
goto cleanup;
}
- if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0)
- goto cleanup;
+ virTypedParamListAddUInt(params, niothreads, "iothread.count");
for (i = 0; i < niothreads; i++) {
if (iothreads[i]->poll_valid) {
- if (virTypedParamListAddULLong(params, iothreads[i]->poll_max_ns,
- "iothread.%u.poll-max-ns",
- iothreads[i]->iothread_id) < 0)
- goto cleanup;
- if (virTypedParamListAddUInt(params, iothreads[i]->poll_grow,
- "iothread.%u.poll-grow",
- iothreads[i]->iothread_id) < 0)
- goto cleanup;
- if (virTypedParamListAddUInt(params, iothreads[i]->poll_shrink,
- "iothread.%u.poll-shrink",
- iothreads[i]->iothread_id) < 0)
- goto cleanup;
+ virTypedParamListAddULLong(params, iothreads[i]->poll_max_ns,
+ "iothread.%u.poll-max-ns",
+ iothreads[i]->iothread_id);
+ virTypedParamListAddUInt(params, iothreads[i]->poll_grow,
+ "iothread.%u.poll-grow",
+ iothreads[i]->iothread_id);
+ virTypedParamListAddUInt(params, iothreads[i]->poll_shrink,
+ "iothread.%u.poll-shrink",
+ iothreads[i]->iothread_id);
}
}
if (virPerfReadEvent(perf, type, &value) < 0)
return -1;
- if (virTypedParamListAddULLong(params, value, "perf.%s",
- virPerfEventTypeToString(type)) < 0)
- return -1;
+ virTypedParamListAddULLong(params, value, "perf.%s", virPerfEventTypeToString(type));
return 0;
}
if (qemuDomainGetStatsDirtyRateMon(dom, &info) < 0)
return -1;
- if (virTypedParamListAddInt(params, info.status,
- "dirtyrate.calc_status") < 0)
- return -1;
-
- if (virTypedParamListAddLLong(params, info.startTime,
- "dirtyrate.calc_start_time") < 0)
- return -1;
-
- if (virTypedParamListAddInt(params, info.calcTime,
- "dirtyrate.calc_period") < 0)
- return -1;
-
- if (virTypedParamListAddString(params,
- qemuMonitorDirtyRateCalcModeTypeToString(info.mode),
- "dirtyrate.calc_mode") < 0)
- return -1;
+ virTypedParamListAddInt(params, info.status, "dirtyrate.calc_status");
+ virTypedParamListAddLLong(params, info.startTime, "dirtyrate.calc_start_time");
+ virTypedParamListAddInt(params, info.calcTime, "dirtyrate.calc_period");
+ virTypedParamListAddString(params, qemuMonitorDirtyRateCalcModeTypeToString(info.mode),
+ "dirtyrate.calc_mode");
if (info.status == VIR_DOMAIN_DIRTYRATE_MEASURED) {
- if (virTypedParamListAddLLong(params, info.dirtyRate,
- "dirtyrate.megabytes_per_second") < 0)
- return -1;
+ virTypedParamListAddLLong(params, info.dirtyRate, "dirtyrate.megabytes_per_second");
if (info.mode == QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_RING) {
size_t i;
for (i = 0; i < info.nvcpus; i++) {
- if (virTypedParamListAddULLong(params, info.rates[i].value,
- "dirtyrate.vcpu.%d.megabytes_per_second",
- info.rates[i].idx) < 0)
- return -1;
+ virTypedParamListAddULLong(params, info.rates[i].value,
+ "dirtyrate.vcpu.%d.megabytes_per_second",
+ info.rates[i].idx);
}
}
}