summary refs log tree commit diff
diff options
context:
space:
mode:
authorThomas Strobel <ts468@cam.ac.uk>2015-07-02 16:33:01 +0200
committerThomas Strobel <ts468@cam.ac.uk>2015-07-02 16:33:01 +0200
commit6bd694321dfb3eec78d515c31654fa86e656f11b (patch)
tree763aefdd8d5a1407ce756c9f71da487ba11b08ee
parent8f911263e9304740b182ff3781a2a1ace0de5b42 (diff)
downloadnixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.tar
nixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.tar.gz
nixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.tar.bz2
nixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.tar.lz
nixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.tar.xz
nixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.tar.zst
nixpkgs-6bd694321dfb3eec78d515c31654fa86e656f11b.zip
Xen: enable Spice/QXL + add libhvm + minor fixes
-rw-r--r--pkgs/applications/virtualization/xen/0000-qemu-seabios-enable-ATA_DMA.patch23
-rw-r--r--pkgs/applications/virtualization/xen/0001-libxl-Spice-image-compression-setting-support-for-up.patch104
-rw-r--r--pkgs/applications/virtualization/xen/0002-libxl-Spice-streaming-video-setting-support-for-upst.patch104
-rw-r--r--pkgs/applications/virtualization/xen/0003-Add-qxl-vga-interface-support-for-upstream-qem.patch165
-rw-r--r--pkgs/applications/virtualization/xen/4.4.1.nix36
-rw-r--r--pkgs/applications/virtualization/xen/4.5.0.nix53
-rw-r--r--pkgs/applications/virtualization/xen/generic.nix35
7 files changed, 473 insertions, 47 deletions
diff --git a/pkgs/applications/virtualization/xen/0000-qemu-seabios-enable-ATA_DMA.patch b/pkgs/applications/virtualization/xen/0000-qemu-seabios-enable-ATA_DMA.patch
new file mode 100644
index 00000000000..1eb3d5949de
--- /dev/null
+++ b/pkgs/applications/virtualization/xen/0000-qemu-seabios-enable-ATA_DMA.patch
@@ -0,0 +1,23 @@
+diff --git a/src/Kconfig b/src/Kconfig
+index 45ca59c..faf8951 100644
+--- a/src/Kconfig
++++ b/src/Kconfig
+@@ -144,13 +144,13 @@ menu "Hardware support"
+     config ATA_DMA
+         depends on ATA
+         bool "ATA DMA"
+-        default n
++        default y
+         help
+             Detect and try to use ATA bus mastering DMA controllers.
+     config ATA_PIO32
+         depends on ATA
+         bool "ATA 32bit PIO"
+-        default n
++        default y
+         help
+             Use 32bit PIO accesses on ATA (minor optimization on PCI 
+transfers).
+     config AHCI
+-- 
+1.7.10.4
diff --git a/pkgs/applications/virtualization/xen/0001-libxl-Spice-image-compression-setting-support-for-up.patch b/pkgs/applications/virtualization/xen/0001-libxl-Spice-image-compression-setting-support-for-up.patch
new file mode 100644
index 00000000000..67b7ac777b5
--- /dev/null
+++ b/pkgs/applications/virtualization/xen/0001-libxl-Spice-image-compression-setting-support-for-up.patch
@@ -0,0 +1,104 @@
+From bd71555985efc423b1a119b6a3177de855763453 Mon Sep 17 00:00:00 2001
+From: Fabio Fantoni <fabio.fantoni@m2r.biz>
+Date: Tue, 20 Jan 2015 11:26:30 +0100
+Subject: [PATCH] libxl: Spice image compression setting support for upstream
+ qemu
+
+Usage:
+spice_image_compression=[auto_glz|auto_lz|quic|glz|lz|off]
+
+Specifies what image compression is to be used by spice (if given),
+otherwise the qemu default will be used.
+
+Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
+Acked-by: Wei Liu <wei.liu2@citrix.com>
+---
+ docs/man/xl.cfg.pod.5       |  6 ++++++
+ tools/libxl/libxl.h         | 11 +++++++++++
+ tools/libxl/libxl_dm.c      |  4 ++++
+ tools/libxl/libxl_types.idl |  1 +
+ tools/libxl/xl_cmdimpl.c    |  2 ++
+ 5 files changed, 24 insertions(+)
+
+diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
+index e2f91fc..0c2cbac 100644
+--- a/docs/man/xl.cfg.pod.5
++++ b/docs/man/xl.cfg.pod.5
+@@ -1427,6 +1427,12 @@ for redirection of up to 4 usb devices from spice client to domU's qemu.
+ It requires an usb controller and if not defined it will automatically adds
+ an usb2 controller. The default is disabled (0).
+ 
++=item B<spice_image_compression=[auto_glz|auto_lz|quic|glz|lz|off]>
++
++Specifies what image compression is to be used by spice (if given), otherwise
++the qemu default will be used. Please see documentations of your current qemu
++version for details.
++
+ =back
+ 
+ =head3 Miscellaneous Emulated Hardware
+diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
+index 0a123f1..b8e0b67 100644
+--- a/tools/libxl/libxl.h
++++ b/tools/libxl/libxl.h
+@@ -528,6 +528,17 @@ typedef struct libxl__ctx libxl_ctx;
+ #define LIBXL_HAVE_SPICE_USBREDIREDIRECTION 1
+ 
+ /*
++ * LIBXL_HAVE_SPICE_IMAGECOMPRESSION
++ *
++ * If defined, then the libxl_spice_info structure will contain a string type
++ * field: image_compression. This value defines what Spice image compression
++ * is used.
++ *
++ * If this is not defined, the Spice image compression setting support is ignored.
++ */
++#define LIBXL_HAVE_SPICE_IMAGECOMPRESSION 1
++
++/*
+  * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
+  *
+  * If this is defined, libxl_domain_create_restore()'s API has changed to
+diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
+index c2b0487..40c8649 100644
+--- a/tools/libxl/libxl_dm.c
++++ b/tools/libxl/libxl_dm.c
+@@ -398,6 +398,10 @@ static char *dm_spice_options(libxl__gc *gc,
+     if (!libxl_defbool_val(spice->clipboard_sharing))
+         opt = libxl__sprintf(gc, "%s,disable-copy-paste", opt);
+ 
++    if (spice->image_compression)
++        opt = libxl__sprintf(gc, "%s,image-compression=%s", opt,
++                             spice->image_compression);
++
+     return opt;
+ }
+ 
+diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
+index 1214d2e..052ded9 100644
+--- a/tools/libxl/libxl_types.idl
++++ b/tools/libxl/libxl_types.idl
+@@ -241,6 +241,7 @@ libxl_spice_info = Struct("spice_info", [
+     ("vdagent",     libxl_defbool),
+     ("clipboard_sharing", libxl_defbool),
+     ("usbredirection", integer),
++    ("image_compression", string),
+     ])
+ 
+ libxl_sdl_info = Struct("sdl_info", [
+diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
+index 0b02a6c..00aa69d 100644
+--- a/tools/libxl/xl_cmdimpl.c
++++ b/tools/libxl/xl_cmdimpl.c
+@@ -1948,6 +1948,8 @@ skip_vfb:
+                             &b_info->u.hvm.spice.clipboard_sharing, 0);
+         if (!xlu_cfg_get_long (config, "spiceusbredirection", &l, 0))
+             b_info->u.hvm.spice.usbredirection = l;
++        xlu_cfg_replace_string (config, "spice_image_compression",
++                                &b_info->u.hvm.spice.image_compression, 0);
+         xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0);
+         xlu_cfg_get_defbool(config, "gfx_passthru",
+                             &b_info->u.hvm.gfx_passthru, 0);
+-- 
+1.9.2
+
diff --git a/pkgs/applications/virtualization/xen/0002-libxl-Spice-streaming-video-setting-support-for-upst.patch b/pkgs/applications/virtualization/xen/0002-libxl-Spice-streaming-video-setting-support-for-upst.patch
new file mode 100644
index 00000000000..acf9cff9925
--- /dev/null
+++ b/pkgs/applications/virtualization/xen/0002-libxl-Spice-streaming-video-setting-support-for-upst.patch
@@ -0,0 +1,104 @@
+From 296c7f3284efe655d95a8ae045a5dc1a20d6fff0 Mon Sep 17 00:00:00 2001
+From: Fabio Fantoni <fabio.fantoni@m2r.biz>
+Date: Tue, 20 Jan 2015 11:33:17 +0100
+Subject: [PATCH] libxl: Spice streaming video setting support for upstream
+ qemu
+
+Usage:
+spice_streaming_video=[filter|all|off]
+
+Specifies what streaming video setting is to be used by spice (if
+given),
+otherwise the qemu default will be used.
+
+Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
+Acked-by: Wei Liu <wei.liu2@citrix.com>
+---
+ docs/man/xl.cfg.pod.5       |  5 +++++
+ tools/libxl/libxl.h         | 11 +++++++++++
+ tools/libxl/libxl_dm.c      |  4 ++++
+ tools/libxl/libxl_types.idl |  1 +
+ tools/libxl/xl_cmdimpl.c    |  2 ++
+ 5 files changed, 23 insertions(+)
+
+diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
+index 0c2cbac..408653f 100644
+--- a/docs/man/xl.cfg.pod.5
++++ b/docs/man/xl.cfg.pod.5
+@@ -1433,6 +1433,11 @@ Specifies what image compression is to be used by spice (if given), otherwise
+ the qemu default will be used. Please see documentations of your current qemu
+ version for details.
+ 
++=item B<spice_streaming_video=[filter|all|off]>
++
++Specifies what streaming video setting is to be used by spice (if given),
++otherwise the qemu default will be used.
++
+ =back
+ 
+ =head3 Miscellaneous Emulated Hardware
+diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
+index b8e0b67..c219f59 100644
+--- a/tools/libxl/libxl.h
++++ b/tools/libxl/libxl.h
+@@ -539,6 +539,17 @@ typedef struct libxl__ctx libxl_ctx;
+ #define LIBXL_HAVE_SPICE_IMAGECOMPRESSION 1
+ 
+ /*
++ * LIBXL_HAVE_SPICE_STREAMINGVIDEO
++ *
++ * If defined, then the libxl_spice_info structure will contain a string type
++ * field: streaming_video. This value defines what Spice streaming video setting
++ * is used.
++ *
++ * If this is not defined, the Spice streaming video setting support is ignored.
++ */
++#define LIBXL_HAVE_SPICE_STREAMINGVIDEO 1
++
++/*
+  * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
+  *
+  * If this is defined, libxl_domain_create_restore()'s API has changed to
+diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
+index 40c8649..d8d6f0c 100644
+--- a/tools/libxl/libxl_dm.c
++++ b/tools/libxl/libxl_dm.c
+@@ -402,6 +402,10 @@ static char *dm_spice_options(libxl__gc *gc,
+         opt = libxl__sprintf(gc, "%s,image-compression=%s", opt,
+                              spice->image_compression);
+ 
++    if (spice->streaming_video)
++        opt = libxl__sprintf(gc, "%s,streaming-video=%s", opt,
++                             spice->streaming_video);
++
+     return opt;
+ }
+ 
+diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
+index 052ded9..02be466 100644
+--- a/tools/libxl/libxl_types.idl
++++ b/tools/libxl/libxl_types.idl
+@@ -242,6 +242,7 @@ libxl_spice_info = Struct("spice_info", [
+     ("clipboard_sharing", libxl_defbool),
+     ("usbredirection", integer),
+     ("image_compression", string),
++    ("streaming_video", string),
+     ])
+ 
+ libxl_sdl_info = Struct("sdl_info", [
+diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
+index 00aa69d..b7eac29 100644
+--- a/tools/libxl/xl_cmdimpl.c
++++ b/tools/libxl/xl_cmdimpl.c
+@@ -1950,6 +1950,8 @@ skip_vfb:
+             b_info->u.hvm.spice.usbredirection = l;
+         xlu_cfg_replace_string (config, "spice_image_compression",
+                                 &b_info->u.hvm.spice.image_compression, 0);
++        xlu_cfg_replace_string (config, "spice_streaming_video",
++                                &b_info->u.hvm.spice.streaming_video, 0);
+         xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0);
+         xlu_cfg_get_defbool(config, "gfx_passthru",
+                             &b_info->u.hvm.gfx_passthru, 0);
+-- 
+1.9.2
+
diff --git a/pkgs/applications/virtualization/xen/0003-Add-qxl-vga-interface-support-for-upstream-qem.patch b/pkgs/applications/virtualization/xen/0003-Add-qxl-vga-interface-support-for-upstream-qem.patch
new file mode 100644
index 00000000000..1771b662bc3
--- /dev/null
+++ b/pkgs/applications/virtualization/xen/0003-Add-qxl-vga-interface-support-for-upstream-qem.patch
@@ -0,0 +1,165 @@
+From 161212ef02312c0681d2d809c8ff1e1f0ea6f6f9 Mon Sep 17 00:00:00 2001
+From: Fabio Fantoni <fabio.fantoni@m2r.biz>
+Date: Wed, 29 Apr 2015 11:20:28 +0200
+Subject: [PATCH] libxl: Add qxl vga interface support for upstream qemu
+
+Usage:
+vga="qxl"
+
+Qxl vga support many resolutions that not supported by stdvga,
+mainly the 16:9 ones and other high up to 2560x1600.
+With QXL you can get improved performance and smooth video also
+with high resolutions and high quality.
+Require their drivers installed in the domU and spice used
+otherwise act as a simple stdvga.
+
+Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
+Signed-off-by: Zhou Peng <zpengxen@gmail.com>
+Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
+Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
+Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
+---
+ docs/man/xl.cfg.pod.5       | 10 +++++++++-
+ tools/libxl/libxl.h         | 10 ++++++++++
+ tools/libxl/libxl_create.c  | 13 +++++++++++++
+ tools/libxl/libxl_dm.c      |  8 ++++++++
+ tools/libxl/libxl_types.idl |  1 +
+ tools/libxl/xl_cmdimpl.c    |  2 ++
+ 6 files changed, 43 insertions(+), 1 deletion(-)
+
+diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
+index f936dfc..8e4154f 100644
+--- a/docs/man/xl.cfg.pod.5
++++ b/docs/man/xl.cfg.pod.5
+@@ -1360,6 +1360,9 @@ qemu-xen-traditional device-model, the amount of video RAM is fixed at 4 MB,
+ which is sufficient for 1024x768 at 32 bpp. For the upstream qemu-xen
+ device-model, the default and minimum is 8 MB.
+ 
++For B<qxl> vga, the default is both default and minimal 128MB.
++If B<videoram> is set less than 128MB, an error will be triggered.
++
+ =item B<stdvga=BOOLEAN>
+ 
+ Select a standard VGA card with VBE (VESA BIOS Extensions) as the
+@@ -1371,9 +1374,14 @@ This option is deprecated, use vga="stdvga" instead.
+ 
+ =item B<vga="STRING">
+ 
+-Selects the emulated video card (none|stdvga|cirrus).
++Selects the emulated video card (none|stdvga|cirrus|qxl).
+ The default is cirrus.
+ 
++In general, QXL should work with the Spice remote display protocol
++for acceleration, and QXL driver is necessary in guest in this case.
++QXL can also work with the VNC protocol, but it will be like a standard
++VGA without acceleration.
++
+ =item B<vnc=BOOLEAN>
+ 
+ Allow access to the display via the VNC protocol.  This enables the
+diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
+index 44bd8e2..efc0617 100644
+--- a/tools/libxl/libxl.h
++++ b/tools/libxl/libxl.h
+@@ -535,6 +535,16 @@ typedef struct libxl__ctx libxl_ctx;
+ #define LIBXL_HAVE_DOMINFO_OUTSTANDING_MEMKB 1
+ 
+ /*
++ * LIBXL_HAVE_QXL
++ *
++ * If defined, then the libxl_vga_interface_type will contain another value:
++ * "QXL". This value define if qxl vga is supported.
++ *
++ * If this is not defined, the qxl vga support is missed.
++ */
++#define LIBXL_HAVE_QXL 1
++
++/*
+  * LIBXL_HAVE_SPICE_VDAGENT
+  *
+  * If defined, then the libxl_spice_info structure will contain a boolean type:
+diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
+index e5a343f..188f7df 100644
+--- a/tools/libxl/libxl_create.c
++++ b/tools/libxl/libxl_create.c
+@@ -248,6 +248,10 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
+                 if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
+                     b_info->video_memkb = 0;
+                 break;
++            case LIBXL_VGA_INTERFACE_TYPE_QXL:
++                LOG(ERROR,"qemu upstream required for qxl vga");
++                return ERROR_INVAL;
++                break;
+             case LIBXL_VGA_INTERFACE_TYPE_STD:
+                 if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
+                     b_info->video_memkb = 8 * 1024;
+@@ -272,6 +276,15 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
+                 if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
+                     b_info->video_memkb = 0;
+                 break;
++            case LIBXL_VGA_INTERFACE_TYPE_QXL:
++                if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT) {
++                    b_info->video_memkb = (128 * 1024);
++                } else if (b_info->video_memkb < (128 * 1024)) {
++                    LOG(ERROR,
++                        "128 Mib videoram is the minimum for qxl default");
++                    return ERROR_INVAL;
++                }
++                break;
+             case LIBXL_VGA_INTERFACE_TYPE_STD:
+                 if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT)
+                     b_info->video_memkb = 16 * 1024;
+diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
+index 30c1578..58c9b99 100644
+--- a/tools/libxl/libxl_dm.c
++++ b/tools/libxl/libxl_dm.c
+@@ -251,6 +251,8 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc,
+         case LIBXL_VGA_INTERFACE_TYPE_NONE:
+             flexarray_append_pair(dm_args, "-vga", "none");
+             break;
++        case LIBXL_VGA_INTERFACE_TYPE_QXL:
++            break;
+         }
+ 
+         if (b_info->u.hvm.boot) {
+@@ -625,6 +627,12 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
+             break;
+         case LIBXL_VGA_INTERFACE_TYPE_NONE:
+             break;
++        case LIBXL_VGA_INTERFACE_TYPE_QXL:
++            /* QXL have 2 ram regions, ram and vram */
++            flexarray_append_pair(dm_args, "-device",
++                GCSPRINTF("qxl-vga,vram_size_mb=%"PRIu64",ram_size_mb=%"PRIu64,
++                (b_info->video_memkb/2/1024), (b_info->video_memkb/2/1024) ) );
++            break;
+         }
+ 
+         if (b_info->u.hvm.boot) {
+diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
+index 117b61d..023b21e 100644
+--- a/tools/libxl/libxl_types.idl
++++ b/tools/libxl/libxl_types.idl
+@@ -183,6 +183,7 @@ libxl_vga_interface_type = Enumeration("vga_interface_type", [
+     (1, "CIRRUS"),
+     (2, "STD"),
+     (3, "NONE"),
++    (4, "QXL"),
+     ], init_val = "LIBXL_VGA_INTERFACE_TYPE_CIRRUS")
+ 
+ libxl_vendor_device = Enumeration("vendor_device", [
+diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
+index 648ca08..526a1f6 100644
+--- a/tools/libxl/xl_cmdimpl.c
++++ b/tools/libxl/xl_cmdimpl.c
+@@ -2115,6 +2115,8 @@ skip_vfb:
+                 b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_CIRRUS;
+             } else if (!strcmp(buf, "none")) {
+                 b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE;
++            } else if (!strcmp(buf, "qxl")) {
++                b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_QXL;
+             } else {
+                 fprintf(stderr, "Unknown vga \"%s\" specified\n", buf);
+                 exit(1);
+-- 
+1.9.2
+
diff --git a/pkgs/applications/virtualization/xen/4.4.1.nix b/pkgs/applications/virtualization/xen/4.4.1.nix
index a13a51a1d4e..ec2056cc547 100644
--- a/pkgs/applications/virtualization/xen/4.4.1.nix
+++ b/pkgs/applications/virtualization/xen/4.4.1.nix
@@ -14,30 +14,34 @@ let
     # Sources needed to build the xen tools and tools/firmware.
     toolsGits =
       [ # tag qemu-xen-4.4.1
-        { name = "qemu-xen";
-          url = git://xenbits.xen.org/qemu-upstream-4.4-testing.git;
-          rev = "65fc9b78ba3d868a26952db0d8e51cecf01d47b4";
-          sha256 = "e24fb58f773fd9134c5aae6d3ca7e9f754dc9822de92b1eb2cedc76faf911f18";
+        { git = { name = "qemu-xen";
+                  url = git://xenbits.xen.org/qemu-upstream-4.4-testing.git;
+                  rev = "65fc9b78ba3d868a26952db0d8e51cecf01d47b4";
+                  sha256 = "e24fb58f773fd9134c5aae6d3ca7e9f754dc9822de92b1eb2cedc76faf911f18";
+                };
         }
         # tag xen-4.4.1
-        {  name = "qemu-xen-traditional";
-          url = git://xenbits.xen.org/qemu-xen-4.4-testing.git;
-          rev = "6ae4e588081620b141071eb010ec40aca7e12876";
-          sha256 = "b1ed1feb92fbe658273a8d6d38d6ea60b79c1658413dd93979d6d128d8554ded";
+        { git = { name = "qemu-xen-traditional";
+                  url = git://xenbits.xen.org/qemu-xen-4.4-testing.git;
+                  rev = "6ae4e588081620b141071eb010ec40aca7e12876";
+                  sha256 = "b1ed1feb92fbe658273a8d6d38d6ea60b79c1658413dd93979d6d128d8554ded";
+                };
         }
       ];
 
     firmwareGits =
       [ # tag 1.7.3.1
-        { name = "seabios";
-          url = git://xenbits.xen.org/seabios.git;
-          rev = "7d9cbe613694924921ed1a6f8947d711c5832eee";
-          sha256 = "c071282bbcb1dd0d98536ef90cd1410f5d8da19648138e0e3863bc540d954a87";
+        { git = { name = "seabios";
+                  url = git://xenbits.xen.org/seabios.git;
+                  rev = "7d9cbe613694924921ed1a6f8947d711c5832eee";
+                  sha256 = "c071282bbcb1dd0d98536ef90cd1410f5d8da19648138e0e3863bc540d954a87";
+                };
         }
-        { name = "ovmf";
-          url = git://xenbits.xen.org/ovmf.git;
-          rev = "447d264115c476142f884af0be287622cd244423";
-          sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
+        { git = { name = "ovmf";
+                  url = git://xenbits.xen.org/ovmf.git;
+                  rev = "447d264115c476142f884af0be287622cd244423";
+                  sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
+                };
         }
       ];
 
diff --git a/pkgs/applications/virtualization/xen/4.5.0.nix b/pkgs/applications/virtualization/xen/4.5.0.nix
index 176e15ea2c7..156255be0d7 100644
--- a/pkgs/applications/virtualization/xen/4.5.0.nix
+++ b/pkgs/applications/virtualization/xen/4.5.0.nix
@@ -14,30 +14,47 @@ let
     # Sources needed to build the xen tools and tools/firmware.
     firmwareGits =
       [ # tag 1.7.5
-        { name = "seabios";
-          url = git://xenbits.xen.org/seabios.git;
-          rev = "e51488c5f8800a52ac5c8da7a31b85cca5cc95d2";
-          sha256 = "b96a0b9f31cab0f3993d007dcbe5f1bd69ad02b0a23eb2dc8a3ed1aafe7985cb";
+        { git = { name = "seabios";
+                  url = git://xenbits.xen.org/seabios.git;
+                  rev = "e51488c5f8800a52ac5c8da7a31b85cca5cc95d2";
+                  sha256 = "b96a0b9f31cab0f3993d007dcbe5f1bd69ad02b0a23eb2dc8a3ed1aafe7985cb";
+                };
+          patches = [ ./0000-qemu-seabios-enable-ATA_DMA.patch ];
         }
-        { name = "ovmf";
-          url = git://xenbits.xen.org/ovmf.git;
-          rev = "447d264115c476142f884af0be287622cd244423";
-          sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
+        { git = { name = "ovmf";
+                  url = git://xenbits.xen.org/ovmf.git;
+                  rev = "447d264115c476142f884af0be287622cd244423";
+                  sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
+                };
         }
       ];
 
     toolsGits =
       [ # tag qemu-xen-4.5.0
-        { name = "qemu-xen";
-          url = git://xenbits.xen.org/qemu-upstream-4.5-testing.git;
-          rev = "1ebb75b1fee779621b63e84fefa7b07354c43a99";
-          sha256 = "1j312q2mqvkvby9adkkxf7f1pn3nz85g5mr9nbg4qpf2y9cg122z";
+        { git = { name = "qemu-xen";
+                  url = git://xenbits.xen.org/qemu-upstream-4.5-testing.git;
+                  rev = "1ebb75b1fee779621b63e84fefa7b07354c43a99";
+                  sha256 = "1j312q2mqvkvby9adkkxf7f1pn3nz85g5mr9nbg4qpf2y9cg122z";
+                };
         }
         # tag xen-4.5.0
-        { name = "qemu-xen-traditional";
-          url = git://xenbits.xen.org/qemu-xen-4.5-testing.git;
-          rev = "b0d42741f8e9a00854c3b3faca1da84bfc69bf22";
-          sha256 = "ce52b5108936c30ab85ec0c9554f88d5e7b34896f3acb666d56765b49c86f2af";
+        { git = { name = "qemu-xen-traditional";
+                  url = git://xenbits.xen.org/qemu-xen-4.5-testing.git;
+                  rev = "b0d42741f8e9a00854c3b3faca1da84bfc69bf22";
+                  sha256 = "ce52b5108936c30ab85ec0c9554f88d5e7b34896f3acb666d56765b49c86f2af";
+                };
+        }
+        { git = { name = "xen-libhvm";
+                  url = "https://github.com/ts468/xen-libhvm";
+                  rev = "442dcc4f6f4e374a51e4613532468bd6b48bdf63";
+                  sha256 = "9ba97c39a00a54c154785716aa06691d312c99be498ebbc00dc3769968178ba8";
+                };
+          description = ''
+            Helper library for reading ACPI and SMBIOS firmware values
+            from the host system for use with the HVM guest firmware
+            pass-through feature in Xen.
+            '';
+          #license = licenses.bsd2;
         }
       ];
 
@@ -52,6 +69,10 @@ let
         quilt push -a
         substituteInPlace tools/xenguest/Makefile --replace "_BSD_SOURCE" "_DEFAULT_SOURCE"
         '';
+
+    xenPatches = [ ./0001-libxl-Spice-image-compression-setting-support-for-up.patch
+                   ./0002-libxl-Spice-streaming-video-setting-support-for-upst.patch
+                   ./0003-Add-qxl-vga-interface-support-for-upstream-qem.patch ];
   };
 
 in callPackage ./generic.nix (args // { xenConfig=xenConfig; })
diff --git a/pkgs/applications/virtualization/xen/generic.nix b/pkgs/applications/virtualization/xen/generic.nix
index 711fd505efa..2c92a983474 100644
--- a/pkgs/applications/virtualization/xen/generic.nix
+++ b/pkgs/applications/virtualization/xen/generic.nix
@@ -3,7 +3,7 @@
 , lvm2, utillinux, procps, texinfo, perl, pythonPackages
 , glib, bridge-utils, xlibs, pixman, iproute, udev, bison
 , flex, cmake, ocaml, ocamlPackages, figlet, libaio, yajl
-, checkpolicy, transfig, glusterfs, fetchgit, xz, spice
+, checkpolicy, transfig, glusterfs, acl, fetchgit, xz, spice
 , spice_protocol, usbredir, alsaLib, quilt
 , coreutils, gawk, gnused, gnugrep, diffutils, multipath_tools
 , inetutils, iptables, openvswitch, nbd, drbd, xenConfig
@@ -69,15 +69,14 @@ stdenv.mkDerivation {
       glib bridge-utils pixman iproute udev bison xlibs.libX11
       flex ocaml ocamlPackages.findlib figlet libaio
       checkpolicy pythonPackages.markdown transfig
-      glusterfs cmake spice spice_protocol usbredir
+      glusterfs acl cmake spice spice_protocol usbredir
       alsaLib quilt
     ];
 
   pythonPath = [ pythonPackages.curses ];
 
-  patchPhase = if ((xenserverPatched == true) && (builtins.hasAttr "xenserverPatches" xenConfig))
-    then xenConfig.xenserverPatches
-    else "";
+  patches = stdenv.lib.optionals ((xenserverPatched == false) && (builtins.hasAttr "xenPatches" xenConfig)) xenConfig.xenPatches;
+  patchPhase = stdenv.lib.optional ((xenserverPatched == true) && (builtins.hasAttr "xenserverPatches" xenConfig)) xenConfig.xenserverPatches;
 
   preConfigure = ''
     # Fake wget: copy prefetched downloads instead
@@ -87,13 +86,9 @@ stdenv.mkDerivation {
     echo "cp \$4 \$3" >> wget/wget
     chmod +x wget/wget
     export PATH=$PATH:$PWD/wget
+    export EXTRA_QEMUU_CONFIGURE_ARGS="--enable-spice --enable-usb-redir --enable-linux-aio"
   '';
 
-  # TODO: If multiple arguments are given with with-extra-qemuu,
-  #       then the configuration aborts; the reason is unclear.
-  #       If you know how to fix it, please let me know! :)
-  #configureFlags = "--with-extra-qemuu-configure-args='--enable-spice --enable-usb-redir --enable-linux-aio'";
-
   # TODO: Flask needs more testing before enabling it by default.
   #makeFlags = "XSM_ENABLE=y FLASK_ENABLE=y PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files ";
   makeFlags = "PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files ";
@@ -154,13 +149,17 @@ stdenv.mkDerivation {
 
       # Xen's tools and firmares need various git repositories that it
       # usually checks out at time using git.  We can't have that.
-      ${flip concatMapStrings xenConfig.toolsGits (x: let src = fetchgit x; in ''
+      ${flip concatMapStrings xenConfig.toolsGits (x: let src = fetchgit x.git; in ''
         cp -r ${src} tools/${src.name}-dir-remote
-        chmod +w tools/${src.name}-dir-remote
+        chmod -R +w tools/${src.name}-dir-remote
+      '' + stdenv.lib.optionalString (builtins.hasAttr "patches" x) ''
+        ( cd tools/${src.name}-dir-remote; ${concatStringsSep "; " (map (p: "patch -p1 < ${p}") x.patches)} )
       '')}
-      ${flip concatMapStrings xenConfig.firmwareGits (x: let src = fetchgit x; in ''
+      ${flip concatMapStrings xenConfig.firmwareGits (x: let src = fetchgit x.git; in ''
         cp -r ${src} tools/firmware/${src.name}-dir-remote
-        chmod +w tools/firmware/${src.name}-dir-remote
+        chmod -R +w tools/firmware/${src.name}-dir-remote
+      '' + stdenv.lib.optionalString (builtins.hasAttr "patches" x) ''
+        ( cd tools/firmware/${src.name}-dir-remote; ${concatStringsSep "; " (map (p: "patch -p1 < ${p}") x.patches)} )
       '')}
 
       # Xen's stubdoms and firmwares need various sources that are usually fetched
@@ -178,6 +177,9 @@ stdenv.mkDerivation {
   postBuild =
     ''
       make -C docs man-pages
+
+      (cd tools/xen-libhvm-dir-remote; make)
+      (cd tools/xen-libhvm-dir-remote/biospt; cc -Wall -g -D_LINUX -Wstrict-prototypes biospt.c -o biospt -I../libhvm -L../libhvm -lxenhvm)
     '';
 
   installPhase =
@@ -192,8 +194,11 @@ stdenv.mkDerivation {
 
       shopt -s extglob
       for i in $out/etc/xen/scripts/!(*.sh); do
-        sed -i '2s@^@export PATH=$out/bin:${scriptEnvPath}@' $i
+        sed -i "2s@^@export PATH=$out/bin:${scriptEnvPath}\n@" $i
       done
+
+      (cd tools/xen-libhvm-dir-remote; make install)
+      cp tools/xen-libhvm-dir-remote/biospt/biospt $out/bin/.
     '';
 
   meta = {