* [PATCH 3/3] usermode for in kernel PIC live migration support
@ 2007-07-25 10:14 He, Qing
[not found] ` <37E52D09333DE2469A03574C88DBF40F048EAA-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: He, Qing @ 2007-07-25 10:14 UTC (permalink / raw)
To: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 5361 bytes --]
This patch is the usermode part of the in-kernel PIC live migration
support. It saves the in kernel PIC using the original usermode PIC
savevm, so it is safe to save a vm using kernel PIC and restore as a vm
using userspace PIC, and vice versa.
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Qing He <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
qemu/hw/i8259.c | 78
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
user/kvmctl.c | 24 +++++++++++++++++
user/kvmctl.h | 23 ++++++++++++++++
3 files changed, 125 insertions(+)
diff --git a/qemu/hw/i8259.c b/qemu/hw/i8259.c
index 117340c..7e7c8e0 100644
--- a/qemu/hw/i8259.c
+++ b/qemu/hw/i8259.c
@@ -465,9 +465,80 @@ static uint32_t elcr_ioport_read(void *opaque,
uint32_t addr1)
return s->elcr;
}
+#ifdef USE_KVM
+#include "qemu-kvm.h"
+extern int kvm_allowed;
+extern kvm_context_t kvm_context;
+
+static void kvm_kernel_pic_save_to_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kvm_get_irqchip(kvm_context, &chip);
+ kpic = &chip.chip.pic;
+
+ s->last_irr = kpic->last_irr;
+ s->irr = kpic->irr;
+ s->imr = kpic->imr;
+ s->isr = kpic->isr;
+ s->priority_add = kpic->priority_add;
+ s->irq_base = kpic->irq_base;
+ s->read_reg_select = kpic->read_reg_select;
+ s->poll = kpic->poll;
+ s->special_mask = kpic->special_mask;
+ s->init_state = kpic->init_state;
+ s->auto_eoi = kpic->auto_eoi;
+ s->rotate_on_auto_eoi = kpic->rotate_on_auto_eoi;
+ s->special_fully_nested_mode = kpic->special_fully_nested_mode;
+ s->init4 = kpic->init4;
+ s->elcr = kpic->elcr;
+ s->elcr_mask = kpic->elcr_mask;
+}
+
+static void kvm_kernel_pic_load_from_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kpic = &chip.chip.pic;
+
+ kpic->last_irr = s->last_irr;
+ kpic->irr = s->irr;
+ kpic->imr = s->imr;
+ kpic->isr = s->isr;
+ kpic->priority_add = s->priority_add;
+ kpic->irq_base = s->irq_base;
+ kpic->read_reg_select = s->read_reg_select;
+ kpic->poll = s->poll;
+ kpic->special_mask = s->special_mask;
+ kpic->init_state = s->init_state;
+ kpic->auto_eoi = s->auto_eoi;
+ kpic->rotate_on_auto_eoi = s->rotate_on_auto_eoi;
+ kpic->special_fully_nested_mode = s->special_fully_nested_mode;
+ kpic->init4 = s->init4;
+ kpic->elcr = s->elcr;
+ kpic->elcr_mask = s->elcr_mask;
+
+ kvm_set_irqchip(kvm_context, &chip);
+}
+#endif
+
static void pic_save(QEMUFile *f, void *opaque)
{
PicState *s = opaque;
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_save_to_user(s);
+ }
+#endif
qemu_put_8s(f, &s->last_irr);
qemu_put_8s(f, &s->irr);
@@ -508,6 +579,13 @@ static int pic_load(QEMUFile *f, void *opaque, int
version_id)
qemu_get_8s(f, &s->special_fully_nested_mode);
qemu_get_8s(f, &s->init4);
qemu_get_8s(f, &s->elcr);
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_load_from_user(s);
+ }
+#endif
+
return 0;
}
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
[-- Attachment #2: kvm-live-pic-user.patch --]
[-- Type: application/octet-stream, Size: 4566 bytes --]
diff --git a/qemu/hw/i8259.c b/qemu/hw/i8259.c
index 117340c..7e7c8e0 100644
--- a/qemu/hw/i8259.c
+++ b/qemu/hw/i8259.c
@@ -465,9 +465,80 @@ static uint32_t elcr_ioport_read(void *opaque, uint32_t addr1)
return s->elcr;
}
+#ifdef USE_KVM
+#include "qemu-kvm.h"
+extern int kvm_allowed;
+extern kvm_context_t kvm_context;
+
+static void kvm_kernel_pic_save_to_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kvm_get_irqchip(kvm_context, &chip);
+ kpic = &chip.chip.pic;
+
+ s->last_irr = kpic->last_irr;
+ s->irr = kpic->irr;
+ s->imr = kpic->imr;
+ s->isr = kpic->isr;
+ s->priority_add = kpic->priority_add;
+ s->irq_base = kpic->irq_base;
+ s->read_reg_select = kpic->read_reg_select;
+ s->poll = kpic->poll;
+ s->special_mask = kpic->special_mask;
+ s->init_state = kpic->init_state;
+ s->auto_eoi = kpic->auto_eoi;
+ s->rotate_on_auto_eoi = kpic->rotate_on_auto_eoi;
+ s->special_fully_nested_mode = kpic->special_fully_nested_mode;
+ s->init4 = kpic->init4;
+ s->elcr = kpic->elcr;
+ s->elcr_mask = kpic->elcr_mask;
+}
+
+static void kvm_kernel_pic_load_from_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kpic = &chip.chip.pic;
+
+ kpic->last_irr = s->last_irr;
+ kpic->irr = s->irr;
+ kpic->imr = s->imr;
+ kpic->isr = s->isr;
+ kpic->priority_add = s->priority_add;
+ kpic->irq_base = s->irq_base;
+ kpic->read_reg_select = s->read_reg_select;
+ kpic->poll = s->poll;
+ kpic->special_mask = s->special_mask;
+ kpic->init_state = s->init_state;
+ kpic->auto_eoi = s->auto_eoi;
+ kpic->rotate_on_auto_eoi = s->rotate_on_auto_eoi;
+ kpic->special_fully_nested_mode = s->special_fully_nested_mode;
+ kpic->init4 = s->init4;
+ kpic->elcr = s->elcr;
+ kpic->elcr_mask = s->elcr_mask;
+
+ kvm_set_irqchip(kvm_context, &chip);
+}
+#endif
+
static void pic_save(QEMUFile *f, void *opaque)
{
PicState *s = opaque;
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_save_to_user(s);
+ }
+#endif
qemu_put_8s(f, &s->last_irr);
qemu_put_8s(f, &s->irr);
@@ -508,6 +579,13 @@ static int pic_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_8s(f, &s->special_fully_nested_mode);
qemu_get_8s(f, &s->init4);
qemu_get_8s(f, &s->elcr);
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_load_from_user(s);
+ }
+#endif
+
return 0;
}
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
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] usermode for in kernel PIC live migration support
[not found] ` <37E52D09333DE2469A03574C88DBF40F048EAA-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-07-25 11:24 ` Avi Kivity
[not found] ` <46A732D8.7050306-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2007-07-25 11:24 UTC (permalink / raw)
To: He, Qing; +Cc: kvm-devel
He, Qing wrote:
> This patch is the usermode part of the in-kernel PIC live migration
> support. It saves the in kernel PIC using the original usermode PIC
> savevm, so it is safe to save a vm using kernel PIC and restore as a vm
> using userspace PIC, and vice versa.
>
> Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Qing He <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
>
Looks good. Please split into separate user/ and qemu/ patches.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] usermode for in kernel PIC live migration support
[not found] ` <46A732D8.7050306-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-07-26 5:49 ` He, Qing
2007-07-26 5:56 ` He, Qing
1 sibling, 0 replies; 5+ messages in thread
From: He, Qing @ 2007-07-26 5:49 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]
Avi,
This is the updated patch for libkvm part to adapt get/set
irqchip ioctls.
Thanks,
Qing
kvm: libkvm: in-kernel irqchip get/set ioctls
This patch allows save and restore of in-kernel irqchips
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Qing He <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
----
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
[-- Attachment #2: kvm-live-pic-libkvm.patch --]
[-- Type: application/octet-stream, Size: 1820 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] usermode for in kernel PIC live migration support
[not found] ` <46A732D8.7050306-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-26 5:49 ` He, Qing
@ 2007-07-26 5:56 ` He, Qing
[not found] ` <37E52D09333DE2469A03574C88DBF40F048EB3-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
1 sibling, 1 reply; 5+ messages in thread
From: He, Qing @ 2007-07-26 5:56 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 3704 bytes --]
Avi,
This is the updated patch for the qemu part of PIC save/restore.
All the above patches are against lapic2 branch.
Thanks,
Qing
kvm: qemu: in-kernel PIC live migration support
This patch fixes the live migration of VMs with in-kernel PIC. It saves
the in-kernel PIC using the original user mode PIC savevm, so it allows
a VM with in-kernel PIC to be saved and later restored as a VM using
userspace PIC, and vice versa.
Signed-off-by: Yaozu (Eddie) Dong <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Qing He <qing.he-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
----
i8259.c | 78
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/qemu/hw/i8259.c b/qemu/hw/i8259.c
index 117340c..7e7c8e0 100644
--- a/qemu/hw/i8259.c
+++ b/qemu/hw/i8259.c
@@ -465,9 +465,80 @@ static uint32_t elcr_ioport_read(void *opaque,
uint32_t addr1)
return s->elcr;
}
+#ifdef USE_KVM
+#include "qemu-kvm.h"
+extern int kvm_allowed;
+extern kvm_context_t kvm_context;
+
+static void kvm_kernel_pic_save_to_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kvm_get_irqchip(kvm_context, &chip);
+ kpic = &chip.chip.pic;
+
+ s->last_irr = kpic->last_irr;
+ s->irr = kpic->irr;
+ s->imr = kpic->imr;
+ s->isr = kpic->isr;
+ s->priority_add = kpic->priority_add;
+ s->irq_base = kpic->irq_base;
+ s->read_reg_select = kpic->read_reg_select;
+ s->poll = kpic->poll;
+ s->special_mask = kpic->special_mask;
+ s->init_state = kpic->init_state;
+ s->auto_eoi = kpic->auto_eoi;
+ s->rotate_on_auto_eoi = kpic->rotate_on_auto_eoi;
+ s->special_fully_nested_mode = kpic->special_fully_nested_mode;
+ s->init4 = kpic->init4;
+ s->elcr = kpic->elcr;
+ s->elcr_mask = kpic->elcr_mask;
+}
+
+static void kvm_kernel_pic_load_from_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kpic = &chip.chip.pic;
+
+ kpic->last_irr = s->last_irr;
+ kpic->irr = s->irr;
+ kpic->imr = s->imr;
+ kpic->isr = s->isr;
+ kpic->priority_add = s->priority_add;
+ kpic->irq_base = s->irq_base;
+ kpic->read_reg_select = s->read_reg_select;
+ kpic->poll = s->poll;
+ kpic->special_mask = s->special_mask;
+ kpic->init_state = s->init_state;
+ kpic->auto_eoi = s->auto_eoi;
+ kpic->rotate_on_auto_eoi = s->rotate_on_auto_eoi;
+ kpic->special_fully_nested_mode = s->special_fully_nested_mode;
+ kpic->init4 = s->init4;
+ kpic->elcr = s->elcr;
+ kpic->elcr_mask = s->elcr_mask;
+
+ kvm_set_irqchip(kvm_context, &chip);
+}
+#endif
+
static void pic_save(QEMUFile *f, void *opaque)
{
PicState *s = opaque;
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_save_to_user(s);
+ }
+#endif
qemu_put_8s(f, &s->last_irr);
qemu_put_8s(f, &s->irr);
@@ -508,6 +579,13 @@ static int pic_load(QEMUFile *f, void *opaque, int
version_id)
qemu_get_8s(f, &s->special_fully_nested_mode);
qemu_get_8s(f, &s->init4);
qemu_get_8s(f, &s->elcr);
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_load_from_user(s);
+ }
+#endif
+
return 0;
}
[-- Attachment #2: kvm-live-pic-qemu.patch --]
[-- Type: application/octet-stream, Size: 2981 bytes --]
i8259.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/qemu/hw/i8259.c b/qemu/hw/i8259.c
index 117340c..7e7c8e0 100644
--- a/qemu/hw/i8259.c
+++ b/qemu/hw/i8259.c
@@ -465,9 +465,80 @@ static uint32_t elcr_ioport_read(void *opaque, uint32_t addr1)
return s->elcr;
}
+#ifdef USE_KVM
+#include "qemu-kvm.h"
+extern int kvm_allowed;
+extern kvm_context_t kvm_context;
+
+static void kvm_kernel_pic_save_to_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kvm_get_irqchip(kvm_context, &chip);
+ kpic = &chip.chip.pic;
+
+ s->last_irr = kpic->last_irr;
+ s->irr = kpic->irr;
+ s->imr = kpic->imr;
+ s->isr = kpic->isr;
+ s->priority_add = kpic->priority_add;
+ s->irq_base = kpic->irq_base;
+ s->read_reg_select = kpic->read_reg_select;
+ s->poll = kpic->poll;
+ s->special_mask = kpic->special_mask;
+ s->init_state = kpic->init_state;
+ s->auto_eoi = kpic->auto_eoi;
+ s->rotate_on_auto_eoi = kpic->rotate_on_auto_eoi;
+ s->special_fully_nested_mode = kpic->special_fully_nested_mode;
+ s->init4 = kpic->init4;
+ s->elcr = kpic->elcr;
+ s->elcr_mask = kpic->elcr_mask;
+}
+
+static void kvm_kernel_pic_load_from_user(PicState *s)
+{
+ struct kvm_irqchip chip;
+ struct kvm_ioctl_pic *kpic;
+
+ chip.chip_id = (&s->pics_state->pics[0] == s) ?
+ KVM_IRQCHIP_PIC_MASTER :
+ KVM_IRQCHIP_PIC_SLAVE;
+ kpic = &chip.chip.pic;
+
+ kpic->last_irr = s->last_irr;
+ kpic->irr = s->irr;
+ kpic->imr = s->imr;
+ kpic->isr = s->isr;
+ kpic->priority_add = s->priority_add;
+ kpic->irq_base = s->irq_base;
+ kpic->read_reg_select = s->read_reg_select;
+ kpic->poll = s->poll;
+ kpic->special_mask = s->special_mask;
+ kpic->init_state = s->init_state;
+ kpic->auto_eoi = s->auto_eoi;
+ kpic->rotate_on_auto_eoi = s->rotate_on_auto_eoi;
+ kpic->special_fully_nested_mode = s->special_fully_nested_mode;
+ kpic->init4 = s->init4;
+ kpic->elcr = s->elcr;
+ kpic->elcr_mask = s->elcr_mask;
+
+ kvm_set_irqchip(kvm_context, &chip);
+}
+#endif
+
static void pic_save(QEMUFile *f, void *opaque)
{
PicState *s = opaque;
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_save_to_user(s);
+ }
+#endif
qemu_put_8s(f, &s->last_irr);
qemu_put_8s(f, &s->irr);
@@ -508,6 +579,13 @@ static int pic_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_8s(f, &s->special_fully_nested_mode);
qemu_get_8s(f, &s->init4);
qemu_get_8s(f, &s->elcr);
+
+#ifdef USE_KVM
+ if (kvm_allowed && kvm_irqchip_in_kernel(kvm_context)) {
+ kvm_kernel_pic_load_from_user(s);
+ }
+#endif
+
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] usermode for in kernel PIC live migration support
[not found] ` <37E52D09333DE2469A03574C88DBF40F048EB3-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-07-26 8:12 ` Avi Kivity
0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2007-07-26 8:12 UTC (permalink / raw)
To: He, Qing; +Cc: kvm-devel
He, Qing wrote:
> Avi,
> This is the updated patch for the qemu part of PIC save/restore.
> All the above patches are against lapic2 branch.
>
>
Thanks. Rebased, applied, and pushed. I fixed a minor error checking
omission in libkvm along the way.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-07-26 8:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-25 10:14 [PATCH 3/3] usermode for in kernel PIC live migration support He, Qing
[not found] ` <37E52D09333DE2469A03574C88DBF40F048EAA-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-07-25 11:24 ` Avi Kivity
[not found] ` <46A732D8.7050306-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-26 5:49 ` He, Qing
2007-07-26 5:56 ` He, Qing
[not found] ` <37E52D09333DE2469A03574C88DBF40F048EB3-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-07-26 8:12 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox