 kvmctl.c |   24 ++++++++++++++++++++++++
 kvmctl.h |   23 +++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/user/kvmctl.c b/user/kvmctl.c
index 50f5021..51d1fc8 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -432,6 +432,30 @@ int kvm_set_irq_level(kvm_context_t kvm, int irq, int level)
 	return 1;
 }
 
+int kvm_get_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip)
+{
+	int r;
+
+	if (!kvm->irqchip_in_kernel)
+		return 0;
+	r = ioctl(kvm->vm_fd, KVM_GET_IRQCHIP, chip);
+	if (r == -1)
+		perror("kvm_get_irqchip\n");
+	return 1;
+}
+
+int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip)
+{
+	int r;
+
+	if (!kvm->irqchip_in_kernel)
+		return 0;
+	r = ioctl(kvm->vm_fd, KVM_SET_IRQCHIP, chip);
+	if (r == -1)
+		perror("kvm_set_irqchip\n");
+	return 1;
+}
+
 static int handle_io_abi10(kvm_context_t kvm, struct kvm_run_abi10 *run,
 			   int vcpu)
 {
diff --git a/user/kvmctl.h b/user/kvmctl.h
index 0c65f4e..e3e3ebf 100644
--- a/user/kvmctl.h
+++ b/user/kvmctl.h
@@ -421,4 +421,27 @@ int kvm_dirty_pages_log_reset(kvm_context_t kvm);
  */
 int kvm_irqchip_in_kernel(kvm_context_t kvm);
 
+/*!
+ * \brief Dump in kernel IRQCHIP contents
+ *
+ * Dump one of the in kernel irq chip devices, including PIC (master/slave)
+ * and IOAPIC into a kvm_irqchip structure
+ *
+ * \param kvm Pointer to the current kvm_context
+ * \param chip The irq chip device to be dumped
+ */
+int kvm_get_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip);
+
+/*!
+ * \brief Set in kernel IRQCHIP contents
+ *
+ * Write one of the in kernel irq chip devices, including PIC (master/slave)
+ * and IOAPIC
+ * 
+ *
+ * \param kvm Pointer to the current kvm_context
+ * \param chip THe irq chip device to be written
+ */
+int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip);
+
 #endif
