Commit Graph

804 Commits

Author SHA1 Message Date
Michal Privoznik
27a653b893 virDomainControllerDef: Convert 'type' field to proper enum type
Convert the field and fill in missing cases to switch()
statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-15 10:35:06 +02:00
Michal Privoznik
f7534c2573 src: Drop needless typecast to virDomainDiskBus
The 'bus' member of _virDomainDiskDef is already declared of
virDomainDiskModel type. Hence, there is no need to typecast the
variable when passing to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-09-15 10:34:52 +02:00
Michal Privoznik
b7c3bb0a84 vbox: Move error messages onto a single line
Error messages are exempt from the 80 columns rule. Move them
onto one line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2023-09-04 09:35:36 +02:00
Michal Privoznik
b20a5e9a4d lib: use struct zero initializer instead of memset
This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Generated using the following semantic patch:

  @@
  type T;
  identifier X;
  @@
  -  T X;
  +  T X = { 0 };
     ... when exists
  (
  -  memset(&X, 0, sizeof(X));
  |
  -  memset(&X, 0, sizeof(T));
  )

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
2023-08-03 16:41:19 +02:00
Daniel P. Berrangé
a315070047 src: remove After=local-fs.target from systemd units
All services are ordered after local-fs.target unless they have set
DefaultDependencies=no, which we do not do.

https://gitlab.com/libvirt/libvirt/-/issues/489
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-07-20 10:58:00 +01:00
Andrea Bolognani
32f772e986 meson: Use initconfdir
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-05 15:08:25 +02:00
Peter Krempa
5b738195a2 virStringParseVersion: Parse into 'unsigned long long'
Phase out 'unsigned long'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-03 09:19:06 +02:00
Jiri Denemark
7d2d1cc705 vbox: Update format strings in translated messages
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-04-01 11:40:35 +02:00
Ján Tomko
4be3ba0226 vbox: unify "unable to get hard disk id" message
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:41 +01:00
Ján Tomko
161e21018a vbox: remove unreachable error in virVBoxSnapshotConfSaveVboxFile
Both callers in the VirtualBox driver handle the error and only
call this function with a non-NULL argument.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Ján Tomko
d2a430f90a vbox: remove unreachable error in virVBoxSnapshotConfLoadVboxFile
Both callers in the VirtualBox driver error out if the path
can't be fetched via VirtualBox APIs and abort on conversion error
from UTF-16 to UTF-8.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-20 14:32:40 +01:00
Michal Privoznik
b76b6a6169 vbox: Stop reporting RC in error messages
As shown in the commit that introduced vboxReportError(), we are
appending the retval of a failed VirtualBox API onto our error
messages. Well, this is no longer needed because
vboxReportError() already appends the VirtualBox error in plain
text.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:48 +01:00
Michal Privoznik
bde1890b63 vbox: Move error messages onto a single line
Our coding style suggests error messages to be on a single line
for easier git grep. Since I'm touching them anyways, let's make
them follow our own suggestion.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:44 +01:00
Michal Privoznik
3d8bd1fbe3 vbox: Replace virReportError() with vboxReportError()
Now that we have vboxReportError() which reports VirtualBox
errors too, we can switch the code to use the former. And since
the vboxReportError() is designed to behave exactly like
virReportError() we can do that almost everywhere, regardless of
the source of the error.

There are a few exceptions though, for instance, when
initializing VirtualBox SDK (we don't have all the objects needed
for querying exceptions yet), or when invalid combination of
arguments was passed to an API of ours, or when a function from
other module (e.g. src/conf/) failed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:41 +01:00
Michal Privoznik
70983f4f53 vbox: Introduce vboxReportError()
When a VirtualBox API fails it produced an exception. Until now,
we did not have correct APIs wired up to get the exception and
its error message. Thus, we were left with plain:

  virReportError("virtualbox API failed, rc=%08x", rc);

This is not very user friendly because those rc values are hard
to parse (e.g. some values are defined as a sum of a base value
and some other value) and also it expects users to know where to
look.

But now that we have all machinery needed for querying
exceptions, vboxReportError() can be introduced. The aim is to
query VirtualBox exceptions and append them after the error
message we intent to report. If the exception can't be queried
successfully, this behaves exactly like virReportError().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:38 +01:00
Michal Privoznik
ab37a858eb vbox: Introduce vboxUniformedPFN::ClearException()
The ClearException() method clears the latest exception inside of
VirtualBox. This needed because obtaining an exception via
GetException() does not clear it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:35 +01:00
Michal Privoznik
52aefc9d31 vbox: Introduce vboxUniformedPFN::GetException()
The GetException() method can be used to obtain the latest
exception that occurred in VirtualBox. Calling the method does
not reset the exception though. For that we'll need to call
another method (introduced in following commit).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:33 +01:00
Michal Privoznik
2a690fc172 vbox: Introduce IVirtualBoxErrorInfo interface
The IVirtualBoxErrorInfo interface allows us to query error
messages from VirtualBox. Since VirtualBox has stacked errors we
need the GetNext() method too.

The odd one, that sticks out is GetIID() as it is not part of the
interface as defined by VirtualBox header files. BUT, we need to
get the interface UUID (which MAY change across each release) so
that it can be passed to VBOX_QUERY_INTERFACE() introduced
earlier.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:30 +01:00
Michal Privoznik
d4b6aa6305 vbox: Introduce VBOX_QUERY_INTERFACE()
So far we haven't needed to use a different interface for objects
we are working with. We were happy with calling their respective
vtbl callbacks. Well, this will change soon as we will query an
exception (type of nsIException) but will need to promote it to
IVirtualBoxErrorInfo class. This promoting is done by
QueryInterface() callback which accepts 3 arguments: the original
object, ID of the new interface and address where to store the
promoted object.

As this is very basic operation, available to every object, it is
part of the ISupports interface among with other goodies like
AddRef() and Release().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:45:26 +01:00
Michal Privoznik
106d795faf vbox: Add support for version 7.0 SDK
As advertised in previous commit that added the SDK header file,
there were some changes to the API:

1) IVirtualBox::OpenMachine() and IVirtualBox::CreateMachine()
   now have @password argument to deal with password protected
   settings files. Well, we don't have that wired now (and we
   don't create such files). If we ever want to support user
   settings files that are password protected (e.g. via
   virSecret) we can wire this argument. For now, just pass NULL.

2) IMachine::GetAudioAdapter() is gone. But it can be replaced
   with IMachine::GetAudioSettings() + IMachine::GetAdapter()
   combo.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/419
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:23 +01:00
Michal Privoznik
3ffb5742cb vbox: add version 7.0 CAPI header
Notable changes in the API:

- Both IVirtualBox::OpenMachine() and
  IVirtualBox::CreateMachine() have new @password argument for
  password protected settings files.

- The IMachine::GetAudioAdapter() function is gone and to be
  replaced with IMachine::GetAudioSettings() +
  IMachine::GetAdapter() combo.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:18 +01:00
Michal Privoznik
90178989c6 vbox: Rename #include guard macro in header files
To avoid including a header file more than once, either:

  #pragma once

can be used, or the older trick (that vbox still uses):

  #ifndef MACRO
  # define MACRO

Well, vbox still uses the latter and in its 7.0 release the macro
was renamed from ___VirtualBox_CXPCOM_h to ___VirtualBox_CAPI_h.
Now, ideally, we wouldn't touch those header files for older
versions, but we need to use the same macro across all header
files (because vbox_tmpl.c includes corresponding vbox_CAPI_XXX.h
and then includes vbox_XPCOMCGlue.h which in turn includes
vbox_CAPI_v6_1.h to get the basic typedefs).

Instead of changing the newer 7.0 header file (and having to
change all subsequent versions), let's change the old ones and as
we drop support for them, we can forget this ever happened.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:13 +01:00
Michal Privoznik
c4b19a0e40 vbox: Drop @networkName from UIDHCPServer::Start()
The @networkName argument of UIDHCPServer::Start() callback is
unused. Drop it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:10 +01:00
Michal Privoznik
aad22bea70 vbox: Drop support for virtualbox-6.0.0
According to VirtualBox download page [1], the 6.0.0 release is
no longer supported (the support ended 2020/07). Drop it from
Libvirt too.

1: https://www.virtualbox.org/wiki/Download_Old_Builds

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:07 +01:00
Michal Privoznik
445549af07 vbox: Drop support for virtualbox-5.2.0
According to VirtualBox download page [1], the 5.2.0 release is
no longer supported (the support ended 2020/07). Drop it from
Libvirt too.

1: https://www.virtualbox.org/wiki/Download_Old_Builds

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:05 +01:00
Michal Privoznik
8a96d7b363 vbox: Drop UIUSBCommon::GetEnabled()
The UIUSBCommon::GetEnabled() function is not needed really, as
it sets a boolean to true and always succeeds. We can live
without the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:02 +01:00
Michal Privoznik
18b7857426 vbox: Drop UIUSBCommon::Enable()
The UIUSBCommon::Enable() function is no longer needed as it is a
NOP. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:24:00 +01:00
Michal Privoznik
6f0ed13b52 vbox: Drop @data and @name from UIHost::CreateHostOnlyNetworkInterface()
The @data and @name arguments of
UIHost::CreateHostOnlyNetworkInterface() callback are unused.
Drop them and also their propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:23:57 +01:00
Michal Privoznik
d983405ea2 vbox: Drop @iid from UISession::OpenExisting()
The @iid argument of UISession::OpenExisting() callback is
unused. Drop it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:23:55 +01:00
Michal Privoznik
22073dfc58 vbox: Drop @iid from UISession::Open()
The @iid argument of UISession::Open() callback is unused. Drop
it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:23:53 +01:00
Michal Privoznik
8bf9fc0032 vbox: Drop @iid from UIMachine::LaunchVMProcess()
The @iid argument of UIMachine::LaunchVMProcess() callback is
unused. Drop it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:23:51 +01:00
Michal Privoznik
ee383c7126 vbox: Drop @mediaChangeOnly from vboxDomainAttachDeviceImpl()
The @mediaChangeOnly argument of vboxDomainAttachDeviceImpl()
function is unused. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:23:49 +01:00
Michal Privoznik
015a04555f vbox: Drop misleading G_GNUC_UNUSED annotation
There are few cases where a function argument is marked as
unused, but it's used later in the function. The majority of such
occurrences are in vbox_tmpl.c as a residue of older vbox
versions, but a pair was found in vbox_common.c too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-24 10:23:46 +01:00
Michal Privoznik
3f4f0ef47d vbox: Fix starting domains
When starting a VirtualBox domain, we try to guess which frontend
to use. While the whole algorithm looks a bit outdated, it may
happen that we tell VirtualBox to use "gui" frontend, but not
which DISPLAY= to use.

I haven't found any documentation on the algorithm we use, but if
I make us fallback onto DISPLAY=:0 when no other configuration is
found then I'm able to start my guests just fine.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-23 16:16:11 +01:00
Michal Privoznik
aee2653c00 vbox: Fix memleak in _virtualboxCreateMachine()
The _virtualboxCreateMachine() function allocates
@createFlagsUtf16 but never frees it.

==12481== 236 bytes in 2 blocks are definitely lost in loss record 2,060 of 2,216
==12481==    at 0x48407E5: malloc (vg_replace_malloc.c:393)
==12481==    by 0xB6C6D1B: RTStrToUtf16Tag (utf-8.cpp:1033)
==12481==    by 0xB4DB500: _virtualboxCreateMachine (vbox_tmpl.c:634)
==12481==    by 0xB4E68A3: vboxDomainDefineXMLFlags (vbox_common.c:1976)
==12481==    by 0x4C7DF83: virDomainDefineXMLFlags (libvirt-domain.c:6666)
==12481==    by 0x13C2DA: remoteDispatchDomainDefineXMLFlags (remote_daemon_dispatch_stubs.h:5271)
==12481==    by 0x13C265: remoteDispatchDomainDefineXMLFlagsHelper (remote_daemon_dispatch_stubs.h:5252)
==12481==    by 0x4AD9DF7: virNetServerProgramDispatchCall (virnetserverprogram.c:428)
==12481==    by 0x4AD9931: virNetServerProgramDispatch (virnetserverprogram.c:302)
==12481==    by 0x4AE28AC: virNetServerProcessMsg (virnetserver.c:135)
==12481==    by 0x4AE2972: virNetServerHandleJob (virnetserver.c:155)
==12481==    by 0x49BC275: virThreadPoolWorker (virthreadpool.c:164)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-01-23 16:16:07 +01:00
Peter Krempa
df570882cd storage|test|vbox: Implement support for validating storage volume XMLs
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-11-01 13:07:20 +01:00
Peter Krempa
1eb67d24de conf: network: Provide only virNetworkDefParse
Replace virNetworkDefParseString/File by direct calls to
virNetworkDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-10-06 10:54:25 +02:00
Peter Krempa
2a166e6c12 conf: storage: Provide only virStorageVolDefParse
Remove the virStorageVolDefParseFile/String shim functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-10-06 10:54:24 +02:00
Peter Krempa
3761a67625 virVBoxSnapshotConfGet(RW|RO)DisksPathsFromLibvirtXML: Refactor
virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML and
virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML were doing the same
thing, except for one XPath query.

Factor out the common code into a helper and bring it up to modern
standard.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-10-06 10:54:24 +02:00
Peter Krempa
366cb6d35a vbox: snapshot_conf: Don't allocate XPath context explicitly
Use the one provided via virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-10-06 10:54:24 +02:00
Peter Krempa
0c5378bc07 util: xml: Expose all arguments of virXMLParseHelper in virXMLParse macro
The generic helper also has helper code to validate the root element and
create an XPath context. Many places in the code duplicate code for
doing these operations.

Extend the helper to provide all arguments and fix all callers.

In many cases this patch refactors the passing of the 'validate'
field into a separate variable to avoid quirky looking arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-10-06 10:54:24 +02:00
Kristina Hanicova
84e9fd068c conf: extend xmlopt with job config & add job object into domain object
This patch adds the generalized job object into the domain object
so that it can be used by all drivers without the need to extract
it from the private data.

Because of this, the job object needs to be created and set
during the creation of the domain object. This patch also extends
xmlopt with possible job config containing virDomainJobObj
callbacks, its private data callbacks and one variable
(maxQueuedJobs).

This patch includes:
* addition of virDomainJobObj into virDomainObj (used in the
  following patches)
* extending xmlopt with job config structure
* new function for freeing the virDomainJobObj

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2022-09-07 12:06:18 +02:00
Laine Stump
8e71e5b10e vbox: replace explicit virNetworkDefFree() with g_autoptr(virNetworkDef)
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-24 12:22:47 -04:00
Peng Liang
3ef307cb9b vbox: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-16 06:43:57 +02:00
Rohit Kumar
911c3cb2f0 conf: Convert def->os.loader->nvram a virStorageSource
Currently, libvirt allows only local filepaths to specify the location
of the 'nvram' image. Changing it to virStorageSource type will allow
supporting remote storage for nvram.

Signed-off-by: Prerna Saxena <prerna.saxena@nutanix.com>
Signed-off-by: Florian Schmidt <flosch@nutanix.com>
Signed-off-by: Rohit Kumar <rohit.kumar3@nutanix.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Rohit Kumar <rohit.kumar3@nutanix.com>
2022-06-14 14:39:55 +02:00
Ján Tomko
ad318a6c12 vbox: SnapshotConfAllChildren: reduce scope of tempSize
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-05-25 15:10:02 +02:00
Peter Krempa
f7ed8d929f vboxSetBootDeviceOrder: Remove whitespace alignment in VIR_DEBUG statements
Don't try to align the output, it's not future-proof and it's for
debugging only.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-08 09:32:47 +02:00
Tim Wiederhake
61d51f2d15 vbox_common: Use automatic mutex management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-05 15:59:08 +02:00
Peter Krempa
c250ab90ac conf: snapshot: Remove VIR_DOMAIN_SNAPSHOT_PARSE_DISKS flag
All callers except the one in the 'esx' driver pass the flag. The 'esx'
driver has a check that 'def->ndisks' is zero after parsing the
definition. This means that we can simply always parse the disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-11 13:55:50 +01:00
Tim Wiederhake
f9c863237f vbox: Use automatic mutex management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-11 16:03:26 +01:00