mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuBuildChannelGuestfwdNetdevProps: Don't use virJSONValueObjectAppendStringPrintf
Use virJSONValueObjectAdd and format the string directly via g_strdup_printf. In the end virJSONValueObjectAppendStringPrintf will be removed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
cac6d59e80
commit
609353275b
@ -10515,22 +10515,24 @@ qemuBuildParallelChrDeviceProps(virDomainChrDef *chr)
|
|||||||
virJSONValue *
|
virJSONValue *
|
||||||
qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr)
|
qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr)
|
||||||
{
|
{
|
||||||
|
g_autofree char *guestfwdstr = NULL;
|
||||||
|
g_autoptr(virJSONValue) guestfwdstrobj = NULL;
|
||||||
g_autoptr(virJSONValue) guestfwdarr = virJSONValueNewArray();
|
g_autoptr(virJSONValue) guestfwdarr = virJSONValueNewArray();
|
||||||
g_autoptr(virJSONValue) guestfwdstrobj = virJSONValueNewObject();
|
|
||||||
g_autofree char *addr = NULL;
|
g_autofree char *addr = NULL;
|
||||||
virJSONValue *ret = NULL;
|
virJSONValue *ret = NULL;
|
||||||
|
|
||||||
if (!(addr = virSocketAddrFormat(chr->target.addr)))
|
if (!(addr = virSocketAddrFormat(chr->target.addr)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
guestfwdstr = g_strdup_printf("tcp:%s:%i-chardev:char%s",
|
||||||
|
addr,
|
||||||
|
virSocketAddrGetPort(chr->target.addr),
|
||||||
|
chr->info.alias);
|
||||||
|
|
||||||
/* this may seem weird, but qemu indeed decided that 'guestfwd' parameter
|
/* this may seem weird, but qemu indeed decided that 'guestfwd' parameter
|
||||||
* is an array of objects which have just one member named 'str' which
|
* is an array of objects which have just one member named 'str' which
|
||||||
* contains the description */
|
* contains the description */
|
||||||
if (virJSONValueObjectAppendStringPrintf(guestfwdstrobj, "str",
|
if (virJSONValueObjectAdd(&guestfwdstrobj, "s:str", guestfwdstr, NULL) < 0)
|
||||||
"tcp:%s:%i-chardev:char%s",
|
|
||||||
addr,
|
|
||||||
virSocketAddrGetPort(chr->target.addr),
|
|
||||||
chr->info.alias) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virJSONValueArrayAppend(guestfwdarr, &guestfwdstrobj) < 0)
|
if (virJSONValueArrayAppend(guestfwdarr, &guestfwdstrobj) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user