diff mbox series

[for-2.12,v3,06/11] spapr: store a reference IRQ bitmap

Message ID 20171110152017.24324-7-clg@kaod.org
State New
Headers show
Series spapr: introduce an IRQ allocator at the machine level | expand

Commit Message

Cédric Le Goater Nov. 10, 2017, 3:20 p.m. UTC
To save some state when the guest is migrated, we capture the IRQ
bitmap after all devices have been reseted and store it as a reference
for the machine.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

 We should probably merge this patch with the previous in the next
 versions of the patchset. For the moment, I thought it would be
 interesting to isolate the topic for discussion.

 hw/ppc/spapr.c         | 7 ++++++-
 include/hw/ppc/spapr.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Greg Kurz Nov. 14, 2017, 3:12 p.m. UTC | #1
On Fri, 10 Nov 2017 15:20:12 +0000
Cédric Le Goater <clg@kaod.org> wrote:

> To save some state when the guest is migrated, we capture the IRQ
> bitmap after all devices have been reseted and store it as a reference
> for the machine.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> 
>  We should probably merge this patch with the previous in the next
>  versions of the patchset. For the moment, I thought it would be
>  interesting to isolate the topic for discussion.
> 

Indeed. So this will be able to catch all devices that are internally
created by the machine and the ones from the command line. If QEMU
is started with -S and the user does some device_add, the IRQs of the
corresponding devices won't be recorded, and we'll migrate the bitmap.
It is also possible to capture the state when the guest is started for
the first time, but it would bring some extra complexity... I guess
your approach is an acceptable trade-off.

>  hw/ppc/spapr.c         | 7 ++++++-
>  include/hw/ppc/spapr.h | 1 +
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 4ef0b73559ca..bf0e5b4f815b 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1437,6 +1437,9 @@ static void ppc_spapr_reset(void)
>      qemu_devices_reset();
>      spapr_clear_pending_events(spapr);
>  
> +    spapr->irq_map_ref = bitmap_new(spapr->nr_irqs);
> +    bitmap_copy(spapr->irq_map_ref, spapr->irq_map, spapr->nr_irqs);
> +
>      /*
>       * We place the device tree and RTAS just below either the top of the RMA,
>       * or just below 2GB, whichever is lowere, so that it can be
> @@ -1683,7 +1686,9 @@ static const VMStateDescription vmstate_spapr_patb_entry = {
>  
>  static bool spapr_irq_map_needed(void *opaque)
>  {
> -    return true;
> +    sPAPRMachineState *spapr = opaque;
> +
> +    return !bitmap_equal(spapr->irq_map, spapr->irq_map_ref, spapr->nr_irqs);
>  }
>  
>  static const VMStateDescription vmstate_spapr_irq_map = {
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 5835c694caff..023436c32b2a 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -81,6 +81,7 @@ struct sPAPRMachineState {
>      struct sPAPRNVRAM *nvram;
>      int32_t nr_irqs;
>      unsigned long *irq_map;
> +    unsigned long *irq_map_ref;
>      ICSState *ics;
>      sPAPRRTCState rtc;
>
diff mbox series

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4ef0b73559ca..bf0e5b4f815b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1437,6 +1437,9 @@  static void ppc_spapr_reset(void)
     qemu_devices_reset();
     spapr_clear_pending_events(spapr);
 
+    spapr->irq_map_ref = bitmap_new(spapr->nr_irqs);
+    bitmap_copy(spapr->irq_map_ref, spapr->irq_map, spapr->nr_irqs);
+
     /*
      * We place the device tree and RTAS just below either the top of the RMA,
      * or just below 2GB, whichever is lowere, so that it can be
@@ -1683,7 +1686,9 @@  static const VMStateDescription vmstate_spapr_patb_entry = {
 
 static bool spapr_irq_map_needed(void *opaque)
 {
-    return true;
+    sPAPRMachineState *spapr = opaque;
+
+    return !bitmap_equal(spapr->irq_map, spapr->irq_map_ref, spapr->nr_irqs);
 }
 
 static const VMStateDescription vmstate_spapr_irq_map = {
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 5835c694caff..023436c32b2a 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -81,6 +81,7 @@  struct sPAPRMachineState {
     struct sPAPRNVRAM *nvram;
     int32_t nr_irqs;
     unsigned long *irq_map;
+    unsigned long *irq_map_ref;
     ICSState *ics;
     sPAPRRTCState rtc;