diff --git a/SOURCES/libvirt-qemu-Report-all-supported-machine-types-in-capabilities.patch b/SOURCES/libvirt-qemu-Report-all-supported-machine-types-in-capabilities.patch
new file mode 100644
index 0000000..398fcea
--- /dev/null
+++ b/SOURCES/libvirt-qemu-Report-all-supported-machine-types-in-capabilities.patch
@@ -0,0 +1,101 @@
+From 778d5a7d8ee0f9d25e70fecf867934e9d54f6526 Mon Sep 17 00:00:00 2001
+Message-Id: <778d5a7d8ee0f9d25e70fecf867934e9d54f6526@dist-git>
+From: Jiri Denemark <jdenemar@redhat.com>
+Date: Fri, 12 Jun 2015 14:36:51 +0200
+Subject: [PATCH] qemu: Report all supported machine types in capabilities
+
+Some machine types are only reported as canonical names for other
+machine types, which make it a bit harder to find what machine types are
+supported by a specific QEMU binary. Ideally, one would just use
+/capabilities/guest/arch[@name='...']/machine/text() XPath to get a list
+of all supported machine types, but it doesn't work right now.
+
+For example, we report
+
+    <machine canonical='pc-i440fx-2.3' maxCpus='255'>pc</machine>
+
+in guest capabilities, but the corresponding
+
+    <machine maxCpus='255'>pc-i440fx-2.3</machine>
+
+is missing.
+
+This is a result of QMP probing. With "-machine ?" parsing QEMU sends
+us two lines:
+
+pc                   Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
+pc-i440fx-2.3        Standard PC (i440FX + PIIX, 1996) (default)
+
+while query-machines QMP command reports both in the same entry:
+
+{"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"}
+
+Let's make sure we always report separate <machine/> for both the
+canonical name and its alias and using the canonical name as the default
+machine type (i.e., inserting it before its alias) in case is-default is
+true.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1229666
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+(cherry picked from commit beca509e437b51b68ff42494cc67919d306876ea)
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1263317
+
+Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
+---
+ src/qemu/qemu_capabilities.c | 38 ++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 38 insertions(+)
+
+diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
+index f827d3f..f16c1f5 100644
+--- a/src/qemu/qemu_capabilities.c
++++ b/src/qemu/qemu_capabilities.c
+@@ -2163,6 +2163,44 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
+         mach->maxCpus = qemuCaps->machineMaxCpus[i];
+     }
+ 
++    /* Make sure all canonical machine types also have their own entry so that
++     * /capabilities/guest/arch[@name='...']/machine/text() XPath selects all
++     * supported machine types.
++     */
++    i = 0;
++    while (i < *nmachines) {
++        size_t j;
++        bool found = false;
++        virCapsGuestMachinePtr machine = (*machines)[i];
++
++        if (!machine->canonical) {
++            i++;
++            continue;
++        }
++
++        for (j = 0; j < *nmachines; j++) {
++            if (STREQ(machine->canonical, (*machines)[j]->name)) {
++                found = true;
++                break;
++            }
++        }
++
++        if (!found) {
++            virCapsGuestMachinePtr mach;
++            if (VIR_ALLOC(mach) < 0)
++                goto error;
++            if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < 0) {
++                VIR_FREE(mach);
++                goto error;
++            }
++            if (VIR_STRDUP(mach->name, machine->canonical) < 0)
++                goto error;
++            mach->maxCpus = machine->maxCpus;
++            i++;
++        }
++        i++;
++    }
++
+     return 0;
+ 
+  error:
+-- 
+2.5.3
+
diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec
index f70cff3..a92962e 100644
--- a/SPECS/libvirt.spec
+++ b/SPECS/libvirt.spec
@@ -367,7 +367,7 @@
 Summary: Library providing a simple virtualization API
 Name: libvirt
 Version: 1.2.8
-Release: 16%{?dist}.4%{?extra_release}
+Release: 16%{?dist}.5%{?extra_release}
 License: LGPLv2+
 Group: Development/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@@ -732,6 +732,7 @@ Patch351: libvirt-qemu-blockjob-Synchronously-update-backing-chain-in-XML-on-ABO
 Patch352: libvirt-qemu-fix-cannot-set-graphic-passwd-via-qemuDomainSaveImageDefineXML.patch
 Patch353: libvirt-qemu-Use-correct-flags-for-ABI-stability-check-in-SaveImageUpdateDef.patch
 Patch354: libvirt-Really-fix-XML-formatting-flags-in-SaveImageUpdateDef.patch
+Patch355: libvirt-qemu-Report-all-supported-machine-types-in-capabilities.patch
 
 
 %if %{with_libvirtd}
@@ -2600,6 +2601,9 @@ exit 0
 %doc examples/systemtap
 
 %changelog
+* Thu Sep 24 2015 Jiri Denemark <jdenemar@redhat.com> - 1.2.8-16.el7_1.5
+- qemu: Report all supported machine types in capabilities (rhbz#1263317)
+
 * Sun Aug 30 2015 Jiri Denemark <jdenemar@redhat.com> - 1.2.8-16.el7_1.4
 - qemu: fix cannot set graphic passwd via qemuDomainSaveImageDefineXML (rhbz#1255859)
 - qemu: Use correct flags for ABI stability check in SaveImageUpdateDef (rhbz#1255859)