Commit Graph

32305 Commits

Author SHA1 Message Date
Boris Fiuczynski
823a62ec8a qemu: segmentation fault in virtqemud executing qemuDomainUndefineFlags
Commit 5adfb34723 causes a segmentation fault.

Stack trace of thread 664419:
 #0  0x000003ff62ec553c in qemuDomainUndefineFlags (dom=0x3ff6c002810, flags=<optimized out>) at ../src/qemu/qemu_driver.c:6618
 #1  0x000003ff876a7e5c in virDomainUndefineFlags (domain=domain@entry=0x3ff6c002810, flags=<optimized out>) at ../src/libvirt-domain.c:6519
 #2  0x000002aa2b64a808 in remoteDispatchDomainUndefineFlags (server=0x2aa2c3d7880, msg=0x2aa2c3d2770, args=<optimized out>, rerr=0x3ff8287b950, client=<optimized out>)
        at src/remote/remote_daemon_dispatch_stubs.h:13080
 #3  remoteDispatchDomainUndefineFlagsHelper (server=0x2aa2c3d7880, client=<optimized out>, msg=0x2aa2c3d2770, rerr=0x3ff8287b950, args=<optimized out>, ret=0x0)
        at src/remote/remote_daemon_dispatch_stubs.h:13059
 #4  0x000003ff8758bbf4 in virNetServerProgramDispatchCall (msg=0x2aa2c3d2770, client=0x2aa2c3e3050, server=0x2aa2c3d7880, prog=0x2aa2c3d8010)
        at ../src/rpc/virnetserverprogram.c:428
 #5  virNetServerProgramDispatch (prog=0x2aa2c3d8010, server=server@entry=0x2aa2c3d7880, client=0x2aa2c3e3050, msg=0x2aa2c3d2770) at ../src/rpc/virnetserverprogram.c:302
 #6  0x000003ff8758c260 in virNetServerProcessMsg (msg=<optimized out>, prog=<optimized out>, client=<optimized out>, srv=0x2aa2c3d7880) at ../src/rpc/virnetserver.c:140
 #7  virNetServerHandleJob (jobOpaque=0x2aa2c3e2d30, opaque=0x2aa2c3d7880) at ../src/rpc/virnetserver.c:160
 #8  0x000003ff874c49aa in virThreadPoolWorker (opaque=<optimized out>) at ../src/util/virthreadpool.c:164
 #9  0x000003ff874c3f62 in virThreadHelper (data=<optimized out>) at ../src/util/virthread.c:256
 #10 0x000003ff86c1cf8c in start_thread () from /lib64/libc.so.6
 #11 0x000003ff86c9650e in thread_start () from /lib64/libc.so.6

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-02 09:32:02 +01:00
Peter Krempa
da3acb8d55 qemu: Implement qemuDomainQemuMonitorCommandWithFiles
Add support for sending one FD from the client along with a monitor
command so that it's possible to use 'getfd' and 'add-fd' to use FDs
passed from the client with other QMP commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-01 13:29:49 +01:00
Peter Krempa
f87fa77ca9 lib: Introduce 'virDomainQemuMonitorCommandWithFiles'
This API has the same semantics as 'virDomainQemuMonitorCommand' but
accepts file descriptors which are then forwarded to qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-01 13:29:49 +01:00
Peter Krempa
7cfbfe66fc virnetmessage: Introduce virNetMessageClearFDs
The helper splits out the clearing of the FDs transacted inside a
virNetMessage.

APIs transacting FDs both from and to the client at the same time will
need to clear the FDs stored in virNetMessage as the structure is
re-used for the reply and without clearing the list of FDs we'd return
the FDs sent by the client in addition to the new FDs sent by the API.t

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-01 13:29:49 +01:00
Peter Krempa
3c4b49e871 qemu: block copy: Propagate 'detect_zeroes' properly into mirror definition
'qemuDomainPrepareDiskSourceData' propagates 'detect_zeroes' only for
the disk source image, but the mirror destination has the ambition to
replace the disk source when the job is finished, so we need to
propagate the 'detect_zeroes' setting also in that case.

Unfortunately it would become very hairy to either set 'disk->mirror'
sooner or propagate that we want this done into
'qemuDomainPrepareDiskSourceData', so the most straightforward solution
is to do the propagation inside 'qemuDomainBlockCopyCommon'.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/277
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-01 13:07:23 +01:00
Kristina Hanicova
8ce46ec2c3 libxl: remove redundant variable from libxlDomainJobObj
It makes no sense to have 'started' variable in the
libxlDomainJobObj as the same one is already in virDomainJobData,
but never used.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-01 11:03:57 +01:00
Daniel P. Berrangé
32b9d8b0ae qemu: support firmware descriptor flash 'mode' for optional NVRAM
Currently the 'nvram_template' entry is mandatory when parsing the
firmware descriptor based on flash. QEMU is extending the firmware
descriptor spec to make the 'nvram_template' optional, depending
on the value of a new 'mode' field:

  - "split"
      * "executable" contains read-only CODE
      * "nvram_template" contains read-write VARS

  - "combined"
      * "executable" contains read-write CODE and VARs
      * "nvram_template" not present

  - "stateless"
      * "executable" contains read-only CODE and VARs
      * "nvram_template" not present

In the latter case, the guest OS can write vars but the
firmware will make no attempt to persist them, so any changes
will be lost at poweroff.

For now we parse this new 'mode' but discard any firmware
which is not 'mode=split' when matching for a domain.

In the tests we have a mixture of files with and without the
mode attribute.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-23 18:11:08 +00:00
Daniel P. Berrangé
5adfb34723 qemu: honour user's nvram path when undefining VM
When undefining a VM, we must optionally delete any NVRAM that might
exist. When using firmware auto-select we always check the generated
path, ignoring any user specified path.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-23 18:09:04 +00:00
Martin Kletzander
a64e666a11 util: Fix machined servicename
Commit 4e42686ade wrongly assumed how g_variant_new_parsed() works and broke
starting of domains on systems with systemd (machined).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-02-23 13:40:24 +01:00
Michal Privoznik
24adb6c7a6 qemu: Don't regenerate NVRAM path if parsed from domain XML
After v8.0.0-466-g08101bde5d we unconditionally regenerate per
domain NVRAM path even though it might have been parsed earlier
from domain XML. The way we do that leads to a memleak:

  43 bytes in 1 blocks are definitely lost in loss record 330 of 682
  at 0x483F7E5: malloc (vg_replace_malloc.c:381)
  by 0x50D5B18: g_malloc (in /usr/lib64/libglib-2.0.so.0.7000.2)
  by 0x50EFA4F: g_strdup (in /usr/lib64/libglib-2.0.so.0.7000.2)
  by 0x49E774E: virXPathString (virxml.c:88)
  by 0x4A3F0E4: virDomainDefParseBootLoaderOptions (domain_conf.c:18226)
  by 0x4A3F49C: virDomainDefParseBootOptions (domain_conf.c:18298)
  by 0x4A448C3: virDomainDefParseXML (domain_conf.c:19598)
  by 0x4A487A1: virDomainDefParseNode (domain_conf.c:20404)
  by 0x117FCF: testCompareXMLToArgv (qemuxml2argvtest.c:726)
  by 0x142124: virTestRun (testutils.c:142)
  by 0x1423D4: virTestRunLog (testutils.c:197)
  by 0x140A76: mymain (qemuxml2argvtest.c:3406)

If we parsed NVRAM path from domain XML we must refrain from
generating new path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-02-23 10:25:19 +01:00
Peter Krempa
14851cff11 qemu: blockjob: Avoid spurious log errors when cancelling a shallow copy with reused images
In case when a user starts a block copy operation with
VIR_DOMAIN_BLOCK_COPY_SHALLOW and VIR_DOMAIN_BLOCK_COPY_REUSE_EXT and
both the reused image and the original disk have a backing image libvirt
specifically does not insert the backing image until after the job is
asked to be completed via virBlockJobAbort with
VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT.

This is so that management applications can copy the backing image on
the background.

Now when a user aborts the block job instead of cancelling it we'd
ignore the fact that we didn't insert the backing image yet and the
cancellation would result into a 'blockdev-del' of a invalid node name
and thus an 'error' severity entry in the log.

To solve this issue we use the same conditions when the backing image
addition is avoided to remove the internal state for them prior to the
call to unplug the mirror destination.

Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-23 09:39:18 +01:00
Michal Privoznik
a6929d62cf qemu: Don't ignore failure when building default memory backend
When building the default memory backend (which has id='pc.ram')
and no guest NUMA is configured then
qemuBuildMemCommandLineMemoryDefaultBackend() is called. However,
its return value is ignored which means that on invalid
configuration (e.g. when non-existent hugepage size was
requested) an error is reported into the logs but QEMU is started
anyway. And while QEMU does error out its error message doesn't
give much clue what's going on:

  qemu-system-x86_64: Memory backend 'pc.ram' not found

While at it, introduce a test case. While I could chose a nice
looking value (e.g. 4MiB) that's exactly what I wanted to avoid,
because while such value might not be possible on x84_64 it may
be possible on other arches (e.g. ppc is notoriously known for
supporting wide range of HP sizes). Let's stick with obviously
wrong value of 5MiB.

Reported-by: Charles Polisher <chas@chasmo.org>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-22 17:26:19 +01:00
Daniel P. Berrangé
4e76dfd2e6 conf: rename struct field for NVRAM template
This is to make it explicit that the template only applies to the NVRAM
store, not the main loader binary, even if the loader is writable.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-22 14:56:26 +00:00
Daniel P. Berrangé
08101bde5d qemu: inline code for filling in per-VM NVRAM path
Before creating a NVRAM path, the qemuDomainNVRAMPathGenerate
method checks whether the config is using the old style
firmware approach. This check is redundant in one of the two
callers. By inlining the check into the other caller, it makes
it clearer to understand that the NVRAM path filling is done
conditionally.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-22 14:55:58 +00:00
Daniel P. Berrangé
7dd53b125a qemu: fix bad indentation for qemuDomainNVRAMPathFormat
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-22 14:54:19 +00:00
Martin Kletzander
4e42686ade Make systemd unit ordering more robust
Since libvirt-guests script/service can operate on various URIs and we do
support both socket activation and traditional services, the ordering should be
specified for all the possible sockets and services.

Also remove the Wants= dependency since do not want to start any service.  We
cannot know which one libvirt-guests is configured, so we'd have to start all
the daemons which would break if unused colliding services are not
masked (libvirtd.service in the modular case and all the modular daemon service
units in the monolithic scenario).  Fortunately we can assume that the system is
configured properly to start services/sockets that are of interest to the user.
That also works with the setup described in https://libvirt.org/daemons.html .

To make it even more robust we add the daemon service into the machine units
created for individual domains as it was missing there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-22 13:35:47 +01:00
Michal Privoznik
ee5c273ec5 qemu: Move some enums impl to qemu_monitor.c
There are some enums that are declared in qemu_monitor.h but
implemented in qemu_monitor_json.c. While from compiler and
linker POV it doesn't matter, the code is cleaner if an enum is
implemented in .c file that corresponds to .h file which declared
the enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-22 11:49:18 +01:00
Michal Privoznik
89e3386670 qemu: Use virDomainObjCheckActive() more
Using the following spatch, I've identified two places which
could be switched from explicit virDomainObjIsActive() +
virReportError() to virDomainObjCheckActive():

  @@
  expression dom;
  @@
      if (
  -        !virDomainObjIsActive(dom)
  +        virDomainObjCheckActive(dom) < 0
      ) {
  -        virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running"));
          ...
      }

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-21 15:25:32 +01:00
Hyman Huang(黄勇)
42d36b65a3 qemu_driver: Add calc_mode for dirtyrate statistics
Add calc_mode for dirtyrate statistics retured by
virsh domstats --dirtyrate api, also add vcpu dirtyrate
if dirty-ring mode was used in last measurement.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:34:16 +01:00
Hyman Huang(黄勇)
b4b1ec6f73 qemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc
Extend flags parameter of virDomainStartDirtyRateCalc as a
superset of virDomainDirtyRateCalcFlags, parse the flags and
handle it correspondingly in qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:34:16 +01:00
Hyman Huang(黄勇)
de4a066bfd qemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc
Add mode parameter to qemuDomainStartDirtyRateCalc API, 'mode'
option of 'calc-dirty-rate' command was introduced since
qemu >= 6.2.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:34:16 +01:00
Hyman Huang(黄勇)
e7a8bd2173 include: Introduce virDomainDirtyRateCalcFlags
Introduce virDomainDirtyRateCalcFlags to get ready for
adding mode parameter to qemuDomainStartDirtyRateCalc.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:34:16 +01:00
Hyman Huang(黄勇)
f8dc72f0ca qemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability
mode option of calc-dirty-rate command since qemu >=6.2.0.
Introduce QEMU_CAPS_DIRTYRATE_MODE capability definition.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:34:16 +01:00
Hyman Huang(黄勇)
f78b804b46 qemu_driver: Probe capability before calculating dirty page rate
Probing QEMU_CAPS_CALC_DIRTY_RATE capability in advance
in case of failure when calculating dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:34:04 +01:00
Hyman Huang(黄勇)
b207f84901 qemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability
calc-dirty-rate command was introduced since qemu >=5.2.0.
Introduce QEMU_CAPS_CALC_DIRTY_RATE capability definition.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-21 13:24:50 +01:00
Jim Fehlig
454b927d1e libxl: Fix libvirtd crash on domain restore
Commit cc2a3c2a94 missed one case in the libxl driver where virDomainDef
is returned from libxlDomainSaveImageOpen and a g_steal_pointer is needed.
Without it, the virDomainDef object is freed and the driver crashes later
in the restore process when accessing the object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-18 11:20:21 -07:00
Daniel P. Berrangé
b56a833243 util: drop support for obsolete systemd in RHEL-7
The systemd version in RHEL-7 lacked support for the LISTEN_FDNAMES env
variable with socket activation. Since we stopped targetting RHEL-7 we
can drop some considerable amount of compatibility code.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-17 12:35:42 +00:00
Peter Krempa
1c71e06619 virDomainCreate(XML)WithFiles: Add check for VIR_DRV_FEATURE_FD_PASSING
All APIs using FD passing have this check to prevent sending a
'VIR_NET_CALL_WITH_FDS' to an older daemon but
virDomainCreateXMLWithFiles was missing it.

Now the LXC driver was historically not exposing
VIR_DRV_FEATURE_FD_PASSING, but that is not a problem as LXC always goes
through the remote driver which intercepts it and injects
VIR_DRV_FEATURE_FD_PASSING when it was implemented.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
ef476708f3 virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_FD_PASSING
The feature implies that fd passing works with RPC. Non-remote impls
thus should always report support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
5c95340100 virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER
The fix was on RPC level so everything should advertise it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
963ac787c4 virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_TYPED_PARAM_STRING
This was a lockout to make strings in typed parameters compatible with
versions which didn't have them. Now all drivers need to expose this
capability.

This namely enables it for 'esx' and 'vz' drivers, while they don't seem
to be implementing any parameters for now, they might later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
0a6335cd22 virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE_(CLOSE|EVENT)_CALLBACK
They are features of the RPC; drivers must say that it's not supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
d56f6360b6 virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_PROGRAM_KEEPALIVE
keepalive is a RPC feature, drivers must say that it's not supported.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
c7f2d0e7b1 virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE
VIR_DRV_FEATURE_REMOTE is a special flag which is asserted only when the
connection is remote. All drivers implementing it must return 0 for it
to work. Handle it in the global handler and add a comment why.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Peter Krempa
f24a22315b driver: Introduce global driver feature flag handling function
The 'virDrvFeature' has a combination of features which are asserted by
the specific driver and features which are actually global.

In many cases the implementation was cargo-culted into newer drivers
without re-assesing whether it makes sense.

This patch introduces a global function which will specifically handle
these global flags and defer the rest to the driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-17 13:15:46 +01:00
Jiri Denemark
f3c2b321e0 qemu: Fix crash at the end of migration
The destination daemon would crash in Finish phase due to NULL
dereference which I missed in my review of commit
v8.0.0-428-g0301db44e2

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-17 10:17:19 +01:00
Nikolay Shirokovskiy
096e3c72ec qemu: fix excluding disk from internal inactive snapshot
'qemuDomainSnapshotForEachQcow2Raw' doesn't properly handle the
'VIR_DOMAIN_SNAPSHOT_LOCATION_NONE' setting and thus doesn't skip disks
which were excluded from the snapshot due to being read-only.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-02-16 16:28:20 +03:00
Michal Privoznik
4b6240adc2 openrc: Make init scripts executable on install
When installing openrc init scripts, we take whatever mode the
generated files are in an copy them under /etc/init.d/. This is
not ideal, because those files are not executable and they should
be.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/250
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-16 10:09:39 +01:00
Kristina Hanicova
65312001bd libxl: use virDomainJobData instead of virDomainJobInfo
This transition will make it easier for me to generalize jobs in
the future as they will always use virDomainJobData and
virDomainJobInfo will be only used in the public api..

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-02-15 12:20:45 +01:00
Kristina Hanicova
0301db44e2 qemu: make separate function for setting statsType of privateData
We only need to set statsType in almost every case of setting
something from private data, so it seems unnecessary to pull
privateData out of current / completed job for just this one
thing every time. I think this patch keeps the code cleaner
without variables used just once.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-02-15 12:20:45 +01:00
Kristina Hanicova
f304de0df6 qemu: use generalized virDomainJobData instead of qemuDomainJobInfo
This patch includes:
* introducing new files: src/hypervisor/domain_job.c and src/hypervisor/domain_job.h
* new struct virDomainJobData, which is almost the same as
  qemuDomainJobInfo - the only differences are moving qemu specific
  job stats into the qemuDomainJobDataPrivate and adding jobType
  (possibly more attributes in the future if needed).
* moving qemuDomainJobStatus to the domain_job.h and renaming it
  as virDomainJobStatus
* moving and renaming qemuDomainJobStatusToType
* adding callback struct virDomainJobDataPrivateDataCallbacks
  taking care of allocation, copying and freeing of private data
  of virDomainJobData
* adding functions for virDomainJobDataPrivateDataCallbacks for
  qemu hypervisor
* adding 'public' (public between the different hypervisors) functions
  taking care of init, copy, free of virDomainJobData
* renaming every occurrence of qemuDomainJobInfo *info to
  virDomainJobData *data

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2022-02-15 12:20:45 +01:00
Peter Krempa
5b5162072c qemuhotplugmock: Mock fd passing to qemu via 'SCM_RIGHTS'
We don't want to be dealing with real FDs thus we mock
'qemuMonitorIOWriteWithFD' to do the same thing as when no FD is being
passed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-15 09:32:23 +01:00
Peter Krempa
654486bd57 syntax-check: sc_avoid_write: Don't use blanket file exceptions
Adding an exception for the whole file usually defeats the purpose of a
syntax check and is also likely to get forgotten once the file is
removed.

In case of the suggestion of using 'safewrite' instead of write even the
comment for safewrite states that the function needs to be used only in
certain cases.

Remove the blanket exceptions for files and use an exclude string
instead. The only instance where we keep the full file exception is for
src/libvirt-stream.c as there are multiple uses in example code in
comments where I couldn't find a nicer targetted wapproach.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-15 09:32:23 +01:00
Peter Krempa
7c35c483ea qemu: monitor: Move declaration of struct _qemuMonitor to qemu_monitor_priv.h
In order to mock the SCM_RIGHTS sendmsg to simulate sending
filedescriptors to fake qemu in tests we need access to some fields of
'struct _qemuMonitor'. Move its declaration to the private header file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-15 09:32:23 +01:00
Peter Krempa
f9ae469a6e qemu: Make 'struct _qemuMonitorMessage' private
Move the declaration of the struct into 'qemu_monitor_priv.h' as other
code has no business in peeking into the monitor messages.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-15 09:32:23 +01:00
Peter Krempa
c5eb99a9d9 qemu: monitor: Drop old monitor fields from 'struct _qemuMonitorMessage'
The fields are no longer used since we've deleted support for HMP-only
qemus. The HMP command pass-through works via a QMP command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-15 09:32:23 +01:00
Peter Krempa
a572a285ab qemu: command: Inline qemuBuildDiskFrontendAttributeErrorPolicy
Commit dc481f11a6 which converted the function generating properties
for disk '-device' argument to JSON removed the only other use of
qemuBuildDiskFrontendAttributeErrorPolicy, so we can now inline it into
qemuBuildDriveStr.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-15 09:28:57 +01:00
Peter Krempa
f923620031 qemuBuildTPMCommandLine: Use 'qemuPassFD' infrastructure
Remove the last code path using hardcoded fdsets.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-14 13:14:00 +01:00
Peter Krempa
4225de7c73 qemuBuildTPMOpenBackendFDs: Construct 'cancel_path' internally
Since 'cancel_path' is constructed from the 'tpmdev' argument, we can
push it down into the function opening the FDs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-14 13:14:00 +01:00
Peter Krempa
d42be77208 virTPMCreateCancelPath: Refactor value returning
Automatically free 'path' inside the loop which fills it and return the
values directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-14 13:14:00 +01:00