thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 6aebc271d95f9c59cb63c923b6ce35f16fce10e4 Mon Sep 17 00:00:00 2001
ed5979
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
Date: Mon, 16 Jan 2023 07:17:23 -0500
ed5979
Subject: [PATCH 30/31] KVM: keep track of running ioctls
ed5979
ed5979
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
RH-MergeRequest: 138: accel: introduce accelerator blocker API
ed5979
RH-Bugzilla: 1979276
ed5979
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
ed5979
RH-Acked-by: David Hildenbrand <david@redhat.com>
ed5979
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ed5979
RH-Commit: [2/3] f566f81dda26ae733008f32261ecd1253ec1796d (eesposit/qemu-kvm)
ed5979
ed5979
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979276
ed5979
ed5979
commit a27dd2de68f37ba96fe164a42121daa5f0750afc
ed5979
Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
Date:   Fri Nov 11 10:47:57 2022 -0500
ed5979
ed5979
    KVM: keep track of running ioctls
ed5979
ed5979
    Using the new accel-blocker API, mark where ioctls are being called
ed5979
    in KVM. Next, we will implement the critical section that will take
ed5979
    care of performing memslots modifications atomically, therefore
ed5979
    preventing any new ioctl from running and allowing the running ones
ed5979
    to finish.
ed5979
ed5979
    Signed-off-by: David Hildenbrand <david@redhat.com>
ed5979
    Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
    Message-Id: <20221111154758.1372674-3-eesposit@redhat.com>
ed5979
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
ed5979
ed5979
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
---
ed5979
 accel/kvm/kvm-all.c | 7 +++++++
ed5979
 1 file changed, 7 insertions(+)
ed5979
ed5979
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
ed5979
index f99b0becd8..ff660fd469 100644
ed5979
--- a/accel/kvm/kvm-all.c
ed5979
+++ b/accel/kvm/kvm-all.c
ed5979
@@ -2310,6 +2310,7 @@ static int kvm_init(MachineState *ms)
ed5979
     assert(TARGET_PAGE_SIZE <= qemu_real_host_page_size());
ed5979
 
ed5979
     s->sigmask_len = 8;
ed5979
+    accel_blocker_init();
ed5979
 
ed5979
 #ifdef KVM_CAP_SET_GUEST_DEBUG
ed5979
     QTAILQ_INIT(&s->kvm_sw_breakpoints);
ed5979
@@ -3014,7 +3015,9 @@ int kvm_vm_ioctl(KVMState *s, int type, ...)
ed5979
     va_end(ap);
ed5979
 
ed5979
     trace_kvm_vm_ioctl(type, arg);
ed5979
+    accel_ioctl_begin();
ed5979
     ret = ioctl(s->vmfd, type, arg);
ed5979
+    accel_ioctl_end();
ed5979
     if (ret == -1) {
ed5979
         ret = -errno;
ed5979
     }
ed5979
@@ -3032,7 +3035,9 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)
ed5979
     va_end(ap);
ed5979
 
ed5979
     trace_kvm_vcpu_ioctl(cpu->cpu_index, type, arg);
ed5979
+    accel_cpu_ioctl_begin(cpu);
ed5979
     ret = ioctl(cpu->kvm_fd, type, arg);
ed5979
+    accel_cpu_ioctl_end(cpu);
ed5979
     if (ret == -1) {
ed5979
         ret = -errno;
ed5979
     }
ed5979
@@ -3050,7 +3055,9 @@ int kvm_device_ioctl(int fd, int type, ...)
ed5979
     va_end(ap);
ed5979
 
ed5979
     trace_kvm_device_ioctl(fd, type, arg);
ed5979
+    accel_ioctl_begin();
ed5979
     ret = ioctl(fd, type, arg);
ed5979
+    accel_ioctl_end();
ed5979
     if (ret == -1) {
ed5979
         ret = -errno;
ed5979
     }
ed5979
-- 
ed5979
2.31.1
ed5979