Commit Graph

40048 Commits

Author SHA1 Message Date
Michal Privoznik
b7d4e6b67e lib: Replace VIR_AUTOSTRINGLIST with GStrv
Glib provides g_auto(GStrv) which is in-place replacement of our
VIR_AUTOSTRINGLIST.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-02 15:43:07 +01:00
Michal Privoznik
b46ec55d53 qemuDomainGetGuestInfo: Exit early if getting info fails
If there is an error getting info from guest agent, then the
control on qemuDomainGetGuestInfo() jumps onto 'exitagent' label
and subsequently continues on 'endagentjob'. Both labels are hit
also in success case too. The control then continues by
attempting to match fetched info (e.g. disk addresses) with
domain def. But this is needless - the API will return error
regardless.

To return early from the function move both 'exitagent' and
'endagentjob' labels at the end of the function and jump straight
onto 'cleanup' afterwards. This allows us to set 'ret = 0' later
- only when we know we succeeded.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-02 15:33:53 +01:00
Daniel P. Berrangé
143d2e9bde meson: add winsock2 library on windows builds
If building for windows with curl disabled we get build failures due to
missing ws2_32 library needed for winsock2.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-12-02 12:49:05 +00:00
Daniel P. Berrangé
eeb0c9aef0 scripts: ignore whitespace in pdwtags output
The pdwtags program changed its whitespace formatting for enum
values in release 1.19:

  @@ -145,22 +145,22 @@
           u_int                      flags;
   };
   enum admin_procedure {
  -        ADMIN_PROC_CONNECT_OPEN = 1,
  -        ADMIN_PROC_CONNECT_CLOSE = 2,
  -        ADMIN_PROC_CONNECT_GET_LIB_VERSION = 3,
  -        ADMIN_PROC_CONNECT_LIST_SERVERS = 4,
  -        ADMIN_PROC_CONNECT_LOOKUP_SERVER = 5,
  +        ADMIN_PROC_CONNECT_OPEN                     = 1,
  +        ADMIN_PROC_CONNECT_CLOSE                    = 2,
  +        ADMIN_PROC_CONNECT_GET_LIB_VERSION          = 3,
  +        ADMIN_PROC_CONNECT_LIST_SERVERS             = 4,
  +        ADMIN_PROC_CONNECT_LOOKUP_SERVER            = 5,

Workaround this by telling diff to ignore whitespace changes.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-12-02 10:30:01 +00:00
Peter Krempa
3c40710f9c qemuMonitorGetCommandLineOptionParameters: remove the unused function and helpers
Remove the function along with helpers for caching the reply and tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-02 09:14:28 +01:00
Peter Krempa
bf8bd93df0 virQEMUCapsProbeQMPCommandLine: Rewrite using qemuMonitorGetCommandLineOptions
Use the new handler to fetch the required data and do the extraction
locally without conversion to string list.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-02 09:14:28 +01:00
Peter Krempa
ebeff6cd57 qemu: monitor: Implement new handlers for 'query-command-line-options'
Add a new set hander for getting the data for
'query-command-line-options' which returns everything at once and lets
the caller extract the data. This way we don't need to cache the output
of the monitor command for repeated calls.

Note that we will have enough testing of this code path via
qemucapabilitiestest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-02 09:14:28 +01:00
Peter Krempa
5dc28cc378 gitlab: Add issue template for a feature request
Try to motivate the users to describe what they want to achieve before
diving down into technical specifics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-12-02 09:11:27 +01:00
Peter Krempa
59dbdedd23 gitlab: Add issue template for reporting a bug
When reporting an issue in gitlab, the project can define a template for
various scenarios which are meant to guide the users to add the relevant
information the project needs to the reported issue.

Add a template for a bug report against libvirt. The template adds
sections which motivate users to add version information and also link
to documentation about fetching logs and such.

Note that markdown seems to be the only supported format for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-12-02 09:11:27 +01:00
Daniel Henrique Barboza
0436a14468 domain_conf.c: modernize virDomainDefControllersParse()
The 'error' label is just returning -1, so let's 'return -1'
directly.

Use g_autoptr() with virDomainControllerDefPtr to remove the
need to call virDomainControllerDefFree() in the error path.

There is no need to VIR_FREE(nodes) explictly since 'nodes'
is using g_autofree.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
491bc80d6b domain_conf.c: modernize virDomainControllerDefParseXML()
Let's register AUTOPTR_CLEANUP_FUNC for virDomainControllerDefPtr
and modernize this function, removing the 'error' label using
g_autoptr().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
6048610c7e domain_conf.c: remove 'error' label in virDomainDefTunablesParse()
The 'error' label is just doing a 'return -1'.

There's also a couple of 'VIR_FREE(nodes)' calls that are happening
right before exiting on error, but 'nodes' is already set for
autocleanup. These calls can also be removed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
7e5f031ff9 domain_conf.c: modernize virDomainSmartcardDefParseXML
Register a AUTOPTR_CLEANUP_FUNC for virDomainSmartcardDef and use
g_autoptr() to eliminate the 'error' label.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
075269d275 domain_conf: modernize virDomainDiskDefParseXML()
Register an AUTOPTR_CLEANUP_FUNC for virDomainDiskDefPtr, then
use g_autoptr() in virDomainDiskDef and virStorageEncryption
pointers to get rid of the 'cleanup' and 'error' labels.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
97b8518356 virstorageencryption.h: add AUTOPTR_CLEANUP_FUNC for virStorageEncryptionPtr
This will open an opportunity to modernize virDomainDiskDefParseXML()
in the next patch.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
af7b910c4e domain_conf.c: use g_autoptr() with virDomainVideoDefPtr
This will modernize virDomainVideoDefParseXML() and
virDomainDefAddImplicitVideo() by removing unneeded
cleanup labels.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
18d29844c6 domain_conf.c: do not leak 'video' in virDomainDefParseXML()
The 'video' pointer is only being freed on error path, meaning
that we're leaking it after each loop restart.

There are more opportunities for auto cleanups of virDomainVideoDef
pointers, so let's register AUTOPTR_CLEANUP_FUNC for it to use
g_autoptr() later on.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
0993f2f360 domain_conf.c: modernize virDomainDefBootOrderPostParse()
Use g_autoptr() with the hash and remove the 'cleanup' label.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Daniel Henrique Barboza
340db6e549 domain_conf.c: use g_autofree in 'dev' in virDomainDefParseBootXML()
This spares us of 2 explicit VIR_FREE() calls.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 19:27:17 -03:00
Ján Tomko
bac69aa1f9 testsutilsqemu: check return value of virQEMUCapsNewCopy
While for virQEMUCapsNew this should not be needed
(the possible failures in VIR_CLASS_NEW are only hit
 on bad API usage which we don't do here),
virQEMUCapsNewCopy calls into many other functions,
some of which actually fail.

Check the return value of both.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-12-01 17:25:31 +01:00
Ján Tomko
5c028697cd qemu: use qemuVirCommandGetDevSet less
Do not look up the index of the passed FD in places where
we already have it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-12-01 17:24:20 +01:00
Ján Tomko
9a20d8ac07 qemu: introduce qemuBuildFDSet
An alternative to qemuVirCommandGetFDSet that takes the index
into the passed FD set as an argument and does not try to look it up.

Use it as well ass virCommandPassFDIndex in qemuBuildChrChardevFileStr
and qemuBuildInterfaceCommandLine.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-12-01 17:24:20 +01:00
Ján Tomko
49c66026cf util: introduce virCommandPassFDIndex
Just like virCommandPassFD, but it also returns an index of
the passed FD in the FD set.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-12-01 17:24:20 +01:00
Ján Tomko
366891533f udevConnectListAllInterfaces: delete pointless cleanup code
We only jump to cleanup before allocating any lists.

Drop the dead code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-01 17:22:09 +01:00
Ján Tomko
fd5df67dce udevConnectListAllInterfaces: initialize ret
Currently, ret is only used in the 'cleanup' section
and initialized right before the jump.

Switch to the customary initialization to -1 and only
leave in the 'ret = 0' statement on an empty list.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-01 17:22:09 +01:00
Michal Privoznik
6e91453bb6 qemu: Use virJSONValueObjectGetStringArray() more
In a few commit back (v6.10.0-5-gb3dad96972) a new helper for
obtaining string arrays from a virJSONObject was introduced:
virJSONValueObjectGetStringArray(). I've identified three places
where it can be used instead of open coding it:
qemuAgentSSHGetAuthorizedKeys(),
qemuMonitorJSONGetStringListProperty() and
qemuMonitorJSONGetCPUDefinitions().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-01 17:21:14 +01:00
Michal Privoznik
043b50b948 virJSONValueObjectGetStringArray: Report error if @key is not an array
The virJSONValueObjectGetStringArray() function is given a @key
which is supposed to be an array inside given @object. Well, if
it's not then an error state is returned (NULL), but no error
message is set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-01 17:21:14 +01:00
Andrea Bolognani
ebc241fcff docs: Update language bindings spotlight
We should highlight the language bindings that are actively
maintained, keep up with the core library's development pace,
have good API coverage and are relevant to people looking to
integrate libvirt into their projects today: based on these
criteria, it makes sense to highlight the Go binding instead
of the Java one.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-01 17:06:21 +01:00
Tuguoyi
c4f4e195a1 qemu_conf: Fix double free problem for cfg->firmwares
cfg->firmwares still points to the original memory address after being
freed by virFirmwareFreeList(). As cfg get freed, it will be freed again
even if cfg->nfirmwares=0 which eventually lead to crash.

The patch fix it by setting cfg->firmwares to NULL explicitly after
virFirmwareFreeList() returns

Signed-off-by: Guoyi Tu<tu.guoyi@h3c.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-01 14:26:33 +01:00
Pavel Hrdina
0cbcd21b1f vircgroupv2: fix virCgroupV2DenyDevice
The original logic is incorrect. We would delete the device entry
from eBPF map only if the newval would be same as current val in the
map. In case that the device was allowed only as read-only but later
we remove all permissions for that device it would remain in the table
with empty values.

The old code would still deny the device but it's not working as
intended. Instead we will update the value in advance. If the updated
value is 0 it means that we are removing all permissions so it should
be removed from the map, otherwise we will update the value in map.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-01 12:46:55 +01:00
Pavel Hrdina
ed1ba69f5a vircgroup: fix cpu quota maximum limit
Kernel commit <d505b8af58912ae1e1a211fabc9995b19bd40828> added proper
check for cpu quota maximum limit to prevent internal overflow.

Even though this change is not present in all kernels it makes sense
to enforce the same limit in libvirt.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 12:41:36 +01:00
Pavel Hrdina
98a09ca48e vircgroupv2: use defines for cpu period and quota limits
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 12:41:35 +01:00
Pavel Hrdina
bc760f4d7c vircgroupv1: use defines for cpu period and quota limits
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 12:41:33 +01:00
Pavel Hrdina
a818e3f6f0 qemu: move cgroup cpu period and quota defines to vircgroup.h
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-12-01 12:41:24 +01:00
Marc-André Lureau
172b830435 virsh: add --disk informations to guestinfo command
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:52 +01:00
Marc-André Lureau
0cb2d9f05d qemu_driver: report guest disk informations
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:50 +01:00
Marc-André Lureau
05a75ca2ce domain: add disk informations to virDomainGetGuestInfo
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:46 +01:00
Marc-André Lureau
8401a586a2 qemu_agent: add qemuAgentGetDisks
guest-get-disks is available since QEMU 5.2:
https://wiki.qemu.org/ChangeLog/5.2#Guest_agent

Note that the test response was manually edited based on a reply on my
bare-metal computer. It shows partial results due to pcieport driver not
being currently supported by QGA.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:41 +01:00
Marc-André Lureau
3169db81f6 qemu: use virJSONValueObjectGetStringArray
There might be more potential users around, I haven't looked thoroughly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:39 +01:00
Marc-André Lureau
b3dad96972 util: json: add virJSONValueObjectGetStringArray convenience
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:37 +01:00
Marc-André Lureau
c6fcb75f77 qemu_agent: factor out qemuAgentGetDiskAddress
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:35 +01:00
Marc-André Lureau
f534eae275 qemu_agent: export qemuAgentDiskAddressFree & add g_auto
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:32 +01:00
Marc-André Lureau
7b1bebdf3d qemu_agent: rename qemuAgentDiskInfo->qemuAgentDiskAddress
To match the QGA schema name (we are introducing a qemuAgentDiskInfo
struct again for different purpose).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:21 +01:00
Jiri Denemark
38dfd3e80e Post-release version bump to 7.0.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2020-12-01 09:54:20 +01:00
Jiri Denemark
e27603980a Release of libvirt-6.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2020-12-01 09:51:03 +01:00
Peter Krempa
08ae9e5f40 NEWS: Mention network disk support in 'virsh attach-disk'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-30 08:48:32 +01:00
Daniel P. Berrangé
5d789c7b37 NEWS: add note about virt-ssh-helper perf improvements
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-27 16:40:55 +00:00
Roman Bolshakov
78999beabc qemucapsprobemock: Fix lookup of qemu functions
qemucapsprobemock can't find real versions of qemuMonitorSend() and
qemuMonitorJSONIOProcessLine() on macOS. That breaks qemucapsprobe.

The failure can be explained by documented behaviour of dlsym(3) on
macOS:

  If dlsym() is called with the special handle RTLD_NEXT, then dyld
  searches for the symbol in the dylibs the calling image linked against
  when built.

  [...] For flat linked images, the search starts in the load ordered
  list of all images, in the image right after the caller's image.

That means qemucapsprobemock must be linked against qemu test driver to
find symbols there with RTLD_NEXT.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-27 16:31:50 +01:00
Roman Bolshakov
11e67a2910 tests: Delay mock creation
There might be mocks that need to reference qemu test driver and link
with it. It's not possible now because qemu test driver is defined after
mocks.

While at it, add 'link_with' parameter to mock definition that allows to
specify a set of libraries the mock has to be linked with.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-27 16:31:36 +01:00
Roman Bolshakov
82256eaa4a ci: Run test suite on macOS
There's no need to have different CI process between macOS and FreeBSD
as test suite has been fixed on macOS.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-27 16:31:30 +01:00