qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH] kvm: add set_one_reg/get_one_reg
Date: Wed, 18 Sep 2013 14:21:58 +1000	[thread overview]
Message-ID: <1379478118-20448-1-git-send-email-aik@ozlabs.ru> (raw)

This adds QEMU wrappers for KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctls.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 include/sysemu/kvm.h |  4 ++++
 kvm-all.c            | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index c7bc07b..b2d61e9 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -319,4 +319,8 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
 void kvm_pc_gsi_handler(void *opaque, int n, int level);
 void kvm_pc_setup_irq_routing(bool pci_enabled);
 void kvm_init_irq_routing(KVMState *s);
+
+int kvm_set_one_reg(CPUState *cs, uint64_t id, void *addr);
+int kvm_get_one_reg(CPUState *cs, uint64_t id, void *addr);
+
 #endif
diff --git a/kvm-all.c b/kvm-all.c
index ded7fc8..c24ab76 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -34,6 +34,7 @@
 #include "exec/address-spaces.h"
 #include "qemu/event_notifier.h"
 #include "trace.h"
+#include "qemu/error-report.h"
 
 /* This check must be after config-host.h is included */
 #ifdef CONFIG_EVENTFD
@@ -2049,3 +2050,33 @@ int kvm_on_sigbus(int code, void *addr)
 {
     return kvm_arch_on_sigbus(code, addr);
 }
+
+int kvm_set_one_reg(CPUState *cs, uint64_t id, void *addr)
+{
+    struct kvm_one_reg reg = {
+        .id = id,
+        .addr = (uintptr_t)addr,
+    };
+    int ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
+
+    if (ret) {
+        error_report("Unable to set reg#0x%"PRIx64" to KVM: %m\n", id);
+    }
+
+    return ret;
+}
+
+int kvm_get_one_reg(CPUState *cs, uint64_t id, void *addr)
+{
+    struct kvm_one_reg reg = {
+        .id = id,
+        .addr = (uintptr_t)addr,
+    };
+    int ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
+
+    if (ret) {
+        error_report("Unable to get reg#0x%"PRIx64" from KVM: %m\n", id);
+    }
+
+    return ret;
+}
-- 
1.8.4.rc4

             reply	other threads:[~2013-09-18  4:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18  4:21 Alexey Kardashevskiy [this message]
2013-09-18  7:14 ` [Qemu-devel] [PATCH] kvm: add set_one_reg/get_one_reg Peter Maydell
2013-09-18  7:46   ` Alexey Kardashevskiy
2013-09-18  7:59     ` Peter Maydell
2013-09-18  8:08       ` Alexey Kardashevskiy
2013-09-18  8:15         ` Paolo Bonzini
2013-09-18  8:15         ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379478118-20448-1-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=agraf@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).