2021-05-12 10:01:31 -07:00
|
|
|
/*
|
|
|
|
* Copyright Intel Corp. 2020-2021
|
|
|
|
*
|
|
|
|
* ch_monitor.h: header file for managing Cloud-Hypervisor interactions
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
#include "virobject.h"
|
2021-09-08 11:01:18 -07:00
|
|
|
#include "virjson.h"
|
2021-05-12 10:01:31 -07:00
|
|
|
#include "domain_conf.h"
|
2023-10-10 16:42:57 -05:00
|
|
|
#include "ch_conf.h"
|
2021-05-12 10:01:31 -07:00
|
|
|
|
|
|
|
#define URL_ROOT "http://localhost/api/v1"
|
|
|
|
#define URL_VMM_SHUTDOWN "vmm.shutdown"
|
|
|
|
#define URL_VM_CREATE "vm.create"
|
|
|
|
#define URL_VM_DELETE "vm.delete"
|
|
|
|
#define URL_VM_BOOT "vm.boot"
|
|
|
|
#define URL_VM_SHUTDOWN "vm.shutdown"
|
|
|
|
#define URL_VM_REBOOT "vm.reboot"
|
|
|
|
#define URL_VM_Suspend "vm.pause"
|
|
|
|
#define URL_VM_RESUME "vm.resume"
|
2021-09-08 11:01:18 -07:00
|
|
|
#define URL_VM_INFO "vm.info"
|
2024-03-11 09:43:57 +00:00
|
|
|
#define URL_VM_SAVE "vm.snapshot"
|
|
|
|
#define URL_VM_RESTORE "vm.restore"
|
2021-05-12 10:01:31 -07:00
|
|
|
|
2022-01-25 16:19:54 +00:00
|
|
|
#define VIRCH_THREAD_NAME_LEN 16
|
|
|
|
|
2024-08-05 14:40:54 +00:00
|
|
|
#define CH_NET_ID_PREFIX "net"
|
|
|
|
|
2022-01-25 16:19:54 +00:00
|
|
|
typedef enum {
|
|
|
|
virCHThreadTypeEmulator,
|
|
|
|
virCHThreadTypeVcpu,
|
|
|
|
virCHThreadTypeIO,
|
|
|
|
virCHThreadTypeMax
|
|
|
|
} virCHThreadType;
|
|
|
|
|
|
|
|
typedef struct _virCHMonitorCPUInfo virCHMonitorCPUInfo;
|
|
|
|
|
|
|
|
struct _virCHMonitorCPUInfo {
|
|
|
|
int cpuid;
|
|
|
|
pid_t tid;
|
|
|
|
|
|
|
|
bool online;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virCHMonitorEmuThreadInfo virCHMonitorEmuThreadInfo;
|
|
|
|
|
|
|
|
struct _virCHMonitorEmuThreadInfo {
|
|
|
|
char thrName[VIRCH_THREAD_NAME_LEN];
|
|
|
|
pid_t tid;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virCHMonitorIOThreadInfo virCHMonitorIOThreadInfo;
|
|
|
|
|
|
|
|
struct _virCHMonitorIOThreadInfo {
|
|
|
|
char thrName[VIRCH_THREAD_NAME_LEN];
|
|
|
|
pid_t tid;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virCHMonitorThreadInfo virCHMonitorThreadInfo;
|
|
|
|
|
|
|
|
struct _virCHMonitorThreadInfo {
|
|
|
|
virCHThreadType type;
|
|
|
|
|
|
|
|
union {
|
|
|
|
virCHMonitorCPUInfo vcpuInfo;
|
|
|
|
virCHMonitorEmuThreadInfo emuInfo;
|
|
|
|
virCHMonitorIOThreadInfo ioInfo;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-05-12 10:01:31 -07:00
|
|
|
typedef struct _virCHMonitor virCHMonitor;
|
|
|
|
|
|
|
|
struct _virCHMonitor {
|
|
|
|
virObjectLockable parent;
|
|
|
|
|
|
|
|
CURL *handle;
|
|
|
|
|
|
|
|
char *socketpath;
|
|
|
|
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
virDomainObj *vm;
|
2022-01-25 16:19:54 +00:00
|
|
|
|
|
|
|
size_t nthreads;
|
|
|
|
virCHMonitorThreadInfo *threads;
|
2021-05-12 10:01:31 -07:00
|
|
|
};
|
|
|
|
|
2024-03-11 09:43:58 +00:00
|
|
|
virCHMonitor *virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg);
|
2021-05-12 10:01:31 -07:00
|
|
|
void virCHMonitorClose(virCHMonitor *mon);
|
2021-10-01 11:12:37 -07:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCHMonitor, virCHMonitorClose);
|
2021-05-12 10:01:31 -07:00
|
|
|
|
2021-12-10 20:34:41 +00:00
|
|
|
|
2024-01-16 15:25:43 -06:00
|
|
|
int virCHMonitorCreateVM(virCHDriver *driver, virCHMonitor *mon);
|
2021-05-12 10:01:31 -07:00
|
|
|
int virCHMonitorBootVM(virCHMonitor *mon);
|
|
|
|
int virCHMonitorShutdownVM(virCHMonitor *mon);
|
|
|
|
int virCHMonitorRebootVM(virCHMonitor *mon);
|
|
|
|
int virCHMonitorSuspendVM(virCHMonitor *mon);
|
|
|
|
int virCHMonitorResumeVM(virCHMonitor *mon);
|
2024-03-11 09:43:57 +00:00
|
|
|
int virCHMonitorSaveVM(virCHMonitor *mon, const char *to);
|
|
|
|
int virCHMonitorRestoreVM(virCHMonitor *mon, const char *from);
|
2021-09-08 11:01:18 -07:00
|
|
|
int virCHMonitorGetInfo(virCHMonitor *mon, virJSONValue **info);
|
2021-12-10 20:34:41 +00:00
|
|
|
|
|
|
|
void virCHMonitorCPUInfoFree(virCHMonitorCPUInfo *cpus);
|
|
|
|
int virCHMonitorGetCPUInfo(virCHMonitor *mon,
|
|
|
|
virCHMonitorCPUInfo **vcpus,
|
|
|
|
size_t maxvcpus);
|
2022-01-25 16:19:54 +00:00
|
|
|
size_t virCHMonitorGetThreadInfo(virCHMonitor *mon, bool refresh,
|
|
|
|
virCHMonitorThreadInfo **threads);
|
2022-01-25 16:19:58 +00:00
|
|
|
int virCHMonitorGetIOThreads(virCHMonitor *mon,
|
|
|
|
virDomainIOThreadInfo ***iothreads);
|
2024-01-16 15:25:43 -06:00
|
|
|
int
|
2024-08-05 14:40:54 +00:00
|
|
|
virCHMonitorBuildNetJson(virDomainNetDef *netdef,
|
|
|
|
int netindex,
|
|
|
|
char **jsonstr);
|