[pve-devel] [PATCH 3/9] qemu v1.4 patches

Stefan Priebe s.priebe at profihost.ag
Mon Feb 11 10:27:31 CET 2013


Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
---
 debian/patches/adjust-path.diff                    |   36 +-
 debian/patches/enable-kvm-by-default.patch         |   67 +--
 debian/patches/fairsched.diff                      |   53 ++-
 debian/patches/fix-qemu-img-snapshot-removal.patch |   26 +-
 debian/patches/internal-snapshot-async.patch       |  496 ++++++++++----------
 debian/patches/move-bdrv-snapshot-find.patch       |   40 +-
 debian/patches/pve-auth.patch                      |  460 +++++++++---------
 .../qemu-img-convert-skipcreate-option.patch       |   29 +-
 8 files changed, 636 insertions(+), 571 deletions(-)

diff --git a/debian/patches/adjust-path.diff b/debian/patches/adjust-path.diff
index 748e907..f595b4a 100644
--- a/debian/patches/adjust-path.diff
+++ b/debian/patches/adjust-path.diff
@@ -1,29 +1,35 @@
-Index: new/net.h
-===================================================================
---- new.orig/net.h	2012-11-21 11:11:22.000000000 +0100
-+++ new/net.h	2012-11-21 11:17:51.000000000 +0100
-@@ -161,8 +161,9 @@
- void netdev_add(QemuOpts *opts, Error **errp);
- int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret);
+commit d3eb1967397a8e895280a353b0cca8cedf278be1
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:18:43 2013 +0100
+
+    adjust-path.diff
+
+diff --git a/include/net/net.h b/include/net/net.h
+index 43a045e..2be8f8e 100644
+--- a/include/net/net.h
++++ b/include/net/net.h
+@@ -168,8 +168,8 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret);
+ int net_hub_id_for_client(NetClientState *nc, int *id);
+ NetClientState *net_hub_port_find(int hub_id);
  
 -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
 +#define DEFAULT_NETWORK_SCRIPT "/etc/kvm/kvm-ifup"
 +#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/kvm/kvm-ifdown"
-+
  #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
  #define DEFAULT_BRIDGE_INTERFACE "br0"
  
-Index: new/net/tap.h
-===================================================================
---- new.orig/net/tap.h	2012-11-21 11:11:22.000000000 +0100
-+++ new/net/tap.h	2012-11-21 11:17:51.000000000 +0100
-@@ -29,8 +29,6 @@
+diff --git a/net/tap_int.h b/net/tap_int.h
+index 86bb224..79afdf2 100644
+--- a/net/tap_int.h
++++ b/net/tap_int.h
+@@ -29,9 +29,6 @@
  #include "qemu-common.h"
  #include "qapi-types.h"
  
 -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
- 
- int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required);
+-
+ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
+              int vnet_hdr_required, int mq_required);
  
diff --git a/debian/patches/enable-kvm-by-default.patch b/debian/patches/enable-kvm-by-default.patch
index 61352d2..3449e0d 100644
--- a/debian/patches/enable-kvm-by-default.patch
+++ b/debian/patches/enable-kvm-by-default.patch
@@ -1,65 +1,78 @@
-Index: new/hw/pc_piix.c
-===================================================================
---- new.orig/hw/pc_piix.c	2012-11-22 10:10:56.000000000 +0100
-+++ new/hw/pc_piix.c	2012-11-22 10:16:29.000000000 +0100
-@@ -352,6 +352,8 @@
+commit 74afcf4e33c910b941ed075a962134ca6812fd61
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:57:33 2013 +0100
+
+    enable-kvm-by-default.patch
+
+diff --git a/hw/pc_piix.c b/hw/pc_piix.c
+index b9a9b2e..de2e8b6 100644
+--- a/hw/pc_piix.c
++++ b/hw/pc_piix.c
+@@ -294,12 +294,15 @@ static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
  }
  #endif
  
 +#define KVM_MACHINE_OPTIONS "accel=kvm"
 +
- static QEMUMachine pc_machine_v1_3 = {
-     .name = "pc-1.3",
+ static QEMUMachine pc_i440fx_machine_v1_4 = {
+     .name = "pc-i440fx-1.4",
      .alias = "pc",
-@@ -359,6 +361,7 @@
-     .init = pc_init_pci_1_3,
+     .desc = "Standard PC (i440FX + PIIX, 1996)",
+     .init = pc_init_pci,
      .max_cpus = 255,
-     .is_default = 1,
 +    .default_machine_opts = KVM_MACHINE_OPTIONS,
+     .is_default = 1,
+     DEFAULT_MACHINE_OPTIONS,
  };
- 
- #define PC_COMPAT_1_2 \
-@@ -393,6 +396,7 @@
+@@ -316,6 +319,7 @@ static QEMUMachine pc_machine_v1_3 = {
      .desc = "Standard PC",
-     .init = pc_init_pci,
+     .init = pc_init_pci_1_3,
+     .max_cpus = 255,
++    .default_machine_opts = KVM_MACHINE_OPTIONS,
+     .compat_props = (GlobalProperty[]) {
+         PC_COMPAT_1_3,
+         { /* end of list */ }
+@@ -356,6 +360,7 @@ static QEMUMachine pc_machine_v1_2 = {
+     .desc = "Standard PC",
+     .init = pc_init_pci_1_2,
      .max_cpus = 255,
 +    .default_machine_opts = KVM_MACHINE_OPTIONS,
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_1_2,
          { /* end of list */ }
-@@ -436,6 +440,7 @@
+@@ -400,6 +405,7 @@ static QEMUMachine pc_machine_v1_1 = {
      .desc = "Standard PC",
-     .init = pc_init_pci,
+     .init = pc_init_pci_1_2,
      .max_cpus = 255,
 +    .default_machine_opts = KVM_MACHINE_OPTIONS,
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_1_1,
          { /* end of list */ }
-@@ -471,6 +476,7 @@
+@@ -436,6 +442,7 @@ static QEMUMachine pc_machine_v1_0 = {
      .desc = "Standard PC",
-     .init = pc_init_pci,
+     .init = pc_init_pci_1_2,
      .max_cpus = 255,
 +    .default_machine_opts = KVM_MACHINE_OPTIONS,
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_1_0,
          { /* end of list */ }
-@@ -486,6 +492,7 @@
+@@ -452,6 +459,7 @@ static QEMUMachine pc_machine_v0_15 = {
      .desc = "Standard PC",
-     .init = pc_init_pci,
+     .init = pc_init_pci_1_2,
      .max_cpus = 255,
 +    .default_machine_opts = KVM_MACHINE_OPTIONS,
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_0_15,
          { /* end of list */ }
-@@ -518,6 +525,7 @@
+@@ -485,6 +493,7 @@ static QEMUMachine pc_machine_v0_14 = {
      .desc = "Standard PC",
-     .init = pc_init_pci,
+     .init = pc_init_pci_1_2,
      .max_cpus = 255,
 +    .default_machine_opts = KVM_MACHINE_OPTIONS,
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_0_14, 
          {
-@@ -551,6 +559,7 @@
+@@ -519,6 +528,7 @@ static QEMUMachine pc_machine_v0_13 = {
      .desc = "Standard PC",
      .init = pc_init_pci_no_kvmclock,
      .max_cpus = 255,
@@ -67,7 +80,7 @@ Index: new/hw/pc_piix.c
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_0_13,
          {
-@@ -588,6 +597,7 @@
+@@ -557,6 +567,7 @@ static QEMUMachine pc_machine_v0_12 = {
      .desc = "Standard PC",
      .init = pc_init_pci_no_kvmclock,
      .max_cpus = 255,
@@ -75,7 +88,7 @@ Index: new/hw/pc_piix.c
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_0_12,
          {
-@@ -621,6 +631,7 @@
+@@ -591,6 +602,7 @@ static QEMUMachine pc_machine_v0_11 = {
      .desc = "Standard PC, qemu 0.11",
      .init = pc_init_pci_no_kvmclock,
      .max_cpus = 255,
@@ -83,7 +96,7 @@ Index: new/hw/pc_piix.c
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_0_11,
          {
-@@ -642,6 +653,7 @@
+@@ -613,6 +625,7 @@ static QEMUMachine pc_machine_v0_10 = {
      .desc = "Standard PC, qemu 0.10",
      .init = pc_init_pci_no_kvmclock,
      .max_cpus = 255,
@@ -91,7 +104,7 @@ Index: new/hw/pc_piix.c
      .compat_props = (GlobalProperty[]) {
          PC_COMPAT_0_11,
          {
-@@ -675,6 +687,7 @@
+@@ -647,6 +660,7 @@ static QEMUMachine isapc_machine = {
      .desc = "ISA-only PC",
      .init = pc_init_isa,
      .max_cpus = 1,
diff --git a/debian/patches/fairsched.diff b/debian/patches/fairsched.diff
index 7e1799e..04482bf 100644
--- a/debian/patches/fairsched.diff
+++ b/debian/patches/fairsched.diff
@@ -1,8 +1,14 @@
-Index: new/qemu-options.hx
-===================================================================
---- new.orig/qemu-options.hx	2012-11-21 11:11:22.000000000 +0100
-+++ new/qemu-options.hx	2012-11-21 11:25:23.000000000 +0100
-@@ -103,6 +103,12 @@
+commit d909f5b2de14beb7e2ac69ad2b4b66a4b25512d6
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:19:37 2013 +0100
+
+    fairsched.diff
+
+diff --git a/qemu-options.hx b/qemu-options.hx
+index 2d44137..9dc2c5d 100644
+--- a/qemu-options.hx
++++ b/qemu-options.hx
+@@ -103,6 +103,12 @@ Simulate a multi node NUMA system. If mem and cpus are omitted, resources
  are split equally.
  ETEXI
  
@@ -15,20 +21,20 @@ Index: new/qemu-options.hx
  DEF("fda", HAS_ARG, QEMU_OPTION_fda,
      "-fda/-fdb file  use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL)
  DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
-Index: new/vl.c
-===================================================================
---- new.orig/vl.c	2012-11-21 11:11:22.000000000 +0100
-+++ new/vl.c	2012-11-21 11:25:23.000000000 +0100
-@@ -154,6 +154,8 @@
+diff --git a/vl.c b/vl.c
+index 7aab73b..6c7fb5c 100644
+--- a/vl.c
++++ b/vl.c
+@@ -154,6 +154,8 @@ int main(int argc, char **argv)
  #endif
- #include "qtest.h"
+ #include "sysemu/qtest.h"
  
 +#include "vzsyscalls.h"
 +
- #include "disas.h"
+ #include "disas/disas.h"
  
- #include "qemu_socket.h"
-@@ -205,6 +207,7 @@
+ #include "qemu/sockets.h"
+@@ -205,6 +207,7 @@ CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
  CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
  int win2k_install_hack = 0;
  int singlestep = 0;
@@ -36,7 +42,7 @@ Index: new/vl.c
  int smp_cpus = 1;
  int max_cpus = 0;
  int smp_cores = 1;
-@@ -2275,7 +2278,7 @@
+@@ -2459,7 +2462,7 @@ static int virtcon_parse(const char *devname)
  }
  
  static int debugcon_parse(const char *devname)
@@ -45,7 +51,7 @@ Index: new/vl.c
      QemuOpts *opts;
  
      if (!qemu_chr_new("debugcon", devname, NULL)) {
-@@ -2527,6 +2530,9 @@
+@@ -2711,6 +2714,9 @@ static int object_create(QemuOpts *opts, void *opaque)
  int main(int argc, char **argv, char **envp)
  {
      int i;
@@ -55,7 +61,7 @@ Index: new/vl.c
      int snapshot, linux_boot;
      const char *icount_option = NULL;
      const char *initrd_filename;
-@@ -3306,6 +3312,21 @@
+@@ -3500,6 +3506,21 @@ int main(int argc, char **argv, char **envp)
                      exit(1);
                  }
                  break;
@@ -77,7 +83,7 @@ Index: new/vl.c
  	    case QEMU_OPTION_vnc:
  #ifdef CONFIG_VNC
                  display_remote++;
-@@ -3377,8 +3398,8 @@
+@@ -3571,8 +3592,8 @@ int main(int argc, char **argv, char **envp)
  			}
  			p += 8;
  			os_set_proc_name(p);
@@ -88,7 +94,7 @@ Index: new/vl.c
                  break;
              case QEMU_OPTION_prom_env:
                  if (nb_prom_envs >= MAX_PROM_ENVS) {
-@@ -3765,6 +3786,39 @@
+@@ -3986,6 +4007,39 @@ int main(int argc, char **argv, char **envp)
          }
      }
  
@@ -128,10 +134,11 @@ Index: new/vl.c
      cpu_exec_init_all();
  
      bdrv_init_with_whitelist();
-Index: new/vzsyscalls.h
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ new/vzsyscalls.h	2012-11-21 11:25:23.000000000 +0100
+diff --git a/vzsyscalls.h b/vzsyscalls.h
+new file mode 100644
+index 0000000..bd9416f
+--- /dev/null
++++ b/vzsyscalls.h
 @@ -0,0 +1,47 @@
 +/*
 + *  Copyright (C) 2000-2008, Parallels, Inc. All rights reserved.
diff --git a/debian/patches/fix-qemu-img-snapshot-removal.patch b/debian/patches/fix-qemu-img-snapshot-removal.patch
index 7a6ad3b..2ad6067 100644
--- a/debian/patches/fix-qemu-img-snapshot-removal.patch
+++ b/debian/patches/fix-qemu-img-snapshot-removal.patch
@@ -1,15 +1,21 @@
-Index: new/qemu-img.c
-===================================================================
---- new.orig/qemu-img.c	2012-11-21 11:11:22.000000000 +0100
-+++ new/qemu-img.c	2012-11-21 11:51:19.000000000 +0100
-@@ -1580,7 +1580,9 @@
+commit 4a9a98ef9c53ea64fe8fb47273261752cc98196f
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:23:58 2013 +0100
+
+    fix-qemu-img-snapshot-removal.patch
+
+diff --git a/qemu-img.c b/qemu-img.c
+index 85d3740..3fcb59e 100644
+--- a/qemu-img.c
++++ b/qemu-img.c
+@@ -1585,6 +1585,10 @@ static int img_snapshot(int argc, char **argv)
              error_report("Could not delete snapshot '%s': %d (%s)",
                  snapshot_name, ret, strerror(-ret));
          }
--        break;
-+ 	// return success if snapshot does not exists
-+	if (ret == -ENOENT) ret = 0;
-+       break;
++        // return success if snapshot does not exists
++        if (ret == -ENOENT) {
++            ret = 0;
++        }
+         break;
      }
  
-     /* Cleanup */
diff --git a/debian/patches/internal-snapshot-async.patch b/debian/patches/internal-snapshot-async.patch
index 6c86de3..e18bd2e 100644
--- a/debian/patches/internal-snapshot-async.patch
+++ b/debian/patches/internal-snapshot-async.patch
@@ -1,109 +1,82 @@
-Index: new/qapi-schema.json
-===================================================================
---- new.orig/qapi-schema.json	2012-11-23 07:30:15.000000000 +0100
-+++ new/qapi-schema.json	2012-11-23 07:31:44.000000000 +0100
-@@ -461,6 +461,40 @@
-            '*downtime': 'int'} }
+commit 687f841def16f2a076d51e4b05dd25a380954530
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:34:43 2013 +0100
+
+    internal-snapshot-async.patch
+    
+    Conflicts:
+    	hmp.c
+    	hmp.h
+    	qmp-commands.hx
+
+diff --git a/Makefile.objs b/Makefile.objs
+index 21e9c91..9829239 100644
+--- a/Makefile.objs
++++ b/Makefile.objs
+@@ -60,6 +60,7 @@ common-obj-y += migration.o migration-tcp.o
+ common-obj-y += qemu-char.o #aio.o
+ common-obj-y += block-migration.o
+ common-obj-y += page_cache.o xbzrle.o
++common-obj-y += savevm-async.o
  
- ##
-+# @SaveVMInfo
-+#
-+# Information about current migration process.
-+#
-+# @status: #optional string describing the current savevm status.
-+#          This can be 'active', 'completed', 'failed'.
-+#          If this field is not returned, no savevm process
-+#          has been initiated
-+#
-+# @error: #optional string containing error message is status is failed.
-+#
-+# @total-time: #optional total amount of milliseconds since savevm started.
-+#        If savevm has ended, it returns the total save time
-+#
-+# @bytes: #optional total amount of data transfered
-+#
-+# Since: 1.3
-+##
-+{ 'type': 'SaveVMInfo',
-+  'data': {'*status': 'str', '*error': 'str',
-+           '*total-time': 'int', '*bytes': 'int'} }
-+
-+##
-+# @query-savevm
-+#
-+# Returns information about current savevm process.
-+#
-+# Returns: @SaveVMInfo
-+#
-+# Since: 1.3
-+##
-+{ 'command': 'query-savevm', 'returns': 'SaveVMInfo' }
-+
-+##
- # @query-migrate
- #
- # Returns information about current migration process.
-@@ -2902,6 +2936,14 @@
- ##
- { 'command': 'query-target', 'returns': 'TargetInfo' }
+ common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
  
-+{ 'command': 'savevm-start' 'data': { '*statefile': 'str' } }
-+
-+{ 'command': 'snapshot-drive', 'data': { 'device': 'str', 'name': 'str' } }
-+
-+{ 'command': 'delete-drive-snapshot', 'data': { 'device': 'str', 'name': 'str' } }
-+
-+{ 'command': 'savevm-end' }
-+
- ##
- # @QKeyCode:
- #
-Index: new/qmp-commands.hx
-===================================================================
---- new.orig/qmp-commands.hx	2012-11-23 07:30:15.000000000 +0100
-+++ new/qmp-commands.hx	2012-11-23 07:31:44.000000000 +0100
-@@ -2654,3 +2654,34 @@
-         .args_type  = "",
-         .mhandler.cmd_new = qmp_marshal_input_query_target,
-     },
+diff --git a/hmp-commands.hx b/hmp-commands.hx
+index bdd48f3..9a30da4 100644
+--- a/hmp-commands.hx
++++ b/hmp-commands.hx
+@@ -1634,6 +1634,8 @@ show migration status
+ show current migration capabilities
+ @item info migrate_cache_size
+ show current migration XBZRLE cache size
++ at item info savevm
++show savevm status
+ @item info balloon
+ show balloon information
+ @item info qtree
+@@ -1653,3 +1655,35 @@ ETEXI
+ STEXI
+ @end table
+ ETEXI
 +
 +    {
 +        .name       = "savevm-start",
 +        .args_type  = "statefile:s?",
-+        .mhandler.cmd_new = qmp_marshal_input_savevm_start,
++        .params     = "[statefile]",
++        .help       = "Prepare for snapshot and halt VM. Save VM state to statefile.",
++        .mhandler.cmd = hmp_savevm_start,
 +    },
 +
 +    {
 +        .name       = "snapshot-drive",
 +        .args_type  = "device:s,name:s",
-+        .mhandler.cmd_new = qmp_marshal_input_snapshot_drive,
++        .params     = "device name",
++        .help       = "Create internal snapshot.",
++        .mhandler.cmd = hmp_snapshot_drive,
 +    },
 +
 +    {
 +        .name       = "delete-drive-snapshot",
 +        .args_type  = "device:s,name:s",
-+        .mhandler.cmd_new = qmp_marshal_input_delete_drive_snapshot,
++        .params     = "device name",
++        .help       = "Delete internal snapshot.",
++        .mhandler.cmd = hmp_delete_drive_snapshot,
 +    },
 +
 +    {
 +        .name       = "savevm-end",
 +        .args_type  = "",
-+        .mhandler.cmd_new = qmp_marshal_input_savevm_end,
-+    },
-+
-+    {
-+        .name       = "query-savevm",
-+        .args_type  = "",
-+        .mhandler.cmd_new = qmp_marshal_input_query_savevm,
++        .params     = "",
++        .help       = "Resume VM after snaphot.",
++        .mhandler.cmd = hmp_savevm_end,
 +    },
-+
-Index: new/hmp.c
-===================================================================
---- new.orig/hmp.c	2012-11-23 07:30:15.000000000 +0100
-+++ new/hmp.c	2012-11-23 07:31:44.000000000 +0100
-@@ -1335,3 +1335,60 @@
-     qmp_nbd_server_stop(&errp);
-     hmp_handle_error(mon, &errp);
+diff --git a/hmp.c b/hmp.c
+index 1689e6f..97816a5 100644
+--- a/hmp.c
++++ b/hmp.c
+@@ -1371,3 +1371,60 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
+     qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
+     hmp_handle_error(mon, &local_err);
  }
 +
 +void hmp_savevm_start(Monitor *mon, const QDict *qdict)
@@ -143,7 +116,7 @@ Index: new/hmp.c
 +    hmp_handle_error(mon, &errp);
 +}
 +
-+void hmp_info_savevm(Monitor *mon)
++void hmp_info_savevm(Monitor *mon, const QDict *qdict)
 +{
 +    SaveVMInfo *info;
 +    info = qmp_query_savevm(NULL);
@@ -162,19 +135,19 @@ Index: new/hmp.c
 +        monitor_printf(mon, "Error: %s\n", info->error);
 +    }
 +}
-Index: new/hmp.h
-===================================================================
---- new.orig/hmp.h	2012-11-23 07:30:15.000000000 +0100
-+++ new/hmp.h	2012-11-23 07:31:44.000000000 +0100
-@@ -25,6 +25,7 @@
- void hmp_info_uuid(Monitor *mon);
- void hmp_info_chardev(Monitor *mon);
- void hmp_info_mice(Monitor *mon);
-+void hmp_info_savevm(Monitor *mon);
- void hmp_info_migrate(Monitor *mon);
- void hmp_info_migrate_capabilities(Monitor *mon);
- void hmp_info_migrate_cache_size(Monitor *mon);
-@@ -75,6 +76,10 @@
+diff --git a/hmp.h b/hmp.h
+index 076d8cf..0071608 100644
+--- a/hmp.h
++++ b/hmp.h
+@@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict);
+ void hmp_info_uuid(Monitor *mon, const QDict *qdict);
+ void hmp_info_chardev(Monitor *mon, const QDict *qdict);
+ void hmp_info_mice(Monitor *mon, const QDict *qdict);
++void hmp_info_savevm(Monitor *mon, const QDict *qdict);
+ void hmp_info_migrate(Monitor *mon, const QDict *qdict);
+ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
+ void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
+@@ -77,6 +78,10 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict);
  void hmp_netdev_del(Monitor *mon, const QDict *qdict);
  void hmp_getfd(Monitor *mon, const QDict *qdict);
  void hmp_closefd(Monitor *mon, const QDict *qdict);
@@ -185,70 +158,177 @@ Index: new/hmp.h
  void hmp_send_key(Monitor *mon, const QDict *qdict);
  void hmp_screen_dump(Monitor *mon, const QDict *qdict);
  void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
-Index: new/hmp-commands.hx
-===================================================================
---- new.orig/hmp-commands.hx	2012-11-23 07:30:15.000000000 +0100
-+++ new/hmp-commands.hx	2012-11-23 07:31:44.000000000 +0100
-@@ -1562,6 +1562,8 @@
- show current migration capabilities
- @item info migrate_cache_size
- show current migration XBZRLE cache size
-+ at item info savevm
-+show savevm status
- @item info balloon
- show balloon information
- @item info qtree
-@@ -1581,3 +1583,35 @@
- STEXI
- @end table
+diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
+index 1d9599e..3e580f6 100644
+--- a/include/sysemu/sysemu.h
++++ b/include/sysemu/sysemu.h
+@@ -67,6 +67,7 @@ void qemu_add_machine_init_done_notifier(Notifier *notify);
+ 
+ void do_savevm(Monitor *mon, const QDict *qdict);
+ int load_vmstate(const char *name);
++int load_state_from_blockdev(const char *filename);
+ void do_delvm(Monitor *mon, const QDict *qdict);
+ void do_info_snapshots(Monitor *mon, const QDict *qdict);
+ 
+diff --git a/monitor.c b/monitor.c
+index 20bd19b..9f3f45f 100644
+--- a/monitor.c
++++ b/monitor.c
+@@ -2687,6 +2687,13 @@ static mon_cmd_t info_cmds[] = {
+         .mhandler.cmd = hmp_info_migrate_cache_size,
+     },
+     {
++        .name       = "savevm",
++        .args_type  = "",
++        .params     = "",
++        .help       = "show savevm status",
++        .mhandler.cmd = hmp_info_savevm,
++    },
++    {
+         .name       = "balloon",
+         .args_type  = "",
+         .params     = "",
+diff --git a/qapi-schema.json b/qapi-schema.json
+index cdd8384..1374f63 100644
+--- a/qapi-schema.json
++++ b/qapi-schema.json
+@@ -535,6 +535,40 @@
+            '*downtime': 'int'} }
+ 
+ ##
++# @SaveVMInfo
++#
++# Information about current migration process.
++#
++# @status: #optional string describing the current savevm status.
++#          This can be 'active', 'completed', 'failed'.
++#          If this field is not returned, no savevm process
++#          has been initiated
++#
++# @error: #optional string containing error message is status is failed.
++#
++# @total-time: #optional total amount of milliseconds since savevm started.
++#        If savevm has ended, it returns the total save time
++#
++# @bytes: #optional total amount of data transfered
++#
++# Since: 1.3
++##
++{ 'type': 'SaveVMInfo',
++  'data': {'*status': 'str', '*error': 'str',
++           '*total-time': 'int', '*bytes': 'int'} }
++
++##
++# @query-savevm
++#
++# Returns information about current savevm process.
++#
++# Returns: @SaveVMInfo
++#
++# Since: 1.3
++##
++{ 'command': 'query-savevm', 'returns': 'SaveVMInfo' }
++
++##
+ # @query-migrate
+ #
+ # Returns information about current migration process.
+@@ -2972,6 +3006,14 @@
+ ##
+ { 'command': 'query-target', 'returns': 'TargetInfo' }
+ 
++{ 'command': 'savevm-start' 'data': { '*statefile': 'str' } }
++
++{ 'command': 'snapshot-drive', 'data': { 'device': 'str', 'name': 'str' } }
++
++{ 'command': 'delete-drive-snapshot', 'data': { 'device': 'str', 'name': 'str' } }
++
++{ 'command': 'savevm-end' }
++
+ ##
+ # @QKeyCode:
+ #
+diff --git a/qemu-options.hx b/qemu-options.hx
+index 9dc2c5d..7d5658d 100644
+--- a/qemu-options.hx
++++ b/qemu-options.hx
+@@ -2608,6 +2608,19 @@ STEXI
+ Start right away with a saved state (@code{loadvm} in monitor)
  ETEXI
+ 
++DEF("loadstate", HAS_ARG, QEMU_OPTION_loadstate, \
++    "-loadstate file\n" \
++    "                start right away with a saved state\n",
++    QEMU_ARCH_ALL)
++STEXI
++ at item -loadstate @var{file}
++ at findex -loadstate
++Start right away with a saved state. This option does not rollback
++disk state like @code{loadvm}, so user must make sure that disk
++have correct state. @var{file} can be any valid device URL. See the section
++for "Device URL Syntax" for more information.
++ETEXI
 +
+ #ifndef _WIN32
+ DEF("daemonize", 0, QEMU_OPTION_daemonize, \
+     "-daemonize      daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
+diff --git a/qmp-commands.hx b/qmp-commands.hx
+index bbb21f3..69e262b 100644
+--- a/qmp-commands.hx
++++ b/qmp-commands.hx
+@@ -973,6 +973,36 @@ EQMP
+         .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_sync,
+     },
+ 
 +    {
 +        .name       = "savevm-start",
 +        .args_type  = "statefile:s?",
-+        .params     = "[statefile]",
-+        .help       = "Prepare for snapshot and halt VM. Save VM state to statefile.",
-+        .mhandler.cmd = hmp_savevm_start,
++        .mhandler.cmd_new = qmp_marshal_input_savevm_start,
 +    },
 +
 +    {
 +        .name       = "snapshot-drive",
 +        .args_type  = "device:s,name:s",
-+        .params     = "device name",
-+        .help       = "Create internal snapshot.",
-+        .mhandler.cmd = hmp_snapshot_drive,
++        .mhandler.cmd_new = qmp_marshal_input_snapshot_drive,
 +    },
 +
 +    {
 +        .name       = "delete-drive-snapshot",
 +        .args_type  = "device:s,name:s",
-+        .params     = "device name",
-+        .help       = "Delete internal snapshot.",
-+        .mhandler.cmd = hmp_delete_drive_snapshot,
++        .mhandler.cmd_new = qmp_marshal_input_delete_drive_snapshot,
 +    },
 +
 +    {
 +        .name       = "savevm-end",
 +        .args_type  = "",
-+        .params     = "",
-+        .help       = "Resume VM after snaphot.",
-+        .mhandler.cmd = hmp_savevm_end,
++        .mhandler.cmd_new = qmp_marshal_input_savevm_end,
 +    },
-Index: new/savevm-async.c
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ new/savevm-async.c	2012-11-23 07:32:48.000000000 +0100
-@@ -0,0 +1,458 @@
-+#include "qemu-common.h"
-+#include "qerror.h"
-+#include "sysemu.h"
++
++    {
++        .name       = "query-savevm",
++        .args_type  = "",
++        .mhandler.cmd_new = qmp_marshal_input_query_savevm,
++    },
++
+ SQMP
+ blockdev-snapshot-sync
+ ----------------------
+diff --git a/savevm-async.c b/savevm-async.c
+new file mode 100644
+index 0000000..e421379
+--- /dev/null
++++ b/savevm-async.c
+@@ -0,0 +1,470 @@
++#include "include/qemu-common.h"
++#include "include/qapi/qmp/qerror.h"
++#include "include/sysemu/sysemu.h"
 +#include "qmp-commands.h"
-+#include "blockdev.h"
-+#include "qemu/qom-qobject.h"
-+#include "buffered_file.h"
-+#include "migration.h"
++#include "include/migration/qemu-file.h"
++#include "include/sysemu/blockdev.h"
++#include "include/qom/qom-qobject.h"
++#include "include/migration/migration.h"
 +
-+/* #define DEBUG_SAVEVM_STATE */
++#define DEBUG_SAVEVM_STATE
 +
 +#ifdef DEBUG_SAVEVM_STATE
 +#define DPRINTF(fmt, ...) \
@@ -273,6 +353,7 @@ Index: new/savevm-async.c
 +    int saved_vm_running;
 +    QEMUFile *file;
 +    int64_t total_time;
++    bool complete;
 +} snap_state;
 +
 +SaveVMInfo *qmp_query_savevm(Error **errp)
@@ -395,8 +476,8 @@ Index: new/savevm-async.c
 +static void process_savevm_co(void *opaque)
 +{
 +    int ret;
-+    uint64_t remaining;
 +    int64_t maxlen;
++    int64_t max_size = 0;
 +    MigrationParams params = {
 +        .blk = 0,
 +        .shared = 0
@@ -410,41 +491,52 @@ Index: new/savevm-async.c
 +        return;
 +    }
 +
-+    while (snap_state.state == SAVE_STATE_ACTIVE) {
++    while (true) {
++        uint64_t pending_size;
 +
-+        ret = qemu_savevm_state_iterate(snap_state.file);
-+        remaining = ram_bytes_remaining();
-+
-+        DPRINTF("savevm inerate %zd %d\n", remaining, ret);
-+
-+        if (ret < 0) {
-+            save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
-+            return;
++        if (snap_state.state != SAVE_STATE_ACTIVE) {
++            DPRINTF("put_ready returning because of non-active state\n");
++            break;
 +        }
 +
-+        /* stop the VM if we get to the end of available space,
-+         * or if remaining is just a few MB
-+         */
-+        maxlen = bdrv_getlength(snap_state.bs) - 30*1024*1024;
-+        if ((remaining < 100000) ||
-+            ((snap_state.bs_pos + remaining) >= maxlen)) {
-+            if (runstate_is_running()) {
-+                vm_stop(RUN_STATE_SAVE_VM);
-+            }
++        if (snap_state.complete) {
++            break;
 +        }
 +
-+        if (ret == 1) { /* finished */
++        pending_size = qemu_savevm_state_pending(snap_state.file, max_size);
++
++        if (pending_size && pending_size >= max_size) {
++                ret = qemu_savevm_state_iterate(snap_state.file);
++                if (ret < 0) {
++                    save_snapshot_error("qemu_savevm_state_iterate error %d", ret);
++                    break;
++                }
++                DPRINTF("avevm inerate pending size %lu max %lu ret %d\n", pending_size, max_size, ret);
++        } else {
++            DPRINTF("done iterating\n");
 +            if (runstate_is_running()) {
 +                vm_stop(RUN_STATE_SAVE_VM);
 +            }
 +            DPRINTF("savevm inerate finished\n");
-+            if ((ret = qemu_savevm_state_complete(snap_state.file)) < 0) {
++            ret = qemu_savevm_state_complete(snap_state.file);
++            if (ret < 0) {
 +                save_snapshot_error("qemu_savevm_state_complete error %d", ret);
-+                return;
++                break;
 +            } else {
 +                DPRINTF("save complete\n");
 +                save_snapshot_completed();
-+                return;
++                break;
++            }
++        }
++
++        /* stop the VM if we get to the end of available space,
++         * or if pending_size is just a few MB
++         */
++        maxlen = bdrv_getlength(snap_state.bs) - 30*1024*1024;
++        if ((pending_size < 100000) ||
++            ((snap_state.bs_pos + pending_size) >= maxlen)) {
++            if (runstate_is_running()) {
++                vm_stop(RUN_STATE_SAVE_VM);
 +            }
 +        }
 +    }
@@ -697,59 +789,11 @@ Index: new/savevm-async.c
 +    }
 +    return ret;
 +}
-Index: new/Makefile.objs
-===================================================================
---- new.orig/Makefile.objs	2012-11-23 07:30:15.000000000 +0100
-+++ new/Makefile.objs	2012-11-23 07:31:44.000000000 +0100
-@@ -84,6 +84,7 @@
- common-obj-y += block-migration.o iohandler.o
- common-obj-y += bitmap.o bitops.o
- common-obj-y += page_cache.o
-+common-obj-y += savevm-async.o
- 
- common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
- common-obj-$(CONFIG_WIN32) += version.o
-Index: new/sysemu.h
-===================================================================
---- new.orig/sysemu.h	2012-11-23 07:30:15.000000000 +0100
-+++ new/sysemu.h	2012-11-23 07:31:44.000000000 +0100
-@@ -67,6 +67,7 @@
- 
- void do_savevm(Monitor *mon, const QDict *qdict);
- int load_vmstate(const char *name);
-+int load_state_from_blockdev(const char *filename);
- void do_delvm(Monitor *mon, const QDict *qdict);
- void do_info_snapshots(Monitor *mon);
- 
-Index: new/qemu-options.hx
-===================================================================
---- new.orig/qemu-options.hx	2012-11-23 07:31:24.000000000 +0100
-+++ new/qemu-options.hx	2012-11-23 07:31:44.000000000 +0100
-@@ -2575,6 +2575,19 @@
- Start right away with a saved state (@code{loadvm} in monitor)
- ETEXI
- 
-+DEF("loadstate", HAS_ARG, QEMU_OPTION_loadstate, \
-+    "-loadstate file\n" \
-+    "                start right away with a saved state\n",
-+    QEMU_ARCH_ALL)
-+STEXI
-+ at item -loadstate @var{file}
-+ at findex -loadstate
-+Start right away with a saved state. This option does not rollback
-+disk state like @code{loadvm}, so user must make sure that disk
-+have correct state. @var{file} can be any valid device URL. See the section
-+for "Device URL Syntax" for more information.
-+ETEXI
-+
- #ifndef _WIN32
- DEF("daemonize", 0, QEMU_OPTION_daemonize, \
-     "-daemonize      daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
-Index: new/vl.c
-===================================================================
---- new.orig/vl.c	2012-11-23 07:31:29.000000000 +0100
-+++ new/vl.c	2012-11-23 07:31:44.000000000 +0100
-@@ -2545,6 +2545,7 @@
+diff --git a/vl.c b/vl.c
+index 816663d..a1897db 100644
+--- a/vl.c
++++ b/vl.c
+@@ -2769,6 +2769,7 @@ int main(int argc, char **argv, char **envp)
      int optind;
      const char *optarg;
      const char *loadvm = NULL;
@@ -757,7 +801,7 @@ Index: new/vl.c
      QEMUMachine *machine;
      const char *cpu_model;
      const char *vga_model = "none";
-@@ -3185,6 +3186,9 @@
+@@ -3423,6 +3424,9 @@ int main(int argc, char **argv, char **envp)
  	    case QEMU_OPTION_loadvm:
  		loadvm = optarg;
  		break;
@@ -767,7 +811,7 @@ Index: new/vl.c
              case QEMU_OPTION_full_screen:
                  full_screen = 1;
                  break;
-@@ -4038,6 +4042,10 @@
+@@ -4314,6 +4318,10 @@ int main(int argc, char **argv, char **envp)
          if (load_vmstate(loadvm) < 0) {
              autostart = 0;
          }
@@ -778,21 +822,3 @@ Index: new/vl.c
      }
  
      if (incoming) {
-Index: new/monitor.c
-===================================================================
---- new.orig/monitor.c	2012-11-23 07:30:15.000000000 +0100
-+++ new/monitor.c	2012-11-23 07:31:44.000000000 +0100
-@@ -2701,6 +2701,13 @@
-         .mhandler.info = hmp_info_migrate_cache_size,
-     },
-     {
-+        .name       = "savevm",
-+        .args_type  = "",
-+        .params     = "",
-+        .help       = "show savevm status",
-+        .mhandler.info = hmp_info_savevm,
-+    },
-+    {
-         .name       = "balloon",
-         .args_type  = "",
-         .params     = "",
diff --git a/debian/patches/move-bdrv-snapshot-find.patch b/debian/patches/move-bdrv-snapshot-find.patch
index 33e6357..612a82b 100644
--- a/debian/patches/move-bdrv-snapshot-find.patch
+++ b/debian/patches/move-bdrv-snapshot-find.patch
@@ -1,13 +1,19 @@
-Index: new/block.c
-===================================================================
---- new.orig/block.c	2012-11-21 11:11:22.000000000 +0100
-+++ new/block.c	2012-11-21 11:51:35.000000000 +0100
-@@ -3137,6 +3137,28 @@
+commit fe9a0c44d65ab94c5557edbcc5ffe438a854b8b7
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:27:59 2013 +0100
+
+    move-bdrv-snapshot-find.patch
+
+diff --git a/block.c b/block.c
+index ba67c0d..4f40958 100644
+--- a/block.c
++++ b/block.c
+@@ -3160,6 +3160,28 @@ int bdrv_snapshot_list(BlockDriverState *bs,
      return -ENOTSUP;
  }
  
 +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
-+		       const char *name)
++                              const char *name)
 +{
 +    QEMUSnapshotInfo *sn_tab, *sn;
 +    int nb_sns, i, ret;
@@ -31,24 +37,24 @@ Index: new/block.c
  int bdrv_snapshot_load_tmp(BlockDriverState *bs,
          const char *snapshot_name)
  {
-Index: new/block.h
-===================================================================
---- new.orig/block.h	2012-11-21 11:11:22.000000000 +0100
-+++ new/block.h	2012-11-21 11:51:35.000000000 +0100
-@@ -327,6 +327,8 @@
+diff --git a/include/block/block.h b/include/block/block.h
+index 5c3b911..c51c2b9 100644
+--- a/include/block/block.h
++++ b/include/block/block.h
+@@ -331,6 +331,8 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
  int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
  int bdrv_snapshot_list(BlockDriverState *bs,
                         QEMUSnapshotInfo **psn_info);
 +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
-+		       const char *name);
++                      const char *name);
  int bdrv_snapshot_load_tmp(BlockDriverState *bs,
                             const char *snapshot_name);
  char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
-Index: new/savevm.c
-===================================================================
---- new.orig/savevm.c	2012-11-21 11:11:22.000000000 +0100
-+++ new/savevm.c	2012-11-21 11:51:35.000000000 +0100
-@@ -2061,28 +2061,6 @@
+diff --git a/savevm.c b/savevm.c
+index 304d1ef..ff91538 100644
+--- a/savevm.c
++++ b/savevm.c
+@@ -2029,28 +2029,6 @@ out:
      return ret;
  }
  
diff --git a/debian/patches/pve-auth.patch b/debian/patches/pve-auth.patch
index 241cd79..8ab05a0 100644
--- a/debian/patches/pve-auth.patch
+++ b/debian/patches/pve-auth.patch
@@ -1,8 +1,220 @@
-Index: new/ui/vnc.c
-===================================================================
---- new.orig/ui/vnc.c	2012-11-21 11:25:33.000000000 +0100
-+++ new/ui/vnc.c	2012-11-21 11:32:25.000000000 +0100
-@@ -43,6 +43,125 @@
+commit 782c32242e09749ae2aa46a1e8846383dae1292d
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:20:41 2013 +0100
+
+    pve-auth.patch
+
+diff --git a/include/ui/console.h b/include/ui/console.h
+index fc23baa..77efd2e 100644
+--- a/include/ui/console.h
++++ b/include/ui/console.h
+@@ -457,6 +457,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
+ void cocoa_display_init(DisplayState *ds, int full_screen);
+ 
+ /* vnc.c */
++void pve_auth_setup(int vmid);
+ void vnc_display_init(DisplayState *ds);
+ void vnc_display_open(DisplayState *ds, const char *display, Error **errp);
+ void vnc_display_add_client(DisplayState *ds, int csock, int skipauth);
+diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c
+index c59b188..3674cad 100644
+--- a/ui/vnc-auth-vencrypt.c
++++ b/ui/vnc-auth-vencrypt.c
+@@ -25,7 +25,107 @@
+  */
+ 
+ #include "vnc.h"
++#include "qemu/sockets.h"
+ 
++static int protocol_client_auth_plain(VncState *vs, uint8_t *data, size_t len)
++{
++	const char *err = NULL;
++	char username[256];
++	char passwd[512];
++
++	char clientip[256];
++	clientip[0] = 0;
++	struct sockaddr_in client;
++	socklen_t addrlen = sizeof(client);
++	if (getpeername(vs->csock, &client, &addrlen) == 0) {
++		inet_ntop(client.sin_family, &client.sin_addr,
++			  clientip, sizeof(clientip));
++	}
++
++	if ((len != (vs->username_len + vs->password_len)) ||
++	    (vs->username_len >= (sizeof(username)-1)) ||
++	    (vs->password_len >= (sizeof(passwd)-1))	) {
++		err = "Got unexpected data length";
++		goto err;
++	}
++
++	strncpy(username, (char *)data, vs->username_len);
++	username[vs->username_len] = 0;
++	strncpy(passwd, (char *)data + vs->username_len, vs->password_len);
++	passwd[vs->password_len] = 0;
++
++	VNC_DEBUG("AUTH PLAIN username: %s pw: %s\n", username, passwd);
++
++	if (pve_auth_verify(clientip, username, passwd) == 0) {
++		vnc_write_u32(vs, 0); /* Accept auth completion */
++		start_client_init(vs);
++		return 0;
++	}
++
++	err =  "Authentication failed";
++err:
++       if (err) {
++	       VNC_DEBUG("AUTH PLAIN ERROR: %s\n", err);
++	       vnc_write_u32(vs, 1); /* Reject auth */
++	       if (vs->minor >= 8) {
++		       int elen = strlen(err);
++		       vnc_write_u32(vs, elen);
++		       vnc_write(vs, err, elen);
++	       }
++       }
++       vnc_flush(vs);
++       vnc_client_error(vs);
++
++       return 0;
++
++}
++
++static int protocol_client_auth_plain_start(VncState *vs, uint8_t *data, size_t len)
++{
++	uint32_t ulen = read_u32(data, 0);
++	uint32_t pwlen = read_u32(data, 4);
++	const char *err = NULL;
++
++	VNC_DEBUG("AUTH PLAIN START %u %u\n", ulen, pwlen);
++
++       if (!ulen) {
++	       err = "No User name.";
++	       goto err;
++       }
++       if (ulen >= 255) {
++	       err = "User name too long.";
++	       goto err;
++       }
++       if (!pwlen) {
++	       err = "Password too short";
++	       goto err;
++       }
++       if (pwlen >= 511) {
++	       err = "Password too long.";
++	       goto err;
++       }
++
++       vs->username_len = ulen;
++       vs->password_len = pwlen;
++
++       vnc_read_when(vs, protocol_client_auth_plain, ulen + pwlen);
++
++       return 0;
++err:
++       if (err) {
++	       VNC_DEBUG("AUTH PLAIN ERROR: %s\n", err);
++	       vnc_write_u32(vs, 1); /* Reject auth */
++	       if (vs->minor >= 8) {
++		       int elen = strlen(err);
++		       vnc_write_u32(vs, elen);
++		       vnc_write(vs, err, elen);
++	       }
++       }
++       vnc_flush(vs);
++       vnc_client_error(vs);
++
++       return 0;
++}
+ 
+ static void start_auth_vencrypt_subauth(VncState *vs)
+ {
+@@ -37,6 +137,12 @@ static void start_auth_vencrypt_subauth(VncState *vs)
+        start_client_init(vs);
+        break;
+ 
++    case VNC_AUTH_VENCRYPT_TLSPLAIN:
++    case VNC_AUTH_VENCRYPT_X509PLAIN:
++       VNC_DEBUG("Start TLS auth PLAIN\n");
++       vnc_read_when(vs, protocol_client_auth_plain_start, 8);
++       break;
++
+     case VNC_AUTH_VENCRYPT_TLSVNC:
+     case VNC_AUTH_VENCRYPT_X509VNC:
+        VNC_DEBUG("Start TLS auth VNC\n");
+diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c
+index 5629263..2108a7d 100644
+--- a/ui/vnc-tls.c
++++ b/ui/vnc-tls.c
+@@ -302,6 +302,14 @@ static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
+ 
+ static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
+ {
++    /* optimize for speed */
++    static const int ciphers[] = {
++	    GNUTLS_CIPHER_ARCFOUR_128,
++	    GNUTLS_CIPHER_AES_128_CBC,
++	    GNUTLS_CIPHER_3DES_CBC,
++	    0
++    };
++
+     static const int cert_types[] = { GNUTLS_CRT_X509, 0 };
+     static const int protocols[] = {
+         GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0
+@@ -313,6 +321,11 @@ static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
+     };
+     int rc;
+ 
++    rc = gnutls_cipher_set_priority(s, ciphers);
++    if (rc != GNUTLS_E_SUCCESS) {
++        return -1;
++    }
++
+     rc = gnutls_kx_set_priority(s, x509 ? kx_x509 : kx_anon);
+     if (rc != GNUTLS_E_SUCCESS) {
+         return -1;
+@@ -449,6 +462,24 @@ static int vnc_set_x509_credential(VncDisplay *vd,
+     return 0;
+ }
+ 
++int pve_tls_set_x509_creds_dir(VncDisplay *vd)
++{
++    if (vnc_set_x509_credential(vd, "/etc/pve", "pve-root-ca.pem", &vd->tls.x509cacert, 0) < 0)
++        goto cleanup;
++    if (vnc_set_x509_credential(vd, "/etc/pve/local", "pve-ssl.pem", &vd->tls.x509cert, 0) < 0)
++        goto cleanup;
++    if (vnc_set_x509_credential(vd, "/etc/pve/local", "pve-ssl.key", &vd->tls.x509key, 0) < 0)
++        goto cleanup;
++
++    return 0;
++
++ cleanup:
++    g_free(vd->tls.x509cacert);
++    g_free(vd->tls.x509cert);
++    g_free(vd->tls.x509key);
++    vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
++    return -1;
++}
+ 
+ int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
+                                const char *certdir)
+diff --git a/ui/vnc-tls.h b/ui/vnc-tls.h
+index 36a2227..0010ecf 100644
+--- a/ui/vnc-tls.h
++++ b/ui/vnc-tls.h
+@@ -68,6 +68,8 @@ void vnc_tls_client_cleanup(VncState *vs);
+ 
+ int vnc_tls_validate_certificate(VncState *vs);
+ 
++int pve_tls_set_x509_creds_dir(VncDisplay *vd);
++
+ int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
+ 			       const char *path);
+ 
+diff --git a/ui/vnc.c b/ui/vnc.c
+index 4d01ef2..e2a86ff 100644
+--- a/ui/vnc.c
++++ b/ui/vnc.c
+@@ -43,6 +43,125 @@ static const struct timeval VNC_REFRESH_LOSSY = { 2, 0 };
  #include "vnc_keysym.h"
  #include "d3des.h"
  
@@ -128,7 +340,7 @@ Index: new/ui/vnc.c
  static VncDisplay *vnc_display; /* needed for info vnc */
  static DisplayChangeListener *dcl;
  
-@@ -1982,7 +2101,7 @@
+@@ -2025,7 +2144,7 @@ static void vnc_colordepth(VncState *vs)
          vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
          vnc_write_u8(vs, 0);
          vnc_write_u16(vs, 1); /* number of rects */
@@ -137,7 +349,7 @@ Index: new/ui/vnc.c
                                 ds_get_height(vs->ds), VNC_ENCODING_WMVi);
          pixel_format_message(vs);
          vnc_unlock_output(vs);
-@@ -2892,7 +3011,7 @@
+@@ -2989,7 +3108,7 @@ int vnc_display_pw_expire(DisplayState *ds, time_t expires)
  char *vnc_display_local_addr(DisplayState *ds)
  {
      VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
@@ -146,7 +358,7 @@ Index: new/ui/vnc.c
      return vnc_socket_local_addr("%s:%s", vs->lsock);
  }
  
-@@ -2950,6 +3069,7 @@
+@@ -3077,6 +3196,7 @@ void vnc_display_open(DisplayState *ds, const char *display, Error **errp)
              tls = 1; /* Require TLS */
          } else if (strncmp(options, "x509", 4) == 0) {
              char *start, *end;
@@ -154,7 +366,7 @@ Index: new/ui/vnc.c
              x509 = 1; /* Require x509 certificates */
              if (strncmp(options, "x509verify", 10) == 0)
                  vs->tls.x509verify = 1; /* ...and verify client certs */
-@@ -2970,8 +3090,10 @@
+@@ -3097,8 +3217,10 @@ void vnc_display_open(DisplayState *ds, const char *display, Error **errp)
                  }
                  g_free(path);
              } else {
@@ -167,7 +379,7 @@ Index: new/ui/vnc.c
              }
  #endif
  #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)
-@@ -3035,10 +3157,10 @@
+@@ -3162,10 +3284,10 @@ void vnc_display_open(DisplayState *ds, const char *display, Error **errp)
              vs->auth = VNC_AUTH_VENCRYPT;
              if (x509) {
                  VNC_DEBUG("Initializing VNC server with x509 password auth\n");
@@ -180,136 +392,11 @@ Index: new/ui/vnc.c
              }
          } else {
  #endif /* CONFIG_VNC_TLS */
-Index: new/ui/vnc-auth-vencrypt.c
-===================================================================
---- new.orig/ui/vnc-auth-vencrypt.c	2012-11-21 11:11:22.000000000 +0100
-+++ new/ui/vnc-auth-vencrypt.c	2012-11-21 11:26:06.000000000 +0100
-@@ -25,7 +25,107 @@
-  */
- 
- #include "vnc.h"
-+#include "qemu_socket.h"
- 
-+static int protocol_client_auth_plain(VncState *vs, uint8_t *data, size_t len)
-+{
-+	const char *err = NULL;
-+	char username[256];
-+	char passwd[512];
-+
-+	char clientip[256];
-+	clientip[0] = 0;
-+	struct sockaddr_in client;
-+	socklen_t addrlen = sizeof(client);
-+	if (getpeername(vs->csock, &client, &addrlen) == 0) {
-+		inet_ntop(client.sin_family, &client.sin_addr,
-+			  clientip, sizeof(clientip));
-+	}
-+
-+	if ((len != (vs->username_len + vs->password_len)) ||
-+	    (vs->username_len >= (sizeof(username)-1)) ||
-+	    (vs->password_len >= (sizeof(passwd)-1))	) {
-+		err = "Got unexpected data length";
-+		goto err;
-+	}
-+
-+	strncpy(username, (char *)data, vs->username_len);
-+	username[vs->username_len] = 0;
-+	strncpy(passwd, (char *)data + vs->username_len, vs->password_len);
-+	passwd[vs->password_len] = 0;
-+
-+	VNC_DEBUG("AUTH PLAIN username: %s pw: %s\n", username, passwd);
-+
-+	if (pve_auth_verify(clientip, username, passwd) == 0) {
-+		vnc_write_u32(vs, 0); /* Accept auth completion */
-+		start_client_init(vs);
-+		return 0;
-+	}
-+
-+	err =  "Authentication failed";
-+err:
-+       if (err) {
-+	       VNC_DEBUG("AUTH PLAIN ERROR: %s\n", err);
-+	       vnc_write_u32(vs, 1); /* Reject auth */
-+	       if (vs->minor >= 8) {
-+		       int elen = strlen(err);
-+		       vnc_write_u32(vs, elen);
-+		       vnc_write(vs, err, elen);
-+	       }
-+       }
-+       vnc_flush(vs);
-+       vnc_client_error(vs);
-+
-+       return 0;
-+
-+}
-+
-+static int protocol_client_auth_plain_start(VncState *vs, uint8_t *data, size_t len)
-+{
-+	uint32_t ulen = read_u32(data, 0);
-+	uint32_t pwlen = read_u32(data, 4);
-+	const char *err = NULL;
-+
-+	VNC_DEBUG("AUTH PLAIN START %u %u\n", ulen, pwlen);
-+
-+       if (!ulen) {
-+	       err = "No User name.";
-+	       goto err;
-+       }
-+       if (ulen >= 255) {
-+	       err = "User name too long.";
-+	       goto err;
-+       }
-+       if (!pwlen) {
-+	       err = "Password too short";
-+	       goto err;
-+       }
-+       if (pwlen >= 511) {
-+	       err = "Password too long.";
-+	       goto err;
-+       }
-+
-+       vs->username_len = ulen;
-+       vs->password_len = pwlen;
-+
-+       vnc_read_when(vs, protocol_client_auth_plain, ulen + pwlen);
-+
-+       return 0;
-+err:
-+       if (err) {
-+	       VNC_DEBUG("AUTH PLAIN ERROR: %s\n", err);
-+	       vnc_write_u32(vs, 1); /* Reject auth */
-+	       if (vs->minor >= 8) {
-+		       int elen = strlen(err);
-+		       vnc_write_u32(vs, elen);
-+		       vnc_write(vs, err, elen);
-+	       }
-+       }
-+       vnc_flush(vs);
-+       vnc_client_error(vs);
-+
-+       return 0;
-+}
- 
- static void start_auth_vencrypt_subauth(VncState *vs)
- {
-@@ -37,6 +137,12 @@
-        start_client_init(vs);
-        break;
- 
-+    case VNC_AUTH_VENCRYPT_TLSPLAIN:
-+    case VNC_AUTH_VENCRYPT_X509PLAIN:
-+       VNC_DEBUG("Start TLS auth PLAIN\n");
-+       vnc_read_when(vs, protocol_client_auth_plain_start, 8);
-+       break;
-+
-     case VNC_AUTH_VENCRYPT_TLSVNC:
-     case VNC_AUTH_VENCRYPT_X509VNC:
-        VNC_DEBUG("Start TLS auth VNC\n");
-Index: new/ui/vnc.h
-===================================================================
---- new.orig/ui/vnc.h	2012-11-21 11:11:22.000000000 +0100
-+++ new/ui/vnc.h	2012-11-21 11:26:06.000000000 +0100
-@@ -264,6 +264,8 @@
+diff --git a/ui/vnc.h b/ui/vnc.h
+index 45d7686..5b40a51 100644
+--- a/ui/vnc.h
++++ b/ui/vnc.h
+@@ -272,6 +272,8 @@ struct VncState
      char challenge[VNC_AUTH_CHALLENGE_SIZE];
  #ifdef CONFIG_VNC_TLS
      int subauth; /* Used by VeNCrypt */
@@ -318,87 +405,18 @@ Index: new/ui/vnc.h
      VncStateTLS tls;
  #endif
  #ifdef CONFIG_VNC_SASL
-@@ -560,4 +562,6 @@
+@@ -581,4 +583,6 @@ int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);
  int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);
  void vnc_zrle_clear(VncState *vs);
  
 +int pve_auth_verify(const char *clientip, const char *username, const char *passwd);
 +
  #endif /* __QEMU_VNC_H */
-Index: new/ui/vnc-tls.c
-===================================================================
---- new.orig/ui/vnc-tls.c	2012-11-21 11:11:22.000000000 +0100
-+++ new/ui/vnc-tls.c	2012-11-21 11:26:06.000000000 +0100
-@@ -302,6 +302,14 @@
- 
- static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
- {
-+    /* optimize for speed */
-+    static const int ciphers[] = {
-+	    GNUTLS_CIPHER_ARCFOUR_128,
-+	    GNUTLS_CIPHER_AES_128_CBC,
-+	    GNUTLS_CIPHER_3DES_CBC,
-+	    0
-+    };
-+
-     static const int cert_types[] = { GNUTLS_CRT_X509, 0 };
-     static const int protocols[] = {
-         GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0
-@@ -313,6 +321,11 @@
-     };
-     int rc;
- 
-+    rc = gnutls_cipher_set_priority(s, ciphers);
-+    if (rc != GNUTLS_E_SUCCESS) {
-+        return -1;
-+    }
-+
-     rc = gnutls_kx_set_priority(s, x509 ? kx_x509 : kx_anon);
-     if (rc != GNUTLS_E_SUCCESS) {
-         return -1;
-@@ -449,6 +462,24 @@
-     return 0;
- }
- 
-+int pve_tls_set_x509_creds_dir(VncDisplay *vd)
-+{
-+    if (vnc_set_x509_credential(vd, "/etc/pve", "pve-root-ca.pem", &vd->tls.x509cacert, 0) < 0)
-+        goto cleanup;
-+    if (vnc_set_x509_credential(vd, "/etc/pve/local", "pve-ssl.pem", &vd->tls.x509cert, 0) < 0)
-+        goto cleanup;
-+    if (vnc_set_x509_credential(vd, "/etc/pve/local", "pve-ssl.key", &vd->tls.x509key, 0) < 0)
-+        goto cleanup;
-+
-+    return 0;
-+
-+ cleanup:
-+    g_free(vd->tls.x509cacert);
-+    g_free(vd->tls.x509cert);
-+    g_free(vd->tls.x509key);
-+    vd->tls.x509cacert = vd->tls.x509cacrl = vd->tls.x509cert = vd->tls.x509key = NULL;
-+    return -1;
-+}
- 
- int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
-                                const char *certdir)
-Index: new/ui/vnc-tls.h
-===================================================================
---- new.orig/ui/vnc-tls.h	2012-11-21 11:11:22.000000000 +0100
-+++ new/ui/vnc-tls.h	2012-11-21 11:26:06.000000000 +0100
-@@ -68,6 +68,8 @@
- 
- int vnc_tls_validate_certificate(VncState *vs);
- 
-+int pve_tls_set_x509_creds_dir(VncDisplay *vd);
-+
- int vnc_tls_set_x509_creds_dir(VncDisplay *vd,
- 			       const char *path);
- 
-Index: new/vl.c
-===================================================================
---- new.orig/vl.c	2012-11-21 11:25:23.000000000 +0100
-+++ new/vl.c	2012-11-21 11:26:06.000000000 +0100
-@@ -3319,6 +3319,7 @@
+diff --git a/vl.c b/vl.c
+index 6c7fb5c..793753e 100644
+--- a/vl.c
++++ b/vl.c
+@@ -3513,6 +3513,7 @@ int main(int argc, char **argv, char **envp)
  		    fprintf(stderr, "Invalid ID\n");
  		    exit(1);
  		}
@@ -406,15 +424,3 @@ Index: new/vl.c
                  break;
              case QEMU_OPTION_cpuunits:
                  cpuunits = atoi(optarg);
-Index: new/console.h
-===================================================================
---- new.orig/console.h	2012-11-21 11:11:22.000000000 +0100
-+++ new/console.h	2012-11-21 11:26:06.000000000 +0100
-@@ -448,6 +448,7 @@
- void cocoa_display_init(DisplayState *ds, int full_screen);
- 
- /* vnc.c */
-+void pve_auth_setup(int vmid);
- void vnc_display_init(DisplayState *ds);
- void vnc_display_open(DisplayState *ds, const char *display, Error **errp);
- void vnc_display_add_client(DisplayState *ds, int csock, int skipauth);
diff --git a/debian/patches/qemu-img-convert-skipcreate-option.patch b/debian/patches/qemu-img-convert-skipcreate-option.patch
index 6bd1d43..2111d37 100644
--- a/debian/patches/qemu-img-convert-skipcreate-option.patch
+++ b/debian/patches/qemu-img-convert-skipcreate-option.patch
@@ -1,19 +1,14 @@
-From 6b8ac153620bbc1a39e9ee6eef0392219886ebb3 Mon Sep 17 00:00:00 2001
-From: Alexandre Derumier <aderumier at odiso.com>
-Date: Mon, 29 Oct 2012 10:02:33 +0100
-Subject: [PATCH] skipcreate
+commit 88fb9516ab022074dff1f3412bd23e994082f5c6
+Author: Stefan Priebe <s.priebe at profihost.ag>
+Date:   Tue Jan 29 21:52:18 2013 +0100
 
+    a
 
-Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
----
- qemu-img.c |   36 +++++++++++++++++++++---------------
- 1 file changed, 21 insertions(+), 15 deletions(-)
-
-Index: new/qemu-img.c
-===================================================================
---- new.orig/qemu-img.c	2012-11-21 11:51:19.000000000 +0100
-+++ new/qemu-img.c	2012-11-21 12:45:10.000000000 +0100
-@@ -660,7 +660,7 @@
+diff --git a/qemu-img.c b/qemu-img.c
+index 3fcb59e..6c2aa00 100644
+--- a/qemu-img.c
++++ b/qemu-img.c
+@@ -665,7 +665,7 @@ static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n,
  
  static int img_convert(int argc, char **argv)
  {
@@ -22,7 +17,7 @@ Index: new/qemu-img.c
      int progress = 0, flags;
      const char *fmt, *out_fmt, *cache, *out_baseimg, *out_filename;
      BlockDriver *drv, *proto_drv;
-@@ -682,8 +682,9 @@
+@@ -687,8 +687,9 @@ static int img_convert(int argc, char **argv)
      cache = "unsafe";
      out_baseimg = NULL;
      compress = 0;
@@ -33,7 +28,7 @@ Index: new/qemu-img.c
          if (c == -1) {
              break;
          }
-@@ -704,6 +705,9 @@
+@@ -709,6 +710,9 @@ static int img_convert(int argc, char **argv)
          case 'c':
              compress = 1;
              break;
@@ -43,7 +38,7 @@ Index: new/qemu-img.c
          case 'e':
              error_report("option -e is deprecated, please use \'-o "
                    "encryption\' instead!");
-@@ -864,20 +868,22 @@
+@@ -869,20 +873,22 @@ static int img_convert(int argc, char **argv)
          }
      }
  
-- 
1.7.10.4




More information about the pve-devel mailing list