{
qemuMonitorEventPanicInfoPtr ret;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(qemuMonitorEventPanicInfo, 1);
ret->type = QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV;
unsigned long long psw_mask, psw_addr;
const char *reason = NULL;
- if (VIR_ALLOC(ret) < 0)
- return NULL;
+ ret = g_new0(qemuMonitorEventPanicInfo, 1);
ret->type = QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390;
if ((ncpus = virJSONValueArraySize(data)) == 0)
return -2;
- if (VIR_ALLOC_N(cpus, ncpus) < 0)
- goto cleanup;
+ cpus = g_new0(struct qemuMonitorQueryCpusEntry, ncpus);
for (i = 0; i < ncpus; i++) {
virJSONValuePtr entry = virJSONValueArrayGet(data, i);
struct qemuDomainDiskInfo *tmp = NULL;
int ret = -1;
- if (VIR_ALLOC(tmp) < 0)
- goto cleanup;
+ tmp = g_new0(struct qemuDomainDiskInfo, 1);
*tmp = *info;
tmp->nodename = NULL;
return NULL;
}
- if (VIR_ALLOC(bstats) < 0)
- return NULL;
+ bstats = g_new0(qemuBlockStats, 1);
#define QEMU_MONITOR_BLOCK_STAT_GET(NAME, VAR, MANDATORY) \
if (MANDATORY || virJSONValueObjectHasKey(stats, NAME)) { \
{
qemuBlockStatsPtr copy = NULL;
- if (VIR_ALLOC(copy) < 0)
- return -1;
+ copy = g_new0(qemuBlockStats, 1);
if (bstats)
*copy = *bstats;
qemuBlockStatsPtr bstats;
if (!(bstats = virHashLookup(stats, name))) {
- if (VIR_ALLOC(bstats) < 0)
- return -1;
+ bstats = g_new0(qemuBlockStats, 1);
if (virHashAddEntry(stats, name, bstats) < 0) {
VIR_FREE(bstats);
goto cleanup;
}
nTable = virJSONValueArraySize(table);
- if (VIR_ALLOC_N(fil->unicast.table, nTable))
- goto cleanup;
+ fil->unicast.table = g_new0(virMacAddr, nTable);
for (i = 0; i < nTable; i++) {
if (!(element = virJSONValueArrayGet(table, i)) ||
!(tmp = virJSONValueGetString(element))) {
goto cleanup;
}
nTable = virJSONValueArraySize(table);
- if (VIR_ALLOC_N(fil->multicast.table, nTable))
- goto cleanup;
+ fil->multicast.table = g_new0(virMacAddr, nTable);
for (i = 0; i < nTable; i++) {
if (!(element = virJSONValueArrayGet(table, i)) ||
!(tmp = virJSONValueGetString(element))) {
goto cleanup;
}
nTable = virJSONValueArraySize(table);
- if (VIR_ALLOC_N(fil->vlan.table, nTable))
- goto cleanup;
+ fil->vlan.table = g_new0(unsigned int, nTable);
for (i = 0; i < nTable; i++) {
if (!(element = virJSONValueArrayGet(table, i)) ||
virJSONValueGetNumberUint(element, &fil->vlan.table[i]) < 0) {
goto cleanup;
}
- if (VIR_ALLOC(entry) < 0)
- goto cleanup;
+ entry = g_new0(qemuMonitorChardevInfo, 1);
if (STRPREFIX(type, "pty:"))
entry->ptyPath = g_strdup(type + strlen("pty:"));
if (!rawjobname)
device = qemuAliasDiskDriveSkipPrefix(device);
- if (VIR_ALLOC(info) < 0)
- return -1;
+ info = g_new0(qemuMonitorBlockJobInfo, 1);
if (virHashAddEntry(blockJobs, device, info) < 0) {
VIR_FREE(info);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(infolist, n + 1) < 0)
- goto cleanup;
+ infolist = g_new0(qemuMonitorMachineInfoPtr, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
const char *tmp;
qemuMonitorMachineInfoPtr info;
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(qemuMonitorMachineInfo, 1);
infolist[i] = info;
}
cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
- if (VIR_ALLOC_N(cpu->blockers, len + 1) < 0)
- return -1;
+ cpu->blockers = g_new0(char *, len + 1);
for (j = 0; j < len; j++) {
virJSONValuePtr blocker = virJSONValueArrayGet(blockers, j);
qemuMonitorCPUModelInfoPtr machine_model = NULL;
int ret = -1;
- if (VIR_ALLOC(machine_model) < 0)
- goto cleanup;
-
+ machine_model = g_new0(qemuMonitorCPUModelInfo, 1);
machine_model->name = g_strdup(cpu_name);
if (cpu_props) {
size_t nprops = virJSONValueObjectKeysNumber(cpu_props);
- if (VIR_ALLOC_N(machine_model->props, nprops) < 0)
- goto cleanup;
+ machine_model->props = g_new0(qemuMonitorCPUProperty, nprops);
if (virJSONValueObjectForeachKeyValue(cpu_props,
qemuMonitorJSONParseCPUModelProperty,
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(commandlist, n + 1) < 0)
- goto cleanup;
+ commandlist = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(eventlist, n + 1) < 0)
- goto cleanup;
+ eventlist = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(paramlist, n + 1) < 0)
- goto cleanup;
+ paramlist = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(typelist, n + 1) < 0)
- goto cleanup;
+ typelist = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(pathlist, n + 1) < 0)
- goto cleanup;
+ pathlist = g_new0(qemuMonitorJSONListPathPtr, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
const char *tmp;
qemuMonitorJSONListPathPtr info;
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(qemuMonitorJSONListPath, 1);
pathlist[i] = info;
data = virJSONValueObjectGetArray(reply, "return");
n = virJSONValueArraySize(data);
- if (VIR_ALLOC_N(list, n + 1) < 0)
- return -1;
+ list = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr item = virJSONValueArrayGet(data, i);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(proplist, n + 1) < 0)
- goto cleanup;
+ proplist = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
caps = virJSONValueObjectGetArray(reply, "return");
n = virJSONValueArraySize(caps);
- if (VIR_ALLOC_N(list, n + 1) < 0)
- goto cleanup;
+ list = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr cap = virJSONValueArrayGet(caps, i);
goto cleanup;
}
- if (VIR_ALLOC_N(list, n) < 0)
- goto cleanup;
+ list = g_new0(virGICCapability, n);
for (i = 0; i < n; i++) {
virJSONValuePtr cap = virJSONValueArrayGet(caps, i);
goto cleanup;
}
- if (VIR_ALLOC(capability) < 0)
- goto cleanup;
+ capability = g_new0(virSEVCapability, 1);
capability->pdh = g_strdup(pdh);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(list, n + 1) < 0)
- goto cleanup;
+ list = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
if (n < 0)
return -1;
- if (VIR_ALLOC_N(*aliases, n + 1) < 0)
- goto cleanup;
+ *aliases = g_new0(char *, n + 1);
alias = *aliases;
for (i = 0; i < n; i++) {
ret = 0;
- cleanup:
for (i = 0; i < n; i++)
qemuMonitorJSONListPathFree(paths[i]);
VIR_FREE(paths);
n = virJSONValueArraySize(data);
/* null-terminated list */
- if (VIR_ALLOC_N(infolist, n + 1) < 0)
- goto cleanup;
+ infolist = g_new0(qemuMonitorIOThreadInfoPtr, n + 1);
for (i = 0; i < n; i++) {
virJSONValuePtr child = virJSONValueArrayGet(data, i);
if (!STRPREFIX(tmp, "iothread"))
continue;
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(qemuMonitorIOThreadInfo, 1);
infolist[i] = info;
goto cleanup;
}
- if (VIR_ALLOC(meminfo) < 0)
- goto cleanup;
+ meminfo = g_new0(qemuMonitorMemoryDeviceInfo, 1);
if (virJSONValueObjectGetNumberUlong(dimminfo, "addr",
&meminfo->address) < 0) {
data = virJSONValueObjectGet(reply, "return");
ninfo = virJSONValueArraySize(data);
- if (VIR_ALLOC_N(info, ninfo) < 0)
- goto cleanup;
+ info = g_new0(struct qemuMonitorQueryHotpluggableCpusEntry, ninfo);
for (i = 0; i < ninfo; i++) {
vcpu = virJSONValueArrayGet(data, i);
if (!(alias = virJSONValueObjectGetString(prManager, "id")))
goto malformed;
- if (VIR_ALLOC(entry) < 0)
- goto cleanup;
+ entry = g_new0(qemuMonitorPRManagerInfo, 1);
if (virJSONValueObjectGetBoolean(prManager,
"connected",
int tmp;
g_autoptr(qemuMonitorJobInfo) job = NULL;
- if (VIR_ALLOC(job) < 0)
- return NULL;
+ job = g_new0(qemuMonitorJobInfo, 1);
if ((tmp = qemuMonitorJobTypeFromString(type)) < 0)
tmp = QEMU_MONITOR_JOB_TYPE_UNKNOWN;