diff --git a/SOURCES/libvirt-process-Log-when-limiting-the-amount-of-locked-memory.patch b/SOURCES/libvirt-process-Log-when-limiting-the-amount-of-locked-memory.patch
new file mode 100644
index 0000000..a3813d3
--- /dev/null
+++ b/SOURCES/libvirt-process-Log-when-limiting-the-amount-of-locked-memory.patch
@@ -0,0 +1,36 @@
+From ea2c6dc03a003bdfe3004fe91eb76ea1f958c898 Mon Sep 17 00:00:00 2001
+Message-Id: <ea2c6dc03a003bdfe3004fe91eb76ea1f958c898@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Fri, 20 Nov 2015 13:29:11 +0100
+Subject: [PATCH] process: Log when limiting the amount of locked memory
+
+This can be useful for debugging.
+
+(cherry picked from commit a6a5ac965056d3949e8fa2b6cb70dc554196d56f)
+
+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1283924
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/util/virprocess.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/util/virprocess.c b/src/util/virprocess.c
+index 8fa7a9b..c86b7e9 100644
+--- a/src/util/virprocess.c
++++ b/src/util/virprocess.c
+@@ -761,6 +761,10 @@ virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes)
+             return -1;
+         }
+     }
++
++    VIR_DEBUG("Locked memory for process %lld limited to %llu bytes",
++              (long long int) pid, bytes);
++
+     return 0;
+ }
+ #else /* ! (HAVE_SETRLIMIT && defined(RLIMIT_MEMLOCK)) */
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Add-ppc64-specific-math-to-qemuDomainGetMlockLimitBytes.patch b/SOURCES/libvirt-qemu-Add-ppc64-specific-math-to-qemuDomainGetMlockLimitBytes.patch
new file mode 100644
index 0000000..ff0c0c7
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Add-ppc64-specific-math-to-qemuDomainGetMlockLimitBytes.patch
@@ -0,0 +1,124 @@
+From c1bbe50778b3a114bccccb1d94fa9beefcc52ae5 Mon Sep 17 00:00:00 2001
+Message-Id: <c1bbe50778b3a114bccccb1d94fa9beefcc52ae5@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Fri, 20 Nov 2015 13:29:14 +0100
+Subject: [PATCH] qemu: Add ppc64-specific math to
+ qemuDomainGetMlockLimitBytes()
+
+The amount of memory a ppc64 domain might need to lock is different
+than that of a equally-sized x86 domain, so we need to check the
+domain's architecture and act accordingly.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1273480
+
+(cherry picked from commit d269ef165c178ad62b48e5179fc4f3b4fa5e590b)
+
+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1283924
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 79 insertions(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index be3dcf6..4615e3e 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3430,7 +3430,7 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
+  * @def: domain definition
+  *
+  * Returns the size of the memory in bytes that needs to be set as
+- * RLIMIT_MEMLOCK for purpose of VFIO device passthrough.
++ * RLIMIT_MEMLOCK for the QEMU process.
+  * If a mem.hard_limit is set, then that value is preferred; otherwise, the
+  * value returned may depend upon the architecture or devices present.
+  */
+@@ -3445,6 +3445,84 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
+         goto done;
+     }
+ 
++    if (ARCH_IS_PPC64(def->os.arch)) {
++        unsigned long long maxMemory;
++        unsigned long long memory;
++        unsigned long long baseLimit;
++        unsigned long long passthroughLimit;
++        size_t nPCIHostBridges;
++        size_t i;
++        bool usesVFIO = false;
++
++        /* TODO: Detect at runtime once we start using more than just
++         *       the default PCI Host Bridge */
++        nPCIHostBridges = 1;
++
++        for (i = 0; i < def->nhostdevs; i++) {
++            virDomainHostdevDefPtr dev = def->hostdevs[i];
++
++            if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
++                dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
++                dev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
++                usesVFIO = true;
++                break;
++            }
++        }
++
++        memory = virDomainDefGetMemoryActual(def);
++
++        if (def->mem.max_memory)
++            maxMemory = def->mem.max_memory;
++        else
++            maxMemory = memory;
++
++        /* baseLimit := maxMemory / 128                                  (a)
++         *              + 4 MiB * #PHBs + 8 MiB                          (b)
++         *
++         * (a) is the hash table
++         *
++         * (b) is accounting for the 32-bit DMA window - it could be either the
++         * KVM accelerated TCE tables for emulated devices, or the VFIO
++         * userspace view. The 4 MiB per-PHB (including the default one) covers
++         * a 2GiB DMA window: default is 1GiB, but it's possible it'll be
++         * increased to help performance. The 8 MiB extra should be plenty for
++         * the TCE table index for any reasonable number of PHBs and several
++         * spapr-vlan or spapr-vscsi devices (512kB + a tiny bit each) */
++        baseLimit = maxMemory / 128 +
++                    4096 * nPCIHostBridges +
++                    8192;
++
++        /* passthroughLimit := max( 2 GiB * #PHBs,                       (c)
++         *                          memory                               (d)
++         *                          + memory * 1/512 * #PHBs + 8 MiB )   (e)
++         *
++         * (c) is the pre-DDW VFIO DMA window accounting. We're allowing 2 GiB
++         * rather than 1 GiB
++         *
++         * (d) is the with-DDW (and memory pre-registration and related
++         * features) DMA window accounting - assuming that we only account RAM
++         * once, even if mapped to multiple PHBs
++         *
++         * (e) is the with-DDW userspace view and overhead for the 64-bit DMA
++         * window. This is based a bit on expected guest behaviour, but there
++         * really isn't a way to completely avoid that. We assume the guest
++         * requests a 64-bit DMA window (per PHB) just big enough to map all
++         * its RAM. 4 kiB page size gives the 1/512; it will be less with 64
++         * kiB pages, less still if the guest is mapped with hugepages (unlike
++         * the default 32-bit DMA window, DDW windows can use large IOMMU
++         * pages). 8 MiB is for second and further level overheads, like (b) */
++        passthroughLimit = MAX(2 * 1024 * 1024 * nPCIHostBridges,
++                               memory +
++                               memory / 512 * nPCIHostBridges + 8192);
++
++        if (usesVFIO)
++            memKB = baseLimit + passthroughLimit;
++        else
++            memKB = baseLimit;
++
++        goto done;
++    }
++
+     /* For device passthrough using VFIO the guest memory and MMIO memory
+      * regions need to be locked persistent in order to allow DMA.
+      *
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Always-set-locked-memory-limit-for-ppc64-domains.patch b/SOURCES/libvirt-qemu-Always-set-locked-memory-limit-for-ppc64-domains.patch
new file mode 100644
index 0000000..1146b8a
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Always-set-locked-memory-limit-for-ppc64-domains.patch
@@ -0,0 +1,51 @@
+From 3f49b7d6c486486baabcfa956bea6aa32f133a91 Mon Sep 17 00:00:00 2001
+Message-Id: <3f49b7d6c486486baabcfa956bea6aa32f133a91@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Fri, 20 Nov 2015 13:29:15 +0100
+Subject: [PATCH] qemu: Always set locked memory limit for ppc64 domains
+
+Unlike other architectures, ppc64 domains need to lock memory
+even when VFIO is not used.
+
+Change qemuDomainRequiresMlock() to reflect this fact.
+
+(cherry picked from commit 16562bbc587add5a03a01c8eb8607c9e05819607)
+
+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1283924
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 4615e3e..d0df935 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3551,8 +3551,9 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
+ /**
+  * @def: domain definition
+  *
+- * Returns ture if the locked memory limit needs to be set or updated due to
+- * configuration or passthrough devices.
++ * Returns true if the locked memory limit needs to be set or updated because
++ * of domain configuration, VFIO passthrough devices or architecture-specific
++ * requirements.
+  * */
+ bool
+ qemuDomainRequiresMlock(virDomainDefPtr def)
+@@ -3562,6 +3563,10 @@ qemuDomainRequiresMlock(virDomainDefPtr def)
+     if (def->mem.locked)
+         return true;
+ 
++    /* ppc64 domains need to lock some memory even when VFIO is not used */
++    if (ARCH_IS_PPC64(def->os.arch))
++        return true;
++
+     for (i = 0; i < def->nhostdevs; i++) {
+         virDomainHostdevDefPtr dev = def->hostdevs[i];
+ 
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Emit-correct-audit-message-for-memory-hot-plug.patch b/SOURCES/libvirt-qemu-Emit-correct-audit-message-for-memory-hot-plug.patch
new file mode 100644
index 0000000..d67587b
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Emit-correct-audit-message-for-memory-hot-plug.patch
@@ -0,0 +1,98 @@
+From 5d51d05823e8cb75b452f86c854d0d404d21503e Mon Sep 17 00:00:00 2001
+Message-Id: <5d51d05823e8cb75b452f86c854d0d404d21503e@dist-git>
+From: Luyao Huang <lhuang@redhat.com>
+Date: Thu, 12 Nov 2015 08:40:41 +0100
+Subject: [PATCH] qemu: Emit correct audit message for memory hot plug
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280420
+https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3
+
+Prior to this patch, after successfully hot plugging memory
+the audit log indicated that the update failed, e.g.:
+
+type=VIRT_RESOURCE ... old-mem=1024000 new-mem=1548288 \
+exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=pts/2 res=failed
+
+This patch will adjust where virDomainAuditMemory is called to
+ensure the proper 'ret' value is used based on success or failure.
+
+Additionally, the audit message should include the size of the
+memory we were attempting to change to rather than the current
+actual size. On failure to add, the message showed the same value
+for old-mem and new-mem.
+
+In order to do this, introduce a 'newmem' local which will compute
+the new size based on the oldmem size plus the size of memory we
+are about to add. NB: This would be the same as calling the
+virDomainDefGetMemoryActual again on success, but avoids the
+overhead of recalculating. Plus cur_balloon is already adjusted
+by the same value, so this follows that.
+
+Signed-off-by: Luyao Huang <lhuang@redhat.com>
+(cherry picked from commit cb1fbda4a1b23581ed9e305a48b0376633d5ff4a)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index aa1fb31..bd96abf 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -1774,6 +1774,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+     qemuDomainObjPrivatePtr priv = vm->privateData;
+     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+     unsigned long long oldmem = virDomainDefGetMemoryActual(vm->def);
++    unsigned long long newmem = oldmem + mem->size;
+     char *devstr = NULL;
+     char *objalias = NULL;
+     const char *backendType;
+@@ -1829,7 +1830,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+         /* we shouldn't touch mem now, as the def might be freed */
+         mem = NULL;
+-        goto cleanup;
++        goto audit;
+     }
+ 
+     event = virDomainEventDeviceAddedNewFromObj(vm, objalias);
+@@ -1840,9 +1841,6 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+     if (fix_balloon)
+         vm->def->mem.cur_balloon += mem->size;
+ 
+-    virDomainAuditMemory(vm, oldmem, virDomainDefGetMemoryActual(vm->def),
+-                         "update", ret == 0);
+-
+     /* mem is consumed by vm->def */
+     mem = NULL;
+ 
+@@ -1852,6 +1850,8 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+ 
+     ret = 0;
+ 
++ audit:
++    virDomainAuditMemory(vm, oldmem, newmem, "update", ret == 0);
+  cleanup:
+     virObjectUnref(cfg);
+     VIR_FREE(devstr);
+@@ -1862,7 +1862,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+  removedef:
+     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+         mem = NULL;
+-        goto cleanup;
++        goto audit;
+     }
+ 
+     if ((id = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
+@@ -1870,7 +1870,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+     else
+         mem = NULL;
+ 
+-    goto cleanup;
++    goto audit;
+ }
+ 
+ 
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Emit-correct-audit-message-for-memory-hot-unplug.patch b/SOURCES/libvirt-qemu-Emit-correct-audit-message-for-memory-hot-unplug.patch
new file mode 100644
index 0000000..8eea993
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Emit-correct-audit-message-for-memory-hot-unplug.patch
@@ -0,0 +1,86 @@
+From 95b3838c5ea2c34dbb400979f69eb50114feb72f Mon Sep 17 00:00:00 2001
+Message-Id: <95b3838c5ea2c34dbb400979f69eb50114feb72f@dist-git>
+From: Luyao Huang <lhuang@redhat.com>
+Date: Thu, 12 Nov 2015 08:40:40 +0100
+Subject: [PATCH] qemu: Emit correct audit message for memory hot unplug
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280420
+https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3
+
+If the qemu monitor fails to remove the memory from the guest for
+any reason, the auditlog message will incorrectly use the current
+actual memory (via virDomainDefGetMemoryActual) instead of the
+value we were attempting to reduce to. The result is the 'new-mem'
+and 'old-mem' values for the auditlog message would be identical.
+
+This patch creates a local 'newmem' which accounts for the current
+memory size minus the memory which is being removed. NB, for the
+success case this results in the same value that would be returned
+by virDomainDefGetMemoryActual without the need to do the math. This
+follows the existing code which would subtract the size for cur_balloon.
+
+Signed-off-by: Luyao Huang <lhuang@redhat.com>
+(cherry picked from commit 8f8031df1998725ac34a9a3138705c4f7cdf0488)
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c | 23 +++++++++++------------
+ 1 file changed, 11 insertions(+), 12 deletions(-)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index f702c9f..aa1fb31 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -2933,11 +2933,11 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
+ {
+     qemuDomainObjPrivatePtr priv = vm->privateData;
+     unsigned long long oldmem = virDomainDefGetMemoryActual(vm->def);
++    unsigned long long newmem = oldmem - mem->size;
+     virObjectEventPtr event;
+     char *backendAlias = NULL;
+     int rc;
+     int idx;
+-    int ret = -1;
+ 
+     VIR_DEBUG("Removing memory device %s from domain %p %s",
+               mem->info.alias, vm, vm->def->name);
+@@ -2946,12 +2946,18 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
+         qemuDomainEventQueue(driver, event);
+ 
+     if (virAsprintf(&backendAlias, "mem%s", mem->info.alias) < 0)
+-        goto cleanup;
++        return -1;
+ 
+     qemuDomainObjEnterMonitor(driver, vm);
+     rc = qemuMonitorDelObject(priv->mon, backendAlias);
+-    if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+-        goto cleanup;
++    if (qemuDomainObjExitMonitor(driver, vm) < 0)
++        rc = -1;
++
++    VIR_FREE(backendAlias);
++
++    virDomainAuditMemory(vm, oldmem, newmem, "update", rc == 0);
++    if (rc < 0)
++        return -1;
+ 
+     vm->def->mem.cur_balloon -= mem->size;
+ 
+@@ -2959,14 +2965,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
+         virDomainMemoryRemove(vm->def, idx);
+ 
+     virDomainMemoryDefFree(mem);
+-    ret = 0;
+-
+- cleanup:
+-    virDomainAuditMemory(vm, oldmem, virDomainDefGetMemoryActual(vm->def),
+-                         "update", ret == 0);
+-
+-    VIR_FREE(backendAlias);
+-    return ret;
++    return 0;
+ }
+ 
+ 
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Explain-mlock-limit-size-more-in-detail.patch b/SOURCES/libvirt-qemu-Explain-mlock-limit-size-more-in-detail.patch
new file mode 100644
index 0000000..750580a
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Explain-mlock-limit-size-more-in-detail.patch
@@ -0,0 +1,56 @@
+From 02482db69537daa5a1235db00ece500fd7e1844d Mon Sep 17 00:00:00 2001
+Message-Id: <02482db69537daa5a1235db00ece500fd7e1844d@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 12 Nov 2015 08:40:45 +0100
+Subject: [PATCH] qemu: Explain mlock limit size more in detail
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280420
+
+Based on Alex's explanation [1] in the recent discussion let's update
+the comment explaining the memory lock limit calculation.
+
+[1]
+http://www.redhat.com/archives/libvir-list/2015-November/msg00329.html
+
+(cherry picked from commit 63ed05d2410bfb9179b26bc3422ea5f9b546d7b3)
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 21 ++++++++++++++++++---
+ 1 file changed, 18 insertions(+), 3 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index fd4449d..be3dcf6 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3445,9 +3445,24 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
+         goto done;
+     }
+ 
+-    /* VFIO requires all of the guest's memory to be locked resident, plus some
+-     * amount for IO space. Alex Williamson suggested adding 1GiB for IO space
+-     * just to be safe (some finer tuning might be nice, though). */
++    /* For device passthrough using VFIO the guest memory and MMIO memory
++     * regions need to be locked persistent in order to allow DMA.
++     *
++     * Currently the below limit is based on assumptions about the x86 platform.
++     *
++     * The chosen value of 1GiB below originates from x86 systems where it was
++     * used as space reserved for the MMIO region for the whole system.
++     *
++     * On x86_64 systems the MMIO regions of the IOMMU mapped devices don't
++     * count towards the locked memory limit since the memory is owned by the
++     * device. Emulated devices though do count, but the regions are usually
++     * small. Although it's not guaranteed that the limit will be enough for all
++     * configurations it didn't pose a problem for now.
++     *
++     * http://www.redhat.com/archives/libvir-list/2015-November/msg00329.html
++     *
++     * Note that this may not be valid for all platforms.
++     */
+     memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
+ 
+  done:
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Extract-logic-to-determine-the-mlock-limit-size-for-VFIO.patch b/SOURCES/libvirt-qemu-Extract-logic-to-determine-the-mlock-limit-size-for-VFIO.patch
new file mode 100644
index 0000000..cd3daf3
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Extract-logic-to-determine-the-mlock-limit-size-for-VFIO.patch
@@ -0,0 +1,136 @@
+From ed413584e982b24442ab860874e307f50d7fdb10 Mon Sep 17 00:00:00 2001
+Message-Id: <ed413584e982b24442ab860874e307f50d7fdb10@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 12 Nov 2015 08:40:42 +0100
+Subject: [PATCH] qemu: Extract logic to determine the mlock limit size for
+ VFIO
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280420
+
+New function qemuDomainGetMlockLimitBytes will now handle the
+calculation so that it unifies the logic to one place and allows later
+reuse.
+
+(cherry picked from commit fbc58cfcaeffdd4a350cf6abd67da6006f01b148)
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 18 ++----------------
+ src/qemu/qemu_domain.c  | 27 +++++++++++++++++++++++++++
+ src/qemu/qemu_domain.h  |  2 ++
+ src/qemu/qemu_hotplug.c | 17 ++---------------
+ 4 files changed, 33 insertions(+), 31 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 9c80e0c..7f8a31b 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -11146,22 +11146,8 @@ qemuBuildCommandLine(virConnectPtr conn,
+             goto error;
+     }
+ 
+-    if (mlock) {
+-        unsigned long long memKB;
+-
+-        /* VFIO requires all of the guest's memory to be
+-         * locked resident, plus some amount for IO
+-         * space. Alex Williamson suggested adding 1GiB for IO
+-         * space just to be safe (some finer tuning might be
+-         * nice, though).
+-         */
+-        if (virMemoryLimitIsSet(def->mem.hard_limit))
+-            memKB = def->mem.hard_limit;
+-        else
+-            memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
+-
+-        virCommandSetMaxMemLock(cmd, memKB * 1024);
+-    }
++    if (mlock)
++        virCommandSetMaxMemLock(cmd, qemuDomainGetMlockLimitBytes(def));
+ 
+     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&
+         cfg->logTimestamp)
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 1528cfd..944817d 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3422,3 +3422,30 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
+ 
+     return 0;
+ }
++
++
++/**
++ * qemuDomainGetMlockLimitBytes:
++ *
++ * @def: domain definition
++ *
++ * Returns the size of the memory in bytes that needs to be set as
++ * RLIMIT_MEMLOCK for purpose of VFIO device passthrough.
++ * If a mem.hard_limit is set, then that value is preferred; otherwise, the
++ * value returned may depend upon the architecture or devices present.
++ */
++unsigned long long
++qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
++{
++    unsigned long long memKB;
++
++    /* VFIO requires all of the guest's memory to be locked resident, plus some
++     * amount for IO space. Alex Williamson suggested adding 1GiB for IO space
++     * just to be safe (some finer tuning might be nice, though). */
++    if (virMemoryLimitIsSet(def->mem.hard_limit))
++        memKB = def->mem.hard_limit;
++    else
++        memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
++
++    return memKB << 10;
++}
+diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
+index e283b58..54e7cd9 100644
+--- a/src/qemu/qemu_domain.h
++++ b/src/qemu/qemu_domain.h
+@@ -475,4 +475,6 @@ bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
+ int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
+                                       virDomainObjPtr vm);
+ 
++unsigned long long qemuDomainGetMlockLimitBytes(virDomainDefPtr def);
++
+ #endif /* __QEMU_DOMAIN_H__ */
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index bd96abf..d96f572 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -1254,7 +1254,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
+     bool teardowncgroup = false;
+     bool teardownlabel = false;
+     int backend;
+-    unsigned long long memKB;
+     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+     unsigned int flags = 0;
+ 
+@@ -1279,20 +1278,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
+             goto error;
+         }
+ 
+-        /* VFIO requires all of the guest's memory to be locked
+-         * resident (plus an additional 1GiB to cover IO space). During
+-         * hotplug, the guest's memory may already be locked, but it
+-         * doesn't hurt to "change" the limit to the same value.
+-         * NB: the domain's memory tuning parameters are stored as
+-         * Kibibytes, but virProcessSetMaxMemLock expects the value in
+-         * bytes.
+-         */
+-        if (virMemoryLimitIsSet(vm->def->mem.hard_limit))
+-            memKB = vm->def->mem.hard_limit;
+-        else
+-            memKB = virDomainDefGetMemoryActual(vm->def) + (1024 * 1024);
+-
+-        virProcessSetMaxMemLock(vm->pid, memKB * 1024);
++        /* setup memory locking limits, that are necessary for VFIO */
++        virProcessSetMaxMemLock(vm->pid, qemuDomainGetMlockLimitBytes(vm->def));
+         break;
+ 
+     default:
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch b/SOURCES/libvirt-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
new file mode 100644
index 0000000..5bb6bdb
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
@@ -0,0 +1,38 @@
+From 4d4ed9e83c4839f3cad7460bff63328e4e553e02 Mon Sep 17 00:00:00 2001
+Message-Id: <4d4ed9e83c4839f3cad7460bff63328e4e553e02@dist-git>
+From: Martin Kletzander <mkletzan@redhat.com>
+Date: Mon, 23 Nov 2015 12:46:36 +0100
+Subject: [PATCH] qemu: Support vhost-user-multiqueue with QEMU 2.3
+
+RHEL-only
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207692
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1284416
+
+Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index 12af0dc..943aa5f 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -3393,8 +3393,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
+         virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF);
+ 
+     /* vhost-user supports multi-queue from v2.4.0 onwards,
+-     * but there is no way to query for that capability */
+-    if (qemuCaps->version >= 2004000)
++     * but there is no way to query for that capability
++     *
++     * RHEL-only: The change was back-ported to earlier QEMU version,
++     * particularly 2.3, in BZ 1276100 */
++    if (qemuCaps->version >= 2003000)
+         virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE);
+ 
+     if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Use-qemuDomainRequiresMlock-in-qemuBuildCommandLine.patch b/SOURCES/libvirt-qemu-Use-qemuDomainRequiresMlock-in-qemuBuildCommandLine.patch
new file mode 100644
index 0000000..1969379
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Use-qemuDomainRequiresMlock-in-qemuBuildCommandLine.patch
@@ -0,0 +1,63 @@
+From 66f6a0bad6db35e654b0625d5a3fac939899c997 Mon Sep 17 00:00:00 2001
+Message-Id: <66f6a0bad6db35e654b0625d5a3fac939899c997@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Fri, 20 Nov 2015 13:29:12 +0100
+Subject: [PATCH] qemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine()
+
+This removes a duplication of the logic used to decide whether
+the memory locking limit should be set.
+
+(cherry picked from commit cf9bd256556cfa1343e4438e4807625c9e1af921)
+
+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1283924
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_command.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
+index 7f8a31b..ece6081 100644
+--- a/src/qemu/qemu_command.c
++++ b/src/qemu/qemu_command.c
+@@ -8974,7 +8974,6 @@ qemuBuildCommandLine(virConnectPtr conn,
+     int usbcontroller = 0;
+     int actualSerials = 0;
+     bool usblegacy = false;
+-    bool mlock = false;
+     int contOrder[] = {
+         /*
+          * List of controller types that we add commandline args for,
+@@ -9158,7 +9157,6 @@ qemuBuildCommandLine(virConnectPtr conn,
+         virCommandAddArgFormat(cmd, "mlock=%s",
+                                def->mem.locked ? "on" : "off");
+     }
+-    mlock = def->mem.locked;
+ 
+     virCommandAddArg(cmd, "-smp");
+     if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
+@@ -10850,9 +10848,6 @@ qemuBuildCommandLine(virConnectPtr conn,
+                                      "supported by this version of qemu"));
+                     goto error;
+                 }
+-                /* VFIO requires all of the guest's memory to be locked
+-                 * resident */
+-                mlock = true;
+             }
+ 
+             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
+@@ -11146,7 +11141,9 @@ qemuBuildCommandLine(virConnectPtr conn,
+             goto error;
+     }
+ 
+-    if (mlock)
++    /* In some situations, eg. VFIO passthrough, QEMU might need to lock a
++     * significant amount of memory, so we need to set the limit accordingly */
++    if (qemuDomainRequiresMlock(def))
+         virCommandSetMaxMemLock(cmd, qemuDomainGetMlockLimitBytes(def));
+ 
+     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-Use-qemuDomainRequiresMlock-when-attaching-PCI-hostdev.patch b/SOURCES/libvirt-qemu-Use-qemuDomainRequiresMlock-when-attaching-PCI-hostdev.patch
new file mode 100644
index 0000000..2504f3e
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Use-qemuDomainRequiresMlock-when-attaching-PCI-hostdev.patch
@@ -0,0 +1,68 @@
+From 27dbf10245342d3547a969b9b69e95fee96932e0 Mon Sep 17 00:00:00 2001
+Message-Id: <27dbf10245342d3547a969b9b69e95fee96932e0@dist-git>
+From: Andrea Bolognani <abologna@redhat.com>
+Date: Fri, 20 Nov 2015 13:29:13 +0100
+Subject: [PATCH] qemu: Use qemuDomainRequiresMlock() when attaching PCI
+ hostdev
+
+The function is used everywhere else to check whether the locked
+memory limit should be set / updated, and it should be used here
+as well.
+
+Moreover, qemuDomainGetMlockLimitBytes() expects the hostdev to
+have already been added to the domain definition, but we only do
+that at the end of qemuDomainAttachHostPCIDevice(). Work around
+the issue by adding the hostdev before adjusting the locked memory
+limit and removing it immediately afterwards.
+
+(cherry picked from commit 79b8c97e995d2e8bc04fb9a3972e1875fad01e6d)
+
+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1283924
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c | 23 ++++++++++++++++-------
+ 1 file changed, 16 insertions(+), 7 deletions(-)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index 785423a..003b614 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -1277,17 +1277,26 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
+                              "supported by this version of qemu"));
+             goto error;
+         }
++        break;
+ 
+-        /* setup memory locking limits, that are necessary for VFIO */
++    default:
++        break;
++    }
++
++    /* Temporarily add the hostdev to the domain definition. This is needed
++     * because qemuDomainRequiresMlock() and qemuDomainGetMlockLimitBytes()
++     * require the hostdev to be already part of the domain definition, but
++     * other functions like qemuAssignDeviceHostdevAlias() used below expect
++     * it *not* to be there. A better way to handle this would be nice */
++    vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
++    if (qemuDomainRequiresMlock(vm->def)) {
+         if (virProcessSetMaxMemLock(vm->pid,
+-                                    qemuDomainGetMlockLimitBytes(vm->def)) < 0)
++                                    qemuDomainGetMlockLimitBytes(vm->def)) < 0) {
++            vm->def->hostdevs[--(vm->def->nhostdevs)] = NULL;
+             goto error;
+-
+-        break;
+-
+-    default:
+-        break;
++        }
+     }
++    vm->def->hostdevs[--(vm->def->nhostdevs)] = NULL;
+ 
+     if (qemuSetupHostdevCGroup(vm, hostdev) < 0)
+         goto error;
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-domain-Restructurate-control-flow-in-qemuDomainGetMlockLimitBytes.patch b/SOURCES/libvirt-qemu-domain-Restructurate-control-flow-in-qemuDomainGetMlockLimitBytes.patch
new file mode 100644
index 0000000..a9cae92
--- /dev/null
+++ b/SOURCES/libvirt-qemu-domain-Restructurate-control-flow-in-qemuDomainGetMlockLimitBytes.patch
@@ -0,0 +1,49 @@
+From edd55b5cb27f6b1f5738a354f59624795a049d73 Mon Sep 17 00:00:00 2001
+Message-Id: <edd55b5cb27f6b1f5738a354f59624795a049d73@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 12 Nov 2015 08:40:44 +0100
+Subject: [PATCH] qemu: domain: Restructurate control flow in
+ qemuDomainGetMlockLimitBytes
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280420
+
+Break early when hard limit is set so that it's not intermixed by other
+logic for determining the limit.
+
+(cherry picked from commit e7b91c510e9831b2741469809465bb68a87c8362)
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 1f206fa..fd4449d 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3439,14 +3439,18 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
+ {
+     unsigned long long memKB;
+ 
++    /* prefer the hard limit */
++    if (virMemoryLimitIsSet(def->mem.hard_limit)) {
++        memKB = def->mem.hard_limit;
++        goto done;
++    }
++
+     /* VFIO requires all of the guest's memory to be locked resident, plus some
+      * amount for IO space. Alex Williamson suggested adding 1GiB for IO space
+      * just to be safe (some finer tuning might be nice, though). */
+-    if (virMemoryLimitIsSet(def->mem.hard_limit))
+-        memKB = def->mem.hard_limit;
+-    else
+-        memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
++    memKB = virDomainDefGetMemoryActual(def) + 1024 * 1024;
+ 
++ done:
+     return memKB << 10;
+ }
+ 
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-hotplug-Fix-mlock-limit-handling-on-memory-hotplug.patch b/SOURCES/libvirt-qemu-hotplug-Fix-mlock-limit-handling-on-memory-hotplug.patch
new file mode 100644
index 0000000..c384d2c
--- /dev/null
+++ b/SOURCES/libvirt-qemu-hotplug-Fix-mlock-limit-handling-on-memory-hotplug.patch
@@ -0,0 +1,159 @@
+From dfdc5b0fc1fdf8c6d122df9578912ed90bfbabb4 Mon Sep 17 00:00:00 2001
+Message-Id: <dfdc5b0fc1fdf8c6d122df9578912ed90bfbabb4@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 12 Nov 2015 08:40:43 +0100
+Subject: [PATCH] qemu: hotplug: Fix mlock limit handling on memory hotplug
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280420
+
+If mlock is required either due to use of VFIO hostdevs or due to the
+fact that it's enabled it needs to be tweaked prior to adding new memory
+or after removing a module. Add a helper to determine when it's
+necessary and reuse it both on hotplug and hotunplug.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1273491
+(cherry picked from commit ec90b34acf7cf7d06a63908c39e21b63382a1967)
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_domain.c  | 27 +++++++++++++++++++++++++++
+ src/qemu/qemu_domain.h  |  1 +
+ src/qemu/qemu_hotplug.c | 41 ++++++++++++++++++++++++++++++++++-------
+ 3 files changed, 62 insertions(+), 7 deletions(-)
+
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index 944817d..1f206fa 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3449,3 +3449,30 @@ qemuDomainGetMlockLimitBytes(virDomainDefPtr def)
+ 
+     return memKB << 10;
+ }
++
++
++/**
++ * @def: domain definition
++ *
++ * Returns ture if the locked memory limit needs to be set or updated due to
++ * configuration or passthrough devices.
++ * */
++bool
++qemuDomainRequiresMlock(virDomainDefPtr def)
++{
++    size_t i;
++
++    if (def->mem.locked)
++        return true;
++
++    for (i = 0; i < def->nhostdevs; i++) {
++        virDomainHostdevDefPtr dev = def->hostdevs[i];
++
++        if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
++            dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
++            dev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
++            return true;
++    }
++
++    return false;
++}
+diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
+index 54e7cd9..32f713b 100644
+--- a/src/qemu/qemu_domain.h
++++ b/src/qemu/qemu_domain.h
+@@ -476,5 +476,6 @@ int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
+                                       virDomainObjPtr vm);
+ 
+ unsigned long long qemuDomainGetMlockLimitBytes(virDomainDefPtr def);
++bool qemuDomainRequiresMlock(virDomainDefPtr def);
+ 
+ #endif /* __QEMU_DOMAIN_H__ */
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index d96f572..70aece4 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -1768,6 +1768,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+     virJSONValuePtr props = NULL;
+     virObjectEventPtr event;
+     bool fix_balloon = false;
++    bool mlock = false;
+     int id;
+     int ret = -1;
+ 
+@@ -1802,16 +1803,26 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+         goto cleanup;
+     }
+ 
++    mlock = qemuDomainRequiresMlock(vm->def);
++
++    if (mlock &&
++        virProcessSetMaxMemLock(vm->pid,
++                                qemuDomainGetMlockLimitBytes(vm->def)) < 0) {
++        mlock = false;
++        virJSONValueFree(props);
++        goto removedef;
++    }
++
+     qemuDomainObjEnterMonitor(driver, vm);
+     if (qemuMonitorAddObject(priv->mon, backendType, objalias, props) < 0)
+-        goto removedef;
++        goto exit_monitor;
+ 
+     if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+         virErrorPtr err = virSaveLastError();
+         ignore_value(qemuMonitorDelObject(priv->mon, objalias));
+         virSetError(err);
+         virFreeError(err);
+-        goto removedef;
++        goto exit_monitor;
+     }
+ 
+     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+@@ -1846,17 +1857,27 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
+     virDomainMemoryDefFree(mem);
+     return ret;
+ 
++ exit_monitor:
++    if (qemuDomainObjExitMonitor(driver, vm) < 0) {
++        mem = NULL;
++        goto audit;
++    }
++
+  removedef:
+-    if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+-        mem = NULL;
+-        goto audit;
+-    }
+-
+     if ((id = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
+         mem = virDomainMemoryRemove(vm->def, id);
+     else
+         mem = NULL;
+ 
++    /* reset the mlock limit */
++    if (mlock) {
++        virErrorPtr err = virSaveLastError();
++        ignore_value(virProcessSetMaxMemLock(vm->pid,
++                                             qemuDomainGetMlockLimitBytes(vm->def)));
++        virSetError(err);
++        virFreeError(err);
++    }
++
+     goto audit;
+ }
+ 
+@@ -2952,6 +2973,12 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
+         virDomainMemoryRemove(vm->def, idx);
+ 
+     virDomainMemoryDefFree(mem);
++
++    /* decrease the mlock limit after memory unplug if necessary */
++    if (qemuDomainRequiresMlock(vm->def))
++        ignore_value(virProcessSetMaxMemLock(vm->pid,
++                                             qemuDomainGetMlockLimitBytes(vm->def)));
++
+     return 0;
+ }
+ 
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-hotplug-Reject-VFIO-hotplug-if-setting-RLIMIT_MEMLOCK-fails.patch b/SOURCES/libvirt-qemu-hotplug-Reject-VFIO-hotplug-if-setting-RLIMIT_MEMLOCK-fails.patch
new file mode 100644
index 0000000..3e53dc5
--- /dev/null
+++ b/SOURCES/libvirt-qemu-hotplug-Reject-VFIO-hotplug-if-setting-RLIMIT_MEMLOCK-fails.patch
@@ -0,0 +1,43 @@
+From 81421950fe905de097d4ac49f932a902937fb01b Mon Sep 17 00:00:00 2001
+Message-Id: <81421950fe905de097d4ac49f932a902937fb01b@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Fri, 20 Nov 2015 13:29:10 +0100
+Subject: [PATCH] qemu: hotplug: Reject VFIO hotplug if setting RLIMIT_MEMLOCK
+ fails
+
+Check the return value of virCommandSetMaxMemLock when hotplugging VFIO
+PCI hostdevs and reject the hotplug if the memory limit can't be set.
+
+(cherry picked from commit baf55e1fa41a6aa77a5373891d70947ef24acadd)
+
+The code touched by this commit is removed in a later commit,
+but including this in the backport gets rid of conflicts when
+doing so.
+
+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1283924
+
+Signed-off-by: Andrea Bolognani <abologna@redhat.com>
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_hotplug.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
+index 70aece4..785423a 100644
+--- a/src/qemu/qemu_hotplug.c
++++ b/src/qemu/qemu_hotplug.c
+@@ -1279,7 +1279,10 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
+         }
+ 
+         /* setup memory locking limits, that are necessary for VFIO */
+-        virProcessSetMaxMemLock(vm->pid, qemuDomainGetMlockLimitBytes(vm->def));
++        if (virProcessSetMaxMemLock(vm->pid,
++                                    qemuDomainGetMlockLimitBytes(vm->def)) < 0)
++            goto error;
++
+         break;
+ 
+     default:
+-- 
+2.6.3
+
diff --git a/SOURCES/libvirt-qemu-migration-Properly-parse-memory-hotplug-migration-flag.patch b/SOURCES/libvirt-qemu-migration-Properly-parse-memory-hotplug-migration-flag.patch
new file mode 100644
index 0000000..db8570f
--- /dev/null
+++ b/SOURCES/libvirt-qemu-migration-Properly-parse-memory-hotplug-migration-flag.patch
@@ -0,0 +1,41 @@
+From cc29e312925235aeab6aba6afec5ff357e39155a Mon Sep 17 00:00:00 2001
+Message-Id: <cc29e312925235aeab6aba6afec5ff357e39155a@dist-git>
+From: Peter Krempa <pkrempa@redhat.com>
+Date: Thu, 12 Nov 2015 07:45:26 +0100
+Subject: [PATCH] qemu: migration: Properly parse memory hotplug migration flag
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1280419 [7.2.z]
+
+Since the flag was not enabled when 'eating' the migration cookie,
+libvirt reported a bogus error when memory hotplug was enabled:
+
+ unsupported migration cookie feature memory-hotplug
+
+The error was ignored though due to a bug in the code so it slipped
+through testing.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1278404
+(cherry picked from commit f59808b724f99d43d042600455f55428a88a1ad9)
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_migration.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
+index d3e024e..8074156 100644
+--- a/src/qemu/qemu_migration.c
++++ b/src/qemu/qemu_migration.c
+@@ -3350,7 +3350,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
+ 
+     if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+                                        QEMU_MIGRATION_COOKIE_LOCKSTATE |
+-                                       QEMU_MIGRATION_COOKIE_NBD)))
++                                       QEMU_MIGRATION_COOKIE_NBD |
++                                       QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG)))
+         goto cleanup;
+ 
+     if (STREQ_NULLABLE(protocol, "rdma") &&
+-- 
+2.6.3
+
diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec
index e3f525d..f165f14 100644
--- a/SPECS/libvirt.spec
+++ b/SPECS/libvirt.spec
@@ -382,7 +382,7 @@
 Summary: Library providing a simple virtualization API
 Name: libvirt
 Version: 1.2.17
-Release: 13%{?dist}%{?extra_release}
+Release: 13%{?dist}.2%{?extra_release}
 License: LGPLv2+
 Group: Development/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@@ -633,6 +633,20 @@ Patch237: libvirt-qemu-Copy-completed-migration-stats-only-on-success.patch
 Patch238: libvirt-qemu-Introduce-flags-in-qemuMigrationCompleted.patch
 Patch239: libvirt-qemu-Make-updating-stats-in-qemuMigrationCheckJobStatus-optional.patch
 Patch240: libvirt-qemu-Wait-until-destination-QEMU-consumes-all-migration-data.patch
+Patch241: libvirt-qemu-migration-Properly-parse-memory-hotplug-migration-flag.patch
+Patch242: libvirt-qemu-Emit-correct-audit-message-for-memory-hot-unplug.patch
+Patch243: libvirt-qemu-Emit-correct-audit-message-for-memory-hot-plug.patch
+Patch244: libvirt-qemu-Extract-logic-to-determine-the-mlock-limit-size-for-VFIO.patch
+Patch245: libvirt-qemu-hotplug-Fix-mlock-limit-handling-on-memory-hotplug.patch
+Patch246: libvirt-qemu-domain-Restructurate-control-flow-in-qemuDomainGetMlockLimitBytes.patch
+Patch247: libvirt-qemu-Explain-mlock-limit-size-more-in-detail.patch
+Patch248: libvirt-qemu-hotplug-Reject-VFIO-hotplug-if-setting-RLIMIT_MEMLOCK-fails.patch
+Patch249: libvirt-process-Log-when-limiting-the-amount-of-locked-memory.patch
+Patch250: libvirt-qemu-Use-qemuDomainRequiresMlock-in-qemuBuildCommandLine.patch
+Patch251: libvirt-qemu-Use-qemuDomainRequiresMlock-when-attaching-PCI-hostdev.patch
+Patch252: libvirt-qemu-Add-ppc64-specific-math-to-qemuDomainGetMlockLimitBytes.patch
+Patch253: libvirt-qemu-Always-set-locked-memory-limit-for-ppc64-domains.patch
+Patch254: libvirt-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch
 
 
 %if %{with_libvirtd}
@@ -2584,6 +2598,24 @@ exit 0
 %doc examples/systemtap
 
 %changelog
+* Mon Nov 23 2015 Jiri Denemark <jdenemar@redhat.com> - 1.2.17-13.el7_2.2
+- qemu: Support vhost-user-multiqueue with QEMU 2.3 (rhbz#1284416)
+
+* Fri Nov 20 2015 Jiri Denemark <jdenemar@redhat.com> - 1.2.17-13.el7_2.1
+- qemu: migration: Properly parse memory hotplug migration flag (rhbz#1280419)
+- qemu: Emit correct audit message for memory hot unplug (rhbz#1280420)
+- qemu: Emit correct audit message for memory hot plug (rhbz#1280420)
+- qemu: Extract logic to determine the mlock limit size for VFIO (rhbz#1280420)
+- qemu: hotplug: Fix mlock limit handling on memory hotplug (rhbz#1280420)
+- qemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes (rhbz#1280420)
+- qemu: Explain mlock limit size more in detail (rhbz#1280420)
+- qemu: hotplug: Reject VFIO hotplug if setting RLIMIT_MEMLOCK fails (rhbz#1283924)
+- process: Log when limiting the amount of locked memory (rhbz#1283924)
+- qemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine() (rhbz#1283924)
+- qemu: Use qemuDomainRequiresMlock() when attaching PCI hostdev (rhbz#1283924)
+- qemu: Add ppc64-specific math to qemuDomainGetMlockLimitBytes() (rhbz#1283924)
+- qemu: Always set locked memory limit for ppc64 domains (rhbz#1283924)
+
 * Thu Oct  8 2015 Jiri Denemark <jdenemar@redhat.com> - 1.2.17-13
 - qemu: Add conditions for qemu-kvm use on ppc64 (rhbz#1267882)
 - qemu: Move simplification variable to begining of the function (rhbz#1266856)