refer to the new repository master
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 25 Sep 2017 13:17:15 +0000 (15:17 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 25 Sep 2017 13:17:15 +0000 (15:17 +0200)
154 files changed:
Makefile [deleted file]
README [new file with mode: 0644]
backup.txt [deleted file]
debian/Logo.bmp [deleted file]
debian/OVMF_CODE-pure-efi.fd [deleted file]
debian/OVMF_README.txt [deleted file]
debian/OVMF_VARS-pure-efi.fd [deleted file]
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/copyright [deleted file]
debian/docs [deleted file]
debian/kvm-ifdown [deleted file]
debian/kvm-ifup [deleted file]
debian/patches-0.12.1/adjust-path.diff [deleted file]
debian/patches-0.12.1/cpuid-fix.diff [deleted file]
debian/patches-0.12.1/enable-ksm.diff [deleted file]
debian/patches-0.12.1/fairsched.diff [deleted file]
debian/patches-0.12.1/keymap.diff [deleted file]
debian/patches-0.12.1/live-migration-fixes.diff [deleted file]
debian/patches-0.12.1/multicore.diff [deleted file]
debian/patches-0.12.1/ps2-queue-size.diff [deleted file]
debian/patches-0.12.1/series [deleted file]
debian/patches-0.12.1/vncticket.diff [deleted file]
debian/patches/old/0000-cover-letter.patch [deleted file]
debian/patches/old/0001-add-documenation-for-new-backup-framework.patch [deleted file]
debian/patches/old/0001-aio-Fix-use-after-free-in-cancellation-path.patch [deleted file]
debian/patches/old/0001-aio-fix-qemu_bh_schedule-bh-ctx-race-condition.patch [deleted file]
debian/patches/old/0001-net-pcnet-add-check-to-validate-receive-data-size-CV.patch [deleted file]
debian/patches/old/0001-smm_available-false.patch [deleted file]
debian/patches/old/0001-ui-vnc-avoid-floating-point-exception.patch [deleted file]
debian/patches/old/0002-add-basic-backup-support-to-block-driver.patch [deleted file]
debian/patches/old/0002-pcnet-fix-rx-buffer-overflow-CVE-2015-7512.patch [deleted file]
debian/patches/old/0003-add-backup-related-monitor-commands.patch [deleted file]
debian/patches/old/0004-introduce-new-vma-archive-format.patch [deleted file]
debian/patches/old/0005-add-regression-tests-for-backup.patch [deleted file]
debian/patches/old/0006-add-vm-state-to-backups.patch [deleted file]
debian/patches/old/0007-use-extra-thread-for-vma-writer.patch [deleted file]
debian/patches/old/0007-vma-add-verify-command.patch [deleted file]
debian/patches/old/0008-vma-restore-tolerate-a-size-difference-up-to-4M.patch [deleted file]
debian/patches/old/0009-vma-only-store-the-basename-of-a-configuration-file.patch [deleted file]
debian/patches/old/CVE-2015-7549-msix-pba-write-ro.patch [deleted file]
debian/patches/old/CVE-2015-8558-ehci_make_idt_processing_more_robust.patch [deleted file]
debian/patches/old/CVE-2015-8613-scsi-initialize-info-object.patch [deleted file]
debian/patches/old/CVE-2015-8619-hmp-sendkey-oob-fix.patch [deleted file]
debian/patches/old/CVE-2015-8666-acpi-fix-buffer-overrun-on-migration.patch [deleted file]
debian/patches/old/CVE-2015-8701-net-rocker-off-by-one.patch [deleted file]
debian/patches/old/CVE-2015-8743-ne2000-ioport-bounds-check.patch [deleted file]
debian/patches/old/CVE-2015-8744-vmxnet3-refine-l2-header-validation.patch [deleted file]
debian/patches/old/CVE-2015-8745-vmxnet3-support-reading-imr-registers.patch [deleted file]
debian/patches/old/CVE-2016-1568-ide-ahci-reset-ncq-object-to-unused-on-error.patch [deleted file]
debian/patches/old/add-qmp-get-link-status.patch [deleted file]
debian/patches/old/add_firewall_to_vma.patch [deleted file]
debian/patches/old/adjust-path.diff [deleted file]
debian/patches/old/ahci-add_migration-support.patch [deleted file]
debian/patches/old/backup-add-dir-format.patch [deleted file]
debian/patches/old/backup-add-pve-monitor-commands.patch [deleted file]
debian/patches/old/backup-add-vma-binary.patch [deleted file]
debian/patches/old/backup-add-vma-verify-command.patch [deleted file]
debian/patches/old/backup-do-not-return-errors-in-dump-callback.patch [deleted file]
debian/patches/old/backup-do-not-use-bdrv-drain-all.patch [deleted file]
debian/patches/old/backup-modify-job-api.patch [deleted file]
debian/patches/old/backup-run-flush-inside-coroutine.patch [deleted file]
debian/patches/old/backup-vma-add-dump-config.patch [deleted file]
debian/patches/old/backup-vma-allow-empty-backups.patch [deleted file]
debian/patches/old/backup-vma-correctly-propagate-error.patch [deleted file]
debian/patches/old/backup-vma-extract-add-block-driver-type.patch [deleted file]
debian/patches/old/backup-vma-remove-async-queue.patch [deleted file]
debian/patches/old/backup-vma-restore-tolerate-a-size-difference-up-to-4M.patch [deleted file]
debian/patches/old/cpuid-fix.diff [deleted file]
debian/patches/old/disable-efi-enable-pxe-roms.patch [deleted file]
debian/patches/old/enable-kvm-by-default.patch [deleted file]
debian/patches/old/fix-emulator-version-string.patch [deleted file]
debian/patches/old/fix-qemu-img-snapshot-removal.patch [deleted file]
debian/patches/old/fr-ca-keymap-corrections.diff [deleted file]
debian/patches/old/gluster-backupserver.patch [deleted file]
debian/patches/old/glusterfs-daemonize.patch [deleted file]
debian/patches/old/internal-snapshot-async.patch [deleted file]
debian/patches/old/jemalloc.patch [deleted file]
debian/patches/old/keymap.diff [deleted file]
debian/patches/old/live-migration-fixes.diff [deleted file]
debian/patches/old/mirror-fix-zero-init.patch [deleted file]
debian/patches/old/modify-query-machines.patch [deleted file]
debian/patches/old/modify-query-spice.patch [deleted file]
debian/patches/old/move-bdrv-snapshot-find.patch [deleted file]
debian/patches/old/multicore.diff [deleted file]
debian/patches/old/ps2-queue-size.diff [deleted file]
debian/patches/old/pve-auth.patch [deleted file]
debian/patches/old/series [deleted file]
debian/patches/old/set-cpu-model-to-kvm64.patch [deleted file]
debian/patches/old/spice-socket.patch [deleted file]
debian/patches/old/spice-use-pve-certs.patch [deleted file]
debian/patches/old/use-local-linux-kvm-h.diff [deleted file]
debian/patches/old/vencrypt-auth-plain.patch [deleted file]
debian/patches/old/virtio-balloon-document-stats.patch [deleted file]
debian/patches/old/virtio-balloon-drop-old-stats-code.patch [deleted file]
debian/patches/old/virtio-balloon-fix-query.patch [deleted file]
debian/patches/old/virtio-balloon-re-enable-balloon-stats.patch [deleted file]
debian/patches/old/vmxnet3-host-memory-leakage.patch [deleted file]
debian/patches/old/vncticket.diff [deleted file]
debian/patches/pve/0001-fr-ca-keymap-corrections.patch [deleted file]
debian/patches/pve/0002-Adjust-network-script-path-to-etc-kvm.patch [deleted file]
debian/patches/pve/0003-vnc-altgr-emulation.patch [deleted file]
debian/patches/pve/0004-qemu-img-return-success-on-info-without-snapshots.patch [deleted file]
debian/patches/pve/0005-use-kvm-by-default.patch [deleted file]
debian/patches/pve/0006-virtio-balloon-fix-query.patch [deleted file]
debian/patches/pve/0007-set-the-CPU-model-to-kvm64-32-instead-of-qemu64-32.patch [deleted file]
debian/patches/pve/0008-qapi-modify-query-machines.patch [deleted file]
debian/patches/pve/0009-qapi-modify-spice-query.patch [deleted file]
debian/patches/pve/0010-ui-spice-default-to-pve-certs-unless-otherwise-speci.patch [deleted file]
debian/patches/pve/0011-introduce-new-vma-archive-format.patch [deleted file]
debian/patches/pve/0012-vma-add-verify-command.patch [deleted file]
debian/patches/pve/0013-vma-add-config-command-to-dump-the-config.patch [deleted file]
debian/patches/pve/0014-backup-modify-job-api.patch [deleted file]
debian/patches/pve/0015-backup-add-pve-monitor-commands.patch [deleted file]
debian/patches/pve/0016-backup-vma-add-dir-format.patch [deleted file]
debian/patches/pve/0017-backup-do-not-return-errors-in-dump-callback.patch [deleted file]
debian/patches/pve/0018-backup-vma-correctly-propagate-error.patch [deleted file]
debian/patches/pve/0019-backup-vma-remove-async-queue.patch [deleted file]
debian/patches/pve/0020-backup-vma-run-flush-inside-coroutine.patch [deleted file]
debian/patches/pve/0021-backup-do-not-use-bdrv_drain_all.patch [deleted file]
debian/patches/pve/0022-internal-snapshot-async.patch [deleted file]
debian/patches/pve/0023-backup-vma-allow-empty-backups.patch [deleted file]
debian/patches/pve/0024-qmp-add-get_link_status.patch [deleted file]
debian/patches/pve/0025-smm_available-false.patch [deleted file]
debian/patches/pve/0026-use-whitespace-between-VERSION-and-PKGVERSION.patch [deleted file]
debian/patches/pve/0027-vma-add-firewall.patch [deleted file]
debian/patches/pve/0028-savevm-async-migration-and-bdrv_open-update.patch [deleted file]
debian/patches/pve/0029-vnc-make-x509-imply-tls-again.patch [deleted file]
debian/patches/pve/0030-PVE-VNC-authentication.patch [deleted file]
debian/patches/pve/0031-vma-writer-don-t-bail-out-on-zero-length-files.patch [deleted file]
debian/patches/pve/0032-vma-better-driver-guessing-for-bdrv_open.patch [deleted file]
debian/patches/pve/0033-block-add-the-zeroinit-block-driver-filter.patch [deleted file]
debian/patches/pve/0034-vma-add-format-option-to-device-mapping.patch [deleted file]
debian/patches/pve/0035-fix-possible-unitialised-return-value.patch [deleted file]
debian/patches/pve/0036-vnc-refactor-to-QIOChannelSocket.patch [deleted file]
debian/patches/pve/0037-vma-use-BlockBackend-on-extract.patch [deleted file]
debian/patches/pve/0038-vma-byte-based-write-calls.patch [deleted file]
debian/patches/pve/0039-rbd-disable-rbd_cache_writethrough_until_flush-with-.patch [deleted file]
debian/patches/pve/0040-enable-cache-unsafe-for-vma-extract_content-and-qmp_.patch [deleted file]
debian/patches/pve/0041-savevm-async-updates.patch [deleted file]
debian/patches/pve/0042-qmp_snapshot_drive-add-aiocontext.patch [deleted file]
debian/patches/pve/0043-vma-sizes-passed-to-blk_co_preadv-should-be-bytes-no.patch [deleted file]
debian/patches/pve/0044-glusterfs-no-default-logfile-if-daemonized.patch [deleted file]
debian/patches/pve/0045-qmp_delete_drive_snapshot-add-aiocontext.patch [deleted file]
debian/patches/pve/0046-convert-savevm-async-to-threads.patch [deleted file]
debian/patches/pve/0047-glusterfs-allow-partial-reads.patch [deleted file]
debian/patches/pve/0048-vma-don-t-use-O_DIRECT-on-pipes.patch [deleted file]
debian/patches/pve/0049-block-zeroinit-request-child-permissions.patch [deleted file]
debian/patches/series [deleted file]
debian/postinst [deleted file]
debian/rules [deleted file]
qemu-kvm-src.tar.gz [deleted file]
vma_spec.txt [deleted file]

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 5f5a841..0000000
--- a/Makefile
+++ /dev/null
@@ -1,54 +0,0 @@
-# also update debian/changelog
-KVMVER=2.9.0
-KVMTAG=$(KVMVER)-rc2
-KVMPKGREL=1~rc2+5
-
-KVMPACKAGE=pve-qemu-kvm
-KVMDIR=qemu-kvm
-KVMSRC=${KVMDIR}-src.tar.gz
-
-ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
-GITVERSION:=$(shell git rev-parse master)
-
-DEB=${KVMPACKAGE}_${KVMVER}-${KVMPKGREL}_${ARCH}.deb
-DEB_DBG=${KVMPACKAGE}-dbg_${KVMVER}-${KVMPKGREL}_${ARCH}.deb
-DEBS=$(DEB) $(DEB_DBG)
-
-
-all: $(DEBS)
-
-.PHONY: download
-download:
-       rm -rf ${KVMDIR} ${KVMSRC}
-       git clone --depth=1 git://git.qemu-project.org/qemu.git -b v${KVMTAG} ${KVMDIR}
-       tar czf ${KVMSRC} --exclude CVS --exclude .git --exclude .svn ${KVMDIR}
-
-.PHONY: deb kvm
-deb kvm: $(DEBS)
-$(DEB_DBG): $(DEB)
-$(DEB): $(KVMSRC)
-       rm -f *.deb
-       rm -rf ${KVMDIR}
-       tar xf ${KVMSRC} 
-       cp -a debian ${KVMDIR}/debian
-       echo "git clone git://git.proxmox.com/git/pve-qemu-kvm.git\\ngit checkout ${GITVERSION}" > ${KVMDIR}/debian/SOURCE
-       # set package version
-       sed -i 's/^pkgversion="".*/pkgversion="${KVMPACKAGE}_${KVMVER}-${KVMPKGREL}"/' ${KVMDIR}/configure
-       cd ${KVMDIR}; dpkg-buildpackage -b -rfakeroot -us -uc
-       lintian ${DEBS} || true
-
-.PHONY: upload
-upload: ${DEBS}
-       tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist stretch
-
-.PHONY: distclean
-distclean: clean
-
-
-.PHONY: clean
-clean:
-       rm -rf *.changes *.buildinfo ${KVMDIR} ${KVMPACKAGE}_* ${DEBS}
-
-.PHONY: dinstall
-dinstall: ${DEBS}
-       dpkg -i ${DEBS}
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..a9b23a6
--- /dev/null
+++ b/README
@@ -0,0 +1,2 @@
+This repository is outdated.
+Please use the pve-qemu.git repository instead.
diff --git a/backup.txt b/backup.txt
deleted file mode 100644 (file)
index 0605250..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-Efficient VM backup for qemu
-
-=Requirements=
-
-* Backup to a single archive file
-* Backup needs to contain all data to restore VM (full backup)
-* Do not depend on storage type or image format
-* Avoid use of temporary storage
-* store sparse images efficiently
-
-=Introduction=
-
-Most VM backup solutions use some kind of snapshot to get a consistent
-VM view at a specific point in time. For example, we previously used
-LVM to create a snapshot of all used VM images, which are then copied
-into a tar file.
-
-That basically means that any data written during backup involve
-considerable overhead. For LVM we get the following steps:
-
-1.) read original data (VM write)
-2.) write original data into snapshot (VM write)
-3.) write new data (VM write)
-4.) read data from snapshot (backup)
-5.) write data from snapshot into tar file (backup)
-
-Another approach to backup VM images is to create a new qcow2 image
-which use the old image as base. During backup, writes are redirected
-to the new image, so the old image represents a 'snapshot'. After
-backup, data need to be copied back from new image into the old
-one (commit). So a simple write during backup triggers the following
-steps:
-
-1.) write new data to new image (VM write)
-2.) read data from old image (backup)
-3.) write data from old image into tar file (backup)
-
-4.) read data from new image (commit)
-5.) write data to old image (commit)
-
-This is in fact the same overhead as before. Other tools like qemu
-livebackup produces similar overhead (2 reads, 3 writes).
-
-Some storage types/formats supports internal snapshots using some kind
-of reference counting (rados, sheepdog, dm-thin, qcow2). It would be possible
-to use that for backups, but for now we want to be storage-independent.
-
-=Make it more efficient=
-
-The be more efficient, we simply need to avoid unnecessary steps. The
-following steps are always required:
-
-1.) read old data before it gets overwritten
-2.) write that data into the backup archive
-3.) write new data (VM write)
-
-As you can see, this involves only one read, and two writes.
-
-To make that work, our backup archive need to be able to store image
-data 'out of order'. It is important to notice that this will not work
-with traditional archive formats like tar.
-
-During backup we simply intercept writes, then read existing data and
-store that directly into the archive. After that we can continue the
-write.
-
-==Advantages==
-
-* very good performance (1 read, 2 writes)
-* works on any storage type and image format.
-* avoid usage of temporary storage
-* we can define a new and simple archive format, which is able to
-  store sparse files efficiently.
-
-Note: Storing sparse files is a mess with existing archive
-formats. For example, tar requires information about holes at the
-beginning of the archive.
-
-==Disadvantages==
-
-* we need to define a new archive format
-
-Note: Most existing archive formats are optimized to store small files
-including file attributes. We simply do not need that for VM archives.
-
-* archive contains data 'out of order'
-
-If you want to access image data in sequential order, you need to
-re-order archive data. It would be possible to to that on the fly,
-using temporary files.
-
-Fortunately, a normal restore/extract works perfectly with 'out of
-order' data, because the target files are seekable.
-
-* slow backup storage can slow down VM during backup
-
-It is important to note that we only do sequential writes to the
-backup storage. Furthermore one can compress the backup stream. IMHO,
-it is better to slow down the VM a bit. All other solutions creates
-large amounts of temporary data during backup.
-
-=Archive format requirements=
-
-The basic requirement for such new format is that we can store image
-date 'out of order'. It is also very likely that we have less than 256
-drives/images per VM, and we want to be able to store VM configuration
-files.
-
-We have defined a very simply format with those properties, see:
-
-https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=vma_spec.txt;
-
-Please let us know if you know an existing format which provides the
-same functionality.
-
-
diff --git a/debian/Logo.bmp b/debian/Logo.bmp
deleted file mode 100644 (file)
index 4c46dd8..0000000
Binary files a/debian/Logo.bmp and /dev/null differ
diff --git a/debian/OVMF_CODE-pure-efi.fd b/debian/OVMF_CODE-pure-efi.fd
deleted file mode 100644 (file)
index 807676d..0000000
Binary files a/debian/OVMF_CODE-pure-efi.fd and /dev/null differ
diff --git a/debian/OVMF_README.txt b/debian/OVMF_README.txt
deleted file mode 100644 (file)
index 7085e29..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-The OVMF images were built through the edk2 github repository.
-
-git clone https://github.com/tianocore/edk2
-
-set up the build environment
-
-copy the Logo.bmp to ./edk2/MdeModulePkg/Logo/
-
-call ./edk2/OvmfPkg/build.sh -a X64 -b RELEASE
-
-The license is under ./edk2/OvmfPkg/License.txt
diff --git a/debian/OVMF_VARS-pure-efi.fd b/debian/OVMF_VARS-pure-efi.fd
deleted file mode 100644 (file)
index 3b8bb9b..0000000
Binary files a/debian/OVMF_VARS-pure-efi.fd and /dev/null differ
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644 (file)
index 9e5f75b..0000000
+++ /dev/null
@@ -1,1378 +0,0 @@
-pve-qemu-kvm (2.9.0-1~rc2+5) unstable; urgency=medium
-
-  * fix a crash caused by the zeroinit filter in drive-mirror
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 31 Mar 2017 09:31:38 +0200
-
-pve-qemu-kvm (2.9.0-1~rc2+4) unstable; urgency=medium
-
-  * fix data loss when sending backups through pipes on kernel >= 4.5
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 30 Mar 2017 16:07:52 +0200
-
-pve-qemu-kvm (2.9.0-1~rc2+3) unstable; urgency=medium
-
-  * fix backup jobs not starting when using multiple disks
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 30 Mar 2017 12:16:30 +0200
-
-pve-qemu-kvm (2.9.0-1~rc2+2) unstable; urgency=medium
-
-  * build with virtfs enabled
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 30 Mar 2017 10:57:46 +0200
-
-pve-qemu-kvm (2.9.0-1~rc2+1) unstable; urgency=medium
-
-  * fix backup jobs not starting and an assertion on backup job cleanup
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 30 Mar 2017 10:49:00 +0200
-
-pve-qemu-kvm (2.9.0-1~rc2) unstable; urgency=medium
-
-  * update to qemu 2.9.0-rc2
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 29 Mar 2017 13:33:48 +0200
-
-pve-qemu-kvm (2.7.1-501) unstable; urgency=medium
-
-  * drop bridge-utils dependency
-
-  * use ip from iproute2 over ifconfig from net-tools
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 15 Mar 2017 11:24:33 +0100
-
-pve-qemu-kvm (2.7.1-500) unstable; urgency=medium
-
-  * version bumped for stetch upgrade
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 10 Mar 2017 14:19:59 +0100
-
-pve-qemu-kvm (2.7.1-4) unstable; urgency=medium
-
-  * fix CVE-2017-2620: display: cirrus: out-of-bounds access issue
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 22 Feb 2017 14:19:57 +0100
-
-pve-qemu-kvm (2.7.1-3) unstable; urgency=medium
-
-  * more fixes for cirrus pattern fill operations
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 10 Feb 2017 12:11:10 +0100
-
-pve-qemu-kvm (2.7.1-2) unstable; urgency=medium
-
-  * fix #1237: cirrus: fix pattern fill regressions
-
-  * fix CVE-2017-2615: cirrus: out of bounds access on backward blits
-
-  * fix CVE-2016-10028: virtio-gpu-3d: check virgl capabilities
-
-  * fix CVE-2016-10155: memory leak on unplugging an Intel 6300ESB watchdog
-
-  * remove debug output from LAPIC patch
-
-  * added 'qemu-utils' to replaces & provides
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 02 Feb 2017 10:01:53 +0100
-
-pve-qemu-kvm (2.7.1-1) unstable; urgency=medium
-
-  * update to qemu 2.7.1
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 03 Jan 2017 07:57:17 +0100
-
-pve-qemu-kvm (2.7.0-10) unstable; urgency=medium
-
-  * fix CVE-2016-9776: net: mcf: check receive buffer size register value
-
-  * fix CVE-2016-9845: virtio-gpu: fix information leak in getting capset info dispatch
-
-  * fix CVE-2016-9846: virtio-gpu: fix memory leak in update_cursor_data_virgl
-
-  * fix CVE-2016-9907: usbredir: free vm_change_state_handler in usbredir destroy dispatch
-
-  * fix CVE-2016-9908: virtio-gpu: fix information leak in capset get dispatch
-
-  * fix CVE-2016-9911: usb: ehci: fix memory leak in ehci_init_transfer
-
-  * fix CVE-2016-9912: virtio-gpu: call cleanup mapping function in resource destroy
-
-  * fix CVE-2016-9913: 9pfs: adjust the order of resource cleanup in device unrealize
-
-  * fix CVE-2016-9914: 9pfs: add cleanup operation in FileOperations
-
-  * fix CVE-2016-9915: 9pfs: add cleanup operation for handle backend driver
-
-  * fix CVE-2016-9916: 9pfs: add cleanup operation for proxy backend driver
-
-  * fix CVE-2016-9921 and CVE-2016-9922:
-     display: cirrus: check vga bits per pixel(bpp) value
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 12 Dec 2016 14:36:58 +0100
-
-pve-qemu-kvm (2.7.0-9) unstable; urgency=medium
-
-  * gluster: fix an issue with linked clones refusing to start
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 01 Dec 2016 11:59:55 +0100
-
-pve-qemu-kvm (2.7.0-8) unstable; urgency=medium
-
-  * correctly report live snapshots as active
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 15 Nov 2016 15:28:44 +0100
-
-pve-qemu-kvm (2.7.0-7) unstable; urgency=medium
-
-  * fix #1182: update EFI roms to include PXE fixes
-
-  * fix snapshot-with-RAM stability with some file systems
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 11 Nov 2016 15:02:28 +0100
-
-pve-qemu-kvm (2.7.0-6) unstable; urgency=medium
-
-  * fix deletion of snapshots on qcow2 while running with iothreads
-
-  * fix #796: live snapshot never finishes with some guests
-
-  * fix live snapshot while running with iothreads
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 08 Nov 2016 11:45:02 +0100
-
-pve-qemu-kvm (2.7.0-5) unstable; urgency=medium
-
-  * fix a missing gluster dependency
-
-  * fix #1193: RAM state of snapshots with RAM getting truncated at creation
-
-  * fix CVE-2016-8909: audio: intel-hda: check stream entry count during transfer
-
-  * fix CVE-2016-8910: net: rtl8139: limit processing of ring descriptors
-
-  * fix CVE-2016-9101: net: eepro100: fix memory leak in device uninit
-
-  * fix CVE-2016-9102: 9pfs: fix memory leak in v9fs_xattrcreate
-
-  * fix CVE-2016-9103: 9pfs: fix information leak in xattr read
-
-  * fix CVE-2016-9104: 9pfs: fix integer overflow issue in xattr read/write
-
-  * fix CVE-2016-9105: 9pfs: fix memory leak in v9fs_link
-
-  * fix CVE-2016-9106: 9pfs: fix memory leak in v9fs_write
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 07 Nov 2016 11:14:31 +0100
-
-pve-qemu-kvm (2.7.0-4) unstable; urgency=medium
-
-  * fix #1178: glusterfs daemonization problem
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 24 Oct 2016 09:35:49 +0200
-
-pve-qemu-kvm (2.7.0-3) unstable; urgency=medium
-
-  * fix a crash when doing an offline backup via vma
-
-  * fix CVE-2016-8668: net: rocker: set limit to DMA buffer size
-
-  * fix CVE-2016-8669: char: serial: check divider value against baud base
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 21 Oct 2016 09:22:36 +0200
-
-pve-qemu-kvm (2.7.0-2) unstable; urgency=medium
-
-  * fix a crash when adding iothreads
-
-  * fix CVE-2016-8576: xhci: limit the number of link trbs we are willing to process
-
-  * fix CVE-2016-8577: 9pfs: fix potential host memory leak in v9fs_read
-
-  * fix CVE-2016-8578: 9pfs: allocate space for guest originated empty strings
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 13 Oct 2016 15:20:52 +0200
-
-pve-qemu-kvm (2.7.0-1) unstable; urgency=medium
-
-  * update to qemu 2.7.0
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 09 Sep 2016 15:55:35 +0200
-
-pve-qemu-kvm (2.6.2-2) unstable; urgency=medium
-
-  * fix CVE-2016-7466: memory leak in usb_xhci_exit
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 07 Oct 2016 11:00:13 +0200
-
-pve-qemu-kvm (2.6.2-1) unstable; urgency=medium
-
-  * update to qemu 2.6.2
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 06 Oct 2016 14:12:07 +0200
-
-pve-qemu-kvm (2.6.1-7) unstable; urgency=medium
-
-  * fix CVE-2016-7161: hw/net: Fix a heap overflow in xlnx.xps-ethernetlite
-
-  * fix CVE-2016-7422: virtio: add check for descriptor's mapped address
-
-  * fix CVE-2016-7907: net: imx: limit buffer descriptor count
-
-  * fix CVE-2016-7908: net: mcf: limit buffer descriptor count
-
-  * fix CVE-2016-7909: net: pcnet: check rx/tx descriptor ring length
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 06 Oct 2016 08:11:52 +0200
-
-pve-qemu-kvm (2.6.1-6) unstable; urgency=medium
-
-  * fix #615: Windows guests suddenly hangs after couple times of migration
-
-  * fix CVE-2016-7170: vmsvga: correct bitmap and pixmap size checks
-
-  * fix CVE-2016-7421: scsi: pvscsi: limit process IO loop to ring size
-
-  * fix CVE-2016-7423: scsi: mptsas: use g_new0 to allocate MPTSASRequest
-    object
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 20 Sep 2016 09:42:12 +0200
-
-pve-qemu-kvm (2.6.1-5) unstable; urgency=medium
-
-  * qmp_snapshot_drive : add aiocontext
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 15 Sep 2016 13:27:14 +0200
-
-pve-qemu-kvm (2.6.1-4) unstable; urgency=medium
-
-  * add new and correct ovmf images
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 08 Sep 2016 12:25:29 +0200
-
-pve-qemu-kvm (2.6.1-3) unstable; urgency=medium
-
-  * fix CVE-2016-7116: various 9pfs fixe
-
-  * fix CVE-2016-7155: scsi: check page count while initialising
-    descriptor rings
-
-  * fix CVE-2016-7156: scsi: pvscsi: avoid infinite loop while building SG list
-
-  * fix CVE-2016-7157: scsi: mptconfig: fix an assert expression
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 07 Sep 2016 12:14:02 +0200
-
-pve-qemu-kvm (2.6.1-2) unstable; urgency=medium
-
-  * virtio related live migration fixes
-
-  * vnc server surface refresh fix
-
-  * iscsi and network fixes
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 25 Aug 2016 10:35:52 +0200
-
-pve-qemu-kvm (2.6.1-1) unstable; urgency=medium
-
-  * update to qemu 2.6.1
-
-  * Fix CVE-2016-6490: virtio: check vring descriptor buffer length
-
-  * Fix CVE-2016-6833: net: vmxnet3: check for device_active before write
-
-  * Fix CVE-2016-6834: net: check fragment length during fragmentation
-
-  * Fix CVE-2016-6835: net: vmxnet: check IP header length
-
-  * Fix CVE-2016-6836: net: vmxnet: initialise local tx descriptor
-
-  * Fix CVE-2016-6888: net: vmxnet: use g_new for pkt initialisation
-
-  * enable cache=unsafe for vma extract_content and qmp_savevm_start
-
-  * rbd : disable cache_writethtrough_until_flush with cache=unsafe
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 22 Aug 2016 11:55:38 +0200
-
-pve-qemu-kvm (2.6-1) unstable; urgency=medium
-
-  * update to qemu 2.6.0
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 01 Jul 2016 10:00:31 +0200
-
-pve-qemu-kvm (2.5-19) unstable; urgency=medium
-
-  * fix CVE-2016-5105: scsi: megasas: initialise local configuration data
-    buffer
-
-  * fix CVE-2016-5106: scsi: megasas: use appropriate property buffer size
-
-  * fix fix CVE-2016-5107: scsi: megasas: check 'read_queue_head' index value
-
-  * fix fix CVE-2016-5126: block/iscsi: avoid potential overflow of
-    acb->task->cdb
-
-  * fix CVE-2016-4454: vmsvga: move fifo sanity checks to vmsvga_fifo_length
-  * fix CVE-2016-4453: vmsvga: don't process more than 1024 fifo commands at
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 31 May 2016 18:04:31 +0200
-
-pve-qemu-kvm (2.5-18) unstable; urgency=medium
-
-  * Fix CVE-2016-4952
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 24 May 2016 17:15:00 +0200
-
-pve-qemu-kvm (2.5-17) unstable; urgency=medium
-
-  * add fix for freezing win7 with VGA #991
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 17 May 2016 12:51:10 +0200
-
-pve-qemu-kvm (2.5-16) unstable; urgency=medium
-
-  * update to qemu 2.5.1.1
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 10 May 2016 09:53:30 +0200
-
-pve-qemu-kvm (2.5-15) unstable; urgency=medium
-
-  * Fix #932: passing BDRV_O_PROTOCOL breaks qcow2 on gluster
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 29 Apr 2016 08:55:53 +0200
-
-pve-qemu-kvm (2.5-14) unstable; urgency=medium
-
-  * Fix CVE-2016-4037
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 26 Apr 2016 15:43:48 +0200
-
-pve-qemu-kvm (2.5-13) unstable; urgency=medium
-
-  * fix 'i386: leakage of stack memory to guest in kvmvapic.c'
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 14 Apr 2016 17:06:52 +0200
-
-pve-qemu-kvm (2.5-12) unstable; urgency=medium
-
-  * Fix #934: assume raw for /dev paths in vma extract
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 13 Apr 2016 08:47:13 +0200
-
-pve-qemu-kvm (2.5-11) unstable; urgency=medium
-
-  * update to qemu 2.5.1
-
-  * target-i386: do not read/write MSR_TSC_AUX from KVM if CPUID
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 01 Apr 2016 10:09:54 +0200
-
-pve-qemu-kvm (2.5-10) unstable; urgency=medium
-
-  * add the zeroinit block driver filter
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 21 Mar 2016 09:47:53 +0100
-
-pve-qemu-kvm (2.5-9) unstable; urgency=medium
-
-  * Fix CVE-2016-2841, CVE-2016-2857, CVE-2016-2858
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 07 Mar 2016 17:08:23 +0100
-
-pve-qemu-kvm (2.5-8) unstable; urgency=medium
-
-  * Fix CVE-2016-2538
-
-  * vma: better driver guessing for bdrv_open
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 24 Feb 2016 16:28:37 +0100
-
-pve-qemu-kvm (2.5-7) unstable; urgency=medium
-
-  * add fw_cfg-unbreak-migration-compatibility-for-2.4 patch
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 19 Feb 2016 09:22:16 +0100
-
-pve-qemu-kvm (2.5-6) unstable; urgency=medium
-
-  * Fix CVE-2016-2392 and CVE-2016-2391
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 18 Feb 2016 09:44:37 +0100
-
-pve-qemu-kvm (2.5-5) unstable; urgency=medium
-
-  * Fix #885: vma-writer: don't bail out on zero length files
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 08 Feb 2016 11:37:52 +0100
-
-pve-qemu-kvm (2.5-4) unstable; urgency=medium
-
-  * Fix CVE-2016-2197 and CVE-2016-2198
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 01 Feb 2016 17:16:09 +0100
-
-pve-qemu-kvm (2.5-3) unstable; urgency=medium
-
-  * Fix CVE-2016-1981
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 22 Jan 2016 09:09:27 +0100
-
-pve-qemu-kvm (2.5-2) unstable; urgency=medium
-
-  * recompile for test environment
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 20 Jan 2016 08:37:49 +0100
-
-pve-qemu-kvm (2.5-1) unstable; urgency=medium
-
-  * update qemu to 2.5.0
-
-  * removed upstream CVE fixes
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 08 Jan 2016 12:43:24 +0100
-
-pve-qemu-kvm (2.4-21) unstable; urgency=medium
-
-  * add correct fix for  CVE-2015-8619
-
-  * close #849: iproute is a transitional package for iproute2
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 11 Jan 2016 15:23:23 +0100
-
-pve-qemu-kvm (2.4-20) unstable; urgency=medium
-
-  * Removing wrong CVE-2015-8619
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 08 Jan 2016 12:43:24 +0100
-
-pve-qemu-kvm (2.4-19) unstable; urgency=medium
-
-  * fix CVE-2015-8613 scsi: initialise info object with appropriate size
-
-  * fix CVE-2015-8619 hmp: avoid redundant null termination of buffer
-
-  * fix CVE-2015-8666 acpi: fix buffer overrun on migration
-
-  * fix CVE-2015-8701 net: rocker: fix an incorrect array bounds check
-
-  * fix CVE-2015-8743 net: ne2000: fix bounds check in ioport operations
-
-  * fix CVE-2015-8744 net/vmxnet3: Refine l2 header validation
-
-  * fix CVE-2015-8745 vmxnet3: Support reading IMR registers on bar0
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 07 Jan 2016 11:12:13 +0100
-
-pve-qemu-kvm (2.4-18) unstable; urgency=medium
-
-  * fixes for CVEs 2015-7549, 2015-8858 and for vmxnet3
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 18 Dec 2015 09:12:43 +0100
-
-pve-qemu-kvm (2.4-17) unstable; urgency=medium
-
-  * fix CVE-2015-8504
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 09 Dec 2015 12:09:03 +0100
-
-pve-qemu-kvm (2.4-16) unstable; urgency=medium
-
-  * added fixes for CVE-2015-7504 and CVE-2015-7512
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 01 Dec 2015 09:51:44 +0100
-
-pve-qemu-kvm (2.4-15) unstable; urgency=medium
-
-  * add ovmf uefi roms
-
-  * add firewall config to qmp_backup
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 26 Nov 2015 07:56:51 +0100
-
-pve-qemu-kvm (2.4-14) unstable; urgency=medium
-
-  * savevm async : setup raw format by default fo vmstate file
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 09 Nov 2015 06:26:53 +0100
-
-pve-qemu-kvm (2.4-13) unstable; urgency=medium
-
-  * update qemu to 2.4.1
-
-  * remove patch mirror-fix-coroutine-reentrance.patch (now upstream)
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 06 Nov 2015 09:47:21 +0100
-
-pve-qemu-kvm (2.4-12) unstable; urgency=medium
-
-  * define QEMU_PKGVERSION
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 23 Oct 2015 09:40:37 +0200
-
-pve-qemu-kvm (2.4-11) unstable; urgency=medium
-
-  * update ipxe binaries, re-enable efi pxe ROMs
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 22 Oct 2015 08:47:07 +0200
-
-pve-qemu-kvm (2.4-10) unstable; urgency=medium
-
-  * pve-qemu-kvm : block: mirror - fix full sync mode when target
-    does not support zeroes init
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 13 Oct 2015 17:06:22 +0200
-
-pve-qemu-kvm (2.4-9) unstable; urgency=medium
-
-  * qemu :disable smm support
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 30 Sep 2015 09:34:06 +0200
-
-pve-qemu-kvm (2.4-8) unstable; urgency=medium
-
-  * update qemu to 2.4.0.1 
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 23 Sep 2015 06:40:27 +0200
-
-pve-qemu-kvm (2.4-7) unstable; urgency=medium
-
-  * savevm-async: move global_state_store to the end
-
- -- Proxmox Support Team <support@proxmox.com>  Sun, 20 Sep 2015 10:08:02 +0200
-
-pve-qemu-kvm (2.4-6) unstable; urgency=medium
-
-  * fix snapshot/rollback of running vm
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 15 Sep 2015 09:07:32 +0200
-
-pve-qemu-kvm (2.4-5) unstable; urgency=medium
-
-  * vma create: correctly create empty (config only) archives 
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 09 Sep 2015 11:27:06 +0200
-
-pve-qemu-kvm (2.4-4) unstable; urgency=medium
-
-  * fix q35 pci passthrough (revert commit b8eb5512)
-
-  * add depend on libjpeg62-turbo to avoid problems when
-    updating from wheezy.
-
- -- Proxmox Support Team <support@proxmox.com>  Sat, 05 Sep 2015 10:15:08 +0200
-
-pve-qemu-kvm (2.4-3) unstable; urgency=medium
-
-  * update to v2.4.0 final
-
-  * add mirror-fix-coroutine-reentrance.patch
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 13 Aug 2015 17:00:49 +0200
-
-pve-qemu-kvm (2.4-2) unstable; urgency=medium
-
-  *  update to latest upstream (v2.4.0-rc4)
-
- -- Proxmox Support Team <support@proxmox.com>  Sat, 08 Aug 2015 15:14:25 +0200
-
-pve-qemu-kvm (2.4-1) unstable; urgency=medium
-
-  * update to latest upstream (v2.4.0-rc3)
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 30 Jul 2015 09:38:14 +0200
-
-pve-qemu-kvm (2.3-8) unstable; urgency=medium
-
-  * update to latest upstream (v2.4.0-rc2 + a few more patches)
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 29 Jul 2015 10:07:20 +0200
-
-pve-qemu-kvm (2.3-7) unstable; urgency=medium
-
-  * update to latest upstream (v2.4.0-rc2 + a few patches)
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 27 Jul 2015 09:59:07 +0200
-
-pve-qemu-kvm (2.3-6) unstable; urgency=medium
-
-  * qemu : add drive-mirror sleep patches
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 01 Jul 2015 06:16:47 +0200
-
-pve-qemu-kvm (2.3-5) unstable; urgency=medium
-
-  * use jemalloc as default memory allocator
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 19 Jun 2015 17:08:37 +0200
-
-pve-qemu-kvm (2.3-4) unstable; urgency=medium
-
-  * remove tcmalloc
-
-  * Added patch for vvfat's file.label option
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 18 Jun 2015 14:06:28 +0200
-
-pve-qemu-kvm (2.3-3) unstable; urgency=medium
-
-  * vma extract: add BlockDevice type to prevent warning
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 10 Jun 2015 17:33:22 +0200
-
-pve-qemu-kvm (2.3-2) unstable; urgency=medium
-
-  * enable tcmalloc, depend on libgoogle-perftools4
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 10 Jun 2015 10:44:24 +0200
-
-pve-qemu-kvm (2.3-1) unstable; urgency=medium
-
-  *  update to v2.3.0
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 05 Jun 2015 06:05:00 +0200
-
-pve-qemu-kvm (2.2-8) unstable; urgency=medium
-
-  * fix package dependencies for Debian Jessie
-
-  * update to v2.2.1
-
-  * remove fix-mc146818rtc-wrong-subsection-name.patch (now upstream)
-  
-  * fix ballooning with memory hotplug
-    
- -- Proxmox Support Team <support@proxmox.com>  Wed, 11 Mar 2015 07:12:43 +0100
-
-pve-qemu-kvm (2.2-7) unstable; urgency=low
-
-  * fix mc146818rtc wrong subsection name to avoid
-    vmstate_subsection_load() fail.
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 24 Feb 2015 17:38:31 +0100
-
-pve-qemu-kvm (2.2-6) unstable; urgency=low
-
-  * qmp: fix backup-cancel
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 29 Dec 2014 07:21:24 +0100
-
-pve-qemu-kvm (2.2-5) unstable; urgency=low
-
-  * add new qmp command: get_link_status
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 11 Dec 2014 10:42:20 +0100
-
-pve-qemu-kvm (2.2-4) unstable; urgency=low
-
-  * update to qemu v2.2.0
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 10 Dec 2014 06:18:34 +0100
-
-pve-qemu-kvm (2.2-3) unstable; urgency=low
-
-  * update to qemu v2.2.0-rc5
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 05 Dec 2014 13:27:35 +0100
-
-pve-qemu-kvm (2.2-2) unstable; urgency=low
-
-  * update to qemu v2.2.0-rc3+ (commit 4cae4d5acaea23f3def84c8dc67ef5106323e5cb)
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 28 Nov 2014 11:50:25 +0100
-
-pve-qemu-kvm (2.2-1) unstable; urgency=low
-
-  * update to qemu v2.2.0-rc2
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 20 Nov 2014 07:56:27 +0100
-
-pve-qemu-kvm (2.1-10) unstable; urgency=low
-
-  * enable support for write_zeroes and discard for images on xfs filesystem
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 13 Oct 2014 10:19:44 +0200
-
-pve-qemu-kvm (2.1-9) unstable; urgency=low
-
-  * update to v2.1.2
-  
-  * remove temporary patches (now upstream)
-    - virtio-net_drop_assert_on_vm_stop.patch
-    - revert_virtio_dont_call_device_on_not_vm_running.patch
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 26 Sep 2014 11:25:57 +0200
-
-pve-qemu-kvm (2.1-8) unstable; urgency=low
-
-  * apply patches/hotfix for virtio-net migration problem in 2.1.1
-    - virtio-net_drop_assert_on_vm_stop.patch
-    - revert_virtio_dont_call_device_on_not_vm_running.patch
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 16 Sep 2014 12:54:48 +0200
-
-pve-qemu-kvm (2.1-7) unstable; urgency=low
-
-  * update to v2.1.1
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 11 Sep 2014 09:27:38 +0200
-
-pve-qemu-kvm (2.1-6) unstable; urgency=low
-
-  *  gluster: allow to specify a backup server
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 26 Aug 2014 12:55:23 +0200
-
-pve-qemu-kvm (2.1-5) unstable; urgency=low
-
-  * glusterfs: do not log to stdout when daemonized
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 22 Aug 2014 13:28:24 +0200
-
-pve-qemu-kvm (2.1-4) unstable; urgency=low
-
-  * depend on new libiscsi 1.12.0
-  
-  * depend on new glusterfs 3.5.2
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 21 Aug 2014 08:18:43 +0200
-
-pve-qemu-kvm (2.1-3) unstable; urgency=low
-
-  * snapshot: fix reference counting bug
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 07 Aug 2014 13:31:30 +0200
-
-pve-qemu-kvm (2.1-2) unstable; urgency=low
-
-  * update to v2.1.0
-
- -- Proxmox Support Team <support@proxmox.com>  Sat, 02 Aug 2014 15:00:58 +0200
-
-pve-qemu-kvm (2.1-1) unstable; urgency=low
-
-  * update to v2.1.0-rc2
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 16 Jul 2014 11:55:13 +0200
-
-pve-qemu-kvm (2.0-2) unstable; urgency=low
-
-  * update to latest qemu (commit 2a2c4830c0068d70443f3dddc4cc668f0c601b5c)
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 12 Jun 2014 10:20:10 +0200
-
-pve-qemu-kvm (2.0-1) unstable; urgency=low
-
-  * update to qemu 2.0
-  
-  * remove virtio-net-fix-guest-triggerable-buffer-overrun-CVE-2014-0150.patch 
-    This is now included in upstream.
-
-  * depend on libiscsi2 (>= 1.11.0)
-  
- -- Proxmox Support Team <support@proxmox.com>  Mon, 05 May 2014 06:57:34 +0200
-
-pve-qemu-kvm (1.7-8) unstable; urgency=low
-
-  * fix guest-triggerable buffer overrun in virtio-net (CVE-2014-0150)
-  
- -- Proxmox Support Team <support@proxmox.com>  Tue, 22 Apr 2014 06:47:02 +0200
-
-pve-qemu-kvm (1.7-7) unstable; urgency=low
-
-  * vma: allows the creation of vma files without data streams
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 14 Apr 2014 11:13:36 +0200
-
-pve-qemu-kvm (1.7-6) unstable; urgency=low
-
-  * backup: remove async queue (avoid segmentation fault)
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 27 Mar 2014 13:06:55 +0100
-
-pve-qemu-kvm (1.7-5) unstable; urgency=low
-
-  * update to 1.7.1
-  
-  * backup: do not report errors to the VM when backup fails.
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 26 Mar 2014 06:37:55 +0100
-
-pve-qemu-kvm (1.7-4) unstable; urgency=low
-
-  * disable efi enabled pxe boot roms (they do not work)
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 29 Jan 2014 12:58:46 +0100
-
-pve-qemu-kvm (1.7-3) unstable; urgency=low
-
-  * vma: add 'vma config' command to easily extract VM configuration
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 04 Dec 2013 10:39:36 +0100
-
-pve-qemu-kvm (1.7-2) unstable; urgency=low
-
-  * depend on latest spice server libs
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 03 Dec 2013 13:40:56 +0100
-
-pve-qemu-kvm (1.7-1) unstable; urgency=low
-
-  * remove qemu-img-convert-skipcreate-option.patch (now upstream)
-  
- -- Proxmox Support Team <support@proxmox.com>  Wed, 27 Nov 2013 10:55:35 +0100
-
-pve-qemu-kvm (1.4-17) unstable; urgency=low
-
-  * enable glusterfs backend
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 13 Aug 2013 06:48:32 +0200
-
-pve-qemu-kvm (1.4-16) unstable; urgency=low
-
-  * add patch to use pce certs for spice by default
-  
-  * disable spice-socket.patch
-  
-  * Allow to query spice ticket
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 23 Jul 2013 10:02:14 +0200
-
-pve-qemu-kvm (1.4-15) unstable; urgency=low
-
-  * add usbredir support to spice
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 19 Jul 2013 07:41:20 +0200
-
-pve-qemu-kvm (1.4-14) unstable; urgency=low
-
-  * add experimental code to support spice 
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 25 Jun 2013 06:41:52 +0200
-
-pve-qemu-kvm (1.4-13) unstable; urgency=low
-
-  * update to qemu 1.4.2
-  
-  * remove rbd-add-an-asynchronous-flush.patch (upstream now)
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 03 Jun 2013 06:28:32 +0200
-
-pve-qemu-kvm (1.4-12) unstable; urgency=low
-
-  * vma create: only store basename of config file.
-  patch: 0009-vma-only-store-the-basename-of-a-configuration-file.patch
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 08 May 2013 10:07:50 +0200
-
-pve-qemu-kvm (1.4-11) unstable; urgency=low
-
-  * rbd: add an asynchronous flush
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 07 May 2013 12:14:57 +0200
-
-pve-qemu-kvm (1.4-10) unstable; urgency=low
-
-  * bump version to 1.4-10
-
-  * this is based on qemu 1.4.1
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 16 Apr 2013 10:39:58 +0200
-
-pve-qemu-kvm (1.4-9) unstable; urgency=low
-
-  * vma restore: tolerate a size difference up to 4M
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 26 Mar 2013 06:33:43 +0100
-
-pve-qemu-kvm (1.4-8) unstable; urgency=low
-
-  * vma: add 'vma verify' command to verify vma archives
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 11 Mar 2013 11:10:34 +0100
-
-pve-qemu-kvm (1.4-7) unstable; urgency=low
-
-  * update seabios to 1.7.2.1 (fix freebsd boot)
-
- -- Proxmox Support Team <support@proxmox.com>  Sat, 09 Mar 2013 09:02:48 +0100
-
-pve-qemu-kvm (1.4-6) unstable; urgency=low
-
-  * set default cpu model to kvm64 (to avoid problems with windows activation)
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 25 Feb 2013 06:55:23 +0100
-
-pve-qemu-kvm (1.4-5) unstable; urgency=low
-
-  * update backup patches to v5
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 21 Feb 2013 12:30:57 +0100
-
-pve-qemu-kvm (1.4-4) unstable; urgency=low
-
-  * update backup patches
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 20 Feb 2013 10:43:04 +0100
-
-pve-qemu-kvm (1.4-3) unstable; urgency=low
-
-  * update to qemu 1.4.0 final
-
- -- Proxmox Support Team <support@proxmox.com>  Sat, 16 Feb 2013 09:24:06 +0100
-
-pve-qemu-kvm (1.4-2) unstable; urgency=low
-
-  * update to latest 1.4.0rc2
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 15 Feb 2013 15:57:56 +0100
-
-pve-qemu-kvm (1.4-1) unstable; urgency=low
-
-  * update to latest 1.4.0 (03ec2f83087de34924489eeae0ea6fe7785cc050)
-
-  * remove ahci-add_migration-support.patch
-  
-  * remove balloon stat patches
-  
-  * remove always-update-expected-downtime.patch: seems latest qemu does 
-  not set that value anymore?
-  
-  * configure with --disable-smartcard-nss (else we need to install
-    vscclient and dynamic libraries)
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 12 Feb 2013 12:04:09 +0100
-
-pve-qemu-kvm (1.3-18) unstable; urgency=low
-
-  * update qemu to v1.3.1
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 29 Jan 2013 15:12:49 +0100
-
-pve-qemu-kvm (1.3-17) unstable; urgency=low
-
-  * update backup patches - removed threaded code - we use qemu-aio
-    instead to avoid problems in bdrv_drain_all().
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 22 Jan 2013 10:37:59 +0100
-
-pve-qemu-kvm (1.3-14) unstable; urgency=low
-
-  * update backup patches
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 18 Jan 2013 10:53:21 +0100
-
-pve-qemu-kvm (1.3-13) unstable; urgency=low
-
-  * fix DSA-2608-1 qemu -- buffer overflow (see 
-  http://www.debian.org/security/2013/dsa-2608)
-  
- -- Proxmox Support Team <support@proxmox.com>  Thu, 17 Jan 2013 06:58:47 +0100
-
-pve-qemu-kvm (1.3-12) unstable; urgency=low
-
-  * update vma patches
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 04 Jan 2013 07:32:17 +0100
-
-pve-qemu-kvm (1.3-10) unstable; urgency=low
-
-  * include fixes for query-balloon
-  
-  * Update seabios to a810e4e72a0d42c7bc04eda57382f8e019add901
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 18 Dec 2012 12:38:36 +0100
-
-pve-qemu-kvm (1.3-9) unstable; urgency=low
-
-  * fixes for vma-reader
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 13 Dec 2012 12:08:12 +0100
-
-pve-qemu-kvm (1.3-8) unstable; urgency=low
-
-  * re-enable balloon stats
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 11 Dec 2012 12:48:26 +0100
-
-pve-qemu-kvm (1.3-7) unstable; urgency=low
-
-  * update seabios to e8a76b0f225bba5ba9d63ab227e0a37b3beb1059
-  
-  * update vma patches
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 11 Dec 2012 11:06:43 +0100
-
-pve-qemu-kvm (1.3-6) unstable; urgency=low
-
-  * include vma utility
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 04 Dec 2012 10:49:54 +0100
-
-pve-qemu-kvm (1.3-5) unstable; urgency=low
-
-  * update to qemu 1.3 final
-  
-  * include fix-off-by-1-error-in-RAM-migration-code.patch
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 04 Dec 2012 06:18:16 +0100
-
-pve-qemu-kvm (1.3-4) unstable; urgency=low
-
-  * update to qemu 1.3 rc2 (bios update, fix lsi bug)
-  
-  * rm stream-fix-ratelimit_set_speed.patch (upstream)
-  
-  * update qemu backup patches
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 03 Dec 2012 06:32:00 +0100
-
-pve-qemu-kvm (1.3-3) unstable; urgency=low
-
-  * include qemu backup patches
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 30 Nov 2012 12:23:37 +0100
-
-pve-qemu-kvm (1.3-2) unstable; urgency=low
-
-  * update to qemu 1.3 rc1 (fix usb tablet)
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 28 Nov 2012 08:48:12 +0100
-
-pve-qemu-kvm (1.3-1) unstable; urgency=low
-
-  * update to qemu 1.3 rc0
-  
-  * we now use qemu sources directly
-  
-  * remove update-cpus-x86_64.conf-to-rhel6.2-version.patch
-  
-  * remove ahci-properly-reset-pxcmd.patch (upstream)
-  
-  * remove sheepdog-fix-savevm-loadvm.patch (upstream)
-  
-  * remove set-max-nics.patch (no longer needed with -device syntax)
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 21 Nov 2012 12:48:56 +0100
-
-pve-qemu-kvm (1.2-7) unstable; urgency=low
-
-  * cleanup snapshot support patches
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 23 Oct 2012 09:45:48 +0200
-
-pve-qemu-kvm (1.2-6) unstable; urgency=low
-
-  * qemu-img: return success for non-existing snapshots on snapshot removal
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 14 Sep 2012 11:09:09 +0200
-
-pve-qemu-kvm (1.2-5) unstable; urgency=low
-
-  * update to 1.2.0
-  
- -- Proxmox Support Team <support@proxmox.com>  Fri, 07 Sep 2012 07:40:06 +0200
-
-pve-qemu-kvm (1.2-4) unstable; urgency=low
-
-  * update to 1.2.0-rc2
-  
-  * add patch for experimental snapshot support
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 04 Sep 2012 07:26:31 +0200
-
-pve-qemu-kvm (1.2-3) unstable; urgency=low
-
-  * fix ahci for win7
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 03 Sep 2012 14:22:17 +0200
-
-pve-qemu-kvm (1.2-2) unstable; urgency=low
-
-  * add ahci migration support
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 31 Aug 2012 10:52:20 +0200
-
-pve-qemu-kvm (1.2-1) unstable; urgency=low
-
-  * update to 1.2.0-rc1
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 27 Aug 2012 14:12:22 +0200
-
-pve-qemu-kvm (1.1-8) unstable; urgency=low
-
-  * fix bug 241: compile it with alsa support instead of oss
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 16 Aug 2012 09:11:19 +0200
-
-pve-qemu-kvm (1.1-7) unstable; urgency=low
-
-  * Enable VeNCrypt PLAIN authentication
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 09 Aug 2012 10:05:52 +0200
-
-pve-qemu-kvm (1.1-6) unstable; urgency=low
-
-  * enable libiscsi
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 17 Jul 2012 11:35:47 +0200
-
-pve-qemu-kvm (1.1-5) unstable; urgency=low
-
-  * update to latest stable-1.1 branch (qemu-kvm-1.1.1)
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 17 Jul 2012 08:58:31 +0200
-
-pve-qemu-kvm (1.1-4) unstable; urgency=low
-
-  * update to latest stable-1.1 branch
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 09 Jul 2012 07:11:06 +0200
-
-pve-qemu-kvm (1.1-3) unstable; urgency=low
-
-  * enable rbd support
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 05 Jun 2012 06:49:52 +0200
-
-pve-qemu-kvm (1.1-2) unstable; urgency=low
-
-  * update to qemu-kvm-1.1-rc3
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 24 May 2012 09:24:57 +0200
-
-pve-qemu-kvm (1.1-1) unstable; urgency=low
-
-  * update to qemu-kvm-1.1-rc2
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 21 May 2012 06:15:49 +0200
-
-pve-qemu-kvm (1.0-9) unstable; urgency=low
-
-  * revert patch to change prefer_msi and share_intx defaults
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 03 Apr 2012 07:29:27 +0200
-
-pve-qemu-kvm (1.0-8) unstable; urgency=low
-
-  * include latest changes from master (update to commit 
-  a0bc8c313ce7da8937e190b1e0cfd051a9ba243e)
-  
- -- Proxmox Support Team <support@proxmox.com>  Mon, 26 Mar 2012 07:22:10 +0200
-
-pve-qemu-kvm (1.0-7) unstable; urgency=low
-
-  * include latest changes from master
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 12 Mar 2012 07:11:15 +0100
-
-pve-qemu-kvm (1.0-6) unstable; urgency=low
-
-  * include changes from master
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 02 Mar 2012 09:40:41 +0100
-
-pve-qemu-kvm (1.0-5) unstable; urgency=low
-
-  * fix usb tablet activation
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 29 Feb 2012 09:54:52 +0100
-
-pve-qemu-kvm (1.0-4) unstable; urgency=low
-
-  * fix Westmere cpu definition
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 23 Feb 2012 13:44:38 +0100
-
-pve-qemu-kvm (1.0-3) unstable; urgency=low
-
-  * include latest updates from master
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 15 Feb 2012 11:32:23 +0100
-
-pve-qemu-kvm (1.0-2) unstable; urgency=low
-
-  * include post 1.0 changes from master
-  
-  * remove live-migration-fixes.diff: seem nobody needs that.
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 09 Feb 2012 13:15:14 +0100
-
-pve-qemu-kvm (1.0-1) unstable; urgency=low
-
-  * update to upstream 1.0
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 07 Dec 2011 09:58:07 +0100
-
-pve-qemu-kvm (0.15.0-1) unstable; urgency=low
-
-  * update to upstream 0.15.0
-
-  * depend on libaio1 (--enable-linux-aio)
-
-  * depend on libuuid1 (--enable-uuid)
-  
-  * use pxe roms from upstream qemu-kvm
-  
-  * do not use --disable-blobs (let qemu-kvm install files, and we remove
-    what we do not need)
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 11 Aug 2011 10:00:44 +0200
-
-pve-qemu-kvm (0.14.1-1) unstable; urgency=low
-
-  * update to upstream 0.14.1
-  
-  * remove enable-ksm.diff patch (newer libc already have those
-    definitions)
-  
-  * also install vgabios-qxl.bin vgabios-stdvga.bin vgabios-vmware.bin
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 21 Jun 2011 06:30:29 +0200
-
-pve-qemu-kvm (0.14.0-1) unstable; urgency=low
-
-  * update to 0.14.0
-
-  * removed kvmtrace (removed from upstream?)
-  
-  * add vnc keyboard fixes for fr-ca (reported by Pierre-Yves)
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 25 Feb 2011 08:17:56 +0100
-
-pve-qemu-kvm (0.13.0-3) unstable; urgency=low
-
-  * fix vnc keyboard altgr/shift emulation
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 07 Dec 2010 12:45:16 +0100
-
-pve-qemu-kvm (0.13.0-2) unstable; urgency=low
-
-  * do not install unnecessary blobs (manually install blobs, use
-    --disable-blobs)
-
-  * update migration and vnc keymap patches for 0.13.0
-  
- -- Proxmox Support Team <support@proxmox.com>  Mon, 25 Oct 2010 13:46:03 +0200
-
-pve-qemu-kvm (0.13.0-1) unstable; urgency=low
-
-  * update to qemu-kvm-0.13.0
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 21 Oct 2010 13:38:14 +0200
-
-pve-qemu-kvm (0.12.5-2) unstable; urgency=low
-
-  * enable up to 32 NICs (as suggested in the forum)
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 06 Oct 2010 08:23:07 +0200
-
-pve-qemu-kvm (0.12.5-1) unstable; urgency=low
-
-  * update to qemu-kvm-0.12.5
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 05 Aug 2010 11:01:56 +0200
-
-pve-qemu-kvm (0.12.4-1) unstable; urgency=low
-
-  * update to qemu-kvm-0.12.4
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 11 May 2010 08:14:29 +0200
-
-pve-qemu-kvm (0.12.3-1) unstable; urgency=low
-
-  * update to qemu-kvm-0.12.3
-  
-  * include gPXE 1.0 network boot
-  
-  * remove multicore.diff patch
-  
-  * do not install ppc and sparc bios files
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 14 Apr 2010 13:30:23 +0200
-
-pve-qemu-kvm (0.11.1-2) unstable; urgency=low
-
-  * Use/Include PXE boot ROMs from the Etherboot package
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 26 Jan 2010 13:28:19 +0100
-
-pve-qemu-kvm (0.11.1-1) unstable; urgency=low
-
-  * update to qemu-kvm-0.11.1
-
-  * cleanup debian rules file
-  
-  * install kvmtrace kvmtrace_format and kvm_stat
-  
-  * configure with --disable-xen --with-kvm-trace 
-  
-  * depend on python for scripts
-  
- -- Proxmox Support Team <support@proxmox.com>  Mon, 14 Dec 2009 14:44:56 +0100
-
-pve-qemu-kvm (0.11.0-2) stable; urgency=low
-
-  * fix live migration (live-migration-fxes.diff)
-
- -- Proxmox Support Team <support@proxmox.com>  Wed, 30 Sep 2009 11:07:23 +0200
-
-pve-qemu-kvm (0.11.0-1) stable; urgency=low
-
-  * update to stable branch
-
-  * rename packare to pve-qemu-kvm
-       
- -- Proxmox Support Team <support@proxmox.com>  Mon, 28 Sep 2009 10:35:05 +0200
-
-pve-kvm (86-4) unstable; urgency=low
-
-  * include multicore patch from amd
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 14 Sep 2009 10:40:00 +0200
-
-pve-kvm (86-3) unstable; urgency=low
-
-  * fix "i8042.c: No controller found" problem
-
- -- Proxmox Support Team <support@proxmox.com>  Mon, 15 Jun 2009 13:35:57 +0200
-
-pve-kvm (86-2) unstable; urgency=low
-
-  * add CPUID fix: http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commitdiff_plain;h=8fa3b3ce6e
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 09 Jun 2009 09:50:28 +0200
-
-pve-kvm (86-1) unstable; urgency=low
-
-  *  New upstream release
-
- -- Proxmox Support Team <support@proxmox.com>  Fri, 22 May 2009 09:16:27 +0200
-
-pve-kvm (85-1) unstable; urgency=low
-
-  *  New upstream release
-
- -- Proxmox Support Team <support@proxmox.com>  Tue, 28 Apr 2009 07:41:21 +0200
-
-pve-kvm (83-1) unstable; urgency=low
-
-  * New upstream release
-
- -- Proxmox Support Team <support@proxmox.com>  Wed,  7 Jan 2009 12:57:02 +0100
-
-pve-kvm (75-1) unstable; urgency=low
-
-  *  New upstream release
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 11 Sep 2008 10:03:51 +0200
-
-pve-kvm (74-1) unstable; urgency=low
-
-  * New upstream release
-  
-  * added fairsched options
-
- -- Proxmox Support Team <support@proxmox.com>  Thu, 28 Aug 2008 12:40:32 +0200
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644 (file)
index ecf65c2..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-Source: pve-qemu-kvm
-Section: admin
-Priority: extra
-Maintainer: Proxmox Support Team <support@proxmox.com>
-Build-Depends: debhelper (>= 5),
- autotools-dev,
- libpci-dev,
- quilt,
- texinfo,
- texi2html,
- libgnutls28-dev,
- libsdl1.2-dev,
- check,
- libaio-dev,
- uuid-dev,
- librbd-dev (>= 0.48),
- libiscsi-dev (>= 1.12.0),
- libspice-protocol-dev (>= 0.12.5),
- pve-libspice-server-dev (>= 0.12.5-1),
- libusbredirparser-dev (>= 0.6-2),
- glusterfs-common (>= 3.5.2-1),
- libusb-1.0-0-dev (>= 1.0.17-1),
- xfslibs-dev,
- libnuma-dev,
- libjemalloc-dev,
- libjpeg-dev,
- libacl1-dev,
- libcap-dev
-Standards-Version: 3.7.2
-
-Package: pve-qemu-kvm
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},
- iproute2,
- python,
- libsdl1.2debian,
- libaio1,
- libuuid1,
- ceph-common (>= 0.48),
- libiscsi4 (>= 1.12.0) | libiscsi7,
- pve-libspice-server1 (>= 0.12.5-1),
- libusbredirparser1 (>= 0.6-2),
- glusterfs-common (>= 3.5.2-1),
- libusb-1.0-0 (>= 1.0.17-1),
- numactl,
- libjemalloc1,
- libjpeg62-turbo
-Conflicts: qemu, qemu-kvm, qemu-utils, kvm, pve-kvm, pve-qemu-kvm-2.6.18
-Provides: qemu-utils
-Replaces: pve-kvm, pve-qemu-kvm-2.6.18, qemu-utils
-Description: Full virtualization on x86 hardware
- Using KVM, one can run multiple virtual PCs, each running unmodified Linux or
- Windows images. Each virtual machine has private virtualized hardware: a
- network card, disk, graphics adapter, etc. 
-
-Package: pve-qemu-kvm-dbg
-Architecture: any
-Section: debug
-Depends: pve-qemu-kvm (= ${binary:Version})
-Description: pve qemu debugging symbols
- This package contains the debugging symbols for pve-qemu-kvm.
-
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644 (file)
index 5348fdb..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-This package was debianized by the proxmox support team <support@proxmox.com>
-
-
-It was downloaded from
-
-git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git
-
-Upstream Author: Fabrice Bellard <fabrice.bellard@free.fr>
-
-Upstream Maintainers: Avi Kivity <avi@redhat.com>
-                      Anthony Liguori <aliguori@us.ibm.com>
-
-Copyright: Copyright (C) 2006 Qumranet, Inc.
-           Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008  Fabrice Bellard
-
-License:
-
-    QEMU as a whole is released under the GNU General Public License version 2.
-    On Debian systems, the complete text of the GNU General Public License
-    version 2 can be found in the file /usr/share/common-licenses/GPL-2.
-
-    Parts of QEMU have specific licenses which are compatible with the
-    GNU General Public License. Hence each source file contains its own
-    licensing information.
-
-    In particular, the QEMU virtual CPU core library (libqemu.a) is
-    released under the GNU Lesser General Public License version 2 or later.
-    On Debian systems, the complete text of the GNU Lesser General Public 
-    License can be found in the file /usr/share/common-licenses/LGPL.
-
-    Some hardware device emulation sources and other QEMU functionality are
-    released under the BSD license, including:
-     * aes, bsd-user, sd, slirp, sys-queue
-
-    Some hardware device emulation sources and other QEMU functionality are
-    released under the MIT/X11 (BSD-like) license, including:
-     * sdl, host-utils, vnc, keymaps, ioport, usb, hw/*, net, acl, block,
-       kqemu, monitor, curses, readline, vl, savevm, osdep, audio, tcg,
-       qemu-malloc, qemu-img
-
-    The following points clarify the QEMU license:
-     1) QEMU as a whole is released under the GNU General Public License
-     2) Parts of QEMU have specific licenses which are compatible with the
-        GNU General Public License. Hence each source file contains its own
-        licensing information.
-        In particular, the QEMU virtual CPU core library (libqemu.a) is
-        released under the GNU Lesser General Public License. Many hardware
-        device emulation sources are released under the BSD license.
-     3) The Tiny Code Generator (TCG) is released under the BSD license
-        (see license headers in files).
-     4) QEMU is a trademark of Fabrice Bellard.
-     -- Fabrice Bellard.
-
-    BIOS sources in QEMU:
-       bios.bin: Copyright (C) 2002 MandrakeSoft S.A. and others.  This file
-       is licensed under the GNU LGPL, version 2, or (at your option) any later
-       version.
-       Homepage: http://sourceforge.net/projects/bochs
-
-       vgabios.bin and vgabios-cirrus.bin: (C) 2003 the LGPL VGABios
-       developers Team. These files are licensed under the GNU LGPL, version 2,
-       or (at your option) any later version.
-       Homepage: http://savannah.nongnu.org/projects/vgabios
-
-BSD license:
-
-Copyright (c) The Regents of the University of California.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. Neither the name of the University nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
diff --git a/debian/docs b/debian/docs
deleted file mode 100644 (file)
index 8696672..0000000
+++ /dev/null
@@ -1 +0,0 @@
-debian/SOURCE
diff --git a/debian/kvm-ifdown b/debian/kvm-ifdown
deleted file mode 100755 (executable)
index 92b94c4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exit 0
\ No newline at end of file
diff --git a/debian/kvm-ifup b/debian/kvm-ifup
deleted file mode 100755 (executable)
index a4c63ea..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-switch=$(/sbin/ip route show |sed -nre 's/^default .* dev ([^ ]+).*$/\1/;T;p;q')
-/sbin/ip link set "$1" up promisc on
-test -d "/sys/class/net/$switch/bridge" && /sbin/ip link set "$1" master "$switch"
diff --git a/debian/patches-0.12.1/adjust-path.diff b/debian/patches-0.12.1/adjust-path.diff
deleted file mode 100644 (file)
index 07c63e6..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-Index: kvm-86/configure
-===================================================================
---- kvm-86.orig/configure      2009-05-22 09:47:55.000000000 +0200
-+++ kvm-86/configure   2009-05-22 09:48:26.000000000 +0200
-@@ -1393,8 +1393,8 @@
-       prefix="/usr/local"
-   fi
-   mansuffix="/share/man"
--  datasuffix="/share/qemu"
--  docsuffix="/share/doc/qemu"
-+  datasuffix="/share/kvm"
-+  docsuffix="/share/doc/pve-qemu-kvm"
-   binsuffix="/bin"
- fi
-Index: kvm-86/net.h
-===================================================================
---- kvm-86.orig/net.h  2009-05-22 09:47:48.000000000 +0200
-+++ kvm-86/net.h       2009-05-22 09:48:26.000000000 +0200
-@@ -124,8 +124,8 @@
- void net_host_device_add(Monitor *mon, const char *device, const char *opts);
- void net_host_device_remove(Monitor *mon, int vlan_id, const char *device);
--#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"
- #ifdef __sun__
- #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
- #else
diff --git a/debian/patches-0.12.1/cpuid-fix.diff b/debian/patches-0.12.1/cpuid-fix.diff
deleted file mode 100644 (file)
index 1052ad5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-see http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commitdiff;h=8fa3b3ce6e#patch1
-
-KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG
-when it runs out of entries. Detect this by always trying again
-with a bigger table if the ioctl() fills the table.
-
---- a/kvm/libkvm/libkvm-x86.c
-+++ b/kvm/libkvm/libkvm-x86.c
-@@ -575,6 +575,8 @@ static struct kvm_cpuid2 *try_get_cpuid(kvm_context_t kvm, int max)
-       r = ioctl(kvm->fd, KVM_GET_SUPPORTED_CPUID, cpuid);
-       if (r == -1)
-               r = -errno;
-+      else if (r == 0 && cpuid->nent >= max)
-+              r = -E2BIG;
-       if (r < 0) {
-               if (r == -E2BIG) {
-                       free(cpuid);
-
diff --git a/debian/patches-0.12.1/enable-ksm.diff b/debian/patches-0.12.1/enable-ksm.diff
deleted file mode 100644 (file)
index 3ecd434..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Izik Eidus <ieidus@redhat.com>
-Date: Thu, 8 Oct 2009 14:39:39 +0000 (+0200)
-Subject: ksm support
-X-Git-Url: http://git.kernel.org/?p=virt%2Fkvm%2Fqemu-kvm.git;a=commitdiff_plain;h=ccb167e9d7d460a7cd09fdabd848efd3606dd27e
-
-ksm support
-
-patch is slighly modified by <support@proxmox.com> for old libc 
-
-Call MADV_MERGEABLE on guest memory allocations.  MADV_MERGABLE will be
-available starting in Linux 2.6.32.  This system call registers a region of
-virtual address space with Linux as a candidate for transparent memory
-sharing.
-
-Patchworks-ID: 35447
-Signed-off-by: Izik Eidus <ieidus@redhat.com>
-Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
----
-
-Index: qemu-kvm/exec.c
-===================================================================
---- qemu-kvm.orig/exec.c       2009-12-21 10:37:57.000000000 +0100
-+++ qemu-kvm/exec.c    2009-12-21 11:22:34.000000000 +0100
-@@ -48,6 +48,9 @@
- #include <qemu.h>
- #endif
-+/* our libc does not define it */
-+#define MADV_MERGEABLE   12
-+
- //#define DEBUG_TB_INVALIDATE
- //#define DEBUG_FLUSH
- //#define DEBUG_TLB
diff --git a/debian/patches-0.12.1/fairsched.diff b/debian/patches-0.12.1/fairsched.diff
deleted file mode 100644 (file)
index 51e8de1..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-Index: qemu-kvm/qemu-options.hx
-===================================================================
---- qemu-kvm.orig/qemu-options.hx      2009-12-21 10:37:57.000000000 +0100
-+++ qemu-kvm/qemu-options.hx   2009-12-21 10:41:25.000000000 +0100
-@@ -66,6 +66,12 @@
- are split equally.
- ETEXI
-+DEF("id", HAS_ARG, QEMU_OPTION_id,
-+    "-id n         set the faisched ID\n")
-+
-+DEF("cpuunits",  HAS_ARG, QEMU_OPTION_cpuunits,
-+    "-cpuuinits n    set fairsched cpu units\n")
-+
- DEF("fda", HAS_ARG, QEMU_OPTION_fda,
-     "-fda/-fdb file  use 'file' as floppy disk 0/1 image\n")
- DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "")
-Index: qemu-kvm/vl.c
-===================================================================
---- qemu-kvm.orig/vl.c 2009-12-21 10:37:58.000000000 +0100
-+++ qemu-kvm/vl.c      2009-12-21 10:42:50.000000000 +0100
-@@ -159,6 +159,7 @@
- #include "qemu-objects.h"
- #include "qemu-kvm.h"
- #include "hw/device-assignment.h"
-+#include "vzsyscalls.h"
- #include "disas.h"
-@@ -224,6 +225,7 @@
- int max_cpus = 0;
- int smp_cores = 1;
- int smp_threads = 1;
-+int fairsched_id = 0;
- const char *vnc_display;
- int acpi_enabled = 1;
- #ifdef TARGET_I386
-@@ -363,7 +365,7 @@
-     prctl(PR_SET_NAME, name);
- #endif        
- }
-- 
-+
- /***************/
- /* ballooning */
-@@ -4897,6 +4899,7 @@
-     const char *gdbstub_dev = NULL;
-     uint32_t boot_devices_bitmap = 0;
-     int i;
-+    int cpuunits = 0;
-     int snapshot, linux_boot, net_boot;
-     const char *initrd_filename;
-     const char *kernel_filename, *kernel_cmdline;
-@@ -5550,6 +5553,20 @@
-                     exit(1);
-                 }
-                 break;
-+            case QEMU_OPTION_id:
-+                fairsched_id = atoi(optarg);
-+              if (fairsched_id < 100 || fairsched_id >= 1000000) {
-+                  fprintf(stderr, "Invalid ID\n");
-+                  exit(1);
-+              }
-+                break;
-+            case QEMU_OPTION_cpuunits:
-+                cpuunits = atoi(optarg);
-+              if (cpuunits < 8 || cpuunits > 500000) {
-+                  fprintf(stderr, "Invalid value for cpuunits\n");
-+                    exit(1);
-+                }
-+                break;
-           case QEMU_OPTION_vnc:
-                 display_type = DT_VNC;
-               vnc_display = optarg;
-@@ -5947,6 +5964,39 @@
-     if (ram_size == 0)
-         ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
-+    if (cpuunits && !fairsched_id) {
-+      fprintf(stderr, "cpuunits specified without -id");
-+      exit (1);
-+    }
-+
-+    if (fairsched_id) {
-+      int ret;
-+      int weight = cpuunits ? 500000/cpuunits : 500;
-+      pid_t cpid = getpid();
-+
-+      ret = syscall(__NR_fairsched_rmnod, fairsched_id);
-+      if (ret == -EBUSY) {
-+      fprintf (stderr, "unable to create fairsched node - still in use\n");
-+      exit(1);
-+      }
-+
-+      ret = syscall(__NR_fairsched_mknod, 0, weight, fairsched_id);
-+      if (ret != fairsched_id) {
-+      fprintf (stderr, "unable to create fairsched node\n");
-+      exit(1);
-+      }
-+
-+      ret = syscall(__NR_fairsched_mvpr, cpid, fairsched_id);
-+      if (ret != 0) {
-+      fprintf (stderr, "unable to move procces to fairsched group");
-+      exit (1);
-+      }
-+
-+      /* note: we can never remove ourself from the group, so the empty group
-+       will exist after we finish
-+      */
-+    }
-+
-     /* init the dynamic translator */
-     cpu_exec_init_all(tb_size * 1024 * 1024);
-Index: qemu-kvm/vzsyscalls.h
-===================================================================
---- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ qemu-kvm/vzsyscalls.h      2009-12-21 10:41:25.000000000 +0100
-@@ -0,0 +1,47 @@
-+/*
-+ *  Copyright (C) 2000-2008, Parallels, Inc. All rights reserved.
-+ *
-+ *  This program is free software; you can redistribute it and/or modify
-+ *  it under the terms of the GNU General Public License as published by
-+ *  the Free Software Foundation; either version 2 of the License, or
-+ *  (at your option) any later version.
-+ *
-+ *  This program is distributed in the hope that it will be useful,
-+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ *  GNU General Public License for more details.
-+ *
-+ *  You should have received a copy of the GNU General Public License
-+ *  along with this program; if not, write to the Free Software
-+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-+ */
-+#ifndef _VZSYSCALLS_H_
-+#define _VZSYSCALLS_H_
-+
-+#include <sys/syscall.h>
-+
-+#ifdef __x86_64__
-+#define __NR_fairsched_vcpus  499
-+#define __NR_setluid          501
-+#define __NR_setublimit               502
-+#define __NR_fairsched_mknod    504
-+#define __NR_fairsched_rmnod    505
-+#define __NR_fairsched_chwt   506
-+#define __NR_fairsched_mvpr     507
-+#define __NR_fairsched_rate   508
-+#define __NR_ioprio_set               251
-+#elif defined(__i386__)
-+#define __NR_fairsched_mknod    500
-+#define __NR_fairsched_rmnod    501
-+#define __NR_fairsched_chwt   502
-+#define __NR_fairsched_mvpr     503
-+#define __NR_fairsched_rate   504
-+#define __NR_fairsched_vcpus  505
-+#define __NR_setluid          511
-+#define __NR_setublimit               512
-+#define __NR_ioprio_set               289
-+#else
-+#error "no syscall for this arch"
-+#endif
-+
-+#endif
diff --git a/debian/patches-0.12.1/keymap.diff b/debian/patches-0.12.1/keymap.diff
deleted file mode 100644 (file)
index ac4904d..0000000
+++ /dev/null
@@ -1,468 +0,0 @@
-Index: kvm-86/curses.c
-===================================================================
---- kvm-86.orig/curses.c       2009-05-22 10:09:19.000000000 +0200
-+++ kvm-86/curses.c    2009-05-22 10:10:38.000000000 +0200
-@@ -238,7 +238,11 @@
-                 keysym = chr;
-             keycode &= ~KEY_MASK;
--            keycode |= keysym2scancode(kbd_layout, keysym);
-+
-+          keydata_t *kd = find_keysym(kbd_layout, keysym);
-+          if (kd) {
-+              keycode |= kd->keycode;
-+          }
-         }
-         if (is_graphic_console()) {
-Index: kvm-86/keymaps.c
-===================================================================
---- kvm-86.orig/keymaps.c      2009-05-22 10:09:24.000000000 +0200
-+++ kvm-86/keymaps.c   2009-05-22 10:10:38.000000000 +0200
-@@ -67,6 +67,7 @@
-     char file_name[1024];
-     char line[1024];
-     int len;
-+    int upper;
-     snprintf(file_name, sizeof(file_name),
-              "%s/keymaps/%s", bios_dir, language);
-@@ -97,25 +98,66 @@
-           if (*end_of_keysym) {
-               int keysym;
-               *end_of_keysym = 0;
-+                uint8_t keymod;
-+                int deadsym;
-+
-+                keymod = 0;
-+                deadsym = 0;
-+              upper = 0;
-+redo:
-+                if (upper==1){
-+                    char *c;
-+                    for(c=line;*c;c++)
-+                        *c=toupper(*c);
-+                    keymod |= KEYMOD_SHIFT;
-+                    upper++;
-+                }
-+
-               keysym = get_keysym(table, line);
-               if (keysym == 0) {
-                     //                    fprintf(stderr, "Warning: unknown keysym %s\n", line);
-               } else {
-                   const char *rest = end_of_keysym + 1;
-                   char *rest2;
-+                  char *modifier;
-                   int keycode = strtol(rest, &rest2, 0);
--                  if (rest && strstr(rest, "numlock")) {
--                      add_to_key_range(&k->keypad_range, keycode);
--                      add_to_key_range(&k->numlock_range, keysym);
--                      //fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
-+                    modifier = strtok (rest2, " ");
-+                    while (modifier != NULL) {
-+                        if (!strcmp(modifier, "shift")) {
-+                            keymod |= KEYMOD_SHIFT;
-+                        } else
-+                      if (!strcmp(modifier, "addupper")) {
-+                          upper++;
-+                      } else
-+                        if (!strcmp(modifier, "ctrl")) {
-+                            keymod |= KEYMOD_CTRL;
-+                        } else
-+                        if (!strcmp(modifier, "alt")) {
-+                            keymod |= KEYMOD_ALT;
-+                        } else
-+                        if (!strcmp(modifier, "altgr")) {
-+                            keymod |= KEYMOD_ALTGR;
-+                        } else
-+                        if (!strncmp(modifier, "dead_",5)) {
-+                            keymod |= KEYMOD_DEAD;
-+                            deadsym = get_keysym(table, modifier);
-+                        } else
-+                        if (!strcmp(modifier, "numlock")) {
-+                          add_to_key_range(&k->keypad_range, keycode);
-+                          add_to_key_range(&k->numlock_range, keysym);
-+                          //fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
-+                      }
-+                      modifier = strtok (NULL," ");
-                   }
-                   /* if(keycode&0x80)
-                      keycode=(keycode<<8)^0x80e0; */
-                   if (keysym < MAX_NORMAL_KEYCODE) {
-                       //fprintf(stderr,"Setting keysym %s (%d) to %d\n",line,keysym,keycode);
--                      k->keysym2keycode[keysym] = keycode;
-+                        k->keysym2keycode[keysym].keycode = keycode;
-+                        k->keysym2keycode[keysym].keymod = keymod;
-+                        k->keysym2keycode[keysym].deadsym = deadsym;
-                   } else {
-                       if (k->extra_count >= MAX_EXTRA_COUNT) {
-                           fprintf(stderr,
-@@ -128,11 +170,18 @@
- #endif
-                           k->keysym2keycode_extra[k->extra_count].
-                               keysym = keysym;
--                          k->keysym2keycode_extra[k->extra_count].
--                              keycode = keycode;
-+                          k->keysym2keycode_extra[k->extra_count].kdata.
-+                              keycode = keycode;
-+                          k->keysym2keycode_extra[k->extra_count].kdata.
-+                              keymod = keymod;
-+                            k->keysym2keycode_extra[k->extra_count].kdata.
-+                              deadsym = deadsym;
-+
-                           k->extra_count++;
-                       }
-                   }
-+                    if (upper==1)
-+                        goto redo;
-               }
-           }
-       }
-@@ -148,14 +197,11 @@
- }
--int keysym2scancode(void *kbd_layout, int keysym)
-+keydata_t *find_keysym(void *kbd_layout, int keysym)
- {
-     kbd_layout_t *k = kbd_layout;
-     if (keysym < MAX_NORMAL_KEYCODE) {
--      if (k->keysym2keycode[keysym] == 0)
--          fprintf(stderr, "Warning: no scancode found for keysym %d\n",
--                  keysym);
--      return k->keysym2keycode[keysym];
-+        return &k->keysym2keycode[keysym];
-     } else {
-       int i;
- #ifdef XK_ISO_Left_Tab
-@@ -163,10 +209,10 @@
-           keysym = XK_Tab;
- #endif
-       for (i = 0; i < k->extra_count; i++)
--          if (k->keysym2keycode_extra[i].keysym == keysym)
--              return k->keysym2keycode_extra[i].keycode;
-+            if (k->keysym2keycode_extra[i].keysym == keysym)
-+                return &k->keysym2keycode_extra[i].kdata;
-     }
--    return 0;
-+    return NULL;
- }
- int keycode_is_keypad(void *kbd_layout, int keycode)
-Index: kvm-86/keymaps.h
-===================================================================
---- kvm-86.orig/keymaps.h      2009-05-22 10:09:32.000000000 +0200
-+++ kvm-86/keymaps.h   2009-05-22 10:10:38.000000000 +0200
-@@ -38,13 +38,26 @@
-     struct key_range *next;
- };
-+#define KEYMOD_SHIFT 0x01
-+#define KEYMOD_CTRL  0x02
-+#define KEYMOD_ALT   0x04
-+#define KEYMOD_DEAD  0x08
-+#define KEYMOD_ALTGR 0x10
-+
- #define MAX_NORMAL_KEYCODE 512
- #define MAX_EXTRA_COUNT 256
-+
-+typedef struct {
-+    uint16_t keycode;
-+    uint8_t keymod;
-+    int deadsym;
-+} keydata_t;
-+
- typedef struct {
--    uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
-+    keydata_t keysym2keycode[MAX_NORMAL_KEYCODE];
-     struct {
-       int keysym;
--      uint16_t keycode;
-+        keydata_t kdata;
-     } keysym2keycode_extra[MAX_EXTRA_COUNT];
-     int extra_count;
-     struct key_range *keypad_range;
-@@ -53,7 +66,7 @@
- void *init_keyboard_layout(const name2keysym_t *table, const char *language);
--int keysym2scancode(void *kbd_layout, int keysym);
-+keydata_t *find_keysym(void *kbd_layout, int keysym);
- int keycode_is_keypad(void *kbd_layout, int keycode);
- int keysym_is_numlock(void *kbd_layout, int keysym);
-Index: kvm-86/sdl.c
-===================================================================
---- kvm-86.orig/sdl.c  2009-05-22 10:09:43.000000000 +0200
-+++ kvm-86/sdl.c       2009-05-22 10:10:38.000000000 +0200
-@@ -214,7 +214,11 @@
-     if (keysym == 92 && ev->keysym.scancode == 133) {
-         keysym = 0xa5;
-     }
--    return keysym2scancode(kbd_layout, keysym);
-+    keydata_t *kd = find_keysym(kbd_layout, keysym);
-+    if (kd==NULL)
-+        return 0;
-+    else
-+        return kd->keycode;
- }
- /* specific keyboard conversions from scan codes */
-Index: kvm-86/vnc.c
-===================================================================
---- kvm-86.orig/vnc.c  2009-05-22 10:09:54.000000000 +0200
-+++ kvm-86/vnc.c       2009-05-22 10:10:38.000000000 +0200
-@@ -1257,27 +1257,85 @@
-     check_pointer_type_change(vs, kbd_mouse_is_absolute());
- }
-+static void do_keycode(int keycode, int down)
-+{
-+    // fprintf (stderr, "KEY: %04x %d\n", keycode, down);
-+    if (keycode & 0x80)
-+        kbd_put_keycode(0xe0);
-+    if (down)
-+        kbd_put_keycode(keycode & 0x7f);
-+    else
-+        kbd_put_keycode(keycode | 0x80);
-+}
-+
-+static void do_modifier(VncState *vs, int keycode, int down, int level)
-+{
-+    do_keycode(keycode, down);
-+    vs->modifiers_state[level][keycode] = down;
-+    if (level==0) {
-+        vs->modifiers_state[1][keycode] = down;
-+    }
-+}
-+
- static void reset_keys(VncState *vs)
- {
-     int i;
-     for(i = 0; i < 256; i++) {
--        if (vs->modifiers_state[i]) {
--            if (i & 0x80)
--                kbd_put_keycode(0xe0);
--            kbd_put_keycode(i | 0x80);
--            vs->modifiers_state[i] = 0;
-+        if (vs->modifiers_state[0][i]) {
-+          do_modifier (vs, i, 0, 0);
-+        }
-+    }
-+}
-+
-+static void set_modifiers(VncState *vs, uint8_t reqstate, int down, int full)
-+{
-+    modifier_t *m;
-+    for(m=test_modifier; m->bit; m++) {
-+        int requested = reqstate & m->bit;
-+        /* Release unwanted modifiers */
-+        if (!down || full) {
-+            if (vs->modifiers_state[1][m->keycode] && !requested)
-+                do_modifier(vs, m->keycode, 0, 1);
-+        }
-+        /* Press desired modifiers */
-+        if (down || full) {
-+            int already_set = vs->modifiers_state[1][m->keycode];
-+            if (!already_set && requested)
-+                do_modifier(vs, m->keycode, 1, 1);
-         }
-     }
- }
-+static void restore_modifiers(VncState *vs)
-+{
-+    /* Restore modifiers from reference */
-+    modifier_t *m;
-+    for(m=test_modifier; m->bit; m++) {
-+        if (vs->modifiers_state[0][m->keycode] !=
-+          vs->modifiers_state[1][m->keycode])
-+            do_modifier(vs, m->keycode, vs->modifiers_state[0][m->keycode], 0);
-+    }
-+}
- static void press_key(VncState *vs, int keysym)
- {
--    kbd_put_keycode(keysym2scancode(vs->vd->kbd_layout, keysym) & 0x7f);
--    kbd_put_keycode(keysym2scancode(vs->vd->kbd_layout, keysym) | 0x80);
-+    keydata_t *kd = find_keysym(vs->vd->kbd_layout, keysym & 0xFFFF);
-+    if (kd==NULL)
-+        return;
-+
-+    kbd_put_keycode(kd->keycode & 0x7f);
-+    kbd_put_keycode(kd->keycode | 0x80);
- }
--static void do_key_event(VncState *vs, int down, int keycode, int sym)
-+static void do_key_event(VncState *vs, int down, keydata_t *kd, int sym)
- {
-+    if (kd==NULL)
-+        return;
-+
-+    int keycode = kd->keycode;
-+    //fprintf (stderr, "SYM: %04x SCANCODE: %04x MOD %04x\n",
-+    //             sym, keycode, kd->keymod);
-+
-+
-     /* QEMU console switch */
-     switch(keycode) {
-     case 0x2a:                          /* Left Shift */
-@@ -1286,23 +1344,24 @@
-     case 0x9d:                          /* Right CTRL */
-     case 0x38:                          /* Left ALT */
-     case 0xb8:                          /* Right ALT */
--        if (down)
--            vs->modifiers_state[keycode] = 1;
--        else
--            vs->modifiers_state[keycode] = 0;
--        break;
-+        do_modifier(vs, keycode, down, 0);
-+        return;
-     case 0x02 ... 0x0a: /* '1' to '9' keys */
--        if (down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) {
-+        if (down && vs->modifiers_state[0][0x1d] && vs->modifiers_state[0][0x38]) {
-             /* Reset the modifiers sent to the current console */
-             reset_keys(vs);
-             console_select(keycode - 0x02);
-             return;
-         }
-         break;
--    case 0x3a:                        /* CapsLock */
--    case 0x45:                        /* NumLock */
--        if (!down)
--            vs->modifiers_state[keycode] ^= 1;
-+    case 0x3a:                        /* CapsLock */
-+    case 0x45:                        /* NumLock */
-+        if (!down) {
-+          if (vs->modifiers_state[0][0x45])
-+              do_modifier(vs, keycode, 0, 0);
-+          else
-+              do_modifier(vs, keycode, 1, 0);
-+      }
-         break;
-     }
-@@ -1312,25 +1371,42 @@
-            toggles numlock away from the VNC window.
-         */
-         if (keysym_is_numlock(vs->vd->kbd_layout, sym & 0xFFFF)) {
--            if (!vs->modifiers_state[0x45]) {
--                vs->modifiers_state[0x45] = 1;
-+          if (!vs->modifiers_state[0][0x45]) {
-+              do_modifier(vs, 0x45, 1, 0);
-                 press_key(vs, 0xff7f);
-             }
-         } else {
--            if (vs->modifiers_state[0x45]) {
--                vs->modifiers_state[0x45] = 0;
--                press_key(vs, 0xff7f);
-+            if (vs->modifiers_state[0][0x45]) {
-+              do_modifier(vs, 0x45, 0, 0);
-+              press_key(vs, 0xff7f);
-             }
-         }
-     }
-     if (is_graphic_console()) {
--        if (keycode & 0x80)
--            kbd_put_keycode(0xe0);
--        if (down)
--            kbd_put_keycode(keycode & 0x7f);
--        else
--            kbd_put_keycode(keycode | 0x80);
-+        if (down) {
-+          /* Send deadkey */
-+          if (kd->keymod & KEYMOD_DEAD) {
-+            keydata_t *deaddata;
-+            deaddata = find_keysym(vs->vd->kbd_layout, kd->deadsym);
-+            if (deaddata != NULL) {
-+                set_modifiers(vs, deaddata->keymod, 0, 1);
-+                do_keycode(deaddata->keycode, 1);
-+                do_keycode(deaddata->keycode, 0);
-+                restore_modifiers(vs);
-+            }
-+          }
-+          set_modifiers(vs, kd->keymod, 1, 0);
-+      } else
-+          restore_modifiers(vs);
-+
-+        do_keycode (keycode, down);
-+
-+      /* vnc never sends ALTGR, so we create an artificial up event */
-+      if (down && (kd->keymod & KEYMOD_ALTGR)) {
-+          set_modifiers(vs, kd->keymod, 0, 0);
-+      }
-+
-     } else {
-         /* QEMU console emulation */
-         if (down) {
-@@ -1388,13 +1464,9 @@
- static void key_event(VncState *vs, int down, uint32_t sym)
- {
--    int keycode;
--
--    if (sym >= 'A' && sym <= 'Z' && is_graphic_console())
--        sym = sym - 'A' + 'a';
-+    keydata_t *kd = find_keysym(vs->vd->kbd_layout, sym & 0xFFFF);
--    keycode = keysym2scancode(vs->vd->kbd_layout, sym & 0xFFFF);
--    do_key_event(vs, down, keycode, sym);
-+    do_key_event(vs, down, kd, sym & 0xFFFF);
- }
- static void ext_key_event(VncState *vs, int down,
-@@ -1403,8 +1475,15 @@
-     /* if the user specifies a keyboard layout, always use it */
-     if (keyboard_layout)
-         key_event(vs, down, sym);
--    else
--        do_key_event(vs, down, keycode, sym);
-+    else {
-+        keydata_t kd;
-+
-+        kd.keycode = keycode;
-+      kd.keymod = 0;
-+      kd.deadsym = 0;
-+
-+      do_key_event(vs, down, &kd, sym & 0xFFFF);
-+    }
- }
- static void framebuffer_update_request(VncState *vs, int incremental,
-Index: kvm-86/vnc.h
-===================================================================
---- kvm-86.orig/vnc.h  2009-05-22 10:10:08.000000000 +0200
-+++ kvm-86/vnc.h       2009-05-22 10:10:38.000000000 +0200
-@@ -49,6 +49,21 @@
-  *
-  *****************************************************************************/
-+typedef struct {
-+    int keycode;
-+    int bit;
-+} modifier_t;
-+
-+static modifier_t test_modifier[]={
-+    {0x2a, KEYMOD_SHIFT},
-+    {0x36, KEYMOD_SHIFT},
-+    {0x1d, KEYMOD_CTRL},
-+    {0x9d, KEYMOD_CTRL},
-+    {0x38, KEYMOD_ALT},
-+    {0xb8, KEYMOD_ALTGR},
-+    {0,0},
-+};
-+
- typedef struct Buffer
- {
-     size_t capacity;
-@@ -156,7 +171,7 @@
-     VncReadEvent *read_handler;
-     size_t read_handler_expect;
-     /* input */
--    uint8_t modifiers_state[256];
-+    uint8_t modifiers_state[2][256];
-     Buffer zlib;
-     Buffer zlib_tmp;
diff --git a/debian/patches-0.12.1/live-migration-fixes.diff b/debian/patches-0.12.1/live-migration-fixes.diff
deleted file mode 100644 (file)
index 1cb3a71..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-Index: qemu-kvm/vl.c
-===================================================================
---- qemu-kvm.orig/vl.c 2009-09-30 10:35:45.000000000 +0200
-+++ qemu-kvm/vl.c      2009-09-30 10:47:05.000000000 +0200
-@@ -3175,9 +3175,10 @@
- static int ram_save_live(QEMUFile *f, int stage, void *opaque)
- {
-     ram_addr_t addr;
--    uint64_t bytes_transferred_last;
-     double bwidth = 0;
-     uint64_t expected_time = 0;
-+    static int64_t starttime = 0;
-+    double timediff;
-     if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
-         qemu_file_set_error(f);
-@@ -3195,10 +3196,9 @@
-         cpu_physical_memory_set_dirty_tracking(1);
-         qemu_put_be64(f, last_ram_offset | RAM_SAVE_FLAG_MEM_SIZE);
--    }
--    bytes_transferred_last = bytes_transferred;
--    bwidth = get_clock();
-+      starttime = get_clock();
-+    }
-     while (!qemu_file_rate_limit(f)) {
-         int ret;
-@@ -3209,8 +3209,8 @@
-             break;
-     }
--    bwidth = get_clock() - bwidth;
--    bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
-+    timediff = get_clock() - starttime;
-+    bwidth = bytes_transferred / timediff;
-     /* if we haven't transferred anything this round, force expected_time to a
-      * a very high value, but without crashing */
-@@ -3230,6 +3230,10 @@
-     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
-+    if ((stage == 2) && (bytes_transferred > 2*ram_bytes_total())) {
-+        return 1;
-+    }
-+
-     expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
-     return (stage == 2) && (expected_time <= migrate_max_downtime());
diff --git a/debian/patches-0.12.1/multicore.diff b/debian/patches-0.12.1/multicore.diff
deleted file mode 100644 (file)
index f4a4674..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-Index: kvm-86/cpu-defs.h
-===================================================================
---- kvm-86.orig/cpu-defs.h     2009-09-24 14:19:14.000000000 +0200
-+++ kvm-86/cpu-defs.h  2009-09-24 14:47:00.000000000 +0200
-@@ -194,6 +194,8 @@
-     int cpu_index; /* CPU index (informative) */                        \
-     uint32_t host_tid; /* host thread ID */                             \
-     int numa_node; /* NUMA node this cpu is belonging to  */            \
-+    int nr_cores;  /* number of cores within this CPU package */        \
-+    int nr_threads;/* number of threads within this CPU */              \
-     int running; /* Nonzero if cpu is currently running(usermode).  */  \
-     int thread_id;                                                    \
-     /* user data */                                                     \
-Index: kvm-86/target-i386/helper.c
-===================================================================
---- kvm-86.orig/target-i386/helper.c   2009-09-24 14:19:14.000000000 +0200
-+++ kvm-86/target-i386/helper.c        2009-09-24 14:50:18.000000000 +0200
-@@ -121,7 +121,7 @@
- #ifdef TARGET_X86_64
-     {
-         .name = "qemu64",
--        .level = 2,
-+        .level = 4,
-         .vendor1 = CPUID_VENDOR_AMD_1,
-         .vendor2 = CPUID_VENDOR_AMD_2,
-         .vendor3 = CPUID_VENDOR_AMD_3,
-@@ -192,7 +192,7 @@
- #endif
-     {
-         .name = "qemu32",
--        .level = 2,
-+        .level = 4,
-         .family = 6,
-         .model = 3,
-         .stepping = 3,
-@@ -1638,6 +1638,12 @@
-         *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
-         *ecx = env->cpuid_ext_features;
-         *edx = env->cpuid_features;
-+
-+        if (env->nr_cores * env->nr_threads > 1) {
-+          *ebx |= (env->nr_cores * env->nr_threads) << 16;
-+          *edx |= 1 << 28;    /* HTT bit */
-+        }
-+
-         break;
-     case 2:
-         /* cache info: needed for Pentium Pro compatibility */
-@@ -1648,21 +1654,29 @@
-         break;
-     case 4:
-         /* cache info: needed for Core compatibility */
-+        if (env->nr_cores > 1) {
-+              *eax = (env->nr_cores - 1) << 26;
-+        } else {
-+              *eax = 0;
-+        }
-         switch (count) {
-             case 0: /* L1 dcache info */
--                *eax = 0x0000121;
-+                *eax |= 0x0000121;
-                 *ebx = 0x1c0003f;
-                 *ecx = 0x000003f;
-                 *edx = 0x0000001;
-                 break;
-             case 1: /* L1 icache info */
--                *eax = 0x0000122;
-+                *eax |= 0x0000122;
-                 *ebx = 0x1c0003f;
-                 *ecx = 0x000003f;
-                 *edx = 0x0000001;
-                 break;
-             case 2: /* L2 cache info */
--                *eax = 0x0000143;
-+                *eax |= 0x0000143;
-+                if (env->nr_threads > 1) {
-+                    *eax |= (env->nr_threads - 1) << 14;
-+                }
-                 *ebx = 0x3c0003f;
-                 *ecx = 0x0000fff;
-                 *edx = 0x0000001;
-@@ -1715,6 +1729,16 @@
-         *ecx = env->cpuid_ext3_features;
-         *edx = env->cpuid_ext2_features;
-+        if (env->nr_cores * env->nr_threads > 1) {
-+            uint32_t teax, tebx, tecx, tedx;
-+            cpu_x86_cpuid(env, 0, 0, &teax, &tebx, &tecx, &tedx);
-+            if ( tebx == CPUID_VENDOR_AMD_1 &&
-+                tedx == CPUID_VENDOR_AMD_2 &&
-+                tecx == CPUID_VENDOR_AMD_3) {
-+                *ecx |= 1 << 1;    /* CmpLegacy bit */
-+            }
-+      }
-+
-         if (kvm_enabled()) {
-             uint32_t h_eax, h_edx;
-@@ -1790,6 +1814,9 @@
-         *ebx = 0;
-         *ecx = 0;
-         *edx = 0;
-+        if (env->nr_cores * env->nr_threads > 1) {
-+            *ecx |= (env->nr_cores * env->nr_threads) - 1;
-+        }
-         break;
-     case 0x8000000A:
-         *eax = 0x00000001; /* SVM Revision */
-Index: kvm-86/vl.c
-===================================================================
---- kvm-86.orig/vl.c   2009-09-24 14:30:14.000000000 +0200
-+++ kvm-86/vl.c        2009-09-24 14:47:00.000000000 +0200
-@@ -230,6 +230,8 @@
- const char *assigned_devices[MAX_DEV_ASSIGN_CMDLINE];
- int assigned_devices_index;
- int smp_cpus = 1;
-+int smp_cores = 1;
-+int smp_threads = 1;
- int fairsched_id = 0;
- const char *vnc_display;
- int acpi_enabled = 1;
-@@ -2499,6 +2501,52 @@
-     return;
- }
-+static void smp_parse(const char *optarg)
-+{
-+    int smp, sockets = 0, threads = 0, cores = 0;
-+    char *endptr;
-+    char option[128];
-+
-+    smp = strtoul(optarg, &endptr, 10);
-+    if (endptr != optarg) {
-+        if (*endptr == ',') {
-+            endptr++;
-+        }
-+    }
-+    if (get_param_value(option, 128, "sockets", endptr) != 0)
-+        sockets = strtoull(option, NULL, 10);
-+    if (get_param_value(option, 128, "cores", endptr) != 0)
-+        cores = strtoull(option, NULL, 10);
-+    if (get_param_value(option, 128, "threads", endptr) != 0)
-+        threads = strtoull(option, NULL, 10);
-+
-+    /* compute missing values, prefer sockets over cores over threads */
-+    if (smp == 0 || sockets == 0) {
-+        sockets = sockets > 0 ? sockets : 1;
-+        cores = cores > 0 ? cores : 1;
-+        threads = threads > 0 ? threads : 1;
-+        if (smp == 0) {
-+            smp = cores * threads * sockets;
-+        } else {
-+            sockets = smp / (cores * threads);
-+        }
-+    } else {
-+        if (cores == 0) {
-+            threads = threads > 0 ? threads : 1;
-+            cores = smp / (sockets * threads);
-+        } else {
-+            if (sockets == 0) {
-+                sockets = smp / (cores * threads);
-+            } else {
-+                threads = smp / (cores * sockets);
-+            }
-+        }
-+    }
-+    smp_cpus = smp;
-+    smp_cores = cores > 0 ? cores : 1;
-+    smp_threads = threads > 0 ? threads : 1;
-+}
-+
- /***********************************************************/
- /* USB devices */
-@@ -3727,6 +3775,8 @@
-     if (kvm_enabled())
-         kvm_init_vcpu(env);
-+    env->nr_cores = smp_cores;
-+    env->nr_threads = smp_threads;
-     return;
- }
-@@ -4060,6 +4110,8 @@
-         kvm_start_vcpu(env);
-     else
-         tcg_init_vcpu(env);
-+    env->nr_cores = smp_cores;
-+    env->nr_threads = smp_threads;
- }
- void qemu_notify_event(void)
-@@ -5560,7 +5612,7 @@
-                 usb_devices_index++;
-                 break;
-             case QEMU_OPTION_smp:
--                smp_cpus = atoi(optarg);
-+                smp_parse(optarg);
-                 if (smp_cpus < 1) {
-                     fprintf(stderr, "Invalid number of CPUs\n");
-                     exit(1);
diff --git a/debian/patches-0.12.1/ps2-queue-size.diff b/debian/patches-0.12.1/ps2-queue-size.diff
deleted file mode 100644 (file)
index 58564bc..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-
-bug description: boot a guest, open VNC console, and when it's still in BIOS / bootloader sequence, type as many keys as you can, move your mouse as much as you can. If needed, just reboot the guest.
-
-Linux guest will boot with "i8042.c: No controller found" and no keyboard.
-
-Further discussion seem to lead to a conclusion that there is some obscure bug in Qemu BIOS which makes this problem visible.
-
-Index: kvm-86/hw/ps2.c
-===================================================================
---- kvm-86.orig/hw/ps2.c       2009-06-15 13:31:24.000000000 +0200
-+++ kvm-86/hw/ps2.c    2009-06-15 13:31:50.000000000 +0200
-@@ -70,7 +70,7 @@
- #define MOUSE_STATUS_ENABLED    0x20
- #define MOUSE_STATUS_SCALE21    0x10
--#define PS2_QUEUE_SIZE 256
-+#define PS2_QUEUE_SIZE 15
- typedef struct {
-     uint8_t data[PS2_QUEUE_SIZE];
diff --git a/debian/patches-0.12.1/series b/debian/patches-0.12.1/series
deleted file mode 100644 (file)
index 902ebc9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-adjust-path.diff
-fairsched.diff
-vncticket.diff
-#keymap.diff
-#multicore.diff
-live-migration-fixes.diff
-enable-ksm.diff
diff --git a/debian/patches-0.12.1/vncticket.diff b/debian/patches-0.12.1/vncticket.diff
deleted file mode 100644 (file)
index 5bf4102..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-Index: qemu-kvm/console.h
-===================================================================
---- qemu-kvm.orig/console.h    2009-12-21 10:37:57.000000000 +0100
-+++ qemu-kvm/console.h 2009-12-21 10:45:29.000000000 +0100
-@@ -322,7 +322,7 @@
- void vnc_display_init(DisplayState *ds);
- void vnc_display_close(DisplayState *ds);
- int vnc_display_open(DisplayState *ds, const char *display);
--int vnc_display_password(DisplayState *ds, const char *password);
-+int vnc_display_password(DisplayState *ds, const char *password, int limit);
- void do_info_vnc_print(Monitor *mon, const QObject *data);
- void do_info_vnc(Monitor *mon, QObject **ret_data);
- char *vnc_display_local_addr(DisplayState *ds);
-Index: qemu-kvm/monitor.c
-===================================================================
---- qemu-kvm.orig/monitor.c    2009-12-21 10:37:58.000000000 +0100
-+++ qemu-kvm/monitor.c 2009-12-21 11:03:40.000000000 +0100
-@@ -949,9 +949,9 @@
-     monitor_read_bdrv_key_start(mon, bs, NULL, NULL);
- }
--static void change_vnc_password(const char *password)
-+static void change_vnc_password(const char *password, int limit)
- {
--    if (vnc_display_password(NULL, password) < 0)
-+    if (vnc_display_password(NULL, password, limit) < 0)
-         qemu_error_new(QERR_SET_PASSWD_FAILED);
- }
-@@ -959,19 +959,30 @@
- static void change_vnc_password_cb(Monitor *mon, const char *password,
-                                    void *opaque)
- {
--    change_vnc_password(password);
-+    change_vnc_password(password, 0);
-+    monitor_read_command(mon, 1);
-+}
-+
-+static void change_vnc_ticket_cb(Monitor *mon, const char *password,
-+                               void *opaque)
-+{
-+    change_vnc_password(password, 1);
-     monitor_read_command(mon, 1);
- }
- static void do_change_vnc(Monitor *mon, const char *target, const char *arg)
- {
-     if (strcmp(target, "passwd") == 0 ||
--        strcmp(target, "password") == 0) {
-+        strcmp(target, "password") == 0 ||
-+      strcmp(target, "ticket") == 0) {
-         if (arg) {
-             char password[9];
-             strncpy(password, arg, sizeof(password));
-             password[sizeof(password) - 1] = '\0';
--            change_vnc_password(password);
-+          if (strcmp(target, "ticket") == 0)
-+            change_vnc_ticket_cb(mon, password, NULL);
-+          else 
-+            change_vnc_password_cb(mon, password, NULL);
-         } else {
-             monitor_read_password(mon, change_vnc_password_cb, NULL);
-         }
-Index: qemu-kvm/vnc.c
-===================================================================
---- qemu-kvm.orig/vnc.c        2009-12-21 10:37:57.000000000 +0100
-+++ qemu-kvm/vnc.c     2009-12-21 10:44:13.000000000 +0100
-@@ -1763,7 +1763,7 @@
- static void set_pixel_conversion(VncState *vs)
- {
-     if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
--        (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG) && 
-+        (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG) &&
-         !memcmp(&(vs->clientds.pf), &(vs->ds->surface->pf), sizeof(PixelFormat))) {
-         vs->write_pixels = vnc_write_pixels_copy;
-         switch (vs->ds->surface->pf.bits_per_pixel) {
-@@ -1871,7 +1871,7 @@
-         vnc_write_u8(vs, 0);  /* msg id */
-         vnc_write_u8(vs, 0);
-         vnc_write_u16(vs, 1); /* number of rects */
--        vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds), 
-+        vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds),
-                                ds_get_height(vs->ds), VNC_ENCODING_WMVi);
-         pixel_format_message(vs);
-         vnc_flush(vs);
-@@ -2068,7 +2068,10 @@
-     int i, j, pwlen;
-     unsigned char key[8];
--    if (!vs->vd->password || !vs->vd->password[0]) {
-+    if (vs->vd->retries >= 0)
-+        vs->vd->retries++;
-+
-+    if (!vs->vd->password || !vs->vd->password[0] || vs->vd->retries > 3) {
-         VNC_DEBUG("No password configured on server");
-         vnc_write_u32(vs, 1); /* Reject auth */
-         if (vs->minor >= 8) {
-@@ -2438,7 +2441,7 @@
- #endif
- }
--int vnc_display_password(DisplayState *ds, const char *password)
-+int vnc_display_password(DisplayState *ds, const char *password, int limit)
- {
-     VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
-@@ -2453,6 +2456,7 @@
-     if (password && password[0]) {
-         if (!(vs->password = qemu_strdup(password)))
-             return -1;
-+      vs->retries = limit ? 0 : -1;
-         if (vs->auth == VNC_AUTH_NONE) {
-             vs->auth = VNC_AUTH_VNC;
-         }
-Index: qemu-kvm/vnc.h
-===================================================================
---- qemu-kvm.orig/vnc.h        2009-12-21 10:37:57.000000000 +0100
-+++ qemu-kvm/vnc.h     2009-12-21 10:44:13.000000000 +0100
-@@ -104,6 +104,7 @@
-     char *display;
-     char *password;
-+    int retries;
-     int auth;
- #ifdef CONFIG_VNC_TLS
-     int subauth; /* Used by VeNCrypt */
diff --git a/debian/patches/old/0000-cover-letter.patch b/debian/patches/old/0000-cover-letter.patch
deleted file mode 100644 (file)
index 2c2f006..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-From aa580be154923056a52fdeec429f7e80f04b456e Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Thu, 21 Feb 2013 12:22:41 +0100
-Subject: [PATCH v5 0/6] Efficient VM backup for qemu
-
-This series provides a way to efficiently backup VMs.
-
-* Backup to a single archive file
-* Backup contain all data to restore VM (full backup)
-* Do not depend on storage type or image format
-* Avoid use of temporary storage
-* store sparse images efficiently
-
-The file docs/backup.txt contains more details.
-
-Changes since v1:
-
-* fix spelling errors
-* move BackupInfo from BDS to BackupBlockJob
-* introduce BackupDriver to allow more than one backup format
-* vma: add suport to store vmstate (size is not known in advance)
-* add ability to store VM state
-
-Changes since v2:
-
-* BackupDriver: remove cancel_cb
-* use enum for BackupFormat
-* vma: use bdrv_open instead of bdrv_file_open
-* vma: fix aio, use O_DIRECT
-* backup one drive after another (try to avoid high load)
-
-Changes since v3:
-
-* move reviewer info from commit messages to cover-letter
-* remove 'RFC' from log headers and file names
-* removed comment about slow qcow2 snapshot bug
-* fix spelling errors
-* fixed copyright
-* change 'backupfile' parameter name to 'backup-file'
-* change 'config-filename' parameter name to 'config-file'
-* add documentation for 'devlist' parameter.
-* rename backup_cancel to backup-cancel
-
-Changes since v4:
-
-* vma create: write verbose output to stderr (not stdout)
-* backup.c: use rwlock instead of sleep, remove backup_in_progress_count
-* BackupDriver: remove '_cb' suffix
-* include cleanups suggested by Stefan
-* use CHAR_BIT instead of magic number '8'
-* implemented bdrv_co_is_allocated_above() - disabled for now because
-  it actually slows down backup speed by 15%
-* extend regression tests to test unallocated regions
-
-Dietmar Maurer (6):
-  add documenation for new backup framework
-  add basic backup support to block driver
-  add backup related monitor commands
-  introduce new vma archive format
-  add regression tests for backup
-  add vm state to backups
-
- Makefile                 |    3 +-
- Makefile.objs            |    1 +
- backup.c                 |  355 +++++++++++++++++
- backup.h                 |   45 +++
- block.c                  |   71 ++++-
- blockdev.c               |  617 ++++++++++++++++++++++++++++++
- docs/backup.txt          |  116 ++++++
- docs/specs/vma_spec.txt  |   24 ++
- hmp-commands.hx          |   31 ++
- hmp.c                    |   64 ++++
- hmp.h                    |    3 +
- include/block/block.h    |    2 +
- include/block/blockjob.h |   10 +
- monitor.c                |    7 +
- qapi-schema.json         |   98 +++++
- qmp-commands.hx          |   27 ++
- tests/Makefile           |   11 +-
- tests/backup-test.c      |  529 ++++++++++++++++++++++++++
- vma-reader.c             |  799 +++++++++++++++++++++++++++++++++++++++
- vma-writer.c             |  940 ++++++++++++++++++++++++++++++++++++++++++++++
- vma.c                    |  561 +++++++++++++++++++++++++++
- vma.h                    |  145 +++++++
- 22 files changed, 4450 insertions(+), 9 deletions(-)
- create mode 100644 backup.c
- create mode 100644 backup.h
- create mode 100644 docs/backup.txt
- create mode 100644 docs/specs/vma_spec.txt
- create mode 100644 tests/backup-test.c
- create mode 100644 vma-reader.c
- create mode 100644 vma-writer.c
- create mode 100644 vma.c
- create mode 100644 vma.h
-
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0001-add-documenation-for-new-backup-framework.patch b/debian/patches/old/0001-add-documenation-for-new-backup-framework.patch
deleted file mode 100644 (file)
index bb3b9bf..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-From 2f0dcd89a0de8b656d33ce6997c09879bd287af7 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Tue, 13 Nov 2012 09:24:50 +0100
-Subject: [PATCH v5 1/6] add documenation for new backup framework
-
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- docs/backup.txt |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 1 files changed, 116 insertions(+), 0 deletions(-)
- create mode 100644 docs/backup.txt
-
-diff --git a/docs/backup.txt b/docs/backup.txt
-new file mode 100644
-index 0000000..927d787
---- /dev/null
-+++ b/docs/backup.txt
-@@ -0,0 +1,116 @@
-+Efficient VM backup for qemu
-+
-+=Requirements=
-+
-+* Backup to a single archive file
-+* Backup needs to contain all data to restore VM (full backup)
-+* Do not depend on storage type or image format
-+* Avoid use of temporary storage
-+* store sparse images efficiently
-+
-+=Introduction=
-+
-+Most VM backup solutions use some kind of snapshot to get a consistent
-+VM view at a specific point in time. For example, we previously used
-+LVM to create a snapshot of all used VM images, which are then copied
-+into a tar file.
-+
-+That basically means that any data written during backup involve
-+considerable overhead. For LVM we get the following steps:
-+
-+1.) read original data (VM write)
-+2.) write original data into snapshot (VM write)
-+3.) write new data (VM write)
-+4.) read data from snapshot (backup)
-+5.) write data from snapshot into tar file (backup)
-+
-+Another approach to backup VM images is to create a new qcow2 image
-+which use the old image as base. During backup, writes are redirected
-+to the new image, so the old image represents a 'snapshot'. After
-+backup, data need to be copied back from new image into the old
-+one (commit). So a simple write during backup triggers the following
-+steps:
-+
-+1.) write new data to new image (VM write)
-+2.) read data from old image (backup)
-+3.) write data from old image into tar file (backup)
-+
-+4.) read data from new image (commit)
-+5.) write data to old image (commit)
-+
-+This is in fact the same overhead as before. Other tools like qemu
-+livebackup produces similar overhead (2 reads, 3 writes).
-+
-+Some storage types/formats supports internal snapshots using some kind
-+of reference counting (rados, sheepdog, dm-thin, qcow2). It would be possible
-+to use that for backups, but for now we want to be storage-independent.
-+
-+=Make it more efficient=
-+
-+The be more efficient, we simply need to avoid unnecessary steps. The
-+following steps are always required:
-+
-+1.) read old data before it gets overwritten
-+2.) write that data into the backup archive
-+3.) write new data (VM write)
-+
-+As you can see, this involves only one read, and two writes.
-+
-+To make that work, our backup archive need to be able to store image
-+data 'out of order'. It is important to notice that this will not work
-+with traditional archive formats like tar.
-+
-+During backup we simply intercept writes, then read existing data and
-+store that directly into the archive. After that we can continue the
-+write.
-+
-+==Advantages==
-+
-+* very good performance (1 read, 2 writes)
-+* works on any storage type and image format.
-+* avoid usage of temporary storage
-+* we can define a new and simple archive format, which is able to
-+  store sparse files efficiently.
-+
-+Note: Storing sparse files is a mess with existing archive
-+formats. For example, tar requires information about holes at the
-+beginning of the archive.
-+
-+==Disadvantages==
-+
-+* we need to define a new archive format
-+
-+Note: Most existing archive formats are optimized to store small files
-+including file attributes. We simply do not need that for VM archives.
-+
-+* archive contains data 'out of order'
-+
-+If you want to access image data in sequential order, you need to
-+re-order archive data. It would be possible to to that on the fly,
-+using temporary files.
-+
-+Fortunately, a normal restore/extract works perfectly with 'out of
-+order' data, because the target files are seekable.
-+
-+* slow backup storage can slow down VM during backup
-+
-+It is important to note that we only do sequential writes to the
-+backup storage. Furthermore one can compress the backup stream. IMHO,
-+it is better to slow down the VM a bit. All other solutions creates
-+large amounts of temporary data during backup.
-+
-+=Archive format requirements=
-+
-+The basic requirement for such new format is that we can store image
-+date 'out of order'. It is also very likely that we have less than 256
-+drives/images per VM, and we want to be able to store VM configuration
-+files.
-+
-+We have defined a very simply format with those properties, see:
-+
-+docs/specs/vma_spec.txt
-+
-+Please let us know if you know an existing format which provides the
-+same functionality.
-+
-+
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0001-aio-Fix-use-after-free-in-cancellation-path.patch b/debian/patches/old/0001-aio-Fix-use-after-free-in-cancellation-path.patch
deleted file mode 100644 (file)
index df88f44..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-From 271c0f68b4eae72691721243a1c37f46a3232d61 Mon Sep 17 00:00:00 2001
-From: Fam Zheng <famz@redhat.com>
-Date: Wed, 21 May 2014 10:42:13 +0800
-Subject: [PATCH] aio: Fix use-after-free in cancellation path
-
-The current flow of canceling a thread from THREAD_ACTIVE state is:
-
-  1) Caller wants to cancel a request, so it calls thread_pool_cancel.
-
-  2) thread_pool_cancel waits on the conditional variable
-     elem->check_cancel.
-
-  3) The worker thread changes state to THREAD_DONE once the task is
-     done, and notifies elem->check_cancel to allow thread_pool_cancel
-     to continue execution, and signals the notifier (pool->notifier) to
-     allow callback function to be called later. But because of the
-     global mutex, the notifier won't get processed until step 4) and 5)
-     are done.
-
-  4) thread_pool_cancel continues, leaving the notifier signaled, it
-     just returns to caller.
-
-  5) Caller thinks the request is already canceled successfully, so it
-     releases any related data, such as freeing elem->common.opaque.
-
-  6) In the next main loop iteration, the notifier handler,
-     event_notifier_ready, is called. It finds the canceled thread in
-     THREAD_DONE state, so calls elem->common.cb, with an (likely)
-     dangling opaque pointer. This is a use-after-free.
-
-Fix it by calling event_notifier_ready before leaving
-thread_pool_cancel.
-
-Test case update: This change will let cancel complete earlier than
-test-thread-pool.c expects, so update the code to check this case: if
-it's already done, done_cb sets .aiocb to NULL, skip calling
-bdrv_aio_cancel on them.
-
-Reported-by: Ulrich Obergfell <uobergfe@redhat.com>
-Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
-Signed-off-by: Fam Zheng <famz@redhat.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
----
- tests/test-thread-pool.c |    2 +-
- thread-pool.c            |    1 +
- 2 files changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
-index c1f8e13..aa156bc 100644
---- a/tests/test-thread-pool.c
-+++ b/tests/test-thread-pool.c
-@@ -180,7 +180,7 @@ static void test_cancel(void)
-     /* Canceling the others will be a blocking operation.  */
-     for (i = 0; i < 100; i++) {
--        if (data[i].n != 3) {
-+        if (data[i].aiocb && data[i].n != 3) {
-             bdrv_aio_cancel(data[i].aiocb);
-         }
-     }
-diff --git a/thread-pool.c b/thread-pool.c
-index fbdd3ff..dfb699d 100644
---- a/thread-pool.c
-+++ b/thread-pool.c
-@@ -224,6 +224,7 @@ static void thread_pool_cancel(BlockDriverAIOCB *acb)
-         pool->pending_cancellations--;
-     }
-     qemu_mutex_unlock(&pool->lock);
-+    event_notifier_ready(&pool->notifier);
- }
- static const AIOCBInfo thread_pool_aiocb_info = {
--- 
-1.7.10.4
-
diff --git a/debian/patches/old/0001-aio-fix-qemu_bh_schedule-bh-ctx-race-condition.patch b/debian/patches/old/0001-aio-fix-qemu_bh_schedule-bh-ctx-race-condition.patch
deleted file mode 100644 (file)
index a01765b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-From 4535f739edfdea392e381811963823bf05649e42 Mon Sep 17 00:00:00 2001
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Tue, 3 Jun 2014 11:21:01 +0200
-Subject: [PATCH] aio: fix qemu_bh_schedule() bh->ctx race condition
-
-qemu_bh_schedule() is supposed to be thread-safe at least the first time
-it is called.  Unfortunately this is not quite true:
-
-  bh->scheduled = 1;
-  aio_notify(bh->ctx);
-
-Since another thread may run the BH callback once it has been scheduled,
-there is a race condition if the callback frees the BH before
-aio_notify(bh->ctx) has a chance to run.
-
-Reported-by: Stefan Priebe <s.priebe@profihost.ag>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Signed-off-by: Stefan Priebe <s.priebe@profihost.ag>
----
- async.c |   14 ++++++++++----
- 1 file changed, 10 insertions(+), 4 deletions(-)
-
-diff --git a/async.c b/async.c
-index 6930185..5b6fe6b 100644
---- a/async.c
-+++ b/async.c
-@@ -117,15 +117,21 @@ void qemu_bh_schedule_idle(QEMUBH *bh)
- void qemu_bh_schedule(QEMUBH *bh)
- {
-+    AioContext *ctx;
-+
-     if (bh->scheduled)
-         return;
-+    ctx = bh->ctx;
-     bh->idle = 0;
--    /* Make sure that idle & any writes needed by the callback are done
--     * before the locations are read in the aio_bh_poll.
-+    /* Make sure that:
-+     * 1. idle & any writes needed by the callback are done before the
-+     *    locations are read in the aio_bh_poll.
-+     * 2. ctx is loaded before scheduled is set and the callback has a chance
-+     *    to execute.
-      */
--    smp_wmb();
-+    smp_mb();
-     bh->scheduled = 1;
--    aio_notify(bh->ctx);
-+    aio_notify(ctx);
- }
--- 
-1.7.10.4
-
diff --git a/debian/patches/old/0001-net-pcnet-add-check-to-validate-receive-data-size-CV.patch b/debian/patches/old/0001-net-pcnet-add-check-to-validate-receive-data-size-CV.patch
deleted file mode 100644 (file)
index 39eceba..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-From 6314c83ae14ee32835668e38bb55f4b93b800736 Mon Sep 17 00:00:00 2001
-From: Prasad J Pandit <pjp@fedoraproject.org>
-Date: Mon, 30 Nov 2015 15:38:22 +0800
-Subject: [PATCH 1/2] net: pcnet: add check to validate receive data
- size(CVE-2015-7504)
-
-In loopback mode, pcnet_receive routine appends CRC code to the
-receive buffer. If the data size given is same as the buffer size,
-the appended CRC code overwrites 4 bytes after s->buffer. Added a
-check to avoid that.
-
-Reported by: Qinghao Tang <luodalongde@gmail.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
-Signed-off-by: Jason Wang <jasowang@redhat.com>
----
- hw/net/pcnet.c | 8 +++++---
- 1 file changed, 5 insertions(+), 3 deletions(-)
-
-diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
-index 0eb3cc4..309c40b 100644
---- a/hw/net/pcnet.c
-+++ b/hw/net/pcnet.c
-@@ -1084,7 +1084,7 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
-                 uint32_t fcs = ~0;
-                 uint8_t *p = src;
--                while (p != &src[size-4])
-+                while (p != &src[size])
-                     CRC(fcs, *p++);
-                 crc_err = (*(uint32_t *)p != htonl(fcs));
-             }
-@@ -1233,8 +1233,10 @@ static void pcnet_transmit(PCNetState *s)
-         bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
-         /* if multi-tmd packet outsizes s->buffer then skip it silently.
--           Note: this is not what real hw does */
--        if (s->xmit_pos + bcnt > sizeof(s->buffer)) {
-+         * Note: this is not what real hw does.
-+         * Last four bytes of s->buffer are used to store CRC FCS code.
-+         */
-+        if (s->xmit_pos + bcnt > sizeof(s->buffer) - 4) {
-             s->xmit_pos = -1;
-             goto txdone;
-         }
--- 
-2.1.4
-
diff --git a/debian/patches/old/0001-smm_available-false.patch b/debian/patches/old/0001-smm_available-false.patch
deleted file mode 100644 (file)
index 8e4d6de..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-From 4a1e7790e45da3b0dae61bd483b37556bae338ee Mon Sep 17 00:00:00 2001
-From: Alexandre Derumier <aderumier@odiso.com>
-Date: Tue, 29 Sep 2015 15:37:44 +0200
-Subject: [PATCH] smm_available = false
-
-Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
----
- hw/i386/pc.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/hw/i386/pc.c b/hw/i386/pc.c
-index 7661ea9..5529dc8 100644
---- a/hw/i386/pc.c
-+++ b/hw/i386/pc.c
-@@ -1842,7 +1842,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms)
-     if (tcg_enabled() || qtest_enabled()) {
-         smm_available = true;
-     } else if (kvm_enabled()) {
--        smm_available = kvm_has_smm();
-+        smm_available = false;
-     }
-     if (smm_available) {
--- 
-2.1.4
-
diff --git a/debian/patches/old/0001-ui-vnc-avoid-floating-point-exception.patch b/debian/patches/old/0001-ui-vnc-avoid-floating-point-exception.patch
deleted file mode 100644 (file)
index f8adea7..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-From 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3 Mon Sep 17 00:00:00 2001
-From: Prasad J Pandit <pjp@fedoraproject.org>
-Date: Thu, 3 Dec 2015 18:54:17 +0530
-Subject: [PATCH] ui: vnc: avoid floating point exception
-
-While sending 'SetPixelFormat' messages to a VNC server,
-the client could set the 'red-max', 'green-max' and 'blue-max'
-values to be zero. This leads to a floating point exception in
-write_png_palette while doing frame buffer updates.
-
-Reported-by: Lian Yihan <lianyihan@360.cn>
-Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
-Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
-Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
----
- ui/vnc.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/ui/vnc.c b/ui/vnc.c
-index 7538405..cbe4d33 100644
---- a/ui/vnc.c
-+++ b/ui/vnc.c
-@@ -2198,15 +2198,15 @@ static void set_pixel_format(VncState *vs,
-         return;
-     }
--    vs->client_pf.rmax = red_max;
-+    vs->client_pf.rmax = red_max ? red_max : 0xFF;
-     vs->client_pf.rbits = hweight_long(red_max);
-     vs->client_pf.rshift = red_shift;
-     vs->client_pf.rmask = red_max << red_shift;
--    vs->client_pf.gmax = green_max;
-+    vs->client_pf.gmax = green_max ? green_max : 0xFF;
-     vs->client_pf.gbits = hweight_long(green_max);
-     vs->client_pf.gshift = green_shift;
-     vs->client_pf.gmask = green_max << green_shift;
--    vs->client_pf.bmax = blue_max;
-+    vs->client_pf.bmax = blue_max ? blue_max : 0xFF;
-     vs->client_pf.bbits = hweight_long(blue_max);
-     vs->client_pf.bshift = blue_shift;
-     vs->client_pf.bmask = blue_max << blue_shift;
--- 
-2.1.4
-
diff --git a/debian/patches/old/0002-add-basic-backup-support-to-block-driver.patch b/debian/patches/old/0002-add-basic-backup-support-to-block-driver.patch
deleted file mode 100644 (file)
index a178c59..0000000
+++ /dev/null
@@ -1,626 +0,0 @@
-From 1d0c6dfc9616c0dd17986cab6744c10cb748de1e Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Tue, 13 Nov 2012 10:03:52 +0100
-Subject: [PATCH v5 2/6] add basic backup support to block driver
-
-Function backup_job_create() creates a block job to backup a block device.
-The coroutine is started with backup_job_start().
-
-We call backup_do_cow() for each write during backup. That function
-reads the original data and pass it to backup_dump_cb().
-
-The tracked_request infrastructure is used to serialize access.
-
-Currently backup cluster size is hardcoded to 65536 bytes.
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- Makefile.objs            |    1 +
- backup.c                 |  355 ++++++++++++++++++++++++++++++++++++++++++++++
- backup.h                 |   30 ++++
- block.c                  |   71 +++++++++-
- include/block/block.h    |    2 +
- include/block/blockjob.h |   10 ++
- 6 files changed, 463 insertions(+), 6 deletions(-)
- create mode 100644 backup.c
- create mode 100644 backup.h
-
-diff --git a/Makefile.objs b/Makefile.objs
-index a68cdac..df64f70 100644
---- a/Makefile.objs
-+++ b/Makefile.objs
-@@ -13,6 +13,7 @@ block-obj-$(CONFIG_POSIX) += aio-posix.o
- block-obj-$(CONFIG_WIN32) += aio-win32.o
- block-obj-y += block/
- block-obj-y += qapi-types.o qapi-visit.o
-+block-obj-y += backup.o
- block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
- block-obj-y += qemu-coroutine-sleep.o
-diff --git a/backup.c b/backup.c
-new file mode 100644
-index 0000000..8955e1a
---- /dev/null
-+++ b/backup.c
-@@ -0,0 +1,355 @@
-+/*
-+ * QEMU backup
-+ *
-+ * Copyright (C) 2013 Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
-+ * See the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#include <stdio.h>
-+#include <errno.h>
-+#include <unistd.h>
-+
-+#include "block/block.h"
-+#include "block/block_int.h"
-+#include "block/blockjob.h"
-+#include "qemu/ratelimit.h"
-+#include "backup.h"
-+
-+#define DEBUG_BACKUP 0
-+
-+#define USE_ALLOCATION_CHECK 0
-+
-+#define DPRINTF(fmt, ...) \
-+    do { if (DEBUG_BACKUP) { printf("backup: " fmt, ## __VA_ARGS__); } } \
-+    while (0)
-+
-+
-+#define SLICE_TIME 100000000ULL /* ns */
-+
-+typedef struct BackupBlockJob {
-+    BlockJob common;
-+    RateLimit limit;
-+    CoRwlock rwlock;
-+    uint64_t sectors_read;
-+    unsigned long *bitmap;
-+    int bitmap_size;
-+    BackupDumpFunc *backup_dump_cb;
-+    BlockDriverCompletionFunc *backup_complete_cb;
-+    void *opaque;
-+} BackupBlockJob;
-+
-+static bool backup_get_bitmap(BackupBlockJob *job, int64_t cluster_num)
-+{
-+    assert(job);
-+    assert(job->bitmap);
-+
-+    unsigned long val, idx, bit;
-+
-+    idx = cluster_num / BITS_PER_LONG;
-+
-+    assert(job->bitmap_size > idx);
-+
-+    bit = cluster_num % BITS_PER_LONG;
-+    val = job->bitmap[idx];
-+
-+    return !!(val & (1UL << bit));
-+}
-+
-+static void backup_set_bitmap(BackupBlockJob *job, int64_t cluster_num,
-+                              bool dirty)
-+{
-+    assert(job);
-+    assert(job->bitmap);
-+
-+    unsigned long val, idx, bit;
-+
-+    idx = cluster_num / BITS_PER_LONG;
-+
-+    assert(job->bitmap_size > idx);
-+
-+    bit = cluster_num % BITS_PER_LONG;
-+    val = job->bitmap[idx];
-+    if (dirty) {
-+        val |= 1UL << bit;
-+    } else {
-+        val &= ~(1UL << bit);
-+    }
-+    job->bitmap[idx] = val;
-+}
-+
-+static int coroutine_fn backup_do_cow(BlockDriverState *bs,
-+                                      int64_t sector_num, int nb_sectors)
-+{
-+    assert(bs);
-+    BackupBlockJob *job = (BackupBlockJob *)bs->job;
-+    assert(job);
-+
-+    BlockDriver *drv = bs->drv;
-+    struct iovec iov;
-+    QEMUIOVector bounce_qiov;
-+    void *bounce_buffer = NULL;
-+    int ret = 0;
-+
-+    qemu_co_rwlock_rdlock(&job->rwlock);
-+
-+    int64_t start, end;
-+
-+    start = sector_num / BACKUP_BLOCKS_PER_CLUSTER;
-+    end = (sector_num + nb_sectors + BACKUP_BLOCKS_PER_CLUSTER - 1) /
-+        BACKUP_BLOCKS_PER_CLUSTER;
-+
-+    DPRINTF("brdv_co_backup_cow enter %s C%" PRId64 " %" PRId64 " %d\n",
-+            bdrv_get_device_name(bs), start, sector_num, nb_sectors);
-+
-+    for (; start < end; start++) {
-+        bool zero = 0;
-+
-+        if (backup_get_bitmap(job, start)) {
-+            DPRINTF("brdv_co_backup_cow skip C%" PRId64 "\n", start);
-+            continue; /* already copied */
-+        }
-+
-+        /* immediately set bitmap (avoid coroutine race) */
-+        backup_set_bitmap(job, start, 1);
-+
-+        DPRINTF("brdv_co_backup_cow C%" PRId64 "\n", start);
-+
-+        if (!bounce_buffer) {
-+            iov.iov_len = BACKUP_CLUSTER_SIZE;
-+            iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len);
-+            qemu_iovec_init_external(&bounce_qiov, &iov, 1);
-+        }
-+
-+#if USE_ALLOCATION_CHECK
-+        int n = 0;
-+        ret = bdrv_co_is_allocated_above(bs, NULL,
-+                                         start * BACKUP_BLOCKS_PER_CLUSTER,
-+                                         BACKUP_BLOCKS_PER_CLUSTER, &n);
-+        if (ret < 0) {
-+            DPRINTF("brdv_co_backup_cow is_allocated C%" PRId64 " failed\n",
-+                    start);
-+            goto out;
-+        }
-+
-+        zero = (ret == 0) && (n == BACKUP_BLOCKS_PER_CLUSTER);
-+
-+        if (!zero) {
-+#endif
-+            ret = drv->bdrv_co_readv(bs, start * BACKUP_BLOCKS_PER_CLUSTER,
-+                                     BACKUP_BLOCKS_PER_CLUSTER,
-+                                     &bounce_qiov);
-+            if (ret < 0) {
-+                DPRINTF("brdv_co_backup_cow bdrv_read C%" PRId64 " failed\n",
-+                        start);
-+                goto out;
-+            }
-+#if USE_ALLOCATION_CHECK
-+        }
-+#endif
-+        job->sectors_read += BACKUP_BLOCKS_PER_CLUSTER;
-+
-+        ret = job->backup_dump_cb(job->opaque, bs, start,
-+                                  zero ? NULL : bounce_buffer);
-+        if (ret < 0) {
-+            DPRINTF("brdv_co_backup_cow dump_cluster_cb C%" PRId64 " failed\n",
-+                    start);
-+            goto out;
-+        }
-+
-+        DPRINTF("brdv_co_backup_cow done C%" PRId64 "\n", start);
-+    }
-+
-+out:
-+    if (bounce_buffer) {
-+        qemu_vfree(bounce_buffer);
-+    }
-+
-+    qemu_co_rwlock_unlock(&job->rwlock);
-+
-+    return ret;
-+}
-+
-+static int coroutine_fn backup_before_read(BlockDriverState *bs,
-+                                           int64_t sector_num,
-+                                           int nb_sectors, QEMUIOVector *qiov)
-+{
-+    return backup_do_cow(bs, sector_num, nb_sectors);
-+}
-+
-+static int coroutine_fn backup_before_write(BlockDriverState *bs,
-+                                            int64_t sector_num,
-+                                            int nb_sectors, QEMUIOVector *qiov)
-+{
-+    return backup_do_cow(bs, sector_num, nb_sectors);
-+}
-+
-+static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
-+{
-+    BackupBlockJob *s = container_of(job, BackupBlockJob, common);
-+
-+    if (speed < 0) {
-+        error_set(errp, QERR_INVALID_PARAMETER, "speed");
-+        return;
-+    }
-+    ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
-+}
-+
-+static BlockJobType backup_job_type = {
-+    .instance_size = sizeof(BackupBlockJob),
-+    .before_read = backup_before_read,
-+    .before_write = backup_before_write,
-+    .job_type = "backup",
-+    .set_speed = backup_set_speed,
-+};
-+
-+static void coroutine_fn backup_run(void *opaque)
-+{
-+    BackupBlockJob *job = opaque;
-+    BlockDriverState *bs = job->common.bs;
-+    assert(bs);
-+
-+    int64_t start, end;
-+
-+    start = 0;
-+    end = (bs->total_sectors + BACKUP_BLOCKS_PER_CLUSTER - 1) /
-+        BACKUP_BLOCKS_PER_CLUSTER;
-+
-+    DPRINTF("backup_run start %s %" PRId64 " %" PRId64 "\n",
-+            bdrv_get_device_name(bs), start, end);
-+
-+    int ret = 0;
-+
-+    for (; start < end; start++) {
-+        if (block_job_is_cancelled(&job->common)) {
-+            ret = -1;
-+            break;
-+        }
-+
-+        /* we need to yield so that qemu_aio_flush() returns.
-+         * (without, VM does not reboot)
-+         * Note: use 1000 instead of 0 (0 prioritize this task too much)
-+         */
-+        if (job->common.speed) {
-+            uint64_t delay_ns = ratelimit_calculate_delay(
-+                &job->limit, job->sectors_read);
-+            job->sectors_read = 0;
-+            block_job_sleep_ns(&job->common, rt_clock, delay_ns);
-+        } else {
-+            block_job_sleep_ns(&job->common, rt_clock, 1000);
-+        }
-+
-+        if (block_job_is_cancelled(&job->common)) {
-+            ret = -1;
-+            break;
-+        }
-+
-+        if (backup_get_bitmap(job, start)) {
-+            continue; /* already copied */
-+        }
-+
-+        DPRINTF("backup_run loop C%" PRId64 "\n", start);
-+
-+        /**
-+         * This triggers a cluster copy
-+         * Note: avoid direct call to brdv_co_backup_cow, because
-+         * this does not call tracked_request_begin()
-+         */
-+        ret = bdrv_co_backup(bs, start*BACKUP_BLOCKS_PER_CLUSTER, 1);
-+        if (ret < 0) {
-+            break;
-+        }
-+        /* Publish progress */
-+        job->common.offset += BACKUP_CLUSTER_SIZE;
-+    }
-+
-+    /* wait until pending backup_do_cow()calls have completed */
-+    qemu_co_rwlock_wrlock(&job->rwlock);
-+    qemu_co_rwlock_unlock(&job->rwlock);
-+
-+    DPRINTF("backup_run complete %d\n", ret);
-+    block_job_completed(&job->common, ret);
-+}
-+
-+static void backup_job_cleanup_cb(void *opaque, int ret)
-+{
-+    BlockDriverState *bs = opaque;
-+    assert(bs);
-+    BackupBlockJob *job = (BackupBlockJob *)bs->job;
-+    assert(job);
-+
-+    DPRINTF("backup_job_cleanup_cb start %d\n", ret);
-+
-+    job->backup_complete_cb(job->opaque, ret);
-+
-+    DPRINTF("backup_job_cleanup_cb end\n");
-+
-+    g_free(job->bitmap);
-+}
-+
-+void
-+backup_job_start(BlockDriverState *bs, bool cancel)
-+{
-+    assert(bs);
-+    assert(bs->job);
-+    assert(bs->job->co == NULL);
-+
-+    if (cancel) {
-+        block_job_cancel(bs->job); /* set cancel flag */
-+    }
-+
-+    bs->job->co = qemu_coroutine_create(backup_run);
-+    qemu_coroutine_enter(bs->job->co, bs->job);
-+}
-+
-+int
-+backup_job_create(BlockDriverState *bs, BackupDumpFunc *backup_dump_cb,
-+                  BlockDriverCompletionFunc *backup_complete_cb,
-+                  void *opaque, int64_t speed)
-+{
-+    assert(bs);
-+    assert(backup_dump_cb);
-+    assert(backup_complete_cb);
-+
-+    if (bs->job) {
-+        DPRINTF("bdrv_backup_init failed - running job on %s\n",
-+                bdrv_get_device_name(bs));
-+        return -1;
-+    }
-+
-+    int64_t bitmap_size;
-+    const char *devname = bdrv_get_device_name(bs);
-+
-+    if (!devname || !devname[0]) {
-+        return -1;
-+    }
-+
-+    DPRINTF("bdrv_backup_init %s\n", bdrv_get_device_name(bs));
-+
-+    Error *errp;
-+    BackupBlockJob *job = block_job_create(&backup_job_type, bs, speed,
-+                                           backup_job_cleanup_cb, bs, &errp);
-+
-+    qemu_co_rwlock_init(&job->rwlock);
-+
-+    job->common.cluster_size = BACKUP_CLUSTER_SIZE;
-+
-+    bitmap_size = bs->total_sectors +
-+        BACKUP_BLOCKS_PER_CLUSTER * BITS_PER_LONG - 1;
-+    bitmap_size /= BACKUP_BLOCKS_PER_CLUSTER * BITS_PER_LONG;
-+
-+    job->backup_dump_cb = backup_dump_cb;
-+    job->backup_complete_cb = backup_complete_cb;
-+    job->opaque = opaque;
-+    job->bitmap_size = bitmap_size;
-+    job->bitmap = g_new0(unsigned long, bitmap_size);
-+
-+    job->common.len = bs->total_sectors*BDRV_SECTOR_SIZE;
-+
-+    return 0;
-+}
-diff --git a/backup.h b/backup.h
-new file mode 100644
-index 0000000..9b1ea1c
---- /dev/null
-+++ b/backup.h
-@@ -0,0 +1,30 @@
-+/*
-+ * QEMU backup related definitions
-+ *
-+ * Copyright (C) 2013 Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
-+ * See the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#ifndef QEMU_BACKUP_H
-+#define QEMU_BACKUP_H
-+
-+#define BACKUP_CLUSTER_BITS 16
-+#define BACKUP_CLUSTER_SIZE (1<<BACKUP_CLUSTER_BITS)
-+#define BACKUP_BLOCKS_PER_CLUSTER (BACKUP_CLUSTER_SIZE/BDRV_SECTOR_SIZE)
-+
-+typedef int BackupDumpFunc(void *opaque, BlockDriverState *bs,
-+                           int64_t cluster_num, unsigned char *buf);
-+
-+void backup_job_start(BlockDriverState *bs, bool cancel);
-+
-+int backup_job_create(BlockDriverState *bs, BackupDumpFunc *backup_dump_cb,
-+                      BlockDriverCompletionFunc *backup_complete_cb,
-+                      void *opaque, int64_t speed);
-+
-+#endif /* QEMU_BACKUP_H */
-diff --git a/block.c b/block.c
-index 50dab8e..6e6d08f 100644
---- a/block.c
-+++ b/block.c
-@@ -54,6 +54,7 @@
- typedef enum {
-     BDRV_REQ_COPY_ON_READ = 0x1,
-     BDRV_REQ_ZERO_WRITE   = 0x2,
-+    BDRV_REQ_BACKUP_ONLY  = 0x4,
- } BdrvRequestFlags;
- static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load);
-@@ -1554,7 +1555,7 @@ int bdrv_commit(BlockDriverState *bs)
-     if (!drv)
-         return -ENOMEDIUM;
--    
-+
-     if (!bs->backing_hd) {
-         return -ENOTSUP;
-     }
-@@ -1691,6 +1692,22 @@ void bdrv_round_to_clusters(BlockDriverState *bs,
-     }
- }
-+/**
-+ * Round a region to job cluster boundaries
-+ */
-+static void round_to_job_clusters(BlockDriverState *bs,
-+                                  int64_t sector_num, int nb_sectors,
-+                                  int job_cluster_size,
-+                                  int64_t *cluster_sector_num,
-+                                  int *cluster_nb_sectors)
-+{
-+    int64_t c = job_cluster_size/BDRV_SECTOR_SIZE;
-+
-+    *cluster_sector_num = QEMU_ALIGN_DOWN(sector_num, c);
-+    *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num +
-+                                        nb_sectors, c);
-+}
-+
- static bool tracked_request_overlaps(BdrvTrackedRequest *req,
-                                      int64_t sector_num, int nb_sectors) {
-     /*        aaaa   bbbb */
-@@ -1705,7 +1722,9 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req,
- }
- static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
--        int64_t sector_num, int nb_sectors)
-+                                                       int64_t sector_num,
-+                                                       int nb_sectors,
-+                                                       int job_cluster_size)
- {
-     BdrvTrackedRequest *req;
-     int64_t cluster_sector_num;
-@@ -1721,6 +1740,11 @@ static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
-     bdrv_round_to_clusters(bs, sector_num, nb_sectors,
-                            &cluster_sector_num, &cluster_nb_sectors);
-+    if (job_cluster_size) {
-+        round_to_job_clusters(bs, sector_num, nb_sectors, job_cluster_size,
-+                              &cluster_sector_num, &cluster_nb_sectors);
-+    }
-+
-     do {
-         retry = false;
-         QLIST_FOREACH(req, &bs->tracked_requests, list) {
-@@ -2260,12 +2284,24 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
-         bs->copy_on_read_in_flight++;
-     }
--    if (bs->copy_on_read_in_flight) {
--        wait_for_overlapping_requests(bs, sector_num, nb_sectors);
-+    int job_cluster_size = bs->job && bs->job->cluster_size ?
-+        bs->job->cluster_size : 0;
-+
-+    if (bs->copy_on_read_in_flight || job_cluster_size) {
-+        wait_for_overlapping_requests(bs, sector_num, nb_sectors,
-+                                      job_cluster_size);
-     }
-     tracked_request_begin(&req, bs, sector_num, nb_sectors, false);
-+    if (bs->job && bs->job->job_type->before_read) {
-+        ret = bs->job->job_type->before_read(bs, sector_num, nb_sectors, qiov);
-+        if ((ret < 0) || (flags & BDRV_REQ_BACKUP_ONLY)) {
-+            /* Note: We do not return any data to the caller */
-+            goto out;
-+        }
-+    }
-+
-     if (flags & BDRV_REQ_COPY_ON_READ) {
-         int pnum;
-@@ -2309,6 +2345,17 @@ int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
-                             BDRV_REQ_COPY_ON_READ);
- }
-+int coroutine_fn bdrv_co_backup(BlockDriverState *bs,
-+    int64_t sector_num, int nb_sectors)
-+{
-+    if (!bs->job) {
-+        return -ENOTSUP;
-+    }
-+
-+    return bdrv_co_do_readv(bs, sector_num, nb_sectors, NULL,
-+                            BDRV_REQ_BACKUP_ONLY);
-+}
-+
- static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
-     int64_t sector_num, int nb_sectors)
- {
-@@ -2366,12 +2413,23 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
-         bdrv_io_limits_intercept(bs, true, nb_sectors);
-     }
--    if (bs->copy_on_read_in_flight) {
--        wait_for_overlapping_requests(bs, sector_num, nb_sectors);
-+    int job_cluster_size = bs->job && bs->job->cluster_size ?
-+        bs->job->cluster_size : 0;
-+
-+    if (bs->copy_on_read_in_flight || job_cluster_size) {
-+        wait_for_overlapping_requests(bs, sector_num, nb_sectors,
-+                                      job_cluster_size);
-     }
-     tracked_request_begin(&req, bs, sector_num, nb_sectors, true);
-+    if (bs->job && bs->job->job_type->before_write) {
-+        ret = bs->job->job_type->before_write(bs, sector_num, nb_sectors, qiov);
-+        if (ret < 0) {
-+            goto out;
-+        }
-+    }
-+
-     if (flags & BDRV_REQ_ZERO_WRITE) {
-         ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors);
-     } else {
-@@ -2390,6 +2448,7 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
-         bs->wr_highest_sector = sector_num + nb_sectors - 1;
-     }
-+out:
-     tracked_request_end(&req);
-     return ret;
-diff --git a/include/block/block.h b/include/block/block.h
-index 5c3b911..b6144be 100644
---- a/include/block/block.h
-+++ b/include/block/block.h
-@@ -172,6 +172,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
-     int nb_sectors, QEMUIOVector *qiov);
- int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
-     int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
-+int coroutine_fn bdrv_co_backup(BlockDriverState *bs,
-+    int64_t sector_num, int nb_sectors);
- int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
-     int nb_sectors, QEMUIOVector *qiov);
- /*
-diff --git a/include/block/blockjob.h b/include/block/blockjob.h
-index c290d07..6f42495 100644
---- a/include/block/blockjob.h
-+++ b/include/block/blockjob.h
-@@ -50,6 +50,13 @@ typedef struct BlockJobType {
-      * manually.
-      */
-     void (*complete)(BlockJob *job, Error **errp);
-+
-+    /** tracked requests */
-+    int coroutine_fn (*before_read)(BlockDriverState *bs, int64_t sector_num,
-+                                    int nb_sectors, QEMUIOVector *qiov);
-+    int coroutine_fn (*before_write)(BlockDriverState *bs, int64_t sector_num,
-+                                     int nb_sectors, QEMUIOVector *qiov);
-+
- } BlockJobType;
- /**
-@@ -103,6 +110,9 @@ struct BlockJob {
-     /** Speed that was set with @block_job_set_speed.  */
-     int64_t speed;
-+    /** tracked requests */
-+    int cluster_size;
-+
-     /** The completion function that will be called when the job completes.  */
-     BlockDriverCompletionFunc *cb;
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0002-pcnet-fix-rx-buffer-overflow-CVE-2015-7512.patch b/debian/patches/old/0002-pcnet-fix-rx-buffer-overflow-CVE-2015-7512.patch
deleted file mode 100644 (file)
index 72c8d25..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-From 59fb70f22143eccdf74639871e862df0c2f570fc Mon Sep 17 00:00:00 2001
-From: Jason Wang <jasowang@redhat.com>
-Date: Mon, 30 Nov 2015 15:38:23 +0800
-Subject: [PATCH 2/2] pcnet: fix rx buffer overflow(CVE-2015-7512)
-
-Backends could provide a packet whose length is greater than buffer
-size. Check for this and truncate the packet to avoid rx buffer
-overflow in this case.
-
-Cc: Prasad J Pandit <pjp@fedoraproject.org>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Jason Wang <jasowang@redhat.com>
----
- hw/net/pcnet.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
-index 309c40b..1f4a3db 100644
---- a/hw/net/pcnet.c
-+++ b/hw/net/pcnet.c
-@@ -1064,6 +1064,12 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
-             int pktcount = 0;
-             if (!s->looptest) {
-+                if (size > 4092) {
-+#ifdef PCNET_DEBUG_RMD
-+                    fprintf(stderr, "pcnet: truncates rx packet.\n");
-+#endif
-+                    size = 4092;
-+                }
-                 memcpy(src, buf, size);
-                 /* no need to compute the CRC */
-                 src[size] = 0;
--- 
-2.1.4
-
diff --git a/debian/patches/old/0003-add-backup-related-monitor-commands.patch b/debian/patches/old/0003-add-backup-related-monitor-commands.patch
deleted file mode 100644 (file)
index 0a23a45..0000000
+++ /dev/null
@@ -1,826 +0,0 @@
-From cf9cc8878d3246069da3fdf7ec865b7b983487fe Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Tue, 13 Nov 2012 11:27:56 +0100
-Subject: [PATCH v5 3/6] add backup related monitor commands
-
-We use a generic BackupDriver struct to encapsulate all archive format
-related function.
-
-Another option would be to simply dump <devid,cluster_num,cluster_data> to
-the output fh (pipe), and an external binary saves the data. That way we
-could move the whole archive format related code out of qemu.
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- backup.h         |   15 ++
- blockdev.c       |  423 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
- hmp-commands.hx  |   31 ++++
- hmp.c            |   63 ++++++++
- hmp.h            |    3 +
- monitor.c        |    7 +
- qapi-schema.json |   95 ++++++++++++
- qmp-commands.hx  |   27 ++++
- 8 files changed, 664 insertions(+), 0 deletions(-)
-
-diff --git a/backup.h b/backup.h
-index 9b1ea1c..22598a6 100644
---- a/backup.h
-+++ b/backup.h
-@@ -14,6 +14,9 @@
- #ifndef QEMU_BACKUP_H
- #define QEMU_BACKUP_H
-+#include <uuid/uuid.h>
-+#include "block/block.h"
-+
- #define BACKUP_CLUSTER_BITS 16
- #define BACKUP_CLUSTER_SIZE (1<<BACKUP_CLUSTER_BITS)
- #define BACKUP_BLOCKS_PER_CLUSTER (BACKUP_CLUSTER_SIZE/BDRV_SECTOR_SIZE)
-@@ -27,4 +30,16 @@ int backup_job_create(BlockDriverState *bs, BackupDumpFunc *backup_dump_cb,
-                       BlockDriverCompletionFunc *backup_complete_cb,
-                       void *opaque, int64_t speed);
-+typedef struct BackupDriver {
-+    const char *format;
-+    void *(*open)(const char *filename, uuid_t uuid, Error **errp);
-+    int (*close)(void *opaque, Error **errp);
-+    int (*register_config)(void *opaque, const char *name, gpointer data,
-+                              size_t data_len);
-+    int (*register_stream)(void *opaque, const char *devname, size_t size);
-+    int (*dump)(void *opaque, uint8_t dev_id, int64_t cluster_num,
-+                   unsigned char *buf, size_t *zero_bytes);
-+    int (*complete)(void *opaque, uint8_t dev_id, int ret);
-+} BackupDriver;
-+
- #endif /* QEMU_BACKUP_H */
-diff --git a/blockdev.c b/blockdev.c
-index 63e6f1e..84f598d 100644
---- a/blockdev.c
-+++ b/blockdev.c
-@@ -20,6 +20,7 @@
- #include "qmp-commands.h"
- #include "trace.h"
- #include "sysemu/arch_init.h"
-+#include "backup.h"
- static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
-@@ -1334,6 +1335,428 @@ void qmp_drive_mirror(const char *device, const char *target,
-     drive_get_ref(drive_get_by_blockdev(bs));
- }
-+/* Backup related function */
-+
-+static void backup_run_next_job(void);
-+
-+static struct GenericBackupState {
-+    Error *error;
-+    bool cancel;
-+    uuid_t uuid;
-+    char uuid_str[37];
-+    int64_t speed;
-+    time_t start_time;
-+    time_t end_time;
-+    char *backup_file;
-+    const BackupDriver *driver;
-+    void *writer;
-+    GList *bcb_list;
-+    size_t total;
-+    size_t transferred;
-+    size_t zero_bytes;
-+} backup_state;
-+
-+typedef struct BackupCB {
-+    BlockDriverState *bs;
-+    uint8_t dev_id;
-+    bool started;
-+    bool completed;
-+    size_t size;
-+    size_t transferred;
-+    size_t zero_bytes;
-+} BackupCB;
-+
-+static int backup_dump_cb(void *opaque, BlockDriverState *bs,
-+                          int64_t cluster_num, unsigned char *buf)
-+{
-+    BackupCB *bcb = opaque;
-+
-+    assert(backup_state.driver);
-+    assert(backup_state.writer);
-+    assert(backup_state.driver->dump);
-+
-+    size_t zero_bytes = 0;
-+    int bytes = backup_state.driver->dump(backup_state.writer,
-+                                          bcb->dev_id, cluster_num,
-+                                          buf, &zero_bytes);
-+
-+    if (bytes > 0) {
-+        bcb->transferred += bytes;
-+        backup_state.transferred += bytes;
-+        if (zero_bytes) {
-+            bcb->zero_bytes += bytes;
-+            backup_state.zero_bytes += zero_bytes;
-+        }
-+    }
-+
-+    return bytes;
-+}
-+
-+static void backup_cleanup(void)
-+{
-+    if (backup_state.writer && backup_state.driver) {
-+        backup_state.end_time = time(NULL);
-+        Error *local_err = NULL;
-+        backup_state.driver->close(backup_state.writer, &local_err);
-+        error_propagate(&backup_state.error, local_err);
-+        backup_state.writer = NULL;
-+    }
-+
-+    if (backup_state.bcb_list) {
-+        GList *l = backup_state.bcb_list;
-+        while (l) {
-+            BackupCB *bcb = l->data;
-+            l = g_list_next(l);
-+            drive_put_ref_bh_schedule(drive_get_by_blockdev(bcb->bs));
-+            g_free(bcb);
-+        }
-+        g_list_free(backup_state.bcb_list);
-+        backup_state.bcb_list = NULL;
-+    }
-+}
-+
-+static void backup_complete_cb(void *opaque, int ret)
-+{
-+    BackupCB *bcb = opaque;
-+
-+    assert(backup_state.driver);
-+    assert(backup_state.writer);
-+    assert(backup_state.driver->complete);
-+    assert(backup_state.driver->close);
-+
-+    bcb->completed = true;
-+
-+    backup_state.driver->complete(backup_state.writer, bcb->dev_id, ret);
-+
-+    if (!backup_state.cancel) {
-+        backup_run_next_job();
-+    }
-+}
-+
-+static void backup_cancel(void)
-+{
-+    backup_state.cancel = true;
-+
-+    if (!backup_state.error) {
-+        error_setg(&backup_state.error, "backup cancelled");
-+    }
-+
-+    /* drain all i/o (awake jobs waiting for aio) */
-+    bdrv_drain_all();
-+
-+    int job_count = 0;
-+    GList *l = backup_state.bcb_list;
-+    while (l) {
-+        BackupCB *bcb = l->data;
-+        l = g_list_next(l);
-+        BlockJob *job = bcb->bs->job;
-+        if (job) {
-+            job_count++;
-+            if (!bcb->started) {
-+                bcb->started = true;
-+                backup_job_start(bcb->bs, true);
-+            }
-+            if (!bcb->completed) {
-+                block_job_cancel_sync(job);
-+            }
-+        }
-+    }
-+
-+    backup_cleanup();
-+}
-+
-+void qmp_backup_cancel(Error **errp)
-+{
-+    backup_cancel();
-+}
-+
-+static void backup_run_next_job(void)
-+{
-+    GList *l = backup_state.bcb_list;
-+    while (l) {
-+        BackupCB *bcb = l->data;
-+        l = g_list_next(l);
-+
-+        if (bcb->bs && bcb->bs->job && !bcb->completed) {
-+            if (!bcb->started) {
-+                bcb->started = true;
-+                bool cancel = backup_state.error || backup_state.cancel;
-+                backup_job_start(bcb->bs, cancel);
-+            }
-+            return;
-+        }
-+    }
-+
-+    backup_cleanup();
-+}
-+
-+static void backup_start_jobs(void)
-+{
-+    /* create all jobs (one for each device), start first one */
-+    GList *l = backup_state.bcb_list;
-+    while (l) {
-+        BackupCB *bcb = l->data;
-+        l = g_list_next(l);
-+
-+        if (backup_job_create(bcb->bs, backup_dump_cb, backup_complete_cb,
-+                              bcb, backup_state.speed) != 0) {
-+            error_setg(&backup_state.error, "backup_job_create failed");
-+            backup_cancel();
-+            return;
-+        }
-+    }
-+
-+    backup_run_next_job();
-+}
-+
-+char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-+                 bool has_config_file, const char *config_file,
-+                 bool has_devlist, const char *devlist,
-+                 bool has_speed, int64_t speed, Error **errp)
-+{
-+    BlockDriverState *bs;
-+    Error *local_err = NULL;
-+    uuid_t uuid;
-+    void *writer = NULL;
-+    gchar **devs = NULL;
-+    GList *bcblist = NULL;
-+
-+    if (backup_state.bcb_list) {
-+        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-+                  "previous backup not finished");
-+        return NULL;
-+    }
-+
-+    /* Todo: try to auto-detect format based on file name */
-+    format = has_format ? format : BACKUP_FORMAT_VMA;
-+
-+    /* fixme: find driver for specifued format */
-+    const BackupDriver *driver = NULL;
-+
-+    if (!driver) {
-+        error_set(errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format");
-+        return NULL;
-+    }
-+
-+    if (has_devlist) {
-+        devs = g_strsplit_set(devlist, ",;:", -1);
-+
-+        gchar **d = devs;
-+        while (d && *d) {
-+            bs = bdrv_find(*d);
-+            if (bs) {
-+                if (bdrv_is_read_only(bs)) {
-+                    error_set(errp, QERR_DEVICE_IS_READ_ONLY, *d);
-+                    goto err;
-+                }
-+                if (!bdrv_is_inserted(bs)) {
-+                    error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d);
-+                    goto err;
-+                }
-+                BackupCB *bcb = g_new0(BackupCB, 1);
-+                bcb->bs = bs;
-+                bcblist = g_list_append(bcblist, bcb);
-+            } else {
-+                error_set(errp, QERR_DEVICE_NOT_FOUND, *d);
-+                goto err;
-+            }
-+            d++;
-+        }
-+
-+    } else {
-+
-+        bs = NULL;
-+        while ((bs = bdrv_next(bs))) {
-+
-+            if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
-+                continue;
-+            }
-+
-+            BackupCB *bcb = g_new0(BackupCB, 1);
-+            bcb->bs = bs;
-+            bcblist = g_list_append(bcblist, bcb);
-+        }
-+    }
-+
-+    if (!bcblist) {
-+        error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
-+        goto err;
-+    }
-+
-+    GList *l = bcblist;
-+    while (l) {
-+        BackupCB *bcb = l->data;
-+        l = g_list_next(l);
-+        if (bcb->bs->job) {
-+            error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bcb->bs));
-+            goto err;
-+        }
-+    }
-+
-+    uuid_generate(uuid);
-+
-+    writer = driver->open(backup_file, uuid, &local_err);
-+    if (!writer) {
-+        if (error_is_set(&local_err)) {
-+            error_propagate(errp, local_err);
-+        }
-+        goto err;
-+    }
-+
-+    size_t total = 0;
-+
-+    /* register all devices for vma writer */
-+    l = bcblist;
-+    while (l) {
-+        BackupCB *bcb = l->data;
-+        l = g_list_next(l);
-+
-+        int64_t size = bdrv_getlength(bcb->bs);
-+        const char *devname = bdrv_get_device_name(bcb->bs);
-+        bcb->dev_id = driver->register_stream(writer, devname, size);
-+        if (bcb->dev_id <= 0) {
-+            error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-+                      "register_stream failed");
-+            goto err;
-+        }
-+        bcb->size = size;
-+        total += size;
-+    }
-+
-+    /* add configuration file to archive */
-+    if (has_config_file) {
-+        char *cdata = NULL;
-+        gsize clen = 0;
-+        GError *err = NULL;
-+        if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
-+            error_setg(errp, "unable to read file '%s'", config_file);
-+            goto err;
-+        }
-+
-+        const char *basename = g_path_get_basename(config_file);
-+        if (driver->register_config(writer, basename, cdata, clen) < 0) {
-+            error_setg(errp, "register_config failed");
-+            g_free(cdata);
-+            goto err;
-+        }
-+        g_free(cdata);
-+    }
-+
-+    /* initialize global backup_state now */
-+
-+    backup_state.cancel = false;
-+
-+    if (backup_state.error) {
-+        error_free(backup_state.error);
-+        backup_state.error = NULL;
-+    }
-+
-+    backup_state.driver = driver;
-+
-+    backup_state.speed = (has_speed && speed > 0) ? speed : 0;
-+
-+    backup_state.start_time = time(NULL);
-+    backup_state.end_time = 0;
-+
-+    if (backup_state.backup_file) {
-+        g_free(backup_state.backup_file);
-+    }
-+    backup_state.backup_file = g_strdup(backup_file);
-+
-+    backup_state.writer = writer;
-+
-+    uuid_copy(backup_state.uuid, uuid);
-+    uuid_unparse_lower(uuid, backup_state.uuid_str);
-+
-+    backup_state.bcb_list = bcblist;
-+
-+    backup_state.total = total;
-+    backup_state.transferred = 0;
-+    backup_state.zero_bytes = 0;
-+
-+    /* Grab a reference so hotplug does not delete the
-+     * BlockDriverState from underneath us.
-+     */
-+    l = bcblist;
-+    while (l) {
-+        BackupCB *bcb = l->data;
-+        l = g_list_next(l);
-+        drive_get_ref(drive_get_by_blockdev(bcb->bs));
-+    }
-+
-+    backup_start_jobs();
-+
-+    return g_strdup(backup_state.uuid_str);
-+
-+err:
-+
-+    l = bcblist;
-+    while (l) {
-+        g_free(l->data);
-+        l = g_list_next(l);
-+    }
-+    g_list_free(bcblist);
-+
-+    if (devs) {
-+        g_strfreev(devs);
-+    }
-+
-+    if (writer) {
-+        unlink(backup_file);
-+        if (driver) {
-+            Error *err = NULL;
-+            driver->close(writer, &err);
-+        }
-+    }
-+
-+    return NULL;
-+}
-+
-+BackupStatus *qmp_query_backup(Error **errp)
-+{
-+    BackupStatus *info = g_malloc0(sizeof(*info));
-+
-+    if (!backup_state.start_time) {
-+        /* not started, return {} */
-+        return info;
-+    }
-+
-+    info->has_status = true;
-+    info->has_start_time = true;
-+    info->start_time = backup_state.start_time;
-+
-+    if (backup_state.backup_file) {
-+        info->has_backup_file = true;
-+        info->backup_file = g_strdup(backup_state.backup_file);
-+    }
-+
-+    info->has_uuid = true;
-+    info->uuid = g_strdup(backup_state.uuid_str);
-+
-+    if (backup_state.end_time) {
-+        if (backup_state.error) {
-+            info->status = g_strdup("error");
-+            info->has_errmsg = true;
-+            info->errmsg = g_strdup(error_get_pretty(backup_state.error));
-+        } else {
-+            info->status = g_strdup("done");
-+        }
-+        info->has_end_time = true;
-+        info->end_time = backup_state.end_time;
-+    } else {
-+        info->status = g_strdup("active");
-+    }
-+
-+    info->has_total = true;
-+    info->total = backup_state.total;
-+    info->has_zero_bytes = true;
-+    info->zero_bytes = backup_state.zero_bytes;
-+    info->has_transferred = true;
-+    info->transferred = backup_state.transferred;
-+
-+    return info;
-+}
-+
- static BlockJob *find_block_job(const char *device)
- {
-     BlockDriverState *bs;
-diff --git a/hmp-commands.hx b/hmp-commands.hx
-index 64008a9..0f178d8 100644
---- a/hmp-commands.hx
-+++ b/hmp-commands.hx
-@@ -83,6 +83,35 @@ STEXI
- Copy data from a backing file into a block device.
- ETEXI
-+   {
-+        .name       = "backup",
-+        .args_type  = "backupfile:s,speed:o?,devlist:s?",
-+        .params     = "backupfile [speed [devlist]]",
-+        .help       = "create a VM Backup.",
-+        .mhandler.cmd = hmp_backup,
-+    },
-+
-+STEXI
-+@item backup
-+@findex backup
-+Create a VM backup.
-+ETEXI
-+
-+    {
-+        .name       = "backup_cancel",
-+        .args_type  = "",
-+        .params     = "",
-+        .help       = "cancel the current VM backup",
-+        .mhandler.cmd = hmp_backup_cancel,
-+    },
-+
-+STEXI
-+@item backup_cancel
-+@findex backup_cancel
-+Cancel the current VM backup.
-+
-+ETEXI
-+
-     {
-         .name       = "block_job_set_speed",
-         .args_type  = "device:B,speed:o",
-@@ -1630,6 +1659,8 @@ show CPU statistics
- show user network stack connection states
- @item info migrate
- show migration status
-+@item info backup
-+show backup status
- @item info migrate_capabilities
- show current migration capabilities
- @item info migrate_cache_size
-diff --git a/hmp.c b/hmp.c
-index 2f47a8a..b2c1f23 100644
---- a/hmp.c
-+++ b/hmp.c
-@@ -131,6 +131,38 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
-     qapi_free_MouseInfoList(mice_list);
- }
-+void hmp_info_backup(Monitor *mon, const QDict *qdict)
-+{
-+    BackupStatus *info;
-+
-+    info = qmp_query_backup(NULL);
-+    if (info->has_status) {
-+        if (info->has_errmsg) {
-+            monitor_printf(mon, "Backup status: %s - %s\n",
-+                           info->status, info->errmsg);
-+        } else {
-+            monitor_printf(mon, "Backup status: %s\n", info->status);
-+        }
-+    }
-+    if (info->has_backup_file) {
-+        int per = (info->has_total && info->total &&
-+            info->has_transferred && info->transferred) ?
-+            (info->transferred * 100)/info->total : 0;
-+        int zero_per = (info->has_total && info->total &&
-+                        info->has_zero_bytes && info->zero_bytes) ?
-+            (info->zero_bytes * 100)/info->total : 0;
-+        monitor_printf(mon, "Backup file: %s\n", info->backup_file);
-+        monitor_printf(mon, "Backup uuid: %s\n", info->uuid);
-+        monitor_printf(mon, "Total size: %zd\n", info->total);
-+        monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
-+                       info->transferred, per);
-+        monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
-+                       info->zero_bytes, zero_per);
-+    }
-+
-+    qapi_free_BackupStatus(info);
-+}
-+
- void hmp_info_migrate(Monitor *mon, const QDict *qdict)
- {
-     MigrationInfo *info;
-@@ -998,6 +1030,37 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
-     hmp_handle_error(mon, &error);
- }
-+void hmp_backup_cancel(Monitor *mon, const QDict *qdict)
-+{
-+    Error *errp = NULL;
-+
-+    qmp_backup_cancel(&errp);
-+
-+    if (error_is_set(&errp)) {
-+        monitor_printf(mon, "%s\n", error_get_pretty(errp));
-+        error_free(errp);
-+        return;
-+    }
-+}
-+
-+void hmp_backup(Monitor *mon, const QDict *qdict)
-+{
-+    const char *backup_file = qdict_get_str(qdict, "backup-file");
-+    const char *devlist = qdict_get_try_str(qdict, "devlist");
-+    int64_t speed = qdict_get_try_int(qdict, "speed", 0);
-+
-+    Error *errp = NULL;
-+
-+    qmp_backup(backup_file, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist,
-+               devlist, qdict_haskey(qdict, "speed"), speed, &errp);
-+
-+    if (error_is_set(&errp)) {
-+        monitor_printf(mon, "%s\n", error_get_pretty(errp));
-+        error_free(errp);
-+        return;
-+    }
-+}
-+
- void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
- {
-     Error *error = NULL;
-diff --git a/hmp.h b/hmp.h
-index 30b3c20..ad4cf80 100644
---- a/hmp.h
-+++ b/hmp.h
-@@ -28,6 +28,7 @@ void hmp_info_mice(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);
-+void hmp_info_backup(Monitor *mon, const QDict *qdict);
- void hmp_info_cpus(Monitor *mon, const QDict *qdict);
- void hmp_info_block(Monitor *mon, const QDict *qdict);
- void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
-@@ -65,6 +66,8 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
- void hmp_change(Monitor *mon, const QDict *qdict);
- void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
- void hmp_block_stream(Monitor *mon, const QDict *qdict);
-+void hmp_backup(Monitor *mon, const QDict *qdict);
-+void hmp_backup_cancel(Monitor *mon, const QDict *qdict);
- void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
- void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
- void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
-diff --git a/monitor.c b/monitor.c
-index 6a0f257..e4a810c 100644
---- a/monitor.c
-+++ b/monitor.c
-@@ -2666,6 +2666,13 @@ static mon_cmd_t info_cmds[] = {
-     },
- #endif
-     {
-+        .name       = "backup",
-+        .args_type  = "",
-+        .params     = "",
-+        .help       = "show backup status",
-+        .mhandler.cmd = hmp_info_backup,
-+    },
-+    {
-         .name       = "migrate",
-         .args_type  = "",
-         .params     = "",
-diff --git a/qapi-schema.json b/qapi-schema.json
-index 7275b5d..09ca8ef 100644
---- a/qapi-schema.json
-+++ b/qapi-schema.json
-@@ -425,6 +425,39 @@
- { 'type': 'EventInfo', 'data': {'name': 'str'} }
- ##
-+# @BackupStatus:
-+#
-+# Detailed backup status.
-+#
-+# @status: #optional string describing the current backup status.
-+#          This can be 'active', 'done', 'error'. If this field is not
-+#          returned, no backup process has been initiated
-+#
-+# @errmsg: #optional error message (only returned if status is 'error')
-+#
-+# @total: #optional total amount of bytes involved in the backup process
-+#
-+# @transferred: #optional amount of bytes already backed up.
-+#
-+# @zero-bytes: #optional amount of 'zero' bytes detected.
-+#
-+# @start-time: #optional time (epoch) when backup job started.
-+#
-+# @end-time: #optional time (epoch) when backup job finished.
-+#
-+# @backupfile: #optional backup file name
-+#
-+# @uuid: #optional uuid for this backup job
-+#
-+# Since: 1.5.0
-+##
-+{ 'type': 'BackupStatus',
-+  'data': {'*status': 'str', '*errmsg': 'str', '*total': 'int',
-+           '*transferred': 'int', '*zero-bytes': 'int',
-+           '*start-time': 'int', '*end-time': 'int',
-+           '*backup-file': 'str', '*uuid': 'str' } }
-+
-+##
- # @query-events:
- #
- # Return a list of supported QMP events by this server
-@@ -1824,6 +1857,68 @@
-   'data': { 'path': 'str' },
-   'returns': [ 'ObjectPropertyInfo' ] }
-+
-+##
-+# @BackupFormat
-+#
-+# An enumeration of supported backup formats.
-+#
-+# @vma: Proxmox vma backup format
-+##
-+{ 'enum': 'BackupFormat',
-+  'data': [ 'vma' ] }
-+
-+##
-+# @backup:
-+#
-+# Starts a VM backup.
-+#
-+# @backup-file: the backup file name
-+#
-+# @format: format of the backup file
-+#
-+# @config-filename: #optional name of a configuration file to include into
-+# the backup archive.
-+#
-+# @speed: #optional the maximum speed, in bytes per second
-+#
-+# @devlist: #optional list of block device names (separated by ',', ';'
-+# or ':'). By default the backup includes all writable block devices.
-+#
-+# Returns: the uuid of the backup job
-+#
-+# Since: 1.5.0
-+##
-+{ 'command': 'backup', 'data': { 'backup-file': 'str',
-+                                 '*format': 'BackupFormat',
-+                                 '*config-file': 'str',
-+                                 '*devlist': 'str', '*speed': 'int' },
-+  'returns': 'str' }
-+
-+##
-+# @query-backup
-+#
-+# Returns information about current/last backup task.
-+#
-+# Returns: @BackupStatus
-+#
-+# Since: 1.5.0
-+##
-+{ 'command': 'query-backup', 'returns': 'BackupStatus' }
-+
-+##
-+# @backup-cancel
-+#
-+# Cancel the current executing backup process.
-+#
-+# Returns: nothing on success
-+#
-+# Notes: This command succeeds even if there is no backup process running.
-+#
-+# Since: 1.5.0
-+##
-+{ 'command': 'backup-cancel' }
-+
- ##
- # @qom-get:
- #
-diff --git a/qmp-commands.hx b/qmp-commands.hx
-index 799adea..17e381b 100644
---- a/qmp-commands.hx
-+++ b/qmp-commands.hx
-@@ -889,6 +889,18 @@ EQMP
-     },
-     {
-+        .name       = "backup",
-+        .args_type  = "backup-file:s,format:s?,config-file:F?,speed:o?,devlist:s?",
-+        .mhandler.cmd_new = qmp_marshal_input_backup,
-+    },
-+
-+    {
-+        .name       = "backup-cancel",
-+        .args_type  = "",
-+        .mhandler.cmd_new = qmp_marshal_input_backup_cancel,
-+    },
-+
-+    {
-         .name       = "block-job-set-speed",
-         .args_type  = "device:B,speed:o",
-         .mhandler.cmd_new = qmp_marshal_input_block_job_set_speed,
-@@ -2566,6 +2578,21 @@ EQMP
-     },
- SQMP
-+
-+query-backup
-+-------------
-+
-+Backup status.
-+
-+EQMP
-+
-+    {
-+        .name       = "query-backup",
-+        .args_type  = "",
-+        .mhandler.cmd_new = qmp_marshal_input_query_backup,
-+    },
-+
-+SQMP
- migrate-set-capabilities
- -------
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0004-introduce-new-vma-archive-format.patch b/debian/patches/old/0004-introduce-new-vma-archive-format.patch
deleted file mode 100644 (file)
index 4af6d62..0000000
+++ /dev/null
@@ -1,2586 +0,0 @@
-From 6289a43696ca6f713a5d3bb9f95a5adb608a5e13 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Tue, 13 Nov 2012 11:11:38 +0100
-Subject: [PATCH v5 4/6] introduce new vma archive format
-
-This is a very simple archive format, see docs/specs/vma_spec.txt
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- Makefile                |    3 +-
- Makefile.objs           |    2 +-
- blockdev.c              |    6 +-
- docs/specs/vma_spec.txt |   24 ++
- vma-reader.c            |  799 ++++++++++++++++++++++++++++++++++++++++
- vma-writer.c            |  940 +++++++++++++++++++++++++++++++++++++++++++++++
- vma.c                   |  561 ++++++++++++++++++++++++++++
- vma.h                   |  145 ++++++++
- 8 files changed, 2476 insertions(+), 4 deletions(-)
- create mode 100644 docs/specs/vma_spec.txt
- create mode 100644 vma-reader.c
- create mode 100644 vma-writer.c
- create mode 100644 vma.c
- create mode 100644 vma.h
-
-diff --git a/Makefile b/Makefile
-index 0d9099a..16f1c25 100644
---- a/Makefile
-+++ b/Makefile
-@@ -115,7 +115,7 @@ ifeq ($(CONFIG_SMARTCARD_NSS),y)
- include $(SRC_PATH)/libcacard/Makefile
- endif
--all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all
-+all: $(DOCS) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all
- config-host.h: config-host.h-timestamp
- config-host.h-timestamp: config-host.mak
-@@ -167,6 +167,7 @@ qemu-img.o: qemu-img-cmds.h
- qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
- qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
- qemu-io$(EXESUF): qemu-io.o cmd.o $(block-obj-y) libqemuutil.a libqemustub.a
-+vma$(EXESUF): vma.o vma-writer.o vma-reader.o $(block-obj-y)  libqemuutil.a libqemustub.a
- qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
-diff --git a/Makefile.objs b/Makefile.objs
-index df64f70..91f133b 100644
---- a/Makefile.objs
-+++ b/Makefile.objs
-@@ -13,7 +13,7 @@ block-obj-$(CONFIG_POSIX) += aio-posix.o
- block-obj-$(CONFIG_WIN32) += aio-win32.o
- block-obj-y += block/
- block-obj-y += qapi-types.o qapi-visit.o
--block-obj-y += backup.o
-+block-obj-y += vma-writer.o backup.o
- block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
- block-obj-y += qemu-coroutine-sleep.o
-diff --git a/blockdev.c b/blockdev.c
-index 84f598d..683f7da 100644
---- a/blockdev.c
-+++ b/blockdev.c
-@@ -21,6 +21,7 @@
- #include "trace.h"
- #include "sysemu/arch_init.h"
- #include "backup.h"
-+#include "vma.h"
- static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
-@@ -1530,10 +1531,11 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-     /* Todo: try to auto-detect format based on file name */
-     format = has_format ? format : BACKUP_FORMAT_VMA;
--    /* fixme: find driver for specifued format */
-     const BackupDriver *driver = NULL;
--    if (!driver) {
-+    if (format == BACKUP_FORMAT_VMA) {
-+        driver = &backup_vma_driver;
-+    } else {
-         error_set(errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format");
-         return NULL;
-     }
-diff --git a/docs/specs/vma_spec.txt b/docs/specs/vma_spec.txt
-new file mode 100644
-index 0000000..9b715f2
---- /dev/null
-+++ b/docs/specs/vma_spec.txt
-@@ -0,0 +1,24 @@
-+=Virtual Machine Archive format (VMA)=
-+
-+This format contains a header which includes the VM configuration as
-+binary blobs, and a list of devices (dev_id, name).
-+
-+The actual VM image data is stored inside extents. An extent contains
-+up to 64 clusters, and start with a 512 byte header containing
-+additional information for those clusters.
-+
-+We use a cluster size of 65536, and use 8 bytes for each
-+cluster in the header to store the following information:
-+
-+* 1 byte dev_id (to identity the drive)
-+* 1 byte not used (reserved)
-+* 2 bytes zero indicator (mark zero regions (16x4096))
-+* 4 bytes cluster number
-+
-+We only store non-zero blocks (such block is 4096 bytes).
-+
-+Each archive is marked with a uuid. The archive header and all
-+extent headers includes that uuid and a MD5 checksum (over header
-+data).
-+
-+
-diff --git a/vma-reader.c b/vma-reader.c
-new file mode 100644
-index 0000000..bc36cba
---- /dev/null
-+++ b/vma-reader.c
-@@ -0,0 +1,799 @@
-+/*
-+ * VMA: Virtual Machine Archive
-+ *
-+ * Copyright (C) 2012 Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
-+ * See the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#include <stdio.h>
-+#include <errno.h>
-+#include <unistd.h>
-+#include <stdio.h>
-+#include <string.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <glib.h>
-+#include <uuid/uuid.h>
-+
-+#include "qemu-common.h"
-+#include "qemu/timer.h"
-+#include "qemu/ratelimit.h"
-+#include "vma.h"
-+#include "block/block.h"
-+
-+#define BITS_PER_LONG  (sizeof(unsigned long) * CHAR_BIT)
-+
-+static unsigned char zero_vma_block[VMA_BLOCK_SIZE];
-+
-+typedef struct VmaRestoreState {
-+    BlockDriverState *bs;
-+    bool write_zeroes;
-+    unsigned long *bitmap;
-+    int bitmap_size;
-+}  VmaRestoreState;
-+
-+struct VmaReader {
-+    int fd;
-+    GChecksum *md5csum;
-+    GHashTable *blob_hash;
-+    unsigned char *head_data;
-+    VmaDeviceInfo devinfo[256];
-+    VmaRestoreState rstate[256];
-+    GList *cdata_list;
-+    guint8 vmstate_stream;
-+    uint32_t vmstate_clusters;
-+    /* to show restore percentage if run with -v */
-+    time_t start_time;
-+    int64_t cluster_count;
-+    int64_t clusters_read;
-+    int clusters_read_per;
-+};
-+
-+static guint
-+g_int32_hash(gconstpointer v)
-+{
-+    return *(const uint32_t *)v;
-+}
-+
-+static gboolean
-+g_int32_equal(gconstpointer v1, gconstpointer v2)
-+{
-+    return *((const uint32_t *)v1) == *((const uint32_t *)v2);
-+}
-+
-+static int vma_reader_get_bitmap(VmaRestoreState *rstate, int64_t cluster_num)
-+{
-+    assert(rstate);
-+    assert(rstate->bitmap);
-+
-+    unsigned long val, idx, bit;
-+
-+    idx = cluster_num / BITS_PER_LONG;
-+
-+    assert(rstate->bitmap_size > idx);
-+
-+    bit = cluster_num % BITS_PER_LONG;
-+    val = rstate->bitmap[idx];
-+
-+    return !!(val & (1UL << bit));
-+}
-+
-+static void vma_reader_set_bitmap(VmaRestoreState *rstate, int64_t cluster_num,
-+                                  int dirty)
-+{
-+    assert(rstate);
-+    assert(rstate->bitmap);
-+
-+    unsigned long val, idx, bit;
-+
-+    idx = cluster_num / BITS_PER_LONG;
-+
-+    assert(rstate->bitmap_size > idx);
-+
-+    bit = cluster_num % BITS_PER_LONG;
-+    val = rstate->bitmap[idx];
-+    if (dirty) {
-+        if (!(val & (1UL << bit))) {
-+            val |= 1UL << bit;
-+        }
-+    } else {
-+        if (val & (1UL << bit)) {
-+            val &= ~(1UL << bit);
-+        }
-+    }
-+    rstate->bitmap[idx] = val;
-+}
-+
-+typedef struct VmaBlob {
-+    uint32_t start;
-+    uint32_t len;
-+    void *data;
-+} VmaBlob;
-+
-+static const VmaBlob *get_header_blob(VmaReader *vmar, uint32_t pos)
-+{
-+    assert(vmar);
-+    assert(vmar->blob_hash);
-+
-+    return g_hash_table_lookup(vmar->blob_hash, &pos);
-+}
-+
-+static const char *get_header_str(VmaReader *vmar, uint32_t pos)
-+{
-+    const VmaBlob *blob = get_header_blob(vmar, pos);
-+    if (!blob) {
-+        return NULL;
-+    }
-+    const char *res = (char *)blob->data;
-+    if (res[blob->len-1] != '\0') {
-+        return NULL;
-+    }
-+    return res;
-+}
-+
-+static ssize_t
-+safe_read(int fd, unsigned char *buf, size_t count)
-+{
-+    ssize_t n;
-+
-+    do {
-+        n = read(fd, buf, count);
-+    } while (n < 0 && errno == EINTR);
-+
-+    return n;
-+}
-+
-+static ssize_t
-+full_read(int fd, unsigned char *buf, size_t len)
-+{
-+    ssize_t n;
-+    size_t total;
-+
-+    total = 0;
-+
-+    while (len > 0) {
-+        n = safe_read(fd, buf, len);
-+
-+        if (n == 0) {
-+            return total;
-+        }
-+
-+        if (n <= 0) {
-+            break;
-+        }
-+
-+        buf += n;
-+        total += n;
-+        len -= n;
-+    }
-+
-+    if (len) {
-+        return -1;
-+    }
-+
-+    return total;
-+}
-+
-+void vma_reader_destroy(VmaReader *vmar)
-+{
-+    assert(vmar);
-+
-+    if (vmar->fd >= 0) {
-+        close(vmar->fd);
-+    }
-+
-+    if (vmar->cdata_list) {
-+        g_list_free(vmar->cdata_list);
-+    }
-+
-+    int i;
-+    for (i = 1; i < 256; i++) {
-+        if (vmar->rstate[i].bitmap) {
-+            g_free(vmar->rstate[i].bitmap);
-+        }
-+    }
-+
-+    if (vmar->md5csum) {
-+        g_checksum_free(vmar->md5csum);
-+    }
-+
-+    if (vmar->blob_hash) {
-+        g_hash_table_destroy(vmar->blob_hash);
-+    }
-+
-+    if (vmar->head_data) {
-+        g_free(vmar->head_data);
-+    }
-+
-+    g_free(vmar);
-+
-+};
-+
-+static int vma_reader_read_head(VmaReader *vmar, Error **errp)
-+{
-+    assert(vmar);
-+    assert(errp);
-+    assert(*errp == NULL);
-+
-+    unsigned char md5sum[16];
-+    int i;
-+    int ret = 0;
-+
-+    vmar->head_data = g_malloc(sizeof(VmaHeader));
-+
-+    if (full_read(vmar->fd, vmar->head_data, sizeof(VmaHeader)) !=
-+        sizeof(VmaHeader)) {
-+        error_setg(errp, "can't read vma header - %s",
-+                   errno ? g_strerror(errno) : "got EOF");
-+        return -1;
-+    }
-+
-+    VmaHeader *h = (VmaHeader *)vmar->head_data;
-+
-+    if (h->magic != VMA_MAGIC) {
-+        error_setg(errp, "not a vma file - wrong magic number");
-+        return -1;
-+    }
-+
-+    uint32_t header_size = GUINT32_FROM_BE(h->header_size);
-+    int need = header_size - sizeof(VmaHeader);
-+    if (need <= 0) {
-+        error_setg(errp, "wrong vma header size %d", header_size);
-+        return -1;
-+    }
-+
-+    vmar->head_data = g_realloc(vmar->head_data, header_size);
-+    h = (VmaHeader *)vmar->head_data;
-+
-+    if (full_read(vmar->fd, vmar->head_data + sizeof(VmaHeader), need) !=
-+        need) {
-+        error_setg(errp, "can't read vma header data - %s",
-+                   errno ? g_strerror(errno) : "got EOF");
-+        return -1;
-+    }
-+
-+    memcpy(md5sum, h->md5sum, 16);
-+    memset(h->md5sum, 0, 16);
-+
-+    g_checksum_reset(vmar->md5csum);
-+    g_checksum_update(vmar->md5csum, vmar->head_data, header_size);
-+    gsize csize = 16;
-+    g_checksum_get_digest(vmar->md5csum, (guint8 *)(h->md5sum), &csize);
-+
-+    if (memcmp(md5sum, h->md5sum, 16) != 0) {
-+        error_setg(errp, "wrong vma header chechsum");
-+        return -1;
-+    }
-+
-+    /* we can modify header data after checksum verify */
-+    h->header_size = header_size;
-+
-+    h->version = GUINT32_FROM_BE(h->version);
-+    if (h->version != 1) {
-+        error_setg(errp, "wrong vma version %d", h->version);
-+        return -1;
-+    }
-+
-+    h->ctime = GUINT64_FROM_BE(h->ctime);
-+    h->blob_buffer_offset = GUINT32_FROM_BE(h->blob_buffer_offset);
-+    h->blob_buffer_size = GUINT32_FROM_BE(h->blob_buffer_size);
-+
-+    uint32_t bstart = h->blob_buffer_offset + 1;
-+    uint32_t bend = h->blob_buffer_offset + h->blob_buffer_size;
-+
-+    if (bstart <= sizeof(VmaHeader)) {
-+        error_setg(errp, "wrong vma blob buffer offset %d",
-+                   h->blob_buffer_offset);
-+        return -1;
-+    }
-+
-+    if (bend > header_size) {
-+        error_setg(errp, "wrong vma blob buffer size %d/%d",
-+                   h->blob_buffer_offset, h->blob_buffer_size);
-+        return -1;
-+    }
-+
-+    while ((bstart + 2) <= bend) {
-+        uint32_t size = vmar->head_data[bstart] +
-+            (vmar->head_data[bstart+1] << 8);
-+        if ((bstart + size + 2) <= bend) {
-+            VmaBlob *blob = g_new0(VmaBlob, 1);
-+            blob->start = bstart - h->blob_buffer_offset;
-+            blob->len = size;
-+            blob->data = vmar->head_data + bstart + 2;
-+            g_hash_table_insert(vmar->blob_hash, &blob->start, blob);
-+        }
-+        bstart += size + 2;
-+    }
-+
-+
-+    int count = 0;
-+    for (i = 1; i < 256; i++) {
-+        VmaDeviceInfoHeader *dih = &h->dev_info[i];
-+        uint32_t devname_ptr = GUINT32_FROM_BE(dih->devname_ptr);
-+        uint64_t size = GUINT64_FROM_BE(dih->size);
-+        const char *devname =  get_header_str(vmar, devname_ptr);
-+
-+        if (size && devname) {
-+            count++;
-+            vmar->devinfo[i].size = size;
-+            vmar->devinfo[i].devname = devname;
-+
-+            if (strcmp(devname, "vmstate") == 0) {
-+                vmar->vmstate_stream = i;
-+            }
-+        }
-+    }
-+
-+    if (!count) {
-+        error_setg(errp, "vma does not contain data");
-+        return -1;
-+    }
-+
-+    for (i = 0; i < VMA_MAX_CONFIGS; i++) {
-+        uint32_t name_ptr = GUINT32_FROM_BE(h->config_names[i]);
-+        uint32_t data_ptr = GUINT32_FROM_BE(h->config_data[i]);
-+
-+        if (!(name_ptr && data_ptr)) {
-+            continue;
-+        }
-+        const char *name =  get_header_str(vmar, name_ptr);
-+        const VmaBlob *blob = get_header_blob(vmar, data_ptr);
-+
-+        if (!(name && blob)) {
-+            error_setg(errp, "vma contains invalid data pointers");
-+            return -1;
-+        }
-+
-+        VmaConfigData *cdata = g_new0(VmaConfigData, 1);
-+        cdata->name = name;
-+        cdata->data = blob->data;
-+        cdata->len = blob->len;
-+
-+        vmar->cdata_list = g_list_append(vmar->cdata_list, cdata);
-+    }
-+
-+    return ret;
-+};
-+
-+VmaReader *vma_reader_create(const char *filename, Error **errp)
-+{
-+    assert(filename);
-+    assert(errp);
-+
-+    VmaReader *vmar = g_new0(VmaReader, 1);
-+
-+    if (strcmp(filename, "-") == 0) {
-+        vmar->fd = dup(0);
-+    } else {
-+        vmar->fd = open(filename, O_RDONLY);
-+    }
-+
-+    if (vmar->fd < 0) {
-+        error_setg(errp, "can't open file %s - %s\n", filename,
-+                   g_strerror(errno));
-+        goto err;
-+    }
-+
-+    vmar->md5csum = g_checksum_new(G_CHECKSUM_MD5);
-+    if (!vmar->md5csum) {
-+        error_setg(errp, "can't allocate cmsum\n");
-+        goto err;
-+    }
-+
-+    vmar->blob_hash = g_hash_table_new_full(g_int32_hash, g_int32_equal,
-+                                            NULL, g_free);
-+
-+    if (vma_reader_read_head(vmar, errp) < 0) {
-+        goto err;
-+    }
-+
-+    return vmar;
-+
-+err:
-+    if (vmar) {
-+        vma_reader_destroy(vmar);
-+    }
-+
-+    return NULL;
-+}
-+
-+VmaHeader *vma_reader_get_header(VmaReader *vmar)
-+{
-+    assert(vmar);
-+    assert(vmar->head_data);
-+
-+    return (VmaHeader *)(vmar->head_data);
-+}
-+
-+GList *vma_reader_get_config_data(VmaReader *vmar)
-+{
-+    assert(vmar);
-+    assert(vmar->head_data);
-+
-+    return vmar->cdata_list;
-+}
-+
-+VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
-+{
-+    assert(vmar);
-+    assert(dev_id);
-+
-+    if (vmar->devinfo[dev_id].size && vmar->devinfo[dev_id].devname) {
-+        return &vmar->devinfo[dev_id];
-+    }
-+
-+    return NULL;
-+}
-+
-+int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockDriverState *bs,
-+                           bool write_zeroes, Error **errp)
-+{
-+    assert(vmar);
-+    assert(bs != NULL);
-+    assert(dev_id);
-+    assert(vmar->rstate[dev_id].bs == NULL);
-+
-+    int64_t size = bdrv_getlength(bs);
-+    if (size != vmar->devinfo[dev_id].size) {
-+        error_setg(errp, "vma_reader_register_bs for stream %s failed - "
-+                   "unexpected size %zd != %zd", vmar->devinfo[dev_id].devname,
-+                   size, vmar->devinfo[dev_id].size);
-+        return -1;
-+    }
-+
-+    vmar->rstate[dev_id].bs = bs;
-+    vmar->rstate[dev_id].write_zeroes = write_zeroes;
-+
-+    int64_t bitmap_size = (size/BDRV_SECTOR_SIZE) +
-+        (VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE) * BITS_PER_LONG - 1;
-+    bitmap_size /= (VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE) * BITS_PER_LONG;
-+
-+    vmar->rstate[dev_id].bitmap_size = bitmap_size;
-+    vmar->rstate[dev_id].bitmap = g_new0(unsigned long, bitmap_size);
-+
-+    vmar->cluster_count += size/VMA_CLUSTER_SIZE;
-+
-+    return 0;
-+}
-+
-+static ssize_t safe_write(int fd, void *buf, size_t count)
-+{
-+    ssize_t n;
-+
-+    do {
-+        n = write(fd, buf, count);
-+    } while (n < 0 && errno == EINTR);
-+
-+    return n;
-+}
-+
-+static size_t full_write(int fd, void *buf, size_t len)
-+{
-+    ssize_t n;
-+    size_t total;
-+
-+    total = 0;
-+
-+    while (len > 0) {
-+        n = safe_write(fd, buf, len);
-+        if (n < 0) {
-+            return n;
-+        }
-+        buf += n;
-+        total += n;
-+        len -= n;
-+    }
-+
-+    if (len) {
-+        /* incomplete write ? */
-+        return -1;
-+    }
-+
-+    return total;
-+}
-+
-+static int restore_write_data(VmaReader *vmar, guint8 dev_id,
-+                              BlockDriverState *bs, int vmstate_fd,
-+                              unsigned char *buf, int64_t sector_num,
-+                              int nb_sectors, Error **errp)
-+{
-+    assert(vmar);
-+
-+    if (dev_id == vmar->vmstate_stream) {
-+        if (vmstate_fd >= 0) {
-+            int len = nb_sectors * BDRV_SECTOR_SIZE;
-+            int res = full_write(vmstate_fd, buf, len);
-+            if (res < 0) {
-+                error_setg(errp, "write vmstate failed %d", res);
-+                return -1;
-+            }
-+        }
-+    } else {
-+        int res = bdrv_write(bs, sector_num, buf, nb_sectors);
-+        if (res < 0) {
-+            error_setg(errp, "bdrv_write to %s failed (%d)",
-+                       bdrv_get_device_name(bs), res);
-+            return -1;
-+        }
-+    }
-+    return 0;
-+}
-+static int restore_extent(VmaReader *vmar, unsigned char *buf,
-+                          int extent_size, int vmstate_fd,
-+                          bool verbose, Error **errp)
-+{
-+    assert(vmar);
-+    assert(buf);
-+
-+    VmaExtentHeader *ehead = (VmaExtentHeader *)buf;
-+    int start = VMA_EXTENT_HEADER_SIZE;
-+    int i;
-+
-+    for (i = 0; i < VMA_BLOCKS_PER_EXTENT; i++) {
-+        uint64_t block_info = GUINT64_FROM_BE(ehead->blockinfo[i]);
-+        uint64_t cluster_num = block_info & 0xffffffff;
-+        uint8_t dev_id = (block_info >> 32) & 0xff;
-+        uint16_t mask = block_info >> (32+16);
-+        int64_t max_sector;
-+
-+        if (!dev_id) {
-+            continue;
-+        }
-+
-+        VmaRestoreState *rstate = &vmar->rstate[dev_id];
-+        BlockDriverState *bs = NULL;
-+
-+        if (dev_id != vmar->vmstate_stream) {
-+            bs = rstate->bs;
-+            if (!bs) {
-+                error_setg(errp, "got wrong dev id %d", dev_id);
-+                return -1;
-+            }
-+
-+            if (vma_reader_get_bitmap(rstate, cluster_num)) {
-+                error_setg(errp, "found duplicated cluster %zd for stream %s",
-+                          cluster_num, vmar->devinfo[dev_id].devname);
-+                return -1;
-+            }
-+            vma_reader_set_bitmap(rstate, cluster_num, 1);
-+
-+            max_sector = vmar->devinfo[dev_id].size/BDRV_SECTOR_SIZE;
-+        } else {
-+            max_sector = G_MAXINT64;
-+            if (cluster_num != vmar->vmstate_clusters) {
-+                error_setg(errp, "found out of order vmstate data");
-+                return -1;
-+            }
-+            vmar->vmstate_clusters++;
-+        }
-+
-+        vmar->clusters_read++;
-+
-+        if (verbose) {
-+            time_t duration = time(NULL) - vmar->start_time;
-+            int percent = (vmar->clusters_read*100)/vmar->cluster_count;
-+            if (percent != vmar->clusters_read_per) {
-+                printf("progress %d%% (read %zd bytes, duration %zd sec)\n",
-+                       percent, vmar->clusters_read*VMA_CLUSTER_SIZE,
-+                       duration);
-+                fflush(stdout);
-+                vmar->clusters_read_per = percent;
-+            }
-+        }
-+
-+        /* try to write whole clusters to speedup restore */
-+        if (mask == 0xffff) {
-+            if ((start + VMA_CLUSTER_SIZE) > extent_size) {
-+                error_setg(errp, "short vma extent - too many blocks");
-+                return -1;
-+            }
-+            int64_t sector_num = (cluster_num * VMA_CLUSTER_SIZE) /
-+                BDRV_SECTOR_SIZE;
-+            int64_t end_sector = sector_num +
-+                VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE;
-+
-+            if (end_sector > max_sector) {
-+                end_sector = max_sector;
-+            }
-+
-+            if (end_sector <= sector_num) {
-+                error_setg(errp, "got wrong block address - write bejond end");
-+                return -1;
-+            }
-+
-+            int nb_sectors = end_sector - sector_num;
-+            if (restore_write_data(vmar, dev_id, bs, vmstate_fd, buf + start,
-+                                   sector_num, nb_sectors, errp) < 0) {
-+                return -1;
-+            }
-+
-+            start += VMA_CLUSTER_SIZE;
-+        } else {
-+            int j;
-+            int bit = 1;
-+
-+            for (j = 0; j < 16; j++) {
-+                int64_t sector_num = (cluster_num*VMA_CLUSTER_SIZE +
-+                                      j*VMA_BLOCK_SIZE)/BDRV_SECTOR_SIZE;
-+
-+                int64_t end_sector = sector_num +
-+                    VMA_BLOCK_SIZE/BDRV_SECTOR_SIZE;
-+                if (end_sector > max_sector) {
-+                    end_sector = max_sector;
-+                }
-+
-+                if (mask & bit) {
-+                    if ((start + VMA_BLOCK_SIZE) > extent_size) {
-+                        error_setg(errp, "short vma extent - too many blocks");
-+                        return -1;
-+                    }
-+
-+                    if (end_sector <= sector_num) {
-+                        error_setg(errp, "got wrong block address - "
-+                                   "write bejond end");
-+                        return -1;
-+                    }
-+
-+                    int nb_sectors = end_sector - sector_num;
-+                    if (restore_write_data(vmar, dev_id, bs, vmstate_fd,
-+                                           buf + start, sector_num,
-+                                           nb_sectors, errp) < 0) {
-+                        return -1;
-+                    }
-+
-+                    start += VMA_BLOCK_SIZE;
-+
-+                } else {
-+
-+                    if (rstate->write_zeroes && (end_sector > sector_num)) {
-+                        /* Todo: use bdrv_co_write_zeroes (but that need to
-+                         * be run inside coroutine?)
-+                         */
-+                        int nb_sectors = end_sector - sector_num;
-+                        if (restore_write_data(vmar, dev_id, bs, vmstate_fd,
-+                                              zero_vma_block, sector_num,
-+                                               nb_sectors, errp) < 0) {
-+                            return -1;
-+                        }
-+                    }
-+                }
-+
-+                bit = bit << 1;
-+            }
-+        }
-+    }
-+
-+    if (start != extent_size) {
-+        error_setg(errp, "vma extent error - missing blocks");
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
-+                       Error **errp)
-+{
-+    assert(vmar);
-+    assert(vmar->head_data);
-+
-+    int ret = 0;
-+    unsigned char buf[VMA_MAX_EXTENT_SIZE];
-+    int buf_pos = 0;
-+    unsigned char md5sum[16];
-+    VmaHeader *h = (VmaHeader *)vmar->head_data;
-+
-+    vmar->start_time = time(NULL);
-+
-+    while (1) {
-+        int bytes = full_read(vmar->fd, buf + buf_pos, sizeof(buf) - buf_pos);
-+        if (bytes < 0) {
-+            error_setg(errp, "read failed - %s", g_strerror(errno));
-+            return -1;
-+        }
-+
-+        buf_pos += bytes;
-+
-+        if (!buf_pos) {
-+            break; /* EOF */
-+        }
-+
-+        if (buf_pos < VMA_EXTENT_HEADER_SIZE) {
-+            error_setg(errp, "read short extent (%d bytes)", buf_pos);
-+            return -1;
-+        }
-+
-+        VmaExtentHeader *ehead = (VmaExtentHeader *)buf;
-+
-+        /* extract md5sum */
-+        memcpy(md5sum, ehead->md5sum, sizeof(ehead->md5sum));
-+        memset(ehead->md5sum, 0, sizeof(ehead->md5sum));
-+
-+        g_checksum_reset(vmar->md5csum);
-+        g_checksum_update(vmar->md5csum, buf, VMA_EXTENT_HEADER_SIZE);
-+        gsize csize = 16;
-+        g_checksum_get_digest(vmar->md5csum, ehead->md5sum, &csize);
-+
-+        if (memcmp(md5sum, ehead->md5sum, 16) != 0) {
-+            error_setg(errp, "wrong vma extent header chechsum");
-+            return -1;
-+        }
-+
-+        if (memcmp(h->uuid, ehead->uuid, sizeof(ehead->uuid)) != 0) {
-+            error_setg(errp, "wrong vma extent uuid");
-+            return -1;
-+        }
-+
-+        if (ehead->magic != VMA_EXTENT_MAGIC || ehead->reserved1 != 0) {
-+            error_setg(errp, "wrong vma extent header magic");
-+            return -1;
-+        }
-+
-+        int block_count = GUINT16_FROM_BE(ehead->block_count);
-+        int extent_size = VMA_EXTENT_HEADER_SIZE + block_count*VMA_BLOCK_SIZE;
-+
-+        if (buf_pos < extent_size) {
-+            error_setg(errp, "short vma extent (%d < %d)", buf_pos,
-+                       extent_size);
-+            return -1;
-+        }
-+
-+        if (restore_extent(vmar, buf, extent_size, vmstate_fd, verbose,
-+                           errp) < 0) {
-+            return -1;
-+        }
-+
-+        if (buf_pos > extent_size) {
-+            memmove(buf, buf + extent_size, buf_pos - extent_size);
-+            buf_pos = buf_pos - extent_size;
-+        } else {
-+            buf_pos = 0;
-+        }
-+    }
-+
-+    bdrv_drain_all();
-+
-+    int i;
-+    for (i = 1; i < 256; i++) {
-+        VmaRestoreState *rstate = &vmar->rstate[i];
-+        if (!rstate->bs) {
-+            continue;
-+        }
-+
-+        if (bdrv_flush(rstate->bs) < 0) {
-+            error_setg(errp, "vma bdrv_flush %s failed",
-+                       vmar->devinfo[i].devname);
-+            return -1;
-+        }
-+
-+        if (vmar->devinfo[i].size &&
-+            (strcmp(vmar->devinfo[i].devname, "vmstate") != 0)) {
-+            assert(rstate->bitmap);
-+
-+            int64_t cluster_num, end;
-+
-+            end = (vmar->devinfo[i].size + VMA_CLUSTER_SIZE - 1) /
-+                VMA_CLUSTER_SIZE;
-+
-+            for (cluster_num = 0; cluster_num < end; cluster_num++) {
-+                if (!vma_reader_get_bitmap(rstate, cluster_num)) {
-+                    error_setg(errp, "detected missing cluster %zd "
-+                               "for stream %s", cluster_num,
-+                               vmar->devinfo[i].devname);
-+                    return -1;
-+                }
-+            }
-+        }
-+    }
-+
-+    return ret;
-+}
-+
-diff --git a/vma-writer.c b/vma-writer.c
-new file mode 100644
-index 0000000..9228ca6
---- /dev/null
-+++ b/vma-writer.c
-@@ -0,0 +1,940 @@
-+/*
-+ * VMA: Virtual Machine Archive
-+ *
-+ * Copyright (C) 2012 Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
-+ * See the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#include <stdio.h>
-+#include <errno.h>
-+#include <unistd.h>
-+#include <stdio.h>
-+#include <string.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <glib.h>
-+#include <uuid/uuid.h>
-+
-+#include "qemu-common.h"
-+#include "vma.h"
-+#include "block/block.h"
-+#include "monitor/monitor.h"
-+
-+#define DEBUG_VMA 0
-+
-+#define DPRINTF(fmt, ...)\
-+    do { if (DEBUG_VMA) { printf("vma: " fmt, ## __VA_ARGS__); } } while (0)
-+
-+#define WRITE_BUFFERS 5
-+
-+typedef struct VmaAIOCB VmaAIOCB;
-+struct VmaAIOCB {
-+    unsigned char buffer[VMA_MAX_EXTENT_SIZE];
-+    VmaWriter *vmaw;
-+    size_t bytes;
-+    Coroutine *co;
-+};
-+
-+struct VmaWriter {
-+    int fd;
-+    FILE *cmd;
-+    int status;
-+    char errmsg[8192];
-+    uuid_t uuid;
-+    bool header_written;
-+    bool closed;
-+
-+    /* we always write extents */
-+    unsigned char outbuf[VMA_MAX_EXTENT_SIZE];
-+    int outbuf_pos; /* in bytes */
-+    int outbuf_count; /* in VMA_BLOCKS */
-+    uint64_t outbuf_block_info[VMA_BLOCKS_PER_EXTENT];
-+
-+    VmaAIOCB *aiocbs[WRITE_BUFFERS];
-+    CoQueue wqueue;
-+
-+    GChecksum *md5csum;
-+    CoMutex writer_lock;
-+    CoMutex flush_lock;
-+    Coroutine *co_writer;
-+
-+    /* drive informations */
-+    VmaStreamInfo stream_info[256];
-+    guint stream_count;
-+
-+    guint8 vmstate_stream;
-+    uint32_t vmstate_clusters;
-+
-+    /* header blob table */
-+    char *header_blob_table;
-+    uint32_t header_blob_table_size;
-+    uint32_t header_blob_table_pos;
-+
-+    /* store for config blobs */
-+    uint32_t config_names[VMA_MAX_CONFIGS]; /* offset into blob_buffer table */
-+    uint32_t config_data[VMA_MAX_CONFIGS];  /* offset into blob_buffer table */
-+    uint32_t config_count;
-+};
-+
-+void vma_writer_set_error(VmaWriter *vmaw, const char *fmt, ...)
-+{
-+    va_list ap;
-+
-+    if (vmaw->status < 0) {
-+        return;
-+    }
-+
-+    vmaw->status = -1;
-+
-+    va_start(ap, fmt);
-+    g_vsnprintf(vmaw->errmsg, sizeof(vmaw->errmsg), fmt, ap);
-+    va_end(ap);
-+
-+    DPRINTF("vma_writer_set_error: %s\n", vmaw->errmsg);
-+}
-+
-+static uint32_t allocate_header_blob(VmaWriter *vmaw, const char *data,
-+                                     size_t len)
-+{
-+    if (len > 65535) {
-+        return 0;
-+    }
-+
-+    if (!vmaw->header_blob_table ||
-+        (vmaw->header_blob_table_size <
-+         (vmaw->header_blob_table_pos + len + 2))) {
-+        int newsize = vmaw->header_blob_table_size + ((len + 2 + 511)/512)*512;
-+
-+        vmaw->header_blob_table = g_realloc(vmaw->header_blob_table, newsize);
-+        memset(vmaw->header_blob_table + vmaw->header_blob_table_size,
-+               0, newsize - vmaw->header_blob_table_size);
-+        vmaw->header_blob_table_size = newsize;
-+    }
-+
-+    uint32_t cpos = vmaw->header_blob_table_pos;
-+    vmaw->header_blob_table[cpos] = len & 255;
-+    vmaw->header_blob_table[cpos+1] = (len >> 8) & 255;
-+    memcpy(vmaw->header_blob_table + cpos + 2, data, len);
-+    vmaw->header_blob_table_pos += len + 2;
-+    return cpos;
-+}
-+
-+static uint32_t allocate_header_string(VmaWriter *vmaw, const char *str)
-+{
-+    assert(vmaw);
-+
-+    size_t len = strlen(str) + 1;
-+
-+    return allocate_header_blob(vmaw, str, len);
-+}
-+
-+int vma_writer_add_config(VmaWriter *vmaw, const char *name, gpointer data,
-+                          gsize len)
-+{
-+    assert(vmaw);
-+    assert(!vmaw->header_written);
-+    assert(vmaw->config_count < VMA_MAX_CONFIGS);
-+    assert(name);
-+    assert(data);
-+    assert(len);
-+
-+    uint32_t name_ptr = allocate_header_string(vmaw, name);
-+    if (!name_ptr) {
-+        return -1;
-+    }
-+
-+    uint32_t data_ptr = allocate_header_blob(vmaw, data, len);
-+    if (!data_ptr) {
-+        return -1;
-+    }
-+
-+    vmaw->config_names[vmaw->config_count] = name_ptr;
-+    vmaw->config_data[vmaw->config_count] = data_ptr;
-+
-+    vmaw->config_count++;
-+
-+    return 0;
-+}
-+
-+int vma_writer_register_stream(VmaWriter *vmaw, const char *devname,
-+                               size_t size)
-+{
-+    assert(vmaw);
-+    assert(devname);
-+    assert(!vmaw->status);
-+
-+    if (vmaw->header_written) {
-+        vma_writer_set_error(vmaw, "vma_writer_register_stream: header "
-+                             "already written");
-+        return -1;
-+    }
-+
-+    guint n = vmaw->stream_count + 1;
-+
-+    /* we can have dev_ids form 1 to 255 (0 reserved)
-+     * 255(-1) reseverd for safety
-+     */
-+    if (n > 254) {
-+        vma_writer_set_error(vmaw, "vma_writer_register_stream: "
-+                             "too many drives");
-+        return -1;
-+    }
-+
-+    if (size <= 0) {
-+        vma_writer_set_error(vmaw, "vma_writer_register_stream: "
-+                             "got strange size %zd", size);
-+        return -1;
-+    }
-+
-+    DPRINTF("vma_writer_register_stream %s %zu %d\n", devname, size, n);
-+
-+    vmaw->stream_info[n].devname = g_strdup(devname);
-+    vmaw->stream_info[n].size = size;
-+
-+    vmaw->stream_info[n].cluster_count = (size + VMA_CLUSTER_SIZE - 1) /
-+        VMA_CLUSTER_SIZE;
-+
-+    vmaw->stream_count = n;
-+
-+    if (strcmp(devname, "vmstate") == 0) {
-+        vmaw->vmstate_stream = n;
-+    }
-+
-+    return n;
-+}
-+
-+static void vma_co_continue_write(void *opaque)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    DPRINTF("vma_co_continue_write\n");
-+    qemu_coroutine_enter(vmaw->co_writer, NULL);
-+}
-+
-+static int vma_co_write_finished(void *opaque)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    return (vmaw->co_writer != 0);
-+}
-+
-+static ssize_t coroutine_fn
-+vma_co_write(VmaWriter *vmaw, const void *buf, size_t bytes)
-+{
-+    size_t done = 0;
-+    ssize_t ret;
-+
-+    /* atomic writes (we cannot interleave writes) */
-+    qemu_co_mutex_lock(&vmaw->writer_lock);
-+
-+    DPRINTF("vma_co_write enter %zd\n", bytes);
-+
-+    assert(vmaw->co_writer == NULL);
-+
-+    vmaw->co_writer = qemu_coroutine_self();
-+
-+    qemu_aio_set_fd_handler(vmaw->fd, NULL, vma_co_continue_write,
-+                            vma_co_write_finished, vmaw);
-+
-+    DPRINTF("vma_co_write wait until writable\n");
-+    qemu_coroutine_yield();
-+    DPRINTF("vma_co_write starting %zd\n", bytes);
-+
-+    while (done < bytes) {
-+        ret = write(vmaw->fd, buf + done, bytes - done);
-+        if (ret > 0) {
-+            done += ret;
-+            DPRINTF("vma_co_write written %zd %zd\n", done, ret);
-+        } else if (ret < 0) {
-+            if (errno == EAGAIN || errno == EWOULDBLOCK) {
-+                DPRINTF("vma_co_write yield %zd\n", done);
-+                qemu_coroutine_yield();
-+                DPRINTF("vma_co_write restart %zd\n", done);
-+            } else {
-+                vma_writer_set_error(vmaw, "vma_co_write write error - %s",
-+                                     g_strerror(errno));
-+                done = -1; /* always return failure for partial writes */
-+                break;
-+            }
-+        } else if (ret == 0) {
-+            /* should not happen - simply try again */
-+        }
-+    }
-+
-+    qemu_aio_set_fd_handler(vmaw->fd, NULL, NULL, NULL, NULL);
-+
-+    vmaw->co_writer = NULL;
-+
-+    qemu_co_mutex_unlock(&vmaw->writer_lock);
-+
-+    DPRINTF("vma_co_write leave %zd\n", done);
-+    return done;
-+}
-+
-+static void coroutine_fn vma_co_writer_task(void *opaque)
-+{
-+    VmaAIOCB *cb = opaque;
-+
-+    DPRINTF("vma_co_writer_task start\n");
-+
-+    int64_t done = vma_co_write(cb->vmaw, cb->buffer, cb->bytes);
-+    DPRINTF("vma_co_writer_task write done %zd\n", done);
-+
-+    if (done != cb->bytes) {
-+        DPRINTF("vma_co_writer_task failed write %zd %zd", cb->bytes, done);
-+        vma_writer_set_error(cb->vmaw, "vma_co_writer_task failed write %zd",
-+                             done);
-+    }
-+
-+    cb->bytes = 0;
-+
-+    qemu_co_queue_next(&cb->vmaw->wqueue);
-+
-+    DPRINTF("vma_co_writer_task end\n");
-+}
-+
-+static void coroutine_fn vma_queue_flush(VmaWriter *vmaw)
-+{
-+    DPRINTF("vma_queue_flush enter\n");
-+
-+    assert(vmaw);
-+
-+    while (1) {
-+        int i;
-+        VmaAIOCB *cb = NULL;
-+        for (i = 0; i < WRITE_BUFFERS; i++) {
-+            if (vmaw->aiocbs[i]->bytes) {
-+                cb = vmaw->aiocbs[i];
-+                DPRINTF("FOUND USED AIO BUFFER %d %zd\n", i,
-+                        vmaw->aiocbs[i]->bytes);
-+                break;
-+            }
-+        }
-+        if (!cb) {
-+            break;
-+        }
-+        qemu_co_queue_wait(&vmaw->wqueue);
-+    }
-+
-+    DPRINTF("vma_queue_flush leave\n");
-+}
-+
-+/**
-+ * NOTE: pipe buffer size in only 4096 bytes on linux (see 'ulimit -a')
-+ * So we need to create a coroutione to allow 'parallel' execution.
-+ */
-+static ssize_t coroutine_fn
-+vma_queue_write(VmaWriter *vmaw, const void *buf, size_t bytes)
-+{
-+    DPRINTF("vma_queue_write enter %zd\n", bytes);
-+
-+    assert(vmaw);
-+    assert(buf);
-+    assert(bytes <= VMA_MAX_EXTENT_SIZE);
-+
-+    VmaAIOCB *cb = NULL;
-+    while (!cb) {
-+        int i;
-+        for (i = 0; i < WRITE_BUFFERS; i++) {
-+            if (!vmaw->aiocbs[i]->bytes) {
-+                cb = vmaw->aiocbs[i];
-+                break;
-+            }
-+        }
-+        if (!cb) {
-+            qemu_co_queue_wait(&vmaw->wqueue);
-+        }
-+    }
-+
-+    memcpy(cb->buffer, buf, bytes);
-+    cb->bytes = bytes;
-+    cb->vmaw = vmaw;
-+
-+    DPRINTF("vma_queue_write start %zd\n", bytes);
-+    cb->co = qemu_coroutine_create(vma_co_writer_task);
-+    qemu_coroutine_enter(cb->co, cb);
-+
-+    DPRINTF("vma_queue_write leave\n");
-+
-+    return bytes;
-+}
-+
-+VmaWriter *vma_writer_create(const char *filename, uuid_t uuid, Error **errp)
-+{
-+    const char *p;
-+
-+    assert(sizeof(VmaHeader) == (4096 + 8192));
-+    assert(sizeof(VmaExtentHeader) == 512);
-+
-+    VmaWriter *vmaw = g_new0(VmaWriter, 1);
-+    vmaw->fd = -1;
-+
-+    vmaw->md5csum = g_checksum_new(G_CHECKSUM_MD5);
-+    if (!vmaw->md5csum) {
-+        error_setg(errp, "can't allocate cmsum\n");
-+        goto err;
-+    }
-+
-+    if (strstart(filename, "exec:", &p)) {
-+        vmaw->cmd = popen(p, "w");
-+        if (vmaw->cmd == NULL) {
-+            error_setg(errp, "can't popen command '%s' - %s\n", p,
-+                       g_strerror(errno));
-+            goto err;
-+        }
-+        vmaw->fd = fileno(vmaw->cmd);
-+
-+        /* try to use O_NONBLOCK and O_DIRECT */
-+        fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK);
-+        fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_DIRECT);
-+
-+    } else {
-+        struct stat st;
-+        int oflags;
-+        const char *tmp_id_str;
-+
-+        if ((stat(filename, &st) == 0) && S_ISFIFO(st.st_mode)) {
-+            oflags = O_NONBLOCK|O_DIRECT|O_WRONLY;
-+            vmaw->fd = qemu_open(filename, oflags, 0644);
-+        } else if (strstart(filename, "/dev/fdset/", &tmp_id_str)) {
-+            oflags = O_NONBLOCK|O_DIRECT|O_WRONLY;
-+            vmaw->fd = qemu_open(filename, oflags, 0644);
-+        } else if (strstart(filename, "/dev/fdname/", &tmp_id_str)) {
-+            vmaw->fd = monitor_get_fd(cur_mon, tmp_id_str, errp);
-+            if (vmaw->fd < 0) {
-+                goto err;
-+            }
-+            /* try to use O_NONBLOCK and O_DIRECT */
-+            fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK);
-+            fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_DIRECT);
-+        } else  {
-+            oflags = O_NONBLOCK|O_DIRECT|O_WRONLY|O_CREAT|O_EXCL;
-+            vmaw->fd = qemu_open(filename, oflags, 0644);
-+        }
-+
-+        if (vmaw->fd < 0) {
-+            error_setg(errp, "can't open file %s - %s\n", filename,
-+                       g_strerror(errno));
-+            goto err;
-+        }
-+    }
-+
-+    /* we use O_DIRECT, so we need to align IO buffers */
-+    int i;
-+    for (i = 0; i < WRITE_BUFFERS; i++) {
-+        vmaw->aiocbs[i] = qemu_memalign(512, sizeof(VmaAIOCB));
-+        memset(vmaw->aiocbs[i], 0, sizeof(VmaAIOCB));
-+    }
-+
-+    vmaw->outbuf_count = 0;
-+    vmaw->outbuf_pos = VMA_EXTENT_HEADER_SIZE;
-+
-+    vmaw->header_blob_table_pos = 1; /* start at pos 1 */
-+
-+    qemu_co_mutex_init(&vmaw->writer_lock);
-+    qemu_co_mutex_init(&vmaw->flush_lock);
-+    qemu_co_queue_init(&vmaw->wqueue);
-+
-+    uuid_copy(vmaw->uuid, uuid);
-+
-+    return vmaw;
-+
-+err:
-+    if (vmaw) {
-+        if (vmaw->cmd) {
-+            pclose(vmaw->cmd);
-+        } else if (vmaw->fd >= 0) {
-+            close(vmaw->fd);
-+        }
-+
-+        if (vmaw->md5csum) {
-+            g_checksum_free(vmaw->md5csum);
-+        }
-+
-+        g_free(vmaw);
-+    }
-+
-+    return NULL;
-+}
-+
-+static int coroutine_fn vma_write_header(VmaWriter *vmaw)
-+{
-+    assert(vmaw);
-+    int header_clusters = 8;
-+    char buf[65536*header_clusters];
-+    VmaHeader *head = (VmaHeader *)buf;
-+
-+    int i;
-+
-+    DPRINTF("VMA WRITE HEADER\n");
-+
-+    if (vmaw->status < 0) {
-+        return vmaw->status;
-+    }
-+
-+    memset(buf, 0, sizeof(buf));
-+
-+    head->magic = VMA_MAGIC;
-+    head->version = GUINT32_TO_BE(1); /* v1 */
-+    memcpy(head->uuid, vmaw->uuid, 16);
-+
-+    time_t ctime = time(NULL);
-+    head->ctime = GUINT64_TO_BE(ctime);
-+
-+    if (!vmaw->stream_count) {
-+        return -1;
-+    }
-+
-+    for (i = 0; i < VMA_MAX_CONFIGS; i++) {
-+        head->config_names[i] = GUINT32_TO_BE(vmaw->config_names[i]);
-+        head->config_data[i] = GUINT32_TO_BE(vmaw->config_data[i]);
-+    }
-+
-+    /* 32 bytes per device (12 used currently) = 8192 bytes max */
-+    for (i = 1; i <= 254; i++) {
-+        VmaStreamInfo *si = &vmaw->stream_info[i];
-+        if (si->size) {
-+            assert(si->devname);
-+            uint32_t devname_ptr = allocate_header_string(vmaw, si->devname);
-+            if (!devname_ptr) {
-+                return -1;
-+            }
-+            head->dev_info[i].devname_ptr = GUINT32_TO_BE(devname_ptr);
-+            head->dev_info[i].size = GUINT64_TO_BE(si->size);
-+        }
-+    }
-+
-+    uint32_t header_size = sizeof(VmaHeader) + vmaw->header_blob_table_size;
-+    head->header_size = GUINT32_TO_BE(header_size);
-+
-+    if (header_size > sizeof(buf)) {
-+        return -1; /* just to be sure */
-+    }
-+
-+    uint32_t blob_buffer_offset = sizeof(VmaHeader);
-+    memcpy(buf + blob_buffer_offset, vmaw->header_blob_table,
-+           vmaw->header_blob_table_size);
-+    head->blob_buffer_offset = GUINT32_TO_BE(blob_buffer_offset);
-+    head->blob_buffer_size = GUINT32_TO_BE(vmaw->header_blob_table_pos);
-+
-+    g_checksum_reset(vmaw->md5csum);
-+    g_checksum_update(vmaw->md5csum, (const guchar *)buf, header_size);
-+    gsize csize = 16;
-+    g_checksum_get_digest(vmaw->md5csum, (guint8 *)(head->md5sum), &csize);
-+
-+    return vma_queue_write(vmaw, buf, header_size);
-+}
-+
-+static int coroutine_fn vma_writer_flush(VmaWriter *vmaw)
-+{
-+    assert(vmaw);
-+
-+    int ret;
-+    int i;
-+
-+    if (vmaw->status < 0) {
-+        return vmaw->status;
-+    }
-+
-+    if (!vmaw->header_written) {
-+        vmaw->header_written = true;
-+        ret = vma_write_header(vmaw);
-+        if (ret < 0) {
-+            vma_writer_set_error(vmaw, "vma_writer_flush: write header failed");
-+            return ret;
-+        }
-+    }
-+
-+    DPRINTF("VMA WRITE FLUSH %d %d\n", vmaw->outbuf_count, vmaw->outbuf_pos);
-+
-+
-+    VmaExtentHeader *ehead = (VmaExtentHeader *)vmaw->outbuf;
-+
-+    ehead->magic = VMA_EXTENT_MAGIC;
-+    ehead->reserved1 = 0;
-+
-+    for (i = 0; i < VMA_BLOCKS_PER_EXTENT; i++) {
-+        ehead->blockinfo[i] = GUINT64_TO_BE(vmaw->outbuf_block_info[i]);
-+    }
-+
-+    guint16 block_count = (vmaw->outbuf_pos - VMA_EXTENT_HEADER_SIZE) /
-+        VMA_BLOCK_SIZE;
-+
-+    ehead->block_count = GUINT16_TO_BE(block_count);
-+
-+    memcpy(ehead->uuid, vmaw->uuid, sizeof(ehead->uuid));
-+    memset(ehead->md5sum, 0, sizeof(ehead->md5sum));
-+
-+    g_checksum_reset(vmaw->md5csum);
-+    g_checksum_update(vmaw->md5csum, vmaw->outbuf, VMA_EXTENT_HEADER_SIZE);
-+    gsize csize = 16;
-+    g_checksum_get_digest(vmaw->md5csum, ehead->md5sum, &csize);
-+
-+    int bytes = vmaw->outbuf_pos;
-+    ret = vma_queue_write(vmaw, vmaw->outbuf, bytes);
-+    if (ret != bytes) {
-+        vma_writer_set_error(vmaw, "vma_writer_flush: failed write");
-+    }
-+
-+    vmaw->outbuf_count = 0;
-+    vmaw->outbuf_pos = VMA_EXTENT_HEADER_SIZE;
-+
-+    for (i = 0; i < VMA_BLOCKS_PER_EXTENT; i++) {
-+        vmaw->outbuf_block_info[i] = 0;
-+    }
-+
-+    return vmaw->status;
-+}
-+
-+static int vma_count_open_streams(VmaWriter *vmaw)
-+{
-+    g_assert(vmaw != NULL);
-+
-+    int i;
-+    int open_drives = 0;
-+    for (i = 0; i <= 255; i++) {
-+        if (vmaw->stream_info[i].size && !vmaw->stream_info[i].finished) {
-+            open_drives++;
-+        }
-+    }
-+
-+    return open_drives;
-+}
-+
-+/**
-+ * all jobs should call this when there is no more data
-+ * Returns: number of remaining stream (0 ==> finished)
-+ */
-+int coroutine_fn
-+vma_writer_close_stream(VmaWriter *vmaw, uint8_t dev_id)
-+{
-+    g_assert(vmaw != NULL);
-+
-+    DPRINTF("vma_writer_set_status %d\n", dev_id);
-+    if (!vmaw->stream_info[dev_id].size) {
-+        vma_writer_set_error(vmaw, "vma_writer_close_stream: "
-+                             "no such stream %d", dev_id);
-+        return -1;
-+    }
-+    if (vmaw->stream_info[dev_id].finished) {
-+        vma_writer_set_error(vmaw, "vma_writer_close_stream: "
-+                             "stream already closed %d", dev_id);
-+        return -1;
-+    }
-+
-+    vmaw->stream_info[dev_id].finished = true;
-+
-+    int open_drives = vma_count_open_streams(vmaw);
-+
-+    if (open_drives <= 0) {
-+        DPRINTF("vma_writer_set_status all drives completed\n");
-+        qemu_co_mutex_lock(&vmaw->flush_lock);
-+        int ret = vma_writer_flush(vmaw);
-+        qemu_co_mutex_unlock(&vmaw->flush_lock);
-+        if (ret < 0) {
-+            vma_writer_set_error(vmaw, "vma_writer_close_stream: flush failed");
-+        }
-+    }
-+
-+    return open_drives;
-+}
-+
-+int vma_writer_get_status(VmaWriter *vmaw, VmaStatus *status)
-+{
-+    int i;
-+
-+    g_assert(vmaw != NULL);
-+
-+    if (status) {
-+        status->status = vmaw->status;
-+        g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
-+        for (i = 0; i <= 255; i++) {
-+            status->stream_info[i] = vmaw->stream_info[i];
-+        }
-+
-+        uuid_unparse_lower(vmaw->uuid, status->uuid_str);
-+    }
-+
-+    status->closed = vmaw->closed;
-+
-+    return vmaw->status;
-+}
-+
-+static int vma_writer_get_buffer(VmaWriter *vmaw)
-+{
-+    int ret = 0;
-+
-+    qemu_co_mutex_lock(&vmaw->flush_lock);
-+
-+    /* wait until buffer is available */
-+    while (vmaw->outbuf_count >= (VMA_BLOCKS_PER_EXTENT - 1)) {
-+        ret = vma_writer_flush(vmaw);
-+        if (ret < 0) {
-+            vma_writer_set_error(vmaw, "vma_writer_get_buffer: flush failed");
-+            break;
-+        }
-+    }
-+
-+    qemu_co_mutex_unlock(&vmaw->flush_lock);
-+
-+    return ret;
-+}
-+
-+
-+int64_t coroutine_fn
-+vma_writer_write(VmaWriter *vmaw, uint8_t dev_id, int64_t cluster_num,
-+                 unsigned char *buf, size_t *zero_bytes)
-+{
-+    g_assert(vmaw != NULL);
-+    g_assert(zero_bytes != NULL);
-+
-+    *zero_bytes = 0;
-+
-+    if (vmaw->status < 0) {
-+        return vmaw->status;
-+    }
-+
-+    if (!dev_id || !vmaw->stream_info[dev_id].size) {
-+        vma_writer_set_error(vmaw, "vma_writer_write: "
-+                             "no such stream %d", dev_id);
-+        return -1;
-+    }
-+
-+    if (vmaw->stream_info[dev_id].finished) {
-+        vma_writer_set_error(vmaw, "vma_writer_write: "
-+                             "stream already closed %d", dev_id);
-+        return -1;
-+    }
-+
-+
-+    if (cluster_num >= (((uint64_t)1)<<32)) {
-+        vma_writer_set_error(vmaw, "vma_writer_write: "
-+                             "cluster number out of range");
-+        return -1;
-+    }
-+
-+    if (dev_id == vmaw->vmstate_stream) {
-+        if (cluster_num != vmaw->vmstate_clusters) {
-+            vma_writer_set_error(vmaw, "vma_writer_write: "
-+                                 "non sequential vmstate write");
-+        }
-+        vmaw->vmstate_clusters++;
-+    } else if (cluster_num >= vmaw->stream_info[dev_id].cluster_count) {
-+        vma_writer_set_error(vmaw, "vma_writer_write: cluster number too big");
-+        return -1;
-+    }
-+
-+    /* wait until buffer is available */
-+    if (vma_writer_get_buffer(vmaw) < 0) {
-+        vma_writer_set_error(vmaw, "vma_writer_write: "
-+                             "vma_writer_get_buffer failed");
-+        return -1;
-+    }
-+
-+    DPRINTF("VMA WRITE %d %zd\n", dev_id, cluster_num);
-+
-+    uint16_t mask = 0;
-+
-+    if (buf) {
-+        int i;
-+        int bit = 1;
-+        for (i = 0; i < 16; i++) {
-+            unsigned char *vmablock = buf + (i*VMA_BLOCK_SIZE);
-+            if (!buffer_is_zero(vmablock, VMA_BLOCK_SIZE)) {
-+                mask |= bit;
-+                memcpy(vmaw->outbuf + vmaw->outbuf_pos, vmablock,
-+                       VMA_BLOCK_SIZE);
-+                vmaw->outbuf_pos += VMA_BLOCK_SIZE;
-+            } else {
-+                DPRINTF("VMA WRITE %zd ZERO BLOCK %d\n", cluster_num, i);
-+                vmaw->stream_info[dev_id].zero_bytes += VMA_BLOCK_SIZE;
-+                *zero_bytes += VMA_BLOCK_SIZE;
-+            }
-+
-+            bit = bit << 1;
-+        }
-+    } else {
-+        DPRINTF("VMA WRITE %zd ZERO CLUSTER\n", cluster_num);
-+        vmaw->stream_info[dev_id].zero_bytes += VMA_CLUSTER_SIZE;
-+        *zero_bytes += VMA_CLUSTER_SIZE;
-+    }
-+
-+    uint64_t block_info = ((uint64_t)mask) << (32+16);
-+    block_info |= ((uint64_t)dev_id) << 32;
-+    block_info |= (cluster_num & 0xffffffff);
-+    vmaw->outbuf_block_info[vmaw->outbuf_count] = block_info;
-+
-+    DPRINTF("VMA WRITE MASK %zd %zx\n", cluster_num, block_info);
-+
-+    vmaw->outbuf_count++;
-+
-+    /** NOTE: We allways write whole clusters, but we correctly set
-+     * transferred bytes. So transferred == size when when everything
-+     * went OK.
-+     */
-+    size_t transferred = VMA_CLUSTER_SIZE;
-+
-+    if (dev_id != vmaw->vmstate_stream) {
-+        uint64_t last = (cluster_num + 1) * VMA_CLUSTER_SIZE;
-+        if (last > vmaw->stream_info[dev_id].size) {
-+            uint64_t diff = last - vmaw->stream_info[dev_id].size;
-+            if (diff >= VMA_CLUSTER_SIZE) {
-+                vma_writer_set_error(vmaw, "vma_writer_write: "
-+                                     "read after last cluster");
-+                return -1;
-+            }
-+            transferred -= diff;
-+        }
-+    }
-+
-+    vmaw->stream_info[dev_id].transferred += transferred;
-+
-+    return transferred;
-+}
-+
-+int vma_writer_close(VmaWriter *vmaw, Error **errp)
-+{
-+    g_assert(vmaw != NULL);
-+
-+    int i;
-+
-+    vma_queue_flush(vmaw);
-+
-+    /* this should not happen - just to be sure */
-+    while (!qemu_co_queue_empty(&vmaw->wqueue)) {
-+        DPRINTF("vma_writer_close wait\n");
-+        co_sleep_ns(rt_clock, 1000000);
-+    }
-+
-+    if (vmaw->cmd) {
-+        if (pclose(vmaw->cmd) < 0) {
-+            vma_writer_set_error(vmaw, "vma_writer_close: "
-+                                 "pclose failed - %s", g_strerror(errno));
-+        }
-+    } else {
-+        if (close(vmaw->fd) < 0) {
-+            vma_writer_set_error(vmaw, "vma_writer_close: "
-+                                 "close failed - %s", g_strerror(errno));
-+        }
-+    }
-+
-+    for (i = 0; i <= 255; i++) {
-+        VmaStreamInfo *si = &vmaw->stream_info[i];
-+        if (si->size) {
-+            if (!si->finished) {
-+                vma_writer_set_error(vmaw, "vma_writer_close: "
-+                                     "detected open stream '%s'", si->devname);
-+            } else if ((si->transferred != si->size) &&
-+                       (i != vmaw->vmstate_stream)) {
-+                vma_writer_set_error(vmaw, "vma_writer_close: "
-+                                     "incomplete stream '%s' (%zd != %zd)",
-+                                     si->devname, si->transferred, si->size);
-+            }
-+        }
-+    }
-+
-+    for (i = 0; i <= 255; i++) {
-+        vmaw->stream_info[i].finished = 1; /* mark as closed */
-+    }
-+
-+    vmaw->closed = 1;
-+
-+    if (vmaw->status < 0 && *errp == NULL) {
-+        error_setg(errp, "%s", vmaw->errmsg);
-+    }
-+
-+    return vmaw->status;
-+}
-+
-+void vma_writer_destroy(VmaWriter *vmaw)
-+{
-+    assert(vmaw);
-+
-+    int i;
-+
-+    for (i = 0; i <= 255; i++) {
-+        if (vmaw->stream_info[i].devname) {
-+            g_free(vmaw->stream_info[i].devname);
-+        }
-+    }
-+
-+    if (vmaw->md5csum) {
-+        g_checksum_free(vmaw->md5csum);
-+    }
-+
-+    for (i = 0; i < WRITE_BUFFERS; i++) {
-+        free(vmaw->aiocbs[i]);
-+    }
-+
-+    g_free(vmaw);
-+}
-+
-+/* backup driver plugin */
-+
-+static int vma_dump_cb(void *opaque, uint8_t dev_id, int64_t cluster_num,
-+                       unsigned char *buf, size_t *zero_bytes)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    return vma_writer_write(vmaw, dev_id, cluster_num, buf, zero_bytes);
-+}
-+
-+static int vma_close_cb(void *opaque, Error **errp)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    int res = vma_writer_close(vmaw, errp);
-+    vma_writer_destroy(vmaw);
-+
-+    return res;
-+}
-+
-+static int vma_complete_cb(void *opaque, uint8_t dev_id, int ret)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    if (ret < 0) {
-+        vma_writer_set_error(vmaw, "backup_complete_cb %d", ret);
-+    }
-+
-+    return vma_writer_close_stream(vmaw, dev_id);
-+}
-+
-+static int vma_register_stream_cb(void *opaque, const char *devname,
-+                                  size_t size)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    return vma_writer_register_stream(vmaw, devname, size);
-+}
-+
-+static int vma_register_config_cb(void *opaque, const char *name,
-+                                  gpointer data, size_t data_len)
-+{
-+    VmaWriter *vmaw = opaque;
-+
-+    return vma_writer_add_config(vmaw, name, data, data_len);
-+}
-+
-+static void *vma_open_cb(const char *filename, uuid_t uuid, Error **errp)
-+{
-+    return vma_writer_create(filename, uuid, errp);
-+}
-+
-+const BackupDriver backup_vma_driver = {
-+    .format = "vma",
-+    .open = vma_open_cb,
-+    .close = vma_close_cb,
-+    .register_config = vma_register_config_cb,
-+    .register_stream = vma_register_stream_cb,
-+    .dump = vma_dump_cb,
-+    .complete = vma_complete_cb,
-+};
-+
-diff --git a/vma.c b/vma.c
-new file mode 100644
-index 0000000..6633aa5
---- /dev/null
-+++ b/vma.c
-@@ -0,0 +1,561 @@
-+/*
-+ * VMA: Virtual Machine Archive
-+ *
-+ * Copyright (C) 2012 Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
-+ * See the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#include <stdio.h>
-+#include <errno.h>
-+#include <unistd.h>
-+#include <stdio.h>
-+#include <string.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <glib.h>
-+
-+#include "qemu-common.h"
-+#include "qemu/error-report.h"
-+#include "vma.h"
-+#include "block/block.h"
-+
-+static void help(void)
-+{
-+    const char *help_msg =
-+        "usage: vma command [command options]\n"
-+        "\n"
-+        "vma list <filename>\n"
-+        "vma create <filename> [-c config] <archive> pathname ...\n"
-+        "vma extract <filename> [-r] <targetdir>\n"
-+        ;
-+
-+    printf("%s", help_msg);
-+    exit(1);
-+}
-+
-+static const char *extract_devname(const char *path, char **devname, int index)
-+{
-+    assert(path);
-+
-+    const char *sep = strchr(path, '=');
-+
-+    if (sep) {
-+        *devname = g_strndup(path, sep - path);
-+        path = sep + 1;
-+    } else {
-+        if (index >= 0) {
-+            *devname = g_strdup_printf("disk%d", index);
-+        } else {
-+            *devname = NULL;
-+        }
-+    }
-+
-+    return path;
-+}
-+
-+static void print_content(VmaReader *vmar)
-+{
-+    assert(vmar);
-+
-+    VmaHeader *head = vma_reader_get_header(vmar);
-+
-+    GList *l = vma_reader_get_config_data(vmar);
-+    while (l && l->data) {
-+        VmaConfigData *cdata = (VmaConfigData *)l->data;
-+        l = g_list_next(l);
-+        printf("CFG: size: %d name: %s\n", cdata->len, cdata->name);
-+    }
-+
-+    int i;
-+    VmaDeviceInfo *di;
-+    for (i = 1; i < 255; i++) {
-+        di = vma_reader_get_device_info(vmar, i);
-+        if (di) {
-+            if (strcmp(di->devname, "vmstate") == 0) {
-+                printf("VMSTATE: dev_id=%d memory: %zd\n", i, di->size);
-+            } else {
-+                printf("DEV: dev_id=%d size: %zd devname: %s\n",
-+                       i, di->size, di->devname);
-+            }
-+        }
-+    }
-+    /* ctime is the last entry we print */
-+    printf("CTIME: %s", ctime(&head->ctime));
-+    fflush(stdout);
-+}
-+
-+static int list_content(int argc, char **argv)
-+{
-+    int c, ret = 0;
-+    const char *filename;
-+
-+    for (;;) {
-+        c = getopt(argc, argv, "h");
-+        if (c == -1) {
-+            break;
-+        }
-+        switch (c) {
-+        case '?':
-+        case 'h':
-+            help();
-+            break;
-+        default:
-+            g_assert_not_reached();
-+        }
-+    }
-+
-+    /* Get the filename */
-+    if ((optind + 1) != argc) {
-+        help();
-+    }
-+    filename = argv[optind++];
-+
-+    Error *errp = NULL;
-+    VmaReader *vmar = vma_reader_create(filename, &errp);
-+
-+    if (!vmar) {
-+        g_error("%s", error_get_pretty(errp));
-+    }
-+
-+    print_content(vmar);
-+
-+    vma_reader_destroy(vmar);
-+
-+    return ret;
-+}
-+
-+typedef struct RestoreMap {
-+    char *devname;
-+    char *path;
-+    bool write_zero;
-+} RestoreMap;
-+
-+static int extract_content(int argc, char **argv)
-+{
-+    int c, ret = 0;
-+    int verbose = 0;
-+    const char *filename;
-+    const char *dirname;
-+    const char *readmap = NULL;
-+
-+    for (;;) {
-+        c = getopt(argc, argv, "hvr:");
-+        if (c == -1) {
-+            break;
-+        }
-+        switch (c) {
-+        case '?':
-+        case 'h':
-+            help();
-+            break;
-+        case 'r':
-+            readmap = optarg;
-+            break;
-+        case 'v':
-+            verbose = 1;
-+            break;
-+        default:
-+            help();
-+        }
-+    }
-+
-+    /* Get the filename */
-+    if ((optind + 2) != argc) {
-+        help();
-+    }
-+    filename = argv[optind++];
-+    dirname = argv[optind++];
-+
-+    Error *errp = NULL;
-+    VmaReader *vmar = vma_reader_create(filename, &errp);
-+
-+    if (!vmar) {
-+        g_error("%s", error_get_pretty(errp));
-+    }
-+
-+    if (mkdir(dirname, 0777) < 0) {
-+        g_error("unable to create target directory %s - %s",
-+                dirname, g_strerror(errno));
-+    }
-+
-+    GList *l = vma_reader_get_config_data(vmar);
-+    while (l && l->data) {
-+        VmaConfigData *cdata = (VmaConfigData *)l->data;
-+        l = g_list_next(l);
-+        char *cfgfn = g_strdup_printf("%s/%s", dirname, cdata->name);
-+        GError *err = NULL;
-+        if (!g_file_set_contents(cfgfn, (gchar *)cdata->data, cdata->len,
-+                                 &err)) {
-+            g_error("unable to write file: %s", err->message);
-+        }
-+    }
-+
-+    GHashTable *devmap = g_hash_table_new(g_str_hash, g_str_equal);
-+
-+    if (readmap) {
-+        print_content(vmar);
-+
-+        FILE *map = fopen(readmap, "r");
-+        if (!map) {
-+            g_error("unable to open fifo %s - %s", readmap, g_strerror(errno));
-+        }
-+
-+        while (1) {
-+            char inbuf[8192];
-+            char *line = fgets(inbuf, sizeof(inbuf), map);
-+            if (!line || line[0] == '\0' || !strcmp(line, "done\n")) {
-+                break;
-+            }
-+            int len = strlen(line);
-+            if (line[len - 1] == '\n') {
-+                line[len - 1] = '\0';
-+                if (len == 1) {
-+                    break;
-+                }
-+            }
-+
-+            const char *path;
-+            bool write_zero;
-+            if (line[0] == '0' && line[1] == ':') {
-+                path = inbuf + 2;
-+                write_zero = false;
-+            } else if (line[0] == '1' && line[1] == ':') {
-+                path = inbuf + 2;
-+                write_zero = true;
-+            } else {
-+                g_error("read map failed - parse error ('%s')", inbuf);
-+            }
-+
-+            char *devname = NULL;
-+            path = extract_devname(path, &devname, -1);
-+            if (!devname) {
-+                g_error("read map failed - no dev name specified ('%s')",
-+                        inbuf);
-+            }
-+
-+            RestoreMap *map = g_new0(RestoreMap, 1);
-+            map->devname = g_strdup(devname);
-+            map->path = g_strdup(path);
-+            map->write_zero = write_zero;
-+
-+            g_hash_table_insert(devmap, map->devname, map);
-+
-+        };
-+    }
-+
-+    int i;
-+    int vmstate_fd = -1;
-+    guint8 vmstate_stream = 0;
-+
-+    for (i = 1; i < 255; i++) {
-+        VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
-+        if (di && (strcmp(di->devname, "vmstate") == 0)) {
-+            vmstate_stream = i;
-+            char *statefn = g_strdup_printf("%s/vmstate.bin", dirname);
-+            vmstate_fd = open(statefn, O_WRONLY|O_CREAT|O_EXCL, 0644);
-+            if (vmstate_fd < 0) {
-+                g_error("create vmstate file '%s' failed - %s", statefn,
-+                        g_strerror(errno));
-+            }
-+            g_free(statefn);
-+        } else if (di) {
-+            char *devfn = NULL;
-+            int flags = BDRV_O_RDWR|BDRV_O_CACHE_WB;
-+            bool write_zero = true;
-+
-+            if (readmap) {
-+                RestoreMap *map;
-+                map = (RestoreMap *)g_hash_table_lookup(devmap, di->devname);
-+                if (map == NULL) {
-+                    g_error("no device name mapping for %s", di->devname);
-+                }
-+                devfn = map->path;
-+                write_zero = map->write_zero;
-+            } else {
-+                devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
-+                                        dirname, di->devname);
-+                printf("DEVINFO %s %zd\n", devfn, di->size);
-+
-+                bdrv_img_create(devfn, "raw", NULL, NULL, NULL, di->size,
-+                                flags, &errp);
-+                if (error_is_set(&errp)) {
-+                    g_error("can't create file %s: %s", devfn,
-+                            error_get_pretty(errp));
-+                }
-+
-+                /* Note: we created an empty file above, so there is no
-+                 * need to write zeroes (so we generate a sparse file)
-+                 */
-+                write_zero = false;
-+            }
-+
-+            BlockDriverState *bs = bdrv_new(di->devname);
-+            if (bdrv_open(bs, devfn, flags, NULL)) {
-+                g_error("can't open file %s", devfn);
-+            }
-+            if (vma_reader_register_bs(vmar, i, bs, write_zero, &errp) < 0) {
-+                g_error("%s", error_get_pretty(errp));
-+            }
-+
-+            if (!readmap) {
-+                g_free(devfn);
-+            }
-+        }
-+    }
-+
-+    if (vma_reader_restore(vmar, vmstate_fd, verbose, &errp) < 0) {
-+        g_error("restore failed - %s", error_get_pretty(errp));
-+    }
-+
-+    if (!readmap) {
-+        for (i = 1; i < 255; i++) {
-+            VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
-+            if (di && (i != vmstate_stream)) {
-+                char *tmpfn = g_strdup_printf("%s/tmp-disk-%s.raw",
-+                                              dirname, di->devname);
-+                char *fn = g_strdup_printf("%s/disk-%s.raw",
-+                                           dirname, di->devname);
-+                if (rename(tmpfn, fn) != 0) {
-+                    g_error("rename %s to %s failed - %s",
-+                            tmpfn, fn, g_strerror(errno));
-+                }
-+            }
-+        }
-+    }
-+
-+    vma_reader_destroy(vmar);
-+
-+    bdrv_close_all();
-+
-+    return ret;
-+}
-+
-+typedef struct BackupCB {
-+    VmaWriter *vmaw;
-+    uint8_t dev_id;
-+} BackupCB;
-+
-+static int backup_dump_cb(void *opaque, BlockDriverState *bs,
-+                          int64_t cluster_num, unsigned char *buf)
-+{
-+    BackupCB *bcb = opaque;
-+    size_t zb = 0;
-+    if (vma_writer_write(bcb->vmaw, bcb->dev_id, cluster_num, buf, &zb) < 0) {
-+        g_warning("backup_dump_cb vma_writer_write failed");
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+static void backup_complete_cb(void *opaque, int ret)
-+{
-+    BackupCB *bcb = opaque;
-+
-+    if (ret < 0) {
-+        vma_writer_set_error(bcb->vmaw, "backup_complete_cb %d", ret);
-+    }
-+
-+    if (vma_writer_close_stream(bcb->vmaw, bcb->dev_id) <= 0) {
-+        Error *err = NULL;
-+        if (vma_writer_close(bcb->vmaw, &err) != 0) {
-+            g_warning("vma_writer_close failed %s", error_get_pretty(err));
-+        }
-+    }
-+}
-+
-+static int create_archive(int argc, char **argv)
-+{
-+    int i, c, res;
-+    int verbose = 0;
-+    const char *archivename;
-+    GList *config_files = NULL;
-+
-+    for (;;) {
-+        c = getopt(argc, argv, "hvc:");
-+        if (c == -1) {
-+            break;
-+        }
-+        switch (c) {
-+        case '?':
-+        case 'h':
-+            help();
-+            break;
-+        case 'c':
-+            config_files = g_list_append(config_files, optarg);
-+            break;
-+        case 'v':
-+            verbose = 1;
-+            break;
-+        default:
-+            g_assert_not_reached();
-+        }
-+    }
-+
-+
-+    /* make sure we have archive name and at least one path */
-+    if ((optind + 2) > argc) {
-+        help();
-+    }
-+
-+    archivename = argv[optind++];
-+
-+    uuid_t uuid;
-+    uuid_generate(uuid);
-+
-+    Error *local_err = NULL;
-+    VmaWriter *vmaw = vma_writer_create(archivename, uuid, &local_err);
-+
-+    if (vmaw == NULL) {
-+        g_error("%s", error_get_pretty(local_err));
-+    }
-+
-+    GList *l = config_files;
-+    while (l && l->data) {
-+        char *name = l->data;
-+        char *cdata = NULL;
-+        gsize clen = 0;
-+        GError *err = NULL;
-+        if (!g_file_get_contents(name, &cdata, &clen, &err)) {
-+            unlink(archivename);
-+            g_error("Unable to read file: %s", err->message);
-+        }
-+
-+        if (vma_writer_add_config(vmaw, name, cdata, clen) != 0) {
-+            unlink(archivename);
-+            g_error("Unable to append config data %s (len = %zd)",
-+                    name, clen);
-+        }
-+        l = g_list_next(l);
-+    }
-+
-+    int ind = 0;
-+    while (optind < argc) {
-+        const char *path = argv[optind++];
-+        char *devname = NULL;
-+        path = extract_devname(path, &devname, ind++);
-+
-+        BlockDriver *drv = NULL;
-+        BlockDriverState *bs = bdrv_new(devname);
-+
-+        res = bdrv_open(bs, path, BDRV_O_CACHE_WB , drv);
-+        if (res < 0) {
-+            unlink(archivename);
-+            g_error("bdrv_open '%s' failed", path);
-+        }
-+        int64_t size = bdrv_getlength(bs);
-+        int dev_id = vma_writer_register_stream(vmaw, devname, size);
-+        if (dev_id <= 0) {
-+            unlink(archivename);
-+            g_error("vma_writer_register_stream '%s' failed", devname);
-+        }
-+
-+        BackupCB *bcb = g_new0(BackupCB, 1);
-+        bcb->vmaw = vmaw;
-+        bcb->dev_id = dev_id;
-+
-+        if (backup_job_create(bs, backup_dump_cb, backup_complete_cb,
-+                              bcb, 0) < 0) {
-+            unlink(archivename);
-+            g_error("backup_job_start failed");
-+        } else {
-+            backup_job_start(bs, false);
-+        }
-+    }
-+
-+    VmaStatus vmastat;
-+    int percent = 0;
-+    int last_percent = -1;
-+
-+    while (1) {
-+        main_loop_wait(false);
-+        vma_writer_get_status(vmaw, &vmastat);
-+
-+        if (verbose) {
-+
-+            uint64_t total = 0;
-+            uint64_t transferred = 0;
-+            uint64_t zero_bytes = 0;
-+
-+            int i;
-+            for (i = 0; i < 256; i++) {
-+                if (vmastat.stream_info[i].size) {
-+                    total += vmastat.stream_info[i].size;
-+                    transferred += vmastat.stream_info[i].transferred;
-+                    zero_bytes += vmastat.stream_info[i].zero_bytes;
-+                }
-+            }
-+            percent = (transferred*100)/total;
-+            if (percent != last_percent) {
-+                fprintf(stderr, "progress %d%% %zd/%zd %zd\n", percent,
-+                        transferred, total, zero_bytes);
-+                fflush(stderr);
-+
-+                last_percent = percent;
-+            }
-+        }
-+
-+        if (vmastat.closed) {
-+            break;
-+        }
-+    }
-+
-+    bdrv_drain_all();
-+
-+    vma_writer_get_status(vmaw, &vmastat);
-+
-+    if (verbose) {
-+        for (i = 0; i < 256; i++) {
-+            VmaStreamInfo *si = &vmastat.stream_info[i];
-+            if (si->size) {
-+                fprintf(stderr, "image %s: size=%zd zeros=%zd saved=%zd\n",
-+                        si->devname, si->size, si->zero_bytes,
-+                        si->size - si->zero_bytes);
-+            }
-+        }
-+    }
-+
-+    if (vmastat.status < 0) {
-+        unlink(archivename);
-+        g_error("creating vma archive failed");
-+    }
-+
-+    return 0;
-+}
-+
-+int main(int argc, char **argv)
-+{
-+    const char *cmdname;
-+
-+    error_set_progname(argv[0]);
-+
-+    qemu_init_main_loop();
-+
-+    bdrv_init();
-+
-+    if (argc < 2) {
-+        help();
-+    }
-+
-+    cmdname = argv[1];
-+    argc--; argv++;
-+
-+
-+    if (!strcmp(cmdname, "list")) {
-+        return list_content(argc, argv);
-+    } else if (!strcmp(cmdname, "create")) {
-+        return create_archive(argc, argv);
-+    } else if (!strcmp(cmdname, "extract")) {
-+        return extract_content(argc, argv);
-+    }
-+
-+    help();
-+    return 0;
-+}
-diff --git a/vma.h b/vma.h
-new file mode 100644
-index 0000000..76d0dc8
---- /dev/null
-+++ b/vma.h
-@@ -0,0 +1,145 @@
-+/*
-+ * VMA: Virtual Machine Archive
-+ *
-+ * Copyright (C) Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
-+ * See the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#ifndef BACKUP_VMA_H
-+#define BACKUP_VMA_H
-+
-+#include "backup.h"
-+#include "error.h"
-+
-+#define VMA_BLOCK_BITS 12
-+#define VMA_BLOCK_SIZE (1<<VMA_BLOCK_BITS)
-+#define VMA_CLUSTER_BITS (VMA_BLOCK_BITS+4)
-+#define VMA_CLUSTER_SIZE (1<<VMA_CLUSTER_BITS)
-+
-+#if VMA_CLUSTER_SIZE != 65536
-+#error unexpected cluster size
-+#endif
-+
-+#define VMA_EXTENT_HEADER_SIZE 512
-+#define VMA_BLOCKS_PER_EXTENT 59
-+#define VMA_MAX_CONFIGS 256
-+
-+#define VMA_MAX_EXTENT_SIZE \
-+    (VMA_EXTENT_HEADER_SIZE+VMA_CLUSTER_SIZE*VMA_BLOCKS_PER_EXTENT)
-+#if VMA_MAX_EXTENT_SIZE != 3867136
-+#error unexpected VMA_EXTENT_SIZE
-+#endif
-+
-+/* File Format Definitions */
-+
-+#define VMA_MAGIC (GUINT32_TO_BE(('V'<<24)|('M'<<16)|('A'<<8)|0x00))
-+#define VMA_EXTENT_MAGIC (GUINT32_TO_BE(('V'<<24)|('M'<<16)|('A'<<8)|'E'))
-+
-+typedef struct VmaDeviceInfoHeader {
-+    uint32_t devname_ptr; /* offset into blob_buffer table */
-+    uint32_t reserved0;
-+    uint64_t size; /* device size in bytes */
-+    uint64_t reserved1;
-+    uint64_t reserved2;
-+} VmaDeviceInfoHeader;
-+
-+typedef struct VmaHeader {
-+    uint32_t magic;
-+    uint32_t version;
-+    unsigned char uuid[16];
-+    int64_t ctime;
-+    unsigned char md5sum[16];
-+
-+    uint32_t blob_buffer_offset;
-+    uint32_t blob_buffer_size;
-+    uint32_t header_size;
-+
-+    unsigned char reserved[1984];
-+
-+    uint32_t config_names[VMA_MAX_CONFIGS]; /* offset into blob_buffer table */
-+    uint32_t config_data[VMA_MAX_CONFIGS];  /* offset into blob_buffer table */
-+
-+    VmaDeviceInfoHeader dev_info[256];
-+} VmaHeader;
-+
-+typedef struct VmaExtentHeader {
-+    uint32_t magic;
-+    uint16_t reserved1;
-+    uint16_t block_count;
-+    unsigned char uuid[16];
-+    unsigned char md5sum[16];
-+    uint64_t blockinfo[VMA_BLOCKS_PER_EXTENT];
-+} VmaExtentHeader;
-+
-+/* functions/definitions to read/write vma files */
-+
-+typedef struct VmaReader VmaReader;
-+
-+typedef struct VmaWriter VmaWriter;
-+
-+typedef struct VmaConfigData {
-+    const char *name;
-+    const void *data;
-+    uint32_t len;
-+} VmaConfigData;
-+
-+typedef struct VmaStreamInfo {
-+    uint64_t size;
-+    uint64_t cluster_count;
-+    uint64_t transferred;
-+    uint64_t zero_bytes;
-+    int finished;
-+    char *devname;
-+} VmaStreamInfo;
-+
-+typedef struct VmaStatus {
-+    int status;
-+    bool closed;
-+    char errmsg[8192];
-+    char uuid_str[37];
-+    VmaStreamInfo stream_info[256];
-+} VmaStatus;
-+
-+typedef struct VmaDeviceInfo {
-+    uint64_t size; /* device size in bytes */
-+    const char *devname;
-+} VmaDeviceInfo;
-+
-+extern const BackupDriver backup_vma_driver;
-+
-+VmaWriter *vma_writer_create(const char *filename, uuid_t uuid, Error **errp);
-+int vma_writer_close(VmaWriter *vmaw, Error **errp);
-+void vma_writer_destroy(VmaWriter *vmaw);
-+int vma_writer_add_config(VmaWriter *vmaw, const char *name, gpointer data,
-+                          size_t len);
-+int vma_writer_register_stream(VmaWriter *vmaw, const char *devname,
-+                               size_t size);
-+
-+int64_t coroutine_fn vma_writer_write(VmaWriter *vmaw, uint8_t dev_id,
-+                                      int64_t cluster_num, unsigned char *buf,
-+                                      size_t *zero_bytes);
-+
-+int coroutine_fn vma_writer_close_stream(VmaWriter *vmaw, uint8_t dev_id);
-+
-+int vma_writer_get_status(VmaWriter *vmaw, VmaStatus *status);
-+void vma_writer_set_error(VmaWriter *vmaw, const char *fmt, ...);
-+
-+
-+VmaReader *vma_reader_create(const char *filename, Error **errp);
-+void vma_reader_destroy(VmaReader *vmar);
-+VmaHeader *vma_reader_get_header(VmaReader *vmar);
-+GList *vma_reader_get_config_data(VmaReader *vmar);
-+VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id);
-+int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id,
-+                           BlockDriverState *bs, bool write_zeroes,
-+                           Error **errp);
-+int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
-+                       Error **errp);
-+
-+#endif /* BACKUP_VMA_H */
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0005-add-regression-tests-for-backup.patch b/debian/patches/old/0005-add-regression-tests-for-backup.patch
deleted file mode 100644 (file)
index fc0679a..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
-From 348a009b2c63ac4d9b6dad7fe2169272c46221f2 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Wed, 14 Nov 2012 09:57:04 +0100
-Subject: [PATCH v5 5/6] add regression tests for backup
-
-Simple regression tests using vma-reader and vma-writer.
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- tests/Makefile      |   11 +-
- tests/backup-test.c |  529 +++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 538 insertions(+), 2 deletions(-)
- create mode 100644 tests/backup-test.c
-
-diff --git a/tests/Makefile b/tests/Makefile
-index 567e36e..136be84 100644
---- a/tests/Makefile
-+++ b/tests/Makefile
-@@ -59,6 +59,8 @@ gcov-files-test-mul64-y = util/host-utils.c
- check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
-+check-backup-y = tests/backup-test$(EXESUF)
-+
- # All QTests for now are POSIX-only, but the dependencies are
- # really in libqtest, not in the testcases themselves.
- check-qtest-i386-y = tests/fdc-test$(EXESUF)
-@@ -102,6 +104,7 @@ tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(block-obj-y) libqemuutil
- tests/test-aio$(EXESUF): tests/test-aio.o $(block-obj-y) libqemuutil.a libqemustub.a
- tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(block-obj-y) libqemuutil.a libqemustub.a
- tests/test-iov$(EXESUF): tests/test-iov.o libqemuutil.a
-+tests/backup-test$(EXESUF): tests/backup-test.o vma-reader.o $(block-obj-y) libqemuutil.a libqemustub.a
- tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o libqemuutil.a libqemustub.a
- tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o
- tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o xbzrle.o page_cache.o libqemuutil.a
-@@ -213,10 +216,14 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF)
- # Consolidated targets
--.PHONY: check-qtest check-unit check
-+.PHONY: check-backup check-qtest check-unit check
- check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
- check-unit: $(patsubst %,check-%, $(check-unit-y))
- check-block: $(patsubst %,check-%, $(check-block-y))
--check: check-unit check-qtest
-+
-+check-backup: tests/backup-test$(EXESUF)
-+      $<
-+
-+check: check-unit check-qtest check-backup
- -include $(wildcard tests/*.d)
-diff --git a/tests/backup-test.c b/tests/backup-test.c
-new file mode 100644
-index 0000000..47a9664
---- /dev/null
-+++ b/tests/backup-test.c
-@@ -0,0 +1,529 @@
-+/*
-+ * QEMU backup test suit
-+ *
-+ * Copyright (C) 2013 Proxmox Server Solutions
-+ *
-+ * Authors:
-+ *  Dietmar Maurer (dietmar@proxmox.com)
-+ *
-+ * This work is licensed under the terms of the GNU GPL, version 2.  See
-+ * the COPYING file in the top-level directory.
-+ *
-+ */
-+
-+#include <sys/time.h>
-+#include <sys/types.h>
-+#include <stdarg.h>
-+#include <stdio.h>
-+#include <getopt.h>
-+#include <libgen.h>
-+
-+#include "qemu-common.h"
-+#include "block/block.h"
-+
-+#include "vma.h"
-+
-+static int opt_debug;
-+static int opt_loop;
-+
-+#define DPRINTF(fmt, ...) \
-+    do { if (opt_debug) { printf(fmt, ## __VA_ARGS__); } } while (0)
-+
-+#define CLUSTER(x) (x*BACKUP_CLUSTER_SIZE)
-+
-+#define RUN_TEST(testfunc, speed) \
-+    backup_test(#testfunc " speed " #speed, speed, testfunc);
-+
-+
-+static unsigned char buf_sec_pattern_cd[BDRV_SECTOR_SIZE];
-+static unsigned char buf_sec_pattern_32[BDRV_SECTOR_SIZE];
-+
-+#define TEST_IMG_SIZE (6*1024*1024+BDRV_SECTOR_SIZE)
-+#define TEST_IMG_NAME "backuptest.raw"
-+#define TEST_IMG_RESTORE_NAME "backuptest.raw.restore"
-+#define TEST_VMA_NAME "backuptest.vma"
-+
-+typedef struct BackupCB {
-+    VmaWriter *vmaw;
-+    uint8_t dev_id;
-+} BackupCB;
-+
-+static int backup_dump_cb(void *opaque, BlockDriverState *bs,
-+                          int64_t cluster_num, unsigned char *buf)
-+{
-+    BackupCB *bcb = opaque;
-+
-+    DPRINTF("backup_dump_cb C%" PRId64 " %d\n", cluster_num, bcb->dev_id);
-+
-+    size_t zb = 0;
-+    if (vma_writer_write(bcb->vmaw, bcb->dev_id, cluster_num, buf, &zb) < 0) {
-+        printf("backup_dump_cb vma_writer_write failed\n");
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+static void backup_complete_cb(void *opaque, int ret)
-+{
-+    BackupCB *bcb = opaque;
-+
-+    DPRINTF("backup_complete_cb %d %d\n", bcb->dev_id, ret);
-+
-+    if (ret < 0) {
-+        vma_writer_set_error(bcb->vmaw, "backup_complete_cb %d", ret);
-+    }
-+
-+    if (vma_writer_close_stream(bcb->vmaw, bcb->dev_id) <= 0) {
-+        Error *err = NULL;
-+        if (vma_writer_close(bcb->vmaw, &err) != 0) {
-+            g_error("vma_writer_close failed %s", error_get_pretty(err));
-+        }
-+    }
-+    DPRINTF("backup_complete_cb finish\n");
-+}
-+
-+static void write_sec_pattern_cd(BlockDriverState *bs, int64_t offset)
-+{
-+    int ret;
-+
-+    DPRINTF("write_sec_pattern_cd %" PRId64 "\n", offset);
-+
-+    if (offset & 0x1ff) {
-+        g_error("write_sec_pattern_cd offset %" PRId64
-+                " is not sector aligned\n", offset);
-+    }
-+
-+    ret = bdrv_write(bs, offset >> 9, buf_sec_pattern_cd, 1);
-+    if (ret < 0) {
-+        g_error("write_sec_pattern_cd %" PRId64 " failed", offset);
-+    }
-+
-+}
-+
-+static void read_sec(BlockDriverState *bs, int64_t offset, unsigned char *buf)
-+{
-+    DPRINTF("read_sec C%" PRId64 " start %" PRId64 "\n",
-+            offset>>VMA_CLUSTER_BITS, offset);
-+
-+    if (offset & 0x1ff) {
-+        g_error("read_sec offset %" PRId64 " is not sector aligned\n", offset);
-+    }
-+
-+    if (bdrv_read(bs, offset >> 9, buf, 1) < 0) {
-+        g_error("bdrv_read failed");
-+    }
-+}
-+
-+static bool request_term;
-+
-+typedef struct TestCB {
-+    Coroutine *co;
-+    BlockDriverState *bs;
-+    bool finished;
-+} TestCB;
-+
-+static TestCB *enter_test_co(BlockDriverState *bs, CoroutineEntry *entry)
-+{
-+    TestCB *cb = g_new0(TestCB, 1);
-+    cb->bs = bs;
-+    cb->co = qemu_coroutine_create(entry);
-+    qemu_coroutine_enter(cb->co, cb);
-+    return cb;
-+}
-+
-+static void test_co_sleep(double sec)
-+{
-+    co_sleep_ns(rt_clock, (int64_t)(sec*1000000000));
-+};
-+
-+static void test_co_yield(void)
-+{
-+    co_sleep_ns(rt_clock, (int64_t)(1000));
-+};
-+
-+static void coroutine_fn run_co_test1(void *opaque)
-+{
-+    assert(opaque);
-+    TestCB *cb = (TestCB *)opaque;
-+
-+    test_co_sleep(0.2);
-+    write_sec_pattern_cd(cb->bs, 5*BACKUP_CLUSTER_SIZE);
-+    test_co_sleep(0.2);
-+    write_sec_pattern_cd(cb->bs, 10*BACKUP_CLUSTER_SIZE);
-+    test_co_sleep(0.2);
-+    write_sec_pattern_cd(cb->bs, 10*BACKUP_CLUSTER_SIZE);
-+
-+    cb->finished = true;
-+}
-+
-+static void coroutine_fn run_co_test2(void *opaque)
-+{
-+    assert(opaque);
-+    TestCB *cb = (TestCB *)opaque;
-+    unsigned char buf[512];
-+
-+    test_co_sleep(0.2);
-+    read_sec(cb->bs, 5*BACKUP_CLUSTER_SIZE, buf);
-+    write_sec_pattern_cd(cb->bs, 6*BACKUP_CLUSTER_SIZE);
-+
-+    cb->finished = true;
-+}
-+
-+static void coroutine_fn run_co_random_read(void *opaque)
-+{
-+    assert(opaque);
-+    TestCB *cb = (TestCB *)opaque;
-+    int64_t sectors = bdrv_getlength(cb->bs)/BDRV_SECTOR_SIZE - 1;
-+    unsigned char buf[512];
-+
-+    while (1) {
-+        test_co_yield();
-+        if (request_term) {
-+            DPRINTF("finish run_co_random_read\n");
-+            break;
-+        }
-+        int64_t s = (rand()*sectors)/RAND_MAX;
-+        read_sec(cb->bs, s*BDRV_SECTOR_SIZE, buf);
-+    }
-+
-+    cb->finished = true;
-+}
-+
-+static void coroutine_fn run_co_random_write(void *opaque)
-+{
-+    assert(opaque);
-+    TestCB *cb = (TestCB *)opaque;
-+    int64_t sectors = bdrv_getlength(cb->bs)/BDRV_SECTOR_SIZE;
-+
-+    while (1) {
-+        test_co_yield();
-+        if (request_term) {
-+            DPRINTF("finish run_co_random_write\n");
-+            break;
-+        }
-+        int64_t s = (rand()*sectors)/RAND_MAX;
-+        write_sec_pattern_cd(cb->bs, s*BDRV_SECTOR_SIZE);
-+    }
-+
-+    cb->finished = true;
-+}
-+
-+static void fill_test_sector(void *buf, size_t sector_num)
-+{
-+    int64_t *i64buf = (int64_t *)buf;
-+    int i;
-+
-+    int data = sector_num;
-+    if (sector_num >= 8 && sector_num < 8*(2*16+2)) {
-+        data = 0;  /* add zero region for testing */
-+    }
-+
-+
-+    if (sector_num >= 20*BACKUP_BLOCKS_PER_CLUSTER &&
-+        sector_num <= 23*BACKUP_BLOCKS_PER_CLUSTER) {
-+        data = 0;  /* another zero region for testing unallocated regions */
-+    }
-+
-+    for (i = 0; i < (512/sizeof(int64_t)); i++) {
-+        i64buf[i] = data;
-+    }
-+}
-+
-+static void verify_archive(const char *archive, size_t size)
-+{
-+    Error *errp = NULL;
-+
-+    VmaReader *vmar = vma_reader_create(archive, &errp);
-+
-+    if (!vmar) {
-+        g_error("%s", error_get_pretty(errp));
-+    }
-+
-+    VmaDeviceInfo *di = vma_reader_get_device_info(vmar, 1);
-+    if (!di || strcmp((char *)di->devname, "hda") || di->size != size) {
-+        g_error("got wrong device info");
-+    }
-+
-+    unlink(TEST_IMG_RESTORE_NAME);
-+
-+    int flags = BDRV_O_NATIVE_AIO|BDRV_O_RDWR|BDRV_O_CACHE_WB;
-+
-+    bdrv_img_create(TEST_IMG_RESTORE_NAME, "raw", NULL, NULL, NULL,
-+                    size, flags, &errp);
-+    if (error_is_set(&errp)) {
-+        g_error("can't create file %s: %s", TEST_IMG_RESTORE_NAME,
-+                error_get_pretty(errp));
-+    }
-+
-+    BlockDriverState *bs = NULL;
-+    if (bdrv_file_open(&bs, TEST_IMG_RESTORE_NAME, flags)) {
-+        g_error("can't open file %s", TEST_IMG_RESTORE_NAME);
-+    }
-+    if (vma_reader_register_bs(vmar, 1, bs, false, &errp) < 0) {
-+        g_error("%s", error_get_pretty(errp));
-+    }
-+
-+    if (vma_reader_restore(vmar, -1, false, &errp) < 0) {
-+        g_error("restore failed - %s", error_get_pretty(errp));
-+    }
-+
-+    size_t i;
-+    size_t sectors = size/BDRV_SECTOR_SIZE;
-+    int64_t buf[512/sizeof(int64_t)];
-+    int64_t buf2[512/sizeof(int64_t)];
-+
-+    for (i = 0; i < sectors; i++) {
-+        if (bdrv_read(bs, i, (uint8_t *)buf, 1) != 0) {
-+            g_error("bdrv_read failed");
-+        }
-+        fill_test_sector(buf2, i);
-+        if (bcmp(buf, buf2, sizeof(buf))) {
-+            g_error("data is different at sector %" PRId64, i);
-+        }
-+    }
-+
-+    vma_reader_destroy(vmar);
-+
-+    unlink(TEST_IMG_RESTORE_NAME);
-+}
-+
-+static void prepare_vm_image(const char *filename, size_t sectors)
-+{
-+    int fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0644);
-+    if (fd < 0) {
-+        g_error("can't open file %s\n", filename);
-+    }
-+
-+    size_t i;
-+    int64_t buf[512/sizeof(int64_t)];
-+
-+    for (i = 0; i < sectors; i++) {
-+        if (i >= 20*BACKUP_BLOCKS_PER_CLUSTER &&
-+            i <= 23*BACKUP_BLOCKS_PER_CLUSTER) {
-+            continue; /* create a hole */
-+        }
-+
-+        fill_test_sector(buf, i);
-+
-+        int res = 0;
-+        while (1) {
-+            res = pwrite(fd, buf, sizeof(buf), i*512);
-+            if (!(res < 0 && errno == EINTR)) {
-+                break;
-+            }
-+        }
-+        if (res != sizeof(buf)) {
-+            g_error("can't initialize file %s - %s %d\n",
-+                    filename, g_strerror(errno), res);
-+        }
-+    }
-+
-+    if (close(fd) != 0) {
-+        g_error("close failed");
-+    }
-+}
-+
-+static GList *simple_test(BlockDriverState *bs)
-+{
-+    GList *cb_list = NULL;
-+
-+    cb_list = g_list_append(cb_list, enter_test_co(bs, run_co_test1));
-+    cb_list = g_list_append(cb_list, enter_test_co(bs, run_co_test2));
-+
-+    return cb_list;
-+}
-+
-+static GList *random_read_write_test(BlockDriverState *bs)
-+{
-+    GList *cb_list = NULL;
-+
-+    cb_list = g_list_append(cb_list, enter_test_co(bs, run_co_random_read));
-+    cb_list = g_list_append(cb_list, enter_test_co(bs, run_co_random_read));
-+    cb_list = g_list_append(cb_list, enter_test_co(bs, run_co_random_write));
-+    cb_list = g_list_append(cb_list, enter_test_co(bs, run_co_random_write));
-+
-+    return cb_list;
-+}
-+
-+static void backup_test(const char *testname, int64_t speed,
-+                        GList *(*start_test_cb)(BlockDriverState *bs))
-+{
-+    BlockDriverState *bs = bdrv_new("hda");
-+
-+    static int test_counter;
-+
-+    test_counter++;
-+
-+    printf("starting test #%d '%s'\n", test_counter, testname);
-+
-+    const char *filename = TEST_IMG_NAME;
-+
-+    prepare_vm_image(TEST_IMG_NAME, TEST_IMG_SIZE/BDRV_SECTOR_SIZE);
-+
-+    int flags = BDRV_O_NATIVE_AIO|BDRV_O_RDWR|BDRV_O_CACHE_WB;
-+
-+    if (bdrv_open(bs, filename, flags, NULL) < 0) {
-+        g_error("can't open device %s\n", filename);
-+    }
-+
-+    Error *err = NULL;
-+    uuid_t uuid;
-+    uuid_generate(uuid);
-+
-+    unlink(TEST_VMA_NAME);
-+
-+    VmaWriter *vmaw = vma_writer_create(TEST_VMA_NAME, uuid, &err);
-+    if (!vmaw) {
-+        g_error("%s", error_get_pretty(err));
-+    }
-+
-+    BackupCB bcb;
-+    bcb.vmaw = vmaw;
-+    bcb.dev_id = vma_writer_register_stream(vmaw, bdrv_get_device_name(bs),
-+                                            bdrv_getlength(bs));
-+    if (backup_job_create(bs, backup_dump_cb, backup_complete_cb, &bcb,
-+                          speed) < 0) {
-+        g_error("backup_job_create failed");
-+    } else {
-+        backup_job_start(bs, false);
-+    }
-+
-+    request_term = false;
-+
-+    GList *cb_list = start_test_cb(bs);
-+
-+    while (1) {
-+        main_loop_wait(false);
-+
-+        VmaStatus vmastat;
-+        vma_writer_get_status(vmaw, &vmastat);
-+        if (vmastat.closed) {
-+            break;
-+        }
-+    }
-+
-+    request_term = true;
-+
-+    while (1) {
-+        GList *l = cb_list;
-+        bool active = 0;
-+        while (l && l->data) {
-+            TestCB *cb = (TestCB *)l->data;
-+            l = g_list_next(l);
-+            if (!cb->finished) {
-+                active = true;
-+                break;
-+            }
-+        }
-+        if (!active) {
-+            DPRINTF("All test coroutines finished\n");
-+            break;
-+        }
-+        main_loop_wait(false);
-+    }
-+
-+    /* Make sure all outstanding requests complete */
-+    bdrv_drain_all();
-+
-+    VmaStatus vmastat;
-+    vma_writer_get_status(vmaw, &vmastat);
-+    DPRINTF("statistic %" PRId64 " %" PRId64 "\n", vmastat.stream_info[1].size,
-+            vmastat.stream_info[1].transferred);
-+    assert(vmastat.stream_info[1].size == vmastat.stream_info[1].transferred);
-+
-+    vma_writer_destroy(vmaw);
-+
-+    bdrv_delete(bs);
-+
-+    /* start verification */
-+    verify_archive(TEST_VMA_NAME, TEST_IMG_SIZE);
-+
-+    bdrv_close_all();
-+
-+    unlink(TEST_IMG_NAME);
-+    unlink(TEST_VMA_NAME);
-+
-+    printf("finish test #%d '%s' OK\n", test_counter, testname);
-+}
-+
-+static void help(void)
-+{
-+    const char *help_msg =
-+        "usage: backup-test [options]\n"
-+        "\n"
-+        "backup-test        run default regression test (fast)\n"
-+        "backup-test -l     run long running test loop (endless)\n"
-+        "\n"
-+        "use option -d to turn on verbose debug output\n"
-+        ;
-+
-+    printf("%s", help_msg);
-+    exit(1);
-+}
-+
-+int main(int argc, char **argv)
-+{
-+    int c;
-+
-+    /* Note: GLib needs to be running in multithreaded mode in order
-+     * for the GSlice allocator to be thread-safe
-+     */
-+    g_thread_init(NULL);
-+
-+    for (;;) {
-+        c = getopt(argc, argv, "hdl");
-+        if (c == -1) {
-+            break;
-+        }
-+        switch (c) {
-+        case '?':
-+        case 'h':
-+            help();
-+            break;
-+        case 'd':
-+            opt_debug = 1;
-+            break;
-+        case 'l':
-+            opt_loop = 1;
-+            break;
-+        default:
-+            g_assert_not_reached();
-+        }
-+    }
-+
-+    memset(buf_sec_pattern_cd, 0xcd, sizeof(buf_sec_pattern_cd));
-+    memset(buf_sec_pattern_32, 0x32, sizeof(buf_sec_pattern_32));
-+
-+    srand(1234);
-+
-+    /* ignore SIGPIPE */
-+    struct sigaction act;
-+    sigfillset(&act.sa_mask);
-+    act.sa_flags = 0;
-+    act.sa_handler = SIG_IGN;
-+    sigaction(SIGPIPE, &act, NULL);
-+
-+    qemu_init_main_loop();
-+
-+    bdrv_init();
-+
-+    if (opt_loop) { /* endless test loop */
-+        while (1) {
-+            RUN_TEST(random_read_write_test, 0);
-+        }
-+        return 0;
-+    }
-+
-+    if (opt_debug) { /* run simple test (rate limited) */
-+        RUN_TEST(simple_test, 1024*1024);
-+        return 0;
-+    }
-+
-+    /* run default regression tests at full speed */
-+
-+    RUN_TEST(simple_test, 0);
-+    RUN_TEST(random_read_write_test, 0);
-+
-+    return 0;
-+}
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0006-add-vm-state-to-backups.patch b/debian/patches/old/0006-add-vm-state-to-backups.patch
deleted file mode 100644 (file)
index d68b427..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-From c209554171466e2aa8b1eca92d952429faca5fc6 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Thu, 29 Nov 2012 10:46:49 +0100
-Subject: [PATCH v5 6/6] add vm state to backups
-
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- blockdev.c       |  196 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
- hmp.c            |    3 +-
- qapi-schema.json |    5 +-
- 3 files changed, 200 insertions(+), 4 deletions(-)
-
-diff --git a/blockdev.c b/blockdev.c
-index 683f7da..dd20631 100644
---- a/blockdev.c
-+++ b/blockdev.c
-@@ -22,6 +22,8 @@
- #include "sysemu/arch_init.h"
- #include "backup.h"
- #include "vma.h"
-+#include "migration/qemu-file.h"
-+#include "migration/migration.h"
- static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
-@@ -1355,6 +1357,10 @@ static struct GenericBackupState {
-     size_t total;
-     size_t transferred;
-     size_t zero_bytes;
-+    unsigned char buf[BACKUP_CLUSTER_SIZE];
-+    int buf_index;
-+    size_t buf_cluster_num;
-+    guint8 vmstate_dev_id;
- } backup_state;
- typedef struct BackupCB {
-@@ -1510,10 +1516,170 @@ static void backup_start_jobs(void)
-     backup_run_next_job();
- }
-+static int backup_state_close(void *opaque)
-+{
-+    if (!backup_state.buf_index) {
-+        return 0;
-+    }
-+
-+    size_t zero_bytes = 0;
-+    if (backup_state.buf_index < BACKUP_CLUSTER_SIZE) {
-+        memset(backup_state.buf + backup_state.buf_index, 0,
-+               BACKUP_CLUSTER_SIZE - backup_state.buf_index);
-+    }
-+    int bytes = backup_state.driver->dump(
-+        backup_state.writer, backup_state.vmstate_dev_id,
-+        backup_state.buf_cluster_num,
-+        backup_state.buf, &zero_bytes);
-+    backup_state.buf_index = 0;
-+
-+    return bytes < 0 ? -1 : 0;
-+}
-+
-+static int backup_state_put_buffer(void *opaque, const uint8_t *buf,
-+                                   int64_t pos, int size)
-+{
-+    assert(backup_state.driver);
-+    assert(backup_state.writer);
-+    assert(backup_state.driver->dump);
-+
-+    /* Note: our backup driver expects to get whole clusters (64KB) */
-+
-+    int ret = size;
-+
-+    while (size > 0) {
-+        int l = BACKUP_CLUSTER_SIZE - backup_state.buf_index;
-+        l = l > size ? size : l;
-+        memcpy(backup_state.buf + backup_state.buf_index, buf, l);
-+        backup_state.buf_index += l;
-+        buf += l;
-+        size -= l;
-+        if (backup_state.buf_index == BACKUP_CLUSTER_SIZE) {
-+            size_t zero_bytes = 0;
-+            int bytes = backup_state.driver->dump(
-+                backup_state.writer, backup_state.vmstate_dev_id,
-+                backup_state.buf_cluster_num++,
-+                backup_state.buf, &zero_bytes);
-+            backup_state.buf_index = 0;
-+            if (bytes < 0) {
-+                return -1;
-+            }
-+        }
-+    }
-+
-+    return ret;
-+}
-+
-+static const QEMUFileOps backup_file_ops = {
-+    .put_buffer = backup_state_put_buffer,
-+    .close = backup_state_close,
-+};
-+
-+static void coroutine_fn backup_start_savevm(void *opaque)
-+{
-+    assert(backup_state.driver);
-+    assert(backup_state.writer);
-+    int ret;
-+    char *err = NULL;
-+    uint64_t remaining;
-+    int64_t maxlen;
-+    MigrationParams params = {
-+        .blk = 0,
-+        .shared = 0
-+    };
-+
-+    int restart = 0;
-+
-+    QEMUFile *file = qemu_fopen_ops(NULL, &backup_file_ops);
-+
-+    ret = qemu_savevm_state_begin(file, &params);
-+    if (ret < 0) {
-+        qemu_fclose(file);
-+        err = g_strdup("qemu_savevm_state_begin failed");
-+        goto abort;
-+    }
-+
-+    while (1) {
-+        ret = qemu_savevm_state_iterate(file);
-+        remaining = ram_bytes_remaining();
-+
-+        if (ret < 0) {
-+            qemu_fclose(file);
-+            err = g_strdup_printf("qemu_savevm_state_iterate error %d", ret);
-+            goto abort;
-+        }
-+
-+        /* stop the VM if we use too much space,
-+         * or if remaining is just a few MB
-+         */
-+        maxlen = ram_bytes_total();
-+        size_t cpos = backup_state.buf_cluster_num * BACKUP_CLUSTER_SIZE;
-+        if ((remaining < 100000) || ((cpos + remaining) >= maxlen)) {
-+            if (runstate_is_running()) {
-+                restart = 1;
-+                vm_stop(RUN_STATE_SAVE_VM);
-+           }
-+        }
-+
-+        if (ret == 1) { /* finished */
-+            if (runstate_is_running()) {
-+                restart = 1;
-+                vm_stop(RUN_STATE_SAVE_VM);
-+            }
-+
-+            ret = qemu_savevm_state_complete(file);
-+            if (ret < 0) {
-+                qemu_fclose(file);
-+                err = g_strdup("qemu_savevm_state_complete error");
-+                goto abort;
-+
-+            } else {
-+                if (qemu_fclose(file) < 0) {
-+                    error_setg(&backup_state.error,
-+                               "backup_start_savevm: qemu_fclose failed");
-+                    goto abort;
-+                }
-+                if (backup_state.driver->complete(backup_state.writer,
-+                    backup_state.vmstate_dev_id, 0) < 0) {
-+                    err = g_strdup("backup_start_savevm: complete failed");
-+                    goto abort;
-+                }
-+                backup_run_next_job();
-+                goto out;
-+            }
-+        }
-+    }
-+
-+out:
-+    if (restart) {
-+        vm_start();
-+    }
-+    return;
-+
-+abort:
-+    backup_state.end_time = time(NULL);
-+
-+    Error *local_err = NULL;
-+    backup_state.driver->close(backup_state.writer, &local_err);
-+    backup_state.writer = NULL;
-+
-+    error_propagate(&backup_state.error, local_err);
-+
-+    if (err) {
-+        if (!backup_state.error) {
-+            error_setg(&backup_state.error, "%s", err);
-+        }
-+        g_free(err);
-+    }
-+
-+    goto out;
-+}
-+
- char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-                  bool has_config_file, const char *config_file,
-                  bool has_devlist, const char *devlist,
--                 bool has_speed, int64_t speed, Error **errp)
-+                 bool has_speed, int64_t speed,
-+                 bool has_state, bool state, Error **errp)
- {
-     BlockDriverState *bs;
-     Error *local_err = NULL;
-@@ -1528,6 +1694,8 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-         return NULL;
-     }
-+    bool save_state = has_state ? state : false;
-+
-     /* Todo: try to auto-detect format based on file name */
-     format = has_format ? format : BACKUP_FORMAT_VMA;
-@@ -1608,6 +1776,22 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-     size_t total = 0;
-     /* register all devices for vma writer */
-+
-+    guint8 vmstate_dev_id = 0;
-+    if (save_state) {
-+        /* Note: we pass ram_bytes_total() for vmstate size
-+         * The backup driver needs to be aware of the fact
-+         * that the real stream size can be different (we do
-+         * not know that size in advance).
-+         */
-+        size_t ramsize = ram_bytes_total();
-+        vmstate_dev_id = driver->register_stream(writer, "vmstate", ramsize);
-+        if (vmstate_dev_id <= 0) {
-+            error_setg(errp, "register vmstate stream failed");
-+            goto err;
-+        }
-+    }
-+
-     l = bcblist;
-     while (l) {
-         BackupCB *bcb = l->data;
-@@ -1675,6 +1859,9 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-     backup_state.total = total;
-     backup_state.transferred = 0;
-     backup_state.zero_bytes = 0;
-+    backup_state.buf_index = 0;
-+    backup_state.buf_cluster_num = 0;
-+    backup_state.vmstate_dev_id = vmstate_dev_id;
-     /* Grab a reference so hotplug does not delete the
-      * BlockDriverState from underneath us.
-@@ -1686,7 +1873,12 @@ char *qmp_backup(const char *backup_file, bool has_format, BackupFormat format,
-         drive_get_ref(drive_get_by_blockdev(bcb->bs));
-     }
--    backup_start_jobs();
-+    if (save_state) {
-+        Coroutine *co = qemu_coroutine_create(backup_start_savevm);
-+        qemu_coroutine_enter(co, NULL);
-+    } else {
-+        backup_start_jobs();
-+    }
-     return g_strdup(backup_state.uuid_str);
-diff --git a/hmp.c b/hmp.c
-index b2c1f23..370cdf8 100644
---- a/hmp.c
-+++ b/hmp.c
-@@ -1052,7 +1052,8 @@ void hmp_backup(Monitor *mon, const QDict *qdict)
-     Error *errp = NULL;
-     qmp_backup(backup_file, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist,
--               devlist, qdict_haskey(qdict, "speed"), speed, &errp);
-+               devlist, qdict_haskey(qdict, "speed"), speed, false, false,
-+               &errp);
-     if (error_is_set(&errp)) {
-         monitor_printf(mon, "%s\n", error_get_pretty(errp));
-diff --git a/qapi-schema.json b/qapi-schema.json
-index 09ca8ef..1fabb67 100644
---- a/qapi-schema.json
-+++ b/qapi-schema.json
-@@ -1885,6 +1885,8 @@
- # @devlist: #optional list of block device names (separated by ',', ';'
- # or ':'). By default the backup includes all writable block devices.
- #
-+# @state: #optional flag to include vm state
-+#
- # Returns: the uuid of the backup job
- #
- # Since: 1.5.0
-@@ -1892,7 +1894,8 @@
- { 'command': 'backup', 'data': { 'backup-file': 'str',
-                                  '*format': 'BackupFormat',
-                                  '*config-file': 'str',
--                                 '*devlist': 'str', '*speed': 'int' },
-+                                 '*devlist': 'str', '*speed': 'int',
-+                                 '*state': 'bool' },
-   'returns': 'str' }
- ##
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0007-use-extra-thread-for-vma-writer.patch b/debian/patches/old/0007-use-extra-thread-for-vma-writer.patch
deleted file mode 100644 (file)
index d6d1f5f..0000000
+++ /dev/null
@@ -1,471 +0,0 @@
-From a6f324d47b810809de2a6106849527c6a9590175 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Mon, 14 Jan 2013 08:05:40 +0100
-Subject: [PATCH v3 7/7] use extra thread for vma writer
-
-The previous AIO approach has problem with bdrv_drain_all(), because writer
-coroutines are not considered there. Those coroutines are not restarted, so
-bdrv_drain_all() can fail (tracked_requests list not empty).
-
-We now use a thread, so we could also add compression here.
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- vma-writer.c |  296 +++++++++++++++++++++++++++++++++++-----------------------
- 1 files changed, 180 insertions(+), 116 deletions(-)
-
-Index: new/vma-writer.c
-===================================================================
---- new.orig/vma-writer.c      2013-01-23 07:35:12.000000000 +0100
-+++ new/vma-writer.c   2013-01-23 09:24:19.000000000 +0100
-@@ -37,13 +37,21 @@
- #define WRITE_BUFFERS 5
--typedef struct VmaAIOCB VmaAIOCB;
--struct VmaAIOCB {
--    VmaWriter *vmaw;
-+typedef struct WriteBuffer {
-     unsigned char buffer[VMA_MAX_EXTENT_SIZE];
-     size_t bytes;
--    Coroutine *co;
--};
-+} WriteBuffer;
-+
-+typedef struct WriterThread {
-+    int fd;
-+    int error;
-+    bool cancel;
-+    GThread *thread;
-+    GMutex *mutex;
-+    GCond *change_cond;
-+    WriteBuffer wbuf[WRITE_BUFFERS];
-+    CoQueue wqueue;
-+} WriterThread;
- struct VmaWriter {
-     int fd;
-@@ -60,8 +68,7 @@
-     int outbuf_count; /* in VMA_BLOCKS */
-     uint64_t outbuf_block_info[VMA_BLOCKS_PER_EXTENT];
--    VmaAIOCB aiocbs[WRITE_BUFFERS];
--    CoQueue wqueue;
-+    WriterThread wt;
-     GChecksum *md5csum;
-     CoMutex writer_lock;
-@@ -86,6 +93,107 @@
-     uint32_t config_count;
- };
-+static gpointer vma_writer_thread(gpointer data)
-+{
-+    WriterThread *wt = (WriterThread *)data;
-+
-+    while (1) {
-+        WriteBuffer *b = NULL;
-+
-+      qemu_mutex_lock_iothread();
-+        int i;
-+        for (i = 0; i < WRITE_BUFFERS; i++) {
-+            if (wt->wbuf[i].bytes) {
-+                b = &wt->wbuf[i];
-+                break;
-+            }
-+        }
-+      qemu_mutex_unlock_iothread();
-+
-+        if (b) {
-+            size_t done = 0;
-+            while (done < b->bytes) {
-+                int ret = write(wt->fd, b->buffer + done, b->bytes - done);
-+                if (ret > 0) {
-+                    done += ret;
-+                } else if (ret < 0) {
-+                    if (!(errno == EAGAIN || errno == EWOULDBLOCK)) {
-+                        qemu_mutex_lock_iothread();
-+                        wt->error = errno;
-+                        qemu_mutex_unlock_iothread();
-+                        break;
-+                    }
-+                } else if (ret == 0) {
-+                    /* should not happen - simply try again */
-+                }
-+            }
-+            qemu_mutex_lock_iothread();
-+            b->bytes = 0;
-+            DPRINTF("AWAKE JOB %d\n", wt->error);
-+            if (wt->error) {
-+                for (i = 0; i < WRITE_BUFFERS; i++) {
-+                    wt->wbuf[i].bytes = 0;
-+                }
-+                qemu_co_queue_restart_all(&wt->wqueue);
-+            } else {
-+                qemu_co_queue_next(&wt->wqueue);
-+            }
-+            qemu_mutex_unlock_iothread();
-+            DPRINTF("AWAKE JOB END\n");
-+        }
-+
-+        if (wt->error) {
-+            DPRINTF("WRITER THREAD ERROR %d - exit thread\n", wt->error);
-+            g_thread_exit(NULL);
-+        }
-+
-+        g_mutex_lock(wt->mutex);
-+        bool cancel = wt->cancel;
-+        if (!b && !cancel) {
-+            DPRINTF("WRITER THREAD WAIT FOR DATA\n");         
-+            g_cond_wait(wt->change_cond, wt->mutex);
-+            cancel = wt->cancel;
-+        }
-+        g_mutex_unlock(wt->mutex);
-+
-+        if (cancel) {
-+            qemu_mutex_lock_iothread();
-+            for (i = 0; i < WRITE_BUFFERS; i++) {
-+                wt->wbuf[i].bytes = 0;
-+            }
-+            qemu_co_queue_restart_all(&wt->wqueue);
-+            qemu_mutex_unlock_iothread();
-+            DPRINTF("END WRITER THREAD\n");
-+            g_thread_exit(NULL);
-+        }
-+    }
-+
-+    return NULL;
-+}
-+
-+static void vma_stop_writer_thread(VmaWriter *vmaw)
-+{
-+    assert(vmaw);
-+
-+    DPRINTF("vma_stop_writer_thread start\n");
-+
-+    if (vmaw->wt.thread) {
-+        DPRINTF("vma_stop_writer_thread 1\n");
-+        g_mutex_lock(vmaw->wt.mutex);
-+        DPRINTF("vma_stop_writer_thread 2\n");
-+        vmaw->wt.cancel = true;
-+        g_cond_signal(vmaw->wt.change_cond);
-+        g_mutex_unlock(vmaw->wt.mutex);
-+        DPRINTF("vma_stop_writer_thread 3\n");
-+        qemu_mutex_unlock_iothread();
-+        g_thread_join(vmaw->wt.thread);
-+        qemu_mutex_lock_iothread();
-+        DPRINTF("vma_stop_writer_thread 4\n");
-+        vmaw->wt.thread = NULL;
-+    }
-+    DPRINTF("vma_stop_writer_thread end\n");
-+}
-+
- void vma_writer_set_error(VmaWriter *vmaw, const char *fmt, ...)
- {
-     va_list ap;
-@@ -213,111 +321,45 @@
-     return n;
- }
--static void vma_co_continue_write(void *opaque)
--{
--    VmaWriter *vmaw = opaque;
--
--    qemu_aio_set_fd_handler(vmaw->fd, NULL, NULL, NULL, NULL);
--
--    DPRINTF("vma_co_continue_write\n");
--    qemu_coroutine_enter(vmaw->co_writer, NULL);
--}
--
--static ssize_t coroutine_fn
--vma_co_write(VmaWriter *vmaw, const void *buf, size_t bytes)
--{
--    size_t done = 0;
--    ssize_t ret;
--
--    /* atomic writes (we cannot interleave writes) */
--    qemu_co_mutex_lock(&vmaw->writer_lock);
--
--    DPRINTF("vma_co_write enter %zd\n", bytes);
--
--    while (done < bytes) {
--        ret = write(vmaw->fd, buf + done, bytes - done);
--        if (ret > 0) {
--            done += ret;
--            DPRINTF("vma_co_write written %zd %zd\n", done, ret);
--        } else if (ret < 0) {
--            if (errno == EAGAIN || errno == EWOULDBLOCK) {
--                DPRINTF("vma_co_write yield %zd\n", done);
--
--                vmaw->co_writer = qemu_coroutine_self();
--                qemu_aio_set_fd_handler(vmaw->fd, NULL, vma_co_continue_write,
--                                        NULL, vmaw);
--
--                qemu_coroutine_yield();
--                DPRINTF("vma_co_write restart %zd\n", done);
--            } else {
--                vma_writer_set_error(vmaw, "vma_co_write write error - %s",
--                                     strerror(errno));
--                done = -1; /* always return failure for partial writes */
--                break;
--            }
--        } else if (ret == 0) {
--            /* should not happen - simply try again */
--        }
--    }
--
--    qemu_co_mutex_unlock(&vmaw->writer_lock);
--
--    DPRINTF("vma_co_write leave %zd\n", done);
--    return done;
--}
--
--static void coroutine_fn vma_co_writer_task(void *opaque)
--{
--    VmaAIOCB *cb = opaque;
--
--    DPRINTF("vma_co_writer_task start\n");
--
--    int64_t done = vma_co_write(cb->vmaw, cb->buffer, cb->bytes);
--    DPRINTF("vma_co_writer_task write done %zd\n", done);
--
--    if (done != cb->bytes) {
--        DPRINTF("vma_co_writer_task failed write %zd %zd", cb->bytes, done);
--        vma_writer_set_error(cb->vmaw, "vma_co_writer_task failed write %zd",
--                             done);
--    }
--
--    cb->bytes = 0;
--
--    qemu_co_queue_next(&cb->vmaw->wqueue);
--
--    DPRINTF("vma_co_writer_task end\n");
--}
--
- static void coroutine_fn vma_queue_flush(VmaWriter *vmaw)
- {
-     DPRINTF("vma_queue_flush enter\n");
-     assert(vmaw);
-+    int error;
-+
-     while (1) {
-         int i;
--        VmaAIOCB *cb = NULL;
-+        WriteBuffer *b = NULL;
-+ 
-+        error = vmaw->wt.error;
-+
-         for (i = 0; i < WRITE_BUFFERS; i++) {
--            if (vmaw->aiocbs[i].bytes) {
--                cb = &vmaw->aiocbs[i];
--                DPRINTF("FOUND USED AIO BUFFER %d %zd\n", i,
--                        vmaw->aiocbs[i].bytes);
-+            if (vmaw->wt.wbuf[i].bytes) {
-+                b = &vmaw->wt.wbuf[i];
-+                DPRINTF("FOUND USED WRITE BUFFER %d %zd\n", i,
-+                        vmaw->wt.wbuf[i].bytes);
-                 break;
-             }
-         }
--        if (!cb) {
-+
-+        if (!b || error) {
-             break;
-         }
--        qemu_co_queue_wait(&vmaw->wqueue);
-+        DPRINTF("WAIT FOR BUFFER FLUSH\n");
-+        qemu_co_queue_wait(&vmaw->wt.wqueue);
-+        DPRINTF("WAIT FOR BUFFER FLUSH END\n");
-+    }
-+
-+    if (error) {
-+        vma_writer_set_error(vmaw, "vma_queue_flush write error - %s",
-+                             strerror(error));
-     }
-     DPRINTF("vma_queue_flush leave\n");
- }
--/**
-- * NOTE: pipe buffer size in only 4096 bytes on linux (see 'ulimit -a')
-- * So we need to create a coroutione to allow 'parallel' execution.
-- */
- static ssize_t coroutine_fn
- vma_queue_write(VmaWriter *vmaw, const void *buf, size_t bytes)
- {
-@@ -327,29 +369,42 @@
-     assert(buf);
-     assert(bytes <= VMA_MAX_EXTENT_SIZE);
--    VmaAIOCB *cb = NULL;
--    while (!cb) {
-+    int error = 0;
-+
-+    /* wait for a free output buffer */
-+    WriteBuffer *b = NULL;
-+    while (!b) {
-+        error = vmaw->wt.error;
-+        if (error) {
-+             vma_writer_set_error(vmaw, "vma_queue_write error - %s",
-+                                 strerror(error));
-+            return -1;
-+        }
-+
-         int i;
-         for (i = 0; i < WRITE_BUFFERS; i++) {
--            if (!vmaw->aiocbs[i].bytes) {
--                cb = &vmaw->aiocbs[i];
-+            if (!vmaw->wt.wbuf[i].bytes) {
-+                b = &vmaw->wt.wbuf[i];
-                 break;
-             }
-         }
--        if (!cb) {
--            qemu_co_queue_wait(&vmaw->wqueue);
-+        if (!b) {
-+            DPRINTF("WAIT FOR BUFFER\n");
-+            qemu_co_queue_wait(&vmaw->wt.wqueue);
-+            DPRINTF("WAIT FOR BUFFER DONE\n");
-         }
-     }
--    memcpy(cb->buffer, buf, bytes);
--    cb->bytes = bytes;
--    cb->vmaw = vmaw;
-+    /* copy data to output buffer */
-+    memcpy(b->buffer, buf, bytes);
-+    b->bytes = bytes;
--    DPRINTF("vma_queue_write start %zd\n", bytes);
--    cb->co = qemu_coroutine_create(vma_co_writer_task);
--    qemu_coroutine_enter(cb->co, cb);
-+    g_mutex_lock(vmaw->wt.mutex);
-+    /* signal writer thread that we have new data */
-+    g_cond_signal(vmaw->wt.change_cond);
-+    g_mutex_unlock(vmaw->wt.mutex);
--    DPRINTF("vma_queue_write leave\n");
-+    DPRINTF("vma_queue_write queued %zd\n", bytes);
-     return bytes;
- }
-@@ -386,10 +441,10 @@
-         const char *tmp_id_str;
-         if ((stat(filename, &st) == 0) && S_ISFIFO(st.st_mode)) {
--            oflags = O_NONBLOCK|O_WRONLY;
-+            oflags = O_WRONLY;
-             vmaw->fd = qemu_open(filename, oflags, 0644);
-         } else if (strstart(filename, "/dev/fdset/", &tmp_id_str)) {
--            oflags = O_NONBLOCK|O_WRONLY;
-+            oflags = O_WRONLY;
-             vmaw->fd = qemu_open(filename, oflags, 0644);
-         } else if (strstart(filename, "/dev/fdname/", &tmp_id_str)) {
-             vmaw->fd = monitor_get_fd(cur_mon, tmp_id_str, errp);
-@@ -397,7 +452,7 @@
-                 goto err;
-             }
-         } else  {
--            oflags = O_NONBLOCK|O_WRONLY|O_CREAT|O_EXCL;
-+            oflags = O_WRONLY|O_CREAT|O_EXCL;
-             vmaw->fd = qemu_open(filename, oflags, 0644);
-         }
-@@ -415,10 +470,19 @@
-     qemu_co_mutex_init(&vmaw->writer_lock);
-     qemu_co_mutex_init(&vmaw->flush_lock);
--    qemu_co_queue_init(&vmaw->wqueue);
-+    qemu_co_queue_init(&vmaw->wt.wqueue);
-     uuid_copy(vmaw->uuid, uuid);
-+    vmaw->wt.mutex = g_mutex_new();
-+    vmaw->wt.change_cond = g_cond_new();
-+    vmaw->wt.fd = vmaw->fd;
-+    vmaw->wt.thread = g_thread_create(vma_writer_thread, &vmaw->wt, true, NULL);
-+    if (vmaw->wt.thread == NULL) {
-+        error_setg(errp, "can't allocate writer thread\n");
-+        goto err;
-+    }
-+
-     return vmaw;
- err:
-@@ -433,6 +497,14 @@
-             g_checksum_free(vmaw->md5csum);
-         }
-+        if (vmaw->wt.mutex) {
-+            g_mutex_free(vmaw->wt.mutex);
-+        }
-+
-+        if (vmaw->wt.change_cond) {
-+            g_cond_free(vmaw->wt.change_cond);
-+        }
-+
-         g_free(vmaw);
-     }
-@@ -672,6 +744,14 @@
-     *zero_bytes = 0;
-+    int error = vmaw->wt.error;
-+
-+    if (error) {
-+        vma_writer_set_error(vmaw, "vma_writer_get_buffer write error - %s",
-+                             strerror(error));
-+        return -1;
-+    }
-+
-     if (vmaw->status < 0) {
-         return vmaw->status;
-     }
-@@ -783,14 +863,17 @@
-     int i;
-+    DPRINTF("vma_writer_close start\n");
-     vma_queue_flush(vmaw);
-     /* this should not happen - just to be sure */
--    while (!qemu_co_queue_empty(&vmaw->wqueue)) {
-+    while (!qemu_co_queue_empty(&vmaw->wt.wqueue)) {
-         DPRINTF("vma_writer_close wait\n");
-         co_sleep_ns(rt_clock, 1000000);
-     }
-+    vma_stop_writer_thread(vmaw);
-+
-     if (vmaw->cmd) {
-         if (pclose(vmaw->cmd) < 0) {
-             vma_writer_set_error(vmaw, "vma_writer_close: "
-@@ -835,8 +918,9 @@
- {
-     assert(vmaw);
--    int i;
-+    vma_stop_writer_thread(vmaw);
-+    int i;
-     for (i = 0; i <= 255; i++) {
-         if (vmaw->stream_info[i].devname) {
-             g_free(vmaw->stream_info[i].devname);
-@@ -847,6 +931,14 @@
-         g_checksum_free(vmaw->md5csum);
-     }
-+    if (vmaw->wt.mutex) {
-+        g_mutex_free(vmaw->wt.mutex);
-+    }
-+
-+    if (vmaw->wt.change_cond) {
-+        g_cond_free(vmaw->wt.change_cond);
-+    }
-+
-     g_free(vmaw);
- }
diff --git a/debian/patches/old/0007-vma-add-verify-command.patch b/debian/patches/old/0007-vma-add-verify-command.patch
deleted file mode 100644 (file)
index a6aff85..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-From acdcd483ac6977e096ef7cde746d22bbf82e04d3 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Mon, 11 Mar 2013 07:07:46 +0100
-Subject: [PATCH v5 7/7] vma: add verify command
-
-Users wants to verify the archive after backup.
-
-Examples:
-
- # vma verify -v test.vma
-
- # lzop -d -c test.vma.lzo |vma verify -
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- vma-reader.c |  118 +++++++++++++++++++++++++++++++++++++++++++---------------
- vma.c        |   57 +++++++++++++++++++++++++++-
- vma.h        |    1 +
- 3 files changed, 145 insertions(+), 31 deletions(-)
-
-diff --git a/vma-reader.c b/vma-reader.c
-index bc36cba..a740f04 100644
---- a/vma-reader.c
-+++ b/vma-reader.c
-@@ -53,6 +53,8 @@ struct VmaReader {
-     time_t start_time;
-     int64_t cluster_count;
-     int64_t clusters_read;
-+    int64_t zero_cluster_data;
-+    int64_t partial_zero_cluster_data;
-     int clusters_read_per;
- };
-@@ -433,6 +435,27 @@ VmaDeviceInfo *vma_reader_get_device_info(VmaReader *vmar, guint8 dev_id)
-     return NULL;
- }
-+static void allocate_rstate(VmaReader *vmar,  guint8 dev_id, 
-+                            BlockDriverState *bs, bool write_zeroes)
-+{
-+    assert(vmar);
-+    assert(dev_id);
-+
-+    vmar->rstate[dev_id].bs = bs;
-+    vmar->rstate[dev_id].write_zeroes = write_zeroes;
-+
-+    int64_t size = vmar->devinfo[dev_id].size;
-+
-+    int64_t bitmap_size = (size/BDRV_SECTOR_SIZE) +
-+        (VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE) * BITS_PER_LONG - 1;
-+    bitmap_size /= (VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE) * BITS_PER_LONG;
-+
-+    vmar->rstate[dev_id].bitmap_size = bitmap_size;
-+    vmar->rstate[dev_id].bitmap = g_new0(unsigned long, bitmap_size);
-+
-+    vmar->cluster_count += size/VMA_CLUSTER_SIZE;
-+}
-+
- int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockDriverState *bs,
-                            bool write_zeroes, Error **errp)
- {
-@@ -449,17 +472,7 @@ int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockDriverState *bs,
-         return -1;
-     }
--    vmar->rstate[dev_id].bs = bs;
--    vmar->rstate[dev_id].write_zeroes = write_zeroes;
--
--    int64_t bitmap_size = (size/BDRV_SECTOR_SIZE) +
--        (VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE) * BITS_PER_LONG - 1;
--    bitmap_size /= (VMA_CLUSTER_SIZE/BDRV_SECTOR_SIZE) * BITS_PER_LONG;
--
--    vmar->rstate[dev_id].bitmap_size = bitmap_size;
--    vmar->rstate[dev_id].bitmap = g_new0(unsigned long, bitmap_size);
--
--    vmar->cluster_count += size/VMA_CLUSTER_SIZE;
-+    allocate_rstate(vmar, dev_id, bs, write_zeroes);
-     return 0;
- }
-@@ -526,9 +539,10 @@ static int restore_write_data(VmaReader *vmar, guint8 dev_id,
-     }
-     return 0;
- }
-+
- static int restore_extent(VmaReader *vmar, unsigned char *buf,
-                           int extent_size, int vmstate_fd,
--                          bool verbose, Error **errp)
-+                          bool verbose, bool verify, Error **errp)
- {
-     assert(vmar);
-     assert(buf);
-@@ -553,7 +567,7 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
-         if (dev_id != vmar->vmstate_stream) {
-             bs = rstate->bs;
--            if (!bs) {
-+            if (!verify && !bs) {
-                 error_setg(errp, "got wrong dev id %d", dev_id);
-                 return -1;
-             }
-@@ -609,10 +623,13 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
-                 return -1;
-             }
--            int nb_sectors = end_sector - sector_num;
--            if (restore_write_data(vmar, dev_id, bs, vmstate_fd, buf + start,
--                                   sector_num, nb_sectors, errp) < 0) {
--                return -1;
-+            if (!verify) {
-+                int nb_sectors = end_sector - sector_num;
-+                if (restore_write_data(vmar, dev_id, bs, vmstate_fd, 
-+                                       buf + start, sector_num, nb_sectors, 
-+                                       errp) < 0) {
-+                    return -1;
-+                }
-             }
-             start += VMA_CLUSTER_SIZE;
-@@ -642,26 +659,37 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
-                         return -1;
-                     }
--                    int nb_sectors = end_sector - sector_num;
--                    if (restore_write_data(vmar, dev_id, bs, vmstate_fd,
--                                           buf + start, sector_num,
--                                           nb_sectors, errp) < 0) {
--                        return -1;
-+                    if (!verify) {
-+                        int nb_sectors = end_sector - sector_num;
-+                        if (restore_write_data(vmar, dev_id, bs, vmstate_fd,
-+                                               buf + start, sector_num,
-+                                               nb_sectors, errp) < 0) {
-+                            return -1;
-+                        }
-                     }
-                     start += VMA_BLOCK_SIZE;
-                 } else {
--                    if (rstate->write_zeroes && (end_sector > sector_num)) {
-+ 
-+                    if (end_sector > sector_num) {
-                         /* Todo: use bdrv_co_write_zeroes (but that need to
-                          * be run inside coroutine?)
-                          */
-                         int nb_sectors = end_sector - sector_num;
--                        if (restore_write_data(vmar, dev_id, bs, vmstate_fd,
--                                              zero_vma_block, sector_num,
--                                               nb_sectors, errp) < 0) {
--                            return -1;
-+                        int zero_size = BDRV_SECTOR_SIZE*nb_sectors;
-+                        vmar->zero_cluster_data += zero_size;
-+                        if (mask != 0) {
-+                            vmar->partial_zero_cluster_data += zero_size;
-+                        }
-+
-+                        if (rstate->write_zeroes && !verify) {
-+                            if (restore_write_data(vmar, dev_id, bs, vmstate_fd,
-+                                                   zero_vma_block, sector_num,
-+                                                   nb_sectors, errp) < 0) {
-+                                return -1;
-+                            }
-                         }
-                     }
-                 }
-@@ -679,8 +707,9 @@ static int restore_extent(VmaReader *vmar, unsigned char *buf,
-     return 0;
- }
--int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
--                       Error **errp)
-+static int vma_reader_restore_full(VmaReader *vmar, int vmstate_fd, 
-+                                   bool verbose, bool verify,
-+                                   Error **errp)
- {
-     assert(vmar);
-     assert(vmar->head_data);
-@@ -747,7 +776,7 @@ int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
-         }
-         if (restore_extent(vmar, buf, extent_size, vmstate_fd, verbose,
--                           errp) < 0) {
-+                           verify, errp) < 0) {
-             return -1;
-         }
-@@ -794,6 +823,35 @@ int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
-         }
-     }
-+    if (verbose) {
-+        printf("total bytes read %zd, sparse bytes %zd (%.3g%%)\n",
-+               vmar->clusters_read*VMA_CLUSTER_SIZE,
-+               vmar->zero_cluster_data,
-+               (double)(100.0*vmar->zero_cluster_data)/
-+               (vmar->clusters_read*VMA_CLUSTER_SIZE));
-+        printf("space reduction due to 4K zero blocks %.3g%%\n",
-+               (double)(100.0*vmar->partial_zero_cluster_data) /
-+               (vmar->clusters_read*VMA_CLUSTER_SIZE-vmar->zero_cluster_data));
-+    }
-     return ret;
- }
-+int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
-+                       Error **errp)
-+{
-+    return vma_reader_restore_full(vmar, vmstate_fd, verbose, false, errp);
-+}
-+
-+int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp)
-+{
-+    guint8 dev_id;
-+
-+    for (dev_id = 1; dev_id < 255; dev_id++) {
-+        if (vma_reader_get_device_info(vmar, dev_id)) {
-+            allocate_rstate(vmar, dev_id, NULL, false);
-+        }
-+    }
-+
-+    return vma_reader_restore_full(vmar, -1, verbose, true, errp);
-+}
-+
-diff --git a/vma.c b/vma.c
-index 6633aa5..bcde379 100644
---- a/vma.c
-+++ b/vma.c
-@@ -33,7 +33,8 @@ static void help(void)
-         "\n"
-         "vma list <filename>\n"
-         "vma create <filename> [-c config] <archive> pathname ...\n"
--        "vma extract <filename> [-r] <targetdir>\n"
-+        "vma extract <filename> [-v] [-r] <targetdir>\n"
-+        "vma verify <filename> [-v]\n"
-         ;
-     printf("%s", help_msg);
-@@ -337,6 +338,58 @@ static int extract_content(int argc, char **argv)
-     return ret;
- }
-+static int verify_content(int argc, char **argv)
-+{
-+    int c, ret = 0;
-+    int verbose = 0;
-+    const char *filename;
-+
-+    for (;;) {
-+        c = getopt(argc, argv, "hv");
-+        if (c == -1) {
-+            break;
-+        }
-+        switch (c) {
-+        case '?':
-+        case 'h':
-+            help();
-+            break;
-+        case 'v':
-+            verbose = 1;
-+            break;
-+        default:
-+            help();
-+        }
-+    }
-+
-+    /* Get the filename */
-+    if ((optind + 1) != argc) {
-+        help();
-+    }
-+    filename = argv[optind++];
-+
-+    Error *errp = NULL;
-+    VmaReader *vmar = vma_reader_create(filename, &errp);
-+
-+    if (!vmar) {
-+        g_error("%s", error_get_pretty(errp));
-+    }
-+
-+    if (verbose) {
-+        print_content(vmar);
-+    }
-+
-+    if (vma_reader_verify(vmar, verbose, &errp) < 0) {
-+        g_error("verify failed - %s", error_get_pretty(errp));
-+    }
-+
-+    vma_reader_destroy(vmar);
-+
-+    bdrv_close_all();
-+
-+    return ret;
-+}
-+
- typedef struct BackupCB {
-     VmaWriter *vmaw;
-     uint8_t dev_id;
-@@ -554,6 +607,8 @@ int main(int argc, char **argv)
-         return create_archive(argc, argv);
-     } else if (!strcmp(cmdname, "extract")) {
-         return extract_content(argc, argv);
-+    } else if (!strcmp(cmdname, "verify")) {
-+        return verify_content(argc, argv);
-     }
-     help();
-diff --git a/vma.h b/vma.h
-index 76d0dc8..ebd96c1 100644
---- a/vma.h
-+++ b/vma.h
-@@ -141,5 +141,6 @@ int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id,
-                            Error **errp);
- int vma_reader_restore(VmaReader *vmar, int vmstate_fd, bool verbose,
-                        Error **errp);
-+int vma_reader_verify(VmaReader *vmar, bool verbose, Error **errp);
- #endif /* BACKUP_VMA_H */
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0008-vma-restore-tolerate-a-size-difference-up-to-4M.patch b/debian/patches/old/0008-vma-restore-tolerate-a-size-difference-up-to-4M.patch
deleted file mode 100644 (file)
index 2e76dae..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-From 4ca68d0ccfd64f2fdc63ba44813bbafab8d90c81 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Tue, 26 Mar 2013 06:21:16 +0100
-Subject: [PATCH v5 8/8] vma restore: tolerate a size difference up to 4M
-
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- vma-reader.c |    8 +++++++-
- 1 files changed, 7 insertions(+), 1 deletions(-)
-
-diff --git a/vma-reader.c b/vma-reader.c
-index a740f04..69e7578 100644
---- a/vma-reader.c
-+++ b/vma-reader.c
-@@ -465,7 +465,13 @@ int vma_reader_register_bs(VmaReader *vmar, guint8 dev_id, BlockDriverState *bs,
-     assert(vmar->rstate[dev_id].bs == NULL);
-     int64_t size = bdrv_getlength(bs);
--    if (size != vmar->devinfo[dev_id].size) {
-+    int64_t size_diff = size - vmar->devinfo[dev_id].size;
-+
-+    /* storage types can have different size restrictions, so it
-+     * is not always possible to create an image with exact size.
-+     * So we tolerate a size difference up to 4MB.
-+     */
-+    if ((size_diff < 0) || (size_diff > 4*1024*1024)) {
-         error_setg(errp, "vma_reader_register_bs for stream %s failed - "
-                    "unexpected size %zd != %zd", vmar->devinfo[dev_id].devname,
-                    size, vmar->devinfo[dev_id].size);
--- 
-1.7.2.5
-
diff --git a/debian/patches/old/0009-vma-only-store-the-basename-of-a-configuration-file.patch b/debian/patches/old/0009-vma-only-store-the-basename-of-a-configuration-file.patch
deleted file mode 100644 (file)
index f6b3a66..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-From 41811d473df9a1cb09bc4f44eba3147dcec231b1 Mon Sep 17 00:00:00 2001
-From: Dietmar Maurer <dietmar@proxmox.com>
-Date: Wed, 8 May 2013 10:01:29 +0200
-Subject: [PATCH v5 9/9] vma: only store the basename of a configuration file
-
-It makes no sense to store the whole filesystem path here.
-
-Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
----
- vma-writer.c |    5 ++++-
- vma.c        |    2 +-
- 2 files changed, 5 insertions(+), 2 deletions(-)
-
-diff --git a/vma-writer.c b/vma-writer.c
-index 9228ca6..3cc9cf2 100644
---- a/vma-writer.c
-+++ b/vma-writer.c
-@@ -145,7 +145,10 @@ int vma_writer_add_config(VmaWriter *vmaw, const char *name, gpointer data,
-     assert(data);
-     assert(len);
--    uint32_t name_ptr = allocate_header_string(vmaw, name);
-+    gchar *basename = g_path_get_basename(name);
-+    uint32_t name_ptr = allocate_header_string(vmaw, basename);
-+    g_free(basename);
-+
-     if (!name_ptr) {
-         return -1;
-     }
-diff --git a/vma.c b/vma.c
-index bcde379..f4a8218 100644
---- a/vma.c
-+++ b/vma.c
-@@ -33,7 +33,7 @@ static void help(void)
-         "\n"
-         "vma list <filename>\n"
-         "vma create <filename> [-c config] <archive> pathname ...\n"
--        "vma extract <filename> [-v] [-r] <targetdir>\n"
-+        "vma extract <filename> [-v] [-r <fifo>] <targetdir>\n"
-         "vma verify <filename> [-v]\n"
-         ;
--- 
-1.7.10.4
-
diff --git a/debian/patches/old/CVE-2015-7549-msix-pba-write-ro.patch b/debian/patches/old/CVE-2015-7549-msix-pba-write-ro.patch
deleted file mode 100644 (file)
index 631ae37..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-commit 43b11a91dd861a946b231b89b7542856ade23d1b
-Author: Marc-AndrĂ© Lureau <marcandre.lureau@redhat.com>
-Date:   Fri Jun 26 14:25:29 2015 +0200
-
-    msix: implement pba write (but read-only)
-    
-    qpci_msix_pending() writes on pba region, causing qemu to SEGV:
-    
-      Program received signal SIGSEGV, Segmentation fault.
-      [Switching to Thread 0x7ffff7fba8c0 (LWP 25882)]
-      0x0000000000000000 in ?? ()
-      (gdb) bt
-      #0  0x0000000000000000 in  ()
-      #1  0x00005555556556c5 in memory_region_oldmmio_write_accessor (mr=0x5555579f3f80, addr=0, value=0x7fffffffbf68, size=4, shift=0, mask=4294967295, attrs=...) at /home/elmarco/src/qemu/memory.c:434
-      #2  0x00005555556558e1 in access_with_adjusted_size (addr=0, value=0x7fffffffbf68, size=4, access_size_min=1, access_size_max=4, access=0x55555565563e <memory_region_oldmmio_write_accessor>, mr=0x5555579f3f80, attrs=...) at /home/elmarco/src/qemu/memory.c:506
-      #3  0x00005555556581eb in memory_region_dispatch_write (mr=0x5555579f3f80, addr=0, data=0, size=4, attrs=...) at /home/elmarco/src/qemu/memory.c:1176
-      #4  0x000055555560b6f9 in address_space_rw (as=0x555555eff4e0 <address_space_memory>, addr=3759147008, attrs=..., buf=0x7fffffffc1b0 "", len=4, is_write=true) at /home/elmarco/src/qemu/exec.c:2439
-      #5  0x000055555560baa2 in cpu_physical_memory_rw (addr=3759147008, buf=0x7fffffffc1b0 "", len=4, is_write=1) at /home/elmarco/src/qemu/exec.c:2534
-      #6  0x000055555564c005 in cpu_physical_memory_write (addr=3759147008, buf=0x7fffffffc1b0, len=4) at /home/elmarco/src/qemu/include/exec/cpu-common.h:80
-      #7  0x000055555564cd9c in qtest_process_command (chr=0x55555642b890, words=0x5555578de4b0) at /home/elmarco/src/qemu/qtest.c:378
-      #8  0x000055555564db77 in qtest_process_inbuf (chr=0x55555642b890, inbuf=0x55555641b340) at /home/elmarco/src/qemu/qtest.c:569
-      #9  0x000055555564dc07 in qtest_read (opaque=0x55555642b890, buf=0x7fffffffc2e0 "writel 0xe0100800 0x0\n", size=22) at /home/elmarco/src/qemu/qtest.c:581
-      #10 0x000055555574ce3e in qemu_chr_be_write (s=0x55555642b890, buf=0x7fffffffc2e0 "writel 0xe0100800 0x0\n", len=22) at qemu-char.c:306
-      #11 0x0000555555751263 in tcp_chr_read (chan=0x55555642bcf0, cond=G_IO_IN, opaque=0x55555642b890) at qemu-char.c:2876
-      #12 0x00007ffff64c9a8a in g_main_context_dispatch (context=0x55555641c400) at gmain.c:3122
-    
-    (without this patch, this can be reproduced with the ivshmem qtest)
-    
-    Implement an empty mmio write to avoid the crash.