[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 07/13] kvm: Add Mirror VM ioctl and enable cap interfaces.
From: |
Ashish Kalra |
Subject: |
[RFC PATCH 07/13] kvm: Add Mirror VM ioctl and enable cap interfaces. |
Date: |
Mon, 16 Aug 2021 13:29:11 +0000 |
From: Ashish Kalra <ashish.kalra@amd.com>
Add VM ioctl and enable cap support for Mirror VM's and
a new VM file descriptor for Mirror VM's in KVMState.
The VCPU ioctl interface for Mirror VM works as it is,
as it uses a CPUState and VCPU file descriptor allocated
and setup for mirror vcpus.
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
accel/kvm/kvm-all.c | 23 +++++++++++++++++++++++
include/sysemu/kvm.h | 14 ++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 0125c17edb..4bc5971881 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -149,6 +149,7 @@ struct KVMState
uint64_t kvm_dirty_ring_bytes; /* Size of the per-vcpu dirty ring */
uint32_t kvm_dirty_ring_size; /* Number of dirty GFNs per ring */
struct KVMDirtyRingReaper reaper;
+ int mirror_vm_fd;
};
KVMState *kvm_state;
@@ -3003,6 +3004,28 @@ int kvm_vm_ioctl(KVMState *s, int type, ...)
return ret;
}
+int kvm_mirror_vm_ioctl(KVMState *s, int type, ...)
+{
+ int ret;
+ void *arg;
+ va_list ap;
+
+ if (!s->mirror_vm_fd) {
+ return 0;
+ }
+
+ va_start(ap, type);
+ arg = va_arg(ap, void *);
+ va_end(ap);
+
+ trace_kvm_vm_ioctl(type, arg);
+ ret = ioctl(s->mirror_vm_fd, type, arg);
+ if (ret == -1) {
+ ret = -errno;
+ }
+ return ret;
+}
+
int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)
{
int ret;
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index a1ab1ee12d..6847ffcdfd 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -255,6 +255,8 @@ int kvm_ioctl(KVMState *s, int type, ...);
int kvm_vm_ioctl(KVMState *s, int type, ...);
+int kvm_mirror_vm_ioctl(KVMState *s, int type, ...);
+
int kvm_vcpu_ioctl(CPUState *cpu, int type, ...);
/**
@@ -434,6 +436,18 @@ int kvm_vm_check_extension(KVMState *s, unsigned int
extension);
kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \
})
+#define kvm_mirror_vm_enable_cap(s, capability, cap_flags, ...) \
+ ({ \
+ struct kvm_enable_cap cap = { \
+ .cap = capability, \
+ .flags = cap_flags, \
+ }; \
+ uint64_t args_tmp[] = { __VA_ARGS__ }; \
+ size_t n = MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \
+ memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \
+ kvm_mirror_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \
+ })
+
#define kvm_vcpu_enable_cap(cpu, capability, cap_flags, ...) \
({ \
struct kvm_enable_cap cap = { \
--
2.17.1
- [RFC PATCH 00/13] Add support for Mirror VM., Ashish Kalra, 2021/08/16
- [RFC PATCH 01/13] machine: Add mirrorvcpus=N suboption to -smp, Ashish Kalra, 2021/08/16
- [RFC PATCH 02/13] hw/boards: Add mirror_vcpu flag to CPUArchId, Ashish Kalra, 2021/08/16
- [RFC PATCH 03/13] hw/i386: Mark mirror vcpus in possible_cpus, Ashish Kalra, 2021/08/16
- [RFC PATCH 04/13] hw/acpi: Don't include mirror vcpus in ACPI tables, Ashish Kalra, 2021/08/16
- [RFC PATCH 05/13] cpu: Add boolean mirror_vcpu field to CPUState, Ashish Kalra, 2021/08/16
- [RFC PATCH 06/13] hw/i386: Set CPUState.mirror_vcpu=true for mirror vcpus, Ashish Kalra, 2021/08/16
- [RFC PATCH 07/13] kvm: Add Mirror VM ioctl and enable cap interfaces.,
Ashish Kalra <=
- [RFC PATCH 08/13] kvm: Add Mirror VM support., Ashish Kalra, 2021/08/16
- [RFC PATCH 09/13] kvm: create Mirror VM and share primary VM's encryption context., Ashish Kalra, 2021/08/16
- [RFC PATCH 10/13] softmmu/cpu: Skip mirror vcpu's for pause, resume and synchronization., Ashish Kalra, 2021/08/16
- [RFC PATCH 11/13] kvm/apic: Disable in-kernel APIC support for mirror vcpu's., Ashish Kalra, 2021/08/16
- [RFC PATCH 12/13] hw/acpi: disable modern CPU hotplug interface for mirror vcpu's, Ashish Kalra, 2021/08/16
- [RFC PATCH 13/13] hw/i386/pc: reduce fw_cfg boot cpu count taking into account mirror vcpu's., Ashish Kalra, 2021/08/16
- Re: [RFC PATCH 00/13] Add support for Mirror VM., Claudio Fontana, 2021/08/16
- Re: [RFC PATCH 00/13] Add support for Mirror VM., Paolo Bonzini, 2021/08/16