Commit Graph

1212 Commits

Author SHA1 Message Date
Peter Krempa
d53e75aad0 conf: Introduce 'absolute' clock offset
The 'absolute' clock offset type has a 'start' attribute which is an
unix epoch timestamp to which the hardware clock is always set at start
of the VM.

This is useful if some VM needs to be kept set to an arbitrary time for
e.g. testing or working around broken software.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-17 19:30:59 +02:00
Jonathon Jongsma
f135fdabab Rename virDomainGraphicsSpiceMouseMode to virDomainMouseMode
This enumeration will be useful for vnc with the upcoming qemu-vdagent
device so make the name more generic.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-10 11:00:15 -05:00
Andrea Bolognani
a8682ab791 drivers: Group global features together
All these features are supposed to be handled by the call to
virDriverFeatureIsGlobal() placed right above the switch
statement, so if any of them is actually encountered inside
the switch statement it means there's a bug in the driver and
we should report an error.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-07 18:59:08 +02:00
Michal Privoznik
19a5b054ac lib: Use virReportSystemError() more
Instead of reporting virReportError(..., g_strerror(), ...) let's
use proper virReportSystemError(). Generated with help of cocci:

  @@
  expression c;
  @@
      <...
  -   virReportError(c,
  +   virReportSystemError(errno,
                         ...,
  -                      g_strerror(errno),
                         ...);
      ...>

But then I had to hand fix format strings, because I'm not sure
if cocci even knows how to do that. And even if it did, I surely
don't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-04-07 12:11:22 +02:00
Kristina Hanicova
44f0b63dbc libxl: use virDomainJob enum instead of libxlDomainJob
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-25 13:41:06 +01:00
Kristina Hanicova
a193f4bef6 move jobs enums QEMU_X into hypervisor as VIR_X
These enums are essentially the same and always sorted in the
same order in every hypervisor with jobs. They can be generalized
by using the qemu enums as the main ones as they are the most
extensive.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-25 13:40:56 +01:00
Michal Privoznik
cac9608c17 libxl: Turn on user aliases
When I implemented user aliases I've invented this
virDomainDefFeatures flag so that individual drivers can signal
support for user provided aliases. The reasoning was that a
device alias might be part of guest ABI, or used in a different
way then in QEMU. Well, neither applies to the libxl driver, so
it's safe to allow user aliases there.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/231
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2022-03-03 11:53:30 +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
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
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
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
Tim Wiederhake
621fa350ab libxl: Use automatic memory management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-11 11:03:47 +01:00
Jim Fehlig
18ec405a36 libxl: Release auto-allocated spice ports
While VNC ports auto-allocated by the libxl driver are released in
libxlDomainCleanup, spice ports are overlooked. Rework the existing
logic to release any auto-allocated graphics ports, not just the VNC
port of the first graphics device.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-08 10:40:40 -07:00
Michal Privoznik
87a43a907f lib: Use g_clear_pointer() more
This change was generated using the following spatch:

  @ rule1 @
  expression a;
  identifier f;
  @@
    <...
  - f(*a);
    ... when != a;
  - *a = NULL;
  + g_clear_pointer(a, f);
    ...>

  @ rule2 @
  expression a;
  identifier f;
  @@
    <...
  - f(a);
    ... when != a;
  - a = NULL;
  + g_clear_pointer(&a, f);
    ...>

Then, I left some of the changes out, like tools/nss/ (which
doesn't link with glib) and put back a comment in
qemuBlockJobProcessEventCompletedActiveCommit() which coccinelle
decided to remove (I have no idea why).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-08 08:42:07 +01:00
Jim Fehlig
e0241f334d libxl: Set auto-allocated graphics ports to used on reconnect
The libxl driver reconnects to all running VMs when libvirtd is restarted,
but it failed to mark auto-allocated graphics ports as set in the port
allocator. If many VMs are running that use port auto-allocation and
libvirtd is restarted, the port allocator is likely to hand out a port
already in use when a new VM is created that uses auto-allocation. VM
creation will fail due to the port clash.

When reconnecting to running VMs after a libvirtd restart, let the port
allocator know about previously allocated ports.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-02-07 13:30:35 -07:00
Andrea Bolognani
7627c96cdb meson: Add missing virt_install_dirs
We recently started listing these in the spec file and, since we
were not creating them during the installation phase, that broke
RPM builds.

Fixes: 4b43da0bff
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-02 16:26:36 +01:00
Andrea Bolognani
29b64dc610 meson: Sort virt_install_dirs
This will make subsequent patches nicer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-02-02 16:26:35 +01:00
Michal Privoznik
2c0898ff4e src: Use g_steal_pointer() more
There are few places where the g_steal_pointer() is open coded.
Switch them to calling the g_steal_pointer() function instead.
Generated by the following spatch:

  @ rule1 @
  expression a, b;
  @@
    <...
  - b = a;
    ... when != b
  - a = NULL;
  + b = g_steal_pointer(&a);
    ...>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-02-01 19:01:49 +01:00
Peter Krempa
f468f0a634 systemd: Use correct man page name in modular daemon service files
The service files were copied out of the service file for libvirtd and
the name of the corresponding manpage was not fixed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2045959
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-02-01 13:20:11 +01:00
Ján Tomko
4d5f82ee7b libxl: assume LIBXL_HAVE_PVUSB
Introduced in Xen 4.7 by commit:
  commit bf7628f087b212052a0e9f024044b2790c33f820
    libxl: add pvusb API

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-31 20:38:53 +01:00
Ján Tomko
c282edb782 libxl: assume LIBXL_HAVE_SRM_V2
Introduced in Xen 4.6.0 by:
  commit 3a9ace0147d48af49ffd34628f9510f248f2f588
    tools/libxc+libxl+xl: Restore v2 streams

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-31 20:38:53 +01:00
Ján Tomko
8ac22ba17e libxl: remove LIBXL_ATTR_UNUSED
Unused as of:
  commit 446d091498
    libxl: pass driver config to libxlMakeDomBuildInfo

All other usage of LIBXL_HAVE_DEVICE_CHANNEL was removed by:
  commit e58004d70a
    Xen: Remove unneeded LIBXL_HAVE_* ifdefs

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-31 20:38:53 +01:00
Ján Tomko
247813acd1 libxl: assume LIBXL_HAVE_DEVICE_BACKEND_DOMNAME
Introduced in 4.3.0 by xen commit:

  commit ef496b81f0336f09968a318e7f81151dd4f5a0cc
    libxl: postpone backend name resolution

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-31 20:38:53 +01:00
Michal Privoznik
82e902ddcc conf: Fix @mode member of _virDomainTimerDef struct
The @mode member of the _virDomainTimerDef struct stores
values of the virDomainTimerModeType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:24 +01:00
Michal Privoznik
10eb597137 conf: Fix @track member of _virDomainTimerDef struct
The @track member of the _virDomainTimerDef struct stores
values of the virDomainTimerTrackType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:22 +01:00
Michal Privoznik
96d72b461f conf: Fix @tickpolicy member of _virDomainTimerDef struct
The @tickpolicy member of the _virDomainTimerDef struct stores
values of the virDomainTimerTickpolicyType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:20 +01:00
Michal Privoznik
754a7f6c94 conf: Fix type of @present in _virDomainTimerDef struct
In the _virDomainTimerDef structure we have @present member which
is like virTristateBool, except it's an integer and has values
shifted by one. This is harder to read. Retype the member to
virTristateBool which we are familiar with.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-26 10:49:18 +01:00
Jim Fehlig
31e937fb3b libxl: Add lock process indicator to saved VM state
Commit fa58f571ee added a lock processes indicator to the
libxlDomainObjPrivate struct to note that a lock process was
successfully started for the VM. However, the commit neglected to
add the indicator to the VM's saved state file. As a result, the
indicator is lost on libvirtd restart, along with the knowledge of
whether a lock process was started for the VM.

This change adds support for the indicator in the domainObjPrivate
data parse and format callbacks, ensuring its value survives libvirtd
restarts.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-25 08:50:19 -07:00
Michal Privoznik
0eb42087c7 conf: Convert virDomainDefParseBootXML() to virXMLProp*()
After previous cleanups, the virDomainDefParseBootXML() function
uses a mixture of virXMLProp*() and the old virXMLPropString() +
virXXXTypeFromString() patterns. Rework it so that virXMLProp*()
is used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-21 16:42:14 +01:00
Olaf Hering
8eb4461645 remove sysconfig files
sysconfig files are owned by the admin of the host. They have the
liberty to put anything they want into these files. This makes it
difficult to provide different built-in defaults.

Remove the sysconfig file and place the current desired default into
the service file.

Local customizations can now go either into /etc/sysconfig/name
or /etc/systemd/system/name.service.d/my-knobs.conf

Attempt to handle upgrades in libvirt.spec.
Dirty files which are marked as %config will be renamed to file.rpmsave.
To restore them automatically, move stale .rpmsave files away, and
catch any new rpmsave files in %posttrans.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-17 18:20:59 +01:00
Michal Privoznik
7b9cebac22 libxl: Remove needless labels
After previous cleanups some labels are needless: they contain
nothing but a return statement. Drop such labels and return
directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
d90cb8ff10 xen_xl.c: Use g_autoptr() for virCPUDef
In xenParseXLVnuma() the @cpu variable is freed explicitly.
However, when switched to g_autoptr(virCPUDef) the explicit call
can be removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
ef7f01b6d0 xen_xl.c: Use g_autofree more
There are few places inside src/libxl/xen_xl.c that can benefit
from g_autofree. Let them use automatic memory freeing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
2645c66a6c libxl: Allocate @libxldisk in xenParseXLDisk() on stack
In xenParseXLDisk() the @libxldisk variable (which is type of
libxl_device_disk) is allocated on heap. But this is not
necessary as nothing in the function needs that approach.

Allocate the variable on the stack and drop corresponding
VIR_FREE() call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
5a1bdcfbf0 libxl: Don't use a static buffer in xenParseXLVnuma()
The xenParseXLVnuma() function is responsible for parsing 'vnuma'
part of XL config and setting corresponding values in
virDomainDef. While doing so it uses a static buffer which is set
to data we are interested in and then parsing the buffer further
(e.g. string to integer conversion, bitmap parsing, and so on).
Well, the data we are interested in are already in a string
(@data) which can be used directly rendering this intermediary
buffer needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
17c324bd25 virconf: Make virConfSetValue() clear consumed pointer
The way that virConfSetValue() works (and the way it is even
documented) is that the @value pointer is always consumed.
However, since the first order pointer is passed it leaves
callers in a pickle situation - they always have to set pointer
to NULL after calling virConfSetValue() to avoid touching it.

Let's switch @value to a double pointer and clear it inside the
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
94ce37c8e2 src: Declare and use g_autoptr(virConfValue)
This commit declares g_autoptr() function for virConfValue type.
At the same time, it switches variable declarations to use it.
Also, in a few places we might have freed a variable twice, for
instance in xenFormatXLDomainNamespaceData(). This is because
virConfSetValue() consumes passed pointer (@value) even in case
of failure and thus any code that uses virConfSetValue() must
refrain from touching @value and it must not call
virConfFreeValue().

This semantic is not obvious and will be addressed in one of
future commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
8b12f6af0b xen_xl: Check for virConfSetValue() retval
There's one case where the return value of virConfSetValue() is
not checked for and it's in xenFormatXLInputDevs() function.
Let's fix that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:45 +01:00
Michal Privoznik
ad051d2a74 storage_file: Declare virStorageSourceParseRBDColonString only in one header
The virStorageSourceParseRBDColonString() function is declared in
src/storage_file/storage_source.h and
src/storage_file/storage_source_backingstore.h but implemented
only in the .c that corresponds to the latter header file.
Therefore, drop declaration from storage_source.h as the function
is not implemented in its corresponding .c file.

Leftover from: 2d29a3a9d8
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-01-17 09:53:44 +01:00
Ani Sinha
974a777f1e do not report generic OPERATION_FAILED error when calling virConnectOpenAuth()
virConnectOpenAuth() calls virConnectOpenInternal(). This later function
generates fine grained errors arising from various failure conditions that are
more accurate than a "catch all" broader VIR_ERR_OPERATION_FAILED error that
the callers of this function generates. Remove the broader error so that more
specific errors can be caught and processed.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-07 16:58:25 +01:00
Jim Fehlig
cbae4eaa19 libxl: Implement domainGetMessages API
Since commit 46783e6307, the 'virsh dominfo' command calls
virDomainGetMessages to report any messages from the domain.
Hypervisors not implementing the API now get the following
libvirtd log message when clients invoke 'virsh dominfo'

this function is not supported by the connection driver: virDomainGetMessages

Although libxl currently does not support any tainting or
deprecation messages, provide an implementation to squelch
the previously unseen error message when collecting dominfo.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-14 08:55:36 -07:00
Ján Tomko
7d825985b4 Remove empty cleanup sections
After recent cleanups, there are some pointless cleanup sections.

Clean them up.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 14:44:01 +01:00
Ján Tomko
eb52b9f8af Use g_auto for stealing virCaps
Convert all the functions that generate virCaps to use g_auto
and g_steal_pointer.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 14:44:01 +01:00
Peter Krempa
9566576c02 libxlDomainGetNumaParameters: Don't clear a freshly allocated bitmap
The bitmap is allocated just above the explicit clear, so it's already
empty.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
e4b00827ed libxl_driver: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Michal Privoznik
4cf9f43f1d lib: Drop some needless labels
After previous cleanups some labels became needless because they
contain just a return statement. There's no point in having such
labels.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-03 17:19:35 +01:00
Michal Privoznik
cc2a3c2a94 lib: Use g_autoptr() for virDomainDef
Instead of calling virDomainDefFree() explicitly, we can annotate
variables with g_autoptr().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-03 17:18:26 +01:00
Ján Tomko
38929464c5 libxl: libxlLoggerFileFree: remove redundant NULL assignment
The 'file' pointer is already zeroed in virFileFclose
and never read again.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-12-03 16:23:49 +01:00
Jim Fehlig
a7a03324d8 libxl: Protect access to libxlLogger files hash table
The hash table of log file objects in libxlLogger is not protected against
concurrent access. It is possible for one thread to remove an entry while
another is updating it. Add a mutex to the libxlLogger object and lock it
when accessing the files hash table.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-02 11:34:49 -07:00
Jim Fehlig
5c5df5310f libxl: Search for virDomainObj in event handler threads
libxl can deliver events and invoke callbacks on any application thread
calling into libxl. This can cause deadlock in the libvirt libxl driver

Thread 19 (Thread 0x7f31411ec700 (LWP 14068) "libvirtd"):
#0  0x00007f318520cc7d in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007f3185205ed5 in pthread_mutex_lock () from /lib64/libpthread.so.0
#2  0x00007f3189488015 in virMutexLock (m=<optimized out>) at ../../src/util/virthread.c:79
#3  0x00007f3189463f3b in virObjectLock (anyobj=<optimized out>) at ../../src/util/virobject.c:433
#4  0x00007f31894f2f41 in virDomainObjListSearchID (payload=0x7f317400a6d0, name=<optimized out>, data=0x7f31411eaeac) at ../../src/conf/virdomainobjlist.c:105
#5  0x00007f3189437ac5 in virHashSearch (ctable=0x7f3124025a30, iter=iter@entry=0x7f31894f2f30 <virDomainObjListSearchID>, data=data@entry=0x7f31411eaeac, name=name@entry=0x0) at ../../src/util/virhash.c:745
#6  0x00007f31894f3919 in virDomainObjListFindByID (doms=0x7f3124025430, id=<optimized out>) at ../../src/conf/virdomainobjlist.c:121
#7  0x00007f3152f292e5 in libxlDomainEventHandler (data=0x7f3124023d80, event=0x7f310c010ae0) at ../../src/libxl/libxl_domain.c:660
#8  0x00007f3152c6ff5d in egc_run_callbacks (egc=egc@entry=0x7f31411eaf50) at libxl_event.c:1427
#9  0x00007f3152c718bd in libxl__egc_cleanup (egc=0x7f31411eaf50) at libxl_event.c:1458
#10 libxl__ao_inprogress (ao=ao@entry=0x7f310c00b8a0, file=file@entry=0x7f3152cce987 "libxl_domain.c", line=line@entry=730, func=func@entry=0x7f3152ccf750 <__func__.22238> "libxl_domain_unpause") at libxl_event.c:2047
#11 0x00007f3152c8c5b8 in libxl_domain_unpause (ctx=0x7f3124015a40, domid=<optimized out>, ao_how=ao_how@entry=0x0) at libxl_domain.c:730
#12 0x00007f3152f2a584 in libxl_domain_unpause_0x041200 (domid=<optimized out>, ctx=<optimized out>) at /usr/include/libxl.h:1756
#13 libxlDomainStart (driver=driver@entry=0x7f3124023d80, vm=vm@entry=0x7f317400a6d0, start_paused=start_paused@entry=false, restore_fd=restore_fd@entry=-1, restore_ver=<optimized out>, restore_ver@entry=2) at ../../src/libxl/libxl_domain.c:1482
#14 0x00007f3152f2a6e3 in libxlDomainStartNew (driver=driver@entry=0x7f3124023d80, vm=vm@entry=0x7f317400a6d0, start_paused=start_paused@entry=false) at ../../src/libxl/libxl_domain.c:1545
#15 0x00007f3152f2a789 in libxlDomainShutdownHandleRestart (driver=0x7f3124023d80, vm=0x7f317400a6d0) at ../../src/libxl/libxl_domain.c:464
#16 0x00007f3152f2a9e4 in libxlDomainShutdownThread (opaque=<optimized out>) at ../../src/libxl/libxl_domain.c:559
#17 0x00007f3189487ee2 in virThreadHelper (data=<optimized out>) at ../../src/util/virthread.c:196
#18 0x00007f3185203539 in start_thread () from /lib64/libpthread.so.0
#19 0x00007f3184f3becf in clone () from /lib64/libc.so.6

Frame 16 runs a thread created to handle domain shutdown processing for
domid 28712. In this case the event contained the reboot reason, so the
old domain is destroyed and a new one is created by libxlDomainStart new.
After starting the domain, it is unpaused by calling libxl_domain_unpause
in frame 12. While the thread is running within libxl, libxl takes the
opportunity to deliver a pending domain shutdown event for unrelated domid
28710. While searching for the associated virDomainObj by ID, a deadlock is
encountered when attempting to lock the virDomainObj for domid 28712, which
is already locked since this thread is processing its shutdown event.

The deadlock can be avoided by moving the search for a virDomainObj
associated with the event domid to the shutdown thread. The same is done
for the death thread.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-02 11:21:10 -07:00
Jim Fehlig
b9a5faea49 libxl: Handle domain death events in a thread
Similar to domain shutdown events, processing domain death events can be a
lengthy process and we don't want to block the event handler while the
operation completes. Move the death handling function to a thread.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-02 11:21:10 -07:00
Jim Fehlig
e4f7589a3e libxl: Modify name of shutdown thread
The current thread name 'ev-<domid>' is a bit terse. Change the name
to 'shutdown-event-<domid>', allowing it to be distinguished between
thread handling other event types.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-02 11:21:10 -07:00
Jim Fehlig
a4e6fba069 libxl: Rename libxlShutdownThreadInfo struct
An upcoming change will use the struct in a thread created to process
death events. Rename libxlShutdownThreadInfo to libxlEventHandlerThreadInfo
to reflect the more generic usage.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-02 11:21:10 -07:00
Jim Fehlig
23b51d7b8e libxl: Disable death events after receiving a shutdown event
The libxl driver will handle all domain destruction and cleanup
when receiving a domain shutdown event from libxl. Commit fa30ee04a2
introduced the ignoreDeathEvent boolean in the DomainObjPrivate struct
to ignore subsequent death events from libxl. But libxl already provides
a mechanism to disable death events via libxl_evdisable_domain_death.

This patch partially reverts commit fa30ee04a2 and instead uses
libxl_evdisable_domain_death to disable subsequent death events when
processing a shutdown event.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-02 11:21:10 -07:00
Peter Krempa
690efb960f Switch away from virHashFree
Use 'g_clear_pointer(&ptr, g_hash_table_unref)' instead.

In few instances it allows us to also remove explicit clearing of
pointers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:12 +01:00
Peter Krempa
04bbaa2b1f libxlLoggerNew: Avoid virHashFree by rearranging code
Allocate the hash table only after the log file is opened so that we
don't need to deallocate it on failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Jim Fehlig
b85cef1b2d libxl: Don't derive libxlDomainObjPrivate from virObjectLockable
The libxlDomainObjPrivate object is never locked and hence does not need to
be a virObjectLockable object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-24 09:47:52 -07:00
Jim Fehlig
c6d2d2d7a5 libxl: Remove unused macros
Remove unused JOB_MASK and DEFAULT_JOB_MASK macros.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-24 09:47:04 -07:00
Michal Privoznik
6bcd263011 virDomainObjListAdd: Transfer definition ownership
Upon successful return from virDomainObjListAdd() the
virDomainObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-11-24 13:12:20 +01:00
Michal Privoznik
784e9e2b62 lib: Drop needless one line labels
In some cases we have a label that contains nothing but a return
statement. The amount of such labels rises as we use automagic
cleanup. Anyway, such labels are pointless and can be dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-11-22 12:39:59 +01:00
Michal Privoznik
7c2a4e84b7 Prefer g_auto(GStrv) over g_strfreev()
There are a few cases where a string list is freed by an explicit
call of g_strfreev(), but the same result can be achieved by
g_atuo(GStrv).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-11 16:16:17 +01:00
Michal Privoznik
2d5b403cff Use virDomainObjEndAPI() more
Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virDomainObjEndAPI() can be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-11-11 11:27:16 +01:00
Jim Fehlig
7f90b137bf libxl: Free data returned from libxl_userdata_retrieve
Found via valgrind

==15016== 3,701 bytes in 2 blocks are definitely lost in loss record 975 of 1,009
==15016==    at 0x4C2A2AF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==15016==    by 0x1FCD30CB: libxl_read_file_contents (in /usr/lib64/libxenlight.so.4.12.0)
==15016==    by 0x1FCCA58A: ??? (in /usr/lib64/libxenlight.so.4.12.0)
==15016==    by 0x1FCCA6C2: libxl_userdata_retrieve (in /usr/lib64/libxenlight.so.4.12.0)
==15016==    by 0x1FA42A5A: libxlReconnectDomain (libxl_driver.c:394)
==15016==    by 0x53BAC99: virDomainObjListHelper (virdomainobjlist.c:802)
==15016==    by 0x530842F: virHashForEach (virhash.c:575)
==15016==    by 0x53BC0E0: virDomainObjListForEach (virdomainobjlist.c:817)
==15016==    by 0x1FA423C4: libxlReconnectDomains (libxl_driver.c:468)
==15016==    by 0x1FA423C4: libxlStateInitialize (libxl_driver.c:778)
==15016==    by 0x54E8E9E: virStateInitialize (libvirt.c:657)
==15016==    by 0x12DBFA: daemonRunStateInit (remote_daemon.c:797)
==15016==    by 0x535BF79: virThreadHelper (virthread.c:206)

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-10 11:15:36 -07:00
Michal Privoznik
196e6faabd lib: Use G_N_ELEMENTS instead of sizeof()/sizeof()
For statically declared arrays one can use G_N_ELEMENTS() instead
of explicit sizeof(array) / sizeof(item). I've noticed couple of
places where the latter was used.

I am not fixing every occurrence because we have some places
which do not use glib (examples and NSS module).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-03 14:46:54 +01:00
Michal Privoznik
2996a94dd0 lib: Don't check for virCapabilitiesAddGuestDomain() retval
The virCapabilitiesAddGuestDomain() function can't fail. It
aborts on OOM. Therefore, there's no need to check for its
return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:08:26 +01:00
Michal Privoznik
c18d9e23fa lib: Don't check for virCapabilitiesAddGuest() retval
The virCapabilitiesAddGuest() function can't fail. It aborts on
OOM. Therefore, there's no need to check for its return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:05:52 +01:00
Jim Fehlig
51eb680b26 libxl: Don't autostart domains on driver reload
When libxlAutostartDomain was introduced with commit fb92307f0d, one hunk
mistakenly added a call site in libxlStateReload. Domains should not be
autostarted when reloading the driver, so remove the offending hunk.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-14 11:37:35 -06:00
Jim Fehlig
65fab900c5 libxl: Fix driver reload
On reload, the libxl driver calls virDomainObjListLoadAllConfigs to load
all configs from /etc/libvirt/libxl/ but incorrectly passes 'true' for
the liveStatus parameter, resulting in error messages such as

libvirtd[21053]: XML error: unexpected root element <domain>, expecting <domstatus>
libvirtd[21053]: Failed to load config for domain 'sles15sp3'

Fix by not requesting live status when re-reading the persistent VM config
files.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-14 11:04:46 -06:00
Jim Fehlig
b75a16ae5e libxl: Improve reporting of die_id in capabilities
On Xen, libvirt runs in a VM (typically dom0) and does not have an accurate
picture of numa and cpu topology of the underlying physical machine using
the "usual" mechanisms. numa info and cpu toplogy are retrieved from libxl
and used to populate the libvirt conterparts. Commit 7b79ee2f78 introduced
support for reporting die_id in capabilities, but did not account for
special handling of numa and cpu topology in libxl.

Currently, Xen does not report die_id in the libxl_cputopology structure.
In the meantime, set die_id to 0, which was suggested by the Xen developers
and is slightly better than random garbage such as

<cpu id='1' socket_id='0' die_id='-1073069552' core_id='0' siblings='0-1'/>

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-14 11:02:26 -06:00
Ján Tomko
fa8ce012a3 libxl: use g_auto in libxlDomainGetEmulatorType
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
d6cd7a478f libxl: use g_auto in libxlCapsNodeData
Also remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
3e4c5e20b8 libxl: refactor libxlCapsInitCPU
Use g_auto, g_steal_pointer and remove unnecessary labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
5f5d698053 libxl: capsInitCPU: fail if we can't initialize host features
Introduced by:
  commit 17322e5518
      libxl: describe host cpu features based on hwcaps
with the justification that libxl_hwcaps does not have a stable
format across all version.

Even though the code would return '0' in the case of such failure,
it frees the 'cpu' pointer, while keeping it in caps->host.
Based on that, assume it does not happen in current usage.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
6b08d4b37d libxl: remove enum libxlHwcapVersion
As well as the code probing for the version in libxlCapsInitHost.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
a8328f5222 libxl: capabilities: assume Xen version >= 4.7
Remove the code handling old Xen's hwcap words,
as well as the comment describing it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Daniel P. Berrangé
88c5b9f827 qemu, xen: add missing deps on virtlockd/virtlogd sockets
The QEMU driver uses both virtlogd and virtlockd, while the Xen driver
uses virtlockd. The libvirtd.service unit contains deps on the socket
units for these services, but these deps were missed in the modular
daemons. As a result the virtlockd/virtlogd sockets are not started
when the virtqemud/virtxend daemons are started.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-08-31 13:40:33 +01:00
Ján Tomko
5590fbf8d6 Remove redundant labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
2c426d2e30 Use g_auto for xmlFreeDoc everywhere
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
5dae71ee8c Use g_auto for xmlXPathContext everywhere
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Michal Privoznik
5c254bb541 conf: Store SCSI bus length in virDomainDef
Libvirt assumes that a SCSI bus can fit up to 8 devices
(including controller itself), except for so called wide bus
which can accommodate up to 16 devices (again, including
controller). This plays important role when computing 'drive'
address in virDomainDiskDefAssignAddress(). So far, the only
driver that enables wide SCSI bus is VMX. But with newer
releases, ESX is capable of "super wide" bus (64 devices).

We can blindly bump the limit in our code because then we would
compute address that's invalid for older ESX versions that we
still want to support.

Unfortunately, I haven't found a better place where to store this
than virDomainDef.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Olaf Hering
42158b8936 libxl: remove conditionals from discard configuration
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE exists since Xen 4.5.0

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-08-13 08:44:01 -06:00
Peter Krempa
18e65eef04 xenParseXMDisk: Use automatic memory clearing and remove 'ret' variable
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:26 +02:00
Peter Krempa
98f6f2081d util: alloc: Reimplement VIR_APPEND_ELEMENT using virAppendElement
Use virAppendElement instead of virInsertElementsN to implement
VIR_APPEND_ELEMENT which allows us to remove error handling as the
only relevant errors were removed when switching to aborting memory
allocation functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-06 08:53:25 +02:00
Tim Wiederhake
ae06bc9cfe libxlLoggerNew: virHashNew cannot return NULL
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-07-23 11:30:34 +02:00
Jim Fehlig
0d1ccad240 libxl: Add helper function for running the hook script
The same pattern of retrieving the domXML, running the hook script, and
checking for error is used throughout the libxl driver. Remove some
repetitive code by adding a helper function to perform these tasks.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
fc94e5c1c2 libxl: Introduce libxlDomainStartPerform
Introduce libxlDomainStartPerform as part of decomposing libxlDomainStart.
Perform all operations that are part of starting a domain. On error the
domain is destroyed from libxl's perspective, but the operations perfomed
in libxlDomainStartPrepare must be unwound by libxlDomainStart.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
b84d6ed2fe libxl: Introduce libxlDomainStartPrepare
Introduce libxlDomainStartPrepare as part of decomposing libxlDomainStart.
Perform all prepratory operations such as hostdevs, network devs, etc.
Also ensure all such operations are properly unwound on error.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
caed469ef5 libxl: Add a helper function to unprepare network devices
Move network device cleanup code from libxlDomainCleanup to a helper
function for use in a subsequent patch.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
572d161f10 libxl: Move managed save logic to libxlDomainStartNew
the logic to check for existence of a managed save image and use it to
start the VM can be moved to libxlDomainStartNew. libxlDomainStart has
become unwieldy and this is a small step to make it more manageable.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
8dab64bda4 libxl: Drop unused 'cfg' parameter from libxlDomainSaveImageOpen
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-07-12 14:02:18 -06:00
Jim Fehlig
e58004d70a Xen: Remove unneeded LIBXL_HAVE_* ifdefs
Now that the minimum supported Xen version has bumped to 4.9, all
uses of LIBXL_HAVE_* that are included in Xen 4.9 can be removed
from the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-21 10:43:04 -06:00
Michal Privoznik
5c359377a0 capabilities: Expose NUMA memory side cache
Memory on a NUMA node can have a side caches. Configuring these
for a domain was implemented in v6.6.0-rc1~249 and friends.
However, up until now mgmt applications did not really know what
values to pass because we were not exposing caches of the host.
With recent enough kernel these are exposed under sysfs and with
a bit of parsing we can extend our capabilities XML. The sysfs
structure is documented in kernel's
Documentation/admin-guide/mm/numaperf.rst and basically maps in
1:1 fashion to our virNumaCache structure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-06-15 10:41:22 +02:00
Jim Fehlig
07dc1ac9d2 libxl: Support firmware autoselection
Xen only supports one firmware, making autoselection easy to implement.
In fact, <os firmware='efi'> is probably preferable in the Xen driver,
where libxl supports a firmware setting with accepted values such as
bios, ovmf, uefi (currently same semantics as ovmf), seabios, etc.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-06-08 11:44:19 -06:00
Jim Fehlig
7c5507df10 libxl: Forbid domain definition with secure boot enabled
Xen+ovmf does not support secure boot. Fail domain def validation
if secure boot is enabled.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-06-08 11:43:48 -06:00
Jim Fehlig
d36be9ffe3 libxl: Introduce domain def validate callback
Introduce libxlDomainDefValidate and move the existing validation
check from libxlDomainDefPostParse. Additional validation will be
introduced in subsequent patches.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-06-08 11:42:33 -06:00
Jim Fehlig
48b9932352 libxl: adjust handling of libxl_device_nic objects
libxl objects are supposed to be initialized and disposed. Adjust
libxlMakeNic to use an already initialized object owned by the caller.

Adjust libxlMakeNicList to initialize the list of objects, before they
are filled by libxlMakeNic. The libxl_domain_config object passed to
libxlMakeNicList is owned by the caller and will be disposed with
libxl_domain_config_dispose, which also disposes embedded objects such
as libxl_device_nic.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Olaf Hering <olaf@aepfle.de>
2021-06-01 11:20:52 -06:00
Michal Privoznik
121083818e libxl: Break down an if() in libxlCapsInitNuma()
There's an if-else statement in libxlCapsInitNuma() that can
really be just two standalone if()-s. Writing it as such helps
with code readability.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-05-25 09:48:21 +02:00
Peter Krempa
7c67afce65 Replace virDomainDiskInsertPreAlloced by virDomainDiskInsert
Pre-extending the disk array size is pointless nowadays since we've
switched to memory APIs which don't return failure.

Switch all uses of reallocation of the array followed by
'virDomainDiskInsertPreAlloced' with direct virDomainDiskInsert.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-05-24 20:38:08 +02:00
Peter Krempa
92a3eddd03 Remove static analysis assertions
None of them are currently needed to pass our upstream CI, most were
either for ancient clang versions or coverity for silencing false
positives.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-05-24 20:26:20 +02:00
Michal Privoznik
4b3dc045b9 conf: Deduplicate NUMA distance code
After previous patches we have two structures:
virCapsHostNUMACellDistance and virNumaDistance which express the
same thing. And have the exact same members (modulo their names).
Drop the former in favor of the latter.

This change means that distances with value of 0 are no longer
printed out into capabilities XML, because domain XML code allows
partial distance specification and thus threats value of 0 as
unspecified by user (see virDomainNumaGetNodeDistance() which
returns the default LOCAL/REMOTE distance for value of 0).

Also, from ACPI 6.1 specification, section 5.2.17 System Locality
Distance Information Table (SLIT):

  Distance values of 0-9 are reserved and have no meaning.

Thus we shouldn't be ever reporting 0 in neither domain nor
capabilities XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-05-24 19:57:45 +02:00