diff mbox

[v2] libxl: change default QEMU machine to pc-i440fx-1.6

Message ID alpine.DEB.2.02.1406121512360.13771@kaball.uk.xensource.com
State New
Headers show

Commit Message

Stefano Stabellini June 12, 2014, 2:33 p.m. UTC
Choose pc-i440fx-1.6 instead of pc for HVM guests, so that we know for
sure what is the machine that we are emulating.

Use pc-i440fx-1.6 regardless of the xen_platform_pci option. Add the
xen-platform device if requested.  Move the machine options earlier,
before any emulated devices options so that QEMU will assign slot 2 to
the xen-platform device, maintaining compatibility with current
installations.

In case of Intel graphic passthrough, slot 2 might be needed by the
grafics card. However it is easy to change the position of the
xen-platform device on the PCI bus if graphic passthrough is enabled, by
passing "addr=desired_slot_number".

Specify PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off, because
differently from xenfv, the other QEMU machines do not have that option
off by default.

This patch does not change the emulated environment in the guest, unless
soundhw='hda' is specified, in that case the xen-platform device is
moved to slot 3 (used to be always slot 2). This change might cause
problems to guests with soundhw='hda', migrating from 4.4 to 4.5.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


---

Changes in v2:
- note the dependency on QEMU >= 1.6.1 in the README;
- move the -machine options even earlier and drop the explicit
  ",slot=0x2".

Comments

Fabio Fantoni June 12, 2014, 5:07 p.m. UTC | #1
2014-06-12 16:33 GMT+02:00 Stefano Stabellini <
stefano.stabellini@eu.citrix.com>:

> Choose pc-i440fx-1.6 instead of pc for HVM guests, so that we know for
> sure what is the machine that we are emulating.
>
> Use pc-i440fx-1.6 regardless of the xen_platform_pci option. Add the
> xen-platform device if requested.  Move the machine options earlier,
> before any emulated devices options so that QEMU will assign slot 2 to
> the xen-platform device, maintaining compatibility with current
> installations.
>
> In case of Intel graphic passthrough, slot 2 might be needed by the
> grafics card. However it is easy to change the position of the
> xen-platform device on the PCI bus if graphic passthrough is enabled, by
> passing "addr=desired_slot_number".
>
> Specify PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off, because
> differently from xenfv, the other QEMU machines do not have that option
> off by default.
>
> This patch does not change the emulated environment in the guest, unless
> soundhw='hda' is specified, in that case the xen-platform device is
> moved to slot 3 (used to be always slot 2). This change might cause
> problems to guests with soundhw='hda', migrating from 4.4 to 4.5.
>

Without fixed xen-platform slot I think will be ok also in migrate.
For test the case it is sufficient save on unstable without the patch and
restore with this patch? If yes I'll thest this on my next build test.


>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
>
> ---
>
> Changes in v2:
> - note the dependency on QEMU >= 1.6.1 in the README;
> - move the -machine options even earlier and drop the explicit
>   ",slot=0x2".
>
>
> diff --git a/README b/README
> index 9bbe734..cb66893 100644
> --- a/README
> +++ b/README
> @@ -73,6 +73,10 @@ disabled at compile time:
>      * markdown
>      * figlet (for generating the traditional Xen start of day banner)
>
> +As a runtime requirement, you need a QEMU binary newer than v1.6.1,
>

Probably my english is very bad but this seems to me >1.6.1 but should be
>=1.6.1 (for example: at least version 1.6.1 of QEMU binary)


> +compiled with Xen support. By default the Xen build system will clone
> +and build one for you.
>


> +
>  Second, you need to acquire a suitable kernel for use in domain 0. If
>  possible you should use a kernel provided by your OS distributor. If
>  no suitable kernel is available from your OS distributor then refer to
> diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
> index 51ab2bf..b5a0beb 100644
> --- a/tools/libxl/libxl_dm.c
> +++ b/tools/libxl/libxl_dm.c
> @@ -403,6 +403,27 @@ static char **
> libxl__build_device_model_args_new(libxl__gc *gc,
>                        "-xen-domid",
>                        libxl__sprintf(gc, "%d", guest_domid), NULL);
>
> +    switch (b_info->type) {
> +    case LIBXL_DOMAIN_TYPE_PV:
> +        flexarray_append_pair(dm_args, "-machine", "xenpv");
> +        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
> +            flexarray_append(dm_args, b_info->extra_pv[i]);
> +        break;
> +    case LIBXL_DOMAIN_TYPE_HVM:
> +        flexarray_append_pair(dm_args, "-machine",
> "pc-i440fx-1.6,accel=xen");
> +        flexarray_append_pair(dm_args, "-global",
> +                "PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off");
> +        if (libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) {
> +            flexarray_append(dm_args, "-device");
> +            flexarray_append(dm_args, "xen-platform");
> +        }
> +        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL;
> i++)
> +            flexarray_append(dm_args, b_info->extra_hvm[i]);
> +        break;
> +    default:
> +        abort();
> +    }
> +
>      flexarray_append(dm_args, "-chardev");
>      flexarray_append(dm_args,
>                       libxl__sprintf(gc, "socket,id=libxl-cmd,"
> @@ -646,29 +667,6 @@ static char **
> libxl__build_device_model_args_new(libxl__gc *gc,
>      for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
>          flexarray_append(dm_args, b_info->extra[i]);
>
> -    flexarray_append(dm_args, "-machine");
> -    switch (b_info->type) {
> -    case LIBXL_DOMAIN_TYPE_PV:
> -        flexarray_append(dm_args, "xenpv");
> -        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
> -            flexarray_append(dm_args, b_info->extra_pv[i]);
> -        break;
> -    case LIBXL_DOMAIN_TYPE_HVM:
> -        if (!libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) {
> -            /* Switching here to the machine "pc" which does not add
> -             * the xen-platform device instead of the default "xenfv"
> machine.
> -             */
> -            flexarray_append(dm_args, "pc,accel=xen");
> -        } else {
> -            flexarray_append(dm_args, "xenfv");
> -        }
> -        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL;
> i++)
> -            flexarray_append(dm_args, b_info->extra_hvm[i]);
> -        break;
> -    default:
> -        abort();
> -    }
> -
>      ram_size = libxl__sizekb_to_mb(b_info->max_memkb -
> b_info->video_memkb);
>      flexarray_append(dm_args, "-m");
>      flexarray_append(dm_args, libxl__sprintf(gc, "%"PRId64, ram_size));
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
>
Stefano Stabellini July 10, 2014, 5:03 p.m. UTC | #2
ping?

On Thu, 12 Jun 2014, Stefano Stabellini wrote:
> Choose pc-i440fx-1.6 instead of pc for HVM guests, so that we know for
> sure what is the machine that we are emulating.
> 
> Use pc-i440fx-1.6 regardless of the xen_platform_pci option. Add the
> xen-platform device if requested.  Move the machine options earlier,
> before any emulated devices options so that QEMU will assign slot 2 to
> the xen-platform device, maintaining compatibility with current
> installations.
> 
> In case of Intel graphic passthrough, slot 2 might be needed by the
> grafics card. However it is easy to change the position of the
> xen-platform device on the PCI bus if graphic passthrough is enabled, by
> passing "addr=desired_slot_number".
> 
> Specify PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off, because
> differently from xenfv, the other QEMU machines do not have that option
> off by default.
> 
> This patch does not change the emulated environment in the guest, unless
> soundhw='hda' is specified, in that case the xen-platform device is
> moved to slot 3 (used to be always slot 2). This change might cause
> problems to guests with soundhw='hda', migrating from 4.4 to 4.5.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> 
> ---
> 
> Changes in v2:
> - note the dependency on QEMU >= 1.6.1 in the README;
> - move the -machine options even earlier and drop the explicit
>   ",slot=0x2".
> 
> 
> diff --git a/README b/README
> index 9bbe734..cb66893 100644
> --- a/README
> +++ b/README
> @@ -73,6 +73,10 @@ disabled at compile time:
>      * markdown
>      * figlet (for generating the traditional Xen start of day banner)
>  
> +As a runtime requirement, you need a QEMU binary newer than v1.6.1,
> +compiled with Xen support. By default the Xen build system will clone
> +and build one for you.
> +
>  Second, you need to acquire a suitable kernel for use in domain 0. If
>  possible you should use a kernel provided by your OS distributor. If
>  no suitable kernel is available from your OS distributor then refer to
> diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
> index 51ab2bf..b5a0beb 100644
> --- a/tools/libxl/libxl_dm.c
> +++ b/tools/libxl/libxl_dm.c
> @@ -403,6 +403,27 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
>                        "-xen-domid",
>                        libxl__sprintf(gc, "%d", guest_domid), NULL);
>  
> +    switch (b_info->type) {
> +    case LIBXL_DOMAIN_TYPE_PV:
> +        flexarray_append_pair(dm_args, "-machine", "xenpv");
> +        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
> +            flexarray_append(dm_args, b_info->extra_pv[i]);
> +        break;
> +    case LIBXL_DOMAIN_TYPE_HVM:
> +        flexarray_append_pair(dm_args, "-machine", "pc-i440fx-1.6,accel=xen");
> +        flexarray_append_pair(dm_args, "-global",
> +                "PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off");
> +        if (libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) {
> +            flexarray_append(dm_args, "-device");
> +            flexarray_append(dm_args, "xen-platform");
> +        }
> +        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
> +            flexarray_append(dm_args, b_info->extra_hvm[i]);
> +        break;
> +    default:
> +        abort();
> +    }
> +
>      flexarray_append(dm_args, "-chardev");
>      flexarray_append(dm_args,
>                       libxl__sprintf(gc, "socket,id=libxl-cmd,"
> @@ -646,29 +667,6 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
>      for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
>          flexarray_append(dm_args, b_info->extra[i]);
>  
> -    flexarray_append(dm_args, "-machine");
> -    switch (b_info->type) {
> -    case LIBXL_DOMAIN_TYPE_PV:
> -        flexarray_append(dm_args, "xenpv");
> -        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
> -            flexarray_append(dm_args, b_info->extra_pv[i]);
> -        break;
> -    case LIBXL_DOMAIN_TYPE_HVM:
> -        if (!libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) {
> -            /* Switching here to the machine "pc" which does not add
> -             * the xen-platform device instead of the default "xenfv" machine.
> -             */
> -            flexarray_append(dm_args, "pc,accel=xen");
> -        } else {
> -            flexarray_append(dm_args, "xenfv");
> -        }
> -        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
> -            flexarray_append(dm_args, b_info->extra_hvm[i]);
> -        break;
> -    default:
> -        abort();
> -    }
> -
>      ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb);
>      flexarray_append(dm_args, "-m");
>      flexarray_append(dm_args, libxl__sprintf(gc, "%"PRId64, ram_size));
>
Ian Jackson July 10, 2014, 5:22 p.m. UTC | #3
Stefano Stabellini writes ("Re: [PATCH v2] libxl: change default QEMU machine to pc-i440fx-1.6"):
> ping?
> 
> On Thu, 12 Jun 2014, Stefano Stabellini wrote:
...
> > This patch does not change the emulated environment in the guest, unless
> > soundhw='hda' is specified, in that case the xen-platform device is
> > moved to slot 3 (used to be always slot 2). This change might cause
> > problems to guests with soundhw='hda', migrating from 4.4 to 4.5.

Is there a way for someone who experiences this problem to make it go
back to the way it was ?

Ian.
Stefano Stabellini July 11, 2014, 11:14 a.m. UTC | #4
On Thu, 10 Jul 2014, Ian Jackson wrote:
> Stefano Stabellini writes ("Re: [PATCH v2] libxl: change default QEMU machine to pc-i440fx-1.6"):
> > ping?
> > 
> > On Thu, 12 Jun 2014, Stefano Stabellini wrote:
> ...
> > > This patch does not change the emulated environment in the guest, unless
> > > soundhw='hda' is specified, in that case the xen-platform device is
> > > moved to slot 3 (used to be always slot 2). This change might cause
> > > problems to guests with soundhw='hda', migrating from 4.4 to 4.5.
> 
> Is there a way for someone who experiences this problem to make it go
> back to the way it was ?

A guest reboot would solve the problem.
Ian Campbell July 11, 2014, 2:19 p.m. UTC | #5
On Fri, 2014-07-11 at 12:14 +0100, Stefano Stabellini wrote:
> On Thu, 10 Jul 2014, Ian Jackson wrote:
> > Stefano Stabellini writes ("Re: [PATCH v2] libxl: change default QEMU machine to pc-i440fx-1.6"):
> > > ping?
> > > 
> > > On Thu, 12 Jun 2014, Stefano Stabellini wrote:
> > ...
> > > > This patch does not change the emulated environment in the guest, unless
> > > > soundhw='hda' is specified, in that case the xen-platform device is
> > > > moved to slot 3 (used to be always slot 2). This change might cause
> > > > problems to guests with soundhw='hda', migrating from 4.4 to 4.5.
> > 
> > Is there a way for someone who experiences this problem to make it go
> > back to the way it was ?
> 
> A guest reboot would solve the problem.

That rather defeats the purpose of being able to migrate from N to N+1.

What is the issue with hda which requires us to move slots around if it
is enabled where we didn't need to do so before?

Ian.
Stefano Stabellini July 11, 2014, 2:54 p.m. UTC | #6
On Fri, 11 Jul 2014, Ian Campbell wrote:
> On Fri, 2014-07-11 at 12:14 +0100, Stefano Stabellini wrote:
> > On Thu, 10 Jul 2014, Ian Jackson wrote:
> > > Stefano Stabellini writes ("Re: [PATCH v2] libxl: change default QEMU machine to pc-i440fx-1.6"):
> > > > ping?
> > > > 
> > > > On Thu, 12 Jun 2014, Stefano Stabellini wrote:
> > > ...
> > > > > This patch does not change the emulated environment in the guest, unless
> > > > > soundhw='hda' is specified, in that case the xen-platform device is
> > > > > moved to slot 3 (used to be always slot 2). This change might cause
> > > > > problems to guests with soundhw='hda', migrating from 4.4 to 4.5.
> > > 
> > > Is there a way for someone who experiences this problem to make it go
> > > back to the way it was ?
> > 
> > A guest reboot would solve the problem.
> 
> That rather defeats the purpose of being able to migrate from N to N+1.
> 
> What is the issue with hda which requires us to move slots around if it
> is enabled where we didn't need to do so before?

If we use -M pc or -M pc-i440fx-1.6, the xen-platform-pci device is
created slightly later in the QEMU boot sequence. The Intel HDA device
is able to "steal" its slot on the PCI bus.

On the other hand it is worth pointing out that currently libxl switches
from -M xenfv to -M pc silently depending on whether the
xen_platform_pci option is enabled or disabled. If it is disabled we get
pc, that is a moving target and not guaranteed to be compatible with
anything.
Ian Campbell July 11, 2014, 3:08 p.m. UTC | #7
On Fri, 2014-07-11 at 15:54 +0100, Stefano Stabellini wrote:
> On Fri, 11 Jul 2014, Ian Campbell wrote:
> > On Fri, 2014-07-11 at 12:14 +0100, Stefano Stabellini wrote:
> > > On Thu, 10 Jul 2014, Ian Jackson wrote:
> > > > Stefano Stabellini writes ("Re: [PATCH v2] libxl: change default QEMU machine to pc-i440fx-1.6"):
> > > > > ping?
> > > > > 
> > > > > On Thu, 12 Jun 2014, Stefano Stabellini wrote:
> > > > ...
> > > > > > This patch does not change the emulated environment in the guest, unless
> > > > > > soundhw='hda' is specified, in that case the xen-platform device is
> > > > > > moved to slot 3 (used to be always slot 2). This change might cause
> > > > > > problems to guests with soundhw='hda', migrating from 4.4 to 4.5.
> > > > 
> > > > Is there a way for someone who experiences this problem to make it go
> > > > back to the way it was ?
> > > 
> > > A guest reboot would solve the problem.
> > 
> > That rather defeats the purpose of being able to migrate from N to N+1.
> > 
> > What is the issue with hda which requires us to move slots around if it
> > is enabled where we didn't need to do so before?
> 
> If we use -M pc or -M pc-i440fx-1.6, the xen-platform-pci device is
> created slightly later in the QEMU boot sequence. The Intel HDA device
> is able to "steal" its slot on the PCI bus.
> 
> On the other hand it is worth pointing out that currently libxl switches
> from -M xenfv to -M pc silently depending on whether the
> xen_platform_pci option is enabled or disabled. If it is disabled we get
> pc, that is a moving target and not guaranteed to be compatible with
> anything.

Changing that option is a guest reboot scenario, which is completely
different to a migration. I think it is (just about) OK for the PCI id
to change on a reboot, but it certainly isn't OK on migrate.

If you can't get the platform device created earlier then perhaps you
can find a way to influence the slot used by the hda device?

Ian.
diff mbox

Patch

diff --git a/README b/README
index 9bbe734..cb66893 100644
--- a/README
+++ b/README
@@ -73,6 +73,10 @@  disabled at compile time:
     * markdown
     * figlet (for generating the traditional Xen start of day banner)
 
+As a runtime requirement, you need a QEMU binary newer than v1.6.1,
+compiled with Xen support. By default the Xen build system will clone
+and build one for you.
+
 Second, you need to acquire a suitable kernel for use in domain 0. If
 possible you should use a kernel provided by your OS distributor. If
 no suitable kernel is available from your OS distributor then refer to
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 51ab2bf..b5a0beb 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -403,6 +403,27 @@  static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                       "-xen-domid",
                       libxl__sprintf(gc, "%d", guest_domid), NULL);
 
+    switch (b_info->type) {
+    case LIBXL_DOMAIN_TYPE_PV:
+        flexarray_append_pair(dm_args, "-machine", "xenpv");
+        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_pv[i]);
+        break;
+    case LIBXL_DOMAIN_TYPE_HVM:
+        flexarray_append_pair(dm_args, "-machine", "pc-i440fx-1.6,accel=xen");
+        flexarray_append_pair(dm_args, "-global",
+                "PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off");
+        if (libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) {
+            flexarray_append(dm_args, "-device");
+            flexarray_append(dm_args, "xen-platform");
+        }
+        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
+            flexarray_append(dm_args, b_info->extra_hvm[i]);
+        break;
+    default:
+        abort();
+    }
+
     flexarray_append(dm_args, "-chardev");
     flexarray_append(dm_args,
                      libxl__sprintf(gc, "socket,id=libxl-cmd,"
@@ -646,29 +667,6 @@  static char ** libxl__build_device_model_args_new(libxl__gc *gc,
     for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++)
         flexarray_append(dm_args, b_info->extra[i]);
 
-    flexarray_append(dm_args, "-machine");
-    switch (b_info->type) {
-    case LIBXL_DOMAIN_TYPE_PV:
-        flexarray_append(dm_args, "xenpv");
-        for (i = 0; b_info->extra_pv && b_info->extra_pv[i] != NULL; i++)
-            flexarray_append(dm_args, b_info->extra_pv[i]);
-        break;
-    case LIBXL_DOMAIN_TYPE_HVM:
-        if (!libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) {
-            /* Switching here to the machine "pc" which does not add
-             * the xen-platform device instead of the default "xenfv" machine.
-             */
-            flexarray_append(dm_args, "pc,accel=xen");
-        } else {
-            flexarray_append(dm_args, "xenfv");
-        }
-        for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++)
-            flexarray_append(dm_args, b_info->extra_hvm[i]);
-        break;
-    default:
-        abort();
-    }
-
     ram_size = libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_memkb);
     flexarray_append(dm_args, "-m");
     flexarray_append(dm_args, libxl__sprintf(gc, "%"PRId64, ram_size));