virJSONValueObjectAdd: Convert @obj argument to double pointer

Change the first argument to a double pointer so that later the function
can be unified with virJSONValueObjectCreate and fix all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-08 17:18:59 +01:00
parent 03f9dfbb51
commit f28b1cf2c9
5 changed files with 87 additions and 87 deletions

View File

@ -636,7 +636,7 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSource *src,
if (!onlytarget && if (!onlytarget &&
src->debug && src->debug &&
virJSONValueObjectAdd(props, "u:debug", src->debugLevel, NULL) < 0) virJSONValueObjectAdd(&props, "u:debug", src->debugLevel, NULL) < 0)
return NULL; return NULL;
return g_steal_pointer(&props); return g_steal_pointer(&props);
@ -700,11 +700,11 @@ qemuBlockStorageSourceGetNFSProps(virStorageSource *src)
return NULL; return NULL;
if (src->nfs_uid != -1 && if (src->nfs_uid != -1 &&
virJSONValueObjectAdd(ret, "i:user", src->nfs_uid, NULL) < 0) virJSONValueObjectAdd(&ret, "i:user", src->nfs_uid, NULL) < 0)
return NULL; return NULL;
if (src->nfs_gid != -1 && if (src->nfs_gid != -1 &&
virJSONValueObjectAdd(ret, "i:group", src->nfs_gid, NULL) < 0) virJSONValueObjectAdd(&ret, "i:group", src->nfs_gid, NULL) < 0)
return NULL; return NULL;
return ret; return ret;
@ -1060,7 +1060,7 @@ qemuBlockStorageSourceGetVvfatProps(virStorageSource *src,
return NULL; return NULL;
if (!onlytarget && if (!onlytarget &&
virJSONValueObjectAdd(ret, "b:rw", !src->readonly, NULL) < 0) virJSONValueObjectAdd(&ret, "b:rw", !src->readonly, NULL) < 0)
return NULL; return NULL;
return g_steal_pointer(&ret); return g_steal_pointer(&ret);
@ -1270,21 +1270,21 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
if (!onlytarget) { if (!onlytarget) {
if (qemuBlockNodeNameValidate(src->nodestorage) < 0 || if (qemuBlockNodeNameValidate(src->nodestorage) < 0 ||
virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage, NULL) < 0) virJSONValueObjectAdd(&fileprops, "S:node-name", src->nodestorage, NULL) < 0)
return NULL; return NULL;
if (!legacy) { if (!legacy) {
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, fileprops) < 0) if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, fileprops) < 0)
return NULL; return NULL;
if (virJSONValueObjectAdd(fileprops, if (virJSONValueObjectAdd(&fileprops,
"T:read-only", ro, "T:read-only", ro,
"T:auto-read-only", aro, "T:auto-read-only", aro,
NULL) < 0) NULL) < 0)
return NULL; return NULL;
if (!(flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP) && if (!(flags & QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP) &&
virJSONValueObjectAdd(fileprops, virJSONValueObjectAdd(&fileprops,
"s:discard", "unmap", "s:discard", "unmap",
NULL) < 0) NULL) < 0)
return NULL; return NULL;
@ -1307,7 +1307,7 @@ qemuBlockStorageSourceGetFormatLUKSProps(virStorageSource *src,
return -1; return -1;
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:driver", "luks", "s:driver", "luks",
"s:key-secret", srcPriv->encinfo->alias, "s:key-secret", srcPriv->encinfo->alias,
NULL) < 0) NULL) < 0)
@ -1321,14 +1321,14 @@ static int
qemuBlockStorageSourceGetFormatRawProps(virStorageSource *src, qemuBlockStorageSourceGetFormatRawProps(virStorageSource *src,
virJSONValue *props) virJSONValue *props)
{ {
if (virJSONValueObjectAdd(props, "s:driver", "raw", NULL) < 0) if (virJSONValueObjectAdd(&props, "s:driver", "raw", NULL) < 0)
return -1; return -1;
/* Currently only storage slices are supported. We'll have to calculate /* Currently only storage slices are supported. We'll have to calculate
* the union of the slices here if we don't want to be adding needless * the union of the slices here if we don't want to be adding needless
* 'raw' nodes. */ * 'raw' nodes. */
if (src->sliceStorage && if (src->sliceStorage &&
virJSONValueObjectAdd(props, virJSONValueObjectAdd(&props,
"U:offset", src->sliceStorage->offset, "U:offset", src->sliceStorage->offset,
"U:size", src->sliceStorage->size, "U:size", src->sliceStorage->size,
NULL) < 0) NULL) < 0)
@ -1392,7 +1392,7 @@ qemuBlockStorageSourceGetFormatQcowGenericProps(virStorageSource *src,
if (qemuBlockStorageSourceGetCryptoProps(src, &encprops) < 0) if (qemuBlockStorageSourceGetCryptoProps(src, &encprops) < 0)
return -1; return -1;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:driver", format, "s:driver", format,
"A:encrypt", &encprops, NULL) < 0) "A:encrypt", &encprops, NULL) < 0)
return -1; return -1;
@ -1426,7 +1426,7 @@ qemuBlockStorageSourceGetFormatQcow2Props(virStorageSource *src,
* https://git.qemu.org/?p=qemu.git;a=blob;f=docs/qcow2-cache.txt * https://git.qemu.org/?p=qemu.git;a=blob;f=docs/qcow2-cache.txt
*/ */
if (src->metadataCacheMaxSize > 0) { if (src->metadataCacheMaxSize > 0) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"U:cache-size", src->metadataCacheMaxSize, "U:cache-size", src->metadataCacheMaxSize,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -1545,7 +1545,7 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virStorageSource *src)
} }
if (driver && if (driver &&
virJSONValueObjectAdd(props, "s:driver", driver, NULL) < 0) virJSONValueObjectAdd(&props, "s:driver", driver, NULL) < 0)
return NULL; return NULL;
return g_steal_pointer(&props); return g_steal_pointer(&props);
@ -2311,7 +2311,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSource *backing,
if (!(backingFileStr = qemuBlockGetBackingStoreString(backing, false))) if (!(backingFileStr = qemuBlockGetBackingStoreString(backing, false)))
return -1; return -1;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"S:backing-file", backingFileStr, "S:backing-file", backingFileStr,
"S:backing-fmt", backingFormatStr, "S:backing-fmt", backingFormatStr,
NULL) < 0) NULL) < 0)
@ -2370,7 +2370,7 @@ qemuBlockStorageSourceCreateGetEncryptionLUKS(virStorageSource *src,
src->encryption->encinfo.cipher_size); src->encryption->encinfo.cipher_size);
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"S:cipher-alg", cipheralg, "S:cipher-alg", cipheralg,
"S:cipher-mode", src->encryption->encinfo.cipher_mode, "S:cipher-mode", src->encryption->encinfo.cipher_mode,
"S:hash-alg", src->encryption->encinfo.cipher_hash, "S:hash-alg", src->encryption->encinfo.cipher_hash,
@ -2394,7 +2394,7 @@ qemuBlockStorageSourceCreateGetFormatPropsLUKS(virStorageSource *src,
if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &luksprops) < 0) if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &luksprops) < 0)
return -1; return -1;
if (virJSONValueObjectAdd(luksprops, if (virJSONValueObjectAdd(&luksprops,
"s:driver", "luks", "s:driver", "luks",
"s:file", src->nodestorage, "s:file", src->nodestorage,
"U:size", src->capacity, "U:size", src->capacity,
@ -2424,10 +2424,10 @@ qemuBlockStorageSourceCreateAddEncryptionQcow(virStorageSource *src,
if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &encryptProps) < 0) if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &encryptProps) < 0)
return -1; return -1;
if (virJSONValueObjectAdd(encryptProps, "s:format", "luks", NULL) < 0) if (virJSONValueObjectAdd(&encryptProps, "s:format", "luks", NULL) < 0)
return -1; return -1;
if (virJSONValueObjectAdd(props, "a:encrypt", &encryptProps, NULL) < 0) if (virJSONValueObjectAdd(&props, "a:encrypt", &encryptProps, NULL) < 0)
return -1; return -1;
return 0; return 0;

View File

@ -449,7 +449,7 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props,
bus = g_strdup_printf("%s.%u", controllerAlias, info->addr.drive.bus); bus = g_strdup_printf("%s.%u", controllerAlias, info->addr.drive.bus);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
"u:unit", info->addr.drive.unit, "u:unit", info->addr.drive.unit,
NULL) < 0) NULL) < 0)
@ -473,7 +473,7 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props,
bus = g_strdup_printf("%s.%u", controllerAlias, info->addr.drive.unit); bus = g_strdup_printf("%s.%u", controllerAlias, info->addr.drive.unit);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -481,7 +481,7 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props,
break; break;
case VIR_DOMAIN_DISK_BUS_FDC: case VIR_DOMAIN_DISK_BUS_FDC:
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"u:unit", info->addr.drive.unit, "u:unit", info->addr.drive.unit,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -503,7 +503,7 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974:
bus = g_strdup_printf("%s.%u", controller->info.alias, info->addr.drive.bus); bus = g_strdup_printf("%s.%u", controller->info.alias, info->addr.drive.bus);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
"u:scsi-id", info->addr.drive.unit, "u:scsi-id", info->addr.drive.unit,
NULL) < 0) NULL) < 0)
@ -522,7 +522,7 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL:
bus = g_strdup_printf("%s.0", controller->info.alias); bus = g_strdup_printf("%s.0", controller->info.alias);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
"u:channel", info->addr.drive.bus, "u:channel", info->addr.drive.bus,
"u:scsi-id", info->addr.drive.target, "u:scsi-id", info->addr.drive.target,
@ -578,7 +578,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
else else
pciaddr = g_strdup_printf("0x%x", info->addr.pci.slot); pciaddr = g_strdup_printf("0x%x", info->addr.pci.slot);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
"T:multifunction", info->addr.pci.multi, "T:multifunction", info->addr.pci.multi,
"s:addr", pciaddr, "s:addr", pciaddr,
@ -604,7 +604,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
virDomainUSBAddressPortFormatBuf(&port, info->addr.usb.port); virDomainUSBAddressPortFormatBuf(&port, info->addr.usb.port);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
"S:port", virBufferCurrentContent(&port), "S:port", virBufferCurrentContent(&port),
NULL) < 0) NULL) < 0)
@ -615,7 +615,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
if (info->addr.spaprvio.has_reg) { if (info->addr.spaprvio.has_reg) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"P:reg", info->addr.spaprvio.reg, "P:reg", info->addr.spaprvio.reg,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -628,14 +628,14 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
info->addr.ccw.ssid, info->addr.ccw.ssid,
info->addr.ccw.devno); info->addr.ccw.devno);
if (virJSONValueObjectAdd(props, "s:devno", devno, NULL) < 0) if (virJSONValueObjectAdd(&props, "s:devno", devno, NULL) < 0)
return -1; return -1;
return 0; return 0;
} }
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"u:iobase", info->addr.isa.iobase, "u:iobase", info->addr.isa.iobase,
"p:irq", info->addr.isa.irq, "p:irq", info->addr.isa.irq,
NULL) < 0) NULL) < 0)
@ -644,7 +644,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
return 0; return 0;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"u:slot", info->addr.dimm.slot, "u:slot", info->addr.dimm.slot,
"P:addr", info->addr.dimm.base, "P:addr", info->addr.dimm.base,
NULL) < 0) NULL) < 0)
@ -666,7 +666,7 @@ qemuBuildDeviceAddressProps(virJSONValue *props,
bus = g_strdup_printf("%s.%d", contAlias, info->addr.vioserial.bus); bus = g_strdup_printf("%s.%d", contAlias, info->addr.vioserial.bus);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:bus", bus, "s:bus", bus,
"i:nr", info->addr.vioserial.port, "i:nr", info->addr.vioserial.port,
NULL) < 0) NULL) < 0)
@ -1122,7 +1122,7 @@ qemuBuildVirtioDevProps(virDomainDeviceType devtype,
return NULL; return NULL;
if (virtioOptions) { if (virtioOptions) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"T:iommu_platform", virtioOptions->iommu, "T:iommu_platform", virtioOptions->iommu,
"T:ats", virtioOptions->ats, "T:ats", virtioOptions->ats,
"T:packed", virtioOptions->packed, "T:packed", virtioOptions->packed,
@ -1165,7 +1165,7 @@ qemuBuildRomProps(virJSONValue *props,
} }
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"k:rombar", rombar, "k:rombar", rombar,
"S:romfile", romfile, "S:romfile", romfile,
NULL) < 0) NULL) < 0)
@ -1975,7 +1975,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def,
if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_DISK, disk, qemuCaps))) if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_DISK, disk, qemuCaps)))
return NULL; return NULL;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"S:iothread", iothread, "S:iothread", iothread,
"T:ioeventfd", disk->ioeventfd, "T:ioeventfd", disk->ioeventfd,
"T:event_idx", disk->event_idx, "T:event_idx", disk->event_idx,
@ -2088,7 +2088,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_STORAGE_WERROR)) if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_STORAGE_WERROR))
qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy); qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"S:device_id", scsiVPDDeviceId, "S:device_id", scsiVPDDeviceId,
"T:share-rw", shareRW, "T:share-rw", shareRW,
"S:drive", drive, "S:drive", drive,
@ -2480,7 +2480,7 @@ qemuBuildVHostUserFsDevProps(virDomainFSDef *fs,
if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, priv->qemuCaps))) if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, priv->qemuCaps)))
return NULL; return NULL;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", fs->info.alias, "s:id", fs->info.alias,
"s:chardev", chardev_alias, "s:chardev", chardev_alias,
"P:queue-size", fs->queue_size, "P:queue-size", fs->queue_size,
@ -2585,7 +2585,7 @@ qemuBuildFSDevCmd(virCommand *cmd,
if (!(devprops = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, qemuCaps))) if (!(devprops = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, qemuCaps)))
return -1; return -1;
if (virJSONValueObjectAdd(devprops, if (virJSONValueObjectAdd(&devprops,
"s:id", fs->info.alias, "s:id", fs->info.alias,
"s:fsdev", fsdev, "s:fsdev", fsdev,
"s:mount_tag", fs->dst, "s:mount_tag", fs->dst,
@ -2776,13 +2776,13 @@ qemuBuildUSBControllerDevProps(const virDomainDef *domainDef,
masterbus = g_strdup_printf("%s.0", alias); masterbus = g_strdup_printf("%s.0", alias);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:masterbus", masterbus, "s:masterbus", masterbus,
"i:firstport", def->info.master.usb.startport, "i:firstport", def->info.master.usb.startport,
NULL) < 0) NULL) < 0)
return NULL; return NULL;
} else { } else {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", def->info.alias, "s:id", def->info.alias,
NULL) < 0) NULL) < 0)
return NULL; return NULL;
@ -2811,7 +2811,7 @@ qemuBuildControllerSCSIDevProps(virDomainControllerDef *def,
if (def->iothread > 0) if (def->iothread > 0)
iothread = g_strdup_printf("iothread%u", def->iothread); iothread = g_strdup_printf("iothread%u", def->iothread);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"S:iothread", iothread, "S:iothread", iothread,
"s:id", def->info.alias, "s:id", def->info.alias,
"p:num_queues", def->queues, "p:num_queues", def->queues,
@ -2915,7 +2915,7 @@ qemuBuildControllerPCIDevProps(virDomainControllerDef *def,
return -1; return -1;
if (pciopts->numaNode != -1 && if (pciopts->numaNode != -1 &&
virJSONValueObjectAdd(props, "i:numa_node", pciopts->numaNode, NULL) < 0) virJSONValueObjectAdd(&props, "i:numa_node", pciopts->numaNode, NULL) < 0)
return -1; return -1;
break; break;
@ -2952,7 +2952,7 @@ qemuBuildControllerPCIDevProps(virDomainControllerDef *def,
return -1; return -1;
if (pciopts->numaNode != -1 && if (pciopts->numaNode != -1 &&
virJSONValueObjectAdd(props, "i:numa_node", pciopts->numaNode, NULL) < 0) virJSONValueObjectAdd(&props, "i:numa_node", pciopts->numaNode, NULL) < 0)
return -1; return -1;
break; break;
@ -3015,7 +3015,7 @@ qemuBuildControllerDevProps(const virDomainDef *domainDef,
qemuCaps))) qemuCaps)))
return -1; return -1;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", def->info.alias, "s:id", def->info.alias,
"k:max_ports", def->opts.vioserial.ports, "k:max_ports", def->opts.vioserial.ports,
"k:vectors", def->opts.vioserial.vectors, "k:vectors", def->opts.vioserial.vectors,
@ -3305,10 +3305,10 @@ qemuBuildMemoryBackendPropsShare(virJSONValue *props,
{ {
switch (memAccess) { switch (memAccess) {
case VIR_DOMAIN_MEMORY_ACCESS_SHARED: case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
return virJSONValueObjectAdd(props, "b:share", true, NULL); return virJSONValueObjectAdd(&props, "b:share", true, NULL);
case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE: case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
return virJSONValueObjectAdd(props, "b:share", false, NULL); return virJSONValueObjectAdd(&props, "b:share", false, NULL);
case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT: case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
case VIR_DOMAIN_MEMORY_ACCESS_LAST: case VIR_DOMAIN_MEMORY_ACCESS_LAST:
@ -3498,8 +3498,8 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
backendType = "memory-backend-memfd"; backendType = "memory-backend-memfd";
if (useHugepage) { if (useHugepage) {
if (virJSONValueObjectAdd(props, "b:hugetlb", useHugepage, NULL) < 0 || if (virJSONValueObjectAdd(&props, "b:hugetlb", useHugepage, NULL) < 0 ||
virJSONValueObjectAdd(props, "U:hugetlbsize", pagesize << 10, NULL) < 0) { virJSONValueObjectAdd(&props, "U:hugetlbsize", pagesize << 10, NULL) < 0) {
return -1; return -1;
} }
@ -3533,7 +3533,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
return -1; return -1;
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:mem-path", memPath, "s:mem-path", memPath,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -3546,7 +3546,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
return -1; return -1;
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"B:discard-data", true, "B:discard-data", true,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -3574,7 +3574,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
*/ */
if (disableCanonicalPath && if (disableCanonicalPath &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_X_USE_CANONICAL_PATH_FOR_RAMBLOCK_ID) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_X_USE_CANONICAL_PATH_FOR_RAMBLOCK_ID) &&
virJSONValueObjectAdd(props, "b:x-use-canonical-path-for-ramblock-id", false, NULL) < 0) virJSONValueObjectAdd(&props, "b:x-use-canonical-path-for-ramblock-id", false, NULL) < 0)
return -1; return -1;
if (mem->model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM) { if (mem->model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM) {
@ -3591,11 +3591,11 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
return -1; return -1;
} else { } else {
if (!priv->memPrealloc && if (!priv->memPrealloc &&
virJSONValueObjectAdd(props, "B:prealloc", prealloc, NULL) < 0) virJSONValueObjectAdd(&props, "B:prealloc", prealloc, NULL) < 0)
return -1; return -1;
} }
if (virJSONValueObjectAdd(props, "U:size", mem->size * 1024, NULL) < 0) if (virJSONValueObjectAdd(&props, "U:size", mem->size * 1024, NULL) < 0)
return -1; return -1;
if (mem->alignsize) { if (mem->alignsize) {
@ -3605,7 +3605,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
"with this QEMU binary")); "with this QEMU binary"));
return -1; return -1;
} }
if (virJSONValueObjectAdd(props, "U:align", mem->alignsize * 1024, NULL) < 0) if (virJSONValueObjectAdd(&props, "U:align", mem->alignsize * 1024, NULL) < 0)
return -1; return -1;
} }
@ -3616,7 +3616,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
"with this QEMU binary")); "with this QEMU binary"));
return -1; return -1;
} }
if (virJSONValueObjectAdd(props, "b:pmem", true, NULL) < 0) if (virJSONValueObjectAdd(&props, "b:pmem", true, NULL) < 0)
return -1; return -1;
} }
@ -3635,7 +3635,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
mode != VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { mode != VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) {
if (!virNumaNodesetIsAvailable(nodemask)) if (!virNumaNodesetIsAvailable(nodemask))
return -1; return -1;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"m:host-nodes", nodemask, "m:host-nodes", nodemask,
"S:policy", qemuNumaPolicyTypeToString(mode), "S:policy", qemuNumaPolicyTypeToString(mode),
NULL) < 0) NULL) < 0)
@ -3884,7 +3884,7 @@ qemuBuildNicDevProps(virDomainDef *def,
if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_NET, net, qemuCaps))) if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_NET, net, qemuCaps)))
return NULL; return NULL;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"S:tx", tx, "S:tx", tx,
"T:ioeventfd", net->driver.virtio.ioeventfd, "T:ioeventfd", net->driver.virtio.ioeventfd,
"T:event_idx", net->driver.virtio.event_idx, "T:event_idx", net->driver.virtio.event_idx,
@ -3917,7 +3917,7 @@ qemuBuildNicDevProps(virDomainDef *def,
virMacAddrFormat(&net->mac, macaddr); virMacAddrFormat(&net->mac, macaddr);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:netdev", netdev, "s:netdev", netdev,
"s:id", net->info.alias, "s:id", net->info.alias,
"s:mac", macaddr, "s:mac", macaddr,
@ -3973,7 +3973,7 @@ qemuBuildHostNetStr(virDomainNetDef *net,
/* for one tapfd 'fd=' shall be used, /* for one tapfd 'fd=' shall be used,
* for more than one 'fds=' is the right choice */ * for more than one 'fds=' is the right choice */
if (tapfdSize == 1) { if (tapfdSize == 1) {
if (virJSONValueObjectAdd(netprops, "s:fd", tapfd[0], NULL) < 0) if (virJSONValueObjectAdd(&netprops, "s:fd", tapfd[0], NULL) < 0)
return NULL; return NULL;
} else { } else {
g_auto(virBuffer) fdsbuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) fdsbuf = VIR_BUFFER_INITIALIZER;
@ -3983,7 +3983,7 @@ qemuBuildHostNetStr(virDomainNetDef *net,
virBufferTrim(&fdsbuf, ":"); virBufferTrim(&fdsbuf, ":");
if (virJSONValueObjectAdd(netprops, if (virJSONValueObjectAdd(&netprops,
"s:fds", virBufferCurrentContent(&fdsbuf), "s:fds", virBufferCurrentContent(&fdsbuf),
NULL) < 0) NULL) < 0)
return NULL; return NULL;
@ -4102,7 +4102,7 @@ qemuBuildHostNetStr(virDomainNetDef *net,
return NULL; return NULL;
if (vhostfdSize == 1) { if (vhostfdSize == 1) {
if (virJSONValueObjectAdd(netprops, "s:vhostfd", vhostfd[0], NULL) < 0) if (virJSONValueObjectAdd(&netprops, "s:vhostfd", vhostfd[0], NULL) < 0)
return NULL; return NULL;
} else { } else {
g_auto(virBuffer) fdsbuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) fdsbuf = VIR_BUFFER_INITIALIZER;
@ -4112,7 +4112,7 @@ qemuBuildHostNetStr(virDomainNetDef *net,
virBufferTrim(&fdsbuf, ":"); virBufferTrim(&fdsbuf, ":");
if (virJSONValueObjectAdd(netprops, if (virJSONValueObjectAdd(&netprops,
"s:vhostfds", virBufferCurrentContent(&fdsbuf), "s:vhostfds", virBufferCurrentContent(&fdsbuf),
NULL) < 0) NULL) < 0)
return NULL; return NULL;
@ -4202,7 +4202,7 @@ qemuBuildMemballoonCommandLine(virCommand *cmd,
def->memballoon, qemuCaps))) def->memballoon, qemuCaps)))
return -1; return -1;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", def->memballoon->info.alias, "s:id", def->memballoon->info.alias,
"T:deflate-on-oom", def->memballoon->autodeflate, "T:deflate-on-oom", def->memballoon->autodeflate,
"T:free-page-reporting", def->memballoon->free_page_reporting, "T:free-page-reporting", def->memballoon->free_page_reporting,
@ -4281,7 +4281,7 @@ qemuBuildInputVirtioDevProps(const virDomainDef *def,
if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_INPUT, dev, qemuCaps))) if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_INPUT, dev, qemuCaps)))
return NULL; return NULL;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", dev->info.alias, "s:id", dev->info.alias,
"S:evdev", evdev, "S:evdev", evdev,
NULL) < 0) NULL) < 0)
@ -4338,11 +4338,11 @@ qemuBuildInputEvdevProps(virDomainInputDef *dev)
return NULL; return NULL;
if (dev->source.grab == VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL && if (dev->source.grab == VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL &&
virJSONValueObjectAdd(props, "b:grab_all", true, NULL) < 0) virJSONValueObjectAdd(&props, "b:grab_all", true, NULL) < 0)
return NULL; return NULL;
if (dev->source.grabToggle != VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_DEFAULT && if (dev->source.grabToggle != VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_DEFAULT &&
virJSONValueObjectAdd(props, "s:grab-toggle", virJSONValueObjectAdd(&props, "s:grab-toggle",
virDomainInputSourceGrabToggleTypeToString(dev->source.grabToggle), virDomainInputSourceGrabToggleTypeToString(dev->source.grabToggle),
NULL) < 0) NULL) < 0)
return NULL; return NULL;
@ -4580,35 +4580,35 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
} }
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", video->info.alias, "s:id", video->info.alias,
"T:virgl", virgl, "T:virgl", virgl,
NULL) < 0) NULL) < 0)
return -1; return -1;
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:ram_size", video->ram * 1024, "p:ram_size", video->ram * 1024,
"p:vram_size", video->vram * 1024, "p:vram_size", video->vram * 1024,
NULL) < 0) NULL) < 0)
return -1; return -1;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VRAM64)) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VRAM64)) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"u:vram64_size_mb", video->vram64 / 1024, "u:vram64_size_mb", video->vram64 / 1024,
NULL) < 0) NULL) < 0)
return -1; return -1;
} }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGAMEM)) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGAMEM)) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"u:vgamem_mb", video->vgamem / 1024, "u:vgamem_mb", video->vgamem / 1024,
NULL) < 0) NULL) < 0)
return -1; return -1;
} }
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:max_outputs", video->heads, "p:max_outputs", video->heads,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -4616,7 +4616,7 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
} else if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { } else if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
g_autofree char *alias = qemuDomainGetVhostUserChrAlias(video->info.alias); g_autofree char *alias = qemuDomainGetVhostUserChrAlias(video->info.alias);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:max_outputs", video->heads, "p:max_outputs", video->heads,
"s:chardev", alias, "s:chardev", alias,
NULL) < 0) NULL) < 0)
@ -4627,7 +4627,7 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS)) if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS))
heads = video->heads; heads = video->heads;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:max_outputs", heads, "p:max_outputs", heads,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -4635,19 +4635,19 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
(video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA && (video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM))) { virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM))) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:vgamem_mb", video->vram / 1024, "p:vgamem_mb", video->vram / 1024,
NULL) < 0) NULL) < 0)
return -1; return -1;
} else if (video->type == VIR_DOMAIN_VIDEO_TYPE_BOCHS) { } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_BOCHS) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:vgamem", video->vram * 1024, "p:vgamem", video->vram * 1024,
NULL) < 0) NULL) < 0)
return -1; return -1;
} }
if (video->res) { if (video->res) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"p:xres", video->res->x, "p:xres", video->res->x,
"p:yres", video->res->y, "p:yres", video->res->y,
NULL) < 0) NULL) < 0)
@ -4900,7 +4900,7 @@ qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def,
if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_HOSTDEV, dev, qemuCaps))) if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_HOSTDEV, dev, qemuCaps)))
return NULL; return NULL;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:wwpn", hostsrc->wwpn, "s:wwpn", hostsrc->wwpn,
"s:vhostfd", vhostfdName, "s:vhostfd", vhostfdName,
"s:id", dev->info->alias, "s:id", dev->info->alias,
@ -5664,7 +5664,7 @@ qemuBuildVirtioSerialPortDevProps(const virDomainDef *def,
targetname = "com.redhat.spice.0"; targetname = "com.redhat.spice.0";
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:chardev", chardev, "s:chardev", chardev,
"s:id", dev->info.alias, "s:id", dev->info.alias,
"S:name", targetname, "S:name", targetname,
@ -5811,7 +5811,7 @@ qemuBuildRNGDevProps(const virDomainDef *def,
period = 1000; period = 1000;
} }
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:rng", rng, "s:rng", rng,
"s:id", dev->info.alias, "s:id", dev->info.alias,
"p:max-bytes", dev->rate, "p:max-bytes", dev->rate,
@ -9150,7 +9150,7 @@ qemuBuildSmartcardCommandLine(virLogManager *logManager,
bus = g_strdup_printf("%s.0", contAlias); bus = g_strdup_printf("%s.0", contAlias);
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", smartcard->info.alias, "s:id", smartcard->info.alias,
"s:bus", bus, "s:bus", bus,
NULL) < 0) NULL) < 0)
@ -10166,7 +10166,7 @@ qemuBuildPanicCommandLine(virCommand *cmd,
/* pvpanic uses 'ioport' instead of 'iobase' so /* pvpanic uses 'ioport' instead of 'iobase' so
* qemuBuildDeviceAddressProps can't be used */ * qemuBuildDeviceAddressProps can't be used */
if (def->panics[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { if (def->panics[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"u:ioport", def->panics[i]->info.addr.isa.iobase, "u:ioport", def->panics[i]->info.addr.isa.iobase,
NULL) < 0) NULL) < 0)
return -1; return -1;
@ -10472,7 +10472,7 @@ qemuBuildVsockDevProps(virDomainDef *def,
if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_VSOCK, vsock, qemuCaps))) if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_VSOCK, vsock, qemuCaps)))
return NULL; return NULL;
if (virJSONValueObjectAdd(props, if (virJSONValueObjectAdd(&props,
"s:id", vsock->info.alias, "s:id", vsock->info.alias,
"u:guest-cid", vsock->guest_cid, "u:guest-cid", vsock->guest_cid,
"s:vhostfd", vhostfd, "s:vhostfd", vhostfd,

View File

@ -3612,7 +3612,7 @@ int qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon,
return -1; return -1;
if (fdset >= 0 && if (fdset >= 0 &&
virJSONValueObjectAdd(args, "j:fdset-id", fdset, NULL) < 0) { virJSONValueObjectAdd(&args, "j:fdset-id", fdset, NULL) < 0) {
return -1; return -1;
} }
@ -6636,7 +6636,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
backend_type = "file"; backend_type = "file";
if (virJSONValueObjectAppendString(data, "out", chr->data.file.path) < 0) if (virJSONValueObjectAppendString(data, "out", chr->data.file.path) < 0)
return NULL; return NULL;
if (virJSONValueObjectAdd(data, if (virJSONValueObjectAdd(&data,
"T:append", chr->data.file.append, "T:append", chr->data.file.append,
NULL) < 0) NULL) < 0)
return NULL; return NULL;
@ -6748,7 +6748,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
} }
if (chr->logfile && if (chr->logfile &&
virJSONValueObjectAdd(data, virJSONValueObjectAdd(&data,
"s:logfile", chr->logfile, "s:logfile", chr->logfile,
"T:logappend", chr->logappend, "T:logappend", chr->logappend,
NULL) < 0) NULL) < 0)

View File

@ -348,13 +348,13 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
int int
virJSONValueObjectAdd(virJSONValue *obj, ...) virJSONValueObjectAdd(virJSONValue **objptr, ...)
{ {
va_list args; va_list args;
int ret; int ret;
va_start(args, obj); va_start(args, objptr);
ret = virJSONValueObjectAddVArgs(obj, args); ret = virJSONValueObjectAddVArgs(*objptr, args);
va_end(args); va_end(args);
return ret; return ret;

View File

@ -48,7 +48,7 @@ int virJSONValueObjectCreate(virJSONValue **obj, ...)
ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED; ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED;
int virJSONValueObjectCreateVArgs(virJSONValue **obj, va_list args) int virJSONValueObjectCreateVArgs(virJSONValue **obj, va_list args)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int virJSONValueObjectAdd(virJSONValue *obj, ...) int virJSONValueObjectAdd(virJSONValue **obj, ...)
ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED; ATTRIBUTE_NONNULL(1) G_GNUC_NULL_TERMINATED;
int virJSONValueObjectAddVArgs(virJSONValue *obj, va_list args) int virJSONValueObjectAddVArgs(virJSONValue *obj, va_list args)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);