diff mbox

[1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

Message ID 1371549586-4672-2-git-send-email-paul.durrant@citrix.com
State New
Headers show

Commit Message

Paul Durrant June 18, 2013, 9:59 a.m. UTC
Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The
initialization code for this machine type can easily be pulled into the
generic pc initialization code and guarded with a test for whether the xen
accelerator options is specified, which is more consistent with the way
other accelerators are used.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
 hw/i386/pc_piix.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Andreas Färber June 18, 2013, 10:28 a.m. UTC | #1
Am 18.06.2013 11:59, schrieb Paul Durrant:
> Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The
> initialization code for this machine type can easily be pulled into the
> generic pc initialization code and guarded with a test for whether the xen
> accelerator options is specified, which is more consistent with the way
> other accelerators are used.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
>  hw/i386/pc_piix.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index d618570..7bbb59a 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -1,3 +1,4 @@
> +
>  /*
>   * QEMU PC System Emulator
>   *

Unrelated whitespace change, please drop this hunk.

> @@ -91,6 +92,10 @@ static void pc_init1(MemoryRegion *system_memory,
>      DeviceState *icc_bridge;
>      FWCfgState *fw_cfg = NULL;
>  
> +    if (xen_enabled() && xen_hvm_init() != 0) {
> +        hw_error("xen hardware virtual machine initialisation failed");

I see this is just a code movement, but maybe consider replacing that
with an fprintf()+exit(1)? Xen does not have any CPUs AFAIU and they
wouldn't be initialized at that point anyway, so hw_error() is not much
more than an fprintf()+abort().

Regards,
Andreas

> +    }
> +
>      icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
>      object_property_add_child(qdev_get_machine(), "icc-bridge",
>                                OBJECT(icc_bridge), NULL);
> @@ -320,9 +325,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
>  #ifdef CONFIG_XEN
>  static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
>  {
> -    if (xen_hvm_init() != 0) {
> -        hw_error("xen hardware virtual machine initialisation failed");
> -    }
>      pc_init_pci(args);
>  }
>  #endif
Paul Durrant June 18, 2013, 10:34 a.m. UTC | #2
> -----Original Message-----
> From: Andreas Färber [mailto:afaerber@suse.de]
> Sent: 18 June 2013 11:29
> To: Paul Durrant
> Cc: qemu-devel@nongnu.org; xen-devel@lists.xen.org; Paolo Bonzini
> Subject: Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type
> (accel=xen) for Xen HVM domains.
> 
> Am 18.06.2013 11:59, schrieb Paul Durrant:
> > Xen HVM domains normally spawn QEMU with a dedicated xenfv machine
> type. The
> > initialization code for this machine type can easily be pulled into the
> > generic pc initialization code and guarded with a test for whether the xen
> > accelerator options is specified, which is more consistent with the way
> > other accelerators are used.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > ---
> >  hw/i386/pc_piix.c |    8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> > index d618570..7bbb59a 100644
> > --- a/hw/i386/pc_piix.c
> > +++ b/hw/i386/pc_piix.c
> > @@ -1,3 +1,4 @@
> > +
> >  /*
> >   * QEMU PC System Emulator
> >   *
> 
> Unrelated whitespace change, please drop this hunk.
> 

Ok.

> > @@ -91,6 +92,10 @@ static void pc_init1(MemoryRegion
> *system_memory,
> >      DeviceState *icc_bridge;
> >      FWCfgState *fw_cfg = NULL;
> >
> > +    if (xen_enabled() && xen_hvm_init() != 0) {
> > +        hw_error("xen hardware virtual machine initialisation failed");
> 
> I see this is just a code movement, but maybe consider replacing that
> with an fprintf()+exit(1)? Xen does not have any CPUs AFAIU and they
> wouldn't be initialized at that point anyway, so hw_error() is not much
> more than an fprintf()+abort().
> 

If that's preferred I can do that, but it makes it less apparent that this patch is just code movement.

  Paul
diff mbox

Patch

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d618570..7bbb59a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -1,3 +1,4 @@ 
+
 /*
  * QEMU PC System Emulator
  *
@@ -91,6 +92,10 @@  static void pc_init1(MemoryRegion *system_memory,
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_enabled() && xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +325,6 @@  static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif