kvm: libkvm: export a new function to disable irqchip creation
    
    Signed-off-by: Qing He <[EMAIL PROTECTED]>
    Signed-off-by: Yaozu (Eddie) Dong <[EMAIL PROTECTED]>
---
 user/kvmctl.c |   25 ++++++++++++++++++-------
 user/kvmctl.h |   10 ++++++++++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/user/kvmctl.c b/user/kvmctl.c
index 8038245..f79d935 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -66,6 +66,9 @@ struct kvm_context {
        int dirty_pages_log_all;
        /// memory regions parameters
        struct kvm_memory_region mem_regions[KVM_MAX_NUM_MEM_REGIONS];
+       /// do not create in-kernel irqchip if set
+       int no_irqchip_creation;
+       /// in-kernel irqchip status
        int irqchip_in_kernel;
 };
 
@@ -187,6 +190,7 @@ kvm_context_t kvm_init(struct kvm_callbacks
*callbacks,
        kvm->callbacks = callbacks;
        kvm->opaque = opaque;
        kvm->dirty_pages_log_all = 0;
+       kvm->no_irqchip_creation = 0;
        memset(&kvm->mem_regions, 0, sizeof(kvm->mem_regions));
 
        return kvm;
@@ -205,6 +209,11 @@ void kvm_finalize(kvm_context_t kvm)
        free(kvm);
 }
 
+void kvm_disable_irqchip_creation(kvm_context_t kvm)
+{
+       kvm->no_irqchip_creation = 1;
+}
+
 int kvm_create_vcpu(kvm_context_t kvm, int slot)
 {
        long mmap_size;
@@ -290,13 +299,15 @@ int kvm_create(kvm_context_t kvm, unsigned long
memory, void **vm_mem)
        close(zfd);
 
        kvm->irqchip_in_kernel = 0;
-       r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_IRQCHIP);
-       if (r > 0) {    /* kernel irqchip supported */
-               r = ioctl(fd, KVM_CREATE_IRQCHIP);
-               if (r >= 0)
-                       kvm->irqchip_in_kernel = 1;
-               else
-                       printf("Create kernel PIC irqchip failed\n");
+       if (!kvm->no_irqchip_creation) {
+               r = ioctl(kvm->fd, KVM_CHECK_EXTENSION,
KVM_CAP_IRQCHIP);
+               if (r > 0) {    /* kernel irqchip supported */
+                       r = ioctl(fd, KVM_CREATE_IRQCHIP);
+                       if (r >= 0)
+                               kvm->irqchip_in_kernel = 1;
+                       else
+                               printf("Create kernel PIC irqchip
failed\n");
+               }
        }
        r = kvm_create_vcpu(kvm, 0);
        if (r < 0)
diff --git a/user/kvmctl.h b/user/kvmctl.h
index 6fecd56..608ee14 100644
--- a/user/kvmctl.h
+++ b/user/kvmctl.h
@@ -94,6 +94,16 @@ kvm_context_t kvm_init(struct kvm_callbacks
*callbacks,
 void kvm_finalize(kvm_context_t kvm);
 
 /*!
+ * \brief Disable the in-kernel IRQCHIP creation
+ *
+ * In-kernel irqchip is enabled by default. If userspace irqchip is to
be used,
+ * this should be called prior to kvm_create().
+ *
+ * \param kvm Pointer to the kvm_context
+ */
+void kvm_disable_irqchip_creation(kvm_context_t kvm);
+
+/*!
  * \brief Create new virtual machine
  *
  * This creates a new virtual machine, maps physical RAM to it, and
creates a

Attachment: kvm-libkvm-no-irqchip-creation.patch
Description: kvm-libkvm-no-irqchip-creation.patch

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to