]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu_monitor_json: Don't transfer ownership to @msg
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 21 Oct 2021 10:53:35 +0000 (12:53 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 25 Oct 2021 11:42:00 +0000 (13:42 +0200)
commit2d7257d5281d430de51c548ddd4273178066906a
treee868b5890decd799589c0d317920b92dccc61bb6
parent139338ab333a70232cb07cc563477db184dd2087
qemu_monitor_json: Don't transfer ownership to @msg

In qemuMonitorJSONCommandWithFd() given command (represented by
virJSONValue struct) is translated to string (represented by
virBuffer). The ownership of the string is then transferred to
the message which is then sent. The downside of this approach is
we have to have an explicit call to free the string from the
message. But if the message just "borrowed" the string (which it
can safely do because it is just reading from the string) then
automatic free of the buffer takes care of freeing the string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c