Commit Graph

117 Commits

Author SHA1 Message Date
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
Ján Tomko
47d194139c ch: virCHProcessSetupIOThreads: use correct type for return value
virCHMonitorGetIOThreads returns an int, not size_t.

Also return early if it's negative, because promoting it to
an unsigned type in the for loop condition could lead to
an infinte loop.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-03 14:15:04 +01:00
Ján Tomko
7b1c1642b1 ch: virCHMonitorGetIOThreads: fix g_steal_pointer usage
Fixes: 81226d8803
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-02-03 14:15:04 +01:00
Ján Tomko
8eb7d869ed virParseVersionString: rename to virStringParseVersion
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2022-02-03 14:10:03 +01: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
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
Praveen K Paladugu
782ef1a992 ch_driver: emulator threadinfo & pinning callbacks
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Praveen K Paladugu
81226d8803 ch_process: Setup emulator and iothread settings
using virCHProcessSetupPid

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Vineeth Pillai
588a2eb719 ch_driver: add numatune callbacks for CH driver
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Vineeth Pillai
06d5055136 ch_driver: enable typed param string for numatune
Enable support of VIR_DRV_FEATURE_TYPED_PARAM_STRING to enable numatune

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Vineeth Pillai
d8343fb0ae ch_driver, ch_domain: vcpupin callback in ch driver
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Vineeth Pillai
ae34b921d9 ch: Move and rename chDomObjFromDomain()
The chDomObjFromDomain() function which currently lives as a
static one in ch_driver.c is going to be needed in other parts
of the driver. Move it into ch_domain.c, rename to
virCHDomainObjFromDomain() and expose in corresponding header
file for the rest of the driver to use.

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Vineeth Pillai
da6d4a2afc ch: methods for cgroup mgmt in ch driver
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-28 17:04:50 +01:00
Michal Privoznik
105dace22c Revert "report error when virProcessGetStatInfo() is unable to parse data"
This reverts commit 938382b60a.

Turns out, the commit did more harm than good. It changed
semantics on some public APIs. For instance, while
qemuDomainGetInfo() previously did not returned an error it does
now. While the calls to virProcessGetStatInfo() is guarded with
virDomainObjIsActive() it doesn't necessarily mean that QEMU's
PID is still alive. QEMU might be gone but we just haven't
realized it (e.g. because the eof handler thread is waiting for a
job).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2041610
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-01-20 17:51:07 +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
Ani Sinha
938382b60a report error when virProcessGetStatInfo() is unable to parse data
Currently virProcessGetStatInfo() always returns success and only logs error
when it is unable to parse the data. Make this function actually report the
error and return a negative value in this error scenario.

Fix the callers so that they do not override the error generated.
Also fix non-linux implementation of this function so as to report error.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-12 14:18:38 +01:00
Vineeth Pillai
dfb5574df6 ch_monitor: Get nicindexes in prep for cgroup mgmt
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-06 16:03:55 +01:00
Vineeth Pillai
df6d4ff4d2 ch_driver: domainGetVcpuPinInfo and nodeGetCPUMap
Add domainGetVcpuPinInfo and nodeGetCPUMap callbacks to ch driver

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-06 16:03:55 +01:00
Praveen K Paladugu
cfe0e657e1 ch_driver, ch_domain: vcpu info getter callbacks
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-06 16:03:55 +01:00
Vineeth Pillai
bfa2da4ca9 ch_domain: add methods to manage private vcpu data
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-06 16:03:55 +01:00
Vineeth Pillai
326a4ed2cb ch_domain: add virCHDomainGetMonitor helper method
Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-01-06 16:03:55 +01: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
Ján Tomko
4eaa499c8b Use g_auto for freeing virCaps
Convert all the users who unref their virCaps object unconditionally.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-13 14:44:00 +01:00
Peter Krempa
f3febf9718 virCHProcessUpdateInfo: Automatically free virJSONValue
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-07 09:00:39 +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
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
Ján Tomko
096412f1ba ch: fix logic in virCHMonitorBuildPtyJson
There is a leftover 'ptys' variable, which we only assign
to and one assignment to 'content', where we add an empty
'pty' object.

Remove 'ptys'.

Fixes: 93accefd9e
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
2021-11-23 16:59:36 +01:00
Tim Wiederhake
cf1177178e virCHDomainObjBeginJob: Cleanup
Remove unnecessary label and goto.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-08 14:32:32 +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
Michal Privoznik
42cc2f9396 ch_driver: Drop needless fwd declaration
In ch_driver.c there are two forward declarations that are not
needed. Drop them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:04:11 +01:00
William Douglas
13fc1432c6 ch: use g_auto in virCHMonitorNew
Also introduces a G_DEFINE_AUTOPTR_CLEANUP_FUNC for virCHMonitor.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
William Douglas
9e99f84328 ch: use g_auto in virCHMonitorBuildKernelRelatedJson
Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
William Douglas
2ba777f5e3 ch: use g_auto in virCHMonitorBuildMemoryJson
Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
William Douglas
08bbe36fe4 ch: remove extra unref of domain object during virCHMonitorClose()
It is already being unrefed in virCHMonitorDispose().

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
William Douglas
bfaac4c2b1 ch: Correctly ref and close the virCHMonitor in virCHMonitorNew
In virCHMontiorNew the monitor object was referenced an additional
time incorrectly preventing it from being disposed of, and wasn't
always closed properly on failure.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
William Douglas
5abf5949c1 ch_monitor: Stop leaking json value objects
In virCHMonitorBuildKernelRelatedJson there are two cases of json
value objects being lost after the pointer being redefined. This
change removes the needless redefinition.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
Ján Tomko
4a6d874946 ch: use g_auto in virCHMonitorBuildVMJson
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-23 15:32:01 +02:00
Ján Tomko
b4436cc3f5 ch: use g_auto in virCHMonitorBuildNetsJson
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-23 15:32:00 +02:00
Ján Tomko
08b943d641 ch: use g_auto in virCHMonitorBuildNetJson
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-23 15:32:00 +02:00
Ján Tomko
1149a6ddc7 ch: use g_auto in virCHMonitorBuildDisksJson
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-23 15:32:00 +02:00
Ján Tomko
48a089a964 ch: use g_auto in virCHMonitorBuildDiskJson
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-23 15:32:00 +02:00
Ján Tomko
25ffb2ce86 ch: use g_auto in virCHMonitorBuildCPUJson
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-23 15:32:00 +02:00
Tim Wiederhake
785a11cec8 Fix typos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-09-17 14:28:00 +02:00
William Douglas
c88b26a656 ch_driver: Handle validation failure correctly
When validation like deviceValidateCallback fails, the vm will not be
set and so the call to virDomainObjListRemove will be passed a NULL
pointer causing a segfault. To prevent this add a check that the vm is
defined before calling out to virDomainObjListRemove.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
d4f047dbd1 ch_driver: Add handler for console API
Enable the handler function to find and open the console character
device that will be used by the console API.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
6a77dd2b67 ch_domain: Allow controller and chr devices
With the console and serial device handling fully functional, allow
the required device types to be specified in the domain
configuration.

The configuration only supports a single serial or console device.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
d79b9a5a17 ch_process: Handle enabled console devices
Add functionality to allow libvirt console to connect to the
cloud-hypervisor created PTY associated with a VM by updating the
domain with console path information. This has to be run after the VM
is created by cloud-hypervisor.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
93accefd9e ch_monitor: Add pty json builder function
Add function to build the the json structure to configure a PTY in
cloud-hypervisor.

The devices themselves still aren't allowed in configurations yet
though.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
3b164e6897 ch_monitor: Make virCHMonitorGet function static
The virCHMonitorGet function isn't going to be used outside of the
monitor, so remove the initial declaration and define the function
to be static.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
14da5cb95a ch_monitor: Use virCHMonitorGet to access cloud-hypervisor API
Now that virCHMonitorGet is capable of handling data returned by the
cloud-hypervisor API, make use of this via virCHMonitorGetInfo to call
into the vm.info endpoint.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
e727cc8041 ch_monitor: Update virCHMonitorGet to handle accept a response
The virCHMonitorGet function needed to be able to return data from the
hypervisor. This functionality is needed in order for the driver to
support PTY enablement and getting details about the VM state.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
William Douglas
f84286c0b3 ch_domain: Add virChrdevs for console support
Add and initialize a virChrdevs to the _virCHDomainObjPrivate
structure in order to eventually track the consoles in use by a domain.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-09-09 14:51:02 +01:00
Ján Tomko
247e8fcc6a ch: monitor: unref mon->vm before vm
Do not access 'mon' after unref'ing it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:29:07 +02:00
Peter Krempa
73985cacf4 chValidateDomainDeviceDef: Remove per-device-type error messages
Vast majority of device types is not supported by the Cloud-Hypervisor
driver. Simplify the error reporting by using
virDomainDeviceTypeToString.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-06-22 13:25:23 +02:00
William Douglas
ff8557b433 ch_domain: Add handler for virDomainDeviceDefValidateCallback
Instead of trying to match devices passed in based on the monitor
detecting the number of devices that were used in the domain
definition, use the deviceValidateCallback to evaluate if
unsupported devices are used.

This allows the compiler to detect when new device types are added
that need to be checked.

Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-06-21 09:34:42 +02:00
Michal Privoznik
51ff124d9c virCHDriverConfig: Drop @uri member
This member is unused (apart from only being set in
virCHDriverConfigNew()), and never freed really (leading to a
memleak).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-06-09 11:24:59 +02:00
Daniel P. Berrangé
b4701fe648 ch: set driver to NULL after freeing it
If the chStateInitialize method fails, we call chStateCleanup
which free's all global state. It fails to set the global
'ch_driver' to NULL, however, so a later attempt to open the
cloud hypervisor driver will succeed and then crash attempting
to access freed memory.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-09 10:18:04 +01:00
Wei Liu
619968a680 ch: set shared drivers
We want to use those shared drivers provided by libvirt to avoid
implementing our own.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-06-04 16:04:15 +01:00
Michal Privoznik
da53324a79 chExtractVersion: Drop @ret
After previous patches, the @ret variable and the 'cleanup'
label are redundant. Remove them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-04 16:39:00 +02:00
Michal Privoznik
4292d4b786 chExtractVersion: use g_auto*
There are two variables that can be freed automatically: @cmd
(which allows us to drop explicit virCommandFree() call at the
end of the function) and @help which was never freed (and thus
leaked).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-04 16:39:00 +02:00
Michal Privoznik
7a90431d7d ch_driver: Don't error out if CH_CMD was not found
The CH driver needs "cloud-hypervisor" binary. And if none was
found then the initialization of the driver fails as
chStateInitialize() returns VIR_DRV_STATE_INIT_ERROR. This in
turn means that whole daemon fails to initialize. Let's return
VIR_DRV_STATE_INIT_SKIPPED in this particular case, which
disables the CH drvier but lets the daemon run.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-04 16:39:00 +02:00
Michal Privoznik
da91bdf836 ch_conf: Dissolve chExtractVersionInfo() in chExtractVersion()
After previous patches, there's not much value in
chExtractVersion(). Rename chExtractVersionInfo() to
chExtractVersion() and have it use virCHDriver directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-04 16:39:00 +02:00
Michal Privoznik
b5fcd27a08 chExtractVersionInfo: Don't check for retversion != NULL
The only caller, chExtractVersion() passes not NULL. Therefore,
it's redundant to check for NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-04 16:39:00 +02:00
Michal Privoznik
6fcbedad40 ch_conf: Move error reporting into chExtractVersionInfo()
If chExtractVersionInfo() fails, in some cases it reports error
and in some it doesn't. Fix those places and drop reporting error
from chExtractVersion() which would just overwrite more specific
error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-04 16:39:00 +02:00
William Douglas
56fbabf1a1 Add basic driver for the Cloud-Hypervisor
Cloud-Hypervisor is a KVM virtualization using hypervisor. It
functions similarly to qemu and the libvirt Cloud-Hypervisor driver
uses a very similar structure to the libvirt driver.

The biggest difference from the libvirt perspective is that the
"monitor" socket is seperated into two sockets one that commands are
issued to and one that events are notified from. The current
implementation only uses the command socket (running over a REST API
with json encoded data) with future changes to add support for the
event socket (to better handle shutdowns from inside the VM).

This patch adds support for the following initial VM actions using the
Cloud-Hypervsior API:
 * vm.create
 * vm.delete
 * vm.boot
 * vm.shutdown
 * vm.reboot
 * vm.pause
 * vm.resume

To use the Cloud-Hypervisor driver, the v15.0 release of
Cloud-Hypervisor is required to be installed.

Some additional notes:
 * The curl handle is persistent but not useful to detect ch process
 shutdown/crash (a future patch will address this shortcoming)
 * On a 64-bit host Cloud-Hypervisor needs to support PVH and so can
 emulate 32-bit mode but it isn't fully tested (a 64-bit kernel and
 32-bit userspace is fine, a 32-bit kernel isn't validated)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
2021-06-04 10:56:06 +01:00