Commit Graph

44393 Commits

Author SHA1 Message Date
Peter Krempa
876f19c19e qemuBuildChrChardevStr: Use proper type for the switch statement
Add the missing cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Peter Krempa
a6577204d7 qemu: command: Rename qemuBuildHostNetStr -> qemuBuildHostNetProps
The function is already returning JSON properties, rename it
accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Peter Krempa
1dbb7cef70 qemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types
Use 'virReportEnumRangeError' for the invalid cases and keep the
original error for known but unsupported chardevs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Peter Krempa
d3af4392f7 qemuMonitorJSONAttachCharDevCommand: Format only the properties
Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev
and rename the function to qemuMonitorJSONAttachCharDevGetProps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Peter Krempa
ab85f52c38 qemuMonitorJSONAddDeviceProps: Simplify construction of the command
Use 'qemuMonitorJSONMakeCommandInternal' instead of
'qemuMonitorJSONMakeCommand' + 'virJSONValueObjectAppend'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Peter Krempa
2c1e3aa6f9 qemu: hotplug: Add wrapper for qemuMonitorAttachCharDev
Add a simple wrapper for 'qemuMonitorAttachCharDev' named
'qemuHotplugChardevAttach' which will simplify the moving of the
character device property generator out of the monitor code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Peter Krempa
4c7e733e79 qemuBuildCommandLine: Properly check return value of qemuBuildShmemCommandLine
Use the customary '< 0' check for return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-19 12:38:34 +01:00
Daniel Henrique Barboza
748c4a6b74 qemu_process.c: use g_autoptr() in qemuProcessQMPInitMonitor
The 'xmlopt' parameter can be auto-unref by using g_autoptr().

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-18 14:51:29 -03:00
Daniel Henrique Barboza
d103db0460 domain_conf.h: add autoptr cleanup func to virDomainXMLOptionPtr
This will enable code cleanups on code that still relies on
virObjectUnref() this pointer manually.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-18 14:51:22 -03:00
Daniel Henrique Barboza
a0ae3bd5d7 cpu_x86.c: remove 'guest' param from x86Compute()
x86Compute() is a static function called only by virCPUx86Compare()
which passes NULL to the 'guest' parameter of x86Compute().

The last caller of x86Compute() that used it with 'guest' != NULL
was an API called 'cpuGuestData'. This API was dropped by commit
03fa904c0c a few years ago. Since then all callers of x86Compute()
uses it with 'guest' = NULL.

Removing the 'guest' parameter allow us to remove a good chunk of
logic that isn't being used for awhile.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-18 14:50:58 -03:00
Andrea Bolognani
c5dc658ea8 spec: Explicitly provide locations for QEMU data
These are the defaults, but we prefer to be explicit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-18 15:49:02 +01:00
Andrea Bolognani
794af15f24 meson: Introduce qemu_datadir option
There is no guarantee that QEMU and libvirt have been configured
with the same prefix.

In particular, Homebrew on macOS will pass a different, private
prefix for each package version and then use symlinks to make
the files for a specific version appear in the usual locations.

This works perfectly fine as long as one package doesn't try to
go poking around another package's data - which is exactly what
libvirt needs to do in order to read and parse the QEMU interop
data.

qemu_datadir can now be explicitly provided to make this and
other uncommon scenarios work. The common scenario, where QEMU
and libvirt both use the same prefix, is unaffected.

https://gitlab.com/libvirt/libvirt/-/issues/168

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-18 15:48:59 +01:00
Andrea Bolognani
c46c2e15d1 qemu: Rename interop locations
Use abstract names that more closely match the Meson
nomenclature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-18 15:48:56 +01:00
Andrea Bolognani
b41c95af5b qemu: Set QEMU data location correctly
While datadir must live under prefix, there is no requirement
that its name must necessarily be "share": a different,
arbitrary name could have been provided by the user.

Fixes: 3c876d2428
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-18 15:48:54 +01:00
Andrea Bolognani
591cb9d0d5 meson: Define qemu_moddir correctly
We can't hardcode /usr here, because the user might have
configured whatever arbitrary prefix.

Everything appeared to be okay because when joining paths
Meson will drop any component that precedes an absolute path
and libdir happens to be absolute, but we should still do
things correctly instead of relying on this.

Fixes: 2ad009eadd
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-18 15:48:49 +01:00
Andrea Bolognani
47c439ce44 spec: Don't create unnecessary directory
The directory is already created by the build system, so we
don't need to create it explicitly in the spec file; moreover,
the path was incorrect, because it used datadir instead of
localstatedir.

Fixes: 4e041189f8
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-18 15:47:57 +01:00
Daniel Henrique Barboza
bbbf774fb2 tests/qemuxml2*/graphics-spice-timeout: skip CPU model check
Commit 65b0b746b5 changed spice tests to use latest caps. Before this
change, "FLAG_REAL_CAPS" wasn't being set in testQemuInfoInitArgs(). The
absence of this flag triggered the code path inside
testCompareXMLToArgv() that executed testUpdateQEMUCaps(). This function
will update the host CPU via virQEMUCapsUpdateHostCPUModel() into
virQEMUCapsInitHostCPUModel(). In this function,
virQEMUCapsInitCPUModel() would end up updating the hostCPU inside the
qemuCaps (via virQEMUCapsProbeHostCPU()). Before the forementioned
commit, the host CPU was being defaulted to x86_64, vendor Intel, for
the 'graphics-spice-timeout' test that is using the 'pc' machine type
and 'accel=kvm'.

Today, "FLAG_REAL_CAPS" is being set because we're using the latest caps
from x86_64. This means that the whole code path mentioned above is
skipped. qemuCaps are now being loaded via virQEMUCapsLoadCache()
directly. Without the handling being done by testUpdateQEMUCaps(), the
host CPU is being retrieved later on, down below
qemuProcessCreatePretendCmdPrepare() into qemuProcessUpdateGuestCPU().
The latter will attempt to update the domain cpu and executing a
virCPUCompare with the hostCPU and def->cpu.

All this logic ended up causing a failure of the
'graphics-spice-timeout' test in ppc64 and s390x hosts. This test is
being run with KVM acceleration, and the KVM driver for ppc64 and s390x
will return a default x86_64 CPU with vendor "AMD", making
virCPUCompare() fail with the following message:

"QEMU XML-2-ARGV graphics-spice-timeout.x86_64-latest   ... libvirt: CPU
Driver error : the CPU is incompatible with host CPU: host CPU vendor does
not match required CPU vendor Intel"

Fix this test by setting cpu check='none' and avoid the virCPUCompare()
that causes the problem for ppc64 and s390x hosts.

Note that this is a build fix. A more adequate fix would be to mock the
getHost() interface of the cpuDriverX86 for non-x86 hosts, allowing
'fullCPU' to be retrieved in qemuProcessUpdateGuestCPU(), and a proper
x86 CPU to be retrieved in the scenario described above.

Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-17 22:47:21 -03:00
Andrea Bolognani
324de132bc docs: Use new URLs for Go modules in downloads page
We've been using the new repositories for a few months now,
but the downloads page still points to the obsolete Go packages.

Fixes: 1832c0a02b
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-17 17:45:55 +01:00
Peter Krempa
279c64dccb qemu: command: Use JSON for parameters of -audiodev
'-audiodev' as a modern implementation based on QAPI already takes JSON
as the argument. Convert our code to use it directly.

The declaration of the QAPI types can be found in
'qemu.git/qapi/audio.json'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
14af0a3290 qemu: command: Use JSON for parameters of -compat
'-compat' as a modern implementation based on QAPI already takes JSON as
the argument. Convert our code to use it directly.

QEMU declares the ised QAPI types as:

{ 'enum': 'CompatPolicyInput',
  'data': [ 'accept', 'reject', 'crash' ] }

{ 'enum': 'CompatPolicyOutput',
  'data': [ 'accept', 'hide' ] }

{ 'struct': 'CompatPolicy',
  'data': { '*deprecated-input': 'CompatPolicyInput',
            '*deprecated-output': 'CompatPolicyOutput' } }

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
12f48c53f5 util: json: Remove virJSONValueObjectCreate(VArgs)
The functions were obsoleted by virJSONValueObjectAdd(VArgs)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
f50cc9c108 Replace virJSONValueObjectCreateVArgs with virJSONValueObjectAddVArgs
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
813ee9fb62 virsh: domain: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
bd9dcd2b4b qemu: migration_params: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
829b6982cc virjsontest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
8049041720 qemublocktest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
acf6b4e83c qemu: command: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
fdda016bce qemuDiskSourceGetProps: Initialize 'ret'
Upcomming patch will convert virJSONValueObjectCreate which didn't check
the value of the passed argument to virJSONValueObjectAdd which will and
this would lead to crashes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
dd45aad40a qemu: migration_cookie: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
d53be3fe93 qemu: monitor: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
d7ea3fe7f4 qemu: monitor_json: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
8de1edd5c7 qemu: agent: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
7552031f57 qemu: block: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
bd74e0d995 virJSONValueObjectAddVArgs: Allocate new object if passed pointer is NULL
Until now the code would crash if virJSONValueObjectAdd is used without
a valid object. Adding the functionality of allocating it if it's NULL
will allow us to replace all uses of virJSONValueObjectCreate with this
single function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
34fc5832e3 virJSONValueObjectAddVArgs: Take double pointer
Pass in the double pointer from the wrappers directly to
virJSONValueObjectAddVArgs, which will allow us to directly allocate the
new objects inside the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-17 12:04:11 +01:00
Peter Krempa
f28b1cf2c9 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>
2021-11-17 12:04:10 +01:00
Ján Tomko
03f9dfbb51 conf: device: compare drive address fields separately
Commit 3210c8b04 introduced a separate field 'diskbus' for
internal use by the commandline formatter.

Adjust the check for address equality to compare the relevant
fields separately instead of the whole struct.

This means that the changes of the 'diskbus' field added
in commit 03ed14d2d4 no longer affect the outcome of the address
equality check.

https://bugzilla.redhat.com/show_bug.cgi?id=2023605

Fixes: 3210c8b047
Fixes: 03ed14d2d4
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-16 16:40:33 +01:00
Göran Uddeborg
810b1d85a1 Translated using Weblate (Swedish)
Currently translated at 28.9% (3018 of 10441 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 28.7% (2998 of 10441 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2021-11-15 21:16:05 +01:00
Piotr Drąg
04b3799018 Translated using Weblate (Polish)
Currently translated at 22.4% (2347 of 10441 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/pl/

Co-authored-by: Piotr Drąg <piotrdrag@gmail.com>
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
2021-11-15 21:16:04 +01:00
simmon
70bf049d1c Translated using Weblate (Korean)
Currently translated at 100.0% (10441 of 10441 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-11-15 21:16:04 +01:00
Daniel Henrique Barboza
df194c5c08 qemu: add DEVICE_UNPLUG_GUEST_ERROR event support
The upcoming QEMU 6.2.0 implements a new event called
DEVICE_UNPLUG_GUEST_ERROR, a new event that reports generic device
unplug errors that were detected by the guest and reported back to QEMU.

This new event is going to be specially useful for pseries guests that
uses newer kernels (must have kernel commit 29c9a2699e71), which is the
case for Fedora 34 at this moment. These guests have the capability of
reporting CPU removal errors back to QEMU which, starting in 6.2.0, will
emit the DEVICE_UNPLUG_GUEST_ERROR event. Libvirt can use this event to
abort the device removal immediately instead of waiting for 'setvcpus'
timeout.

QEMU 6.2.0 is also going to emit DEVICE_UNPLUG_GUEST_ERROR for memory
hotunplug errors, both in pseries and ACPI guests. QEMU 6.1.0 reports
memory removal errors using the MEM_UNPLUG_ERROR event, which is going to
be deprecated by DEVICE_UNPLUG_GUEST_ERROR in 6.2.0. Given that
Libvirt wasn't handling the MEM_UNPLUG_ERROR event we don't need to
worry about it - adding support to DEVICE_UNPLUG_GUEST_ERROR will be
enough to cover all future cases.

This patch adds support to DEVICE_UNPLUG_GUEST_ERROR by adding the
minimal wiring required for Libvirt to be aware of it. The monitor
callback for this event will abort the pending removal operation of the
device reported by the "device" property of the event. Most of the heavy
lifting is already done by existing code that handles
QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED, making our life
easier to abort the pending removal operation.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-12 13:44:42 -03:00
Daniel Henrique Barboza
9b2130ec8e tests: update QEMU and domain ppc64 capabilities for qemu 6.2
This patch updates domaincapsdata and qemucapabilitiesdata for ppc64
with qemu commit v6.1.0-1714-gc5b2f55981.

Changes in all 'ppc64-latest.ags' files were needed. The changes are
mundane despite the volume. For all 'ppc64-latest.args' files the
changes are:

- removing '-sandbox' command line;
- 'secret' and 'memory-backend-ram' objects are now using qom-type format;
- '-device' is now using qom-type format.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-12 13:44:42 -03:00
Michal Privoznik
842cfc9d41 virsh: Remove unnecessary else branches
In a few cases we call a public API, wrapped in an if() statement
with both branches written out explicitly. The error branch jumps
onto cleanup label, while the successful prints out a message.
Right after these ifs there's 'ret = true;' and the cleanup
label. The code is a bit more readable if only the error branch
is kept and printing happens at the same level as setting the ret
variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
2021-11-12 17:17:19 +01:00
Michal Privoznik
a4056d52eb examples/dommigrate: Make retval portable
Currently, the dommigrate example returns 0 or 1 for success or
failure state, respectively. Except for a few cases where it
forgot to change the @ret variable just before jumping onto the
'cleanup' label. Making the code follow our usual pattern
(initialize @ret to an error value and set it to success value
only at the end) fixes those cases. Also, using EXIT_SUCCESS and
EXIT_FAILURE is more portable (even though on my system they are
just an alias to values the example already uses).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
2021-11-12 17:17:16 +01:00
Michal Privoznik
132069f845 examples/dommigrate: Don't set retval in usage()
The usage() function should just print expected arguments. Make
the function return void then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
2021-11-12 17:17:12 +01:00
Michal Privoznik
c70cf347b9 virNetDevVPortProfileParse: Use g_autofree
Explicit calls to VIR_FREE() can be dropped then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
2021-11-12 17:16:44 +01:00
Michal Privoznik
3640731ed5 qemuMonitorOpen: Rework domain object refcounting
Similarly to one of previous commits, there's no need to
increment domain object refcounter before unlocking it. Any
number of lock and unlock calls over domain object has no effect
on the refcounter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-12 14:11:49 +01:00
Michal Privoznik
e812213bc1 qemu_agent: Drop destroy callback
After previous cleanups this callback is unused. Remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-12 14:11:43 +01:00
Michal Privoznik
0a9cb29ba2 qemuAgentOpen: Rework domain object refcounting
Currently, when opening an agent socket the qemuConnectAgent()
increments domain object refcounter and calls qemuAgentOpen()
where the domain object pointer is simply stored inside
_qemuAgent struct. If qemuAgentOpen() fails, then it clears @cb
member only to avoid qemuProcessHandleAgentDestroy() being called
(which decrements the domain object refcounter) and the domain
object refcounter is then decreased explicitly in
qemuConnectAgent().

The same result can be achieved with much cleaner code: increment
the refcounter inside qemuAgentOpen() and drop the dance around
@cb.

Also, the comment in qemuConnectAgent() about holding an extra
reference is not correct. The thread that called
qemuConnectAgent() already holds a reference to the domain
object. No matter how many time the object is locked and unlocked
the reference counter can't be decreased.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-12 14:11:29 +01:00
Michal Privoznik
108e131a3d qemu_agent: Rework domain object locking when opening agent
Just like qemuMonitorOpen(), hold the domain object locked
throughout the whole time of qemuConnectAgent() and unlock it
only for a brief time of actual connect() (because this is the
only part that has a potential of blocking).

The reason is that qemuAgentOpen() does access domain object
(well, its privateData) AND also at least one argument (@context)
depends on domain object. Accessing these without the lock is
potentially dangerous.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1845468#c12
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-12 14:11:11 +01:00